@pure-ds/storybook 0.1.9 → 0.1.11
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.
package/.storybook/preview.js
CHANGED
|
@@ -42,7 +42,7 @@ console.log('🎨 Starting PDS initialization with preset:', initialPreset);
|
|
|
42
42
|
|
|
43
43
|
// Wrap top-level await in IIFE for production build compatibility
|
|
44
44
|
(async () => {
|
|
45
|
-
|
|
45
|
+
PDS.initializing = true;
|
|
46
46
|
const pdsOptions = {
|
|
47
47
|
mode: 'live',
|
|
48
48
|
preset: initialPreset,
|
|
@@ -70,14 +70,13 @@ console.log('🎨 Starting PDS initialization with preset:', initialPreset);
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
await PDS.start(pdsOptions);
|
|
73
|
-
|
|
73
|
+
PDS.initializing = false;
|
|
74
74
|
|
|
75
75
|
console.log('✨ PDS initialized in live mode for Storybook');
|
|
76
76
|
console.log('📦 AutoDefiner active at:', PDS.autoDefiner?.config?.baseURL);
|
|
77
77
|
|
|
78
78
|
// Store PDS designer globally for reuse
|
|
79
|
-
|
|
80
|
-
window.__pdsCurrentPreset = initialPreset;
|
|
79
|
+
PDS.currentPreset = initialPreset;
|
|
81
80
|
})();
|
|
82
81
|
|
|
83
82
|
// Set up persistent style protection - monitor and restore PDS sheets if cleared
|
|
@@ -86,9 +85,9 @@ function ensurePDSStyles() {
|
|
|
86
85
|
const sheets = document.adoptedStyleSheets || [];
|
|
87
86
|
const hasPDS = sheets.some(s => s._pds === true);
|
|
88
87
|
|
|
89
|
-
if (!hasPDS &&
|
|
88
|
+
if (!hasPDS && PDS.Generator.instance) {
|
|
90
89
|
console.log('🛡️ PDS sheets missing - restoring...');
|
|
91
|
-
PDS.Generator.applyStyles(
|
|
90
|
+
PDS.Generator.applyStyles(PDS.Generator.instance);
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
|
|
@@ -107,14 +106,14 @@ const withPDS = (story, context) => {
|
|
|
107
106
|
console.log('📋 Current adoptedStyleSheets:', currentSheets.length, 'PDS sheets:', pdsSheets.length);
|
|
108
107
|
|
|
109
108
|
// ALWAYS reapply PDS styles before each story render
|
|
110
|
-
const designer =
|
|
109
|
+
const designer = PDS.Generator.instance;
|
|
111
110
|
if (designer) {
|
|
112
111
|
PDS.Generator.applyStyles(designer);
|
|
113
112
|
|
|
114
113
|
// Check again after applying
|
|
115
114
|
const afterSheets = document.adoptedStyleSheets || [];
|
|
116
115
|
const afterPdsSheets = afterSheets.filter(s => s._pds === true);
|
|
117
|
-
} else if (!
|
|
116
|
+
} else if (!PDS.initializing && PDS.isLiveMode()) {
|
|
118
117
|
console.warn('⚠️ No designer found!');
|
|
119
118
|
}
|
|
120
119
|
|
|
@@ -236,13 +235,13 @@ const withGlobalsHandler = (story, context) => {
|
|
|
236
235
|
const { globals } = context;
|
|
237
236
|
|
|
238
237
|
// Handle preset changes via decorator (has access to globals)
|
|
239
|
-
if (globals?.preset && globals.preset !==
|
|
240
|
-
console.log('🔄 Decorator detected preset change:',
|
|
238
|
+
if (globals?.preset && globals.preset !== PDS.currentPreset) {
|
|
239
|
+
console.log('🔄 Decorator detected preset change:', PDS.currentPreset, '→', globals.preset);
|
|
241
240
|
|
|
242
241
|
// Apply preset asynchronously
|
|
243
242
|
(async () => {
|
|
244
243
|
try {
|
|
245
|
-
|
|
244
|
+
PDS.currentPreset = globals.preset;
|
|
246
245
|
|
|
247
246
|
// Store for persistence
|
|
248
247
|
try {
|
|
@@ -267,9 +266,6 @@ const withGlobalsHandler = (story, context) => {
|
|
|
267
266
|
const newDesigner = new PDS.Generator(generatorOptions);
|
|
268
267
|
await PDS.Generator.applyStyles(newDesigner);
|
|
269
268
|
|
|
270
|
-
PDS.registry._designer = newDesigner;
|
|
271
|
-
window.__pdsDesigner = newDesigner;
|
|
272
|
-
|
|
273
269
|
console.log(`✅ Preset applied via decorator: ${globals.preset}`);
|
|
274
270
|
}
|
|
275
271
|
} catch (err) {
|
|
@@ -1397,10 +1393,10 @@ if (typeof window !== 'undefined') {
|
|
|
1397
1393
|
|
|
1398
1394
|
if (globals?.preset) {
|
|
1399
1395
|
console.log('🔔 SET_GLOBALS message received with preset:', globals.preset);
|
|
1400
|
-
console.log('📦 Current stored preset:',
|
|
1396
|
+
console.log('📦 Current stored preset:', PDS.currentPreset);
|
|
1401
1397
|
|
|
1402
1398
|
// Skip if already on this preset
|
|
1403
|
-
if (globals.preset ===
|
|
1399
|
+
if (globals.preset === PDS.currentPreset) {
|
|
1404
1400
|
console.log('⏭️ Preset unchanged, skipping');
|
|
1405
1401
|
return;
|
|
1406
1402
|
}
|
|
@@ -1453,10 +1449,8 @@ if (typeof window !== 'undefined') {
|
|
|
1453
1449
|
await PDS.Generator.applyStyles(newDesigner);
|
|
1454
1450
|
console.log('✅ Styles applied to document');
|
|
1455
1451
|
|
|
1456
|
-
// Update
|
|
1457
|
-
PDS.
|
|
1458
|
-
window.__pdsDesigner = newDesigner;
|
|
1459
|
-
window.__pdsCurrentPreset = presetId;
|
|
1452
|
+
// Update global reference
|
|
1453
|
+
PDS.currentPreset = presetId;
|
|
1460
1454
|
|
|
1461
1455
|
console.log(`✅✅✅ Preset applied successfully: ${presetConfig.name || presetId}`);
|
|
1462
1456
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pure-ds/storybook",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Storybook showcase for Pure Design System with live configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"storybook:build": "npm run build-storybook"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@pure-ds/core": "^0.3.
|
|
35
|
+
"@pure-ds/core": "^0.3.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|
|
@@ -5311,7 +5311,7 @@ export function createStylesheet(css) {
|
|
|
5311
5311
|
* @returns {boolean}
|
|
5312
5312
|
*/
|
|
5313
5313
|
export function isLiveMode() {
|
|
5314
|
-
return
|
|
5314
|
+
return window.PDS?.registry?.isLive;
|
|
5315
5315
|
}
|
|
5316
5316
|
import { enums } from "./pds-enums.js";
|
|
5317
5317
|
import { ontology } from "./pds-ontology.js";
|
|
@@ -79,30 +79,6 @@ class PDSRegistry {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// /**
|
|
83
|
-
// * Get BLOB URL for a layer (live mode only)
|
|
84
|
-
// * Used for @import statements in CSS
|
|
85
|
-
// */
|
|
86
|
-
// getBlobURL(layer) {
|
|
87
|
-
// if (this._mode === "live" && this._designer) {
|
|
88
|
-
// switch (layer) {
|
|
89
|
-
// case "tokens":
|
|
90
|
-
// return this._designer.tokensBlobURL;
|
|
91
|
-
// case "primitives":
|
|
92
|
-
// return this._designer.primitivesBlobURL;
|
|
93
|
-
// case "components":
|
|
94
|
-
// return this._designer.componentsBlobURL;
|
|
95
|
-
// case "utilities":
|
|
96
|
-
// return this._designer.utilitiesBlobURL;
|
|
97
|
-
// case "styles":
|
|
98
|
-
// return this._designer.stylesBlobURL;
|
|
99
|
-
// default:
|
|
100
|
-
// return null;
|
|
101
|
-
// }
|
|
102
|
-
// }
|
|
103
|
-
// return null;
|
|
104
|
-
// }
|
|
105
|
-
|
|
106
82
|
/**
|
|
107
83
|
* Get current mode
|
|
108
84
|
*/
|