@ds-mo/ui 2.9.0 → 2.10.1
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/dist/.build-stamp +1 -1
- package/dist/components/ds-app-shell.js +1 -1
- package/dist/components/ds-badge.js +1 -1
- package/dist/components/ds-bar-nav.js +1 -1
- package/dist/components/ds-button-filled.js +1 -1
- package/dist/components/ds-button-unfilled-icon.js +1 -1
- package/dist/components/ds-card-setting.js +1 -1
- package/dist/components/ds-fade.js +1 -1
- package/dist/components/ds-icon.js +1 -1
- package/dist/components/ds-menu.js +1 -1
- package/dist/components/ds-panel-nav.js +1 -1
- package/dist/components/ds-panel-tools.js +1 -1
- package/dist/components/ds-select.js +1 -1
- package/dist/components/ds-shell-gradient-picker.js +1 -1
- package/dist/components/ds-shell-gradient-swatch.js +1 -1
- package/dist/components/ds-tab-group-nav.js +1 -1
- package/dist/components/ds-tab-group.js +1 -1
- package/dist/components/{p-g6MCxfm4.js → p-BFPfyJ8Z.js} +1 -1
- package/dist/components/p-BFPfyJ8Z.js.map +1 -0
- package/dist/components/{p-CiEc8Nwx.js → p-BOpHKDOG.js} +2 -2
- package/dist/components/p-BOpHKDOG.js.map +1 -0
- package/dist/components/{p-CDNVPM2x.js → p-BqOChY2z.js} +2 -2
- package/dist/components/p-Bz3jyrDV.js +2 -0
- package/dist/components/p-Bz3jyrDV.js.map +1 -0
- package/dist/components/p-Cynjsv-P.js +2 -0
- package/dist/components/p-Cynjsv-P.js.map +1 -0
- package/dist/components/{p-CKCBqwIw.js → p-DSTK6-QR.js} +2 -2
- package/dist/components/{p-C_hgdYcC.js → p-Dul5eGGE.js} +2 -2
- package/dist/components/{p-BA6a6P0b.js → p-evjnuLjj.js} +2 -2
- package/dist/components/{p-DnGr8qtq.js → p-j_GdU4Aa.js} +2 -2
- package/dist/components/{p-Cv5NDZug.js → p-w2Wrf0jC.js} +2 -2
- package/dist/lib/components/Icon/icon-cache.d.ts +24 -0
- package/dist/lib/components/Menu/menu-placement.d.ts +23 -0
- package/dist/lib/components/Menu/menu-position.d.ts +19 -0
- package/dist/lib/nav/badge-gradient-ring.d.ts +27 -0
- package/dist/lib/nav/chrome-transition.d.ts +24 -0
- package/dist/lib/nav/index.d.ts +16 -0
- package/dist/lib/nav/index.js +419 -0
- package/dist/lib/nav/index.js.map +7 -0
- package/dist/lib/nav/nav-chrome.d.ts +9 -0
- package/dist/lib/nav/shell-chrome-metrics.d.ts +11 -0
- package/dist/lib/nav/shell-gradient-presets.d.ts +20 -0
- package/dist/lib/nav/shell-gradient.d.ts +43 -0
- package/dist/lib/nav/shell-view-transition.d.ts +23 -0
- package/dist/lib/utils/index.d.ts +7 -0
- package/dist/lib/utils/index.js +188 -0
- package/dist/lib/utils/index.js.map +7 -0
- package/dist/lib/utils/resolve-css-length-px.d.ts +7 -0
- package/dist/lib/utils/resolve-css-time-ms.d.ts +7 -0
- package/dist/lib/utils/scroll-edge-fade.d.ts +12 -0
- package/dist/lib/utils/token-defaults.d.ts +33 -0
- package/dist/types/components/Badge/Badge.d.ts +5 -1
- package/dist/types/components/Icon/Icon.d.ts +14 -1
- package/dist/types/components/Icon/flag-icon-catalog.d.ts +2 -1
- package/dist/types/components/Icon/icon-cache.d.ts +25 -0
- package/dist/types/components/Icon/icon-svg.d.ts +26 -0
- package/dist/types/components/Icon/system-icon-catalog.d.ts +2 -1
- package/dist/types/components.d.ts +2 -2
- package/dist/types/nav/index.d.ts +1 -1
- package/dist/types/nav/shell-gradient-presets.d.ts +8 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +9 -8
- package/src/wc/components/Badge/Badge.tsx +6 -2
- package/src/wc/components/Icon/Icon.tsx +82 -22
- package/src/wc/components/Icon/flag-icon-catalog.ts +33 -65
- package/src/wc/components/Icon/icon-cache.ts +47 -0
- package/src/wc/components/Icon/icon-svg.ts +73 -0
- package/src/wc/components/Icon/system-icon-catalog.ts +398 -795
- package/src/wc/components.d.ts +2 -2
- package/src/wc/nav/badge-gradient-ring.ts +4 -1
- package/src/wc/nav/index.ts +1 -0
- package/src/wc/nav/shell-gradient-presets.ts +16 -2
- package/src/wc/utils/index.ts +1 -0
- package/dist/components/p-0y48zKIF.js +0 -2
- package/dist/components/p-0y48zKIF.js.map +0 -1
- package/dist/components/p-CF4avTQw.js +0 -2
- package/dist/components/p-CF4avTQw.js.map +0 -1
- package/dist/components/p-CiEc8Nwx.js.map +0 -1
- package/dist/components/p-g6MCxfm4.js.map +0 -1
- /package/dist/components/{p-CDNVPM2x.js.map → p-BqOChY2z.js.map} +0 -0
- /package/dist/components/{p-CKCBqwIw.js.map → p-DSTK6-QR.js.map} +0 -0
- /package/dist/components/{p-C_hgdYcC.js.map → p-Dul5eGGE.js.map} +0 -0
- /package/dist/components/{p-BA6a6P0b.js.map → p-evjnuLjj.js.map} +0 -0
- /package/dist/components/{p-DnGr8qtq.js.map → p-j_GdU4Aa.js.map} +0 -0
- /package/dist/components/{p-Cv5NDZug.js.map → p-w2Wrf0jC.js.map} +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// src/wc/components/Icon/icon-cache.ts
|
|
2
|
+
var CACHE_KEY = /* @__PURE__ */ Symbol.for("ds-mo.icon-svg-cache");
|
|
3
|
+
function iconCacheKey(name, flag) {
|
|
4
|
+
return flag ? `flag:${name}` : `system:${name}`;
|
|
5
|
+
}
|
|
6
|
+
function iconCache() {
|
|
7
|
+
const g = globalThis;
|
|
8
|
+
return g[CACHE_KEY] ?? (g[CACHE_KEY] = /* @__PURE__ */ new Map());
|
|
9
|
+
}
|
|
10
|
+
function registerIcons(icons, options) {
|
|
11
|
+
const cache = iconCache();
|
|
12
|
+
const flag = options?.flag === true;
|
|
13
|
+
for (const [name, svg] of Object.entries(icons)) {
|
|
14
|
+
cache.set(iconCacheKey(name, flag), svg);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/wc/utils/resolve-css-length-px.ts
|
|
19
|
+
var lengthPxCache = /* @__PURE__ */ new Map();
|
|
20
|
+
var probeEl = null;
|
|
21
|
+
function getProbeElement() {
|
|
22
|
+
if (typeof document === "undefined") return null;
|
|
23
|
+
if (!probeEl) {
|
|
24
|
+
probeEl = document.createElement("div");
|
|
25
|
+
probeEl.setAttribute("aria-hidden", "true");
|
|
26
|
+
probeEl.style.cssText = "position:absolute;visibility:hidden;pointer-events:none;top:0;left:0;width:0;height:0;overflow:hidden;";
|
|
27
|
+
document.documentElement.appendChild(probeEl);
|
|
28
|
+
}
|
|
29
|
+
return probeEl;
|
|
30
|
+
}
|
|
31
|
+
function clearCssLengthPxCache() {
|
|
32
|
+
lengthPxCache.clear();
|
|
33
|
+
}
|
|
34
|
+
function resolveCssLengthPx(value, fallback) {
|
|
35
|
+
const resolved = value === void 0 || value === null || value === "" ? fallback : value;
|
|
36
|
+
if (typeof resolved === "number") return resolved;
|
|
37
|
+
const trimmed = resolved.trim();
|
|
38
|
+
if (!trimmed) return resolveCssLengthPx(fallback, 0);
|
|
39
|
+
const cached = lengthPxCache.get(trimmed);
|
|
40
|
+
if (cached !== void 0) return cached;
|
|
41
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
42
|
+
const n = Number(trimmed);
|
|
43
|
+
lengthPxCache.set(trimmed, n);
|
|
44
|
+
return n;
|
|
45
|
+
}
|
|
46
|
+
const pxMatch = trimmed.match(/^(-?\d+(\.\d+)?)px$/);
|
|
47
|
+
if (pxMatch) {
|
|
48
|
+
const px2 = parseFloat(pxMatch[1]);
|
|
49
|
+
lengthPxCache.set(trimmed, px2);
|
|
50
|
+
return px2;
|
|
51
|
+
}
|
|
52
|
+
const cssLength = /^--[\w-]+$/.test(trimmed) ? `var(${trimmed})` : trimmed;
|
|
53
|
+
const probe = getProbeElement();
|
|
54
|
+
if (!probe) {
|
|
55
|
+
return typeof fallback === "number" ? fallback : 0;
|
|
56
|
+
}
|
|
57
|
+
probe.style.width = cssLength;
|
|
58
|
+
const px = probe.getBoundingClientRect().width;
|
|
59
|
+
probe.style.width = "";
|
|
60
|
+
lengthPxCache.set(trimmed, px);
|
|
61
|
+
return px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/wc/utils/resolve-css-time-ms.ts
|
|
65
|
+
function parseCssTimeMs(value, fallback) {
|
|
66
|
+
const firstToken = value.trim().split(/\s+/)[0] ?? "";
|
|
67
|
+
const num = parseFloat(firstToken);
|
|
68
|
+
if (Number.isNaN(num)) return fallback;
|
|
69
|
+
if (/ms\s*$/.test(firstToken)) return num;
|
|
70
|
+
if (/s\s*$/.test(firstToken)) return num * 1e3;
|
|
71
|
+
return num;
|
|
72
|
+
}
|
|
73
|
+
function extractCssCustomProp(ref) {
|
|
74
|
+
const varMatch = ref.match(/^var\(\s*(--[^),]+)/);
|
|
75
|
+
if (varMatch) return varMatch[1].trim();
|
|
76
|
+
if (ref.startsWith("--")) return ref.trim();
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function readTokenTimeMs(token, fallback) {
|
|
80
|
+
if (typeof document === "undefined") return fallback;
|
|
81
|
+
const prop = extractCssCustomProp(token);
|
|
82
|
+
if (!prop) return parseCssTimeMs(token, fallback);
|
|
83
|
+
const raw = getComputedStyle(document.documentElement).getPropertyValue(prop).trim();
|
|
84
|
+
return parseCssTimeMs(raw, fallback);
|
|
85
|
+
}
|
|
86
|
+
function resolveCssTimeMs(value, fallbackToken) {
|
|
87
|
+
if (typeof value === "number") return value;
|
|
88
|
+
const token = typeof value === "string" && value.trim() ? value.trim() : fallbackToken;
|
|
89
|
+
const prop = extractCssCustomProp(token);
|
|
90
|
+
if (prop) {
|
|
91
|
+
return readTokenTimeMs(token, readTokenTimeMs(fallbackToken, 200));
|
|
92
|
+
}
|
|
93
|
+
return parseCssTimeMs(token, readTokenTimeMs(fallbackToken, 200));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/wc/utils/scroll-edge-fade.ts
|
|
97
|
+
var SCROLL_EDGE_FADE_SIZE_VAR = "--ds-scroll-edge-fade-size";
|
|
98
|
+
var SCROLL_EDGE_FADE_DEFAULT_SIZE = "var(--dimension-size-600)";
|
|
99
|
+
var SIZE_REF = `var(${SCROLL_EDGE_FADE_SIZE_VAR}, ${SCROLL_EDGE_FADE_DEFAULT_SIZE})`;
|
|
100
|
+
function scrollEdgeFadeMaskImage(edge) {
|
|
101
|
+
switch (edge) {
|
|
102
|
+
case "top":
|
|
103
|
+
return `linear-gradient(to bottom, #000 0, #000 50%, transparent 100%)`;
|
|
104
|
+
case "bottom":
|
|
105
|
+
return `linear-gradient(to bottom, #000 0, #000 calc(100% - ${SIZE_REF}), transparent 100%)`;
|
|
106
|
+
case "left":
|
|
107
|
+
return `linear-gradient(to right, #000 0, #000 calc(100% - ${SIZE_REF}), transparent 100%)`;
|
|
108
|
+
case "right":
|
|
109
|
+
return `linear-gradient(to left, #000 0, #000 calc(100% - ${SIZE_REF}), transparent 100%)`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function scrollEdgeFadeMaskStyle(edge) {
|
|
113
|
+
const mask = scrollEdgeFadeMaskImage(edge);
|
|
114
|
+
return {
|
|
115
|
+
[SCROLL_EDGE_FADE_SIZE_VAR]: SCROLL_EDGE_FADE_DEFAULT_SIZE,
|
|
116
|
+
WebkitMaskImage: mask,
|
|
117
|
+
maskImage: mask,
|
|
118
|
+
WebkitMaskSize: "100% 100%",
|
|
119
|
+
maskSize: "100% 100%"
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/wc/utils/token-defaults.ts
|
|
124
|
+
import {
|
|
125
|
+
dimensionIconographyMd,
|
|
126
|
+
dimensionIconographySm,
|
|
127
|
+
dimensionIconographyXs,
|
|
128
|
+
dimensionMenuWidthXs,
|
|
129
|
+
dimensionPanelWidth2xs,
|
|
130
|
+
dimensionPanelWidthLg,
|
|
131
|
+
dimensionPanelWidthMd,
|
|
132
|
+
dimensionSize300,
|
|
133
|
+
dimensionSize600,
|
|
134
|
+
dimensionSize800,
|
|
135
|
+
dimensionSpace050,
|
|
136
|
+
dimensionSpace200,
|
|
137
|
+
effectAnimationDelayLong2,
|
|
138
|
+
effectAnimationDelayMedium1,
|
|
139
|
+
effectAnimationDelayShort2,
|
|
140
|
+
effectAnimationDurationMedium1,
|
|
141
|
+
effectAnimationDurationShort3,
|
|
142
|
+
effectMotionShort2,
|
|
143
|
+
effectMotionShort3
|
|
144
|
+
} from "@ds-mo/tokens/ts";
|
|
145
|
+
var TOKEN_DEFAULTS = {
|
|
146
|
+
space050: dimensionSpace050,
|
|
147
|
+
space200: dimensionSpace200,
|
|
148
|
+
size300: dimensionSize300,
|
|
149
|
+
size600: dimensionSize600,
|
|
150
|
+
size800: dimensionSize800,
|
|
151
|
+
iconographyMd: dimensionIconographyMd,
|
|
152
|
+
iconographySm: dimensionIconographySm,
|
|
153
|
+
iconographyXs: dimensionIconographyXs,
|
|
154
|
+
panelWidth2xs: dimensionPanelWidth2xs,
|
|
155
|
+
panelWidthMd: dimensionPanelWidthMd,
|
|
156
|
+
panelWidthLg: dimensionPanelWidthLg,
|
|
157
|
+
menuWidthXs: dimensionMenuWidthXs,
|
|
158
|
+
motionShort2: effectMotionShort2,
|
|
159
|
+
motionShort3: effectMotionShort3,
|
|
160
|
+
animationDurationShort3: effectAnimationDurationShort3,
|
|
161
|
+
animationDurationMedium1: effectAnimationDurationMedium1,
|
|
162
|
+
animationDelayMedium1: effectAnimationDelayMedium1,
|
|
163
|
+
animationDelayShort2: effectAnimationDelayShort2,
|
|
164
|
+
animationDelayLong2: effectAnimationDelayLong2,
|
|
165
|
+
/** Unmeasured menu height fallback: 20× base (160px at default scale). */
|
|
166
|
+
menuFallbackHeight: "calc(var(--dimension-size-base) * 20)",
|
|
167
|
+
/** Unmeasured tooltip width fallback: size-800 + size-200 (80px). */
|
|
168
|
+
tooltipFallbackWidth: "calc(var(--dimension-size-800) + var(--dimension-size-200))"
|
|
169
|
+
};
|
|
170
|
+
var TOKEN_CSS_LENGTHS = {
|
|
171
|
+
space050: `var(${dimensionSpace050})`,
|
|
172
|
+
space200: `var(${dimensionSpace200})`,
|
|
173
|
+
menuWidthXs: `var(${dimensionMenuWidthXs})`
|
|
174
|
+
};
|
|
175
|
+
export {
|
|
176
|
+
SCROLL_EDGE_FADE_DEFAULT_SIZE,
|
|
177
|
+
SCROLL_EDGE_FADE_SIZE_VAR,
|
|
178
|
+
TOKEN_CSS_LENGTHS,
|
|
179
|
+
TOKEN_DEFAULTS,
|
|
180
|
+
clearCssLengthPxCache,
|
|
181
|
+
parseCssTimeMs,
|
|
182
|
+
registerIcons,
|
|
183
|
+
resolveCssLengthPx,
|
|
184
|
+
resolveCssTimeMs,
|
|
185
|
+
scrollEdgeFadeMaskImage,
|
|
186
|
+
scrollEdgeFadeMaskStyle
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/wc/components/Icon/icon-cache.ts", "../../../src/wc/utils/resolve-css-length-px.ts", "../../../src/wc/utils/resolve-css-time-ms.ts", "../../../src/wc/utils/scroll-edge-fade.ts", "../../../src/wc/utils/token-defaults.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Shared SVG glyph cache for ds-icon.\n *\n * Keyed on a global symbol so every module instance (the compiled Stencil chunk\n * inside dist/components and any direct source import, e.g. via `@ds-mo/ui/utils`)\n * reads and writes the same cache. Without this, `registerIcons` called from an\n * app would fill a different Map than the one ds-icon resolves from.\n */\nconst CACHE_KEY = Symbol.for('ds-mo.icon-svg-cache');\n\ntype IconCacheMap = Map<string, string>;\n\ntype GlobalWithIconCache = { [CACHE_KEY]?: IconCacheMap };\n\nexport function iconCacheKey(name: string, flag: boolean): string {\n return flag ? `flag:${name}` : `system:${name}`;\n}\n\nexport function iconCache(): IconCacheMap {\n const g = globalThis as GlobalWithIconCache;\n return (g[CACHE_KEY] ??= new Map());\n}\n\n/**\n * Pre-register glyphs so ds-icon renders them synchronously \u2014 no lazy-chunk\n * fetch, no first-paint pop-in. Import the SVG strings from `@ds-mo/icons`\n * in the app (statically, so they ship in the app's own bundle):\n *\n * ```ts\n * import { Bell } from '@ds-mo/icons/svg/Bell';\n * import { US } from '@ds-mo/icons/svg/flags/US';\n * import { registerIcons } from '@ds-mo/ui/utils';\n *\n * registerIcons({ Bell });\n * registerIcons({ US }, { flag: true });\n * ```\n *\n * Icons that are not registered still work \u2014 they lazy-load on first render\n * and stay cached afterwards.\n */\nexport function registerIcons(icons: Record<string, string>, options?: { flag?: boolean }): void {\n const cache = iconCache();\n const flag = options?.flag === true;\n for (const [name, svg] of Object.entries(icons)) {\n cache.set(iconCacheKey(name, flag), svg);\n }\n}\n", "const lengthPxCache = new Map<string, number>();\n\nlet probeEl: HTMLElement | null = null;\n\nfunction getProbeElement(): HTMLElement | null {\n if (typeof document === 'undefined') return null;\n\n if (!probeEl) {\n probeEl = document.createElement('div');\n probeEl.setAttribute('aria-hidden', 'true');\n probeEl.style.cssText =\n 'position:absolute;visibility:hidden;pointer-events:none;top:0;left:0;width:0;height:0;overflow:hidden;';\n document.documentElement.appendChild(probeEl);\n }\n\n return probeEl;\n}\n\n/** Clear session cache (tests only). */\nexport function clearCssLengthPxCache(): void {\n lengthPxCache.clear();\n}\n\n/**\n * Resolve a CSS length to pixels for layout math.\n * Numbers pass through; `var(--dimension-*)`, `calc(...)`, and `16px` resolve via a hidden probe.\n */\nexport function resolveCssLengthPx(\n value: number | string | undefined,\n fallback: number | string,\n): number {\n const resolved = value === undefined || value === null || value === '' ? fallback : value;\n if (typeof resolved === 'number') return resolved;\n\n const trimmed = resolved.trim();\n if (!trimmed) return resolveCssLengthPx(fallback, 0);\n\n const cached = lengthPxCache.get(trimmed);\n if (cached !== undefined) return cached;\n\n if (/^-?\\d+(\\.\\d+)?$/.test(trimmed)) {\n const n = Number(trimmed);\n lengthPxCache.set(trimmed, n);\n return n;\n }\n\n const pxMatch = trimmed.match(/^(-?\\d+(\\.\\d+)?)px$/);\n if (pxMatch) {\n const px = parseFloat(pxMatch[1]);\n lengthPxCache.set(trimmed, px);\n return px;\n }\n\n const cssLength = /^--[\\w-]+$/.test(trimmed) ? `var(${trimmed})` : trimmed;\n\n const probe = getProbeElement();\n if (!probe) {\n return typeof fallback === 'number' ? fallback : 0;\n }\n\n probe.style.width = cssLength;\n const px = probe.getBoundingClientRect().width;\n probe.style.width = '';\n lengthPxCache.set(trimmed, px);\n return px;\n}\n", "/** Parse a CSS <time> value (or motion shorthand's first token) to milliseconds. */\nexport function parseCssTimeMs(value: string, fallback: number): number {\n const firstToken = value.trim().split(/\\s+/)[0] ?? '';\n const num = parseFloat(firstToken);\n if (Number.isNaN(num)) return fallback;\n if (/ms\\s*$/.test(firstToken)) return num;\n if (/s\\s*$/.test(firstToken)) return num * 1000;\n return num;\n}\n\nfunction extractCssCustomProp(ref: string): string | null {\n const varMatch = ref.match(/^var\\(\\s*(--[^),]+)/);\n if (varMatch) return varMatch[1].trim();\n if (ref.startsWith('--')) return ref.trim();\n return null;\n}\n\nfunction readTokenTimeMs(token: string, fallback: number): number {\n if (typeof document === 'undefined') return fallback;\n\n const prop = extractCssCustomProp(token);\n if (!prop) return parseCssTimeMs(token, fallback);\n\n const raw = getComputedStyle(document.documentElement).getPropertyValue(prop).trim();\n return parseCssTimeMs(raw, fallback);\n}\n\n/**\n * Resolve a duration to milliseconds for JS timers aligned with CSS motion tokens.\n * Accepts numbers (ms), raw times (`200ms`, `0.75s`), or `var(--effect-*)` references.\n */\nexport function resolveCssTimeMs(\n value: number | string | undefined,\n fallbackToken: string,\n): number {\n if (typeof value === 'number') return value;\n\n const token = typeof value === 'string' && value.trim() ? value.trim() : fallbackToken;\n const prop = extractCssCustomProp(token);\n\n if (prop) {\n return readTokenTimeMs(token, readTokenTimeMs(fallbackToken, 200));\n }\n\n return parseCssTimeMs(token, readTokenTimeMs(fallbackToken, 200));\n}\n", "/** CSS custom property for scroll-edge fade depth (dimension token or length). */\nexport const SCROLL_EDGE_FADE_SIZE_VAR = '--ds-scroll-edge-fade-size';\n\nexport const SCROLL_EDGE_FADE_DEFAULT_SIZE = 'var(--dimension-size-600)';\n\nexport type ScrollEdgeFadeEdge = 'top' | 'bottom' | 'left' | 'right';\n\nconst SIZE_REF = `var(${SCROLL_EDGE_FADE_SIZE_VAR}, ${SCROLL_EDGE_FADE_DEFAULT_SIZE})`;\n\n/**\n * Alpha mask for a scroll container edge \u2014 content fades to transparent so\n * textured backgrounds (gradients, images) show through. Prefer over painted\n * `ds-fade` overlays on non-flat surfaces.\n */\nexport function scrollEdgeFadeMaskImage(edge: ScrollEdgeFadeEdge): string {\n switch (edge) {\n case 'top':\n return `linear-gradient(to bottom, #000 0, #000 50%, transparent 100%)`;\n case 'bottom':\n return `linear-gradient(to bottom, #000 0, #000 calc(100% - ${SIZE_REF}), transparent 100%)`;\n case 'left':\n return `linear-gradient(to right, #000 0, #000 calc(100% - ${SIZE_REF}), transparent 100%)`;\n case 'right':\n return `linear-gradient(to left, #000 0, #000 calc(100% - ${SIZE_REF}), transparent 100%)`;\n }\n}\n\n/** Inline style map for a masked scroll region. */\nexport function scrollEdgeFadeMaskStyle(edge: ScrollEdgeFadeEdge): Record<string, string> {\n const mask = scrollEdgeFadeMaskImage(edge);\n return {\n [SCROLL_EDGE_FADE_SIZE_VAR]: SCROLL_EDGE_FADE_DEFAULT_SIZE,\n WebkitMaskImage: mask,\n maskImage: mask,\n WebkitMaskSize: '100% 100%',\n maskSize: '100% 100%',\n };\n}\n", "import {\n dimensionIconographyMd,\n dimensionIconographySm,\n dimensionIconographyXs,\n dimensionMenuWidthXs,\n dimensionPanelWidth2xs,\n dimensionPanelWidthLg,\n dimensionPanelWidthMd,\n dimensionSize300,\n dimensionSize600,\n dimensionSize800,\n dimensionSpace050,\n dimensionSpace200,\n effectAnimationDelayLong2,\n effectAnimationDelayMedium1,\n effectAnimationDelayShort2,\n effectAnimationDurationMedium1,\n effectAnimationDurationShort3,\n effectMotionShort2,\n effectMotionShort3,\n} from '@ds-mo/tokens/ts';\n\n/** TokoMo CSS custom-property names for shared component defaults (runtime resolution). */\nexport const TOKEN_DEFAULTS = {\n space050: dimensionSpace050,\n space200: dimensionSpace200,\n size300: dimensionSize300,\n size600: dimensionSize600,\n size800: dimensionSize800,\n iconographyMd: dimensionIconographyMd,\n iconographySm: dimensionIconographySm,\n iconographyXs: dimensionIconographyXs,\n panelWidth2xs: dimensionPanelWidth2xs,\n panelWidthMd: dimensionPanelWidthMd,\n panelWidthLg: dimensionPanelWidthLg,\n menuWidthXs: dimensionMenuWidthXs,\n motionShort2: effectMotionShort2,\n motionShort3: effectMotionShort3,\n animationDurationShort3: effectAnimationDurationShort3,\n animationDurationMedium1: effectAnimationDurationMedium1,\n animationDelayMedium1: effectAnimationDelayMedium1,\n animationDelayShort2: effectAnimationDelayShort2,\n animationDelayLong2: effectAnimationDelayLong2,\n /** Unmeasured menu height fallback: 20\u00D7 base (160px at default scale). */\n menuFallbackHeight: 'calc(var(--dimension-size-base) * 20)',\n /** Unmeasured tooltip width fallback: size-800 + size-200 (80px). */\n tooltipFallbackWidth: 'calc(var(--dimension-size-800) + var(--dimension-size-200))',\n} as const;\n\nexport type TokenDefaultKey = keyof typeof TOKEN_DEFAULTS;\n\n/** Valid CSS length strings for overlay offset props \u2014 bind on `sideOffset` / `alignOffset` in hosts. */\nexport const TOKEN_CSS_LENGTHS = {\n space050: `var(${dimensionSpace050})`,\n space200: `var(${dimensionSpace200})`,\n menuWidthXs: `var(${dimensionMenuWidthXs})`,\n} as const;\n"],
|
|
5
|
+
"mappings": ";AAQA,IAAM,YAAY,uBAAO,IAAI,sBAAsB;AAM5C,SAAS,aAAa,MAAc,MAAuB;AAChE,SAAO,OAAO,QAAQ,IAAI,KAAK,UAAU,IAAI;AAC/C;AAEO,SAAS,YAA0B;AACxC,QAAM,IAAI;AACV,SAAQ,gCAAiB,oBAAI,IAAI;AACnC;AAmBO,SAA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AAAA,EAClC,aAAa,OAAO,oBAAoB;AAC1C;",
|
|
6
|
+
"names": ["px"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Clear session cache (tests only). */
|
|
2
|
+
export declare function clearCssLengthPxCache(): void;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a CSS length to pixels for layout math.
|
|
5
|
+
* Numbers pass through; `var(--dimension-*)`, `calc(...)`, and `16px` resolve via a hidden probe.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveCssLengthPx(value: number | string | undefined, fallback: number | string): number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Parse a CSS <time> value (or motion shorthand's first token) to milliseconds. */
|
|
2
|
+
export declare function parseCssTimeMs(value: string, fallback: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a duration to milliseconds for JS timers aligned with CSS motion tokens.
|
|
5
|
+
* Accepts numbers (ms), raw times (`200ms`, `0.75s`), or `var(--effect-*)` references.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveCssTimeMs(value: number | string | undefined, fallbackToken: string): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** CSS custom property for scroll-edge fade depth (dimension token or length). */
|
|
2
|
+
export declare const SCROLL_EDGE_FADE_SIZE_VAR = "--ds-scroll-edge-fade-size";
|
|
3
|
+
export declare const SCROLL_EDGE_FADE_DEFAULT_SIZE = "var(--dimension-size-600)";
|
|
4
|
+
export type ScrollEdgeFadeEdge = 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
+
/**
|
|
6
|
+
* Alpha mask for a scroll container edge — content fades to transparent so
|
|
7
|
+
* textured backgrounds (gradients, images) show through. Prefer over painted
|
|
8
|
+
* `ds-fade` overlays on non-flat surfaces.
|
|
9
|
+
*/
|
|
10
|
+
export declare function scrollEdgeFadeMaskImage(edge: ScrollEdgeFadeEdge): string;
|
|
11
|
+
/** Inline style map for a masked scroll region. */
|
|
12
|
+
export declare function scrollEdgeFadeMaskStyle(edge: ScrollEdgeFadeEdge): Record<string, string>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** TokoMo CSS custom-property names for shared component defaults (runtime resolution). */
|
|
2
|
+
export declare const TOKEN_DEFAULTS: {
|
|
3
|
+
readonly space050: "--dimension-space-050";
|
|
4
|
+
readonly space200: "--dimension-space-200";
|
|
5
|
+
readonly size300: "--dimension-size-300";
|
|
6
|
+
readonly size600: "--dimension-size-600";
|
|
7
|
+
readonly size800: "--dimension-size-800";
|
|
8
|
+
readonly iconographyMd: "--dimension-iconography-md";
|
|
9
|
+
readonly iconographySm: "--dimension-iconography-sm";
|
|
10
|
+
readonly iconographyXs: "--dimension-iconography-xs";
|
|
11
|
+
readonly panelWidth2xs: "--dimension-panel-width-2xs";
|
|
12
|
+
readonly panelWidthMd: "--dimension-panel-width-md";
|
|
13
|
+
readonly panelWidthLg: "--dimension-panel-width-lg";
|
|
14
|
+
readonly menuWidthXs: "--dimension-menu-width-xs";
|
|
15
|
+
readonly motionShort2: "--effect-motion-short-2";
|
|
16
|
+
readonly motionShort3: "--effect-motion-short-3";
|
|
17
|
+
readonly animationDurationShort3: "--effect-animation-duration-short-3";
|
|
18
|
+
readonly animationDurationMedium1: "--effect-animation-duration-medium-1";
|
|
19
|
+
readonly animationDelayMedium1: "--effect-animation-delay-medium-1";
|
|
20
|
+
readonly animationDelayShort2: "--effect-animation-delay-short-2";
|
|
21
|
+
readonly animationDelayLong2: "--effect-animation-delay-long-2";
|
|
22
|
+
/** Unmeasured menu height fallback: 20× base (160px at default scale). */
|
|
23
|
+
readonly menuFallbackHeight: "calc(var(--dimension-size-base) * 20)";
|
|
24
|
+
/** Unmeasured tooltip width fallback: size-800 + size-200 (80px). */
|
|
25
|
+
readonly tooltipFallbackWidth: "calc(var(--dimension-size-800) + var(--dimension-size-200))";
|
|
26
|
+
};
|
|
27
|
+
export type TokenDefaultKey = keyof typeof TOKEN_DEFAULTS;
|
|
28
|
+
/** Valid CSS length strings for overlay offset props — bind on `sideOffset` / `alignOffset` in hosts. */
|
|
29
|
+
export declare const TOKEN_CSS_LENGTHS: {
|
|
30
|
+
readonly space050: "var(--dimension-space-050)";
|
|
31
|
+
readonly space200: "var(--dimension-space-200)";
|
|
32
|
+
readonly menuWidthXs: "var(--dimension-menu-width-xs)";
|
|
33
|
+
};
|
|
@@ -15,7 +15,11 @@ export declare class Badge {
|
|
|
15
15
|
/**
|
|
16
16
|
* Ring samples the shell gradient stack (base fill + wash) instead of a flat
|
|
17
17
|
* `box-shadow`. Auto-enabled in `componentDidLoad` under `ds-app-shell[gradient]`;
|
|
18
|
-
* set `
|
|
18
|
+
* set `gradient-background` to opt in/out explicitly.
|
|
19
|
+
*
|
|
20
|
+
* The attribute must NOT start with `on` — Stencil's setAccessor routes any
|
|
21
|
+
* unknown `on*` member down the event-listener path during attribute
|
|
22
|
+
* reflection, calling addEventListener with a non-listener and throwing.
|
|
19
23
|
*/
|
|
20
24
|
gradientBackground: boolean;
|
|
21
25
|
/** Deprecated alias for selected counter styling. Prefer context-specific color in the parent. */
|
|
@@ -13,7 +13,20 @@ export declare class Icon {
|
|
|
13
13
|
label: string | undefined;
|
|
14
14
|
/** Set `true` to look up from the flag icon set instead of the system icon set. */
|
|
15
15
|
flag: boolean;
|
|
16
|
-
|
|
16
|
+
/** Resolved SVG markup — set synchronously on cache hit, async after a lazy load. */
|
|
17
|
+
private svg;
|
|
18
|
+
/** Guards against out-of-order async resolutions when `name`/`flag` change quickly. */
|
|
19
|
+
private loadToken;
|
|
20
|
+
/**
|
|
21
|
+
* Cache hit → render synchronously (pre-registered via `registerIcons` or
|
|
22
|
+
* previously loaded). Miss → fire the per-icon lazy loader; the glyph pops in
|
|
23
|
+
* when the (tiny, per-icon) chunk resolves and stays cached for every other
|
|
24
|
+
* ds-icon instance.
|
|
25
|
+
*/
|
|
26
|
+
private resolveSvg;
|
|
27
|
+
componentWillLoad(): void;
|
|
28
|
+
/** Last markup injected into the DOM — skips redundant re-parse on unrelated re-renders. */
|
|
29
|
+
private renderedSvg;
|
|
17
30
|
private updateSvg;
|
|
18
31
|
onIconChange(): void;
|
|
19
32
|
componentDidRender(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type IconCacheMap = Map<string, string>;
|
|
2
|
+
export declare function iconCacheKey(name: string, flag: boolean): string;
|
|
3
|
+
export declare function iconCache(): IconCacheMap;
|
|
4
|
+
/**
|
|
5
|
+
* Pre-register glyphs so ds-icon renders them synchronously — no lazy-chunk
|
|
6
|
+
* fetch, no first-paint pop-in. Import the SVG strings from `@ds-mo/icons`
|
|
7
|
+
* in the app (statically, so they ship in the app's own bundle):
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Bell } from '@ds-mo/icons/svg/Bell';
|
|
11
|
+
* import { US } from '@ds-mo/icons/svg/flags/US';
|
|
12
|
+
* import { registerIcons } from '@ds-mo/ui/utils';
|
|
13
|
+
*
|
|
14
|
+
* registerIcons({ Bell });
|
|
15
|
+
* registerIcons({ US }, { flag: true });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Icons that are not registered still work — they lazy-load on first render
|
|
19
|
+
* and stay cached afterwards.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerIcons(icons: Record<string, string>, options?: {
|
|
22
|
+
flag?: boolean;
|
|
23
|
+
}): void;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=icon-cache.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glyph markup validation + Trusted-Types-safe parsing for ds-icon.
|
|
3
|
+
*
|
|
4
|
+
* Glyphs normally come from the trusted @ds-mo/icons build pipeline, but
|
|
5
|
+
* `registerIcons` accepts arbitrary app-provided strings and injection is a
|
|
6
|
+
* sink — so every glyph is validated at the render boundary. Injection uses
|
|
7
|
+
* parsed DOM nodes (never innerHTML), which keeps ds-icon working under a
|
|
8
|
+
* strict CSP with `require-trusted-types-for 'script'`.
|
|
9
|
+
*/
|
|
10
|
+
/** Structural view of an element so the walk is unit-testable without a DOM. */
|
|
11
|
+
export interface IconSvgElementLike {
|
|
12
|
+
localName: string;
|
|
13
|
+
getAttributeNames(): string[];
|
|
14
|
+
getAttribute(name: string): string | null;
|
|
15
|
+
children: ArrayLike<IconSvgElementLike>;
|
|
16
|
+
}
|
|
17
|
+
/** True when `root` is an `<svg>` whose whole tree passes validation. */
|
|
18
|
+
export declare function isValidIconSvgRoot(root: IconSvgElementLike | null): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Parse + validate glyph markup. Returns a detached `<svg>` element ready to
|
|
21
|
+
* append (appending adopts it into the document), or `null` when the markup
|
|
22
|
+
* is not well-formed XML, not rooted at `<svg>`, or fails validation —
|
|
23
|
+
* ds-icon renders an empty fixed-size box in that case.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseIconSvg(svg: string): SVGElement | null;
|
|
26
|
+
//# sourceMappingURL=icon-svg.d.ts.map
|
|
@@ -135,7 +135,7 @@ export namespace Components {
|
|
|
135
135
|
*/
|
|
136
136
|
"count": number;
|
|
137
137
|
/**
|
|
138
|
-
* Ring samples the shell gradient stack (base fill + wash) instead of a flat `box-shadow`. Auto-enabled in `componentDidLoad` under `ds-app-shell[gradient]`; set `
|
|
138
|
+
* Ring samples the shell gradient stack (base fill + wash) instead of a flat `box-shadow`. Auto-enabled in `componentDidLoad` under `ds-app-shell[gradient]`; set `gradient-background` to opt in/out explicitly. The attribute must NOT start with `on` — Stencil's setAccessor routes any unknown `on*` member down the event-listener path during attribute reflection, calling addEventListener with a non-listener and throwing.
|
|
139
139
|
* @default false
|
|
140
140
|
*/
|
|
141
141
|
"gradientBackground": boolean;
|
|
@@ -1800,7 +1800,7 @@ declare namespace LocalJSX {
|
|
|
1800
1800
|
*/
|
|
1801
1801
|
"count"?: number;
|
|
1802
1802
|
/**
|
|
1803
|
-
* Ring samples the shell gradient stack (base fill + wash) instead of a flat `box-shadow`. Auto-enabled in `componentDidLoad` under `ds-app-shell[gradient]`; set `
|
|
1803
|
+
* Ring samples the shell gradient stack (base fill + wash) instead of a flat `box-shadow`. Auto-enabled in `componentDidLoad` under `ds-app-shell[gradient]`; set `gradient-background` to opt in/out explicitly. The attribute must NOT start with `on` — Stencil's setAccessor routes any unknown `on*` member down the event-listener path during attribute reflection, calling addEventListener with a non-listener and throwing.
|
|
1804
1804
|
* @default false
|
|
1805
1805
|
*/
|
|
1806
1806
|
"gradientBackground"?: boolean;
|
|
@@ -7,7 +7,7 @@ export type { ShellGradientLayout, ShellViewportDimensions } from './shell-gradi
|
|
|
7
7
|
export type { MenuPlacement } from '../components/Menu/menu-placement';
|
|
8
8
|
export { PANEL_NAV_USER_MENU_PLACEMENT, } from '../components/Menu/menu-placement';
|
|
9
9
|
export type { ShellGradientPreset } from './shell-gradient-presets';
|
|
10
|
-
export { DEFAULT_SHELL_GRADIENT_PRESET, SHELL_GRADIENT_PRESETS, SHELL_GRADIENT_PRESET_LABELS, buildShellRadialGradientForPreset, isShellGradientPreset, shellGradientPresetStopToken, } from './shell-gradient-presets';
|
|
10
|
+
export { DEFAULT_SHELL_GRADIENT_PRESET, SHELL_GRADIENT_PRESETS, SHELL_GRADIENT_PRESET_LABELS, buildShellRadialGradientForPreset, isShellGradientPreset, normalizeShellGradientPreset, shellGradientPresetStopToken, } from './shell-gradient-presets';
|
|
11
11
|
export type { ChromeTransitionDetail, ChromeTransitionSource } from './chrome-transition';
|
|
12
12
|
export { CHROME_TRANSITION_END, CHROME_TRANSITION_START, ChromeTransitionDepth, createRafCoalescer, readChromeTransitionSource, readChromeTransitionPhase, } from './chrome-transition';
|
|
13
13
|
export { barGradientPositionFromPanelWidth, isPanelNavCollapsed, panelWidthPxFromTokens, readCssVarWidthPx, readPanelNavWidthTokens, } from './shell-chrome-metrics';
|
|
@@ -8,6 +8,14 @@ export declare const DEFAULT_SHELL_GRADIENT_PRESET: ShellGradientPreset;
|
|
|
8
8
|
export declare const SHELL_GRADIENT_PRESET_LABELS: Record<ShellGradientPreset, string>;
|
|
9
9
|
export declare function shellGradientPresetStopToken(preset: ShellGradientPreset): string | null;
|
|
10
10
|
export declare function isShellGradientPreset(value: string): value is ShellGradientPreset;
|
|
11
|
+
/**
|
|
12
|
+
* Coerce unknown/absent presets to the default. Runtime values escape the
|
|
13
|
+
* type: removing the reflected `gradient-preset` attribute (e.g. an Angular
|
|
14
|
+
* `[attr.gradient-preset]="null"` binding) drives the prop to null past its
|
|
15
|
+
* field default — without normalization the stop lookup interpolates the
|
|
16
|
+
* literal string "undefined" into CSS and the wash silently disappears.
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeShellGradientPreset(value: string | null | undefined): ShellGradientPreset;
|
|
11
19
|
/** Radial wash for a preset — transparent at top-left into the intent stop. `none` returns no image. */
|
|
12
20
|
export declare function buildShellRadialGradientForPreset(preset: ShellGradientPreset): string;
|
|
13
21
|
//# sourceMappingURL=shell-gradient-presets.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { registerIcons } from '../components/Icon/icon-cache';
|
|
1
2
|
export { clearCssLengthPxCache, resolveCssLengthPx } from './resolve-css-length-px';
|
|
2
3
|
export { parseCssTimeMs, resolveCssTimeMs } from './resolve-css-time-ms';
|
|
3
4
|
export { SCROLL_EDGE_FADE_DEFAULT_SIZE, SCROLL_EDGE_FADE_SIZE_VAR, scrollEdgeFadeMaskImage, scrollEdgeFadeMaskStyle, } from './scroll-edge-fade';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ds-mo/ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"description": "CompoMo — composable web components styled with TokoMo design tokens",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"import": "./dist/components/index.js"
|
|
43
43
|
},
|
|
44
44
|
"./nav": {
|
|
45
|
-
"types": "./
|
|
46
|
-
"import": "./
|
|
45
|
+
"types": "./dist/lib/nav/index.d.ts",
|
|
46
|
+
"import": "./dist/lib/nav/index.js"
|
|
47
47
|
},
|
|
48
48
|
"./utils": {
|
|
49
|
-
"types": "./
|
|
50
|
-
"import": "./
|
|
49
|
+
"types": "./dist/lib/utils/index.d.ts",
|
|
50
|
+
"import": "./dist/lib/utils/index.js"
|
|
51
51
|
},
|
|
52
52
|
"./dist/components/*": "./dist/components/*"
|
|
53
53
|
},
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"prebuild": "node scripts/generate-icon-catalog.mjs",
|
|
68
68
|
"pretypecheck": "node scripts/generate-icon-catalog.mjs",
|
|
69
69
|
"pretest": "node scripts/generate-icon-catalog.mjs",
|
|
70
|
-
"build": "stencil build && node scripts/patch-index-types.mjs && node scripts/patch-components-d-exports.mjs && node scripts/verify-icons-externalized.mjs && node scripts/write-build-stamp.mjs",
|
|
70
|
+
"build": "stencil build && node scripts/patch-index-types.mjs && node scripts/patch-components-d-exports.mjs && node scripts/verify-icons-externalized.mjs && node scripts/write-build-stamp.mjs && node scripts/build-lib-exports.mjs",
|
|
71
71
|
"verify:pack": "node scripts/verify-npm-pack.mjs && node scripts/verify-nav-import.mjs",
|
|
72
|
-
"test": "node --import tsx/esm --test tests/panel-nav-utils.test.ts tests/panel-tools.test.ts tests/shell-shortcuts.test.ts tests/shell-gradient-presets.test.ts tests/shell-view-transition.test.ts tests/shell-gradient.test.ts tests/shell-chrome-metrics.test.ts tests/shell-chrome-layer.test.ts tests/chrome-transition.test.ts tests/bar-nav-overflow-hysteresis.test.ts tests/badge-gradient-ring.test.ts tests/scroll-edge-fade.test.ts tests/resolve-css-length-px.test.ts tests/resolve-css-time-ms.test.ts tests/overlay-positioning.test.ts tests/menu-position.test.ts tests/menu-placement.test.ts tests/bar-nav-utils.test.ts tests/bar-nav-tabs-menu-utils.test.ts tests/bar-nav-dom-utils.test.ts tests/icon-catalog.test.ts",
|
|
72
|
+
"test": "node --import tsx/esm --test tests/panel-nav-utils.test.ts tests/panel-tools.test.ts tests/shell-shortcuts.test.ts tests/shell-gradient-presets.test.ts tests/shell-view-transition.test.ts tests/shell-gradient.test.ts tests/shell-chrome-metrics.test.ts tests/shell-chrome-layer.test.ts tests/chrome-transition.test.ts tests/bar-nav-overflow-hysteresis.test.ts tests/badge-gradient-ring.test.ts tests/scroll-edge-fade.test.ts tests/resolve-css-length-px.test.ts tests/resolve-css-time-ms.test.ts tests/overlay-positioning.test.ts tests/menu-position.test.ts tests/menu-placement.test.ts tests/bar-nav-utils.test.ts tests/bar-nav-tabs-menu-utils.test.ts tests/bar-nav-dom-utils.test.ts tests/icon-catalog.test.ts tests/icon-cache.test.ts tests/icon-svg.test.ts",
|
|
73
73
|
"test:e2e": "npm run build && playwright test",
|
|
74
74
|
"test:e2e:install": "playwright install chromium",
|
|
75
75
|
"build:docs": "stencil build --docs",
|
|
@@ -130,7 +130,8 @@
|
|
|
130
130
|
"typescript": "~6.0.3",
|
|
131
131
|
"typescript-eslint": "^8.59.1",
|
|
132
132
|
"vite": "^8.0.16",
|
|
133
|
-
"zod": "^4.4.3"
|
|
133
|
+
"zod": "^4.4.3",
|
|
134
|
+
"esbuild": "^0.28.0"
|
|
134
135
|
},
|
|
135
136
|
"engines": {
|
|
136
137
|
"node": "^20.19.0 || >=22.12.0"
|
|
@@ -52,9 +52,13 @@ export class Badge {
|
|
|
52
52
|
/**
|
|
53
53
|
* Ring samples the shell gradient stack (base fill + wash) instead of a flat
|
|
54
54
|
* `box-shadow`. Auto-enabled in `componentDidLoad` under `ds-app-shell[gradient]`;
|
|
55
|
-
* set `
|
|
55
|
+
* set `gradient-background` to opt in/out explicitly.
|
|
56
|
+
*
|
|
57
|
+
* The attribute must NOT start with `on` — Stencil's setAccessor routes any
|
|
58
|
+
* unknown `on*` member down the event-listener path during attribute
|
|
59
|
+
* reflection, calling addEventListener with a non-listener and throwing.
|
|
56
60
|
*/
|
|
57
|
-
@Prop({ attribute: '
|
|
61
|
+
@Prop({ attribute: 'gradient-background', reflect: true }) gradientBackground: boolean = false;
|
|
58
62
|
|
|
59
63
|
/** Deprecated alias for selected counter styling. Prefer context-specific color in the parent. */
|
|
60
64
|
@Prop() isSelected: boolean = false;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Component, Prop, Element, Watch, h, Host } from '@stencil/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Component, Prop, Element, State, Watch, h, Host } from '@stencil/core';
|
|
2
|
+
import { flagIconLoaders } from './flag-icon-catalog';
|
|
3
|
+
import { systemIconLoaders } from './system-icon-catalog';
|
|
4
|
+
import { iconCache, iconCacheKey } from './icon-cache';
|
|
5
|
+
import { parseIconSvg } from './icon-svg';
|
|
4
6
|
|
|
5
7
|
export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
|
|
6
8
|
|
|
@@ -47,36 +49,94 @@ export class Icon {
|
|
|
47
49
|
/** Set `true` to look up from the flag icon set instead of the system icon set. */
|
|
48
50
|
@Prop() flag: boolean = false;
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
/** Resolved SVG markup — set synchronously on cache hit, async after a lazy load. */
|
|
53
|
+
@State() private svg: string = '';
|
|
54
|
+
|
|
55
|
+
/** Guards against out-of-order async resolutions when `name`/`flag` change quickly. */
|
|
56
|
+
private loadToken = 0;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Cache hit → render synchronously (pre-registered via `registerIcons` or
|
|
60
|
+
* previously loaded). Miss → fire the per-icon lazy loader; the glyph pops in
|
|
61
|
+
* when the (tiny, per-icon) chunk resolves and stays cached for every other
|
|
62
|
+
* ds-icon instance.
|
|
63
|
+
*/
|
|
64
|
+
private resolveSvg() {
|
|
65
|
+
const flag = this.flag;
|
|
66
|
+
const key = iconCacheKey(this.name, flag);
|
|
67
|
+
const token = ++this.loadToken;
|
|
68
|
+
|
|
69
|
+
const cached = iconCache().get(key);
|
|
70
|
+
if (cached !== undefined) {
|
|
71
|
+
this.svg = cached;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Own-key lookup only: names resolve by exact canonical IcoMo export key —
|
|
76
|
+
// never meta.json aliases (not in the maps) and never inherited prototype
|
|
77
|
+
// keys ('constructor', 'toString', …) that a bare index access would hit.
|
|
78
|
+
const loaders = flag ? flagIconLoaders : systemIconLoaders;
|
|
79
|
+
const loader = Object.prototype.hasOwnProperty.call(loaders, this.name)
|
|
80
|
+
? loaders[this.name]
|
|
81
|
+
: undefined;
|
|
82
|
+
if (!loader) {
|
|
83
|
+
this.svg = '';
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
loader()
|
|
88
|
+
.then(svg => {
|
|
89
|
+
iconCache().set(key, svg);
|
|
90
|
+
if (token === this.loadToken) this.svg = svg;
|
|
91
|
+
})
|
|
92
|
+
.catch(() => {
|
|
93
|
+
if (token === this.loadToken) this.svg = '';
|
|
94
|
+
});
|
|
53
95
|
}
|
|
54
96
|
|
|
97
|
+
componentWillLoad() {
|
|
98
|
+
// Fire-and-forget: do not return the promise — a cache miss must not block
|
|
99
|
+
// the parent render tree on a network fetch.
|
|
100
|
+
this.resolveSvg();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Last markup injected into the DOM — skips redundant re-parse on unrelated re-renders. */
|
|
104
|
+
private renderedSvg: string | null = null;
|
|
105
|
+
|
|
55
106
|
private updateSvg() {
|
|
56
107
|
const container = this.el.querySelector<HTMLElement>('.icon__svg');
|
|
57
108
|
if (!container) return;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
69
|
-
svg.style.display = 'block';
|
|
70
|
-
svg.style.flexShrink = '0';
|
|
71
|
-
svg.style.width = '100%';
|
|
72
|
-
svg.style.height = '100%';
|
|
109
|
+
if (this.svg === this.renderedSvg) return;
|
|
110
|
+
this.renderedSvg = this.svg;
|
|
111
|
+
|
|
112
|
+
// Validate + inject as parsed DOM nodes — never innerHTML. Keeps ds-icon
|
|
113
|
+
// Trusted-Types compatible and rejects executable/foreign content in
|
|
114
|
+
// glyph strings (registerIcons accepts app-provided markup).
|
|
115
|
+
const svg = this.svg ? parseIconSvg(this.svg) : null;
|
|
116
|
+
if (!svg) {
|
|
117
|
+
container.replaceChildren();
|
|
118
|
+
return;
|
|
73
119
|
}
|
|
120
|
+
|
|
121
|
+
// Stencil's scoped CSS cannot reach injected elements (no sc-* class).
|
|
122
|
+
// Apply width/height as inline styles so sizing works regardless of scope class.
|
|
123
|
+
svg.removeAttribute('width');
|
|
124
|
+
svg.removeAttribute('height');
|
|
125
|
+
// Prevent SVG from being natively focusable (Firefox/IE default) while
|
|
126
|
+
// sitting inside an aria-hidden parent — fixes aria-hidden-focus violation.
|
|
127
|
+
svg.setAttribute('focusable', 'false');
|
|
128
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
129
|
+
svg.style.display = 'block';
|
|
130
|
+
svg.style.flexShrink = '0';
|
|
131
|
+
svg.style.width = '100%';
|
|
132
|
+
svg.style.height = '100%';
|
|
133
|
+
container.replaceChildren(svg);
|
|
74
134
|
}
|
|
75
135
|
|
|
76
136
|
@Watch('name')
|
|
77
137
|
@Watch('flag')
|
|
78
138
|
onIconChange() {
|
|
79
|
-
this.
|
|
139
|
+
this.resolveSvg();
|
|
80
140
|
}
|
|
81
141
|
|
|
82
142
|
componentDidRender() {
|