1 line
2.6 KiB
JSON
1 line
2.6 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 { useDropdownMenu } from 'react-overlays/DropdownMenu';\nimport useMergedRefs from '@restart/hooks/useMergedRefs';\nimport NavbarContext from './NavbarContext';\nimport { useBootstrapPrefix } from './ThemeProvider';\nimport useWrappedRefWithWarning from './useWrappedRefWithWarning';\nvar defaultProps = {\n alignRight: false,\n flip: true\n};\nvar DropdownMenu = React.forwardRef(function (_ref, ref) {\n var bsPrefix = _ref.bsPrefix,\n className = _ref.className,\n alignRight = _ref.alignRight,\n rootCloseEvent = _ref.rootCloseEvent,\n flip = _ref.flip,\n popperConfig = _ref.popperConfig,\n showProps = _ref.show,\n _ref$as = _ref.as,\n Component = _ref$as === void 0 ? 'div' : _ref$as,\n props = _objectWithoutPropertiesLoose(_ref, [\"bsPrefix\", \"className\", \"alignRight\", \"rootCloseEvent\", \"flip\", \"popperConfig\", \"show\", \"as\"]);\n\n var isNavbar = useContext(NavbarContext);\n var prefix = useBootstrapPrefix(bsPrefix, 'dropdown-menu');\n\n var _useDropdownMenu = useDropdownMenu({\n flip: flip,\n popperConfig: popperConfig,\n rootCloseEvent: rootCloseEvent,\n show: showProps,\n alignEnd: alignRight,\n usePopper: !isNavbar\n }),\n hasShown = _useDropdownMenu.hasShown,\n placement = _useDropdownMenu.placement,\n show = _useDropdownMenu.show,\n alignEnd = _useDropdownMenu.alignEnd,\n close = _useDropdownMenu.close,\n menuProps = _useDropdownMenu.props;\n\n menuProps.ref = useMergedRefs(menuProps.ref, useWrappedRefWithWarning(ref, 'DropdownMenu'));\n if (!hasShown) return null; // For custom components provide additional, non-DOM, props;\n\n if (typeof Component !== 'string') {\n menuProps.show = show;\n menuProps.close = close;\n menuProps.alignRight = alignEnd;\n }\n\n var style = props.style;\n\n if (placement) {\n // we don't need the default popper style,\n // menus are display: none when not shown.\n style = _extends({}, style, {}, menuProps.style);\n props['x-placement'] = placement;\n }\n\n return React.createElement(Component, _extends({}, props, menuProps, {\n style: style,\n className: classNames(className, prefix, show && 'show', alignEnd && prefix + \"-right\")\n }));\n});\nDropdownMenu.displayName = 'DropdownMenu';\nDropdownMenu.defaultProps = defaultProps;\nexport default DropdownMenu;","map":null,"metadata":{},"sourceType":"module"} |