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 | import cn from 'classnames';
|
8 | import { prefix, splitBsPropsAndOmit, bsClass } from './utils/bootstrapUtils';
|
9 | import PanelCollapse from './PanelCollapse';
|
10 |
|
11 | var propTypes = {
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | collapsible: PropTypes.bool.isRequired
|
24 | };
|
25 |
|
26 | var defaultProps = {
|
27 | collapsible: false
|
28 | };
|
29 |
|
30 | var contextTypes = {
|
31 | $bs_panel: PropTypes.shape({
|
32 | bsClass: PropTypes.string
|
33 | })
|
34 | };
|
35 |
|
36 | var PanelBody = function (_React$Component) {
|
37 | _inherits(PanelBody, _React$Component);
|
38 |
|
39 | function PanelBody() {
|
40 | _classCallCheck(this, PanelBody);
|
41 |
|
42 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
43 | }
|
44 |
|
45 | PanelBody.prototype.render = function render() {
|
46 | var _props = this.props,
|
47 | children = _props.children,
|
48 | className = _props.className,
|
49 | collapsible = _props.collapsible;
|
50 |
|
51 | var _ref = this.context.$bs_panel || {},
|
52 | _bsClass = _ref.bsClass;
|
53 |
|
54 | var _splitBsPropsAndOmit = splitBsPropsAndOmit(this.props, ['collapsible']),
|
55 | bsProps = _splitBsPropsAndOmit[0],
|
56 | elementProps = _splitBsPropsAndOmit[1];
|
57 |
|
58 | bsProps.bsClass = _bsClass || bsProps.bsClass;
|
59 |
|
60 | var body = React.createElement(
|
61 | 'div',
|
62 | _extends({}, elementProps, { className: cn(className, prefix(bsProps, 'body')) }),
|
63 | children
|
64 | );
|
65 |
|
66 | if (collapsible) {
|
67 | body = React.createElement(
|
68 | PanelCollapse,
|
69 | null,
|
70 | body
|
71 | );
|
72 | }
|
73 |
|
74 | return body;
|
75 | };
|
76 |
|
77 | return PanelBody;
|
78 | }(React.Component);
|
79 |
|
80 | PanelBody.propTypes = propTypes;
|
81 | PanelBody.defaultProps = defaultProps;
|
82 | PanelBody.contextTypes = contextTypes;
|
83 |
|
84 | export default bsClass('panel', PanelBody); |
\ | No newline at end of file |