@genesislcap/foundation-notifications 14.114.2 → 14.115.1
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 +83 -11
- package/dist/dts/alert/alert-builder.d.ts +7 -0
- package/dist/dts/alert/alert-builder.d.ts.map +1 -0
- package/dist/dts/alert/index.d.ts +2 -0
- package/dist/dts/alert/index.d.ts.map +1 -0
- package/dist/dts/banner/banner-builder-old.d.ts +40 -0
- package/dist/dts/banner/banner-builder-old.d.ts.map +1 -0
- package/dist/dts/banner/banner-builder.d.ts +3 -31
- package/dist/dts/banner/banner-builder.d.ts.map +1 -1
- package/dist/dts/banner/banner-launcher.d.ts.map +1 -1
- package/dist/dts/banner/index.d.ts +1 -0
- package/dist/dts/banner/index.d.ts.map +1 -1
- package/dist/dts/dialog/dialog-builder-old.d.ts +40 -0
- package/dist/dts/dialog/dialog-builder-old.d.ts.map +1 -0
- package/dist/dts/dialog/dialog-builder.d.ts +3 -31
- package/dist/dts/dialog/dialog-builder.d.ts.map +1 -1
- package/dist/dts/dialog/dialog-launcher.d.ts +1 -1
- package/dist/dts/dialog/dialog-launcher.d.ts.map +1 -1
- package/dist/dts/dialog/index.d.ts +1 -0
- package/dist/dts/dialog/index.d.ts.map +1 -1
- package/dist/dts/index.d.ts +5 -4
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/notification-builder.d.ts +12 -0
- package/dist/dts/notification-builder.d.ts.map +1 -1
- package/dist/dts/notification-launcher.d.ts.map +1 -1
- package/dist/dts/notification-util.d.ts +6 -0
- package/dist/dts/notification-util.d.ts.map +1 -1
- package/dist/dts/snackbar/index.d.ts +1 -0
- package/dist/dts/snackbar/index.d.ts.map +1 -1
- package/dist/dts/snackbar/snackbar-builder-old.d.ts +39 -0
- package/dist/dts/snackbar/snackbar-builder-old.d.ts.map +1 -0
- package/dist/dts/snackbar/snackbar-builder.d.ts +3 -30
- package/dist/dts/snackbar/snackbar-builder.d.ts.map +1 -1
- package/dist/dts/snackbar/snackbar-launcher.d.ts +1 -1
- package/dist/dts/snackbar/snackbar-launcher.d.ts.map +1 -1
- package/dist/dts/toast/index.d.ts +1 -0
- package/dist/dts/toast/index.d.ts.map +1 -1
- package/dist/dts/toast/toast-builder-old.d.ts +74 -0
- package/dist/dts/toast/toast-builder-old.d.ts.map +1 -0
- package/dist/dts/toast/toast-builder.d.ts +3 -61
- package/dist/dts/toast/toast-builder.d.ts.map +1 -1
- package/dist/dts/toast/toast-launcher.d.ts.map +1 -1
- package/dist/dts/types.d.ts +50 -2
- package/dist/dts/types.d.ts.map +1 -1
- package/dist/esm/alert/alert-builder.js +9 -0
- package/dist/esm/alert/index.js +1 -0
- package/dist/esm/banner/banner-builder-old.js +56 -0
- package/dist/esm/banner/banner-builder.js +17 -43
- package/dist/esm/banner/banner-launcher.js +2 -1
- package/dist/esm/banner/index.js +1 -0
- package/dist/esm/dialog/dialog-builder-old.js +56 -0
- package/dist/esm/dialog/dialog-builder.js +21 -43
- package/dist/esm/dialog/dialog-launcher.js +4 -3
- package/dist/esm/dialog/index.js +1 -0
- package/dist/esm/index.js +5 -4
- package/dist/esm/notification-builder.js +14 -0
- package/dist/esm/notification-launcher.js +2 -10
- package/dist/esm/notification-util.js +12 -0
- package/dist/esm/snackbar/index.js +1 -0
- package/dist/esm/snackbar/snackbar-builder-old.js +55 -0
- package/dist/esm/snackbar/snackbar-builder.js +17 -42
- package/dist/esm/snackbar/snackbar-launcher.js +4 -3
- package/dist/esm/toast/index.js +1 -0
- package/dist/esm/toast/toast-builder-old.js +107 -0
- package/dist/esm/toast/toast-builder.js +22 -88
- package/dist/esm/toast/toast-launcher.js +2 -1
- package/dist/foundation-notifications.api.json +911 -88
- package/dist/foundation-notifications.d.ts +130 -4
- package/docs/api/foundation-notifications.alertstructure.body.md +11 -0
- package/docs/api/foundation-notifications.alertstructure.loglevel.md +11 -0
- package/docs/api/foundation-notifications.alertstructure.md +22 -0
- package/docs/api/foundation-notifications.alertstructure.title.md +11 -0
- package/docs/api/foundation-notifications.bannerbuilder.build.md +5 -0
- package/docs/api/foundation-notifications.bannerbuilder.md +5 -0
- package/docs/api/foundation-notifications.bannerbuilder.withconfirmingaction.md +5 -0
- package/docs/api/foundation-notifications.bannerbuilder.withdismissingaction.md +5 -0
- package/docs/api/foundation-notifications.bannerstructure.banner.md +11 -0
- package/docs/api/foundation-notifications.bannerstructure.body.md +11 -0
- package/docs/api/foundation-notifications.bannerstructure.loglevel.md +11 -0
- package/docs/api/foundation-notifications.bannerstructure.md +22 -0
- package/docs/api/foundation-notifications.dialogbuilder.build.md +5 -0
- package/docs/api/foundation-notifications.dialogbuilder.md +5 -0
- package/docs/api/foundation-notifications.dialogbuilder.withconfirmingaction.md +5 -0
- package/docs/api/foundation-notifications.dialogbuilder.withdismissingaction.md +5 -0
- package/docs/api/foundation-notifications.dialogstructure.body.md +11 -0
- package/docs/api/foundation-notifications.dialogstructure.dialog.md +11 -0
- package/docs/api/foundation-notifications.dialogstructure.loglevel.md +11 -0
- package/docs/api/foundation-notifications.dialogstructure.md +23 -0
- package/docs/api/foundation-notifications.dialogstructure.title.md +11 -0
- package/docs/api/foundation-notifications.getbannerbuilder.md +5 -0
- package/docs/api/foundation-notifications.getdialogbuilder.md +5 -0
- package/docs/api/foundation-notifications.getnotificationbuilder.md +5 -0
- package/docs/api/foundation-notifications.getsnackbarbuilder.md +5 -0
- package/docs/api/foundation-notifications.gettoastbuilder.md +5 -0
- package/docs/api/foundation-notifications.md +12 -1
- package/docs/api/foundation-notifications.notificationbuilder.build.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withalert.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withbanner.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withbody.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withcreatedat.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withdialog.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withloglevel.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withsnackbar.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withtitle.md +5 -0
- package/docs/api/foundation-notifications.notificationbuilder.withtoast.md +5 -0
- package/docs/api/foundation-notifications.notificationstructure.md +2 -2
- package/docs/api/foundation-notifications.notificationstructure.title.md +1 -1
- package/docs/api/foundation-notifications.showloggerloglevel.md +13 -0
- package/docs/api/foundation-notifications.shownotificationalert.md +13 -0
- package/docs/api/foundation-notifications.shownotificationbanner.md +13 -0
- package/docs/api/foundation-notifications.shownotificationdialog.md +13 -0
- package/docs/api/foundation-notifications.shownotificationsnackbar.md +13 -0
- package/docs/api/foundation-notifications.shownotificationtoast.md +13 -0
- package/docs/api/foundation-notifications.snackbarbuilder.build.md +5 -0
- package/docs/api/foundation-notifications.snackbarbuilder.md +5 -0
- package/docs/api/foundation-notifications.snackbarbuilder.withconfirmingaction.md +5 -0
- package/docs/api/foundation-notifications.snackbarbuilder.withtype.md +5 -0
- package/docs/api/foundation-notifications.snackbarstructure.body.md +11 -0
- package/docs/api/foundation-notifications.snackbarstructure.loglevel.md +11 -0
- package/docs/api/foundation-notifications.snackbarstructure.md +22 -0
- package/docs/api/foundation-notifications.snackbarstructure.snackbar.md +11 -0
- package/docs/api/foundation-notifications.toastbuilder.build.md +5 -0
- package/docs/api/foundation-notifications.toastbuilder.md +4 -0
- package/docs/api/foundation-notifications.toastbuilder.withautoclose.md +5 -0
- package/docs/api/foundation-notifications.toastbuilder.withbuttons.md +5 -0
- package/docs/api/foundation-notifications.toastbuilder.withclosetimeout.md +5 -0
- package/docs/api/foundation-notifications.toastbuilder.withdetails.md +5 -0
- package/docs/api/foundation-notifications.toastbuilder.withposition.md +5 -0
- package/docs/api/foundation-notifications.toastbuilder.withtype.md +5 -0
- package/docs/api/foundation-notifications.toaststructure.body.md +11 -0
- package/docs/api/foundation-notifications.toaststructure.createdat.md +11 -0
- package/docs/api/foundation-notifications.toaststructure.loglevel.md +11 -0
- package/docs/api/foundation-notifications.toaststructure.md +24 -0
- package/docs/api/foundation-notifications.toaststructure.title.md +11 -0
- package/docs/api/foundation-notifications.toaststructure.toast.md +11 -0
- package/docs/api-report.md +113 -14
- package/package.json +5 -5
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { LogLevel } from '@genesislcap/foundation-logger';
|
|
2
|
+
import { logger } from './logger';
|
|
2
3
|
/**
|
|
3
4
|
* NotificationBuilder to build NotificationStructure
|
|
4
5
|
* @public
|
|
6
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
5
7
|
*/
|
|
6
8
|
export class NotificationBuilder {
|
|
7
9
|
/**
|
|
@@ -9,6 +11,7 @@ export class NotificationBuilder {
|
|
|
9
11
|
* @public
|
|
10
12
|
* @param title - string
|
|
11
13
|
* @returns
|
|
14
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
12
15
|
*/
|
|
13
16
|
withTitle(title) {
|
|
14
17
|
this.title = title;
|
|
@@ -19,6 +22,7 @@ export class NotificationBuilder {
|
|
|
19
22
|
* @public
|
|
20
23
|
* @param body - string
|
|
21
24
|
* @returns
|
|
25
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
22
26
|
*/
|
|
23
27
|
withBody(body) {
|
|
24
28
|
this.body = body;
|
|
@@ -29,6 +33,7 @@ export class NotificationBuilder {
|
|
|
29
33
|
* @public
|
|
30
34
|
* @param createdAt - Date
|
|
31
35
|
* @returns
|
|
36
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
32
37
|
*/
|
|
33
38
|
withCreatedAt(createdAt) {
|
|
34
39
|
this.createdAt = createdAt;
|
|
@@ -38,6 +43,7 @@ export class NotificationBuilder {
|
|
|
38
43
|
* Add log level to notification
|
|
39
44
|
* @public
|
|
40
45
|
* @returns
|
|
46
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
41
47
|
*/
|
|
42
48
|
withLogLevel(logLevel) {
|
|
43
49
|
this.logLevel = logLevel;
|
|
@@ -48,6 +54,7 @@ export class NotificationBuilder {
|
|
|
48
54
|
* @public
|
|
49
55
|
* @param alert - boolean
|
|
50
56
|
* @returns
|
|
57
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
51
58
|
*/
|
|
52
59
|
withAlert(alert) {
|
|
53
60
|
this.alert = alert;
|
|
@@ -58,6 +65,7 @@ export class NotificationBuilder {
|
|
|
58
65
|
* @public
|
|
59
66
|
* @param notification - {@link Toast}
|
|
60
67
|
* @returns
|
|
68
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
61
69
|
*/
|
|
62
70
|
withToast(toast) {
|
|
63
71
|
this.toast = toast;
|
|
@@ -68,6 +76,7 @@ export class NotificationBuilder {
|
|
|
68
76
|
* @public
|
|
69
77
|
* @param banner - {@link Banner}
|
|
70
78
|
* @returns
|
|
79
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
71
80
|
*/
|
|
72
81
|
withBanner(banner) {
|
|
73
82
|
this.banner = banner;
|
|
@@ -78,6 +87,7 @@ export class NotificationBuilder {
|
|
|
78
87
|
* @public
|
|
79
88
|
* @param snackbar - {@link Snackbar}
|
|
80
89
|
* @returns
|
|
90
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
81
91
|
*/
|
|
82
92
|
withSnackbar(snackbar) {
|
|
83
93
|
this.snackbar = snackbar;
|
|
@@ -88,6 +98,7 @@ export class NotificationBuilder {
|
|
|
88
98
|
* @public
|
|
89
99
|
* @param dialog - {@link Dialog}
|
|
90
100
|
* @returns
|
|
101
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
91
102
|
*/
|
|
92
103
|
withDialog(dialog) {
|
|
93
104
|
this.dialog = dialog;
|
|
@@ -97,6 +108,7 @@ export class NotificationBuilder {
|
|
|
97
108
|
* Build NotificationStructure
|
|
98
109
|
* @public
|
|
99
110
|
* @returns
|
|
111
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
100
112
|
*/
|
|
101
113
|
build() {
|
|
102
114
|
if (!this.title) {
|
|
@@ -136,11 +148,13 @@ export class NotificationBuilder {
|
|
|
136
148
|
config = Object.assign({ dialog: this.dialog }, config);
|
|
137
149
|
notificationStructure = Object.assign({ config }, notificationStructure);
|
|
138
150
|
}
|
|
151
|
+
logger.deprecated('getNotificationBuilder', 'Use `showNotificationBanner/Dialog/Snackbar/Toast` from `@genesislcap/foundation-notifications` instead or provide a NotificationStructure object when used with an event for a notification listener.');
|
|
139
152
|
return notificationStructure;
|
|
140
153
|
}
|
|
141
154
|
}
|
|
142
155
|
/**
|
|
143
156
|
* Returns a new NotificationBuilder instance
|
|
144
157
|
* @public
|
|
158
|
+
* @deprecated Use showNotificationBanner/Dialog/Snackbar/Toast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
145
159
|
*/
|
|
146
160
|
export const getNotificationBuilder = () => new NotificationBuilder();
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { showNotificationAlert } from './alert';
|
|
2
2
|
import { showBanner } from './banner';
|
|
3
3
|
import { showDialog } from './dialog';
|
|
4
|
-
import { getNotificationDetails, getLoglevel } from './notification-util';
|
|
5
4
|
import { showSnackbar } from './snackbar';
|
|
6
5
|
import { showToast } from './toast';
|
|
7
|
-
const logger = createLogger('foundation-notifications');
|
|
8
6
|
const notificationTypeToComponentMap = {
|
|
9
|
-
alert:
|
|
10
|
-
alert(getNotificationDetails(notificationStructure));
|
|
11
|
-
},
|
|
7
|
+
alert: showNotificationAlert,
|
|
12
8
|
toast: showToast,
|
|
13
9
|
dialog: showDialog,
|
|
14
10
|
snackbar: showSnackbar,
|
|
@@ -23,10 +19,6 @@ const notificationTypeToComponentMap = {
|
|
|
23
19
|
* @returns
|
|
24
20
|
* */
|
|
25
21
|
export const showNotification = (notificationStructure, tagName, notificationBoundary) => {
|
|
26
|
-
logger.log({
|
|
27
|
-
message: getNotificationDetails(notificationStructure),
|
|
28
|
-
level: getLoglevel(notificationStructure),
|
|
29
|
-
});
|
|
30
22
|
const keys = Object.keys((notificationStructure === null || notificationStructure === void 0 ? void 0 : notificationStructure.config) || {});
|
|
31
23
|
keys.forEach((key) => {
|
|
32
24
|
if (notificationTypeToComponentMap[key]) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LogLevel } from '@genesislcap/foundation-logger';
|
|
2
|
+
import { logger } from './logger';
|
|
2
3
|
/**
|
|
3
4
|
* Retrieves the notification details from an NotificationStructure object
|
|
4
5
|
* @public
|
|
@@ -21,6 +22,17 @@ export const getLoglevel = (details) => {
|
|
|
21
22
|
var _a;
|
|
22
23
|
return (details === null || details === void 0 ? void 0 : details.logLevel) || ((_a = details === null || details === void 0 ? void 0 : details.config) === null || _a === void 0 ? void 0 : _a.logLevel) || LogLevel.Debug;
|
|
23
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Shows logger with log level from NotificationStructure object
|
|
27
|
+
* @public
|
|
28
|
+
* @param notificationStructure - The NotificationStructure object
|
|
29
|
+
*/
|
|
30
|
+
export const showLoggerLogLevel = (notificationStructure) => {
|
|
31
|
+
logger.log({
|
|
32
|
+
message: getNotificationDetails(notificationStructure),
|
|
33
|
+
level: getLoglevel(notificationStructure),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
24
36
|
/**
|
|
25
37
|
* Get/Create the error container in the DOM
|
|
26
38
|
* @public
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { logger } from '../logger';
|
|
2
|
+
/**
|
|
3
|
+
* SnackbarBuilder to build Snackbar
|
|
4
|
+
* @public
|
|
5
|
+
* @deprecated Use showNotificationSnackbar instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
6
|
+
*/
|
|
7
|
+
export class SnackbarBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
* @param type - {@link SnackbarType}
|
|
11
|
+
* @returns
|
|
12
|
+
* @deprecated Use showNotificationSnackbar instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
13
|
+
*/
|
|
14
|
+
withType(type) {
|
|
15
|
+
this.type = type;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Add confirming action to snackbar
|
|
20
|
+
* @public
|
|
21
|
+
* @param confirmingAction - {@link ConfirmingAction}
|
|
22
|
+
* @returns
|
|
23
|
+
* @deprecated Use showNotificationSnackbar instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
24
|
+
*/
|
|
25
|
+
withConfirmingAction(confirmingAction) {
|
|
26
|
+
if (!this.confirmingActions) {
|
|
27
|
+
this.confirmingActions = [];
|
|
28
|
+
}
|
|
29
|
+
this.confirmingActions.push(confirmingAction);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build snackbar
|
|
34
|
+
* @public
|
|
35
|
+
* @returns Snackbar
|
|
36
|
+
* @deprecated Use showNotificationSnackbar instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
37
|
+
*/
|
|
38
|
+
build() {
|
|
39
|
+
let snackbar = {};
|
|
40
|
+
if (this.confirmingActions) {
|
|
41
|
+
snackbar = Object.assign({ confirmingActions: this.confirmingActions }, snackbar);
|
|
42
|
+
}
|
|
43
|
+
if (this.type !== undefined) {
|
|
44
|
+
snackbar = Object.assign({ type: this.type }, snackbar);
|
|
45
|
+
}
|
|
46
|
+
logger.deprecated('getSnackbarBuilder', 'Use `showNotificationSnackbar` from `@genesislcap/foundation-notifications` instead or provide a NotificationStructure object when used with an event for a notification listener.');
|
|
47
|
+
return snackbar;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get snackbar builder instance
|
|
52
|
+
* @public
|
|
53
|
+
* @deprecated Use showNotificationSnackbar instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
54
|
+
*/
|
|
55
|
+
export const getSnackbarBuilder = () => new SnackbarBuilder();
|
|
@@ -1,48 +1,23 @@
|
|
|
1
|
+
import { LogLevel } from '@genesislcap/foundation-logger';
|
|
2
|
+
import { showSnackbar } from './snackbar-launcher';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* Shows the notification snackbar
|
|
3
5
|
* @public
|
|
4
6
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @param type - {@link SnackbarType}
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
withType(type) {
|
|
12
|
-
this.type = type;
|
|
13
|
-
return this;
|
|
7
|
+
export const showNotificationSnackbar = (configuration, tagName) => {
|
|
8
|
+
if (!configuration.body) {
|
|
9
|
+
throw new Error(`Missing required param 'body'`);
|
|
14
10
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
withConfirmingAction(confirmingAction) {
|
|
22
|
-
if (!this.confirmingActions) {
|
|
23
|
-
this.confirmingActions = [];
|
|
24
|
-
}
|
|
25
|
-
this.confirmingActions.push(confirmingAction);
|
|
26
|
-
return this;
|
|
11
|
+
let notificationStructure = {
|
|
12
|
+
body: configuration.body,
|
|
13
|
+
};
|
|
14
|
+
let config = {};
|
|
15
|
+
if (configuration.logLevel in LogLevel) {
|
|
16
|
+
notificationStructure = Object.assign({ logLevel: configuration.logLevel }, notificationStructure);
|
|
27
17
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* @returns Snackbar
|
|
32
|
-
*/
|
|
33
|
-
build() {
|
|
34
|
-
let snackbar = {};
|
|
35
|
-
if (this.confirmingActions) {
|
|
36
|
-
snackbar = Object.assign({ confirmingActions: this.confirmingActions }, snackbar);
|
|
37
|
-
}
|
|
38
|
-
if (this.type !== undefined) {
|
|
39
|
-
snackbar = Object.assign({ type: this.type }, snackbar);
|
|
40
|
-
}
|
|
41
|
-
return snackbar;
|
|
18
|
+
if (configuration.snackbar) {
|
|
19
|
+
config = Object.assign({ snackbar: configuration.snackbar }, config);
|
|
20
|
+
notificationStructure = Object.assign({ config }, notificationStructure);
|
|
42
21
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* Get snackbar builder instance
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
48
|
-
export const getSnackbarBuilder = () => new SnackbarBuilder();
|
|
22
|
+
showSnackbar(notificationStructure, tagName);
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNotificationContainer } from '../notification-util';
|
|
1
|
+
import { getNotificationContainer, showLoggerLogLevel } from '../notification-util';
|
|
2
2
|
/**
|
|
3
3
|
* Shows the snackbar
|
|
4
4
|
* @internal
|
|
@@ -6,10 +6,11 @@ import { getNotificationContainer } from '../notification-util';
|
|
|
6
6
|
* @param tagName - The tag name to create prefix for the design system provider & notification component
|
|
7
7
|
* @returns
|
|
8
8
|
* */
|
|
9
|
-
export const showSnackbar = (
|
|
9
|
+
export const showSnackbar = (notificationStructure, tagName) => {
|
|
10
|
+
showLoggerLogLevel(notificationStructure);
|
|
10
11
|
const tagPrefix = tagName.split('-')[0];
|
|
11
12
|
const snackbar = document.createElement(`${tagPrefix}-snackbar`);
|
|
12
13
|
const container = getNotificationContainer('snack-container', tagName);
|
|
13
14
|
container.appendChild(snackbar);
|
|
14
|
-
snackbar.notification =
|
|
15
|
+
snackbar.notification = notificationStructure;
|
|
15
16
|
};
|
package/dist/esm/toast/index.js
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { logger } from '../logger';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
5
|
+
*/
|
|
6
|
+
export class ToastBuilder {
|
|
7
|
+
/**
|
|
8
|
+
* Add position to toast
|
|
9
|
+
* @public
|
|
10
|
+
* @param position - {@link ToastPosition}
|
|
11
|
+
* @returns
|
|
12
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
13
|
+
*/
|
|
14
|
+
withPosition(position) {
|
|
15
|
+
this.position = position;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Add auto close to notification
|
|
20
|
+
* @public
|
|
21
|
+
* @param autoClose - boolean
|
|
22
|
+
* @returns
|
|
23
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
24
|
+
*/
|
|
25
|
+
withAutoClose(autoClose) {
|
|
26
|
+
this.autoClose = autoClose;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Add close timeout to notification
|
|
31
|
+
* @public
|
|
32
|
+
* @param closeTimeout - number
|
|
33
|
+
* @returns
|
|
34
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
35
|
+
*/
|
|
36
|
+
withCloseTimeout(closeTimeout) {
|
|
37
|
+
this.closeTimeout = closeTimeout;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Add type to notification, if the type is anything other than 'warning' or 'success' do not add it
|
|
42
|
+
* @public
|
|
43
|
+
* @param type - {@link NotificationType}
|
|
44
|
+
* @returns
|
|
45
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
46
|
+
*/
|
|
47
|
+
withType(type) {
|
|
48
|
+
this.type = type;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Add details data to notifications
|
|
53
|
+
* @public
|
|
54
|
+
* @param details - NotificationDataRow
|
|
55
|
+
* @returns
|
|
56
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
57
|
+
*/
|
|
58
|
+
withDetails(details) {
|
|
59
|
+
this.details = details;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Add buttons to notifications
|
|
64
|
+
* @public
|
|
65
|
+
* @param buttons - ToastButton[]
|
|
66
|
+
* @returns
|
|
67
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
68
|
+
*/
|
|
69
|
+
withButtons(buttons) {
|
|
70
|
+
this.buttons = buttons;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build notification
|
|
75
|
+
* @returns Toast
|
|
76
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
77
|
+
*/
|
|
78
|
+
build() {
|
|
79
|
+
let toast = {};
|
|
80
|
+
if (this.position) {
|
|
81
|
+
toast = Object.assign({ position: this.position }, toast);
|
|
82
|
+
}
|
|
83
|
+
if (this.autoClose) {
|
|
84
|
+
toast = Object.assign({ autoClose: this.autoClose }, toast);
|
|
85
|
+
}
|
|
86
|
+
if (this.closeTimeout) {
|
|
87
|
+
toast = Object.assign({ closeTimeout: this.closeTimeout }, toast);
|
|
88
|
+
}
|
|
89
|
+
if (this.type) {
|
|
90
|
+
toast = Object.assign({ type: this.type }, toast);
|
|
91
|
+
}
|
|
92
|
+
if (this.details) {
|
|
93
|
+
toast = Object.assign({ details: this.details }, toast);
|
|
94
|
+
}
|
|
95
|
+
if (this.buttons) {
|
|
96
|
+
toast = Object.assign({ buttons: this.buttons }, toast);
|
|
97
|
+
}
|
|
98
|
+
logger.deprecated('getToastBuilder', 'Use `showNotificationToast` from `@genesislcap/foundation-notifications` instead or provide a NotificationStructure object when used with an event for a notification listener.');
|
|
99
|
+
return toast;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get notification builder instance
|
|
104
|
+
* @public
|
|
105
|
+
* @deprecated Use showNotificationToast instead or provide a NotificationStructure object when used with an event for a notification listener.
|
|
106
|
+
*/
|
|
107
|
+
export const getToastBuilder = () => new ToastBuilder();
|
|
@@ -1,96 +1,30 @@
|
|
|
1
|
+
import { LogLevel } from '@genesislcap/foundation-logger';
|
|
2
|
+
import { showToast } from './toast-launcher';
|
|
1
3
|
/**
|
|
4
|
+
* Shows the notification toast
|
|
2
5
|
* @public
|
|
3
6
|
*/
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @public
|
|
8
|
-
* @param position - {@link ToastPosition}
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
withPosition(position) {
|
|
12
|
-
this.position = position;
|
|
13
|
-
return this;
|
|
7
|
+
export const showNotificationToast = (configuration, tagName) => {
|
|
8
|
+
if (!configuration.title) {
|
|
9
|
+
throw new Error('Title is required');
|
|
14
10
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* @public
|
|
18
|
-
* @param autoClose - boolean
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
withAutoClose(autoClose) {
|
|
22
|
-
this.autoClose = autoClose;
|
|
23
|
-
return this;
|
|
11
|
+
if (!configuration.body) {
|
|
12
|
+
throw new Error(`Missing required param 'body'`);
|
|
24
13
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.closeTimeout = closeTimeout;
|
|
33
|
-
return this;
|
|
14
|
+
let notificationStructure = {
|
|
15
|
+
title: configuration.title,
|
|
16
|
+
body: configuration.body,
|
|
17
|
+
};
|
|
18
|
+
let config = {};
|
|
19
|
+
if (configuration.createdAt) {
|
|
20
|
+
notificationStructure = Object.assign({ createdAt: configuration.createdAt }, notificationStructure);
|
|
34
21
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* @public
|
|
38
|
-
* @param type - {@link NotificationType}
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
withType(type) {
|
|
42
|
-
this.type = type;
|
|
43
|
-
return this;
|
|
22
|
+
if (configuration.logLevel in LogLevel) {
|
|
23
|
+
notificationStructure = Object.assign({ logLevel: configuration.logLevel }, notificationStructure);
|
|
44
24
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* @param details - NotificationDataRow
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
withDetails(details) {
|
|
52
|
-
this.details = details;
|
|
53
|
-
return this;
|
|
25
|
+
if (configuration.toast) {
|
|
26
|
+
config = Object.assign({ toast: configuration.toast }, config);
|
|
27
|
+
notificationStructure = Object.assign({ config }, notificationStructure);
|
|
54
28
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* @public
|
|
58
|
-
* @param buttons - ToastButton[]
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
withButtons(buttons) {
|
|
62
|
-
this.buttons = buttons;
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Build notification
|
|
67
|
-
* @returns Toast
|
|
68
|
-
*/
|
|
69
|
-
build() {
|
|
70
|
-
let toast = {};
|
|
71
|
-
if (this.position) {
|
|
72
|
-
toast = Object.assign({ position: this.position }, toast);
|
|
73
|
-
}
|
|
74
|
-
if (this.autoClose) {
|
|
75
|
-
toast = Object.assign({ autoClose: this.autoClose }, toast);
|
|
76
|
-
}
|
|
77
|
-
if (this.closeTimeout) {
|
|
78
|
-
toast = Object.assign({ closeTimeout: this.closeTimeout }, toast);
|
|
79
|
-
}
|
|
80
|
-
if (this.type) {
|
|
81
|
-
toast = Object.assign({ type: this.type }, toast);
|
|
82
|
-
}
|
|
83
|
-
if (this.details) {
|
|
84
|
-
toast = Object.assign({ details: this.details }, toast);
|
|
85
|
-
}
|
|
86
|
-
if (this.buttons) {
|
|
87
|
-
toast = Object.assign({ buttons: this.buttons }, toast);
|
|
88
|
-
}
|
|
89
|
-
return toast;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get notification builder instance
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
export const getToastBuilder = () => new ToastBuilder();
|
|
29
|
+
showToast(notificationStructure, tagName);
|
|
30
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNotificationContainer } from '../notification-util';
|
|
1
|
+
import { getNotificationContainer, showLoggerLogLevel } from '../notification-util';
|
|
2
2
|
/**
|
|
3
3
|
* Shows the notificationStructure
|
|
4
4
|
* @internal
|
|
@@ -8,6 +8,7 @@ import { getNotificationContainer } from '../notification-util';
|
|
|
8
8
|
* */
|
|
9
9
|
export const showToast = (notificationStructure, tagName) => {
|
|
10
10
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
11
|
+
showLoggerLogLevel(notificationStructure);
|
|
11
12
|
const tagPrefix = tagName.split('-')[0];
|
|
12
13
|
const container = getNotificationContainer('notify-container', tagName);
|
|
13
14
|
if (container) {
|