@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.
Files changed (94) hide show
  1. package/.storybook/addons/html-preview/Panel.jsx +67 -6
  2. package/.storybook/addons/html-preview/preview.js +66 -2
  3. package/.storybook/main.js +1 -0
  4. package/.storybook/manager.js +5 -1
  5. package/.storybook/preview-head.html +1 -0
  6. package/dist/pds-reference.json +630 -383
  7. package/package.json +2 -2
  8. package/public/assets/js/app.js +9 -163
  9. package/public/assets/js/pds-ask.js +25 -0
  10. package/public/assets/js/pds-auto-definer.js +1 -0
  11. package/public/assets/js/pds-autocomplete.js +7 -0
  12. package/public/assets/js/pds-enhancers.js +1 -0
  13. package/public/assets/js/pds-manager.js +487 -254
  14. package/public/assets/js/pds-toast.js +1 -0
  15. package/public/assets/js/pds.js +2 -32
  16. package/public/assets/pds/components/pds-calendar.js +2 -2
  17. package/public/assets/pds/components/pds-drawer.js +1 -1
  18. package/public/assets/pds/components/pds-form.js +131 -33
  19. package/public/assets/pds/components/pds-icon.js +12 -9
  20. package/public/assets/pds/components/pds-live-converter.js +47 -0
  21. package/public/assets/pds/components/pds-live-edit.js +1624 -212
  22. package/public/assets/pds/components/pds-live-importer.js +773 -0
  23. package/public/assets/pds/components/pds-live-template-canvas.js +172 -0
  24. package/public/assets/pds/components/pds-omnibox.js +157 -21
  25. package/public/assets/pds/components/pds-richtext.js +2 -0
  26. package/public/assets/pds/components/pds-scrollrow.js +61 -2
  27. package/public/assets/pds/components/pds-splitpanel.js +3 -1
  28. package/public/assets/pds/components/pds-theme.js +2 -0
  29. package/public/assets/pds/components/pds-toaster.js +52 -5
  30. package/public/assets/pds/components/pds-treeview.js +974 -0
  31. package/public/assets/pds/components/pds-upload.js +2 -0
  32. package/public/assets/pds/core/pds-ask.js +25 -0
  33. package/public/assets/pds/core/pds-auto-definer.js +1 -0
  34. package/public/assets/pds/core/pds-autocomplete.js +7 -0
  35. package/public/assets/pds/core/pds-enhancers.js +1 -0
  36. package/public/assets/pds/core/pds-manager.js +487 -254
  37. package/public/assets/pds/core/pds-toast.js +1 -0
  38. package/public/assets/pds/core.js +2 -0
  39. package/public/assets/pds/custom-elements.json +865 -35
  40. package/public/assets/pds/pds-css-complete.json +7 -7
  41. package/public/assets/pds/pds-runtime-config.json +5904 -6
  42. package/public/assets/pds/pds.css-data.json +5 -35
  43. package/public/assets/pds/styles/pds-components.css +148 -24
  44. package/public/assets/pds/styles/pds-components.css.js +382 -78
  45. package/public/assets/pds/styles/pds-styles.css +275 -72
  46. package/public/assets/pds/styles/pds-styles.css.js +550 -144
  47. package/public/assets/pds/styles/pds-tokens.css +0 -5
  48. package/public/assets/pds/styles/pds-tokens.css.js +0 -10
  49. package/public/assets/pds/styles/pds-utilities.css +41 -13
  50. package/public/assets/pds/styles/pds-utilities.css.js +82 -26
  51. package/public/assets/pds/templates/commerce-scroll-explorer.html +115 -0
  52. package/public/assets/pds/templates/content-brand-showcase.html +110 -0
  53. package/public/assets/pds/templates/feedback-ops-dashboard.html +91 -0
  54. package/public/assets/pds/templates/release-readiness-radar.html +69 -0
  55. package/public/assets/pds/templates/support-command-center.html +92 -0
  56. package/public/assets/pds/templates/templates.json +53 -0
  57. package/public/assets/pds/templates/workspace-settings-lab.html +131 -0
  58. package/public/assets/pds/vscode-custom-data.json +54 -4
  59. package/src/js/app.js +7 -137
  60. package/src/js/common/ask.js +5 -2
  61. package/src/js/common/pds-core/pds.d.ts +1 -0
  62. package/src/js/common/toast.js +2 -0
  63. package/src/js/pds-ask.js +1 -0
  64. package/src/js/pds-auto-definer.js +1 -0
  65. package/src/js/pds-autocomplete.js +1 -0
  66. package/src/js/pds-core/pds-config.js +831 -40
  67. package/src/js/pds-core/pds-enhancers-meta.js +11 -0
  68. package/src/js/pds-core/pds-enhancers.js +259 -5
  69. package/src/js/pds-core/pds-generator.js +353 -52
  70. package/src/js/pds-core/pds-live.js +633 -15
  71. package/src/js/pds-core/pds-ontology.js +6 -0
  72. package/src/js/pds-core/pds-start-helpers.js +19 -7
  73. package/src/js/pds-enhancers.js +1 -0
  74. package/src/js/pds-live-manager/conversion-service.js +3135 -0
  75. package/src/js/pds-live-manager/import-contract.js +57 -0
  76. package/src/js/pds-live-manager/import-history-service.js +145 -0
  77. package/src/js/pds-live-manager/import-service.js +255 -0
  78. package/src/js/pds-live-manager/tailwind-conversion-rules.json +383 -0
  79. package/src/js/pds-live-manager/template-service.js +170 -0
  80. package/src/js/pds-manager.js +18 -0
  81. package/src/js/pds-toast.js +1 -0
  82. package/src/js/pds.d.ts +31 -0
  83. package/src/js/pds.js +227 -71
  84. package/stories/components/PdsOmnibox.stories.js +7 -6
  85. package/stories/components/PdsToaster.stories.js +7 -0
  86. package/stories/components/PdsTreeview.stories.js +589 -0
  87. package/stories/enhancements/ColorInput.stories.js +92 -0
  88. package/stories/enhancements/Dropdowns.stories.js +33 -0
  89. package/stories/enhancements/_enhancement-header.js +1 -0
  90. package/stories/foundations/Icons.stories.js +1 -1
  91. package/stories/getting-started.md +9 -1
  92. package/stories/utils/PdsAsk.stories.js +3 -2
  93. package/stories/utils/PdsParse.stories.js +3 -2
  94. 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-omnibox elements
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 pds-form / pds-omnibox stories
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
  }
@@ -70,6 +70,7 @@ const config = {
70
70
  // Ensure Lit import alias is resolved to PDS bundle
71
71
  const aliases = {
72
72
  ...config.resolve.alias,
73
+ '#pds': resolve(pdsSrcPath, 'js/pds.js'),
73
74
  '#pds/lit': resolve(pdsSrcPath, 'js/lit.js'),
74
75
  };
75
76
 
@@ -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
- window.pdsOntology = {
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
@@ -9,6 +9,7 @@
9
9
  <script type="importmap">
10
10
  {
11
11
  "imports": {
12
+ "#pds": "/assets/pds/core.js",
12
13
  "#pds/lit": "/assets/pds/external/lit.js",
13
14
  "#showdown": "https://cdn.jsdelivr.net/npm/showdown@2.1.0/dist/showdown.mjs"
14
15
  }