builder-settings-types 0.0.313 → 0.0.314
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.
|
@@ -181,23 +181,23 @@ const G = class G {
|
|
|
181
181
|
t = { ...this.props.inputProps, ...t };
|
|
182
182
|
const e = document.createElement("div");
|
|
183
183
|
if (e.className = t.wrapperClassName || "", t.title || t.icon) {
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
184
|
+
const a = document.createElement("div");
|
|
185
|
+
if (a.className = "icon-container", t.icon) {
|
|
186
186
|
const l = this.createIcon(t.icon, t.iconClassName);
|
|
187
|
-
|
|
187
|
+
a.appendChild(l);
|
|
188
188
|
}
|
|
189
189
|
if (t.title) {
|
|
190
190
|
const l = this.createLabel(t.title, t.labelClassName);
|
|
191
|
-
|
|
191
|
+
a.appendChild(l);
|
|
192
192
|
}
|
|
193
|
-
e.appendChild(
|
|
193
|
+
e.appendChild(a);
|
|
194
194
|
}
|
|
195
195
|
const i = document.createElement("div");
|
|
196
196
|
i.className = t.wrapperClassName || "";
|
|
197
197
|
const s = document.createElement("input");
|
|
198
198
|
this.inputEl = s, s.value = String(t.value || xt(t.inputType)), s.type = t.inputType, s.placeholder = t.placeholder || "", s.className = t.inputClassName || "", this.dataPropsPath && s.setAttribute("data-test-id", this.dataPropsPath);
|
|
199
|
-
const n = (
|
|
200
|
-
const l =
|
|
199
|
+
const n = (a) => {
|
|
200
|
+
const l = a.target;
|
|
201
201
|
let r = l.value;
|
|
202
202
|
switch (t.inputType) {
|
|
203
203
|
case "number":
|
|
@@ -222,10 +222,10 @@ const G = class G {
|
|
|
222
222
|
r = l.value;
|
|
223
223
|
}
|
|
224
224
|
this.value = r, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
|
|
225
|
-
},
|
|
226
|
-
|
|
225
|
+
}, o = (a) => {
|
|
226
|
+
a.target, this.onBlur && this.onBlur(this.value);
|
|
227
227
|
};
|
|
228
|
-
return s.addEventListener("input", n), s.addEventListener("change", n), s.addEventListener("blur",
|
|
228
|
+
return s.addEventListener("input", n), s.addEventListener("change", n), s.addEventListener("blur", o), t.inputCustomizer && t.inputCustomizer(s), i.appendChild(s), e.appendChild(i), e;
|
|
229
229
|
}
|
|
230
230
|
createLabel(t, e) {
|
|
231
231
|
const i = document.createElement("span");
|
|
@@ -321,21 +321,21 @@ const Y = class Y {
|
|
|
321
321
|
".setting-group-content"
|
|
322
322
|
);
|
|
323
323
|
if (n) {
|
|
324
|
-
const
|
|
324
|
+
const o = Array.from(
|
|
325
325
|
n.querySelectorAll(
|
|
326
326
|
".setting-group, .setting, [data-setting-id]"
|
|
327
327
|
)
|
|
328
328
|
);
|
|
329
|
-
for (const
|
|
330
|
-
const l =
|
|
329
|
+
for (const a of o) {
|
|
330
|
+
const l = a.id, r = a.getAttribute(
|
|
331
331
|
"data-setting-id"
|
|
332
332
|
);
|
|
333
333
|
if (l && "id" in e && typeof e.id == "string" && l.includes(e.id)) {
|
|
334
|
-
|
|
334
|
+
a.remove();
|
|
335
335
|
break;
|
|
336
336
|
}
|
|
337
337
|
if (r && "id" in e && typeof e.id == "string" && r === e.id) {
|
|
338
|
-
|
|
338
|
+
a.remove();
|
|
339
339
|
break;
|
|
340
340
|
}
|
|
341
341
|
}
|
|
@@ -348,38 +348,38 @@ const Y = class Y {
|
|
|
348
348
|
updateVisibility() {
|
|
349
349
|
this.elementRef;
|
|
350
350
|
}
|
|
351
|
-
updateSettings(t) {
|
|
352
|
-
var
|
|
353
|
-
const e = new Set(Object.keys(this.settings)),
|
|
354
|
-
i.forEach((
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
}),
|
|
358
|
-
|
|
359
|
-
}),
|
|
351
|
+
updateSettings(t, e) {
|
|
352
|
+
var l;
|
|
353
|
+
const i = (e == null ? void 0 : e.preserveValues) ?? !0, s = new Set(Object.keys(this.settings)), n = Object.keys(t), o = {};
|
|
354
|
+
i && n.forEach((r) => {
|
|
355
|
+
const h = this.settings[r];
|
|
356
|
+
h && (L(h) ? o[r] = h.getValues() : A(h) ? o[r] = h.value : typeof h.getValues == "function" ? o[r] = h.getValues() : h.value !== void 0 && (o[r] = h.value));
|
|
357
|
+
}), s.forEach((r) => {
|
|
358
|
+
n.includes(r) || this.removeSetting(r);
|
|
359
|
+
}), n.forEach((r) => {
|
|
360
360
|
var p;
|
|
361
|
-
const
|
|
362
|
-
if (
|
|
363
|
-
const
|
|
361
|
+
const h = t[r], d = this.settings[r];
|
|
362
|
+
if (d !== h && (d && this.removeSetting(r), this.addSetting(r, h), i && r in o)) {
|
|
363
|
+
const g = o[r];
|
|
364
364
|
try {
|
|
365
|
-
L(
|
|
366
|
-
|
|
367
|
-
) : A(
|
|
368
|
-
} catch (
|
|
369
|
-
console.warn(`Could not preserve value for setting ${
|
|
365
|
+
L(h) ? h.setValue(
|
|
366
|
+
g
|
|
367
|
+
) : A(h) ? (p = h.setValue) == null || p.call(h, g) : h.setValue && h.setValue(g);
|
|
368
|
+
} catch (v) {
|
|
369
|
+
console.warn(`Could not preserve value for setting ${r}:`, v);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
}), this.settings = t, this.propagateNestingLevel(), this.propagateDataPropsPath();
|
|
373
|
-
const
|
|
374
|
-
this.initialValues =
|
|
373
|
+
const a = this.getValues();
|
|
374
|
+
this.initialValues = a, (l = this.onChange) == null || l.call(this, a);
|
|
375
375
|
}
|
|
376
376
|
clone() {
|
|
377
377
|
const t = {};
|
|
378
378
|
j(this.settings, (s, n) => {
|
|
379
|
-
const
|
|
380
|
-
typeof n.clone == "function" ? t[
|
|
381
|
-
`Setting with key '${
|
|
382
|
-
), t[
|
|
379
|
+
const o = String(s);
|
|
380
|
+
typeof n.clone == "function" ? t[o] = n.clone() : (console.warn(
|
|
381
|
+
`Setting with key '${o}' does not have a clone method. Copying reference.`
|
|
382
|
+
), t[o] = n);
|
|
383
383
|
});
|
|
384
384
|
const e = {
|
|
385
385
|
title: this.title,
|
|
@@ -442,15 +442,15 @@ const Y = class Y {
|
|
|
442
442
|
var n;
|
|
443
443
|
if (L(s))
|
|
444
444
|
s.setOnChange(() => {
|
|
445
|
-
const
|
|
446
|
-
this.initialValues =
|
|
445
|
+
const o = this.getValues();
|
|
446
|
+
this.initialValues = o, t(o);
|
|
447
447
|
}), this.changeHandlers.add(() => t(this.getValues()));
|
|
448
448
|
else if (A(s)) {
|
|
449
|
-
const
|
|
450
|
-
this.changeHandlers.add(
|
|
449
|
+
const o = () => e();
|
|
450
|
+
this.changeHandlers.add(o), s.setOnChange(o);
|
|
451
451
|
} else {
|
|
452
|
-
const
|
|
453
|
-
this.changeHandlers.add(
|
|
452
|
+
const o = () => e();
|
|
453
|
+
this.changeHandlers.add(o), (n = s.setOnChange) == null || n.call(s, o);
|
|
454
454
|
}
|
|
455
455
|
}), this;
|
|
456
456
|
}
|
|
@@ -465,9 +465,9 @@ const Y = class Y {
|
|
|
465
465
|
Object.entries(t).forEach(([i, s]) => {
|
|
466
466
|
let n = this.settings[i];
|
|
467
467
|
if (!n && this.addItemCfg && i.startsWith(this.addItemCfg.keyPrefix)) {
|
|
468
|
-
const
|
|
469
|
-
if (Number.isFinite(
|
|
470
|
-
const l = this.addItemCfg.createItem(
|
|
468
|
+
const o = i.slice(this.addItemCfg.keyPrefix.length), a = Number(o);
|
|
469
|
+
if (Number.isFinite(a)) {
|
|
470
|
+
const l = this.addItemCfg.createItem(a);
|
|
471
471
|
lt(l) && (this.addSetting(i, l), n = l);
|
|
472
472
|
}
|
|
473
473
|
}
|
|
@@ -490,20 +490,20 @@ const Y = class Y {
|
|
|
490
490
|
addSetting(t, e) {
|
|
491
491
|
var s, n;
|
|
492
492
|
if (this.settings[t] = e, this.wireChild(e), this.elementRef) {
|
|
493
|
-
const
|
|
493
|
+
const o = this.elementRef.querySelector(
|
|
494
494
|
".setting-group-content"
|
|
495
495
|
);
|
|
496
|
-
if (
|
|
496
|
+
if (o) {
|
|
497
497
|
L(e) && typeof e.setNestingLevel == "function" && e.setNestingLevel(this.nestingLevel + 1);
|
|
498
|
-
const
|
|
498
|
+
const a = e.draw(), l = this.deleteItemCfg ?? this.addItemCfg;
|
|
499
499
|
if (l) {
|
|
500
|
-
const
|
|
501
|
-
|
|
500
|
+
const d = l.keyPrefix ?? ((s = this.addItemCfg) == null ? void 0 : s.keyPrefix);
|
|
501
|
+
d && t.startsWith(d) && this.addDeleteButtonToElement(a, t);
|
|
502
502
|
}
|
|
503
|
-
const r =
|
|
504
|
-
r ?
|
|
505
|
-
const
|
|
506
|
-
|
|
503
|
+
const r = o.querySelector(".sg-add-button-bottom");
|
|
504
|
+
r ? o.insertBefore(a, r) : o.appendChild(a), at.trackElement(a), _(a, this.nestingLevel + 1), tt(a, this.nestingLevel + 1);
|
|
505
|
+
const h = a.style.display;
|
|
506
|
+
a.style.display = "none", a.offsetHeight, a.style.display = h, this.updateNestingStyles();
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
const i = this.getValues();
|
|
@@ -520,9 +520,9 @@ const Y = class Y {
|
|
|
520
520
|
const r = Array.from(
|
|
521
521
|
t.querySelectorAll(".setting-group-title")
|
|
522
522
|
);
|
|
523
|
-
for (const
|
|
524
|
-
if (
|
|
525
|
-
s =
|
|
523
|
+
for (const h of r)
|
|
524
|
+
if (h.closest(".setting-group") === t) {
|
|
525
|
+
s = h;
|
|
526
526
|
break;
|
|
527
527
|
}
|
|
528
528
|
s || (s = r[0] ?? null);
|
|
@@ -530,8 +530,8 @@ const Y = class Y {
|
|
|
530
530
|
if (!s) return;
|
|
531
531
|
const n = s.querySelector(".actions-section");
|
|
532
532
|
if (!n) return;
|
|
533
|
-
const
|
|
534
|
-
|
|
533
|
+
const o = document.createElement("button");
|
|
534
|
+
o.type = "button", o.className = "sg-delete-button", i ? i.deleteItemCfg : this.deleteItemCfg ?? this.addItemCfg, o.title = "Delete", o.style.cssText = `
|
|
535
535
|
background: none;
|
|
536
536
|
border: none;
|
|
537
537
|
cursor: pointer;
|
|
@@ -544,23 +544,23 @@ const Y = class Y {
|
|
|
544
544
|
border-radius: 4px;
|
|
545
545
|
transition: background-color 0.2s;
|
|
546
546
|
`;
|
|
547
|
-
const
|
|
547
|
+
const a = `
|
|
548
548
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
549
549
|
<path d="M2 4h12M5.333 4V2.667a1.333 1.333 0 0 1 1.334-1.334h2.666a1.333 1.333 0 0 1 1.334 1.334V4m2 0v9.333a1.333 1.333 0 0 1-1.334 1.334H4.667a1.333 1.333 0 0 1-1.334-1.334V4h8.667Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
550
550
|
<path d="M6.667 7.333v4M9.333 7.333v4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
551
551
|
</svg>
|
|
552
552
|
`;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}),
|
|
556
|
-
|
|
557
|
-
}),
|
|
558
|
-
r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((
|
|
559
|
-
|
|
553
|
+
o.innerHTML = a, o.addEventListener("mouseenter", () => {
|
|
554
|
+
o.style.backgroundColor = "#fef2f2";
|
|
555
|
+
}), o.addEventListener("mouseleave", () => {
|
|
556
|
+
o.style.backgroundColor = "transparent";
|
|
557
|
+
}), o.addEventListener("click", (r) => {
|
|
558
|
+
r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((h) => {
|
|
559
|
+
h && (i && i.deleteItemCfg ? this.removeSetting(e) : this.removeSetting(e));
|
|
560
560
|
});
|
|
561
561
|
});
|
|
562
562
|
const l = n.querySelector(".setting-group-arrow");
|
|
563
|
-
l ? n.insertBefore(
|
|
563
|
+
l ? n.insertBefore(o, l) : n.appendChild(o);
|
|
564
564
|
}
|
|
565
565
|
showDeleteConfirmation() {
|
|
566
566
|
return new Promise((t) => {
|
|
@@ -603,14 +603,14 @@ const Y = class Y {
|
|
|
603
603
|
font-size: 14px;
|
|
604
604
|
line-height: 1.5;
|
|
605
605
|
`;
|
|
606
|
-
const
|
|
607
|
-
|
|
606
|
+
const o = document.createElement("div");
|
|
607
|
+
o.style.cssText = `
|
|
608
608
|
display: flex;
|
|
609
609
|
gap: 12px;
|
|
610
610
|
justify-content: flex-end;
|
|
611
611
|
`;
|
|
612
|
-
const
|
|
613
|
-
|
|
612
|
+
const a = document.createElement("button");
|
|
613
|
+
a.textContent = "Cancel", a.type = "button", a.style.cssText = `
|
|
614
614
|
padding: 8px 16px;
|
|
615
615
|
border: 1px solid #d1d5db;
|
|
616
616
|
background: white;
|
|
@@ -632,10 +632,10 @@ const Y = class Y {
|
|
|
632
632
|
font-weight: 500;
|
|
633
633
|
cursor: pointer;
|
|
634
634
|
transition: all 0.2s;
|
|
635
|
-
`,
|
|
636
|
-
|
|
637
|
-
}),
|
|
638
|
-
|
|
635
|
+
`, a.addEventListener("mouseenter", () => {
|
|
636
|
+
a.style.backgroundColor = "#f9fafb", a.style.borderColor = "#9ca3af";
|
|
637
|
+
}), a.addEventListener("mouseleave", () => {
|
|
638
|
+
a.style.backgroundColor = "white", a.style.borderColor = "#d1d5db";
|
|
639
639
|
}), l.addEventListener("mouseenter", () => {
|
|
640
640
|
l.style.backgroundColor = "#dc2626";
|
|
641
641
|
}), l.addEventListener("mouseleave", () => {
|
|
@@ -646,17 +646,17 @@ const Y = class Y {
|
|
|
646
646
|
e.parentNode && e.parentNode.removeChild(e);
|
|
647
647
|
}, 200);
|
|
648
648
|
};
|
|
649
|
-
|
|
649
|
+
a.addEventListener("click", () => {
|
|
650
650
|
r(), t(!1);
|
|
651
651
|
}), l.addEventListener("click", () => {
|
|
652
652
|
r(), t(!0);
|
|
653
|
-
}), e.addEventListener("click", (
|
|
654
|
-
|
|
653
|
+
}), e.addEventListener("click", (d) => {
|
|
654
|
+
d.target === e && (r(), t(!1));
|
|
655
655
|
});
|
|
656
|
-
const
|
|
657
|
-
|
|
656
|
+
const h = (d) => {
|
|
657
|
+
d.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", h));
|
|
658
658
|
};
|
|
659
|
-
document.addEventListener("keydown",
|
|
659
|
+
document.addEventListener("keydown", h), o.appendChild(a), o.appendChild(l), i.appendChild(s), i.appendChild(n), i.appendChild(o), e.appendChild(i), document.body.appendChild(e), requestAnimationFrame(() => {
|
|
660
660
|
e.style.opacity = "1", i.style.transform = "scale(1)";
|
|
661
661
|
}), setTimeout(() => l.focus(), 100);
|
|
662
662
|
});
|
|
@@ -674,8 +674,8 @@ const Y = class Y {
|
|
|
674
674
|
...Object.keys(t),
|
|
675
675
|
...Object.keys(e)
|
|
676
676
|
])).forEach((n) => {
|
|
677
|
-
const
|
|
678
|
-
JSON.stringify(
|
|
677
|
+
const o = t[n], a = e[n];
|
|
678
|
+
JSON.stringify(o) !== JSON.stringify(a) && (i[n] = { from: o, to: a });
|
|
679
679
|
}), i;
|
|
680
680
|
}
|
|
681
681
|
getValues(t) {
|
|
@@ -709,11 +709,11 @@ const Y = class Y {
|
|
|
709
709
|
if (Object.prototype.hasOwnProperty.call(this.settings, s)) {
|
|
710
710
|
const n = this.settings[s];
|
|
711
711
|
if (L(n)) {
|
|
712
|
-
const
|
|
713
|
-
|
|
712
|
+
const o = n.getValuesForJson();
|
|
713
|
+
o !== null && (i[s] = o);
|
|
714
714
|
} else {
|
|
715
|
-
const
|
|
716
|
-
|
|
715
|
+
const o = n;
|
|
716
|
+
o.includeGetJson !== !1 && (i[s] = o.value);
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
return (this.hide === !0 || ((e = this == null ? void 0 : this.groupProps) == null ? void 0 : e.hide) === !0) && (i.hide = !0), i;
|
|
@@ -764,57 +764,57 @@ const Y = class Y {
|
|
|
764
764
|
s.textContent = this.title, i.appendChild(s);
|
|
765
765
|
const n = document.createElement("div");
|
|
766
766
|
n.className = "actions-section";
|
|
767
|
-
const
|
|
768
|
-
|
|
767
|
+
const o = document.createElement("span");
|
|
768
|
+
o.className = "setting-group-arrow", o.innerHTML = `
|
|
769
769
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
770
770
|
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
771
771
|
</svg>
|
|
772
|
-
`, this.isCollapsed &&
|
|
773
|
-
const
|
|
774
|
-
|
|
772
|
+
`, this.isCollapsed && o.classList.add("rotated"), n.appendChild(o);
|
|
773
|
+
const a = document.createElement("div");
|
|
774
|
+
a.className = "setting-group-content", this.isCollapsed && (a.classList.add("collapsed"), e.classList.add("collapsed-view"), o.classList.add("rotated"), t.classList.add("collapsed")), this.isMain && a.classList.add("main-content");
|
|
775
775
|
const l = () => {
|
|
776
|
-
this.isCollapsed = !this.isCollapsed,
|
|
776
|
+
this.isCollapsed = !this.isCollapsed, a.classList.toggle("collapsed"), e.classList.toggle("collapsed-view"), o.classList.toggle("rotated"), t.classList.toggle("collapsed", this.isCollapsed), e.setAttribute(
|
|
777
777
|
"aria-expanded",
|
|
778
778
|
(!this.isCollapsed).toString()
|
|
779
779
|
);
|
|
780
780
|
};
|
|
781
|
-
if (e.onclick = l, e.onkeydown = (
|
|
782
|
-
(
|
|
781
|
+
if (e.onclick = l, e.onkeydown = (h) => {
|
|
782
|
+
(h.key === "Enter" || h.key === " ") && (h.preventDefault(), l());
|
|
783
783
|
}, Object.keys(this.settings).length > 0) {
|
|
784
|
-
for (const
|
|
785
|
-
if (Object.prototype.hasOwnProperty.call(this.settings,
|
|
786
|
-
const
|
|
787
|
-
L(
|
|
788
|
-
const
|
|
789
|
-
L(
|
|
790
|
-
d,
|
|
784
|
+
for (const h in this.settings)
|
|
785
|
+
if (Object.prototype.hasOwnProperty.call(this.settings, h)) {
|
|
786
|
+
const d = this.settings[h];
|
|
787
|
+
L(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.nestingLevel + 1);
|
|
788
|
+
const p = d.draw();
|
|
789
|
+
L(d) && d.deleteItemCfg && this.addDeleteButtonToElement(
|
|
791
790
|
p,
|
|
792
|
-
h
|
|
793
|
-
|
|
791
|
+
h,
|
|
792
|
+
d
|
|
793
|
+
), a.appendChild(p);
|
|
794
794
|
}
|
|
795
795
|
} else {
|
|
796
|
-
const
|
|
797
|
-
|
|
796
|
+
const h = document.createElement("div");
|
|
797
|
+
h.className = "setting-group-empty", h.textContent = "No settings in this group", a.appendChild(h);
|
|
798
798
|
}
|
|
799
799
|
if (this.addItemCfg) {
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
const
|
|
800
|
+
const h = document.createElement("button");
|
|
801
|
+
h.type = "button", h.className = "sg-add-button-bottom", h.style.marginTop = "8px";
|
|
802
|
+
const d = `
|
|
803
803
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
|
|
804
804
|
xmlns="http://www.w3.org/2000/svg">
|
|
805
805
|
<path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
|
|
806
806
|
stroke-width="1.5" stroke-linecap="round"/>
|
|
807
807
|
</svg>`;
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
const g = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),
|
|
811
|
-
if (lt(
|
|
808
|
+
h.innerHTML = `${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, h.addEventListener("click", (p) => {
|
|
809
|
+
p.stopPropagation(), p.preventDefault();
|
|
810
|
+
const g = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), v = this.addItemCfg.createItem(g);
|
|
811
|
+
if (lt(v)) {
|
|
812
812
|
const m = `${this.addItemCfg.keyPrefix}${g}`;
|
|
813
|
-
this.addSetting(m,
|
|
813
|
+
this.addSetting(m, v);
|
|
814
814
|
}
|
|
815
|
-
}),
|
|
815
|
+
}), a.appendChild(h);
|
|
816
816
|
}
|
|
817
|
-
return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(
|
|
817
|
+
return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(a), this.elementRef = t, at.trackElement(t), setTimeout(() => {
|
|
818
818
|
this.updateNestingStyles();
|
|
819
819
|
}, 0), this.pendingBlurHandler && (this.pendingBlurHandler = null), t;
|
|
820
820
|
}
|
|
@@ -845,10 +845,10 @@ const Y = class Y {
|
|
|
845
845
|
let i = e;
|
|
846
846
|
const s = Object.keys(this.settings), n = Object.keys(e);
|
|
847
847
|
if (!s.some(
|
|
848
|
-
(
|
|
848
|
+
(a) => n.includes(a)
|
|
849
849
|
) && n.length === 1) {
|
|
850
|
-
const
|
|
851
|
-
i = e[
|
|
850
|
+
const a = n[0];
|
|
851
|
+
i = e[a];
|
|
852
852
|
}
|
|
853
853
|
this.setValue(i);
|
|
854
854
|
} catch (e) {
|
|
@@ -905,19 +905,19 @@ class Lt extends T {
|
|
|
905
905
|
s.textContent = this.title, i.appendChild(s);
|
|
906
906
|
const n = document.createElement("div");
|
|
907
907
|
n.className = "tabs-header", this.tabsContainer = n;
|
|
908
|
-
const
|
|
909
|
-
if (
|
|
908
|
+
const o = document.createElement("div");
|
|
909
|
+
if (o.className = "tab-content", this.contentContainers = {}, Object.keys(this.settings).forEach((a, l) => {
|
|
910
910
|
const r = document.createElement("button");
|
|
911
|
-
r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id",
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
)),
|
|
918
|
-
}), e.appendChild(i), e.appendChild(n), e.appendChild(
|
|
919
|
-
const
|
|
920
|
-
this.activeTabId =
|
|
911
|
+
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);
|
|
912
|
+
const h = document.createElement("div");
|
|
913
|
+
h.className = "tab-panel", this.contentContainers[a] = h;
|
|
914
|
+
const d = this.settings[a];
|
|
915
|
+
d && (L(d) && typeof d.setNestingLevel == "function" && d.setNestingLevel(this.getNestingLevel() + 1), h.appendChild(
|
|
916
|
+
d.draw()
|
|
917
|
+
)), o.appendChild(h), l === 0 && !this.activeTabId && (this.activeTabId = a);
|
|
918
|
+
}), e.appendChild(i), e.appendChild(n), e.appendChild(o), !this.activeTabId) {
|
|
919
|
+
const a = Object.keys(this.settings)[0];
|
|
920
|
+
this.activeTabId = a || "";
|
|
921
921
|
}
|
|
922
922
|
return this.updateTabUI(), t;
|
|
923
923
|
}
|
|
@@ -965,14 +965,14 @@ class V extends Mt {
|
|
|
965
965
|
return t = t.replace("#", ""), t.length === 3 && (t = t.split("").map((e) => e + e).join("")), t.length !== 6 ? (console.warn(`Invalid hex value "${t}", using default "#000000"`), "#000000") : /^[0-9A-Fa-f]{6}$/.test(t) ? `#${t.toLowerCase()}` : (console.warn(`Invalid hex value "${t}", using default "#000000"`), "#000000");
|
|
966
966
|
}
|
|
967
967
|
static rgbToHexStatic(t) {
|
|
968
|
-
const e = t.split(",").map((
|
|
968
|
+
const e = t.split(",").map((h) => parseInt(h.trim()));
|
|
969
969
|
if (e.length !== 3 || e.some(isNaN))
|
|
970
970
|
return console.warn(`Invalid RGB value "${t}", using default "#000000"`), "#000000";
|
|
971
|
-
const [i, s, n] = e,
|
|
972
|
-
const
|
|
973
|
-
return
|
|
971
|
+
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 = (h) => {
|
|
972
|
+
const d = h.toString(16);
|
|
973
|
+
return d.length === 1 ? "0" + d : d;
|
|
974
974
|
};
|
|
975
|
-
return `#${r(
|
|
975
|
+
return `#${r(o)}${r(a)}${r(l)}`;
|
|
976
976
|
}
|
|
977
977
|
setValue(t) {
|
|
978
978
|
if (t === void 0) {
|
|
@@ -1012,90 +1012,90 @@ class V extends Mt {
|
|
|
1012
1012
|
s.className = "color-tab active", s.textContent = "Solid";
|
|
1013
1013
|
const n = document.createElement("button");
|
|
1014
1014
|
n.className = "color-tab", n.textContent = "Global", i.appendChild(s), i.appendChild(n);
|
|
1015
|
-
const a = document.createElement("div");
|
|
1016
|
-
a.className = "color-content-solid";
|
|
1017
1015
|
const o = document.createElement("div");
|
|
1018
|
-
o.className = "color-content-
|
|
1016
|
+
o.className = "color-content-solid";
|
|
1017
|
+
const a = document.createElement("div");
|
|
1018
|
+
a.className = "color-content-global", a.style.display = "none", a.style.display = "grid", a.style.gridTemplateColumns = "repeat(auto-fill, minmax(30px, 1fr))", a.style.gap = "8px";
|
|
1019
1019
|
const l = () => {
|
|
1020
1020
|
try {
|
|
1021
|
-
if (console.log("ColorSetting: renderGlobalOptions called"),
|
|
1021
|
+
if (console.log("ColorSetting: renderGlobalOptions called"), a.innerHTML = "", !x) {
|
|
1022
1022
|
console.error("ColorSetting: Setting class is undefined");
|
|
1023
1023
|
const u = document.createElement("div");
|
|
1024
|
-
u.textContent = "Error: System error (Setting undefined)",
|
|
1024
|
+
u.textContent = "Error: System error (Setting undefined)", a.appendChild(u);
|
|
1025
1025
|
return;
|
|
1026
1026
|
}
|
|
1027
1027
|
const m = x.GlobalVariables || {};
|
|
1028
1028
|
if (console.log("ColorSetting: GlobalVariables:", m), !m || Object.keys(m).length === 0) {
|
|
1029
1029
|
const u = document.createElement("div");
|
|
1030
|
-
u.textContent = "No global colors defined", u.style.gridColumn = "1 / -1", u.style.fontSize = "12px", u.style.color = "#666",
|
|
1030
|
+
u.textContent = "No global colors defined", u.style.gridColumn = "1 / -1", u.style.fontSize = "12px", u.style.color = "#666", a.appendChild(u);
|
|
1031
1031
|
return;
|
|
1032
1032
|
}
|
|
1033
1033
|
Object.entries(m).forEach(([u, f]) => {
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1034
|
+
const C = document.createElement("button");
|
|
1035
|
+
C.className = "global-color-btn", C.title = u, C.style.width = "30px", C.style.height = "30px", C.style.borderRadius = "50%", C.style.border = "1px solid #ddd", C.style.backgroundColor = f, C.style.cursor = "pointer", this.value === `var(--${u})` && (C.style.border = "2px solid #2196f3"), C.addEventListener("click", (y) => {
|
|
1036
1036
|
var k, S;
|
|
1037
1037
|
y.preventDefault();
|
|
1038
1038
|
const w = `var(--${u})`;
|
|
1039
|
-
this.value = w, (k = this.onChange) == null || k.call(this, w), (S = this.detectChange) == null || S.call(this, w), Array.from(
|
|
1039
|
+
this.value = w, (k = this.onChange) == null || k.call(this, w), (S = this.detectChange) == null || S.call(this, w), Array.from(a.children).forEach((b) => {
|
|
1040
1040
|
b.style.border = "1px solid #ddd";
|
|
1041
|
-
}),
|
|
1042
|
-
}),
|
|
1041
|
+
}), C.style.border = "2px solid #2196f3", d.style.backgroundColor = f;
|
|
1042
|
+
}), a.appendChild(C);
|
|
1043
1043
|
});
|
|
1044
1044
|
} catch (m) {
|
|
1045
|
-
console.error("ColorSetting: Error in renderGlobalOptions", m),
|
|
1045
|
+
console.error("ColorSetting: Error in renderGlobalOptions", m), a.innerHTML = "Error loading global options";
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|
|
1048
1048
|
l(), s.addEventListener("click", (m) => {
|
|
1049
|
-
m.preventDefault(), s.classList.add("active"), n.classList.remove("active"),
|
|
1049
|
+
m.preventDefault(), s.classList.add("active"), n.classList.remove("active"), o.style.display = "flex", a.style.display = "none", this.value && this.value.startsWith("var(--");
|
|
1050
1050
|
}), n.addEventListener("click", (m) => {
|
|
1051
|
-
m.preventDefault(), n.classList.add("active"), s.classList.remove("active"),
|
|
1051
|
+
m.preventDefault(), n.classList.add("active"), s.classList.remove("active"), o.style.display = "none", a.style.display = "grid", l();
|
|
1052
1052
|
}), this.value && this.value.startsWith("var(--") ? n.click() : s.click();
|
|
1053
1053
|
const r = (m) => {
|
|
1054
1054
|
const u = m.value.trim();
|
|
1055
1055
|
if (!u)
|
|
1056
1056
|
return e.classList.remove("error"), !0;
|
|
1057
|
-
const
|
|
1058
|
-
return
|
|
1059
|
-
},
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
let
|
|
1064
|
-
if (
|
|
1065
|
-
const m =
|
|
1066
|
-
|
|
1057
|
+
const C = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(u);
|
|
1058
|
+
return C ? e.classList.remove("error") : e.classList.add("error"), C;
|
|
1059
|
+
}, h = document.createElement("input");
|
|
1060
|
+
h.type = "color", h.className = "color-picker", h.value = this.value && !this.value.startsWith("var(--") ? this.value : "#000000", h.setAttribute("aria-label", "Choose color"), h.setAttribute("title", "Click to open color picker"), this.getDataPropsPath() && h.setAttribute("data-test-id", this.getDataPropsPath()), this.colorInputEl = h;
|
|
1061
|
+
const d = document.createElement("div");
|
|
1062
|
+
d.className = "color-preview";
|
|
1063
|
+
let p = this.value || "#000000";
|
|
1064
|
+
if (p.startsWith("var(--")) {
|
|
1065
|
+
const m = p.replace("var(--", "").replace(")", "");
|
|
1066
|
+
p = (x.GlobalVariables || {})[m] || "#000000";
|
|
1067
1067
|
}
|
|
1068
|
-
|
|
1068
|
+
d.style.backgroundColor = p;
|
|
1069
1069
|
const g = document.createElement("input");
|
|
1070
1070
|
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;
|
|
1071
|
-
const
|
|
1072
|
-
var f,
|
|
1071
|
+
const v = (m) => {
|
|
1072
|
+
var f, C;
|
|
1073
1073
|
let u = m.trim();
|
|
1074
1074
|
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)) {
|
|
1075
1075
|
const y = V.normalizeColorValue(u);
|
|
1076
|
-
this.value = y, (f = this.onChange) == null || f.call(this, y), (
|
|
1076
|
+
this.value = y, (f = this.onChange) == null || f.call(this, y), (C = this.detectChange) == null || C.call(this, y), this.colorInputEl && (this.colorInputEl.value = y), d.style.backgroundColor = y;
|
|
1077
1077
|
}
|
|
1078
1078
|
};
|
|
1079
1079
|
return this.textInputEl.addEventListener("input", (m) => {
|
|
1080
1080
|
const u = m.target.value;
|
|
1081
|
-
|
|
1081
|
+
v(u);
|
|
1082
1082
|
}), this.textInputEl.addEventListener("paste", (m) => {
|
|
1083
1083
|
var f;
|
|
1084
1084
|
m.preventDefault();
|
|
1085
1085
|
const u = ((f = m.clipboardData) == null ? void 0 : f.getData("text")) || "";
|
|
1086
|
-
this.textInputEl && (this.textInputEl.value = u.trim(),
|
|
1086
|
+
this.textInputEl && (this.textInputEl.value = u.trim(), v(u));
|
|
1087
1087
|
}), this.textInputEl.addEventListener("keydown", (m) => {
|
|
1088
|
-
var u, f,
|
|
1089
|
-
m.key === "Enter" && (m.preventDefault(),
|
|
1088
|
+
var u, f, C;
|
|
1089
|
+
m.key === "Enter" && (m.preventDefault(), v(((u = this.textInputEl) == null ? void 0 : u.value) || ""), (f = this.textInputEl) == null || f.blur()), m.key === "Escape" && (this.textInputEl && this.value && (this.textInputEl.value = this.value), (C = this.textInputEl) == null || C.blur(), e.classList.remove("error"));
|
|
1090
1090
|
}), this.colorInputEl.addEventListener("input", (m) => {
|
|
1091
|
-
var
|
|
1091
|
+
var C, y;
|
|
1092
1092
|
const u = m.target.value, f = V.normalizeColorValue(u);
|
|
1093
|
-
this.value = f, (
|
|
1093
|
+
this.value = f, (C = this.onChange) == null || C.call(this, f), (y = this.detectChange) == null || y.call(this, f), this.textInputEl && (this.textInputEl.value = f), d.style.backgroundColor = f, e.classList.remove("error");
|
|
1094
1094
|
}), this.colorInputEl.addEventListener("change", (m) => {
|
|
1095
|
-
var
|
|
1095
|
+
var C, y;
|
|
1096
1096
|
const u = m.target.value, f = V.normalizeColorValue(u);
|
|
1097
|
-
this.value = f, (
|
|
1098
|
-
}),
|
|
1097
|
+
this.value = f, (C = this.onChange) == null || C.call(this, f), (y = this.detectChange) == null || y.call(this, f), this.textInputEl && (this.textInputEl.value = f), d.style.backgroundColor = f;
|
|
1098
|
+
}), o.appendChild(h), o.appendChild(d), o.appendChild(g), e.appendChild(i), e.appendChild(o), e.appendChild(a), t.appendChild(e), this.element = t, t;
|
|
1099
1099
|
}
|
|
1100
1100
|
getElement() {
|
|
1101
1101
|
return this.element;
|
|
@@ -1151,8 +1151,8 @@ class F extends x {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
updateColorPreview() {
|
|
1153
1153
|
if (!this.colorPreviewEl || !this.value) return;
|
|
1154
|
-
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16),
|
|
1155
|
-
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${
|
|
1154
|
+
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16), o = parseInt(i.substring(4, 6), 16);
|
|
1155
|
+
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
1156
1156
|
}
|
|
1157
1157
|
handleColorChange(t) {
|
|
1158
1158
|
const e = this.getOpacityPercent(), i = F.combineColorOpacity(
|
|
@@ -1175,16 +1175,16 @@ class F extends x {
|
|
|
1175
1175
|
draw() {
|
|
1176
1176
|
const t = document.createElement("div");
|
|
1177
1177
|
if (t.className = "color-with-opacity-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
1178
|
-
const
|
|
1179
|
-
if (
|
|
1178
|
+
const a = document.createElement("div");
|
|
1179
|
+
if (a.className = "icon-container", this.props.icon) {
|
|
1180
1180
|
const l = document.createElement("span");
|
|
1181
|
-
l.className = "input-icon", l.innerHTML = this.props.icon,
|
|
1181
|
+
l.className = "input-icon", l.innerHTML = this.props.icon, a.appendChild(l);
|
|
1182
1182
|
}
|
|
1183
1183
|
if (this.props.title) {
|
|
1184
1184
|
const l = document.createElement("span");
|
|
1185
|
-
l.className = "input-label", l.textContent = this.props.title,
|
|
1185
|
+
l.className = "input-label", l.textContent = this.props.title, a.appendChild(l);
|
|
1186
1186
|
}
|
|
1187
|
-
t.appendChild(
|
|
1187
|
+
t.appendChild(a);
|
|
1188
1188
|
}
|
|
1189
1189
|
const e = document.createElement("div");
|
|
1190
1190
|
e.className = "color-with-opacity-input-wrapper", this.colorInputEl = document.createElement("input"), this.colorInputEl.type = "color", this.colorInputEl.className = "color-with-opacity-picker", this.getDataPropsPath() && this.colorInputEl.setAttribute(
|
|
@@ -1194,32 +1194,32 @@ class F extends x {
|
|
|
1194
1194
|
"data-test-id",
|
|
1195
1195
|
`${this.getDataPropsPath()}_text`
|
|
1196
1196
|
), this.updateInputElements(), this.updateColorPreview();
|
|
1197
|
-
const i = (
|
|
1198
|
-
let l =
|
|
1197
|
+
const i = (a) => {
|
|
1198
|
+
let l = a.trim();
|
|
1199
1199
|
l && !l.startsWith("#") && /^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(l) && (l = "#" + l, this.textInputEl && (this.textInputEl.value = l));
|
|
1200
1200
|
const r = this.handleTextInput(l);
|
|
1201
1201
|
return r ? (this.colorInputEl && (this.colorInputEl.value = this.getRgbColor()), this.updateColorPreview(), e.classList.remove("error")) : l === "" ? e.classList.remove("error") : e.classList.add("error"), r;
|
|
1202
1202
|
};
|
|
1203
|
-
this.colorInputEl.addEventListener("input", (
|
|
1204
|
-
const l =
|
|
1203
|
+
this.colorInputEl.addEventListener("input", (a) => {
|
|
1204
|
+
const l = a.target;
|
|
1205
1205
|
this.handleColorChange(l.value), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview();
|
|
1206
|
-
}), this.textInputEl.addEventListener("input", (
|
|
1207
|
-
const l =
|
|
1206
|
+
}), this.textInputEl.addEventListener("input", (a) => {
|
|
1207
|
+
const l = a.target;
|
|
1208
1208
|
i(l.value);
|
|
1209
|
-
}), this.textInputEl.addEventListener("paste", (
|
|
1209
|
+
}), this.textInputEl.addEventListener("paste", (a) => {
|
|
1210
1210
|
var r;
|
|
1211
|
-
|
|
1212
|
-
const l = ((r =
|
|
1211
|
+
a.preventDefault();
|
|
1212
|
+
const l = ((r = a.clipboardData) == null ? void 0 : r.getData("text")) || "";
|
|
1213
1213
|
this.textInputEl && (this.textInputEl.value = l.trim(), i(l));
|
|
1214
|
-
}), this.textInputEl.addEventListener("keydown", (
|
|
1215
|
-
var l, r,
|
|
1216
|
-
|
|
1217
|
-
}), this.textInputEl.addEventListener("blur", (
|
|
1218
|
-
const l =
|
|
1214
|
+
}), this.textInputEl.addEventListener("keydown", (a) => {
|
|
1215
|
+
var l, r, h;
|
|
1216
|
+
a.key === "Enter" && (a.preventDefault(), i(((l = this.textInputEl) == null ? void 0 : l.value) || ""), (r = this.textInputEl) == null || r.blur()), a.key === "Escape" && (this.textInputEl && this.value && (this.textInputEl.value = this.value), (h = this.textInputEl) == null || h.blur(), e.classList.remove("error"));
|
|
1217
|
+
}), this.textInputEl.addEventListener("blur", (a) => {
|
|
1218
|
+
const l = a.target;
|
|
1219
1219
|
l.value.trim() === "" && (l.value = this.value || "#000000FF", e.classList.remove("error"));
|
|
1220
1220
|
}), this.colorPreviewEl.addEventListener("click", () => {
|
|
1221
|
-
var
|
|
1222
|
-
(
|
|
1221
|
+
var a;
|
|
1222
|
+
(a = this.colorInputEl) == null || a.click();
|
|
1223
1223
|
}), e.appendChild(this.colorInputEl), e.appendChild(this.colorPreviewEl), e.appendChild(this.textInputEl);
|
|
1224
1224
|
const s = document.createElement("div");
|
|
1225
1225
|
s.className = "color-with-opacity-opacity-wrapper", this.opacityInputEl = document.createElement("input"), this.opacityInputEl.type = "number", this.opacityInputEl.className = "color-with-opacity-opacity-input", this.opacityInputEl.value = this.getOpacityPercent().toString(), this.opacityInputEl.min = "0", this.opacityInputEl.max = "100", this.opacityInputEl.step = "1", this.opacityInputEl.placeholder = "100", this.getDataPropsPath() && this.opacityInputEl.setAttribute(
|
|
@@ -1227,16 +1227,16 @@ class F extends x {
|
|
|
1227
1227
|
`${this.getDataPropsPath()}_opacity`
|
|
1228
1228
|
);
|
|
1229
1229
|
const n = document.createElement("span");
|
|
1230
|
-
n.className = "color-with-opacity-opacity-suffix", n.textContent = "%", this.opacityInputEl.addEventListener("input", (
|
|
1231
|
-
const l =
|
|
1230
|
+
n.className = "color-with-opacity-opacity-suffix", n.textContent = "%", this.opacityInputEl.addEventListener("input", (a) => {
|
|
1231
|
+
const l = a.target, r = parseFloat(l.value);
|
|
1232
1232
|
isNaN(r) || (this.handleOpacityChange(r), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview());
|
|
1233
|
-
}), this.opacityInputEl.addEventListener("blur", (
|
|
1234
|
-
const l =
|
|
1233
|
+
}), this.opacityInputEl.addEventListener("blur", (a) => {
|
|
1234
|
+
const l = a.target;
|
|
1235
1235
|
let r = parseFloat(l.value);
|
|
1236
1236
|
isNaN(r) && (r = this.getOpacityPercent()), r = Math.max(0, Math.min(100, r)), l.value = r.toString(), this.handleOpacityChange(r), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview();
|
|
1237
1237
|
}), s.appendChild(this.opacityInputEl), s.appendChild(n);
|
|
1238
|
-
const
|
|
1239
|
-
return
|
|
1238
|
+
const o = document.createElement("div");
|
|
1239
|
+
return o.className = "color-with-opacity-controls-wrapper", o.appendChild(e), o.appendChild(s), t.appendChild(o), this.element = t, this.updateInputElements(), this.updateColorPreview(), t;
|
|
1240
1240
|
}
|
|
1241
1241
|
getElement() {
|
|
1242
1242
|
return this.element;
|
|
@@ -1246,8 +1246,8 @@ class F extends x {
|
|
|
1246
1246
|
}
|
|
1247
1247
|
getRgbaValue() {
|
|
1248
1248
|
if (!this.value) return "rgba(0, 0, 0, 1)";
|
|
1249
|
-
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16),
|
|
1250
|
-
return `rgba(${s}, ${n}, ${
|
|
1249
|
+
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16), o = parseInt(i.substring(4, 6), 16);
|
|
1250
|
+
return `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
1251
1251
|
}
|
|
1252
1252
|
getColorAndOpacity() {
|
|
1253
1253
|
return {
|
|
@@ -1268,20 +1268,20 @@ class ge extends x {
|
|
|
1268
1268
|
if (t.className = "html-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
1269
1269
|
const n = document.createElement("div");
|
|
1270
1270
|
if (n.className = "icon-container", this.props.icon) {
|
|
1271
|
-
const
|
|
1272
|
-
n.appendChild(
|
|
1271
|
+
const o = this.createIcon(this.props.icon);
|
|
1272
|
+
n.appendChild(o);
|
|
1273
1273
|
}
|
|
1274
1274
|
if (this.props.title) {
|
|
1275
|
-
const
|
|
1276
|
-
n.appendChild(
|
|
1275
|
+
const o = this.createLabel(this.props.title);
|
|
1276
|
+
n.appendChild(o);
|
|
1277
1277
|
}
|
|
1278
1278
|
t.appendChild(n);
|
|
1279
1279
|
}
|
|
1280
1280
|
const e = document.createElement("textarea");
|
|
1281
1281
|
this.textareaEl = e, e.value = this.value || "", e.placeholder = this.props.placeholder || "Paste your HTML here...", e.className = "html-setting-textarea " + (this.props.textareaClassName || ""), e.rows = this.props.rows || 6, this.getDataPropsPath() && e.setAttribute("data-test-id", this.getDataPropsPath()), this.props.maxLength !== void 0 && (e.maxLength = this.props.maxLength), this.props.className && e.classList.add(this.props.className);
|
|
1282
1282
|
const i = (n) => {
|
|
1283
|
-
const
|
|
1284
|
-
this.value =
|
|
1283
|
+
const a = n.target.value;
|
|
1284
|
+
this.value = a, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
|
|
1285
1285
|
}, s = (n) => {
|
|
1286
1286
|
this.onBlur && this.value !== void 0 && this.onBlur(this.value);
|
|
1287
1287
|
};
|
|
@@ -1311,12 +1311,12 @@ class P extends x {
|
|
|
1311
1311
|
const i = document.createElement("input");
|
|
1312
1312
|
if (i.type = "number", i.className = "number-setting-input " + (this.props.inputClassName || ""), i.value = String(this.value ?? ""), i.placeholder = this.props.placeholder || "", this.getDataPropsPath() && i.setAttribute("data-test-id", this.getDataPropsPath()), this.props.minValue !== void 0 && (i.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (i.max = String(this.props.maxValue)), this.props.step !== void 0 && (i.step = String(this.props.step)), i.addEventListener("input", () => {
|
|
1313
1313
|
const s = this.props.minValue ?? Number.MIN_SAFE_INTEGER, n = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
1314
|
-
let
|
|
1315
|
-
|
|
1314
|
+
let o = Number(i.value);
|
|
1315
|
+
o < s && (o = s), o > n && (o = n), String(o) !== i.value && (i.value = String(o)), this.setValue(o);
|
|
1316
1316
|
}), i.addEventListener("blur", () => {
|
|
1317
|
-
var n,
|
|
1317
|
+
var n, o;
|
|
1318
1318
|
const s = this.validateValue(Number(i.value));
|
|
1319
|
-
s !== Number(i.value) && (i.value = String(s), this.setValue(s)), (
|
|
1319
|
+
s !== Number(i.value) && (i.value = String(s), this.setValue(s)), (o = (n = this.props).onBlur) == null || o.call(n);
|
|
1320
1320
|
}), e.appendChild(i), this.props.suffix && this.props.suffix !== "none") {
|
|
1321
1321
|
const s = document.createElement("span");
|
|
1322
1322
|
s.className = "suffix-label", s.textContent = this.props.suffix, e.appendChild(s);
|
|
@@ -1399,12 +1399,12 @@ class et extends x {
|
|
|
1399
1399
|
if (t.classList.add("select-container"), this.container = t, this.props.icon || this.props.title) {
|
|
1400
1400
|
const n = document.createElement("div");
|
|
1401
1401
|
if (n.className = "icon-container", this.props.icon) {
|
|
1402
|
-
const
|
|
1403
|
-
n.appendChild(
|
|
1402
|
+
const o = this.createIcon(this.props.icon);
|
|
1403
|
+
n.appendChild(o);
|
|
1404
1404
|
}
|
|
1405
1405
|
if (this.props.title) {
|
|
1406
|
-
const
|
|
1407
|
-
n.appendChild(
|
|
1406
|
+
const o = this.createLabel(this.props.title);
|
|
1407
|
+
n.appendChild(o);
|
|
1408
1408
|
}
|
|
1409
1409
|
t.appendChild(n);
|
|
1410
1410
|
} else {
|
|
@@ -1413,13 +1413,13 @@ class et extends x {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
const e = document.createElement("div");
|
|
1415
1415
|
e.classList.add("select-button"), this.getDataPropsPath() && e.setAttribute("data-test-id", this.getDataPropsPath()), this.isLoading ? e.classList.add("loading") : e.textContent = this.selectedOptionIndex !== null ? this._options[this.selectedOptionIndex].name : this.props.placeholder || "Select an option", e.onclick = () => {
|
|
1416
|
-
var n,
|
|
1417
|
-
this.isLoading || (this.isOpen = !this.isOpen, this.isOpen ? this.checkDropdownPosition() : this.cleanupDropdownPosition(), (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1416
|
+
var n, o;
|
|
1417
|
+
this.isLoading || (this.isOpen = !this.isOpen, this.isOpen ? this.checkDropdownPosition() : this.cleanupDropdownPosition(), (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (o = this.svgContainer) == null || o.classList.toggle("open", this.isOpen));
|
|
1418
1418
|
}, t.appendChild(e), this.buttonEl = e;
|
|
1419
1419
|
const i = document.createElement("ul");
|
|
1420
|
-
i.classList.add("select-options"), this._options.forEach((n,
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1420
|
+
i.classList.add("select-options"), this._options.forEach((n, o) => {
|
|
1421
|
+
const a = this.createOption(n, o);
|
|
1422
|
+
a.onclick = (l) => this.selectOption(l, o, e), i.appendChild(a);
|
|
1423
1423
|
}), document.body.appendChild(i);
|
|
1424
1424
|
const s = document.createElement("div");
|
|
1425
1425
|
return s.classList.add("svg-container"), s.innerHTML = Tt, t.appendChild(s), this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
@@ -1427,8 +1427,8 @@ class et extends x {
|
|
|
1427
1427
|
}).catch((n) => {
|
|
1428
1428
|
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText("Failed to load options");
|
|
1429
1429
|
})), this.clickOutsideListener && document.removeEventListener("click", this.clickOutsideListener), this.clickOutsideListener = (n) => {
|
|
1430
|
-
var
|
|
1431
|
-
this.isOpen && !t.contains(n.target) && (this.isOpen = !1, (
|
|
1430
|
+
var o, a;
|
|
1431
|
+
this.isOpen && !t.contains(n.target) && (this.isOpen = !1, (o = this.optionsListEl) == null || o.classList.remove("open"), (a = this.svgContainer) == null || a.classList.remove("open"), this.cleanupDropdownPosition());
|
|
1432
1432
|
}, document.addEventListener("click", this.clickOutsideListener), this.resizeListener && window.removeEventListener("resize", this.resizeListener), this.resizeListener = () => {
|
|
1433
1433
|
this.isOpen && this.checkDropdownPosition();
|
|
1434
1434
|
}, window.addEventListener("resize", this.resizeListener), t;
|
|
@@ -1447,9 +1447,9 @@ class et extends x {
|
|
|
1447
1447
|
}
|
|
1448
1448
|
}
|
|
1449
1449
|
selectOption(t, e, i) {
|
|
1450
|
-
var n,
|
|
1450
|
+
var n, o;
|
|
1451
1451
|
const s = this._options[e];
|
|
1452
|
-
s && (this.setValue(s.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (n = this.optionsListEl) == null || n.classList.remove("open"), (
|
|
1452
|
+
s && (this.setValue(s.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (n = this.optionsListEl) == null || n.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.cleanupDropdownPosition(), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((l, r) => {
|
|
1453
1453
|
r === e ? l.classList.add("selected") : l.classList.remove("selected");
|
|
1454
1454
|
}));
|
|
1455
1455
|
}
|
|
@@ -1530,14 +1530,14 @@ class Pt extends x {
|
|
|
1530
1530
|
`
|
|
1531
1531
|
}
|
|
1532
1532
|
].forEach((n) => {
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1533
|
+
const o = document.createElement("button");
|
|
1534
|
+
o.className = "align-option-button", o.innerHTML = n.icon, this.getDataPropsPath() && o.setAttribute(
|
|
1535
1535
|
"data-test-id",
|
|
1536
1536
|
`${this.getDataPropsPath()}_${n.name}`
|
|
1537
|
-
), this.value === n.name &&
|
|
1538
|
-
var
|
|
1539
|
-
i.querySelectorAll(".align-option-button").forEach((l) => l.classList.remove("selected")),
|
|
1540
|
-
}), i.appendChild(
|
|
1537
|
+
), this.value === n.name && o.classList.add("selected"), o.addEventListener("click", () => {
|
|
1538
|
+
var a;
|
|
1539
|
+
i.querySelectorAll(".align-option-button").forEach((l) => l.classList.remove("selected")), o.classList.add("selected"), this.value = n.name, (a = this.onChange) == null || a.call(this, this.value);
|
|
1540
|
+
}), i.appendChild(o);
|
|
1541
1541
|
}), t.appendChild(i), t;
|
|
1542
1542
|
}
|
|
1543
1543
|
}
|
|
@@ -1555,19 +1555,19 @@ class me extends x {
|
|
|
1555
1555
|
/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i
|
|
1556
1556
|
);
|
|
1557
1557
|
if (n) {
|
|
1558
|
-
let
|
|
1559
|
-
|
|
1558
|
+
let a = +n[1], l = +n[2], r = +n[3], h = +n[4];
|
|
1559
|
+
h >= 1 ? (a = Math.round(a * 0.9), l = Math.round(l * 0.9), r = Math.round(r * 0.9)) : h = Math.min(1, h + 0.12), s = `rgba(${a},${l},${r},${h})`;
|
|
1560
1560
|
}
|
|
1561
1561
|
t.addEventListener("mouseenter", () => {
|
|
1562
1562
|
console.log("hoverBg", s), t.style.setProperty("background-color", s, "important");
|
|
1563
1563
|
}), t.addEventListener("mouseleave", () => {
|
|
1564
1564
|
t.style.setProperty("background-color", e, "important");
|
|
1565
1565
|
}), t.addEventListener("click", () => {
|
|
1566
|
-
var
|
|
1567
|
-
return (l = (
|
|
1566
|
+
var a, l;
|
|
1567
|
+
return (l = (a = this.props).onClick) == null ? void 0 : l.call(a);
|
|
1568
1568
|
});
|
|
1569
|
-
const
|
|
1570
|
-
return
|
|
1569
|
+
const o = document.createElement("div");
|
|
1570
|
+
return o.className = "button-setting-wrapper " + (this.props.wrapperClassName || ""), o.appendChild(t), o;
|
|
1571
1571
|
}
|
|
1572
1572
|
}
|
|
1573
1573
|
class fe extends x {
|
|
@@ -1660,8 +1660,8 @@ class fe extends x {
|
|
|
1660
1660
|
return n.className = "dimension-lock-icon", n.setAttribute("type", "button"), n.setAttribute("aria-pressed", String(this.locked)), n.setAttribute(
|
|
1661
1661
|
"aria-label",
|
|
1662
1662
|
this.locked ? "Unlock aspect ratio" : "Lock aspect ratio"
|
|
1663
|
-
), n.title = this.locked ? "Unlock aspect ratio" : "Lock aspect ratio", n.innerHTML = this.getLockSVG(this.locked), n.onclick = (
|
|
1664
|
-
|
|
1663
|
+
), n.title = this.locked ? "Unlock aspect ratio" : "Lock aspect ratio", n.innerHTML = this.getLockSVG(this.locked), n.onclick = (o) => {
|
|
1664
|
+
o.preventDefault(), this.toggleLock(n);
|
|
1665
1665
|
}, s.appendChild(n), t.appendChild(e), t.appendChild(s), t.appendChild(i), t;
|
|
1666
1666
|
}
|
|
1667
1667
|
isLocked() {
|
|
@@ -1778,11 +1778,11 @@ class nt extends x {
|
|
|
1778
1778
|
<span class="upload-label">Replace</span>
|
|
1779
1779
|
`);
|
|
1780
1780
|
const n = () => {
|
|
1781
|
-
this.hideLoading(), this.previewWrapper.classList.add("has-image"), this.previewEl.style.display = "block", this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error",
|
|
1782
|
-
},
|
|
1783
|
-
this.hideLoading(), this.showError("Failed to load image. Please try again."), this.previewWrapper.classList.remove("has-image"), this.previewEl.style.display = "none", this.previewWrapper.style.display = "none", s && s instanceof HTMLElement && (s.style.display = "block"), e && e.classList.add("no-image"), this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error",
|
|
1781
|
+
this.hideLoading(), this.previewWrapper.classList.add("has-image"), this.previewEl.style.display = "block", this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error", o);
|
|
1782
|
+
}, o = () => {
|
|
1783
|
+
this.hideLoading(), this.showError("Failed to load image. Please try again."), this.previewWrapper.classList.remove("has-image"), this.previewEl.style.display = "none", this.previewWrapper.style.display = "none", s && s instanceof HTMLElement && (s.style.display = "block"), e && e.classList.add("no-image"), this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error", o);
|
|
1784
1784
|
};
|
|
1785
|
-
this.previewEl.addEventListener("load", n), this.previewEl.addEventListener("error",
|
|
1785
|
+
this.previewEl.addEventListener("load", n), this.previewEl.addEventListener("error", o), this.previewEl.src = t;
|
|
1786
1786
|
} else
|
|
1787
1787
|
this.hideLoading(), this.previewWrapper.classList.remove("has-image"), this.previewEl.src = "", this.previewEl.style.display = "none", this.previewWrapper.style.display = "none", s && s instanceof HTMLElement && (s.style.display = "block"), e && e.classList.add("no-image"), i && (i.innerHTML = `
|
|
1788
1788
|
<span class="upload-icon">${Q}</span>
|
|
@@ -1793,24 +1793,24 @@ class nt extends x {
|
|
|
1793
1793
|
const t = document.createElement("div");
|
|
1794
1794
|
t.className = "upload-setting-wrapper", t.setAttribute("data-setting-id", this.id), t.addEventListener(
|
|
1795
1795
|
"focusout",
|
|
1796
|
-
(
|
|
1796
|
+
(a) => {
|
|
1797
1797
|
var l;
|
|
1798
|
-
|
|
1798
|
+
a.relatedTarget && t.contains(a.relatedTarget) || (l = this.onBlur) == null || l.call(this, this.value ?? "");
|
|
1799
1799
|
},
|
|
1800
1800
|
!0
|
|
1801
1801
|
);
|
|
1802
1802
|
const e = !!(this.props.title || this.props.icon);
|
|
1803
1803
|
if (e || t.classList.add("no-label"), e) {
|
|
1804
|
-
const
|
|
1805
|
-
if (
|
|
1804
|
+
const a = document.createElement("div");
|
|
1805
|
+
if (a.className = "icon-title-container", this.props.icon) {
|
|
1806
1806
|
const l = this.createIcon(this.props.icon);
|
|
1807
|
-
|
|
1807
|
+
a.appendChild(l);
|
|
1808
1808
|
}
|
|
1809
1809
|
if (this.props.title) {
|
|
1810
1810
|
const l = this.createLabel(this.props.title);
|
|
1811
|
-
|
|
1811
|
+
a.appendChild(l);
|
|
1812
1812
|
}
|
|
1813
|
-
t.appendChild(
|
|
1813
|
+
t.appendChild(a);
|
|
1814
1814
|
}
|
|
1815
1815
|
this.errorContainer = document.createElement("div"), this.errorContainer.className = "error-message", this.errorContainer.style.display = "none", t.appendChild(this.errorContainer);
|
|
1816
1816
|
const i = document.createElement("div");
|
|
@@ -1819,18 +1819,18 @@ class nt extends x {
|
|
|
1819
1819
|
s || i.classList.add("no-image");
|
|
1820
1820
|
const n = document.createElement("div");
|
|
1821
1821
|
if (n.className = "preview-placeholder", n.innerHTML = Ht, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.loadingSpinner = document.createElement("div"), this.loadingSpinner.className = "loading-spinner", this.loadingSpinner.innerHTML = At, this.loadingSpinner.style.display = "none", this.previewWrapper.appendChild(this.loadingSpinner), this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
|
|
1822
|
-
const
|
|
1823
|
-
|
|
1822
|
+
const a = document.createElement("button");
|
|
1823
|
+
a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML = Bt, this.previewWrapper.appendChild(a), a.onclick = (l) => {
|
|
1824
1824
|
var r;
|
|
1825
1825
|
l.stopPropagation(), this.value = "", this.updatePreviewState(null), (r = this.onChange) == null || r.call(this, ""), this.hideError();
|
|
1826
1826
|
};
|
|
1827
1827
|
}
|
|
1828
1828
|
this.previewWrapper.appendChild(this.previewEl);
|
|
1829
|
-
const
|
|
1830
|
-
return
|
|
1829
|
+
const o = document.createElement("button");
|
|
1830
|
+
return o.className = "upload-button", this.getDataPropsPath() && o.setAttribute("data-test-id", this.getDataPropsPath()), o.innerHTML = `
|
|
1831
1831
|
<span class="upload-icon">${Q}</span>
|
|
1832
1832
|
<span class="upload-label">Upload</span>
|
|
1833
|
-
`, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(
|
|
1833
|
+
`, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(o), t.appendChild(i), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), o.onclick = () => {
|
|
1834
1834
|
window.postMessage(
|
|
1835
1835
|
{
|
|
1836
1836
|
type: "OPEN_FILE_MANAGER_MODAL",
|
|
@@ -1914,44 +1914,44 @@ class ve extends x {
|
|
|
1914
1914
|
e.classList.add("has-label");
|
|
1915
1915
|
const n = document.createElement("div");
|
|
1916
1916
|
n.className = "select-label", n.textContent = this.props.title, e.appendChild(n);
|
|
1917
|
-
const
|
|
1918
|
-
if (
|
|
1919
|
-
|
|
1917
|
+
const o = document.createElement("span");
|
|
1918
|
+
if (o.className = "select-value", this.isLoading)
|
|
1919
|
+
o.textContent = this.props.loadingText || "Loading options...";
|
|
1920
1920
|
else {
|
|
1921
|
-
const
|
|
1922
|
-
|
|
1921
|
+
const a = this.selectedOptionIndex !== null && this._options && this.selectedOptionIndex >= 0 && this.selectedOptionIndex < this._options.length ? this._options[this.selectedOptionIndex] : null, l = a && typeof a.name == "string" ? a.name : "Select an option";
|
|
1922
|
+
o.textContent = l;
|
|
1923
1923
|
}
|
|
1924
|
-
e.appendChild(
|
|
1924
|
+
e.appendChild(o);
|
|
1925
1925
|
} else {
|
|
1926
1926
|
const n = document.createElement("span");
|
|
1927
1927
|
if (this.isLoading)
|
|
1928
1928
|
n.textContent = this.props.loadingText || "Loading options...";
|
|
1929
1929
|
else {
|
|
1930
|
-
const
|
|
1931
|
-
n.textContent =
|
|
1930
|
+
const o = this.selectedOptionIndex !== null && this._options && this.selectedOptionIndex >= 0 && this.selectedOptionIndex < this._options.length ? this._options[this.selectedOptionIndex] : null, a = o && typeof o.name == "string" ? o.name : "Select an option";
|
|
1931
|
+
n.textContent = a;
|
|
1932
1932
|
}
|
|
1933
1933
|
e.appendChild(n);
|
|
1934
1934
|
}
|
|
1935
1935
|
e.onclick = () => {
|
|
1936
|
-
var n,
|
|
1937
|
-
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1936
|
+
var n, o;
|
|
1937
|
+
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (o = this.svgContainer) == null || o.classList.toggle("open", this.isOpen));
|
|
1938
1938
|
}, t.appendChild(e), this.buttonEl = e;
|
|
1939
1939
|
const i = document.createElement("ul");
|
|
1940
|
-
i.classList.add("select-api-options"), this._options.forEach((n,
|
|
1941
|
-
const
|
|
1942
|
-
|
|
1940
|
+
i.classList.add("select-api-options"), this._options.forEach((n, o) => {
|
|
1941
|
+
const a = this.createOption(n, o);
|
|
1942
|
+
a.onclick = (l) => this.selectApiOption(l, o, e), i.appendChild(a);
|
|
1943
1943
|
}), t.appendChild(i);
|
|
1944
1944
|
const s = document.createElement("div");
|
|
1945
1945
|
return s.classList.add("svg-container"), s.innerHTML = Wt, t.appendChild(s), s.onclick = () => {
|
|
1946
|
-
var n,
|
|
1947
|
-
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1946
|
+
var n, o;
|
|
1947
|
+
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (o = this.svgContainer) == null || o.classList.toggle("open", this.isOpen));
|
|
1948
1948
|
}, this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && !this.hasInitializedOptions ? (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
1949
|
-
const
|
|
1949
|
+
const o = new Set(
|
|
1950
1950
|
this._options.map((l) => JSON.stringify(l.value))
|
|
1951
|
-
),
|
|
1952
|
-
(l) => !
|
|
1951
|
+
), a = n.filter(
|
|
1952
|
+
(l) => !o.has(JSON.stringify(l.value))
|
|
1953
1953
|
);
|
|
1954
|
-
if (this._options.push(...
|
|
1954
|
+
if (this._options.push(...a), this.isLoading = !1, this.hasInitializedOptions = !0, this.value !== void 0) {
|
|
1955
1955
|
const l = this._options.findIndex(
|
|
1956
1956
|
(r) => JSON.stringify(r.value) === JSON.stringify(this.value)
|
|
1957
1957
|
);
|
|
@@ -1965,12 +1965,12 @@ class ve extends x {
|
|
|
1965
1965
|
!0
|
|
1966
1966
|
);
|
|
1967
1967
|
})) : this.props.getOptionsAsync && this._options.length <= 1 && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
1968
|
-
const
|
|
1968
|
+
const o = new Set(
|
|
1969
1969
|
this._options.map((l) => JSON.stringify(l.value))
|
|
1970
|
-
),
|
|
1971
|
-
(l) => !
|
|
1970
|
+
), a = n.filter(
|
|
1971
|
+
(l) => !o.has(JSON.stringify(l.value))
|
|
1972
1972
|
);
|
|
1973
|
-
if (this._options.push(...
|
|
1973
|
+
if (this._options.push(...a), this.isLoading = !1, this.value !== void 0) {
|
|
1974
1974
|
const l = this._options.findIndex(
|
|
1975
1975
|
(r) => JSON.stringify(r.value) === JSON.stringify(this.value)
|
|
1976
1976
|
);
|
|
@@ -1989,11 +1989,11 @@ class ve extends x {
|
|
|
1989
1989
|
return JSON.stringify(t ? {} : { value: this.value }, null, 2);
|
|
1990
1990
|
}
|
|
1991
1991
|
selectApiOption(t, e, i) {
|
|
1992
|
-
var
|
|
1993
|
-
const s = t.target, n = s.querySelector(".select-api-radio") || ((
|
|
1992
|
+
var a, l, r;
|
|
1993
|
+
const s = t.target, n = s.querySelector(".select-api-radio") || ((a = s.closest(".select-api-option")) == null ? void 0 : a.querySelector(".select-api-radio"));
|
|
1994
1994
|
n && (n.checked = !0);
|
|
1995
|
-
const
|
|
1996
|
-
this.setValue(
|
|
1995
|
+
const o = this._options[e].value;
|
|
1996
|
+
this.setValue(o), this.isOpen = !1, (l = this.optionsListEl) == null || l.classList.remove("open"), (r = this.svgContainer) == null || r.classList.remove("open");
|
|
1997
1997
|
}
|
|
1998
1998
|
updateOptionsList() {
|
|
1999
1999
|
!this.optionsListEl || !this.buttonEl || (this.optionsListEl.innerHTML = "", this._options.forEach((t, e) => {
|
|
@@ -2042,7 +2042,7 @@ class Ce extends x {
|
|
|
2042
2042
|
super(t), this.inputType = "text", this.value = t.default ?? ((i = (e = t.options) == null ? void 0 : e[0]) == null ? void 0 : i.value) ?? "", this.detectChangeCallback = t.detectChange;
|
|
2043
2043
|
}
|
|
2044
2044
|
draw() {
|
|
2045
|
-
var
|
|
2045
|
+
var o, a;
|
|
2046
2046
|
const t = document.createElement("div");
|
|
2047
2047
|
t.className = "toggle-setting-container", this.props.icon && t.classList.add("toggle-with-icon");
|
|
2048
2048
|
const e = document.createElement("div");
|
|
@@ -2058,20 +2058,20 @@ class Ce extends x {
|
|
|
2058
2058
|
const i = document.createElement("label");
|
|
2059
2059
|
i.className = "toggle-switch";
|
|
2060
2060
|
const s = document.createElement("input");
|
|
2061
|
-
s.type = "checkbox", s.checked = ((
|
|
2062
|
-
var r,
|
|
2063
|
-
const l = ((
|
|
2061
|
+
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", () => {
|
|
2062
|
+
var r, h;
|
|
2063
|
+
const l = ((h = (r = this.props.options) == null ? void 0 : r.find((d) => d.status === s.checked)) == null ? void 0 : h.value) ?? "";
|
|
2064
2064
|
this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
|
|
2065
2065
|
});
|
|
2066
2066
|
const n = document.createElement("span");
|
|
2067
2067
|
if (n.className = "toggle-slider", this.props.activeColor || this.props.inactiveColor) {
|
|
2068
|
-
const l = document.createElement("style"), r = this.props.activeColor || "#4CAF50",
|
|
2068
|
+
const l = document.createElement("style"), r = this.props.activeColor || "#4CAF50", h = this.props.inactiveColor || "#ccc";
|
|
2069
2069
|
l.textContent = `
|
|
2070
2070
|
.toggle-switch input:checked + .toggle-slider {
|
|
2071
2071
|
background-color: ${r};
|
|
2072
2072
|
}
|
|
2073
2073
|
.toggle-switch .toggle-slider {
|
|
2074
|
-
background-color: ${
|
|
2074
|
+
background-color: ${h};
|
|
2075
2075
|
}
|
|
2076
2076
|
`, document.head.appendChild(l);
|
|
2077
2077
|
}
|
|
@@ -2103,27 +2103,27 @@ class ye extends x {
|
|
|
2103
2103
|
i.className = "setting-label", i.setAttribute("for", this.id + "-input");
|
|
2104
2104
|
const s = document.createElement("span");
|
|
2105
2105
|
if (s.textContent = this.props.title ?? "Gap", i.appendChild(s), this.props.icon) {
|
|
2106
|
-
const
|
|
2107
|
-
|
|
2106
|
+
const a = document.createElement("span");
|
|
2107
|
+
a.className = "setting-icon", a.innerHTML = this.props.icon, i.insertBefore(a, s);
|
|
2108
2108
|
}
|
|
2109
2109
|
const n = document.createElement("div");
|
|
2110
2110
|
n.className = `setting-input-wrapper ${this.props.wrapperClassName || ""}`, n.classList.add("gap-setting-wrapper");
|
|
2111
|
-
const
|
|
2112
|
-
return
|
|
2111
|
+
const o = document.createElement("div");
|
|
2112
|
+
return o.className = "gap-inputs-container", this.props.rowGap && o.appendChild(this.createGapInput("row", "Row")), this.props.columnGap && o.appendChild(this.createGapInput("column", "Col")), n.appendChild(o), e.appendChild(i), e.appendChild(n), t.appendChild(e), t;
|
|
2113
2113
|
}
|
|
2114
2114
|
createGapInput(t, e) {
|
|
2115
2115
|
const i = document.createElement("div");
|
|
2116
2116
|
i.className = "gap-input-wrapper";
|
|
2117
2117
|
const s = document.createElement("input");
|
|
2118
2118
|
if (s.type = "number", s.className = `gap-input gap-${t}-input ${this.props.inputClassName || ""}`, s.id = `${this.id}-${t}-input`, s.min = String(this.props.minValue ?? 0), this.props.maxValue !== void 0 && (s.max = String(this.props.maxValue)), s.step = String(this.props.step ?? 1), s.value = String(this.inputValues[t] ?? this.value), s.title = e, this.getDataPropsPath() && s.setAttribute("data-test-id", `${this.getDataPropsPath()}_${t}`), s.addEventListener("input", (n) => {
|
|
2119
|
-
const
|
|
2120
|
-
let
|
|
2121
|
-
|
|
2119
|
+
const o = n.target;
|
|
2120
|
+
let a = parseFloat(o.value);
|
|
2121
|
+
a = this.validateValue(a), String(a) !== o.value && (o.value = String(a)), this.inputValues[t] = a, this.setValue(a);
|
|
2122
2122
|
}), s.addEventListener("blur", (n) => {
|
|
2123
2123
|
var l, r;
|
|
2124
|
-
const
|
|
2125
|
-
let
|
|
2126
|
-
|
|
2124
|
+
const o = n.target;
|
|
2125
|
+
let a = parseFloat(o.value);
|
|
2126
|
+
a = this.validateValue(a), String(a) !== o.value && (o.value = String(a), this.inputValues[t] = a, this.setValue(a)), (r = (l = this.props).onBlur) == null || r.call(l);
|
|
2127
2127
|
}), i.appendChild(s), this.props.suffix && this.props.suffix !== "none") {
|
|
2128
2128
|
const n = document.createElement("span");
|
|
2129
2129
|
n.className = "gap-suffix", n.textContent = this.props.suffix, i.appendChild(n), s.style.paddingRight = "30px";
|
|
@@ -2196,9 +2196,9 @@ class we extends x {
|
|
|
2196
2196
|
return i.font = s, i.measureText(t).width;
|
|
2197
2197
|
}
|
|
2198
2198
|
adaptPlaceholderToSingleLine(t, e) {
|
|
2199
|
-
const i = window.getComputedStyle(t), s = parseFloat(i.paddingLeft) || 0, n = parseFloat(i.paddingRight) || 0,
|
|
2199
|
+
const i = window.getComputedStyle(t), s = parseFloat(i.paddingLeft) || 0, n = parseFloat(i.paddingRight) || 0, o = parseFloat(i.borderLeftWidth) || 0, a = parseFloat(i.borderRightWidth) || 0, l = Math.max(
|
|
2200
2200
|
0,
|
|
2201
|
-
t.clientWidth - s - n -
|
|
2201
|
+
t.clientWidth - s - n - o - a
|
|
2202
2202
|
);
|
|
2203
2203
|
if (l <= 0) {
|
|
2204
2204
|
t.placeholder = e;
|
|
@@ -2208,19 +2208,19 @@ class we extends x {
|
|
|
2208
2208
|
t.placeholder = e;
|
|
2209
2209
|
return;
|
|
2210
2210
|
}
|
|
2211
|
-
const
|
|
2212
|
-
let
|
|
2213
|
-
for (;
|
|
2214
|
-
const m = Math.floor((
|
|
2215
|
-
this.measureTextWidth(u, i) <= l ? (g = m,
|
|
2211
|
+
const h = "...";
|
|
2212
|
+
let d = 0, p = e.length, g = 0;
|
|
2213
|
+
for (; d <= p; ) {
|
|
2214
|
+
const m = Math.floor((d + p) / 2), u = e.slice(0, m).trimEnd() + h;
|
|
2215
|
+
this.measureTextWidth(u, i) <= l ? (g = m, d = m + 1) : p = m - 1;
|
|
2216
2216
|
}
|
|
2217
|
-
const
|
|
2218
|
-
t.placeholder =
|
|
2217
|
+
const v = e.slice(0, g).trimEnd() + h;
|
|
2218
|
+
t.placeholder = v;
|
|
2219
2219
|
}
|
|
2220
2220
|
autosizeTextarea(t, e = 3) {
|
|
2221
2221
|
t.style.height = "auto";
|
|
2222
|
-
const i = window.getComputedStyle(t), s = parseFloat(i.lineHeight) || 20, n = parseFloat(i.paddingTop) + parseFloat(i.paddingBottom),
|
|
2223
|
-
t.style.height = `${l}px`, t.scrollHeight >
|
|
2222
|
+
const i = window.getComputedStyle(t), s = parseFloat(i.lineHeight) || 20, n = parseFloat(i.paddingTop) + parseFloat(i.paddingBottom), o = parseFloat(i.borderTopWidth) + parseFloat(i.borderBottomWidth), a = s * e + n + o, l = Math.min(t.scrollHeight || 44, a);
|
|
2223
|
+
t.style.height = `${l}px`, t.scrollHeight > a ? t.style.overflowY = "auto" : t.style.overflowY = "hidden";
|
|
2224
2224
|
}
|
|
2225
2225
|
createTextareaRow(t, e) {
|
|
2226
2226
|
const i = document.createElement("div");
|
|
@@ -2232,26 +2232,26 @@ class we extends x {
|
|
|
2232
2232
|
title: "",
|
|
2233
2233
|
id: `${this.id}_upload_${t}`
|
|
2234
2234
|
});
|
|
2235
|
-
n.setOnChange((
|
|
2236
|
-
this.updateLanguageValue(t,
|
|
2235
|
+
n.setOnChange((a) => {
|
|
2236
|
+
this.updateLanguageValue(t, a), t === this.defaultLanguage && this.updateOtherLanguagePlaceholders(a);
|
|
2237
2237
|
}), this.uploadSettings.set(t, n);
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2238
|
+
const o = n.draw();
|
|
2239
|
+
o.classList.add("simple-language-upload"), i.appendChild(o);
|
|
2240
2240
|
} else {
|
|
2241
2241
|
const n = document.createElement("textarea");
|
|
2242
2242
|
n.id = `textarea-${t}`, n.classList.add("simple-language-textarea"), n.value = e || "", n.rows = 1, n.style.overflowY = "hidden";
|
|
2243
|
-
let
|
|
2244
|
-
|
|
2243
|
+
let o = this.props.placeholder || "Enter text in {language}...";
|
|
2244
|
+
o.includes("{language}") && (o = o.replace(
|
|
2245
2245
|
"{language}",
|
|
2246
2246
|
t.toUpperCase()
|
|
2247
|
-
)), n.setAttribute("data-full-placeholder",
|
|
2247
|
+
)), n.setAttribute("data-full-placeholder", o), this.adaptPlaceholderToSingleLine(n, o), this.getDataPropsPath() && n.setAttribute(
|
|
2248
2248
|
"data-test-id",
|
|
2249
2249
|
`${this.getDataPropsPath()}_${t}`
|
|
2250
2250
|
), n.addEventListener("input", (l) => {
|
|
2251
2251
|
const r = l.target;
|
|
2252
2252
|
this.updateLanguageValue(t, r.value), t === this.defaultLanguage && this.updateOtherLanguagePlaceholders(r.value), this.autosizeTextarea(r, 3);
|
|
2253
|
-
const
|
|
2254
|
-
|
|
2253
|
+
const h = n.getAttribute("data-full-placeholder") || "";
|
|
2254
|
+
h && this.adaptPlaceholderToSingleLine(n, h);
|
|
2255
2255
|
}), i.appendChild(n), ((l) => (typeof queueMicrotask == "function" ? queueMicrotask : (r) => setTimeout(r, 0))(l))(() => {
|
|
2256
2256
|
this.autosizeTextarea(n, 3);
|
|
2257
2257
|
const l = n.getAttribute("data-full-placeholder") || "";
|
|
@@ -2273,11 +2273,11 @@ class we extends x {
|
|
|
2273
2273
|
`#textarea-${e}`
|
|
2274
2274
|
);
|
|
2275
2275
|
if (i && (!i.value || i.value.trim() === "")) {
|
|
2276
|
-
const
|
|
2276
|
+
const o = t || ((n = this.props.placeholder) == null ? void 0 : n.replace(
|
|
2277
2277
|
"{language}",
|
|
2278
2278
|
e.toUpperCase()
|
|
2279
2279
|
)) || `Enter text in ${e.toUpperCase()}...`;
|
|
2280
|
-
i.setAttribute("data-full-placeholder",
|
|
2280
|
+
i.setAttribute("data-full-placeholder", o), this.adaptPlaceholderToSingleLine(i, o);
|
|
2281
2281
|
}
|
|
2282
2282
|
});
|
|
2283
2283
|
}
|
|
@@ -2289,17 +2289,17 @@ class we extends x {
|
|
|
2289
2289
|
}
|
|
2290
2290
|
const e = document.createElement("div");
|
|
2291
2291
|
e.classList.add("simple-multi-language-content"), this.props.languages.forEach((s) => {
|
|
2292
|
-
var
|
|
2293
|
-
const n = ((
|
|
2294
|
-
e.appendChild(
|
|
2292
|
+
var a;
|
|
2293
|
+
const n = ((a = this.value) == null ? void 0 : a[s]) || "", o = this.createTextareaRow(s, n);
|
|
2294
|
+
e.appendChild(o);
|
|
2295
2295
|
}), t.appendChild(e), this.container = t;
|
|
2296
2296
|
const i = () => {
|
|
2297
2297
|
if (!this.container) return;
|
|
2298
2298
|
this.container.querySelectorAll(
|
|
2299
2299
|
".simple-language-textarea"
|
|
2300
2300
|
).forEach((n) => {
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2301
|
+
const o = n.getAttribute("data-full-placeholder") || "";
|
|
2302
|
+
o && this.adaptPlaceholderToSingleLine(n, o);
|
|
2303
2303
|
});
|
|
2304
2304
|
};
|
|
2305
2305
|
return window.addEventListener("resize", i), t;
|
|
@@ -2351,19 +2351,19 @@ class xe extends x {
|
|
|
2351
2351
|
}
|
|
2352
2352
|
}
|
|
2353
2353
|
const ut = (c, t, e) => {
|
|
2354
|
-
let i = !1, s = 0, n = 0,
|
|
2355
|
-
const l = (
|
|
2356
|
-
if (
|
|
2357
|
-
i = !0, s =
|
|
2358
|
-
const
|
|
2359
|
-
|
|
2360
|
-
}, r = (
|
|
2354
|
+
let i = !1, s = 0, n = 0, o = 0, a = 0;
|
|
2355
|
+
const l = (d) => {
|
|
2356
|
+
if (d.target.closest("button")) return;
|
|
2357
|
+
i = !0, s = d.clientX, n = d.clientY;
|
|
2358
|
+
const p = t.getBoundingClientRect();
|
|
2359
|
+
o = p.left, a = p.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup", h), document.body.style.userSelect = "none";
|
|
2360
|
+
}, r = (d) => {
|
|
2361
2361
|
if (!i) return;
|
|
2362
|
-
const
|
|
2363
|
-
let
|
|
2364
|
-
|
|
2365
|
-
},
|
|
2366
|
-
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup",
|
|
2362
|
+
const p = d.clientX - s, g = d.clientY - n, v = window.innerWidth, m = window.innerHeight, u = t.offsetWidth, f = t.offsetHeight;
|
|
2363
|
+
let C = o + p, y = a + g;
|
|
2364
|
+
C = Math.max(8, Math.min(v - u - 8, C)), y = Math.max(8, Math.min(m - f - 8, y)), t.style.left = `${C}px`, t.style.top = `${y}px`, e == null || e(C, y);
|
|
2365
|
+
}, h = () => {
|
|
2366
|
+
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", h), document.body.style.userSelect = "";
|
|
2367
2367
|
};
|
|
2368
2368
|
c.addEventListener("mousedown", l);
|
|
2369
2369
|
}, U = (c) => {
|
|
@@ -2378,35 +2378,35 @@ const ut = (c, t, e) => {
|
|
|
2378
2378
|
b: parseInt(e.slice(4, 6), 16)
|
|
2379
2379
|
};
|
|
2380
2380
|
}, R = (c) => {
|
|
2381
|
-
const { r: t, g: e, b: i } = N(c), s = t / 255, n = e / 255,
|
|
2382
|
-
let
|
|
2383
|
-
r !== 0 && (
|
|
2384
|
-
const
|
|
2385
|
-
return { h:
|
|
2381
|
+
const { r: t, g: e, b: i } = N(c), s = t / 255, n = e / 255, o = i / 255, a = Math.max(s, n, o), l = Math.min(s, n, o), r = a - l;
|
|
2382
|
+
let h = 0;
|
|
2383
|
+
r !== 0 && (a === s ? h = (n - o) / r % 6 : a === n ? h = (o - s) / r + 2 : h = (s - n) / r + 4), h < 0 && (h += 6);
|
|
2384
|
+
const d = a === 0 ? 0 : r / a, p = a;
|
|
2385
|
+
return { h: h * 60, s: d, v: p };
|
|
2386
2386
|
}, W = (c, t, e) => {
|
|
2387
|
-
const i = (c % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)),
|
|
2388
|
-
let
|
|
2389
|
-
return i < 60 ? (
|
|
2390
|
-
Math.round((
|
|
2391
|
-
Math.round((l +
|
|
2392
|
-
Math.round((r +
|
|
2387
|
+
const i = (c % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)), o = e - s;
|
|
2388
|
+
let a = 0, l = 0, r = 0;
|
|
2389
|
+
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), J(
|
|
2390
|
+
Math.round((a + o) * 255),
|
|
2391
|
+
Math.round((l + o) * 255),
|
|
2392
|
+
Math.round((r + o) * 255)
|
|
2393
2393
|
);
|
|
2394
2394
|
}, gt = (c, t, e) => {
|
|
2395
2395
|
const i = e * (1 - t / 2), s = i === 0 || i === 1 ? 0 : (e - i) / Math.min(i, 1 - i);
|
|
2396
2396
|
return { hue: c, sat: s, lightness: i };
|
|
2397
2397
|
}, it = (c, t, e) => {
|
|
2398
2398
|
const i = (1 - Math.abs(2 * e - 1)) * t, s = i * (1 - Math.abs(c / 60 % 2 - 1)), n = e - i / 2;
|
|
2399
|
-
let
|
|
2400
|
-
return c < 60 ? (
|
|
2401
|
-
r: Math.round((
|
|
2402
|
-
g: Math.round((
|
|
2399
|
+
let o = 0, a = 0, l = 0;
|
|
2400
|
+
return c < 60 ? (o = i, a = s, l = 0) : c < 120 ? (o = s, a = i, l = 0) : c < 180 ? (o = 0, a = i, l = s) : c < 240 ? (o = 0, a = s, l = i) : c < 300 ? (o = s, a = 0, l = i) : (o = i, a = 0, l = s), {
|
|
2401
|
+
r: Math.round((o + n) * 255),
|
|
2402
|
+
g: Math.round((a + n) * 255),
|
|
2403
2403
|
b: Math.round((l + n) * 255)
|
|
2404
2404
|
};
|
|
2405
2405
|
}, st = (c, t) => {
|
|
2406
2406
|
const e = Math.max(0, Math.min(100, t)) / 100;
|
|
2407
2407
|
if (c.startsWith("#")) {
|
|
2408
|
-
const { r: s, g: n, b:
|
|
2409
|
-
return `rgba(${s}, ${n}, ${
|
|
2408
|
+
const { r: s, g: n, b: o } = N(c);
|
|
2409
|
+
return `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
2410
2410
|
}
|
|
2411
2411
|
if (c.startsWith("rgba("))
|
|
2412
2412
|
return c.replace(/,\s*[\d.]+\)$/, `, ${e})`);
|
|
@@ -2415,29 +2415,29 @@ const ut = (c, t, e) => {
|
|
|
2415
2415
|
if (c.startsWith("hsl(")) {
|
|
2416
2416
|
const s = c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2417
2417
|
if (s) {
|
|
2418
|
-
const { r: n, g:
|
|
2418
|
+
const { r: n, g: o, b: a } = it(
|
|
2419
2419
|
parseInt(s[1]),
|
|
2420
2420
|
parseInt(s[2]) / 100,
|
|
2421
2421
|
parseInt(s[3]) / 100
|
|
2422
2422
|
);
|
|
2423
|
-
return `rgba(${n}, ${
|
|
2423
|
+
return `rgba(${n}, ${o}, ${a}, ${e})`;
|
|
2424
2424
|
}
|
|
2425
2425
|
}
|
|
2426
2426
|
if (c.startsWith("hsla(")) {
|
|
2427
2427
|
const s = c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);
|
|
2428
2428
|
if (s) {
|
|
2429
|
-
const { r: n, g:
|
|
2429
|
+
const { r: n, g: o, b: a } = it(
|
|
2430
2430
|
parseInt(s[1]),
|
|
2431
2431
|
parseInt(s[2]) / 100,
|
|
2432
2432
|
parseInt(s[3]) / 100
|
|
2433
2433
|
);
|
|
2434
|
-
return `rgba(${n}, ${
|
|
2434
|
+
return `rgba(${n}, ${o}, ${a}, ${e})`;
|
|
2435
2435
|
}
|
|
2436
2436
|
}
|
|
2437
2437
|
const i = U(c);
|
|
2438
2438
|
if (i) {
|
|
2439
|
-
const { r: s, g: n, b:
|
|
2440
|
-
return `rgba(${s}, ${n}, ${
|
|
2439
|
+
const { r: s, g: n, b: o } = N(i);
|
|
2440
|
+
return `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
2441
2441
|
}
|
|
2442
2442
|
return c;
|
|
2443
2443
|
}, qt = (c) => [
|
|
@@ -2477,9 +2477,9 @@ const ut = (c, t, e) => {
|
|
|
2477
2477
|
}, ft = (c) => {
|
|
2478
2478
|
const t = c.trim();
|
|
2479
2479
|
if (/^#[0-9A-Fa-f]{8}$/.test(t)) {
|
|
2480
|
-
const n = t.slice(1),
|
|
2480
|
+
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);
|
|
2481
2481
|
return {
|
|
2482
|
-
color: J(
|
|
2482
|
+
color: J(o, a, l),
|
|
2483
2483
|
position: 0,
|
|
2484
2484
|
opacity: Math.round(r / 255 * 100)
|
|
2485
2485
|
};
|
|
@@ -2488,9 +2488,9 @@ const ut = (c, t, e) => {
|
|
|
2488
2488
|
/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/
|
|
2489
2489
|
);
|
|
2490
2490
|
if (e) {
|
|
2491
|
-
const n = parseInt(e[1]),
|
|
2491
|
+
const n = parseInt(e[1]), o = parseInt(e[2]), a = parseInt(e[3]), l = e[4] ? parseFloat(e[4]) : 1;
|
|
2492
2492
|
return {
|
|
2493
|
-
color: J(n,
|
|
2493
|
+
color: J(n, o, a),
|
|
2494
2494
|
position: 0,
|
|
2495
2495
|
opacity: Math.round(l * 100)
|
|
2496
2496
|
};
|
|
@@ -2499,13 +2499,13 @@ const ut = (c, t, e) => {
|
|
|
2499
2499
|
/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/
|
|
2500
2500
|
);
|
|
2501
2501
|
if (i) {
|
|
2502
|
-
const { r: n, g:
|
|
2502
|
+
const { r: n, g: o, b: a } = it(
|
|
2503
2503
|
parseFloat(i[1]),
|
|
2504
2504
|
parseFloat(i[2]) / 100,
|
|
2505
2505
|
parseFloat(i[3]) / 100
|
|
2506
2506
|
), l = i[4] ? parseFloat(i[4]) : 1;
|
|
2507
2507
|
return {
|
|
2508
|
-
color: J(n,
|
|
2508
|
+
color: J(n, o, a),
|
|
2509
2509
|
position: 0,
|
|
2510
2510
|
opacity: Math.round(l * 100)
|
|
2511
2511
|
};
|
|
@@ -2529,10 +2529,10 @@ const ut = (c, t, e) => {
|
|
|
2529
2529
|
const e = new RegExp(`${t}\\s*\\(`, "i"), i = c.match(e);
|
|
2530
2530
|
if (!i) return null;
|
|
2531
2531
|
const s = i.index + i[0].length;
|
|
2532
|
-
let n = 1,
|
|
2533
|
-
for (let
|
|
2534
|
-
c[
|
|
2535
|
-
return n === 0 ? c.substring(s,
|
|
2532
|
+
let n = 1, o = s;
|
|
2533
|
+
for (let a = s; a < c.length && n > 0; a++)
|
|
2534
|
+
c[a] === "(" ? n++ : c[a] === ")" && n--, o = a;
|
|
2535
|
+
return n === 0 ? c.substring(s, o) : null;
|
|
2536
2536
|
}, Jt = (c) => {
|
|
2537
2537
|
const t = c.split(" ")[0].toLowerCase();
|
|
2538
2538
|
return [
|
|
@@ -2551,11 +2551,11 @@ const ut = (c, t, e) => {
|
|
|
2551
2551
|
return c.forEach((e, i) => {
|
|
2552
2552
|
const s = e.trim();
|
|
2553
2553
|
if (!s) return;
|
|
2554
|
-
let n = "",
|
|
2555
|
-
const
|
|
2556
|
-
|
|
2554
|
+
let n = "", o = 0;
|
|
2555
|
+
const a = s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);
|
|
2556
|
+
a && mt(a[1].trim()) ? (n = a[1].trim(), o = parseFloat(a[2])) : (n = s, o = c.length === 1 ? 0 : i / (c.length - 1) * 100);
|
|
2557
2557
|
const l = ft(n);
|
|
2558
|
-
l.position = Math.max(0, Math.min(100, Math.round(
|
|
2558
|
+
l.position = Math.max(0, Math.min(100, Math.round(o))), t.push(l);
|
|
2559
2559
|
}), t;
|
|
2560
2560
|
}, H = (c) => {
|
|
2561
2561
|
const t = c.stops && c.stops.length ? c.stops : [{ color: "#000000", position: 0, opacity: 100 }];
|
|
@@ -2577,12 +2577,12 @@ const ut = (c, t, e) => {
|
|
|
2577
2577
|
const e = ct(t, "linear-gradient");
|
|
2578
2578
|
if (e) {
|
|
2579
2579
|
const s = rt(e);
|
|
2580
|
-
let n = 90,
|
|
2581
|
-
const
|
|
2582
|
-
if (
|
|
2583
|
-
const r =
|
|
2584
|
-
r && (n = parseFloat(r[1]),
|
|
2585
|
-
} else
|
|
2580
|
+
let n = 90, o = s;
|
|
2581
|
+
const a = s[0];
|
|
2582
|
+
if (a.includes("deg")) {
|
|
2583
|
+
const r = a.match(/(-?\d+(?:\.\d+)?)deg/);
|
|
2584
|
+
r && (n = parseFloat(r[1]), o = s.slice(1));
|
|
2585
|
+
} else a.includes("to ") && (n = {
|
|
2586
2586
|
"to right": 90,
|
|
2587
2587
|
"to left": 270,
|
|
2588
2588
|
"to bottom": 180,
|
|
@@ -2591,14 +2591,14 @@ const ut = (c, t, e) => {
|
|
|
2591
2591
|
"to bottom left": 225,
|
|
2592
2592
|
"to top right": 45,
|
|
2593
2593
|
"to top left": 315
|
|
2594
|
-
}[
|
|
2595
|
-
const l = ht(
|
|
2594
|
+
}[a] ?? 90, o = s.slice(1));
|
|
2595
|
+
const l = ht(o);
|
|
2596
2596
|
return l.length ? H({ type: "linear", angle: n, stops: l }) : null;
|
|
2597
2597
|
}
|
|
2598
2598
|
const i = ct(t, "radial-gradient");
|
|
2599
2599
|
if (i) {
|
|
2600
|
-
const s = rt(i), n = s[0] && !Jt(s[0]) ? s.slice(1) : s,
|
|
2601
|
-
return
|
|
2600
|
+
const s = rt(i), n = s[0] && !Jt(s[0]) ? s.slice(1) : s, o = ht(n);
|
|
2601
|
+
return o.length ? H({ type: "radial", angle: 0, stops: o }) : null;
|
|
2602
2602
|
}
|
|
2603
2603
|
return null;
|
|
2604
2604
|
}, O = (c) => {
|
|
@@ -2606,8 +2606,8 @@ const ut = (c, t, e) => {
|
|
|
2606
2606
|
const e = c.stops[0], i = e.color;
|
|
2607
2607
|
if (i.startsWith("var(--"))
|
|
2608
2608
|
return i;
|
|
2609
|
-
const s = e.opacity ?? 100, n = i.replace("#", ""),
|
|
2610
|
-
return `#${n}${
|
|
2609
|
+
const s = e.opacity ?? 100, n = i.replace("#", ""), o = Math.round(s / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
2610
|
+
return `#${n}${o}`;
|
|
2611
2611
|
}
|
|
2612
2612
|
const t = c.stops.map(
|
|
2613
2613
|
(e) => `${st(e.color, e.opacity ?? 100)} ${e.position}%`
|
|
@@ -2680,8 +2680,8 @@ const ut = (c, t, e) => {
|
|
|
2680
2680
|
static getColors(t) {
|
|
2681
2681
|
if (t === "all") {
|
|
2682
2682
|
const e = this.list("solid"), i = this.list("gradient"), s = [], n = Math.max(e.length, i.length);
|
|
2683
|
-
for (let
|
|
2684
|
-
|
|
2683
|
+
for (let o = 0; o < n; o++)
|
|
2684
|
+
o < e.length && s.push(e[o]), o < i.length && s.push(i[o]);
|
|
2685
2685
|
return this.normalizeList(s);
|
|
2686
2686
|
}
|
|
2687
2687
|
return [...this.list(t)];
|
|
@@ -2696,8 +2696,8 @@ const ut = (c, t, e) => {
|
|
|
2696
2696
|
l && (i = t, s = l.type === "solid" ? "solid" : "gradient");
|
|
2697
2697
|
}
|
|
2698
2698
|
if (!i) return;
|
|
2699
|
-
const n = e === "all" ? s : e,
|
|
2700
|
-
|
|
2699
|
+
const n = e === "all" ? s : e, o = this.list(n), a = o.indexOf(i);
|
|
2700
|
+
a !== -1 && o.splice(a, 1), o.unshift(i), o.length > this.MAX_COLORS && (o.length = this.MAX_COLORS), this.persist();
|
|
2701
2701
|
}
|
|
2702
2702
|
};
|
|
2703
2703
|
z.STORAGE_KEY = "settingsLib_recentColors", z.MAX_COLORS = 12, z.colors = null;
|
|
@@ -2711,41 +2711,41 @@ const ot = (c, t) => {
|
|
|
2711
2711
|
s.className = "color-picker-tooltip", s.style.display = "none", e.appendChild(s);
|
|
2712
2712
|
const n = () => {
|
|
2713
2713
|
s.style.display = "none";
|
|
2714
|
-
},
|
|
2715
|
-
const
|
|
2716
|
-
s.textContent =
|
|
2717
|
-
},
|
|
2718
|
-
|
|
2714
|
+
}, o = (h, d) => {
|
|
2715
|
+
const p = h.getBoundingClientRect();
|
|
2716
|
+
s.textContent = d, s.style.left = `${p.left + p.width / 2}px`, s.style.top = `${p.bottom + 8}px`, s.style.display = "block";
|
|
2717
|
+
}, a = document.createElement("div");
|
|
2718
|
+
a.className = "color-picker-recent-grid";
|
|
2719
2719
|
const l = document.createElement("div");
|
|
2720
|
-
l.className = "color-picker-recent-placeholder", l.textContent = "No recent colors yet", e.appendChild(i), e.appendChild(
|
|
2720
|
+
l.className = "color-picker-recent-placeholder", l.textContent = "No recent colors yet", e.appendChild(i), e.appendChild(a), e.appendChild(l);
|
|
2721
2721
|
const r = () => {
|
|
2722
|
-
n(),
|
|
2723
|
-
const
|
|
2724
|
-
if (
|
|
2725
|
-
|
|
2722
|
+
n(), a.innerHTML = "";
|
|
2723
|
+
const h = D.getColors(t);
|
|
2724
|
+
if (h.length === 0) {
|
|
2725
|
+
a.style.display = "none", l.style.display = "block";
|
|
2726
2726
|
return;
|
|
2727
2727
|
}
|
|
2728
|
-
|
|
2729
|
-
const
|
|
2730
|
-
|
|
2731
|
-
const g = Xt(
|
|
2732
|
-
if (
|
|
2733
|
-
|
|
2734
|
-
const m = I(
|
|
2735
|
-
m && m.stops && m.stops.length > 0 && (
|
|
2728
|
+
a.style.display = "grid", l.style.display = "none", h.forEach((d) => {
|
|
2729
|
+
const p = document.createElement("button");
|
|
2730
|
+
p.type = "button", p.className = "color-picker-recent-swatch";
|
|
2731
|
+
const g = Xt(d);
|
|
2732
|
+
if (p.title = g, p.setAttribute("aria-label", `Use color: ${g}`), d.includes("gradient(")) {
|
|
2733
|
+
p.style.backgroundImage = d, p.style.backgroundColor = "transparent";
|
|
2734
|
+
const m = I(d);
|
|
2735
|
+
m && m.stops && m.stops.length > 0 && (p.style.borderColor = m.stops[0].color);
|
|
2736
2736
|
} else
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
n(),
|
|
2740
|
-
}),
|
|
2741
|
-
|
|
2742
|
-
}),
|
|
2737
|
+
p.style.backgroundColor = d, p.style.borderColor = d;
|
|
2738
|
+
p.addEventListener("mouseenter", () => o(p, g)), p.addEventListener("mouseleave", () => {
|
|
2739
|
+
n(), p.style.boxShadow = "";
|
|
2740
|
+
}), p.addEventListener("mousedown", () => {
|
|
2741
|
+
p.style.boxShadow = "0px 0px 0px 2px var(--grey40)";
|
|
2742
|
+
}), p.addEventListener("mouseup", () => {
|
|
2743
2743
|
setTimeout(() => {
|
|
2744
|
-
|
|
2744
|
+
p.style.boxShadow = "";
|
|
2745
2745
|
}, 150);
|
|
2746
|
-
}),
|
|
2747
|
-
n(), c(
|
|
2748
|
-
}),
|
|
2746
|
+
}), p.addEventListener("click", () => {
|
|
2747
|
+
n(), c(d);
|
|
2748
|
+
}), a.appendChild(p);
|
|
2749
2749
|
});
|
|
2750
2750
|
};
|
|
2751
2751
|
return r(), { container: e, refresh: r };
|
|
@@ -2800,8 +2800,8 @@ class dt {
|
|
|
2800
2800
|
if (Array.from(n).some(
|
|
2801
2801
|
(l) => l.contains(s)
|
|
2802
2802
|
)) return;
|
|
2803
|
-
const
|
|
2804
|
-
|
|
2803
|
+
const a = document.querySelector(".gradient-popover");
|
|
2804
|
+
a && a.contains(s) || (i.preventDefault(), i.stopPropagation(), this.close(!0));
|
|
2805
2805
|
}, this.keyDown = (i) => {
|
|
2806
2806
|
if (this.isOpen) {
|
|
2807
2807
|
if (i.key === "Escape")
|
|
@@ -2829,102 +2829,102 @@ class dt {
|
|
|
2829
2829
|
s.className = "color-picker-close", s.innerHTML = vt, s.addEventListener("click", () => this.close(!0)), e.appendChild(i), e.appendChild(s), ut(e, t);
|
|
2830
2830
|
const n = document.createElement("div");
|
|
2831
2831
|
n.className = "color-picker-area", this.colorArea = n;
|
|
2832
|
-
const a = document.createElement("div");
|
|
2833
|
-
a.className = "color-picker-marker", this.colorMarker = a, n.appendChild(a);
|
|
2834
2832
|
const o = document.createElement("div");
|
|
2835
|
-
o.className = "color-picker-
|
|
2833
|
+
o.className = "color-picker-marker", this.colorMarker = o, n.appendChild(o);
|
|
2834
|
+
const a = document.createElement("div");
|
|
2835
|
+
a.className = "color-picker-sliders-container";
|
|
2836
2836
|
const l = document.createElement("button");
|
|
2837
2837
|
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML = Ct;
|
|
2838
2838
|
const r = document.createElement("div");
|
|
2839
2839
|
r.className = "color-picker-sliders-group";
|
|
2840
|
-
const p = document.createElement("div");
|
|
2841
|
-
p.className = "color-picker-hue", this.hueSlider = p;
|
|
2842
2840
|
const h = document.createElement("div");
|
|
2843
|
-
h.className = "color-picker-hue
|
|
2841
|
+
h.className = "color-picker-hue", this.hueSlider = h;
|
|
2844
2842
|
const d = document.createElement("div");
|
|
2845
|
-
d.className = "color-picker-
|
|
2843
|
+
d.className = "color-picker-hue-marker", this.hueMarker = d, h.appendChild(d);
|
|
2844
|
+
const p = document.createElement("div");
|
|
2845
|
+
p.className = "color-picker-opacity", this.opacitySlider = p;
|
|
2846
2846
|
const g = document.createElement("div");
|
|
2847
|
-
g.className = "color-picker-opacity-marker", this.opacityMarker = g,
|
|
2848
|
-
const
|
|
2847
|
+
g.className = "color-picker-opacity-marker", this.opacityMarker = g, p.appendChild(g), r.appendChild(h), r.appendChild(p), a.appendChild(l), a.appendChild(r);
|
|
2848
|
+
const v = ot((b) => {
|
|
2849
2849
|
var E;
|
|
2850
2850
|
this.setColor(b), (E = this.onChange) == null || E.call(this, b, this.currentOpacity);
|
|
2851
2851
|
}, this.recentScope);
|
|
2852
|
-
this.recentSectionRefresh =
|
|
2852
|
+
this.recentSectionRefresh = v.refresh;
|
|
2853
2853
|
const m = document.createElement("div");
|
|
2854
2854
|
m.className = "color-picker-format-section";
|
|
2855
2855
|
const u = document.createElement("select");
|
|
2856
2856
|
u.className = "color-picker-format-select", this.select = u;
|
|
2857
2857
|
const f = document.createElement("option");
|
|
2858
2858
|
f.value = "hex", f.textContent = "HEX";
|
|
2859
|
-
const
|
|
2860
|
-
|
|
2859
|
+
const C = document.createElement("option");
|
|
2860
|
+
C.value = "rgb", C.textContent = "RGB";
|
|
2861
2861
|
const y = document.createElement("option");
|
|
2862
|
-
y.value = "hsl", y.textContent = "HSL", u.appendChild(f), u.appendChild(
|
|
2862
|
+
y.value = "hsl", y.textContent = "HSL", u.appendChild(f), u.appendChild(C), u.appendChild(y);
|
|
2863
2863
|
const w = document.createElement("input");
|
|
2864
2864
|
w.type = "text", w.className = "color-picker-color-input", w.value = this.currentColor, this.input = w;
|
|
2865
2865
|
const k = document.createElement("div");
|
|
2866
2866
|
k.className = "color-picker-input-container";
|
|
2867
2867
|
const S = document.createElement("button");
|
|
2868
|
-
return S.className = "color-picker-copy-inside", S.textContent = "Copy", k.appendChild(w), k.appendChild(S), m.appendChild(u), m.appendChild(k), t.appendChild(e), t.appendChild(n), t.appendChild(
|
|
2868
|
+
return S.className = "color-picker-copy-inside", S.textContent = "Copy", k.appendChild(w), k.appendChild(S), m.appendChild(u), m.appendChild(k), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(v.container), t.appendChild(m), t.addEventListener("click", (b) => b.stopPropagation()), this.bind(n, h, p, w, u, S, l), t;
|
|
2869
2869
|
}
|
|
2870
2870
|
createBackdrop() {
|
|
2871
2871
|
const t = document.createElement("div");
|
|
2872
2872
|
return t.className = "color-picker-backdrop", t.style.display = "none", t.style.pointerEvents = "none", t;
|
|
2873
2873
|
}
|
|
2874
|
-
bind(t, e, i, s, n,
|
|
2875
|
-
const l = (
|
|
2876
|
-
var v;
|
|
2877
|
-
const d = t.getBoundingClientRect(), g = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width)), C = Math.max(0, Math.min(1, (h.clientY - d.top) / d.height));
|
|
2878
|
-
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${C * 100}%`;
|
|
2879
|
-
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, f = W(u, g, 1 - C);
|
|
2880
|
-
this.currentColor = f, this.syncInput(), this.updateOpacityBg(), (v = this.onChange) == null || v.call(this, f, this.currentOpacity);
|
|
2881
|
-
}, r = (h) => {
|
|
2882
|
-
var v;
|
|
2883
|
-
const d = e.getBoundingClientRect();
|
|
2884
|
-
let g = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width));
|
|
2885
|
-
this.hueMarker.style.left = `${g * 100}%`;
|
|
2886
|
-
const C = g * 360, m = this.parsePercentage(this.colorMarker.style.left || "0%"), u = this.parsePercentage(this.colorMarker.style.top || "0%"), f = W(C, m, 1 - u);
|
|
2887
|
-
this.currentColor = f, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (v = this.onChange) == null || v.call(this, f, this.currentOpacity);
|
|
2888
|
-
}, p = (h) => {
|
|
2874
|
+
bind(t, e, i, s, n, o, a) {
|
|
2875
|
+
const l = (d) => {
|
|
2889
2876
|
var C;
|
|
2890
|
-
const
|
|
2891
|
-
this.
|
|
2877
|
+
const p = t.getBoundingClientRect(), g = Math.max(0, Math.min(1, (d.clientX - p.left) / p.width)), v = Math.max(0, Math.min(1, (d.clientY - p.top) / p.height));
|
|
2878
|
+
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${v * 100}%`;
|
|
2879
|
+
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, f = W(u, g, 1 - v);
|
|
2880
|
+
this.currentColor = f, this.syncInput(), this.updateOpacityBg(), (C = this.onChange) == null || C.call(this, f, this.currentOpacity);
|
|
2881
|
+
}, r = (d) => {
|
|
2882
|
+
var C;
|
|
2883
|
+
const p = e.getBoundingClientRect();
|
|
2884
|
+
let g = Math.max(0, Math.min(1, (d.clientX - p.left) / p.width));
|
|
2885
|
+
this.hueMarker.style.left = `${g * 100}%`;
|
|
2886
|
+
const v = g * 360, m = this.parsePercentage(this.colorMarker.style.left || "0%"), u = this.parsePercentage(this.colorMarker.style.top || "0%"), f = W(v, m, 1 - u);
|
|
2887
|
+
this.currentColor = f, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${v}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (C = this.onChange) == null || C.call(this, f, this.currentOpacity);
|
|
2888
|
+
}, h = (d) => {
|
|
2889
|
+
var v;
|
|
2890
|
+
const p = i.getBoundingClientRect(), g = Math.max(0, Math.min(1, (d.clientX - p.left) / p.width));
|
|
2891
|
+
this.opacityMarker.style.left = `${g * 100}%`, this.currentOpacity = Math.round(g * 100), (v = this.onChange) == null || v.call(this, this.currentColor, this.currentOpacity);
|
|
2892
2892
|
};
|
|
2893
|
-
t.addEventListener("mousedown", (
|
|
2894
|
-
|
|
2895
|
-
const
|
|
2896
|
-
document.removeEventListener("mousemove",
|
|
2893
|
+
t.addEventListener("mousedown", (d) => {
|
|
2894
|
+
d.preventDefault(), l(d);
|
|
2895
|
+
const p = (v) => l(v), g = () => {
|
|
2896
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g);
|
|
2897
2897
|
};
|
|
2898
|
-
document.addEventListener("mousemove",
|
|
2899
|
-
}), e.addEventListener("mousedown", (
|
|
2900
|
-
|
|
2901
|
-
const
|
|
2902
|
-
document.removeEventListener("mousemove",
|
|
2898
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
|
|
2899
|
+
}), e.addEventListener("mousedown", (d) => {
|
|
2900
|
+
d.preventDefault(), r(d);
|
|
2901
|
+
const p = (v) => r(v), g = () => {
|
|
2902
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g);
|
|
2903
2903
|
};
|
|
2904
|
-
document.addEventListener("mousemove",
|
|
2905
|
-
}), i.addEventListener("mousedown", (
|
|
2906
|
-
|
|
2907
|
-
const
|
|
2908
|
-
document.removeEventListener("mousemove",
|
|
2904
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
|
|
2905
|
+
}), i.addEventListener("mousedown", (d) => {
|
|
2906
|
+
d.preventDefault(), h(d);
|
|
2907
|
+
const p = (v) => h(v), g = () => {
|
|
2908
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g);
|
|
2909
2909
|
};
|
|
2910
|
-
document.addEventListener("mousemove",
|
|
2911
|
-
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (
|
|
2912
|
-
|
|
2913
|
-
}),
|
|
2910
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
|
|
2911
|
+
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (d) => {
|
|
2912
|
+
d.key === "Enter" && (d.preventDefault(), this.syncInput(), s.blur());
|
|
2913
|
+
}), o.addEventListener("click", async () => {
|
|
2914
2914
|
try {
|
|
2915
2915
|
await navigator.clipboard.writeText(s.value);
|
|
2916
2916
|
} catch {
|
|
2917
2917
|
s.select(), document.execCommand("copy");
|
|
2918
2918
|
}
|
|
2919
|
-
}),
|
|
2920
|
-
var
|
|
2919
|
+
}), a.addEventListener("click", async () => {
|
|
2920
|
+
var d;
|
|
2921
2921
|
if (!("EyeDropper" in window)) {
|
|
2922
2922
|
alert("EyeDropper API is not supported in this browser.");
|
|
2923
2923
|
return;
|
|
2924
2924
|
}
|
|
2925
2925
|
try {
|
|
2926
|
-
const
|
|
2927
|
-
this.setColor(g), (
|
|
2926
|
+
const p = new window.EyeDropper(), { sRGBHex: g } = await p.open();
|
|
2927
|
+
this.setColor(g), (d = this.onChange) == null || d.call(this, g, this.currentOpacity);
|
|
2928
2928
|
} catch {
|
|
2929
2929
|
}
|
|
2930
2930
|
}), document.addEventListener("keydown", this.keyDown, !0), setTimeout(
|
|
@@ -2933,22 +2933,22 @@ class dt {
|
|
|
2933
2933
|
);
|
|
2934
2934
|
}
|
|
2935
2935
|
setColor(t) {
|
|
2936
|
-
var
|
|
2936
|
+
var o;
|
|
2937
2937
|
this.currentColor = t;
|
|
2938
2938
|
const { h: e, s: i, v: s } = R(t), n = e >= 360 ? e % 360 : e;
|
|
2939
|
-
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(), (
|
|
2939
|
+
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);
|
|
2940
2940
|
}
|
|
2941
2941
|
syncInput() {
|
|
2942
2942
|
const t = this.select.value, { h: e, s: i, v: s } = R(this.currentColor);
|
|
2943
2943
|
if (t === "hex") this.input.value = this.currentColor;
|
|
2944
2944
|
else if (t === "rgb") {
|
|
2945
|
-
const { r: n, g:
|
|
2946
|
-
this.input.value = `rgb(${n}, ${
|
|
2945
|
+
const { r: n, g: o, b: a } = N(this.currentColor);
|
|
2946
|
+
this.input.value = `rgb(${n}, ${o}, ${a})`;
|
|
2947
2947
|
} else {
|
|
2948
|
-
const { hue: n, sat:
|
|
2948
|
+
const { hue: n, sat: o, lightness: a } = gt(e, i, s);
|
|
2949
2949
|
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
2950
|
-
|
|
2951
|
-
)}%, ${Math.round(
|
|
2950
|
+
o * 100
|
|
2951
|
+
)}%, ${Math.round(a * 100)}%)`;
|
|
2952
2952
|
}
|
|
2953
2953
|
}
|
|
2954
2954
|
applyFromInput() {
|
|
@@ -2958,12 +2958,12 @@ class dt {
|
|
|
2958
2958
|
else {
|
|
2959
2959
|
const i = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
2960
2960
|
if (i) {
|
|
2961
|
-
const s = parseInt(i[1]), n = parseInt(i[2]),
|
|
2962
|
-
s <= 255 && n <= 255 &&
|
|
2961
|
+
const s = parseInt(i[1]), n = parseInt(i[2]), o = parseInt(i[3]);
|
|
2962
|
+
s <= 255 && n <= 255 && o <= 255 && (e = `#${[s, n, o].map((a) => a.toString(16).padStart(2, "0")).join("")}`);
|
|
2963
2963
|
} else {
|
|
2964
2964
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2965
2965
|
if (s) {
|
|
2966
|
-
const n = parseInt(s[1]),
|
|
2966
|
+
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);
|
|
2967
2967
|
e = W(n, r, l);
|
|
2968
2968
|
}
|
|
2969
2969
|
}
|
|
@@ -2980,14 +2980,14 @@ class dt {
|
|
|
2980
2980
|
open(t, e, i) {
|
|
2981
2981
|
var y;
|
|
2982
2982
|
this.currentColor = t, this.currentOpacity = i ?? 100, this.syncInput();
|
|
2983
|
-
const { h: s, s: n, v:
|
|
2984
|
-
this.hueMarker.style.left = `${s / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 -
|
|
2985
|
-
const
|
|
2986
|
-
let g = r.right + 8,
|
|
2987
|
-
const m =
|
|
2988
|
-
m >=
|
|
2989
|
-
const f =
|
|
2990
|
-
f >= l +
|
|
2983
|
+
const { h: s, s: n, v: o } = R(t);
|
|
2984
|
+
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);
|
|
2985
|
+
const a = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(), h = window.innerWidth, d = window.innerHeight, p = 16;
|
|
2986
|
+
let g = r.right + 8, v = r.top;
|
|
2987
|
+
const m = h - r.right, u = r.left;
|
|
2988
|
+
m >= a + p ? g = r.right + 8 : u >= a + p ? g = r.left - a - 8 : g = Math.max(p, (h - a) / 2);
|
|
2989
|
+
const f = d - r.bottom, C = r.top;
|
|
2990
|
+
f >= l + p ? v = r.bottom + 8 : C >= l + p ? v = r.top - l - 8 : f > C ? (v = r.bottom + 8, v + l > d - p && (v = d - l - p)) : (v = r.top - l - 8, v < p && (v = p)), this.element.style.left = `${g}px`, this.element.style.top = `${v}px`;
|
|
2991
2991
|
}
|
|
2992
2992
|
close(t) {
|
|
2993
2993
|
var e;
|
|
@@ -3016,94 +3016,94 @@ class ie {
|
|
|
3016
3016
|
s.className = "color-picker-sliders-container embedded";
|
|
3017
3017
|
const n = document.createElement("button");
|
|
3018
3018
|
n.className = "color-picker-eyedropper", n.type = "button", n.innerHTML = Ct;
|
|
3019
|
-
const a = document.createElement("div");
|
|
3020
|
-
a.className = "color-picker-sliders-group";
|
|
3021
3019
|
const o = document.createElement("div");
|
|
3022
|
-
o.className = "color-picker-
|
|
3020
|
+
o.className = "color-picker-sliders-group";
|
|
3021
|
+
const a = document.createElement("div");
|
|
3022
|
+
a.className = "color-picker-hue embedded", this.hueSlider = a;
|
|
3023
3023
|
const l = document.createElement("div");
|
|
3024
|
-
l.className = "color-picker-hue-marker", this.hueMarker = l,
|
|
3024
|
+
l.className = "color-picker-hue-marker", this.hueMarker = l, a.appendChild(l);
|
|
3025
3025
|
const r = document.createElement("div");
|
|
3026
3026
|
r.className = "color-picker-opacity embedded", this.opacitySlider = r;
|
|
3027
|
-
const
|
|
3028
|
-
|
|
3029
|
-
const
|
|
3027
|
+
const h = document.createElement("div");
|
|
3028
|
+
h.className = "color-picker-opacity-marker", this.opacityMarker = h, r.appendChild(h), o.appendChild(a), o.appendChild(r), s.appendChild(n), s.appendChild(o);
|
|
3029
|
+
const d = ot((w) => {
|
|
3030
3030
|
const k = I(w);
|
|
3031
3031
|
k && k.type !== "solid" ? this.onColorChange(w, this.currentOpacity) : (this.setColor(w), this.onColorChange(this.currentColor, this.currentOpacity));
|
|
3032
3032
|
}, "all");
|
|
3033
|
-
this.recentSectionRefresh =
|
|
3034
|
-
const
|
|
3035
|
-
|
|
3033
|
+
this.recentSectionRefresh = d.refresh;
|
|
3034
|
+
const p = document.createElement("div");
|
|
3035
|
+
p.className = "color-picker-format-section embedded";
|
|
3036
3036
|
const g = document.createElement("select");
|
|
3037
3037
|
g.className = "color-picker-format-select", this.select = g;
|
|
3038
|
-
const
|
|
3039
|
-
|
|
3038
|
+
const v = document.createElement("option");
|
|
3039
|
+
v.value = "hex", v.textContent = "HEX";
|
|
3040
3040
|
const m = document.createElement("option");
|
|
3041
3041
|
m.value = "rgb", m.textContent = "RGB";
|
|
3042
3042
|
const u = document.createElement("option");
|
|
3043
|
-
u.value = "hsl", u.textContent = "HSL", g.appendChild(
|
|
3043
|
+
u.value = "hsl", u.textContent = "HSL", g.appendChild(v), g.appendChild(m), g.appendChild(u);
|
|
3044
3044
|
const f = document.createElement("input");
|
|
3045
3045
|
f.type = "text", f.className = "color-picker-color-input", this.input = f;
|
|
3046
|
-
const
|
|
3047
|
-
|
|
3046
|
+
const C = document.createElement("div");
|
|
3047
|
+
C.className = "color-picker-input-container";
|
|
3048
3048
|
const y = document.createElement("button");
|
|
3049
|
-
return y.className = "color-picker-copy-inside", y.textContent = "Copy",
|
|
3049
|
+
return y.className = "color-picker-copy-inside", y.textContent = "Copy", C.appendChild(f), C.appendChild(y), p.appendChild(g), p.appendChild(C), t.appendChild(e), t.appendChild(s), t.appendChild(p), t.appendChild(d.container), this.bind(e, a, r, f, g, y, n), t;
|
|
3050
3050
|
}
|
|
3051
|
-
bind(t, e, i, s, n,
|
|
3052
|
-
const l = (
|
|
3053
|
-
const
|
|
3054
|
-
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${
|
|
3055
|
-
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, f = W(u, g, 1 -
|
|
3051
|
+
bind(t, e, i, s, n, o, a) {
|
|
3052
|
+
const l = (d) => {
|
|
3053
|
+
const p = t.getBoundingClientRect(), g = Math.max(0, Math.min(1, (d.clientX - p.left) / p.width)), v = Math.max(0, Math.min(1, (d.clientY - p.top) / p.height));
|
|
3054
|
+
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${v * 100}%`;
|
|
3055
|
+
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, f = W(u, g, 1 - v);
|
|
3056
3056
|
this.currentColor = f, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
3057
|
-
}, r = (
|
|
3058
|
-
const
|
|
3057
|
+
}, r = (d) => {
|
|
3058
|
+
const p = e.getBoundingClientRect(), g = Math.max(0, Math.min(1, (d.clientX - p.left) / p.width));
|
|
3059
3059
|
this.hueMarker.style.left = `${g * 100}%`;
|
|
3060
|
-
const
|
|
3060
|
+
const v = g * 360, m = this.parsePercentage(this.colorMarker.style.left || "0%"), u = this.parsePercentage(this.colorMarker.style.top || "0%"), f = W(v, m, 1 - u);
|
|
3061
3061
|
this.currentColor = f, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
3062
|
-
linear-gradient(to right, #fff, hsl(${
|
|
3063
|
-
},
|
|
3064
|
-
const
|
|
3062
|
+
linear-gradient(to right, #fff, hsl(${v}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
3063
|
+
}, h = (d) => {
|
|
3064
|
+
const p = i.getBoundingClientRect(), g = Math.max(0, Math.min(1, (d.clientX - p.left) / p.width));
|
|
3065
3065
|
this.opacityMarker.style.left = `${g * 100}%`, this.currentOpacity = Math.round(g * 100), this.queueChange();
|
|
3066
3066
|
};
|
|
3067
|
-
t.addEventListener("mousedown", (
|
|
3068
|
-
|
|
3069
|
-
const
|
|
3070
|
-
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove",
|
|
3067
|
+
t.addEventListener("mousedown", (d) => {
|
|
3068
|
+
d.preventDefault(), this.isDragging = !0, l(d);
|
|
3069
|
+
const p = (v) => l(v), g = () => {
|
|
3070
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g), this.applyPendingExternal();
|
|
3071
3071
|
};
|
|
3072
|
-
document.addEventListener("mousemove",
|
|
3073
|
-
}), e.addEventListener("mousedown", (
|
|
3074
|
-
|
|
3075
|
-
const
|
|
3076
|
-
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove",
|
|
3072
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
|
|
3073
|
+
}), e.addEventListener("mousedown", (d) => {
|
|
3074
|
+
d.preventDefault(), this.isDragging = !0, r(d);
|
|
3075
|
+
const p = (v) => r(v), g = () => {
|
|
3076
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g), this.applyPendingExternal();
|
|
3077
3077
|
};
|
|
3078
|
-
document.addEventListener("mousemove",
|
|
3079
|
-
}), i.addEventListener("mousedown", (
|
|
3080
|
-
|
|
3081
|
-
const
|
|
3082
|
-
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove",
|
|
3078
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
|
|
3079
|
+
}), i.addEventListener("mousedown", (d) => {
|
|
3080
|
+
d.preventDefault(), this.isDragging = !0, h(d);
|
|
3081
|
+
const p = (v) => h(v), g = () => {
|
|
3082
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g), this.applyPendingExternal();
|
|
3083
3083
|
};
|
|
3084
|
-
document.addEventListener("mousemove",
|
|
3084
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
|
|
3085
3085
|
}), n.addEventListener("change", () => {
|
|
3086
3086
|
this.syncInput();
|
|
3087
3087
|
}), s.addEventListener("input", () => {
|
|
3088
3088
|
this.applyFromInput();
|
|
3089
3089
|
}), s.addEventListener("blur", () => {
|
|
3090
3090
|
this.syncInput();
|
|
3091
|
-
}), s.addEventListener("keydown", (
|
|
3092
|
-
|
|
3093
|
-
}),
|
|
3091
|
+
}), s.addEventListener("keydown", (d) => {
|
|
3092
|
+
d.key === "Enter" && (d.preventDefault(), this.syncInput(), s.blur());
|
|
3093
|
+
}), o.addEventListener("click", async () => {
|
|
3094
3094
|
try {
|
|
3095
3095
|
await navigator.clipboard.writeText(s.value);
|
|
3096
3096
|
} catch {
|
|
3097
3097
|
s.select(), document.execCommand("copy");
|
|
3098
3098
|
}
|
|
3099
|
-
}),
|
|
3099
|
+
}), a.addEventListener("click", async () => {
|
|
3100
3100
|
if (!("EyeDropper" in window)) {
|
|
3101
3101
|
alert("EyeDropper API is not supported in this browser.");
|
|
3102
3102
|
return;
|
|
3103
3103
|
}
|
|
3104
3104
|
try {
|
|
3105
|
-
const
|
|
3106
|
-
this.setColor(
|
|
3105
|
+
const d = new window.EyeDropper(), { sRGBHex: p } = await d.open();
|
|
3106
|
+
this.setColor(p), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
3107
3107
|
} catch {
|
|
3108
3108
|
}
|
|
3109
3109
|
});
|
|
@@ -3119,13 +3119,13 @@ class ie {
|
|
|
3119
3119
|
if (t === "hex")
|
|
3120
3120
|
this.input.value = this.currentColor;
|
|
3121
3121
|
else if (t === "rgb") {
|
|
3122
|
-
const { r: n, g:
|
|
3123
|
-
this.input.value = `rgb(${n}, ${
|
|
3122
|
+
const { r: n, g: o, b: a } = N(this.currentColor);
|
|
3123
|
+
this.input.value = `rgb(${n}, ${o}, ${a})`;
|
|
3124
3124
|
} else {
|
|
3125
|
-
const { hue: n, sat:
|
|
3125
|
+
const { hue: n, sat: o, lightness: a } = gt(e, i, s);
|
|
3126
3126
|
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
3127
|
-
|
|
3128
|
-
)}%, ${Math.round(
|
|
3127
|
+
o * 100
|
|
3128
|
+
)}%, ${Math.round(a * 100)}%)`;
|
|
3129
3129
|
}
|
|
3130
3130
|
}
|
|
3131
3131
|
applyFromInput() {
|
|
@@ -3136,12 +3136,12 @@ class ie {
|
|
|
3136
3136
|
else {
|
|
3137
3137
|
const i = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
3138
3138
|
if (i) {
|
|
3139
|
-
const s = parseInt(i[1], 10), n = parseInt(i[2], 10),
|
|
3140
|
-
s <= 255 && n <= 255 &&
|
|
3139
|
+
const s = parseInt(i[1], 10), n = parseInt(i[2], 10), o = parseInt(i[3], 10);
|
|
3140
|
+
s <= 255 && n <= 255 && o <= 255 && (e = "#" + [s, n, o].map((a) => a.toString(16).padStart(2, "0")).join(""));
|
|
3141
3141
|
} else {
|
|
3142
3142
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
3143
3143
|
if (s) {
|
|
3144
|
-
const n = parseInt(s[1], 10),
|
|
3144
|
+
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);
|
|
3145
3145
|
e = W(n, r, l);
|
|
3146
3146
|
}
|
|
3147
3147
|
}
|
|
@@ -3169,11 +3169,11 @@ class ie {
|
|
|
3169
3169
|
this.pendingExternalUpdate = void 0, this.initFromColor(t, e);
|
|
3170
3170
|
}
|
|
3171
3171
|
initFromColor(t, e) {
|
|
3172
|
-
var
|
|
3172
|
+
var a;
|
|
3173
3173
|
this.currentColor = t, this.currentOpacity = e;
|
|
3174
|
-
const { h: i, s, v: n } = R(t),
|
|
3175
|
-
this.hueMarker.style.left = `${
|
|
3176
|
-
linear-gradient(to right, #fff, hsl(${
|
|
3174
|
+
const { h: i, s, v: n } = R(t), o = i >= 360 ? i % 360 : i;
|
|
3175
|
+
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),
|
|
3176
|
+
linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`, this.opacityMarker.style.left = `${e}%`, this.updateOpacityBg(), this.syncInput(), (a = this.recentSectionRefresh) == null || a.call(this);
|
|
3177
3177
|
}
|
|
3178
3178
|
commitRecentColor() {
|
|
3179
3179
|
var t;
|
|
@@ -3202,16 +3202,16 @@ const $ = class $ extends x {
|
|
|
3202
3202
|
angle: "number",
|
|
3203
3203
|
stops: "text"
|
|
3204
3204
|
}, 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.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) => {
|
|
3205
|
-
var
|
|
3205
|
+
var p;
|
|
3206
3206
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
3207
|
-
const s = i.target, n = this.popoverEl.contains(s),
|
|
3207
|
+
const s = i.target, n = this.popoverEl.contains(s), o = (p = this.element) == null ? void 0 : p.contains(s), a = document.querySelectorAll(".custom-color-picker"), l = Array.from(a).some((g) => g.contains(s)), r = s.closest(
|
|
3208
3208
|
".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"
|
|
3209
|
-
), p = s.classList.contains(
|
|
3210
|
-
"color-picker-backdrop"
|
|
3211
3209
|
), h = s.classList.contains(
|
|
3210
|
+
"color-picker-backdrop"
|
|
3211
|
+
), d = s.classList.contains(
|
|
3212
3212
|
"gradient-popover-backdrop"
|
|
3213
3213
|
);
|
|
3214
|
-
!n && !
|
|
3214
|
+
!n && !o && !l && !r && !h && !d && this.closePopover();
|
|
3215
3215
|
}, this.handlePopoverKeydown = (i) => {
|
|
3216
3216
|
if (this.isPopoverOpen) {
|
|
3217
3217
|
if (i.key === "Escape") {
|
|
@@ -3349,8 +3349,8 @@ const $ = class $ extends x {
|
|
|
3349
3349
|
if (n === 100)
|
|
3350
3350
|
this.inputEl.value = s;
|
|
3351
3351
|
else {
|
|
3352
|
-
const
|
|
3353
|
-
this.inputEl.value = `${s}${
|
|
3352
|
+
const a = Math.round(n / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
3353
|
+
this.inputEl.value = `${s}${a}`;
|
|
3354
3354
|
}
|
|
3355
3355
|
}
|
|
3356
3356
|
} else
|
|
@@ -3392,14 +3392,14 @@ const $ = class $ extends x {
|
|
|
3392
3392
|
s.className = "gradient-editor";
|
|
3393
3393
|
const n = document.createElement("div");
|
|
3394
3394
|
n.className = "type-tabs-wrapper";
|
|
3395
|
-
const
|
|
3396
|
-
n.appendChild(
|
|
3397
|
-
const
|
|
3398
|
-
if (
|
|
3399
|
-
const l = e.children[0], r = e.children[1],
|
|
3400
|
-
this.currentMode =
|
|
3395
|
+
const o = this.createTypeTabs();
|
|
3396
|
+
n.appendChild(o), s.appendChild(n);
|
|
3397
|
+
const a = document.createElement("div");
|
|
3398
|
+
if (a.className = "gradient-editor-content", this.updatePopoverContent(a), s.appendChild(a), this.variant !== "global" && e) {
|
|
3399
|
+
const l = e.children[0], r = e.children[1], h = (d) => {
|
|
3400
|
+
this.currentMode = d, d === "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);
|
|
3401
3401
|
};
|
|
3402
|
-
l.addEventListener("click", () =>
|
|
3402
|
+
l.addEventListener("click", () => h("custom")), r.addEventListener("click", () => h("global")), this.isBoundToGlobal() ? (this.currentMode = "global", h("global")) : (this.currentMode = "custom", h("custom"));
|
|
3403
3403
|
}
|
|
3404
3404
|
this.popoverEl.appendChild(t), this.popoverEl.appendChild(s), document.body.appendChild(this.backdropEl), document.body.appendChild(this.popoverEl);
|
|
3405
3405
|
}
|
|
@@ -3411,9 +3411,9 @@ const $ = class $ extends x {
|
|
|
3411
3411
|
e.type = "button", e.className = `gradient-type-tab ${((s = this.value) == null ? void 0 : s.type) === "solid" ? "active" : ""}`, e.innerHTML = Qt, e.style.minWidth = "32px", e.addEventListener("click", () => this.switchType("solid"));
|
|
3412
3412
|
const i = document.createElement("button");
|
|
3413
3413
|
return i.type = "button", i.className = `gradient-type-tab ${((n = this.value) == null ? void 0 : n.type) !== "solid" ? "active" : ""}`, i.innerHTML = te, i.style.minWidth = "32px", i.addEventListener("click", () => {
|
|
3414
|
-
var
|
|
3415
|
-
const
|
|
3416
|
-
this.switchType(
|
|
3414
|
+
var a, l;
|
|
3415
|
+
const o = ((a = this.value) == null ? void 0 : a.type) === "solid" ? "linear" : ((l = this.value) == null ? void 0 : l.type) || "linear";
|
|
3416
|
+
this.switchType(o);
|
|
3417
3417
|
}), t.appendChild(e), t.appendChild(i), t;
|
|
3418
3418
|
}
|
|
3419
3419
|
switchType(t) {
|
|
@@ -3424,9 +3424,9 @@ const $ = class $ extends x {
|
|
|
3424
3424
|
{ color: "#a84b4b", position: 0, opacity: 100 },
|
|
3425
3425
|
{ color: "#786666", position: 100, opacity: 100 }
|
|
3426
3426
|
]), t !== "solid" && this.value.stops.length === 1) {
|
|
3427
|
-
const
|
|
3428
|
-
if (
|
|
3429
|
-
const l = this.resolveGlobalVarColor(
|
|
3427
|
+
const a = this.value.stops[0].color;
|
|
3428
|
+
if (a.startsWith("var(--")) {
|
|
3429
|
+
const l = this.resolveGlobalVarColor(a), r = I(l);
|
|
3430
3430
|
r && r.type !== "solid" && r.stops.length >= 2 ? (this.value.stops = r.stops, this.value.angle = r.angle, this.value.type = r.type) : (this.value.stops.push({
|
|
3431
3431
|
color: "#786666",
|
|
3432
3432
|
position: 100,
|
|
@@ -3441,16 +3441,16 @@ const $ = class $ extends x {
|
|
|
3441
3441
|
} else if (t !== "solid" && this.value.stops.length >= 2)
|
|
3442
3442
|
this.value.angle || (this.value.angle = 90);
|
|
3443
3443
|
else if (t === "solid" && e && i) {
|
|
3444
|
-
const
|
|
3444
|
+
const o = this.value.stops && this.value.stops[0] ? this.value.stops[0].opacity ?? 100 : 100;
|
|
3445
3445
|
this.value.stops = [
|
|
3446
|
-
{ color: i, position: 0, opacity:
|
|
3446
|
+
{ color: i, position: 0, opacity: o }
|
|
3447
3447
|
], this.value.angle = 0;
|
|
3448
3448
|
}
|
|
3449
3449
|
if (this.popoverEl) {
|
|
3450
|
-
const
|
|
3451
|
-
|
|
3452
|
-
const
|
|
3453
|
-
t === "solid" ?
|
|
3450
|
+
const o = this.popoverEl.querySelectorAll(".gradient-type-tab");
|
|
3451
|
+
o.forEach((r) => r.classList.remove("active"));
|
|
3452
|
+
const a = o[0], l = o[1];
|
|
3453
|
+
t === "solid" ? a == null || a.classList.add("active") : l == null || l.classList.add("active");
|
|
3454
3454
|
}
|
|
3455
3455
|
const s = (n = this.popoverEl) == null ? void 0 : n.querySelector(".gradient-editor-content");
|
|
3456
3456
|
s && this.updatePopoverContent(s), this.updateUI(), this.triggerChange();
|
|
@@ -3466,17 +3466,17 @@ const $ = class $ extends x {
|
|
|
3466
3466
|
}
|
|
3467
3467
|
renderGlobalColors(t) {
|
|
3468
3468
|
(!this.value || !this.value.stops || !this.value.stops.length) && (this.value || (this.value = this.defaultValue()), this.value.stops = [{ color: "#000000", position: 0, opacity: 100 }]);
|
|
3469
|
-
const e = this.value.stops[0], i = (
|
|
3470
|
-
|
|
3471
|
-
let
|
|
3469
|
+
const e = this.value.stops[0], i = (d) => {
|
|
3470
|
+
d.innerHTML = "";
|
|
3471
|
+
let p = {};
|
|
3472
3472
|
try {
|
|
3473
|
-
|
|
3473
|
+
p = x.GlobalVariables || {};
|
|
3474
3474
|
} catch (u) {
|
|
3475
3475
|
console.warn("Could not access Setting.GlobalVariables", u);
|
|
3476
3476
|
}
|
|
3477
|
-
if (!
|
|
3477
|
+
if (!p || Object.keys(p).length === 0) {
|
|
3478
3478
|
const u = document.createElement("div");
|
|
3479
|
-
u.textContent = "No global colors defined", u.style.fontSize = "12px", u.style.color = "#666", u.style.padding = "8px",
|
|
3479
|
+
u.textContent = "No global colors defined", u.style.fontSize = "12px", u.style.color = "#666", u.style.padding = "8px", d.appendChild(u);
|
|
3480
3480
|
return;
|
|
3481
3481
|
}
|
|
3482
3482
|
const g = [
|
|
@@ -3488,32 +3488,32 @@ const $ = class $ extends x {
|
|
|
3488
3488
|
title: "Text Color",
|
|
3489
3489
|
keys: ["text-dark", "text-light"]
|
|
3490
3490
|
}
|
|
3491
|
-
],
|
|
3491
|
+
], v = this.globalSearchQuery.toLowerCase();
|
|
3492
3492
|
let m;
|
|
3493
|
-
this.globalLayoutMode === "list" ? (m = document.createElement("div"), m.className = "global-colors-list") : (m = document.createElement("div"), m.className = "global-colors-grid"),
|
|
3494
|
-
const f = Object.entries(
|
|
3495
|
-
f.length !== 0 && f.forEach(([
|
|
3493
|
+
this.globalLayoutMode === "list" ? (m = document.createElement("div"), m.className = "global-colors-list") : (m = document.createElement("div"), m.className = "global-colors-grid"), d.appendChild(m), g.forEach((u) => {
|
|
3494
|
+
const f = Object.entries(p).filter(([C]) => !u.keys.includes(C) && u.title !== "Global Colors" ? !1 : u.keys.includes(C) && C.toLowerCase().includes(v));
|
|
3495
|
+
f.length !== 0 && f.forEach(([C, y]) => {
|
|
3496
3496
|
if (this.globalLayoutMode === "list") {
|
|
3497
3497
|
const w = document.createElement("div");
|
|
3498
3498
|
w.className = "global-color-row";
|
|
3499
3499
|
const k = document.createElement("div");
|
|
3500
3500
|
k.className = "global-color-circle";
|
|
3501
3501
|
const S = this.resolveGlobalVarColor(y);
|
|
3502
|
-
k.style.background = S, (this.linkedGlobalVariable === `var(--${
|
|
3502
|
+
k.style.background = S, (this.linkedGlobalVariable === `var(--${C})` || e.color === `var(--${C})`) && k.classList.add("selected");
|
|
3503
3503
|
const E = document.createElement("span");
|
|
3504
|
-
E.className = "global-color-label", E.textContent =
|
|
3504
|
+
E.className = "global-color-label", E.textContent = C.split("-").map((M) => M.charAt(0).toUpperCase() + M.slice(1)).join(" "), w.appendChild(k), w.appendChild(E), w.addEventListener("click", (M) => {
|
|
3505
3505
|
M.preventDefault();
|
|
3506
|
-
const B = `var(--${
|
|
3507
|
-
this.setValue(B), this.pendingSolidColor = B, i(
|
|
3506
|
+
const B = `var(--${C})`;
|
|
3507
|
+
this.setValue(B), this.pendingSolidColor = B, i(d);
|
|
3508
3508
|
}), m.appendChild(w);
|
|
3509
3509
|
} else {
|
|
3510
3510
|
const w = document.createElement("div");
|
|
3511
3511
|
w.className = "global-color-circle";
|
|
3512
3512
|
const k = this.resolveGlobalVarColor(y);
|
|
3513
|
-
w.style.background = k, w.title =
|
|
3513
|
+
w.style.background = k, w.title = C.split("-").map((b) => b.charAt(0).toUpperCase() + b.slice(1)).join(" "), (this.linkedGlobalVariable === `var(--${C})` || e.color === `var(--${C})`) && w.classList.add("selected"), w.addEventListener("click", (b) => {
|
|
3514
3514
|
b.preventDefault();
|
|
3515
|
-
const E = `var(--${
|
|
3516
|
-
this.setValue(E), this.pendingSolidColor = E, i(
|
|
3515
|
+
const E = `var(--${C})`;
|
|
3516
|
+
this.setValue(E), this.pendingSolidColor = E, i(d);
|
|
3517
3517
|
}), m.appendChild(w);
|
|
3518
3518
|
}
|
|
3519
3519
|
});
|
|
@@ -3522,21 +3522,21 @@ const $ = class $ extends x {
|
|
|
3522
3522
|
s.className = "global-controls-row";
|
|
3523
3523
|
const n = document.createElement("div");
|
|
3524
3524
|
n.className = "global-search-container";
|
|
3525
|
-
const
|
|
3526
|
-
|
|
3527
|
-
const
|
|
3528
|
-
|
|
3525
|
+
const o = document.createElement("span");
|
|
3526
|
+
o.className = "global-search-icon", o.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';
|
|
3527
|
+
const a = document.createElement("input");
|
|
3528
|
+
a.type = "text", a.className = "global-search-input", a.placeholder = "Search", a.value = this.globalSearchQuery;
|
|
3529
3529
|
const l = document.createElement("div");
|
|
3530
|
-
|
|
3531
|
-
this.globalSearchQuery =
|
|
3532
|
-
}), n.appendChild(
|
|
3530
|
+
a.addEventListener("input", (d) => {
|
|
3531
|
+
this.globalSearchQuery = d.target.value, i(l);
|
|
3532
|
+
}), n.appendChild(o), n.appendChild(a);
|
|
3533
3533
|
const r = document.createElement("button");
|
|
3534
3534
|
r.className = "global-layout-toggle", r.type = "button";
|
|
3535
|
-
const
|
|
3535
|
+
const h = () => {
|
|
3536
3536
|
r.innerHTML = this.globalLayoutMode === "list" ? '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>' : '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>';
|
|
3537
3537
|
};
|
|
3538
|
-
|
|
3539
|
-
this.globalLayoutMode = this.globalLayoutMode === "list" ? "grid" : "list",
|
|
3538
|
+
h(), r.addEventListener("click", () => {
|
|
3539
|
+
this.globalLayoutMode = this.globalLayoutMode === "list" ? "grid" : "list", h(), i(l);
|
|
3540
3540
|
}), s.appendChild(n), s.appendChild(r), t.appendChild(s), t.appendChild(l), i(l);
|
|
3541
3541
|
}
|
|
3542
3542
|
renderSolid(t) {
|
|
@@ -3546,9 +3546,9 @@ const $ = class $ extends x {
|
|
|
3546
3546
|
initialOpacity: e.opacity ?? 100,
|
|
3547
3547
|
onColorChange: (s, n) => {
|
|
3548
3548
|
if (this.clearGlobalBindingForCustomChange(), this.value) {
|
|
3549
|
-
const
|
|
3550
|
-
if (
|
|
3551
|
-
this.value =
|
|
3549
|
+
const o = I(s);
|
|
3550
|
+
if (o && o.type !== "solid") {
|
|
3551
|
+
this.value = o, this.switchType(o.type);
|
|
3552
3552
|
return;
|
|
3553
3553
|
}
|
|
3554
3554
|
this.value.stops[0].color = s, this.value.stops[0].opacity = n, this.updateUI(), this.triggerChange(), this.pendingSolidColor = s;
|
|
@@ -3561,17 +3561,17 @@ const $ = class $ extends x {
|
|
|
3561
3561
|
this.solidPicker = null;
|
|
3562
3562
|
let e = null;
|
|
3563
3563
|
{
|
|
3564
|
-
const
|
|
3565
|
-
|
|
3566
|
-
const
|
|
3567
|
-
|
|
3568
|
-
const
|
|
3569
|
-
|
|
3564
|
+
const h = document.createElement("div");
|
|
3565
|
+
h.className = "gradient-subtype-inline";
|
|
3566
|
+
const d = document.createElement("select");
|
|
3567
|
+
d.className = "gradient-subtype-select";
|
|
3568
|
+
const p = document.createElement("option");
|
|
3569
|
+
p.value = "linear", p.textContent = "Linear";
|
|
3570
3570
|
const g = document.createElement("option");
|
|
3571
|
-
g.value = "radial", g.textContent = "Radial",
|
|
3572
|
-
const
|
|
3573
|
-
|
|
3574
|
-
this.clearGlobalBindingForCustomChange(), this.switchType(
|
|
3571
|
+
g.value = "radial", g.textContent = "Radial", d.appendChild(p), d.appendChild(g), d.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°");
|
|
3572
|
+
const v = document.createElement("button");
|
|
3573
|
+
v.type = "button", v.className = "gradient-flip-btn", v.innerHTML = Kt, d.addEventListener("change", () => {
|
|
3574
|
+
this.clearGlobalBindingForCustomChange(), this.switchType(d.value === "radial" ? "radial" : "linear"), e && this.updateDegreeVisibility(e);
|
|
3575
3575
|
}), e.addEventListener("focus", (m) => {
|
|
3576
3576
|
const u = m.target;
|
|
3577
3577
|
u.value = u.value.replace(/[^0-9-]/g, ""), setTimeout(() => u.select(), 0);
|
|
@@ -3580,16 +3580,16 @@ const $ = class $ extends x {
|
|
|
3580
3580
|
const u = parseInt(m.target.value);
|
|
3581
3581
|
!Number.isNaN(u) && this.value && (this.value.angle = Math.max(0, Math.min(360, u)), this.debouncedPreviewUpdate());
|
|
3582
3582
|
}), e.addEventListener("blur", (m) => {
|
|
3583
|
-
var
|
|
3583
|
+
var C;
|
|
3584
3584
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
3585
3585
|
const u = m.target;
|
|
3586
3586
|
let f = parseInt(u.value);
|
|
3587
|
-
Number.isNaN(f) && (f = ((
|
|
3588
|
-
}),
|
|
3587
|
+
Number.isNaN(f) && (f = ((C = this.value) == null ? void 0 : C.angle) ?? 0), f = Math.max(0, Math.min(360, f)), this.value && (this.value.angle = f), u.value = `${f}°`, this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3588
|
+
}), v.addEventListener("click", () => {
|
|
3589
3589
|
this.clearGlobalBindingForCustomChange(), !(!this.value || !this.value.stops) && (this.value.stops.forEach((m) => {
|
|
3590
3590
|
m.position = 100 - m.position;
|
|
3591
3591
|
}), this.value.stops.sort((m, u) => m.position - u.position), this.updateGradientPreview(i), this.createHandles(s, i), this.updateStopsList(l), this.updateUI(), this.triggerChange());
|
|
3592
|
-
}),
|
|
3592
|
+
}), h.appendChild(d), h.appendChild(e), h.appendChild(v), t.appendChild(h), this.updateDegreeVisibility(e);
|
|
3593
3593
|
}
|
|
3594
3594
|
const i = document.createElement("div");
|
|
3595
3595
|
i.className = "gradient-preview", this.updateGradientPreview(i);
|
|
@@ -3597,19 +3597,19 @@ const $ = class $ extends x {
|
|
|
3597
3597
|
s.className = "gradient-handles", i.appendChild(s), t.appendChild(i), this.createHandles(s, i);
|
|
3598
3598
|
const n = document.createElement("div");
|
|
3599
3599
|
n.className = "gradient-stops-header";
|
|
3600
|
-
const
|
|
3601
|
-
|
|
3602
|
-
const
|
|
3603
|
-
|
|
3600
|
+
const o = document.createElement("span");
|
|
3601
|
+
o.textContent = "Stops";
|
|
3602
|
+
const a = document.createElement("button");
|
|
3603
|
+
a.type = "button", a.className = "gradient-add-stop", a.textContent = "+", n.appendChild(o), n.appendChild(a);
|
|
3604
3604
|
const l = document.createElement("div");
|
|
3605
3605
|
l.className = "gradient-stops", t.appendChild(n), t.appendChild(l), this.updateStopsList(l);
|
|
3606
|
-
const r = ot((
|
|
3607
|
-
const
|
|
3608
|
-
|
|
3606
|
+
const r = ot((h) => {
|
|
3607
|
+
const d = I(h);
|
|
3608
|
+
d && (this.clearGlobalBindingForCustomChange(), this.value = d, this.switchType(d.type), this.updateUI(), this.triggerChange());
|
|
3609
3609
|
}, "all");
|
|
3610
|
-
this.recentGradientRefresh = r.refresh, t.appendChild(r.container),
|
|
3611
|
-
var
|
|
3612
|
-
this.clearGlobalBindingForCustomChange(), this.addStop(), this.updateStopsList(l), this.updateGradientPreview(i), this.createHandles(s, i), this.updateUI(), ((
|
|
3610
|
+
this.recentGradientRefresh = r.refresh, t.appendChild(r.container), a.addEventListener("click", () => {
|
|
3611
|
+
var h;
|
|
3612
|
+
this.clearGlobalBindingForCustomChange(), this.addStop(), this.updateStopsList(l), this.updateGradientPreview(i), this.createHandles(s, i), this.updateUI(), ((h = document.activeElement) == null ? void 0 : h.tagName) !== "INPUT" && this.repositionPopover(), this.triggerChange();
|
|
3613
3613
|
});
|
|
3614
3614
|
}
|
|
3615
3615
|
updateDegreeVisibility(t) {
|
|
@@ -3638,36 +3638,36 @@ const $ = class $ extends x {
|
|
|
3638
3638
|
t.innerHTML = "", !(!this.value || this.value.type === "solid" || !this.value.stops) && this.value.stops.forEach((i, s) => {
|
|
3639
3639
|
const n = document.createElement("div");
|
|
3640
3640
|
n.className = "gstop-handle", n.style.left = `${Math.max(0, Math.min(100, i.position))}%`, n.style.top = "0%";
|
|
3641
|
-
const
|
|
3642
|
-
|
|
3643
|
-
const
|
|
3644
|
-
|
|
3641
|
+
const o = document.createElement("div");
|
|
3642
|
+
o.className = "gstop-chip";
|
|
3643
|
+
const a = this.resolveGlobalVarColor(i.color);
|
|
3644
|
+
o.style.backgroundColor = a, n.appendChild(o);
|
|
3645
3645
|
const l = new dt((u, f) => {
|
|
3646
|
-
this.clearGlobalBindingForCustomChange(), this.value && this.value.stops[s] && (this.value.stops[s].color = u, f !== void 0 && (this.value.stops[s].opacity = f),
|
|
3646
|
+
this.clearGlobalBindingForCustomChange(), this.value && this.value.stops[s] && (this.value.stops[s].color = u, f !== void 0 && (this.value.stops[s].opacity = f), o.style.backgroundColor = u, this.updateGradientPreview(), this.updateStopsList(), this.updateUI(), this.triggerChange());
|
|
3647
3647
|
}, "solid");
|
|
3648
|
-
let r = !1,
|
|
3648
|
+
let r = !1, h = !1, d = 0, p = 0;
|
|
3649
3649
|
const g = (u) => {
|
|
3650
|
-
r = !0,
|
|
3651
|
-
},
|
|
3650
|
+
r = !0, h = !1, d = u.clientX, p = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove", v), document.addEventListener("mouseup", m), u.preventDefault(), u.stopPropagation();
|
|
3651
|
+
}, v = (u) => {
|
|
3652
3652
|
if (!r || !this.value) return;
|
|
3653
|
-
const f = u.clientX -
|
|
3654
|
-
if (Math.abs(f) > 3 && (
|
|
3653
|
+
const f = u.clientX - d;
|
|
3654
|
+
if (Math.abs(f) > 3 && (h = !0), h) {
|
|
3655
3655
|
this.clearGlobalBindingForCustomChange();
|
|
3656
|
-
const
|
|
3657
|
-
let y =
|
|
3656
|
+
const C = e.getBoundingClientRect();
|
|
3657
|
+
let y = p + f / C.width * 100;
|
|
3658
3658
|
y = Math.max(0, Math.min(100, y)), this.value.stops[s].position = Math.round(y), n.style.left = `${y}%`, this.updateGradientPreview();
|
|
3659
3659
|
}
|
|
3660
3660
|
}, m = (u) => {
|
|
3661
3661
|
var f;
|
|
3662
3662
|
if (r)
|
|
3663
|
-
if (r = !1, n.classList.remove("selected"), document.removeEventListener("mousemove",
|
|
3664
|
-
this.value && (this.value.stops.sort((
|
|
3663
|
+
if (r = !1, n.classList.remove("selected"), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", m), h)
|
|
3664
|
+
this.value && (this.value.stops.sort((C, y) => C.position - y.position), this.createHandles(t, e), this.updateStopsList()), this.updateUI(), this.triggerChange();
|
|
3665
3665
|
else {
|
|
3666
3666
|
u.stopPropagation();
|
|
3667
|
-
const
|
|
3668
|
-
|
|
3669
|
-
const y = this.resolveGlobalVarColor(
|
|
3670
|
-
l.open(y,
|
|
3667
|
+
const C = (f = this.value) == null ? void 0 : f.stops[s];
|
|
3668
|
+
C && setTimeout(() => {
|
|
3669
|
+
const y = this.resolveGlobalVarColor(C.color);
|
|
3670
|
+
l.open(y, o, C.opacity ?? 100);
|
|
3671
3671
|
}, 0);
|
|
3672
3672
|
}
|
|
3673
3673
|
};
|
|
@@ -3679,37 +3679,37 @@ const $ = class $ extends x {
|
|
|
3679
3679
|
const e = t || ((i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-stops"));
|
|
3680
3680
|
!e || !this.value || this.value.type === "solid" || !this.value.stops || (e.innerHTML = "", this.value.stops.forEach((s, n) => {
|
|
3681
3681
|
var k, S;
|
|
3682
|
-
const a = document.createElement("div");
|
|
3683
|
-
a.className = "gstop-row";
|
|
3684
3682
|
const o = document.createElement("div");
|
|
3685
|
-
o.className = "gstop-
|
|
3683
|
+
o.className = "gstop-row";
|
|
3684
|
+
const a = document.createElement("div");
|
|
3685
|
+
a.className = "gstop-position-group";
|
|
3686
3686
|
const l = document.createElement("input");
|
|
3687
|
-
l.type = "text", l.className = "gstop-position-input", l.value = `${s.position}%`, l.style.width = "60px",
|
|
3687
|
+
l.type = "text", l.className = "gstop-position-input", l.value = `${s.position}%`, l.style.width = "60px", a.appendChild(l);
|
|
3688
3688
|
const r = document.createElement("div");
|
|
3689
3689
|
r.className = "gstop-color-container";
|
|
3690
|
-
const
|
|
3691
|
-
|
|
3692
|
-
const
|
|
3693
|
-
|
|
3690
|
+
const h = this.resolveGlobalVarColor(s.color), d = document.createElement("div");
|
|
3691
|
+
d.className = "gstop-color-preview", d.style.backgroundColor = h;
|
|
3692
|
+
const p = document.createElement("input");
|
|
3693
|
+
p.type = "text", p.className = "gstop-color-input", p.value = h.replace("#", "").toUpperCase();
|
|
3694
3694
|
const g = document.createElement("button");
|
|
3695
|
-
g.type = "button", g.className = "gstop-color-copy", g.textContent = "Copy", r.appendChild(
|
|
3696
|
-
const
|
|
3697
|
-
|
|
3695
|
+
g.type = "button", g.className = "gstop-color-copy", g.textContent = "Copy", r.appendChild(d), r.appendChild(p), r.appendChild(g);
|
|
3696
|
+
const v = document.createElement("button");
|
|
3697
|
+
v.type = "button", v.className = "gstop-del", v.innerHTML = Yt, v.disabled = (((S = (k = this.value) == null ? void 0 : k.stops) == null ? void 0 : S.length) || 0) <= 2, o.appendChild(a), o.appendChild(r), o.appendChild(v), e.appendChild(o);
|
|
3698
3698
|
const m = document.createElement("span");
|
|
3699
3699
|
m.className = "gstop-opacity-label", m.textContent = "Opacity";
|
|
3700
3700
|
const u = document.createElement("div");
|
|
3701
3701
|
u.className = "gstop-opacity-group";
|
|
3702
3702
|
const f = document.createElement("input");
|
|
3703
3703
|
f.type = "range", f.className = "gstop-opacity-slider", f.min = "0", f.max = "100", f.value = String(s.opacity ?? 100);
|
|
3704
|
-
const
|
|
3704
|
+
const C = N(h);
|
|
3705
3705
|
f.style.setProperty(
|
|
3706
3706
|
"--slider-color",
|
|
3707
|
-
`rgb(${
|
|
3707
|
+
`rgb(${C.r}, ${C.g}, ${C.b})`
|
|
3708
3708
|
);
|
|
3709
3709
|
const y = document.createElement("span");
|
|
3710
3710
|
y.className = "gstop-opacity-value", y.textContent = `${s.opacity ?? 100}%`, u.appendChild(f), u.appendChild(y);
|
|
3711
3711
|
const w = new dt((b, E) => {
|
|
3712
|
-
this.clearGlobalBindingForCustomChange(),
|
|
3712
|
+
this.clearGlobalBindingForCustomChange(), p.value = b.replace("#", "").toUpperCase(), d.style.backgroundColor = b, this.value.stops[n].color = b, E !== void 0 && (this.value.stops[n].opacity = E, f.value = String(E), y.textContent = `${E}%`);
|
|
3713
3713
|
const M = N(b);
|
|
3714
3714
|
f.style.setProperty(
|
|
3715
3715
|
"--slider-color",
|
|
@@ -3719,27 +3719,27 @@ const $ = class $ extends x {
|
|
|
3719
3719
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3720
3720
|
), this.updateUI(), this.triggerChange();
|
|
3721
3721
|
}, "solid");
|
|
3722
|
-
|
|
3722
|
+
p.addEventListener("click", (b) => {
|
|
3723
3723
|
b.preventDefault(), b.stopPropagation();
|
|
3724
3724
|
const E = this.resolveGlobalVarColor(s.color);
|
|
3725
|
-
w.open(E,
|
|
3726
|
-
}),
|
|
3725
|
+
w.open(E, p, s.opacity ?? 100);
|
|
3726
|
+
}), p.addEventListener("input", () => {
|
|
3727
3727
|
this.clearGlobalBindingForCustomChange();
|
|
3728
|
-
const b =
|
|
3728
|
+
const b = p.value.trim(), E = b.startsWith("#") ? b : `#${b}`;
|
|
3729
3729
|
if (/^#[0-9A-Fa-f]{6}$/.test(E)) {
|
|
3730
|
-
this.value.stops[n].color = E,
|
|
3730
|
+
this.value.stops[n].color = E, d.style.backgroundColor = E;
|
|
3731
3731
|
const M = N(E);
|
|
3732
3732
|
f.style.setProperty(
|
|
3733
3733
|
"--slider-color",
|
|
3734
3734
|
`rgb(${M.r}, ${M.g}, ${M.b})`
|
|
3735
3735
|
), this.debouncedPreviewUpdate();
|
|
3736
3736
|
}
|
|
3737
|
-
}),
|
|
3737
|
+
}), p.addEventListener("blur", () => {
|
|
3738
3738
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3739
3739
|
}), g.addEventListener("click", async (b) => {
|
|
3740
3740
|
b.stopPropagation();
|
|
3741
3741
|
try {
|
|
3742
|
-
await navigator.clipboard.writeText(`#${
|
|
3742
|
+
await navigator.clipboard.writeText(`#${p.value}`);
|
|
3743
3743
|
} catch {
|
|
3744
3744
|
}
|
|
3745
3745
|
}), l.addEventListener("focus", (b) => {
|
|
@@ -3765,7 +3765,7 @@ const $ = class $ extends x {
|
|
|
3765
3765
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
3766
3766
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3767
3767
|
), this.updateStopsList(), this.updateUI(), this.triggerChange();
|
|
3768
|
-
}),
|
|
3768
|
+
}), v.addEventListener("click", () => {
|
|
3769
3769
|
var b;
|
|
3770
3770
|
(this.value.stops.length || 0) <= 2 || (this.clearGlobalBindingForCustomChange(), this.value.stops.splice(n, 1), this.createHandles(
|
|
3771
3771
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
@@ -3782,32 +3782,32 @@ const $ = class $ extends x {
|
|
|
3782
3782
|
}
|
|
3783
3783
|
addStop() {
|
|
3784
3784
|
if (!this.value || this.value.type === "solid" || !this.value.stops) return;
|
|
3785
|
-
const t = this.value.stops.map((
|
|
3785
|
+
const t = this.value.stops.map((o) => o.position).sort((o, a) => o - a);
|
|
3786
3786
|
let e = 50, i = 0;
|
|
3787
|
-
for (let
|
|
3788
|
-
const
|
|
3789
|
-
|
|
3787
|
+
for (let o = 0; o < t.length - 1; o++) {
|
|
3788
|
+
const a = t[o + 1] - t[o];
|
|
3789
|
+
a > i && (i = a, e = t[o] + a / 2);
|
|
3790
3790
|
}
|
|
3791
3791
|
const s = this.value.stops.reduce(
|
|
3792
|
-
(
|
|
3792
|
+
(o, a) => Math.abs(a.position - e) < Math.abs(o.position - e) ? a : o
|
|
3793
3793
|
), n = {
|
|
3794
3794
|
position: Math.round(e),
|
|
3795
3795
|
color: s.color,
|
|
3796
3796
|
opacity: s.opacity ?? 100
|
|
3797
3797
|
};
|
|
3798
|
-
this.value.stops.push(n), this.value.stops.sort((
|
|
3798
|
+
this.value.stops.push(n), this.value.stops.sort((o, a) => o.position - a.position);
|
|
3799
3799
|
}
|
|
3800
3800
|
openPopover() {
|
|
3801
3801
|
if (this.popoverEl && ($.openInstance && $.openInstance !== this && $.openInstance.closePopover(), !this.isPopoverOpen)) {
|
|
3802
3802
|
if (this.isPopoverOpen = !0, $.openInstance = this, this.backdropEl && (this.backdropEl.style.display = "block", this.backdropEl.parentElement || document.body.appendChild(this.backdropEl)), this.popoverEl.style.display = "flex", this.refreshPopoverContent(), this.element) {
|
|
3803
3803
|
const t = this.element.getBoundingClientRect(), e = 306, i = window.innerWidth, s = window.innerHeight, n = 16;
|
|
3804
3804
|
this.popoverEl.style.position = "fixed", this.popoverEl.style.zIndex = "10000", this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3805
|
-
const
|
|
3806
|
-
let
|
|
3807
|
-
const r = i - t.right,
|
|
3808
|
-
r <
|
|
3809
|
-
const
|
|
3810
|
-
g >=
|
|
3805
|
+
const o = this.popoverEl.offsetHeight;
|
|
3806
|
+
let a = t.right + 8, l = t.top;
|
|
3807
|
+
const r = i - t.right, h = t.left, d = e + n;
|
|
3808
|
+
r < d && h > r + 100 && (a = t.left - e - 8);
|
|
3809
|
+
const p = s - t.bottom, g = t.top;
|
|
3810
|
+
g >= o + n ? l = t.top - o - 8 : p >= o + n ? l = t.bottom + 8 : g > p ? (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 };
|
|
3811
3811
|
}
|
|
3812
3812
|
setTimeout(
|
|
3813
3813
|
() => document.addEventListener("click", this.onBackgroundClick, !0),
|
|
@@ -3824,24 +3824,24 @@ const $ = class $ extends x {
|
|
|
3824
3824
|
}
|
|
3825
3825
|
requestAnimationFrame(() => {
|
|
3826
3826
|
if (!this.popoverEl || !this.element) return;
|
|
3827
|
-
const e = this.element.getBoundingClientRect(), i = 306, s = window.innerWidth, n = window.innerHeight,
|
|
3827
|
+
const e = this.element.getBoundingClientRect(), i = 306, s = window.innerWidth, n = window.innerHeight, o = 16;
|
|
3828
3828
|
this.popoverEl.style.left, this.popoverEl.style.top, this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3829
|
-
const
|
|
3829
|
+
const a = this.popoverEl.offsetHeight;
|
|
3830
3830
|
let l = e.right + 8, r = e.top;
|
|
3831
|
-
const
|
|
3832
|
-
|
|
3833
|
-
const g = n - e.bottom,
|
|
3834
|
-
|
|
3831
|
+
const h = s - e.right, d = e.left, p = i + o;
|
|
3832
|
+
h < p && d > h + 100 && (l = e.left - i - 8);
|
|
3833
|
+
const g = n - e.bottom, v = e.top;
|
|
3834
|
+
v >= a + o ? r = e.top - a - 8 : g >= a + o ? r = e.bottom + 8 : v > 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`;
|
|
3835
3835
|
});
|
|
3836
3836
|
}
|
|
3837
3837
|
}
|
|
3838
3838
|
refreshPopoverContent() {
|
|
3839
|
-
var n,
|
|
3839
|
+
var n, o;
|
|
3840
3840
|
if (!this.popoverEl) return;
|
|
3841
3841
|
const t = this.popoverEl.querySelectorAll(".gradient-type-tab");
|
|
3842
|
-
t.forEach((
|
|
3842
|
+
t.forEach((a) => a.classList.remove("active"));
|
|
3843
3843
|
const e = t[0], i = t[1];
|
|
3844
|
-
((n = this.value) == null ? void 0 : n.type) === "solid" ? e.classList.add("active") : (i.classList.add("active"), (
|
|
3844
|
+
((n = this.value) == null ? void 0 : n.type) === "solid" ? e.classList.add("active") : (i.classList.add("active"), (o = this.recentGradientRefresh) == null || o.call(this)), this.popoverEl.offsetHeight;
|
|
3845
3845
|
const s = this.popoverEl.querySelector(".gradient-editor-content");
|
|
3846
3846
|
s && this.updatePopoverContent(s);
|
|
3847
3847
|
}
|
|
@@ -4026,8 +4026,8 @@ class ke extends T {
|
|
|
4026
4026
|
});
|
|
4027
4027
|
}
|
|
4028
4028
|
getCssCode() {
|
|
4029
|
-
var
|
|
4030
|
-
const t = this.settings.color.getValue() ?? "#000000", e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((
|
|
4029
|
+
var o;
|
|
4030
|
+
const t = this.settings.color.getValue() ?? "#000000", e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((o = this.settings.align) == null ? void 0 : o.value) ?? "left";
|
|
4031
4031
|
return `
|
|
4032
4032
|
color: ${t};
|
|
4033
4033
|
font-family: ${e};
|
|
@@ -4037,8 +4037,8 @@ class ke extends T {
|
|
|
4037
4037
|
`;
|
|
4038
4038
|
}
|
|
4039
4039
|
getTextGradientCss() {
|
|
4040
|
-
var
|
|
4041
|
-
const t = this.settings.color.getCSSForText(), e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((
|
|
4040
|
+
var a;
|
|
4041
|
+
const t = this.settings.color.getCSSForText(), e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((a = this.settings.align) == null ? void 0 : a.value) ?? "left";
|
|
4042
4042
|
return `
|
|
4043
4043
|
${Object.entries(t).map(([l, r]) => `${l}: ${r};`).join(`
|
|
4044
4044
|
`)}
|
|
@@ -4057,11 +4057,11 @@ class q extends x {
|
|
|
4057
4057
|
}), this.inputType = "number", this.value = t.default !== void 0 ? t.default : "auto";
|
|
4058
4058
|
}
|
|
4059
4059
|
draw() {
|
|
4060
|
-
const t = this.value === "auto" ? "text" : "number", e = (
|
|
4061
|
-
this.value !== "auto" && (this.props.minValue !== void 0 && (
|
|
4060
|
+
const t = this.value === "auto" ? "text" : "number", e = (a) => {
|
|
4061
|
+
this.value !== "auto" && (this.props.minValue !== void 0 && (a.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (a.max = String(this.props.maxValue)), this.props.className && a.classList.add(this.props.className), a.addEventListener("input", () => {
|
|
4062
4062
|
const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
4063
|
-
let
|
|
4064
|
-
|
|
4063
|
+
let h = Number(a.value);
|
|
4064
|
+
h < l && (h = l), h > r && (h = r), a.value = String(h);
|
|
4065
4065
|
}));
|
|
4066
4066
|
}, i = this.createInput({
|
|
4067
4067
|
value: this.value,
|
|
@@ -4082,9 +4082,9 @@ class q extends x {
|
|
|
4082
4082
|
s && (s.style.paddingRight = "35px");
|
|
4083
4083
|
const n = document.createElement("span");
|
|
4084
4084
|
n.className = "suffix-label", n.textContent = this.props.suffix, i.appendChild(n);
|
|
4085
|
-
const
|
|
4086
|
-
return
|
|
4087
|
-
const l =
|
|
4085
|
+
const o = i.querySelector("input");
|
|
4086
|
+
return o && (o.oninput = (a) => {
|
|
4087
|
+
const l = a.target.value.trim();
|
|
4088
4088
|
if (l.toLowerCase() === "auto")
|
|
4089
4089
|
this.value = "auto";
|
|
4090
4090
|
else {
|
|
@@ -4169,10 +4169,10 @@ class Se extends T {
|
|
|
4169
4169
|
draw() {
|
|
4170
4170
|
const t = super.draw(), e = t.querySelector(".setting-group-content");
|
|
4171
4171
|
if (!e) return t;
|
|
4172
|
-
const i = Array.from(e.children), [s, n,
|
|
4172
|
+
const i = Array.from(e.children), [s, n, o] = i;
|
|
4173
4173
|
e.innerHTML = "", e.appendChild(s), e.appendChild(n);
|
|
4174
|
-
const
|
|
4175
|
-
return
|
|
4174
|
+
const a = document.createElement("div");
|
|
4175
|
+
return a.className = "bgset-or-label", a.textContent = "OR", e.appendChild(a), e.appendChild(o), t;
|
|
4176
4176
|
}
|
|
4177
4177
|
getCssCode() {
|
|
4178
4178
|
const t = this.settings.backgroundImage.value || "", e = this.settings.opacity.value ?? 100, i = this.settings.backgroundColor.value || "#000000";
|