@takazudo/zdtp 0.7.0 → 0.8.0
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 +36 -0
- package/dist/apply/build-apply-overrides.d.ts +2 -0
- package/dist/astro/host-adapter.js +3 -3
- package/dist/astro/index.js +1 -1
- package/dist/{autoload-state-CGnis85c.js → autoload-state-CtB0e8mY.js} +1 -1
- package/dist/config/cluster-config.d.ts +10 -2
- package/dist/dashboard/index.d.ts +2 -1
- package/dist/dashboard/index.js +314 -266
- package/dist/dashboard/model.d.ts +3 -1
- package/dist/dashboard/styles.css +107 -32
- package/dist/dashboard/token-dashboard.d.ts +8 -5
- package/dist/dashboard/types.d.ts +19 -3
- package/dist/import-modal.d.ts +21 -22
- package/dist/{index-BcqHRoxf.js → index-BH_IJp9W.js} +2 -2
- package/dist/index-blRjSavc.js +12890 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +39 -32
- package/dist/mode-dependence-Ci9avNt8.js +61 -0
- package/dist/{panel-config-Crn5QJGy.js → panel-config-DKfob-1r.js} +314 -301
- package/dist/state/tweak-state.d.ts +17 -7
- package/dist/tabs/modes-row.d.ts +39 -0
- package/dist/testing.js +2 -2
- package/dist/tokens/mode-dependence.d.ts +23 -0
- package/dist/tokens/tier-model.d.ts +9 -0
- package/dist/{tweak-state-Dhjqig0C.js → tweak-state-BiaKbhXN.js} +729 -671
- package/dist/utils/design-token-serde.d.ts +32 -2
- package/dist/zdtp.css +1 -1
- package/package.json +1 -1
- package/dist/index-CUWkR-Gb.js +0 -12322
package/dist/dashboard/index.js
CHANGED
|
@@ -1,408 +1,456 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { jsxs as v, jsx as m } from "preact/jsx-runtime";
|
|
2
|
+
import { r as P } from "../mode-dependence-Ci9avNt8.js";
|
|
3
|
+
import { i as re, s as ae } from "../mode-dependence-Ci9avNt8.js";
|
|
4
|
+
const U = new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent currentcolor inherit initial unset revert revert-layer".split(" "));
|
|
5
|
+
function A(r) {
|
|
6
|
+
return r.startsWith("#") || r.includes("(") || U.has(r.toLowerCase());
|
|
5
7
|
}
|
|
6
|
-
const
|
|
8
|
+
const W = [
|
|
7
9
|
"background",
|
|
8
10
|
"foreground",
|
|
9
11
|
"cursor",
|
|
10
12
|
"selectionBg",
|
|
11
13
|
"selectionFg"
|
|
12
|
-
],
|
|
13
|
-
function
|
|
14
|
-
let f = "",
|
|
15
|
-
for (let
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
let
|
|
20
|
-
for (
|
|
21
|
-
if (
|
|
22
|
-
else if (
|
|
23
|
-
|
|
14
|
+
], F = /^--[\w\u0080-\uffff-]+$/u;
|
|
15
|
+
function G(r) {
|
|
16
|
+
let f = "", i = 0;
|
|
17
|
+
for (let a = 0; a < r.length; a++) {
|
|
18
|
+
const d = r[a];
|
|
19
|
+
if (d === '"' || d === "'") {
|
|
20
|
+
const o = d;
|
|
21
|
+
let w = !1;
|
|
22
|
+
for (a++; a < r.length; a++)
|
|
23
|
+
if (r[a] === "\\") a++;
|
|
24
|
+
else if (r[a] === o) {
|
|
25
|
+
w = !0;
|
|
24
26
|
break;
|
|
25
|
-
} else if (/[\n\r\f]/.test(
|
|
26
|
-
if (!
|
|
27
|
+
} else if (/[\n\r\f]/.test(r[a])) return { syntax: f, safe: !1 };
|
|
28
|
+
if (!w) return { syntax: f, safe: !1 };
|
|
27
29
|
f += '""';
|
|
28
|
-
} else if (
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
f += " ",
|
|
30
|
+
} else if (d === "/" && r[a + 1] === "*") {
|
|
31
|
+
const o = r.indexOf("*/", a + 2);
|
|
32
|
+
if (o === -1) return { syntax: f, safe: !1 };
|
|
33
|
+
f += " ", a = o + 1;
|
|
32
34
|
} else {
|
|
33
|
-
const
|
|
34
|
-
if (/[;{}\\@]/.test(
|
|
35
|
+
const o = d.charCodeAt(0);
|
|
36
|
+
if (/[;{}\\@]/.test(d) || o <= 8 || o === 11 || o >= 14 && o <= 31 || o === 127)
|
|
35
37
|
return { syntax: f, safe: !1 };
|
|
36
|
-
if (
|
|
37
|
-
f +=
|
|
38
|
+
if (d === "(" && i++, d === ")" && --i < 0) return { syntax: f, safe: !1 };
|
|
39
|
+
f += d;
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
return {
|
|
41
43
|
syntax: f,
|
|
42
|
-
safe:
|
|
44
|
+
safe: i === 0 && !/\b(?:url|(?:-webkit-)?image-set|image|cross-fade|element|paint|src)\s*\(/i.test(f) && !/!\s*important\b/i.test(f)
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
|
|
47
|
+
function L(r, f) {
|
|
48
|
+
const i = /* @__PURE__ */ new Map();
|
|
49
|
+
for (const a of r) {
|
|
50
|
+
const d = f(a), o = i.get(d) ?? [];
|
|
51
|
+
o.push(a), i.set(d, o);
|
|
50
52
|
}
|
|
51
|
-
return
|
|
53
|
+
return i;
|
|
52
54
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
mode:
|
|
55
|
+
function K(r, f = {}) {
|
|
56
|
+
const { mode: i = "light", include: a = "all" } = typeof f == "string" ? { mode: f } : f, d = {
|
|
57
|
+
mode: i,
|
|
58
|
+
include: a,
|
|
56
59
|
tabs: [],
|
|
57
60
|
rows: [],
|
|
58
61
|
declarations: /* @__PURE__ */ Object.create(null),
|
|
59
62
|
diagnostics: []
|
|
60
|
-
},
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
e?.row.diagnostics.some((
|
|
63
|
+
}, o = [], w = r.filter((e) => e.id !== "notes"), z = L(w, (e) => e.id);
|
|
64
|
+
function n(e, t, s, c = "error") {
|
|
65
|
+
const u = { code: t, severity: c, message: s, ...e ? { rowKey: e.row.key } : {} };
|
|
66
|
+
e?.row.diagnostics.some((l) => l.code === t && l.message === s) || (e?.row.diagnostics.push(u), d.diagnostics.push(u));
|
|
64
67
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
68
|
+
function _(e, t, s, c, u, l) {
|
|
69
|
+
t.rows.push(s), d.rows.push(s), o.push({ row: s, tab: e, tier: u, item: c, baseRole: l, dependencies: [], contextDependent: !1 });
|
|
67
70
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
key: `${
|
|
73
|
-
id:
|
|
74
|
-
label:
|
|
75
|
-
palette: !
|
|
76
|
-
preview:
|
|
77
|
-
previewBase:
|
|
71
|
+
w.forEach((e, t) => {
|
|
72
|
+
const s = { key: `tab-${t}`, id: e.id, label: e.label, tiers: [] };
|
|
73
|
+
d.tabs.push(s), e.tiers.forEach((l, V) => {
|
|
74
|
+
const h = {
|
|
75
|
+
key: `${s.key}-tier-${V}`,
|
|
76
|
+
id: l.id,
|
|
77
|
+
label: l.label,
|
|
78
|
+
palette: !l.semantic && !l.referencesTier && !l.referencesRamps?.length && l.items.length > 0 && l.items.every(($) => $.type.kind === "color"),
|
|
79
|
+
preview: l.preview,
|
|
80
|
+
previewBase: l.previewBase,
|
|
78
81
|
rows: []
|
|
79
82
|
};
|
|
80
|
-
|
|
81
|
-
key: `${
|
|
83
|
+
s.tiers.push(h), l.items.forEach(($, C) => _(e, h, {
|
|
84
|
+
key: `${h.key}-item-${C}`,
|
|
82
85
|
tabId: e.id,
|
|
83
|
-
tierId:
|
|
84
|
-
itemId:
|
|
85
|
-
label:
|
|
86
|
-
cssVar:
|
|
87
|
-
kind:
|
|
86
|
+
tierId: l.id,
|
|
87
|
+
itemId: $.id,
|
|
88
|
+
label: $.label,
|
|
89
|
+
cssVar: $.cssVar,
|
|
90
|
+
kind: $.type.kind,
|
|
88
91
|
source: "item",
|
|
89
|
-
defaultValue:
|
|
90
|
-
declaredValue:
|
|
92
|
+
defaultValue: $.default,
|
|
93
|
+
declaredValue: $.default,
|
|
94
|
+
modeDependent: !1,
|
|
95
|
+
sides: null,
|
|
96
|
+
origin: null,
|
|
91
97
|
cssValue: null,
|
|
92
98
|
resolvedValue: null,
|
|
93
99
|
references: [],
|
|
94
100
|
diagnostics: []
|
|
95
|
-
},
|
|
101
|
+
}, $, l));
|
|
96
102
|
});
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
99
|
-
const
|
|
100
|
-
key: `${
|
|
103
|
+
const c = e.colorExtras;
|
|
104
|
+
if (!c) return;
|
|
105
|
+
const u = {
|
|
106
|
+
key: `${s.key}-base-roles`,
|
|
101
107
|
id: "base-roles",
|
|
102
108
|
label: "Base roles",
|
|
103
109
|
rows: []
|
|
104
110
|
};
|
|
105
|
-
for (const
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
key: `${
|
|
111
|
+
for (const l of W) {
|
|
112
|
+
const V = c.baseRoles[l];
|
|
113
|
+
if (V === void 0) continue;
|
|
114
|
+
const h = c.baseDefaults[l];
|
|
115
|
+
_(e, u, {
|
|
116
|
+
key: `${u.key}-${l}`,
|
|
111
117
|
tabId: e.id,
|
|
112
|
-
tierId:
|
|
113
|
-
itemId:
|
|
114
|
-
label:
|
|
115
|
-
cssVar:
|
|
118
|
+
tierId: u.id,
|
|
119
|
+
itemId: l,
|
|
120
|
+
label: l,
|
|
121
|
+
cssVar: V,
|
|
116
122
|
kind: "color",
|
|
117
123
|
source: "base-role",
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
modeDependent: !1,
|
|
125
|
+
sides: null,
|
|
126
|
+
origin: null,
|
|
127
|
+
defaultValue: h === void 0 ? "" : String(h),
|
|
128
|
+
declaredValue: h === void 0 ? "(no declared default)" : `palette[${h}]`,
|
|
120
129
|
cssValue: null,
|
|
121
130
|
resolvedValue: null,
|
|
122
131
|
references: [],
|
|
123
132
|
diagnostics: []
|
|
124
|
-
}, void 0, void 0,
|
|
133
|
+
}, void 0, void 0, l);
|
|
125
134
|
}
|
|
126
|
-
|
|
135
|
+
u.rows.length > 0 && s.tiers.push(u);
|
|
127
136
|
});
|
|
128
|
-
const
|
|
129
|
-
for (const e of
|
|
130
|
-
|
|
131
|
-
function
|
|
132
|
-
e.directReference =
|
|
137
|
+
const x = L(o, (e) => e.row.cssVar);
|
|
138
|
+
for (const e of o)
|
|
139
|
+
F.test(e.row.cssVar) || n(e, "invalid-variable", `Unsupported CSS custom property name: ${e.row.cssVar}.`), x.get(e.row.cssVar).length > 1 && n(e, "duplicate-variable", `Multiple declarations use ${e.row.cssVar}; none is selected.`), z.get(e.tab.id).length > 1 && n(e, "duplicate-tab", `Multiple tabs use the id ${e.tab.id}.`), e.tier && (e.tab.tiers.filter((t) => t.id === e.tier.id).length > 1 && n(e, "duplicate-tier", `Multiple tiers use the id ${e.tier.id} in tab ${e.tab.id}.`), e.tier.items.filter((t) => t.id === e.item.id).length > 1 && n(e, "duplicate-item", `Multiple items use the id ${e.item.id} in tier ${e.tier.id}.`));
|
|
140
|
+
function k(e, t) {
|
|
141
|
+
e.directReference = t, e.row.cssValue = `var(${t.row.cssVar})`;
|
|
133
142
|
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
|
|
143
|
+
function g(e, t, s, c) {
|
|
144
|
+
const u = z.get(t) ?? [];
|
|
145
|
+
if (u.length !== 1) {
|
|
146
|
+
n(e, u.length ? "ambiguous-reference" : "missing-reference", `Reference tab ${t} ${u.length ? "is ambiguous" : "does not exist"}.`);
|
|
138
147
|
return;
|
|
139
148
|
}
|
|
140
|
-
const
|
|
141
|
-
if (
|
|
142
|
-
|
|
149
|
+
const l = u[0].tiers.filter((h) => h.id === s);
|
|
150
|
+
if (l.length !== 1) {
|
|
151
|
+
n(e, l.length ? "ambiguous-reference" : "missing-reference", `Reference tier ${t}/${s} ${l.length ? "is ambiguous" : "does not exist"}.`);
|
|
143
152
|
return;
|
|
144
153
|
}
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
|
|
154
|
+
const V = o.filter((h) => h.tab === u[0] && h.tier === l[0] && h.item?.id === c);
|
|
155
|
+
if (V.length !== 1) {
|
|
156
|
+
n(e, V.length ? "ambiguous-reference" : "missing-reference", `Reference item ${t}/${s}/${c} ${V.length ? "is ambiguous" : "does not exist"}.`);
|
|
148
157
|
return;
|
|
149
158
|
}
|
|
150
|
-
return
|
|
159
|
+
return V[0];
|
|
151
160
|
}
|
|
152
|
-
function
|
|
153
|
-
return e.tab.tiers.filter((
|
|
161
|
+
function N(e) {
|
|
162
|
+
return e.tab.tiers.filter((t) => !t.semantic && !t.referencesTier && t.items.length > 0 && t.items.every((s) => s.type.kind === "color"));
|
|
154
163
|
}
|
|
155
|
-
function
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
|
|
164
|
+
function b(e, t) {
|
|
165
|
+
const s = N(e), c = e.tier?.referencesTier ? s.filter((V) => V.id === e.tier.referencesTier) : s;
|
|
166
|
+
if (c.length !== 1) {
|
|
167
|
+
n(e, "unsupported-palette", `A palette index requires one unambiguous declared palette tier; found ${c.length}.`);
|
|
159
168
|
return;
|
|
160
169
|
}
|
|
161
|
-
if (!Number.isInteger(
|
|
162
|
-
|
|
170
|
+
if (!Number.isInteger(t) || t < 0 || t >= c[0].items.length) {
|
|
171
|
+
n(e, "invalid-palette-index", `Palette index ${t} is outside the declared palette.`);
|
|
163
172
|
return;
|
|
164
173
|
}
|
|
165
|
-
const
|
|
166
|
-
|
|
174
|
+
const u = c[0].items[t], l = g(e, e.tab.id, c[0].id, u.id);
|
|
175
|
+
l && k(e, l);
|
|
167
176
|
}
|
|
168
|
-
function
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
|
|
177
|
+
function p(e, t) {
|
|
178
|
+
const s = e.tab.colorExtras?.baseDefaults[t];
|
|
179
|
+
if (s === void 0) {
|
|
180
|
+
n(e, "missing-base-default", `Base role ${t} has no explicit baseDefaults mapping.`);
|
|
172
181
|
return;
|
|
173
182
|
}
|
|
174
|
-
|
|
183
|
+
b(e, s);
|
|
175
184
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
e.row.declaredValue = t, e
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
e.row.declaredValue =
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
function D(e) {
|
|
186
|
+
return i === "host" ? `light-dark(${e.light}, ${e.dark})` : e[i];
|
|
187
|
+
}
|
|
188
|
+
function O(e, t) {
|
|
189
|
+
if (typeof t == "number")
|
|
190
|
+
e.row.declaredValue = `palette[${t}]`, b(e, t);
|
|
191
|
+
else if (t === "bg" || t === "fg")
|
|
192
|
+
e.row.declaredValue = t, p(e, t === "bg" ? "background" : "foreground");
|
|
193
|
+
else if (typeof t == "object" && t !== null && "literal" in t) {
|
|
194
|
+
const s = typeof t.literal == "string" ? t.literal : D(t.literal);
|
|
195
|
+
e.row.declaredValue = s, e.row.cssValue = s;
|
|
196
|
+
} else if (typeof t == "object" && t !== null && "ref" in t) {
|
|
197
|
+
const { tab: s = e.tab.id, tier: c, item: u } = t.ref;
|
|
198
|
+
e.row.declaredValue = `${s}/${c}/${u}`;
|
|
199
|
+
const l = g(e, s, c, u);
|
|
200
|
+
l && k(e, l);
|
|
189
201
|
} else
|
|
190
|
-
|
|
202
|
+
n(e, "invalid-semantic-default", "Unsupported semantic default mapping.");
|
|
191
203
|
}
|
|
192
|
-
for (const e of
|
|
204
|
+
for (const e of o) {
|
|
193
205
|
if (e.baseRole) {
|
|
194
|
-
|
|
206
|
+
p(e, e.baseRole);
|
|
195
207
|
continue;
|
|
196
208
|
}
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
$(
|
|
200
|
-
else if (
|
|
201
|
-
|
|
202
|
-
|
|
209
|
+
const t = e.tier, s = e.item, c = N(e), u = t.semantic || e.tab.colorExtras && c.some((y) => y.id === t.referencesTier), V = (t.referencesTier === void 0 ? c : c.filter((y) => y.id === t.referencesTier)).flatMap((y) => y.items.filter((R) => R.id === s.default).map(() => y)), h = e.tab.colorExtras?.semanticDefaults, $ = u && h && Object.hasOwn(h, s.id) ? h[s.id] : void 0, C = P(s, $);
|
|
210
|
+
if (C !== null)
|
|
211
|
+
e.row.modeDependent = !0, e.row.sides = C, e.row.origin = s.modes !== void 0 ? "modes" : typeof $ == "object" && $ !== null && "literal" in $ && typeof $.literal != "string" ? "semantic" : "default", e.row.declaredValue = D(C), e.row.cssValue = e.row.declaredValue;
|
|
212
|
+
else if (u && h && Object.hasOwn(h, s.id))
|
|
213
|
+
O(e, h[s.id]);
|
|
214
|
+
else if (u && V.length > 0)
|
|
215
|
+
if (V.length > 1)
|
|
216
|
+
n(e, "ambiguous-reference", `Default ${s.default} names multiple palette items.`);
|
|
203
217
|
else {
|
|
204
|
-
const
|
|
205
|
-
|
|
218
|
+
const y = g(e, e.tab.id, V[0].id, s.default);
|
|
219
|
+
y && k(e, y);
|
|
206
220
|
}
|
|
207
|
-
else if (
|
|
208
|
-
|
|
209
|
-
else if (
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
} else if (
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
216
|
-
|
|
221
|
+
else if (u && (s.default === "bg" || s.default === "fg"))
|
|
222
|
+
p(e, s.default === "bg" ? "background" : "foreground");
|
|
223
|
+
else if (t.referencesTier !== void 0 && !(u && t.referencesRamps?.length) && !(t.semantic && A(s.default))) {
|
|
224
|
+
const y = g(e, e.tab.id, t.referencesTier, s.default);
|
|
225
|
+
y && k(e, y);
|
|
226
|
+
} else if (u)
|
|
227
|
+
if (t.referencesRamps?.length && !A(s.default)) {
|
|
228
|
+
const y = s.default.indexOf(":"), R = y === -1 ? [t.referencesRamps[0]] : t.referencesRamps.filter((M) => M.tier === s.default.slice(0, y));
|
|
229
|
+
if (R.length !== 1)
|
|
230
|
+
n(e, R.length ? "ambiguous-reference" : "missing-reference", `Ramp source for ${s.default} ${R.length ? "is ambiguous" : "does not exist"}.`);
|
|
217
231
|
else {
|
|
218
|
-
const
|
|
219
|
-
|
|
232
|
+
const M = g(e, R[0].tab ?? e.tab.id, R[0].tier, y === -1 ? s.default : s.default.slice(y + 1));
|
|
233
|
+
M && k(e, M);
|
|
220
234
|
}
|
|
221
235
|
} else
|
|
222
|
-
e.row.cssValue =
|
|
236
|
+
e.row.cssValue = s.default;
|
|
223
237
|
else
|
|
224
|
-
e.row.cssValue =
|
|
238
|
+
e.row.cssValue = s.default;
|
|
225
239
|
}
|
|
226
|
-
for (const e of
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
|
|
240
|
+
for (const e of o) {
|
|
241
|
+
const t = e.row.cssValue;
|
|
242
|
+
if (t === null) continue;
|
|
243
|
+
const s = G(t);
|
|
244
|
+
if (!s.safe) {
|
|
245
|
+
n(e, "unsafe-css", "This declaration contains unsupported CSS syntax or a resource-loading function; preview omitted.");
|
|
232
246
|
continue;
|
|
233
247
|
}
|
|
234
248
|
e.directReference && e.dependencies.push(e.directReference);
|
|
235
|
-
for (const
|
|
236
|
-
const
|
|
237
|
-
|
|
249
|
+
for (const c of s.syntax.matchAll(/\bvar\(\s*(--[\w\u0080-\uffff-]+)\s*(?=[,)])/giu)) {
|
|
250
|
+
const u = x.get(c[1]) ?? [];
|
|
251
|
+
u.length > 1 ? n(e, "ambiguous-reference", `CSS reference ${c[1]} has multiple declarations.`) : u.length === 1 ? e.dependencies.push(u[0]) : (e.contextDependent = !0, n(e, "external-reference", `CSS reference ${c[1]} is not in this inventory; its value depends on the host context or fallback.`, "warning"));
|
|
238
252
|
}
|
|
239
|
-
e.dependencies = [...new Set(e.dependencies)], e.row.references = e.dependencies.map(({ row:
|
|
253
|
+
e.dependencies = [...new Set(e.dependencies)], e.row.references = e.dependencies.map(({ row: c }) => ({ key: c.key, cssVar: c.cssVar, label: c.label })), /(?:^|[^\w-])(?:currentcolor|initial|inherit|unset|revert|revert-layer)(?=$|[^\w-])|\b(?:env|attr)\s*\(/i.test(s.syntax) && (e.contextDependent = !0, n(e, "context-dependent", "This CSS value depends on the surrounding document; no computed preview is claimed.", "warning"));
|
|
240
254
|
}
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
255
|
+
const S = /* @__PURE__ */ new Map();
|
|
256
|
+
for (const e of o)
|
|
257
|
+
for (const t of e.dependencies) {
|
|
258
|
+
const s = S.get(t) ?? [];
|
|
259
|
+
s.push(e), S.set(t, s);
|
|
260
|
+
}
|
|
261
|
+
const T = o.filter((e) => e.row.modeDependent);
|
|
262
|
+
for (let e = 0; e < T.length; e++)
|
|
263
|
+
for (const t of S.get(T[e]) ?? [])
|
|
264
|
+
t.row.modeDependent || (t.row.modeDependent = !0, t.row.origin = "reference", T.push(t));
|
|
265
|
+
const j = /* @__PURE__ */ new Set(), E = [];
|
|
266
|
+
function q(e) {
|
|
267
|
+
if (j.has(e)) return;
|
|
268
|
+
const t = E.indexOf(e);
|
|
269
|
+
if (t !== -1) {
|
|
270
|
+
for (const s of E.slice(t)) n(s, "cyclic-reference", "Declared references form a cycle.");
|
|
247
271
|
return;
|
|
248
272
|
}
|
|
249
|
-
|
|
250
|
-
for (const
|
|
251
|
-
|
|
252
|
-
|
|
273
|
+
E.push(e);
|
|
274
|
+
for (const s of e.dependencies)
|
|
275
|
+
q(s), s.row.diagnostics.some((c) => c.severity === "error") ? n(e, "invalid-reference", `Referenced declaration ${s.row.cssVar} is invalid.`) : s.contextDependent && (e.contextDependent = !0, n(e, "context-dependent", `Referenced declaration ${s.row.cssVar} depends on the host context.`, "warning"));
|
|
276
|
+
E.pop(), j.add(e), e.row.diagnostics.some((s) => s.severity === "error") ? e.row.cssValue = null : !e.contextDependent && !(i === "host" && e.row.modeDependent) && (e.row.resolvedValue = e.directReference?.row.resolvedValue ?? e.row.cssValue);
|
|
277
|
+
}
|
|
278
|
+
for (const e of o) q(e);
|
|
279
|
+
d.declarations = Object.fromEntries(o.filter((e) => e.row.cssValue !== null).map((e) => [e.row.cssVar, e.row.cssValue]));
|
|
280
|
+
for (const e of d.tabs) {
|
|
281
|
+
for (const t of e.tiers)
|
|
282
|
+
t.rows = t.rows.filter((s) => a === "all" || s.modeDependent === (a === "mode-dependent"));
|
|
283
|
+
e.tiers = e.tiers.filter((t) => t.rows.length > 0);
|
|
253
284
|
}
|
|
254
|
-
|
|
255
|
-
return o.declarations = Object.fromEntries(r.filter((e) => e.row.cssValue !== null).map((e) => [e.row.cssVar, e.row.cssValue])), o;
|
|
285
|
+
return d.tabs = d.tabs.filter((e) => e.tiers.length > 0), d;
|
|
256
286
|
}
|
|
257
|
-
function
|
|
258
|
-
return
|
|
287
|
+
function H(r, f, i) {
|
|
288
|
+
return i?.[r.cssVar] ?? f.preview ?? (r.kind === "color" ? "color" : "text");
|
|
259
289
|
}
|
|
260
|
-
const
|
|
290
|
+
const X = `Good typography gives every idea room to breathe. Compare the rhythm of several lines, the shapes of letters, and the distance between words. A token becomes useful when you can see it in context.
|
|
261
291
|
|
|
262
292
|
読みやすさは、文字の大きさだけでは決まりません。行間と余白を比べて、心地よいリズムを探しましょう。0123456789`;
|
|
263
|
-
function
|
|
264
|
-
return ["size", "family", "weight", "line-height"].includes(
|
|
293
|
+
function I(r) {
|
|
294
|
+
return ["size", "family", "weight", "line-height"].includes(r);
|
|
295
|
+
}
|
|
296
|
+
function B(r, f) {
|
|
297
|
+
return r.flatMap((i) => {
|
|
298
|
+
const a = i.tiers.flatMap((d) => {
|
|
299
|
+
const o = d.rows.filter((w) => w.modeDependent === f);
|
|
300
|
+
return o.length > 0 ? [{ ...d, rows: o }] : [];
|
|
301
|
+
});
|
|
302
|
+
return a.length > 0 ? [{ ...i, tiers: a }] : [];
|
|
303
|
+
});
|
|
265
304
|
}
|
|
266
|
-
function
|
|
267
|
-
const
|
|
268
|
-
let
|
|
269
|
-
for (;
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
if (/^(?:0|\+?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))$/i.test(
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
|
|
305
|
+
function Y(r, f) {
|
|
306
|
+
const i = /* @__PURE__ */ new Set();
|
|
307
|
+
let a = r;
|
|
308
|
+
for (; a.cssValue !== null && a.resolvedValue !== null && !i.has(a.key); ) {
|
|
309
|
+
i.add(a.key);
|
|
310
|
+
const d = a.resolvedValue.trim();
|
|
311
|
+
if (/^(?:0|\+?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))$/i.test(d)) return d;
|
|
312
|
+
const o = /^var\(\s*(--[a-zA-Z0-9_-]+)\s*\)$/.exec(d);
|
|
313
|
+
if (!o) return null;
|
|
314
|
+
const w = f.rows.filter((z) => z.cssVar === o[1]);
|
|
315
|
+
if (w.length !== 1) return null;
|
|
316
|
+
a = w[0];
|
|
278
317
|
}
|
|
279
318
|
return null;
|
|
280
319
|
}
|
|
281
|
-
function
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
return
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
-
/* @__PURE__ */
|
|
320
|
+
function Z({ row: r, tier: f, kind: i, model: a, previewText: d, colorScheme: o }) {
|
|
321
|
+
if (i === "bar") {
|
|
322
|
+
const k = Y(r, a);
|
|
323
|
+
return k === null ? /* @__PURE__ */ m("div", { className: "zdtp-dashboard__preview-unavailable", children: "Ruler unavailable: requires a nonnegative px/rem length or a resolved direct alias." }) : /* @__PURE__ */ v("div", { className: "zdtp-dashboard__ruler-wrap", children: [
|
|
324
|
+
/* @__PURE__ */ m("div", { className: "zdtp-dashboard__ruler-caption", children: "Actual size · ticks every 8 CSS px · major ticks every 64 CSS px" }),
|
|
325
|
+
/* @__PURE__ */ m("div", { className: "zdtp-dashboard__scroll zdtp-dashboard__ruler-scroll", role: "region", tabIndex: 0, "aria-label": `${r.label} (${r.cssVar}) actual-size ruler`, children: /* @__PURE__ */ v("div", { className: "zdtp-dashboard__ruler", style: { inlineSize: `max(100%, ${k})` }, children: [
|
|
326
|
+
/* @__PURE__ */ m("div", { className: "zdtp-dashboard__ruler-origin", children: "0" }),
|
|
327
|
+
/* @__PURE__ */ m("div", { className: "zdtp-dashboard__specimen", style: { colorScheme: o }, children: /* @__PURE__ */ m("span", { className: "zdtp-dashboard__sample zdtp-dashboard__sample--bar", style: { inlineSize: k }, "aria-hidden": "true" }) })
|
|
289
328
|
] }) })
|
|
290
329
|
] });
|
|
291
330
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
331
|
+
const w = r.resolvedValue ?? (a.mode === "host" && r.modeDependent && i === "color" && r.diagnostics.length === 0 ? r.cssValue : null);
|
|
332
|
+
if (r.cssValue === null || w === null || i === "text" || i === "duration") return null;
|
|
333
|
+
const z = w.trim().toLowerCase();
|
|
334
|
+
if (!z || (i === "radius" || i === "size") && (/^(?:auto|none|normal|(?:min|max)-content|stretch|content)$|^fit-content(?:\(|$)/.test(z) || /^[+-]?(?:\d*\.)?\d+(?:ms|s)$/.test(z) || /^[+-]?(?:\d*\.)?\d+$/.test(z) && Number(z) !== 0))
|
|
295
335
|
return null;
|
|
296
|
-
const
|
|
297
|
-
let
|
|
298
|
-
switch (
|
|
336
|
+
const n = r.cssValue;
|
|
337
|
+
let _;
|
|
338
|
+
switch (i) {
|
|
299
339
|
case "color":
|
|
300
|
-
|
|
340
|
+
_ = { backgroundColor: n };
|
|
301
341
|
break;
|
|
302
342
|
case "radius":
|
|
303
|
-
|
|
343
|
+
_ = { borderRadius: n };
|
|
304
344
|
break;
|
|
305
345
|
case "shadow":
|
|
306
|
-
|
|
346
|
+
_ = { boxShadow: n };
|
|
307
347
|
break;
|
|
308
348
|
case "size":
|
|
309
|
-
|
|
349
|
+
_ = { fontSize: n };
|
|
310
350
|
break;
|
|
311
351
|
case "family":
|
|
312
|
-
|
|
352
|
+
_ = { fontFamily: n };
|
|
313
353
|
break;
|
|
314
354
|
case "weight":
|
|
315
|
-
|
|
355
|
+
_ = { fontWeight: n };
|
|
316
356
|
break;
|
|
317
357
|
case "line-height": {
|
|
318
|
-
const
|
|
319
|
-
|
|
358
|
+
const k = a.rows.find((g) => g.cssVar === f.previewBase);
|
|
359
|
+
_ = { lineHeight: n, ...k?.cssValue !== null && k?.resolvedValue != null ? { fontSize: `var(${k.cssVar})` } : {} };
|
|
320
360
|
break;
|
|
321
361
|
}
|
|
322
362
|
}
|
|
323
|
-
const
|
|
324
|
-
return /* @__PURE__ */
|
|
363
|
+
const x = I(i);
|
|
364
|
+
return /* @__PURE__ */ m(
|
|
325
365
|
"div",
|
|
326
366
|
{
|
|
327
|
-
className: `zdtp-dashboard__preview zdtp-dashboard__preview--${
|
|
328
|
-
"aria-hidden":
|
|
329
|
-
role:
|
|
330
|
-
tabIndex:
|
|
331
|
-
"aria-label":
|
|
332
|
-
children: /* @__PURE__ */
|
|
367
|
+
className: `zdtp-dashboard__preview zdtp-dashboard__preview--${i}${x ? " zdtp-dashboard__preview--typography zdtp-dashboard__scroll" : ""}`,
|
|
368
|
+
"aria-hidden": x ? void 0 : "true",
|
|
369
|
+
role: x ? "region" : void 0,
|
|
370
|
+
tabIndex: x ? 0 : void 0,
|
|
371
|
+
"aria-label": x ? `${r.label} (${r.cssVar}) typography specimen` : void 0,
|
|
372
|
+
children: /* @__PURE__ */ m("div", { className: "zdtp-dashboard__specimen", style: { colorScheme: o }, children: /* @__PURE__ */ m("span", { className: `zdtp-dashboard__sample zdtp-dashboard__sample--${i}`, style: _, children: x ? d : "" }) })
|
|
333
373
|
}
|
|
334
374
|
);
|
|
335
375
|
}
|
|
336
|
-
function
|
|
337
|
-
tabs:
|
|
376
|
+
function ee({
|
|
377
|
+
tabs: r,
|
|
338
378
|
mode: f = "light",
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
379
|
+
include: i = "all",
|
|
380
|
+
chrome: a = "light",
|
|
381
|
+
title: d = "Token dashboard",
|
|
382
|
+
id: o,
|
|
383
|
+
previewOverrides: w,
|
|
384
|
+
previewText: z = X
|
|
344
385
|
}) {
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
386
|
+
const n = K(r, { mode: f, include: i }), _ = n.tabs.flatMap((g) => g.tiers.flatMap((N) => N.rows)), x = _.filter((g) => g.diagnostics.length > 0).length, k = [
|
|
387
|
+
{ key: "mode-dependent", scheme: f, tabs: B(n.tabs, !0) },
|
|
388
|
+
{ key: "mode-independent", scheme: a, tabs: B(n.tabs, !1) }
|
|
389
|
+
].filter((g) => g.tabs.length > 0);
|
|
390
|
+
return /* @__PURE__ */ v("div", { id: o, className: "zdtp-dashboard", role: "region", "aria-label": d, "data-mode": f, "data-include": i, "data-chrome": a, children: [
|
|
391
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__header", children: [
|
|
392
|
+
/* @__PURE__ */ m("div", { role: "heading", "aria-level": 2, className: "zdtp-dashboard__title", children: d }),
|
|
393
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__summary", children: [
|
|
394
|
+
/* @__PURE__ */ v("span", { className: "zdtp-dashboard__count", children: [
|
|
395
|
+
_.length,
|
|
352
396
|
" tokens"
|
|
353
397
|
] }),
|
|
354
|
-
/* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ v("span", { children: [
|
|
355
399
|
"Declared defaults · ",
|
|
356
400
|
f,
|
|
357
|
-
" mode"
|
|
401
|
+
" mode",
|
|
402
|
+
i !== "all" ? ` · ${i} only` : ""
|
|
358
403
|
] }),
|
|
359
|
-
|
|
360
|
-
|
|
404
|
+
x > 0 && /* @__PURE__ */ v("span", { children: [
|
|
405
|
+
x,
|
|
361
406
|
" with diagnostics"
|
|
362
407
|
] })
|
|
363
408
|
] })
|
|
364
409
|
] }),
|
|
365
|
-
/* @__PURE__ */
|
|
366
|
-
|
|
367
|
-
m.tabs.map((
|
|
368
|
-
/* @__PURE__ */
|
|
369
|
-
/* @__PURE__ */
|
|
370
|
-
/* @__PURE__ */
|
|
371
|
-
|
|
410
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__inventory", style: n.declarations, children: [
|
|
411
|
+
_.length === 0 && /* @__PURE__ */ m("div", { className: "zdtp-dashboard__empty", style: { colorScheme: a === "host" ? "inherit" : a }, children: n.rows.length === 0 ? "No tokens declared." : "No tokens match this view." }),
|
|
412
|
+
k.map((g) => /* @__PURE__ */ m("div", { className: "zdtp-dashboard__region", "data-scheme": g.scheme, children: g.tabs.map((N) => /* @__PURE__ */ v("div", { className: "zdtp-dashboard__tab", role: "group", "aria-label": N.label, children: [
|
|
413
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__tab-header", children: [
|
|
414
|
+
/* @__PURE__ */ m("div", { role: "heading", "aria-level": 3, className: "zdtp-dashboard__tab-title", children: N.label }),
|
|
415
|
+
/* @__PURE__ */ v("span", { className: "zdtp-dashboard__tab-count", children: [
|
|
416
|
+
N.tiers.reduce((b, p) => b + p.rows.length, 0),
|
|
372
417
|
" tokens"
|
|
373
418
|
] })
|
|
374
419
|
] }),
|
|
375
|
-
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */
|
|
378
|
-
const
|
|
379
|
-
return /* @__PURE__ */
|
|
380
|
-
/* @__PURE__ */
|
|
381
|
-
/* @__PURE__ */
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
/* @__PURE__ */
|
|
385
|
-
|
|
420
|
+
N.tiers.map((b) => /* @__PURE__ */ v("div", { className: "zdtp-dashboard__tier", children: [
|
|
421
|
+
/* @__PURE__ */ m("div", { role: "heading", "aria-level": 4, className: "zdtp-dashboard__tier-title", children: b.label }),
|
|
422
|
+
/* @__PURE__ */ m("div", { className: b.palette ? "zdtp-dashboard__scroll zdtp-dashboard__palette-scroll" : void 0, role: b.palette ? "region" : void 0, tabIndex: b.palette ? 0 : void 0, "aria-label": b.palette ? `${b.label} palette stops` : void 0, children: /* @__PURE__ */ m("div", { className: `zdtp-dashboard__grid${b.palette ? " zdtp-dashboard__palette" : ""}`, role: "list", "aria-label": b.label, children: b.rows.map((p) => {
|
|
423
|
+
const D = H(p, b, w), O = !b.palette && (D === "bar" || I(D));
|
|
424
|
+
return /* @__PURE__ */ v("div", { className: `zdtp-dashboard__token${O ? " zdtp-dashboard__token--wide" : ""}`, role: "listitem", "data-css-var": p.cssVar, children: [
|
|
425
|
+
/* @__PURE__ */ m(Z, { row: p, tier: b, kind: D, model: n, previewText: z, colorScheme: g.scheme === "host" ? "inherit" : g.scheme }),
|
|
426
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__token-content", children: [
|
|
427
|
+
/* @__PURE__ */ m("div", { className: "zdtp-dashboard__name", children: p.label }),
|
|
428
|
+
/* @__PURE__ */ m("div", { className: "zdtp-dashboard__variable", children: p.cssVar }),
|
|
429
|
+
/* @__PURE__ */ m("div", { className: "zdtp-dashboard__value", children: p.declaredValue || "(empty)" }),
|
|
430
|
+
p.cssValue !== null && p.cssValue !== p.declaredValue && /* @__PURE__ */ v("div", { className: "zdtp-dashboard__reference", children: [
|
|
386
431
|
"CSS: ",
|
|
387
|
-
|
|
432
|
+
p.cssValue
|
|
388
433
|
] }),
|
|
389
|
-
|
|
434
|
+
p.references.length > 0 && /* @__PURE__ */ v("div", { className: "zdtp-dashboard__reference", children: [
|
|
390
435
|
"References: ",
|
|
391
|
-
|
|
436
|
+
p.references.map((S) => S.cssVar).join(", ")
|
|
392
437
|
] }),
|
|
393
|
-
|
|
394
|
-
|
|
438
|
+
p.diagnostics.map((S, T) => /* @__PURE__ */ v("div", { className: "zdtp-dashboard__diagnostic", "data-diagnostic": S.code, children: [
|
|
439
|
+
S.severity === "error" ? "Unavailable" : "Context needed",
|
|
395
440
|
": ",
|
|
396
|
-
|
|
397
|
-
] },
|
|
441
|
+
S.message
|
|
442
|
+
] }, T))
|
|
398
443
|
] })
|
|
399
|
-
] },
|
|
444
|
+
] }, p.key);
|
|
400
445
|
}) }) })
|
|
401
|
-
] },
|
|
402
|
-
] }, g.key))
|
|
446
|
+
] }, b.key))
|
|
447
|
+
] }, N.key)) }, g.key))
|
|
403
448
|
] })
|
|
404
449
|
] });
|
|
405
450
|
}
|
|
406
451
|
export {
|
|
407
|
-
|
|
452
|
+
ee as TokenDashboard,
|
|
453
|
+
re as isModeDependent,
|
|
454
|
+
P as resolveModeSides,
|
|
455
|
+
ae as splitLightDark
|
|
408
456
|
};
|