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 classNames from 'classnames';
|
7 | import PropTypes from 'prop-types';
|
8 | import React from 'react';
|
9 |
|
10 | import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
|
11 | import createChainedFunction from './utils/createChainedFunction';
|
12 | import CloseButton from './CloseButton';
|
13 |
|
14 |
|
15 |
|
16 | var propTypes = {
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 | closeLabel: PropTypes.string,
|
23 |
|
24 | |
25 |
|
26 |
|
27 | closeButton: PropTypes.bool,
|
28 |
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 | onHide: PropTypes.func
|
35 | };
|
36 |
|
37 | var defaultProps = {
|
38 | closeLabel: 'Close',
|
39 | closeButton: false
|
40 | };
|
41 |
|
42 | var contextTypes = {
|
43 | $bs_modal: PropTypes.shape({
|
44 | onHide: PropTypes.func
|
45 | })
|
46 | };
|
47 |
|
48 | var ModalHeader = function (_React$Component) {
|
49 | _inherits(ModalHeader, _React$Component);
|
50 |
|
51 | function ModalHeader() {
|
52 | _classCallCheck(this, ModalHeader);
|
53 |
|
54 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
55 | }
|
56 |
|
57 | ModalHeader.prototype.render = function render() {
|
58 | var _props = this.props,
|
59 | closeLabel = _props.closeLabel,
|
60 | closeButton = _props.closeButton,
|
61 | onHide = _props.onHide,
|
62 | className = _props.className,
|
63 | children = _props.children,
|
64 | props = _objectWithoutProperties(_props, ['closeLabel', 'closeButton', 'onHide', 'className', 'children']);
|
65 |
|
66 | var modal = this.context.$bs_modal;
|
67 |
|
68 | var _splitBsProps = splitBsProps(props),
|
69 | bsProps = _splitBsProps[0],
|
70 | elementProps = _splitBsProps[1];
|
71 |
|
72 | var classes = getClassSet(bsProps);
|
73 |
|
74 | return React.createElement(
|
75 | 'div',
|
76 | _extends({}, elementProps, { className: classNames(className, classes) }),
|
77 | closeButton && React.createElement(CloseButton, {
|
78 | label: closeLabel,
|
79 | onClick: createChainedFunction(modal && modal.onHide, onHide)
|
80 | }),
|
81 | children
|
82 | );
|
83 | };
|
84 |
|
85 | return ModalHeader;
|
86 | }(React.Component);
|
87 |
|
88 | ModalHeader.propTypes = propTypes;
|
89 | ModalHeader.defaultProps = defaultProps;
|
90 | ModalHeader.contextTypes = contextTypes;
|
91 |
|
92 | export default bsClass('modal-header', ModalHeader); |
\ | No newline at end of file |