1 | var _excluded = ["className", "cssModule", "children", "toggle", "tag", "wrapTag", "closeAriaLabel", "close", "tagClassName", "icon"];
|
2 | function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
3 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
4 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import classNames from 'classnames';
|
8 | import { mapToCssModules, tagPropType } from './utils';
|
9 | var propTypes = {
|
10 | tag: tagPropType,
|
11 | icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
12 | wrapTag: tagPropType,
|
13 | toggle: PropTypes.func,
|
14 | className: PropTypes.string,
|
15 | cssModule: PropTypes.object,
|
16 | children: PropTypes.node,
|
17 | closeAriaLabel: PropTypes.string,
|
18 | charCode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
19 | close: PropTypes.object,
|
20 | tagClassName: PropTypes.string
|
21 | };
|
22 | function ToastHeader(props) {
|
23 | var closeButton;
|
24 | var icon;
|
25 | var className = props.className,
|
26 | cssModule = props.cssModule,
|
27 | children = props.children,
|
28 | toggle = props.toggle,
|
29 | _props$tag = props.tag,
|
30 | Tag = _props$tag === void 0 ? 'strong' : _props$tag,
|
31 | _props$wrapTag = props.wrapTag,
|
32 | WrapTag = _props$wrapTag === void 0 ? 'div' : _props$wrapTag,
|
33 | _props$closeAriaLabel = props.closeAriaLabel,
|
34 | closeAriaLabel = _props$closeAriaLabel === void 0 ? 'Close' : _props$closeAriaLabel,
|
35 | close = props.close,
|
36 | _props$tagClassName = props.tagClassName,
|
37 | tagClassName = _props$tagClassName === void 0 ? 'me-auto' : _props$tagClassName,
|
38 | iconProp = props.icon,
|
39 | attributes = _objectWithoutProperties(props, _excluded);
|
40 | var classes = mapToCssModules(classNames(className, 'toast-header'), cssModule);
|
41 | if (!close && toggle) {
|
42 | closeButton = React.createElement("button", {
|
43 | type: "button",
|
44 | onClick: toggle,
|
45 | className: mapToCssModules('btn-close', cssModule),
|
46 | "aria-label": closeAriaLabel
|
47 | });
|
48 | }
|
49 | if (typeof iconProp === 'string') {
|
50 | icon = React.createElement("svg", {
|
51 | className: mapToCssModules("rounded text-".concat(iconProp)),
|
52 | width: "20",
|
53 | height: "20",
|
54 | xmlns: "http://www.w3.org/2000/svg",
|
55 | preserveAspectRatio: "xMidYMid slice",
|
56 | focusable: "false",
|
57 | role: "img"
|
58 | }, React.createElement("rect", {
|
59 | fill: "currentColor",
|
60 | width: "100%",
|
61 | height: "100%"
|
62 | }));
|
63 | } else if (iconProp) {
|
64 | icon = iconProp;
|
65 | }
|
66 | return React.createElement(WrapTag, _extends({}, attributes, {
|
67 | className: classes
|
68 | }), icon, React.createElement(Tag, {
|
69 | className: mapToCssModules(classNames(tagClassName, {
|
70 | 'ms-2': icon != null
|
71 | }), cssModule)
|
72 | }, children), close || closeButton);
|
73 | }
|
74 | ToastHeader.propTypes = propTypes;
|
75 | export default ToastHeader; |
\ | No newline at end of file |