@etsoo/notificationbase 1.1.25 → 1.1.27
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/README.md +11 -0
- package/lib/Notification.d.ts +7 -3
- package/lib/Notification.js +8 -4
- package/lib/NotificationContainer.d.ts +20 -0
- package/lib/NotificationContainer.js +18 -0
- package/package.json +12 -12
- package/src/Notification.ts +12 -5
- package/src/NotificationContainer.ts +34 -0
package/README.md
CHANGED
|
@@ -194,6 +194,17 @@ Methods:
|
|
|
194
194
|
props?: C
|
|
195
195
|
): INotification<UI, C>;
|
|
196
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Popup component as modal
|
|
199
|
+
* @param component Component to popup
|
|
200
|
+
* @param anchor Position anchor
|
|
201
|
+
* @returns Result
|
|
202
|
+
*/
|
|
203
|
+
popup(
|
|
204
|
+
component: NotificationContent<UI>,
|
|
205
|
+
anchor?: HTMLElement | string | { left: number; top: number }
|
|
206
|
+
): INotification<UI, C>;
|
|
207
|
+
|
|
197
208
|
/**
|
|
198
209
|
* Prompt action
|
|
199
210
|
* @param message Message
|
package/lib/Notification.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ export declare enum NotificationModalType {
|
|
|
21
21
|
Loading = 0,
|
|
22
22
|
Confirm = 1,
|
|
23
23
|
Prompt = 2,
|
|
24
|
-
Error = 3
|
|
24
|
+
Error = 3,
|
|
25
|
+
Popup = 6
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Message types
|
|
@@ -47,6 +48,7 @@ export declare const NotificationType: {
|
|
|
47
48
|
Confirm: NotificationModalType.Confirm;
|
|
48
49
|
Prompt: NotificationModalType.Prompt;
|
|
49
50
|
Error: NotificationModalType.Error;
|
|
51
|
+
Popup: NotificationModalType.Popup;
|
|
50
52
|
};
|
|
51
53
|
/**
|
|
52
54
|
* Notification types
|
|
@@ -200,9 +202,10 @@ export interface INotification<UI, C extends NotificationCallProps> extends INot
|
|
|
200
202
|
/**
|
|
201
203
|
* Dismiss it
|
|
202
204
|
* @param delaySeconds Delay seconds
|
|
205
|
+
* @param noTrigger No onReturn trigger
|
|
203
206
|
* @returns Is delayed or not
|
|
204
207
|
*/
|
|
205
|
-
dismiss(delaySeconds?: number): boolean;
|
|
208
|
+
dismiss(delaySeconds?: number, noTrigger?: boolean): boolean;
|
|
206
209
|
/**
|
|
207
210
|
* Dispose it
|
|
208
211
|
*/
|
|
@@ -300,9 +303,10 @@ export declare abstract class Notification<UI, C extends NotificationCallProps>
|
|
|
300
303
|
/**
|
|
301
304
|
* Dismiss it
|
|
302
305
|
* @param delaySeconds Delay seconds
|
|
306
|
+
* @param noTrigger No onReturn trigger
|
|
303
307
|
* @returns Is delayed or not
|
|
304
308
|
*/
|
|
305
|
-
dismiss(delaySeconds?: number): boolean;
|
|
309
|
+
dismiss(delaySeconds?: number, noTrigger?: boolean): boolean;
|
|
306
310
|
private removeTimeout;
|
|
307
311
|
/**
|
|
308
312
|
* Dispose it
|
package/lib/Notification.js
CHANGED
|
@@ -21,7 +21,8 @@ export var NotificationModalType;
|
|
|
21
21
|
NotificationModalType[NotificationModalType["Loading"] = 0] = "Loading";
|
|
22
22
|
NotificationModalType[NotificationModalType["Confirm"] = 1] = "Confirm";
|
|
23
23
|
NotificationModalType[NotificationModalType["Prompt"] = 2] = "Prompt";
|
|
24
|
-
NotificationModalType[NotificationModalType["Error"] = 3] = "Error";
|
|
24
|
+
NotificationModalType[NotificationModalType["Error"] = 3] = "Error";
|
|
25
|
+
NotificationModalType[NotificationModalType["Popup"] = 6] = "Popup";
|
|
25
26
|
})(NotificationModalType || (NotificationModalType = {}));
|
|
26
27
|
/**
|
|
27
28
|
* Message types
|
|
@@ -88,9 +89,10 @@ export class Notification {
|
|
|
88
89
|
/**
|
|
89
90
|
* Dismiss it
|
|
90
91
|
* @param delaySeconds Delay seconds
|
|
92
|
+
* @param noTrigger No onReturn trigger
|
|
91
93
|
* @returns Is delayed or not
|
|
92
94
|
*/
|
|
93
|
-
dismiss(delaySeconds = 0) {
|
|
95
|
+
dismiss(delaySeconds = 0, noTrigger = false) {
|
|
94
96
|
// If it's closed, return
|
|
95
97
|
if (!this._open)
|
|
96
98
|
return false;
|
|
@@ -101,7 +103,9 @@ export class Notification {
|
|
|
101
103
|
return true;
|
|
102
104
|
}
|
|
103
105
|
// For message, call onReturn
|
|
104
|
-
if (
|
|
106
|
+
if (!noTrigger &&
|
|
107
|
+
this.onReturn != null &&
|
|
108
|
+
this.type in NotificationMessageType) {
|
|
105
109
|
this.onReturn(undefined);
|
|
106
110
|
}
|
|
107
111
|
// Indicate closed
|
|
@@ -136,6 +140,6 @@ export class Notification {
|
|
|
136
140
|
if (result === false)
|
|
137
141
|
return;
|
|
138
142
|
}
|
|
139
|
-
this.dismiss();
|
|
143
|
+
this.dismiss(0, true);
|
|
140
144
|
}
|
|
141
145
|
}
|
|
@@ -88,6 +88,16 @@ export interface INotifier<UI, C extends NotificationCallProps> {
|
|
|
88
88
|
* @param props Props
|
|
89
89
|
*/
|
|
90
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 anchor Position anchor
|
|
95
|
+
* @returns Result
|
|
96
|
+
*/
|
|
97
|
+
popup(component: NotificationContent<UI>, anchor?: HTMLElement | string | {
|
|
98
|
+
left: number;
|
|
99
|
+
top: number;
|
|
100
|
+
}): INotification<UI, C>;
|
|
91
101
|
/**
|
|
92
102
|
* Prompt action
|
|
93
103
|
* @param message Message
|
|
@@ -224,6 +234,16 @@ export declare abstract class NotificationContainer<UI, C extends NotificationCa
|
|
|
224
234
|
* @param title Title
|
|
225
235
|
*/
|
|
226
236
|
showLoading(title?: NotificationContent<UI>): void;
|
|
237
|
+
/**
|
|
238
|
+
* Popup component as modal
|
|
239
|
+
* @param component Component to popup
|
|
240
|
+
* @param anchor Position anchor
|
|
241
|
+
* @returns Result
|
|
242
|
+
*/
|
|
243
|
+
popup(component: NotificationContent<UI>, anchor?: HTMLElement | string | {
|
|
244
|
+
left: number;
|
|
245
|
+
top: number;
|
|
246
|
+
}): INotification<UI, C>;
|
|
227
247
|
/**
|
|
228
248
|
* Show a success message
|
|
229
249
|
* @param message Message
|
|
@@ -259,6 +259,24 @@ export class NotificationContainer {
|
|
|
259
259
|
this.lastLoading = this.addRaw(n);
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Popup component as modal
|
|
264
|
+
* @param component Component to popup
|
|
265
|
+
* @param anchor Position anchor
|
|
266
|
+
* @returns Result
|
|
267
|
+
*/
|
|
268
|
+
popup(component, anchor) {
|
|
269
|
+
// Setup
|
|
270
|
+
const n = {
|
|
271
|
+
type: NotificationType.Popup,
|
|
272
|
+
content: component,
|
|
273
|
+
renderSetup: (options) => {
|
|
274
|
+
options.anchor = anchor;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
// Add to the collection
|
|
278
|
+
return this.addRaw(n);
|
|
279
|
+
}
|
|
262
280
|
/**
|
|
263
281
|
* Show a success message
|
|
264
282
|
* @param message Message
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/notificationbase",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27",
|
|
4
4
|
"description": "TypeScript notification component for extending with all features described and partially implemented",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/ETSOO/NotificationBase#readme",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@etsoo/shared": "^1.2.
|
|
48
|
+
"@etsoo/shared": "^1.2.10"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
53
|
-
"@babel/preset-env": "^7.
|
|
54
|
-
"@babel/runtime-corejs3": "^7.
|
|
55
|
-
"@types/jest": "^29.5.
|
|
56
|
-
"babel-jest": "^29.
|
|
57
|
-
"jest": "^29.
|
|
58
|
-
"jest-environment-jsdom": "^29.
|
|
59
|
-
"ts-jest": "^29.1.
|
|
60
|
-
"typescript": "^5.
|
|
51
|
+
"@babel/core": "^7.22.11",
|
|
52
|
+
"@babel/plugin-transform-runtime": "^7.22.10",
|
|
53
|
+
"@babel/preset-env": "^7.22.14",
|
|
54
|
+
"@babel/runtime-corejs3": "^7.22.11",
|
|
55
|
+
"@types/jest": "^29.5.4",
|
|
56
|
+
"babel-jest": "^29.6.4",
|
|
57
|
+
"jest": "^29.6.4",
|
|
58
|
+
"jest-environment-jsdom": "^29.6.4",
|
|
59
|
+
"ts-jest": "^29.1.1",
|
|
60
|
+
"typescript": "^5.2.2"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/src/Notification.ts
CHANGED
|
@@ -27,7 +27,8 @@ export enum NotificationModalType {
|
|
|
27
27
|
Loading = 0,
|
|
28
28
|
Confirm = 1,
|
|
29
29
|
Prompt = 2,
|
|
30
|
-
Error = 3 // Alert
|
|
30
|
+
Error = 3, // Alert
|
|
31
|
+
Popup = 6
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -232,9 +233,10 @@ export interface INotification<UI, C extends NotificationCallProps>
|
|
|
232
233
|
/**
|
|
233
234
|
* Dismiss it
|
|
234
235
|
* @param delaySeconds Delay seconds
|
|
236
|
+
* @param noTrigger No onReturn trigger
|
|
235
237
|
* @returns Is delayed or not
|
|
236
238
|
*/
|
|
237
|
-
dismiss(delaySeconds?: number): boolean;
|
|
239
|
+
dismiss(delaySeconds?: number, noTrigger?: boolean): boolean;
|
|
238
240
|
|
|
239
241
|
/**
|
|
240
242
|
* Dispose it
|
|
@@ -382,9 +384,10 @@ export abstract class Notification<UI, C extends NotificationCallProps>
|
|
|
382
384
|
/**
|
|
383
385
|
* Dismiss it
|
|
384
386
|
* @param delaySeconds Delay seconds
|
|
387
|
+
* @param noTrigger No onReturn trigger
|
|
385
388
|
* @returns Is delayed or not
|
|
386
389
|
*/
|
|
387
|
-
dismiss(delaySeconds: number = 0): boolean {
|
|
390
|
+
dismiss(delaySeconds: number = 0, noTrigger: boolean = false): boolean {
|
|
388
391
|
// If it's closed, return
|
|
389
392
|
if (!this._open) return false;
|
|
390
393
|
|
|
@@ -399,7 +402,11 @@ export abstract class Notification<UI, C extends NotificationCallProps>
|
|
|
399
402
|
}
|
|
400
403
|
|
|
401
404
|
// For message, call onReturn
|
|
402
|
-
if (
|
|
405
|
+
if (
|
|
406
|
+
!noTrigger &&
|
|
407
|
+
this.onReturn != null &&
|
|
408
|
+
this.type in NotificationMessageType
|
|
409
|
+
) {
|
|
403
410
|
this.onReturn(undefined);
|
|
404
411
|
}
|
|
405
412
|
|
|
@@ -449,6 +456,6 @@ export abstract class Notification<UI, C extends NotificationCallProps>
|
|
|
449
456
|
const result = await this.onReturn(value);
|
|
450
457
|
if (result === false) return;
|
|
451
458
|
}
|
|
452
|
-
this.dismiss();
|
|
459
|
+
this.dismiss(0, true);
|
|
453
460
|
}
|
|
454
461
|
}
|
|
@@ -133,6 +133,17 @@ export interface INotifier<UI, C extends NotificationCallProps> {
|
|
|
133
133
|
props?: C
|
|
134
134
|
): INotification<UI, C>;
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Popup component as modal
|
|
138
|
+
* @param component Component to popup
|
|
139
|
+
* @param anchor Position anchor
|
|
140
|
+
* @returns Result
|
|
141
|
+
*/
|
|
142
|
+
popup(
|
|
143
|
+
component: NotificationContent<UI>,
|
|
144
|
+
anchor?: HTMLElement | string | { left: number; top: number }
|
|
145
|
+
): INotification<UI, C>;
|
|
146
|
+
|
|
136
147
|
/**
|
|
137
148
|
* Prompt action
|
|
138
149
|
* @param message Message
|
|
@@ -510,6 +521,29 @@ export abstract class NotificationContainer<UI, C extends NotificationCallProps>
|
|
|
510
521
|
}
|
|
511
522
|
}
|
|
512
523
|
|
|
524
|
+
/**
|
|
525
|
+
* Popup component as modal
|
|
526
|
+
* @param component Component to popup
|
|
527
|
+
* @param anchor Position anchor
|
|
528
|
+
* @returns Result
|
|
529
|
+
*/
|
|
530
|
+
popup(
|
|
531
|
+
component: NotificationContent<UI>,
|
|
532
|
+
anchor?: HTMLElement | string | { left: number; top: number }
|
|
533
|
+
) {
|
|
534
|
+
// Setup
|
|
535
|
+
const n: INotificaseBase<UI, C> = {
|
|
536
|
+
type: NotificationType.Popup,
|
|
537
|
+
content: component,
|
|
538
|
+
renderSetup: (options) => {
|
|
539
|
+
options.anchor = anchor;
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
// Add to the collection
|
|
544
|
+
return this.addRaw(n);
|
|
545
|
+
}
|
|
546
|
+
|
|
513
547
|
/**
|
|
514
548
|
* Show a success message
|
|
515
549
|
* @param message Message
|