1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 | import cn from 'classnames';
|
7 | import PropTypes from 'prop-types';
|
8 | import React from 'react';
|
9 | import elementType from 'react-prop-types/lib/elementType';
|
10 |
|
11 | import { prefix, splitBsProps, bsClass } from './utils/bootstrapUtils';
|
12 | import PanelToggle from './PanelToggle';
|
13 |
|
14 | var propTypes = {
|
15 | componentClass: elementType,
|
16 | |
17 |
|
18 |
|
19 |
|
20 | toggle: PropTypes.bool
|
21 | };
|
22 |
|
23 | var contextTypes = {
|
24 | $bs_panel: PropTypes.shape({
|
25 | bsClass: PropTypes.string
|
26 | })
|
27 | };
|
28 |
|
29 | var defaultProps = {
|
30 | componentClass: 'div'
|
31 | };
|
32 |
|
33 | var PanelTitle = function (_React$Component) {
|
34 | _inherits(PanelTitle, _React$Component);
|
35 |
|
36 | function PanelTitle() {
|
37 | _classCallCheck(this, PanelTitle);
|
38 |
|
39 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
40 | }
|
41 |
|
42 | PanelTitle.prototype.render = function render() {
|
43 | var _props = this.props,
|
44 | children = _props.children,
|
45 | className = _props.className,
|
46 | toggle = _props.toggle,
|
47 | Component = _props.componentClass,
|
48 | props = _objectWithoutProperties(_props, ['children', 'className', 'toggle', 'componentClass']);
|
49 |
|
50 | var _ref = this.context.$bs_panel || {},
|
51 | _bsClass = _ref.bsClass;
|
52 |
|
53 | var _splitBsProps = splitBsProps(props),
|
54 | bsProps = _splitBsProps[0],
|
55 | elementProps = _splitBsProps[1];
|
56 |
|
57 | bsProps.bsClass = _bsClass || bsProps.bsClass;
|
58 |
|
59 | if (toggle) {
|
60 | children = React.createElement(
|
61 | PanelToggle,
|
62 | null,
|
63 | children
|
64 | );
|
65 | }
|
66 |
|
67 | return React.createElement(
|
68 | Component,
|
69 | _extends({}, elementProps, {
|
70 | className: cn(className, prefix(bsProps, 'title'))
|
71 | }),
|
72 | children
|
73 | );
|
74 | };
|
75 |
|
76 | return PanelTitle;
|
77 | }(React.Component);
|
78 |
|
79 | PanelTitle.propTypes = propTypes;
|
80 | PanelTitle.defaultProps = defaultProps;
|
81 | PanelTitle.contextTypes = contextTypes;
|
82 |
|
83 | export default bsClass('panel', PanelTitle); |
\ | No newline at end of file |