@takazudo/zdtp 0.4.4 → 0.4.6
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/CHANGELOG.md +46 -0
- package/README.md +159 -12
- package/dist/apply/apply-token-overrides.d.ts +139 -32
- package/dist/astro/host-adapter.js +71 -58
- package/dist/astro/index.js +1 -1
- package/dist/{autoload-state-CmhI7q9j.js → autoload-state-D26ML6sW.js} +1 -1
- package/dist/bin/server.js +116 -112
- package/dist/config/panel-config.d.ts +68 -1
- package/dist/controls/actions-menu-popover.d.ts +26 -0
- package/dist/controls/help-icon.d.ts +43 -0
- package/dist/controls/tooltip.d.ts +20 -2
- package/dist/export-modal.d.ts +5 -3
- package/dist/import-modal.d.ts +9 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3383 -3012
- package/dist/load-routing-LJ72261l.js +421 -0
- package/dist/{panel-config-CXTCcYQs.js → panel-config-Bw7D-25C.js} +381 -271
- package/dist/server/create-apply-handler.d.ts +6 -0
- package/dist/server/index.js +1 -1
- package/dist/state/tweak-state.d.ts +137 -14
- package/dist/tabs/notes-tab.d.ts +25 -0
- package/dist/testing.js +7 -7
- package/dist/tokens/manifest.d.ts +8 -0
- package/dist/tokens/tier-model.d.ts +36 -0
- package/dist/tweak-state-CD1y56zR.js +1958 -0
- package/dist/utils/design-token-serde.d.ts +20 -12
- package/dist/utils/sanitize-html.d.ts +27 -0
- package/dist/utils/unit-cycle.d.ts +61 -0
- package/dist/zdtp.css +1 -1
- package/package.json +1 -1
- package/dist/load-routing-DtNTKoLW.js +0 -353
- package/dist/tweak-state-BeXkzoj8.js +0 -1858
|
@@ -3,68 +3,68 @@ class w extends Error {
|
|
|
3
3
|
super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, w.prototype);
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function A(e, t) {
|
|
7
7
|
return e.tiers.find((n) => n.id === t);
|
|
8
8
|
}
|
|
9
9
|
function $(e, t) {
|
|
10
10
|
return e.items.find((n) => n.id === t);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const g =
|
|
12
|
+
function Y(e, t, n, a) {
|
|
13
|
+
const g = A(e, t);
|
|
14
14
|
if (!g)
|
|
15
15
|
throw new w(
|
|
16
|
-
`Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((
|
|
16
|
+
`Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((l) => l.id).join(", ")}.`
|
|
17
17
|
);
|
|
18
18
|
const c = $(g, n);
|
|
19
19
|
if (!c)
|
|
20
20
|
throw new w(
|
|
21
21
|
`Item "${n}" not found in tier "${t}" of tab "${e.id}".`
|
|
22
22
|
);
|
|
23
|
-
const
|
|
23
|
+
const s = a[t]?.[n];
|
|
24
24
|
if (g.referencesTier !== void 0) {
|
|
25
|
-
const
|
|
25
|
+
const l = g.referencesTier, f = A(e, l);
|
|
26
26
|
if (!f)
|
|
27
27
|
throw new w(
|
|
28
|
-
`Tier "${t}" declares referencesTier "${
|
|
28
|
+
`Tier "${t}" declares referencesTier "${l}" but that tier does not exist in tab "${e.id}".`
|
|
29
29
|
);
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
30
|
+
const i = $(f, s ?? n);
|
|
31
|
+
if (!i) {
|
|
32
|
+
const u = $(f, c.default) ?? $(f, n) ?? f.items[0];
|
|
33
|
+
if (!u)
|
|
34
34
|
throw new w(
|
|
35
|
-
`Referenced tier "${
|
|
35
|
+
`Referenced tier "${l}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
|
|
36
36
|
);
|
|
37
|
-
return { kind: "ref", targetCssVar:
|
|
37
|
+
return { kind: "ref", targetCssVar: u.cssVar };
|
|
38
38
|
}
|
|
39
|
-
return { kind: "ref", targetCssVar:
|
|
39
|
+
return { kind: "ref", targetCssVar: i.cssVar };
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return s !== void 0 ? c.pill && s === c.pill.value ? { kind: "literal", value: c.pill.value } : { kind: "literal", value: s } : c.pill ? { kind: "literal", value: c.pill.customDefault } : { kind: "literal", value: c.default };
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Z(e) {
|
|
44
44
|
return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
46
|
+
function M(e, t, n = [t]) {
|
|
47
|
+
const a = e.tab === void 0 || e.tab === t.id ? t : n.find((o) => o.id === e.tab);
|
|
48
|
+
if (!a)
|
|
49
49
|
throw new w(
|
|
50
|
-
`Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((
|
|
50
|
+
`Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((o) => o.id).join(", ")}.`
|
|
51
51
|
);
|
|
52
|
-
const g =
|
|
52
|
+
const g = A(a, e.tier);
|
|
53
53
|
if (!g)
|
|
54
54
|
throw new w(
|
|
55
|
-
`Cross-tab ref target tier "${e.tier}" not found in tab "${
|
|
55
|
+
`Cross-tab ref target tier "${e.tier}" not found in tab "${a.id}". Available tiers: ${a.tiers.map((o) => o.id).join(", ")}.`
|
|
56
56
|
);
|
|
57
57
|
const c = $(g, e.item);
|
|
58
58
|
if (!c)
|
|
59
59
|
throw new w(
|
|
60
|
-
`Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${
|
|
60
|
+
`Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${a.id}". Available items: ${g.items.map((o) => o.id).join(", ")}.`
|
|
61
61
|
);
|
|
62
62
|
return c.cssVar;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function X(e, t) {
|
|
65
65
|
return e.paletteCssVarTemplate.replace("{n}", String(t));
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const N = /* @__PURE__ */ new Set([
|
|
68
68
|
"aliceblue",
|
|
69
69
|
"antiquewhite",
|
|
70
70
|
"aqua",
|
|
@@ -221,39 +221,39 @@ const M = /* @__PURE__ */ new Set([
|
|
|
221
221
|
"revert",
|
|
222
222
|
"revert-layer"
|
|
223
223
|
]);
|
|
224
|
-
function
|
|
225
|
-
return e.startsWith("#") || e.includes("(") ||
|
|
224
|
+
function z(e) {
|
|
225
|
+
return e.startsWith("#") || e.includes("(") || N.has(e.toLowerCase());
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function H(e, t, n, a) {
|
|
228
228
|
const g = [], c = e.indexOf(":");
|
|
229
229
|
if (c !== -1) {
|
|
230
|
-
const
|
|
231
|
-
f && g.push({ tab: f.tab, tier: f.tier, item:
|
|
230
|
+
const s = e.slice(0, c), l = e.slice(c + 1), f = t.find((r) => r.tier === s);
|
|
231
|
+
f && g.push({ tab: f.tab, tier: f.tier, item: l });
|
|
232
232
|
}
|
|
233
|
-
const [
|
|
234
|
-
g.push({ tab:
|
|
235
|
-
for (const
|
|
233
|
+
const [o] = t;
|
|
234
|
+
g.push({ tab: o.tab, tier: o.tier, item: e });
|
|
235
|
+
for (const s of g)
|
|
236
236
|
try {
|
|
237
|
-
return
|
|
237
|
+
return M(s, n, a), { ref: s };
|
|
238
238
|
} catch {
|
|
239
239
|
}
|
|
240
240
|
return { ref: g[0] };
|
|
241
241
|
}
|
|
242
|
-
function K(e, t, n,
|
|
243
|
-
const
|
|
244
|
-
return
|
|
242
|
+
function K(e, t, n, a, g, c) {
|
|
243
|
+
const o = t.get(e.default);
|
|
244
|
+
return o !== void 0 ? o : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !z(e.default) ? H(e.default, n, a, g) : c ? (console.warn(
|
|
245
245
|
`[design-token-panel] semantic item "${e.id}" default "${e.default}" names no palette item; falling back to palette index 0`
|
|
246
246
|
), 0) : { literal: e.default };
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function V(e, t = [e]) {
|
|
249
249
|
const n = e.colorExtras;
|
|
250
250
|
if (!n) return;
|
|
251
|
-
const
|
|
252
|
-
(
|
|
251
|
+
const a = e.tiers.find(
|
|
252
|
+
(i) => !i.referencesTier && !i.semantic && i.items.length > 0 && i.items[0].type.kind === "color"
|
|
253
253
|
), g = e.tiers.find(
|
|
254
|
-
(
|
|
254
|
+
(i) => a && i.referencesTier === a.id || i.semantic === !0
|
|
255
255
|
);
|
|
256
|
-
if (!
|
|
256
|
+
if (!a && !g)
|
|
257
257
|
return {
|
|
258
258
|
id: n.id,
|
|
259
259
|
label: n.label,
|
|
@@ -267,28 +267,28 @@ function R(e, t = [e]) {
|
|
|
267
267
|
colorSchemes: n.colorSchemes,
|
|
268
268
|
panelSettings: n.panelSettings
|
|
269
269
|
};
|
|
270
|
-
const c =
|
|
271
|
-
for (let
|
|
272
|
-
|
|
270
|
+
const c = a?.items ?? [], o = c.length, s = c[0] ? c[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", l = /* @__PURE__ */ new Map();
|
|
271
|
+
for (let i = 0; i < c.length; i++)
|
|
272
|
+
l.set(c[i].id, i);
|
|
273
273
|
const f = {}, r = {};
|
|
274
274
|
if (g) {
|
|
275
|
-
const
|
|
275
|
+
const i = !g.semantic, u = n.semanticDefaults;
|
|
276
276
|
for (const d of g.items)
|
|
277
|
-
r[d.id] = d.cssVar, f[d.id] = K(
|
|
277
|
+
r[d.id] = d.cssVar, f[d.id] = u && d.id in u ? u[d.id] : K(
|
|
278
278
|
d,
|
|
279
|
-
|
|
279
|
+
l,
|
|
280
280
|
g.referencesRamps,
|
|
281
281
|
e,
|
|
282
282
|
t,
|
|
283
|
-
|
|
283
|
+
i
|
|
284
284
|
);
|
|
285
285
|
}
|
|
286
286
|
return {
|
|
287
287
|
id: n.id,
|
|
288
288
|
label: n.label,
|
|
289
|
-
paletteSize:
|
|
289
|
+
paletteSize: o,
|
|
290
290
|
baseRoles: n.baseRoles,
|
|
291
|
-
paletteCssVarTemplate:
|
|
291
|
+
paletteCssVarTemplate: s,
|
|
292
292
|
semanticDefaults: f,
|
|
293
293
|
semanticCssNames: r,
|
|
294
294
|
baseDefaults: n.baseDefaults,
|
|
@@ -297,34 +297,34 @@ function R(e, t = [e]) {
|
|
|
297
297
|
panelSettings: n.panelSettings
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function Q(e) {
|
|
301
301
|
const t = e.find((n) => n.id === "color");
|
|
302
302
|
if (t)
|
|
303
|
-
return
|
|
303
|
+
return V(t, e);
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function L(e) {
|
|
306
306
|
const t = e.find((n) => n.id === "color-secondary");
|
|
307
|
-
return t ?
|
|
307
|
+
return t ? V(t, e) ?? null : null;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function S(e, t) {
|
|
310
310
|
if (Object.is(e, t)) return !0;
|
|
311
311
|
if (e === null || t === null || typeof e != typeof t || typeof e != "object") return !1;
|
|
312
312
|
if (Array.isArray(e)) {
|
|
313
313
|
if (!Array.isArray(t) || e.length !== t.length) return !1;
|
|
314
314
|
for (let c = 0; c < e.length; c++)
|
|
315
|
-
if (!
|
|
315
|
+
if (!S(e[c], t[c])) return !1;
|
|
316
316
|
return !0;
|
|
317
317
|
}
|
|
318
318
|
if (Array.isArray(t)) return !1;
|
|
319
|
-
const n = Object.keys(e),
|
|
320
|
-
if (n.length !==
|
|
321
|
-
const g = new Set(
|
|
319
|
+
const n = Object.keys(e), a = Object.keys(t);
|
|
320
|
+
if (n.length !== a.length) return !1;
|
|
321
|
+
const g = new Set(a);
|
|
322
322
|
for (const c of n)
|
|
323
|
-
if (!g.has(c) || !
|
|
323
|
+
if (!g.has(c) || !S(e[c], t[c]))
|
|
324
324
|
return !1;
|
|
325
325
|
return !0;
|
|
326
326
|
}
|
|
327
|
-
const
|
|
327
|
+
const _ = {
|
|
328
328
|
storagePrefix: "zudo-design-token-panel",
|
|
329
329
|
consoleNamespace: "zudo",
|
|
330
330
|
modalClassPrefix: "zudo-design-token-panel-modal",
|
|
@@ -336,33 +336,34 @@ const V = {
|
|
|
336
336
|
// No bundled apply endpoint / routing — hosts wire their own.
|
|
337
337
|
applyEndpoint: void 0,
|
|
338
338
|
applyRouting: void 0
|
|
339
|
-
},
|
|
340
|
-
function
|
|
339
|
+
}, R = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:singleton");
|
|
340
|
+
function m() {
|
|
341
341
|
const e = globalThis;
|
|
342
|
-
let t = e[
|
|
342
|
+
let t = e[R];
|
|
343
343
|
return t || (t = {
|
|
344
344
|
instances: /* @__PURE__ */ new Map(),
|
|
345
345
|
defaultPrefix: null,
|
|
346
346
|
pendingColorPresets: null,
|
|
347
347
|
pendingPostConfigureHooks: [],
|
|
348
|
-
lifecycleHooks: {}
|
|
349
|
-
|
|
348
|
+
lifecycleHooks: {},
|
|
349
|
+
colorSchemeOwners: /* @__PURE__ */ new Set()
|
|
350
|
+
}, e[R] = t), t;
|
|
350
351
|
}
|
|
351
|
-
function
|
|
352
|
+
function F(e) {
|
|
352
353
|
return {
|
|
353
354
|
instanceId: e,
|
|
354
355
|
open() {
|
|
355
|
-
|
|
356
|
+
m().lifecycleHooks.open?.(e);
|
|
356
357
|
},
|
|
357
358
|
close() {
|
|
358
|
-
|
|
359
|
+
m().lifecycleHooks.close?.(e);
|
|
359
360
|
},
|
|
360
361
|
toggle() {
|
|
361
|
-
|
|
362
|
+
m().lifecycleHooks.toggle?.(e);
|
|
362
363
|
},
|
|
363
364
|
destroy() {
|
|
364
|
-
|
|
365
|
-
const t =
|
|
365
|
+
m().lifecycleHooks.destroy?.(e);
|
|
366
|
+
const t = m();
|
|
366
367
|
if (t.instances.delete(e), t.defaultPrefix === e) {
|
|
367
368
|
const n = [...t.instances.keys()];
|
|
368
369
|
t.defaultPrefix = n.length > 0 ? n[n.length - 1] : null;
|
|
@@ -371,7 +372,7 @@ function D(e) {
|
|
|
371
372
|
};
|
|
372
373
|
}
|
|
373
374
|
function I(e) {
|
|
374
|
-
|
|
375
|
+
m().lifecycleHooks = {
|
|
375
376
|
configured: e.configured,
|
|
376
377
|
open: e.open,
|
|
377
378
|
close: e.close,
|
|
@@ -379,110 +380,140 @@ function I(e) {
|
|
|
379
380
|
destroy: e.destroy
|
|
380
381
|
};
|
|
381
382
|
}
|
|
382
|
-
function
|
|
383
|
-
const t =
|
|
384
|
-
if (
|
|
383
|
+
function ee(e) {
|
|
384
|
+
const t = m(), n = e.storagePrefix, a = t.instances.get(n);
|
|
385
|
+
if (a) {
|
|
385
386
|
const f = (r) => ({ ...r, applySink: void 0 });
|
|
386
|
-
if (
|
|
387
|
-
return t.defaultPrefix = n,
|
|
387
|
+
if (S(f(a.suppliedConfig), f(e)))
|
|
388
|
+
return t.defaultPrefix = n, a.handle;
|
|
388
389
|
throw new Error(
|
|
389
390
|
`[design-token-panel] configurePanel() was already called with different values for storagePrefix "${n}". Configuration is one-shot per prefix per page lifecycle. To re-configure this prefix, call handle.destroy() first, then configurePanel() again. (Use a distinct storagePrefix for a second panel instance.)`
|
|
390
391
|
);
|
|
391
392
|
}
|
|
392
393
|
const g = t.pendingColorPresets, c = g ? { ...e, colorPresets: g } : { ...e };
|
|
393
394
|
t.pendingColorPresets = null;
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
const
|
|
395
|
+
const o = t.instances.size === 0, s = o ? [...t.pendingPostConfigureHooks] : [];
|
|
396
|
+
o && (t.pendingPostConfigureHooks.length = 0);
|
|
397
|
+
const l = {
|
|
397
398
|
config: c,
|
|
398
399
|
// Snapshot the as-supplied config before any runtime merges. Used by the
|
|
399
400
|
// idempotency guard so view-transition re-calls with the original inline
|
|
400
401
|
// config keep passing even after setPanelColorPresets mutates `config`.
|
|
401
402
|
suppliedConfig: { ...e },
|
|
402
403
|
pendingColorPresets: null,
|
|
403
|
-
postConfigureHooks:
|
|
404
|
-
handle:
|
|
404
|
+
postConfigureHooks: s,
|
|
405
|
+
handle: F(n)
|
|
405
406
|
};
|
|
406
|
-
t.instances.set(n,
|
|
407
|
-
for (const f of
|
|
407
|
+
t.instances.set(n, l), t.defaultPrefix = n;
|
|
408
|
+
for (const f of l.postConfigureHooks)
|
|
408
409
|
f();
|
|
409
|
-
return t.lifecycleHooks.configured?.(n),
|
|
410
|
+
return t.lifecycleHooks.configured?.(n), l.handle;
|
|
410
411
|
}
|
|
411
412
|
function x() {
|
|
412
|
-
const e =
|
|
413
|
+
const e = m();
|
|
413
414
|
return e.defaultPrefix === null ? null : e.instances.get(e.defaultPrefix) ?? null;
|
|
414
415
|
}
|
|
415
|
-
function
|
|
416
|
+
function te(e) {
|
|
416
417
|
const t = x();
|
|
417
418
|
if (t === null) {
|
|
418
|
-
const n =
|
|
419
|
+
const n = m();
|
|
419
420
|
if (n.pendingPostConfigureHooks.includes(e)) return;
|
|
420
421
|
n.pendingPostConfigureHooks.push(e);
|
|
421
422
|
return;
|
|
422
423
|
}
|
|
423
424
|
t.postConfigureHooks.includes(e) || (t.postConfigureHooks.push(e), e());
|
|
424
425
|
}
|
|
425
|
-
function
|
|
426
|
-
return x()?.config ??
|
|
426
|
+
function D() {
|
|
427
|
+
return x()?.config ?? _;
|
|
427
428
|
}
|
|
428
|
-
function
|
|
429
|
-
return [...
|
|
429
|
+
function ne() {
|
|
430
|
+
return [...m().instances.values()].map((e) => e.config);
|
|
430
431
|
}
|
|
431
|
-
function
|
|
432
|
-
return
|
|
432
|
+
function re(e) {
|
|
433
|
+
return m().instances.get(e)?.config ?? null;
|
|
433
434
|
}
|
|
434
|
-
function
|
|
435
|
-
const e =
|
|
436
|
-
e.instances.clear(), e.defaultPrefix = null, e.pendingColorPresets = null, e.pendingPostConfigureHooks.length = 0;
|
|
435
|
+
function ie() {
|
|
436
|
+
const e = m();
|
|
437
|
+
e.instances.clear(), e.defaultPrefix = null, e.pendingColorPresets = null, e.pendingPostConfigureHooks.length = 0, v().clear();
|
|
437
438
|
}
|
|
438
|
-
function
|
|
439
|
-
|
|
439
|
+
function v() {
|
|
440
|
+
const e = m();
|
|
441
|
+
return e.colorSchemeOwners || (e.colorSchemeOwners = /* @__PURE__ */ new Set()), e.colorSchemeOwners;
|
|
440
442
|
}
|
|
441
|
-
function
|
|
443
|
+
function oe(e) {
|
|
444
|
+
v().add(e);
|
|
445
|
+
}
|
|
446
|
+
function se(e) {
|
|
447
|
+
v().delete(e);
|
|
448
|
+
}
|
|
449
|
+
function ae(e) {
|
|
450
|
+
return v().has(e);
|
|
451
|
+
}
|
|
452
|
+
function le(e = D()) {
|
|
453
|
+
return L(e.tabs);
|
|
454
|
+
}
|
|
455
|
+
function fe(e) {
|
|
442
456
|
return `${e.storagePrefix}-state-v2`;
|
|
443
457
|
}
|
|
444
|
-
function
|
|
458
|
+
function ce(e) {
|
|
445
459
|
return `${e.storagePrefix}-state-v3`;
|
|
446
460
|
}
|
|
447
|
-
function
|
|
461
|
+
function ge(e) {
|
|
462
|
+
return `${e.storagePrefix}-state-v4`;
|
|
463
|
+
}
|
|
464
|
+
function ue(e) {
|
|
448
465
|
return `${e.storagePrefix}-state`;
|
|
449
466
|
}
|
|
450
|
-
function
|
|
467
|
+
function de(e) {
|
|
451
468
|
return `${e.storagePrefix}-open`;
|
|
452
469
|
}
|
|
453
|
-
function
|
|
470
|
+
function pe(e) {
|
|
454
471
|
return `${e.storagePrefix}-position`;
|
|
455
472
|
}
|
|
456
|
-
function
|
|
473
|
+
function ye(e) {
|
|
457
474
|
return `${e.storagePrefix}-size`;
|
|
458
475
|
}
|
|
459
|
-
function
|
|
476
|
+
function me(e) {
|
|
460
477
|
return `${e.storagePrefix}-density`;
|
|
461
478
|
}
|
|
462
|
-
function
|
|
479
|
+
function he(e) {
|
|
463
480
|
return `${e.storagePrefix}:visible`;
|
|
464
481
|
}
|
|
465
|
-
function
|
|
482
|
+
function be(e) {
|
|
466
483
|
return `${e.storagePrefix}:autoload`;
|
|
467
484
|
}
|
|
468
|
-
function
|
|
485
|
+
function we(e) {
|
|
469
486
|
return `${e.storagePrefix}-root`;
|
|
470
487
|
}
|
|
471
|
-
const
|
|
472
|
-
function
|
|
473
|
-
return e.storagePrefix ===
|
|
488
|
+
const J = _.storagePrefix, q = "toggle-design-token-panel";
|
|
489
|
+
function ke(e) {
|
|
490
|
+
return e.storagePrefix === J ? q : e.toggleEvent ?? `toggle-${e.storagePrefix}`;
|
|
474
491
|
}
|
|
475
|
-
const
|
|
476
|
-
function
|
|
477
|
-
return `${
|
|
492
|
+
const G = "__zdtp:open-state-changed";
|
|
493
|
+
function $e(e) {
|
|
494
|
+
return `${G}:${e.storagePrefix}`;
|
|
478
495
|
}
|
|
479
|
-
function
|
|
496
|
+
function Pe(e, t) {
|
|
480
497
|
return `${e.modalClassPrefix}${t}`;
|
|
481
498
|
}
|
|
482
|
-
function
|
|
499
|
+
function Ce(e) {
|
|
483
500
|
return `${e.exportFilenameBase}.json`;
|
|
484
501
|
}
|
|
485
|
-
|
|
502
|
+
const O = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:global-alias-marker");
|
|
503
|
+
function Ee(e) {
|
|
504
|
+
if (typeof window > "u") return;
|
|
505
|
+
const t = window, n = t.zdtp;
|
|
506
|
+
if (n !== void 0) {
|
|
507
|
+
if ((typeof n == "object" || typeof n == "function") && n !== null && n[O] === !0) return;
|
|
508
|
+
console.warn(
|
|
509
|
+
"[design-token-panel] window.zdtp already exists and was not installed by this package. Skipping the zdtp.show() / zdtp.hide() / zdtp.toggle() global alias to avoid clobbering it. Use window[consoleNamespace].* or the configurePanel(cfg) handle instead."
|
|
510
|
+
);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const a = { ...e };
|
|
514
|
+
a[O] = !0, t.zdtp = a;
|
|
515
|
+
}
|
|
516
|
+
function ve(e) {
|
|
486
517
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
487
518
|
throw new Error("[design-token-panel] PanelConfig must be a non-null object");
|
|
488
519
|
const t = e;
|
|
@@ -497,7 +528,7 @@ function he(e) {
|
|
|
497
528
|
throw new Error(
|
|
498
529
|
`[design-token-panel] PanelConfig.${n} must be a non-empty string (got ${typeof t[n]})`
|
|
499
530
|
);
|
|
500
|
-
if (
|
|
531
|
+
if (B(t.tabs), t.toggleEvent !== void 0 && (typeof t.toggleEvent != "string" || t.toggleEvent.length === 0))
|
|
501
532
|
throw new Error(
|
|
502
533
|
`[design-token-panel] PanelConfig.toggleEvent must be a non-empty string when set (got ${typeof t.toggleEvent})`
|
|
503
534
|
);
|
|
@@ -508,8 +539,8 @@ function he(e) {
|
|
|
508
539
|
if (t.applyRouting !== void 0) {
|
|
509
540
|
if (t.applyRouting === null || typeof t.applyRouting != "object" || Array.isArray(t.applyRouting))
|
|
510
541
|
throw new Error("[design-token-panel] PanelConfig.applyRouting must be a plain object");
|
|
511
|
-
for (const [n,
|
|
512
|
-
if (typeof
|
|
542
|
+
for (const [n, a] of Object.entries(t.applyRouting))
|
|
543
|
+
if (typeof a != "string")
|
|
513
544
|
throw new Error(
|
|
514
545
|
`[design-token-panel] PanelConfig.applyRouting[${JSON.stringify(n)}] must be a string`
|
|
515
546
|
);
|
|
@@ -517,87 +548,106 @@ function he(e) {
|
|
|
517
548
|
if (t.legacyIdRenameMap !== void 0) {
|
|
518
549
|
if (t.legacyIdRenameMap === null || typeof t.legacyIdRenameMap != "object" || Array.isArray(t.legacyIdRenameMap))
|
|
519
550
|
throw new Error("[design-token-panel] PanelConfig.legacyIdRenameMap must be a plain object");
|
|
520
|
-
for (const [n,
|
|
521
|
-
if (
|
|
551
|
+
for (const [n, a] of Object.entries(t.legacyIdRenameMap))
|
|
552
|
+
if (a !== null && typeof a != "string")
|
|
522
553
|
throw new Error(
|
|
523
|
-
`[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof
|
|
554
|
+
`[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof a})`
|
|
524
555
|
);
|
|
525
556
|
}
|
|
526
557
|
}
|
|
527
|
-
function
|
|
558
|
+
function B(e) {
|
|
528
559
|
if (!Array.isArray(e))
|
|
529
560
|
throw new Error("[design-token-panel] PanelConfig.tabs must be an array");
|
|
530
561
|
const t = /* @__PURE__ */ new Set();
|
|
531
562
|
for (const n of e) {
|
|
532
563
|
if (n === null || typeof n != "object" || Array.isArray(n))
|
|
533
564
|
throw new Error("[design-token-panel] PanelConfig.tabs: each tab must be a non-null object");
|
|
534
|
-
const
|
|
535
|
-
if (typeof
|
|
565
|
+
const a = n;
|
|
566
|
+
if (typeof a.id != "string" || a.id.length === 0)
|
|
536
567
|
throw new Error("[design-token-panel] PanelConfig.tabs: each tab must have a non-empty string id");
|
|
537
|
-
if (t.has(
|
|
568
|
+
if (t.has(a.id))
|
|
538
569
|
throw new Error(
|
|
539
|
-
`[design-token-panel] PanelConfig.tabs: duplicate tab id "${
|
|
570
|
+
`[design-token-panel] PanelConfig.tabs: duplicate tab id "${a.id}"`
|
|
540
571
|
);
|
|
541
|
-
t.add(
|
|
572
|
+
t.add(a.id), W(a.id, a, e);
|
|
542
573
|
}
|
|
543
574
|
}
|
|
544
|
-
function
|
|
575
|
+
function U(e) {
|
|
576
|
+
if (typeof e == "number" || e === "bg" || e === "fg") return !0;
|
|
577
|
+
if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
|
|
578
|
+
const t = e;
|
|
579
|
+
if ("literal" in t) {
|
|
580
|
+
const n = t.literal;
|
|
581
|
+
if (typeof n == "string") return !0;
|
|
582
|
+
if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
|
|
583
|
+
const a = n;
|
|
584
|
+
return typeof a.light == "string" && typeof a.dark == "string";
|
|
585
|
+
}
|
|
586
|
+
if ("ref" in t) {
|
|
587
|
+
const n = t.ref;
|
|
588
|
+
if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
|
|
589
|
+
const a = n;
|
|
590
|
+
return !(typeof a.tier != "string" || typeof a.item != "string" || a.tab !== void 0 && typeof a.tab != "string");
|
|
591
|
+
}
|
|
592
|
+
return !1;
|
|
593
|
+
}
|
|
594
|
+
function W(e, t, n) {
|
|
545
595
|
if (!Array.isArray(t.tiers))
|
|
546
596
|
throw new Error(
|
|
547
597
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers must be an array`
|
|
548
598
|
);
|
|
549
|
-
const
|
|
550
|
-
for (const
|
|
551
|
-
if (
|
|
599
|
+
const a = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
|
|
600
|
+
for (const o of t.tiers) {
|
|
601
|
+
if (o === null || typeof o != "object" || Array.isArray(o))
|
|
552
602
|
throw new Error(
|
|
553
603
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must be a non-null object`
|
|
554
604
|
);
|
|
555
|
-
const
|
|
556
|
-
if (typeof
|
|
605
|
+
const s = o;
|
|
606
|
+
if (typeof s.id != "string" || s.id.length === 0)
|
|
557
607
|
throw new Error(
|
|
558
608
|
`[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must have a non-empty string id`
|
|
559
609
|
);
|
|
560
|
-
if (
|
|
610
|
+
if (a.has(s.id))
|
|
561
611
|
throw new Error(
|
|
562
|
-
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${
|
|
612
|
+
`[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${s.id}"`
|
|
563
613
|
);
|
|
564
|
-
if (
|
|
614
|
+
if (a.add(s.id), s.semantic !== void 0 && s.semantic !== !0)
|
|
565
615
|
throw new Error(
|
|
566
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
616
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(s.semantic)})`
|
|
567
617
|
);
|
|
568
|
-
if (!Array.isArray(
|
|
618
|
+
if (!Array.isArray(s.items))
|
|
569
619
|
throw new Error(
|
|
570
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
620
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"].items must be an array`
|
|
571
621
|
);
|
|
572
|
-
let
|
|
573
|
-
for (const f of
|
|
622
|
+
let l;
|
|
623
|
+
for (const f of s.items) {
|
|
574
624
|
if (f === null || typeof f != "object" || Array.isArray(f)) continue;
|
|
575
|
-
const
|
|
576
|
-
if (
|
|
577
|
-
const
|
|
578
|
-
if (typeof
|
|
579
|
-
if (
|
|
580
|
-
|
|
581
|
-
else if (
|
|
625
|
+
const i = f.type;
|
|
626
|
+
if (i === null || typeof i != "object" || Array.isArray(i)) continue;
|
|
627
|
+
const u = i.kind;
|
|
628
|
+
if (typeof u == "string") {
|
|
629
|
+
if (l === void 0)
|
|
630
|
+
l = u;
|
|
631
|
+
else if (l !== u)
|
|
582
632
|
throw new Error(
|
|
583
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
633
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"]: mixed item kinds — found "${l}" and "${u}" in the same tier (all items must share the same kind)`
|
|
584
634
|
);
|
|
585
635
|
}
|
|
586
636
|
}
|
|
587
|
-
|
|
637
|
+
l !== void 0 && g.set(s.id, l);
|
|
588
638
|
}
|
|
589
639
|
const c = /* @__PURE__ */ new Set();
|
|
590
|
-
for (const
|
|
591
|
-
const
|
|
592
|
-
for (const f of
|
|
640
|
+
for (const o of t.tiers) {
|
|
641
|
+
const s = o, l = s.id;
|
|
642
|
+
for (const f of s.items) {
|
|
593
643
|
if (f === null || typeof f != "object" || Array.isArray(f))
|
|
594
644
|
throw new Error(
|
|
595
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
645
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items: each item must be a non-null object`
|
|
596
646
|
);
|
|
597
647
|
const r = f;
|
|
598
648
|
if (typeof r.id != "string" || r.id.length === 0)
|
|
599
649
|
throw new Error(
|
|
600
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
650
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items: each item must have a non-empty string id`
|
|
601
651
|
);
|
|
602
652
|
if (c.has(r.id))
|
|
603
653
|
throw new Error(
|
|
@@ -605,220 +655,280 @@ function B(e, t, n) {
|
|
|
605
655
|
);
|
|
606
656
|
if (c.add(r.id), typeof r.cssVar != "string" || !r.cssVar.startsWith("--"))
|
|
607
657
|
throw new Error(
|
|
608
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
658
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].cssVar must start with "--" (got ${JSON.stringify(r.cssVar)})`
|
|
609
659
|
);
|
|
610
660
|
if (r.cssVar.length <= 2)
|
|
611
661
|
throw new Error(
|
|
612
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
662
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].cssVar must be non-empty after "--"`
|
|
613
663
|
);
|
|
664
|
+
const i = r.type;
|
|
665
|
+
if (i !== null && typeof i == "object" && !Array.isArray(i) && i.kind === "length" && i.units !== void 0) {
|
|
666
|
+
const u = i.units;
|
|
667
|
+
if (!Array.isArray(u))
|
|
668
|
+
throw new Error(
|
|
669
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units must be an array`
|
|
670
|
+
);
|
|
671
|
+
const d = /* @__PURE__ */ new Set();
|
|
672
|
+
for (const p of u) {
|
|
673
|
+
if (typeof p != "string" || p.length === 0)
|
|
674
|
+
throw new Error(
|
|
675
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(p)})`
|
|
676
|
+
);
|
|
677
|
+
if (d.has(p))
|
|
678
|
+
throw new Error(
|
|
679
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units: duplicate unit ${JSON.stringify(p)}`
|
|
680
|
+
);
|
|
681
|
+
d.add(p);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
614
684
|
}
|
|
615
685
|
}
|
|
616
|
-
for (const
|
|
617
|
-
const
|
|
618
|
-
if (
|
|
619
|
-
if (typeof
|
|
686
|
+
for (const o of t.tiers) {
|
|
687
|
+
const s = o, l = s.id;
|
|
688
|
+
if (s.referencesTier !== void 0) {
|
|
689
|
+
if (typeof s.referencesTier != "string")
|
|
620
690
|
throw new Error(
|
|
621
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
691
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier must be a string`
|
|
622
692
|
);
|
|
623
|
-
const f =
|
|
624
|
-
if (!
|
|
693
|
+
const f = s.referencesTier;
|
|
694
|
+
if (!a.has(f))
|
|
625
695
|
throw new Error(
|
|
626
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
696
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: tier "${f}" does not exist in this tab`
|
|
627
697
|
);
|
|
628
|
-
const r = g.get(
|
|
629
|
-
if (r !== void 0 &&
|
|
698
|
+
const r = g.get(l), i = g.get(f);
|
|
699
|
+
if (r !== void 0 && i !== void 0 && r !== "text" && r !== i)
|
|
630
700
|
throw new Error(
|
|
631
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
701
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: referencing tier has kind "${r}" but referenced tier "${f}" has kind "${i}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
|
|
632
702
|
);
|
|
633
703
|
}
|
|
634
704
|
}
|
|
635
|
-
for (const
|
|
636
|
-
const
|
|
637
|
-
if (
|
|
638
|
-
if (
|
|
705
|
+
for (const o of t.tiers) {
|
|
706
|
+
const s = o, l = s.id;
|
|
707
|
+
if (s.referencesRamps === void 0) continue;
|
|
708
|
+
if (s.semantic !== !0)
|
|
639
709
|
throw new Error(
|
|
640
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
710
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps is only valid on a tier with semantic: true`
|
|
641
711
|
);
|
|
642
|
-
if (!Array.isArray(
|
|
712
|
+
if (!Array.isArray(s.referencesRamps))
|
|
643
713
|
throw new Error(
|
|
644
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
714
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps must be an array`
|
|
645
715
|
);
|
|
646
|
-
const f = g.get(
|
|
647
|
-
for (let
|
|
648
|
-
const
|
|
649
|
-
if (
|
|
716
|
+
const f = g.get(l), r = s.referencesRamps;
|
|
717
|
+
for (let i = 0; i < r.length; i++) {
|
|
718
|
+
const u = r[i];
|
|
719
|
+
if (u === null || typeof u != "object" || Array.isArray(u))
|
|
650
720
|
throw new Error(
|
|
651
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
721
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}] must be a non-null object`
|
|
652
722
|
);
|
|
653
|
-
const
|
|
654
|
-
if (typeof
|
|
723
|
+
const d = u;
|
|
724
|
+
if (typeof d.tier != "string" || d.tier.length === 0)
|
|
655
725
|
throw new Error(
|
|
656
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
726
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tier must be a non-empty string`
|
|
657
727
|
);
|
|
658
|
-
if (
|
|
728
|
+
if (d.tab !== void 0 && (typeof d.tab != "string" || d.tab.length === 0))
|
|
659
729
|
throw new Error(
|
|
660
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
730
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tab must be a non-empty string when set`
|
|
661
731
|
);
|
|
662
|
-
const
|
|
732
|
+
const p = d.tab === void 0 ? e : d.tab;
|
|
663
733
|
let k;
|
|
664
|
-
if (
|
|
734
|
+
if (p === e)
|
|
665
735
|
k = t;
|
|
666
736
|
else {
|
|
667
737
|
const b = n.find(
|
|
668
|
-
(
|
|
738
|
+
(y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === p
|
|
669
739
|
);
|
|
670
740
|
if (!b) {
|
|
671
|
-
const
|
|
741
|
+
const y = n.filter((h) => h !== null && typeof h == "object" && !Array.isArray(h)).map((h) => h.id).join(", ");
|
|
672
742
|
throw new Error(
|
|
673
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
743
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tab "${p}" does not exist. Available tabs: ${y}.`
|
|
674
744
|
);
|
|
675
745
|
}
|
|
676
746
|
k = b;
|
|
677
747
|
}
|
|
678
|
-
const P = Array.isArray(k.tiers) ? k.tiers : [],
|
|
748
|
+
const P = Array.isArray(k.tiers) ? k.tiers : [], j = [];
|
|
679
749
|
let C;
|
|
680
750
|
for (const b of P) {
|
|
681
751
|
if (b === null || typeof b != "object" || Array.isArray(b)) continue;
|
|
682
|
-
const
|
|
683
|
-
typeof
|
|
752
|
+
const y = b;
|
|
753
|
+
typeof y.id == "string" && (j.push(y.id), y.id === d.tier && (C = y));
|
|
684
754
|
}
|
|
685
755
|
if (!C)
|
|
686
756
|
throw new Error(
|
|
687
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
757
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tier "${d.tier}" does not exist in tab "${p}". Available tiers: ${j.join(", ")}.`
|
|
688
758
|
);
|
|
689
759
|
if (f !== void 0) {
|
|
690
760
|
const b = Array.isArray(C.items) ? C.items : [];
|
|
691
|
-
let
|
|
761
|
+
let y;
|
|
692
762
|
for (const h of b) {
|
|
693
763
|
if (h === null || typeof h != "object" || Array.isArray(h)) continue;
|
|
694
|
-
const
|
|
695
|
-
if (
|
|
696
|
-
const T =
|
|
764
|
+
const E = h.type;
|
|
765
|
+
if (E === null || typeof E != "object" || Array.isArray(E)) continue;
|
|
766
|
+
const T = E.kind;
|
|
697
767
|
if (typeof T == "string") {
|
|
698
|
-
|
|
768
|
+
y = T;
|
|
699
769
|
break;
|
|
700
770
|
}
|
|
701
771
|
}
|
|
702
|
-
if (
|
|
772
|
+
if (y !== void 0 && f !== y)
|
|
703
773
|
throw new Error(
|
|
704
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${
|
|
774
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: referencing semantic tier has kind "${f}" but target tier "${d.tier}" in tab "${p}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
|
|
705
775
|
);
|
|
706
776
|
}
|
|
707
777
|
}
|
|
708
778
|
}
|
|
709
779
|
if (t.colorExtras !== void 0) {
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
780
|
+
const o = t.colorExtras;
|
|
781
|
+
if (o === null || typeof o != "object" || Array.isArray(o))
|
|
712
782
|
throw new Error(
|
|
713
783
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras must be a plain object`
|
|
714
784
|
);
|
|
715
785
|
for (const r of ["id", "defaultShikiTheme"])
|
|
716
|
-
if (typeof
|
|
786
|
+
if (typeof o[r] != "string" || o[r].length === 0)
|
|
717
787
|
throw new Error(
|
|
718
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof
|
|
788
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof o[r]})`
|
|
719
789
|
);
|
|
720
790
|
for (const r of ["colorSchemes", "baseRoles", "baseDefaults"])
|
|
721
|
-
if (
|
|
791
|
+
if (o[r] === void 0 || o[r] === null || typeof o[r] != "object" || Array.isArray(o[r]))
|
|
722
792
|
throw new Error(
|
|
723
793
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a plain object`
|
|
724
794
|
);
|
|
725
|
-
if (
|
|
795
|
+
if (o.panelSettings === void 0 || o.panelSettings === null || typeof o.panelSettings != "object" || Array.isArray(o.panelSettings))
|
|
726
796
|
throw new Error(
|
|
727
797
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings must be a plain object`
|
|
728
798
|
);
|
|
729
|
-
const
|
|
730
|
-
if (typeof
|
|
799
|
+
const s = o.panelSettings;
|
|
800
|
+
if (typeof s.colorScheme != "string" || s.colorScheme.length === 0)
|
|
731
801
|
throw new Error(
|
|
732
802
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorScheme must be a non-empty string`
|
|
733
803
|
);
|
|
734
|
-
if (
|
|
735
|
-
if (
|
|
804
|
+
if (s.colorMode !== !1) {
|
|
805
|
+
if (s.colorMode === null || typeof s.colorMode != "object" || Array.isArray(s.colorMode))
|
|
736
806
|
throw new Error(
|
|
737
807
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode must be false or a plain object`
|
|
738
808
|
);
|
|
739
|
-
const r =
|
|
740
|
-
for (const
|
|
741
|
-
if (typeof r[
|
|
809
|
+
const r = s.colorMode;
|
|
810
|
+
for (const i of ["lightScheme", "darkScheme"])
|
|
811
|
+
if (typeof r[i] != "string" || r[i].length === 0)
|
|
742
812
|
throw new Error(
|
|
743
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${
|
|
813
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${i} must be a non-empty string`
|
|
744
814
|
);
|
|
745
815
|
if (r.defaultMode !== "light" && r.defaultMode !== "dark")
|
|
746
816
|
throw new Error(
|
|
747
817
|
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(r.defaultMode)})`
|
|
748
818
|
);
|
|
749
819
|
}
|
|
820
|
+
if (o.semanticDefaults !== void 0) {
|
|
821
|
+
if (o.semanticDefaults === null || typeof o.semanticDefaults != "object" || Array.isArray(o.semanticDefaults))
|
|
822
|
+
throw new Error(
|
|
823
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults must be a plain object`
|
|
824
|
+
);
|
|
825
|
+
const r = o.semanticDefaults;
|
|
826
|
+
for (const [i, u] of Object.entries(r))
|
|
827
|
+
if (!U(u))
|
|
828
|
+
throw new Error(
|
|
829
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${i}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(u)}`
|
|
830
|
+
);
|
|
831
|
+
}
|
|
750
832
|
const f = t.tiers.find((r) => {
|
|
751
833
|
if (r.referencesTier !== void 0 || r.semantic === !0) return !1;
|
|
752
|
-
const
|
|
753
|
-
if (!Array.isArray(
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
const
|
|
757
|
-
return
|
|
834
|
+
const i = r.items;
|
|
835
|
+
if (!Array.isArray(i) || i.length === 0) return !1;
|
|
836
|
+
const u = i[0];
|
|
837
|
+
if (u === null || typeof u != "object" || Array.isArray(u)) return !1;
|
|
838
|
+
const d = u.type;
|
|
839
|
+
return d === null || typeof d != "object" || Array.isArray(d) ? !1 : d.kind === "color";
|
|
758
840
|
});
|
|
759
841
|
if (f) {
|
|
760
|
-
const r = f.id,
|
|
761
|
-
if (
|
|
762
|
-
const
|
|
763
|
-
if (
|
|
764
|
-
for (let
|
|
765
|
-
const k =
|
|
842
|
+
const r = f.id, i = f.items, u = i[0]?.cssVar;
|
|
843
|
+
if (u !== void 0) {
|
|
844
|
+
const d = u.replace(/\d+$/, "{n}");
|
|
845
|
+
if (d.includes("{n}"))
|
|
846
|
+
for (let p = 0; p < i.length; p++) {
|
|
847
|
+
const k = i[p], P = d.replace("{n}", String(p));
|
|
766
848
|
if (k.cssVar !== P)
|
|
767
849
|
throw new Error(
|
|
768
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[${
|
|
850
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[${p}].cssVar is ${JSON.stringify(k.cssVar)} but expected ${JSON.stringify(P)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(d)})`
|
|
769
851
|
);
|
|
770
852
|
}
|
|
771
|
-
else if (
|
|
853
|
+
else if (i.length > 1)
|
|
772
854
|
throw new Error(
|
|
773
|
-
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[0].cssVar ${JSON.stringify(
|
|
855
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[0].cssVar ${JSON.stringify(u)} has no trailing digit — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (e.g. "--pal-0" … "--pal-15")`
|
|
774
856
|
);
|
|
775
857
|
}
|
|
776
858
|
}
|
|
777
859
|
}
|
|
860
|
+
if (e === "notes") {
|
|
861
|
+
if (t.tiers.length > 0)
|
|
862
|
+
throw new Error(
|
|
863
|
+
'[design-token-panel] PanelConfig.tabs["notes"].tiers must be empty — the notes tab does not hold token tiers'
|
|
864
|
+
);
|
|
865
|
+
if (t.colorExtras !== void 0)
|
|
866
|
+
throw new Error(
|
|
867
|
+
'[design-token-panel] PanelConfig.tabs["notes"].colorExtras must not be set — the notes tab does not carry token config'
|
|
868
|
+
);
|
|
869
|
+
if (t.notesExtras === void 0 || t.notesExtras === null || typeof t.notesExtras != "object" || Array.isArray(t.notesExtras))
|
|
870
|
+
throw new Error(
|
|
871
|
+
'[design-token-panel] PanelConfig.tabs["notes"].notesExtras must be a plain object with { title, html }'
|
|
872
|
+
);
|
|
873
|
+
const o = t.notesExtras;
|
|
874
|
+
for (const s of ["title", "html"])
|
|
875
|
+
if (typeof o[s] != "string" || o[s].length === 0)
|
|
876
|
+
throw new Error(
|
|
877
|
+
`[design-token-panel] PanelConfig.tabs["notes"].notesExtras.${s} must be a non-empty string (got ${typeof o[s]})`
|
|
878
|
+
);
|
|
879
|
+
} else if (t.notesExtras !== void 0)
|
|
880
|
+
throw new Error(
|
|
881
|
+
`[design-token-panel] PanelConfig.tabs["${e}"].notesExtras must only be set on a tab with id "notes"`
|
|
882
|
+
);
|
|
778
883
|
}
|
|
779
|
-
function
|
|
884
|
+
function Ae(e = D()) {
|
|
780
885
|
return e.applyRouting ?? {};
|
|
781
886
|
}
|
|
782
|
-
function
|
|
887
|
+
function Se(e) {
|
|
783
888
|
const t = x();
|
|
784
889
|
if (t === null) {
|
|
785
|
-
|
|
890
|
+
m().pendingColorPresets = e;
|
|
786
891
|
return;
|
|
787
892
|
}
|
|
788
893
|
t.config = { ...t.config, colorPresets: e };
|
|
789
894
|
}
|
|
790
895
|
export {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
ge as
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
896
|
+
Pe as A,
|
|
897
|
+
Ae as B,
|
|
898
|
+
V as C,
|
|
899
|
+
$e as D,
|
|
900
|
+
I as E,
|
|
901
|
+
te as F,
|
|
902
|
+
ke as G,
|
|
903
|
+
q as H,
|
|
904
|
+
ne as I,
|
|
905
|
+
re as J,
|
|
906
|
+
we as K,
|
|
907
|
+
ie as _,
|
|
908
|
+
he as a,
|
|
909
|
+
fe as b,
|
|
910
|
+
ee as c,
|
|
911
|
+
ce as d,
|
|
912
|
+
ge as e,
|
|
913
|
+
ve as f,
|
|
914
|
+
D as g,
|
|
915
|
+
de as h,
|
|
916
|
+
Ee as i,
|
|
917
|
+
pe as j,
|
|
918
|
+
ue as k,
|
|
919
|
+
be as l,
|
|
920
|
+
se as m,
|
|
921
|
+
le as n,
|
|
922
|
+
Y as o,
|
|
923
|
+
Z as p,
|
|
924
|
+
ye as q,
|
|
925
|
+
Q as r,
|
|
926
|
+
Se as s,
|
|
927
|
+
me as t,
|
|
928
|
+
X as u,
|
|
929
|
+
oe as v,
|
|
930
|
+
ae as w,
|
|
931
|
+
M as x,
|
|
932
|
+
S as y,
|
|
933
|
+
Ce as z
|
|
824
934
|
};
|