@genesislcap/foundation-errors 13.2.0-pa-659.2 → 13.3.0

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.
@@ -0,0 +1,10 @@
1
+ import { ErrorStructure } from '../types';
2
+ /**
3
+ * Shows the error dialog
4
+ * @public
5
+ * @param error - The ErrorStructure object
6
+ * @param tagName - The tag name to create prefix for the design system provider & error component
7
+ * @returns
8
+ * */
9
+ export declare const showBanner: (error: ErrorStructure, tagName: String, errorBoundary: HTMLElement) => void;
10
+ //# sourceMappingURL=error-banner-launcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-banner-launcher.d.ts","sourceRoot":"","sources":["../../../src/banner/error-banner-launcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAsB,MAAM,UAAU,CAAC;AAE9D;;;;;;KAMK;AACL,eAAO,MAAM,UAAU,UACd,cAAc,WACZ,MAAM,iBACA,WAAW,KACzB,IAaF,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './error-banner-builder';
2
+ export * from './error-banner-launcher';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/banner/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/banner/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"}
@@ -4,7 +4,8 @@ import { ErrorStructure } from './types';
4
4
  * @public
5
5
  * @param error - The ErrorStructure object
6
6
  * @param tagName - The tag name to create prefix for the design system provider *
7
+ * @param errorBoundary - The error boundary element
7
8
  * @returns
8
9
  * */
9
- export declare const showError: (error: ErrorStructure, tagName: String) => void;
10
+ export declare const showError: (error: ErrorStructure, tagName: String, errorBoundary?: HTMLElement) => void;
10
11
  //# sourceMappingURL=error-launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-launcher.d.ts","sourceRoot":"","sources":["../../src/error-launcher.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAazC;;;;;;KAMK;AACL,eAAO,MAAM,SAAS,UAAW,cAAc,WAAW,MAAM,KAAG,IAWlE,CAAC"}
1
+ {"version":3,"file":"error-launcher.d.ts","sourceRoot":"","sources":["../../src/error-launcher.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAczC;;;;;;;KAOK;AACL,eAAO,MAAM,SAAS,UACb,cAAc,WACZ,MAAM,kBACC,WAAW,KAC1B,IAWF,CAAC"}
@@ -22,4 +22,11 @@ export declare const getLoglevel: (details: ErrorStructure) => LogLevel;
22
22
  * @returns
23
23
  */
24
24
  export declare const getErrorContainer: (id: string, tagName: String) => HTMLElement;
25
+ /**
26
+ * Get the error banner anchor to attach the banner to
27
+ * @public
28
+ * @param element - The element to start searching from
29
+ * @returns
30
+ */
31
+ export declare const getErrorBannerAnchor: (element: any) => HTMLElement | null;
25
32
  //# sourceMappingURL=error-util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-util.d.ts","sourceRoot":"","sources":["../../src/error-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,YAAa,cAAc,KAAG,MAIzD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,YAAa,cAAc,KAAG,QAErD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,OAAQ,MAAM,WAAW,MAAM,KAAG,WAa/D,CAAC"}
1
+ {"version":3,"file":"error-util.d.ts","sourceRoot":"","sources":["../../src/error-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,eAAe,YAAa,cAAc,KAAG,MAIzD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,YAAa,cAAc,KAAG,QAErD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,OAAQ,MAAM,WAAW,MAAM,KAAG,WAa/D,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,oBAAoB,YAAa,GAAG,KAAG,WAAW,GAAG,IAUjE,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { getErrorBannerAnchor } from '../error-util';
2
+ /**
3
+ * Shows the error dialog
4
+ * @public
5
+ * @param error - The ErrorStructure object
6
+ * @param tagName - The tag name to create prefix for the design system provider & error component
7
+ * @returns
8
+ * */
9
+ export const showBanner = (error, tagName, errorBoundary) => {
10
+ var _a;
11
+ const tagPrefix = tagName.split('-')[0];
12
+ const banner = document.createElement(`${tagPrefix}-error-banner`);
13
+ 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) {
15
+ banner.style.position = 'absolute';
16
+ banner.style.top = '0';
17
+ banner.style.left = '0';
18
+ banner.style.width = '100%';
19
+ }
20
+ container.appendChild(banner);
21
+ banner.error = error;
22
+ };
@@ -1 +1,2 @@
1
1
  export * from './error-banner-builder';
2
+ export * from './error-banner-launcher';
@@ -1,4 +1,5 @@
1
1
  import { createLogger } from '@genesislcap/foundation-utils';
2
+ import { showBanner } from './banner';
2
3
  import { showDialog } from './dialog';
3
4
  import { getErrorDetails, getLoglevel } from './error-util';
4
5
  import { showNotification } from './notification';
@@ -11,15 +12,17 @@ const errorTypeToComponentMap = {
11
12
  notification: showNotification,
12
13
  dialog: showDialog,
13
14
  snackbar: showSnackbar,
15
+ banner: showBanner,
14
16
  };
15
17
  /**
16
18
  * Shows the error in the appropriate component
17
19
  * @public
18
20
  * @param error - The ErrorStructure object
19
21
  * @param tagName - The tag name to create prefix for the design system provider *
22
+ * @param errorBoundary - The error boundary element
20
23
  * @returns
21
24
  * */
22
- export const showError = (error, tagName) => {
25
+ export const showError = (error, tagName, errorBoundary) => {
23
26
  logger.log({
24
27
  message: getErrorDetails(error),
25
28
  level: getLoglevel(error),
@@ -27,7 +30,7 @@ export const showError = (error, tagName) => {
27
30
  const keys = Object.keys((error === null || error === void 0 ? void 0 : error.config) || {});
28
31
  keys.forEach((key) => {
29
32
  if (errorTypeToComponentMap[key]) {
30
- errorTypeToComponentMap[key](error, tagName);
33
+ errorTypeToComponentMap[key](error, tagName, errorBoundary);
31
34
  }
32
35
  });
33
36
  };
@@ -40,3 +40,28 @@ export const getErrorContainer = (id, tagName) => {
40
40
  }
41
41
  return container;
42
42
  };
43
+ /**
44
+ * Get the error banner anchor to attach the banner to
45
+ * @public
46
+ * @param element - The element to start searching from
47
+ * @returns
48
+ */
49
+ export const getErrorBannerAnchor = (element) => {
50
+ var _a, _b;
51
+ 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');
53
+ if (anchor) {
54
+ anchor.style.position = 'relative';
55
+ return anchor;
56
+ }
57
+ element = (_b = element === null || element === void 0 ? void 0 : element.getRootNode()) === null || _b === void 0 ? void 0 : _b.host;
58
+ }
59
+ return createErrorBannerContainer();
60
+ };
61
+ const createErrorBannerContainer = () => {
62
+ const anchor = document.createElement('div');
63
+ anchor.setAttribute('id', 'error-banner-anchor');
64
+ anchor.style.position = 'relative';
65
+ document.body.insertBefore(anchor, document.body.firstChild);
66
+ return anchor;
67
+ };
@@ -1580,6 +1580,38 @@
1580
1580
  ],
1581
1581
  "extendsTokenRanges": []
1582
1582
  },
1583
+ {
1584
+ "kind": "Variable",
1585
+ "canonicalReference": "@genesislcap/foundation-errors!getErrorBannerAnchor:var",
1586
+ "docComment": "/**\n * Get the error banner anchor to attach the banner to\n *\n * @param element - The element to start searching from\n *\n * @returns \n *\n * @public\n */\n",
1587
+ "excerptTokens": [
1588
+ {
1589
+ "kind": "Content",
1590
+ "text": "getErrorBannerAnchor: "
1591
+ },
1592
+ {
1593
+ "kind": "Content",
1594
+ "text": "(element: any) => "
1595
+ },
1596
+ {
1597
+ "kind": "Reference",
1598
+ "text": "HTMLElement",
1599
+ "canonicalReference": "!HTMLElement:interface"
1600
+ },
1601
+ {
1602
+ "kind": "Content",
1603
+ "text": " | null"
1604
+ }
1605
+ ],
1606
+ "fileUrlPath": "src/error-util.ts",
1607
+ "isReadonly": true,
1608
+ "releaseTag": "Public",
1609
+ "name": "getErrorBannerAnchor",
1610
+ "variableTypeTokenRange": {
1611
+ "startIndex": 1,
1612
+ "endIndex": 4
1613
+ }
1614
+ },
1583
1615
  {
1584
1616
  "kind": "Variable",
1585
1617
  "canonicalReference": "@genesislcap/foundation-errors!getErrorBannerBuilder:var",
@@ -2025,10 +2057,60 @@
2025
2057
  ],
2026
2058
  "implementsTokenRanges": []
2027
2059
  },
2060
+ {
2061
+ "kind": "Variable",
2062
+ "canonicalReference": "@genesislcap/foundation-errors!showBanner:var",
2063
+ "docComment": "/**\n * Shows the error dialog\n *\n * @param error - The ErrorStructure object\n *\n * @param tagName - The tag name to create prefix for the design system provider & error component\n *\n * @returns \n *\n * @public\n */\n",
2064
+ "excerptTokens": [
2065
+ {
2066
+ "kind": "Content",
2067
+ "text": "showBanner: "
2068
+ },
2069
+ {
2070
+ "kind": "Content",
2071
+ "text": "(error: "
2072
+ },
2073
+ {
2074
+ "kind": "Reference",
2075
+ "text": "ErrorStructure",
2076
+ "canonicalReference": "@genesislcap/foundation-errors!ErrorStructure:interface"
2077
+ },
2078
+ {
2079
+ "kind": "Content",
2080
+ "text": ", tagName: "
2081
+ },
2082
+ {
2083
+ "kind": "Reference",
2084
+ "text": "String",
2085
+ "canonicalReference": "!String:interface"
2086
+ },
2087
+ {
2088
+ "kind": "Content",
2089
+ "text": ", errorBoundary: "
2090
+ },
2091
+ {
2092
+ "kind": "Reference",
2093
+ "text": "HTMLElement",
2094
+ "canonicalReference": "!HTMLElement:interface"
2095
+ },
2096
+ {
2097
+ "kind": "Content",
2098
+ "text": ") => void"
2099
+ }
2100
+ ],
2101
+ "fileUrlPath": "src/banner/error-banner-launcher.ts",
2102
+ "isReadonly": true,
2103
+ "releaseTag": "Public",
2104
+ "name": "showBanner",
2105
+ "variableTypeTokenRange": {
2106
+ "startIndex": 1,
2107
+ "endIndex": 8
2108
+ }
2109
+ },
2028
2110
  {
2029
2111
  "kind": "Variable",
2030
2112
  "canonicalReference": "@genesislcap/foundation-errors!showError:var",
2031
- "docComment": "/**\n * Shows the error in the appropriate component\n *\n * @param error - The ErrorStructure object\n *\n * @param tagName - The tag name to create prefix for the design system provider *\n *\n * @returns \n *\n * @public\n */\n",
2113
+ "docComment": "/**\n * Shows the error in the appropriate component\n *\n * @param error - The ErrorStructure object\n *\n * @param tagName - The tag name to create prefix for the design system provider *\n *\n * @param errorBoundary - The error boundary element\n *\n * @returns \n *\n * @public\n */\n",
2032
2114
  "excerptTokens": [
2033
2115
  {
2034
2116
  "kind": "Content",
@@ -2052,6 +2134,15 @@
2052
2134
  "text": "String",
2053
2135
  "canonicalReference": "!String:interface"
2054
2136
  },
2137
+ {
2138
+ "kind": "Content",
2139
+ "text": ", errorBoundary?: "
2140
+ },
2141
+ {
2142
+ "kind": "Reference",
2143
+ "text": "HTMLElement",
2144
+ "canonicalReference": "!HTMLElement:interface"
2145
+ },
2055
2146
  {
2056
2147
  "kind": "Content",
2057
2148
  "text": ") => void"
@@ -2063,7 +2154,7 @@
2063
2154
  "name": "showError",
2064
2155
  "variableTypeTokenRange": {
2065
2156
  "startIndex": 1,
2066
- "endIndex": 6
2157
+ "endIndex": 8
2067
2158
  }
2068
2159
  },
2069
2160
  {
@@ -229,6 +229,14 @@ export declare interface ErrorStructure {
229
229
  };
230
230
  }
231
231
 
232
+ /**
233
+ * Get the error banner anchor to attach the banner to
234
+ * @public
235
+ * @param element - The element to start searching from
236
+ * @returns
237
+ */
238
+ export declare const getErrorBannerAnchor: (element: any) => HTMLElement | null;
239
+
232
240
  /**
233
241
  * Get error banner builder instance
234
242
  * @public
@@ -320,6 +328,15 @@ export declare class NotificationBuilder {
320
328
  build(): ErrorNotification;
321
329
  }
322
330
 
331
+ /**
332
+ * Shows the error dialog
333
+ * @public
334
+ * @param error - The ErrorStructure object
335
+ * @param tagName - The tag name to create prefix for the design system provider & error component
336
+ * @returns
337
+ * */
338
+ export declare const showBanner: (error: ErrorStructure, tagName: String, errorBoundary: HTMLElement) => void;
339
+
323
340
  /**
324
341
  * Shows the error dialog
325
342
  * @internal
@@ -334,9 +351,10 @@ export declare const showDialog: (error: ErrorStructure, tagName: String) => voi
334
351
  * @public
335
352
  * @param error - The ErrorStructure object
336
353
  * @param tagName - The tag name to create prefix for the design system provider *
354
+ * @param errorBoundary - The error boundary element
337
355
  * @returns
338
356
  * */
339
- export declare const showError: (error: ErrorStructure, tagName: String) => void;
357
+ export declare const showError: (error: ErrorStructure, tagName: String, errorBoundary?: HTMLElement) => void;
340
358
 
341
359
  /**
342
360
  * Shows the error notification
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-errors](./foundation-errors.md) &gt; [getErrorBannerAnchor](./foundation-errors.geterrorbanneranchor.md)
4
+
5
+ ## getErrorBannerAnchor variable
6
+
7
+ Get the error banner anchor to attach the banner to
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ getErrorBannerAnchor: (element: any) => HTMLElement | null
13
+ ```
@@ -36,6 +36,7 @@
36
36
 
37
37
  | Variable | Description |
38
38
  | --- | --- |
39
+ | [getErrorBannerAnchor](./foundation-errors.geterrorbanneranchor.md) | Get the error banner anchor to attach the banner to |
39
40
  | [getErrorBannerBuilder](./foundation-errors.geterrorbannerbuilder.md) | Get error banner builder instance |
40
41
  | [getErrorBuilder](./foundation-errors.geterrorbuilder.md) | Returns a new ErrorBuilder instance |
41
42
  | [getErrorContainer](./foundation-errors.geterrorcontainer.md) | Get/Create the error container in the DOM |
@@ -44,6 +45,7 @@
44
45
  | [getLoglevel](./foundation-errors.getloglevel.md) | Retrieves the log level from an ErrorStructure object |
45
46
  | [getNotificationBuilder](./foundation-errors.getnotificationbuilder.md) | Get notification builder instance |
46
47
  | [getSnackbarBuilder](./foundation-errors.getsnackbarbuilder.md) | Get snackbar builder instance |
48
+ | [showBanner](./foundation-errors.showbanner.md) | Shows the error dialog |
47
49
  | [showError](./foundation-errors.showerror.md) | Shows the error in the appropriate component |
48
50
 
49
51
  ## Type Aliases
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-errors](./foundation-errors.md) &gt; [showBanner](./foundation-errors.showbanner.md)
4
+
5
+ ## showBanner variable
6
+
7
+ Shows the error dialog
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ showBanner: (error: ErrorStructure, tagName: String, errorBoundary: HTMLElement) => void
13
+ ```
@@ -9,5 +9,5 @@ Shows the error in the appropriate component
9
9
  **Signature:**
10
10
 
11
11
  ```typescript
12
- showError: (error: ErrorStructure, tagName: String) => void
12
+ showError: (error: ErrorStructure, tagName: String, errorBoundary?: HTMLElement) => void
13
13
  ```
@@ -117,6 +117,9 @@ export interface ErrorStructure {
117
117
  readonly title: string;
118
118
  }
119
119
 
120
+ // @public
121
+ export const getErrorBannerAnchor: (element: any) => HTMLElement | null;
122
+
120
123
  // @public
121
124
  export const getErrorBannerBuilder: () => ErrorBannerBuilder;
122
125
 
@@ -149,13 +152,16 @@ export class NotificationBuilder {
149
152
  withType(type: ErrorNotificationType): NotificationBuilder;
150
153
  }
151
154
 
155
+ // @public
156
+ export const showBanner: (error: ErrorStructure, tagName: String, errorBoundary: HTMLElement) => void;
157
+
152
158
  // Warning: (ae-internal-missing-underscore) The name "showDialog" should be prefixed with an underscore because the declaration is marked as @internal
153
159
  //
154
160
  // @internal
155
161
  export const showDialog: (error: ErrorStructure, tagName: String) => void;
156
162
 
157
163
  // @public
158
- export const showError: (error: ErrorStructure, tagName: String) => void;
164
+ export const showError: (error: ErrorStructure, tagName: String, errorBoundary?: HTMLElement) => void;
159
165
 
160
166
  // Warning: (ae-internal-missing-underscore) The name "showNotification" should be prefixed with an underscore because the declaration is marked as @internal
161
167
  //
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": "13.2.0-pa-659.2",
4
+ "version": "13.3.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -45,7 +45,7 @@
45
45
  "test:unit:watch": "watchlist src test -- npm run test:unit"
46
46
  },
47
47
  "devDependencies": {
48
- "@genesislcap/foundation-testing": "13.2.0-pa-659.2",
48
+ "@genesislcap/foundation-testing": "^13.3.0",
49
49
  "@module-federation/dashboard-plugin": "2.3.0",
50
50
  "@pixability-ui/federated-types": "^0.2.0",
51
51
  "@playwright/test": "^1.18.1",
@@ -83,7 +83,7 @@
83
83
  "webpack-merge": "^5.7.3"
84
84
  },
85
85
  "dependencies": {
86
- "@genesislcap/foundation-utils": "13.2.0-pa-659.2",
86
+ "@genesislcap/foundation-utils": "^13.3.0",
87
87
  "@microsoft/fast-element": "^1.7.0",
88
88
  "tslib": "^2.3.1"
89
89
  },
@@ -95,5 +95,5 @@
95
95
  "publishConfig": {
96
96
  "access": "public"
97
97
  },
98
- "gitHead": "fab6d0a578d7f47a19124b2cd9b7ce161c576619"
98
+ "gitHead": "e747be94876490deba62943d376f6e919dbb8cc2"
99
99
  }