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