1 line
2.2 KiB
JSON
1 line
2.2 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 useEventCallback from '@restart/hooks/useEventCallback';\nimport SafeAnchor from './SafeAnchor';\nimport SelectableContext, { makeEventKey } from './SelectableContext';\nimport { useBootstrapPrefix } from './ThemeProvider';\nimport NavContext from './NavContext';\nvar defaultProps = {\n as: SafeAnchor,\n disabled: false\n};\nvar DropdownItem = React.forwardRef(function (_ref, ref) {\n var bsPrefix = _ref.bsPrefix,\n className = _ref.className,\n children = _ref.children,\n eventKey = _ref.eventKey,\n disabled = _ref.disabled,\n href = _ref.href,\n onClick = _ref.onClick,\n onSelect = _ref.onSelect,\n propActive = _ref.active,\n Component = _ref.as,\n props = _objectWithoutPropertiesLoose(_ref, [\"bsPrefix\", \"className\", \"children\", \"eventKey\", \"disabled\", \"href\", \"onClick\", \"onSelect\", \"active\", \"as\"]);\n\n var prefix = useBootstrapPrefix(bsPrefix, 'dropdown-item');\n var onSelectCtx = useContext(SelectableContext);\n var navContext = useContext(NavContext);\n\n var _ref2 = navContext || {},\n activeKey = _ref2.activeKey;\n\n var key = makeEventKey(eventKey, href);\n var active = propActive == null && key != null ? makeEventKey(activeKey) === key : propActive;\n var handleClick = useEventCallback(function (event) {\n // SafeAnchor handles the disabled case, but we handle it here\n // for other components\n if (disabled) return;\n if (onClick) onClick(event);\n if (onSelectCtx) onSelectCtx(key, event);\n if (onSelect) onSelect(key, event);\n });\n return React.createElement(Component, _extends({}, props, {\n ref: ref,\n href: href,\n disabled: disabled,\n className: classNames(className, prefix, active && 'active', disabled && 'disabled'),\n onClick: handleClick\n }), children);\n});\nDropdownItem.displayName = 'DropdownItem';\nDropdownItem.defaultProps = defaultProps;\nexport default DropdownItem;","map":null,"metadata":{},"sourceType":"module"} |