@genesislcap/foundation-errors 14.70.3 → 14.70.4-es2021.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/dist/esm/banner/error-banner-builder.js +2 -2
- package/dist/esm/banner/error-banner-launcher.js +1 -2
- package/dist/esm/dialog/error-dialog-builder.js +2 -2
- package/dist/esm/error-builder.js +11 -11
- package/dist/esm/error-launcher.js +1 -1
- package/dist/esm/error-util.js +5 -8
- package/dist/esm/notification/notification-builder.js +4 -4
- package/dist/esm/notification/notification-launcher.js +8 -9
- package/dist/esm/snackbar/snackbar-builder.js +2 -2
- package/package.json +5 -5
|
@@ -34,10 +34,10 @@ export class ErrorBannerBuilder {
|
|
|
34
34
|
build() {
|
|
35
35
|
let errorBanner = {};
|
|
36
36
|
if (this.dismissingAction) {
|
|
37
|
-
errorBanner =
|
|
37
|
+
errorBanner = { dismissingAction: this.dismissingAction, ...errorBanner };
|
|
38
38
|
}
|
|
39
39
|
if (this.confirmingActions) {
|
|
40
|
-
errorBanner =
|
|
40
|
+
errorBanner = { confirmingActions: this.confirmingActions, ...errorBanner };
|
|
41
41
|
}
|
|
42
42
|
return errorBanner;
|
|
43
43
|
}
|
|
@@ -7,11 +7,10 @@ import { getErrorBannerAnchor } from '../error-util';
|
|
|
7
7
|
* @returns
|
|
8
8
|
* */
|
|
9
9
|
export const showBanner = (error, tagName, errorBoundary) => {
|
|
10
|
-
var _a;
|
|
11
10
|
const tagPrefix = tagName.split('-')[0];
|
|
12
11
|
const banner = document.createElement(`${tagPrefix}-error-banner`);
|
|
13
12
|
const container = getErrorBannerAnchor(errorBoundary);
|
|
14
|
-
if (
|
|
13
|
+
if (container?.children?.length > 0) {
|
|
15
14
|
banner.style.position = 'absolute';
|
|
16
15
|
banner.style.top = '0';
|
|
17
16
|
banner.style.left = '0';
|
|
@@ -34,10 +34,10 @@ export class ErrorDialogBuilder {
|
|
|
34
34
|
build() {
|
|
35
35
|
let errorDialog = {};
|
|
36
36
|
if (this.dismissingAction) {
|
|
37
|
-
errorDialog =
|
|
37
|
+
errorDialog = { dismissingAction: this.dismissingAction, ...errorDialog };
|
|
38
38
|
}
|
|
39
39
|
if (this.confirmingActions) {
|
|
40
|
-
errorDialog =
|
|
40
|
+
errorDialog = { confirmingActions: this.confirmingActions, ...errorDialog };
|
|
41
41
|
}
|
|
42
42
|
return errorDialog;
|
|
43
43
|
}
|
|
@@ -101,27 +101,27 @@ export class ErrorBuilder {
|
|
|
101
101
|
};
|
|
102
102
|
let config = {};
|
|
103
103
|
if (this.logLevel in LogLevel) {
|
|
104
|
-
errorStructure =
|
|
104
|
+
errorStructure = { logLevel: this.logLevel, ...errorStructure };
|
|
105
105
|
}
|
|
106
106
|
if (this.alert) {
|
|
107
|
-
config =
|
|
108
|
-
errorStructure =
|
|
107
|
+
config = { alert: this.alert, ...config };
|
|
108
|
+
errorStructure = { config, ...errorStructure };
|
|
109
109
|
}
|
|
110
110
|
if (this.notification) {
|
|
111
|
-
config =
|
|
112
|
-
errorStructure =
|
|
111
|
+
config = { notification: this.notification, ...config };
|
|
112
|
+
errorStructure = { config, ...errorStructure };
|
|
113
113
|
}
|
|
114
114
|
if (this.banner) {
|
|
115
|
-
config =
|
|
116
|
-
errorStructure =
|
|
115
|
+
config = { banner: this.banner, ...config };
|
|
116
|
+
errorStructure = { config, ...errorStructure };
|
|
117
117
|
}
|
|
118
118
|
if (this.snackbar) {
|
|
119
|
-
config =
|
|
120
|
-
errorStructure =
|
|
119
|
+
config = { snackbar: this.snackbar, ...config };
|
|
120
|
+
errorStructure = { config, ...errorStructure };
|
|
121
121
|
}
|
|
122
122
|
if (this.dialog) {
|
|
123
|
-
config =
|
|
124
|
-
errorStructure =
|
|
123
|
+
config = { dialog: this.dialog, ...config };
|
|
124
|
+
errorStructure = { config, ...errorStructure };
|
|
125
125
|
}
|
|
126
126
|
return errorStructure;
|
|
127
127
|
}
|
|
@@ -27,7 +27,7 @@ export const showError = (error, tagName, errorBoundary) => {
|
|
|
27
27
|
message: getErrorDetails(error),
|
|
28
28
|
level: getLoglevel(error),
|
|
29
29
|
});
|
|
30
|
-
const keys = Object.keys(
|
|
30
|
+
const keys = Object.keys(error?.config || {});
|
|
31
31
|
keys.forEach((key) => {
|
|
32
32
|
if (errorTypeToComponentMap[key]) {
|
|
33
33
|
errorTypeToComponentMap[key](error, tagName, errorBoundary);
|
package/dist/esm/error-util.js
CHANGED
|
@@ -6,9 +6,8 @@ import { LogLevel } from '@genesislcap/foundation-utils';
|
|
|
6
6
|
* @returns The title and error details concatenated as a string, or default values ('Error: Something went wrong') if not present
|
|
7
7
|
*/
|
|
8
8
|
export const getErrorDetails = (details) => {
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const errorDetails = (_b = details === null || details === void 0 ? void 0 : details.errorDetails) !== null && _b !== void 0 ? _b : 'Something went wrong';
|
|
9
|
+
const title = details?.title ?? 'Error';
|
|
10
|
+
const errorDetails = details?.errorDetails ?? 'Something went wrong';
|
|
12
11
|
return `${title}: ${errorDetails}`;
|
|
13
12
|
};
|
|
14
13
|
/**
|
|
@@ -18,8 +17,7 @@ export const getErrorDetails = (details) => {
|
|
|
18
17
|
* @returns The log level or the default value (LogLevel.Error) if not present
|
|
19
18
|
*/
|
|
20
19
|
export const getLoglevel = (details) => {
|
|
21
|
-
|
|
22
|
-
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.Error;
|
|
20
|
+
return details?.logLevel || details?.config?.logLevel || LogLevel.Error;
|
|
23
21
|
};
|
|
24
22
|
/**
|
|
25
23
|
* Get/Create the error container in the DOM
|
|
@@ -47,14 +45,13 @@ export const getErrorContainer = (id, tagName) => {
|
|
|
47
45
|
* @returns
|
|
48
46
|
*/
|
|
49
47
|
export const getErrorBannerAnchor = (element) => {
|
|
50
|
-
var _a, _b;
|
|
51
48
|
while (element && !(element instanceof ShadowRoot)) {
|
|
52
|
-
const anchor =
|
|
49
|
+
const anchor = element?.getRootNode()?.getElementById('error-banner-anchor');
|
|
53
50
|
if (anchor) {
|
|
54
51
|
anchor.style.position = 'relative';
|
|
55
52
|
return anchor;
|
|
56
53
|
}
|
|
57
|
-
element =
|
|
54
|
+
element = element?.getRootNode()?.host;
|
|
58
55
|
}
|
|
59
56
|
return createErrorBannerContainer();
|
|
60
57
|
};
|
|
@@ -50,16 +50,16 @@ export class NotificationBuilder {
|
|
|
50
50
|
build() {
|
|
51
51
|
let notification = {};
|
|
52
52
|
if (this.position) {
|
|
53
|
-
notification =
|
|
53
|
+
notification = { position: this.position, ...notification };
|
|
54
54
|
}
|
|
55
55
|
if (this.autoClose) {
|
|
56
|
-
notification =
|
|
56
|
+
notification = { autoClose: this.autoClose, ...notification };
|
|
57
57
|
}
|
|
58
58
|
if (this.closeTimeout) {
|
|
59
|
-
notification =
|
|
59
|
+
notification = { closeTimeout: this.closeTimeout, ...notification };
|
|
60
60
|
}
|
|
61
61
|
if (this.type) {
|
|
62
|
-
notification =
|
|
62
|
+
notification = { type: this.type, ...notification };
|
|
63
63
|
}
|
|
64
64
|
return notification;
|
|
65
65
|
}
|
|
@@ -7,12 +7,11 @@ import { getErrorContainer } from '../error-util';
|
|
|
7
7
|
* @returns
|
|
8
8
|
* */
|
|
9
9
|
export const showNotification = (error, tagName) => {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
11
10
|
const tagPrefix = tagName.split('-')[0];
|
|
12
11
|
const container = getErrorContainer('notify-container', tagName);
|
|
13
12
|
if (container) {
|
|
14
13
|
container.style.position = 'fixed';
|
|
15
|
-
switch (
|
|
14
|
+
switch (error?.config?.notification?.position) {
|
|
16
15
|
case 'top-left':
|
|
17
16
|
container.style.top = '0';
|
|
18
17
|
container.style.left = '0';
|
|
@@ -33,19 +32,19 @@ export const showNotification = (error, tagName) => {
|
|
|
33
32
|
const toastNotify = document.createElement(`${tagPrefix}-toast`);
|
|
34
33
|
const errorTitle = document.createElement('div');
|
|
35
34
|
errorTitle.setAttribute('slot', 'top');
|
|
36
|
-
errorTitle.textContent =
|
|
35
|
+
errorTitle.textContent = error.title ?? 'Error';
|
|
37
36
|
const errorDetails = document.createElement('div');
|
|
38
37
|
errorDetails.setAttribute('slot', 'content');
|
|
39
|
-
errorDetails.textContent =
|
|
38
|
+
errorDetails.textContent = error?.errorDetails || '';
|
|
40
39
|
const errorDate = document.createElement('div');
|
|
41
40
|
errorDate.setAttribute('slot', 'date');
|
|
42
41
|
errorDate.textContent = new Date().toLocaleTimeString();
|
|
43
|
-
toastNotify.setAttribute('notify',
|
|
44
|
-
|
|
45
|
-
? toastNotify.setAttribute('auto-close', `${
|
|
42
|
+
toastNotify.setAttribute('notify', error?.config?.notification?.type || '');
|
|
43
|
+
error?.config?.notification?.autoClose
|
|
44
|
+
? toastNotify.setAttribute('auto-close', `${error?.config?.notification?.autoClose}`)
|
|
46
45
|
: '';
|
|
47
|
-
|
|
48
|
-
? toastNotify.setAttribute('close-timeout', `${
|
|
46
|
+
error?.config?.notification?.closeTimeout
|
|
47
|
+
? toastNotify.setAttribute('close-timeout', `${error?.config?.notification?.closeTimeout}`)
|
|
49
48
|
: '';
|
|
50
49
|
toastNotify.appendChild(errorTitle);
|
|
51
50
|
toastNotify.appendChild(errorDetails);
|
|
@@ -34,10 +34,10 @@ export class SnackbarBuilder {
|
|
|
34
34
|
build() {
|
|
35
35
|
let snackbar = {};
|
|
36
36
|
if (this.confirmingActions) {
|
|
37
|
-
snackbar =
|
|
37
|
+
snackbar = { confirmingActions: this.confirmingActions, ...snackbar };
|
|
38
38
|
}
|
|
39
39
|
if (this.type !== undefined) {
|
|
40
|
-
snackbar =
|
|
40
|
+
snackbar = { type: this.type, ...snackbar };
|
|
41
41
|
}
|
|
42
42
|
return snackbar;
|
|
43
43
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-errors",
|
|
3
3
|
"description": "Genesis Foundation UI Error Utils",
|
|
4
|
-
"version": "14.70.
|
|
4
|
+
"version": "14.70.4-es2021.1",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"test:debug": "genx test --debug"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@genesislcap/foundation-testing": "14.70.
|
|
41
|
-
"@genesislcap/genx": "14.70.
|
|
40
|
+
"@genesislcap/foundation-testing": "14.70.4-es2021.1",
|
|
41
|
+
"@genesislcap/genx": "14.70.4-es2021.1",
|
|
42
42
|
"rimraf": "^3.0.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@genesislcap/foundation-utils": "14.70.
|
|
45
|
+
"@genesislcap/foundation-utils": "14.70.4-es2021.1",
|
|
46
46
|
"@microsoft/fast-element": "^1.7.0",
|
|
47
47
|
"tslib": "^2.3.1"
|
|
48
48
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "5d0d8ee36cfd068cfc6211033b326d0a978cfc05"
|
|
58
58
|
}
|