@takazudo/zdtp 0.6.1 → 0.7.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 +34 -0
- package/PORTABLE-CONTRACT.md +17 -7
- package/README.md +18 -7
- package/dist/astro/host-adapter.js +1 -1
- package/dist/components/color-picker/color-field.d.ts +3 -1
- package/dist/components/color-picker/color-picker.d.ts +3 -1
- package/dist/components/color-picker/custom-slider.d.ts +2 -1
- package/dist/dashboard/index.d.ts +1 -1
- package/dist/dashboard/index.js +224 -223
- package/dist/dashboard/styles.css +70 -36
- package/dist/dashboard/token-dashboard.d.ts +6 -2
- package/dist/dashboard/types.d.ts +2 -0
- package/dist/{index-LYsbHWcy.js → index-BcqHRoxf.js} +1 -1
- package/dist/{index-DWs1XPfy.js → index-CUWkR-Gb.js} +4006 -3935
- package/dist/index.js +2 -2
- package/dist/testing.js +1 -1
- package/dist/{tweak-state-Dzr5kDhX.js → tweak-state-Dhjqig0C.js} +8 -8
- package/dist/utils/resolve-css-color.d.ts +12 -0
- package/dist/zdtp.css +1 -1
- package/package.json +1 -1
package/dist/dashboard/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as _, jsx as v } from "preact/jsx-runtime";
|
|
2
2
|
const q = 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(" "));
|
|
3
3
|
function C(l) {
|
|
4
4
|
return l.startsWith("#") || l.includes("(") || q.has(l.toLowerCase());
|
|
@@ -11,93 +11,93 @@ const O = [
|
|
|
11
11
|
"selectionFg"
|
|
12
12
|
], j = /^--[\w\u0080-\uffff-]+$/u;
|
|
13
13
|
function A(l) {
|
|
14
|
-
let
|
|
15
|
-
for (let
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
let
|
|
20
|
-
for (
|
|
21
|
-
if (l[
|
|
22
|
-
else if (l[
|
|
23
|
-
|
|
14
|
+
let f = "", o = 0;
|
|
15
|
+
for (let r = 0; r < l.length; r++) {
|
|
16
|
+
const h = l[r];
|
|
17
|
+
if (h === '"' || h === "'") {
|
|
18
|
+
const c = h;
|
|
19
|
+
let a = !1;
|
|
20
|
+
for (r++; r < l.length; r++)
|
|
21
|
+
if (l[r] === "\\") r++;
|
|
22
|
+
else if (l[r] === c) {
|
|
23
|
+
a = !0;
|
|
24
24
|
break;
|
|
25
|
-
} else if (/[\n\r\f]/.test(l[
|
|
26
|
-
if (!
|
|
27
|
-
|
|
28
|
-
} else if (
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
|
|
25
|
+
} else if (/[\n\r\f]/.test(l[r])) return { syntax: f, safe: !1 };
|
|
26
|
+
if (!a) return { syntax: f, safe: !1 };
|
|
27
|
+
f += '""';
|
|
28
|
+
} else if (h === "/" && l[r + 1] === "*") {
|
|
29
|
+
const c = l.indexOf("*/", r + 2);
|
|
30
|
+
if (c === -1) return { syntax: f, safe: !1 };
|
|
31
|
+
f += " ", r = c + 1;
|
|
32
32
|
} else {
|
|
33
|
-
const
|
|
34
|
-
if (/[;{}\\@]/.test(
|
|
35
|
-
return { syntax:
|
|
36
|
-
if (
|
|
37
|
-
|
|
33
|
+
const c = h.charCodeAt(0);
|
|
34
|
+
if (/[;{}\\@]/.test(h) || c <= 8 || c === 11 || c >= 14 && c <= 31 || c === 127)
|
|
35
|
+
return { syntax: f, safe: !1 };
|
|
36
|
+
if (h === "(" && o++, h === ")" && --o < 0) return { syntax: f, safe: !1 };
|
|
37
|
+
f += h;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
return {
|
|
41
|
-
syntax:
|
|
42
|
-
safe: o === 0 && !/\b(?:url|(?:-webkit-)?image-set|image|cross-fade|element|paint|src)\s*\(/i.test(
|
|
41
|
+
syntax: f,
|
|
42
|
+
safe: o === 0 && !/\b(?:url|(?:-webkit-)?image-set|image|cross-fade|element|paint|src)\s*\(/i.test(f) && !/!\s*important\b/i.test(f)
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
function D(l,
|
|
45
|
+
function D(l, f) {
|
|
46
46
|
const o = /* @__PURE__ */ new Map();
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
|
|
47
|
+
for (const r of l) {
|
|
48
|
+
const h = f(r), c = o.get(h) ?? [];
|
|
49
|
+
c.push(r), o.set(h, c);
|
|
50
50
|
}
|
|
51
51
|
return o;
|
|
52
52
|
}
|
|
53
|
-
function B(l,
|
|
53
|
+
function B(l, f = "light") {
|
|
54
54
|
const o = {
|
|
55
|
-
mode:
|
|
55
|
+
mode: f,
|
|
56
56
|
tabs: [],
|
|
57
57
|
rows: [],
|
|
58
58
|
declarations: /* @__PURE__ */ Object.create(null),
|
|
59
59
|
diagnostics: []
|
|
60
|
-
},
|
|
61
|
-
function
|
|
62
|
-
const d = { code:
|
|
63
|
-
e?.row.diagnostics.some((i) => i.code ===
|
|
60
|
+
}, r = [], h = l.filter((e) => e.id !== "notes"), c = D(h, (e) => e.id);
|
|
61
|
+
function a(e, s, t, n = "error") {
|
|
62
|
+
const d = { code: s, severity: n, message: t, ...e ? { rowKey: e.row.key } : {} };
|
|
63
|
+
e?.row.diagnostics.some((i) => i.code === s && i.message === t) || (e?.row.diagnostics.push(d), o.diagnostics.push(d));
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
65
|
+
function m(e, s, t, n, d, i) {
|
|
66
|
+
s.rows.push(t), o.rows.push(t), r.push({ row: t, tab: e, tier: d, item: n, baseRole: i, dependencies: [], contextDependent: !1 });
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
o.tabs.push(
|
|
71
|
-
const
|
|
72
|
-
key: `${
|
|
68
|
+
h.forEach((e, s) => {
|
|
69
|
+
const t = { key: `tab-${s}`, id: e.id, label: e.label, tiers: [] };
|
|
70
|
+
o.tabs.push(t), e.tiers.forEach((i, w) => {
|
|
71
|
+
const y = {
|
|
72
|
+
key: `${t.key}-tier-${w}`,
|
|
73
73
|
id: i.id,
|
|
74
74
|
label: i.label,
|
|
75
|
-
palette: !i.semantic && !i.referencesTier && !i.referencesRamps?.length && i.items.length > 0 && i.items.every((
|
|
75
|
+
palette: !i.semantic && !i.referencesTier && !i.referencesRamps?.length && i.items.length > 0 && i.items.every((u) => u.type.kind === "color"),
|
|
76
76
|
preview: i.preview,
|
|
77
77
|
previewBase: i.previewBase,
|
|
78
78
|
rows: []
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
key: `${
|
|
80
|
+
t.tiers.push(y), i.items.forEach((u, V) => m(e, y, {
|
|
81
|
+
key: `${y.key}-item-${V}`,
|
|
82
82
|
tabId: e.id,
|
|
83
83
|
tierId: i.id,
|
|
84
|
-
itemId:
|
|
85
|
-
label:
|
|
86
|
-
cssVar:
|
|
87
|
-
kind:
|
|
84
|
+
itemId: u.id,
|
|
85
|
+
label: u.label,
|
|
86
|
+
cssVar: u.cssVar,
|
|
87
|
+
kind: u.type.kind,
|
|
88
88
|
source: "item",
|
|
89
|
-
defaultValue:
|
|
90
|
-
declaredValue:
|
|
89
|
+
defaultValue: u.default,
|
|
90
|
+
declaredValue: u.default,
|
|
91
91
|
cssValue: null,
|
|
92
92
|
resolvedValue: null,
|
|
93
93
|
references: [],
|
|
94
94
|
diagnostics: []
|
|
95
|
-
},
|
|
95
|
+
}, u, i));
|
|
96
96
|
});
|
|
97
97
|
const n = e.colorExtras;
|
|
98
98
|
if (!n) return;
|
|
99
99
|
const d = {
|
|
100
|
-
key: `${
|
|
100
|
+
key: `${t.key}-base-roles`,
|
|
101
101
|
id: "base-roles",
|
|
102
102
|
label: "Base roles",
|
|
103
103
|
rows: []
|
|
@@ -105,8 +105,8 @@ function B(l, u = "light") {
|
|
|
105
105
|
for (const i of O) {
|
|
106
106
|
const w = n.baseRoles[i];
|
|
107
107
|
if (w === void 0) continue;
|
|
108
|
-
const
|
|
109
|
-
|
|
108
|
+
const y = n.baseDefaults[i];
|
|
109
|
+
m(e, d, {
|
|
110
110
|
key: `${d.key}-${i}`,
|
|
111
111
|
tabId: e.id,
|
|
112
112
|
tierId: d.id,
|
|
@@ -115,147 +115,147 @@ function B(l, u = "light") {
|
|
|
115
115
|
cssVar: w,
|
|
116
116
|
kind: "color",
|
|
117
117
|
source: "base-role",
|
|
118
|
-
defaultValue:
|
|
119
|
-
declaredValue:
|
|
118
|
+
defaultValue: y === void 0 ? "" : String(y),
|
|
119
|
+
declaredValue: y === void 0 ? "(no declared default)" : `palette[${y}]`,
|
|
120
120
|
cssValue: null,
|
|
121
121
|
resolvedValue: null,
|
|
122
122
|
references: [],
|
|
123
123
|
diagnostics: []
|
|
124
124
|
}, void 0, void 0, i);
|
|
125
125
|
}
|
|
126
|
-
d.rows.length > 0 &&
|
|
126
|
+
d.rows.length > 0 && t.tiers.push(d);
|
|
127
127
|
});
|
|
128
|
-
const
|
|
129
|
-
for (const e of
|
|
130
|
-
j.test(e.row.cssVar) ||
|
|
131
|
-
function
|
|
132
|
-
e.directReference =
|
|
128
|
+
const k = D(r, (e) => e.row.cssVar);
|
|
129
|
+
for (const e of r)
|
|
130
|
+
j.test(e.row.cssVar) || a(e, "invalid-variable", `Unsupported CSS custom property name: ${e.row.cssVar}.`), k.get(e.row.cssVar).length > 1 && a(e, "duplicate-variable", `Multiple declarations use ${e.row.cssVar}; none is selected.`), c.get(e.tab.id).length > 1 && a(e, "duplicate-tab", `Multiple tabs use the id ${e.tab.id}.`), e.tier && (e.tab.tiers.filter((s) => s.id === e.tier.id).length > 1 && a(e, "duplicate-tier", `Multiple tiers use the id ${e.tier.id} in tab ${e.tab.id}.`), e.tier.items.filter((s) => s.id === e.item.id).length > 1 && a(e, "duplicate-item", `Multiple items use the id ${e.item.id} in tier ${e.tier.id}.`));
|
|
131
|
+
function g(e, s) {
|
|
132
|
+
e.directReference = s, e.row.cssValue = `var(${s.row.cssVar})`;
|
|
133
133
|
}
|
|
134
|
-
function p(e,
|
|
135
|
-
const d =
|
|
134
|
+
function p(e, s, t, n) {
|
|
135
|
+
const d = c.get(s) ?? [];
|
|
136
136
|
if (d.length !== 1) {
|
|
137
|
-
|
|
137
|
+
a(e, d.length ? "ambiguous-reference" : "missing-reference", `Reference tab ${s} ${d.length ? "is ambiguous" : "does not exist"}.`);
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
const i = d[0].tiers.filter((
|
|
140
|
+
const i = d[0].tiers.filter((y) => y.id === t);
|
|
141
141
|
if (i.length !== 1) {
|
|
142
|
-
|
|
142
|
+
a(e, i.length ? "ambiguous-reference" : "missing-reference", `Reference tier ${s}/${t} ${i.length ? "is ambiguous" : "does not exist"}.`);
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
const w =
|
|
145
|
+
const w = r.filter((y) => y.tab === d[0] && y.tier === i[0] && y.item?.id === n);
|
|
146
146
|
if (w.length !== 1) {
|
|
147
|
-
|
|
147
|
+
a(e, w.length ? "ambiguous-reference" : "missing-reference", `Reference item ${s}/${t}/${n} ${w.length ? "is ambiguous" : "does not exist"}.`);
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
return w[0];
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
return e.tab.tiers.filter((
|
|
152
|
+
function b(e) {
|
|
153
|
+
return e.tab.tiers.filter((s) => !s.semantic && !s.referencesTier && s.items.length > 0 && s.items.every((t) => t.type.kind === "color"));
|
|
154
154
|
}
|
|
155
|
-
function z(e,
|
|
156
|
-
const
|
|
155
|
+
function z(e, s) {
|
|
156
|
+
const t = b(e), n = e.tier?.referencesTier ? t.filter((w) => w.id === e.tier.referencesTier) : t;
|
|
157
157
|
if (n.length !== 1) {
|
|
158
|
-
|
|
158
|
+
a(e, "unsupported-palette", `A palette index requires one unambiguous declared palette tier; found ${n.length}.`);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
-
if (!Number.isInteger(
|
|
162
|
-
|
|
161
|
+
if (!Number.isInteger(s) || s < 0 || s >= n[0].items.length) {
|
|
162
|
+
a(e, "invalid-palette-index", `Palette index ${s} is outside the declared palette.`);
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
const d = n[0].items[
|
|
166
|
-
i &&
|
|
165
|
+
const d = n[0].items[s], i = p(e, e.tab.id, n[0].id, d.id);
|
|
166
|
+
i && g(e, i);
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
const
|
|
170
|
-
if (
|
|
171
|
-
|
|
168
|
+
function x(e, s) {
|
|
169
|
+
const t = e.tab.colorExtras?.baseDefaults[s];
|
|
170
|
+
if (t === void 0) {
|
|
171
|
+
a(e, "missing-base-default", `Base role ${s} has no explicit baseDefaults mapping.`);
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
|
-
z(e,
|
|
174
|
+
z(e, t);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
if (typeof
|
|
178
|
-
e.row.declaredValue = `palette[${
|
|
179
|
-
else if (
|
|
180
|
-
e.row.declaredValue =
|
|
181
|
-
else if (typeof
|
|
182
|
-
const
|
|
183
|
-
e.row.declaredValue =
|
|
184
|
-
} else if (typeof
|
|
185
|
-
const { tab:
|
|
186
|
-
e.row.declaredValue = `${
|
|
187
|
-
const i = p(e,
|
|
188
|
-
i &&
|
|
176
|
+
function $(e, s) {
|
|
177
|
+
if (typeof s == "number")
|
|
178
|
+
e.row.declaredValue = `palette[${s}]`, z(e, s);
|
|
179
|
+
else if (s === "bg" || s === "fg")
|
|
180
|
+
e.row.declaredValue = s, x(e, s === "bg" ? "background" : "foreground");
|
|
181
|
+
else if (typeof s == "object" && s !== null && "literal" in s) {
|
|
182
|
+
const t = typeof s.literal == "string" ? s.literal : s.literal[f];
|
|
183
|
+
e.row.declaredValue = t, e.row.cssValue = t;
|
|
184
|
+
} else if (typeof s == "object" && s !== null && "ref" in s) {
|
|
185
|
+
const { tab: t = e.tab.id, tier: n, item: d } = s.ref;
|
|
186
|
+
e.row.declaredValue = `${t}/${n}/${d}`;
|
|
187
|
+
const i = p(e, t, n, d);
|
|
188
|
+
i && g(e, i);
|
|
189
189
|
} else
|
|
190
|
-
|
|
190
|
+
a(e, "invalid-semantic-default", "Unsupported semantic default mapping.");
|
|
191
191
|
}
|
|
192
|
-
for (const e of
|
|
192
|
+
for (const e of r) {
|
|
193
193
|
if (e.baseRole) {
|
|
194
|
-
|
|
194
|
+
x(e, e.baseRole);
|
|
195
195
|
continue;
|
|
196
196
|
}
|
|
197
|
-
const
|
|
198
|
-
if (d &&
|
|
199
|
-
|
|
197
|
+
const s = e.tier, t = e.item, n = b(e), d = s.semantic || e.tab.colorExtras && n.some((u) => u.id === s.referencesTier), w = (s.referencesTier === void 0 ? n : n.filter((u) => u.id === s.referencesTier)).flatMap((u) => u.items.filter((V) => V.id === t.default).map(() => u)), y = e.tab.colorExtras?.semanticDefaults;
|
|
198
|
+
if (d && y && Object.hasOwn(y, t.id))
|
|
199
|
+
$(e, y[t.id]);
|
|
200
200
|
else if (d && w.length > 0)
|
|
201
201
|
if (w.length > 1)
|
|
202
|
-
|
|
202
|
+
a(e, "ambiguous-reference", `Default ${t.default} names multiple palette items.`);
|
|
203
203
|
else {
|
|
204
|
-
const
|
|
205
|
-
|
|
204
|
+
const u = p(e, e.tab.id, w[0].id, t.default);
|
|
205
|
+
u && g(e, u);
|
|
206
206
|
}
|
|
207
|
-
else if (d && (
|
|
208
|
-
|
|
209
|
-
else if (
|
|
210
|
-
const
|
|
211
|
-
|
|
207
|
+
else if (d && (t.default === "bg" || t.default === "fg"))
|
|
208
|
+
x(e, t.default === "bg" ? "background" : "foreground");
|
|
209
|
+
else if (s.referencesTier !== void 0 && !(d && s.referencesRamps?.length) && !(s.semantic && C(t.default))) {
|
|
210
|
+
const u = p(e, e.tab.id, s.referencesTier, t.default);
|
|
211
|
+
u && g(e, u);
|
|
212
212
|
} else if (d)
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
213
|
+
if (s.referencesRamps?.length && !C(t.default)) {
|
|
214
|
+
const u = t.default.indexOf(":"), V = u === -1 ? [s.referencesRamps[0]] : s.referencesRamps.filter((R) => R.tier === t.default.slice(0, u));
|
|
215
215
|
if (V.length !== 1)
|
|
216
|
-
|
|
216
|
+
a(e, V.length ? "ambiguous-reference" : "missing-reference", `Ramp source for ${t.default} ${V.length ? "is ambiguous" : "does not exist"}.`);
|
|
217
217
|
else {
|
|
218
|
-
const
|
|
219
|
-
|
|
218
|
+
const R = p(e, V[0].tab ?? e.tab.id, V[0].tier, u === -1 ? t.default : t.default.slice(u + 1));
|
|
219
|
+
R && g(e, R);
|
|
220
220
|
}
|
|
221
221
|
} else
|
|
222
|
-
e.row.cssValue =
|
|
222
|
+
e.row.cssValue = t.default;
|
|
223
223
|
else
|
|
224
|
-
e.row.cssValue =
|
|
224
|
+
e.row.cssValue = t.default;
|
|
225
225
|
}
|
|
226
|
-
for (const e of
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
|
|
226
|
+
for (const e of r) {
|
|
227
|
+
const s = e.row.cssValue;
|
|
228
|
+
if (s === null) continue;
|
|
229
|
+
const t = A(s);
|
|
230
|
+
if (!t.safe) {
|
|
231
|
+
a(e, "unsafe-css", "This declaration contains unsupported CSS syntax or a resource-loading function; preview omitted.");
|
|
232
232
|
continue;
|
|
233
233
|
}
|
|
234
234
|
e.directReference && e.dependencies.push(e.directReference);
|
|
235
|
-
for (const n of
|
|
236
|
-
const d =
|
|
237
|
-
d.length > 1 ?
|
|
235
|
+
for (const n of t.syntax.matchAll(/\bvar\(\s*(--[\w\u0080-\uffff-]+)\s*(?=[,)])/giu)) {
|
|
236
|
+
const d = k.get(n[1]) ?? [];
|
|
237
|
+
d.length > 1 ? a(e, "ambiguous-reference", `CSS reference ${n[1]} has multiple declarations.`) : d.length === 1 ? e.dependencies.push(d[0]) : (e.contextDependent = !0, a(e, "external-reference", `CSS reference ${n[1]} is not in this inventory; its value depends on the host context or fallback.`, "warning"));
|
|
238
238
|
}
|
|
239
|
-
e.dependencies = [...new Set(e.dependencies)], e.row.references = e.dependencies.map(({ row: n }) => ({ key: n.key, cssVar: n.cssVar, label: n.label })), /(?:^|[^\w-])(?:currentcolor|initial|inherit|unset|revert|revert-layer)(?=$|[^\w-])|\b(?:env|attr)\s*\(/i.test(
|
|
239
|
+
e.dependencies = [...new Set(e.dependencies)], e.row.references = e.dependencies.map(({ row: n }) => ({ key: n.key, cssVar: n.cssVar, label: n.label })), /(?:^|[^\w-])(?:currentcolor|initial|inherit|unset|revert|revert-layer)(?=$|[^\w-])|\b(?:env|attr)\s*\(/i.test(t.syntax) && (e.contextDependent = !0, a(e, "context-dependent", "This CSS value depends on the surrounding document; no computed preview is claimed.", "warning"));
|
|
240
240
|
}
|
|
241
|
-
const
|
|
241
|
+
const N = /* @__PURE__ */ new Set(), S = [];
|
|
242
242
|
function T(e) {
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
for (const
|
|
243
|
+
if (N.has(e)) return;
|
|
244
|
+
const s = S.indexOf(e);
|
|
245
|
+
if (s !== -1) {
|
|
246
|
+
for (const t of S.slice(s)) a(t, "cyclic-reference", "Declared references form a cycle.");
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
|
-
|
|
250
|
-
for (const
|
|
251
|
-
T(
|
|
252
|
-
|
|
249
|
+
S.push(e);
|
|
250
|
+
for (const t of e.dependencies)
|
|
251
|
+
T(t), t.row.diagnostics.some((n) => n.severity === "error") ? a(e, "invalid-reference", `Referenced declaration ${t.row.cssVar} is invalid.`) : t.contextDependent && (e.contextDependent = !0, a(e, "context-dependent", `Referenced declaration ${t.row.cssVar} depends on the host context.`, "warning"));
|
|
252
|
+
S.pop(), N.add(e), e.row.diagnostics.some((t) => t.severity === "error") ? e.row.cssValue = null : e.contextDependent || (e.row.resolvedValue = e.directReference?.row.resolvedValue ?? e.row.cssValue);
|
|
253
253
|
}
|
|
254
|
-
for (const e of
|
|
255
|
-
return o.declarations = Object.fromEntries(
|
|
254
|
+
for (const e of r) T(e);
|
|
255
|
+
return o.declarations = Object.fromEntries(r.filter((e) => e.row.cssValue !== null).map((e) => [e.row.cssVar, e.row.cssValue])), o;
|
|
256
256
|
}
|
|
257
|
-
function L(l,
|
|
258
|
-
return o?.[l.cssVar] ??
|
|
257
|
+
function L(l, f, o) {
|
|
258
|
+
return o?.[l.cssVar] ?? f.preview ?? (l.kind === "color" ? "color" : "text");
|
|
259
259
|
}
|
|
260
260
|
const M = `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
261
|
|
|
@@ -263,142 +263,143 @@ const M = `Good typography gives every idea room to breathe. Compare the rhythm
|
|
|
263
263
|
function E(l) {
|
|
264
264
|
return ["size", "family", "weight", "line-height"].includes(l);
|
|
265
265
|
}
|
|
266
|
-
function I(l,
|
|
266
|
+
function I(l, f) {
|
|
267
267
|
const o = /* @__PURE__ */ new Set();
|
|
268
|
-
let
|
|
269
|
-
for (;
|
|
270
|
-
o.add(
|
|
271
|
-
const
|
|
272
|
-
if (/^(?:0|\+?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))$/i.test(
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
|
|
268
|
+
let r = l;
|
|
269
|
+
for (; r.cssValue !== null && r.resolvedValue !== null && !o.has(r.key); ) {
|
|
270
|
+
o.add(r.key);
|
|
271
|
+
const h = r.resolvedValue.trim();
|
|
272
|
+
if (/^(?:0|\+?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))$/i.test(h)) return h;
|
|
273
|
+
const c = /^var\(\s*(--[a-zA-Z0-9_-]+)\s*\)$/.exec(h);
|
|
274
|
+
if (!c) return null;
|
|
275
|
+
const a = f.rows.filter((m) => m.cssVar === c[1]);
|
|
276
|
+
if (a.length !== 1) return null;
|
|
277
|
+
r = a[0];
|
|
278
278
|
}
|
|
279
279
|
return null;
|
|
280
280
|
}
|
|
281
|
-
function P({ row: l, tier:
|
|
281
|
+
function P({ row: l, tier: f, kind: o, model: r, previewText: h }) {
|
|
282
282
|
if (o === "bar") {
|
|
283
|
-
const
|
|
284
|
-
return
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
-
/* @__PURE__ */
|
|
283
|
+
const g = I(l, r);
|
|
284
|
+
return g === null ? /* @__PURE__ */ v("div", { className: "zdtp-dashboard__preview-unavailable", children: "Ruler unavailable: requires a nonnegative px/rem length or a resolved direct alias." }) : /* @__PURE__ */ _("div", { className: "zdtp-dashboard__ruler-wrap", children: [
|
|
285
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__ruler-caption", children: "Actual size · ticks every 8 CSS px · major ticks every 64 CSS px" }),
|
|
286
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__scroll zdtp-dashboard__ruler-scroll", role: "region", tabIndex: 0, "aria-label": `${l.label} (${l.cssVar}) actual-size ruler`, children: /* @__PURE__ */ _("div", { className: "zdtp-dashboard__ruler", style: { inlineSize: `max(100%, ${g})` }, children: [
|
|
287
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__ruler-origin", children: "0" }),
|
|
288
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__specimen", style: { colorScheme: r.mode }, children: /* @__PURE__ */ v("span", { className: "zdtp-dashboard__sample zdtp-dashboard__sample--bar", style: { inlineSize: g }, "aria-hidden": "true" }) })
|
|
289
289
|
] }) })
|
|
290
290
|
] });
|
|
291
291
|
}
|
|
292
292
|
if (l.cssValue === null || l.resolvedValue === null || o === "text" || o === "duration") return null;
|
|
293
|
-
const
|
|
294
|
-
if (!
|
|
293
|
+
const c = l.resolvedValue.trim().toLowerCase();
|
|
294
|
+
if (!c || (o === "radius" || o === "size") && (/^(?:auto|none|normal|(?:min|max)-content|stretch|content)$|^fit-content(?:\(|$)/.test(c) || /^[+-]?(?:\d*\.)?\d+(?:ms|s)$/.test(c) || /^[+-]?(?:\d*\.)?\d+$/.test(c) && Number(c) !== 0))
|
|
295
295
|
return null;
|
|
296
|
-
const
|
|
297
|
-
let
|
|
296
|
+
const a = l.cssValue;
|
|
297
|
+
let m;
|
|
298
298
|
switch (o) {
|
|
299
299
|
case "color":
|
|
300
|
-
|
|
300
|
+
m = { backgroundColor: a };
|
|
301
301
|
break;
|
|
302
302
|
case "radius":
|
|
303
|
-
|
|
303
|
+
m = { borderRadius: a };
|
|
304
304
|
break;
|
|
305
305
|
case "shadow":
|
|
306
|
-
|
|
306
|
+
m = { boxShadow: a };
|
|
307
307
|
break;
|
|
308
308
|
case "size":
|
|
309
|
-
|
|
309
|
+
m = { fontSize: a };
|
|
310
310
|
break;
|
|
311
311
|
case "family":
|
|
312
|
-
|
|
312
|
+
m = { fontFamily: a };
|
|
313
313
|
break;
|
|
314
314
|
case "weight":
|
|
315
|
-
|
|
315
|
+
m = { fontWeight: a };
|
|
316
316
|
break;
|
|
317
317
|
case "line-height": {
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
const g = r.rows.find((p) => p.cssVar === f.previewBase);
|
|
319
|
+
m = { lineHeight: a, ...g?.cssValue !== null && g?.resolvedValue != null ? { fontSize: `var(${g.cssVar})` } : {} };
|
|
320
320
|
break;
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
const
|
|
324
|
-
return /* @__PURE__ */
|
|
323
|
+
const k = E(o);
|
|
324
|
+
return /* @__PURE__ */ v(
|
|
325
325
|
"div",
|
|
326
326
|
{
|
|
327
|
-
className: `zdtp-dashboard__preview zdtp-dashboard__preview--${o}${
|
|
328
|
-
"aria-hidden":
|
|
329
|
-
role:
|
|
330
|
-
tabIndex:
|
|
331
|
-
"aria-label":
|
|
332
|
-
children: /* @__PURE__ */
|
|
327
|
+
className: `zdtp-dashboard__preview zdtp-dashboard__preview--${o}${k ? " zdtp-dashboard__preview--typography zdtp-dashboard__scroll" : ""}`,
|
|
328
|
+
"aria-hidden": k ? void 0 : "true",
|
|
329
|
+
role: k ? "region" : void 0,
|
|
330
|
+
tabIndex: k ? 0 : void 0,
|
|
331
|
+
"aria-label": k ? `${l.label} (${l.cssVar}) typography specimen` : void 0,
|
|
332
|
+
children: /* @__PURE__ */ v("div", { className: "zdtp-dashboard__specimen", style: { colorScheme: r.mode }, children: /* @__PURE__ */ v("span", { className: `zdtp-dashboard__sample zdtp-dashboard__sample--${o}`, style: m, children: k ? h : "" }) })
|
|
333
333
|
}
|
|
334
334
|
);
|
|
335
335
|
}
|
|
336
336
|
function W({
|
|
337
337
|
tabs: l,
|
|
338
|
-
mode:
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
338
|
+
mode: f = "light",
|
|
339
|
+
chrome: o = "light",
|
|
340
|
+
title: r = "Token dashboard",
|
|
341
|
+
id: h,
|
|
342
|
+
previewOverrides: c,
|
|
343
|
+
previewText: a = M
|
|
343
344
|
}) {
|
|
344
|
-
const
|
|
345
|
-
return /* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */
|
|
347
|
-
/* @__PURE__ */
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
/* @__PURE__ */
|
|
350
|
-
|
|
345
|
+
const m = B(l, f), k = m.rows.filter((g) => g.diagnostics.length > 0).length;
|
|
346
|
+
return /* @__PURE__ */ _("div", { id: h, className: "zdtp-dashboard", role: "region", "aria-label": r, "data-mode": f, "data-chrome": o, children: [
|
|
347
|
+
/* @__PURE__ */ _("div", { className: "zdtp-dashboard__header", children: [
|
|
348
|
+
/* @__PURE__ */ v("div", { role: "heading", "aria-level": 2, className: "zdtp-dashboard__title", children: r }),
|
|
349
|
+
/* @__PURE__ */ _("div", { className: "zdtp-dashboard__summary", children: [
|
|
350
|
+
/* @__PURE__ */ _("span", { className: "zdtp-dashboard__count", children: [
|
|
351
|
+
m.rows.length,
|
|
351
352
|
" tokens"
|
|
352
353
|
] }),
|
|
353
|
-
/* @__PURE__ */
|
|
354
|
+
/* @__PURE__ */ _("span", { children: [
|
|
354
355
|
"Declared defaults · ",
|
|
355
|
-
|
|
356
|
+
f,
|
|
356
357
|
" mode"
|
|
357
358
|
] }),
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
k > 0 && /* @__PURE__ */ _("span", { children: [
|
|
360
|
+
k,
|
|
360
361
|
" with diagnostics"
|
|
361
362
|
] })
|
|
362
363
|
] })
|
|
363
364
|
] }),
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
/* @__PURE__ */
|
|
368
|
-
/* @__PURE__ */
|
|
369
|
-
/* @__PURE__ */
|
|
370
|
-
|
|
365
|
+
/* @__PURE__ */ _("div", { className: "zdtp-dashboard__inventory", style: m.declarations, children: [
|
|
366
|
+
m.rows.length === 0 && /* @__PURE__ */ v("div", { className: "zdtp-dashboard__empty", children: "No tokens declared." }),
|
|
367
|
+
m.tabs.map((g) => /* @__PURE__ */ _("div", { className: "zdtp-dashboard__tab", role: "group", "aria-label": g.label, children: [
|
|
368
|
+
/* @__PURE__ */ _("div", { className: "zdtp-dashboard__tab-header", children: [
|
|
369
|
+
/* @__PURE__ */ v("div", { role: "heading", "aria-level": 3, className: "zdtp-dashboard__tab-title", children: g.label }),
|
|
370
|
+
/* @__PURE__ */ _("span", { className: "zdtp-dashboard__tab-count", children: [
|
|
371
|
+
g.tiers.reduce((p, b) => p + b.rows.length, 0),
|
|
371
372
|
" tokens"
|
|
372
373
|
] })
|
|
373
374
|
] }),
|
|
374
|
-
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
const
|
|
378
|
-
return /* @__PURE__ */
|
|
379
|
-
/* @__PURE__ */
|
|
380
|
-
/* @__PURE__ */
|
|
381
|
-
/* @__PURE__ */
|
|
382
|
-
/* @__PURE__ */
|
|
383
|
-
/* @__PURE__ */
|
|
384
|
-
|
|
375
|
+
g.tiers.map((p) => /* @__PURE__ */ _("div", { className: "zdtp-dashboard__tier", children: [
|
|
376
|
+
/* @__PURE__ */ v("div", { role: "heading", "aria-level": 4, className: "zdtp-dashboard__tier-title", children: p.label }),
|
|
377
|
+
/* @__PURE__ */ v("div", { className: p.palette ? "zdtp-dashboard__scroll zdtp-dashboard__palette-scroll" : void 0, role: p.palette ? "region" : void 0, tabIndex: p.palette ? 0 : void 0, "aria-label": p.palette ? `${p.label} palette stops` : void 0, children: /* @__PURE__ */ v("div", { className: `zdtp-dashboard__grid${p.palette ? " zdtp-dashboard__palette" : ""}`, role: "list", "aria-label": p.label, children: p.rows.map((b) => {
|
|
378
|
+
const z = L(b, p, c), x = !p.palette && (z === "bar" || E(z));
|
|
379
|
+
return /* @__PURE__ */ _("div", { className: `zdtp-dashboard__token${x ? " zdtp-dashboard__token--wide" : ""}`, role: "listitem", "data-css-var": b.cssVar, children: [
|
|
380
|
+
/* @__PURE__ */ v(P, { row: b, tier: p, kind: z, model: m, previewText: a }),
|
|
381
|
+
/* @__PURE__ */ _("div", { className: "zdtp-dashboard__token-content", children: [
|
|
382
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__name", children: b.label }),
|
|
383
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__variable", children: b.cssVar }),
|
|
384
|
+
/* @__PURE__ */ v("div", { className: "zdtp-dashboard__value", children: b.declaredValue || "(empty)" }),
|
|
385
|
+
b.cssValue !== null && b.cssValue !== b.declaredValue && /* @__PURE__ */ _("div", { className: "zdtp-dashboard__reference", children: [
|
|
385
386
|
"CSS: ",
|
|
386
|
-
|
|
387
|
+
b.cssValue
|
|
387
388
|
] }),
|
|
388
|
-
|
|
389
|
+
b.references.length > 0 && /* @__PURE__ */ _("div", { className: "zdtp-dashboard__reference", children: [
|
|
389
390
|
"References: ",
|
|
390
|
-
|
|
391
|
+
b.references.map(($) => $.cssVar).join(", ")
|
|
391
392
|
] }),
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
b.diagnostics.map(($, N) => /* @__PURE__ */ _("div", { className: "zdtp-dashboard__diagnostic", "data-diagnostic": $.code, children: [
|
|
394
|
+
$.severity === "error" ? "Unavailable" : "Context needed",
|
|
394
395
|
": ",
|
|
395
|
-
|
|
396
|
-
] },
|
|
396
|
+
$.message
|
|
397
|
+
] }, N))
|
|
397
398
|
] })
|
|
398
|
-
] },
|
|
399
|
+
] }, b.key);
|
|
399
400
|
}) }) })
|
|
400
|
-
] },
|
|
401
|
-
] },
|
|
401
|
+
] }, p.key))
|
|
402
|
+
] }, g.key))
|
|
402
403
|
] })
|
|
403
404
|
] });
|
|
404
405
|
}
|