1 | import _Object$values from 'babel-runtime/core-js/object/values';
|
2 | import _extends from 'babel-runtime/helpers/extends';
|
3 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
4 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
5 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
6 | import _inherits from 'babel-runtime/helpers/inherits';
|
7 | import classNames from 'classnames';
|
8 | import React from 'react';
|
9 | import PropTypes from 'prop-types';
|
10 |
|
11 | import { bsClass, bsStyles, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
|
12 | import { State } from './utils/StyleConfig';
|
13 | import CloseButton from './CloseButton';
|
14 |
|
15 | var propTypes = {
|
16 | onDismiss: PropTypes.func,
|
17 | closeLabel: PropTypes.string
|
18 | };
|
19 |
|
20 | var defaultProps = {
|
21 | closeLabel: 'Close alert'
|
22 | };
|
23 |
|
24 | var Alert = function (_React$Component) {
|
25 | _inherits(Alert, _React$Component);
|
26 |
|
27 | function Alert() {
|
28 | _classCallCheck(this, Alert);
|
29 |
|
30 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
31 | }
|
32 |
|
33 | Alert.prototype.render = function render() {
|
34 | var _extends2;
|
35 |
|
36 | var _props = this.props,
|
37 | onDismiss = _props.onDismiss,
|
38 | closeLabel = _props.closeLabel,
|
39 | className = _props.className,
|
40 | children = _props.children,
|
41 | props = _objectWithoutProperties(_props, ['onDismiss', 'closeLabel', 'className', 'children']);
|
42 |
|
43 | var _splitBsProps = splitBsProps(props),
|
44 | bsProps = _splitBsProps[0],
|
45 | elementProps = _splitBsProps[1];
|
46 |
|
47 | var dismissable = !!onDismiss;
|
48 | var classes = _extends({}, getClassSet(bsProps), (_extends2 = {}, _extends2[prefix(bsProps, 'dismissable')] = dismissable, _extends2));
|
49 |
|
50 | return React.createElement(
|
51 | 'div',
|
52 | _extends({}, elementProps, {
|
53 | role: 'alert',
|
54 | className: classNames(className, classes)
|
55 | }),
|
56 | dismissable && React.createElement(CloseButton, { onClick: onDismiss, label: closeLabel }),
|
57 | children
|
58 | );
|
59 | };
|
60 |
|
61 | return Alert;
|
62 | }(React.Component);
|
63 |
|
64 | Alert.propTypes = propTypes;
|
65 | Alert.defaultProps = defaultProps;
|
66 |
|
67 | export default bsStyles(_Object$values(State), State.INFO, bsClass('alert', Alert)); |
\ | No newline at end of file |