@pure-ds/core 0.4.37 → 0.5.2

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.
Files changed (146) hide show
  1. package/dist/types/pds.d.ts +34 -11
  2. package/dist/types/public/assets/auto-definer-XWHRBQPU.d.ts +9 -0
  3. package/dist/types/public/assets/auto-definer-XWHRBQPU.d.ts.map +1 -0
  4. package/dist/types/public/assets/chunk-746HIXIK.d.ts +52 -0
  5. package/dist/types/public/assets/chunk-746HIXIK.d.ts.map +1 -0
  6. package/dist/types/public/assets/chunk-APJV5T3J.d.ts +106 -0
  7. package/dist/types/public/assets/chunk-APJV5T3J.d.ts.map +1 -0
  8. package/dist/types/public/assets/chunk-BEPKFFM7.d.ts +398 -0
  9. package/dist/types/public/assets/chunk-BEPKFFM7.d.ts.map +1 -0
  10. package/dist/types/public/assets/chunk-ISS7UH5H.d.ts +2424 -0
  11. package/dist/types/public/assets/chunk-ISS7UH5H.d.ts.map +1 -0
  12. package/dist/types/public/assets/chunk-RUPLQUDG.d.ts +582 -0
  13. package/dist/types/public/assets/chunk-RUPLQUDG.d.ts.map +1 -0
  14. package/dist/types/public/assets/chunk-USML4NYF.d.ts +18 -0
  15. package/dist/types/public/assets/chunk-USML4NYF.d.ts.map +1 -0
  16. package/dist/types/public/assets/chunk-Z47A3HLT.d.ts +3 -0
  17. package/dist/types/public/assets/chunk-Z47A3HLT.d.ts.map +1 -0
  18. package/dist/types/public/assets/js/auto-definer-HZLD2XF4.d.ts +9 -0
  19. package/dist/types/public/assets/js/auto-definer-HZLD2XF4.d.ts.map +1 -0
  20. package/dist/types/public/assets/js/chunk-6A6DFAIG.d.ts +88 -0
  21. package/dist/types/public/assets/js/chunk-6A6DFAIG.d.ts.map +1 -0
  22. package/dist/types/public/assets/js/chunk-746HIXIK.d.ts +52 -0
  23. package/dist/types/public/assets/js/chunk-746HIXIK.d.ts.map +1 -0
  24. package/dist/types/public/assets/js/chunk-A3TZGIYX.d.ts +4 -0
  25. package/dist/types/public/assets/js/chunk-A3TZGIYX.d.ts.map +1 -0
  26. package/dist/types/public/assets/js/chunk-BEPKFFM7.d.ts +398 -0
  27. package/dist/types/public/assets/js/chunk-BEPKFFM7.d.ts.map +1 -0
  28. package/dist/types/public/assets/js/chunk-OTTRJ5MB.d.ts +1695 -0
  29. package/dist/types/public/assets/js/chunk-OTTRJ5MB.d.ts.map +1 -0
  30. package/dist/types/public/assets/js/chunk-RBPKHG76.d.ts +747 -0
  31. package/dist/types/public/assets/js/chunk-RBPKHG76.d.ts.map +1 -0
  32. package/dist/types/public/assets/js/chunk-RUPLQUDG.d.ts +582 -0
  33. package/dist/types/public/assets/js/chunk-RUPLQUDG.d.ts.map +1 -0
  34. package/dist/types/public/assets/js/chunk-SMD2R3CX.d.ts +68 -0
  35. package/dist/types/public/assets/js/chunk-SMD2R3CX.d.ts.map +1 -0
  36. package/dist/types/public/assets/js/chunk-Y73DA2D5.d.ts +15 -0
  37. package/dist/types/public/assets/js/chunk-Y73DA2D5.d.ts.map +1 -0
  38. package/dist/types/public/assets/js/chunks/auto-definer-X7MSXKTU.d.ts +9 -0
  39. package/dist/types/public/assets/js/chunks/auto-definer-X7MSXKTU.d.ts.map +1 -0
  40. package/dist/types/public/assets/js/chunks/chunk-7BDQH5CT.d.ts +485 -0
  41. package/dist/types/public/assets/js/chunks/chunk-7BDQH5CT.d.ts.map +1 -0
  42. package/dist/types/public/assets/js/chunks/chunk-MWB3S7NG.d.ts +3 -0
  43. package/dist/types/public/assets/js/chunks/chunk-MWB3S7NG.d.ts.map +1 -0
  44. package/dist/types/public/assets/js/chunks/chunk-WIMLORAU.d.ts +5 -0
  45. package/dist/types/public/assets/js/chunks/chunk-WIMLORAU.d.ts.map +1 -0
  46. package/dist/types/public/assets/js/chunks/chunk-WN4Y2ELN.d.ts +833 -0
  47. package/dist/types/public/assets/js/chunks/chunk-WN4Y2ELN.d.ts.map +1 -0
  48. package/dist/types/public/assets/js/chunks/chunk-XQOUIBLO.d.ts +1687 -0
  49. package/dist/types/public/assets/js/chunks/chunk-XQOUIBLO.d.ts.map +1 -0
  50. package/dist/types/public/assets/js/chunks/font-loader-VN5SRNOD.d.ts +5 -0
  51. package/dist/types/public/assets/js/chunks/font-loader-VN5SRNOD.d.ts.map +1 -0
  52. package/dist/types/public/assets/js/chunks/pds-live-validation-BQPWN5JG.d.ts +38 -0
  53. package/dist/types/public/assets/js/chunks/pds-live-validation-BQPWN5JG.d.ts.map +1 -0
  54. package/dist/types/public/assets/js/common-WIAC4WAJ.d.ts +4 -0
  55. package/dist/types/public/assets/js/common-WIAC4WAJ.d.ts.map +1 -0
  56. package/dist/types/public/assets/js/pds-config-WEBAXXSM.d.ts +4 -0
  57. package/dist/types/public/assets/js/pds-config-WEBAXXSM.d.ts.map +1 -0
  58. package/dist/types/public/assets/js/pds-core/pds-generator.d.ts +700 -0
  59. package/dist/types/public/assets/js/pds-core/pds-generator.d.ts.map +1 -0
  60. package/dist/types/public/assets/js/pds-core/pds-utilities.d.ts +27 -0
  61. package/dist/types/public/assets/js/pds-core/pds-utilities.d.ts.map +1 -0
  62. package/dist/types/public/assets/js/pds-enums-DCBZHS64.d.ts +3 -0
  63. package/dist/types/public/assets/js/pds-enums-DCBZHS64.d.ts.map +1 -0
  64. package/dist/types/public/assets/js/pds-gen.d.ts +106 -0
  65. package/dist/types/public/assets/js/pds-gen.d.ts.map +1 -0
  66. package/dist/types/public/assets/js/pds-live.d.ts +11 -0
  67. package/dist/types/public/assets/js/pds-live.d.ts.map +1 -0
  68. package/dist/types/public/assets/js/pds-manager.d.ts +1047 -0
  69. package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -0
  70. package/dist/types/public/assets/js/pds-ontology-2DICJXHO.d.ts +9 -0
  71. package/dist/types/public/assets/js/pds-ontology-2DICJXHO.d.ts.map +1 -0
  72. package/dist/types/public/assets/js/pds-query-B54LBKKR.d.ts +70 -0
  73. package/dist/types/public/assets/js/pds-query-B54LBKKR.d.ts.map +1 -0
  74. package/dist/types/public/assets/js/pds.d.ts +1 -18
  75. package/dist/types/public/assets/js/pds.d.ts.map +1 -1
  76. package/dist/types/public/assets/pds-ontology-ZO6TJHO3.d.ts +9 -0
  77. package/dist/types/public/assets/pds-ontology-ZO6TJHO3.d.ts.map +1 -0
  78. package/dist/types/src/js/common/pds-core/pds-config.d.ts +757 -0
  79. package/dist/types/src/js/common/pds-core/pds-config.d.ts.map +1 -0
  80. package/dist/types/src/js/common/pds-core/pds-enhancers.d.ts +28 -0
  81. package/dist/types/src/js/common/pds-core/pds-enhancers.d.ts.map +1 -0
  82. package/dist/types/src/js/common/pds-core/pds-enums.d.ts +87 -0
  83. package/dist/types/src/js/common/pds-core/pds-enums.d.ts.map +1 -0
  84. package/dist/types/src/js/common/pds-core/pds-generator.d.ts +700 -0
  85. package/dist/types/src/js/common/pds-core/pds-generator.d.ts.map +1 -0
  86. package/dist/types/src/js/common/pds-core/pds-ontology.d.ts +380 -0
  87. package/dist/types/src/js/common/pds-core/pds-ontology.d.ts.map +1 -0
  88. package/dist/types/src/js/common/pds-core/pds-paths.d.ts +37 -0
  89. package/dist/types/src/js/common/pds-core/pds-paths.d.ts.map +1 -0
  90. package/dist/types/src/js/common/pds-core/pds-query.d.ts +102 -0
  91. package/dist/types/src/js/common/pds-core/pds-query.d.ts.map +1 -0
  92. package/dist/types/src/js/common/pds-core/pds-registry.d.ts +35 -0
  93. package/dist/types/src/js/common/pds-core/pds-registry.d.ts.map +1 -0
  94. package/dist/types/src/js/common/pds-core/pds-utilities.d.ts +27 -0
  95. package/dist/types/src/js/common/pds-core/pds-utilities.d.ts.map +1 -0
  96. package/dist/types/src/js/pds-core/pds-generator.d.ts +38 -46
  97. package/dist/types/src/js/pds-core/pds-generator.d.ts.map +1 -1
  98. package/dist/types/src/js/pds-core/pds-live.d.ts +39 -0
  99. package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -0
  100. package/dist/types/src/js/pds-core/pds-runtime.d.ts +39 -0
  101. package/dist/types/src/js/pds-core/pds-runtime.d.ts.map +1 -0
  102. package/dist/types/src/js/pds-core/pds-start-helpers.d.ts +60 -0
  103. package/dist/types/src/js/pds-core/pds-start-helpers.d.ts.map +1 -0
  104. package/dist/types/src/js/pds-core/pds-utilities.d.ts +27 -0
  105. package/dist/types/src/js/pds-core/pds-utilities.d.ts.map +1 -0
  106. package/dist/types/src/js/pds-gen.d.ts +48 -0
  107. package/dist/types/src/js/pds-gen.d.ts.map +1 -0
  108. package/dist/types/src/js/pds-live-runtime.d.ts +7 -0
  109. package/dist/types/src/js/pds-live-runtime.d.ts.map +1 -0
  110. package/dist/types/src/js/pds-live-validation.d.ts +44 -0
  111. package/dist/types/src/js/pds-live-validation.d.ts.map +1 -0
  112. package/dist/types/src/js/pds-live.d.ts +11 -0
  113. package/dist/types/src/js/pds-live.d.ts.map +1 -0
  114. package/dist/types/src/js/pds-manager.d.ts +2 -0
  115. package/dist/types/src/js/pds-manager.d.ts.map +1 -0
  116. package/dist/types/src/js/pds.d.ts +6 -33
  117. package/dist/types/src/js/pds.d.ts.map +1 -1
  118. package/package.json +11 -12
  119. package/packages/pds-cli/bin/{generate-css-data.mjs → generate-css-data.js} +563 -563
  120. package/packages/pds-cli/bin/{generate-manifest.mjs → generate-manifest.js} +352 -352
  121. package/packages/pds-cli/bin/{pds-build-icons.mjs → pds-build-icons.js} +152 -152
  122. package/packages/pds-cli/bin/{pds-dx.mjs → pds-dx.js} +114 -114
  123. package/packages/pds-cli/bin/{pds-init-config.mjs → pds-init-config.js} +34 -34
  124. package/packages/pds-cli/bin/{pds-setup-copilot.mjs → pds-setup-copilot.js} +106 -106
  125. package/packages/pds-cli/bin/{pds-static.mjs → pds-static.js} +597 -581
  126. package/packages/pds-cli/bin/{pds.mjs → pds.js} +127 -127
  127. package/packages/pds-cli/bin/postinstall.mjs +522 -563
  128. package/packages/pds-cli/bin/{sync-assets.mjs → sync-assets.js} +251 -251
  129. package/packages/pds-cli/lib/{asset-roots.mjs → asset-roots.js} +47 -47
  130. package/packages/pds-cli/lib/{fs-writer.mjs → fs-writer.js} +75 -75
  131. package/public/assets/js/app.js +95 -118
  132. package/public/assets/js/pds-manager.js +3251 -0
  133. package/public/assets/js/pds.js +10 -3201
  134. package/readme.md +2014 -2016
  135. package/src/js/pds-core/pds-enhancers.js +518 -518
  136. package/src/js/pds-core/pds-enums.js +86 -86
  137. package/src/js/pds-core/pds-generator.js +255 -185
  138. package/src/js/pds-core/pds-live.js +434 -0
  139. package/src/js/pds-core/pds-paths.js +109 -109
  140. package/src/js/pds-core/pds-registry.js +79 -79
  141. package/src/js/pds-core/pds-runtime.js +184 -0
  142. package/src/js/pds-core/pds-start-helpers.js +405 -0
  143. package/src/js/pds.d.ts +34 -11
  144. package/src/js/pds.js +43 -1182
  145. package/getting-started.md +0 -626
  146. package/src/js/pds-core/pds.d.ts +0 -129
@@ -1,79 +1,79 @@
1
-
2
- // ============================================================================
3
- // PDS REGISTRY - Global mode manager for live vs static mode
4
- // ============================================================================
5
-
6
- class PDSRegistry {
7
- constructor() {
8
- this._mode = "static"; // Default to static mode
9
- this._staticPaths = {
10
- tokens: "/assets/pds/styles/pds-tokens.css.js",
11
- primitives: "/assets/pds/styles/pds-primitives.css.js",
12
- components: "/assets/pds/styles/pds-components.css.js",
13
- utilities: "/assets/pds/styles/pds-utilities.css.js",
14
- styles: "/assets/pds/styles/pds-styles.css.js",
15
- };
16
- }
17
-
18
- /**
19
- * Switch to live mode
20
- */
21
- setLiveMode() {
22
- this._mode = "live";
23
- }
24
-
25
- /**
26
- * Switch to static mode with custom paths
27
- * Called by consumers who want to use static CSS files
28
- */
29
- setStaticMode(paths = {}) {
30
- this._mode = "static";
31
- this._staticPaths = { ...this._staticPaths, ...paths };
32
- // Note: No access to config in static mode, using console
33
- console.log("[PDS Registry] Switched to STATIC mode", this._staticPaths);
34
- }
35
-
36
- /**
37
- * Get stylesheet for adoption in shadow DOM
38
- * Returns CSSStyleSheet object (constructable stylesheet)
39
- */
40
- async getStylesheet(layer) {
41
- if (this._mode === "live") {
42
- // In live mode, stylesheets should be retrieved from Generator.instance
43
- // If we are here, it means adoptLayers fell back or something is wrong
44
- return null;
45
- } else {
46
- // Import from static path
47
- try {
48
- const module = await import(/* @vite-ignore */ this._staticPaths[layer]);
49
- return module[layer]; // Return exported stylesheet
50
- } catch (error) {
51
- // No access to config in static mode, fall back to console
52
- console.error(`[PDS Registry] Failed to load static ${layer}:`, error);
53
- console.error(`[PDS Registry] Looking for: ${this._staticPaths[layer]}`);
54
- console.error(`[PDS Registry] Make sure you've run 'npm run pds:export' and configured PDS.start() with the correct static.root path`);
55
- // Return empty stylesheet as fallback
56
- const fallback = new CSSStyleSheet();
57
- fallback.replaceSync("/* Failed to load " + layer + " */");
58
- return fallback;
59
- }
60
- }
61
- }
62
-
63
- /**
64
- * Get current mode
65
- */
66
- get mode() {
67
- return this._mode;
68
- }
69
-
70
- /**
71
- * Check if in live mode
72
- */
73
- get isLive() {
74
- return this._mode === "live";
75
- }
76
- }
77
-
78
- // Export singleton instance
79
- export const registry = new PDSRegistry();
1
+
2
+ // ============================================================================
3
+ // PDS REGISTRY - Global mode manager for live vs static mode
4
+ // ============================================================================
5
+
6
+ class PDSRegistry {
7
+ constructor() {
8
+ this._mode = "static"; // Default to static mode
9
+ this._staticPaths = {
10
+ tokens: "/assets/pds/styles/pds-tokens.css.js",
11
+ primitives: "/assets/pds/styles/pds-primitives.css.js",
12
+ components: "/assets/pds/styles/pds-components.css.js",
13
+ utilities: "/assets/pds/styles/pds-utilities.css.js",
14
+ styles: "/assets/pds/styles/pds-styles.css.js",
15
+ };
16
+ }
17
+
18
+ /**
19
+ * Switch to live mode
20
+ */
21
+ setLiveMode() {
22
+ this._mode = "live";
23
+ }
24
+
25
+ /**
26
+ * Switch to static mode with custom paths
27
+ * Called by consumers who want to use static CSS files
28
+ */
29
+ setStaticMode(paths = {}) {
30
+ this._mode = "static";
31
+ this._staticPaths = { ...this._staticPaths, ...paths };
32
+ // Note: No access to config in static mode, using console
33
+ console.log("[PDS Registry] Switched to STATIC mode", this._staticPaths);
34
+ }
35
+
36
+ /**
37
+ * Get stylesheet for adoption in shadow DOM
38
+ * Returns CSSStyleSheet object (constructable stylesheet)
39
+ */
40
+ async getStylesheet(layer) {
41
+ if (this._mode === "live") {
42
+ // In live mode, stylesheets should be retrieved from Generator.instance
43
+ // If we are here, it means adoptLayers fell back or something is wrong
44
+ return null;
45
+ } else {
46
+ // Import from static path
47
+ try {
48
+ const module = await import(/* @vite-ignore */ this._staticPaths[layer]);
49
+ return module[layer]; // Return exported stylesheet
50
+ } catch (error) {
51
+ // No access to config in static mode, fall back to console
52
+ console.error(`[PDS Registry] Failed to load static ${layer}:`, error);
53
+ console.error(`[PDS Registry] Looking for: ${this._staticPaths[layer]}`);
54
+ console.error(`[PDS Registry] Make sure you've run 'npm run pds:export' and configured PDS.start() with the correct static.root path`);
55
+ // Return empty stylesheet as fallback
56
+ const fallback = new CSSStyleSheet();
57
+ fallback.replaceSync("/* Failed to load " + layer + " */");
58
+ return fallback;
59
+ }
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Get current mode
65
+ */
66
+ get mode() {
67
+ return this._mode;
68
+ }
69
+
70
+ /**
71
+ * Check if in live mode
72
+ */
73
+ get isLive() {
74
+ return this._mode === "live";
75
+ }
76
+ }
77
+
78
+ // Export singleton instance
79
+ export const registry = new PDSRegistry();
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Runtime helpers for applying and adopting PDS styles in live and static modes.
3
+ * These functions are intentionally separated from the Generator to keep the
4
+ * generator bundle lean and optional.
5
+ */
6
+ import { registry as pdsRegistry } from "./pds-registry.js";
7
+
8
+ /**
9
+ * Install runtime styles for PDS using constructable stylesheets when
10
+ * available, otherwise update a single <style id="pds-runtime-stylesheet">.
11
+ * This approach reduces flicker and avoids link/blob swapping.
12
+ */
13
+ export function installRuntimeStyles(cssText) {
14
+ try {
15
+ if (typeof document === "undefined") return; // server-side guard
16
+
17
+ // Preferred: constructable stylesheet (fast, atomic)
18
+ if (
19
+ typeof CSSStyleSheet !== "undefined" &&
20
+ "adoptedStyleSheets" in Document.prototype
21
+ ) {
22
+ const sheet = new CSSStyleSheet();
23
+ // replaceSync is synchronous and atomic for the stylesheet
24
+ sheet.replaceSync(cssText);
25
+
26
+ // Tag it so we can keep existing non-PDS sheets
27
+ sheet._pds = true;
28
+
29
+ const others = (document.adoptedStyleSheets || []).filter(
30
+ (s) => s._pds !== true
31
+ );
32
+ document.adoptedStyleSheets = [...others, sheet];
33
+ return;
34
+ }
35
+
36
+ // Fallback: single <style> element in the document head
37
+ const styleId = "pds-runtime-stylesheet";
38
+ let el = document.getElementById(styleId);
39
+ if (!el) {
40
+ el = document.createElement("style");
41
+ el.id = styleId;
42
+ el.type = "text/css";
43
+ const head = document.head || document.getElementsByTagName("head")[0];
44
+ if (head) head.appendChild(el);
45
+ else document.documentElement.appendChild(el);
46
+ }
47
+
48
+ // Update the stylesheet content in place
49
+ el.textContent = cssText;
50
+ } catch (err) {
51
+ console.warn("installRuntimeStyles failed:", err);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Apply generated styles to the current document.
57
+ * @param {Generator} [generator] - Optional Generator instance (defaults to singleton)
58
+ */
59
+ export function applyStyles(generator) {
60
+ const target = generator;
61
+
62
+ if (!target || typeof target !== "object") {
63
+ console.error(
64
+ "[Runtime] applyStyles requires an explicit generator instance in live mode"
65
+ );
66
+ return;
67
+ }
68
+
69
+ // Preferred: apply layered CSS so tokens + primitives + components + utilities
70
+ // are available in light DOM (ensures primitives like :where(button):active apply)
71
+ const cssText = target.layeredCSS || target.css || "";
72
+ if (!cssText) {
73
+ target.options?.log?.(
74
+ "warn",
75
+ "[Runtime] No CSS available on generator to apply"
76
+ );
77
+ return;
78
+ }
79
+
80
+ // Install/update runtime styles atomically to avoid flicker
81
+ installRuntimeStyles(cssText);
82
+ }
83
+
84
+ // ============================================================================
85
+ // PDS ADOPTER - Helper for web components
86
+ // ============================================================================
87
+
88
+ /**
89
+ * Adopt primitives stylesheet into a shadow root.
90
+ * This is the primary method components should use.
91
+ *
92
+ * @param {ShadowRoot} shadowRoot - The shadow root to adopt into
93
+ * @param {CSSStyleSheet[]} additionalSheets - Additional component-specific stylesheets
94
+ * @returns {Promise<void>}
95
+ */
96
+ export async function adoptPrimitives(
97
+ shadowRoot,
98
+ additionalSheets = [],
99
+ generator = null
100
+ ) {
101
+ try {
102
+ // Prefer live generator when provided
103
+ const primitives = generator?.primitivesStylesheet
104
+ ? generator.primitivesStylesheet
105
+ : await pdsRegistry.getStylesheet("primitives");
106
+
107
+ // Adopt primitives + additional sheets
108
+ shadowRoot.adoptedStyleSheets = [primitives, ...additionalSheets];
109
+ } catch (error) {
110
+ const componentName = shadowRoot.host?.tagName?.toLowerCase() || "unknown";
111
+ console.error(
112
+ `[PDS Adopter] <${componentName}> failed to adopt primitives:`,
113
+ error
114
+ );
115
+ // Continue with just additional sheets as fallback
116
+ shadowRoot.adoptedStyleSheets = additionalSheets;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Adopt multiple layers into a shadow root.
122
+ * For complex components that need more than just primitives.
123
+ *
124
+ * @param {ShadowRoot} shadowRoot - The shadow root to adopt into
125
+ * @param {string[]} layers - Array of layer names to adopt (e.g., ['tokens', 'primitives', 'components'])
126
+ * @param {CSSStyleSheet[]} additionalSheets - Additional component-specific stylesheets
127
+ * @returns {Promise<void>}
128
+ */
129
+ export async function adoptLayers(
130
+ shadowRoot,
131
+ layers = ["primitives"],
132
+ additionalSheets = [],
133
+ generator = null
134
+ ) {
135
+ try {
136
+ // Get all requested stylesheets
137
+ const stylesheets = await Promise.all(
138
+ layers.map(async (layer) => {
139
+ if (generator) {
140
+ switch (layer) {
141
+ case "tokens":
142
+ return generator.tokensStylesheet;
143
+ case "primitives":
144
+ return generator.primitivesStylesheet;
145
+ case "components":
146
+ return generator.componentsStylesheet;
147
+ case "utilities":
148
+ return generator.utilitiesStylesheet;
149
+ default:
150
+ break;
151
+ }
152
+ }
153
+ return pdsRegistry.getStylesheet(layer);
154
+ })
155
+ );
156
+
157
+ // Filter out any null results
158
+ const validStylesheets = stylesheets.filter((sheet) => sheet !== null);
159
+
160
+ // Adopt all layers + additional sheets
161
+ shadowRoot.adoptedStyleSheets = [...validStylesheets, ...additionalSheets];
162
+ } catch (error) {
163
+ const componentName = shadowRoot.host?.tagName?.toLowerCase() || "unknown";
164
+ console.error(
165
+ `[PDS Adopter] <${componentName}> failed to adopt layers:`,
166
+ error
167
+ );
168
+ // Continue with just additional sheets as fallback
169
+ shadowRoot.adoptedStyleSheets = additionalSheets;
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Create a component-specific stylesheet from CSS string.
175
+ * Helper to create constructable stylesheets.
176
+ *
177
+ * @param {string} css - CSS string
178
+ * @returns {CSSStyleSheet}
179
+ */
180
+ export function createStylesheet(css) {
181
+ const sheet = new CSSStyleSheet();
182
+ sheet.replaceSync(css);
183
+ return sheet;
184
+ }