builder-settings-types 0.0.324 → 0.0.325
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.
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
const bt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
2
|
-
let mt = (
|
|
3
|
-
let t = "", e = crypto.getRandomValues(new Uint8Array(
|
|
4
|
-
for (;
|
|
5
|
-
t += bt[e[
|
|
2
|
+
let mt = (h = 21) => {
|
|
3
|
+
let t = "", e = crypto.getRandomValues(new Uint8Array(h |= 0));
|
|
4
|
+
for (; h--; )
|
|
5
|
+
t += bt[e[h] & 63];
|
|
6
6
|
return t;
|
|
7
7
|
};
|
|
8
|
-
function wt(
|
|
9
|
-
let t = 0, e =
|
|
8
|
+
function wt(h) {
|
|
9
|
+
let t = 0, e = h.parentElement;
|
|
10
10
|
for (; e; )
|
|
11
|
-
e.classList.contains("setting-group") && e !==
|
|
11
|
+
e.classList.contains("setting-group") && e !== h && t++, e = e.parentElement;
|
|
12
12
|
return t;
|
|
13
13
|
}
|
|
14
|
-
function Z(
|
|
14
|
+
function Z(h, t) {
|
|
15
15
|
const e = Math.min(Math.max(t, 0), 5);
|
|
16
|
-
|
|
16
|
+
h.setAttribute("data-nesting-level", e.toString()), e > 0 ? h.style.setProperty("--visual-indent", `${e * 2}px`) : (h.style.removeProperty("--visual-indent"), h.style.marginLeft = "");
|
|
17
17
|
}
|
|
18
|
-
function et(
|
|
19
|
-
|
|
18
|
+
function et(h, t = 0) {
|
|
19
|
+
h.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach((i) => {
|
|
20
20
|
const s = i, n = t + 1;
|
|
21
21
|
Z(s, n), et(s, n);
|
|
22
22
|
});
|
|
@@ -112,20 +112,20 @@ class Lt {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
const rt = new Lt();
|
|
115
|
-
function Y(
|
|
116
|
-
if (
|
|
117
|
-
if (
|
|
118
|
-
if (
|
|
119
|
-
if (typeof
|
|
115
|
+
function Y(h) {
|
|
116
|
+
if (h === null || typeof h != "object") return h;
|
|
117
|
+
if (h instanceof Date) return new Date(h.getTime());
|
|
118
|
+
if (h instanceof Array) return h.map((t) => Y(t));
|
|
119
|
+
if (typeof h == "object") {
|
|
120
120
|
const t = {};
|
|
121
|
-
for (const e in
|
|
122
|
-
Object.prototype.hasOwnProperty.call(
|
|
121
|
+
for (const e in h)
|
|
122
|
+
Object.prototype.hasOwnProperty.call(h, e) && (t[e] = Y(h[e]));
|
|
123
123
|
return t;
|
|
124
124
|
}
|
|
125
|
-
return
|
|
125
|
+
return h;
|
|
126
126
|
}
|
|
127
|
-
function kt(
|
|
128
|
-
switch (
|
|
127
|
+
function kt(h) {
|
|
128
|
+
switch (h) {
|
|
129
129
|
case "number":
|
|
130
130
|
return 0;
|
|
131
131
|
case "text":
|
|
@@ -262,79 +262,79 @@ M.currentLanguageExplicitlySet = !1, M.languageChangeCallbacks = /* @__PURE__ */
|
|
|
262
262
|
{ title: "Text Color", keys: ["text-dark", "text-light"] }
|
|
263
263
|
];
|
|
264
264
|
let x = M;
|
|
265
|
-
function G(
|
|
266
|
-
return
|
|
265
|
+
function G(h) {
|
|
266
|
+
return h instanceof x;
|
|
267
267
|
}
|
|
268
|
-
function k(
|
|
269
|
-
return
|
|
268
|
+
function k(h) {
|
|
269
|
+
return h instanceof $;
|
|
270
270
|
}
|
|
271
|
-
function ct(
|
|
272
|
-
return G(
|
|
271
|
+
function ct(h) {
|
|
272
|
+
return G(h) || k(h);
|
|
273
273
|
}
|
|
274
|
-
const ot = (
|
|
274
|
+
const ot = (h, t, e) => {
|
|
275
275
|
let i = !1, s = 0, n = 0, o = 0, a = 0;
|
|
276
|
-
const l = (
|
|
277
|
-
if (
|
|
278
|
-
i = !0, s =
|
|
279
|
-
const
|
|
280
|
-
o =
|
|
281
|
-
}, r = (
|
|
276
|
+
const l = (p) => {
|
|
277
|
+
if (p.target.closest("button")) return;
|
|
278
|
+
i = !0, s = p.clientX, n = p.clientY;
|
|
279
|
+
const d = t.getBoundingClientRect();
|
|
280
|
+
o = d.left, a = d.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup", c), document.body.style.userSelect = "none";
|
|
281
|
+
}, r = (p) => {
|
|
282
282
|
if (!i) return;
|
|
283
|
-
const
|
|
284
|
-
let
|
|
285
|
-
|
|
283
|
+
const d = p.clientX - s, g = p.clientY - n, C = window.innerWidth, m = window.innerHeight, u = t.offsetWidth, v = t.offsetHeight;
|
|
284
|
+
let f = o + d, y = a + g;
|
|
285
|
+
f = Math.max(8, Math.min(C - u - 8, f)), y = Math.max(8, Math.min(m - v - 8, y)), t.style.left = `${f}px`, t.style.top = `${y}px`, e == null || e(f, y);
|
|
286
286
|
}, c = () => {
|
|
287
287
|
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", c), document.body.style.userSelect = "";
|
|
288
288
|
};
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
if (!
|
|
292
|
-
let t =
|
|
289
|
+
h.addEventListener("mousedown", l);
|
|
290
|
+
}, F = (h) => {
|
|
291
|
+
if (!h) return null;
|
|
292
|
+
let t = h.trim();
|
|
293
293
|
return !t.startsWith("#") || (t = t.slice(1), t.length === 3 && (t = t.split("").map((e) => e + e).join("")), !/^[0-9a-fA-F]{6}$/.test(t)) ? null : `#${t.toUpperCase()}`;
|
|
294
|
-
}, X = (
|
|
295
|
-
const t =
|
|
294
|
+
}, X = (h, t, e) => `#${[h, t, e].map((i) => Math.max(0, Math.min(255, i)).toString(16).padStart(2, "0")).join("")}`, P = (h) => {
|
|
295
|
+
const t = h.replace("#", ""), e = t.length === 3 ? t.split("").map((i) => i + i).join("") : t;
|
|
296
296
|
return {
|
|
297
297
|
r: parseInt(e.slice(0, 2), 16),
|
|
298
298
|
g: parseInt(e.slice(2, 4), 16),
|
|
299
299
|
b: parseInt(e.slice(4, 6), 16)
|
|
300
300
|
};
|
|
301
|
-
},
|
|
302
|
-
const { r: t, g: e, b: i } = P(
|
|
301
|
+
}, U = (h) => {
|
|
302
|
+
const { r: t, g: e, b: i } = P(h), s = t / 255, n = e / 255, o = i / 255, a = Math.max(s, n, o), l = Math.min(s, n, o), r = a - l;
|
|
303
303
|
let c = 0;
|
|
304
304
|
r !== 0 && (a === s ? c = (n - o) / r % 6 : a === n ? c = (o - s) / r + 2 : c = (s - n) / r + 4), c < 0 && (c += 6);
|
|
305
|
-
const
|
|
306
|
-
return { h: c * 60, s:
|
|
307
|
-
},
|
|
308
|
-
const i = (
|
|
305
|
+
const p = a === 0 ? 0 : r / a, d = a;
|
|
306
|
+
return { h: c * 60, s: p, v: d };
|
|
307
|
+
}, W = (h, t, e) => {
|
|
308
|
+
const i = (h % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)), o = e - s;
|
|
309
309
|
let a = 0, l = 0, r = 0;
|
|
310
310
|
return i < 60 ? (a = s, l = n, r = 0) : i < 120 ? (a = n, l = s, r = 0) : i < 180 ? (a = 0, l = s, r = n) : i < 240 ? (a = 0, l = n, r = s) : i < 300 ? (a = n, l = 0, r = s) : (a = s, l = 0, r = n), X(
|
|
311
311
|
Math.round((a + o) * 255),
|
|
312
312
|
Math.round((l + o) * 255),
|
|
313
313
|
Math.round((r + o) * 255)
|
|
314
314
|
);
|
|
315
|
-
}, vt = (
|
|
315
|
+
}, vt = (h, t, e) => {
|
|
316
316
|
const i = e * (1 - t / 2), s = i === 0 || i === 1 ? 0 : (e - i) / Math.min(i, 1 - i);
|
|
317
|
-
return { hue:
|
|
318
|
-
}, it = (
|
|
319
|
-
const i = (1 - Math.abs(2 * e - 1)) * t, s = i * (1 - Math.abs(
|
|
317
|
+
return { hue: h, sat: s, lightness: i };
|
|
318
|
+
}, it = (h, t, e) => {
|
|
319
|
+
const i = (1 - Math.abs(2 * e - 1)) * t, s = i * (1 - Math.abs(h / 60 % 2 - 1)), n = e - i / 2;
|
|
320
320
|
let o = 0, a = 0, l = 0;
|
|
321
|
-
return
|
|
321
|
+
return h < 60 ? (o = i, a = s, l = 0) : h < 120 ? (o = s, a = i, l = 0) : h < 180 ? (o = 0, a = i, l = s) : h < 240 ? (o = 0, a = s, l = i) : h < 300 ? (o = s, a = 0, l = i) : (o = i, a = 0, l = s), {
|
|
322
322
|
r: Math.round((o + n) * 255),
|
|
323
323
|
g: Math.round((a + n) * 255),
|
|
324
324
|
b: Math.round((l + n) * 255)
|
|
325
325
|
};
|
|
326
|
-
}, st = (
|
|
326
|
+
}, st = (h, t) => {
|
|
327
327
|
const e = Math.max(0, Math.min(100, t)) / 100;
|
|
328
|
-
if (
|
|
329
|
-
const { r: s, g: n, b: o } = P(
|
|
328
|
+
if (h.startsWith("#")) {
|
|
329
|
+
const { r: s, g: n, b: o } = P(h);
|
|
330
330
|
return `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
331
331
|
}
|
|
332
|
-
if (
|
|
333
|
-
return
|
|
334
|
-
if (
|
|
335
|
-
return
|
|
336
|
-
if (
|
|
337
|
-
const s =
|
|
332
|
+
if (h.startsWith("rgba("))
|
|
333
|
+
return h.replace(/,\s*[\d.]+\)$/, `, ${e})`);
|
|
334
|
+
if (h.startsWith("rgb("))
|
|
335
|
+
return h.replace("rgb(", "rgba(").replace(")", `, ${e})`);
|
|
336
|
+
if (h.startsWith("hsl(")) {
|
|
337
|
+
const s = h.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
338
338
|
if (s) {
|
|
339
339
|
const { r: n, g: o, b: a } = it(
|
|
340
340
|
parseInt(s[1]),
|
|
@@ -344,8 +344,8 @@ const ot = (d, t, e) => {
|
|
|
344
344
|
return `rgba(${n}, ${o}, ${a}, ${e})`;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
if (
|
|
348
|
-
const s =
|
|
347
|
+
if (h.startsWith("hsla(")) {
|
|
348
|
+
const s = h.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);
|
|
349
349
|
if (s) {
|
|
350
350
|
const { r: n, g: o, b: a } = it(
|
|
351
351
|
parseInt(s[1]),
|
|
@@ -355,13 +355,13 @@ const ot = (d, t, e) => {
|
|
|
355
355
|
return `rgba(${n}, ${o}, ${a}, ${e})`;
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
const i =
|
|
358
|
+
const i = F(h);
|
|
359
359
|
if (i) {
|
|
360
360
|
const { r: s, g: n, b: o } = P(i);
|
|
361
361
|
return `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
362
362
|
}
|
|
363
|
-
return
|
|
364
|
-
}, Mt = (
|
|
363
|
+
return h;
|
|
364
|
+
}, Mt = (h) => [
|
|
365
365
|
"red",
|
|
366
366
|
"green",
|
|
367
367
|
"blue",
|
|
@@ -385,18 +385,18 @@ const ot = (d, t, e) => {
|
|
|
385
385
|
"teal",
|
|
386
386
|
"fuchsia",
|
|
387
387
|
"transparent"
|
|
388
|
-
].includes(
|
|
388
|
+
].includes(h.toLowerCase()), ft = (h) => [
|
|
389
389
|
/^#[0-9a-fA-F]{3,8}$/,
|
|
390
390
|
/^rgba?\s*\([^)]+\)$/,
|
|
391
391
|
/^hsla?\s*\([^)]+\)$/,
|
|
392
392
|
/^[a-zA-Z]+$/
|
|
393
|
-
].some((e) => e.test(
|
|
393
|
+
].some((e) => e.test(h.trim())), Nt = (h) => {
|
|
394
394
|
if (typeof document > "u")
|
|
395
|
-
return ft(
|
|
395
|
+
return ft(h) || !!F(h);
|
|
396
396
|
const t = document.createElement("div");
|
|
397
|
-
return t.style.color =
|
|
398
|
-
}, Ct = (
|
|
399
|
-
const t =
|
|
397
|
+
return t.style.color = h, t.style.color !== "";
|
|
398
|
+
}, Ct = (h) => {
|
|
399
|
+
const t = h.trim();
|
|
400
400
|
if (/^#[0-9A-Fa-f]{8}$/.test(t)) {
|
|
401
401
|
const n = t.slice(1), o = parseInt(n.slice(0, 2), 16), a = parseInt(n.slice(2, 4), 16), l = parseInt(n.slice(4, 6), 16), r = parseInt(n.slice(6, 8), 16);
|
|
402
402
|
return {
|
|
@@ -431,12 +431,12 @@ const ot = (d, t, e) => {
|
|
|
431
431
|
opacity: Math.round(l * 100)
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
|
-
return { color:
|
|
435
|
-
}, ht = (
|
|
434
|
+
return { color: F(t) || t, position: 0, opacity: 100 };
|
|
435
|
+
}, ht = (h) => {
|
|
436
436
|
const t = [];
|
|
437
437
|
let e = "", i = 0;
|
|
438
|
-
for (let s = 0; s <
|
|
439
|
-
const n =
|
|
438
|
+
for (let s = 0; s < h.length; s++) {
|
|
439
|
+
const n = h[s];
|
|
440
440
|
if (n === "(") i++;
|
|
441
441
|
else if (n === ")") i--;
|
|
442
442
|
else if (n === "," && i === 0) {
|
|
@@ -446,16 +446,16 @@ const ot = (d, t, e) => {
|
|
|
446
446
|
e += n;
|
|
447
447
|
}
|
|
448
448
|
return e.trim() && t.push(e.trim()), t;
|
|
449
|
-
}, dt = (
|
|
450
|
-
const e = new RegExp(`${t}\\s*\\(`, "i"), i =
|
|
449
|
+
}, dt = (h, t) => {
|
|
450
|
+
const e = new RegExp(`${t}\\s*\\(`, "i"), i = h.match(e);
|
|
451
451
|
if (!i) return null;
|
|
452
452
|
const s = i.index + i[0].length;
|
|
453
453
|
let n = 1, o = s;
|
|
454
|
-
for (let a = s; a <
|
|
455
|
-
|
|
456
|
-
return n === 0 ?
|
|
457
|
-
}, It = (
|
|
458
|
-
const t =
|
|
454
|
+
for (let a = s; a < h.length && n > 0; a++)
|
|
455
|
+
h[a] === "(" ? n++ : h[a] === ")" && n--, o = a;
|
|
456
|
+
return n === 0 ? h.substring(s, o) : null;
|
|
457
|
+
}, It = (h) => {
|
|
458
|
+
const t = h.split(" ")[0].toLowerCase();
|
|
459
459
|
return [
|
|
460
460
|
"circle",
|
|
461
461
|
"ellipse",
|
|
@@ -466,31 +466,31 @@ const ot = (d, t, e) => {
|
|
|
466
466
|
"at",
|
|
467
467
|
"contain",
|
|
468
468
|
"cover"
|
|
469
|
-
].includes(t) ? !1 : /^#[0-9a-f]{3,8}$/i.test(t) || /^rgb/i.test(
|
|
470
|
-
}, pt = (
|
|
469
|
+
].includes(t) ? !1 : /^#[0-9a-f]{3,8}$/i.test(t) || /^rgb/i.test(h) || /^hsl/i.test(h) || Mt(t);
|
|
470
|
+
}, pt = (h) => {
|
|
471
471
|
const t = [];
|
|
472
|
-
return
|
|
472
|
+
return h.forEach((e, i) => {
|
|
473
473
|
const s = e.trim();
|
|
474
474
|
if (!s) return;
|
|
475
475
|
let n = "", o = 0;
|
|
476
476
|
const a = s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);
|
|
477
|
-
a && ft(a[1].trim()) ? (n = a[1].trim(), o = parseFloat(a[2])) : (n = s, o =
|
|
477
|
+
a && ft(a[1].trim()) ? (n = a[1].trim(), o = parseFloat(a[2])) : (n = s, o = h.length === 1 ? 0 : i / (h.length - 1) * 100);
|
|
478
478
|
const l = Ct(n);
|
|
479
479
|
l.position = Math.max(0, Math.min(100, Math.round(o))), t.push(l);
|
|
480
480
|
}), t;
|
|
481
|
-
}, A = (
|
|
482
|
-
const t =
|
|
481
|
+
}, A = (h) => {
|
|
482
|
+
const t = h.stops && h.stops.length ? h.stops : [{ color: "#000000", position: 0, opacity: 100 }];
|
|
483
483
|
return {
|
|
484
|
-
type:
|
|
485
|
-
angle: typeof
|
|
484
|
+
type: h.type && ["linear", "radial", "solid"].includes(h.type) ? h.type : "linear",
|
|
485
|
+
angle: typeof h.angle == "number" ? h.angle : 90,
|
|
486
486
|
stops: t.map((e, i) => ({
|
|
487
487
|
color: e.color || "#000000",
|
|
488
488
|
position: typeof e.position == "number" ? e.position : t.length === 1 ? 0 : Math.round(i / (t.length - 1) * 100),
|
|
489
489
|
opacity: e.opacity === void 0 || Number.isNaN(e.opacity) ? 100 : e.opacity
|
|
490
490
|
}))
|
|
491
491
|
};
|
|
492
|
-
}, T = (
|
|
493
|
-
const t =
|
|
492
|
+
}, T = (h) => {
|
|
493
|
+
const t = h.replace(/;$/, "").trim();
|
|
494
494
|
if (Nt(t)) {
|
|
495
495
|
const s = Ct(t);
|
|
496
496
|
return A({ type: "solid", angle: 0, stops: [s] });
|
|
@@ -522,21 +522,21 @@ const ot = (d, t, e) => {
|
|
|
522
522
|
return o.length ? A({ type: "radial", angle: 0, stops: o }) : null;
|
|
523
523
|
}
|
|
524
524
|
return null;
|
|
525
|
-
}, S = (
|
|
526
|
-
if (
|
|
527
|
-
const e =
|
|
525
|
+
}, S = (h) => {
|
|
526
|
+
if (h.type === "solid") {
|
|
527
|
+
const e = h.stops[0], i = e.color;
|
|
528
528
|
if (i.startsWith("var(--"))
|
|
529
529
|
return i;
|
|
530
530
|
const s = e.opacity ?? 100, n = i.replace("#", ""), o = Math.round(s / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
531
531
|
return `#${n}${o}`;
|
|
532
532
|
}
|
|
533
|
-
const t =
|
|
533
|
+
const t = h.stops.map(
|
|
534
534
|
(e) => `${st(e.color, e.opacity ?? 100)} ${e.position}%`
|
|
535
535
|
).join(", ");
|
|
536
|
-
return
|
|
537
|
-
}, St = (
|
|
538
|
-
if (
|
|
539
|
-
const t =
|
|
536
|
+
return h.type === "radial" ? `radial-gradient(circle, ${t})` : `linear-gradient(${h.angle}deg, ${t})`;
|
|
537
|
+
}, St = (h) => Math.round(h / 100 * 255).toString(16).toUpperCase().padStart(2, "0"), K = (h) => {
|
|
538
|
+
if (h.type === "solid") {
|
|
539
|
+
const t = h.stops[0];
|
|
540
540
|
if (t) {
|
|
541
541
|
const e = t.color;
|
|
542
542
|
if (e.startsWith("var(--"))
|
|
@@ -552,7 +552,7 @@ const ot = (d, t, e) => {
|
|
|
552
552
|
}
|
|
553
553
|
return "#000000";
|
|
554
554
|
}
|
|
555
|
-
return
|
|
555
|
+
return h.type === "linear" ? `Linear ${h.angle}°` : "Radial Gradient";
|
|
556
556
|
}, q = class q {
|
|
557
557
|
static defaults() {
|
|
558
558
|
return {
|
|
@@ -563,7 +563,7 @@ const ot = (d, t, e) => {
|
|
|
563
563
|
static normalizeList(t) {
|
|
564
564
|
const e = /* @__PURE__ */ new Set(), i = [];
|
|
565
565
|
return t.forEach((s) => {
|
|
566
|
-
let n =
|
|
566
|
+
let n = F(s);
|
|
567
567
|
n || T(s) && (n = s), n && (e.has(n) || (e.add(n), i.push(n)));
|
|
568
568
|
}), i.slice(0, this.MAX_COLORS);
|
|
569
569
|
}
|
|
@@ -609,7 +609,7 @@ const ot = (d, t, e) => {
|
|
|
609
609
|
}
|
|
610
610
|
static addColor(t, e) {
|
|
611
611
|
if (!t) return;
|
|
612
|
-
let i =
|
|
612
|
+
let i = F(t), s = "solid";
|
|
613
613
|
if (i)
|
|
614
614
|
s = "solid";
|
|
615
615
|
else {
|
|
@@ -622,8 +622,8 @@ const ot = (d, t, e) => {
|
|
|
622
622
|
}
|
|
623
623
|
};
|
|
624
624
|
q.STORAGE_KEY = "settingsLib_recentColors", q.MAX_COLORS = 12, q.colors = null;
|
|
625
|
-
let
|
|
626
|
-
const at = (
|
|
625
|
+
let R = q;
|
|
626
|
+
const at = (h, t) => {
|
|
627
627
|
const e = document.createElement("div");
|
|
628
628
|
e.className = "color-picker-recent-section";
|
|
629
629
|
const i = document.createElement("div");
|
|
@@ -632,54 +632,54 @@ const at = (d, t) => {
|
|
|
632
632
|
s.className = "color-picker-tooltip", s.style.display = "none", e.appendChild(s);
|
|
633
633
|
const n = () => {
|
|
634
634
|
s.style.display = "none";
|
|
635
|
-
}, o = (c,
|
|
636
|
-
const
|
|
637
|
-
s.textContent =
|
|
635
|
+
}, o = (c, p) => {
|
|
636
|
+
const d = c.getBoundingClientRect();
|
|
637
|
+
s.textContent = p, s.style.left = `${d.left + d.width / 2}px`, s.style.top = `${d.bottom + 8}px`, s.style.display = "block";
|
|
638
638
|
}, a = document.createElement("div");
|
|
639
639
|
a.className = "color-picker-recent-grid";
|
|
640
640
|
const l = document.createElement("div");
|
|
641
641
|
l.className = "color-picker-recent-placeholder", l.textContent = "No recent colors yet", e.appendChild(i), e.appendChild(a), e.appendChild(l);
|
|
642
642
|
const r = () => {
|
|
643
643
|
n(), a.innerHTML = "";
|
|
644
|
-
const c =
|
|
644
|
+
const c = R.getColors(t);
|
|
645
645
|
if (c.length === 0) {
|
|
646
646
|
a.style.display = "none", l.style.display = "block";
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
|
-
a.style.display = "grid", l.style.display = "none", c.forEach((
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
const g = Vt(
|
|
653
|
-
if (
|
|
654
|
-
|
|
655
|
-
const m = T(
|
|
656
|
-
m && m.stops && m.stops.length > 0 && (
|
|
649
|
+
a.style.display = "grid", l.style.display = "none", c.forEach((p) => {
|
|
650
|
+
const d = document.createElement("button");
|
|
651
|
+
d.type = "button", d.className = "color-picker-recent-swatch";
|
|
652
|
+
const g = Vt(p);
|
|
653
|
+
if (d.title = g, d.setAttribute("aria-label", `Use color: ${g}`), p.includes("gradient(")) {
|
|
654
|
+
d.style.backgroundImage = p, d.style.backgroundColor = "transparent";
|
|
655
|
+
const m = T(p);
|
|
656
|
+
m && m.stops && m.stops.length > 0 && (d.style.borderColor = m.stops[0].color);
|
|
657
657
|
} else
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
n(),
|
|
661
|
-
}),
|
|
662
|
-
|
|
663
|
-
}),
|
|
658
|
+
d.style.backgroundColor = p, d.style.borderColor = p;
|
|
659
|
+
d.addEventListener("mouseenter", () => o(d, g)), d.addEventListener("mouseleave", () => {
|
|
660
|
+
n(), d.style.boxShadow = "";
|
|
661
|
+
}), d.addEventListener("mousedown", () => {
|
|
662
|
+
d.style.boxShadow = "0px 0px 0px 2px var(--grey40)";
|
|
663
|
+
}), d.addEventListener("mouseup", () => {
|
|
664
664
|
setTimeout(() => {
|
|
665
|
-
|
|
665
|
+
d.style.boxShadow = "";
|
|
666
666
|
}, 150);
|
|
667
|
-
}),
|
|
668
|
-
n(),
|
|
669
|
-
}), a.appendChild(
|
|
667
|
+
}), d.addEventListener("click", () => {
|
|
668
|
+
n(), h(p);
|
|
669
|
+
}), a.appendChild(d);
|
|
670
670
|
});
|
|
671
671
|
};
|
|
672
672
|
return r(), { container: e, refresh: r };
|
|
673
|
-
}, Vt = (
|
|
674
|
-
const t = T(
|
|
673
|
+
}, Vt = (h) => {
|
|
674
|
+
const t = T(h);
|
|
675
675
|
if (t)
|
|
676
676
|
return K(t);
|
|
677
|
-
const e =
|
|
677
|
+
const e = F(h);
|
|
678
678
|
if (e) {
|
|
679
679
|
const i = P(e);
|
|
680
680
|
return `${e} (RGB: ${i.r}, ${i.g}, ${i.b})`;
|
|
681
681
|
}
|
|
682
|
-
return
|
|
682
|
+
return h;
|
|
683
683
|
}, yt = `<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
684
684
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
685
685
|
d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
|
|
@@ -760,77 +760,77 @@ class ut {
|
|
|
760
760
|
r.className = "color-picker-sliders-group";
|
|
761
761
|
const c = document.createElement("div");
|
|
762
762
|
c.className = "color-picker-hue", this.hueSlider = c;
|
|
763
|
-
const h = document.createElement("div");
|
|
764
|
-
h.className = "color-picker-hue-marker", this.hueMarker = h, c.appendChild(h);
|
|
765
763
|
const p = document.createElement("div");
|
|
766
|
-
p.className = "color-picker-
|
|
764
|
+
p.className = "color-picker-hue-marker", this.hueMarker = p, c.appendChild(p);
|
|
765
|
+
const d = document.createElement("div");
|
|
766
|
+
d.className = "color-picker-opacity", this.opacitySlider = d;
|
|
767
767
|
const g = document.createElement("div");
|
|
768
|
-
g.className = "color-picker-opacity-marker", this.opacityMarker = g,
|
|
769
|
-
const
|
|
768
|
+
g.className = "color-picker-opacity-marker", this.opacityMarker = g, d.appendChild(g), r.appendChild(c), r.appendChild(d), a.appendChild(l), a.appendChild(r);
|
|
769
|
+
const C = at((E) => {
|
|
770
770
|
var w;
|
|
771
771
|
this.setColor(E), (w = this.onChange) == null || w.call(this, E, this.currentOpacity);
|
|
772
772
|
}, this.recentScope);
|
|
773
|
-
this.recentSectionRefresh =
|
|
773
|
+
this.recentSectionRefresh = C.refresh;
|
|
774
774
|
const m = document.createElement("div");
|
|
775
775
|
m.className = "color-picker-format-section";
|
|
776
776
|
const u = document.createElement("select");
|
|
777
777
|
u.className = "color-picker-format-select", this.select = u;
|
|
778
778
|
const v = document.createElement("option");
|
|
779
779
|
v.value = "hex", v.textContent = "HEX";
|
|
780
|
-
const
|
|
781
|
-
|
|
780
|
+
const f = document.createElement("option");
|
|
781
|
+
f.value = "rgb", f.textContent = "RGB";
|
|
782
782
|
const y = document.createElement("option");
|
|
783
|
-
y.value = "hsl", y.textContent = "HSL", u.appendChild(v), u.appendChild(
|
|
783
|
+
y.value = "hsl", y.textContent = "HSL", u.appendChild(v), u.appendChild(f), u.appendChild(y);
|
|
784
784
|
const b = document.createElement("input");
|
|
785
785
|
b.type = "text", b.className = "color-picker-color-input", b.value = this.currentColor, this.input = b;
|
|
786
786
|
const L = document.createElement("div");
|
|
787
787
|
L.className = "color-picker-input-container";
|
|
788
788
|
const I = document.createElement("button");
|
|
789
|
-
return I.className = "color-picker-copy-inside", I.textContent = "Copy", L.appendChild(b), L.appendChild(I), m.appendChild(u), m.appendChild(L), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(
|
|
789
|
+
return I.className = "color-picker-copy-inside", I.textContent = "Copy", L.appendChild(b), L.appendChild(I), m.appendChild(u), m.appendChild(L), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(C.container), t.appendChild(m), t.addEventListener("click", (E) => E.stopPropagation()), this.bind(n, c, d, b, u, I, l), t;
|
|
790
790
|
}
|
|
791
791
|
createBackdrop() {
|
|
792
792
|
const t = document.createElement("div");
|
|
793
793
|
return t.className = "color-picker-backdrop", t.style.display = "none", t.style.pointerEvents = "none", t;
|
|
794
794
|
}
|
|
795
795
|
bind(t, e, i, s, n, o, a) {
|
|
796
|
-
const l = (
|
|
797
|
-
var
|
|
798
|
-
const
|
|
799
|
-
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${
|
|
800
|
-
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, v =
|
|
801
|
-
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), (
|
|
802
|
-
}, r = (
|
|
803
|
-
var C;
|
|
804
|
-
const p = e.getBoundingClientRect();
|
|
805
|
-
let g = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width));
|
|
806
|
-
this.hueMarker.style.left = `${g * 100}%`;
|
|
807
|
-
const f = g * 360, m = this.parsePercentage(this.colorMarker.style.left || "0%"), u = this.parsePercentage(this.colorMarker.style.top || "0%"), v = U(f, m, 1 - u);
|
|
808
|
-
this.currentColor = v, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${f}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (C = this.onChange) == null || C.call(this, v, this.currentOpacity);
|
|
809
|
-
}, c = (h) => {
|
|
796
|
+
const l = (p) => {
|
|
797
|
+
var f;
|
|
798
|
+
const d = t.getBoundingClientRect(), g = Math.max(0, Math.min(1, (p.clientX - d.left) / d.width)), C = Math.max(0, Math.min(1, (p.clientY - d.top) / d.height));
|
|
799
|
+
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${C * 100}%`;
|
|
800
|
+
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, v = W(u, g, 1 - C);
|
|
801
|
+
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), (f = this.onChange) == null || f.call(this, v, this.currentOpacity);
|
|
802
|
+
}, r = (p) => {
|
|
810
803
|
var f;
|
|
811
|
-
const
|
|
812
|
-
|
|
804
|
+
const d = e.getBoundingClientRect();
|
|
805
|
+
let g = Math.max(0, Math.min(1, (p.clientX - d.left) / d.width));
|
|
806
|
+
this.hueMarker.style.left = `${g * 100}%`;
|
|
807
|
+
const C = g * 360, m = this.parsePercentage(this.colorMarker.style.left || "0%"), u = this.parsePercentage(this.colorMarker.style.top || "0%"), v = W(C, m, 1 - u);
|
|
808
|
+
this.currentColor = v, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (f = this.onChange) == null || f.call(this, v, this.currentOpacity);
|
|
809
|
+
}, c = (p) => {
|
|
810
|
+
var C;
|
|
811
|
+
const d = i.getBoundingClientRect(), g = Math.max(0, Math.min(1, (p.clientX - d.left) / d.width));
|
|
812
|
+
this.opacityMarker.style.left = `${g * 100}%`, this.currentOpacity = Math.round(g * 100), (C = this.onChange) == null || C.call(this, this.currentColor, this.currentOpacity);
|
|
813
813
|
};
|
|
814
|
-
t.addEventListener("mousedown", (
|
|
815
|
-
|
|
816
|
-
const
|
|
817
|
-
document.removeEventListener("mousemove",
|
|
814
|
+
t.addEventListener("mousedown", (p) => {
|
|
815
|
+
p.preventDefault(), l(p);
|
|
816
|
+
const d = (C) => l(C), g = () => {
|
|
817
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g);
|
|
818
818
|
};
|
|
819
|
-
document.addEventListener("mousemove",
|
|
820
|
-
}), e.addEventListener("mousedown", (
|
|
821
|
-
|
|
822
|
-
const
|
|
823
|
-
document.removeEventListener("mousemove",
|
|
819
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
820
|
+
}), e.addEventListener("mousedown", (p) => {
|
|
821
|
+
p.preventDefault(), r(p);
|
|
822
|
+
const d = (C) => r(C), g = () => {
|
|
823
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g);
|
|
824
824
|
};
|
|
825
|
-
document.addEventListener("mousemove",
|
|
826
|
-
}), i.addEventListener("mousedown", (
|
|
827
|
-
|
|
828
|
-
const
|
|
829
|
-
document.removeEventListener("mousemove",
|
|
825
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
826
|
+
}), i.addEventListener("mousedown", (p) => {
|
|
827
|
+
p.preventDefault(), c(p);
|
|
828
|
+
const d = (C) => c(C), g = () => {
|
|
829
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g);
|
|
830
830
|
};
|
|
831
|
-
document.addEventListener("mousemove",
|
|
832
|
-
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (
|
|
833
|
-
|
|
831
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
832
|
+
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (p) => {
|
|
833
|
+
p.key === "Enter" && (p.preventDefault(), this.syncInput(), s.blur());
|
|
834
834
|
}), o.addEventListener("click", async () => {
|
|
835
835
|
try {
|
|
836
836
|
await navigator.clipboard.writeText(s.value);
|
|
@@ -838,14 +838,14 @@ class ut {
|
|
|
838
838
|
s.select(), document.execCommand("copy");
|
|
839
839
|
}
|
|
840
840
|
}), a.addEventListener("click", async () => {
|
|
841
|
-
var
|
|
841
|
+
var p;
|
|
842
842
|
if (!("EyeDropper" in window)) {
|
|
843
843
|
alert("EyeDropper API is not supported in this browser.");
|
|
844
844
|
return;
|
|
845
845
|
}
|
|
846
846
|
try {
|
|
847
|
-
const
|
|
848
|
-
this.setColor(g), (
|
|
847
|
+
const d = new window.EyeDropper(), { sRGBHex: g } = await d.open();
|
|
848
|
+
this.setColor(g), (p = this.onChange) == null || p.call(this, g, this.currentOpacity);
|
|
849
849
|
} catch {
|
|
850
850
|
}
|
|
851
851
|
}), document.addEventListener("keydown", this.keyDown, !0), setTimeout(
|
|
@@ -856,11 +856,11 @@ class ut {
|
|
|
856
856
|
setColor(t) {
|
|
857
857
|
var o;
|
|
858
858
|
this.currentColor = t;
|
|
859
|
-
const { h: e, s: i, v: s } =
|
|
859
|
+
const { h: e, s: i, v: s } = U(t), n = e >= 360 ? e % 360 : e;
|
|
860
860
|
this.hueMarker.style.left = `${n / 360 * 100}%`, this.colorMarker.style.left = `${i * 100}%`, this.colorMarker.style.top = `${(1 - s) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (o = this.onChange) == null || o.call(this, t, this.currentOpacity);
|
|
861
861
|
}
|
|
862
862
|
syncInput() {
|
|
863
|
-
const t = this.select.value, { h: e, s: i, v: s } =
|
|
863
|
+
const t = this.select.value, { h: e, s: i, v: s } = U(this.currentColor);
|
|
864
864
|
if (t === "hex") this.input.value = this.currentColor;
|
|
865
865
|
else if (t === "rgb") {
|
|
866
866
|
const { r: n, g: o, b: a } = P(this.currentColor);
|
|
@@ -885,7 +885,7 @@ class ut {
|
|
|
885
885
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
886
886
|
if (s) {
|
|
887
887
|
const n = parseInt(s[1]), o = parseInt(s[2]) / 100, a = parseInt(s[3]) / 100, l = a + o * Math.min(a, 1 - a), r = l === 0 ? 0 : 2 * (1 - a / l);
|
|
888
|
-
e =
|
|
888
|
+
e = W(n, r, l);
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
891
|
}
|
|
@@ -901,18 +901,18 @@ class ut {
|
|
|
901
901
|
open(t, e, i) {
|
|
902
902
|
var y;
|
|
903
903
|
this.currentColor = t, this.currentOpacity = i ?? 100, this.syncInput();
|
|
904
|
-
const { h: s, s: n, v: o } =
|
|
904
|
+
const { h: s, s: n, v: o } = U(t);
|
|
905
905
|
this.hueMarker.style.left = `${s / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 - o) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`, this.updateOpacityBg(), this.opacityMarker.style.left = `${this.currentOpacity}%`, (y = this.recentSectionRefresh) == null || y.call(this), this.isOpen = !0, this.backdrop.style.display = "block", this.backdrop.parentElement || document.body.appendChild(this.backdrop), this.element.style.display = "block", this.element.style.position = "fixed", this.element.style.zIndex = "10002", this.element.style.left = "-9999px", this.element.style.top = "0px", this.element.parentElement || document.body.appendChild(this.element);
|
|
906
|
-
const a = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(), c = window.innerWidth,
|
|
907
|
-
let g = r.right + 8,
|
|
906
|
+
const a = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(), c = window.innerWidth, p = window.innerHeight, d = 16;
|
|
907
|
+
let g = r.right + 8, C = r.top;
|
|
908
908
|
const m = c - r.right, u = r.left;
|
|
909
|
-
m >= a +
|
|
910
|
-
const v =
|
|
911
|
-
v >= l +
|
|
909
|
+
m >= a + d ? g = r.right + 8 : u >= a + d ? g = r.left - a - 8 : g = Math.max(d, (c - a) / 2);
|
|
910
|
+
const v = p - r.bottom, f = r.top;
|
|
911
|
+
v >= l + d ? C = r.bottom + 8 : f >= l + d ? C = r.top - l - 8 : v > f ? (C = r.bottom + 8, C + l > p - d && (C = p - l - d)) : (C = r.top - l - 8, C < d && (C = d)), this.element.style.left = `${g}px`, this.element.style.top = `${C}px`;
|
|
912
912
|
}
|
|
913
913
|
close(t) {
|
|
914
914
|
var e;
|
|
915
|
-
this.isOpen && (this.isOpen = !1, this.backdrop.style.display = "none", this.element.style.display = "none", document.removeEventListener("click", this.outsideClick, !0), document.removeEventListener("keydown", this.keyDown, !0), t && this.onChange && this.recentScope === "solid" && (
|
|
915
|
+
this.isOpen && (this.isOpen = !1, this.backdrop.style.display = "none", this.element.style.display = "none", document.removeEventListener("click", this.outsideClick, !0), document.removeEventListener("keydown", this.keyDown, !0), t && this.onChange && this.recentScope === "solid" && (R.addColor(this.currentColor, this.recentScope), (e = this.recentSectionRefresh) == null || e.call(this)));
|
|
916
916
|
}
|
|
917
917
|
getElement() {
|
|
918
918
|
return this.element;
|
|
@@ -920,12 +920,19 @@ class ut {
|
|
|
920
920
|
}
|
|
921
921
|
class Bt {
|
|
922
922
|
constructor(t) {
|
|
923
|
-
this.isDragging = !1, this.currentColor = t.initialColor, this.currentOpacity = t.initialOpacity, this.onColorChange = t.onColorChange, this.recentScope = t.scope ?? "solid", this.element = this.build(), this.initFromColor(this.currentColor, this.currentOpacity);
|
|
923
|
+
this.isDragging = !1, this.currentColor = "#FFFFFF", this.currentColor = this.sanitizeColor(t.initialColor), this.currentOpacity = this.clampOpacity(t.initialOpacity), this.onColorChange = t.onColorChange, this.recentScope = t.scope ?? "solid", this.element = this.build(), this.initFromColor(this.currentColor, this.currentOpacity);
|
|
924
924
|
}
|
|
925
925
|
parsePercentage(t) {
|
|
926
926
|
const e = parseFloat(t);
|
|
927
927
|
return isNaN(e) ? 0 : e / 100;
|
|
928
928
|
}
|
|
929
|
+
sanitizeColor(t) {
|
|
930
|
+
const e = this.currentColor || "#FFFFFF";
|
|
931
|
+
return F(t) ?? e;
|
|
932
|
+
}
|
|
933
|
+
clampOpacity(t) {
|
|
934
|
+
return Number.isFinite(t) ? Math.min(100, Math.max(0, Math.round(t))) : 100;
|
|
935
|
+
}
|
|
929
936
|
build() {
|
|
930
937
|
const t = document.createElement("div");
|
|
931
938
|
t.className = "embedded-color-picker";
|
|
@@ -947,70 +954,71 @@ class Bt {
|
|
|
947
954
|
r.className = "color-picker-opacity embedded", this.opacitySlider = r;
|
|
948
955
|
const c = document.createElement("div");
|
|
949
956
|
c.className = "color-picker-opacity-marker", this.opacityMarker = c, r.appendChild(c), o.appendChild(a), o.appendChild(r), s.appendChild(n), s.appendChild(o);
|
|
950
|
-
const
|
|
957
|
+
const p = at((b) => {
|
|
951
958
|
const L = T(b);
|
|
952
959
|
L && L.type !== "solid" ? this.onColorChange(b, this.currentOpacity) : (this.setColor(b), this.onColorChange(this.currentColor, this.currentOpacity));
|
|
953
960
|
}, "all");
|
|
954
|
-
this.recentSectionRefresh =
|
|
955
|
-
const
|
|
956
|
-
|
|
961
|
+
this.recentSectionRefresh = p.refresh;
|
|
962
|
+
const d = document.createElement("div");
|
|
963
|
+
d.className = "color-picker-format-section embedded";
|
|
957
964
|
const g = document.createElement("select");
|
|
958
965
|
g.className = "color-picker-format-select", this.select = g;
|
|
959
|
-
const
|
|
960
|
-
|
|
966
|
+
const C = document.createElement("option");
|
|
967
|
+
C.value = "hex", C.textContent = "HEX";
|
|
961
968
|
const m = document.createElement("option");
|
|
962
969
|
m.value = "rgb", m.textContent = "RGB";
|
|
963
970
|
const u = document.createElement("option");
|
|
964
|
-
u.value = "hsl", u.textContent = "HSL", g.appendChild(
|
|
971
|
+
u.value = "hsl", u.textContent = "HSL", g.appendChild(C), g.appendChild(m), g.appendChild(u);
|
|
965
972
|
const v = document.createElement("input");
|
|
966
973
|
v.type = "text", v.className = "color-picker-color-input", this.input = v;
|
|
967
|
-
const
|
|
968
|
-
|
|
974
|
+
const f = document.createElement("div");
|
|
975
|
+
f.className = "color-picker-input-container";
|
|
969
976
|
const y = document.createElement("button");
|
|
970
|
-
return y.className = "color-picker-copy-inside", y.textContent = "Copy",
|
|
977
|
+
return y.className = "color-picker-copy-inside", y.textContent = "Copy", f.appendChild(v), f.appendChild(y), d.appendChild(g), d.appendChild(f), t.appendChild(e), t.appendChild(s), t.appendChild(d), t.appendChild(p.container), this.bind(e, a, r, v, g, y, n), t;
|
|
971
978
|
}
|
|
972
979
|
bind(t, e, i, s, n, o, a) {
|
|
973
|
-
const l = (
|
|
974
|
-
const
|
|
975
|
-
this.colorMarker.style.left = `${
|
|
976
|
-
const
|
|
977
|
-
this.currentColor =
|
|
978
|
-
}, r = (
|
|
979
|
-
const
|
|
980
|
-
this.hueMarker.style.left = `${
|
|
981
|
-
const
|
|
982
|
-
this.currentColor =
|
|
983
|
-
linear-gradient(to right, #fff, hsl(${
|
|
984
|
-
}, c = (
|
|
985
|
-
const
|
|
986
|
-
this.opacityMarker.style.left = `${
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
const
|
|
991
|
-
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove",
|
|
980
|
+
const l = (d) => {
|
|
981
|
+
const g = t.getBoundingClientRect(), C = Math.max(0, Math.min(1, (d.clientX - g.left) / g.width)), m = Math.max(0, Math.min(1, (d.clientY - g.top) / g.height));
|
|
982
|
+
this.colorMarker.style.left = `${C * 100}%`, this.colorMarker.style.top = `${m * 100}%`;
|
|
983
|
+
const v = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, f = W(v, C, 1 - m);
|
|
984
|
+
this.currentColor = f, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
985
|
+
}, r = (d) => {
|
|
986
|
+
const g = e.getBoundingClientRect(), C = Math.max(0, Math.min(1, (d.clientX - g.left) / g.width));
|
|
987
|
+
this.hueMarker.style.left = `${C * 100}%`;
|
|
988
|
+
const m = C * 360, u = this.parsePercentage(this.colorMarker.style.left || "0%"), v = this.parsePercentage(this.colorMarker.style.top || "0%"), f = W(m, u, 1 - v);
|
|
989
|
+
this.currentColor = f, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
990
|
+
linear-gradient(to right, #fff, hsl(${m}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
991
|
+
}, c = (d) => {
|
|
992
|
+
const g = i.getBoundingClientRect(), C = Math.max(0, Math.min(1, (d.clientX - g.left) / g.width));
|
|
993
|
+
this.opacityMarker.style.left = `${C * 100}%`, this.currentOpacity = this.clampOpacity(C * 100), this.queueChange();
|
|
994
|
+
}, p = (d, g) => {
|
|
995
|
+
d.preventDefault(), this.isDragging = !0, g(d);
|
|
996
|
+
let C;
|
|
997
|
+
const m = () => {
|
|
998
|
+
this.isDragging && (this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", m), window.removeEventListener("blur", m), this.applyPendingExternal());
|
|
992
999
|
};
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
document.addEventListener("mousemove",
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1000
|
+
C = (u) => {
|
|
1001
|
+
if (!u.buttons) {
|
|
1002
|
+
m();
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
g(u);
|
|
1006
|
+
}, document.addEventListener("mousemove", C), document.addEventListener("mouseup", m), window.addEventListener("blur", m);
|
|
1007
|
+
};
|
|
1008
|
+
t.addEventListener("mousedown", (d) => {
|
|
1009
|
+
p(d, l);
|
|
1010
|
+
}), e.addEventListener("mousedown", (d) => {
|
|
1011
|
+
p(d, r);
|
|
1012
|
+
}), i.addEventListener("mousedown", (d) => {
|
|
1013
|
+
p(d, c);
|
|
1006
1014
|
}), n.addEventListener("change", () => {
|
|
1007
1015
|
this.syncInput();
|
|
1008
1016
|
}), s.addEventListener("input", () => {
|
|
1009
1017
|
this.applyFromInput();
|
|
1010
1018
|
}), s.addEventListener("blur", () => {
|
|
1011
1019
|
this.syncInput();
|
|
1012
|
-
}), s.addEventListener("keydown", (
|
|
1013
|
-
|
|
1020
|
+
}), s.addEventListener("keydown", (d) => {
|
|
1021
|
+
d.key === "Enter" && (d.preventDefault(), this.syncInput(), s.blur());
|
|
1014
1022
|
}), o.addEventListener("click", async () => {
|
|
1015
1023
|
try {
|
|
1016
1024
|
await navigator.clipboard.writeText(s.value);
|
|
@@ -1023,20 +1031,21 @@ class Bt {
|
|
|
1023
1031
|
return;
|
|
1024
1032
|
}
|
|
1025
1033
|
try {
|
|
1026
|
-
const
|
|
1027
|
-
this.setColor(
|
|
1034
|
+
const d = new window.EyeDropper(), { sRGBHex: g } = await d.open();
|
|
1035
|
+
this.setColor(g), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
1028
1036
|
} catch {
|
|
1029
1037
|
}
|
|
1030
1038
|
});
|
|
1031
1039
|
}
|
|
1032
1040
|
setColor(t) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1041
|
+
const e = this.sanitizeColor(t);
|
|
1042
|
+
this.currentColor = e;
|
|
1043
|
+
const { h: i, s, v: n } = U(e), o = i >= 360 ? i % 360 : i;
|
|
1044
|
+
this.hueMarker.style.left = `${o / 360 * 100}%`, this.colorMarker.style.left = `${s * 100}%`, this.colorMarker.style.top = `${(1 - n) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
1045
|
+
linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg();
|
|
1037
1046
|
}
|
|
1038
1047
|
syncInput() {
|
|
1039
|
-
const t = this.select.value, { h: e, s: i, v: s } =
|
|
1048
|
+
const t = this.select.value, { h: e, s: i, v: s } = U(this.currentColor);
|
|
1040
1049
|
if (t === "hex")
|
|
1041
1050
|
this.input.value = this.currentColor;
|
|
1042
1051
|
else if (t === "rgb") {
|
|
@@ -1063,7 +1072,7 @@ class Bt {
|
|
|
1063
1072
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
1064
1073
|
if (s) {
|
|
1065
1074
|
const n = parseInt(s[1], 10), o = parseInt(s[2], 10) / 100, a = parseInt(s[3], 10) / 100, l = a + o * Math.min(a, 1 - a), r = l === 0 ? 0 : 2 * (1 - a / l);
|
|
1066
|
-
e =
|
|
1075
|
+
e = W(n, r, l);
|
|
1067
1076
|
}
|
|
1068
1077
|
}
|
|
1069
1078
|
}
|
|
@@ -1090,15 +1099,16 @@ class Bt {
|
|
|
1090
1099
|
this.pendingExternalUpdate = void 0, this.initFromColor(t, e);
|
|
1091
1100
|
}
|
|
1092
1101
|
initFromColor(t, e) {
|
|
1093
|
-
var
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1102
|
+
var l;
|
|
1103
|
+
const i = this.sanitizeColor(t);
|
|
1104
|
+
this.currentColor = i, this.currentOpacity = this.clampOpacity(e);
|
|
1105
|
+
const { h: s, s: n, v: o } = U(i), a = s >= 360 ? s % 360 : s;
|
|
1106
|
+
this.hueMarker.style.left = `${a / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 - o) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
1107
|
+
linear-gradient(to right, #fff, hsl(${a}, 100%, 50%))`, this.opacityMarker.style.left = `${this.currentOpacity}%`, this.updateOpacityBg(), this.syncInput(), (l = this.recentSectionRefresh) == null || l.call(this);
|
|
1098
1108
|
}
|
|
1099
1109
|
commitRecentColor() {
|
|
1100
1110
|
var t;
|
|
1101
|
-
this.recentScope === "solid" && (
|
|
1111
|
+
this.recentScope === "solid" && (R.addColor(this.currentColor, this.recentScope), (t = this.recentSectionRefresh) == null || t.call(this));
|
|
1102
1112
|
}
|
|
1103
1113
|
getElement() {
|
|
1104
1114
|
return this.element;
|
|
@@ -1123,10 +1133,10 @@ const V = class V extends x {
|
|
|
1123
1133
|
angle: "number",
|
|
1124
1134
|
stops: "text"
|
|
1125
1135
|
}, this.element = null, this.previewEl = null, this.inputEl = void 0, this.popoverEl = null, this.backdropEl = null, this.isPopoverOpen = !1, this.isEditing = !1, this.popoverPosition = null, this.previewUpdateTimeout = null, this.changeDebounceTimeout = null, this.solidPicker = null, this.pendingSolidColor = null, this.variant = "default", this.globalLayoutMode = "list", this.globalSearchQuery = "", this.currentMode = "custom", this.linkedGlobalVariable = null, this.unlinkButton = null, this.onBackgroundClick = (i) => {
|
|
1126
|
-
var
|
|
1136
|
+
var d;
|
|
1127
1137
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
1128
|
-
const s = i.target, n = this.popoverEl.contains(s), o = (
|
|
1129
|
-
!n && !o && !l && !r && !c && !
|
|
1138
|
+
const s = i.target, n = this.popoverEl.contains(s), o = (d = this.element) == null ? void 0 : d.contains(s), a = document.querySelectorAll(".custom-color-picker"), l = Array.from(a).some((g) => g.contains(s)), r = s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"), c = s.classList.contains("color-picker-backdrop"), p = s.classList.contains("gradient-popover-backdrop");
|
|
1139
|
+
!n && !o && !l && !r && !c && !p && this.closePopover();
|
|
1130
1140
|
}, this.handlePopoverKeydown = (i) => {
|
|
1131
1141
|
if (this.isPopoverOpen) {
|
|
1132
1142
|
if (i.key === "Escape") {
|
|
@@ -1308,8 +1318,8 @@ const V = class V extends x {
|
|
|
1308
1318
|
n.appendChild(o), s.appendChild(n);
|
|
1309
1319
|
const a = document.createElement("div");
|
|
1310
1320
|
if (a.className = "gradient-editor-content", this.updatePopoverContent(a), s.appendChild(a), this.variant !== "global" && e) {
|
|
1311
|
-
const l = e.children[0], r = e.children[1], c = (
|
|
1312
|
-
this.currentMode =
|
|
1321
|
+
const l = e.children[0], r = e.children[1], c = (p) => {
|
|
1322
|
+
this.currentMode = p, p === "custom" ? (l.classList.add("active"), r.classList.remove("active"), n.style.display = "block") : (r.classList.add("active"), l.classList.remove("active"), n.style.display = "none"), this.updatePopoverContent(a);
|
|
1313
1323
|
};
|
|
1314
1324
|
l.addEventListener("click", () => c("custom")), r.addEventListener("click", () => c("global")), this.isBoundToGlobal() ? (this.currentMode = "global", c("global")) : (this.currentMode = "custom", c("custom"));
|
|
1315
1325
|
}
|
|
@@ -1376,48 +1386,48 @@ const V = class V extends x {
|
|
|
1376
1386
|
}
|
|
1377
1387
|
renderGlobalColors(t) {
|
|
1378
1388
|
(!this.value || !this.value.stops || !this.value.stops.length) && (this.value || (this.value = this.defaultValue()), this.value.stops = [{ color: "#000000", position: 0, opacity: 100 }]);
|
|
1379
|
-
const e = this.value.stops[0], i = (
|
|
1380
|
-
|
|
1381
|
-
let
|
|
1389
|
+
const e = this.value.stops[0], i = (p) => {
|
|
1390
|
+
p.innerHTML = "";
|
|
1391
|
+
let d = {};
|
|
1382
1392
|
try {
|
|
1383
|
-
|
|
1393
|
+
d = x.GlobalVariables || {};
|
|
1384
1394
|
} catch (u) {
|
|
1385
1395
|
console.warn("Could not access Setting.GlobalVariables", u);
|
|
1386
1396
|
}
|
|
1387
|
-
if (!
|
|
1397
|
+
if (!d || Object.keys(d).length === 0) {
|
|
1388
1398
|
const u = document.createElement("div");
|
|
1389
|
-
u.textContent = "No global colors defined", u.style.fontSize = "12px", u.style.color = "#666", u.style.padding = "8px",
|
|
1399
|
+
u.textContent = "No global colors defined", u.style.fontSize = "12px", u.style.color = "#666", u.style.padding = "8px", p.appendChild(u);
|
|
1390
1400
|
return;
|
|
1391
1401
|
}
|
|
1392
1402
|
const g = x.GlobalVariableGroups || [
|
|
1393
1403
|
{ title: "Global Colors", keys: ["primary", "secondary", "tertiary", "accent"] },
|
|
1394
1404
|
{ title: "Text Color", keys: ["text-dark", "text-light"] }
|
|
1395
|
-
],
|
|
1405
|
+
], C = this.globalSearchQuery.toLowerCase();
|
|
1396
1406
|
let m;
|
|
1397
|
-
this.globalLayoutMode === "list" ? (m = document.createElement("div"), m.className = "global-colors-list") : (m = document.createElement("div"), m.className = "global-colors-grid"),
|
|
1398
|
-
const v = Object.entries(
|
|
1399
|
-
v.length !== 0 && v.forEach(([
|
|
1407
|
+
this.globalLayoutMode === "list" ? (m = document.createElement("div"), m.className = "global-colors-list") : (m = document.createElement("div"), m.className = "global-colors-grid"), p.appendChild(m), g.forEach((u) => {
|
|
1408
|
+
const v = Object.entries(d).filter(([f]) => !u.keys.includes(f) && u.title !== "Global Colors" ? !1 : u.keys.includes(f) && f.toLowerCase().includes(C));
|
|
1409
|
+
v.length !== 0 && v.forEach(([f, y]) => {
|
|
1400
1410
|
if (this.globalLayoutMode === "list") {
|
|
1401
1411
|
const b = document.createElement("div");
|
|
1402
1412
|
b.className = "global-color-row";
|
|
1403
1413
|
const L = document.createElement("div");
|
|
1404
1414
|
L.className = "global-color-circle";
|
|
1405
1415
|
const I = this.resolveGlobalVarColor(y);
|
|
1406
|
-
L.style.background = I, (this.linkedGlobalVariable === `var(--${
|
|
1416
|
+
L.style.background = I, (this.linkedGlobalVariable === `var(--${f})` || e.color === `var(--${f})`) && L.classList.add("selected");
|
|
1407
1417
|
const w = document.createElement("span");
|
|
1408
|
-
w.className = "global-color-label", w.textContent =
|
|
1418
|
+
w.className = "global-color-label", w.textContent = f.split("-").map((N) => N.charAt(0).toUpperCase() + N.slice(1)).join(" "), b.appendChild(L), b.appendChild(w), b.addEventListener("click", (N) => {
|
|
1409
1419
|
N.preventDefault();
|
|
1410
|
-
const D = `var(--${
|
|
1411
|
-
this.setValue(D), this.pendingSolidColor = D, i(
|
|
1420
|
+
const D = `var(--${f})`;
|
|
1421
|
+
this.setValue(D), this.pendingSolidColor = D, i(p);
|
|
1412
1422
|
}), m.appendChild(b);
|
|
1413
1423
|
} else {
|
|
1414
1424
|
const b = document.createElement("div");
|
|
1415
1425
|
b.className = "global-color-circle";
|
|
1416
1426
|
const L = this.resolveGlobalVarColor(y);
|
|
1417
|
-
b.style.background = L, b.title =
|
|
1427
|
+
b.style.background = L, b.title = f.split("-").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" "), (this.linkedGlobalVariable === `var(--${f})` || e.color === `var(--${f})`) && b.classList.add("selected"), b.addEventListener("click", (E) => {
|
|
1418
1428
|
E.preventDefault();
|
|
1419
|
-
const w = `var(--${
|
|
1420
|
-
this.setValue(w), this.pendingSolidColor = w, i(
|
|
1429
|
+
const w = `var(--${f})`;
|
|
1430
|
+
this.setValue(w), this.pendingSolidColor = w, i(p);
|
|
1421
1431
|
}), m.appendChild(b);
|
|
1422
1432
|
}
|
|
1423
1433
|
});
|
|
@@ -1431,8 +1441,8 @@ const V = class V extends x {
|
|
|
1431
1441
|
const a = document.createElement("input");
|
|
1432
1442
|
a.type = "text", a.className = "global-search-input", a.placeholder = "Search", a.value = this.globalSearchQuery;
|
|
1433
1443
|
const l = document.createElement("div");
|
|
1434
|
-
a.addEventListener("input", (
|
|
1435
|
-
this.globalSearchQuery =
|
|
1444
|
+
a.addEventListener("input", (p) => {
|
|
1445
|
+
this.globalSearchQuery = p.target.value, i(l);
|
|
1436
1446
|
}), n.appendChild(o), n.appendChild(a);
|
|
1437
1447
|
const r = document.createElement("button");
|
|
1438
1448
|
r.className = "global-layout-toggle", r.type = "button";
|
|
@@ -1467,15 +1477,15 @@ const V = class V extends x {
|
|
|
1467
1477
|
{
|
|
1468
1478
|
const c = document.createElement("div");
|
|
1469
1479
|
c.className = "gradient-subtype-inline";
|
|
1470
|
-
const
|
|
1471
|
-
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1480
|
+
const p = document.createElement("select");
|
|
1481
|
+
p.className = "gradient-subtype-select";
|
|
1482
|
+
const d = document.createElement("option");
|
|
1483
|
+
d.value = "linear", d.textContent = "Linear";
|
|
1474
1484
|
const g = document.createElement("option");
|
|
1475
|
-
g.value = "radial", g.textContent = "Radial",
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1478
|
-
this.clearGlobalBindingForCustomChange(), this.switchType(
|
|
1485
|
+
g.value = "radial", g.textContent = "Radial", p.appendChild(d), p.appendChild(g), p.value = this.value.type === "radial" ? "radial" : "linear", e = document.createElement("input"), e.type = "text", e.inputMode = "numeric", e.className = "gradient-degree-input", e.value = `${this.value.angle ?? 90}°`, e.style.width = "75px", e.style.textAlign = "center", (!this.value.angle || this.value.stops.length < 2) && (this.value.angle = 90, e.value = "90°");
|
|
1486
|
+
const C = document.createElement("button");
|
|
1487
|
+
C.type = "button", C.className = "gradient-flip-btn", C.innerHTML = Tt, p.addEventListener("change", () => {
|
|
1488
|
+
this.clearGlobalBindingForCustomChange(), this.switchType(p.value === "radial" ? "radial" : "linear", !0), e && this.updateDegreeVisibility(e);
|
|
1479
1489
|
}), e.addEventListener("focus", (m) => {
|
|
1480
1490
|
const u = m.target;
|
|
1481
1491
|
u.value = u.value.replace(/[^0-9-]/g, ""), setTimeout(() => u.select(), 0);
|
|
@@ -1484,16 +1494,16 @@ const V = class V extends x {
|
|
|
1484
1494
|
const u = parseInt(m.target.value);
|
|
1485
1495
|
!Number.isNaN(u) && this.value && (this.value.angle = Math.max(0, Math.min(360, u)), this.debouncedPreviewUpdate());
|
|
1486
1496
|
}), e.addEventListener("blur", (m) => {
|
|
1487
|
-
var
|
|
1497
|
+
var f;
|
|
1488
1498
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
1489
1499
|
const u = m.target;
|
|
1490
1500
|
let v = parseInt(u.value);
|
|
1491
|
-
Number.isNaN(v) && (v = ((
|
|
1492
|
-
}),
|
|
1501
|
+
Number.isNaN(v) && (v = ((f = this.value) == null ? void 0 : f.angle) ?? 0), v = Math.max(0, Math.min(360, v)), this.value && (this.value.angle = v), u.value = `${v}°`, this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
1502
|
+
}), C.addEventListener("click", () => {
|
|
1493
1503
|
this.clearGlobalBindingForCustomChange(), !(!this.value || !this.value.stops) && (this.value.stops.forEach((m) => {
|
|
1494
1504
|
m.position = 100 - m.position;
|
|
1495
1505
|
}), this.value.stops.sort((m, u) => m.position - u.position), this.updateGradientPreview(i), this.createHandles(s, i), this.updateStopsList(l), this.updateUI(), this.triggerChange());
|
|
1496
|
-
}), c.appendChild(
|
|
1506
|
+
}), c.appendChild(p), c.appendChild(e), c.appendChild(C), t.appendChild(c), this.updateDegreeVisibility(e);
|
|
1497
1507
|
}
|
|
1498
1508
|
const i = document.createElement("div");
|
|
1499
1509
|
i.className = "gradient-preview", this.updateGradientPreview(i);
|
|
@@ -1508,8 +1518,8 @@ const V = class V extends x {
|
|
|
1508
1518
|
const l = document.createElement("div");
|
|
1509
1519
|
l.className = "gradient-stops", t.appendChild(n), t.appendChild(l), this.updateStopsList(l);
|
|
1510
1520
|
const r = at((c) => {
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1521
|
+
const p = T(c);
|
|
1522
|
+
p && (this.clearGlobalBindingForCustomChange(), this.value = p, this.switchType(p.type, !0), this.updateUI(), this.triggerChange());
|
|
1513
1523
|
}, "all");
|
|
1514
1524
|
this.recentGradientRefresh = r.refresh, t.appendChild(r.container), a.addEventListener("click", () => {
|
|
1515
1525
|
var c;
|
|
@@ -1547,29 +1557,29 @@ const V = class V extends x {
|
|
|
1547
1557
|
const l = new ut((u, v) => {
|
|
1548
1558
|
this.clearGlobalBindingForCustomChange(), this.value && this.value.stops[s] && (this.value.stops[s].color = u, v !== void 0 && (this.value.stops[s].opacity = v), o.style.backgroundColor = u, this.updateGradientPreview(), this.updateStopsList(), this.updateUI(), this.triggerChange());
|
|
1549
1559
|
}, "solid");
|
|
1550
|
-
let r = !1, c = !1,
|
|
1560
|
+
let r = !1, c = !1, p = 0, d = 0;
|
|
1551
1561
|
const g = (u) => {
|
|
1552
|
-
r = !0, c = !1,
|
|
1553
|
-
},
|
|
1562
|
+
r = !0, c = !1, p = u.clientX, d = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove", C), document.addEventListener("mouseup", m), u.preventDefault(), u.stopPropagation();
|
|
1563
|
+
}, C = (u) => {
|
|
1554
1564
|
if (!r || !this.value) return;
|
|
1555
|
-
const v = u.clientX -
|
|
1565
|
+
const v = u.clientX - p;
|
|
1556
1566
|
if (Math.abs(v) > 3 && (c = !0), c) {
|
|
1557
1567
|
this.clearGlobalBindingForCustomChange();
|
|
1558
|
-
const
|
|
1559
|
-
let y =
|
|
1568
|
+
const f = e.getBoundingClientRect();
|
|
1569
|
+
let y = d + v / f.width * 100;
|
|
1560
1570
|
y = Math.max(0, Math.min(100, y)), this.value.stops[s].position = Math.round(y), n.style.left = `${y}%`, this.updateGradientPreview();
|
|
1561
1571
|
}
|
|
1562
1572
|
}, m = (u) => {
|
|
1563
1573
|
var v;
|
|
1564
1574
|
if (r)
|
|
1565
|
-
if (r = !1, n.classList.remove("selected"), document.removeEventListener("mousemove",
|
|
1566
|
-
this.value && (this.value.stops.sort((
|
|
1575
|
+
if (r = !1, n.classList.remove("selected"), document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", m), c)
|
|
1576
|
+
this.value && (this.value.stops.sort((f, y) => f.position - y.position), this.createHandles(t, e), this.updateStopsList()), this.updateUI(), this.triggerChange();
|
|
1567
1577
|
else {
|
|
1568
1578
|
u.stopPropagation();
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1571
|
-
const y = this.resolveGlobalVarColor(
|
|
1572
|
-
l.open(y, o,
|
|
1579
|
+
const f = (v = this.value) == null ? void 0 : v.stops[s];
|
|
1580
|
+
f && setTimeout(() => {
|
|
1581
|
+
const y = this.resolveGlobalVarColor(f.color);
|
|
1582
|
+
l.open(y, o, f.opacity ?? 100);
|
|
1573
1583
|
}, 0);
|
|
1574
1584
|
}
|
|
1575
1585
|
};
|
|
@@ -1589,50 +1599,50 @@ const V = class V extends x {
|
|
|
1589
1599
|
l.type = "text", l.className = "gstop-position-input", l.value = `${s.position}%`, l.style.width = "60px", a.appendChild(l);
|
|
1590
1600
|
const r = document.createElement("div");
|
|
1591
1601
|
r.className = "gstop-color-container";
|
|
1592
|
-
const c = this.resolveGlobalVarColor(s.color),
|
|
1593
|
-
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1602
|
+
const c = this.resolveGlobalVarColor(s.color), p = document.createElement("div");
|
|
1603
|
+
p.className = "gstop-color-preview", p.style.backgroundColor = c;
|
|
1604
|
+
const d = document.createElement("input");
|
|
1605
|
+
d.type = "text", d.className = "gstop-color-input", d.value = c.replace("#", "").toUpperCase();
|
|
1596
1606
|
const g = document.createElement("button");
|
|
1597
|
-
g.type = "button", g.className = "gstop-color-copy", g.textContent = "Copy", r.appendChild(
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1607
|
+
g.type = "button", g.className = "gstop-color-copy", g.textContent = "Copy", r.appendChild(p), r.appendChild(d), r.appendChild(g);
|
|
1608
|
+
const C = document.createElement("button");
|
|
1609
|
+
C.type = "button", C.className = "gstop-del", C.innerHTML = Pt, C.disabled = (((I = (L = this.value) == null ? void 0 : L.stops) == null ? void 0 : I.length) || 0) <= 2, o.appendChild(a), o.appendChild(r), o.appendChild(C), e.appendChild(o);
|
|
1600
1610
|
const m = document.createElement("span");
|
|
1601
1611
|
m.className = "gstop-opacity-label", m.textContent = "Opacity";
|
|
1602
1612
|
const u = document.createElement("div");
|
|
1603
1613
|
u.className = "gstop-opacity-group";
|
|
1604
1614
|
const v = document.createElement("input");
|
|
1605
1615
|
v.type = "range", v.className = "gstop-opacity-slider", v.min = "0", v.max = "100", v.value = String(s.opacity ?? 100);
|
|
1606
|
-
const
|
|
1607
|
-
v.style.setProperty("--slider-color", `rgb(${
|
|
1616
|
+
const f = P(c);
|
|
1617
|
+
v.style.setProperty("--slider-color", `rgb(${f.r}, ${f.g}, ${f.b})`);
|
|
1608
1618
|
const y = document.createElement("span");
|
|
1609
1619
|
y.className = "gstop-opacity-value", y.textContent = `${s.opacity ?? 100}%`, u.appendChild(v), u.appendChild(y);
|
|
1610
1620
|
const b = new ut((E, w) => {
|
|
1611
|
-
this.clearGlobalBindingForCustomChange(),
|
|
1621
|
+
this.clearGlobalBindingForCustomChange(), d.value = E.replace("#", "").toUpperCase(), p.style.backgroundColor = E, this.value.stops[n].color = E, w !== void 0 && (this.value.stops[n].opacity = w, v.value = String(w), y.textContent = `${w}%`);
|
|
1612
1622
|
const N = P(E);
|
|
1613
1623
|
v.style.setProperty("--slider-color", `rgb(${N.r}, ${N.g}, ${N.b})`), this.updateGradientPreview(), this.createHandles(
|
|
1614
1624
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
1615
1625
|
this.popoverEl.querySelector(".gradient-preview")
|
|
1616
1626
|
), this.updateUI(), this.triggerChange();
|
|
1617
1627
|
}, "solid");
|
|
1618
|
-
|
|
1628
|
+
d.addEventListener("click", (E) => {
|
|
1619
1629
|
E.preventDefault(), E.stopPropagation();
|
|
1620
1630
|
const w = this.resolveGlobalVarColor(s.color);
|
|
1621
|
-
b.open(w,
|
|
1622
|
-
}),
|
|
1631
|
+
b.open(w, d, s.opacity ?? 100);
|
|
1632
|
+
}), d.addEventListener("input", () => {
|
|
1623
1633
|
this.clearGlobalBindingForCustomChange();
|
|
1624
|
-
const E =
|
|
1634
|
+
const E = d.value.trim(), w = E.startsWith("#") ? E : `#${E}`;
|
|
1625
1635
|
if (/^#[0-9A-Fa-f]{6}$/.test(w)) {
|
|
1626
|
-
this.value.stops[n].color = w,
|
|
1636
|
+
this.value.stops[n].color = w, p.style.backgroundColor = w;
|
|
1627
1637
|
const N = P(w);
|
|
1628
1638
|
v.style.setProperty("--slider-color", `rgb(${N.r}, ${N.g}, ${N.b})`), this.debouncedPreviewUpdate();
|
|
1629
1639
|
}
|
|
1630
|
-
}),
|
|
1640
|
+
}), d.addEventListener("blur", () => {
|
|
1631
1641
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
1632
1642
|
}), g.addEventListener("click", async (E) => {
|
|
1633
1643
|
E.stopPropagation();
|
|
1634
1644
|
try {
|
|
1635
|
-
await navigator.clipboard.writeText(`#${
|
|
1645
|
+
await navigator.clipboard.writeText(`#${d.value}`);
|
|
1636
1646
|
} catch {
|
|
1637
1647
|
}
|
|
1638
1648
|
}), l.addEventListener("focus", (E) => {
|
|
@@ -1658,7 +1668,7 @@ const V = class V extends x {
|
|
|
1658
1668
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
1659
1669
|
this.popoverEl.querySelector(".gradient-preview")
|
|
1660
1670
|
), this.updateStopsList(), this.updateUI(), this.triggerChange();
|
|
1661
|
-
}),
|
|
1671
|
+
}), C.addEventListener("click", () => {
|
|
1662
1672
|
var E;
|
|
1663
1673
|
(this.value.stops.length || 0) <= 2 || (this.clearGlobalBindingForCustomChange(), this.value.stops.splice(n, 1), this.createHandles(
|
|
1664
1674
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
@@ -1697,10 +1707,10 @@ const V = class V extends x {
|
|
|
1697
1707
|
this.popoverEl.style.position = "fixed", this.popoverEl.style.zIndex = "10000", this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
1698
1708
|
const o = this.popoverEl.offsetHeight;
|
|
1699
1709
|
let a = t.right + 8, l = t.top;
|
|
1700
|
-
const r = i - t.right, c = t.left,
|
|
1701
|
-
r <
|
|
1702
|
-
const
|
|
1703
|
-
g >= o + n ? l = t.top - o - 8 :
|
|
1710
|
+
const r = i - t.right, c = t.left, p = e + n;
|
|
1711
|
+
r < p && c > r + 100 && (a = t.left - e - 8);
|
|
1712
|
+
const d = s - t.bottom, g = t.top;
|
|
1713
|
+
g >= o + n ? l = t.top - o - 8 : d >= o + n ? l = t.bottom + 8 : g > d ? (l = t.top - o - 8, l < n && (l = n)) : (l = t.bottom + 8, l + o > s - n && (l = s - o - n)), this.popoverEl.style.left = `${a}px`, this.popoverEl.style.top = `${l}px`, this.popoverPosition = { left: a, top: l };
|
|
1704
1714
|
}
|
|
1705
1715
|
setTimeout(() => document.addEventListener("click", this.onBackgroundClick, !0), 200), document.addEventListener("keydown", this.handlePopoverKeydown, !0);
|
|
1706
1716
|
}
|
|
@@ -1718,10 +1728,10 @@ const V = class V extends x {
|
|
|
1718
1728
|
this.popoverEl.style.left, this.popoverEl.style.top, this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
1719
1729
|
const a = this.popoverEl.offsetHeight;
|
|
1720
1730
|
let l = e.right + 8, r = e.top;
|
|
1721
|
-
const c = s - e.right,
|
|
1722
|
-
c <
|
|
1723
|
-
const g = n - e.bottom,
|
|
1724
|
-
|
|
1731
|
+
const c = s - e.right, p = e.left, d = i + o;
|
|
1732
|
+
c < d && p > c + 100 && (l = e.left - i - 8);
|
|
1733
|
+
const g = n - e.bottom, C = e.top;
|
|
1734
|
+
C >= a + o ? r = e.top - a - 8 : g >= a + o ? r = e.bottom + 8 : C > g ? (r = e.top - a - 8, r < o && (r = o)) : (r = e.bottom + 8, r + a > n - o && (r = n - a - o)), this.popoverEl.style.left = `${l}px`, this.popoverEl.style.top = `${r}px`;
|
|
1725
1735
|
});
|
|
1726
1736
|
}
|
|
1727
1737
|
}
|
|
@@ -1740,13 +1750,13 @@ const V = class V extends x {
|
|
|
1740
1750
|
if (!(!this.popoverEl || !this.isPopoverOpen)) {
|
|
1741
1751
|
if (this.isPopoverOpen = !1, this.popoverPosition = null, this.backdropEl && (this.backdropEl.style.display = "none"), this.popoverEl.style.display = "none", document.removeEventListener("click", this.onBackgroundClick, !0), document.removeEventListener("keydown", this.handlePopoverKeydown, !0), this.commitPendingSolidColor(), this.value && this.value.type !== "solid") {
|
|
1742
1752
|
const e = S(this.value);
|
|
1743
|
-
|
|
1753
|
+
R.addColor(e, "gradient"), (t = this.recentGradientRefresh) == null || t.call(this);
|
|
1744
1754
|
}
|
|
1745
1755
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), V.openInstance === this && (V.openInstance = null);
|
|
1746
1756
|
}
|
|
1747
1757
|
}
|
|
1748
1758
|
commitPendingSolidColor() {
|
|
1749
|
-
this.pendingSolidColor && (this.solidPicker ? this.solidPicker.commitRecentColor() :
|
|
1759
|
+
this.pendingSolidColor && (this.solidPicker ? this.solidPicker.commitRecentColor() : R.addColor(this.pendingSolidColor, "solid"), this.pendingSolidColor = null);
|
|
1750
1760
|
}
|
|
1751
1761
|
handlePaste(t) {
|
|
1752
1762
|
var i;
|
|
@@ -1796,10 +1806,10 @@ const V = class V extends x {
|
|
|
1796
1806
|
};
|
|
1797
1807
|
V.openInstance = null, V.CHANGE_DEBOUNCE_DELAY = 150;
|
|
1798
1808
|
let j = V;
|
|
1799
|
-
function J(
|
|
1800
|
-
for (const e in
|
|
1801
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
1802
|
-
const i =
|
|
1809
|
+
function J(h, t) {
|
|
1810
|
+
for (const e in h)
|
|
1811
|
+
if (Object.prototype.hasOwnProperty.call(h, e)) {
|
|
1812
|
+
const i = h[e];
|
|
1803
1813
|
t(e, i);
|
|
1804
1814
|
}
|
|
1805
1815
|
}
|
|
@@ -1820,6 +1830,14 @@ const Q = class Q {
|
|
|
1820
1830
|
setNestingLevel(t) {
|
|
1821
1831
|
this.nestingLevel = t, this.propagateNestingLevel(), this.elementRef && this.updateNestingStyles();
|
|
1822
1832
|
}
|
|
1833
|
+
setTitle(t) {
|
|
1834
|
+
if (this.title = t, this.elementRef) {
|
|
1835
|
+
const e = this.elementRef.querySelector(
|
|
1836
|
+
".setting-group-title h3"
|
|
1837
|
+
);
|
|
1838
|
+
e && (e.textContent = t);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1823
1841
|
getDataPropsPath() {
|
|
1824
1842
|
return this.dataPropsPath;
|
|
1825
1843
|
}
|
|
@@ -1897,16 +1915,16 @@ const Q = class Q {
|
|
|
1897
1915
|
}), s.forEach((r) => {
|
|
1898
1916
|
n.includes(r) || this.removeSetting(r);
|
|
1899
1917
|
}), n.forEach((r) => {
|
|
1900
|
-
var
|
|
1901
|
-
const c = t[r],
|
|
1902
|
-
if (
|
|
1918
|
+
var d;
|
|
1919
|
+
const c = t[r], p = this.settings[r];
|
|
1920
|
+
if (p !== c && (p && this.removeSetting(r), this.addSetting(r, c), i && r in o)) {
|
|
1903
1921
|
const g = o[r];
|
|
1904
1922
|
try {
|
|
1905
1923
|
k(c) ? c.setValue(
|
|
1906
1924
|
g
|
|
1907
|
-
) : G(c) ? (
|
|
1908
|
-
} catch (
|
|
1909
|
-
console.warn(`Could not preserve value for setting ${r}:`,
|
|
1925
|
+
) : G(c) ? (d = c.setValue) == null || d.call(c, g) : c.setValue && c.setValue(g);
|
|
1926
|
+
} catch (C) {
|
|
1927
|
+
console.warn(`Could not preserve value for setting ${r}:`, C);
|
|
1910
1928
|
}
|
|
1911
1929
|
}
|
|
1912
1930
|
}), this.settings = t, this.propagateNestingLevel(), this.propagateDataPropsPath();
|
|
@@ -2037,8 +2055,8 @@ const Q = class Q {
|
|
|
2037
2055
|
k(e) && typeof e.setNestingLevel == "function" && e.setNestingLevel(this.nestingLevel + 1);
|
|
2038
2056
|
const a = e.draw(), l = this.deleteItemCfg ?? this.addItemCfg;
|
|
2039
2057
|
if (l) {
|
|
2040
|
-
const
|
|
2041
|
-
|
|
2058
|
+
const p = l.keyPrefix ?? ((s = this.addItemCfg) == null ? void 0 : s.keyPrefix);
|
|
2059
|
+
p && t.startsWith(p) && this.addDeleteButtonToElement(a, t);
|
|
2042
2060
|
}
|
|
2043
2061
|
const r = o.querySelector(".sg-add-button-bottom");
|
|
2044
2062
|
r ? o.insertBefore(a, r) : o.appendChild(a), rt.trackElement(a), Z(a, this.nestingLevel + 1), et(a, this.nestingLevel + 1);
|
|
@@ -2190,11 +2208,11 @@ const Q = class Q {
|
|
|
2190
2208
|
r(), t(!1);
|
|
2191
2209
|
}), l.addEventListener("click", () => {
|
|
2192
2210
|
r(), t(!0);
|
|
2193
|
-
}), e.addEventListener("click", (
|
|
2194
|
-
|
|
2211
|
+
}), e.addEventListener("click", (p) => {
|
|
2212
|
+
p.target === e && (r(), t(!1));
|
|
2195
2213
|
});
|
|
2196
|
-
const c = (
|
|
2197
|
-
|
|
2214
|
+
const c = (p) => {
|
|
2215
|
+
p.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", c));
|
|
2198
2216
|
};
|
|
2199
2217
|
document.addEventListener("keydown", c), o.appendChild(a), o.appendChild(l), i.appendChild(s), i.appendChild(n), i.appendChild(o), e.appendChild(i), document.body.appendChild(e), requestAnimationFrame(() => {
|
|
2200
2218
|
e.style.opacity = "1", i.style.transform = "scale(1)";
|
|
@@ -2338,14 +2356,14 @@ const Q = class Q {
|
|
|
2338
2356
|
}, Object.keys(this.settings).length > 0) {
|
|
2339
2357
|
for (const c in this.settings)
|
|
2340
2358
|
if (Object.prototype.hasOwnProperty.call(this.settings, c)) {
|
|
2341
|
-
const
|
|
2342
|
-
k(
|
|
2343
|
-
const
|
|
2344
|
-
k(
|
|
2345
|
-
|
|
2359
|
+
const p = this.settings[c];
|
|
2360
|
+
k(p) && typeof p.setNestingLevel == "function" && p.setNestingLevel(this.nestingLevel + 1);
|
|
2361
|
+
const d = p.draw();
|
|
2362
|
+
k(p) && p.deleteItemCfg && this.addDeleteButtonToElement(
|
|
2363
|
+
d,
|
|
2346
2364
|
c,
|
|
2347
|
-
|
|
2348
|
-
), a.appendChild(
|
|
2365
|
+
p
|
|
2366
|
+
), a.appendChild(d);
|
|
2349
2367
|
}
|
|
2350
2368
|
} else {
|
|
2351
2369
|
const c = document.createElement("div");
|
|
@@ -2354,18 +2372,18 @@ const Q = class Q {
|
|
|
2354
2372
|
if (this.addItemCfg) {
|
|
2355
2373
|
const c = document.createElement("button");
|
|
2356
2374
|
c.type = "button", c.className = "sg-add-button-bottom", c.style.marginTop = "8px";
|
|
2357
|
-
const
|
|
2375
|
+
const p = `
|
|
2358
2376
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
|
|
2359
2377
|
xmlns="http://www.w3.org/2000/svg">
|
|
2360
2378
|
<path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
|
|
2361
2379
|
stroke-width="1.5" stroke-linecap="round"/>
|
|
2362
2380
|
</svg>`;
|
|
2363
|
-
c.innerHTML = `${
|
|
2364
|
-
|
|
2365
|
-
const g = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),
|
|
2366
|
-
if (ct(
|
|
2381
|
+
c.innerHTML = `${p}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, c.addEventListener("click", (d) => {
|
|
2382
|
+
d.stopPropagation(), d.preventDefault();
|
|
2383
|
+
const g = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), C = this.addItemCfg.createItem(g);
|
|
2384
|
+
if (ct(C)) {
|
|
2367
2385
|
const m = `${this.addItemCfg.keyPrefix}${g}`;
|
|
2368
|
-
this.addSetting(m,
|
|
2386
|
+
this.addSetting(m, C);
|
|
2369
2387
|
}
|
|
2370
2388
|
}), a.appendChild(c);
|
|
2371
2389
|
}
|
|
@@ -2413,8 +2431,8 @@ const Q = class Q {
|
|
|
2413
2431
|
};
|
|
2414
2432
|
Q.hiddenElements = /* @__PURE__ */ new Set();
|
|
2415
2433
|
let $ = Q;
|
|
2416
|
-
function be(
|
|
2417
|
-
return new At(
|
|
2434
|
+
function be(h) {
|
|
2435
|
+
return new At(h);
|
|
2418
2436
|
}
|
|
2419
2437
|
class At extends $ {
|
|
2420
2438
|
constructor(t) {
|
|
@@ -2466,9 +2484,9 @@ class At extends $ {
|
|
|
2466
2484
|
r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id", a), r.textContent = a, r.addEventListener("click", () => this.switchToTab(a)), n.appendChild(r);
|
|
2467
2485
|
const c = document.createElement("div");
|
|
2468
2486
|
c.className = "tab-panel", this.contentContainers[a] = c;
|
|
2469
|
-
const
|
|
2470
|
-
|
|
2471
|
-
|
|
2487
|
+
const p = this.settings[a];
|
|
2488
|
+
p && (k(p) && typeof p.setNestingLevel == "function" && p.setNestingLevel(this.getNestingLevel() + 1), c.appendChild(
|
|
2489
|
+
p.draw()
|
|
2472
2490
|
)), o.appendChild(c), l === 0 && !this.activeTabId && (this.activeTabId = a);
|
|
2473
2491
|
}), e.appendChild(i), e.appendChild(n), e.appendChild(o), !this.activeTabId) {
|
|
2474
2492
|
const a = Object.keys(this.settings)[0];
|
|
@@ -2477,11 +2495,11 @@ class At extends $ {
|
|
|
2477
2495
|
return this.updateTabUI(), t;
|
|
2478
2496
|
}
|
|
2479
2497
|
}
|
|
2480
|
-
function Dt(
|
|
2481
|
-
return new $(
|
|
2498
|
+
function Dt(h) {
|
|
2499
|
+
return new $(h);
|
|
2482
2500
|
}
|
|
2483
|
-
function we(
|
|
2484
|
-
return
|
|
2501
|
+
function we(h) {
|
|
2502
|
+
return h;
|
|
2485
2503
|
}
|
|
2486
2504
|
class Gt extends x {
|
|
2487
2505
|
constructor(t = {}) {
|
|
@@ -2524,8 +2542,8 @@ class O extends Gt {
|
|
|
2524
2542
|
if (e.length !== 3 || e.some(isNaN))
|
|
2525
2543
|
return console.warn(`Invalid RGB value "${t}", using default "#000000"`), "#000000";
|
|
2526
2544
|
const [i, s, n] = e, o = Math.max(0, Math.min(255, i)), a = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (c) => {
|
|
2527
|
-
const
|
|
2528
|
-
return
|
|
2545
|
+
const p = c.toString(16);
|
|
2546
|
+
return p.length === 1 ? "0" + p : p;
|
|
2529
2547
|
};
|
|
2530
2548
|
return `#${r(o)}${r(a)}${r(l)}`;
|
|
2531
2549
|
}
|
|
@@ -2586,15 +2604,15 @@ class O extends Gt {
|
|
|
2586
2604
|
return;
|
|
2587
2605
|
}
|
|
2588
2606
|
Object.entries(m).forEach(([u, v]) => {
|
|
2589
|
-
const
|
|
2590
|
-
|
|
2607
|
+
const f = document.createElement("button");
|
|
2608
|
+
f.className = "global-color-btn", f.title = u, f.style.width = "30px", f.style.height = "30px", f.style.borderRadius = "50%", f.style.border = "1px solid #ddd", f.style.backgroundColor = v, f.style.cursor = "pointer", this.value === `var(--${u})` && (f.style.border = "2px solid #2196f3"), f.addEventListener("click", (y) => {
|
|
2591
2609
|
var L, I;
|
|
2592
2610
|
y.preventDefault();
|
|
2593
2611
|
const b = `var(--${u})`;
|
|
2594
2612
|
this.value = b, (L = this.onChange) == null || L.call(this, b), (I = this.detectChange) == null || I.call(this, b), Array.from(a.children).forEach((E) => {
|
|
2595
2613
|
E.style.border = "1px solid #ddd";
|
|
2596
|
-
}),
|
|
2597
|
-
}), a.appendChild(
|
|
2614
|
+
}), f.style.border = "2px solid #2196f3", p.style.backgroundColor = v;
|
|
2615
|
+
}), a.appendChild(f);
|
|
2598
2616
|
});
|
|
2599
2617
|
} catch (m) {
|
|
2600
2618
|
console.error("ColorSetting: Error in renderGlobalOptions", m), a.innerHTML = "Error loading global options";
|
|
@@ -2609,48 +2627,48 @@ class O extends Gt {
|
|
|
2609
2627
|
const u = m.value.trim();
|
|
2610
2628
|
if (!u)
|
|
2611
2629
|
return e.classList.remove("error"), !0;
|
|
2612
|
-
const
|
|
2613
|
-
return
|
|
2630
|
+
const f = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(u);
|
|
2631
|
+
return f ? e.classList.remove("error") : e.classList.add("error"), f;
|
|
2614
2632
|
}, c = document.createElement("input");
|
|
2615
2633
|
c.type = "color", c.className = "color-picker", c.value = this.value && !this.value.startsWith("var(--") ? this.value : "#000000", c.setAttribute("aria-label", "Choose color"), c.setAttribute("title", "Click to open color picker"), this.getDataPropsPath() && c.setAttribute("data-test-id", this.getDataPropsPath()), this.colorInputEl = c;
|
|
2616
|
-
const
|
|
2617
|
-
|
|
2618
|
-
let
|
|
2619
|
-
if (
|
|
2620
|
-
const m =
|
|
2621
|
-
|
|
2634
|
+
const p = document.createElement("div");
|
|
2635
|
+
p.className = "color-preview";
|
|
2636
|
+
let d = this.value || "#000000";
|
|
2637
|
+
if (d.startsWith("var(--")) {
|
|
2638
|
+
const m = d.replace("var(--", "").replace(")", "");
|
|
2639
|
+
d = (x.GlobalVariables || {})[m] || "#000000";
|
|
2622
2640
|
}
|
|
2623
|
-
|
|
2641
|
+
p.style.backgroundColor = d;
|
|
2624
2642
|
const g = document.createElement("input");
|
|
2625
2643
|
g.type = "text", g.className = "color-text-input", g.value = this.value || "", g.placeholder = "#000000", g.setAttribute("pattern", "#[0-9A-Fa-f]{6}"), g.setAttribute("title", "Enter a hex color value (e.g., #ff0000)"), g.setAttribute("aria-label", "Hex color value"), g.setAttribute("maxlength", "7"), this.getDataPropsPath() && g.setAttribute("data-test-id", `${this.getDataPropsPath()}_text`), this.textInputEl = g;
|
|
2626
|
-
const
|
|
2627
|
-
var v,
|
|
2644
|
+
const C = (m) => {
|
|
2645
|
+
var v, f;
|
|
2628
2646
|
let u = m.trim();
|
|
2629
2647
|
if (u && !u.startsWith("#") && !u.startsWith("var(") && /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(u) && (u = "#" + u, this.textInputEl && (this.textInputEl.value = u)), this.textInputEl && r(this.textInputEl)) {
|
|
2630
2648
|
const y = O.normalizeColorValue(u);
|
|
2631
|
-
this.value = y, (v = this.onChange) == null || v.call(this, y), (
|
|
2649
|
+
this.value = y, (v = this.onChange) == null || v.call(this, y), (f = this.detectChange) == null || f.call(this, y), this.colorInputEl && (this.colorInputEl.value = y), p.style.backgroundColor = y;
|
|
2632
2650
|
}
|
|
2633
2651
|
};
|
|
2634
2652
|
return this.textInputEl.addEventListener("input", (m) => {
|
|
2635
2653
|
const u = m.target.value;
|
|
2636
|
-
|
|
2654
|
+
C(u);
|
|
2637
2655
|
}), this.textInputEl.addEventListener("paste", (m) => {
|
|
2638
2656
|
var v;
|
|
2639
2657
|
m.preventDefault();
|
|
2640
2658
|
const u = ((v = m.clipboardData) == null ? void 0 : v.getData("text")) || "";
|
|
2641
|
-
this.textInputEl && (this.textInputEl.value = u.trim(),
|
|
2659
|
+
this.textInputEl && (this.textInputEl.value = u.trim(), C(u));
|
|
2642
2660
|
}), this.textInputEl.addEventListener("keydown", (m) => {
|
|
2643
|
-
var u, v,
|
|
2644
|
-
m.key === "Enter" && (m.preventDefault(),
|
|
2661
|
+
var u, v, f;
|
|
2662
|
+
m.key === "Enter" && (m.preventDefault(), C(((u = this.textInputEl) == null ? void 0 : u.value) || ""), (v = this.textInputEl) == null || v.blur()), m.key === "Escape" && (this.textInputEl && this.value && (this.textInputEl.value = this.value), (f = this.textInputEl) == null || f.blur(), e.classList.remove("error"));
|
|
2645
2663
|
}), this.colorInputEl.addEventListener("input", (m) => {
|
|
2646
|
-
var
|
|
2664
|
+
var f, y;
|
|
2647
2665
|
const u = m.target.value, v = O.normalizeColorValue(u);
|
|
2648
|
-
this.value = v, (
|
|
2666
|
+
this.value = v, (f = this.onChange) == null || f.call(this, v), (y = this.detectChange) == null || y.call(this, v), this.textInputEl && (this.textInputEl.value = v), p.style.backgroundColor = v, e.classList.remove("error");
|
|
2649
2667
|
}), this.colorInputEl.addEventListener("change", (m) => {
|
|
2650
|
-
var
|
|
2668
|
+
var f, y;
|
|
2651
2669
|
const u = m.target.value, v = O.normalizeColorValue(u);
|
|
2652
|
-
this.value = v, (
|
|
2653
|
-
}), o.appendChild(c), o.appendChild(
|
|
2670
|
+
this.value = v, (f = this.onChange) == null || f.call(this, v), (y = this.detectChange) == null || y.call(this, v), this.textInputEl && (this.textInputEl.value = v), p.style.backgroundColor = v;
|
|
2671
|
+
}), o.appendChild(c), o.appendChild(p), o.appendChild(g), e.appendChild(i), e.appendChild(o), e.appendChild(a), t.appendChild(e), this.element = t, t;
|
|
2654
2672
|
}
|
|
2655
2673
|
getElement() {
|
|
2656
2674
|
return this.element;
|
|
@@ -2674,14 +2692,14 @@ const Rt = `
|
|
|
2674
2692
|
<path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
2675
2693
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
2676
2694
|
</svg>`;
|
|
2677
|
-
class
|
|
2695
|
+
class z extends x {
|
|
2678
2696
|
constructor(t = {}) {
|
|
2679
2697
|
super({
|
|
2680
2698
|
...t,
|
|
2681
2699
|
icon: t.icon || Rt,
|
|
2682
2700
|
title: t.title || "Color & Opacity",
|
|
2683
2701
|
default: t.default || "#000000FF"
|
|
2684
|
-
}), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.opacityInputEl = null, this.colorPreviewEl = null, this.detectChange = t.detectChange, this.value && (this.value =
|
|
2702
|
+
}), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.opacityInputEl = null, this.colorPreviewEl = null, this.detectChange = t.detectChange, this.value && (this.value = z.normalizeHexWithOpacity(this.value));
|
|
2685
2703
|
}
|
|
2686
2704
|
static normalizeHexWithOpacity(t) {
|
|
2687
2705
|
return t = t.replace("#", ""), t.length === 3 && (t = t.split("").map((e) => e + e).join("")), t.length === 6 && (t = t + "FF"), t.length === 8 && /^[0-9A-Fa-f]{8}$/.test(t) ? `#${t.toUpperCase()}` : (console.warn(`Invalid hex value "${t}", using default "#000000FF"`), "#000000FF");
|
|
@@ -2699,7 +2717,7 @@ class R extends x {
|
|
|
2699
2717
|
return `#${i}${n}`;
|
|
2700
2718
|
}
|
|
2701
2719
|
setValue(t) {
|
|
2702
|
-
t === void 0 || t === "" ? this.value = "#000000FF" : this.value =
|
|
2720
|
+
t === void 0 || t === "" ? this.value = "#000000FF" : this.value = z.normalizeHexWithOpacity(t), this.updateInputElements(), this.updateColorPreview(), this.onChange && this.onChange(this.value), this.detectChange && this.detectChange(this.value);
|
|
2703
2721
|
}
|
|
2704
2722
|
updateInputElements() {
|
|
2705
2723
|
this.value && (this.colorInputEl && (this.colorInputEl.value = this.getRgbColor()), this.textInputEl && (this.textInputEl.value = this.value), this.opacityInputEl && (this.opacityInputEl.value = this.getOpacityPercent().toString()));
|
|
@@ -2710,7 +2728,7 @@ class R extends x {
|
|
|
2710
2728
|
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
2711
2729
|
}
|
|
2712
2730
|
handleColorChange(t) {
|
|
2713
|
-
const e = this.getOpacityPercent(), i =
|
|
2731
|
+
const e = this.getOpacityPercent(), i = z.combineColorOpacity(
|
|
2714
2732
|
t,
|
|
2715
2733
|
e
|
|
2716
2734
|
);
|
|
@@ -2721,7 +2739,7 @@ class R extends x {
|
|
|
2721
2739
|
return e || i ? (this.setValue(t), !0) : !1;
|
|
2722
2740
|
}
|
|
2723
2741
|
handleOpacityChange(t) {
|
|
2724
|
-
const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s =
|
|
2742
|
+
const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s = z.combineColorOpacity(
|
|
2725
2743
|
e,
|
|
2726
2744
|
i
|
|
2727
2745
|
);
|
|
@@ -3637,33 +3655,33 @@ const Kt = `
|
|
|
3637
3655
|
"mousemove",
|
|
3638
3656
|
(c) => this.updateCursorTooltip(c)
|
|
3639
3657
|
), this.value && this.value.markers && this.value.markers.forEach((c) => {
|
|
3640
|
-
const
|
|
3641
|
-
r.appendChild(
|
|
3658
|
+
const p = this.createMarkerElement(c);
|
|
3659
|
+
r.appendChild(p);
|
|
3642
3660
|
}), l.appendChild(r), t.appendChild(l);
|
|
3643
3661
|
}
|
|
3644
3662
|
renderSidebar(t) {
|
|
3645
|
-
var c,
|
|
3663
|
+
var c, p;
|
|
3646
3664
|
const e = document.createElement("div");
|
|
3647
3665
|
e.className = "prize-counter";
|
|
3648
3666
|
const i = this.props.maxMarkers || 10, s = ((c = this.value) == null ? void 0 : c.markers.length) || 0, n = s === i;
|
|
3649
3667
|
e.textContent = `Prizes ${s}/${i}`, n && e.classList.add("complete"), t.appendChild(e);
|
|
3650
3668
|
const o = document.createElement("div");
|
|
3651
3669
|
o.className = "prize-list";
|
|
3652
|
-
const a = ((
|
|
3653
|
-
a.forEach((
|
|
3654
|
-
for (let
|
|
3655
|
-
const g = l.get(
|
|
3656
|
-
u.className = `prize-item ${
|
|
3670
|
+
const a = ((p = this.value) == null ? void 0 : p.markers) || [], l = /* @__PURE__ */ new Map();
|
|
3671
|
+
a.forEach((d) => l.set(d.index, d));
|
|
3672
|
+
for (let d = 1; d <= i; d++) {
|
|
3673
|
+
const g = l.get(d), C = !!g, m = (g == null ? void 0 : g.prizeName) || this.props.prizeMap && this.props.prizeMap[d - 1] || `Prize #${d}`, u = document.createElement("div");
|
|
3674
|
+
u.className = `prize-item ${C ? "placed" : "missing"}`;
|
|
3657
3675
|
const v = document.createElement("div");
|
|
3658
|
-
v.className = "prize-index", v.textContent = String(
|
|
3659
|
-
const
|
|
3660
|
-
|
|
3676
|
+
v.className = "prize-index", v.textContent = String(d);
|
|
3677
|
+
const f = document.createElement("div");
|
|
3678
|
+
f.className = "prize-label";
|
|
3661
3679
|
const y = document.createElement("div");
|
|
3662
|
-
y.className = "prize-title", y.textContent = `Prize #${
|
|
3680
|
+
y.className = "prize-title", y.textContent = `Prize #${d}`;
|
|
3663
3681
|
const b = document.createElement("div");
|
|
3664
|
-
b.className = "prize-subtitle", b.textContent =
|
|
3682
|
+
b.className = "prize-subtitle", b.textContent = C ? m : "Not Placed", f.appendChild(y), f.appendChild(b);
|
|
3665
3683
|
const L = document.createElement("div");
|
|
3666
|
-
L.className = `prize-status ${
|
|
3684
|
+
L.className = `prize-status ${C ? "placed" : "missing"}`, L.innerHTML = C ? ie : se, u.appendChild(v), u.appendChild(f), u.appendChild(L), o.appendChild(u);
|
|
3667
3685
|
}
|
|
3668
3686
|
t.appendChild(o);
|
|
3669
3687
|
const r = document.createElement("button");
|
|
@@ -3716,20 +3734,20 @@ const Kt = `
|
|
|
3716
3734
|
if (typeof a == "string") {
|
|
3717
3735
|
const r = new Image();
|
|
3718
3736
|
r.onload = () => {
|
|
3719
|
-
var
|
|
3737
|
+
var d;
|
|
3720
3738
|
const c = {
|
|
3721
3739
|
width: r.naturalWidth || 0,
|
|
3722
3740
|
height: r.naturalHeight || 0
|
|
3723
|
-
},
|
|
3724
|
-
((
|
|
3741
|
+
}, p = this.scaleMarkersForNewImage(
|
|
3742
|
+
((d = this.value) == null ? void 0 : d.markers) || [],
|
|
3725
3743
|
e,
|
|
3726
3744
|
c
|
|
3727
3745
|
);
|
|
3728
3746
|
this.value = {
|
|
3729
3747
|
imageUrl: a,
|
|
3730
|
-
markers:
|
|
3748
|
+
markers: p
|
|
3731
3749
|
}, this.lastImageNaturalSize = c, this.history = [
|
|
3732
|
-
JSON.parse(JSON.stringify(
|
|
3750
|
+
JSON.parse(JSON.stringify(p))
|
|
3733
3751
|
], this.historyIndex = 0, this.updateUndoRedoButtons(), this.updateButtonDisplay(), this.refreshPopoverContent(), this.triggerChange();
|
|
3734
3752
|
}, r.onerror = () => {
|
|
3735
3753
|
this.showError("Failed to read image file.");
|
|
@@ -3747,7 +3765,7 @@ const Kt = `
|
|
|
3747
3765
|
);
|
|
3748
3766
|
return;
|
|
3749
3767
|
}
|
|
3750
|
-
const e = this.imageElement.getBoundingClientRect(), i = (t.clientX - e.left) / e.width * 100, s = (t.clientY - e.top) / e.height * 100, n = this.value.markers.map((c) => c.index).sort((c,
|
|
3768
|
+
const e = this.imageElement.getBoundingClientRect(), i = (t.clientX - e.left) / e.width * 100, s = (t.clientY - e.top) / e.height * 100, n = this.value.markers.map((c) => c.index).sort((c, p) => c - p);
|
|
3751
3769
|
let o = 1;
|
|
3752
3770
|
for (const c of n)
|
|
3753
3771
|
if (c === o)
|
|
@@ -3955,11 +3973,11 @@ const Kt = `
|
|
|
3955
3973
|
r.type = "button", r.className = "confirm-btn ghost", r.textContent = "Cancel";
|
|
3956
3974
|
const c = document.createElement("button");
|
|
3957
3975
|
c.type = "button", c.className = "confirm-btn danger", c.textContent = "Discard";
|
|
3958
|
-
const
|
|
3959
|
-
s.remove(), this.confirmOverlayEl = null, this.confirmPromise = null, i(
|
|
3976
|
+
const p = (d) => {
|
|
3977
|
+
s.remove(), this.confirmOverlayEl = null, this.confirmPromise = null, i(d);
|
|
3960
3978
|
};
|
|
3961
|
-
r.addEventListener("click", () =>
|
|
3962
|
-
|
|
3979
|
+
r.addEventListener("click", () => p(!1)), c.addEventListener("click", () => p(!0)), s.addEventListener("click", (d) => {
|
|
3980
|
+
d.target === s && p(!1);
|
|
3963
3981
|
}), l.appendChild(r), l.appendChild(c), n.appendChild(o), n.appendChild(a), n.appendChild(l), s.appendChild(n), document.body.appendChild(s), setTimeout(() => {
|
|
3964
3982
|
n.classList.add("visible");
|
|
3965
3983
|
}, 10);
|
|
@@ -4194,7 +4212,7 @@ class Ne extends x {
|
|
|
4194
4212
|
const s = document.createElement("input");
|
|
4195
4213
|
s.type = "checkbox", s.checked = ((a = (o = this.props.options) == null ? void 0 : o.find((l) => l.value === this.value)) == null ? void 0 : a.status) ?? !1, this.getDataPropsPath() && s.setAttribute("data-test-id", this.getDataPropsPath()), s.addEventListener("change", () => {
|
|
4196
4214
|
var r, c;
|
|
4197
|
-
const l = ((c = (r = this.props.options) == null ? void 0 : r.find((
|
|
4215
|
+
const l = ((c = (r = this.props.options) == null ? void 0 : r.find((p) => p.status === s.checked)) == null ? void 0 : c.value) ?? "";
|
|
4198
4216
|
this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
|
|
4199
4217
|
});
|
|
4200
4218
|
const n = document.createElement("span");
|
|
@@ -4345,13 +4363,13 @@ class Te extends x {
|
|
|
4345
4363
|
return;
|
|
4346
4364
|
}
|
|
4347
4365
|
const c = "...";
|
|
4348
|
-
let
|
|
4349
|
-
for (;
|
|
4350
|
-
const m = Math.floor((
|
|
4351
|
-
this.measureTextWidth(u, i) <= l ? (g = m,
|
|
4366
|
+
let p = 0, d = e.length, g = 0;
|
|
4367
|
+
for (; p <= d; ) {
|
|
4368
|
+
const m = Math.floor((p + d) / 2), u = e.slice(0, m).trimEnd() + c;
|
|
4369
|
+
this.measureTextWidth(u, i) <= l ? (g = m, p = m + 1) : d = m - 1;
|
|
4352
4370
|
}
|
|
4353
|
-
const
|
|
4354
|
-
t.placeholder =
|
|
4371
|
+
const C = e.slice(0, g).trimEnd() + c;
|
|
4372
|
+
t.placeholder = C;
|
|
4355
4373
|
}
|
|
4356
4374
|
autosizeTextarea(t, e = 3) {
|
|
4357
4375
|
t.style.height = "auto";
|
|
@@ -4860,7 +4878,7 @@ class Be extends $ {
|
|
|
4860
4878
|
opacity: new Ut({
|
|
4861
4879
|
default: (t == null ? void 0 : t.opacity) ?? 100
|
|
4862
4880
|
}),
|
|
4863
|
-
backgroundColor: new
|
|
4881
|
+
backgroundColor: new z({
|
|
4864
4882
|
default: (t == null ? void 0 : t.backgroundColor) ?? "0, 0, 30"
|
|
4865
4883
|
})
|
|
4866
4884
|
}
|
|
@@ -4915,7 +4933,7 @@ export {
|
|
|
4915
4933
|
Oe as BorderSettingSet,
|
|
4916
4934
|
Le as ButtonSetting,
|
|
4917
4935
|
O as ColorSetting,
|
|
4918
|
-
|
|
4936
|
+
z as ColorWithOpacitySetting,
|
|
4919
4937
|
ke as DimensionSetting,
|
|
4920
4938
|
Ie as GapSetting,
|
|
4921
4939
|
j as GradientSetting,
|