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