@pure-ds/storybook 0.6.9 → 0.7.1
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 +67 -6
- package/.storybook/addons/html-preview/preview.js +66 -2
- package/.storybook/main.js +1 -0
- package/.storybook/manager.js +5 -1
- package/.storybook/preview-head.html +1 -0
- package/dist/pds-reference.json +630 -383
- package/package.json +2 -2
- package/public/assets/js/app.js +9 -163
- package/public/assets/js/pds-ask.js +25 -0
- package/public/assets/js/pds-auto-definer.js +1 -0
- package/public/assets/js/pds-autocomplete.js +7 -0
- package/public/assets/js/pds-enhancers.js +1 -0
- package/public/assets/js/pds-manager.js +487 -254
- package/public/assets/js/pds-toast.js +1 -0
- package/public/assets/js/pds.js +2 -32
- package/public/assets/pds/components/pds-calendar.js +2 -2
- package/public/assets/pds/components/pds-drawer.js +1 -1
- package/public/assets/pds/components/pds-form.js +131 -33
- package/public/assets/pds/components/pds-icon.js +12 -9
- package/public/assets/pds/components/pds-live-converter.js +47 -0
- package/public/assets/pds/components/pds-live-edit.js +1624 -212
- package/public/assets/pds/components/pds-live-importer.js +773 -0
- package/public/assets/pds/components/pds-live-template-canvas.js +172 -0
- package/public/assets/pds/components/pds-omnibox.js +157 -21
- package/public/assets/pds/components/pds-richtext.js +2 -0
- package/public/assets/pds/components/pds-scrollrow.js +61 -2
- package/public/assets/pds/components/pds-splitpanel.js +3 -1
- package/public/assets/pds/components/pds-theme.js +2 -0
- package/public/assets/pds/components/pds-toaster.js +52 -5
- package/public/assets/pds/components/pds-treeview.js +974 -0
- package/public/assets/pds/components/pds-upload.js +2 -0
- package/public/assets/pds/core/pds-ask.js +25 -0
- package/public/assets/pds/core/pds-auto-definer.js +1 -0
- package/public/assets/pds/core/pds-autocomplete.js +7 -0
- package/public/assets/pds/core/pds-enhancers.js +1 -0
- package/public/assets/pds/core/pds-manager.js +487 -254
- package/public/assets/pds/core/pds-toast.js +1 -0
- package/public/assets/pds/core.js +2 -0
- package/public/assets/pds/custom-elements.json +865 -35
- package/public/assets/pds/pds-css-complete.json +7 -7
- package/public/assets/pds/pds-runtime-config.json +5904 -6
- package/public/assets/pds/pds.css-data.json +5 -35
- package/public/assets/pds/styles/pds-components.css +148 -24
- package/public/assets/pds/styles/pds-components.css.js +382 -78
- package/public/assets/pds/styles/pds-styles.css +275 -72
- package/public/assets/pds/styles/pds-styles.css.js +550 -144
- package/public/assets/pds/styles/pds-tokens.css +0 -5
- package/public/assets/pds/styles/pds-tokens.css.js +0 -10
- package/public/assets/pds/styles/pds-utilities.css +41 -13
- package/public/assets/pds/styles/pds-utilities.css.js +82 -26
- package/public/assets/pds/templates/commerce-scroll-explorer.html +115 -0
- package/public/assets/pds/templates/content-brand-showcase.html +110 -0
- package/public/assets/pds/templates/feedback-ops-dashboard.html +91 -0
- package/public/assets/pds/templates/release-readiness-radar.html +69 -0
- package/public/assets/pds/templates/support-command-center.html +92 -0
- package/public/assets/pds/templates/templates.json +53 -0
- package/public/assets/pds/templates/workspace-settings-lab.html +131 -0
- package/public/assets/pds/vscode-custom-data.json +54 -4
- package/src/js/app.js +7 -137
- package/src/js/common/ask.js +5 -2
- package/src/js/common/pds-core/pds.d.ts +1 -0
- package/src/js/common/toast.js +2 -0
- package/src/js/pds-ask.js +1 -0
- package/src/js/pds-auto-definer.js +1 -0
- package/src/js/pds-autocomplete.js +1 -0
- package/src/js/pds-core/pds-config.js +831 -40
- package/src/js/pds-core/pds-enhancers-meta.js +11 -0
- package/src/js/pds-core/pds-enhancers.js +259 -5
- package/src/js/pds-core/pds-generator.js +353 -52
- package/src/js/pds-core/pds-live.js +633 -15
- package/src/js/pds-core/pds-ontology.js +6 -0
- package/src/js/pds-core/pds-start-helpers.js +19 -7
- package/src/js/pds-enhancers.js +1 -0
- package/src/js/pds-live-manager/conversion-service.js +3135 -0
- package/src/js/pds-live-manager/import-contract.js +57 -0
- package/src/js/pds-live-manager/import-history-service.js +145 -0
- package/src/js/pds-live-manager/import-service.js +255 -0
- package/src/js/pds-live-manager/tailwind-conversion-rules.json +383 -0
- package/src/js/pds-live-manager/template-service.js +170 -0
- package/src/js/pds-manager.js +18 -0
- package/src/js/pds-toast.js +1 -0
- package/src/js/pds.d.ts +31 -0
- package/src/js/pds.js +227 -71
- package/stories/components/PdsOmnibox.stories.js +7 -6
- package/stories/components/PdsToaster.stories.js +7 -0
- package/stories/components/PdsTreeview.stories.js +589 -0
- package/stories/enhancements/ColorInput.stories.js +92 -0
- package/stories/enhancements/Dropdowns.stories.js +33 -0
- package/stories/enhancements/_enhancement-header.js +1 -0
- package/stories/foundations/Icons.stories.js +1 -1
- package/stories/getting-started.md +9 -1
- package/stories/utils/PdsAsk.stories.js +3 -2
- package/stories/utils/PdsParse.stories.js +3 -2
- package/stories/utils/PdsToast.stories.js +66 -2
|
@@ -109,11 +109,12 @@ const CheckIcon = () => (
|
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
export const Panel = ({ active }) => {
|
|
112
|
-
const [source, setSource] = useState({ markup: '', forms: [], omniboxes: [], fabs: [] });
|
|
112
|
+
const [source, setSource] = useState({ markup: '', forms: [], omniboxes: [], treeviews: [], fabs: [] });
|
|
113
113
|
const [copied, setCopied] = useState(false);
|
|
114
114
|
const [highlightedMarkup, setHighlightedMarkup] = useState('');
|
|
115
115
|
const [highlightedforms, setHighlightedforms] = useState([]);
|
|
116
116
|
const [highlightedOmniboxes, setHighlightedOmniboxes] = useState([]);
|
|
117
|
+
const [highlightedTreeviews, setHighlightedTreeviews] = useState([]);
|
|
117
118
|
const [highlightedFabs, setHighlightedFabs] = useState([]);
|
|
118
119
|
const shikiRef = useRef(null);
|
|
119
120
|
|
|
@@ -267,10 +268,44 @@ export const Panel = ({ active }) => {
|
|
|
267
268
|
processFabs();
|
|
268
269
|
}, [source.fabs, shikiTheme]);
|
|
269
270
|
|
|
271
|
+
// Highlight treeview options when source or theme changes
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
if (!source.treeviews || source.treeviews.length === 0) {
|
|
274
|
+
setHighlightedTreeviews([]);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const highlightCode = async (code) => {
|
|
279
|
+
if (!code) return '';
|
|
280
|
+
const highlighter = shikiRef.current || await loadShiki();
|
|
281
|
+
if (highlighter) {
|
|
282
|
+
try {
|
|
283
|
+
return highlighter.codeToHtml(code, { lang: 'javascript', theme: shikiTheme });
|
|
284
|
+
} catch (err) {
|
|
285
|
+
return `<pre><code>${escapeHtml(code)}</code></pre>`;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return `<pre><code>${escapeHtml(code)}</code></pre>`;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const processTreeviews = async () => {
|
|
292
|
+
const highlighted = await Promise.all(
|
|
293
|
+
source.treeviews.map(async (treeview, index) => ({
|
|
294
|
+
id: treeview.id ?? index,
|
|
295
|
+
label: treeview.label,
|
|
296
|
+
options: await highlightCode(treeview.options)
|
|
297
|
+
}))
|
|
298
|
+
);
|
|
299
|
+
setHighlightedTreeviews(highlighted);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
processTreeviews();
|
|
303
|
+
}, [source.treeviews, shikiTheme]);
|
|
304
|
+
|
|
270
305
|
useChannel({
|
|
271
306
|
[EVENTS.UPDATE_HTML]: (payload) => {
|
|
272
307
|
if (typeof payload === 'string') {
|
|
273
|
-
setSource({ markup: payload || '', forms: [], omniboxes: [], fabs: [] });
|
|
308
|
+
setSource({ markup: payload || '', forms: [], omniboxes: [], treeviews: [], fabs: [] });
|
|
274
309
|
return;
|
|
275
310
|
}
|
|
276
311
|
|
|
@@ -279,18 +314,19 @@ export const Panel = ({ active }) => {
|
|
|
279
314
|
markup: payload.markup || '',
|
|
280
315
|
forms: Array.isArray(payload.forms) ? payload.forms : [],
|
|
281
316
|
omniboxes: Array.isArray(payload.omniboxes) ? payload.omniboxes : [],
|
|
317
|
+
treeviews: Array.isArray(payload.treeviews) ? payload.treeviews : [],
|
|
282
318
|
fabs: Array.isArray(payload.fabs) ? payload.fabs : []
|
|
283
319
|
});
|
|
284
320
|
return;
|
|
285
321
|
}
|
|
286
322
|
|
|
287
|
-
setSource({ markup: '', forms: [], omniboxes: [], fabs: [] });
|
|
323
|
+
setSource({ markup: '', forms: [], omniboxes: [], treeviews: [], fabs: [] });
|
|
288
324
|
}
|
|
289
325
|
});
|
|
290
326
|
|
|
291
327
|
// Request HTML update when panel becomes active
|
|
292
328
|
React.useEffect(() => {
|
|
293
|
-
if (active && !source.markup && source.forms.length === 0 && source.omniboxes.length === 0 && source.fabs.length === 0) {
|
|
329
|
+
if (active && !source.markup && source.forms.length === 0 && source.omniboxes.length === 0 && source.treeviews.length === 0 && source.fabs.length === 0) {
|
|
294
330
|
// Trigger a re-extraction by emitting a request event
|
|
295
331
|
// The decorator will pick this up on the next render cycle
|
|
296
332
|
const container = document.querySelector('#storybook-root');
|
|
@@ -302,7 +338,7 @@ export const Panel = ({ active }) => {
|
|
|
302
338
|
}, 100);
|
|
303
339
|
}
|
|
304
340
|
}
|
|
305
|
-
}, [active, source.markup, source.forms.length, source.omniboxes.length, source.fabs.length]);
|
|
341
|
+
}, [active, source.markup, source.forms.length, source.omniboxes.length, source.treeviews.length, source.fabs.length]);
|
|
306
342
|
|
|
307
343
|
const copyToClipboard = useCallback(async () => {
|
|
308
344
|
try {
|
|
@@ -318,9 +354,10 @@ export const Panel = ({ active }) => {
|
|
|
318
354
|
const hasMarkup = Boolean(source.markup);
|
|
319
355
|
const hasforms = source.forms.length > 0;
|
|
320
356
|
const hasOmniboxes = source.omniboxes.length > 0;
|
|
357
|
+
const hasTreeviews = source.treeviews.length > 0;
|
|
321
358
|
const hasFabs = source.fabs.length > 0;
|
|
322
359
|
|
|
323
|
-
if (!hasMarkup && !hasforms && !hasOmniboxes && !hasFabs) {
|
|
360
|
+
if (!hasMarkup && !hasforms && !hasOmniboxes && !hasTreeviews && !hasFabs) {
|
|
324
361
|
return (
|
|
325
362
|
<Container>
|
|
326
363
|
<EmptyState>
|
|
@@ -437,6 +474,30 @@ export const Panel = ({ active }) => {
|
|
|
437
474
|
);
|
|
438
475
|
})}
|
|
439
476
|
|
|
477
|
+
{hasTreeviews && source.treeviews.map((sourceTreeview, index) => {
|
|
478
|
+
const key = sourceTreeview.id ?? index;
|
|
479
|
+
const highlightedTreeview = highlightedTreeviews[index];
|
|
480
|
+
const heading = source.treeviews.length > 1 ? (sourceTreeview.label || `Treeview ${index + 1}`) : 'pds-treeview';
|
|
481
|
+
|
|
482
|
+
return (
|
|
483
|
+
<SectionWrapper key={key}>
|
|
484
|
+
<SectionHeading>{heading}</SectionHeading>
|
|
485
|
+
|
|
486
|
+
{sourceTreeview.options && (
|
|
487
|
+
<>
|
|
488
|
+
<Subheading>options</Subheading>
|
|
489
|
+
<CodeBlock
|
|
490
|
+
$compact
|
|
491
|
+
dangerouslySetInnerHTML={{
|
|
492
|
+
__html: highlightedTreeview?.options || `<pre><code>${escapeHtml(sourceTreeview.options)}</code></pre>`
|
|
493
|
+
}}
|
|
494
|
+
/>
|
|
495
|
+
</>
|
|
496
|
+
)}
|
|
497
|
+
</SectionWrapper>
|
|
498
|
+
);
|
|
499
|
+
})}
|
|
500
|
+
|
|
440
501
|
|
|
441
502
|
{hasMarkup && (
|
|
442
503
|
<CopyButton
|
|
@@ -241,6 +241,38 @@ function generatePdsOmniboxMarkup(omniboxElement) {
|
|
|
241
241
|
return `<pds-omnibox${formattedAttrs}></pds-omnibox>`;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Generate realistic source code for pds-treeview elements
|
|
246
|
+
*/
|
|
247
|
+
function generatePdsTreeviewMarkup(treeviewElement) {
|
|
248
|
+
const attrs = [];
|
|
249
|
+
|
|
250
|
+
const stringAttrs = ['name', 'value', 'src'];
|
|
251
|
+
stringAttrs.forEach((attr) => {
|
|
252
|
+
const value = treeviewElement.getAttribute(attr);
|
|
253
|
+
if (value !== null && value !== undefined && value !== '') {
|
|
254
|
+
attrs.push(`${attr}="${value}"`);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const booleanAttrs = ['required', 'disabled', 'display-only', 'expanded-all'];
|
|
259
|
+
booleanAttrs.forEach((attr) => {
|
|
260
|
+
if (treeviewElement.hasAttribute(attr)) {
|
|
261
|
+
attrs.push(attr);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
if (treeviewElement.options || treeviewElement.settings) {
|
|
266
|
+
attrs.push('.options=${options}');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const formattedAttrs = attrs.length > 0
|
|
270
|
+
? '\n ' + attrs.join('\n ') + '\n'
|
|
271
|
+
: '';
|
|
272
|
+
|
|
273
|
+
return `<pds-treeview${formattedAttrs}></pds-treeview>`;
|
|
274
|
+
}
|
|
275
|
+
|
|
244
276
|
/**
|
|
245
277
|
* Generate realistic source code for pds-fab elements
|
|
246
278
|
*/
|
|
@@ -288,17 +320,19 @@ export const withHTMLExtractor = (storyFn, context) => {
|
|
|
288
320
|
// Try to get HTML from the story container
|
|
289
321
|
const container = document.querySelector('#storybook-root');
|
|
290
322
|
if (container) {
|
|
291
|
-
// Check if this story has pds-form or pds-
|
|
323
|
+
// Check if this story has pds-form, pds-omnibox, pds-treeview, or pds-fab elements
|
|
292
324
|
const pdsFormElements = Array.from(container.querySelectorAll('pds-form'));
|
|
293
325
|
const pdsOmniboxElements = Array.from(container.querySelectorAll('pds-omnibox'));
|
|
326
|
+
const pdsTreeviewElements = Array.from(container.querySelectorAll('pds-treeview'));
|
|
294
327
|
const pdsFabElements = Array.from(container.querySelectorAll('pds-fab'));
|
|
295
328
|
const hasSpecialElements =
|
|
296
329
|
pdsFormElements.length > 0 ||
|
|
297
330
|
pdsOmniboxElements.length > 0 ||
|
|
331
|
+
pdsTreeviewElements.length > 0 ||
|
|
298
332
|
pdsFabElements.length > 0;
|
|
299
333
|
|
|
300
334
|
if (hasSpecialElements) {
|
|
301
|
-
// Generate realistic markup for
|
|
335
|
+
// Generate realistic markup for PDS component stories
|
|
302
336
|
const alerts = Array.from(container.querySelectorAll('.callout'));
|
|
303
337
|
let markup = '';
|
|
304
338
|
|
|
@@ -321,6 +355,11 @@ export const withHTMLExtractor = (storyFn, context) => {
|
|
|
321
355
|
markup += generatePdsOmniboxMarkup(omnibox);
|
|
322
356
|
});
|
|
323
357
|
|
|
358
|
+
// Add pds-treeview markup
|
|
359
|
+
pdsTreeviewElements.forEach(treeview => {
|
|
360
|
+
markup += generatePdsTreeviewMarkup(treeview);
|
|
361
|
+
});
|
|
362
|
+
|
|
324
363
|
// Add pds-fab markup
|
|
325
364
|
pdsFabElements.forEach(fab => {
|
|
326
365
|
markup += generatePdsFabMarkup(fab);
|
|
@@ -379,6 +418,30 @@ export const withHTMLExtractor = (storyFn, context) => {
|
|
|
379
418
|
})
|
|
380
419
|
.filter((entry) => entry.settings);
|
|
381
420
|
|
|
421
|
+
const treeviews = pdsTreeviewElements
|
|
422
|
+
.map((treeview, index) => {
|
|
423
|
+
const label =
|
|
424
|
+
treeview.getAttribute?.('id') ||
|
|
425
|
+
treeview.getAttribute?.('name') ||
|
|
426
|
+
(pdsTreeviewElements.length > 1 ? `Treeview ${index + 1}` : 'Treeview');
|
|
427
|
+
|
|
428
|
+
const optionsSource =
|
|
429
|
+
treeview.getAttribute?.('data-options-source') ||
|
|
430
|
+
treeview.dataset?.optionsSource ||
|
|
431
|
+
null;
|
|
432
|
+
|
|
433
|
+
const options =
|
|
434
|
+
optionsSource ||
|
|
435
|
+
serializeForDisplay(treeview.options || treeview.settings) ||
|
|
436
|
+
'const options = {};';
|
|
437
|
+
|
|
438
|
+
return {
|
|
439
|
+
id: index,
|
|
440
|
+
label,
|
|
441
|
+
options
|
|
442
|
+
};
|
|
443
|
+
});
|
|
444
|
+
|
|
382
445
|
const fabs = pdsFabElements
|
|
383
446
|
.map((fab, index) => {
|
|
384
447
|
const label =
|
|
@@ -404,6 +467,7 @@ export const withHTMLExtractor = (storyFn, context) => {
|
|
|
404
467
|
markup: html || '',
|
|
405
468
|
forms,
|
|
406
469
|
omniboxes,
|
|
470
|
+
treeviews,
|
|
407
471
|
fabs
|
|
408
472
|
});
|
|
409
473
|
}
|
package/.storybook/main.js
CHANGED
package/.storybook/manager.js
CHANGED
|
@@ -818,7 +818,7 @@ addons.register(ADDON_ID, (api) => {
|
|
|
818
818
|
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
819
819
|
|
|
820
820
|
// Public API for programmatic search
|
|
821
|
-
|
|
821
|
+
const pdsOntologyApi = {
|
|
822
822
|
search: (query) => {
|
|
823
823
|
const field = document.getElementById('storybook-explorer-searchfield');
|
|
824
824
|
if (field) {
|
|
@@ -838,6 +838,10 @@ addons.register(ADDON_ID, (api) => {
|
|
|
838
838
|
}
|
|
839
839
|
};
|
|
840
840
|
|
|
841
|
+
if (typeof globalThis !== 'undefined') {
|
|
842
|
+
globalThis.pdsOntology = pdsOntologyApi;
|
|
843
|
+
}
|
|
844
|
+
|
|
841
845
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
842
846
|
// AUTO-SELECT CODE PANEL FOR ENHANCEMENT STORIES
|
|
843
847
|
// Switch to the "Code" panel when navigating to Enhancement stories
|