@pure-ds/storybook 0.5.33 → 0.5.34
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 +68 -7
- package/.storybook/addons/html-preview/preview.js +71 -8
- package/dist/pds-reference.json +39 -1
- package/package.json +2 -2
- package/public/assets/pds/components/pds-icon.js +315 -40
- package/public/assets/pds/components/pds-omnibox.js +203 -9
- package/stories/components/PdsOmnibox.stories.js +276 -35
|
@@ -109,10 +109,11 @@ const CheckIcon = () => (
|
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
export const Panel = ({ active }) => {
|
|
112
|
-
const [source, setSource] = useState({ markup: '', forms: [] });
|
|
112
|
+
const [source, setSource] = useState({ markup: '', forms: [], omniboxes: [] });
|
|
113
113
|
const [copied, setCopied] = useState(false);
|
|
114
114
|
const [highlightedMarkup, setHighlightedMarkup] = useState('');
|
|
115
115
|
const [highlightedforms, setHighlightedforms] = useState([]);
|
|
116
|
+
const [highlightedOmniboxes, setHighlightedOmniboxes] = useState([]);
|
|
116
117
|
const shikiRef = useRef(null);
|
|
117
118
|
|
|
118
119
|
// Get Storybook theme to detect light/dark mode
|
|
@@ -197,28 +198,63 @@ export const Panel = ({ active }) => {
|
|
|
197
198
|
processforms();
|
|
198
199
|
}, [source.forms, shikiTheme]);
|
|
199
200
|
|
|
201
|
+
// Highlight omnibox settings when source or theme changes
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (!source.omniboxes || source.omniboxes.length === 0) {
|
|
204
|
+
setHighlightedOmniboxes([]);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const highlightCode = async (code) => {
|
|
209
|
+
if (!code) return '';
|
|
210
|
+
const highlighter = shikiRef.current || await loadShiki();
|
|
211
|
+
if (highlighter) {
|
|
212
|
+
try {
|
|
213
|
+
return highlighter.codeToHtml(code, { lang: 'javascript', theme: shikiTheme });
|
|
214
|
+
} catch (err) {
|
|
215
|
+
return `<pre><code>${escapeHtml(code)}</code></pre>`;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return `<pre><code>${escapeHtml(code)}</code></pre>`;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const processOmniboxes = async () => {
|
|
222
|
+
const highlighted = await Promise.all(
|
|
223
|
+
source.omniboxes.map(async (omnibox, index) => ({
|
|
224
|
+
id: omnibox.id ?? index,
|
|
225
|
+
label: omnibox.label,
|
|
226
|
+
settings: await highlightCode(omnibox.settings)
|
|
227
|
+
}))
|
|
228
|
+
);
|
|
229
|
+
setHighlightedOmniboxes(highlighted);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
processOmniboxes();
|
|
233
|
+
}, [source.omniboxes, shikiTheme]);
|
|
234
|
+
|
|
200
235
|
useChannel({
|
|
201
236
|
[EVENTS.UPDATE_HTML]: (payload) => {
|
|
202
237
|
if (typeof payload === 'string') {
|
|
203
|
-
setSource({ markup: payload || '', forms: [] });
|
|
238
|
+
setSource({ markup: payload || '', forms: [], omniboxes: [] });
|
|
204
239
|
return;
|
|
205
240
|
}
|
|
206
241
|
|
|
207
242
|
if (payload && typeof payload === 'object') {
|
|
208
243
|
setSource({
|
|
209
244
|
markup: payload.markup || '',
|
|
210
|
-
forms: Array.isArray(payload.forms) ? payload.forms : []
|
|
245
|
+
forms: Array.isArray(payload.forms) ? payload.forms : [],
|
|
246
|
+
omniboxes: Array.isArray(payload.omniboxes) ? payload.omniboxes : []
|
|
211
247
|
});
|
|
212
248
|
return;
|
|
213
249
|
}
|
|
214
250
|
|
|
215
|
-
setSource({ markup: '', forms: [] });
|
|
251
|
+
setSource({ markup: '', forms: [], omniboxes: [] });
|
|
216
252
|
}
|
|
217
253
|
});
|
|
218
254
|
|
|
219
255
|
// Request HTML update when panel becomes active
|
|
220
256
|
React.useEffect(() => {
|
|
221
|
-
if (active && !source.markup && source.forms.length === 0) {
|
|
257
|
+
if (active && !source.markup && source.forms.length === 0 && source.omniboxes.length === 0) {
|
|
222
258
|
// Trigger a re-extraction by emitting a request event
|
|
223
259
|
// The decorator will pick this up on the next render cycle
|
|
224
260
|
const container = document.querySelector('#storybook-root');
|
|
@@ -230,7 +266,7 @@ export const Panel = ({ active }) => {
|
|
|
230
266
|
}, 100);
|
|
231
267
|
}
|
|
232
268
|
}
|
|
233
|
-
}, [active, source.markup, source.forms.length]);
|
|
269
|
+
}, [active, source.markup, source.forms.length, source.omniboxes.length]);
|
|
234
270
|
|
|
235
271
|
const copyToClipboard = useCallback(async () => {
|
|
236
272
|
try {
|
|
@@ -245,8 +281,9 @@ export const Panel = ({ active }) => {
|
|
|
245
281
|
|
|
246
282
|
const hasMarkup = Boolean(source.markup);
|
|
247
283
|
const hasforms = source.forms.length > 0;
|
|
284
|
+
const hasOmniboxes = source.omniboxes.length > 0;
|
|
248
285
|
|
|
249
|
-
if (!hasMarkup && !hasforms) {
|
|
286
|
+
if (!hasMarkup && !hasforms && !hasOmniboxes) {
|
|
250
287
|
return (
|
|
251
288
|
<Container>
|
|
252
289
|
<EmptyState>
|
|
@@ -314,6 +351,30 @@ export const Panel = ({ active }) => {
|
|
|
314
351
|
);
|
|
315
352
|
})}
|
|
316
353
|
|
|
354
|
+
{hasOmniboxes && source.omniboxes.map((sourceOmnibox, index) => {
|
|
355
|
+
const key = sourceOmnibox.id ?? index;
|
|
356
|
+
const highlightedOmnibox = highlightedOmniboxes[index];
|
|
357
|
+
const heading = source.omniboxes.length > 1 ? (sourceOmnibox.label || `Omnibox ${index + 1}`) : 'pds-omnibox';
|
|
358
|
+
|
|
359
|
+
return (
|
|
360
|
+
<SectionWrapper key={key}>
|
|
361
|
+
<SectionHeading>{heading}</SectionHeading>
|
|
362
|
+
|
|
363
|
+
{sourceOmnibox.settings && (
|
|
364
|
+
<>
|
|
365
|
+
<Subheading>settings</Subheading>
|
|
366
|
+
<CodeBlock
|
|
367
|
+
$compact
|
|
368
|
+
dangerouslySetInnerHTML={{
|
|
369
|
+
__html: highlightedOmnibox?.settings || `<pre><code>${escapeHtml(sourceOmnibox.settings)}</code></pre>`
|
|
370
|
+
}}
|
|
371
|
+
/>
|
|
372
|
+
</>
|
|
373
|
+
)}
|
|
374
|
+
</SectionWrapper>
|
|
375
|
+
);
|
|
376
|
+
})}
|
|
377
|
+
|
|
317
378
|
{hasMarkup && (
|
|
318
379
|
<CopyButton
|
|
319
380
|
onClick={copyToClipboard}
|
|
@@ -197,6 +197,39 @@ function generatePdsFormMarkup(formElement) {
|
|
|
197
197
|
return `<pds-form${formattedAttrs}>${slotContent}</pds-form>`;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Generate realistic source code for pds-omnibox elements
|
|
202
|
+
*/
|
|
203
|
+
function generatePdsOmniboxMarkup(omniboxElement) {
|
|
204
|
+
const attrs = [];
|
|
205
|
+
|
|
206
|
+
const stringAttrs = ['name', 'placeholder', 'value', 'autocomplete'];
|
|
207
|
+
stringAttrs.forEach((attr) => {
|
|
208
|
+
const value = omniboxElement.getAttribute(attr);
|
|
209
|
+
if (value !== null && value !== undefined && value !== '') {
|
|
210
|
+
attrs.push(`${attr}="${value}"`);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
if (omniboxElement.hasAttribute('required')) {
|
|
215
|
+
attrs.push('required');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (omniboxElement.hasAttribute('disabled')) {
|
|
219
|
+
attrs.push('disabled');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (omniboxElement.settings) {
|
|
223
|
+
attrs.push('.settings=${settings}');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const formattedAttrs = attrs.length > 0
|
|
227
|
+
? '\n ' + attrs.join('\n ') + '\n'
|
|
228
|
+
: '';
|
|
229
|
+
|
|
230
|
+
return `<pds-omnibox${formattedAttrs}></pds-omnibox>`;
|
|
231
|
+
}
|
|
232
|
+
|
|
200
233
|
/**
|
|
201
234
|
* Global decorator that extracts and sends HTML to the panel
|
|
202
235
|
*/
|
|
@@ -211,14 +244,16 @@ export const withHTMLExtractor = (storyFn, context) => {
|
|
|
211
244
|
// Try to get HTML from the story container
|
|
212
245
|
const container = document.querySelector('#storybook-root');
|
|
213
246
|
if (container) {
|
|
214
|
-
// Check if this story has pds-form elements
|
|
247
|
+
// Check if this story has pds-form or pds-omnibox elements
|
|
215
248
|
const pdsFormElements = Array.from(container.querySelectorAll('pds-form'));
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
249
|
+
const pdsOmniboxElements = Array.from(container.querySelectorAll('pds-omnibox'));
|
|
250
|
+
const hasSpecialElements = pdsFormElements.length > 0 || pdsOmniboxElements.length > 0;
|
|
251
|
+
|
|
252
|
+
if (hasSpecialElements) {
|
|
253
|
+
// Generate realistic markup for pds-form / pds-omnibox stories
|
|
219
254
|
const alerts = Array.from(container.querySelectorAll('.callout'));
|
|
220
255
|
let markup = '';
|
|
221
|
-
|
|
256
|
+
|
|
222
257
|
// Include any alert/info boxes before the form
|
|
223
258
|
if (alerts.length > 0) {
|
|
224
259
|
alerts.forEach(alert => {
|
|
@@ -227,12 +262,17 @@ export const withHTMLExtractor = (storyFn, context) => {
|
|
|
227
262
|
markup += `</div>\n\n`;
|
|
228
263
|
});
|
|
229
264
|
}
|
|
230
|
-
|
|
265
|
+
|
|
231
266
|
// Add pds-form markup
|
|
232
267
|
pdsFormElements.forEach(form => {
|
|
233
268
|
markup += generatePdsFormMarkup(form);
|
|
234
269
|
});
|
|
235
|
-
|
|
270
|
+
|
|
271
|
+
// Add pds-omnibox markup
|
|
272
|
+
pdsOmniboxElements.forEach(omnibox => {
|
|
273
|
+
markup += generatePdsOmniboxMarkup(omnibox);
|
|
274
|
+
});
|
|
275
|
+
|
|
236
276
|
html = markup;
|
|
237
277
|
} else {
|
|
238
278
|
// No pds-form elements, use standard extraction
|
|
@@ -264,9 +304,32 @@ export const withHTMLExtractor = (storyFn, context) => {
|
|
|
264
304
|
})
|
|
265
305
|
.filter((entry) => entry.jsonSchema || entry.uiSchema || entry.options);
|
|
266
306
|
|
|
307
|
+
const omniboxes = pdsOmniboxElements
|
|
308
|
+
.map((omnibox, index) => {
|
|
309
|
+
const label =
|
|
310
|
+
omnibox.getAttribute?.('id') ||
|
|
311
|
+
omnibox.getAttribute?.('name') ||
|
|
312
|
+
(pdsOmniboxElements.length > 1 ? `Omnibox ${index + 1}` : 'Omnibox');
|
|
313
|
+
|
|
314
|
+
const settingsSource =
|
|
315
|
+
omnibox.getAttribute?.('data-settings-source') ||
|
|
316
|
+
omnibox.dataset?.settingsSource ||
|
|
317
|
+
null;
|
|
318
|
+
|
|
319
|
+
const settings = settingsSource || serializeForDisplay(omnibox.settings);
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
id: index,
|
|
323
|
+
label,
|
|
324
|
+
settings
|
|
325
|
+
};
|
|
326
|
+
})
|
|
327
|
+
.filter((entry) => entry.settings);
|
|
328
|
+
|
|
267
329
|
channel.emit(EVENTS.UPDATE_HTML, {
|
|
268
330
|
markup: html || '',
|
|
269
|
-
forms
|
|
331
|
+
forms,
|
|
332
|
+
omniboxes
|
|
270
333
|
});
|
|
271
334
|
}
|
|
272
335
|
};
|
package/dist/pds-reference.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-01-
|
|
2
|
+
"generatedAt": "2026-01-29T12:10:11.322Z",
|
|
3
3
|
"sources": {
|
|
4
4
|
"customElements": "custom-elements.json",
|
|
5
5
|
"ontology": "src\\js\\pds-core\\pds-ontology.js",
|
|
@@ -2723,6 +2723,14 @@
|
|
|
2723
2723
|
],
|
|
2724
2724
|
"ontology": null,
|
|
2725
2725
|
"stories": [
|
|
2726
|
+
{
|
|
2727
|
+
"exportName": "CombinedCategories",
|
|
2728
|
+
"name": "CombinedCategories",
|
|
2729
|
+
"id": "components-pds-omnibox--combined-categories",
|
|
2730
|
+
"tags": [],
|
|
2731
|
+
"description": null,
|
|
2732
|
+
"source": "packages\\pds-storybook\\stories\\components\\PdsOmnibox.stories.js"
|
|
2733
|
+
},
|
|
2726
2734
|
{
|
|
2727
2735
|
"exportName": "Default",
|
|
2728
2736
|
"name": "Default",
|
|
@@ -2730,6 +2738,14 @@
|
|
|
2730
2738
|
"tags": [],
|
|
2731
2739
|
"description": null,
|
|
2732
2740
|
"source": "packages\\pds-storybook\\stories\\components\\PdsOmnibox.stories.js"
|
|
2741
|
+
},
|
|
2742
|
+
{
|
|
2743
|
+
"exportName": "InForm",
|
|
2744
|
+
"name": "InForm",
|
|
2745
|
+
"id": "components-pds-omnibox--in-form",
|
|
2746
|
+
"tags": [],
|
|
2747
|
+
"description": null,
|
|
2748
|
+
"source": "packages\\pds-storybook\\stories\\components\\PdsOmnibox.stories.js"
|
|
2733
2749
|
}
|
|
2734
2750
|
],
|
|
2735
2751
|
"sourceModule": "public/assets/pds/components/pds-omnibox.js",
|
|
@@ -2836,6 +2852,12 @@
|
|
|
2836
2852
|
"parameters": [],
|
|
2837
2853
|
"return": "void"
|
|
2838
2854
|
},
|
|
2855
|
+
{
|
|
2856
|
+
"name": "disconnectedCallback",
|
|
2857
|
+
"description": null,
|
|
2858
|
+
"parameters": [],
|
|
2859
|
+
"return": "void"
|
|
2860
|
+
},
|
|
2839
2861
|
{
|
|
2840
2862
|
"name": "formAssociatedCallback",
|
|
2841
2863
|
"description": null,
|
|
@@ -5584,6 +5606,14 @@
|
|
|
5584
5606
|
]
|
|
5585
5607
|
},
|
|
5586
5608
|
"stories": [
|
|
5609
|
+
{
|
|
5610
|
+
"exportName": "CombinedCategories",
|
|
5611
|
+
"name": "CombinedCategories",
|
|
5612
|
+
"id": "components-pds-omnibox--combined-categories",
|
|
5613
|
+
"tags": [],
|
|
5614
|
+
"description": null,
|
|
5615
|
+
"source": "packages\\pds-storybook\\stories\\components\\PdsOmnibox.stories.js"
|
|
5616
|
+
},
|
|
5587
5617
|
{
|
|
5588
5618
|
"exportName": "Default",
|
|
5589
5619
|
"name": "Default",
|
|
@@ -5591,6 +5621,14 @@
|
|
|
5591
5621
|
"tags": [],
|
|
5592
5622
|
"description": null,
|
|
5593
5623
|
"source": "packages\\pds-storybook\\stories\\components\\PdsOmnibox.stories.js"
|
|
5624
|
+
},
|
|
5625
|
+
{
|
|
5626
|
+
"exportName": "InForm",
|
|
5627
|
+
"name": "InForm",
|
|
5628
|
+
"id": "components-pds-omnibox--in-form",
|
|
5629
|
+
"tags": [],
|
|
5630
|
+
"description": null,
|
|
5631
|
+
"source": "packages\\pds-storybook\\stories\\components\\PdsOmnibox.stories.js"
|
|
5594
5632
|
}
|
|
5595
5633
|
],
|
|
5596
5634
|
"files": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pure-ds/storybook",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.34",
|
|
4
4
|
"description": "Storybook showcase for Pure Design System with live configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"pds:build-icons": "pds-build-icons"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@pure-ds/core": "^0.5.
|
|
41
|
+
"@pure-ds/core": "^0.5.34"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|