@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.
@@ -34,10 +34,10 @@ export class ErrorBannerBuilder {
34
34
  build() {
35
35
  let errorBanner = {};
36
36
  if (this.dismissingAction) {
37
- errorBanner = Object.assign({ dismissingAction: this.dismissingAction }, errorBanner);
37
+ errorBanner = { dismissingAction: this.dismissingAction, ...errorBanner };
38
38
  }
39
39
  if (this.confirmingActions) {
40
- errorBanner = Object.assign({ confirmingActions: this.confirmingActions }, 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 (((_a = container === null || container === void 0 ? void 0 : container.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
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 = Object.assign({ dismissingAction: this.dismissingAction }, errorDialog);
37
+ errorDialog = { dismissingAction: this.dismissingAction, ...errorDialog };
38
38
  }
39
39
  if (this.confirmingActions) {
40
- errorDialog = Object.assign({ confirmingActions: this.confirmingActions }, 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 = Object.assign({ logLevel: this.logLevel }, errorStructure);
104
+ errorStructure = { logLevel: this.logLevel, ...errorStructure };
105
105
  }
106
106
  if (this.alert) {
107
- config = Object.assign({ alert: this.alert }, config);
108
- errorStructure = Object.assign({ config }, errorStructure);
107
+ config = { alert: this.alert, ...config };
108
+ errorStructure = { config, ...errorStructure };
109
109
  }
110
110
  if (this.notification) {
111
- config = Object.assign({ notification: this.notification }, config);
112
- errorStructure = Object.assign({ config }, errorStructure);
111
+ config = { notification: this.notification, ...config };
112
+ errorStructure = { config, ...errorStructure };
113
113
  }
114
114
  if (this.banner) {
115
- config = Object.assign({ banner: this.banner }, config);
116
- errorStructure = Object.assign({ config }, errorStructure);
115
+ config = { banner: this.banner, ...config };
116
+ errorStructure = { config, ...errorStructure };
117
117
  }
118
118
  if (this.snackbar) {
119
- config = Object.assign({ snackbar: this.snackbar }, config);
120
- errorStructure = Object.assign({ config }, errorStructure);
119
+ config = { snackbar: this.snackbar, ...config };
120
+ errorStructure = { config, ...errorStructure };
121
121
  }
122
122
  if (this.dialog) {
123
- config = Object.assign({ dialog: this.dialog }, config);
124
- errorStructure = Object.assign({ config }, 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((error === null || error === void 0 ? void 0 : error.config) || {});
30
+ const keys = Object.keys(error?.config || {});
31
31
  keys.forEach((key) => {
32
32
  if (errorTypeToComponentMap[key]) {
33
33
  errorTypeToComponentMap[key](error, tagName, errorBoundary);
@@ -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
- var _a, _b;
10
- const title = (_a = details === null || details === void 0 ? void 0 : details.title) !== null && _a !== void 0 ? _a : 'Error';
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
- var _a;
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 = (_a = element === null || element === void 0 ? void 0 : element.getRootNode()) === null || _a === void 0 ? void 0 : _a.getElementById('error-banner-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 = (_b = element === null || element === void 0 ? void 0 : element.getRootNode()) === null || _b === void 0 ? void 0 : _b.host;
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 = Object.assign({ position: this.position }, notification);
53
+ notification = { position: this.position, ...notification };
54
54
  }
55
55
  if (this.autoClose) {
56
- notification = Object.assign({ autoClose: this.autoClose }, notification);
56
+ notification = { autoClose: this.autoClose, ...notification };
57
57
  }
58
58
  if (this.closeTimeout) {
59
- notification = Object.assign({ closeTimeout: this.closeTimeout }, notification);
59
+ notification = { closeTimeout: this.closeTimeout, ...notification };
60
60
  }
61
61
  if (this.type) {
62
- notification = Object.assign({ type: this.type }, 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 ((_b = (_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.notification) === null || _b === void 0 ? void 0 : _b.position) {
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 = (_c = error.title) !== null && _c !== void 0 ? _c : 'Error';
35
+ errorTitle.textContent = error.title ?? 'Error';
37
36
  const errorDetails = document.createElement('div');
38
37
  errorDetails.setAttribute('slot', 'content');
39
- errorDetails.textContent = (error === null || error === void 0 ? void 0 : error.errorDetails) || '';
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', ((_e = (_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.notification) === null || _e === void 0 ? void 0 : _e.type) || '');
44
- ((_g = (_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.notification) === null || _g === void 0 ? void 0 : _g.autoClose)
45
- ? toastNotify.setAttribute('auto-close', `${(_j = (_h = error === null || error === void 0 ? void 0 : error.config) === null || _h === void 0 ? void 0 : _h.notification) === null || _j === void 0 ? void 0 : _j.autoClose}`)
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
- ((_l = (_k = error === null || error === void 0 ? void 0 : error.config) === null || _k === void 0 ? void 0 : _k.notification) === null || _l === void 0 ? void 0 : _l.closeTimeout)
48
- ? toastNotify.setAttribute('close-timeout', `${(_o = (_m = error === null || error === void 0 ? void 0 : error.config) === null || _m === void 0 ? void 0 : _m.notification) === null || _o === void 0 ? void 0 : _o.closeTimeout}`)
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 = Object.assign({ confirmingActions: this.confirmingActions }, snackbar);
37
+ snackbar = { confirmingActions: this.confirmingActions, ...snackbar };
38
38
  }
39
39
  if (this.type !== undefined) {
40
- snackbar = Object.assign({ type: this.type }, 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.3",
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.3",
41
- "@genesislcap/genx": "14.70.3",
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.3",
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": "2bd15e0c3928fa0fbfa60ccb7e4f89e956afda73"
57
+ "gitHead": "5d0d8ee36cfd068cfc6211033b326d0a978cfc05"
58
58
  }