@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.
- package/.storybook/addons/html-preview/preview.js +1 -1
- package/.storybook/htmlPreview.js +2 -7
- package/.storybook/main.js +20 -12
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.js +71 -0
- package/.storybook/shiki.js +1 -0
- package/dist/pds-reference.json +411 -313
- package/package.json +2 -2
- package/public/assets/js/app.js +2 -2
- package/public/assets/js/pds-manager.js +281 -307
- package/public/assets/js/pds.js +2 -2
- package/public/assets/pds/components/pds-calendar.js +522 -26
- package/public/assets/pds/components/pds-code.js +203 -0
- package/public/assets/pds/components/pds-form.js +85 -2
- 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-omnibox.js +9 -6
- package/public/assets/pds/components/pds-scrollrow.js +27 -2
- package/public/assets/pds/components/pds-treeview.js +506 -24
- package/public/assets/pds/core/pds-manager.js +281 -307
- 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/public/assets/pds/vscode-custom-data.json +4 -0
- 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-config.js +1 -0
- package/src/js/pds-core/pds-generator.js +152 -160
- package/src/js/pds-core/pds-live.js +55 -34
- package/src/js/pds-core/pds-ontology.js +2 -2
- package/src/js/pds-core/pds-runtime.js +18 -2
- package/src/js/pds.d.ts +2 -3
- package/src/js/pds.js +142 -76
- package/stories/WhatIsPDS.md +1 -1
- package/stories/components/PdsCalendar.stories.js +75 -1
- package/stories/components/PdsDrawer.stories.js +1 -1
- package/stories/components/PdsFab.stories.js +2 -1
- package/stories/components/PdsForm.stories.js +157 -71
- package/stories/components/PdsIcon.stories.js +2 -2
- package/stories/components/PdsOmnibox.stories.js +212 -40
- package/stories/components/PdsRichtext.stories.js +2 -2
- package/stories/components/PdsScrollrow.stories.js +5 -5
- package/stories/components/PdsSplitpanel.stories.js +16 -16
- package/stories/components/PdsTabstrip.stories.js +8 -8
- package/stories/components/PdsTheme/PdsTheme.stories.js +1 -1
- package/stories/components/PdsToaster.stories.js +1 -1
- package/stories/components/PdsTreeview.stories.js +202 -21
- package/stories/components/PdsUpload.stories.js +1 -1
- package/stories/enhancements/Accordion.stories.js +8 -8
- package/stories/enhancements/ButtonWorking.stories.js +1 -1
- package/stories/enhancements/Clip.stories.js +1 -1
- package/stories/enhancements/ColorInput.stories.js +3 -3
- package/stories/enhancements/Dropdowns.stories.js +4 -4
- package/stories/enhancements/OpenGroups.stories.js +5 -5
- package/stories/enhancements/RangeSliders.stories.js +6 -6
- package/stories/enhancements/RequiredFields.stories.js +1 -1
- package/stories/enhancements/Toggles.stories.js +2 -2
- package/stories/foundations/Dividers.stories.js +12 -12
- package/stories/foundations/HTMLDefaults.stories.js +8 -22
- package/stories/foundations/Icons.stories.js +36 -45
- package/stories/foundations/MeshGradients.stories.js +4 -6
- package/stories/foundations/SmartSurfaces.stories.js +36 -36
- package/stories/foundations/Typography.stories.js +87 -227
- package/stories/foundations/ZIndex.stories.js +3 -3
- package/stories/getting-started.md +2 -1
- package/stories/layout/LayoutOverview.stories.js +3 -8
- package/stories/layout/LayoutSystem.stories.js +1 -1
- package/stories/patterns/BorderEffects.stories.js +4 -4
- package/stories/patterns/InteractiveStates.stories.js +1 -1
- package/stories/patterns/Utilities.stories.js +3 -3
- package/stories/primitives/Badges.stories.js +5 -5
- package/stories/primitives/Buttons.stories.js +6 -6
- package/stories/primitives/Callouts.stories.js +13 -13
- package/stories/primitives/Cards.stories.js +6 -6
- package/stories/primitives/FormElements.stories.js +1 -1
- package/stories/primitives/HtmlFormElements.stories.js +6 -4
- package/stories/primitives/HtmlFormGroups.stories.js +10 -10
- package/stories/primitives/Media.stories.js +1 -1
- package/stories/primitives/Tables.stories.js +5 -5
- package/stories/reference/reference-catalog.js +1 -0
- package/stories/reference/reference-docs.js +1 -0
- package/stories/utils/PdsParse.stories.js +30 -25
- package/stories/utils/PdsToast.stories.js +3 -7
- package/stories/utils/markdown.js +20 -38
- package/stories/utils/shiki.js +42 -1
- package/stories/utils/toast-utils.js +2 -0
- 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 {
|
|
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
|
@@ -67,12 +67,20 @@ const config = {
|
|
|
67
67
|
process.cwd()
|
|
68
68
|
];
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
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
|
|
91
|
-
config.resolve.alias
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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';
|
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);
|