@genesislcap/foundation-notifications 14.307.2 → 14.307.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"notification-util.d.ts","sourceRoot":"","sources":["../../src/notification-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA4BhD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,qBAAqB,KAAG,MAIvE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,qBAAqB,KAAG,QAE5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,uBAAuB,qBAAqB,SAK9E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,EAAE,SAAS,MAAM,KAAG,WA8BtE,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,eAAe,GAAI,SAAS,GAAG,KAAG,WAAW,GAAG,IAU5D,CAAC"}
1
+ {"version":3,"file":"notification-util.d.ts","sourceRoot":"","sources":["../../src/notification-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAOhD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,qBAAqB,KAAG,MAIvE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,qBAAqB,KAAG,QAE5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,uBAAuB,qBAAqB,SAK9E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,IAAI,MAAM,EAAE,SAAS,MAAM,KAAG,WAkDtE,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,eAAe,GAAI,SAAS,GAAG,KAAG,WAAW,GAAG,IAU5D,CAAC"}
@@ -1,28 +1,10 @@
1
1
  import { LogLevel } from '@genesislcap/foundation-logger';
2
- import { getCurrentDesignSystemPrefix } from '@genesislcap/foundation-utils';
2
+ import { getCurrentDesignSystem, getAllElements } from '@genesislcap/foundation-utils';
3
3
  import { logger } from './logger';
4
- /**
5
- * Get all elements including those in shadow DOM
6
- * @private
7
- */
8
- function getAllElements(root) {
9
- const elements = [];
10
- const processedShadowRoots = new Set();
11
- function collectElements(node) {
12
- // Get all elements in the current node
13
- const nodeElements = Array.from(node.querySelectorAll('*'));
14
- elements.push(...nodeElements);
15
- // Process shadow roots
16
- nodeElements.forEach((el) => {
17
- if (el.shadowRoot && !processedShadowRoots.has(el.shadowRoot)) {
18
- processedShadowRoots.add(el.shadowRoot);
19
- collectElements(el.shadowRoot);
20
- }
21
- });
22
- }
23
- collectElements(root);
24
- return elements;
25
- }
4
+ // Cache for the design system provider to avoid expensive DOM traversal
5
+ let cachedProvider = null;
6
+ // Cache for existing notification containers to avoid expensive DOM traversal
7
+ const cachedContainers = new Map();
26
8
  /**
27
9
  * Retrieves the notification details from an NotificationStructure object
28
10
  * @public
@@ -65,28 +47,44 @@ export const showLoggerLogLevel = (notificationStructure) => {
65
47
  */
66
48
  export const getNotificationContainer = (id, tagName) => {
67
49
  let container = document.querySelector(`#${id}`);
50
+ // If not found in light DOM, check cache first, then search deeply including shadow roots
51
+ if (!container) {
52
+ // Check cache first
53
+ if (cachedContainers.has(id)) {
54
+ container = cachedContainers.get(id);
55
+ }
56
+ else {
57
+ // Search deeply and cache the result
58
+ const deepElements = getAllElements(document);
59
+ const found = deepElements.find((el) => el.id === id);
60
+ if (found) {
61
+ container = found;
62
+ cachedContainers.set(id, found);
63
+ }
64
+ }
65
+ }
68
66
  if (!container) {
69
67
  container = document.createElement('div');
70
68
  container.setAttribute('id', id);
71
69
  container.style.zIndex = '9999';
72
- // Get the current design system prefix using the existing utility
73
- const currentPrefix = getCurrentDesignSystemPrefix(document.body, 'rapid');
74
- // Search for existing provider including shadow DOMs
75
- const allElements = getAllElements(document);
76
- const existingProvider = allElements.find((el) => {
77
- var _a;
78
- const elementTagName = (_a = el.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
79
- return elementTagName === `${currentPrefix}-design-system-provider`;
80
- });
81
- if (existingProvider) {
82
- // Use existing provider
83
- existingProvider.appendChild(container);
70
+ // Get the current design system provider and prefix in one call
71
+ const { element: providerElement, prefix: currentPrefix } = getCurrentDesignSystem(document.body, 'rapid');
72
+ // Use the found provider element if available, otherwise use cached provider or find it
73
+ if (providerElement) {
74
+ // We already have the provider element, use it directly
75
+ providerElement.appendChild(container);
76
+ cachedProvider = providerElement;
77
+ }
78
+ else if (cachedProvider) {
79
+ // Use existing cached provider
80
+ cachedProvider.appendChild(container);
84
81
  }
85
82
  else {
86
83
  // Only create new provider if none exists
87
84
  const dsProvider = document.createElement(`${currentPrefix}-design-system-provider`);
88
85
  dsProvider.appendChild(container);
89
86
  document.body.appendChild(dsProvider);
87
+ cachedProvider = dsProvider;
90
88
  }
91
89
  }
92
90
  return container;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-notifications",
3
3
  "description": "Genesis Foundation UI Notifications Utils",
4
- "version": "14.307.2",
4
+ "version": "14.307.3",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -49,17 +49,17 @@
49
49
  }
50
50
  },
51
51
  "devDependencies": {
52
- "@genesislcap/foundation-testing": "14.307.2",
53
- "@genesislcap/genx": "14.307.2",
54
- "@genesislcap/rollup-builder": "14.307.2",
55
- "@genesislcap/ts-builder": "14.307.2",
56
- "@genesislcap/uvu-playwright-builder": "14.307.2",
57
- "@genesislcap/vite-builder": "14.307.2",
58
- "@genesislcap/webpack-builder": "14.307.2"
52
+ "@genesislcap/foundation-testing": "14.307.3",
53
+ "@genesislcap/genx": "14.307.3",
54
+ "@genesislcap/rollup-builder": "14.307.3",
55
+ "@genesislcap/ts-builder": "14.307.3",
56
+ "@genesislcap/uvu-playwright-builder": "14.307.3",
57
+ "@genesislcap/vite-builder": "14.307.3",
58
+ "@genesislcap/webpack-builder": "14.307.3"
59
59
  },
60
60
  "dependencies": {
61
- "@genesislcap/foundation-logger": "14.307.2",
62
- "@genesislcap/foundation-utils": "14.307.2"
61
+ "@genesislcap/foundation-logger": "14.307.3",
62
+ "@genesislcap/foundation-utils": "14.307.3"
63
63
  },
64
64
  "repository": {
65
65
  "type": "git",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "a3bfd4199f20640443c512431840c7e8dedc5b4c"
72
+ "gitHead": "a6bf424ee6ddd2dee5758ca81d960dc1308b1bb0"
73
73
  }