{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose\";\nimport React, { useContext } from 'react';\nimport SelectableContext from './SelectableContext';\nimport AccordionContext from './AccordionContext';\nexport function useAccordionToggle(eventKey, onClick) {\n var contextEventKey = useContext(AccordionContext);\n var onSelect = useContext(SelectableContext);\n return function (e) {\n /* \n Compare the event key in context with the given event key.\n If they are the same, then collapse the component.\n */\n var eventKeyPassed = eventKey === contextEventKey ? null : eventKey;\n onSelect(eventKeyPassed, e);\n if (onClick) onClick(e);\n };\n}\nvar AccordionToggle = React.forwardRef(function (_ref, ref) {\n var _ref$as = _ref.as,\n Component = _ref$as === void 0 ? 'button' : _ref$as,\n children = _ref.children,\n eventKey = _ref.eventKey,\n onClick = _ref.onClick,\n props = _objectWithoutPropertiesLoose(_ref, [\"as\", \"children\", \"eventKey\", \"onClick\"]);\n\n var accordionOnClick = useAccordionToggle(eventKey, onClick);\n return React.createElement(Component, _extends({\n ref: ref,\n onClick: accordionOnClick\n }, props), children);\n});\nexport default AccordionToggle;","map":null,"metadata":{},"sourceType":"module"}