@pure-ds/storybook 0.7.4 → 0.7.23

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 (99) hide show
  1. package/.storybook/addons/html-preview/preview.js +1 -1
  2. package/.storybook/htmlPreview.js +2 -7
  3. package/.storybook/main.js +20 -12
  4. package/.storybook/preview-head.html +1 -0
  5. package/.storybook/preview.js +71 -0
  6. package/.storybook/shiki.js +1 -0
  7. package/dist/pds-reference.json +411 -313
  8. package/package.json +2 -2
  9. package/public/assets/js/app.js +2 -2
  10. package/public/assets/js/pds-manager.js +281 -307
  11. package/public/assets/js/pds.js +2 -2
  12. package/public/assets/pds/components/pds-calendar.js +522 -26
  13. package/public/assets/pds/components/pds-code.js +203 -0
  14. package/public/assets/pds/components/pds-form.js +85 -2
  15. package/public/assets/pds/components/pds-icon.js +165 -39
  16. package/public/assets/pds/components/pds-live-importer.js +2 -2
  17. package/public/assets/pds/components/pds-omnibox.js +9 -6
  18. package/public/assets/pds/components/pds-scrollrow.js +27 -2
  19. package/public/assets/pds/components/pds-treeview.js +506 -24
  20. package/public/assets/pds/core/pds-manager.js +281 -307
  21. package/public/assets/pds/core.js +2 -2
  22. package/public/assets/pds/custom-elements.json +263 -18
  23. package/public/assets/pds/external/shiki.js +32 -0
  24. package/public/assets/pds/pds-css-complete.json +1 -1
  25. package/public/assets/pds/pds-runtime-config.json +1 -1
  26. package/public/assets/pds/styles/pds-components.css +93 -96
  27. package/public/assets/pds/styles/pds-components.css.js +186 -192
  28. package/public/assets/pds/styles/pds-primitives.css +61 -66
  29. package/public/assets/pds/styles/pds-primitives.css.js +122 -132
  30. package/public/assets/pds/styles/pds-styles.css +148 -156
  31. package/public/assets/pds/styles/pds-styles.css.js +296 -312
  32. package/public/assets/pds/templates/feedback-ops-dashboard.html +1 -1
  33. package/public/assets/pds/templates/release-readiness-radar.html +2 -2
  34. package/public/assets/pds/templates/support-command-center.html +1 -1
  35. package/public/assets/pds/vscode-custom-data.json +4 -0
  36. package/scripts/build-pds-reference.mjs +33 -0
  37. package/src/js/components/pds-code.js +203 -0
  38. package/src/js/external/shiki.js +32 -0
  39. package/src/js/pds-core/pds-config.js +1 -0
  40. package/src/js/pds-core/pds-generator.js +152 -160
  41. package/src/js/pds-core/pds-live.js +55 -34
  42. package/src/js/pds-core/pds-ontology.js +2 -2
  43. package/src/js/pds-core/pds-runtime.js +18 -2
  44. package/src/js/pds.d.ts +2 -3
  45. package/src/js/pds.js +142 -76
  46. package/stories/WhatIsPDS.md +1 -1
  47. package/stories/components/PdsCalendar.stories.js +75 -1
  48. package/stories/components/PdsDrawer.stories.js +1 -1
  49. package/stories/components/PdsFab.stories.js +2 -1
  50. package/stories/components/PdsForm.stories.js +157 -71
  51. package/stories/components/PdsIcon.stories.js +2 -2
  52. package/stories/components/PdsOmnibox.stories.js +212 -40
  53. package/stories/components/PdsRichtext.stories.js +2 -2
  54. package/stories/components/PdsScrollrow.stories.js +5 -5
  55. package/stories/components/PdsSplitpanel.stories.js +16 -16
  56. package/stories/components/PdsTabstrip.stories.js +8 -8
  57. package/stories/components/PdsTheme/PdsTheme.stories.js +1 -1
  58. package/stories/components/PdsToaster.stories.js +1 -1
  59. package/stories/components/PdsTreeview.stories.js +202 -21
  60. package/stories/components/PdsUpload.stories.js +1 -1
  61. package/stories/enhancements/Accordion.stories.js +8 -8
  62. package/stories/enhancements/ButtonWorking.stories.js +1 -1
  63. package/stories/enhancements/Clip.stories.js +1 -1
  64. package/stories/enhancements/ColorInput.stories.js +3 -3
  65. package/stories/enhancements/Dropdowns.stories.js +4 -4
  66. package/stories/enhancements/OpenGroups.stories.js +5 -5
  67. package/stories/enhancements/RangeSliders.stories.js +6 -6
  68. package/stories/enhancements/RequiredFields.stories.js +1 -1
  69. package/stories/enhancements/Toggles.stories.js +2 -2
  70. package/stories/foundations/Dividers.stories.js +12 -12
  71. package/stories/foundations/HTMLDefaults.stories.js +8 -22
  72. package/stories/foundations/Icons.stories.js +36 -45
  73. package/stories/foundations/MeshGradients.stories.js +4 -6
  74. package/stories/foundations/SmartSurfaces.stories.js +36 -36
  75. package/stories/foundations/Typography.stories.js +87 -227
  76. package/stories/foundations/ZIndex.stories.js +3 -3
  77. package/stories/getting-started.md +2 -1
  78. package/stories/layout/LayoutOverview.stories.js +3 -8
  79. package/stories/layout/LayoutSystem.stories.js +1 -1
  80. package/stories/patterns/BorderEffects.stories.js +4 -4
  81. package/stories/patterns/InteractiveStates.stories.js +1 -1
  82. package/stories/patterns/Utilities.stories.js +3 -3
  83. package/stories/primitives/Badges.stories.js +5 -5
  84. package/stories/primitives/Buttons.stories.js +6 -6
  85. package/stories/primitives/Callouts.stories.js +13 -13
  86. package/stories/primitives/Cards.stories.js +6 -6
  87. package/stories/primitives/FormElements.stories.js +1 -1
  88. package/stories/primitives/HtmlFormElements.stories.js +6 -4
  89. package/stories/primitives/HtmlFormGroups.stories.js +10 -10
  90. package/stories/primitives/Media.stories.js +1 -1
  91. package/stories/primitives/Tables.stories.js +5 -5
  92. package/stories/reference/reference-catalog.js +1 -0
  93. package/stories/reference/reference-docs.js +1 -0
  94. package/stories/utils/PdsParse.stories.js +30 -25
  95. package/stories/utils/PdsToast.stories.js +3 -7
  96. package/stories/utils/markdown.js +20 -38
  97. package/stories/utils/shiki.js +42 -1
  98. package/stories/utils/toast-utils.js +2 -0
  99. package/stories/foundations/Spacing.stories.js +0 -179
@@ -247,7 +247,7 @@ function generatePdsOmniboxMarkup(omniboxElement) {
247
247
  function generatePdsTreeviewMarkup(treeviewElement) {
248
248
  const attrs = [];
249
249
 
250
- const stringAttrs = ['name', 'value', 'src'];
250
+ const stringAttrs = ['name', 'value', 'src', 'multiselect'];
251
251
  stringAttrs.forEach((attr) => {
252
252
  const value = treeviewElement.getAttribute(attr);
253
253
  if (value !== null && value !== undefined && value !== '') {
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { render as litRender } from 'lit';
8
- import { highlight, getCurrentTheme, escapeHtml, preloadShiki } from './shiki.js';
8
+ import { renderCodeBlock, getCurrentTheme, preloadShiki } from './shiki.js';
9
9
 
10
10
  // Pre-load Shiki in the background
11
11
  preloadShiki();
@@ -174,15 +174,10 @@ export const withHTMLSource = (storyFn, context) => {
174
174
  html = formatHTML(extractHTML(storyContainer));
175
175
  }
176
176
 
177
- const codeEl = sourceSection.querySelector('.html-source-code');
178
177
  const preEl = sourceSection.querySelector('.html-source-pre');
179
178
  if (preEl && html) {
180
- // Use Shiki for syntax highlighting
181
179
  const theme = getCurrentTheme();
182
- const highlighted = await highlight(html, 'html', theme);
183
-
184
- // Shiki returns complete <pre><code>...</code></pre>, replace the whole pre element
185
- preEl.outerHTML = highlighted;
180
+ await renderCodeBlock(preEl, html, 'html', theme);
186
181
  }
187
182
 
188
183
  // Setup copy button
@@ -67,12 +67,20 @@ const config = {
67
67
  process.cwd()
68
68
  ];
69
69
 
70
- // Ensure Lit import alias is resolved to PDS bundle
71
- const aliases = {
72
- ...config.resolve.alias,
73
- '#pds': resolve(pdsSrcPath, 'js/pds.js'),
74
- '#pds/lit': resolve(pdsSrcPath, 'js/lit.js'),
75
- };
70
+ config.resolve = config.resolve || {};
71
+
72
+ // Ensure virtual import aliases resolve consistently.
73
+ // Use exact-match regex for #pds so it does not capture #pds/lit.
74
+ const existingAliases = Array.isArray(config.resolve.alias)
75
+ ? [...config.resolve.alias]
76
+ : Object.entries(config.resolve.alias || {}).map(([find, replacement]) => ({ find, replacement }));
77
+
78
+ const aliases = [
79
+ { find: '#pds/lit', replacement: resolve(pdsSrcPath, 'js/lit.js') },
80
+ { find: /^#pds$/, replacement: resolve(pdsSrcPath, 'js/pds.js') },
81
+ { find: /^#shiki$/, replacement: resolve(pdsSrcPath, 'js/external/shiki.js') },
82
+ ...existingAliases,
83
+ ];
76
84
 
77
85
  // In monorepo, map the local src folder to the monorepo root src folder
78
86
  // This eliminates the need for a copied src folder during development
@@ -80,15 +88,15 @@ const config = {
80
88
  aliases[resolve(currentDirname, '../src')] = pdsSrcPath;
81
89
  }
82
90
 
83
- aliases['@pds-src'] = pdsSrcPath;
91
+ aliases.push({ find: '@pds-src', replacement: pdsSrcPath });
84
92
  config.resolve.alias = aliases;
85
93
 
86
94
  // Alias for relative paths to src (handles ../../../src in stories)
87
95
  // This allows stories to work in both monorepo (where ../../../src is valid)
88
96
  // and package (where it needs to be mapped to the local src folder)
89
97
  // Note: We use a regex to catch varying depths of ../
90
- config.resolve.alias['../../../src'] = pdsSrcPath;
91
- config.resolve.alias['../../../../src'] = pdsSrcPath;
98
+ config.resolve.alias.push({ find: '../../../src', replacement: pdsSrcPath });
99
+ config.resolve.alias.push({ find: '../../../../src', replacement: pdsSrcPath });
92
100
 
93
101
  // Also handle the case where the import is exactly 'D:\Code\pure\pure-ds\packages\src\js\common\ask.js'
94
102
  // which seems to be happening in the error log:
@@ -169,15 +177,15 @@ const config = {
169
177
 
170
178
  // I will change it back to `../../../../src`.
171
179
 
172
- config.resolve.alias['../../../../src'] = pdsSrcPath;
180
+ config.resolve.alias.push({ find: '../../../../src', replacement: pdsSrcPath });
173
181
 
174
182
  // Try to resolve user's pds.config.js
175
183
  const userConfigPath = resolve(process.cwd(), 'pds.config.js');
176
184
  if (fs.existsSync(userConfigPath)) {
177
- config.resolve.alias['@user/pds-config'] = userConfigPath;
185
+ config.resolve.alias.push({ find: '@user/pds-config', replacement: userConfigPath });
178
186
  } else {
179
187
  // Fallback to a default config file if user config doesn't exist
180
- config.resolve.alias['@user/pds-config'] = resolve(currentDirname, '../default-pds.config.js');
188
+ config.resolve.alias.push({ find: '@user/pds-config', replacement: resolve(currentDirname, '../default-pds.config.js') });
181
189
  }
182
190
 
183
191
  // Support absolute path imports like: import { html } from '/assets/pds/external/lit.js';
@@ -11,6 +11,7 @@
11
11
  "imports": {
12
12
  "#pds": "/assets/pds/core.js",
13
13
  "#pds/lit": "/assets/pds/external/lit.js",
14
+ "#shiki": "/assets/pds/external/shiki.js",
14
15
  "#showdown": "https://cdn.jsdelivr.net/npm/showdown@2.1.0/dist/showdown.mjs"
15
16
  }
16
17
  }
@@ -16,6 +16,42 @@ import { toastFormData } from '../stories/utils/toast-utils.js';
16
16
  // Expose toastFormData globally for inline event handlers
17
17
  window.toastFormData = toastFormData;
18
18
 
19
+ let pdsCodeLoadPromise = null;
20
+
21
+ async function ensurePdsCodeLoaded() {
22
+ if (typeof customElements !== 'undefined' && customElements.get('pds-code')) {
23
+ return true;
24
+ }
25
+
26
+ if (!pdsCodeLoadPromise) {
27
+ pdsCodeLoadPromise = (async () => {
28
+ const candidates = [
29
+ '@pds-src/js/components/pds-code.js',
30
+ '/assets/pds/components/pds-code.js',
31
+ '/pds/components/pds-code.js',
32
+ ];
33
+
34
+ for (const specifier of candidates) {
35
+ try {
36
+ await import(specifier);
37
+ if (typeof customElements !== 'undefined' && customElements.get('pds-code')) {
38
+ return true;
39
+ }
40
+ } catch {
41
+ // try next candidate
42
+ }
43
+ }
44
+
45
+ console.warn('Failed to load pds-code component from known locations.');
46
+ return false;
47
+ })();
48
+ }
49
+
50
+ return pdsCodeLoadPromise;
51
+ }
52
+
53
+ void ensurePdsCodeLoaded();
54
+
19
55
  // Get initial preset from storage or URL or default
20
56
  const getInitialPreset = () => {
21
57
  try {
@@ -52,6 +88,36 @@ function isDocsPage() {
52
88
  }
53
89
  }
54
90
 
91
+ function inferCodeLanguage(codeEl) {
92
+ if (!codeEl) return 'html';
93
+ const className = codeEl.className || '';
94
+ const languageMatch = className.match(/(?:language|lang)-([a-z0-9-]+)/i);
95
+ if (languageMatch?.[1]) {
96
+ return languageMatch[1].toLowerCase();
97
+ }
98
+ return codeEl.getAttribute('data-lang') || 'html';
99
+ }
100
+
101
+ function upgradeLegacyCodeBlocks(root) {
102
+ if (!root) return;
103
+ if (typeof customElements !== 'undefined' && !customElements.get('pds-code')) return;
104
+
105
+ const blocks = root.querySelectorAll('pre > code');
106
+ blocks.forEach((codeEl) => {
107
+ const preEl = codeEl.parentElement;
108
+ if (!preEl || preEl.closest('pds-code')) return;
109
+
110
+ const content = codeEl.textContent || '';
111
+ if (!content.trim()) return;
112
+
113
+ const lang = inferCodeLanguage(codeEl);
114
+ const pdsCode = document.createElement('pds-code');
115
+ pdsCode.setAttribute('lang', lang);
116
+ pdsCode.code = content;
117
+ preEl.replaceWith(pdsCode);
118
+ });
119
+ }
120
+
55
121
  let liveGenerator = null;
56
122
  const setLiveGenerator = (generator) => {
57
123
  if (generator && typeof generator === 'object') {
@@ -216,6 +282,8 @@ const withPDS = (story, context) => {
216
282
  const adoptAllShadowStyles = async () => {
217
283
  const container = document.querySelector('#storybook-root');
218
284
  if (!container) return;
285
+
286
+ upgradeLegacyCodeBlocks(container);
219
287
 
220
288
  const walker = document.createTreeWalker(
221
289
  container,
@@ -283,6 +351,9 @@ const withPDS = (story, context) => {
283
351
  };
284
352
 
285
353
  // Initial adoption - run multiple times to catch lazy components
354
+ setTimeout(() => {
355
+ upgradeLegacyCodeBlocks(document.querySelector('#storybook-root'));
356
+ }, 0);
286
357
  setTimeout(adoptAllShadowStyles, 0);
287
358
  setTimeout(adoptAllShadowStyles, 100);
288
359
  setTimeout(adoptAllShadowStyles, 300);
@@ -8,6 +8,7 @@
8
8
  export {
9
9
  loadShiki,
10
10
  highlight,
11
+ renderCodeBlock,
11
12
  getCurrentTheme,
12
13
  escapeHtml,
13
14
  preloadShiki