@autobest-ui/components 2.4.0 → 2.5.0
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/esm/index.d.ts +2 -2
- package/esm/index.js +1 -1
- package/esm/message/index.d.ts +32 -6
- package/esm/message/index.js +95 -82
- package/esm/message/renderMessage.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -3
- package/lib/message/index.d.ts +32 -6
- package/lib/message/index.js +97 -83
- package/lib/message/renderMessage.d.ts +1 -1
- package/package.json +2 -2
package/esm/index.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ export type { CheckboxProps } from './checkbox';
|
|
|
38
38
|
export { default as Checkbox } from './checkbox';
|
|
39
39
|
export type { ScriptAttributes, ScriptProps } from './script';
|
|
40
40
|
export { default as Script } from './script';
|
|
41
|
-
export type { MessageProps, MessageConfig } from './message';
|
|
42
|
-
export { default as Message } from './message';
|
|
41
|
+
export type { MessageProps, MessageConfig, MessageResult } from './message';
|
|
42
|
+
export { default as message, Message } from './message';
|
|
43
43
|
export type { TableProps, TableRowSelectionInfo } from './table';
|
|
44
44
|
export type { TableColumnInfo, TableColumnOnRenderReturnObjectInfo } from './table/interface';
|
|
45
45
|
export { default as Table } from './table';
|
package/esm/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export { default as LazyImage } from './lazy-image';
|
|
|
18
18
|
export { default as LinkList } from './link-list';
|
|
19
19
|
export { default as Checkbox } from './checkbox';
|
|
20
20
|
export { default as Script } from './script';
|
|
21
|
-
export { default as Message } from './message';
|
|
21
|
+
export { default as message, Message } from './message';
|
|
22
22
|
export { default as Table } from './table';
|
|
23
23
|
export { default as DatePicker } from './date-picker';
|
|
24
24
|
export { default as Tabs } from './tabs';
|
package/esm/message/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { MessageItem } from './renderMessage';
|
|
2
3
|
export interface MessageProps {
|
|
3
4
|
/**
|
|
4
5
|
* 提示文字
|
|
5
6
|
*/
|
|
6
|
-
content: React.
|
|
7
|
+
content: React.ReactChild;
|
|
7
8
|
/**
|
|
8
9
|
* 支持多种样式
|
|
9
10
|
*/
|
|
@@ -25,11 +26,36 @@ export interface MessageConfig {
|
|
|
25
26
|
*/
|
|
26
27
|
maxCount?: number;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
onCloseAll: () => void;
|
|
29
|
+
export interface MessageResult {
|
|
30
30
|
onClose: () => void;
|
|
31
|
+
onCloseAll: () => void;
|
|
32
|
+
}
|
|
33
|
+
declare type MessageItemWithTimer = MessageItem & {
|
|
34
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
31
35
|
};
|
|
32
|
-
declare
|
|
33
|
-
|
|
36
|
+
export declare class Message {
|
|
37
|
+
id: number;
|
|
38
|
+
prefixCls: string;
|
|
39
|
+
options: MessageItemWithTimer[];
|
|
40
|
+
config: MessageConfig;
|
|
41
|
+
constructor(config?: MessageConfig & {
|
|
42
|
+
prefixCls?: string;
|
|
43
|
+
});
|
|
44
|
+
private _render;
|
|
45
|
+
/**
|
|
46
|
+
* 关闭指定的一条message
|
|
47
|
+
* @param currentId
|
|
48
|
+
*/
|
|
49
|
+
private _onClose;
|
|
50
|
+
/**
|
|
51
|
+
* 关闭所有message
|
|
52
|
+
*/
|
|
53
|
+
private _onCloseAll;
|
|
54
|
+
setConfig: (config: MessageConfig) => void;
|
|
55
|
+
open: (props: MessageProps) => {
|
|
56
|
+
onCloseAll: () => void;
|
|
57
|
+
onClose: () => void;
|
|
58
|
+
};
|
|
34
59
|
}
|
|
35
|
-
|
|
60
|
+
declare const message: Message;
|
|
61
|
+
export default message;
|
package/esm/message/index.js
CHANGED
|
@@ -12,87 +12,100 @@ var __assign = this && this.__assign || function () {
|
|
|
12
12
|
};
|
|
13
13
|
import { canUseDOM, isEmptyArray } from '@autobest-ui/utils';
|
|
14
14
|
import renderMessage from './renderMessage';
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var currentConfig = {
|
|
20
|
-
expires: 3000,
|
|
21
|
-
maxCount: 3
|
|
22
|
-
};
|
|
23
|
-
export default function Message(props) {
|
|
24
|
-
if (!canUseDOM) {
|
|
25
|
-
throw new Error('Message use client!');
|
|
26
|
-
}
|
|
27
|
-
var cachedId = id++;
|
|
28
|
-
function render() {
|
|
29
|
-
renderMessage({
|
|
30
|
-
prefixCls: prefixCls,
|
|
31
|
-
className: currentConfig.className,
|
|
32
|
-
options: options
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 关闭指定的一条message
|
|
37
|
-
* @param currentId
|
|
38
|
-
*/
|
|
39
|
-
function _onClose(currentId) {
|
|
40
|
-
if (isEmptyArray(options)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
var index = options.findIndex(function (item) {
|
|
44
|
-
return item.id === currentId;
|
|
45
|
-
});
|
|
46
|
-
if (index >= 0) {
|
|
47
|
-
clearTimeout(options[index].timer);
|
|
48
|
-
options.splice(index, 1);
|
|
49
|
-
// 关闭需要再渲染一次
|
|
50
|
-
render();
|
|
15
|
+
var Message = /** @class */function () {
|
|
16
|
+
function Message(config) {
|
|
17
|
+
if (config === void 0) {
|
|
18
|
+
config = {};
|
|
51
19
|
}
|
|
20
|
+
var _this = this;
|
|
21
|
+
this.id = 0;
|
|
22
|
+
this.options = [];
|
|
23
|
+
this._render = function () {
|
|
24
|
+
renderMessage({
|
|
25
|
+
prefixCls: _this.prefixCls,
|
|
26
|
+
className: _this.config.className,
|
|
27
|
+
options: _this.options
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 关闭指定的一条message
|
|
32
|
+
* @param currentId
|
|
33
|
+
*/
|
|
34
|
+
this._onClose = function (currentId) {
|
|
35
|
+
if (isEmptyArray(_this.options)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var index = _this.options.findIndex(function (item) {
|
|
39
|
+
return item.id === currentId;
|
|
40
|
+
});
|
|
41
|
+
if (index >= 0) {
|
|
42
|
+
clearTimeout(_this.options[index].timer);
|
|
43
|
+
_this.options.splice(index, 1);
|
|
44
|
+
// 关闭需要再渲染一次
|
|
45
|
+
_this._render();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 关闭所有message
|
|
50
|
+
*/
|
|
51
|
+
this._onCloseAll = function () {
|
|
52
|
+
if (isEmptyArray(_this.options)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
_this.options.forEach(function (child) {
|
|
56
|
+
clearTimeout(child.timer);
|
|
57
|
+
});
|
|
58
|
+
_this.options = [];
|
|
59
|
+
_this._render();
|
|
60
|
+
};
|
|
61
|
+
this.setConfig = function (config) {
|
|
62
|
+
_this.config = __assign({
|
|
63
|
+
expires: 3000,
|
|
64
|
+
maxCount: 3
|
|
65
|
+
}, config);
|
|
66
|
+
};
|
|
67
|
+
this.open = function (props) {
|
|
68
|
+
if (!canUseDOM) {
|
|
69
|
+
throw new Error('Message use client!');
|
|
70
|
+
}
|
|
71
|
+
_this.id++;
|
|
72
|
+
var currentId = _this.id;
|
|
73
|
+
/**
|
|
74
|
+
* 超出条数,将删除最旧的那条message
|
|
75
|
+
*/
|
|
76
|
+
if (_this.options.length >= _this.config.maxCount) {
|
|
77
|
+
_this._onClose(_this.options[0].id);
|
|
78
|
+
}
|
|
79
|
+
// 每条message对象
|
|
80
|
+
var item = {
|
|
81
|
+
content: props.content,
|
|
82
|
+
contentClassName: props.contentClassName,
|
|
83
|
+
id: currentId,
|
|
84
|
+
onDestroy: props.onDestroy,
|
|
85
|
+
onClose: _this._onClose,
|
|
86
|
+
timer: null
|
|
87
|
+
};
|
|
88
|
+
// push
|
|
89
|
+
_this.options.push(item);
|
|
90
|
+
// 开始渲染
|
|
91
|
+
_this._render();
|
|
92
|
+
// render后设置自动关闭功能,把定时器绑定到列表
|
|
93
|
+
item.timer = setTimeout(function () {
|
|
94
|
+
_this._onClose(currentId);
|
|
95
|
+
}, props.expires || _this.config.expires);
|
|
96
|
+
return {
|
|
97
|
+
onCloseAll: _this._onCloseAll,
|
|
98
|
+
onClose: function onClose() {
|
|
99
|
+
return _this._onClose(currentId);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
this.prefixCls = config.prefixCls || 'ab-message';
|
|
104
|
+
delete config.prefixCls;
|
|
105
|
+
this.setConfig(__assign({}, config));
|
|
52
106
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
options.forEach(function (child) {
|
|
61
|
-
clearTimeout(child.timer);
|
|
62
|
-
});
|
|
63
|
-
options = [];
|
|
64
|
-
render();
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 超出条数,将删除最旧的那条message
|
|
68
|
-
*/
|
|
69
|
-
if (options.length >= currentConfig.maxCount) {
|
|
70
|
-
_onClose(options[0].id);
|
|
71
|
-
}
|
|
72
|
-
// 每条message对象
|
|
73
|
-
var item = {
|
|
74
|
-
content: props.content,
|
|
75
|
-
contentClassName: props.contentClassName,
|
|
76
|
-
id: cachedId,
|
|
77
|
-
onDestroy: props.onDestroy,
|
|
78
|
-
onClose: _onClose,
|
|
79
|
-
timer: null
|
|
80
|
-
};
|
|
81
|
-
// push
|
|
82
|
-
options.push(item);
|
|
83
|
-
// 开始渲染
|
|
84
|
-
render();
|
|
85
|
-
// render后设置自动关闭功能,把定时器绑定到列表
|
|
86
|
-
item.timer = setTimeout(function () {
|
|
87
|
-
_onClose(cachedId);
|
|
88
|
-
}, props.expires || currentConfig.expires);
|
|
89
|
-
return {
|
|
90
|
-
onCloseAll: onCloseAll,
|
|
91
|
-
onClose: function onClose() {
|
|
92
|
-
return _onClose(cachedId);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
Message.setConfig = function (config) {
|
|
97
|
-
currentConfig = __assign(__assign({}, currentConfig), config);
|
|
98
|
-
};
|
|
107
|
+
return Message;
|
|
108
|
+
}();
|
|
109
|
+
export { Message };
|
|
110
|
+
var message = new Message();
|
|
111
|
+
export default message;
|
package/lib/index.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ export type { CheckboxProps } from './checkbox';
|
|
|
38
38
|
export { default as Checkbox } from './checkbox';
|
|
39
39
|
export type { ScriptAttributes, ScriptProps } from './script';
|
|
40
40
|
export { default as Script } from './script';
|
|
41
|
-
export type { MessageProps, MessageConfig } from './message';
|
|
42
|
-
export { default as Message } from './message';
|
|
41
|
+
export type { MessageProps, MessageConfig, MessageResult } from './message';
|
|
42
|
+
export { default as message, Message } from './message';
|
|
43
43
|
export type { TableProps, TableRowSelectionInfo } from './table';
|
|
44
44
|
export type { TableColumnInfo, TableColumnOnRenderReturnObjectInfo } from './table/interface';
|
|
45
45
|
export { default as Table } from './table';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
@@ -109,7 +110,7 @@ Object.defineProperty(exports, "LoadingIcon", {
|
|
|
109
110
|
Object.defineProperty(exports, "Message", {
|
|
110
111
|
enumerable: true,
|
|
111
112
|
get: function get() {
|
|
112
|
-
return _message.
|
|
113
|
+
return _message.Message;
|
|
113
114
|
}
|
|
114
115
|
});
|
|
115
116
|
Object.defineProperty(exports, "Modal", {
|
|
@@ -172,6 +173,12 @@ Object.defineProperty(exports, "Tooltip", {
|
|
|
172
173
|
return _tooltip.default;
|
|
173
174
|
}
|
|
174
175
|
});
|
|
176
|
+
Object.defineProperty(exports, "message", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function get() {
|
|
179
|
+
return _message.default;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
175
182
|
var _accordion = _interopRequireDefault(require("./accordion"));
|
|
176
183
|
var _ellipsis = _interopRequireDefault(require("./ellipsis"));
|
|
177
184
|
var _affix = _interopRequireDefault(require("./affix"));
|
|
@@ -192,11 +199,13 @@ var _lazyImage = _interopRequireDefault(require("./lazy-image"));
|
|
|
192
199
|
var _linkList = _interopRequireDefault(require("./link-list"));
|
|
193
200
|
var _checkbox = _interopRequireDefault(require("./checkbox"));
|
|
194
201
|
var _script = _interopRequireDefault(require("./script"));
|
|
195
|
-
var _message =
|
|
202
|
+
var _message = _interopRequireWildcard(require("./message"));
|
|
196
203
|
var _table = _interopRequireDefault(require("./table"));
|
|
197
204
|
var _datePicker = _interopRequireDefault(require("./date-picker"));
|
|
198
205
|
var _tabs = _interopRequireDefault(require("./tabs"));
|
|
199
206
|
var _loading = _interopRequireDefault(require("./loading"));
|
|
200
207
|
var _loadingContainer = _interopRequireDefault(require("./loading-container"));
|
|
201
208
|
var _loadingBar = _interopRequireDefault(require("./loading-bar"));
|
|
202
|
-
var _loadingIcon = _interopRequireDefault(require("./loading-icon"));
|
|
209
|
+
var _loadingIcon = _interopRequireDefault(require("./loading-icon"));
|
|
210
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
211
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/message/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { MessageItem } from './renderMessage';
|
|
2
3
|
export interface MessageProps {
|
|
3
4
|
/**
|
|
4
5
|
* 提示文字
|
|
5
6
|
*/
|
|
6
|
-
content: React.
|
|
7
|
+
content: React.ReactChild;
|
|
7
8
|
/**
|
|
8
9
|
* 支持多种样式
|
|
9
10
|
*/
|
|
@@ -25,11 +26,36 @@ export interface MessageConfig {
|
|
|
25
26
|
*/
|
|
26
27
|
maxCount?: number;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
onCloseAll: () => void;
|
|
29
|
+
export interface MessageResult {
|
|
30
30
|
onClose: () => void;
|
|
31
|
+
onCloseAll: () => void;
|
|
32
|
+
}
|
|
33
|
+
declare type MessageItemWithTimer = MessageItem & {
|
|
34
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
31
35
|
};
|
|
32
|
-
declare
|
|
33
|
-
|
|
36
|
+
export declare class Message {
|
|
37
|
+
id: number;
|
|
38
|
+
prefixCls: string;
|
|
39
|
+
options: MessageItemWithTimer[];
|
|
40
|
+
config: MessageConfig;
|
|
41
|
+
constructor(config?: MessageConfig & {
|
|
42
|
+
prefixCls?: string;
|
|
43
|
+
});
|
|
44
|
+
private _render;
|
|
45
|
+
/**
|
|
46
|
+
* 关闭指定的一条message
|
|
47
|
+
* @param currentId
|
|
48
|
+
*/
|
|
49
|
+
private _onClose;
|
|
50
|
+
/**
|
|
51
|
+
* 关闭所有message
|
|
52
|
+
*/
|
|
53
|
+
private _onCloseAll;
|
|
54
|
+
setConfig: (config: MessageConfig) => void;
|
|
55
|
+
open: (props: MessageProps) => {
|
|
56
|
+
onCloseAll: () => void;
|
|
57
|
+
onClose: () => void;
|
|
58
|
+
};
|
|
34
59
|
}
|
|
35
|
-
|
|
60
|
+
declare const message: Message;
|
|
61
|
+
export default message;
|
package/lib/message/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = Message;
|
|
7
|
+
exports.default = exports.Message = void 0;
|
|
8
8
|
var _utils = require("@autobest-ui/utils");
|
|
9
9
|
var _renderMessage = _interopRequireDefault(require("./renderMessage"));
|
|
10
10
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
@@ -19,87 +19,101 @@ var __assign = void 0 && (void 0).__assign || function () {
|
|
|
19
19
|
};
|
|
20
20
|
return __assign.apply(this, arguments);
|
|
21
21
|
};
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var currentConfig = {
|
|
27
|
-
expires: 3000,
|
|
28
|
-
maxCount: 3
|
|
29
|
-
};
|
|
30
|
-
function Message(props) {
|
|
31
|
-
if (!_utils.canUseDOM) {
|
|
32
|
-
throw new Error('Message use client!');
|
|
33
|
-
}
|
|
34
|
-
var cachedId = id++;
|
|
35
|
-
function render() {
|
|
36
|
-
(0, _renderMessage.default)({
|
|
37
|
-
prefixCls: prefixCls,
|
|
38
|
-
className: currentConfig.className,
|
|
39
|
-
options: options
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 关闭指定的一条message
|
|
44
|
-
* @param currentId
|
|
45
|
-
*/
|
|
46
|
-
function _onClose(currentId) {
|
|
47
|
-
if ((0, _utils.isEmptyArray)(options)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
var index = options.findIndex(function (item) {
|
|
51
|
-
return item.id === currentId;
|
|
52
|
-
});
|
|
53
|
-
if (index >= 0) {
|
|
54
|
-
clearTimeout(options[index].timer);
|
|
55
|
-
options.splice(index, 1);
|
|
56
|
-
// 关闭需要再渲染一次
|
|
57
|
-
render();
|
|
22
|
+
var Message = /** @class */function () {
|
|
23
|
+
function Message(config) {
|
|
24
|
+
if (config === void 0) {
|
|
25
|
+
config = {};
|
|
58
26
|
}
|
|
27
|
+
var _this = this;
|
|
28
|
+
this.id = 0;
|
|
29
|
+
this.options = [];
|
|
30
|
+
this._render = function () {
|
|
31
|
+
(0, _renderMessage.default)({
|
|
32
|
+
prefixCls: _this.prefixCls,
|
|
33
|
+
className: _this.config.className,
|
|
34
|
+
options: _this.options
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 关闭指定的一条message
|
|
39
|
+
* @param currentId
|
|
40
|
+
*/
|
|
41
|
+
this._onClose = function (currentId) {
|
|
42
|
+
if ((0, _utils.isEmptyArray)(_this.options)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var index = _this.options.findIndex(function (item) {
|
|
46
|
+
return item.id === currentId;
|
|
47
|
+
});
|
|
48
|
+
if (index >= 0) {
|
|
49
|
+
clearTimeout(_this.options[index].timer);
|
|
50
|
+
_this.options.splice(index, 1);
|
|
51
|
+
// 关闭需要再渲染一次
|
|
52
|
+
_this._render();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* 关闭所有message
|
|
57
|
+
*/
|
|
58
|
+
this._onCloseAll = function () {
|
|
59
|
+
if ((0, _utils.isEmptyArray)(_this.options)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
_this.options.forEach(function (child) {
|
|
63
|
+
clearTimeout(child.timer);
|
|
64
|
+
});
|
|
65
|
+
_this.options = [];
|
|
66
|
+
_this._render();
|
|
67
|
+
};
|
|
68
|
+
this.setConfig = function (config) {
|
|
69
|
+
_this.config = __assign({
|
|
70
|
+
expires: 3000,
|
|
71
|
+
maxCount: 3
|
|
72
|
+
}, config);
|
|
73
|
+
};
|
|
74
|
+
this.open = function (props) {
|
|
75
|
+
if (!_utils.canUseDOM) {
|
|
76
|
+
throw new Error('Message use client!');
|
|
77
|
+
}
|
|
78
|
+
_this.id++;
|
|
79
|
+
var currentId = _this.id;
|
|
80
|
+
/**
|
|
81
|
+
* 超出条数,将删除最旧的那条message
|
|
82
|
+
*/
|
|
83
|
+
if (_this.options.length >= _this.config.maxCount) {
|
|
84
|
+
_this._onClose(_this.options[0].id);
|
|
85
|
+
}
|
|
86
|
+
// 每条message对象
|
|
87
|
+
var item = {
|
|
88
|
+
content: props.content,
|
|
89
|
+
contentClassName: props.contentClassName,
|
|
90
|
+
id: currentId,
|
|
91
|
+
onDestroy: props.onDestroy,
|
|
92
|
+
onClose: _this._onClose,
|
|
93
|
+
timer: null
|
|
94
|
+
};
|
|
95
|
+
// push
|
|
96
|
+
_this.options.push(item);
|
|
97
|
+
// 开始渲染
|
|
98
|
+
_this._render();
|
|
99
|
+
// render后设置自动关闭功能,把定时器绑定到列表
|
|
100
|
+
item.timer = setTimeout(function () {
|
|
101
|
+
_this._onClose(currentId);
|
|
102
|
+
}, props.expires || _this.config.expires);
|
|
103
|
+
return {
|
|
104
|
+
onCloseAll: _this._onCloseAll,
|
|
105
|
+
onClose: function onClose() {
|
|
106
|
+
return _this._onClose(currentId);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
this.prefixCls = config.prefixCls || 'ab-message';
|
|
111
|
+
delete config.prefixCls;
|
|
112
|
+
this.setConfig(__assign({}, config));
|
|
59
113
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
options.forEach(function (child) {
|
|
68
|
-
clearTimeout(child.timer);
|
|
69
|
-
});
|
|
70
|
-
options = [];
|
|
71
|
-
render();
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* 超出条数,将删除最旧的那条message
|
|
75
|
-
*/
|
|
76
|
-
if (options.length >= currentConfig.maxCount) {
|
|
77
|
-
_onClose(options[0].id);
|
|
78
|
-
}
|
|
79
|
-
// 每条message对象
|
|
80
|
-
var item = {
|
|
81
|
-
content: props.content,
|
|
82
|
-
contentClassName: props.contentClassName,
|
|
83
|
-
id: cachedId,
|
|
84
|
-
onDestroy: props.onDestroy,
|
|
85
|
-
onClose: _onClose,
|
|
86
|
-
timer: null
|
|
87
|
-
};
|
|
88
|
-
// push
|
|
89
|
-
options.push(item);
|
|
90
|
-
// 开始渲染
|
|
91
|
-
render();
|
|
92
|
-
// render后设置自动关闭功能,把定时器绑定到列表
|
|
93
|
-
item.timer = setTimeout(function () {
|
|
94
|
-
_onClose(cachedId);
|
|
95
|
-
}, props.expires || currentConfig.expires);
|
|
96
|
-
return {
|
|
97
|
-
onCloseAll: onCloseAll,
|
|
98
|
-
onClose: function onClose() {
|
|
99
|
-
return _onClose(cachedId);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
Message.setConfig = function (config) {
|
|
104
|
-
currentConfig = __assign(__assign({}, currentConfig), config);
|
|
105
|
-
};
|
|
114
|
+
return Message;
|
|
115
|
+
}();
|
|
116
|
+
exports.Message = Message;
|
|
117
|
+
var message = new Message();
|
|
118
|
+
var _default = message;
|
|
119
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobest-ui/components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "components common ui for React",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@autobest-ui/utils": "^2.1.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "9b8f5b76f9bd726e24416b7992f2667a5d6b202d"
|
|
56
56
|
}
|