@para-ui/core 4.0.0-rc.4 → 4.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AutoBox/index.js +72 -85
- package/AutoTips/index.js +72 -95
- package/Badge/index.js +17 -16
- package/Breadcrumbs/index.js +57 -73
- package/Button/index.js +90 -118
- package/ButtonGroup/index.js +30 -33
- package/Carousel/index.js +29 -33
- package/Cascader/index.js +9 -10
- package/Checkbox/index.js +28 -35
- package/CheckboxGroup/index.js +43 -58
- package/Collapse/index.js +52 -49
- package/CollapseBox/index.js +65 -70
- package/CollapseLayout/index.js +106 -101
- package/ColorPicker/index.js +3 -3
- package/ComboSelect/index.js +260 -337
- package/ComboSelect/lang/en_US.d.ts +1 -0
- package/ComboSelect/lang/index.d.ts +2 -0
- package/ComboSelect/lang/zh_CN.d.ts +1 -0
- package/ComboSelect/utils.d.ts +6 -0
- package/Container/index.js +17 -21
- package/CopyText/index.js +50 -83
- package/DatePicker/index.js +24 -27
- package/Descriptions/index.js +50 -59
- package/Desktop/index.js +161 -180
- package/DragVerify/index.js +77 -113
- package/Drawer/index.js +80 -95
- package/Dropdown/index.js +3 -3
- package/DynamicMultiBox/index.js +222 -224
- package/DynamicMultiBox/interface.d.ts +7 -0
- package/Empty/index.js +26 -28
- package/Form/index.js +70 -74
- package/FormItem/index.js +18 -15
- package/FunctionModal/index.js +7 -14
- package/GlobalContext/index.js +17 -20
- package/Help/index.js +9 -12
- package/HelperText/index.js +11 -11
- package/InputLang/index.js +104 -124
- package/InputNumber/index.js +62 -81
- package/Label/index.js +19 -21
- package/Loading/index.js +11 -10
- package/Menu/index.js +302 -371
- package/Message/index.js +104 -113
- package/Modal/index.js +122 -148
- package/MultiBox/index.d.ts +5 -0
- package/MultiBox/index.js +111 -115
- package/Notification/index.js +105 -103
- package/OperateBtn/index.d.ts +3 -0
- package/OperateBtn/index.js +77 -107
- package/PageHeader/index.js +327 -406
- package/Pagination/index.js +107 -137
- package/ParauiProvider/index.js +20 -22
- package/PasswordRules/index.js +36 -40
- package/PopConfirm/index.js +60 -77
- package/Popover/index.js +12 -12
- package/Progress/index.js +72 -74
- package/Querying/index.js +22 -23
- package/README.md +2 -0
- package/Radio/index.js +27 -34
- package/RadioGroup/index.js +38 -52
- package/Search/index.js +34 -43
- package/Select/index.js +281 -345
- package/SelectInput/index.js +8 -13
- package/Selector/index.js +582 -796
- package/SelectorPicker/index.js +113 -134
- package/SingleBox/index.d.ts +5 -0
- package/SingleBox/index.js +92 -88
- package/Slider/index.js +46 -57
- package/Status/index.js +14 -13
- package/Stepper/index.js +24 -25
- package/Styles/theme.scss +9 -9
- package/Switch/index.js +32 -35
- package/Table/index.js +360 -494
- package/Tabs/index.js +100 -100
- package/Tag/index.js +64 -82
- package/TextEditor/index.js +78 -100
- package/TextField/index.js +142 -183
- package/TimePicker/index.js +29 -28
- package/Timeline/index.js +50 -47
- package/Title/index.js +32 -34
- package/ToggleButton/index.js +29 -29
- package/Tooltip/index.js +52 -56
- package/Transfer/index.js +117 -154
- package/Tree/index.js +9 -10
- package/Upload/index.js +125 -143
- package/Upload/interface.d.ts +2 -0
- package/_verture/{constant-0d9802f7.js → constant-5317fc89.js} +2 -2
- package/_verture/{index-5a7e2438.js → index-3cdaba96.js} +967 -934
- package/_verture/{index-b1f80962.js → index-4fafd0a0.js} +6 -8
- package/_verture/{index-024bbc9b.js → index-775ad32d.js} +29 -25
- package/_verture/{index-05f7bf11.js → index-c568f272.js} +2 -2
- package/_verture/{index-232d890b.js → index-d63bd287.js} +1 -1
- package/_verture/index-da9097d3.js +239 -0
- package/_verture/{index-9331b116.js → index-e0f9064d.js} +125 -134
- package/_verture/intl-f2f27722.js +69 -0
- package/_verture/{modalContext-736ff215.js → modalContext-8534f23d.js} +36 -64
- package/_verture/{slicedToArray-a8206399.js → slicedToArray-75fa4188.js} +15 -2
- package/_verture/{toConsumableArray-8f4c9589.js → toConsumableArray-c7a8028f.js} +1 -1
- package/_verture/{useFormatMessage-703f8b20.js → useFormatMessage-eb13cf56.js} +5 -4
- package/_verture/{useGlobalProps-1b846a65.js → useGlobalProps-1e416658.js} +4 -3
- package/_verture/{usePopupContainer-87febeb9.js → usePopupContainer-635f66f4.js} +16 -15
- package/_verture/{util-7e1fb1e2.js → util-82646c4f.js} +5 -4
- package/_verture/utils-c17b5265.js +97 -0
- package/index.js +24 -23
- package/locale/en-US.d.ts +1 -0
- package/locale/index.d.ts +2 -0
- package/locale/index.js +10 -8
- package/locale/zh-CN.d.ts +1 -0
- package/package.json +11 -10
- package/umd/AutoBox.js +9 -8
- package/umd/AutoTips.js +9 -8
- package/umd/Badge.js +1 -1
- package/umd/Breadcrumbs.js +9 -8
- package/umd/Button.js +9 -8
- package/umd/ButtonGroup.js +9 -8
- package/umd/Carousel.js +5 -5
- package/umd/Cascader.js +9 -8
- package/umd/Checkbox.js +9 -8
- package/umd/CheckboxGroup.js +9 -8
- package/umd/Collapse.js +8 -7
- package/umd/CollapseBox.js +1 -1
- package/umd/CollapseLayout.js +4 -4
- package/umd/ColorPicker.js +1 -1
- package/umd/ComboSelect.js +9 -8
- package/umd/Container.js +1 -1
- package/umd/CopyText.js +9 -8
- package/umd/DatePicker.js +9 -8
- package/umd/Descriptions.js +9 -8
- package/umd/Desktop.js +9 -8
- package/umd/DragVerify.js +4 -4
- package/umd/Drawer.js +9 -8
- package/umd/Dropdown.js +6 -5
- package/umd/DynamicMultiBox.js +11 -10
- package/umd/Empty.js +1 -1
- package/umd/Form.js +9 -8
- package/umd/FormItem.js +9 -8
- package/umd/FunctionModal.js +9 -8
- package/umd/GlobalContext.js +1 -1
- package/umd/Help.js +9 -8
- package/umd/HelperText.js +1 -1
- package/umd/InputLang.js +9 -8
- package/umd/InputNumber.js +9 -8
- package/umd/Label.js +9 -8
- package/umd/Loading.js +4 -4
- package/umd/Menu.js +4 -4
- package/umd/Message.js +4 -4
- package/umd/Modal.js +9 -8
- package/umd/MultiBox.js +9 -8
- package/umd/Notification.js +8 -7
- package/umd/OperateBtn.js +9 -8
- package/umd/PageHeader.js +9 -8
- package/umd/Pagination.js +9 -8
- package/umd/ParauiProvider.js +1 -1
- package/umd/PasswordRules.js +4 -4
- package/umd/PopConfirm.js +9 -8
- package/umd/Popover.js +9 -8
- package/umd/Progress.js +5 -5
- package/umd/Querying.js +1 -1
- package/umd/Radio.js +9 -8
- package/umd/RadioGroup.js +9 -8
- package/umd/Search.js +9 -8
- package/umd/Select.js +9 -8
- package/umd/SelectInput.js +9 -8
- package/umd/Selector.js +9 -8
- package/umd/SelectorPicker.js +9 -8
- package/umd/SingleBox.js +9 -8
- package/umd/Slider.js +6 -5
- package/umd/Status.js +4 -4
- package/umd/Stepper.js +9 -8
- package/umd/Switch.js +9 -8
- package/umd/Table.js +9 -8
- package/umd/Tabs.js +9 -8
- package/umd/Tag.js +9 -8
- package/umd/TextEditor.js +22 -21
- package/umd/TextField.js +9 -8
- package/umd/TimePicker.js +9 -8
- package/umd/Timeline.js +1 -1
- package/umd/Title.js +9 -8
- package/umd/ToggleButton.js +9 -8
- package/umd/Tooltip.js +9 -8
- package/umd/Transfer.js +10 -9
- package/umd/Tree.js +9 -8
- package/umd/Upload.js +10 -9
- package/umd/locale.js +1 -1
- package/_verture/index-e9007d6a.js +0 -236
- package/_verture/intl-5c1ec055.js +0 -81
- package/_verture/unsupportedIterableToArray-cb478f24.js +0 -16
- package/_verture/utils-418da0a4.js +0 -73
- /package/_verture/{typeof-c310ee4a.js → typeof-b240b062.js} +0 -0
package/Message/index.js
CHANGED
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
import { _ as _typeof } from '../_verture/typeof-adeedc13.js';
|
|
2
|
-
import { _ as _toConsumableArray } from '../_verture/toConsumableArray-8f4c9589.js';
|
|
3
1
|
import { jsx } from 'react/jsx-runtime';
|
|
4
2
|
import { useEffect } from 'react';
|
|
5
3
|
import ReactDOM from 'react-dom';
|
|
6
4
|
import WarningCircleF from '@para-ui/icons/WarningCircleF';
|
|
7
|
-
import
|
|
5
|
+
import SuccessOutlined from '@para-ui/icons/CheckCircleF';
|
|
8
6
|
import CloseIcon from '@para-ui/icons/Close';
|
|
9
7
|
import CloseCircleF from '@para-ui/icons/CloseCircleF';
|
|
10
|
-
import { $ as $prefixCls } from '../_verture/constant-
|
|
8
|
+
import { $ as $prefixCls } from '../_verture/constant-5317fc89.js';
|
|
11
9
|
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
|
|
12
|
-
import '../_verture/unsupportedIterableToArray-cb478f24.js';
|
|
13
10
|
|
|
14
11
|
var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/1 下午5:48\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-message-box {\n /*从上到下进入*/\n /*从上到下*/\n}\n.paraui-v4-message-box--message-float {\n position: fixed;\n top: 3%;\n left: 0;\n z-index: 9999;\n text-align: center;\n width: 100%;\n pointer-events: none;\n}\n.paraui-v4-message-box .message-no-close .msg-text {\n max-width: 384px;\n margin-right: 0;\n}\n.paraui-v4-message-box .msg-icon {\n position: absolute;\n top: 11px;\n left: 16px;\n line-height: 0;\n}\n.paraui-v4-message-box .msg-icon svg {\n font-size: 18px;\n color: currentColor;\n}\n.paraui-v4-message-box .msg-text {\n display: inline-block;\n max-width: 352px;\n word-wrap: break-word;\n margin-right: 32px;\n margin-left: 24px;\n line-height: 20px;\n word-break: break-all;\n}\n.paraui-v4-message-box .msg-text--title {\n font-weight: 700;\n}\n.paraui-v4-message-box .msg-text--noicon {\n margin-left: 0;\n}\n.paraui-v4-message-box .msg-text .msg-desc {\n display: block;\n margin-top: 8px;\n font-weight: 400;\n word-wrap: break-word;\n}\n.paraui-v4-message-box .msg-close {\n width: 18px;\n height: 18px;\n border-radius: 2px;\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n right: 16px;\n top: 11px;\n cursor: pointer;\n line-height: 0;\n pointer-events: auto;\n}\n.paraui-v4-message-box .msg-close svg {\n font-size: 18px;\n color: currentColor;\n}\n.paraui-v4-message-box .msg-item-fill .msg-wrapper {\n width: 100%;\n}\n.paraui-v4-message-box .msg-wrapper {\n position: relative;\n display: inline-block;\n margin: 10px auto;\n min-height: 40px;\n padding: 10px 16px;\n border-radius: 4px;\n font-size: 14px;\n text-align: left;\n}\n.paraui-v4-message-box .msg-wrapper.msg-wrapper-title {\n padding: 16px 16px;\n}\n.paraui-v4-message-box .msg-wrapper.msg-wrapper-title .msg-icon {\n top: 17px;\n}\n.paraui-v4-message-box .msg-wrapper.msg-wrapper-title .msg-close {\n top: 17px;\n}\n.paraui-v4-message-box .msg-info {\n background-color: rgb(240, 245, 255);\n color: rgb(46, 101, 230);\n}\n.paraui-v4-message-box .msg-info .msg-close {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-message-box .msg-info .msg-close:hover {\n background-color: rgba(46, 101, 230, 0.1);\n}\n.paraui-v4-message-box .msg-warn {\n background-color: rgb(255, 246, 235);\n color: rgb(255, 147, 38);\n}\n.paraui-v4-message-box .msg-warn .msg-close {\n color: rgb(255, 147, 38);\n}\n.paraui-v4-message-box .msg-warn .msg-close:hover {\n background-color: rgba(255, 147, 38, 0.1);\n}\n.paraui-v4-message-box .msg-error {\n background-color: rgb(255, 235, 235);\n color: rgb(244, 66, 66);\n}\n.paraui-v4-message-box .msg-error .msg-close {\n color: rgb(244, 66, 66);\n}\n.paraui-v4-message-box .msg-error .msg-close:hover {\n background-color: rgba(244, 66, 66, 0.1);\n}\n.paraui-v4-message-box .msg-success {\n background-color: rgb(232, 252, 239);\n color: rgb(19, 191, 76);\n}\n.paraui-v4-message-box .msg-success .msg-close {\n color: rgb(19, 191, 76);\n}\n.paraui-v4-message-box .msg-success .msg-close:hover {\n background-color: rgba(19, 191, 76, 0.1);\n}\n.paraui-v4-message-box .message-fadeInDown {\n animation-duration: 0.5s;\n animation-name: messageFadeInDown;\n}\n@keyframes messageFadeInDown {\n from {\n opacity: 0;\n transform: translate(0, -50px); /* 标准语法 */\n }\n to {\n opacity: 1;\n transform: translate(0, 0); /* 标准语法 */\n }\n}";
|
|
15
12
|
styleInject(css_248z);
|
|
16
13
|
|
|
17
14
|
//图标map
|
|
18
|
-
|
|
15
|
+
const iconMapping = {
|
|
19
16
|
info: jsx(WarningCircleF, {}),
|
|
20
17
|
warn: jsx(WarningCircleF, {}),
|
|
21
18
|
error: jsx(CloseCircleF, {}),
|
|
22
|
-
success: jsx(
|
|
19
|
+
success: jsx(SuccessOutlined, {})
|
|
23
20
|
};
|
|
24
21
|
//获取window
|
|
25
|
-
|
|
22
|
+
const getMsgWindow = () => {
|
|
26
23
|
return window === window.top ? window : window.top;
|
|
27
24
|
};
|
|
28
25
|
//消息内容模板
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
const template = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
icon,
|
|
29
|
+
text,
|
|
30
|
+
id,
|
|
31
|
+
type,
|
|
32
|
+
html,
|
|
33
|
+
close,
|
|
34
|
+
desc,
|
|
35
|
+
hideIcon
|
|
36
|
+
} = _ref;
|
|
37
|
+
let item = document.createElement('div');
|
|
39
38
|
item.className = "msg-item";
|
|
40
39
|
item.id = id || '';
|
|
41
40
|
item.innerHTML = "<div class=\"msg-wrapper message-fadeInDown ".concat(close ? 'message-close' : 'message-no-close', " msg-").concat(type, "\">\n ").concat(icon ? "<div class=\"msg-icon\"></div>" : '', "\n <div class=\"msg-text\"></div>\n ").concat(close ? "<div class=\"msg-close\"></div>" : '', "\n </div>\n ");
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const msgWrapper = item.querySelector('.msg-wrapper');
|
|
42
|
+
const msgBox = item.querySelector('.msg-text');
|
|
44
43
|
if (!msgBox || !msgWrapper) return item;
|
|
45
44
|
if (html) msgBox.innerHTML = text;else msgBox.textContent = text;
|
|
46
45
|
//描述
|
|
47
46
|
if (desc) {
|
|
48
|
-
|
|
47
|
+
const span = document.createElement('span');
|
|
49
48
|
span.className = 'msg-desc';
|
|
50
49
|
span.textContent = desc || '';
|
|
51
50
|
msgBox.classList.add('msg-text--title');
|
|
@@ -55,10 +54,10 @@ var template = function template(_ref) {
|
|
|
55
54
|
if (hideIcon) {
|
|
56
55
|
msgBox.classList.add('msg-text--noicon');
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
if (msgClose) msgClose.addEventListener('click',
|
|
57
|
+
const msgClose = item.querySelector('.msg-close');
|
|
58
|
+
if (msgClose) msgClose.addEventListener('click', () => {
|
|
60
59
|
var _a;
|
|
61
|
-
|
|
60
|
+
const hasNode = document.querySelector("#".concat(id));
|
|
62
61
|
if (hasNode) {
|
|
63
62
|
(_a = item === null || item === void 0 ? void 0 : item.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(item);
|
|
64
63
|
item = null;
|
|
@@ -66,85 +65,87 @@ var template = function template(_ref) {
|
|
|
66
65
|
});
|
|
67
66
|
return item;
|
|
68
67
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
const MessageBar = props => {
|
|
69
|
+
const {
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
72
|
+
type
|
|
73
|
+
} = props;
|
|
74
|
+
const pId = createParentId();
|
|
75
|
+
const mId = getMsgId();
|
|
76
|
+
let cls = getParentClassName(props.className || '');
|
|
76
77
|
if (className) cls += " ".concat(className);
|
|
77
|
-
useEffect(
|
|
78
|
-
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const parent = document.getElementById(pId);
|
|
79
80
|
renderContent(parent, Object.assign(Object.assign({}, props), {
|
|
80
81
|
id: mId,
|
|
81
82
|
icon: iconMapping[type]
|
|
82
83
|
}), 0, false, true);
|
|
83
|
-
return
|
|
84
|
-
|
|
84
|
+
return () => {
|
|
85
|
+
const hasNode = document.querySelector("#".concat(mId));
|
|
85
86
|
if (hasNode) {
|
|
86
87
|
parent === null || parent === void 0 ? void 0 : parent.removeChild(hasNode);
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
|
-
},
|
|
90
|
+
}, [...Object.values(props)]);
|
|
90
91
|
return jsx("div", {
|
|
91
92
|
id: pId,
|
|
92
93
|
className: cls,
|
|
93
94
|
style: style
|
|
94
95
|
});
|
|
95
96
|
};
|
|
96
|
-
|
|
97
|
-
return "msgbox_".concat(String(Math.random() * 100000 | 0 + new Date().getTime()));
|
|
98
|
-
};
|
|
97
|
+
const createParentId = () => "msgbox_".concat(String(Math.random() * 100000 | 0 + new Date().getTime()));
|
|
99
98
|
//消息box id
|
|
100
|
-
|
|
99
|
+
const parentId = createParentId();
|
|
101
100
|
//message mountNode
|
|
102
|
-
var index = (
|
|
101
|
+
var index = (() => {
|
|
103
102
|
return jsx("div", {
|
|
104
103
|
className: "".concat($prefixCls, "-message-box"),
|
|
105
104
|
id: parentId
|
|
106
105
|
});
|
|
107
106
|
});
|
|
108
107
|
//渲染msg 内容
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
108
|
+
const renderContent = (box, _ref2, removeTime, autoClose, fill) => {
|
|
109
|
+
let {
|
|
110
|
+
icon,
|
|
111
|
+
text,
|
|
112
|
+
id,
|
|
113
|
+
type,
|
|
114
|
+
html,
|
|
115
|
+
close,
|
|
116
|
+
desc,
|
|
117
|
+
hideIcon
|
|
118
|
+
} = _ref2;
|
|
119
|
+
const item = template({
|
|
120
|
+
id,
|
|
121
|
+
text,
|
|
122
|
+
icon,
|
|
123
|
+
type,
|
|
124
|
+
html,
|
|
125
|
+
close,
|
|
126
|
+
desc,
|
|
127
|
+
hideIcon
|
|
127
128
|
});
|
|
128
129
|
if (fill && item) item.classList.add('msg-item-fill');
|
|
129
130
|
box === null || box === void 0 ? void 0 : box.appendChild(item);
|
|
130
|
-
|
|
131
|
+
const iconDom = document.querySelector("#".concat(id, " .msg-icon"));
|
|
131
132
|
if (iconDom && icon && !hideIcon) ReactDOM.render(icon, iconDom);
|
|
132
|
-
|
|
133
|
+
const closeDom = document.querySelector("#".concat(id, " .msg-close"));
|
|
133
134
|
if (closeDom) ReactDOM.render(jsx(CloseIcon, {}), closeDom);
|
|
134
135
|
if (!autoClose) return;
|
|
135
|
-
setTimeout(
|
|
136
|
-
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
const hasNode = document.querySelector("#".concat(item.id));
|
|
137
138
|
if (hasNode) box === null || box === void 0 ? void 0 : box.removeChild(item);
|
|
138
139
|
}, removeTime);
|
|
139
140
|
};
|
|
140
141
|
//message 构造方法
|
|
141
|
-
|
|
142
|
+
const Msg = (config, removeTime, type, parentId) => {
|
|
142
143
|
var _a, _b;
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
const getMsgConf = () => {
|
|
145
|
+
const _win = getMsgWindow();
|
|
145
146
|
return _win['__msg_conf__'] || {};
|
|
146
147
|
};
|
|
147
|
-
|
|
148
|
+
let icon = iconMapping[type],
|
|
148
149
|
text = '',
|
|
149
150
|
desc = '',
|
|
150
151
|
html = false,
|
|
@@ -153,8 +154,8 @@ var Msg = function Msg(config, removeTime, type, parentId) {
|
|
|
153
154
|
maxCount = (_a = getMsgConf().maxCount) !== null && _a !== void 0 ? _a : Infinity,
|
|
154
155
|
duration = (_b = getMsgConf().duration) !== null && _b !== void 0 ? _b : removeTime,
|
|
155
156
|
className = '';
|
|
156
|
-
|
|
157
|
-
if (typeof config === 'string') text = config;else if (
|
|
157
|
+
const autoClose = !isNaN(duration) && duration > 0;
|
|
158
|
+
if (typeof config === 'string') text = config;else if (typeof config === 'object') {
|
|
158
159
|
text = config.text || '';
|
|
159
160
|
desc = config.desc;
|
|
160
161
|
icon = config.icon || iconMapping[type];
|
|
@@ -162,8 +163,8 @@ var Msg = function Msg(config, removeTime, type, parentId) {
|
|
|
162
163
|
hideIcon = config.hideIcon || false;
|
|
163
164
|
if (config.maxCount > 0) maxCount = config.maxCount || Infinity;
|
|
164
165
|
}
|
|
165
|
-
if (
|
|
166
|
-
|
|
166
|
+
if (typeof config === 'object' && typeof config.close === 'boolean') close = config.close;else close = !autoClose;
|
|
167
|
+
let parent = document.getElementById(parentId);
|
|
167
168
|
if (!parent) {
|
|
168
169
|
parent = document.createElement('div');
|
|
169
170
|
parent.id = parentId;
|
|
@@ -171,33 +172,29 @@ var Msg = function Msg(config, removeTime, type, parentId) {
|
|
|
171
172
|
}
|
|
172
173
|
parent.className = getParentClassName(className);
|
|
173
174
|
parent.className += ' ' + "".concat($prefixCls, "-message-box--message-float");
|
|
174
|
-
|
|
175
|
+
const id = getMsgId();
|
|
175
176
|
renderContent(parent, {
|
|
176
|
-
id
|
|
177
|
-
text
|
|
178
|
-
icon
|
|
179
|
-
type
|
|
180
|
-
html
|
|
181
|
-
close
|
|
182
|
-
desc
|
|
183
|
-
hideIcon
|
|
177
|
+
id,
|
|
178
|
+
text,
|
|
179
|
+
icon,
|
|
180
|
+
type,
|
|
181
|
+
html,
|
|
182
|
+
close,
|
|
183
|
+
desc,
|
|
184
|
+
hideIcon
|
|
184
185
|
}, duration, autoClose);
|
|
185
186
|
dropEleWhenExceedLimit(parent, maxCount);
|
|
186
187
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
};
|
|
190
|
-
var getMsgId = function getMsgId() {
|
|
191
|
-
return "msgitem_".concat(String(Math.random() * 100000 | 0 + new Date().getTime()));
|
|
192
|
-
};
|
|
188
|
+
const getParentClassName = className => "".concat($prefixCls, "-message-box").concat(className ? " ".concat(className) : '');
|
|
189
|
+
const getMsgId = () => "msgitem_".concat(String(Math.random() * 100000 | 0 + new Date().getTime()));
|
|
193
190
|
//超出maxCount 删除之前元素
|
|
194
|
-
|
|
191
|
+
const dropEleWhenExceedLimit = (parent, maxCount) => {
|
|
195
192
|
var _a, _b;
|
|
196
193
|
if (!parent || !((_a = parent.children) === null || _a === void 0 ? void 0 : _a.length)) return;
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
const child = parent.children;
|
|
195
|
+
const len = child.length;
|
|
199
196
|
if (len > maxCount) {
|
|
200
|
-
for (
|
|
197
|
+
for (let i = 0; i < len; i++) {
|
|
201
198
|
if (i < maxCount && child[i]) {
|
|
202
199
|
(_b = child[i].parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(child[i]);
|
|
203
200
|
}
|
|
@@ -205,44 +202,38 @@ var dropEleWhenExceedLimit = function dropEleWhenExceedLimit(parent, maxCount) {
|
|
|
205
202
|
}
|
|
206
203
|
};
|
|
207
204
|
//清除所有msg
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
const clearFunc = parentId => {
|
|
206
|
+
const parent = document.getElementById(parentId);
|
|
210
207
|
if (!parent) return;
|
|
211
208
|
parent.innerHTML = '';
|
|
212
209
|
};
|
|
213
210
|
//msg 全局配置
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
const msgConfig = function () {
|
|
212
|
+
let conf = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
213
|
+
const _win = getMsgWindow();
|
|
217
214
|
_win.__msg_conf__ = conf;
|
|
218
215
|
};
|
|
219
216
|
//message
|
|
220
|
-
|
|
221
|
-
info: function
|
|
222
|
-
|
|
217
|
+
const Message = {
|
|
218
|
+
info: function (config) {
|
|
219
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
223
220
|
return Msg(config, duration, 'info', parentId);
|
|
224
221
|
},
|
|
225
|
-
warn: function
|
|
226
|
-
|
|
222
|
+
warn: function (config) {
|
|
223
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
227
224
|
return Msg(config, duration, 'warn', parentId);
|
|
228
225
|
},
|
|
229
|
-
error: function
|
|
230
|
-
|
|
226
|
+
error: function (config) {
|
|
227
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
231
228
|
return Msg(config, duration, 'error', parentId);
|
|
232
229
|
},
|
|
233
|
-
success: function
|
|
234
|
-
|
|
230
|
+
success: function (config) {
|
|
231
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
235
232
|
return Msg(config, duration, 'success', parentId);
|
|
236
233
|
},
|
|
237
|
-
clear:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
destroyAll: function destroyAll() {
|
|
241
|
-
return clearFunc(parentId);
|
|
242
|
-
},
|
|
243
|
-
config: function config(_config) {
|
|
244
|
-
return msgConfig(_config);
|
|
245
|
-
}
|
|
234
|
+
clear: () => clearFunc(parentId),
|
|
235
|
+
destroyAll: () => clearFunc(parentId),
|
|
236
|
+
config: config => msgConfig(config)
|
|
246
237
|
};
|
|
247
238
|
|
|
248
239
|
export { Message, MessageBar, index as default };
|