Gazebo_simulation-Frontend/node_modules/react-bootstrap/esm/Dropdown.js

83 lines
3.2 KiB
JavaScript
Raw Normal View History

2020-12-21 11:29:31 -04:00
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import classNames from 'classnames';
import React, { useContext } from 'react';
import BaseDropdown from 'react-overlays/Dropdown';
import { useUncontrolled } from 'uncontrollable';
import useEventCallback from '@restart/hooks/useEventCallback';
import DropdownItem from './DropdownItem';
import DropdownMenu from './DropdownMenu';
import DropdownToggle from './DropdownToggle';
import SelectableContext from './SelectableContext';
import { useBootstrapPrefix } from './ThemeProvider';
import createWithBsPrefix from './createWithBsPrefix';
var defaultProps = {
navbar: false
};
var Dropdown = React.forwardRef(function (uncontrolledProps, ref) {
var _useUncontrolled = useUncontrolled(uncontrolledProps, {
show: 'onToggle'
}),
bsPrefix = _useUncontrolled.bsPrefix,
drop = _useUncontrolled.drop,
show = _useUncontrolled.show,
className = _useUncontrolled.className,
alignRight = _useUncontrolled.alignRight,
onSelect = _useUncontrolled.onSelect,
onToggle = _useUncontrolled.onToggle,
focusFirstItemOnShow = _useUncontrolled.focusFirstItemOnShow,
_useUncontrolled$as = _useUncontrolled.as,
Component = _useUncontrolled$as === void 0 ? 'div' : _useUncontrolled$as,
_4 = _useUncontrolled.navbar,
props = _objectWithoutPropertiesLoose(_useUncontrolled, ["bsPrefix", "drop", "show", "className", "alignRight", "onSelect", "onToggle", "focusFirstItemOnShow", "as", "navbar"]);
var onSelectCtx = useContext(SelectableContext);
var prefix = useBootstrapPrefix(bsPrefix, 'dropdown');
var handleToggle = useEventCallback(function (nextShow, event, source) {
if (source === void 0) {
source = event.type;
}
if (event.currentTarget === document) source = 'rootClose';
onToggle(nextShow, event, {
source: source
});
});
var handleSelect = useEventCallback(function (key, event) {
if (onSelectCtx) onSelectCtx(key, event);
if (onSelect) onSelect(key, event);
handleToggle(false, event, 'select');
});
return React.createElement(SelectableContext.Provider, {
value: handleSelect
}, React.createElement(BaseDropdown, {
drop: drop,
show: show,
alignEnd: alignRight,
onToggle: handleToggle,
focusFirstItemOnShow: focusFirstItemOnShow,
itemSelector: "." + prefix + "-item:not(.disabled):not(:disabled)"
}, function (_ref) {
var dropdownProps = _ref.props;
return React.createElement(Component, _extends({}, props, dropdownProps, {
ref: ref,
className: classNames(className, show && 'show', (!drop || drop === 'down') && prefix, drop === 'up' && 'dropup', drop === 'right' && 'dropright', drop === 'left' && 'dropleft')
}));
}));
});
Dropdown.displayName = 'Dropdown';
Dropdown.defaultProps = defaultProps;
Dropdown.Toggle = DropdownToggle;
Dropdown.Menu = DropdownMenu;
Dropdown.Item = DropdownItem;
Dropdown.Header = createWithBsPrefix('dropdown-header', {
defaultProps: {
role: 'heading'
}
});
Dropdown.Divider = createWithBsPrefix('dropdown-divider', {
defaultProps: {
role: 'separator'
}
});
export default Dropdown;