@pure-ds/storybook 0.7.19 → 0.7.25

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 (75) hide show
  1. package/.storybook/htmlPreview.css +8 -0
  2. package/.storybook/htmlPreview.js +2 -7
  3. package/.storybook/main.js +1 -0
  4. package/.storybook/preview-head.html +1 -0
  5. package/.storybook/preview.js +93 -1
  6. package/.storybook/shiki.js +1 -0
  7. package/dist/pds-reference.json +292 -129
  8. package/package.json +2 -2
  9. package/public/assets/js/app.js +4 -4
  10. package/public/assets/js/pds-enhancers.js +1 -1
  11. package/public/assets/js/pds-manager.js +163 -173
  12. package/public/assets/js/pds.js +2 -2
  13. package/public/assets/pds/components/pds-calendar.js +504 -16
  14. package/public/assets/pds/components/pds-code.js +203 -0
  15. package/public/assets/pds/components/pds-icon.js +165 -39
  16. package/public/assets/pds/components/pds-live-edit.js +3 -8
  17. package/public/assets/pds/components/pds-live-importer.js +2 -2
  18. package/public/assets/pds/components/pds-omnibox.js +37 -1
  19. package/public/assets/pds/components/pds-scrollrow.js +27 -2
  20. package/public/assets/pds/components/pds-toaster.js +35 -1
  21. package/public/assets/pds/components/pds-treeview.js +185 -0
  22. package/public/assets/pds/core/pds-enhancers.js +1 -1
  23. package/public/assets/pds/core/pds-manager.js +163 -173
  24. package/public/assets/pds/core.js +2 -2
  25. package/public/assets/pds/custom-elements.json +263 -18
  26. package/public/assets/pds/external/shiki.js +32 -0
  27. package/public/assets/pds/pds-css-complete.json +1 -1
  28. package/public/assets/pds/pds-runtime-config.json +1 -1
  29. package/public/assets/pds/styles/pds-components.css +93 -96
  30. package/public/assets/pds/styles/pds-components.css.js +186 -192
  31. package/public/assets/pds/styles/pds-primitives.css +61 -66
  32. package/public/assets/pds/styles/pds-primitives.css.js +122 -132
  33. package/public/assets/pds/styles/pds-styles.css +148 -156
  34. package/public/assets/pds/styles/pds-styles.css.js +296 -312
  35. package/public/assets/pds/templates/feedback-ops-dashboard.html +1 -1
  36. package/public/assets/pds/templates/release-readiness-radar.html +2 -2
  37. package/public/assets/pds/templates/support-command-center.html +1 -1
  38. package/scripts/build-pds-reference.mjs +33 -0
  39. package/src/js/components/pds-code.js +203 -0
  40. package/src/js/external/shiki.js +32 -0
  41. package/src/js/pds-core/pds-enhancers.js +53 -8
  42. package/src/js/pds-core/pds-generator.js +143 -153
  43. package/src/js/pds-core/pds-live.js +59 -21
  44. package/src/js/pds.d.ts +2 -2
  45. package/src/js/pds.js +142 -76
  46. package/stories/WhatIsPDS.md +1 -1
  47. package/stories/components/PdsCalendar.stories.js +74 -0
  48. package/stories/components/PdsForm.stories.js +0 -16
  49. package/stories/components/PdsOmnibox.stories.js +1 -73
  50. package/stories/components/PdsSplitpanel.stories.js +11 -11
  51. package/stories/components/PdsTabstrip.stories.js +1 -1
  52. package/stories/components/PdsToaster.stories.js +36 -116
  53. package/stories/enhancements/Accordion.stories.js +34 -39
  54. package/stories/enhancements/_enhancement-header.js +1 -1
  55. package/stories/foundations/Dividers.stories.js +2 -2
  56. package/stories/foundations/HTMLDefaults.stories.js +18 -32
  57. package/stories/foundations/Icons.stories.js +17 -26
  58. package/stories/foundations/MeshGradients.stories.js +2 -4
  59. package/stories/foundations/SmartSurfaces.stories.js +8 -6
  60. package/stories/foundations/ZIndex.stories.js +6 -6
  61. package/stories/getting-started.md +2 -1
  62. package/stories/layout/LayoutOverview.stories.js +3 -8
  63. package/stories/layout/LayoutSystem.stories.js +13 -13
  64. package/stories/patterns/InteractiveStates.stories.js +3 -3
  65. package/stories/primitives/Callouts.stories.js +5 -5
  66. package/stories/primitives/Cards.stories.js +13 -9
  67. package/stories/primitives/Media.stories.js +3 -3
  68. package/stories/reference/reference-catalog.js +1 -0
  69. package/stories/reference/reference-docs.js +1 -0
  70. package/stories/utilities/Backdrop.stories.js +4 -4
  71. package/stories/utils/PdsObjectApi.stories.js +704 -0
  72. package/stories/utils/PdsParse.stories.js +39 -19
  73. package/stories/utils/PdsToast.stories.js +23 -9
  74. package/stories/utils/markdown.js +20 -38
  75. package/stories/utils/shiki.js +42 -1
@@ -75,3 +75,11 @@ pds-config-form {
75
75
  right: 0;
76
76
  }
77
77
  }
78
+
79
+ #storybook-root {
80
+ header:has(.text-muted){
81
+ margin-bottom: var(--spacing-6, 1rem);
82
+ border-bottom: 1px solid var(--color-border);
83
+ border-radius: 0;
84
+ }
85
+ }
@@ -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
@@ -78,6 +78,7 @@ const config = {
78
78
  const aliases = [
79
79
  { find: '#pds/lit', replacement: resolve(pdsSrcPath, 'js/lit.js') },
80
80
  { find: /^#pds$/, replacement: resolve(pdsSrcPath, 'js/pds.js') },
81
+ { find: /^#shiki$/, replacement: resolve(pdsSrcPath, 'js/external/shiki.js') },
81
82
  ...existingAliases,
82
83
  ];
83
84
 
@@ -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
  }
@@ -1,6 +1,7 @@
1
1
  import { addons } from '@storybook/preview-api';
2
2
  import { SELECT_STORY, UPDATE_GLOBALS } from '@storybook/core-events';
3
3
  import React from 'react';
4
+ import { html } from 'lit';
4
5
  import { Title, Subtitle, Description as DocsDescription, Controls } from '@storybook/blocks';
5
6
  import { PDS } from '@pds-src/js/pds.js';
6
7
  import { presets } from '@pds-src/js/pds-core/pds-config.js';
@@ -16,6 +17,42 @@ import { toastFormData } from '../stories/utils/toast-utils.js';
16
17
  // Expose toastFormData globally for inline event handlers
17
18
  window.toastFormData = toastFormData;
18
19
 
20
+ let pdsCodeLoadPromise = null;
21
+
22
+ async function ensurePdsCodeLoaded() {
23
+ if (typeof customElements !== 'undefined' && customElements.get('pds-code')) {
24
+ return true;
25
+ }
26
+
27
+ if (!pdsCodeLoadPromise) {
28
+ pdsCodeLoadPromise = (async () => {
29
+ const candidates = [
30
+ '@pds-src/js/components/pds-code.js',
31
+ '/assets/pds/components/pds-code.js',
32
+ '/pds/components/pds-code.js',
33
+ ];
34
+
35
+ for (const specifier of candidates) {
36
+ try {
37
+ await import(specifier);
38
+ if (typeof customElements !== 'undefined' && customElements.get('pds-code')) {
39
+ return true;
40
+ }
41
+ } catch {
42
+ // try next candidate
43
+ }
44
+ }
45
+
46
+ console.warn('Failed to load pds-code component from known locations.');
47
+ return false;
48
+ })();
49
+ }
50
+
51
+ return pdsCodeLoadPromise;
52
+ }
53
+
54
+ void ensurePdsCodeLoaded();
55
+
19
56
  // Get initial preset from storage or URL or default
20
57
  const getInitialPreset = () => {
21
58
  try {
@@ -52,6 +89,36 @@ function isDocsPage() {
52
89
  }
53
90
  }
54
91
 
92
+ function inferCodeLanguage(codeEl) {
93
+ if (!codeEl) return 'html';
94
+ const className = codeEl.className || '';
95
+ const languageMatch = className.match(/(?:language|lang)-([a-z0-9-]+)/i);
96
+ if (languageMatch?.[1]) {
97
+ return languageMatch[1].toLowerCase();
98
+ }
99
+ return codeEl.getAttribute('data-lang') || 'html';
100
+ }
101
+
102
+ function upgradeLegacyCodeBlocks(root) {
103
+ if (!root) return;
104
+ if (typeof customElements !== 'undefined' && !customElements.get('pds-code')) return;
105
+
106
+ const blocks = root.querySelectorAll('pre > code');
107
+ blocks.forEach((codeEl) => {
108
+ const preEl = codeEl.parentElement;
109
+ if (!preEl || preEl.closest('pds-code')) return;
110
+
111
+ const content = codeEl.textContent || '';
112
+ if (!content.trim()) return;
113
+
114
+ const lang = inferCodeLanguage(codeEl);
115
+ const pdsCode = document.createElement('pds-code');
116
+ pdsCode.setAttribute('lang', lang);
117
+ pdsCode.code = content;
118
+ preEl.replaceWith(pdsCode);
119
+ });
120
+ }
121
+
55
122
  let liveGenerator = null;
56
123
  const setLiveGenerator = (generator) => {
57
124
  if (generator && typeof generator === 'object') {
@@ -216,6 +283,8 @@ const withPDS = (story, context) => {
216
283
  const adoptAllShadowStyles = async () => {
217
284
  const container = document.querySelector('#storybook-root');
218
285
  if (!container) return;
286
+
287
+ upgradeLegacyCodeBlocks(container);
219
288
 
220
289
  const walker = document.createTreeWalker(
221
290
  container,
@@ -283,6 +352,9 @@ const withPDS = (story, context) => {
283
352
  };
284
353
 
285
354
  // Initial adoption - run multiple times to catch lazy components
355
+ setTimeout(() => {
356
+ upgradeLegacyCodeBlocks(document.querySelector('#storybook-root'));
357
+ }, 0);
286
358
  setTimeout(adoptAllShadowStyles, 0);
287
359
  setTimeout(adoptAllShadowStyles, 100);
288
360
  setTimeout(adoptAllShadowStyles, 300);
@@ -1353,6 +1425,26 @@ const withRelatedStories = (story, context) => {
1353
1425
  return result;
1354
1426
  };
1355
1427
 
1428
+ const withComponentStoryHeader = (story, context) => {
1429
+ if (context.viewMode !== 'story') return story();
1430
+
1431
+ const titlePath = context.title || '';
1432
+ if (!titlePath.startsWith('Components/')) return story();
1433
+
1434
+ const tagName = titlePath.split('/').pop() || 'component';
1435
+ const storyTitle = context.name || 'Story';
1436
+
1437
+ return html`
1438
+ <div class="stack-md">
1439
+ <header>
1440
+ <h2>${tagName}</h2>
1441
+ <small class="text-muted">${storyTitle}</small>
1442
+ </header>
1443
+ ${story()}
1444
+ </div>
1445
+ `;
1446
+ };
1447
+
1356
1448
  const DocsPage = () => React.createElement(
1357
1449
  React.Fragment,
1358
1450
  null,
@@ -1364,7 +1456,7 @@ const DocsPage = () => React.createElement(
1364
1456
 
1365
1457
  /** @type { import('@storybook/web-components').Preview } */
1366
1458
  const preview = {
1367
- decorators: [withGlobalsHandler, withPDS, withHTMLExtractor, withDescription, withRelatedStories],
1459
+ decorators: [withGlobalsHandler, withPDS, withHTMLExtractor, withDescription, withComponentStoryHeader, withRelatedStories],
1368
1460
  parameters: {
1369
1461
  controls: {
1370
1462
  matchers: {
@@ -8,6 +8,7 @@
8
8
  export {
9
9
  loadShiki,
10
10
  highlight,
11
+ renderCodeBlock,
11
12
  getCurrentTheme,
12
13
  escapeHtml,
13
14
  preloadShiki