1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
3 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
4 | var __rest = this && this.__rest || function (s, e) {
|
5 | var t = {};
|
6 | for (var p in s) {
|
7 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
8 | }
|
9 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
10 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
11 | }
|
12 | return t;
|
13 | };
|
14 | import * as React from 'react';
|
15 | import LoadingOutlined from "@ant-design/icons/es/icons/LoadingOutlined";
|
16 | import ExclamationCircleFilled from "@ant-design/icons/es/icons/ExclamationCircleFilled";
|
17 | import CloseCircleFilled from "@ant-design/icons/es/icons/CloseCircleFilled";
|
18 | import CheckCircleFilled from "@ant-design/icons/es/icons/CheckCircleFilled";
|
19 | import InfoCircleFilled from "@ant-design/icons/es/icons/InfoCircleFilled";
|
20 | import CloseOutlined from "@ant-design/icons/es/icons/CloseOutlined";
|
21 | import { Notice } from 'rc-notification';
|
22 | import classNames from 'classnames';
|
23 | import useStyle from './style';
|
24 | import { ConfigContext } from '../config-provider';
|
25 | export var TypeIcon = {
|
26 | info: React.createElement(InfoCircleFilled, null),
|
27 | success: React.createElement(CheckCircleFilled, null),
|
28 | error: React.createElement(CloseCircleFilled, null),
|
29 | warning: React.createElement(ExclamationCircleFilled, null),
|
30 | loading: React.createElement(LoadingOutlined, null)
|
31 | };
|
32 | export function getCloseIcon(prefixCls, closeIcon) {
|
33 | return closeIcon || React.createElement("span", {
|
34 | className: prefixCls + "-close-x"
|
35 | }, React.createElement(CloseOutlined, {
|
36 | className: prefixCls + "-close-icon"
|
37 | }));
|
38 | }
|
39 | var typeToIcon = {
|
40 | success: CheckCircleFilled,
|
41 | info: InfoCircleFilled,
|
42 | error: CloseCircleFilled,
|
43 | warning: ExclamationCircleFilled
|
44 | };
|
45 | export function PureContent(_ref) {
|
46 | var prefixCls = _ref.prefixCls,
|
47 | icon = _ref.icon,
|
48 | type = _ref.type,
|
49 | message = _ref.message,
|
50 | description = _ref.description,
|
51 | btn = _ref.btn;
|
52 | var iconNode = null;
|
53 | if (icon) {
|
54 | iconNode = React.createElement("span", {
|
55 | className: prefixCls + "-icon"
|
56 | }, icon);
|
57 | } else if (type) {
|
58 | iconNode = React.createElement(typeToIcon[type] || null, {
|
59 | className: classNames(prefixCls + "-icon", prefixCls + "-icon-" + type)
|
60 | });
|
61 | }
|
62 | return React.createElement("div", {
|
63 | className: classNames(_defineProperty({}, prefixCls + "-with-icon", iconNode)),
|
64 | role: "alert"
|
65 | }, iconNode, React.createElement("div", {
|
66 | className: prefixCls + "-message"
|
67 | }, message), React.createElement("div", {
|
68 | className: prefixCls + "-description"
|
69 | }, description), btn && React.createElement("div", {
|
70 | className: prefixCls + "-btn"
|
71 | }, btn));
|
72 | }
|
73 |
|
74 | export default function PurePanel(props) {
|
75 | var staticPrefixCls = props.prefixCls,
|
76 | className = props.className,
|
77 | icon = props.icon,
|
78 | type = props.type,
|
79 | message = props.message,
|
80 | description = props.description,
|
81 | btn = props.btn,
|
82 | _props$closable = props.closable,
|
83 | closable = _props$closable === void 0 ? true : _props$closable,
|
84 | closeIcon = props.closeIcon,
|
85 | restProps = __rest(props, ["prefixCls", "className", "icon", "type", "message", "description", "btn", "closable", "closeIcon"]);
|
86 | var _React$useContext = React.useContext(ConfigContext),
|
87 | getPrefixCls = _React$useContext.getPrefixCls;
|
88 | var prefixCls = staticPrefixCls || getPrefixCls('notification');
|
89 | var noticePrefixCls = prefixCls + "-notice";
|
90 | var _useStyle = useStyle(prefixCls),
|
91 | _useStyle2 = _slicedToArray(_useStyle, 2),
|
92 | hashId = _useStyle2[1];
|
93 | return React.createElement(Notice, _extends({}, restProps, {
|
94 | prefixCls: prefixCls,
|
95 | className: classNames(className, hashId, noticePrefixCls + "-pure-panel"),
|
96 | eventKey: "pure",
|
97 | duration: null,
|
98 | closable: closable,
|
99 | closeIcon: getCloseIcon(prefixCls, closeIcon),
|
100 | content: React.createElement(PureContent, {
|
101 | prefixCls: noticePrefixCls,
|
102 | icon: icon,
|
103 | type: type,
|
104 | message: message,
|
105 | description: description,
|
106 | btn: btn
|
107 | })
|
108 | }));
|
109 | } |
\ | No newline at end of file |