@pure-ds/storybook 0.1.16 → 0.3.8
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/main.js +13 -3
- package/bin/index.js +49 -0
- package/dist/pds-reference.json +32 -15
- package/package.json +1 -1
package/.storybook/main.js
CHANGED
|
@@ -16,7 +16,9 @@ const normalizePath = (path) => path.replace(/\\/g, '/');
|
|
|
16
16
|
/** @type { import('@storybook/web-components-vite').StorybookConfig } */
|
|
17
17
|
const config = {
|
|
18
18
|
stories: [
|
|
19
|
-
|
|
19
|
+
process.env.PDS_STORIES_PATH
|
|
20
|
+
? normalizePath(resolve(process.env.PDS_STORIES_PATH, '**/*.stories.@(js|jsx|mjs|ts|tsx)'))
|
|
21
|
+
: '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
|
20
22
|
// Include user stories from the project root, but only if we are NOT running in the package itself
|
|
21
23
|
...(process.cwd() === resolve(__dirname, '..') ? [] : [
|
|
22
24
|
normalizePath(resolve(process.cwd(), 'stories/**/*.stories.@(js|jsx|mjs|ts|tsx)')),
|
|
@@ -45,12 +47,20 @@ const config = {
|
|
|
45
47
|
},
|
|
46
48
|
viteFinal: async (config) => {
|
|
47
49
|
// Ensure Lit import alias is resolved
|
|
48
|
-
|
|
50
|
+
const aliases = {
|
|
49
51
|
...config.resolve.alias,
|
|
50
52
|
'#pds/lit': 'lit',
|
|
51
|
-
'@pds-src': pdsSrcPath,
|
|
52
53
|
};
|
|
53
54
|
|
|
55
|
+
// In monorepo, pds-configurator is in a separate package, not in src/js
|
|
56
|
+
// This must be defined BEFORE @pds-src to take precedence
|
|
57
|
+
if (!isPackage) {
|
|
58
|
+
aliases['@pds-src/js/pds-configurator'] = resolve(currentDirname, '../../../packages/pds-configurator/src');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
aliases['@pds-src'] = pdsSrcPath;
|
|
62
|
+
config.resolve.alias = aliases;
|
|
63
|
+
|
|
54
64
|
// Alias for relative paths to src (handles ../../../src in stories)
|
|
55
65
|
// This allows stories to work in both monorepo (where ../../../src is valid)
|
|
56
66
|
// and package (where it needs to be mapped to the local src folder)
|
package/bin/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { dirname, join } from 'path';
|
|
6
|
+
import fs from 'fs';
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const __dirname = dirname(__filename);
|
|
@@ -23,6 +24,54 @@ if (command !== 'build' && !args.includes('-p') && !args.includes('--port')) {
|
|
|
23
24
|
storybookArgs.push('-p', '6006');
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
// Check if running in custom mode (consumer project)
|
|
28
|
+
if (process.cwd() !== packageRoot) {
|
|
29
|
+
try {
|
|
30
|
+
const cacheDir = join(process.cwd(), 'node_modules', '.cache', 'pds-storybook', 'stories');
|
|
31
|
+
const srcStoriesDir = join(packageRoot, 'stories');
|
|
32
|
+
|
|
33
|
+
console.log(`Preparing PDS stories in ${cacheDir}...`);
|
|
34
|
+
|
|
35
|
+
if (fs.existsSync(cacheDir)) {
|
|
36
|
+
fs.rmSync(cacheDir, { recursive: true, force: true });
|
|
37
|
+
}
|
|
38
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
39
|
+
|
|
40
|
+
const copyAndTransform = (src, dest) => {
|
|
41
|
+
if (!fs.existsSync(src)) return;
|
|
42
|
+
|
|
43
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
const srcPath = join(src, entry.name);
|
|
46
|
+
const destPath = join(dest, entry.name);
|
|
47
|
+
|
|
48
|
+
if (entry.isDirectory()) {
|
|
49
|
+
fs.mkdirSync(destPath, { recursive: true });
|
|
50
|
+
copyAndTransform(srcPath, destPath);
|
|
51
|
+
} else if (entry.isFile()) {
|
|
52
|
+
if (entry.name.endsWith('.stories.js') || entry.name.endsWith('.stories.ts') || entry.name.endsWith('.stories.mjs')) {
|
|
53
|
+
let content = fs.readFileSync(srcPath, 'utf-8');
|
|
54
|
+
// Prepend PDS/ to title
|
|
55
|
+
content = content.replace(/(title:\s*['"])(.+?)(['"])/, (match, prefix, title, suffix) => {
|
|
56
|
+
if (title.startsWith('PDS/')) return match;
|
|
57
|
+
return `${prefix}PDS/${title}${suffix}`;
|
|
58
|
+
});
|
|
59
|
+
fs.writeFileSync(destPath, content);
|
|
60
|
+
} else {
|
|
61
|
+
fs.copyFileSync(srcPath, destPath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
copyAndTransform(srcStoriesDir, cacheDir);
|
|
68
|
+
process.env.PDS_STORIES_PATH = cacheDir.replace(/\\/g, '/');
|
|
69
|
+
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error('Error preparing PDS stories:', err);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
26
75
|
console.log(`Running Storybook with config: ${configDir}`);
|
|
27
76
|
|
|
28
77
|
const child = spawn('npx', ['storybook', ...storybookArgs], {
|
package/dist/pds-reference.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2025-12-
|
|
2
|
+
"generatedAt": "2025-12-18T09:21:39.368Z",
|
|
3
3
|
"sources": {
|
|
4
4
|
"customElements": "custom-elements.json",
|
|
5
5
|
"ontology": "src\\js\\pds-core\\pds-ontology.js",
|
|
@@ -114,12 +114,18 @@
|
|
|
114
114
|
"pds-drawer": {
|
|
115
115
|
"tag": "pds-drawer",
|
|
116
116
|
"className": "anonymous_0",
|
|
117
|
-
"displayName": "
|
|
118
|
-
"storyTitle": "
|
|
119
|
-
"category": "
|
|
117
|
+
"displayName": "Pds Drawer",
|
|
118
|
+
"storyTitle": "Components/Pds Drawer",
|
|
119
|
+
"category": "Components",
|
|
120
120
|
"description": null,
|
|
121
121
|
"docsDescription": "Slide-out panels from any edge",
|
|
122
|
-
"pdsTags": [
|
|
122
|
+
"pdsTags": [
|
|
123
|
+
"autodocs",
|
|
124
|
+
"grouping",
|
|
125
|
+
"interaction",
|
|
126
|
+
"layout",
|
|
127
|
+
"navigation"
|
|
128
|
+
],
|
|
123
129
|
"ontology": {
|
|
124
130
|
"id": "pds-drawer",
|
|
125
131
|
"name": "Drawer",
|
|
@@ -131,7 +137,7 @@
|
|
|
131
137
|
{
|
|
132
138
|
"exportName": "Default",
|
|
133
139
|
"name": "Default",
|
|
134
|
-
"id": "
|
|
140
|
+
"id": "components-pds-drawer--default",
|
|
135
141
|
"tags": [],
|
|
136
142
|
"description": null,
|
|
137
143
|
"source": "stories\\components\\PdsDrawer.stories.js"
|
|
@@ -307,18 +313,24 @@
|
|
|
307
313
|
"pds-icon": {
|
|
308
314
|
"tag": "pds-icon",
|
|
309
315
|
"className": "SvgIcon",
|
|
310
|
-
"displayName": "
|
|
311
|
-
"storyTitle": "
|
|
312
|
-
"category": "
|
|
316
|
+
"displayName": "Pds Icon",
|
|
317
|
+
"storyTitle": "Components/Pds Icon",
|
|
318
|
+
"category": "Components",
|
|
313
319
|
"description": "SVG Icon Web Component",
|
|
314
320
|
"docsDescription": "SVG sprite icons with fallbacks",
|
|
315
|
-
"pdsTags": [
|
|
321
|
+
"pdsTags": [
|
|
322
|
+
"autodocs",
|
|
323
|
+
"buttons",
|
|
324
|
+
"icons",
|
|
325
|
+
"sprite",
|
|
326
|
+
"svg"
|
|
327
|
+
],
|
|
316
328
|
"ontology": null,
|
|
317
329
|
"stories": [
|
|
318
330
|
{
|
|
319
331
|
"exportName": "Default",
|
|
320
332
|
"name": "Default",
|
|
321
|
-
"id": "
|
|
333
|
+
"id": "components-pds-icon--default",
|
|
322
334
|
"tags": [],
|
|
323
335
|
"description": null,
|
|
324
336
|
"source": "stories\\components\\PdsIcon.stories.js"
|
|
@@ -1420,12 +1432,17 @@
|
|
|
1420
1432
|
"pds-tabstrip": {
|
|
1421
1433
|
"tag": "pds-tabstrip",
|
|
1422
1434
|
"className": "TabStrip",
|
|
1423
|
-
"displayName": "
|
|
1424
|
-
"storyTitle": "
|
|
1425
|
-
"category": "
|
|
1435
|
+
"displayName": "Pds Tabstrip",
|
|
1436
|
+
"storyTitle": "Components/Pds Tabstrip",
|
|
1437
|
+
"category": "Components",
|
|
1426
1438
|
"description": "Tab navigation component that pairs anchors with `pds-tabpanel` children.",
|
|
1427
1439
|
"docsDescription": "Accessible tab interface with keyboard navigation",
|
|
1428
|
-
"pdsTags": [
|
|
1440
|
+
"pdsTags": [
|
|
1441
|
+
"autodocs",
|
|
1442
|
+
"grouping",
|
|
1443
|
+
"layout",
|
|
1444
|
+
"navigation"
|
|
1445
|
+
],
|
|
1429
1446
|
"ontology": {
|
|
1430
1447
|
"id": "pds-tabstrip",
|
|
1431
1448
|
"name": "Tab Strip",
|