1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
4 | import _inherits from 'babel-runtime/helpers/inherits';
|
5 | import PropTypes from 'prop-types';
|
6 | import React from 'react';
|
7 |
|
8 | import { prefix, splitBsProps, bsClass } from './utils/bootstrapUtils';
|
9 | import Collapse from './Collapse';
|
10 |
|
11 | var propTypes = {
|
12 | |
13 |
|
14 |
|
15 | onEnter: PropTypes.func,
|
16 | |
17 |
|
18 |
|
19 | onEntering: PropTypes.func,
|
20 | |
21 |
|
22 |
|
23 | onEntered: PropTypes.func,
|
24 | |
25 |
|
26 |
|
27 | onExit: PropTypes.func,
|
28 | |
29 |
|
30 |
|
31 | onExiting: PropTypes.func,
|
32 | |
33 |
|
34 |
|
35 | onExited: PropTypes.func
|
36 | };
|
37 |
|
38 | var contextTypes = {
|
39 | $bs_panel: PropTypes.shape({
|
40 | headingId: PropTypes.string,
|
41 | bodyId: PropTypes.string,
|
42 | bsClass: PropTypes.string,
|
43 | expanded: PropTypes.bool
|
44 | })
|
45 | };
|
46 |
|
47 | var PanelCollapse = function (_React$Component) {
|
48 | _inherits(PanelCollapse, _React$Component);
|
49 |
|
50 | function PanelCollapse() {
|
51 | _classCallCheck(this, PanelCollapse);
|
52 |
|
53 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
54 | }
|
55 |
|
56 | PanelCollapse.prototype.render = function render() {
|
57 | var children = this.props.children;
|
58 |
|
59 | var _ref = this.context.$bs_panel || {},
|
60 | headingId = _ref.headingId,
|
61 | bodyId = _ref.bodyId,
|
62 | _bsClass = _ref.bsClass,
|
63 | expanded = _ref.expanded;
|
64 |
|
65 | var _splitBsProps = splitBsProps(this.props),
|
66 | bsProps = _splitBsProps[0],
|
67 | props = _splitBsProps[1];
|
68 |
|
69 | bsProps.bsClass = _bsClass || bsProps.bsClass;
|
70 |
|
71 | if (headingId && bodyId) {
|
72 | props.id = bodyId;
|
73 | props.role = props.role || 'tabpanel';
|
74 | props['aria-labelledby'] = headingId;
|
75 | }
|
76 |
|
77 | return React.createElement(
|
78 | Collapse,
|
79 | _extends({ 'in': expanded }, props),
|
80 | React.createElement(
|
81 | 'div',
|
82 | { className: prefix(bsProps, 'collapse') },
|
83 | children
|
84 | )
|
85 | );
|
86 | };
|
87 |
|
88 | return PanelCollapse;
|
89 | }(React.Component);
|
90 |
|
91 | PanelCollapse.propTypes = propTypes;
|
92 | PanelCollapse.contextTypes = contextTypes;
|
93 |
|
94 | export default bsClass('panel', PanelCollapse); |
\ | No newline at end of file |