GoScrobble/web/node_modules/react-bootstrap/esm/AccordionCollapse.js

24 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["children", "eventKey"];
import React, { useContext } from 'react';
import Collapse from './Collapse';
import AccordionContext from './AccordionContext';
import SelectableContext from './SelectableContext';
var AccordionCollapse = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
var children = _ref.children,
eventKey = _ref.eventKey,
props = _objectWithoutPropertiesLoose(_ref, _excluded);
var contextEventKey = useContext(AccordionContext); // Empty SelectableContext is to prevent elements in the collapse
// from collapsing the accordion when clicked.
return /*#__PURE__*/React.createElement(SelectableContext.Provider, {
value: null
}, /*#__PURE__*/React.createElement(Collapse, _extends({
ref: ref,
in: contextEventKey === eventKey
}, props), /*#__PURE__*/React.createElement("div", null, React.Children.only(children))));
});
AccordionCollapse.displayName = 'AccordionCollapse';
export default AccordionCollapse;