@pure-ds/storybook 0.7.19 → 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.
- package/.storybook/htmlPreview.js +2 -7
- package/.storybook/main.js +1 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.js +71 -0
- package/.storybook/shiki.js +1 -0
- package/dist/pds-reference.json +271 -130
- package/package.json +2 -2
- package/public/assets/js/app.js +4 -4
- package/public/assets/js/pds-manager.js +164 -174
- 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-importer.js +2 -2
- package/public/assets/pds/components/pds-scrollrow.js +27 -2
- package/public/assets/pds/components/pds-treeview.js +185 -0
- package/public/assets/pds/core/pds-manager.js +164 -174
- 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-generator.js +142 -152
- package/src/js/pds-core/pds-live.js +54 -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/PdsSplitpanel.stories.js +11 -11
- package/stories/components/PdsTabstrip.stories.js +1 -1
- package/stories/foundations/HTMLDefaults.stories.js +8 -22
- package/stories/foundations/Icons.stories.js +7 -16
- package/stories/foundations/MeshGradients.stories.js +2 -4
- package/stories/getting-started.md +2 -1
- package/stories/layout/LayoutOverview.stories.js +3 -8
- package/stories/reference/reference-catalog.js +1 -0
- package/stories/reference/reference-docs.js +1 -0
- package/stories/utils/PdsParse.stories.js +29 -18
- 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
|
@@ -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);
|