Gazebo_simulation-Frontend/node_modules/react-bootstrap/cjs/Dropdown.js
2020-12-21 10:29:31 -05:00

109 lines
4.0 KiB
JavaScript

"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _classnames = _interopRequireDefault(require("classnames"));
var _react = _interopRequireWildcard(require("react"));
var _Dropdown = _interopRequireDefault(require("react-overlays/Dropdown"));
var _uncontrollable = require("uncontrollable");
var _useEventCallback = _interopRequireDefault(require("@restart/hooks/useEventCallback"));
var _DropdownItem = _interopRequireDefault(require("./DropdownItem"));
var _DropdownMenu = _interopRequireDefault(require("./DropdownMenu"));
var _DropdownToggle = _interopRequireDefault(require("./DropdownToggle"));
var _SelectableContext = _interopRequireDefault(require("./SelectableContext"));
var _ThemeProvider = require("./ThemeProvider");
var _createWithBsPrefix = _interopRequireDefault(require("./createWithBsPrefix"));
var defaultProps = {
navbar: false
};
var Dropdown = _react.default.forwardRef(function (uncontrolledProps, ref) {
var _useUncontrolled = (0, _uncontrollable.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 = (0, _objectWithoutPropertiesLoose2.default)(_useUncontrolled, ["bsPrefix", "drop", "show", "className", "alignRight", "onSelect", "onToggle", "focusFirstItemOnShow", "as", "navbar"]);
var onSelectCtx = (0, _react.useContext)(_SelectableContext.default);
var prefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, 'dropdown');
var handleToggle = (0, _useEventCallback.default)(function (nextShow, event, source) {
if (source === void 0) {
source = event.type;
}
if (event.currentTarget === document) source = 'rootClose';
onToggle(nextShow, event, {
source: source
});
});
var handleSelect = (0, _useEventCallback.default)(function (key, event) {
if (onSelectCtx) onSelectCtx(key, event);
if (onSelect) onSelect(key, event);
handleToggle(false, event, 'select');
});
return _react.default.createElement(_SelectableContext.default.Provider, {
value: handleSelect
}, _react.default.createElement(_Dropdown.default, {
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.default.createElement(Component, (0, _extends2.default)({}, props, dropdownProps, {
ref: ref,
className: (0, _classnames.default)(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.default;
Dropdown.Menu = _DropdownMenu.default;
Dropdown.Item = _DropdownItem.default;
Dropdown.Header = (0, _createWithBsPrefix.default)('dropdown-header', {
defaultProps: {
role: 'heading'
}
});
Dropdown.Divider = (0, _createWithBsPrefix.default)('dropdown-divider', {
defaultProps: {
role: 'separator'
}
});
var _default = Dropdown;
exports.default = _default;
module.exports = exports["default"];