@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.
- package/.storybook/htmlPreview.css +8 -0
- package/.storybook/htmlPreview.js +2 -7
- package/.storybook/main.js +1 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.js +93 -1
- package/.storybook/shiki.js +1 -0
- package/dist/pds-reference.json +292 -129
- package/package.json +2 -2
- package/public/assets/js/app.js +4 -4
- package/public/assets/js/pds-enhancers.js +1 -1
- package/public/assets/js/pds-manager.js +163 -173
- package/public/assets/js/pds.js +2 -2
- package/public/assets/pds/components/pds-calendar.js +504 -16
- package/public/assets/pds/components/pds-code.js +203 -0
- package/public/assets/pds/components/pds-icon.js +165 -39
- package/public/assets/pds/components/pds-live-edit.js +3 -8
- package/public/assets/pds/components/pds-live-importer.js +2 -2
- package/public/assets/pds/components/pds-omnibox.js +37 -1
- package/public/assets/pds/components/pds-scrollrow.js +27 -2
- package/public/assets/pds/components/pds-toaster.js +35 -1
- package/public/assets/pds/components/pds-treeview.js +185 -0
- package/public/assets/pds/core/pds-enhancers.js +1 -1
- package/public/assets/pds/core/pds-manager.js +163 -173
- package/public/assets/pds/core.js +2 -2
- package/public/assets/pds/custom-elements.json +263 -18
- package/public/assets/pds/external/shiki.js +32 -0
- package/public/assets/pds/pds-css-complete.json +1 -1
- package/public/assets/pds/pds-runtime-config.json +1 -1
- package/public/assets/pds/styles/pds-components.css +93 -96
- package/public/assets/pds/styles/pds-components.css.js +186 -192
- package/public/assets/pds/styles/pds-primitives.css +61 -66
- package/public/assets/pds/styles/pds-primitives.css.js +122 -132
- package/public/assets/pds/styles/pds-styles.css +148 -156
- package/public/assets/pds/styles/pds-styles.css.js +296 -312
- package/public/assets/pds/templates/feedback-ops-dashboard.html +1 -1
- package/public/assets/pds/templates/release-readiness-radar.html +2 -2
- package/public/assets/pds/templates/support-command-center.html +1 -1
- package/scripts/build-pds-reference.mjs +33 -0
- package/src/js/components/pds-code.js +203 -0
- package/src/js/external/shiki.js +32 -0
- package/src/js/pds-core/pds-enhancers.js +53 -8
- package/src/js/pds-core/pds-generator.js +143 -153
- package/src/js/pds-core/pds-live.js +59 -21
- package/src/js/pds.d.ts +2 -2
- package/src/js/pds.js +142 -76
- package/stories/WhatIsPDS.md +1 -1
- package/stories/components/PdsCalendar.stories.js +74 -0
- package/stories/components/PdsForm.stories.js +0 -16
- package/stories/components/PdsOmnibox.stories.js +1 -73
- package/stories/components/PdsSplitpanel.stories.js +11 -11
- package/stories/components/PdsTabstrip.stories.js +1 -1
- package/stories/components/PdsToaster.stories.js +36 -116
- package/stories/enhancements/Accordion.stories.js +34 -39
- package/stories/enhancements/_enhancement-header.js +1 -1
- package/stories/foundations/Dividers.stories.js +2 -2
- package/stories/foundations/HTMLDefaults.stories.js +18 -32
- package/stories/foundations/Icons.stories.js +17 -26
- package/stories/foundations/MeshGradients.stories.js +2 -4
- package/stories/foundations/SmartSurfaces.stories.js +8 -6
- package/stories/foundations/ZIndex.stories.js +6 -6
- package/stories/getting-started.md +2 -1
- package/stories/layout/LayoutOverview.stories.js +3 -8
- package/stories/layout/LayoutSystem.stories.js +13 -13
- package/stories/patterns/InteractiveStates.stories.js +3 -3
- package/stories/primitives/Callouts.stories.js +5 -5
- package/stories/primitives/Cards.stories.js +13 -9
- package/stories/primitives/Media.stories.js +3 -3
- package/stories/reference/reference-catalog.js +1 -0
- package/stories/reference/reference-docs.js +1 -0
- package/stories/utilities/Backdrop.stories.js +4 -4
- package/stories/utils/PdsObjectApi.stories.js +704 -0
- package/stories/utils/PdsParse.stories.js +39 -19
- package/stories/utils/PdsToast.stories.js +23 -9
- package/stories/utils/markdown.js +20 -38
- package/stories/utils/shiki.js +42 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { render as litRender } from 'lit';
|
|
8
|
-
import {
|
|
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
|
-
|
|
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
|
package/.storybook/main.js
CHANGED
|
@@ -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
|
|
package/.storybook/preview.js
CHANGED
|
@@ -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: {
|