@pure-ds/storybook 0.1.12 → 0.1.13

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.
@@ -85,7 +85,7 @@ async function loadConfigForm() {
85
85
  // The event detail contains both config and designer from pds-config-form
86
86
  if (e.detail.designer) {
87
87
  // Apply the styles from the designer that was already created by pds-config-form
88
- await PDS.Generator.applyStyles(e.detail.designer);
88
+ await PDS.Generator.applyStyles();
89
89
  }
90
90
 
91
91
  // Notify manager
@@ -87,7 +87,7 @@ function ensurePDSStyles() {
87
87
 
88
88
  if (!hasPDS && PDS.Generator.instance) {
89
89
  console.log('🛡️ PDS sheets missing - restoring...');
90
- PDS.Generator.applyStyles(PDS.Generator.instance);
90
+ PDS.Generator.applyStyles();
91
91
  }
92
92
  }
93
93
 
@@ -108,7 +108,7 @@ const withPDS = (story, context) => {
108
108
  // ALWAYS reapply PDS styles before each story render
109
109
  const designer = PDS.Generator.instance;
110
110
  if (designer) {
111
- PDS.Generator.applyStyles(designer);
111
+ PDS.Generator.applyStyles();
112
112
 
113
113
  // Check again after applying
114
114
  const afterSheets = document.adoptedStyleSheets || [];
@@ -264,7 +264,7 @@ const withGlobalsHandler = (story, context) => {
264
264
  if (PDS.theme) generatorOptions.theme = PDS.theme;
265
265
 
266
266
  const newDesigner = new PDS.Generator(generatorOptions);
267
- await PDS.Generator.applyStyles(newDesigner);
267
+ await PDS.Generator.applyStyles();
268
268
 
269
269
  console.log(`✅ Preset applied via decorator: ${globals.preset}`);
270
270
  }
@@ -1446,7 +1446,7 @@ if (typeof window !== 'undefined') {
1446
1446
  console.log('✅ Generator created');
1447
1447
 
1448
1448
  console.log('🎨 Applying styles to document...');
1449
- await PDS.Generator.applyStyles(newDesigner);
1449
+ await PDS.Generator.applyStyles();
1450
1450
  console.log('✅ Styles applied to document');
1451
1451
 
1452
1452
  // Update global reference
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pure-ds/storybook",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Storybook showcase for Pure Design System with live configuration",
5
5
  "type": "module",
6
6
  "private": false,
@@ -5126,23 +5126,23 @@ export const ${name}CSS = \`${escapedCSS}\`;
5126
5126
  /**
5127
5127
  * Static method to apply styles to document
5128
5128
  * Creates a link element with BLOB URL
5129
- * @param {Generator} generator - The Generator instance with generated styles
5129
+ * @param {Generator} [generator] - Optional Generator instance (defaults to singleton)
5130
5130
  */
5131
5131
  static applyStyles(generator) {
5132
+ // Use provided generator or singleton instance
5133
+ const target = generator || Generator.instance;
5134
+
5132
5135
  // Validate parameter
5133
- if (!generator || typeof generator !== "object") {
5134
- generator?.options?.log?.(
5135
- "error",
5136
- "[Generator] applyStyles requires a generator object"
5137
- );
5136
+ if (!target || typeof target !== "object") {
5137
+ console.error("[Generator] applyStyles requires a generator object or active singleton");
5138
5138
  return;
5139
5139
  }
5140
5140
 
5141
5141
  // Preferred: apply layered CSS so tokens + primitives + components + utilities
5142
5142
  // are available in light DOM (ensures primitives like :where(button):active apply)
5143
- const cssText = generator.layeredCSS || generator.css || "";
5143
+ const cssText = target.layeredCSS || target.css || "";
5144
5144
  if (!cssText) {
5145
- generator?.options?.log?.(
5145
+ target.options?.log?.(
5146
5146
  "warn",
5147
5147
  "[Generator] No CSS available on designer to apply"
5148
5148
  );
package/src/js/pds.js CHANGED
@@ -1166,7 +1166,7 @@ async function live(config) {
1166
1166
 
1167
1167
  // Apply styles globally if requested (default behavior)
1168
1168
  if (applyGlobalStyles) {
1169
- await PDS.Generator.applyStyles(generator);
1169
+ await PDS.Generator.applyStyles();
1170
1170
 
1171
1171
  // Clean up critical styles after adoptedStyleSheets are applied
1172
1172
  if (typeof window !== "undefined") {
@@ -1477,10 +1477,10 @@ async function setTheme(theme, options = {}) {
1477
1477
  currentGenerator.configure(newConfig);
1478
1478
 
1479
1479
  // Reapply styles
1480
- await PDS.Generator.applyStyles(currentDesigner);
1480
+ await PDS.Generator.applyStyles();
1481
1481
  }
1482
1482
  } catch (error) {
1483
- currentDesigner?.options?.log?.("warn", "Failed to update styles for new theme:", error);
1483
+ console.warn("Failed to update styles for new theme:", error);
1484
1484
  }
1485
1485
  }
1486
1486