@etsoo/notificationbase 1.1.39 → 1.1.41
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/__tests__/tsconfig.json +3 -4
- package/babel.config.json +11 -0
- package/lib/cjs/Notification.js +149 -0
- package/lib/cjs/NotificationContainer.js +302 -0
- package/lib/cjs/index.js +18 -0
- package/lib/mjs/Notification.d.ts +328 -0
- package/lib/mjs/NotificationContainer.d.ts +250 -0
- package/lib/mjs/index.js +2 -0
- package/package.json +12 -5
- package/tsconfig.cjs.json +17 -0
- package/tsconfig.json +2 -2
- package/babel.config.js +0 -11
- /package/lib/{Notification.d.ts → cjs/Notification.d.ts} +0 -0
- /package/lib/{NotificationContainer.d.ts → cjs/NotificationContainer.d.ts} +0 -0
- /package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/lib/{Notification.js → mjs/Notification.js} +0 -0
- /package/lib/{NotificationContainer.js → mjs/NotificationContainer.js} +0 -0
- /package/lib/{index.js → mjs/index.d.ts} +0 -0
package/__tests__/tsconfig.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2020",
|
|
4
4
|
"module": "ESNext",
|
|
5
|
-
"
|
|
5
|
+
"moduleResolution": "Node10",
|
|
6
|
+
"allowJs": false,
|
|
6
7
|
"skipLibCheck": true,
|
|
7
8
|
"esModuleInterop": true,
|
|
8
9
|
"allowSyntheticDefaultImports": true,
|
|
9
10
|
"strict": true,
|
|
10
11
|
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"moduleResolution": "node",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
12
|
"isolatedModules": true,
|
|
14
13
|
"noEmit": true,
|
|
15
14
|
"declaration": true
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Notification = exports.NotificationType = exports.NotificationMessageType = exports.NotificationModalType = exports.NotificationAlign = void 0;
|
|
4
|
+
const shared_1 = require("@etsoo/shared");
|
|
5
|
+
// https://devimalplanet.com/typescript-how-to-extend-one-enum-from-another
|
|
6
|
+
// Number index keys are still there
|
|
7
|
+
const { MiddleLeft, MiddleRight, ...alignItems } = shared_1.DataTypes.PlacementEnum;
|
|
8
|
+
const newItems = {
|
|
9
|
+
...alignItems
|
|
10
|
+
};
|
|
11
|
+
delete newItems[MiddleLeft];
|
|
12
|
+
delete newItems[MiddleRight];
|
|
13
|
+
/**
|
|
14
|
+
* Display align
|
|
15
|
+
*/
|
|
16
|
+
exports.NotificationAlign = {
|
|
17
|
+
...newItems
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Modal types
|
|
21
|
+
*/
|
|
22
|
+
var NotificationModalType;
|
|
23
|
+
(function (NotificationModalType) {
|
|
24
|
+
NotificationModalType[NotificationModalType["Loading"] = 0] = "Loading";
|
|
25
|
+
NotificationModalType[NotificationModalType["Confirm"] = 1] = "Confirm";
|
|
26
|
+
NotificationModalType[NotificationModalType["Prompt"] = 2] = "Prompt";
|
|
27
|
+
NotificationModalType[NotificationModalType["Error"] = 3] = "Error";
|
|
28
|
+
NotificationModalType[NotificationModalType["Popup"] = 6] = "Popup";
|
|
29
|
+
})(NotificationModalType || (exports.NotificationModalType = NotificationModalType = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Message types
|
|
32
|
+
*/
|
|
33
|
+
var NotificationMessageType;
|
|
34
|
+
(function (NotificationMessageType) {
|
|
35
|
+
NotificationMessageType[NotificationMessageType["Default"] = 10] = "Default";
|
|
36
|
+
NotificationMessageType[NotificationMessageType["Success"] = 11] = "Success";
|
|
37
|
+
NotificationMessageType[NotificationMessageType["Warning"] = 12] = "Warning";
|
|
38
|
+
NotificationMessageType[NotificationMessageType["Info"] = 13] = "Info";
|
|
39
|
+
NotificationMessageType[NotificationMessageType["Danger"] = 14] = "Danger"; // Error
|
|
40
|
+
})(NotificationMessageType || (exports.NotificationMessageType = NotificationMessageType = {}));
|
|
41
|
+
/**
|
|
42
|
+
* Merged type definition below together
|
|
43
|
+
*/
|
|
44
|
+
exports.NotificationType = {
|
|
45
|
+
...NotificationModalType,
|
|
46
|
+
...NotificationMessageType
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Notification class
|
|
50
|
+
* Generic parameter UI presents UI element type
|
|
51
|
+
*/
|
|
52
|
+
class Notification {
|
|
53
|
+
/**
|
|
54
|
+
* Is open or not
|
|
55
|
+
*/
|
|
56
|
+
get open() {
|
|
57
|
+
return this._open;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Constructor
|
|
61
|
+
* @param type Type
|
|
62
|
+
* @param content Content
|
|
63
|
+
* @param title Title
|
|
64
|
+
* @param align Align
|
|
65
|
+
* @param timespan Timespan
|
|
66
|
+
*/
|
|
67
|
+
constructor(type, content, title, align, timespan) {
|
|
68
|
+
/**
|
|
69
|
+
* Dismiss timeout seed
|
|
70
|
+
*/
|
|
71
|
+
this.dismissSeed = 0;
|
|
72
|
+
this._open = true;
|
|
73
|
+
this.id = shared_1.Utils.newGUID();
|
|
74
|
+
this.type = type;
|
|
75
|
+
this.content = content;
|
|
76
|
+
this.title = title;
|
|
77
|
+
// Modal type
|
|
78
|
+
this.modal = type in NotificationModalType;
|
|
79
|
+
// Align, only available for none modal
|
|
80
|
+
if (this.modal)
|
|
81
|
+
this.align = exports.NotificationAlign.Unknown;
|
|
82
|
+
else if (align != null)
|
|
83
|
+
this.align = align;
|
|
84
|
+
// Message align default to top left
|
|
85
|
+
else if (type in NotificationMessageType)
|
|
86
|
+
this.align = exports.NotificationAlign.TopLeft;
|
|
87
|
+
else
|
|
88
|
+
this.align = exports.NotificationAlign.Center;
|
|
89
|
+
// Display as modal will lasts otherwise 5 seconds to dismiss it
|
|
90
|
+
this.timespan = timespan ?? (this.modal ? 0 : 5);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Dismiss it
|
|
94
|
+
* @param delaySeconds Delay seconds
|
|
95
|
+
* @param noTrigger No onReturn trigger
|
|
96
|
+
* @returns Is delayed or not
|
|
97
|
+
*/
|
|
98
|
+
dismiss(delaySeconds = 0, noTrigger = false) {
|
|
99
|
+
// If it's closed, return
|
|
100
|
+
if (!this._open)
|
|
101
|
+
return false;
|
|
102
|
+
if (delaySeconds > 0) {
|
|
103
|
+
this.removeTimeout();
|
|
104
|
+
this.dismissSeed = window.setTimeout(this.dismiss.bind(this), delaySeconds * 1000, 0 // force to dismiss
|
|
105
|
+
);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
// For message, call onReturn
|
|
109
|
+
if (!noTrigger &&
|
|
110
|
+
this.onReturn != null &&
|
|
111
|
+
this.type in NotificationMessageType) {
|
|
112
|
+
this.onReturn(undefined);
|
|
113
|
+
}
|
|
114
|
+
// Indicate closed
|
|
115
|
+
this._open = false;
|
|
116
|
+
if (this.onDismiss)
|
|
117
|
+
this.onDismiss();
|
|
118
|
+
this.dispose();
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
// Remove possible dismiss timeout
|
|
122
|
+
removeTimeout() {
|
|
123
|
+
if (this.dismissSeed > 0) {
|
|
124
|
+
clearTimeout(this.dismissSeed);
|
|
125
|
+
this.dismissSeed = 0;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Dispose it
|
|
130
|
+
*/
|
|
131
|
+
dispose() {
|
|
132
|
+
this.removeTimeout();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Return value
|
|
136
|
+
* Dismiss first, then run callback
|
|
137
|
+
* @param value
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
140
|
+
async returnValue(value) {
|
|
141
|
+
if (this.onReturn) {
|
|
142
|
+
const result = await this.onReturn(value);
|
|
143
|
+
if (result === false)
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.dismiss(0, true);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.Notification = Notification;
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationContainer = void 0;
|
|
4
|
+
const Notification_1 = require("./Notification");
|
|
5
|
+
/**
|
|
6
|
+
* Notification container class
|
|
7
|
+
*/
|
|
8
|
+
class NotificationContainer {
|
|
9
|
+
/**
|
|
10
|
+
* Is loading bar showing
|
|
11
|
+
*/
|
|
12
|
+
get isLoading() {
|
|
13
|
+
return this.notifications[Notification_1.NotificationAlign.Unknown].some((n) => n.open && n.type === Notification_1.NotificationModalType.Loading);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Is model window showing
|
|
17
|
+
*/
|
|
18
|
+
get isModeling() {
|
|
19
|
+
return this.alignOpenCount(Notification_1.NotificationAlign.Unknown) > 0;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor(update) {
|
|
25
|
+
this.loadingCount = 0;
|
|
26
|
+
// Update callback
|
|
27
|
+
this.update = update;
|
|
28
|
+
// Init notification collection
|
|
29
|
+
this.notifications = {};
|
|
30
|
+
for (const align in Notification_1.NotificationAlign) {
|
|
31
|
+
if (!isNaN(Number(align)))
|
|
32
|
+
this.notifications[align] = [];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Add notification
|
|
37
|
+
* @param notification Notification
|
|
38
|
+
* @param top Is insert top
|
|
39
|
+
*/
|
|
40
|
+
add(notification, top = false) {
|
|
41
|
+
// Align collection
|
|
42
|
+
const alignItems = this.notifications[notification.align];
|
|
43
|
+
// Support dismiss action
|
|
44
|
+
const { timespan, onDismiss } = notification;
|
|
45
|
+
notification.onDismiss = () => {
|
|
46
|
+
// Remove from the collection
|
|
47
|
+
const index = alignItems.findIndex((item) => item.id === notification.id);
|
|
48
|
+
if (index > -1)
|
|
49
|
+
alignItems.splice(index, 1);
|
|
50
|
+
// Call the registered callback
|
|
51
|
+
this.doRegister(notification, true);
|
|
52
|
+
// Custom onDismiss callback
|
|
53
|
+
if (onDismiss)
|
|
54
|
+
onDismiss();
|
|
55
|
+
};
|
|
56
|
+
// Add to the collection
|
|
57
|
+
if (top)
|
|
58
|
+
alignItems.unshift(notification);
|
|
59
|
+
else
|
|
60
|
+
alignItems.push(notification);
|
|
61
|
+
// Call the registered callback
|
|
62
|
+
this.doRegister(notification, false);
|
|
63
|
+
// Auto dismiss in timespan seconds
|
|
64
|
+
if (timespan > 0)
|
|
65
|
+
notification.dismiss(timespan);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Align all notification count
|
|
69
|
+
* @param align Align
|
|
70
|
+
*/
|
|
71
|
+
alignCount(align) {
|
|
72
|
+
return this.notifications[align].length;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Align open notification count
|
|
76
|
+
* @param align Align
|
|
77
|
+
*/
|
|
78
|
+
alignOpenCount(align) {
|
|
79
|
+
const items = this.notifications[align];
|
|
80
|
+
return items.filter((item) => item.open).length;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove all closed notification
|
|
84
|
+
*/
|
|
85
|
+
clear() {
|
|
86
|
+
for (const align in this.notifications) {
|
|
87
|
+
// Align items
|
|
88
|
+
const items = this.notifications[align];
|
|
89
|
+
// Loop to remove closed item
|
|
90
|
+
const len = items.length - 1;
|
|
91
|
+
for (let n = len; n >= 0; n--) {
|
|
92
|
+
const notification = items[n];
|
|
93
|
+
if (!notification.open) {
|
|
94
|
+
notification.dispose();
|
|
95
|
+
items.splice(n, 1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Dispose all notifications
|
|
102
|
+
*/
|
|
103
|
+
dispose() {
|
|
104
|
+
for (const align in this.notifications) {
|
|
105
|
+
// Align items
|
|
106
|
+
const items = this.notifications[align];
|
|
107
|
+
items.forEach((item) => item.dispose());
|
|
108
|
+
// Reset
|
|
109
|
+
this.notifications[align] = [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Call register callback
|
|
114
|
+
* @param id Notification id
|
|
115
|
+
* @param dismiss Is dismiss
|
|
116
|
+
*/
|
|
117
|
+
doRegister(item, dismiss) {
|
|
118
|
+
// Call
|
|
119
|
+
this.update(item, dismiss);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get notification with align and id
|
|
123
|
+
* @param align Align
|
|
124
|
+
* @param id Notification id
|
|
125
|
+
*/
|
|
126
|
+
get(align, id) {
|
|
127
|
+
const items = this.notifications[align];
|
|
128
|
+
return items.find((item) => item.id === id);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get notification with id
|
|
132
|
+
* @param id Notification id
|
|
133
|
+
*/
|
|
134
|
+
getById(id) {
|
|
135
|
+
for (const align in Object.keys(Notification_1.NotificationAlign)) {
|
|
136
|
+
var item = this.get(align, id);
|
|
137
|
+
if (item != null)
|
|
138
|
+
return item;
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Report error or message
|
|
144
|
+
* @param errorOrTitle Error message or title
|
|
145
|
+
* @param callback Callback
|
|
146
|
+
* @param type Type, default is Error
|
|
147
|
+
* @param props Props
|
|
148
|
+
*/
|
|
149
|
+
alert(errorOrTitle, callback, type, props) {
|
|
150
|
+
// Parse messange and title
|
|
151
|
+
let error, title;
|
|
152
|
+
if (Array.isArray(errorOrTitle)) {
|
|
153
|
+
error = errorOrTitle[0];
|
|
154
|
+
title = errorOrTitle[1];
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
error = errorOrTitle;
|
|
158
|
+
}
|
|
159
|
+
// Setup
|
|
160
|
+
const n = {
|
|
161
|
+
inputProps: props,
|
|
162
|
+
type: type ?? Notification_1.NotificationType.Error,
|
|
163
|
+
title,
|
|
164
|
+
content: error,
|
|
165
|
+
onReturn: callback
|
|
166
|
+
};
|
|
167
|
+
// Add to the collection
|
|
168
|
+
return this.addRaw(n, true);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Confirm action
|
|
172
|
+
* @param message Message
|
|
173
|
+
* @param title Title
|
|
174
|
+
* @param callback Callback
|
|
175
|
+
* @param props Props
|
|
176
|
+
*/
|
|
177
|
+
confirm(message, title, callback, props) {
|
|
178
|
+
// Setup
|
|
179
|
+
const n = {
|
|
180
|
+
type: Notification_1.NotificationType.Confirm,
|
|
181
|
+
content: message,
|
|
182
|
+
title,
|
|
183
|
+
onReturn: callback,
|
|
184
|
+
inputProps: props
|
|
185
|
+
};
|
|
186
|
+
// Add to the collection
|
|
187
|
+
return this.addRaw(n);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Hide loading
|
|
191
|
+
* @param force Force to hide, otherwise, only the last one
|
|
192
|
+
*/
|
|
193
|
+
hideLoading(force) {
|
|
194
|
+
// Deduct to count
|
|
195
|
+
this.loadingCount--;
|
|
196
|
+
if (force)
|
|
197
|
+
this.loadingCount = 0;
|
|
198
|
+
if (this.loadingCount === 0) {
|
|
199
|
+
this.lastLoading?.dismiss();
|
|
200
|
+
this.lastLoading = undefined;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Show a message
|
|
205
|
+
* @param type Message type
|
|
206
|
+
* @param message Message
|
|
207
|
+
* @param title Title
|
|
208
|
+
* @param parameters Parameters
|
|
209
|
+
* @param props Props
|
|
210
|
+
*/
|
|
211
|
+
message(type, message, title, parameters, props) {
|
|
212
|
+
// Destruct
|
|
213
|
+
const { align, timespan, callback, modal } = parameters ?? {};
|
|
214
|
+
// Setup
|
|
215
|
+
const n = {
|
|
216
|
+
type,
|
|
217
|
+
content: message,
|
|
218
|
+
title,
|
|
219
|
+
align,
|
|
220
|
+
timespan,
|
|
221
|
+
onReturn: callback,
|
|
222
|
+
inputProps: props
|
|
223
|
+
};
|
|
224
|
+
// Add to the collection
|
|
225
|
+
return this.addRaw(n, modal);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Prompt action
|
|
229
|
+
* @param message Message
|
|
230
|
+
* @param callback Callback
|
|
231
|
+
* @param title Title
|
|
232
|
+
* @param props More properties
|
|
233
|
+
*/
|
|
234
|
+
prompt(message, callback, title, props) {
|
|
235
|
+
// Setup
|
|
236
|
+
const n = {
|
|
237
|
+
type: Notification_1.NotificationType.Prompt,
|
|
238
|
+
content: message,
|
|
239
|
+
title,
|
|
240
|
+
inputProps: props,
|
|
241
|
+
onReturn: callback
|
|
242
|
+
};
|
|
243
|
+
// Add to the collection
|
|
244
|
+
return this.addRaw(n);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Show loading
|
|
248
|
+
* @param title Title
|
|
249
|
+
*/
|
|
250
|
+
showLoading(title) {
|
|
251
|
+
// Add to count
|
|
252
|
+
this.loadingCount++;
|
|
253
|
+
if (this.lastLoading == null) {
|
|
254
|
+
// Setup
|
|
255
|
+
const n = {
|
|
256
|
+
type: Notification_1.NotificationType.Loading,
|
|
257
|
+
content: title ?? ''
|
|
258
|
+
};
|
|
259
|
+
// Add to the collection
|
|
260
|
+
// Keep the reference
|
|
261
|
+
this.lastLoading = this.addRaw(n);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Popup component as modal
|
|
266
|
+
* @param component Component to popup
|
|
267
|
+
* @param properties Popup properties
|
|
268
|
+
* @returns Result
|
|
269
|
+
*/
|
|
270
|
+
popup(component, properties) {
|
|
271
|
+
// Setup
|
|
272
|
+
const n = {
|
|
273
|
+
type: Notification_1.NotificationType.Popup,
|
|
274
|
+
content: component,
|
|
275
|
+
renderSetup: (_options) => {
|
|
276
|
+
return properties;
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
// Add to the collection
|
|
280
|
+
return this.addRaw(n);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Show a success message
|
|
284
|
+
* @param message Message
|
|
285
|
+
* @param title Title
|
|
286
|
+
* @param callback Callback
|
|
287
|
+
* @param timespan Timespan to close
|
|
288
|
+
* @param props Props
|
|
289
|
+
*/
|
|
290
|
+
succeed(message, title, callback, timespan, props) {
|
|
291
|
+
// Default to zero for constant
|
|
292
|
+
timespan ?? (timespan = 0);
|
|
293
|
+
// Create as message
|
|
294
|
+
return this.message(Notification_1.NotificationMessageType.Success, message, title, {
|
|
295
|
+
align: Notification_1.NotificationAlign.Center,
|
|
296
|
+
modal: true,
|
|
297
|
+
timespan,
|
|
298
|
+
callback
|
|
299
|
+
}, props);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
exports.NotificationContainer = NotificationContainer;
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Notification"), exports);
|
|
18
|
+
__exportStar(require("./NotificationContainer"), exports);
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Display align
|
|
4
|
+
*/
|
|
5
|
+
export declare const NotificationAlign: {
|
|
6
|
+
[x: number]: string;
|
|
7
|
+
TopLeft: DataTypes.PlacementEnum.TopLeft;
|
|
8
|
+
TopCenter: DataTypes.PlacementEnum.TopCenter;
|
|
9
|
+
TopRight: DataTypes.PlacementEnum.TopRight;
|
|
10
|
+
Center: DataTypes.PlacementEnum.Center;
|
|
11
|
+
BottomLeft: DataTypes.PlacementEnum.BottomLeft;
|
|
12
|
+
BottomCenter: DataTypes.PlacementEnum.BottomCenter;
|
|
13
|
+
BottomRight: DataTypes.PlacementEnum.BottomRight;
|
|
14
|
+
Unknown: DataTypes.PlacementEnum.Unknown;
|
|
15
|
+
};
|
|
16
|
+
export type NotificationAlign = Exclude<DataTypes.PlacementEnum, DataTypes.PlacementEnum.MiddleLeft | DataTypes.PlacementEnum.MiddleRight>;
|
|
17
|
+
/**
|
|
18
|
+
* Modal types
|
|
19
|
+
*/
|
|
20
|
+
export declare enum NotificationModalType {
|
|
21
|
+
Loading = 0,
|
|
22
|
+
Confirm = 1,
|
|
23
|
+
Prompt = 2,
|
|
24
|
+
Error = 3,// Alert
|
|
25
|
+
Popup = 6
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Message types
|
|
29
|
+
*/
|
|
30
|
+
export declare enum NotificationMessageType {
|
|
31
|
+
Default = 10,// No default then refer to Info
|
|
32
|
+
Success = 11,
|
|
33
|
+
Warning = 12,
|
|
34
|
+
Info = 13,
|
|
35
|
+
Danger = 14
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Merged type definition below together
|
|
39
|
+
*/
|
|
40
|
+
export declare const NotificationType: {
|
|
41
|
+
[x: number]: string;
|
|
42
|
+
Default: NotificationMessageType.Default;
|
|
43
|
+
Success: NotificationMessageType.Success;
|
|
44
|
+
Warning: NotificationMessageType.Warning;
|
|
45
|
+
Info: NotificationMessageType.Info;
|
|
46
|
+
Danger: NotificationMessageType.Danger;
|
|
47
|
+
Loading: NotificationModalType.Loading;
|
|
48
|
+
Confirm: NotificationModalType.Confirm;
|
|
49
|
+
Prompt: NotificationModalType.Prompt;
|
|
50
|
+
Error: NotificationModalType.Error;
|
|
51
|
+
Popup: NotificationModalType.Popup;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Notification types
|
|
55
|
+
*/
|
|
56
|
+
export type NotificationType = NotificationModalType | NotificationMessageType;
|
|
57
|
+
/**
|
|
58
|
+
* Notification content
|
|
59
|
+
*/
|
|
60
|
+
export type NotificationContent<UI> = string | UI;
|
|
61
|
+
/**
|
|
62
|
+
* On dismiss callback
|
|
63
|
+
*/
|
|
64
|
+
export interface NotificationDismiss {
|
|
65
|
+
(): void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Notification reander setup
|
|
69
|
+
*/
|
|
70
|
+
export interface NotifictionRenderSetup {
|
|
71
|
+
(options: any): any;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* On return callback
|
|
75
|
+
* T = string | undefined, Undefined value means cancel
|
|
76
|
+
* return false will prevent default action
|
|
77
|
+
* return string is the error message to show
|
|
78
|
+
*/
|
|
79
|
+
export interface NotificationReturn<T> {
|
|
80
|
+
(value: T): boolean | string | void | PromiseLike<boolean | string | void>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Notification message parameters
|
|
84
|
+
*/
|
|
85
|
+
export interface NotificationParameters {
|
|
86
|
+
/**
|
|
87
|
+
* Display align
|
|
88
|
+
*/
|
|
89
|
+
align?: NotificationAlign;
|
|
90
|
+
/**
|
|
91
|
+
* Callback
|
|
92
|
+
*/
|
|
93
|
+
callback?: NotificationReturn<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Show as modal
|
|
96
|
+
*/
|
|
97
|
+
modal?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Time span to dismiss
|
|
100
|
+
*/
|
|
101
|
+
timespan?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Add to the top
|
|
104
|
+
*/
|
|
105
|
+
top?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Notification props supported for calls
|
|
109
|
+
*/
|
|
110
|
+
export type NotificationCallProps = {
|
|
111
|
+
/**
|
|
112
|
+
* Input component properties
|
|
113
|
+
*/
|
|
114
|
+
inputProps?: DataTypes.StringRecord;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Notification render props
|
|
118
|
+
*/
|
|
119
|
+
export type NotificationRenderProps = DataTypes.StringRecord;
|
|
120
|
+
/**
|
|
121
|
+
* Notification base interface
|
|
122
|
+
*/
|
|
123
|
+
export interface INotificaseBase<UI, C extends NotificationCallProps = {}> {
|
|
124
|
+
/**
|
|
125
|
+
* Display align
|
|
126
|
+
*/
|
|
127
|
+
readonly align?: NotificationAlign;
|
|
128
|
+
/**
|
|
129
|
+
* Content
|
|
130
|
+
*/
|
|
131
|
+
readonly content: NotificationContent<UI>;
|
|
132
|
+
/**
|
|
133
|
+
* Input or control properties
|
|
134
|
+
*/
|
|
135
|
+
inputProps?: C;
|
|
136
|
+
/**
|
|
137
|
+
* On dismiss handling
|
|
138
|
+
*/
|
|
139
|
+
onDismiss?: NotificationDismiss;
|
|
140
|
+
/**
|
|
141
|
+
* On return value
|
|
142
|
+
*/
|
|
143
|
+
onReturn?: NotificationReturn<any>;
|
|
144
|
+
/**
|
|
145
|
+
* Show the icon or hide it
|
|
146
|
+
*/
|
|
147
|
+
showIcon?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Seconds to auto dismiss
|
|
150
|
+
*/
|
|
151
|
+
timespan?: number;
|
|
152
|
+
/**
|
|
153
|
+
* Render setup / callback
|
|
154
|
+
* Add more properties
|
|
155
|
+
*/
|
|
156
|
+
renderSetup?: NotifictionRenderSetup;
|
|
157
|
+
/**
|
|
158
|
+
* Title
|
|
159
|
+
*/
|
|
160
|
+
readonly title?: NotificationContent<UI>;
|
|
161
|
+
/**
|
|
162
|
+
* Type
|
|
163
|
+
*/
|
|
164
|
+
readonly type: NotificationType;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Notification interface
|
|
168
|
+
*/
|
|
169
|
+
export interface INotification<UI, C extends NotificationCallProps> extends INotificaseBase<UI, C> {
|
|
170
|
+
/**
|
|
171
|
+
* Display align
|
|
172
|
+
*/
|
|
173
|
+
readonly align: NotificationAlign;
|
|
174
|
+
/**
|
|
175
|
+
* Seconds to auto dismiss
|
|
176
|
+
*/
|
|
177
|
+
timespan: number;
|
|
178
|
+
/**
|
|
179
|
+
* Unique id
|
|
180
|
+
*/
|
|
181
|
+
readonly id: string;
|
|
182
|
+
/**
|
|
183
|
+
* Display as modal
|
|
184
|
+
*/
|
|
185
|
+
modal: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Is open or not
|
|
188
|
+
*/
|
|
189
|
+
readonly open: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Reference
|
|
192
|
+
*/
|
|
193
|
+
ref?: any;
|
|
194
|
+
/**
|
|
195
|
+
* Content
|
|
196
|
+
*/
|
|
197
|
+
readonly content: NotificationContent<UI>;
|
|
198
|
+
/**
|
|
199
|
+
* Title
|
|
200
|
+
*/
|
|
201
|
+
readonly title?: NotificationContent<UI>;
|
|
202
|
+
/**
|
|
203
|
+
* Dismiss it
|
|
204
|
+
* @param delaySeconds Delay seconds
|
|
205
|
+
* @param noTrigger No onReturn trigger
|
|
206
|
+
* @returns Is delayed or not
|
|
207
|
+
*/
|
|
208
|
+
dismiss(delaySeconds?: number, noTrigger?: boolean): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Dispose it
|
|
211
|
+
*/
|
|
212
|
+
dispose(): void;
|
|
213
|
+
/**
|
|
214
|
+
* Render method
|
|
215
|
+
* @param props Props
|
|
216
|
+
* @param className Style class name
|
|
217
|
+
* @param options Other options
|
|
218
|
+
*/
|
|
219
|
+
render(props: NotificationRenderProps, className?: string): UI | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Return value
|
|
222
|
+
* Dismiss first, then run callback
|
|
223
|
+
* @param value
|
|
224
|
+
* @returns
|
|
225
|
+
*/
|
|
226
|
+
returnValue(value: any): Promise<void>;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Notification class
|
|
230
|
+
* Generic parameter UI presents UI element type
|
|
231
|
+
*/
|
|
232
|
+
export declare abstract class Notification<UI, C extends NotificationCallProps> implements INotification<UI, C> {
|
|
233
|
+
/**
|
|
234
|
+
* Display align
|
|
235
|
+
*/
|
|
236
|
+
readonly align: NotificationAlign;
|
|
237
|
+
/**
|
|
238
|
+
* Content
|
|
239
|
+
*/
|
|
240
|
+
readonly content: NotificationContent<UI>;
|
|
241
|
+
/**
|
|
242
|
+
* Dismiss timeout seed
|
|
243
|
+
*/
|
|
244
|
+
private dismissSeed;
|
|
245
|
+
/**
|
|
246
|
+
* Unique id
|
|
247
|
+
*/
|
|
248
|
+
readonly id: string;
|
|
249
|
+
/**
|
|
250
|
+
* Input or control properties
|
|
251
|
+
*/
|
|
252
|
+
inputProps?: C;
|
|
253
|
+
/**
|
|
254
|
+
* Display as modal
|
|
255
|
+
*/
|
|
256
|
+
modal: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* On dismiss handling
|
|
259
|
+
*/
|
|
260
|
+
onDismiss?: NotificationDismiss;
|
|
261
|
+
/**
|
|
262
|
+
* On return value
|
|
263
|
+
*/
|
|
264
|
+
onReturn?: NotificationReturn<unknown>;
|
|
265
|
+
private _open;
|
|
266
|
+
/**
|
|
267
|
+
* Is open or not
|
|
268
|
+
*/
|
|
269
|
+
get open(): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Reference
|
|
272
|
+
*/
|
|
273
|
+
ref?: any;
|
|
274
|
+
/**
|
|
275
|
+
* Render setup / callback
|
|
276
|
+
*/
|
|
277
|
+
renderSetup?: NotifictionRenderSetup;
|
|
278
|
+
/**
|
|
279
|
+
* Show the icon or hide it
|
|
280
|
+
*/
|
|
281
|
+
showIcon?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* Seconds to auto dismiss
|
|
284
|
+
*/
|
|
285
|
+
timespan: number;
|
|
286
|
+
/**
|
|
287
|
+
* Title
|
|
288
|
+
*/
|
|
289
|
+
readonly title?: NotificationContent<UI>;
|
|
290
|
+
/**
|
|
291
|
+
* Type
|
|
292
|
+
*/
|
|
293
|
+
readonly type: NotificationType;
|
|
294
|
+
/**
|
|
295
|
+
* Constructor
|
|
296
|
+
* @param type Type
|
|
297
|
+
* @param content Content
|
|
298
|
+
* @param title Title
|
|
299
|
+
* @param align Align
|
|
300
|
+
* @param timespan Timespan
|
|
301
|
+
*/
|
|
302
|
+
constructor(type: NotificationType, content: NotificationContent<UI>, title?: NotificationContent<UI>, align?: NotificationAlign, timespan?: number);
|
|
303
|
+
/**
|
|
304
|
+
* Dismiss it
|
|
305
|
+
* @param delaySeconds Delay seconds
|
|
306
|
+
* @param noTrigger No onReturn trigger
|
|
307
|
+
* @returns Is delayed or not
|
|
308
|
+
*/
|
|
309
|
+
dismiss(delaySeconds?: number, noTrigger?: boolean): boolean;
|
|
310
|
+
private removeTimeout;
|
|
311
|
+
/**
|
|
312
|
+
* Dispose it
|
|
313
|
+
*/
|
|
314
|
+
dispose(): void;
|
|
315
|
+
/**
|
|
316
|
+
* Render method
|
|
317
|
+
* @param props Props, provider's UI props
|
|
318
|
+
* @param className Style class name
|
|
319
|
+
*/
|
|
320
|
+
abstract render(props: NotificationRenderProps, className?: string): UI | undefined;
|
|
321
|
+
/**
|
|
322
|
+
* Return value
|
|
323
|
+
* Dismiss first, then run callback
|
|
324
|
+
* @param value
|
|
325
|
+
* @returns
|
|
326
|
+
*/
|
|
327
|
+
returnValue(value: any): Promise<void>;
|
|
328
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { INotificaseBase, INotification, NotificationAlign, NotificationCallProps, NotificationContent, NotificationMessageType, NotificationParameters, NotificationReturn } from './Notification';
|
|
2
|
+
/**
|
|
3
|
+
* Notification action
|
|
4
|
+
*/
|
|
5
|
+
export interface NotificationAction<UI, C extends NotificationCallProps> {
|
|
6
|
+
(notification: INotification<UI, C>, dismiss: boolean): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Notifications sorted with display align type
|
|
10
|
+
*/
|
|
11
|
+
export type NotificationDictionary<UI, C extends NotificationCallProps> = {
|
|
12
|
+
[key: number]: INotification<UI, C>[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Notifier interface
|
|
16
|
+
*/
|
|
17
|
+
export interface INotifier<UI, C extends NotificationCallProps> {
|
|
18
|
+
/**
|
|
19
|
+
* Is loading bar showing
|
|
20
|
+
*/
|
|
21
|
+
readonly isLoading: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Is model window showing
|
|
24
|
+
*/
|
|
25
|
+
readonly isModeling: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Add notification
|
|
28
|
+
* @param notification Notification
|
|
29
|
+
* @param top Is insert top
|
|
30
|
+
*/
|
|
31
|
+
add(notification: INotification<UI, C>, top?: boolean): void;
|
|
32
|
+
/**
|
|
33
|
+
* Report error or message
|
|
34
|
+
* @param errorOrTitle Error message or title
|
|
35
|
+
* @param callback Callback
|
|
36
|
+
* @param type Type, default is Error
|
|
37
|
+
* @param props Props
|
|
38
|
+
*/
|
|
39
|
+
alert(errorOrTitle: NotificationContent<UI> | [NotificationContent<UI>, NotificationContent<UI>], callback?: NotificationReturn<void>, type?: NotificationMessageType, props?: C): INotification<UI, C>;
|
|
40
|
+
/**
|
|
41
|
+
* Align all notification count
|
|
42
|
+
* @param align Align
|
|
43
|
+
*/
|
|
44
|
+
alignCount(align: NotificationAlign): number;
|
|
45
|
+
/**
|
|
46
|
+
* Align open notification count
|
|
47
|
+
* @param align Align
|
|
48
|
+
*/
|
|
49
|
+
alignOpenCount(align: NotificationAlign): number;
|
|
50
|
+
/**
|
|
51
|
+
* Remove all closed notification
|
|
52
|
+
*/
|
|
53
|
+
clear(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Confirm action
|
|
56
|
+
* @param message Message
|
|
57
|
+
* @param title Title
|
|
58
|
+
* @param callback Callback
|
|
59
|
+
* @param props Props
|
|
60
|
+
*/
|
|
61
|
+
confirm(message: NotificationContent<UI>, title?: NotificationContent<UI>, callback?: NotificationReturn<boolean>, props?: C): INotification<UI, C>;
|
|
62
|
+
/**
|
|
63
|
+
* Dispose all notifications
|
|
64
|
+
*/
|
|
65
|
+
dispose(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Get notification with align and id
|
|
68
|
+
* @param align Align
|
|
69
|
+
* @param id Notification id
|
|
70
|
+
*/
|
|
71
|
+
get(align: NotificationAlign, id: string): INotification<UI, C> | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Get notification with id
|
|
74
|
+
* @param id Notification id
|
|
75
|
+
*/
|
|
76
|
+
getById(id: string): INotification<UI, C> | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Hide loading
|
|
79
|
+
* @param force Force to hide, otherwise, only the last one
|
|
80
|
+
*/
|
|
81
|
+
hideLoading(force?: boolean): void;
|
|
82
|
+
/**
|
|
83
|
+
* Show a message
|
|
84
|
+
* @param type Message type
|
|
85
|
+
* @param message Message
|
|
86
|
+
* @param title Title
|
|
87
|
+
* @param parameters Parameters
|
|
88
|
+
* @param props Props
|
|
89
|
+
*/
|
|
90
|
+
message(type: NotificationMessageType, message: NotificationContent<UI>, title?: NotificationContent<UI>, parameters?: NotificationParameters, props?: C): INotification<UI, C>;
|
|
91
|
+
/**
|
|
92
|
+
* Popup component as modal
|
|
93
|
+
* @param component Component to popup
|
|
94
|
+
* @param properties Popup properties
|
|
95
|
+
* @returns Result
|
|
96
|
+
*/
|
|
97
|
+
popup(component: NotificationContent<UI>, properties: any): INotification<UI, C>;
|
|
98
|
+
/**
|
|
99
|
+
* Prompt action
|
|
100
|
+
* @param message Message
|
|
101
|
+
* @param callback Callback
|
|
102
|
+
* @param title Title
|
|
103
|
+
* @param props More properties
|
|
104
|
+
*/
|
|
105
|
+
prompt<T = string | undefined>(message: NotificationContent<UI>, callback: NotificationReturn<T>, title?: NotificationContent<UI>, props?: C): INotification<UI, C>;
|
|
106
|
+
/**
|
|
107
|
+
* Show loading
|
|
108
|
+
* @param title Title
|
|
109
|
+
*/
|
|
110
|
+
showLoading(title?: NotificationContent<UI>): void;
|
|
111
|
+
/**
|
|
112
|
+
* Show a success message
|
|
113
|
+
* @param message Message
|
|
114
|
+
* @param title Title
|
|
115
|
+
* @param callback Callback
|
|
116
|
+
* @param timespan Timespan to close
|
|
117
|
+
* @param props Props
|
|
118
|
+
*/
|
|
119
|
+
succeed(message: NotificationContent<UI>, title?: NotificationContent<UI>, callback?: NotificationReturn<void>, timespan?: number, props?: C): INotification<UI, C>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Notification container class
|
|
123
|
+
*/
|
|
124
|
+
export declare abstract class NotificationContainer<UI, C extends NotificationCallProps> implements INotifier<UI, C> {
|
|
125
|
+
private update;
|
|
126
|
+
private lastLoading?;
|
|
127
|
+
private loadingCount;
|
|
128
|
+
/**
|
|
129
|
+
* Notification collection to display
|
|
130
|
+
*/
|
|
131
|
+
readonly notifications: NotificationDictionary<UI, C>;
|
|
132
|
+
/**
|
|
133
|
+
* Is loading bar showing
|
|
134
|
+
*/
|
|
135
|
+
get isLoading(): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Is model window showing
|
|
138
|
+
*/
|
|
139
|
+
get isModeling(): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Constructor
|
|
142
|
+
*/
|
|
143
|
+
constructor(update: NotificationAction<UI, C>);
|
|
144
|
+
/**
|
|
145
|
+
* Add raw definition
|
|
146
|
+
* @param data Notification data definition
|
|
147
|
+
* @param modal Show as modal
|
|
148
|
+
*/
|
|
149
|
+
protected abstract addRaw(data: INotificaseBase<UI, C>, modal?: boolean): INotification<UI, C>;
|
|
150
|
+
/**
|
|
151
|
+
* Add notification
|
|
152
|
+
* @param notification Notification
|
|
153
|
+
* @param top Is insert top
|
|
154
|
+
*/
|
|
155
|
+
add(notification: INotification<UI, C>, top?: boolean): void;
|
|
156
|
+
/**
|
|
157
|
+
* Align all notification count
|
|
158
|
+
* @param align Align
|
|
159
|
+
*/
|
|
160
|
+
alignCount(align: NotificationAlign): number;
|
|
161
|
+
/**
|
|
162
|
+
* Align open notification count
|
|
163
|
+
* @param align Align
|
|
164
|
+
*/
|
|
165
|
+
alignOpenCount(align: NotificationAlign): number;
|
|
166
|
+
/**
|
|
167
|
+
* Remove all closed notification
|
|
168
|
+
*/
|
|
169
|
+
clear(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Dispose all notifications
|
|
172
|
+
*/
|
|
173
|
+
dispose(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Call register callback
|
|
176
|
+
* @param id Notification id
|
|
177
|
+
* @param dismiss Is dismiss
|
|
178
|
+
*/
|
|
179
|
+
private doRegister;
|
|
180
|
+
/**
|
|
181
|
+
* Get notification with align and id
|
|
182
|
+
* @param align Align
|
|
183
|
+
* @param id Notification id
|
|
184
|
+
*/
|
|
185
|
+
get(align: NotificationAlign, id: string): INotification<UI, C> | undefined;
|
|
186
|
+
/**
|
|
187
|
+
* Get notification with id
|
|
188
|
+
* @param id Notification id
|
|
189
|
+
*/
|
|
190
|
+
getById(id: string): INotification<UI, C> | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Report error or message
|
|
193
|
+
* @param errorOrTitle Error message or title
|
|
194
|
+
* @param callback Callback
|
|
195
|
+
* @param type Type, default is Error
|
|
196
|
+
* @param props Props
|
|
197
|
+
*/
|
|
198
|
+
alert(errorOrTitle: NotificationContent<UI> | [NotificationContent<UI>, NotificationContent<UI>], callback?: NotificationReturn<void>, type?: NotificationMessageType, props?: C): INotification<UI, C>;
|
|
199
|
+
/**
|
|
200
|
+
* Confirm action
|
|
201
|
+
* @param message Message
|
|
202
|
+
* @param title Title
|
|
203
|
+
* @param callback Callback
|
|
204
|
+
* @param props Props
|
|
205
|
+
*/
|
|
206
|
+
confirm(message: NotificationContent<UI>, title?: NotificationContent<UI>, callback?: NotificationReturn<boolean>, props?: C): INotification<UI, C>;
|
|
207
|
+
/**
|
|
208
|
+
* Hide loading
|
|
209
|
+
* @param force Force to hide, otherwise, only the last one
|
|
210
|
+
*/
|
|
211
|
+
hideLoading(force?: boolean): void;
|
|
212
|
+
/**
|
|
213
|
+
* Show a message
|
|
214
|
+
* @param type Message type
|
|
215
|
+
* @param message Message
|
|
216
|
+
* @param title Title
|
|
217
|
+
* @param parameters Parameters
|
|
218
|
+
* @param props Props
|
|
219
|
+
*/
|
|
220
|
+
message(type: NotificationMessageType, message: NotificationContent<UI>, title?: NotificationContent<UI>, parameters?: NotificationParameters, props?: C): INotification<UI, C>;
|
|
221
|
+
/**
|
|
222
|
+
* Prompt action
|
|
223
|
+
* @param message Message
|
|
224
|
+
* @param callback Callback
|
|
225
|
+
* @param title Title
|
|
226
|
+
* @param props More properties
|
|
227
|
+
*/
|
|
228
|
+
prompt<T = string | undefined>(message: NotificationContent<UI>, callback: NotificationReturn<T>, title?: string, props?: C): INotification<UI, C>;
|
|
229
|
+
/**
|
|
230
|
+
* Show loading
|
|
231
|
+
* @param title Title
|
|
232
|
+
*/
|
|
233
|
+
showLoading(title?: NotificationContent<UI>): void;
|
|
234
|
+
/**
|
|
235
|
+
* Popup component as modal
|
|
236
|
+
* @param component Component to popup
|
|
237
|
+
* @param properties Popup properties
|
|
238
|
+
* @returns Result
|
|
239
|
+
*/
|
|
240
|
+
popup(component: NotificationContent<UI>, properties: any): INotification<UI, C>;
|
|
241
|
+
/**
|
|
242
|
+
* Show a success message
|
|
243
|
+
* @param message Message
|
|
244
|
+
* @param title Title
|
|
245
|
+
* @param callback Callback
|
|
246
|
+
* @param timespan Timespan to close
|
|
247
|
+
* @param props Props
|
|
248
|
+
*/
|
|
249
|
+
succeed(message: NotificationContent<UI>, title?: NotificationContent<UI>, callback?: NotificationReturn<void>, timespan?: number, props?: C): INotification<UI, C>;
|
|
250
|
+
}
|
package/lib/mjs/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/notificationbase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.41",
|
|
4
4
|
"description": "TypeScript notification component for extending with all features described and partially implemented",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"
|
|
5
|
+
"main": "lib/cjs/index.js",
|
|
6
|
+
"module": "lib/mjs/index.js",
|
|
7
|
+
"types": "lib/mjs/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./lib/mjs/index.js",
|
|
11
|
+
"require": "./lib/cjs/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
15
|
+
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
|
|
9
16
|
"format": "prettier --write src/**/*.ts",
|
|
10
17
|
"lint": "eslint --ext .ts src/",
|
|
11
18
|
"test": "jest",
|
|
@@ -45,7 +52,7 @@
|
|
|
45
52
|
},
|
|
46
53
|
"homepage": "https://github.com/ETSOO/NotificationBase#readme",
|
|
47
54
|
"dependencies": {
|
|
48
|
-
"@etsoo/shared": "^1.2.
|
|
55
|
+
"@etsoo/shared": "^1.2.33"
|
|
49
56
|
},
|
|
50
57
|
"devDependencies": {
|
|
51
58
|
"@babel/core": "^7.24.0",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"isolatedModules": true,
|
|
8
|
+
"outDir": "./lib/cjs",
|
|
9
|
+
"noEmit": false,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src"]
|
|
17
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
4
|
"target": "ES2020",
|
|
5
5
|
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "
|
|
6
|
+
"moduleResolution": "Node10",
|
|
7
7
|
"isolatedModules": true,
|
|
8
|
-
"outDir": "./lib",
|
|
8
|
+
"outDir": "./lib/mjs",
|
|
9
9
|
"noEmit": false,
|
|
10
10
|
"declaration": true,
|
|
11
11
|
"strict": true,
|
package/babel.config.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|