@pure-ds/storybook 0.4.17 → 0.4.19
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/addons/html-preview/Panel.jsx +21 -21
- package/.storybook/addons/html-preview/preview.js +4 -5
- package/.storybook/manager.js +337 -49
- package/.storybook/preview-head.html +2 -2
- package/.storybook/preview.js +2 -2
- package/README.md +2 -2
- package/dist/pds-reference.json +1915 -261
- package/package.json +2 -2
- package/public/assets/css/app.css +2 -2
- package/public/assets/js/app.js +41 -22
- package/public/assets/js/pds.js +60 -41
- package/public/assets/pds/components/{pds-jsonform.js → pds-form.js} +536 -45
- package/public/assets/pds/custom-elements.json +8 -8
- package/public/assets/pds/vscode-custom-data.json +63 -63
- package/scripts/build-pds-reference.mjs +112 -38
- package/scripts/generate-stories.js +2 -2
- package/src/js/common/ask.js +48 -21
- package/src/js/pds-configurator/pds-config-form.js +9 -9
- package/src/js/pds-configurator/pds-demo.js +2 -2
- package/src/js/pds-core/pds-config.js +14 -14
- package/src/js/pds-core/pds-generator.js +25 -12
- package/src/js/pds-core/pds-ontology.js +5 -5
- package/src/js/pds.d.ts +2 -2
- package/stories/GettingStarted.stories.js +3 -0
- package/stories/WhatIsPDS.stories.js +3 -0
- package/stories/components/PdsForm.stories.js +4356 -0
- package/stories/components/{PdsJsonformUiSchema.md → PdsFormUiSchema.md} +2 -2
- package/stories/foundations/Spacing.stories.js +5 -5
- package/stories/layout/LayoutOverview.stories.js +13 -11
- package/stories/primitives/{Forms.stories.js → FormElements.stories.js} +3 -3
- package/stories/primitives/HtmlFormElements.stories.js +128 -0
- package/stories/primitives/{FormGroups.stories.js → HtmlFormGroups.stories.js} +70 -21
- package/stories/utils/PdsAsk.stories.js +14 -13
- package/stories/components/PdsJsonform.stories.js +0 -2007
- /package/src/{pds-core → node-api}/pds-api.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
3
|
"readme": "",
|
|
4
4
|
"modules": [
|
|
@@ -671,11 +671,11 @@
|
|
|
671
671
|
},
|
|
672
672
|
{
|
|
673
673
|
"kind": "javascript-module",
|
|
674
|
-
"path": "public/assets/pds/components/pds-
|
|
674
|
+
"path": "public/assets/pds/components/pds-form.js",
|
|
675
675
|
"declarations": [
|
|
676
676
|
{
|
|
677
677
|
"kind": "class",
|
|
678
|
-
"description": "<pds-
|
|
678
|
+
"description": "<pds-form>\n\nForm Actions:\nBy default, the form includes Submit and Reset buttons inside the <form> element.\n\nUsage options:\n1. Default buttons:\n <pds-form .jsonSchema=${schema}></pds-form>\n\n2. Customize labels:\n <pds-form .jsonSchema=${schema} submit-label=\"Save\" reset-label=\"Clear\"></pds-form>\n\n3. Hide reset button:\n <pds-form .jsonSchema=${schema} hide-reset></pds-form>\n\n4. Add extra buttons (slot):\n <pds-form .jsonSchema=${schema}>\n <button type=\"button\" slot=\"actions\"",
|
|
679
679
|
"name": "SchemaForm",
|
|
680
680
|
"members": [
|
|
681
681
|
{
|
|
@@ -953,9 +953,9 @@
|
|
|
953
953
|
],
|
|
954
954
|
"superclass": {
|
|
955
955
|
"name": "LitElement",
|
|
956
|
-
"module": "/public/assets/pds/components/pds-
|
|
956
|
+
"module": "/public/assets/pds/components/pds-form.js"
|
|
957
957
|
},
|
|
958
|
-
"tagName": "pds-
|
|
958
|
+
"tagName": "pds-form",
|
|
959
959
|
"customElement": true
|
|
960
960
|
}
|
|
961
961
|
],
|
|
@@ -965,15 +965,15 @@
|
|
|
965
965
|
"name": "SchemaForm",
|
|
966
966
|
"declaration": {
|
|
967
967
|
"name": "SchemaForm",
|
|
968
|
-
"module": "public/assets/pds/components/pds-
|
|
968
|
+
"module": "public/assets/pds/components/pds-form.js"
|
|
969
969
|
}
|
|
970
970
|
},
|
|
971
971
|
{
|
|
972
972
|
"kind": "custom-element-definition",
|
|
973
|
-
"name": "pds-
|
|
973
|
+
"name": "pds-form",
|
|
974
974
|
"declaration": {
|
|
975
975
|
"name": "SchemaForm",
|
|
976
|
-
"module": "public/assets/pds/components/pds-
|
|
976
|
+
"module": "public/assets/pds/components/pds-form.js"
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
979
|
]
|
|
@@ -65,6 +65,69 @@
|
|
|
65
65
|
}
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
+
{
|
|
69
|
+
"name": "pds-form",
|
|
70
|
+
"description": "<pds-form>\n\nForm Actions:\nBy default, the form includes Submit and Reset buttons inside the <form> element.\n\nUsage options:\n1. Default buttons:\n <pds-form .jsonSchema=${schema}></pds-form>\n\n2. Customize labels:\n <pds-form .jsonSchema=${schema} submit-label=\"Save\" reset-label=\"Clear\"></pds-form>\n\n3. Hide reset button:\n <pds-form .jsonSchema=${schema} hide-reset></pds-form>\n\n4. Add extra buttons (slot):\n <pds-form .jsonSchema=${schema}>\n <button type=\"button\" slot=\"actions\"",
|
|
71
|
+
"attributes": [
|
|
72
|
+
{
|
|
73
|
+
"name": "json-schema",
|
|
74
|
+
"description": ""
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "ui-schema",
|
|
78
|
+
"description": ""
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "options",
|
|
82
|
+
"description": ""
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "values",
|
|
86
|
+
"description": ""
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "action",
|
|
90
|
+
"description": ""
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "method",
|
|
94
|
+
"description": ""
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "disabled",
|
|
98
|
+
"description": "",
|
|
99
|
+
"valueSet": "v"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "hide-actions",
|
|
103
|
+
"description": "",
|
|
104
|
+
"valueSet": "v"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "submit-label",
|
|
108
|
+
"description": ""
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "reset-label",
|
|
112
|
+
"description": ""
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "hide-reset",
|
|
116
|
+
"description": "",
|
|
117
|
+
"valueSet": "v"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "hide-submit",
|
|
121
|
+
"description": "",
|
|
122
|
+
"valueSet": "v"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "hide-legend",
|
|
126
|
+
"description": "",
|
|
127
|
+
"valueSet": "v"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
68
131
|
{
|
|
69
132
|
"name": "pds-icon",
|
|
70
133
|
"description": "SVG Icon Web Component",
|
|
@@ -598,69 +661,6 @@
|
|
|
598
661
|
}
|
|
599
662
|
]
|
|
600
663
|
},
|
|
601
|
-
{
|
|
602
|
-
"name": "pds-jsonform",
|
|
603
|
-
"description": "<pds-jsonform>\n\nForm Actions:\nBy default, the form includes Submit and Reset buttons inside the <form> element.\n\nUsage options:\n1. Default buttons:\n <pds-jsonform .jsonSchema=${schema}></pds-jsonform>\n\n2. Customize labels:\n <pds-jsonform .jsonSchema=${schema} submit-label=\"Save\" reset-label=\"Clear\"></pds-jsonform>\n\n3. Hide reset button:\n <pds-jsonform .jsonSchema=${schema} hide-reset></pds-jsonform>\n\n4. Add extra buttons (slot):\n <pds-jsonform .jsonSchema=${schema}>\n <button type=\"button\" slot=\"actions\"",
|
|
604
|
-
"attributes": [
|
|
605
|
-
{
|
|
606
|
-
"name": "json-schema",
|
|
607
|
-
"description": ""
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
"name": "ui-schema",
|
|
611
|
-
"description": ""
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
"name": "options",
|
|
615
|
-
"description": ""
|
|
616
|
-
},
|
|
617
|
-
{
|
|
618
|
-
"name": "values",
|
|
619
|
-
"description": ""
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
"name": "action",
|
|
623
|
-
"description": ""
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
"name": "method",
|
|
627
|
-
"description": ""
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
"name": "disabled",
|
|
631
|
-
"description": "",
|
|
632
|
-
"valueSet": "v"
|
|
633
|
-
},
|
|
634
|
-
{
|
|
635
|
-
"name": "hide-actions",
|
|
636
|
-
"description": "",
|
|
637
|
-
"valueSet": "v"
|
|
638
|
-
},
|
|
639
|
-
{
|
|
640
|
-
"name": "submit-label",
|
|
641
|
-
"description": ""
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
"name": "reset-label",
|
|
645
|
-
"description": ""
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
"name": "hide-reset",
|
|
649
|
-
"description": "",
|
|
650
|
-
"valueSet": "v"
|
|
651
|
-
},
|
|
652
|
-
{
|
|
653
|
-
"name": "hide-submit",
|
|
654
|
-
"description": "",
|
|
655
|
-
"valueSet": "v"
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
"name": "hide-legend",
|
|
659
|
-
"description": "",
|
|
660
|
-
"valueSet": "v"
|
|
661
|
-
}
|
|
662
|
-
]
|
|
663
|
-
},
|
|
664
664
|
{
|
|
665
665
|
"name": "pds-richtext",
|
|
666
666
|
"description": "RichText component",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// Consolidated reference data generator for Pure Design System Storybook
|
|
4
4
|
// Combines metadata from custom-elements.json, the PDS ontology, and Storybook stories
|
|
@@ -49,10 +49,10 @@ const OUTPUT_PATH = path.join(OUTPUT_DIR, 'pds-reference.json');
|
|
|
49
49
|
const TYPE_METADATA_CACHE = new Map();
|
|
50
50
|
|
|
51
51
|
const SPECIAL_COMPONENT_OVERRIDES = {
|
|
52
|
-
'pds-
|
|
52
|
+
'pds-form': {
|
|
53
53
|
title: 'PDS JSON Schema Form',
|
|
54
54
|
notes: [
|
|
55
|
-
'Typed interfaces for `
|
|
55
|
+
'Typed interfaces for `formOptions`, `UISchema`, and related events live in `src/js/pds.d.ts`.',
|
|
56
56
|
'The form accepts standard JSON Schema (Draft 7) documents via the `jsonSchema` property. `uiSchema` and `options` fine-tune layout, widgets, and behaviors.'
|
|
57
57
|
],
|
|
58
58
|
properties: {
|
|
@@ -65,7 +65,7 @@ const SPECIAL_COMPONENT_OVERRIDES = {
|
|
|
65
65
|
description: 'Optional UI overrides keyed by JSON Pointer. Controls layout, widgets, surfaces, dialogs, and per-field hints.'
|
|
66
66
|
},
|
|
67
67
|
options: {
|
|
68
|
-
type: '
|
|
68
|
+
type: 'formOptions',
|
|
69
69
|
description: 'Toolkit-level options that adjust widget families, layouts, and validation behavior. Supports path-specific overrides.'
|
|
70
70
|
},
|
|
71
71
|
values: {
|
|
@@ -76,37 +76,37 @@ const SPECIAL_COMPONENT_OVERRIDES = {
|
|
|
76
76
|
events: [
|
|
77
77
|
{
|
|
78
78
|
name: 'pw:submit',
|
|
79
|
-
detail: '
|
|
79
|
+
detail: 'formSubmitDetail',
|
|
80
80
|
description: 'Emitted after submission. `detail` includes `{ json, formData, valid, issues }` for server hand-off or additional processing.'
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
name: 'pw:value-change',
|
|
84
|
-
detail: '
|
|
84
|
+
detail: 'formValueChangeDetail',
|
|
85
85
|
description: 'Live value updates whenever a field changes. `detail.name` contains the JSON Pointer-compatible path.'
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
name: 'pw:array-add',
|
|
89
|
-
detail: '
|
|
89
|
+
detail: 'formArrayEventDetail',
|
|
90
90
|
description: 'Triggered when an array item is appended. Carries the path and index metadata.'
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
name: 'pw:array-remove',
|
|
94
|
-
detail: '
|
|
94
|
+
detail: 'formArrayEventDetail',
|
|
95
95
|
description: 'Triggered when an array item is removed.'
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
name: 'pw:array-reorder',
|
|
99
|
-
detail: '
|
|
99
|
+
detail: 'formArrayEventDetail',
|
|
100
100
|
description: 'Triggered when array items are reordered (drag & drop scenarios).'
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
name: 'pw:dialog-open',
|
|
104
|
-
detail: '
|
|
104
|
+
detail: 'formDialogEventDetail',
|
|
105
105
|
description: 'Fires before a dialog-driven field opens (e.g. complex editors).'
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
name: 'pw:dialog-submit',
|
|
109
|
-
detail: '
|
|
109
|
+
detail: 'formDialogEventDetail',
|
|
110
110
|
description: 'Fires when a dialog-driven field is saved.'
|
|
111
111
|
}
|
|
112
112
|
]
|
|
@@ -224,6 +224,62 @@ async function walkStories(dir) {
|
|
|
224
224
|
return files;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Extract story metadata statically from file content when dynamic import fails
|
|
229
|
+
* This is a fallback for files with non-JS dependencies (e.g., markdown imports)
|
|
230
|
+
* @param {string} content - File content
|
|
231
|
+
* @param {string} relPath - Relative path for logging
|
|
232
|
+
* @returns {Object|null} - Extracted metadata or null
|
|
233
|
+
*/
|
|
234
|
+
function extractStaticMetadata(content, relPath) {
|
|
235
|
+
// Look for: export default { title: '...', parameters: { pds: { tags: [...] } } }
|
|
236
|
+
// This is a simple regex-based extraction, not a full parser
|
|
237
|
+
|
|
238
|
+
// Extract title
|
|
239
|
+
const titleMatch = content.match(/title:\s*['"`]([^'"`]+)['"`]/);
|
|
240
|
+
if (!titleMatch) return null;
|
|
241
|
+
|
|
242
|
+
const title = titleMatch[1];
|
|
243
|
+
|
|
244
|
+
// Extract pds.tags array
|
|
245
|
+
// Look for: pds: { tags: ['tag1', 'tag2', ...] }
|
|
246
|
+
const pdsTagsMatch = content.match(/pds:\s*\{[^}]*tags:\s*\[([\s\S]*?)\]/);
|
|
247
|
+
let pdsTags = [];
|
|
248
|
+
if (pdsTagsMatch) {
|
|
249
|
+
// Extract individual tags from the array
|
|
250
|
+
const tagsContent = pdsTagsMatch[1];
|
|
251
|
+
const tagMatches = tagsContent.matchAll(/['"`]([^'"`]+)['"`]/g);
|
|
252
|
+
for (const match of tagMatches) {
|
|
253
|
+
pdsTags.push(match[1]);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Extract standard tags array
|
|
258
|
+
// Look for: tags: ['tag1', 'tag2', ...] (not inside pds: {})
|
|
259
|
+
const standardTagsMatch = content.match(/(?<!pds:\s*\{[^}]*)tags:\s*\[([\s\S]*?)\]/);
|
|
260
|
+
let standardTags = [];
|
|
261
|
+
if (standardTagsMatch && !standardTagsMatch[0].includes('pds:')) {
|
|
262
|
+
const tagsContent = standardTagsMatch[1];
|
|
263
|
+
const tagMatches = tagsContent.matchAll(/['"`]([^'"`]+)['"`]/g);
|
|
264
|
+
for (const match of tagMatches) {
|
|
265
|
+
standardTags.push(match[1]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Extract description
|
|
270
|
+
const descMatch = content.match(/description:\s*\{[^}]*component:\s*['"`]([^'"`]+)['"`]/);
|
|
271
|
+
const description = descMatch ? descMatch[1] : null;
|
|
272
|
+
|
|
273
|
+
return {
|
|
274
|
+
title,
|
|
275
|
+
tags: standardTags,
|
|
276
|
+
parameters: {
|
|
277
|
+
pds: pdsTags.length > 0 ? { tags: pdsTags } : undefined,
|
|
278
|
+
docs: description ? { description: { component: description } } : undefined
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
227
283
|
async function collectStoryMetadata() {
|
|
228
284
|
const storyFiles = await walkStories(STORIES_ROOT);
|
|
229
285
|
const index = new Map();
|
|
@@ -232,20 +288,35 @@ async function collectStoryMetadata() {
|
|
|
232
288
|
if (file.includes(`${path.sep}reference${path.sep}`)) continue;
|
|
233
289
|
|
|
234
290
|
const fileUrl = pathToFileURL(file).href;
|
|
291
|
+
const relPath = path.relative(ROOT_DIR, file);
|
|
235
292
|
let mod;
|
|
293
|
+
let meta = null;
|
|
294
|
+
|
|
236
295
|
try {
|
|
237
296
|
mod = await import(fileUrl);
|
|
297
|
+
meta = mod.default;
|
|
238
298
|
} catch (error) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
299
|
+
// Import failed - try to extract metadata statically from the file
|
|
300
|
+
try {
|
|
301
|
+
const content = await fs.promises.readFile(file, 'utf-8');
|
|
302
|
+
meta = extractStaticMetadata(content, relPath);
|
|
303
|
+
if (meta) {
|
|
304
|
+
console.log(`[pds-reference] Extracted static metadata from ${relPath}`);
|
|
305
|
+
}
|
|
306
|
+
} catch (parseError) {
|
|
307
|
+
// Ignore parse errors
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (!meta) {
|
|
311
|
+
if (error.code === 'ERR_UNKNOWN_FILE_EXTENSION') {
|
|
312
|
+
console.warn(`[pds-reference] Skipped ${relPath} (non-JS dependency: ${error.message.split(' for ').pop() || error.message})`);
|
|
313
|
+
} else {
|
|
314
|
+
console.warn(`[pds-reference] Skipped ${relPath}: ${error.message}`);
|
|
315
|
+
}
|
|
316
|
+
continue;
|
|
244
317
|
}
|
|
245
|
-
continue;
|
|
246
318
|
}
|
|
247
319
|
|
|
248
|
-
const meta = mod.default;
|
|
249
320
|
if (!meta || !meta.title) {
|
|
250
321
|
continue;
|
|
251
322
|
}
|
|
@@ -256,7 +327,6 @@ async function collectStoryMetadata() {
|
|
|
256
327
|
if (!slug) continue;
|
|
257
328
|
|
|
258
329
|
const idBase = slugifyTitle(meta.title);
|
|
259
|
-
const relPath = path.relative(ROOT_DIR, file);
|
|
260
330
|
|
|
261
331
|
const entry = index.get(slug) || {
|
|
262
332
|
slug,
|
|
@@ -287,24 +357,27 @@ async function collectStoryMetadata() {
|
|
|
287
357
|
entry.description = meta.parameters.docs.description.component;
|
|
288
358
|
}
|
|
289
359
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
360
|
+
// Only iterate over exports if we have the actual module
|
|
361
|
+
if (mod) {
|
|
362
|
+
for (const [exportName, story] of Object.entries(mod)) {
|
|
363
|
+
if (exportName === 'default' || exportName === '__namedExportsOrder') continue;
|
|
364
|
+
|
|
365
|
+
const storyItem = typeof story === 'object' ? story : null;
|
|
366
|
+
if (!storyItem) continue;
|
|
367
|
+
|
|
368
|
+
const storyTags = [];
|
|
369
|
+
if (Array.isArray(storyItem.tags)) storyTags.push(...storyItem.tags);
|
|
370
|
+
if (Array.isArray(storyItem.parameters?.pds?.tags)) storyTags.push(...storyItem.parameters.pds.tags);
|
|
371
|
+
|
|
372
|
+
entry.stories.push({
|
|
373
|
+
exportName,
|
|
374
|
+
name: storyItem.storyName || storyItem.name || exportName,
|
|
375
|
+
id: `${idBase}--${slugifySegment(exportName)}`,
|
|
376
|
+
tags: dedupe(storyTags),
|
|
377
|
+
description: trimOrNull(storyItem.parameters?.docs?.description?.story || storyItem.parameters?.docs?.description?.component),
|
|
378
|
+
source: relPath
|
|
379
|
+
});
|
|
380
|
+
}
|
|
308
381
|
}
|
|
309
382
|
|
|
310
383
|
index.set(slug, entry);
|
|
@@ -847,7 +920,8 @@ async function main() {
|
|
|
847
920
|
primitives,
|
|
848
921
|
enhancements,
|
|
849
922
|
tokens,
|
|
850
|
-
ontologyData
|
|
923
|
+
ontologyData,
|
|
924
|
+
storyIndex // Include story metadata with pds.tags for search
|
|
851
925
|
};
|
|
852
926
|
|
|
853
927
|
await fs.promises.mkdir(OUTPUT_DIR, { recursive: true });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
2
|
* Story Generator for Pure Design System Storybook
|
|
3
3
|
*
|
|
4
4
|
* Reads pds-ontology.js and pds-demo.js to auto-generate stories
|
|
@@ -51,7 +51,7 @@ const STORY_GROUPS = {
|
|
|
51
51
|
'pds-upload',
|
|
52
52
|
'pds-toaster',
|
|
53
53
|
'pds-richtext',
|
|
54
|
-
'pds-
|
|
54
|
+
'pds-form',
|
|
55
55
|
'pds-splitpanel',
|
|
56
56
|
'pds-scrollrow'
|
|
57
57
|
]
|
package/src/js/common/ask.js
CHANGED
|
@@ -50,6 +50,11 @@ export async function ask(message, options = {}) {
|
|
|
50
50
|
dialog.classList.add(options.class);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
// Set maxHeight via CSS custom property (constrained to 90vh by default)
|
|
55
|
+
if (options.maxHeight) {
|
|
56
|
+
dialog.style.setProperty('--dialog-max-height', options.maxHeight);
|
|
57
|
+
}
|
|
53
58
|
|
|
54
59
|
// Build button elements
|
|
55
60
|
const buttons = Object.entries(options.buttons).map(([code, obj]) => {
|
|
@@ -61,33 +66,55 @@ export async function ask(message, options = {}) {
|
|
|
61
66
|
// Create PDS-compliant dialog structure
|
|
62
67
|
// When useForm is true, don't wrap in a form - let the content provide the form
|
|
63
68
|
if (options.useForm) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<h2>${options.title}</h2>
|
|
67
|
-
</header>
|
|
68
|
-
|
|
69
|
-
<article id="msg-container"></article>
|
|
70
|
-
`;
|
|
71
|
-
|
|
72
|
-
// Render message content first
|
|
73
|
-
const article = dialog.querySelector("#msg-container");
|
|
69
|
+
// Create a temporary container to render the message content
|
|
70
|
+
const tempContainer = document.createElement("div");
|
|
74
71
|
if (typeof message === "object" && message._$litType$) {
|
|
75
|
-
render(message,
|
|
72
|
+
render(message, tempContainer);
|
|
76
73
|
} else if (typeof message === "string") {
|
|
77
|
-
|
|
74
|
+
tempContainer.textContent = message;
|
|
78
75
|
} else {
|
|
79
|
-
render(message,
|
|
76
|
+
render(message, tempContainer);
|
|
80
77
|
}
|
|
81
78
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
// Find the form in the rendered content
|
|
80
|
+
const form = tempContainer.querySelector("form");
|
|
81
|
+
if (form) {
|
|
82
|
+
// Build dialog structure with form as direct child for proper flex layout
|
|
83
|
+
dialog.innerHTML = /*html*/ `
|
|
84
|
+
<header>
|
|
85
|
+
<h2>${options.title}</h2>
|
|
86
|
+
</header>
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
// Create article wrapper and move form children into it (preserves DOM nodes & bindings)
|
|
90
|
+
const article = document.createElement("article");
|
|
91
|
+
article.className = "dialog-body";
|
|
92
|
+
while (form.firstChild) {
|
|
93
|
+
article.appendChild(form.firstChild);
|
|
89
94
|
}
|
|
90
|
-
|
|
95
|
+
form.appendChild(article);
|
|
96
|
+
|
|
97
|
+
// Add footer with buttons
|
|
98
|
+
const footer = document.createElement("footer");
|
|
99
|
+
footer.innerHTML = buttons.join("");
|
|
100
|
+
form.appendChild(footer);
|
|
101
|
+
|
|
102
|
+
// Append the restructured form to dialog
|
|
103
|
+
dialog.appendChild(form);
|
|
104
|
+
} else {
|
|
105
|
+
// No form found, use standard article structure
|
|
106
|
+
dialog.innerHTML = /*html*/ `
|
|
107
|
+
<header>
|
|
108
|
+
<h2>${options.title}</h2>
|
|
109
|
+
</header>
|
|
110
|
+
<article id="msg-container"></article>
|
|
111
|
+
<footer>
|
|
112
|
+
${buttons.join("")}
|
|
113
|
+
</footer>
|
|
114
|
+
`;
|
|
115
|
+
const article = dialog.querySelector("#msg-container");
|
|
116
|
+
article.appendChild(tempContainer);
|
|
117
|
+
}
|
|
91
118
|
} else {
|
|
92
119
|
dialog.innerHTML = /*html*/ `
|
|
93
120
|
<form method="dialog">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement, html, nothing } from "../../../src/js/lit.js";
|
|
1
|
+
import { LitElement, html, nothing } from "../../../src/js/lit.js";
|
|
2
2
|
//import { config } from "../config";
|
|
3
3
|
import { Generator } from "../../../src/js/pds-core/pds-generator.js";
|
|
4
4
|
import { presets } from "../../../src/js/pds-core/pds-config.js";
|
|
@@ -429,7 +429,7 @@ customElements.define(
|
|
|
429
429
|
);
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
// Flatten nested config to dot-notation for pds-
|
|
432
|
+
// Flatten nested config to dot-notation for pds-form
|
|
433
433
|
flattenConfig(obj, prefix = "") {
|
|
434
434
|
const flattened = {};
|
|
435
435
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -444,7 +444,7 @@ customElements.define(
|
|
|
444
444
|
return flattened;
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
// Get schema property paths in JSON Pointer format for pds-
|
|
447
|
+
// Get schema property paths in JSON Pointer format for pds-form
|
|
448
448
|
getSchemaProperties(schema, prefix = "") {
|
|
449
449
|
const paths = new Set();
|
|
450
450
|
if (!schema || !schema.properties) return paths;
|
|
@@ -486,7 +486,7 @@ customElements.define(
|
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
handleFormChange = (event) => {
|
|
489
|
-
// Get values from the pds-
|
|
489
|
+
// Get values from the pds-form's serialize method or from event detail
|
|
490
490
|
let values;
|
|
491
491
|
let changedField = null;
|
|
492
492
|
|
|
@@ -501,9 +501,9 @@ customElements.define(
|
|
|
501
501
|
} else {
|
|
502
502
|
// pw:value-change event - get values directly from the form element
|
|
503
503
|
const form =
|
|
504
|
-
event.currentTarget?.tagName?.toUpperCase() === "
|
|
504
|
+
event.currentTarget?.tagName?.toUpperCase() === "pds-form"
|
|
505
505
|
? event.currentTarget
|
|
506
|
-
: this.querySelector("pds-
|
|
506
|
+
: this.querySelector("pds-form");
|
|
507
507
|
|
|
508
508
|
if (form) {
|
|
509
509
|
// Use getValuesFlat() to get JSON Pointer formatted keys
|
|
@@ -873,7 +873,7 @@ export const pdsConfig = ${JSON.stringify(this.config, null, 2)};
|
|
|
873
873
|
</div>
|
|
874
874
|
|
|
875
875
|
<div class="designer-form-container">
|
|
876
|
-
<pds-
|
|
876
|
+
<pds-form
|
|
877
877
|
.jsonSchema=${this.schema}
|
|
878
878
|
.uiSchema=${this._designerUiSchema()}
|
|
879
879
|
.values=${this.formValues || {}}
|
|
@@ -882,7 +882,7 @@ export const pdsConfig = ${JSON.stringify(this.config, null, 2)};
|
|
|
882
882
|
@pw:value-change=${this.handleFormChange}
|
|
883
883
|
@pw:serialize=${this.handleFormChange}
|
|
884
884
|
>
|
|
885
|
-
</pds-
|
|
885
|
+
</pds-form>
|
|
886
886
|
</div>
|
|
887
887
|
|
|
888
888
|
<div class="designer-actions">
|
|
@@ -1009,7 +1009,7 @@ export const pdsConfig = ${JSON.stringify(this.config, null, 2)};
|
|
|
1009
1009
|
"ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
|
|
1010
1010
|
];
|
|
1011
1011
|
|
|
1012
|
-
// UI schema (paths use the pds-
|
|
1012
|
+
// UI schema (paths use the pds-form path notation, e.g. /typography/fontFamilyHeadings)
|
|
1013
1013
|
const ui = {};
|
|
1014
1014
|
|
|
1015
1015
|
// Font family fields: use datalist via ui.datalist
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement, html, nothing, render, unsafeHTML } from "../../../src/js/lit.js";
|
|
1
|
+
import { LitElement, html, nothing, render, unsafeHTML } from "../../../src/js/lit.js";
|
|
2
2
|
import { PDS } from "../../../src/js/pds.js";
|
|
3
3
|
|
|
4
4
|
import { AutoComplete } from "pure-web/ac";
|
|
@@ -1056,7 +1056,7 @@ customElements.define(
|
|
|
1056
1056
|
scrollToRelevantSection(fieldPath) {
|
|
1057
1057
|
console.log("🎯 Scrolling to section for field:", fieldPath);
|
|
1058
1058
|
|
|
1059
|
-
// Remove leading slash if present (pds-
|
|
1059
|
+
// Remove leading slash if present (pds-form sends "/behavior.transitionSpeed")
|
|
1060
1060
|
const normalizedPath = fieldPath.startsWith("/")
|
|
1061
1061
|
? fieldPath.slice(1)
|
|
1062
1062
|
: fieldPath;
|