1 | var _excluded = ["className", "cssModule", "tag", "innerRef", "children", "accordionId"];
|
2 | function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5 | import React, { useContext } from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import classNames from 'classnames';
|
8 | import { mapToCssModules, tagPropType } from './utils';
|
9 | import Collapse from './Collapse';
|
10 | import { AccordionContext } from './AccordionContext';
|
11 | var propTypes = {
|
12 |
|
13 | accordionId: PropTypes.string.isRequired,
|
14 |
|
15 | className: PropTypes.string,
|
16 | children: PropTypes.node,
|
17 |
|
18 | cssModule: PropTypes.object,
|
19 |
|
20 | innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func]),
|
21 |
|
22 | tag: tagPropType
|
23 | };
|
24 | function AccordionBody(props) {
|
25 | var className = props.className,
|
26 | cssModule = props.cssModule,
|
27 | _props$tag = props.tag,
|
28 | Tag = _props$tag === void 0 ? 'div' : _props$tag,
|
29 | innerRef = props.innerRef,
|
30 | children = props.children,
|
31 | accordionId = props.accordionId,
|
32 | attributes = _objectWithoutProperties(props, _excluded);
|
33 | var _useContext = useContext(AccordionContext),
|
34 | open = _useContext.open;
|
35 | var classes = mapToCssModules(classNames(className, 'accordion-collapse'), cssModule);
|
36 | return React.createElement(Collapse, _extends({}, attributes, {
|
37 | className: classes,
|
38 | ref: innerRef,
|
39 | isOpen: Array.isArray(open) ? open.includes(accordionId) : open === accordionId
|
40 | }), React.createElement(Tag, {
|
41 | className: "accordion-body"
|
42 | }, children));
|
43 | }
|
44 | AccordionBody.propTypes = propTypes;
|
45 | export default AccordionBody; |
\ | No newline at end of file |