@etsoo/notificationbase 1.1.26 → 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 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
@@ -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
@@ -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"; // Alert
24
+ NotificationModalType[NotificationModalType["Error"] = 3] = "Error";
25
+ NotificationModalType[NotificationModalType["Popup"] = 6] = "Popup";
25
26
  })(NotificationModalType || (NotificationModalType = {}));
26
27
  /**
27
28
  * Message types
@@ -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.26",
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.8"
48
+ "@etsoo/shared": "^1.2.10"
49
49
  },
50
50
  "devDependencies": {
51
- "@babel/core": "^7.22.10",
51
+ "@babel/core": "^7.22.11",
52
52
  "@babel/plugin-transform-runtime": "^7.22.10",
53
- "@babel/preset-env": "^7.22.10",
54
- "@babel/runtime-corejs3": "^7.22.10",
55
- "@types/jest": "^29.5.3",
56
- "babel-jest": "^29.6.2",
57
- "jest": "^29.6.2",
58
- "jest-environment-jsdom": "^29.6.2",
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
59
  "ts-jest": "^29.1.1",
60
- "typescript": "^5.1.6"
60
+ "typescript": "^5.2.2"
61
61
  }
62
62
  }
@@ -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
  /**
@@ -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