1 line
1.7 KiB
JSON
1 line
1.7 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 { useBootstrapPrefix } from './ThemeProvider';\nimport NavbarContext from './NavbarContext';\nvar defaultProps = {\n label: 'Toggle navigation'\n};\nvar NavbarToggle = React.forwardRef(function (_ref, ref) {\n var bsPrefix = _ref.bsPrefix,\n className = _ref.className,\n children = _ref.children,\n label = _ref.label,\n _ref$as = _ref.as,\n Component = _ref$as === void 0 ? 'button' : _ref$as,\n onClick = _ref.onClick,\n props = _objectWithoutPropertiesLoose(_ref, [\"bsPrefix\", \"className\", \"children\", \"label\", \"as\", \"onClick\"]);\n\n bsPrefix = useBootstrapPrefix(bsPrefix, 'navbar-toggler');\n\n var _ref2 = useContext(NavbarContext) || {},\n onToggle = _ref2.onToggle,\n expanded = _ref2.expanded;\n\n var handleClick = useEventCallback(function (e) {\n if (onClick) onClick(e);\n if (onToggle) onToggle();\n });\n\n if (Component === 'button') {\n props.type = 'button';\n }\n\n return React.createElement(Component, _extends({}, props, {\n ref: ref,\n onClick: handleClick,\n \"aria-label\": label,\n className: classNames(className, bsPrefix, !expanded && 'collapsed')\n }), children || React.createElement(\"span\", {\n className: bsPrefix + \"-icon\"\n }));\n});\nNavbarToggle.displayName = 'NavbarToggle';\nNavbarToggle.defaultProps = defaultProps;\nexport default NavbarToggle;","map":null,"metadata":{},"sourceType":"module"} |