@nonoun/native-ui 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components-lean.css +53 -0
- package/dist/components.css +53 -0
- package/dist/custom-elements.json +5013 -5013
- package/dist/define.js +62 -0
- package/dist/dialog-controller.js +30 -154
- package/dist/inspector.css +231 -0
- package/dist/inspector.d.ts +7 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +591 -0
- package/dist/kernel.js +182 -181
- package/dist/native-ui-lean.css +53 -0
- package/dist/native-ui.css +53 -0
- package/dist/native-ui.js +7 -5
- package/dist/nav/inspector/build-inspector.d.ts +8 -0
- package/dist/nav/inspector/build-inspector.d.ts.map +1 -0
- package/dist/nav/inspector/ds-color-swatch-element.d.ts +15 -0
- package/dist/nav/inspector/ds-color-swatch-element.d.ts.map +1 -0
- package/dist/nav/inspector/ds-color-swatch.d.ts +3 -0
- package/dist/nav/inspector/ds-color-swatch.d.ts.map +1 -0
- package/dist/nav/inspector/ds-colors-element.d.ts +14 -0
- package/dist/nav/inspector/ds-colors-element.d.ts.map +1 -0
- package/dist/nav/inspector/ds-colors.d.ts +4 -0
- package/dist/nav/inspector/ds-colors.d.ts.map +1 -0
- package/dist/nav/inspector/ds-themes-element.d.ts +13 -0
- package/dist/nav/inspector/ds-themes-element.d.ts.map +1 -0
- package/dist/nav/inspector/ds-themes.d.ts +4 -0
- package/dist/nav/inspector/ds-themes.d.ts.map +1 -0
- package/dist/nav/inspector/ds-variable-element.d.ts +19 -0
- package/dist/nav/inspector/ds-variable-element.d.ts.map +1 -0
- package/dist/nav/inspector/ds-variable.d.ts +4 -0
- package/dist/nav/inspector/ds-variable.d.ts.map +1 -0
- package/dist/nav/inspector/index.d.ts +9 -0
- package/dist/nav/inspector/index.d.ts.map +1 -0
- package/dist/register-all.js +1 -1
- package/dist/register-all2.js +25 -24
- package/dist/traits.js +5 -3
- package/dist/ui-element.js +128 -0
- package/dist/ui-icon-element.js +158 -156
- package/dist/uid.js +3 -63
- package/package.json +9 -3
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import { t as e } from "./uid.js";
|
|
2
|
+
import { t } from "./ui-element.js";
|
|
3
|
+
var n = class extends t {
|
|
4
|
+
static observedAttributes = ["data"];
|
|
5
|
+
#e = null;
|
|
6
|
+
#t = null;
|
|
7
|
+
#n = null;
|
|
8
|
+
attributeChangedCallback(e, t, n) {
|
|
9
|
+
if (t !== n && e === "data" && n) {
|
|
10
|
+
try {
|
|
11
|
+
this.#e = JSON.parse(n);
|
|
12
|
+
} catch {}
|
|
13
|
+
this.#t && this.#a();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
setup() {
|
|
17
|
+
super.setup();
|
|
18
|
+
let e = this.getAttribute("data");
|
|
19
|
+
if (e) try {
|
|
20
|
+
this.#e = JSON.parse(e);
|
|
21
|
+
} catch {}
|
|
22
|
+
this.#a(), this.addEventListener("ds-theme-change", this.#r);
|
|
23
|
+
}
|
|
24
|
+
teardown() {
|
|
25
|
+
this.removeEventListener("ds-theme-change", this.#r), this.innerHTML = "", this.#t = null, this.#n = null, super.teardown();
|
|
26
|
+
}
|
|
27
|
+
#r = () => {
|
|
28
|
+
requestAnimationFrame(() => this.#i());
|
|
29
|
+
};
|
|
30
|
+
sync() {
|
|
31
|
+
this.#i();
|
|
32
|
+
}
|
|
33
|
+
#i() {
|
|
34
|
+
if (!this.#e || !this.#t || !this.#n) return;
|
|
35
|
+
let e = getComputedStyle(document.documentElement).getPropertyValue(this.#e.token).trim();
|
|
36
|
+
if (e) {
|
|
37
|
+
this.#t.value = parseFloat(e);
|
|
38
|
+
let t = this.#e.step ?? .01;
|
|
39
|
+
this.#n.textContent = parseFloat(e).toFixed(t < .01 ? 3 : 2);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
#a() {
|
|
43
|
+
if (!this.#e) return;
|
|
44
|
+
let e = this.#e;
|
|
45
|
+
this.innerHTML = "";
|
|
46
|
+
let t = document.createElement("div");
|
|
47
|
+
t.className = "ds-variable-row";
|
|
48
|
+
let n = document.createElement("label");
|
|
49
|
+
n.className = "ds-variable-label", n.textContent = e.name;
|
|
50
|
+
let r = document.createElement("ui-range");
|
|
51
|
+
r.setAttribute("min", String(e.min ?? 0)), r.setAttribute("max", String(e.max ?? 1)), r.setAttribute("step", String(e.step ?? .01)), r.setAttribute("size", "xs");
|
|
52
|
+
let i = getComputedStyle(document.documentElement).getPropertyValue(e.token).trim(), a = i ? parseFloat(i) : e.value;
|
|
53
|
+
r.setAttribute("value", String(a));
|
|
54
|
+
let o = e.step ?? .01, s = document.createElement("span");
|
|
55
|
+
s.className = "ds-variable-value", s.textContent = a.toFixed(o < .01 ? 3 : 2), r.addEventListener("ui-input", ((t) => {
|
|
56
|
+
let n = t.detail.value;
|
|
57
|
+
document.documentElement.style.setProperty(e.token, String(n)), s.textContent = n.toFixed(o < .01 ? 3 : 2), this.dispatchEvent(new CustomEvent("ds-change", {
|
|
58
|
+
bubbles: !0,
|
|
59
|
+
detail: {
|
|
60
|
+
token: e.token,
|
|
61
|
+
value: n
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
})), this.#t = r, this.#n = s, t.append(n, r, s), this.appendChild(t);
|
|
65
|
+
}
|
|
66
|
+
}, r = class extends t {
|
|
67
|
+
static observedAttributes = ["data"];
|
|
68
|
+
#e = [];
|
|
69
|
+
attributeChangedCallback(e, t, n) {
|
|
70
|
+
if (t !== n && e === "data" && n) {
|
|
71
|
+
try {
|
|
72
|
+
this.#e = JSON.parse(n);
|
|
73
|
+
} catch {}
|
|
74
|
+
this.isConnected && this.#n();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
setup() {
|
|
78
|
+
super.setup();
|
|
79
|
+
let e = this.getAttribute("data");
|
|
80
|
+
if (e) try {
|
|
81
|
+
this.#e = JSON.parse(e);
|
|
82
|
+
} catch {}
|
|
83
|
+
this.#n(), this.addEventListener("ds-change", this.#t), this.addEventListener("ds-theme-change", this.#t);
|
|
84
|
+
}
|
|
85
|
+
teardown() {
|
|
86
|
+
this.removeEventListener("ds-change", this.#t), this.removeEventListener("ds-theme-change", this.#t), this.innerHTML = "", super.teardown();
|
|
87
|
+
}
|
|
88
|
+
#t = () => {
|
|
89
|
+
requestAnimationFrame(() => this.#r());
|
|
90
|
+
};
|
|
91
|
+
refresh() {
|
|
92
|
+
this.#r();
|
|
93
|
+
}
|
|
94
|
+
#n() {
|
|
95
|
+
this.innerHTML = "";
|
|
96
|
+
let e = document.createElement("div");
|
|
97
|
+
e.className = "ds-colors-strip";
|
|
98
|
+
for (let t of this.#e) {
|
|
99
|
+
let n = document.createElement("ds-color-swatch");
|
|
100
|
+
n.setAttribute("token", t.token), n.setAttribute("name", t.name), e.appendChild(n);
|
|
101
|
+
}
|
|
102
|
+
this.appendChild(e);
|
|
103
|
+
}
|
|
104
|
+
#r() {
|
|
105
|
+
this.querySelectorAll("ds-color-swatch").forEach((e) => e.refresh());
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/** Parse a computed `rgb(...)` / `rgba(...)` string into [r, g, b, a] (0–255, 0–1). */
|
|
109
|
+
function i(e) {
|
|
110
|
+
let t = e.match(/[\d.]+/g);
|
|
111
|
+
return !t || t.length < 3 ? [
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
0,
|
|
115
|
+
1
|
|
116
|
+
] : [
|
|
117
|
+
Number(t[0]),
|
|
118
|
+
Number(t[1]),
|
|
119
|
+
Number(t[2]),
|
|
120
|
+
t[3] === void 0 ? 1 : Number(t[3])
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
/** Relative luminance (ITU-R BT.709). Returns true if light. */
|
|
124
|
+
function a(e, t, n) {
|
|
125
|
+
let r = [
|
|
126
|
+
e,
|
|
127
|
+
t,
|
|
128
|
+
n
|
|
129
|
+
].map((e) => (e /= 255, e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4));
|
|
130
|
+
return .2126 * r[0] + .7152 * r[1] + .0722 * r[2] > .4;
|
|
131
|
+
}
|
|
132
|
+
/** Convert 0–255 component to 2-digit hex. */
|
|
133
|
+
function o(e) {
|
|
134
|
+
return Math.round(e).toString(16).padStart(2, "0");
|
|
135
|
+
}
|
|
136
|
+
/** sRGB → linear. */
|
|
137
|
+
function s(e) {
|
|
138
|
+
return e /= 255, e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
139
|
+
}
|
|
140
|
+
/** linear → sRGB (0–1 range). */
|
|
141
|
+
/** sRGB (0–255) → OKLCH via OKLab. Returns [L (0–1), C, H (degrees)]. */
|
|
142
|
+
function c(e, t, n) {
|
|
143
|
+
let r = s(e), i = s(t), a = s(n), o = .4122214708 * r + .5363325363 * i + .0514459929 * a, c = .2119034982 * r + .6806995451 * i + .1073969566 * a, l = .0883024619 * r + .2817188376 * i + .6299787005 * a, u = Math.cbrt(o), d = Math.cbrt(c), f = Math.cbrt(l), p = .2104542553 * u + .793617785 * d - .0040720468 * f, m = 1.9779984951 * u - 2.428592205 * d + .4505937099 * f, h = .0259040371 * u + .7827717662 * d - .808675766 * f, g = Math.sqrt(m * m + h * h), _ = Math.atan2(h, m) * (180 / Math.PI);
|
|
144
|
+
return _ < 0 && (_ += 360), [
|
|
145
|
+
p,
|
|
146
|
+
g,
|
|
147
|
+
_
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
/** sRGB (0–255) → HSL. Returns [H (0–360), S (0–100), L (0–100)]. */
|
|
151
|
+
function l(e, t, n) {
|
|
152
|
+
e /= 255, t /= 255, n /= 255;
|
|
153
|
+
let r = Math.max(e, t, n), i = Math.min(e, t, n), a = r - i, o = (r + i) / 2;
|
|
154
|
+
if (a === 0) return [
|
|
155
|
+
0,
|
|
156
|
+
0,
|
|
157
|
+
o * 100
|
|
158
|
+
];
|
|
159
|
+
let s = a / (1 - Math.abs(2 * o - 1)), c = 0;
|
|
160
|
+
return c = r === e ? ((t - n) / a + 6) % 6 : r === t ? (n - e) / a + 2 : (e - t) / a + 4, [
|
|
161
|
+
c * 60,
|
|
162
|
+
s * 100,
|
|
163
|
+
o * 100
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
/** sRGB (0–255) → HSB/HSV. Returns [H (0–360), S (0–100), B (0–100)]. */
|
|
167
|
+
function u(e, t, n) {
|
|
168
|
+
e /= 255, t /= 255, n /= 255;
|
|
169
|
+
let r = Math.max(e, t, n), i = r - Math.min(e, t, n), a = r * 100;
|
|
170
|
+
if (r === 0) return [
|
|
171
|
+
0,
|
|
172
|
+
0,
|
|
173
|
+
a
|
|
174
|
+
];
|
|
175
|
+
let o = i / r * 100, s = 0;
|
|
176
|
+
return i !== 0 && (s = r === e ? ((t - n) / i + 6) % 6 : r === t ? (n - e) / i + 2 : (e - t) / i + 4, s *= 60), [
|
|
177
|
+
s,
|
|
178
|
+
o,
|
|
179
|
+
a
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
function d(e, t, n, r) {
|
|
183
|
+
let [i, a, o] = c(e, t, n), s = `oklch(${(i * 100).toFixed(1)}% ${a.toFixed(4)} ${o.toFixed(1)})`;
|
|
184
|
+
return r < 1 ? `oklch(${(i * 100).toFixed(1)}% ${a.toFixed(4)} ${o.toFixed(1)} / ${r.toFixed(2)})` : s;
|
|
185
|
+
}
|
|
186
|
+
function f(e, t, n, r) {
|
|
187
|
+
let i = `#${o(e)}${o(t)}${o(n)}`;
|
|
188
|
+
return r < 1 ? `${i}${o(Math.round(r * 255))}` : i;
|
|
189
|
+
}
|
|
190
|
+
function p(e, t, n, r) {
|
|
191
|
+
return r < 1 ? `rgba(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)}, ${r.toFixed(2)})` : `rgb(${Math.round(e)}, ${Math.round(t)}, ${Math.round(n)})`;
|
|
192
|
+
}
|
|
193
|
+
function m(e, t, n, r) {
|
|
194
|
+
let [i, a, o] = l(e, t, n);
|
|
195
|
+
return r < 1 ? `hsla(${i.toFixed(0)}, ${a.toFixed(1)}%, ${o.toFixed(1)}%, ${r.toFixed(2)})` : `hsl(${i.toFixed(0)}, ${a.toFixed(1)}%, ${o.toFixed(1)}%)`;
|
|
196
|
+
}
|
|
197
|
+
function h(e, t, n, r) {
|
|
198
|
+
let [i, a, o] = u(e, t, n);
|
|
199
|
+
return `hsb(${i.toFixed(0)}, ${a.toFixed(1)}%, ${o.toFixed(1)}%)`;
|
|
200
|
+
}
|
|
201
|
+
var g = [
|
|
202
|
+
{
|
|
203
|
+
label: "OKLCH",
|
|
204
|
+
fn: d
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
label: "HEX",
|
|
208
|
+
fn: f
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
label: "RGB",
|
|
212
|
+
fn: p
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
label: "HSL",
|
|
216
|
+
fn: m
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
label: "HSB",
|
|
220
|
+
fn: h
|
|
221
|
+
}
|
|
222
|
+
], _ = class extends t {
|
|
223
|
+
static observedAttributes = ["token", "name"];
|
|
224
|
+
#e = null;
|
|
225
|
+
#t = null;
|
|
226
|
+
#n = "";
|
|
227
|
+
get token() {
|
|
228
|
+
return this.getAttribute("token") ?? "";
|
|
229
|
+
}
|
|
230
|
+
set token(e) {
|
|
231
|
+
this.setAttribute("token", e);
|
|
232
|
+
}
|
|
233
|
+
get name() {
|
|
234
|
+
return this.getAttribute("name") ?? "";
|
|
235
|
+
}
|
|
236
|
+
set name(e) {
|
|
237
|
+
this.setAttribute("name", e);
|
|
238
|
+
}
|
|
239
|
+
attributeChangedCallback(e, t, n) {
|
|
240
|
+
t !== n && (e === "token" && this.isConnected && (this.style.background = n ? `var(${n})` : "", this.title = `${this.name}\n${n}`, requestAnimationFrame(() => this.#a())), e === "name" && this.#t && (this.#t.textContent = n ?? "", this.title = `${n}\n${this.token}`));
|
|
241
|
+
}
|
|
242
|
+
setup() {
|
|
243
|
+
super.setup(), this.token && (this.style.background = `var(${this.token})`, this.title = `${this.name}\n${this.token}`);
|
|
244
|
+
let t = document.createElement("span");
|
|
245
|
+
t.className = "ds-swatch-label", t.textContent = this.name, this.#t = t, this.appendChild(t), this.#n = e("swatch"), this.style.setProperty("anchor-name", `--${this.#n}`);
|
|
246
|
+
let n = document.createElement("div");
|
|
247
|
+
n.className = "ds-swatch-popover", n.setAttribute("popover", "auto"), n.style.setProperty("position-anchor", `--${this.#n}`), this.#e = n, this.appendChild(n), this.addEventListener("click", this.#i), this.addEventListener("ds-change", this.#r), this.addEventListener("ds-theme-change", this.#r), requestAnimationFrame(() => this.#a());
|
|
248
|
+
}
|
|
249
|
+
teardown() {
|
|
250
|
+
this.removeEventListener("click", this.#i), this.removeEventListener("ds-change", this.#r), this.removeEventListener("ds-theme-change", this.#r), this.#e = null, this.#t = null, this.innerHTML = "", super.teardown();
|
|
251
|
+
}
|
|
252
|
+
/** Refresh background and contrast from current token value. */
|
|
253
|
+
refresh() {
|
|
254
|
+
this.token && (this.style.background = `var(${this.token})`), this.#a();
|
|
255
|
+
}
|
|
256
|
+
#r = () => {
|
|
257
|
+
requestAnimationFrame(() => this.refresh());
|
|
258
|
+
};
|
|
259
|
+
#i = (e) => {
|
|
260
|
+
if (!(this.#e && e.target.closest(".ds-swatch-popover")) && this.#e) {
|
|
261
|
+
this.#o();
|
|
262
|
+
try {
|
|
263
|
+
this.#e.showPopover();
|
|
264
|
+
} catch {}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
#a() {
|
|
268
|
+
let e = getComputedStyle(this).backgroundColor, [t, n, r] = i(e);
|
|
269
|
+
this.#t && (this.#t.style.color = a(t, n, r) ? "rgba(0,0,0,0.55)" : "rgba(255,255,255,0.7)");
|
|
270
|
+
}
|
|
271
|
+
#o() {
|
|
272
|
+
if (!this.#e) return;
|
|
273
|
+
this.#e.innerHTML = "";
|
|
274
|
+
let e = getComputedStyle(this).backgroundColor, [t, n, r, a] = i(e), o = document.createElement("div");
|
|
275
|
+
o.className = "ds-swatch-popover-header", o.textContent = this.token, this.#e.appendChild(o);
|
|
276
|
+
for (let e of g) {
|
|
277
|
+
let i = e.fn(t, n, r, a), o = document.createElement("button");
|
|
278
|
+
o.className = "ds-swatch-popover-row", o.type = "button";
|
|
279
|
+
let s = document.createElement("span");
|
|
280
|
+
s.className = "ds-swatch-popover-label", s.textContent = e.label;
|
|
281
|
+
let c = document.createElement("span");
|
|
282
|
+
c.className = "ds-swatch-popover-value", c.textContent = i, o.append(s, c), o.addEventListener("click", (e) => {
|
|
283
|
+
e.stopPropagation(), navigator.clipboard.writeText(i).then(() => {
|
|
284
|
+
c.textContent = "Copied!", setTimeout(() => {
|
|
285
|
+
c.textContent = i;
|
|
286
|
+
}, 1200);
|
|
287
|
+
});
|
|
288
|
+
}), this.#e.appendChild(o);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}, v = /* @__PURE__ */ "color-env-lightness-min.color-env-lightness-max.color-env-lightness-delta.color-env-chroma.color-env-chroma-k-muted.color-env-chroma-k-vivid.color-env-chroma-k-edge.color-env-alpha.color-env-alpha-delta.color-env-hue-neutral.color-env-chroma-neutral.color-env-lightness-neutral.color-env-hue-accent.color-env-chroma-accent.color-env-lightness-accent.color-env-hue-info.color-env-chroma-info.color-env-lightness-info.color-env-hue-success.color-env-chroma-success.color-env-lightness-success.color-env-hue-warning.color-env-chroma-warning.color-env-lightness-warning.color-env-hue-danger.color-env-chroma-danger.color-env-lightness-danger".split("."), y = class extends t {
|
|
292
|
+
static observedAttributes = ["data"];
|
|
293
|
+
#e = [];
|
|
294
|
+
attributeChangedCallback(e, t, n) {
|
|
295
|
+
if (t !== n && e === "data" && n) {
|
|
296
|
+
try {
|
|
297
|
+
this.#e = JSON.parse(n);
|
|
298
|
+
} catch {}
|
|
299
|
+
this.isConnected && this.#t();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
setup() {
|
|
303
|
+
super.setup();
|
|
304
|
+
let e = this.getAttribute("data");
|
|
305
|
+
if (e) try {
|
|
306
|
+
this.#e = JSON.parse(e);
|
|
307
|
+
} catch {}
|
|
308
|
+
this.#t();
|
|
309
|
+
}
|
|
310
|
+
teardown() {
|
|
311
|
+
this.innerHTML = "", super.teardown();
|
|
312
|
+
}
|
|
313
|
+
#t() {
|
|
314
|
+
this.innerHTML = "";
|
|
315
|
+
let e = document.documentElement.getAttribute("theme") ?? "", t = document.createElement("ui-combobox");
|
|
316
|
+
t.setAttribute("size", "xs"), t.setAttribute("placeholder", "Theme..."), t.setAttribute("options", JSON.stringify(this.#e.map((e) => ({
|
|
317
|
+
value: e.value,
|
|
318
|
+
label: e.name
|
|
319
|
+
})))), t.setAttribute("value", e), t.addEventListener("ui-change", ((e) => {
|
|
320
|
+
this.#n(e.detail.value);
|
|
321
|
+
})), this.appendChild(t);
|
|
322
|
+
}
|
|
323
|
+
#n(e) {
|
|
324
|
+
let t = document.documentElement;
|
|
325
|
+
for (let e of v) t.style.removeProperty("--" + e);
|
|
326
|
+
e ? t.setAttribute("theme", e) : t.removeAttribute("theme"), this.dispatchEvent(new CustomEvent("ds-theme-change", {
|
|
327
|
+
bubbles: !0,
|
|
328
|
+
detail: { theme: e }
|
|
329
|
+
}));
|
|
330
|
+
}
|
|
331
|
+
}, b = [
|
|
332
|
+
{
|
|
333
|
+
name: "Default",
|
|
334
|
+
value: ""
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "Forest",
|
|
338
|
+
value: "forest"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: "Rose",
|
|
342
|
+
value: "rose"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: "Zinc",
|
|
346
|
+
value: "zinc"
|
|
347
|
+
}
|
|
348
|
+
], x = [
|
|
349
|
+
{
|
|
350
|
+
name: "L min",
|
|
351
|
+
token: "--color-env-lightness-min",
|
|
352
|
+
value: .15,
|
|
353
|
+
step: .01,
|
|
354
|
+
min: 0,
|
|
355
|
+
max: 1,
|
|
356
|
+
group: "Lightness"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "L max",
|
|
360
|
+
token: "--color-env-lightness-max",
|
|
361
|
+
value: 1,
|
|
362
|
+
step: .01,
|
|
363
|
+
min: 0,
|
|
364
|
+
max: 1,
|
|
365
|
+
group: "Lightness"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: "L delta",
|
|
369
|
+
token: "--color-env-lightness-delta",
|
|
370
|
+
value: .015,
|
|
371
|
+
step: .005,
|
|
372
|
+
min: 0,
|
|
373
|
+
max: .15,
|
|
374
|
+
group: "Lightness"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: "Chroma",
|
|
378
|
+
token: "--color-env-chroma",
|
|
379
|
+
value: .2,
|
|
380
|
+
step: .005,
|
|
381
|
+
min: 0,
|
|
382
|
+
max: .5,
|
|
383
|
+
group: "Chroma"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
name: "C muted",
|
|
387
|
+
token: "--color-env-chroma-k-muted",
|
|
388
|
+
value: .125,
|
|
389
|
+
step: .01,
|
|
390
|
+
min: 0,
|
|
391
|
+
max: 1,
|
|
392
|
+
group: "Chroma"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "C vivid",
|
|
396
|
+
token: "--color-env-chroma-k-vivid",
|
|
397
|
+
value: 1,
|
|
398
|
+
step: .01,
|
|
399
|
+
min: 0,
|
|
400
|
+
max: 1,
|
|
401
|
+
group: "Chroma"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
name: "C edge",
|
|
405
|
+
token: "--color-env-chroma-k-edge",
|
|
406
|
+
value: .05,
|
|
407
|
+
step: .01,
|
|
408
|
+
min: 0,
|
|
409
|
+
max: 1,
|
|
410
|
+
group: "Chroma"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: "Alpha",
|
|
414
|
+
token: "--color-env-alpha",
|
|
415
|
+
value: .85,
|
|
416
|
+
step: .01,
|
|
417
|
+
min: 0,
|
|
418
|
+
max: 1,
|
|
419
|
+
group: "Alpha"
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: "A delta",
|
|
423
|
+
token: "--color-env-alpha-delta",
|
|
424
|
+
value: .02,
|
|
425
|
+
step: .005,
|
|
426
|
+
min: 0,
|
|
427
|
+
max: .15,
|
|
428
|
+
group: "Alpha"
|
|
429
|
+
}
|
|
430
|
+
], S = [
|
|
431
|
+
"neutral",
|
|
432
|
+
"accent",
|
|
433
|
+
"info",
|
|
434
|
+
"success",
|
|
435
|
+
"warning",
|
|
436
|
+
"danger"
|
|
437
|
+
], C = [
|
|
438
|
+
"lowest",
|
|
439
|
+
"lower",
|
|
440
|
+
"low",
|
|
441
|
+
"base",
|
|
442
|
+
"high",
|
|
443
|
+
"higher",
|
|
444
|
+
"highest"
|
|
445
|
+
], w = [
|
|
446
|
+
"brightest",
|
|
447
|
+
"brighter",
|
|
448
|
+
"bright",
|
|
449
|
+
"base",
|
|
450
|
+
"dim",
|
|
451
|
+
"dimmer",
|
|
452
|
+
"dimmest"
|
|
453
|
+
], T = [
|
|
454
|
+
"1",
|
|
455
|
+
"2",
|
|
456
|
+
"3",
|
|
457
|
+
"4",
|
|
458
|
+
"5",
|
|
459
|
+
"6",
|
|
460
|
+
"7",
|
|
461
|
+
"8",
|
|
462
|
+
"9",
|
|
463
|
+
"10",
|
|
464
|
+
"11"
|
|
465
|
+
], E = [
|
|
466
|
+
"050",
|
|
467
|
+
"100",
|
|
468
|
+
"200",
|
|
469
|
+
"300",
|
|
470
|
+
"400",
|
|
471
|
+
"500",
|
|
472
|
+
"600",
|
|
473
|
+
"700",
|
|
474
|
+
"800",
|
|
475
|
+
"900",
|
|
476
|
+
"950"
|
|
477
|
+
], D = [
|
|
478
|
+
"strongest",
|
|
479
|
+
"stronger",
|
|
480
|
+
"strong",
|
|
481
|
+
"base",
|
|
482
|
+
"weak",
|
|
483
|
+
"weaker",
|
|
484
|
+
"weakest"
|
|
485
|
+
];
|
|
486
|
+
function O(e, t) {
|
|
487
|
+
let n = document.createElement("div");
|
|
488
|
+
n.className = "ds-inspector-section", t && (n.dataset.family = t);
|
|
489
|
+
let r = document.createElement("h3");
|
|
490
|
+
return r.className = "ds-inspector-heading", r.textContent = e, n.appendChild(r), n;
|
|
491
|
+
}
|
|
492
|
+
function k(e) {
|
|
493
|
+
let t = document.createElement("h4");
|
|
494
|
+
return t.className = "ds-inspector-subheading", t.textContent = e, t;
|
|
495
|
+
}
|
|
496
|
+
function A(e) {
|
|
497
|
+
let t = document.createElement("ds-colors");
|
|
498
|
+
return t.setAttribute("data", JSON.stringify(e)), t;
|
|
499
|
+
}
|
|
500
|
+
function j(e) {
|
|
501
|
+
let t = document.createElement("ds-variable");
|
|
502
|
+
return t.setAttribute("data", JSON.stringify({
|
|
503
|
+
name: e.name,
|
|
504
|
+
type: "number",
|
|
505
|
+
token: e.token,
|
|
506
|
+
value: e.value,
|
|
507
|
+
step: e.step,
|
|
508
|
+
min: e.min,
|
|
509
|
+
max: e.max
|
|
510
|
+
})), t;
|
|
511
|
+
}
|
|
512
|
+
function M(e) {
|
|
513
|
+
let t = document.createElement("div");
|
|
514
|
+
t.className = "ds-inspector-toolbar";
|
|
515
|
+
let n = document.createElement("ds-themes");
|
|
516
|
+
n.setAttribute("data", JSON.stringify(b)), t.appendChild(n);
|
|
517
|
+
let r = [{
|
|
518
|
+
value: "all",
|
|
519
|
+
label: "All Families"
|
|
520
|
+
}, ...S.map((e) => ({
|
|
521
|
+
value: e,
|
|
522
|
+
label: e.charAt(0).toUpperCase() + e.slice(1)
|
|
523
|
+
}))], i = document.createElement("ui-combobox");
|
|
524
|
+
i.setAttribute("size", "xs"), i.setAttribute("placeholder", "Family..."), i.setAttribute("options", JSON.stringify(r)), i.setAttribute("value", "all"), t.appendChild(i), e.appendChild(t);
|
|
525
|
+
let a = "", o = null;
|
|
526
|
+
for (let t of x) t.group !== a && (a = t.group, o = O(t.group, "env"), e.appendChild(o)), o.appendChild(j(t));
|
|
527
|
+
for (let t of S) {
|
|
528
|
+
let n = O(t.charAt(0).toUpperCase() + t.slice(1), t);
|
|
529
|
+
n.appendChild(j({
|
|
530
|
+
name: "Hue",
|
|
531
|
+
token: `--color-env-hue-${t}`,
|
|
532
|
+
value: 230,
|
|
533
|
+
step: 1,
|
|
534
|
+
min: 0,
|
|
535
|
+
max: 360
|
|
536
|
+
})), n.appendChild(j({
|
|
537
|
+
name: "Chroma",
|
|
538
|
+
token: `--color-env-chroma-${t}`,
|
|
539
|
+
value: .5,
|
|
540
|
+
step: .01,
|
|
541
|
+
min: 0,
|
|
542
|
+
max: 1
|
|
543
|
+
})), n.appendChild(j({
|
|
544
|
+
name: "Lightness",
|
|
545
|
+
token: `--color-env-lightness-${t}`,
|
|
546
|
+
value: .5,
|
|
547
|
+
step: .01,
|
|
548
|
+
min: 0,
|
|
549
|
+
max: 1
|
|
550
|
+
})), n.appendChild(k("Elevation")), n.appendChild(A(C.map((e) => ({
|
|
551
|
+
name: e,
|
|
552
|
+
token: `--${t}-${e}`
|
|
553
|
+
})))), n.appendChild(k("Brightness")), n.appendChild(A(w.map((e) => ({
|
|
554
|
+
name: e,
|
|
555
|
+
token: `--${t}-${e}`
|
|
556
|
+
})))), n.appendChild(k("Solid")), n.appendChild(A(T.map((e) => ({
|
|
557
|
+
name: e,
|
|
558
|
+
token: `--${t}-${e}`
|
|
559
|
+
})))), n.appendChild(k("Scrim")), n.appendChild(A(T.map((e) => ({
|
|
560
|
+
name: e,
|
|
561
|
+
token: `--${t}-${e}-scrim`
|
|
562
|
+
})))), n.appendChild(k("Semantic")), n.appendChild(A(E.map((e) => ({
|
|
563
|
+
name: e,
|
|
564
|
+
token: `--${t}-${e}`
|
|
565
|
+
})))), n.appendChild(k("Semantic Scrim")), n.appendChild(A(E.map((e) => ({
|
|
566
|
+
name: e,
|
|
567
|
+
token: `--${t}-${e}-scrim`
|
|
568
|
+
})))), n.appendChild(k("Tint")), n.appendChild(A(D.map((e) => ({
|
|
569
|
+
name: e,
|
|
570
|
+
token: `--${t}-scrim-tint-${e}`
|
|
571
|
+
})))), n.appendChild(k("Shade")), n.appendChild(A(D.map((e) => ({
|
|
572
|
+
name: e,
|
|
573
|
+
token: `--${t}-scrim-shade-${e}`
|
|
574
|
+
})))), e.appendChild(n);
|
|
575
|
+
}
|
|
576
|
+
i.addEventListener("ui-change", ((t) => {
|
|
577
|
+
let n = t.detail.value, r = e.querySelectorAll(".ds-inspector-section[data-family]");
|
|
578
|
+
for (let e of r) {
|
|
579
|
+
let t = e.dataset.family;
|
|
580
|
+
n === "all" || t === "env" ? e.hidden = !1 : e.hidden = t !== n;
|
|
581
|
+
}
|
|
582
|
+
requestAnimationFrame(() => {
|
|
583
|
+
e.querySelectorAll("ds-colors").forEach((e) => e.refresh());
|
|
584
|
+
});
|
|
585
|
+
})), e.addEventListener("ds-theme-change", () => {
|
|
586
|
+
requestAnimationFrame(() => {
|
|
587
|
+
e.querySelectorAll("ds-variable").forEach((e) => e.sync());
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
export { _ as DSColorSwatch, r as DSColors, y as DSThemes, n as DSVariable, M as buildInspector };
|