builder-settings-types 0.0.312 → 0.0.313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder-settings-types.cjs.js +29 -29
- package/dist/builder-settings-types.es.js +710 -680
- package/package.json +1 -1
|
@@ -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 o = document.createElement("div");
|
|
185
|
+
if (o.className = "icon-container", t.icon) {
|
|
186
186
|
const l = this.createIcon(t.icon, t.iconClassName);
|
|
187
|
-
|
|
187
|
+
o.appendChild(l);
|
|
188
188
|
}
|
|
189
189
|
if (t.title) {
|
|
190
190
|
const l = this.createLabel(t.title, t.labelClassName);
|
|
191
|
-
|
|
191
|
+
o.appendChild(l);
|
|
192
192
|
}
|
|
193
|
-
e.appendChild(
|
|
193
|
+
e.appendChild(o);
|
|
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 = (o) => {
|
|
200
|
+
const l = o.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
|
+
}, a = (o) => {
|
|
226
|
+
o.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", a), 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 a = 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 o of a) {
|
|
330
|
+
const l = o.id, r = o.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
|
+
o.remove();
|
|
335
335
|
break;
|
|
336
336
|
}
|
|
337
337
|
if (r && "id" in e && typeof e.id == "string" && r === e.id) {
|
|
338
|
-
|
|
338
|
+
o.remove();
|
|
339
339
|
break;
|
|
340
340
|
}
|
|
341
341
|
}
|
|
@@ -349,37 +349,37 @@ const Y = class Y {
|
|
|
349
349
|
this.elementRef;
|
|
350
350
|
}
|
|
351
351
|
updateSettings(t) {
|
|
352
|
-
var
|
|
352
|
+
var a;
|
|
353
353
|
const e = new Set(Object.keys(this.settings)), i = Object.keys(t), s = {};
|
|
354
|
-
i.forEach((
|
|
355
|
-
const l = this.settings[
|
|
356
|
-
l && (L(l) ? s[
|
|
357
|
-
}), e.forEach((
|
|
358
|
-
i.includes(
|
|
359
|
-
}), i.forEach((
|
|
354
|
+
i.forEach((o) => {
|
|
355
|
+
const l = this.settings[o];
|
|
356
|
+
l && (L(l) ? s[o] = l.getValues() : A(l) ? s[o] = l.value : typeof l.getValues == "function" ? s[o] = l.getValues() : l.value !== void 0 && (s[o] = l.value));
|
|
357
|
+
}), e.forEach((o) => {
|
|
358
|
+
i.includes(o) || this.removeSetting(o);
|
|
359
|
+
}), i.forEach((o) => {
|
|
360
360
|
var p;
|
|
361
|
-
const l = t[
|
|
362
|
-
if (r !== l && (r && this.removeSetting(
|
|
363
|
-
const h = s[
|
|
361
|
+
const l = t[o], r = this.settings[o];
|
|
362
|
+
if (r !== l && (r && this.removeSetting(o), this.addSetting(o, l), o in s)) {
|
|
363
|
+
const h = s[o];
|
|
364
364
|
try {
|
|
365
365
|
L(l) ? l.setValue(
|
|
366
366
|
h
|
|
367
367
|
) : A(l) ? (p = l.setValue) == null || p.call(l, h) : l.setValue && l.setValue(h);
|
|
368
368
|
} catch (d) {
|
|
369
|
-
console.warn(`Could not preserve value for setting ${
|
|
369
|
+
console.warn(`Could not preserve value for setting ${o}:`, d);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
}), this.settings = t, this.propagateNestingLevel(), this.propagateDataPropsPath();
|
|
373
373
|
const n = this.getValues();
|
|
374
|
-
this.initialValues = n, (
|
|
374
|
+
this.initialValues = n, (a = this.onChange) == null || a.call(this, n);
|
|
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 a = String(s);
|
|
380
|
+
typeof n.clone == "function" ? t[a] = n.clone() : (console.warn(
|
|
381
|
+
`Setting with key '${a}' does not have a clone method. Copying reference.`
|
|
382
|
+
), t[a] = 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 a = this.getValues();
|
|
446
|
+
this.initialValues = a, t(a);
|
|
447
447
|
}), this.changeHandlers.add(() => t(this.getValues()));
|
|
448
448
|
else if (A(s)) {
|
|
449
|
-
const
|
|
450
|
-
this.changeHandlers.add(
|
|
449
|
+
const a = () => e();
|
|
450
|
+
this.changeHandlers.add(a), s.setOnChange(a);
|
|
451
451
|
} else {
|
|
452
|
-
const
|
|
453
|
-
this.changeHandlers.add(
|
|
452
|
+
const a = () => e();
|
|
453
|
+
this.changeHandlers.add(a), (n = s.setOnChange) == null || n.call(s, a);
|
|
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 a = i.slice(this.addItemCfg.keyPrefix.length), o = Number(a);
|
|
469
|
+
if (Number.isFinite(o)) {
|
|
470
|
+
const l = this.addItemCfg.createItem(o);
|
|
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 a = this.elementRef.querySelector(
|
|
494
494
|
".setting-group-content"
|
|
495
495
|
);
|
|
496
|
-
if (
|
|
496
|
+
if (a) {
|
|
497
497
|
L(e) && typeof e.setNestingLevel == "function" && e.setNestingLevel(this.nestingLevel + 1);
|
|
498
|
-
const
|
|
498
|
+
const o = e.draw(), l = this.deleteItemCfg ?? this.addItemCfg;
|
|
499
499
|
if (l) {
|
|
500
500
|
const h = l.keyPrefix ?? ((s = this.addItemCfg) == null ? void 0 : s.keyPrefix);
|
|
501
|
-
h && t.startsWith(h) && this.addDeleteButtonToElement(
|
|
501
|
+
h && t.startsWith(h) && this.addDeleteButtonToElement(o, t);
|
|
502
502
|
}
|
|
503
|
-
const r =
|
|
504
|
-
r ?
|
|
505
|
-
const p =
|
|
506
|
-
|
|
503
|
+
const r = a.querySelector(".sg-add-button-bottom");
|
|
504
|
+
r ? a.insertBefore(o, r) : a.appendChild(o), at.trackElement(o), _(o, this.nestingLevel + 1), tt(o, this.nestingLevel + 1);
|
|
505
|
+
const p = o.style.display;
|
|
506
|
+
o.style.display = "none", o.offsetHeight, o.style.display = p, this.updateNestingStyles();
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
const i = this.getValues();
|
|
@@ -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 a = document.createElement("button");
|
|
534
|
+
a.type = "button", a.className = "sg-delete-button", i ? i.deleteItemCfg : this.deleteItemCfg ?? this.addItemCfg, a.title = "Delete", a.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 o = `
|
|
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
|
-
}),
|
|
553
|
+
a.innerHTML = o, a.addEventListener("mouseenter", () => {
|
|
554
|
+
a.style.backgroundColor = "#fef2f2";
|
|
555
|
+
}), a.addEventListener("mouseleave", () => {
|
|
556
|
+
a.style.backgroundColor = "transparent";
|
|
557
|
+
}), a.addEventListener("click", (r) => {
|
|
558
558
|
r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((p) => {
|
|
559
559
|
p && (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(a, l) : n.appendChild(a);
|
|
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 a = document.createElement("div");
|
|
607
|
+
a.style.cssText = `
|
|
608
608
|
display: flex;
|
|
609
609
|
gap: 12px;
|
|
610
610
|
justify-content: flex-end;
|
|
611
611
|
`;
|
|
612
|
-
const
|
|
613
|
-
|
|
612
|
+
const o = document.createElement("button");
|
|
613
|
+
o.textContent = "Cancel", o.type = "button", o.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
|
+
`, o.addEventListener("mouseenter", () => {
|
|
636
|
+
o.style.backgroundColor = "#f9fafb", o.style.borderColor = "#9ca3af";
|
|
637
|
+
}), o.addEventListener("mouseleave", () => {
|
|
638
|
+
o.style.backgroundColor = "white", o.style.borderColor = "#d1d5db";
|
|
639
639
|
}), l.addEventListener("mouseenter", () => {
|
|
640
640
|
l.style.backgroundColor = "#dc2626";
|
|
641
641
|
}), l.addEventListener("mouseleave", () => {
|
|
@@ -646,7 +646,7 @@ const Y = class Y {
|
|
|
646
646
|
e.parentNode && e.parentNode.removeChild(e);
|
|
647
647
|
}, 200);
|
|
648
648
|
};
|
|
649
|
-
|
|
649
|
+
o.addEventListener("click", () => {
|
|
650
650
|
r(), t(!1);
|
|
651
651
|
}), l.addEventListener("click", () => {
|
|
652
652
|
r(), t(!0);
|
|
@@ -656,7 +656,7 @@ const Y = class Y {
|
|
|
656
656
|
const p = (h) => {
|
|
657
657
|
h.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", p));
|
|
658
658
|
};
|
|
659
|
-
document.addEventListener("keydown", p),
|
|
659
|
+
document.addEventListener("keydown", p), a.appendChild(o), a.appendChild(l), i.appendChild(s), i.appendChild(n), i.appendChild(a), 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 a = t[n], o = e[n];
|
|
678
|
+
JSON.stringify(a) !== JSON.stringify(o) && (i[n] = { from: a, to: o });
|
|
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 a = n.getValuesForJson();
|
|
713
|
+
a !== null && (i[s] = a);
|
|
714
714
|
} else {
|
|
715
|
-
const
|
|
716
|
-
|
|
715
|
+
const a = n;
|
|
716
|
+
a.includeGetJson !== !1 && (i[s] = a.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,16 +764,16 @@ 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 a = document.createElement("span");
|
|
768
|
+
a.className = "setting-group-arrow", a.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 && a.classList.add("rotated"), n.appendChild(a);
|
|
773
|
+
const o = document.createElement("div");
|
|
774
|
+
o.className = "setting-group-content", this.isCollapsed && (o.classList.add("collapsed"), e.classList.add("collapsed-view"), a.classList.add("rotated"), t.classList.add("collapsed")), this.isMain && o.classList.add("main-content");
|
|
775
775
|
const l = () => {
|
|
776
|
-
this.isCollapsed = !this.isCollapsed,
|
|
776
|
+
this.isCollapsed = !this.isCollapsed, o.classList.toggle("collapsed"), e.classList.toggle("collapsed-view"), a.classList.toggle("rotated"), t.classList.toggle("collapsed", this.isCollapsed), e.setAttribute(
|
|
777
777
|
"aria-expanded",
|
|
778
778
|
(!this.isCollapsed).toString()
|
|
779
779
|
);
|
|
@@ -790,11 +790,11 @@ const Y = class Y {
|
|
|
790
790
|
d,
|
|
791
791
|
p,
|
|
792
792
|
h
|
|
793
|
-
),
|
|
793
|
+
), o.appendChild(d);
|
|
794
794
|
}
|
|
795
795
|
} else {
|
|
796
796
|
const p = document.createElement("div");
|
|
797
|
-
p.className = "setting-group-empty", p.textContent = "No settings in this group",
|
|
797
|
+
p.className = "setting-group-empty", p.textContent = "No settings in this group", o.appendChild(p);
|
|
798
798
|
}
|
|
799
799
|
if (this.addItemCfg) {
|
|
800
800
|
const p = document.createElement("button");
|
|
@@ -807,14 +807,14 @@ const Y = class Y {
|
|
|
807
807
|
</svg>`;
|
|
808
808
|
p.innerHTML = `${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, p.addEventListener("click", (d) => {
|
|
809
809
|
d.stopPropagation(), d.preventDefault();
|
|
810
|
-
const
|
|
811
|
-
if (lt(
|
|
812
|
-
const m = `${this.addItemCfg.keyPrefix}${
|
|
813
|
-
this.addSetting(m,
|
|
810
|
+
const g = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), C = this.addItemCfg.createItem(g);
|
|
811
|
+
if (lt(C)) {
|
|
812
|
+
const m = `${this.addItemCfg.keyPrefix}${g}`;
|
|
813
|
+
this.addSetting(m, C);
|
|
814
814
|
}
|
|
815
|
-
}),
|
|
815
|
+
}), o.appendChild(p);
|
|
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(o), 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
|
+
(o) => n.includes(o)
|
|
849
849
|
) && n.length === 1) {
|
|
850
|
-
const
|
|
851
|
-
i = e[
|
|
850
|
+
const o = n[0];
|
|
851
|
+
i = e[o];
|
|
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 a = document.createElement("div");
|
|
909
|
+
if (a.className = "tab-content", this.contentContainers = {}, Object.keys(this.settings).forEach((o, l) => {
|
|
910
910
|
const r = document.createElement("button");
|
|
911
|
-
r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id",
|
|
911
|
+
r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id", o), r.textContent = o, r.addEventListener("click", () => this.switchToTab(o)), n.appendChild(r);
|
|
912
912
|
const p = document.createElement("div");
|
|
913
|
-
p.className = "tab-panel", this.contentContainers[
|
|
914
|
-
const h = this.settings[
|
|
913
|
+
p.className = "tab-panel", this.contentContainers[o] = p;
|
|
914
|
+
const h = this.settings[o];
|
|
915
915
|
h && (L(h) && typeof h.setNestingLevel == "function" && h.setNestingLevel(this.getNestingLevel() + 1), p.appendChild(
|
|
916
916
|
h.draw()
|
|
917
|
-
)),
|
|
918
|
-
}), e.appendChild(i), e.appendChild(n), e.appendChild(
|
|
919
|
-
const
|
|
920
|
-
this.activeTabId =
|
|
917
|
+
)), a.appendChild(p), l === 0 && !this.activeTabId && (this.activeTabId = o);
|
|
918
|
+
}), e.appendChild(i), e.appendChild(n), e.appendChild(a), !this.activeTabId) {
|
|
919
|
+
const o = Object.keys(this.settings)[0];
|
|
920
|
+
this.activeTabId = o || "";
|
|
921
921
|
}
|
|
922
922
|
return this.updateTabUI(), t;
|
|
923
923
|
}
|
|
@@ -949,17 +949,17 @@ class Mt extends x {
|
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
951
|
const St = "<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";
|
|
952
|
-
class
|
|
952
|
+
class V extends Mt {
|
|
953
953
|
constructor(t) {
|
|
954
954
|
super({
|
|
955
955
|
...t,
|
|
956
956
|
icon: t.icon || St,
|
|
957
957
|
title: t.title || "Color",
|
|
958
|
-
default: t.default ?
|
|
958
|
+
default: t.default ? V.normalizeColorValue(t.default) : "#000000"
|
|
959
959
|
}), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.detectChange = t.detectChange;
|
|
960
960
|
}
|
|
961
961
|
static normalizeColorValue(t) {
|
|
962
|
-
return t.startsWith("var(--") ? t : t.startsWith("#") ?
|
|
962
|
+
return t.startsWith("var(--") ? t : t.startsWith("#") ? V.normalizeHexValue(t) : t.includes(",") ? V.rgbToHexStatic(t) : V.normalizeHexValue(t);
|
|
963
963
|
}
|
|
964
964
|
static normalizeHexValue(t) {
|
|
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");
|
|
@@ -968,11 +968,11 @@ class I extends Mt {
|
|
|
968
968
|
const e = t.split(",").map((p) => parseInt(p.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,
|
|
971
|
+
const [i, s, n] = e, a = Math.max(0, Math.min(255, i)), o = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (p) => {
|
|
972
972
|
const h = p.toString(16);
|
|
973
973
|
return h.length === 1 ? "0" + h : h;
|
|
974
974
|
};
|
|
975
|
-
return `#${r(
|
|
975
|
+
return `#${r(a)}${r(o)}${r(l)}`;
|
|
976
976
|
}
|
|
977
977
|
setValue(t) {
|
|
978
978
|
if (t === void 0) {
|
|
@@ -980,7 +980,7 @@ class I extends Mt {
|
|
|
980
980
|
return;
|
|
981
981
|
}
|
|
982
982
|
if (typeof t == "string") {
|
|
983
|
-
const e =
|
|
983
|
+
const e = V.normalizeColorValue(t);
|
|
984
984
|
this.value = e, this.colorInputEl && (this.colorInputEl.value = e), this.textInputEl && (this.textInputEl.value = e), this.onChange && this.onChange(e), this.props.detectChange && this.props.detectChange(e);
|
|
985
985
|
} else
|
|
986
986
|
this.value = "#000000", this.colorInputEl && (this.colorInputEl.value = "#000000"), this.textInputEl && (this.textInputEl.value = "#000000"), this.onChange && this.onChange("#000000"), this.props.detectChange && this.props.detectChange("#000000");
|
|
@@ -993,16 +993,16 @@ class I extends Mt {
|
|
|
993
993
|
draw() {
|
|
994
994
|
const t = document.createElement("div");
|
|
995
995
|
if (t.className = "color-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
996
|
-
const
|
|
997
|
-
if (
|
|
998
|
-
const
|
|
999
|
-
|
|
996
|
+
const m = document.createElement("div");
|
|
997
|
+
if (m.className = "icon-container", this.props.icon) {
|
|
998
|
+
const u = document.createElement("span");
|
|
999
|
+
u.className = "input-icon", u.innerHTML = this.props.icon, m.appendChild(u);
|
|
1000
1000
|
}
|
|
1001
1001
|
if (this.props.title) {
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1002
|
+
const u = document.createElement("span");
|
|
1003
|
+
u.className = "input-label", u.textContent = this.props.title, m.appendChild(u);
|
|
1004
1004
|
}
|
|
1005
|
-
t.appendChild(
|
|
1005
|
+
t.appendChild(m);
|
|
1006
1006
|
}
|
|
1007
1007
|
const e = document.createElement("div");
|
|
1008
1008
|
e.className = "color-input-wrapper";
|
|
@@ -1012,49 +1012,49 @@ class I 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 o = document.createElement("div");
|
|
1016
|
-
o.className = "color-content-solid";
|
|
1017
1015
|
const a = document.createElement("div");
|
|
1018
|
-
a.className = "color-content-
|
|
1016
|
+
a.className = "color-content-solid";
|
|
1017
|
+
const o = document.createElement("div");
|
|
1018
|
+
o.className = "color-content-global", o.style.display = "none", o.style.display = "grid", o.style.gridTemplateColumns = "repeat(auto-fill, minmax(30px, 1fr))", o.style.gap = "8px";
|
|
1019
1019
|
const l = () => {
|
|
1020
1020
|
try {
|
|
1021
|
-
if (console.log("ColorSetting: renderGlobalOptions called"),
|
|
1021
|
+
if (console.log("ColorSetting: renderGlobalOptions called"), o.innerHTML = "", !x) {
|
|
1022
1022
|
console.error("ColorSetting: Setting class is undefined");
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1023
|
+
const u = document.createElement("div");
|
|
1024
|
+
u.textContent = "Error: System error (Setting undefined)", o.appendChild(u);
|
|
1025
1025
|
return;
|
|
1026
1026
|
}
|
|
1027
|
-
const
|
|
1028
|
-
if (console.log("ColorSetting: GlobalVariables:",
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1027
|
+
const m = x.GlobalVariables || {};
|
|
1028
|
+
if (console.log("ColorSetting: GlobalVariables:", m), !m || Object.keys(m).length === 0) {
|
|
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", o.appendChild(u);
|
|
1031
1031
|
return;
|
|
1032
1032
|
}
|
|
1033
|
-
Object.entries(
|
|
1033
|
+
Object.entries(m).forEach(([u, f]) => {
|
|
1034
1034
|
const v = document.createElement("button");
|
|
1035
|
-
v.className = "global-color-btn", v.title =
|
|
1036
|
-
var
|
|
1037
|
-
|
|
1038
|
-
const
|
|
1039
|
-
this.value =
|
|
1040
|
-
|
|
1035
|
+
v.className = "global-color-btn", v.title = u, v.style.width = "30px", v.style.height = "30px", v.style.borderRadius = "50%", v.style.border = "1px solid #ddd", v.style.backgroundColor = f, v.style.cursor = "pointer", this.value === `var(--${u})` && (v.style.border = "2px solid #2196f3"), v.addEventListener("click", (y) => {
|
|
1036
|
+
var k, S;
|
|
1037
|
+
y.preventDefault();
|
|
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(o.children).forEach((b) => {
|
|
1040
|
+
b.style.border = "1px solid #ddd";
|
|
1041
1041
|
}), v.style.border = "2px solid #2196f3", h.style.backgroundColor = f;
|
|
1042
|
-
}),
|
|
1042
|
+
}), o.appendChild(v);
|
|
1043
1043
|
});
|
|
1044
|
-
} catch (
|
|
1045
|
-
console.error("ColorSetting: Error in renderGlobalOptions",
|
|
1044
|
+
} catch (m) {
|
|
1045
|
+
console.error("ColorSetting: Error in renderGlobalOptions", m), o.innerHTML = "Error loading global options";
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|
|
1048
|
-
l(), s.addEventListener("click", (
|
|
1049
|
-
|
|
1050
|
-
}), n.addEventListener("click", (
|
|
1051
|
-
|
|
1048
|
+
l(), s.addEventListener("click", (m) => {
|
|
1049
|
+
m.preventDefault(), s.classList.add("active"), n.classList.remove("active"), a.style.display = "flex", o.style.display = "none", this.value && this.value.startsWith("var(--");
|
|
1050
|
+
}), n.addEventListener("click", (m) => {
|
|
1051
|
+
m.preventDefault(), n.classList.add("active"), s.classList.remove("active"), a.style.display = "none", o.style.display = "grid", l();
|
|
1052
1052
|
}), this.value && this.value.startsWith("var(--") ? n.click() : s.click();
|
|
1053
|
-
const r = (
|
|
1054
|
-
const
|
|
1055
|
-
if (!
|
|
1053
|
+
const r = (m) => {
|
|
1054
|
+
const u = m.value.trim();
|
|
1055
|
+
if (!u)
|
|
1056
1056
|
return e.classList.remove("error"), !0;
|
|
1057
|
-
const v = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(
|
|
1057
|
+
const v = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(u);
|
|
1058
1058
|
return v ? e.classList.remove("error") : e.classList.add("error"), v;
|
|
1059
1059
|
}, p = document.createElement("input");
|
|
1060
1060
|
p.type = "color", p.className = "color-picker", p.value = this.value && !this.value.startsWith("var(--") ? this.value : "#000000", p.setAttribute("aria-label", "Choose color"), p.setAttribute("title", "Click to open color picker"), this.getDataPropsPath() && p.setAttribute("data-test-id", this.getDataPropsPath()), this.colorInputEl = p;
|
|
@@ -1062,34 +1062,47 @@ class I extends Mt {
|
|
|
1062
1062
|
h.className = "color-preview";
|
|
1063
1063
|
let d = this.value || "#000000";
|
|
1064
1064
|
if (d.startsWith("var(--")) {
|
|
1065
|
-
const
|
|
1066
|
-
d = (x.GlobalVariables || {})[
|
|
1065
|
+
const m = d.replace("var(--", "").replace(")", "");
|
|
1066
|
+
d = (x.GlobalVariables || {})[m] || "#000000";
|
|
1067
1067
|
}
|
|
1068
1068
|
h.style.backgroundColor = d;
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1069
|
+
const g = document.createElement("input");
|
|
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 C = (m) => {
|
|
1071
1072
|
var f, v;
|
|
1072
|
-
let
|
|
1073
|
-
if (this.textInputEl && r(this.textInputEl)) {
|
|
1074
|
-
const
|
|
1075
|
-
this.value =
|
|
1073
|
+
let u = m.trim();
|
|
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
|
+
const y = V.normalizeColorValue(u);
|
|
1076
|
+
this.value = y, (f = this.onChange) == null || f.call(this, y), (v = this.detectChange) == null || v.call(this, y), this.colorInputEl && (this.colorInputEl.value = y), h.style.backgroundColor = y;
|
|
1076
1077
|
}
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
}), this.
|
|
1082
|
-
var
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1078
|
+
};
|
|
1079
|
+
return this.textInputEl.addEventListener("input", (m) => {
|
|
1080
|
+
const u = m.target.value;
|
|
1081
|
+
C(u);
|
|
1082
|
+
}), this.textInputEl.addEventListener("paste", (m) => {
|
|
1083
|
+
var f;
|
|
1084
|
+
m.preventDefault();
|
|
1085
|
+
const u = ((f = m.clipboardData) == null ? void 0 : f.getData("text")) || "";
|
|
1086
|
+
this.textInputEl && (this.textInputEl.value = u.trim(), C(u));
|
|
1087
|
+
}), this.textInputEl.addEventListener("keydown", (m) => {
|
|
1088
|
+
var u, f, v;
|
|
1089
|
+
m.key === "Enter" && (m.preventDefault(), C(((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), (v = this.textInputEl) == null || v.blur(), e.classList.remove("error"));
|
|
1090
|
+
}), this.colorInputEl.addEventListener("input", (m) => {
|
|
1091
|
+
var v, y;
|
|
1092
|
+
const u = m.target.value, f = V.normalizeColorValue(u);
|
|
1093
|
+
this.value = f, (v = this.onChange) == null || v.call(this, f), (y = this.detectChange) == null || y.call(this, f), this.textInputEl && (this.textInputEl.value = f), h.style.backgroundColor = f, e.classList.remove("error");
|
|
1094
|
+
}), this.colorInputEl.addEventListener("change", (m) => {
|
|
1095
|
+
var v, y;
|
|
1096
|
+
const u = m.target.value, f = V.normalizeColorValue(u);
|
|
1097
|
+
this.value = f, (v = this.onChange) == null || v.call(this, f), (y = this.detectChange) == null || y.call(this, f), this.textInputEl && (this.textInputEl.value = f), h.style.backgroundColor = f;
|
|
1098
|
+
}), a.appendChild(p), a.appendChild(h), a.appendChild(g), e.appendChild(i), e.appendChild(a), e.appendChild(o), t.appendChild(e), this.element = t, t;
|
|
1086
1099
|
}
|
|
1087
1100
|
getElement() {
|
|
1088
1101
|
return this.element;
|
|
1089
1102
|
}
|
|
1090
1103
|
// Helper method to get normalized hex value
|
|
1091
1104
|
getNormalizedValue() {
|
|
1092
|
-
return this.value ?
|
|
1105
|
+
return this.value ? V.normalizeColorValue(this.value) : "#000000";
|
|
1093
1106
|
}
|
|
1094
1107
|
// Helper method to check if current value is valid hex
|
|
1095
1108
|
isValidHex() {
|
|
@@ -1100,7 +1113,7 @@ class I extends Mt {
|
|
|
1100
1113
|
return this.isValidHex() ? this.hexToRgb(this.value) : "0, 0, 0";
|
|
1101
1114
|
}
|
|
1102
1115
|
}
|
|
1103
|
-
const
|
|
1116
|
+
const It = `
|
|
1104
1117
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1105
1118
|
<path d="M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1106
1119
|
<path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
@@ -1110,7 +1123,7 @@ class F extends x {
|
|
|
1110
1123
|
constructor(t = {}) {
|
|
1111
1124
|
super({
|
|
1112
1125
|
...t,
|
|
1113
|
-
icon: t.icon ||
|
|
1126
|
+
icon: t.icon || It,
|
|
1114
1127
|
title: t.title || "Color & Opacity",
|
|
1115
1128
|
default: t.default || "#000000FF"
|
|
1116
1129
|
}), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.opacityInputEl = null, this.colorPreviewEl = null, this.detectChange = t.detectChange, this.value && (this.value = F.normalizeHexWithOpacity(this.value));
|
|
@@ -1138,8 +1151,8 @@ class F extends x {
|
|
|
1138
1151
|
}
|
|
1139
1152
|
updateColorPreview() {
|
|
1140
1153
|
if (!this.colorPreviewEl || !this.value) return;
|
|
1141
|
-
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),
|
|
1142
|
-
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), a = parseInt(i.substring(4, 6), 16);
|
|
1155
|
+
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
1143
1156
|
}
|
|
1144
1157
|
handleColorChange(t) {
|
|
1145
1158
|
const e = this.getOpacityPercent(), i = F.combineColorOpacity(
|
|
@@ -1164,12 +1177,12 @@ class F extends x {
|
|
|
1164
1177
|
if (t.className = "color-with-opacity-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
1165
1178
|
const o = document.createElement("div");
|
|
1166
1179
|
if (o.className = "icon-container", this.props.icon) {
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1180
|
+
const l = document.createElement("span");
|
|
1181
|
+
l.className = "input-icon", l.innerHTML = this.props.icon, o.appendChild(l);
|
|
1169
1182
|
}
|
|
1170
1183
|
if (this.props.title) {
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1184
|
+
const l = document.createElement("span");
|
|
1185
|
+
l.className = "input-label", l.textContent = this.props.title, o.appendChild(l);
|
|
1173
1186
|
}
|
|
1174
1187
|
t.appendChild(o);
|
|
1175
1188
|
}
|
|
@@ -1180,35 +1193,50 @@ class F extends x {
|
|
|
1180
1193
|
), this.colorPreviewEl = document.createElement("div"), this.colorPreviewEl.className = "color-with-opacity-preview", this.textInputEl = document.createElement("input"), this.textInputEl.type = "text", this.textInputEl.className = "color-with-opacity-text-input", this.textInputEl.placeholder = "#000000FF", this.getDataPropsPath() && this.textInputEl.setAttribute(
|
|
1181
1194
|
"data-test-id",
|
|
1182
1195
|
`${this.getDataPropsPath()}_text`
|
|
1183
|
-
), this.updateInputElements(), this.updateColorPreview()
|
|
1184
|
-
|
|
1185
|
-
|
|
1196
|
+
), this.updateInputElements(), this.updateColorPreview();
|
|
1197
|
+
const i = (o) => {
|
|
1198
|
+
let l = o.trim();
|
|
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
|
+
const r = this.handleTextInput(l);
|
|
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
|
+
};
|
|
1203
|
+
this.colorInputEl.addEventListener("input", (o) => {
|
|
1204
|
+
const l = o.target;
|
|
1205
|
+
this.handleColorChange(l.value), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview();
|
|
1186
1206
|
}), this.textInputEl.addEventListener("input", (o) => {
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1207
|
+
const l = o.target;
|
|
1208
|
+
i(l.value);
|
|
1209
|
+
}), this.textInputEl.addEventListener("paste", (o) => {
|
|
1210
|
+
var r;
|
|
1211
|
+
o.preventDefault();
|
|
1212
|
+
const l = ((r = o.clipboardData) == null ? void 0 : r.getData("text")) || "";
|
|
1213
|
+
this.textInputEl && (this.textInputEl.value = l.trim(), i(l));
|
|
1214
|
+
}), this.textInputEl.addEventListener("keydown", (o) => {
|
|
1215
|
+
var l, r, p;
|
|
1216
|
+
o.key === "Enter" && (o.preventDefault(), i(((l = this.textInputEl) == null ? void 0 : l.value) || ""), (r = this.textInputEl) == null || r.blur()), o.key === "Escape" && (this.textInputEl && this.value && (this.textInputEl.value = this.value), (p = this.textInputEl) == null || p.blur(), e.classList.remove("error"));
|
|
1189
1217
|
}), this.textInputEl.addEventListener("blur", (o) => {
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1218
|
+
const l = o.target;
|
|
1219
|
+
l.value.trim() === "" && (l.value = this.value || "#000000FF", e.classList.remove("error"));
|
|
1192
1220
|
}), this.colorPreviewEl.addEventListener("click", () => {
|
|
1193
1221
|
var o;
|
|
1194
1222
|
(o = this.colorInputEl) == null || o.click();
|
|
1195
1223
|
}), e.appendChild(this.colorInputEl), e.appendChild(this.colorPreviewEl), e.appendChild(this.textInputEl);
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1224
|
+
const s = document.createElement("div");
|
|
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(
|
|
1198
1226
|
"data-test-id",
|
|
1199
1227
|
`${this.getDataPropsPath()}_opacity`
|
|
1200
1228
|
);
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
const
|
|
1204
|
-
isNaN(
|
|
1229
|
+
const n = document.createElement("span");
|
|
1230
|
+
n.className = "color-with-opacity-opacity-suffix", n.textContent = "%", this.opacityInputEl.addEventListener("input", (o) => {
|
|
1231
|
+
const l = o.target, r = parseFloat(l.value);
|
|
1232
|
+
isNaN(r) || (this.handleOpacityChange(r), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview());
|
|
1205
1233
|
}), this.opacityInputEl.addEventListener("blur", (o) => {
|
|
1206
|
-
const
|
|
1207
|
-
let
|
|
1208
|
-
isNaN(
|
|
1209
|
-
}),
|
|
1210
|
-
const
|
|
1211
|
-
return
|
|
1234
|
+
const l = o.target;
|
|
1235
|
+
let r = parseFloat(l.value);
|
|
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
|
+
}), s.appendChild(this.opacityInputEl), s.appendChild(n);
|
|
1238
|
+
const a = document.createElement("div");
|
|
1239
|
+
return a.className = "color-with-opacity-controls-wrapper", a.appendChild(e), a.appendChild(s), t.appendChild(a), this.element = t, this.updateInputElements(), this.updateColorPreview(), t;
|
|
1212
1240
|
}
|
|
1213
1241
|
getElement() {
|
|
1214
1242
|
return this.element;
|
|
@@ -1218,8 +1246,8 @@ class F extends x {
|
|
|
1218
1246
|
}
|
|
1219
1247
|
getRgbaValue() {
|
|
1220
1248
|
if (!this.value) return "rgba(0, 0, 0, 1)";
|
|
1221
|
-
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),
|
|
1222
|
-
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), a = parseInt(i.substring(4, 6), 16);
|
|
1250
|
+
return `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
1223
1251
|
}
|
|
1224
1252
|
getColorAndOpacity() {
|
|
1225
1253
|
return {
|
|
@@ -1240,20 +1268,20 @@ class ge extends x {
|
|
|
1240
1268
|
if (t.className = "html-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
1241
1269
|
const n = document.createElement("div");
|
|
1242
1270
|
if (n.className = "icon-container", this.props.icon) {
|
|
1243
|
-
const
|
|
1244
|
-
n.appendChild(
|
|
1271
|
+
const a = this.createIcon(this.props.icon);
|
|
1272
|
+
n.appendChild(a);
|
|
1245
1273
|
}
|
|
1246
1274
|
if (this.props.title) {
|
|
1247
|
-
const
|
|
1248
|
-
n.appendChild(
|
|
1275
|
+
const a = this.createLabel(this.props.title);
|
|
1276
|
+
n.appendChild(a);
|
|
1249
1277
|
}
|
|
1250
1278
|
t.appendChild(n);
|
|
1251
1279
|
}
|
|
1252
1280
|
const e = document.createElement("textarea");
|
|
1253
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);
|
|
1254
1282
|
const i = (n) => {
|
|
1255
|
-
const
|
|
1256
|
-
this.value =
|
|
1283
|
+
const o = n.target.value;
|
|
1284
|
+
this.value = o, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
|
|
1257
1285
|
}, s = (n) => {
|
|
1258
1286
|
this.onBlur && this.value !== void 0 && this.onBlur(this.value);
|
|
1259
1287
|
};
|
|
@@ -1283,12 +1311,12 @@ class P extends x {
|
|
|
1283
1311
|
const i = document.createElement("input");
|
|
1284
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", () => {
|
|
1285
1313
|
const s = this.props.minValue ?? Number.MIN_SAFE_INTEGER, n = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
1286
|
-
let
|
|
1287
|
-
|
|
1314
|
+
let a = Number(i.value);
|
|
1315
|
+
a < s && (a = s), a > n && (a = n), String(a) !== i.value && (i.value = String(a)), this.setValue(a);
|
|
1288
1316
|
}), i.addEventListener("blur", () => {
|
|
1289
|
-
var n,
|
|
1317
|
+
var n, a;
|
|
1290
1318
|
const s = this.validateValue(Number(i.value));
|
|
1291
|
-
s !== Number(i.value) && (i.value = String(s), this.setValue(s)), (
|
|
1319
|
+
s !== Number(i.value) && (i.value = String(s), this.setValue(s)), (a = (n = this.props).onBlur) == null || a.call(n);
|
|
1292
1320
|
}), e.appendChild(i), this.props.suffix && this.props.suffix !== "none") {
|
|
1293
1321
|
const s = document.createElement("span");
|
|
1294
1322
|
s.className = "suffix-label", s.textContent = this.props.suffix, e.appendChild(s);
|
|
@@ -1319,12 +1347,12 @@ class P extends x {
|
|
|
1319
1347
|
);
|
|
1320
1348
|
}
|
|
1321
1349
|
}
|
|
1322
|
-
const
|
|
1350
|
+
const Nt = `
|
|
1323
1351
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1324
1352
|
<path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1325
1353
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1326
1354
|
</svg>`;
|
|
1327
|
-
class
|
|
1355
|
+
class Vt extends P {
|
|
1328
1356
|
constructor(t = {}) {
|
|
1329
1357
|
const e = {
|
|
1330
1358
|
title: "Opacity",
|
|
@@ -1333,7 +1361,7 @@ class It extends P {
|
|
|
1333
1361
|
maxValue: 100,
|
|
1334
1362
|
step: 1,
|
|
1335
1363
|
default: t.default ?? 100,
|
|
1336
|
-
icon:
|
|
1364
|
+
icon: Nt,
|
|
1337
1365
|
...t
|
|
1338
1366
|
};
|
|
1339
1367
|
super(e), this.inputType = "number", this.mobileValue = t.mobile;
|
|
@@ -1371,12 +1399,12 @@ class et extends x {
|
|
|
1371
1399
|
if (t.classList.add("select-container"), this.container = t, this.props.icon || this.props.title) {
|
|
1372
1400
|
const n = document.createElement("div");
|
|
1373
1401
|
if (n.className = "icon-container", this.props.icon) {
|
|
1374
|
-
const
|
|
1375
|
-
n.appendChild(
|
|
1402
|
+
const a = this.createIcon(this.props.icon);
|
|
1403
|
+
n.appendChild(a);
|
|
1376
1404
|
}
|
|
1377
1405
|
if (this.props.title) {
|
|
1378
|
-
const
|
|
1379
|
-
n.appendChild(
|
|
1406
|
+
const a = this.createLabel(this.props.title);
|
|
1407
|
+
n.appendChild(a);
|
|
1380
1408
|
}
|
|
1381
1409
|
t.appendChild(n);
|
|
1382
1410
|
} else {
|
|
@@ -1385,13 +1413,13 @@ class et extends x {
|
|
|
1385
1413
|
}
|
|
1386
1414
|
const e = document.createElement("div");
|
|
1387
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 = () => {
|
|
1388
|
-
var n,
|
|
1389
|
-
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, a;
|
|
1417
|
+
this.isLoading || (this.isOpen = !this.isOpen, this.isOpen ? this.checkDropdownPosition() : this.cleanupDropdownPosition(), (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (a = this.svgContainer) == null || a.classList.toggle("open", this.isOpen));
|
|
1390
1418
|
}, t.appendChild(e), this.buttonEl = e;
|
|
1391
1419
|
const i = document.createElement("ul");
|
|
1392
|
-
i.classList.add("select-options"), this._options.forEach((n,
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1420
|
+
i.classList.add("select-options"), this._options.forEach((n, a) => {
|
|
1421
|
+
const o = this.createOption(n, a);
|
|
1422
|
+
o.onclick = (l) => this.selectOption(l, a, e), i.appendChild(o);
|
|
1395
1423
|
}), document.body.appendChild(i);
|
|
1396
1424
|
const s = document.createElement("div");
|
|
1397
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) => {
|
|
@@ -1399,8 +1427,8 @@ class et extends x {
|
|
|
1399
1427
|
}).catch((n) => {
|
|
1400
1428
|
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText("Failed to load options");
|
|
1401
1429
|
})), this.clickOutsideListener && document.removeEventListener("click", this.clickOutsideListener), this.clickOutsideListener = (n) => {
|
|
1402
|
-
var
|
|
1403
|
-
this.isOpen && !t.contains(n.target) && (this.isOpen = !1, (
|
|
1430
|
+
var a, o;
|
|
1431
|
+
this.isOpen && !t.contains(n.target) && (this.isOpen = !1, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.cleanupDropdownPosition());
|
|
1404
1432
|
}, document.addEventListener("click", this.clickOutsideListener), this.resizeListener && window.removeEventListener("resize", this.resizeListener), this.resizeListener = () => {
|
|
1405
1433
|
this.isOpen && this.checkDropdownPosition();
|
|
1406
1434
|
}, window.addEventListener("resize", this.resizeListener), t;
|
|
@@ -1419,9 +1447,9 @@ class et extends x {
|
|
|
1419
1447
|
}
|
|
1420
1448
|
}
|
|
1421
1449
|
selectOption(t, e, i) {
|
|
1422
|
-
var n,
|
|
1450
|
+
var n, a;
|
|
1423
1451
|
const s = this._options[e];
|
|
1424
|
-
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"), (a = this.svgContainer) == null || a.classList.remove("open"), this.cleanupDropdownPosition(), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((l, r) => {
|
|
1425
1453
|
r === e ? l.classList.add("selected") : l.classList.remove("selected");
|
|
1426
1454
|
}));
|
|
1427
1455
|
}
|
|
@@ -1502,14 +1530,14 @@ class Pt extends x {
|
|
|
1502
1530
|
`
|
|
1503
1531
|
}
|
|
1504
1532
|
].forEach((n) => {
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1533
|
+
const a = document.createElement("button");
|
|
1534
|
+
a.className = "align-option-button", a.innerHTML = n.icon, this.getDataPropsPath() && a.setAttribute(
|
|
1507
1535
|
"data-test-id",
|
|
1508
1536
|
`${this.getDataPropsPath()}_${n.name}`
|
|
1509
|
-
), this.value === n.name &&
|
|
1510
|
-
var
|
|
1511
|
-
i.querySelectorAll(".align-option-button").forEach((l) => l.classList.remove("selected")),
|
|
1512
|
-
}), i.appendChild(
|
|
1537
|
+
), this.value === n.name && a.classList.add("selected"), a.addEventListener("click", () => {
|
|
1538
|
+
var o;
|
|
1539
|
+
i.querySelectorAll(".align-option-button").forEach((l) => l.classList.remove("selected")), a.classList.add("selected"), this.value = n.name, (o = this.onChange) == null || o.call(this, this.value);
|
|
1540
|
+
}), i.appendChild(a);
|
|
1513
1541
|
}), t.appendChild(i), t;
|
|
1514
1542
|
}
|
|
1515
1543
|
}
|
|
@@ -1527,19 +1555,19 @@ class me extends x {
|
|
|
1527
1555
|
/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i
|
|
1528
1556
|
);
|
|
1529
1557
|
if (n) {
|
|
1530
|
-
let
|
|
1531
|
-
p >= 1 ? (
|
|
1558
|
+
let o = +n[1], l = +n[2], r = +n[3], p = +n[4];
|
|
1559
|
+
p >= 1 ? (o = Math.round(o * 0.9), l = Math.round(l * 0.9), r = Math.round(r * 0.9)) : p = Math.min(1, p + 0.12), s = `rgba(${o},${l},${r},${p})`;
|
|
1532
1560
|
}
|
|
1533
1561
|
t.addEventListener("mouseenter", () => {
|
|
1534
1562
|
console.log("hoverBg", s), t.style.setProperty("background-color", s, "important");
|
|
1535
1563
|
}), t.addEventListener("mouseleave", () => {
|
|
1536
1564
|
t.style.setProperty("background-color", e, "important");
|
|
1537
1565
|
}), t.addEventListener("click", () => {
|
|
1538
|
-
var
|
|
1539
|
-
return (l = (
|
|
1566
|
+
var o, l;
|
|
1567
|
+
return (l = (o = this.props).onClick) == null ? void 0 : l.call(o);
|
|
1540
1568
|
});
|
|
1541
|
-
const
|
|
1542
|
-
return
|
|
1569
|
+
const a = document.createElement("div");
|
|
1570
|
+
return a.className = "button-setting-wrapper " + (this.props.wrapperClassName || ""), a.appendChild(t), a;
|
|
1543
1571
|
}
|
|
1544
1572
|
}
|
|
1545
1573
|
class fe extends x {
|
|
@@ -1562,7 +1590,7 @@ class fe extends x {
|
|
|
1562
1590
|
suffix: "px",
|
|
1563
1591
|
minValue: this.minHeight,
|
|
1564
1592
|
maxValue: this.maxHeight,
|
|
1565
|
-
icon:
|
|
1593
|
+
icon: $t
|
|
1566
1594
|
}), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
|
|
1567
1595
|
}
|
|
1568
1596
|
handleWidthChange(t) {
|
|
@@ -1632,8 +1660,8 @@ class fe extends x {
|
|
|
1632
1660
|
return n.className = "dimension-lock-icon", n.setAttribute("type", "button"), n.setAttribute("aria-pressed", String(this.locked)), n.setAttribute(
|
|
1633
1661
|
"aria-label",
|
|
1634
1662
|
this.locked ? "Unlock aspect ratio" : "Lock aspect ratio"
|
|
1635
|
-
), n.title = this.locked ? "Unlock aspect ratio" : "Lock aspect ratio", n.innerHTML = this.getLockSVG(this.locked), n.onclick = (
|
|
1636
|
-
|
|
1663
|
+
), n.title = this.locked ? "Unlock aspect ratio" : "Lock aspect ratio", n.innerHTML = this.getLockSVG(this.locked), n.onclick = (a) => {
|
|
1664
|
+
a.preventDefault(), this.toggleLock(n);
|
|
1637
1665
|
}, s.appendChild(n), t.appendChild(e), t.appendChild(s), t.appendChild(i), t;
|
|
1638
1666
|
}
|
|
1639
1667
|
isLocked() {
|
|
@@ -1658,13 +1686,13 @@ class fe extends x {
|
|
|
1658
1686
|
}
|
|
1659
1687
|
const Ot = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1660
1688
|
<path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1661
|
-
</svg>`,
|
|
1689
|
+
</svg>`, $t = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1662
1690
|
<path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1663
1691
|
</svg>`, Q = `
|
|
1664
1692
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
1665
1693
|
<path d="M5 10.5L7.5 8M7.5 8L10 10.5M7.5 8V13.625M12.5 10.9643C13.2634 10.3338 13.75 9.37996 13.75 8.3125C13.75 6.41402 12.211 4.875 10.3125 4.875C10.1759 4.875 10.0482 4.80375 9.97882 4.68609C9.16379 3.30302 7.65902 2.375 5.9375 2.375C3.34867 2.375 1.25 4.47367 1.25 7.0625C1.25 8.35381 1.77215 9.52317 2.61684 10.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1666
1694
|
</svg>
|
|
1667
|
-
`,
|
|
1695
|
+
`, Ht = `
|
|
1668
1696
|
<svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1669
1697
|
<rect width="91" height="71" rx="4" fill="#F2F4F7"/>
|
|
1670
1698
|
<path d="M37 31.5L39.5 29M39.5 29L42 31.5M39.5 29V34.625M44.5 31.9643C45.2634 31.3338 45.75 30.38 45.75 29.3125C45.75 27.414 44.211 25.875 42.3125 25.875C42.1759 25.875 42.0482 25.8037 41.9788 25.6861C41.1638 24.303 39.659 23.375 37.9375 23.375C35.3487 23.375 33.25 25.4737 33.25 28.0625C33.25 29.3538 33.7721 30.5232 34.6168 31.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -1750,11 +1778,11 @@ class nt extends x {
|
|
|
1750
1778
|
<span class="upload-label">Replace</span>
|
|
1751
1779
|
`);
|
|
1752
1780
|
const n = () => {
|
|
1753
|
-
this.hideLoading(), this.previewWrapper.classList.add("has-image"), this.previewEl.style.display = "block", this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error",
|
|
1754
|
-
},
|
|
1755
|
-
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", a);
|
|
1782
|
+
}, a = () => {
|
|
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", a);
|
|
1756
1784
|
};
|
|
1757
|
-
this.previewEl.addEventListener("load", n), this.previewEl.addEventListener("error",
|
|
1785
|
+
this.previewEl.addEventListener("load", n), this.previewEl.addEventListener("error", a), this.previewEl.src = t;
|
|
1758
1786
|
} else
|
|
1759
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 = `
|
|
1760
1788
|
<span class="upload-icon">${Q}</span>
|
|
@@ -1765,24 +1793,24 @@ class nt extends x {
|
|
|
1765
1793
|
const t = document.createElement("div");
|
|
1766
1794
|
t.className = "upload-setting-wrapper", t.setAttribute("data-setting-id", this.id), t.addEventListener(
|
|
1767
1795
|
"focusout",
|
|
1768
|
-
(
|
|
1796
|
+
(o) => {
|
|
1769
1797
|
var l;
|
|
1770
|
-
|
|
1798
|
+
o.relatedTarget && t.contains(o.relatedTarget) || (l = this.onBlur) == null || l.call(this, this.value ?? "");
|
|
1771
1799
|
},
|
|
1772
1800
|
!0
|
|
1773
1801
|
);
|
|
1774
1802
|
const e = !!(this.props.title || this.props.icon);
|
|
1775
1803
|
if (e || t.classList.add("no-label"), e) {
|
|
1776
|
-
const
|
|
1777
|
-
if (
|
|
1804
|
+
const o = document.createElement("div");
|
|
1805
|
+
if (o.className = "icon-title-container", this.props.icon) {
|
|
1778
1806
|
const l = this.createIcon(this.props.icon);
|
|
1779
|
-
|
|
1807
|
+
o.appendChild(l);
|
|
1780
1808
|
}
|
|
1781
1809
|
if (this.props.title) {
|
|
1782
1810
|
const l = this.createLabel(this.props.title);
|
|
1783
|
-
|
|
1811
|
+
o.appendChild(l);
|
|
1784
1812
|
}
|
|
1785
|
-
t.appendChild(
|
|
1813
|
+
t.appendChild(o);
|
|
1786
1814
|
}
|
|
1787
1815
|
this.errorContainer = document.createElement("div"), this.errorContainer.className = "error-message", this.errorContainer.style.display = "none", t.appendChild(this.errorContainer);
|
|
1788
1816
|
const i = document.createElement("div");
|
|
@@ -1790,19 +1818,19 @@ class nt extends x {
|
|
|
1790
1818
|
const s = this.value && this.value !== "";
|
|
1791
1819
|
s || i.classList.add("no-image");
|
|
1792
1820
|
const n = document.createElement("div");
|
|
1793
|
-
if (n.className = "preview-placeholder", n.innerHTML =
|
|
1794
|
-
const
|
|
1795
|
-
|
|
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 o = document.createElement("button");
|
|
1823
|
+
o.className = "delete-button", o.type = "button", o.title = "Delete image", o.innerHTML = Bt, this.previewWrapper.appendChild(o), o.onclick = (l) => {
|
|
1796
1824
|
var r;
|
|
1797
1825
|
l.stopPropagation(), this.value = "", this.updatePreviewState(null), (r = this.onChange) == null || r.call(this, ""), this.hideError();
|
|
1798
1826
|
};
|
|
1799
1827
|
}
|
|
1800
1828
|
this.previewWrapper.appendChild(this.previewEl);
|
|
1801
|
-
const
|
|
1802
|
-
return
|
|
1829
|
+
const a = document.createElement("button");
|
|
1830
|
+
return a.className = "upload-button", this.getDataPropsPath() && a.setAttribute("data-test-id", this.getDataPropsPath()), a.innerHTML = `
|
|
1803
1831
|
<span class="upload-icon">${Q}</span>
|
|
1804
1832
|
<span class="upload-label">Upload</span>
|
|
1805
|
-
`, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(
|
|
1833
|
+
`, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(a), t.appendChild(i), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), a.onclick = () => {
|
|
1806
1834
|
window.postMessage(
|
|
1807
1835
|
{
|
|
1808
1836
|
type: "OPEN_FILE_MANAGER_MODAL",
|
|
@@ -1854,7 +1882,7 @@ class Ft extends P {
|
|
|
1854
1882
|
}
|
|
1855
1883
|
const Rt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1856
1884
|
<path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1857
|
-
</svg>`,
|
|
1885
|
+
</svg>`, Wt = `
|
|
1858
1886
|
<svg xmlns="http://www.w3.org/2000/svg" class="svg-select-api" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down">
|
|
1859
1887
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
1860
1888
|
</svg>
|
|
@@ -1886,44 +1914,44 @@ class ve extends x {
|
|
|
1886
1914
|
e.classList.add("has-label");
|
|
1887
1915
|
const n = document.createElement("div");
|
|
1888
1916
|
n.className = "select-label", n.textContent = this.props.title, e.appendChild(n);
|
|
1889
|
-
const
|
|
1890
|
-
if (
|
|
1891
|
-
|
|
1917
|
+
const a = document.createElement("span");
|
|
1918
|
+
if (a.className = "select-value", this.isLoading)
|
|
1919
|
+
a.textContent = this.props.loadingText || "Loading options...";
|
|
1892
1920
|
else {
|
|
1893
|
-
const
|
|
1894
|
-
|
|
1921
|
+
const o = this.selectedOptionIndex !== null && this._options && this.selectedOptionIndex >= 0 && this.selectedOptionIndex < this._options.length ? this._options[this.selectedOptionIndex] : null, l = o && typeof o.name == "string" ? o.name : "Select an option";
|
|
1922
|
+
a.textContent = l;
|
|
1895
1923
|
}
|
|
1896
|
-
e.appendChild(
|
|
1924
|
+
e.appendChild(a);
|
|
1897
1925
|
} else {
|
|
1898
1926
|
const n = document.createElement("span");
|
|
1899
1927
|
if (this.isLoading)
|
|
1900
1928
|
n.textContent = this.props.loadingText || "Loading options...";
|
|
1901
1929
|
else {
|
|
1902
|
-
const
|
|
1903
|
-
n.textContent =
|
|
1930
|
+
const a = this.selectedOptionIndex !== null && this._options && this.selectedOptionIndex >= 0 && this.selectedOptionIndex < this._options.length ? this._options[this.selectedOptionIndex] : null, o = a && typeof a.name == "string" ? a.name : "Select an option";
|
|
1931
|
+
n.textContent = o;
|
|
1904
1932
|
}
|
|
1905
1933
|
e.appendChild(n);
|
|
1906
1934
|
}
|
|
1907
1935
|
e.onclick = () => {
|
|
1908
|
-
var n,
|
|
1909
|
-
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1936
|
+
var n, a;
|
|
1937
|
+
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (a = this.svgContainer) == null || a.classList.toggle("open", this.isOpen));
|
|
1910
1938
|
}, t.appendChild(e), this.buttonEl = e;
|
|
1911
1939
|
const i = document.createElement("ul");
|
|
1912
|
-
i.classList.add("select-api-options"), this._options.forEach((n,
|
|
1913
|
-
const
|
|
1914
|
-
|
|
1940
|
+
i.classList.add("select-api-options"), this._options.forEach((n, a) => {
|
|
1941
|
+
const o = this.createOption(n, a);
|
|
1942
|
+
o.onclick = (l) => this.selectApiOption(l, a, e), i.appendChild(o);
|
|
1915
1943
|
}), t.appendChild(i);
|
|
1916
1944
|
const s = document.createElement("div");
|
|
1917
|
-
return s.classList.add("svg-container"), s.innerHTML =
|
|
1918
|
-
var n,
|
|
1919
|
-
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1945
|
+
return s.classList.add("svg-container"), s.innerHTML = Wt, t.appendChild(s), s.onclick = () => {
|
|
1946
|
+
var n, a;
|
|
1947
|
+
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (a = this.svgContainer) == null || a.classList.toggle("open", this.isOpen));
|
|
1920
1948
|
}, this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && !this.hasInitializedOptions ? (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
1921
|
-
const
|
|
1949
|
+
const a = new Set(
|
|
1922
1950
|
this._options.map((l) => JSON.stringify(l.value))
|
|
1923
|
-
),
|
|
1924
|
-
(l) => !
|
|
1951
|
+
), o = n.filter(
|
|
1952
|
+
(l) => !a.has(JSON.stringify(l.value))
|
|
1925
1953
|
);
|
|
1926
|
-
if (this._options.push(...
|
|
1954
|
+
if (this._options.push(...o), this.isLoading = !1, this.hasInitializedOptions = !0, this.value !== void 0) {
|
|
1927
1955
|
const l = this._options.findIndex(
|
|
1928
1956
|
(r) => JSON.stringify(r.value) === JSON.stringify(this.value)
|
|
1929
1957
|
);
|
|
@@ -1937,12 +1965,12 @@ class ve extends x {
|
|
|
1937
1965
|
!0
|
|
1938
1966
|
);
|
|
1939
1967
|
})) : this.props.getOptionsAsync && this._options.length <= 1 && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
1940
|
-
const
|
|
1968
|
+
const a = new Set(
|
|
1941
1969
|
this._options.map((l) => JSON.stringify(l.value))
|
|
1942
|
-
),
|
|
1943
|
-
(l) => !
|
|
1970
|
+
), o = n.filter(
|
|
1971
|
+
(l) => !a.has(JSON.stringify(l.value))
|
|
1944
1972
|
);
|
|
1945
|
-
if (this._options.push(...
|
|
1973
|
+
if (this._options.push(...o), this.isLoading = !1, this.value !== void 0) {
|
|
1946
1974
|
const l = this._options.findIndex(
|
|
1947
1975
|
(r) => JSON.stringify(r.value) === JSON.stringify(this.value)
|
|
1948
1976
|
);
|
|
@@ -1961,11 +1989,11 @@ class ve extends x {
|
|
|
1961
1989
|
return JSON.stringify(t ? {} : { value: this.value }, null, 2);
|
|
1962
1990
|
}
|
|
1963
1991
|
selectApiOption(t, e, i) {
|
|
1964
|
-
var
|
|
1965
|
-
const s = t.target, n = s.querySelector(".select-api-radio") || ((
|
|
1992
|
+
var o, l, r;
|
|
1993
|
+
const s = t.target, n = s.querySelector(".select-api-radio") || ((o = s.closest(".select-api-option")) == null ? void 0 : o.querySelector(".select-api-radio"));
|
|
1966
1994
|
n && (n.checked = !0);
|
|
1967
|
-
const
|
|
1968
|
-
this.setValue(
|
|
1995
|
+
const a = this._options[e].value;
|
|
1996
|
+
this.setValue(a), this.isOpen = !1, (l = this.optionsListEl) == null || l.classList.remove("open"), (r = this.svgContainer) == null || r.classList.remove("open");
|
|
1969
1997
|
}
|
|
1970
1998
|
updateOptionsList() {
|
|
1971
1999
|
!this.optionsListEl || !this.buttonEl || (this.optionsListEl.innerHTML = "", this._options.forEach((t, e) => {
|
|
@@ -2014,7 +2042,7 @@ class Ce extends x {
|
|
|
2014
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;
|
|
2015
2043
|
}
|
|
2016
2044
|
draw() {
|
|
2017
|
-
var
|
|
2045
|
+
var a, o;
|
|
2018
2046
|
const t = document.createElement("div");
|
|
2019
2047
|
t.className = "toggle-setting-container", this.props.icon && t.classList.add("toggle-with-icon");
|
|
2020
2048
|
const e = document.createElement("div");
|
|
@@ -2030,7 +2058,7 @@ class Ce extends x {
|
|
|
2030
2058
|
const i = document.createElement("label");
|
|
2031
2059
|
i.className = "toggle-switch";
|
|
2032
2060
|
const s = document.createElement("input");
|
|
2033
|
-
s.type = "checkbox", s.checked = ((
|
|
2061
|
+
s.type = "checkbox", s.checked = ((o = (a = this.props.options) == null ? void 0 : a.find((l) => l.value === this.value)) == null ? void 0 : o.status) ?? !1, this.getDataPropsPath() && s.setAttribute("data-test-id", this.getDataPropsPath()), s.addEventListener("change", () => {
|
|
2034
2062
|
var r, p;
|
|
2035
2063
|
const l = ((p = (r = this.props.options) == null ? void 0 : r.find((h) => h.status === s.checked)) == null ? void 0 : p.value) ?? "";
|
|
2036
2064
|
this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
|
|
@@ -2058,13 +2086,13 @@ class Ce extends x {
|
|
|
2058
2086
|
this.detectChangeCallback = t;
|
|
2059
2087
|
}
|
|
2060
2088
|
}
|
|
2061
|
-
const
|
|
2089
|
+
const Ut = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2062
2090
|
<path d="M13.3334 5.99996H2.66675M13.3334 9.99996H2.66675M5.33341 12.6666V3.33329M10.6667 12.6666V3.33329" stroke="#667085" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2063
2091
|
</svg>`;
|
|
2064
2092
|
class ye extends x {
|
|
2065
2093
|
// Store mobile value
|
|
2066
2094
|
constructor(t = {}) {
|
|
2067
|
-
t.rowGap = t.rowGap ?? !0, t.columnGap = t.columnGap ?? !0, t.title = t.title ?? "Gap", t.icon = t.icon ??
|
|
2095
|
+
t.rowGap = t.rowGap ?? !0, t.columnGap = t.columnGap ?? !0, t.title = t.title ?? "Gap", t.icon = t.icon ?? Ut, t.suffix = t.suffix ?? "px", t.minValue = t.minValue ?? 0, super(t), this.inputType = "number", this.inputValues = {}, this.mobileValue = t.mobile, this.value = this.validateValue(t.default ?? 0), t.rowGap && (this.inputValues.row = this.value), t.columnGap && (this.inputValues.column = this.value);
|
|
2068
2096
|
}
|
|
2069
2097
|
draw() {
|
|
2070
2098
|
const t = document.createElement("div");
|
|
@@ -2075,27 +2103,27 @@ class ye extends x {
|
|
|
2075
2103
|
i.className = "setting-label", i.setAttribute("for", this.id + "-input");
|
|
2076
2104
|
const s = document.createElement("span");
|
|
2077
2105
|
if (s.textContent = this.props.title ?? "Gap", i.appendChild(s), this.props.icon) {
|
|
2078
|
-
const
|
|
2079
|
-
|
|
2106
|
+
const o = document.createElement("span");
|
|
2107
|
+
o.className = "setting-icon", o.innerHTML = this.props.icon, i.insertBefore(o, s);
|
|
2080
2108
|
}
|
|
2081
2109
|
const n = document.createElement("div");
|
|
2082
2110
|
n.className = `setting-input-wrapper ${this.props.wrapperClassName || ""}`, n.classList.add("gap-setting-wrapper");
|
|
2083
|
-
const
|
|
2084
|
-
return
|
|
2111
|
+
const a = document.createElement("div");
|
|
2112
|
+
return a.className = "gap-inputs-container", this.props.rowGap && a.appendChild(this.createGapInput("row", "Row")), this.props.columnGap && a.appendChild(this.createGapInput("column", "Col")), n.appendChild(a), e.appendChild(i), e.appendChild(n), t.appendChild(e), t;
|
|
2085
2113
|
}
|
|
2086
2114
|
createGapInput(t, e) {
|
|
2087
2115
|
const i = document.createElement("div");
|
|
2088
2116
|
i.className = "gap-input-wrapper";
|
|
2089
2117
|
const s = document.createElement("input");
|
|
2090
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) => {
|
|
2091
|
-
const
|
|
2092
|
-
let
|
|
2093
|
-
|
|
2119
|
+
const a = n.target;
|
|
2120
|
+
let o = parseFloat(a.value);
|
|
2121
|
+
o = this.validateValue(o), String(o) !== a.value && (a.value = String(o)), this.inputValues[t] = o, this.setValue(o);
|
|
2094
2122
|
}), s.addEventListener("blur", (n) => {
|
|
2095
2123
|
var l, r;
|
|
2096
|
-
const
|
|
2097
|
-
let
|
|
2098
|
-
|
|
2124
|
+
const a = n.target;
|
|
2125
|
+
let o = parseFloat(a.value);
|
|
2126
|
+
o = this.validateValue(o), String(o) !== a.value && (a.value = String(o), this.inputValues[t] = o, this.setValue(o)), (r = (l = this.props).onBlur) == null || r.call(l);
|
|
2099
2127
|
}), i.appendChild(s), this.props.suffix && this.props.suffix !== "none") {
|
|
2100
2128
|
const n = document.createElement("span");
|
|
2101
2129
|
n.className = "gap-suffix", n.textContent = this.props.suffix, i.appendChild(n), s.style.paddingRight = "30px";
|
|
@@ -2168,9 +2196,9 @@ class we extends x {
|
|
|
2168
2196
|
return i.font = s, i.measureText(t).width;
|
|
2169
2197
|
}
|
|
2170
2198
|
adaptPlaceholderToSingleLine(t, e) {
|
|
2171
|
-
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, a = parseFloat(i.borderLeftWidth) || 0, o = parseFloat(i.borderRightWidth) || 0, l = Math.max(
|
|
2172
2200
|
0,
|
|
2173
|
-
t.clientWidth - s - n -
|
|
2201
|
+
t.clientWidth - s - n - a - o
|
|
2174
2202
|
);
|
|
2175
2203
|
if (l <= 0) {
|
|
2176
2204
|
t.placeholder = e;
|
|
@@ -2181,18 +2209,18 @@ class we extends x {
|
|
|
2181
2209
|
return;
|
|
2182
2210
|
}
|
|
2183
2211
|
const p = "...";
|
|
2184
|
-
let h = 0, d = e.length,
|
|
2212
|
+
let h = 0, d = e.length, g = 0;
|
|
2185
2213
|
for (; h <= d; ) {
|
|
2186
|
-
const m = Math.floor((h + d) / 2),
|
|
2187
|
-
this.measureTextWidth(
|
|
2214
|
+
const m = Math.floor((h + d) / 2), u = e.slice(0, m).trimEnd() + p;
|
|
2215
|
+
this.measureTextWidth(u, i) <= l ? (g = m, h = m + 1) : d = m - 1;
|
|
2188
2216
|
}
|
|
2189
|
-
const
|
|
2190
|
-
t.placeholder =
|
|
2217
|
+
const C = e.slice(0, g).trimEnd() + p;
|
|
2218
|
+
t.placeholder = C;
|
|
2191
2219
|
}
|
|
2192
2220
|
autosizeTextarea(t, e = 3) {
|
|
2193
2221
|
t.style.height = "auto";
|
|
2194
|
-
const i = window.getComputedStyle(t), s = parseFloat(i.lineHeight) || 20, n = parseFloat(i.paddingTop) + parseFloat(i.paddingBottom),
|
|
2195
|
-
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), a = parseFloat(i.borderTopWidth) + parseFloat(i.borderBottomWidth), o = s * e + n + a, l = Math.min(t.scrollHeight || 44, o);
|
|
2223
|
+
t.style.height = `${l}px`, t.scrollHeight > o ? t.style.overflowY = "auto" : t.style.overflowY = "hidden";
|
|
2196
2224
|
}
|
|
2197
2225
|
createTextareaRow(t, e) {
|
|
2198
2226
|
const i = document.createElement("div");
|
|
@@ -2204,19 +2232,19 @@ class we extends x {
|
|
|
2204
2232
|
title: "",
|
|
2205
2233
|
id: `${this.id}_upload_${t}`
|
|
2206
2234
|
});
|
|
2207
|
-
n.setOnChange((
|
|
2208
|
-
this.updateLanguageValue(t,
|
|
2235
|
+
n.setOnChange((o) => {
|
|
2236
|
+
this.updateLanguageValue(t, o), t === this.defaultLanguage && this.updateOtherLanguagePlaceholders(o);
|
|
2209
2237
|
}), this.uploadSettings.set(t, n);
|
|
2210
|
-
const
|
|
2211
|
-
|
|
2238
|
+
const a = n.draw();
|
|
2239
|
+
a.classList.add("simple-language-upload"), i.appendChild(a);
|
|
2212
2240
|
} else {
|
|
2213
2241
|
const n = document.createElement("textarea");
|
|
2214
2242
|
n.id = `textarea-${t}`, n.classList.add("simple-language-textarea"), n.value = e || "", n.rows = 1, n.style.overflowY = "hidden";
|
|
2215
|
-
let
|
|
2216
|
-
|
|
2243
|
+
let a = this.props.placeholder || "Enter text in {language}...";
|
|
2244
|
+
a.includes("{language}") && (a = a.replace(
|
|
2217
2245
|
"{language}",
|
|
2218
2246
|
t.toUpperCase()
|
|
2219
|
-
)), n.setAttribute("data-full-placeholder",
|
|
2247
|
+
)), n.setAttribute("data-full-placeholder", a), this.adaptPlaceholderToSingleLine(n, a), this.getDataPropsPath() && n.setAttribute(
|
|
2220
2248
|
"data-test-id",
|
|
2221
2249
|
`${this.getDataPropsPath()}_${t}`
|
|
2222
2250
|
), n.addEventListener("input", (l) => {
|
|
@@ -2245,11 +2273,11 @@ class we extends x {
|
|
|
2245
2273
|
`#textarea-${e}`
|
|
2246
2274
|
);
|
|
2247
2275
|
if (i && (!i.value || i.value.trim() === "")) {
|
|
2248
|
-
const
|
|
2276
|
+
const a = t || ((n = this.props.placeholder) == null ? void 0 : n.replace(
|
|
2249
2277
|
"{language}",
|
|
2250
2278
|
e.toUpperCase()
|
|
2251
2279
|
)) || `Enter text in ${e.toUpperCase()}...`;
|
|
2252
|
-
i.setAttribute("data-full-placeholder",
|
|
2280
|
+
i.setAttribute("data-full-placeholder", a), this.adaptPlaceholderToSingleLine(i, a);
|
|
2253
2281
|
}
|
|
2254
2282
|
});
|
|
2255
2283
|
}
|
|
@@ -2261,17 +2289,17 @@ class we extends x {
|
|
|
2261
2289
|
}
|
|
2262
2290
|
const e = document.createElement("div");
|
|
2263
2291
|
e.classList.add("simple-multi-language-content"), this.props.languages.forEach((s) => {
|
|
2264
|
-
var
|
|
2265
|
-
const n = ((
|
|
2266
|
-
e.appendChild(
|
|
2292
|
+
var o;
|
|
2293
|
+
const n = ((o = this.value) == null ? void 0 : o[s]) || "", a = this.createTextareaRow(s, n);
|
|
2294
|
+
e.appendChild(a);
|
|
2267
2295
|
}), t.appendChild(e), this.container = t;
|
|
2268
2296
|
const i = () => {
|
|
2269
2297
|
if (!this.container) return;
|
|
2270
2298
|
this.container.querySelectorAll(
|
|
2271
2299
|
".simple-language-textarea"
|
|
2272
2300
|
).forEach((n) => {
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2301
|
+
const a = n.getAttribute("data-full-placeholder") || "";
|
|
2302
|
+
a && this.adaptPlaceholderToSingleLine(n, a);
|
|
2275
2303
|
});
|
|
2276
2304
|
};
|
|
2277
2305
|
return window.addEventListener("resize", i), t;
|
|
@@ -2323,26 +2351,26 @@ class xe extends x {
|
|
|
2323
2351
|
}
|
|
2324
2352
|
}
|
|
2325
2353
|
const ut = (c, t, e) => {
|
|
2326
|
-
let i = !1, s = 0, n = 0,
|
|
2354
|
+
let i = !1, s = 0, n = 0, a = 0, o = 0;
|
|
2327
2355
|
const l = (h) => {
|
|
2328
2356
|
if (h.target.closest("button")) return;
|
|
2329
2357
|
i = !0, s = h.clientX, n = h.clientY;
|
|
2330
2358
|
const d = t.getBoundingClientRect();
|
|
2331
|
-
|
|
2359
|
+
a = d.left, o = d.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup", p), document.body.style.userSelect = "none";
|
|
2332
2360
|
}, r = (h) => {
|
|
2333
2361
|
if (!i) return;
|
|
2334
|
-
const d = h.clientX - s,
|
|
2335
|
-
let
|
|
2336
|
-
|
|
2362
|
+
const d = h.clientX - s, g = h.clientY - n, C = window.innerWidth, m = window.innerHeight, u = t.offsetWidth, f = t.offsetHeight;
|
|
2363
|
+
let v = a + d, y = o + g;
|
|
2364
|
+
v = Math.max(8, Math.min(C - u - 8, v)), y = Math.max(8, Math.min(m - f - 8, y)), t.style.left = `${v}px`, t.style.top = `${y}px`, e == null || e(v, y);
|
|
2337
2365
|
}, p = () => {
|
|
2338
2366
|
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", p), document.body.style.userSelect = "";
|
|
2339
2367
|
};
|
|
2340
2368
|
c.addEventListener("mousedown", l);
|
|
2341
|
-
},
|
|
2369
|
+
}, U = (c) => {
|
|
2342
2370
|
if (!c) return null;
|
|
2343
2371
|
let t = c.trim();
|
|
2344
2372
|
return !t.startsWith("#") || (t = t.slice(1), t.length === 3 && (t = t.split("").map((e) => e + e).join("")), !/^[0-9a-fA-F]{6}$/.test(t)) ? null : `#${t.toUpperCase()}`;
|
|
2345
|
-
}, J = (c, t, e) => `#${[c, t, e].map((i) => Math.max(0, Math.min(255, i)).toString(16).padStart(2, "0")).join("")}`,
|
|
2373
|
+
}, J = (c, t, e) => `#${[c, t, e].map((i) => Math.max(0, Math.min(255, i)).toString(16).padStart(2, "0")).join("")}`, N = (c) => {
|
|
2346
2374
|
const t = c.replace("#", ""), e = t.length === 3 ? t.split("").map((i) => i + i).join("") : t;
|
|
2347
2375
|
return {
|
|
2348
2376
|
r: parseInt(e.slice(0, 2), 16),
|
|
@@ -2350,35 +2378,35 @@ const ut = (c, t, e) => {
|
|
|
2350
2378
|
b: parseInt(e.slice(4, 6), 16)
|
|
2351
2379
|
};
|
|
2352
2380
|
}, R = (c) => {
|
|
2353
|
-
const { r: t, g: e, b: i } =
|
|
2381
|
+
const { r: t, g: e, b: i } = N(c), s = t / 255, n = e / 255, a = i / 255, o = Math.max(s, n, a), l = Math.min(s, n, a), r = o - l;
|
|
2354
2382
|
let p = 0;
|
|
2355
|
-
r !== 0 && (
|
|
2356
|
-
const h =
|
|
2383
|
+
r !== 0 && (o === s ? p = (n - a) / r % 6 : o === n ? p = (a - s) / r + 2 : p = (s - n) / r + 4), p < 0 && (p += 6);
|
|
2384
|
+
const h = o === 0 ? 0 : r / o, d = o;
|
|
2357
2385
|
return { h: p * 60, s: h, v: d };
|
|
2358
|
-
},
|
|
2359
|
-
const i = (c % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)),
|
|
2360
|
-
let
|
|
2361
|
-
return i < 60 ? (
|
|
2362
|
-
Math.round((
|
|
2363
|
-
Math.round((l +
|
|
2364
|
-
Math.round((r +
|
|
2386
|
+
}, W = (c, t, e) => {
|
|
2387
|
+
const i = (c % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)), a = e - s;
|
|
2388
|
+
let o = 0, l = 0, r = 0;
|
|
2389
|
+
return i < 60 ? (o = s, l = n, r = 0) : i < 120 ? (o = n, l = s, r = 0) : i < 180 ? (o = 0, l = s, r = n) : i < 240 ? (o = 0, l = n, r = s) : i < 300 ? (o = n, l = 0, r = s) : (o = s, l = 0, r = n), J(
|
|
2390
|
+
Math.round((o + a) * 255),
|
|
2391
|
+
Math.round((l + a) * 255),
|
|
2392
|
+
Math.round((r + a) * 255)
|
|
2365
2393
|
);
|
|
2366
2394
|
}, gt = (c, t, e) => {
|
|
2367
2395
|
const i = e * (1 - t / 2), s = i === 0 || i === 1 ? 0 : (e - i) / Math.min(i, 1 - i);
|
|
2368
2396
|
return { hue: c, sat: s, lightness: i };
|
|
2369
2397
|
}, it = (c, t, e) => {
|
|
2370
2398
|
const i = (1 - Math.abs(2 * e - 1)) * t, s = i * (1 - Math.abs(c / 60 % 2 - 1)), n = e - i / 2;
|
|
2371
|
-
let
|
|
2372
|
-
return c < 60 ? (
|
|
2373
|
-
r: Math.round((
|
|
2374
|
-
g: Math.round((
|
|
2399
|
+
let a = 0, o = 0, l = 0;
|
|
2400
|
+
return c < 60 ? (a = i, o = s, l = 0) : c < 120 ? (a = s, o = i, l = 0) : c < 180 ? (a = 0, o = i, l = s) : c < 240 ? (a = 0, o = s, l = i) : c < 300 ? (a = s, o = 0, l = i) : (a = i, o = 0, l = s), {
|
|
2401
|
+
r: Math.round((a + n) * 255),
|
|
2402
|
+
g: Math.round((o + n) * 255),
|
|
2375
2403
|
b: Math.round((l + n) * 255)
|
|
2376
2404
|
};
|
|
2377
2405
|
}, st = (c, t) => {
|
|
2378
2406
|
const e = Math.max(0, Math.min(100, t)) / 100;
|
|
2379
2407
|
if (c.startsWith("#")) {
|
|
2380
|
-
const { r: s, g: n, b:
|
|
2381
|
-
return `rgba(${s}, ${n}, ${
|
|
2408
|
+
const { r: s, g: n, b: a } = N(c);
|
|
2409
|
+
return `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
2382
2410
|
}
|
|
2383
2411
|
if (c.startsWith("rgba("))
|
|
2384
2412
|
return c.replace(/,\s*[\d.]+\)$/, `, ${e})`);
|
|
@@ -2387,29 +2415,29 @@ const ut = (c, t, e) => {
|
|
|
2387
2415
|
if (c.startsWith("hsl(")) {
|
|
2388
2416
|
const s = c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2389
2417
|
if (s) {
|
|
2390
|
-
const { r: n, g:
|
|
2418
|
+
const { r: n, g: a, b: o } = it(
|
|
2391
2419
|
parseInt(s[1]),
|
|
2392
2420
|
parseInt(s[2]) / 100,
|
|
2393
2421
|
parseInt(s[3]) / 100
|
|
2394
2422
|
);
|
|
2395
|
-
return `rgba(${n}, ${
|
|
2423
|
+
return `rgba(${n}, ${a}, ${o}, ${e})`;
|
|
2396
2424
|
}
|
|
2397
2425
|
}
|
|
2398
2426
|
if (c.startsWith("hsla(")) {
|
|
2399
2427
|
const s = c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);
|
|
2400
2428
|
if (s) {
|
|
2401
|
-
const { r: n, g:
|
|
2429
|
+
const { r: n, g: a, b: o } = it(
|
|
2402
2430
|
parseInt(s[1]),
|
|
2403
2431
|
parseInt(s[2]) / 100,
|
|
2404
2432
|
parseInt(s[3]) / 100
|
|
2405
2433
|
);
|
|
2406
|
-
return `rgba(${n}, ${
|
|
2434
|
+
return `rgba(${n}, ${a}, ${o}, ${e})`;
|
|
2407
2435
|
}
|
|
2408
2436
|
}
|
|
2409
|
-
const i =
|
|
2437
|
+
const i = U(c);
|
|
2410
2438
|
if (i) {
|
|
2411
|
-
const { r: s, g: n, b:
|
|
2412
|
-
return `rgba(${s}, ${n}, ${
|
|
2439
|
+
const { r: s, g: n, b: a } = N(i);
|
|
2440
|
+
return `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
2413
2441
|
}
|
|
2414
2442
|
return c;
|
|
2415
2443
|
}, qt = (c) => [
|
|
@@ -2443,15 +2471,15 @@ const ut = (c, t, e) => {
|
|
|
2443
2471
|
/^[a-zA-Z]+$/
|
|
2444
2472
|
].some((e) => e.test(c.trim())), _t = (c) => {
|
|
2445
2473
|
if (typeof document > "u")
|
|
2446
|
-
return mt(c) || !!
|
|
2474
|
+
return mt(c) || !!U(c);
|
|
2447
2475
|
const t = document.createElement("div");
|
|
2448
2476
|
return t.style.color = c, t.style.color !== "";
|
|
2449
2477
|
}, ft = (c) => {
|
|
2450
2478
|
const t = c.trim();
|
|
2451
2479
|
if (/^#[0-9A-Fa-f]{8}$/.test(t)) {
|
|
2452
|
-
const n = t.slice(1),
|
|
2480
|
+
const n = t.slice(1), a = parseInt(n.slice(0, 2), 16), o = parseInt(n.slice(2, 4), 16), l = parseInt(n.slice(4, 6), 16), r = parseInt(n.slice(6, 8), 16);
|
|
2453
2481
|
return {
|
|
2454
|
-
color: J(
|
|
2482
|
+
color: J(a, o, l),
|
|
2455
2483
|
position: 0,
|
|
2456
2484
|
opacity: Math.round(r / 255 * 100)
|
|
2457
2485
|
};
|
|
@@ -2460,9 +2488,9 @@ const ut = (c, t, e) => {
|
|
|
2460
2488
|
/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/
|
|
2461
2489
|
);
|
|
2462
2490
|
if (e) {
|
|
2463
|
-
const n = parseInt(e[1]),
|
|
2491
|
+
const n = parseInt(e[1]), a = parseInt(e[2]), o = parseInt(e[3]), l = e[4] ? parseFloat(e[4]) : 1;
|
|
2464
2492
|
return {
|
|
2465
|
-
color: J(n,
|
|
2493
|
+
color: J(n, a, o),
|
|
2466
2494
|
position: 0,
|
|
2467
2495
|
opacity: Math.round(l * 100)
|
|
2468
2496
|
};
|
|
@@ -2471,18 +2499,18 @@ const ut = (c, t, e) => {
|
|
|
2471
2499
|
/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/
|
|
2472
2500
|
);
|
|
2473
2501
|
if (i) {
|
|
2474
|
-
const { r: n, g:
|
|
2502
|
+
const { r: n, g: a, b: o } = it(
|
|
2475
2503
|
parseFloat(i[1]),
|
|
2476
2504
|
parseFloat(i[2]) / 100,
|
|
2477
2505
|
parseFloat(i[3]) / 100
|
|
2478
2506
|
), l = i[4] ? parseFloat(i[4]) : 1;
|
|
2479
2507
|
return {
|
|
2480
|
-
color: J(n,
|
|
2508
|
+
color: J(n, a, o),
|
|
2481
2509
|
position: 0,
|
|
2482
2510
|
opacity: Math.round(l * 100)
|
|
2483
2511
|
};
|
|
2484
2512
|
}
|
|
2485
|
-
return { color:
|
|
2513
|
+
return { color: U(t) || t, position: 0, opacity: 100 };
|
|
2486
2514
|
}, rt = (c) => {
|
|
2487
2515
|
const t = [];
|
|
2488
2516
|
let e = "", i = 0;
|
|
@@ -2501,10 +2529,10 @@ const ut = (c, t, e) => {
|
|
|
2501
2529
|
const e = new RegExp(`${t}\\s*\\(`, "i"), i = c.match(e);
|
|
2502
2530
|
if (!i) return null;
|
|
2503
2531
|
const s = i.index + i[0].length;
|
|
2504
|
-
let n = 1,
|
|
2505
|
-
for (let
|
|
2506
|
-
c[
|
|
2507
|
-
return n === 0 ? c.substring(s,
|
|
2532
|
+
let n = 1, a = s;
|
|
2533
|
+
for (let o = s; o < c.length && n > 0; o++)
|
|
2534
|
+
c[o] === "(" ? n++ : c[o] === ")" && n--, a = o;
|
|
2535
|
+
return n === 0 ? c.substring(s, a) : null;
|
|
2508
2536
|
}, Jt = (c) => {
|
|
2509
2537
|
const t = c.split(" ")[0].toLowerCase();
|
|
2510
2538
|
return [
|
|
@@ -2523,13 +2551,13 @@ const ut = (c, t, e) => {
|
|
|
2523
2551
|
return c.forEach((e, i) => {
|
|
2524
2552
|
const s = e.trim();
|
|
2525
2553
|
if (!s) return;
|
|
2526
|
-
let n = "",
|
|
2527
|
-
const
|
|
2528
|
-
|
|
2554
|
+
let n = "", a = 0;
|
|
2555
|
+
const o = s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);
|
|
2556
|
+
o && mt(o[1].trim()) ? (n = o[1].trim(), a = parseFloat(o[2])) : (n = s, a = c.length === 1 ? 0 : i / (c.length - 1) * 100);
|
|
2529
2557
|
const l = ft(n);
|
|
2530
|
-
l.position = Math.max(0, Math.min(100, Math.round(
|
|
2558
|
+
l.position = Math.max(0, Math.min(100, Math.round(a))), t.push(l);
|
|
2531
2559
|
}), t;
|
|
2532
|
-
},
|
|
2560
|
+
}, H = (c) => {
|
|
2533
2561
|
const t = c.stops && c.stops.length ? c.stops : [{ color: "#000000", position: 0, opacity: 100 }];
|
|
2534
2562
|
return {
|
|
2535
2563
|
type: c.type && ["linear", "radial", "solid"].includes(c.type) ? c.type : "linear",
|
|
@@ -2540,21 +2568,21 @@ const ut = (c, t, e) => {
|
|
|
2540
2568
|
opacity: e.opacity === void 0 || Number.isNaN(e.opacity) ? 100 : e.opacity
|
|
2541
2569
|
}))
|
|
2542
2570
|
};
|
|
2543
|
-
},
|
|
2571
|
+
}, I = (c) => {
|
|
2544
2572
|
const t = c.replace(/;$/, "").trim();
|
|
2545
2573
|
if (_t(t)) {
|
|
2546
2574
|
const s = ft(t);
|
|
2547
|
-
return
|
|
2575
|
+
return H({ type: "solid", angle: 0, stops: [s] });
|
|
2548
2576
|
}
|
|
2549
2577
|
const e = ct(t, "linear-gradient");
|
|
2550
2578
|
if (e) {
|
|
2551
2579
|
const s = rt(e);
|
|
2552
|
-
let n = 90,
|
|
2553
|
-
const
|
|
2554
|
-
if (
|
|
2555
|
-
const r =
|
|
2556
|
-
r && (n = parseFloat(r[1]),
|
|
2557
|
-
} else
|
|
2580
|
+
let n = 90, a = s;
|
|
2581
|
+
const o = s[0];
|
|
2582
|
+
if (o.includes("deg")) {
|
|
2583
|
+
const r = o.match(/(-?\d+(?:\.\d+)?)deg/);
|
|
2584
|
+
r && (n = parseFloat(r[1]), a = s.slice(1));
|
|
2585
|
+
} else o.includes("to ") && (n = {
|
|
2558
2586
|
"to right": 90,
|
|
2559
2587
|
"to left": 270,
|
|
2560
2588
|
"to bottom": 180,
|
|
@@ -2563,14 +2591,14 @@ const ut = (c, t, e) => {
|
|
|
2563
2591
|
"to bottom left": 225,
|
|
2564
2592
|
"to top right": 45,
|
|
2565
2593
|
"to top left": 315
|
|
2566
|
-
}[
|
|
2567
|
-
const l = ht(
|
|
2568
|
-
return l.length ?
|
|
2594
|
+
}[o] ?? 90, a = s.slice(1));
|
|
2595
|
+
const l = ht(a);
|
|
2596
|
+
return l.length ? H({ type: "linear", angle: n, stops: l }) : null;
|
|
2569
2597
|
}
|
|
2570
2598
|
const i = ct(t, "radial-gradient");
|
|
2571
2599
|
if (i) {
|
|
2572
|
-
const s = rt(i), n = s[0] && !Jt(s[0]) ? s.slice(1) : s,
|
|
2573
|
-
return
|
|
2600
|
+
const s = rt(i), n = s[0] && !Jt(s[0]) ? s.slice(1) : s, a = ht(n);
|
|
2601
|
+
return a.length ? H({ type: "radial", angle: 0, stops: a }) : null;
|
|
2574
2602
|
}
|
|
2575
2603
|
return null;
|
|
2576
2604
|
}, O = (c) => {
|
|
@@ -2578,8 +2606,8 @@ const ut = (c, t, e) => {
|
|
|
2578
2606
|
const e = c.stops[0], i = e.color;
|
|
2579
2607
|
if (i.startsWith("var(--"))
|
|
2580
2608
|
return i;
|
|
2581
|
-
const s = e.opacity ?? 100, n = i.replace("#", ""),
|
|
2582
|
-
return `#${n}${
|
|
2609
|
+
const s = e.opacity ?? 100, n = i.replace("#", ""), a = Math.round(s / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
2610
|
+
return `#${n}${a}`;
|
|
2583
2611
|
}
|
|
2584
2612
|
const t = c.stops.map(
|
|
2585
2613
|
(e) => `${st(e.color, e.opacity ?? 100)} ${e.position}%`
|
|
@@ -2614,8 +2642,8 @@ const ut = (c, t, e) => {
|
|
|
2614
2642
|
static normalizeList(t) {
|
|
2615
2643
|
const e = /* @__PURE__ */ new Set(), i = [];
|
|
2616
2644
|
return t.forEach((s) => {
|
|
2617
|
-
let n =
|
|
2618
|
-
n ||
|
|
2645
|
+
let n = U(s);
|
|
2646
|
+
n || I(s) && (n = s), n && (e.has(n) || (e.add(n), i.push(n)));
|
|
2619
2647
|
}), i.slice(0, this.MAX_COLORS);
|
|
2620
2648
|
}
|
|
2621
2649
|
static ensureLoaded() {
|
|
@@ -2652,24 +2680,24 @@ const ut = (c, t, e) => {
|
|
|
2652
2680
|
static getColors(t) {
|
|
2653
2681
|
if (t === "all") {
|
|
2654
2682
|
const e = this.list("solid"), i = this.list("gradient"), s = [], n = Math.max(e.length, i.length);
|
|
2655
|
-
for (let
|
|
2656
|
-
|
|
2683
|
+
for (let a = 0; a < n; a++)
|
|
2684
|
+
a < e.length && s.push(e[a]), a < i.length && s.push(i[a]);
|
|
2657
2685
|
return this.normalizeList(s);
|
|
2658
2686
|
}
|
|
2659
2687
|
return [...this.list(t)];
|
|
2660
2688
|
}
|
|
2661
2689
|
static addColor(t, e) {
|
|
2662
2690
|
if (!t) return;
|
|
2663
|
-
let i =
|
|
2691
|
+
let i = U(t), s = "solid";
|
|
2664
2692
|
if (i)
|
|
2665
2693
|
s = "solid";
|
|
2666
2694
|
else {
|
|
2667
|
-
const l =
|
|
2695
|
+
const l = I(t);
|
|
2668
2696
|
l && (i = t, s = l.type === "solid" ? "solid" : "gradient");
|
|
2669
2697
|
}
|
|
2670
2698
|
if (!i) return;
|
|
2671
|
-
const n = e === "all" ? s : e,
|
|
2672
|
-
|
|
2699
|
+
const n = e === "all" ? s : e, a = this.list(n), o = a.indexOf(i);
|
|
2700
|
+
o !== -1 && a.splice(o, 1), a.unshift(i), a.length > this.MAX_COLORS && (a.length = this.MAX_COLORS), this.persist();
|
|
2673
2701
|
}
|
|
2674
2702
|
};
|
|
2675
2703
|
z.STORAGE_KEY = "settingsLib_recentColors", z.MAX_COLORS = 12, z.colors = null;
|
|
@@ -2683,31 +2711,31 @@ const ot = (c, t) => {
|
|
|
2683
2711
|
s.className = "color-picker-tooltip", s.style.display = "none", e.appendChild(s);
|
|
2684
2712
|
const n = () => {
|
|
2685
2713
|
s.style.display = "none";
|
|
2686
|
-
},
|
|
2714
|
+
}, a = (p, h) => {
|
|
2687
2715
|
const d = p.getBoundingClientRect();
|
|
2688
2716
|
s.textContent = h, s.style.left = `${d.left + d.width / 2}px`, s.style.top = `${d.bottom + 8}px`, s.style.display = "block";
|
|
2689
|
-
},
|
|
2690
|
-
|
|
2717
|
+
}, o = document.createElement("div");
|
|
2718
|
+
o.className = "color-picker-recent-grid";
|
|
2691
2719
|
const l = document.createElement("div");
|
|
2692
|
-
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(o), e.appendChild(l);
|
|
2693
2721
|
const r = () => {
|
|
2694
|
-
n(),
|
|
2722
|
+
n(), o.innerHTML = "";
|
|
2695
2723
|
const p = D.getColors(t);
|
|
2696
2724
|
if (p.length === 0) {
|
|
2697
|
-
|
|
2725
|
+
o.style.display = "none", l.style.display = "block";
|
|
2698
2726
|
return;
|
|
2699
2727
|
}
|
|
2700
|
-
|
|
2728
|
+
o.style.display = "grid", l.style.display = "none", p.forEach((h) => {
|
|
2701
2729
|
const d = document.createElement("button");
|
|
2702
2730
|
d.type = "button", d.className = "color-picker-recent-swatch";
|
|
2703
|
-
const
|
|
2704
|
-
if (d.title =
|
|
2731
|
+
const g = Xt(h);
|
|
2732
|
+
if (d.title = g, d.setAttribute("aria-label", `Use color: ${g}`), h.includes("gradient(")) {
|
|
2705
2733
|
d.style.backgroundImage = h, d.style.backgroundColor = "transparent";
|
|
2706
|
-
const m =
|
|
2734
|
+
const m = I(h);
|
|
2707
2735
|
m && m.stops && m.stops.length > 0 && (d.style.borderColor = m.stops[0].color);
|
|
2708
2736
|
} else
|
|
2709
2737
|
d.style.backgroundColor = h, d.style.borderColor = h;
|
|
2710
|
-
d.addEventListener("mouseenter", () =>
|
|
2738
|
+
d.addEventListener("mouseenter", () => a(d, g)), d.addEventListener("mouseleave", () => {
|
|
2711
2739
|
n(), d.style.boxShadow = "";
|
|
2712
2740
|
}), d.addEventListener("mousedown", () => {
|
|
2713
2741
|
d.style.boxShadow = "0px 0px 0px 2px var(--grey40)";
|
|
@@ -2717,17 +2745,17 @@ const ot = (c, t) => {
|
|
|
2717
2745
|
}, 150);
|
|
2718
2746
|
}), d.addEventListener("click", () => {
|
|
2719
2747
|
n(), c(h);
|
|
2720
|
-
}),
|
|
2748
|
+
}), o.appendChild(d);
|
|
2721
2749
|
});
|
|
2722
2750
|
};
|
|
2723
2751
|
return r(), { container: e, refresh: r };
|
|
2724
2752
|
}, Xt = (c) => {
|
|
2725
|
-
const t =
|
|
2753
|
+
const t = I(c);
|
|
2726
2754
|
if (t)
|
|
2727
2755
|
return Z(t);
|
|
2728
|
-
const e =
|
|
2756
|
+
const e = U(c);
|
|
2729
2757
|
if (e) {
|
|
2730
|
-
const i =
|
|
2758
|
+
const i = N(e);
|
|
2731
2759
|
return `${e} (RGB: ${i.r}, ${i.g}, ${i.b})`;
|
|
2732
2760
|
}
|
|
2733
2761
|
return c;
|
|
@@ -2772,8 +2800,8 @@ class dt {
|
|
|
2772
2800
|
if (Array.from(n).some(
|
|
2773
2801
|
(l) => l.contains(s)
|
|
2774
2802
|
)) return;
|
|
2775
|
-
const
|
|
2776
|
-
|
|
2803
|
+
const o = document.querySelector(".gradient-popover");
|
|
2804
|
+
o && o.contains(s) || (i.preventDefault(), i.stopPropagation(), this.close(!0));
|
|
2777
2805
|
}, this.keyDown = (i) => {
|
|
2778
2806
|
if (this.isOpen) {
|
|
2779
2807
|
if (i.key === "Escape")
|
|
@@ -2801,10 +2829,10 @@ class dt {
|
|
|
2801
2829
|
s.className = "color-picker-close", s.innerHTML = vt, s.addEventListener("click", () => this.close(!0)), e.appendChild(i), e.appendChild(s), ut(e, t);
|
|
2802
2830
|
const n = document.createElement("div");
|
|
2803
2831
|
n.className = "color-picker-area", this.colorArea = n;
|
|
2804
|
-
const o = document.createElement("div");
|
|
2805
|
-
o.className = "color-picker-marker", this.colorMarker = o, n.appendChild(o);
|
|
2806
2832
|
const a = document.createElement("div");
|
|
2807
|
-
a.className = "color-picker-
|
|
2833
|
+
a.className = "color-picker-marker", this.colorMarker = a, n.appendChild(a);
|
|
2834
|
+
const o = document.createElement("div");
|
|
2835
|
+
o.className = "color-picker-sliders-container";
|
|
2808
2836
|
const l = document.createElement("button");
|
|
2809
2837
|
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML = Ct;
|
|
2810
2838
|
const r = document.createElement("div");
|
|
@@ -2815,88 +2843,88 @@ class dt {
|
|
|
2815
2843
|
h.className = "color-picker-hue-marker", this.hueMarker = h, p.appendChild(h);
|
|
2816
2844
|
const d = document.createElement("div");
|
|
2817
2845
|
d.className = "color-picker-opacity", this.opacitySlider = d;
|
|
2818
|
-
const
|
|
2819
|
-
|
|
2820
|
-
const
|
|
2846
|
+
const g = document.createElement("div");
|
|
2847
|
+
g.className = "color-picker-opacity-marker", this.opacityMarker = g, d.appendChild(g), r.appendChild(p), r.appendChild(d), o.appendChild(l), o.appendChild(r);
|
|
2848
|
+
const C = ot((b) => {
|
|
2821
2849
|
var E;
|
|
2822
2850
|
this.setColor(b), (E = this.onChange) == null || E.call(this, b, this.currentOpacity);
|
|
2823
2851
|
}, this.recentScope);
|
|
2824
|
-
this.recentSectionRefresh =
|
|
2852
|
+
this.recentSectionRefresh = C.refresh;
|
|
2825
2853
|
const m = document.createElement("div");
|
|
2826
2854
|
m.className = "color-picker-format-section";
|
|
2827
|
-
const
|
|
2828
|
-
|
|
2855
|
+
const u = document.createElement("select");
|
|
2856
|
+
u.className = "color-picker-format-select", this.select = u;
|
|
2857
|
+
const f = document.createElement("option");
|
|
2858
|
+
f.value = "hex", f.textContent = "HEX";
|
|
2829
2859
|
const v = document.createElement("option");
|
|
2830
|
-
v.value = "
|
|
2831
|
-
const C = document.createElement("option");
|
|
2832
|
-
C.value = "rgb", C.textContent = "RGB";
|
|
2860
|
+
v.value = "rgb", v.textContent = "RGB";
|
|
2833
2861
|
const y = document.createElement("option");
|
|
2834
|
-
y.value = "hsl", y.textContent = "HSL",
|
|
2862
|
+
y.value = "hsl", y.textContent = "HSL", u.appendChild(f), u.appendChild(v), u.appendChild(y);
|
|
2835
2863
|
const w = document.createElement("input");
|
|
2836
2864
|
w.type = "text", w.className = "color-picker-color-input", w.value = this.currentColor, this.input = w;
|
|
2837
2865
|
const k = document.createElement("div");
|
|
2838
2866
|
k.className = "color-picker-input-container";
|
|
2839
2867
|
const S = document.createElement("button");
|
|
2840
|
-
return S.className = "color-picker-copy-inside", S.textContent = "Copy", k.appendChild(w), k.appendChild(S), m.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(o), t.appendChild(C.container), t.appendChild(m), t.addEventListener("click", (b) => b.stopPropagation()), this.bind(n, p, d, w, u, S, l), t;
|
|
2841
2869
|
}
|
|
2842
2870
|
createBackdrop() {
|
|
2843
2871
|
const t = document.createElement("div");
|
|
2844
2872
|
return t.className = "color-picker-backdrop", t.style.display = "none", t.style.pointerEvents = "none", t;
|
|
2845
2873
|
}
|
|
2846
|
-
bind(t, e, i, s, n,
|
|
2874
|
+
bind(t, e, i, s, n, a, o) {
|
|
2847
2875
|
const l = (h) => {
|
|
2848
|
-
var
|
|
2849
|
-
const d = t.getBoundingClientRect(),
|
|
2850
|
-
this.colorMarker.style.left = `${
|
|
2851
|
-
const
|
|
2852
|
-
this.currentColor =
|
|
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);
|
|
2853
2881
|
}, r = (h) => {
|
|
2854
|
-
var
|
|
2882
|
+
var v;
|
|
2855
2883
|
const d = e.getBoundingClientRect();
|
|
2856
|
-
let
|
|
2857
|
-
this.hueMarker.style.left = `${
|
|
2858
|
-
const
|
|
2859
|
-
this.currentColor =
|
|
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);
|
|
2860
2888
|
}, p = (h) => {
|
|
2861
|
-
var
|
|
2862
|
-
const d = i.getBoundingClientRect(),
|
|
2863
|
-
this.opacityMarker.style.left = `${
|
|
2889
|
+
var C;
|
|
2890
|
+
const d = i.getBoundingClientRect(), g = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width));
|
|
2891
|
+
this.opacityMarker.style.left = `${g * 100}%`, this.currentOpacity = Math.round(g * 100), (C = this.onChange) == null || C.call(this, this.currentColor, this.currentOpacity);
|
|
2864
2892
|
};
|
|
2865
2893
|
t.addEventListener("mousedown", (h) => {
|
|
2866
2894
|
h.preventDefault(), l(h);
|
|
2867
|
-
const d = (
|
|
2868
|
-
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup",
|
|
2895
|
+
const d = (C) => l(C), g = () => {
|
|
2896
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g);
|
|
2869
2897
|
};
|
|
2870
|
-
document.addEventListener("mousemove", d), document.addEventListener("mouseup",
|
|
2898
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
2871
2899
|
}), e.addEventListener("mousedown", (h) => {
|
|
2872
2900
|
h.preventDefault(), r(h);
|
|
2873
|
-
const d = (
|
|
2874
|
-
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup",
|
|
2901
|
+
const d = (C) => r(C), g = () => {
|
|
2902
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g);
|
|
2875
2903
|
};
|
|
2876
|
-
document.addEventListener("mousemove", d), document.addEventListener("mouseup",
|
|
2904
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
2877
2905
|
}), i.addEventListener("mousedown", (h) => {
|
|
2878
2906
|
h.preventDefault(), p(h);
|
|
2879
|
-
const d = (
|
|
2880
|
-
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup",
|
|
2907
|
+
const d = (C) => p(C), g = () => {
|
|
2908
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g);
|
|
2881
2909
|
};
|
|
2882
|
-
document.addEventListener("mousemove", d), document.addEventListener("mouseup",
|
|
2910
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
2883
2911
|
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (h) => {
|
|
2884
2912
|
h.key === "Enter" && (h.preventDefault(), this.syncInput(), s.blur());
|
|
2885
|
-
}),
|
|
2913
|
+
}), a.addEventListener("click", async () => {
|
|
2886
2914
|
try {
|
|
2887
2915
|
await navigator.clipboard.writeText(s.value);
|
|
2888
2916
|
} catch {
|
|
2889
2917
|
s.select(), document.execCommand("copy");
|
|
2890
2918
|
}
|
|
2891
|
-
}),
|
|
2919
|
+
}), o.addEventListener("click", async () => {
|
|
2892
2920
|
var h;
|
|
2893
2921
|
if (!("EyeDropper" in window)) {
|
|
2894
2922
|
alert("EyeDropper API is not supported in this browser.");
|
|
2895
2923
|
return;
|
|
2896
2924
|
}
|
|
2897
2925
|
try {
|
|
2898
|
-
const d = new window.EyeDropper(), { sRGBHex:
|
|
2899
|
-
this.setColor(
|
|
2926
|
+
const d = new window.EyeDropper(), { sRGBHex: g } = await d.open();
|
|
2927
|
+
this.setColor(g), (h = this.onChange) == null || h.call(this, g, this.currentOpacity);
|
|
2900
2928
|
} catch {
|
|
2901
2929
|
}
|
|
2902
2930
|
}), document.addEventListener("keydown", this.keyDown, !0), setTimeout(
|
|
@@ -2905,22 +2933,22 @@ class dt {
|
|
|
2905
2933
|
);
|
|
2906
2934
|
}
|
|
2907
2935
|
setColor(t) {
|
|
2908
|
-
var
|
|
2936
|
+
var a;
|
|
2909
2937
|
this.currentColor = t;
|
|
2910
2938
|
const { h: e, s: i, v: s } = R(t), n = e >= 360 ? e % 360 : e;
|
|
2911
|
-
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(), (a = this.onChange) == null || a.call(this, t, this.currentOpacity);
|
|
2912
2940
|
}
|
|
2913
2941
|
syncInput() {
|
|
2914
2942
|
const t = this.select.value, { h: e, s: i, v: s } = R(this.currentColor);
|
|
2915
2943
|
if (t === "hex") this.input.value = this.currentColor;
|
|
2916
2944
|
else if (t === "rgb") {
|
|
2917
|
-
const { r: n, g:
|
|
2918
|
-
this.input.value = `rgb(${n}, ${
|
|
2945
|
+
const { r: n, g: a, b: o } = N(this.currentColor);
|
|
2946
|
+
this.input.value = `rgb(${n}, ${a}, ${o})`;
|
|
2919
2947
|
} else {
|
|
2920
|
-
const { hue: n, sat:
|
|
2948
|
+
const { hue: n, sat: a, lightness: o } = gt(e, i, s);
|
|
2921
2949
|
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
2922
|
-
|
|
2923
|
-
)}%, ${Math.round(
|
|
2950
|
+
a * 100
|
|
2951
|
+
)}%, ${Math.round(o * 100)}%)`;
|
|
2924
2952
|
}
|
|
2925
2953
|
}
|
|
2926
2954
|
applyFromInput() {
|
|
@@ -2930,20 +2958,20 @@ class dt {
|
|
|
2930
2958
|
else {
|
|
2931
2959
|
const i = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
2932
2960
|
if (i) {
|
|
2933
|
-
const s = parseInt(i[1]), n = parseInt(i[2]),
|
|
2934
|
-
s <= 255 && n <= 255 &&
|
|
2961
|
+
const s = parseInt(i[1]), n = parseInt(i[2]), a = parseInt(i[3]);
|
|
2962
|
+
s <= 255 && n <= 255 && a <= 255 && (e = `#${[s, n, a].map((o) => o.toString(16).padStart(2, "0")).join("")}`);
|
|
2935
2963
|
} else {
|
|
2936
2964
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2937
2965
|
if (s) {
|
|
2938
|
-
const n = parseInt(s[1]),
|
|
2939
|
-
e =
|
|
2966
|
+
const n = parseInt(s[1]), a = parseInt(s[2]) / 100, o = parseInt(s[3]) / 100, l = o + a * Math.min(o, 1 - o), r = l === 0 ? 0 : 2 * (1 - o / l);
|
|
2967
|
+
e = W(n, r, l);
|
|
2940
2968
|
}
|
|
2941
2969
|
}
|
|
2942
2970
|
}
|
|
2943
2971
|
e && this.setColor(e);
|
|
2944
2972
|
}
|
|
2945
2973
|
updateOpacityBg() {
|
|
2946
|
-
const { r: t, g: e, b: i } =
|
|
2974
|
+
const { r: t, g: e, b: i } = N(this.currentColor);
|
|
2947
2975
|
this.opacitySlider.style.setProperty(
|
|
2948
2976
|
"--base-color",
|
|
2949
2977
|
`rgb(${t}, ${e}, ${i})`
|
|
@@ -2952,14 +2980,14 @@ class dt {
|
|
|
2952
2980
|
open(t, e, i) {
|
|
2953
2981
|
var y;
|
|
2954
2982
|
this.currentColor = t, this.currentOpacity = i ?? 100, this.syncInput();
|
|
2955
|
-
const { h: s, s: n, v:
|
|
2956
|
-
this.hueMarker.style.left = `${s / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 -
|
|
2957
|
-
const
|
|
2958
|
-
let
|
|
2959
|
-
const m = p - r.right,
|
|
2960
|
-
m >=
|
|
2961
|
-
const
|
|
2962
|
-
|
|
2983
|
+
const { h: s, s: n, v: a } = R(t);
|
|
2984
|
+
this.hueMarker.style.left = `${s / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 - a) * 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 o = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(), p = window.innerWidth, h = window.innerHeight, d = 16;
|
|
2986
|
+
let g = r.right + 8, C = r.top;
|
|
2987
|
+
const m = p - r.right, u = r.left;
|
|
2988
|
+
m >= o + d ? g = r.right + 8 : u >= o + d ? g = r.left - o - 8 : g = Math.max(d, (p - o) / 2);
|
|
2989
|
+
const f = h - r.bottom, v = r.top;
|
|
2990
|
+
f >= l + d ? C = r.bottom + 8 : v >= l + d ? C = r.top - l - 8 : f > v ? (C = r.bottom + 8, C + l > h - d && (C = h - l - d)) : (C = r.top - l - 8, C < d && (C = d)), this.element.style.left = `${g}px`, this.element.style.top = `${C}px`;
|
|
2963
2991
|
}
|
|
2964
2992
|
close(t) {
|
|
2965
2993
|
var e;
|
|
@@ -2988,72 +3016,72 @@ class ie {
|
|
|
2988
3016
|
s.className = "color-picker-sliders-container embedded";
|
|
2989
3017
|
const n = document.createElement("button");
|
|
2990
3018
|
n.className = "color-picker-eyedropper", n.type = "button", n.innerHTML = Ct;
|
|
2991
|
-
const o = document.createElement("div");
|
|
2992
|
-
o.className = "color-picker-sliders-group";
|
|
2993
3019
|
const a = document.createElement("div");
|
|
2994
|
-
a.className = "color-picker-
|
|
3020
|
+
a.className = "color-picker-sliders-group";
|
|
3021
|
+
const o = document.createElement("div");
|
|
3022
|
+
o.className = "color-picker-hue embedded", this.hueSlider = o;
|
|
2995
3023
|
const l = document.createElement("div");
|
|
2996
|
-
l.className = "color-picker-hue-marker", this.hueMarker = l,
|
|
3024
|
+
l.className = "color-picker-hue-marker", this.hueMarker = l, o.appendChild(l);
|
|
2997
3025
|
const r = document.createElement("div");
|
|
2998
3026
|
r.className = "color-picker-opacity embedded", this.opacitySlider = r;
|
|
2999
3027
|
const p = document.createElement("div");
|
|
3000
|
-
p.className = "color-picker-opacity-marker", this.opacityMarker = p, r.appendChild(p),
|
|
3028
|
+
p.className = "color-picker-opacity-marker", this.opacityMarker = p, r.appendChild(p), a.appendChild(o), a.appendChild(r), s.appendChild(n), s.appendChild(a);
|
|
3001
3029
|
const h = ot((w) => {
|
|
3002
|
-
const k =
|
|
3030
|
+
const k = I(w);
|
|
3003
3031
|
k && k.type !== "solid" ? this.onColorChange(w, this.currentOpacity) : (this.setColor(w), this.onColorChange(this.currentColor, this.currentOpacity));
|
|
3004
3032
|
}, "all");
|
|
3005
3033
|
this.recentSectionRefresh = h.refresh;
|
|
3006
3034
|
const d = document.createElement("div");
|
|
3007
3035
|
d.className = "color-picker-format-section embedded";
|
|
3008
|
-
const
|
|
3009
|
-
|
|
3010
|
-
const
|
|
3011
|
-
|
|
3036
|
+
const g = document.createElement("select");
|
|
3037
|
+
g.className = "color-picker-format-select", this.select = g;
|
|
3038
|
+
const C = document.createElement("option");
|
|
3039
|
+
C.value = "hex", C.textContent = "HEX";
|
|
3012
3040
|
const m = document.createElement("option");
|
|
3013
3041
|
m.value = "rgb", m.textContent = "RGB";
|
|
3014
|
-
const
|
|
3015
|
-
|
|
3016
|
-
const
|
|
3017
|
-
|
|
3018
|
-
const
|
|
3019
|
-
|
|
3042
|
+
const u = document.createElement("option");
|
|
3043
|
+
u.value = "hsl", u.textContent = "HSL", g.appendChild(C), g.appendChild(m), g.appendChild(u);
|
|
3044
|
+
const f = document.createElement("input");
|
|
3045
|
+
f.type = "text", f.className = "color-picker-color-input", this.input = f;
|
|
3046
|
+
const v = document.createElement("div");
|
|
3047
|
+
v.className = "color-picker-input-container";
|
|
3020
3048
|
const y = document.createElement("button");
|
|
3021
|
-
return y.className = "color-picker-copy-inside", y.textContent = "Copy",
|
|
3049
|
+
return y.className = "color-picker-copy-inside", y.textContent = "Copy", v.appendChild(f), v.appendChild(y), d.appendChild(g), d.appendChild(v), t.appendChild(e), t.appendChild(s), t.appendChild(d), t.appendChild(h.container), this.bind(e, o, r, f, g, y, n), t;
|
|
3022
3050
|
}
|
|
3023
|
-
bind(t, e, i, s, n,
|
|
3051
|
+
bind(t, e, i, s, n, a, o) {
|
|
3024
3052
|
const l = (h) => {
|
|
3025
|
-
const d = t.getBoundingClientRect(),
|
|
3026
|
-
this.colorMarker.style.left = `${
|
|
3027
|
-
const
|
|
3028
|
-
this.currentColor =
|
|
3053
|
+
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));
|
|
3054
|
+
this.colorMarker.style.left = `${g * 100}%`, this.colorMarker.style.top = `${C * 100}%`;
|
|
3055
|
+
const u = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, f = W(u, g, 1 - C);
|
|
3056
|
+
this.currentColor = f, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
3029
3057
|
}, r = (h) => {
|
|
3030
|
-
const d = e.getBoundingClientRect(),
|
|
3031
|
-
this.hueMarker.style.left = `${
|
|
3032
|
-
const
|
|
3033
|
-
this.currentColor =
|
|
3034
|
-
linear-gradient(to right, #fff, hsl(${
|
|
3058
|
+
const d = e.getBoundingClientRect(), g = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width));
|
|
3059
|
+
this.hueMarker.style.left = `${g * 100}%`;
|
|
3060
|
+
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);
|
|
3061
|
+
this.currentColor = f, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
3062
|
+
linear-gradient(to right, #fff, hsl(${C}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
3035
3063
|
}, p = (h) => {
|
|
3036
|
-
const d = i.getBoundingClientRect(),
|
|
3037
|
-
this.opacityMarker.style.left = `${
|
|
3064
|
+
const d = i.getBoundingClientRect(), g = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width));
|
|
3065
|
+
this.opacityMarker.style.left = `${g * 100}%`, this.currentOpacity = Math.round(g * 100), this.queueChange();
|
|
3038
3066
|
};
|
|
3039
3067
|
t.addEventListener("mousedown", (h) => {
|
|
3040
3068
|
h.preventDefault(), this.isDragging = !0, l(h);
|
|
3041
|
-
const d = (
|
|
3042
|
-
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup",
|
|
3069
|
+
const d = (C) => l(C), g = () => {
|
|
3070
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g), this.applyPendingExternal();
|
|
3043
3071
|
};
|
|
3044
|
-
document.addEventListener("mousemove", d), document.addEventListener("mouseup",
|
|
3072
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
3045
3073
|
}), e.addEventListener("mousedown", (h) => {
|
|
3046
3074
|
h.preventDefault(), this.isDragging = !0, r(h);
|
|
3047
|
-
const d = (
|
|
3048
|
-
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup",
|
|
3075
|
+
const d = (C) => r(C), g = () => {
|
|
3076
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g), this.applyPendingExternal();
|
|
3049
3077
|
};
|
|
3050
|
-
document.addEventListener("mousemove", d), document.addEventListener("mouseup",
|
|
3078
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
3051
3079
|
}), i.addEventListener("mousedown", (h) => {
|
|
3052
3080
|
h.preventDefault(), this.isDragging = !0, p(h);
|
|
3053
|
-
const d = (
|
|
3054
|
-
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup",
|
|
3081
|
+
const d = (C) => p(C), g = () => {
|
|
3082
|
+
this.isDragging = !1, this.flushChange(), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", g), this.applyPendingExternal();
|
|
3055
3083
|
};
|
|
3056
|
-
document.addEventListener("mousemove", d), document.addEventListener("mouseup",
|
|
3084
|
+
document.addEventListener("mousemove", d), document.addEventListener("mouseup", g);
|
|
3057
3085
|
}), n.addEventListener("change", () => {
|
|
3058
3086
|
this.syncInput();
|
|
3059
3087
|
}), s.addEventListener("input", () => {
|
|
@@ -3062,13 +3090,13 @@ class ie {
|
|
|
3062
3090
|
this.syncInput();
|
|
3063
3091
|
}), s.addEventListener("keydown", (h) => {
|
|
3064
3092
|
h.key === "Enter" && (h.preventDefault(), this.syncInput(), s.blur());
|
|
3065
|
-
}),
|
|
3093
|
+
}), a.addEventListener("click", async () => {
|
|
3066
3094
|
try {
|
|
3067
3095
|
await navigator.clipboard.writeText(s.value);
|
|
3068
3096
|
} catch {
|
|
3069
3097
|
s.select(), document.execCommand("copy");
|
|
3070
3098
|
}
|
|
3071
|
-
}),
|
|
3099
|
+
}), o.addEventListener("click", async () => {
|
|
3072
3100
|
if (!("EyeDropper" in window)) {
|
|
3073
3101
|
alert("EyeDropper API is not supported in this browser.");
|
|
3074
3102
|
return;
|
|
@@ -3091,13 +3119,13 @@ class ie {
|
|
|
3091
3119
|
if (t === "hex")
|
|
3092
3120
|
this.input.value = this.currentColor;
|
|
3093
3121
|
else if (t === "rgb") {
|
|
3094
|
-
const { r: n, g:
|
|
3095
|
-
this.input.value = `rgb(${n}, ${
|
|
3122
|
+
const { r: n, g: a, b: o } = N(this.currentColor);
|
|
3123
|
+
this.input.value = `rgb(${n}, ${a}, ${o})`;
|
|
3096
3124
|
} else {
|
|
3097
|
-
const { hue: n, sat:
|
|
3125
|
+
const { hue: n, sat: a, lightness: o } = gt(e, i, s);
|
|
3098
3126
|
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
3099
|
-
|
|
3100
|
-
)}%, ${Math.round(
|
|
3127
|
+
a * 100
|
|
3128
|
+
)}%, ${Math.round(o * 100)}%)`;
|
|
3101
3129
|
}
|
|
3102
3130
|
}
|
|
3103
3131
|
applyFromInput() {
|
|
@@ -3108,20 +3136,20 @@ class ie {
|
|
|
3108
3136
|
else {
|
|
3109
3137
|
const i = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
3110
3138
|
if (i) {
|
|
3111
|
-
const s = parseInt(i[1], 10), n = parseInt(i[2], 10),
|
|
3112
|
-
s <= 255 && n <= 255 &&
|
|
3139
|
+
const s = parseInt(i[1], 10), n = parseInt(i[2], 10), a = parseInt(i[3], 10);
|
|
3140
|
+
s <= 255 && n <= 255 && a <= 255 && (e = "#" + [s, n, a].map((o) => o.toString(16).padStart(2, "0")).join(""));
|
|
3113
3141
|
} else {
|
|
3114
3142
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
3115
3143
|
if (s) {
|
|
3116
|
-
const n = parseInt(s[1], 10),
|
|
3117
|
-
e =
|
|
3144
|
+
const n = parseInt(s[1], 10), a = parseInt(s[2], 10) / 100, o = parseInt(s[3], 10) / 100, l = o + a * Math.min(o, 1 - o), r = l === 0 ? 0 : 2 * (1 - o / l);
|
|
3145
|
+
e = W(n, r, l);
|
|
3118
3146
|
}
|
|
3119
3147
|
}
|
|
3120
3148
|
}
|
|
3121
3149
|
e && (this.setColor(e), this.onColorChange(this.currentColor, this.currentOpacity));
|
|
3122
3150
|
}
|
|
3123
3151
|
updateOpacityBg() {
|
|
3124
|
-
const { r: t, g: e, b: i } =
|
|
3152
|
+
const { r: t, g: e, b: i } = N(this.currentColor);
|
|
3125
3153
|
this.opacitySlider.style.setProperty(
|
|
3126
3154
|
"--base-color",
|
|
3127
3155
|
`rgb(${t}, ${e}, ${i})`
|
|
@@ -3141,11 +3169,11 @@ class ie {
|
|
|
3141
3169
|
this.pendingExternalUpdate = void 0, this.initFromColor(t, e);
|
|
3142
3170
|
}
|
|
3143
3171
|
initFromColor(t, e) {
|
|
3144
|
-
var
|
|
3172
|
+
var o;
|
|
3145
3173
|
this.currentColor = t, this.currentOpacity = e;
|
|
3146
|
-
const { h: i, s, v: n } = R(t),
|
|
3147
|
-
this.hueMarker.style.left = `${
|
|
3148
|
-
linear-gradient(to right, #fff, hsl(${
|
|
3174
|
+
const { h: i, s, v: n } = R(t), a = i >= 360 ? i % 360 : i;
|
|
3175
|
+
this.hueMarker.style.left = `${a / 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(${a}, 100%, 50%))`, this.opacityMarker.style.left = `${e}%`, this.updateOpacityBg(), this.syncInput(), (o = this.recentSectionRefresh) == null || o.call(this);
|
|
3149
3177
|
}
|
|
3150
3178
|
commitRecentColor() {
|
|
3151
3179
|
var t;
|
|
@@ -3162,7 +3190,7 @@ class ie {
|
|
|
3162
3190
|
this.initFromColor(t, e);
|
|
3163
3191
|
}
|
|
3164
3192
|
}
|
|
3165
|
-
const
|
|
3193
|
+
const $ = class $ extends x {
|
|
3166
3194
|
constructor(t = {}) {
|
|
3167
3195
|
const e = typeof t.default == "string" ? void 0 : t.default;
|
|
3168
3196
|
super({
|
|
@@ -3176,14 +3204,14 @@ const H = class H extends x {
|
|
|
3176
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) => {
|
|
3177
3205
|
var d;
|
|
3178
3206
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
3179
|
-
const s = i.target, n = this.popoverEl.contains(s),
|
|
3207
|
+
const s = i.target, n = this.popoverEl.contains(s), a = (d = this.element) == null ? void 0 : d.contains(s), o = document.querySelectorAll(".custom-color-picker"), l = Array.from(o).some((g) => g.contains(s)), r = s.closest(
|
|
3180
3208
|
".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"
|
|
3181
3209
|
), p = s.classList.contains(
|
|
3182
3210
|
"color-picker-backdrop"
|
|
3183
3211
|
), h = s.classList.contains(
|
|
3184
3212
|
"gradient-popover-backdrop"
|
|
3185
3213
|
);
|
|
3186
|
-
!n && !
|
|
3214
|
+
!n && !a && !l && !r && !p && !h && this.closePopover();
|
|
3187
3215
|
}, this.handlePopoverKeydown = (i) => {
|
|
3188
3216
|
if (this.isPopoverOpen) {
|
|
3189
3217
|
if (i.key === "Escape") {
|
|
@@ -3236,16 +3264,16 @@ const H = class H extends x {
|
|
|
3236
3264
|
const t = this.originalDefault;
|
|
3237
3265
|
if (typeof t == "string") {
|
|
3238
3266
|
if (t.startsWith("var(--"))
|
|
3239
|
-
return
|
|
3267
|
+
return H({
|
|
3240
3268
|
type: "solid",
|
|
3241
3269
|
angle: 0,
|
|
3242
3270
|
stops: [{ color: t, position: 0, opacity: 100 }]
|
|
3243
3271
|
});
|
|
3244
|
-
const i =
|
|
3272
|
+
const i = I(t);
|
|
3245
3273
|
if (i)
|
|
3246
|
-
return
|
|
3274
|
+
return H(i);
|
|
3247
3275
|
}
|
|
3248
|
-
return
|
|
3276
|
+
return H(t && typeof t == "object" ? t : {
|
|
3249
3277
|
type: "linear",
|
|
3250
3278
|
angle: 90,
|
|
3251
3279
|
stops: [
|
|
@@ -3256,11 +3284,11 @@ const H = class H extends x {
|
|
|
3256
3284
|
}
|
|
3257
3285
|
setValue(t) {
|
|
3258
3286
|
let e = null;
|
|
3259
|
-
typeof t == "string" ? t.startsWith("var(--") ? e =
|
|
3287
|
+
typeof t == "string" ? t.startsWith("var(--") ? e = H({
|
|
3260
3288
|
type: "solid",
|
|
3261
3289
|
angle: 0,
|
|
3262
3290
|
stops: [{ color: t, position: 0, opacity: 100 }]
|
|
3263
|
-
}) : e =
|
|
3291
|
+
}) : e = I(t) : t && typeof t == "object" && (e = H(t)), e || (e = this.defaultValue()), this.value = e, this.setLinkedGlobalVariableFrom(t ?? e), this.updateUI(), this.isPopoverOpen && this.refreshPopoverContent(), this.triggerChange(), this.pendingSolidColor = null, this.updateUnlinkButtonVisibility();
|
|
3264
3292
|
}
|
|
3265
3293
|
updateUI() {
|
|
3266
3294
|
if (this.previewEl && this.value)
|
|
@@ -3321,8 +3349,8 @@ const H = class H extends x {
|
|
|
3321
3349
|
if (n === 100)
|
|
3322
3350
|
this.inputEl.value = s;
|
|
3323
3351
|
else {
|
|
3324
|
-
const
|
|
3325
|
-
this.inputEl.value = `${s}${
|
|
3352
|
+
const o = Math.round(n / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
3353
|
+
this.inputEl.value = `${s}${o}`;
|
|
3326
3354
|
}
|
|
3327
3355
|
}
|
|
3328
3356
|
} else
|
|
@@ -3364,12 +3392,12 @@ const H = class H extends x {
|
|
|
3364
3392
|
s.className = "gradient-editor";
|
|
3365
3393
|
const n = document.createElement("div");
|
|
3366
3394
|
n.className = "type-tabs-wrapper";
|
|
3367
|
-
const
|
|
3368
|
-
n.appendChild(
|
|
3369
|
-
const
|
|
3370
|
-
if (
|
|
3395
|
+
const a = this.createTypeTabs();
|
|
3396
|
+
n.appendChild(a), s.appendChild(n);
|
|
3397
|
+
const o = document.createElement("div");
|
|
3398
|
+
if (o.className = "gradient-editor-content", this.updatePopoverContent(o), s.appendChild(o), this.variant !== "global" && e) {
|
|
3371
3399
|
const l = e.children[0], r = e.children[1], p = (h) => {
|
|
3372
|
-
this.currentMode = h, h === "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(
|
|
3400
|
+
this.currentMode = h, h === "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(o);
|
|
3373
3401
|
};
|
|
3374
3402
|
l.addEventListener("click", () => p("custom")), r.addEventListener("click", () => p("global")), this.isBoundToGlobal() ? (this.currentMode = "global", p("global")) : (this.currentMode = "custom", p("custom"));
|
|
3375
3403
|
}
|
|
@@ -3383,9 +3411,9 @@ const H = class H extends x {
|
|
|
3383
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"));
|
|
3384
3412
|
const i = document.createElement("button");
|
|
3385
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", () => {
|
|
3386
|
-
var
|
|
3387
|
-
const
|
|
3388
|
-
this.switchType(
|
|
3414
|
+
var o, l;
|
|
3415
|
+
const a = ((o = this.value) == null ? void 0 : o.type) === "solid" ? "linear" : ((l = this.value) == null ? void 0 : l.type) || "linear";
|
|
3416
|
+
this.switchType(a);
|
|
3389
3417
|
}), t.appendChild(e), t.appendChild(i), t;
|
|
3390
3418
|
}
|
|
3391
3419
|
switchType(t) {
|
|
@@ -3396,9 +3424,9 @@ const H = class H extends x {
|
|
|
3396
3424
|
{ color: "#a84b4b", position: 0, opacity: 100 },
|
|
3397
3425
|
{ color: "#786666", position: 100, opacity: 100 }
|
|
3398
3426
|
]), t !== "solid" && this.value.stops.length === 1) {
|
|
3399
|
-
const
|
|
3400
|
-
if (
|
|
3401
|
-
const l = this.resolveGlobalVarColor(
|
|
3427
|
+
const o = this.value.stops[0].color;
|
|
3428
|
+
if (o.startsWith("var(--")) {
|
|
3429
|
+
const l = this.resolveGlobalVarColor(o), r = I(l);
|
|
3402
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({
|
|
3403
3431
|
color: "#786666",
|
|
3404
3432
|
position: 100,
|
|
@@ -3413,16 +3441,16 @@ const H = class H extends x {
|
|
|
3413
3441
|
} else if (t !== "solid" && this.value.stops.length >= 2)
|
|
3414
3442
|
this.value.angle || (this.value.angle = 90);
|
|
3415
3443
|
else if (t === "solid" && e && i) {
|
|
3416
|
-
const
|
|
3444
|
+
const a = this.value.stops && this.value.stops[0] ? this.value.stops[0].opacity ?? 100 : 100;
|
|
3417
3445
|
this.value.stops = [
|
|
3418
|
-
{ color: i, position: 0, opacity:
|
|
3446
|
+
{ color: i, position: 0, opacity: a }
|
|
3419
3447
|
], this.value.angle = 0;
|
|
3420
3448
|
}
|
|
3421
3449
|
if (this.popoverEl) {
|
|
3422
|
-
const
|
|
3423
|
-
|
|
3424
|
-
const
|
|
3425
|
-
t === "solid" ?
|
|
3450
|
+
const a = this.popoverEl.querySelectorAll(".gradient-type-tab");
|
|
3451
|
+
a.forEach((r) => r.classList.remove("active"));
|
|
3452
|
+
const o = a[0], l = a[1];
|
|
3453
|
+
t === "solid" ? o == null || o.classList.add("active") : l == null || l.classList.add("active");
|
|
3426
3454
|
}
|
|
3427
3455
|
const s = (n = this.popoverEl) == null ? void 0 : n.querySelector(".gradient-editor-content");
|
|
3428
3456
|
s && this.updatePopoverContent(s), this.updateUI(), this.triggerChange();
|
|
@@ -3443,15 +3471,15 @@ const H = class H extends x {
|
|
|
3443
3471
|
let d = {};
|
|
3444
3472
|
try {
|
|
3445
3473
|
d = x.GlobalVariables || {};
|
|
3446
|
-
} catch (
|
|
3447
|
-
console.warn("Could not access Setting.GlobalVariables",
|
|
3474
|
+
} catch (u) {
|
|
3475
|
+
console.warn("Could not access Setting.GlobalVariables", u);
|
|
3448
3476
|
}
|
|
3449
3477
|
if (!d || Object.keys(d).length === 0) {
|
|
3450
|
-
const
|
|
3451
|
-
|
|
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", h.appendChild(u);
|
|
3452
3480
|
return;
|
|
3453
3481
|
}
|
|
3454
|
-
const
|
|
3482
|
+
const g = [
|
|
3455
3483
|
{
|
|
3456
3484
|
title: "Global Colors",
|
|
3457
3485
|
keys: ["primary", "secondary", "tertiary", "accent", "background"]
|
|
@@ -3460,31 +3488,31 @@ const H = class H extends x {
|
|
|
3460
3488
|
title: "Text Color",
|
|
3461
3489
|
keys: ["text-dark", "text-light"]
|
|
3462
3490
|
}
|
|
3463
|
-
],
|
|
3491
|
+
], C = this.globalSearchQuery.toLowerCase();
|
|
3464
3492
|
let m;
|
|
3465
|
-
this.globalLayoutMode === "list" ? (m = document.createElement("div"), m.className = "global-colors-list") : (m = document.createElement("div"), m.className = "global-colors-grid"), h.appendChild(m),
|
|
3466
|
-
const
|
|
3467
|
-
|
|
3493
|
+
this.globalLayoutMode === "list" ? (m = document.createElement("div"), m.className = "global-colors-list") : (m = document.createElement("div"), m.className = "global-colors-grid"), h.appendChild(m), g.forEach((u) => {
|
|
3494
|
+
const f = Object.entries(d).filter(([v]) => !u.keys.includes(v) && u.title !== "Global Colors" ? !1 : u.keys.includes(v) && v.toLowerCase().includes(C));
|
|
3495
|
+
f.length !== 0 && f.forEach(([v, y]) => {
|
|
3468
3496
|
if (this.globalLayoutMode === "list") {
|
|
3469
3497
|
const w = document.createElement("div");
|
|
3470
3498
|
w.className = "global-color-row";
|
|
3471
3499
|
const k = document.createElement("div");
|
|
3472
3500
|
k.className = "global-color-circle";
|
|
3473
3501
|
const S = this.resolveGlobalVarColor(y);
|
|
3474
|
-
k.style.background = S, (this.linkedGlobalVariable === `var(--${
|
|
3502
|
+
k.style.background = S, (this.linkedGlobalVariable === `var(--${v})` || e.color === `var(--${v})`) && k.classList.add("selected");
|
|
3475
3503
|
const E = document.createElement("span");
|
|
3476
|
-
E.className = "global-color-label", E.textContent =
|
|
3504
|
+
E.className = "global-color-label", E.textContent = v.split("-").map((M) => M.charAt(0).toUpperCase() + M.slice(1)).join(" "), w.appendChild(k), w.appendChild(E), w.addEventListener("click", (M) => {
|
|
3477
3505
|
M.preventDefault();
|
|
3478
|
-
const B = `var(--${
|
|
3506
|
+
const B = `var(--${v})`;
|
|
3479
3507
|
this.setValue(B), this.pendingSolidColor = B, i(h);
|
|
3480
3508
|
}), m.appendChild(w);
|
|
3481
3509
|
} else {
|
|
3482
3510
|
const w = document.createElement("div");
|
|
3483
3511
|
w.className = "global-color-circle";
|
|
3484
3512
|
const k = this.resolveGlobalVarColor(y);
|
|
3485
|
-
w.style.background = k, w.title =
|
|
3513
|
+
w.style.background = k, w.title = v.split("-").map((b) => b.charAt(0).toUpperCase() + b.slice(1)).join(" "), (this.linkedGlobalVariable === `var(--${v})` || e.color === `var(--${v})`) && w.classList.add("selected"), w.addEventListener("click", (b) => {
|
|
3486
3514
|
b.preventDefault();
|
|
3487
|
-
const E = `var(--${
|
|
3515
|
+
const E = `var(--${v})`;
|
|
3488
3516
|
this.setValue(E), this.pendingSolidColor = E, i(h);
|
|
3489
3517
|
}), m.appendChild(w);
|
|
3490
3518
|
}
|
|
@@ -3494,14 +3522,14 @@ const H = class H extends x {
|
|
|
3494
3522
|
s.className = "global-controls-row";
|
|
3495
3523
|
const n = document.createElement("div");
|
|
3496
3524
|
n.className = "global-search-container";
|
|
3497
|
-
const
|
|
3498
|
-
|
|
3499
|
-
const
|
|
3500
|
-
|
|
3525
|
+
const a = document.createElement("span");
|
|
3526
|
+
a.className = "global-search-icon", a.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 o = document.createElement("input");
|
|
3528
|
+
o.type = "text", o.className = "global-search-input", o.placeholder = "Search", o.value = this.globalSearchQuery;
|
|
3501
3529
|
const l = document.createElement("div");
|
|
3502
|
-
|
|
3530
|
+
o.addEventListener("input", (h) => {
|
|
3503
3531
|
this.globalSearchQuery = h.target.value, i(l);
|
|
3504
|
-
}), n.appendChild(
|
|
3532
|
+
}), n.appendChild(a), n.appendChild(o);
|
|
3505
3533
|
const r = document.createElement("button");
|
|
3506
3534
|
r.className = "global-layout-toggle", r.type = "button";
|
|
3507
3535
|
const p = () => {
|
|
@@ -3518,9 +3546,9 @@ const H = class H extends x {
|
|
|
3518
3546
|
initialOpacity: e.opacity ?? 100,
|
|
3519
3547
|
onColorChange: (s, n) => {
|
|
3520
3548
|
if (this.clearGlobalBindingForCustomChange(), this.value) {
|
|
3521
|
-
const
|
|
3522
|
-
if (
|
|
3523
|
-
this.value =
|
|
3549
|
+
const a = I(s);
|
|
3550
|
+
if (a && a.type !== "solid") {
|
|
3551
|
+
this.value = a, this.switchType(a.type);
|
|
3524
3552
|
return;
|
|
3525
3553
|
}
|
|
3526
3554
|
this.value.stops[0].color = s, this.value.stops[0].opacity = n, this.updateUI(), this.triggerChange(), this.pendingSolidColor = s;
|
|
@@ -3539,29 +3567,29 @@ const H = class H extends x {
|
|
|
3539
3567
|
h.className = "gradient-subtype-select";
|
|
3540
3568
|
const d = document.createElement("option");
|
|
3541
3569
|
d.value = "linear", d.textContent = "Linear";
|
|
3542
|
-
const
|
|
3543
|
-
|
|
3544
|
-
const
|
|
3545
|
-
|
|
3570
|
+
const g = document.createElement("option");
|
|
3571
|
+
g.value = "radial", g.textContent = "Radial", h.appendChild(d), h.appendChild(g), h.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 C = document.createElement("button");
|
|
3573
|
+
C.type = "button", C.className = "gradient-flip-btn", C.innerHTML = Kt, h.addEventListener("change", () => {
|
|
3546
3574
|
this.clearGlobalBindingForCustomChange(), this.switchType(h.value === "radial" ? "radial" : "linear"), e && this.updateDegreeVisibility(e);
|
|
3547
3575
|
}), e.addEventListener("focus", (m) => {
|
|
3548
|
-
const
|
|
3549
|
-
|
|
3576
|
+
const u = m.target;
|
|
3577
|
+
u.value = u.value.replace(/[^0-9-]/g, ""), setTimeout(() => u.select(), 0);
|
|
3550
3578
|
}), e.addEventListener("input", (m) => {
|
|
3551
3579
|
this.clearGlobalBindingForCustomChange();
|
|
3552
|
-
const
|
|
3553
|
-
!Number.isNaN(
|
|
3580
|
+
const u = parseInt(m.target.value);
|
|
3581
|
+
!Number.isNaN(u) && this.value && (this.value.angle = Math.max(0, Math.min(360, u)), this.debouncedPreviewUpdate());
|
|
3554
3582
|
}), e.addEventListener("blur", (m) => {
|
|
3555
|
-
var
|
|
3583
|
+
var v;
|
|
3556
3584
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
3557
|
-
const
|
|
3558
|
-
let
|
|
3559
|
-
Number.isNaN(
|
|
3560
|
-
}),
|
|
3585
|
+
const u = m.target;
|
|
3586
|
+
let f = parseInt(u.value);
|
|
3587
|
+
Number.isNaN(f) && (f = ((v = this.value) == null ? void 0 : v.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
|
+
}), C.addEventListener("click", () => {
|
|
3561
3589
|
this.clearGlobalBindingForCustomChange(), !(!this.value || !this.value.stops) && (this.value.stops.forEach((m) => {
|
|
3562
3590
|
m.position = 100 - m.position;
|
|
3563
|
-
}), this.value.stops.sort((m,
|
|
3564
|
-
}), p.appendChild(h), p.appendChild(e), p.appendChild(
|
|
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
|
+
}), p.appendChild(h), p.appendChild(e), p.appendChild(C), t.appendChild(p), this.updateDegreeVisibility(e);
|
|
3565
3593
|
}
|
|
3566
3594
|
const i = document.createElement("div");
|
|
3567
3595
|
i.className = "gradient-preview", this.updateGradientPreview(i);
|
|
@@ -3569,17 +3597,17 @@ const H = class H extends x {
|
|
|
3569
3597
|
s.className = "gradient-handles", i.appendChild(s), t.appendChild(i), this.createHandles(s, i);
|
|
3570
3598
|
const n = document.createElement("div");
|
|
3571
3599
|
n.className = "gradient-stops-header";
|
|
3572
|
-
const
|
|
3573
|
-
|
|
3574
|
-
const
|
|
3575
|
-
|
|
3600
|
+
const a = document.createElement("span");
|
|
3601
|
+
a.textContent = "Stops";
|
|
3602
|
+
const o = document.createElement("button");
|
|
3603
|
+
o.type = "button", o.className = "gradient-add-stop", o.textContent = "+", n.appendChild(a), n.appendChild(o);
|
|
3576
3604
|
const l = document.createElement("div");
|
|
3577
3605
|
l.className = "gradient-stops", t.appendChild(n), t.appendChild(l), this.updateStopsList(l);
|
|
3578
3606
|
const r = ot((p) => {
|
|
3579
|
-
const h =
|
|
3607
|
+
const h = I(p);
|
|
3580
3608
|
h && (this.clearGlobalBindingForCustomChange(), this.value = h, this.switchType(h.type), this.updateUI(), this.triggerChange());
|
|
3581
3609
|
}, "all");
|
|
3582
|
-
this.recentGradientRefresh = r.refresh, t.appendChild(r.container),
|
|
3610
|
+
this.recentGradientRefresh = r.refresh, t.appendChild(r.container), o.addEventListener("click", () => {
|
|
3583
3611
|
var p;
|
|
3584
3612
|
this.clearGlobalBindingForCustomChange(), this.addStop(), this.updateStopsList(l), this.updateGradientPreview(i), this.createHandles(s, i), this.updateUI(), ((p = document.activeElement) == null ? void 0 : p.tagName) !== "INPUT" && this.repositionPopover(), this.triggerChange();
|
|
3585
3613
|
});
|
|
@@ -3610,40 +3638,40 @@ const H = class H extends x {
|
|
|
3610
3638
|
t.innerHTML = "", !(!this.value || this.value.type === "solid" || !this.value.stops) && this.value.stops.forEach((i, s) => {
|
|
3611
3639
|
const n = document.createElement("div");
|
|
3612
3640
|
n.className = "gstop-handle", n.style.left = `${Math.max(0, Math.min(100, i.position))}%`, n.style.top = "0%";
|
|
3613
|
-
const
|
|
3614
|
-
|
|
3615
|
-
const
|
|
3616
|
-
|
|
3617
|
-
const l = new dt((
|
|
3618
|
-
this.clearGlobalBindingForCustomChange(), this.value && this.value.stops[s] && (this.value.stops[s].color =
|
|
3641
|
+
const a = document.createElement("div");
|
|
3642
|
+
a.className = "gstop-chip";
|
|
3643
|
+
const o = this.resolveGlobalVarColor(i.color);
|
|
3644
|
+
a.style.backgroundColor = o, n.appendChild(a);
|
|
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), a.style.backgroundColor = u, this.updateGradientPreview(), this.updateStopsList(), this.updateUI(), this.triggerChange());
|
|
3619
3647
|
}, "solid");
|
|
3620
3648
|
let r = !1, p = !1, h = 0, d = 0;
|
|
3621
|
-
const
|
|
3622
|
-
r = !0, p = !1, h =
|
|
3623
|
-
},
|
|
3649
|
+
const g = (u) => {
|
|
3650
|
+
r = !0, p = !1, h = u.clientX, d = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove", C), document.addEventListener("mouseup", m), u.preventDefault(), u.stopPropagation();
|
|
3651
|
+
}, C = (u) => {
|
|
3624
3652
|
if (!r || !this.value) return;
|
|
3625
|
-
const
|
|
3626
|
-
if (Math.abs(
|
|
3653
|
+
const f = u.clientX - h;
|
|
3654
|
+
if (Math.abs(f) > 3 && (p = !0), p) {
|
|
3627
3655
|
this.clearGlobalBindingForCustomChange();
|
|
3628
|
-
const
|
|
3629
|
-
let y = d +
|
|
3656
|
+
const v = e.getBoundingClientRect();
|
|
3657
|
+
let y = d + f / v.width * 100;
|
|
3630
3658
|
y = Math.max(0, Math.min(100, y)), this.value.stops[s].position = Math.round(y), n.style.left = `${y}%`, this.updateGradientPreview();
|
|
3631
3659
|
}
|
|
3632
|
-
}, m = (
|
|
3633
|
-
var
|
|
3660
|
+
}, m = (u) => {
|
|
3661
|
+
var f;
|
|
3634
3662
|
if (r)
|
|
3635
|
-
if (r = !1, n.classList.remove("selected"), document.removeEventListener("mousemove",
|
|
3636
|
-
this.value && (this.value.stops.sort((
|
|
3663
|
+
if (r = !1, n.classList.remove("selected"), document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", m), p)
|
|
3664
|
+
this.value && (this.value.stops.sort((v, y) => v.position - y.position), this.createHandles(t, e), this.updateStopsList()), this.updateUI(), this.triggerChange();
|
|
3637
3665
|
else {
|
|
3638
|
-
|
|
3639
|
-
const
|
|
3640
|
-
|
|
3641
|
-
const y = this.resolveGlobalVarColor(
|
|
3642
|
-
l.open(y,
|
|
3666
|
+
u.stopPropagation();
|
|
3667
|
+
const v = (f = this.value) == null ? void 0 : f.stops[s];
|
|
3668
|
+
v && setTimeout(() => {
|
|
3669
|
+
const y = this.resolveGlobalVarColor(v.color);
|
|
3670
|
+
l.open(y, a, v.opacity ?? 100);
|
|
3643
3671
|
}, 0);
|
|
3644
3672
|
}
|
|
3645
3673
|
};
|
|
3646
|
-
n.addEventListener("mousedown",
|
|
3674
|
+
n.addEventListener("mousedown", g), t.appendChild(n);
|
|
3647
3675
|
});
|
|
3648
3676
|
}
|
|
3649
3677
|
updateStopsList(t) {
|
|
@@ -3651,39 +3679,39 @@ const H = class H extends x {
|
|
|
3651
3679
|
const e = t || ((i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-stops"));
|
|
3652
3680
|
!e || !this.value || this.value.type === "solid" || !this.value.stops || (e.innerHTML = "", this.value.stops.forEach((s, n) => {
|
|
3653
3681
|
var k, S;
|
|
3654
|
-
const o = document.createElement("div");
|
|
3655
|
-
o.className = "gstop-row";
|
|
3656
3682
|
const a = document.createElement("div");
|
|
3657
|
-
a.className = "gstop-
|
|
3683
|
+
a.className = "gstop-row";
|
|
3684
|
+
const o = document.createElement("div");
|
|
3685
|
+
o.className = "gstop-position-group";
|
|
3658
3686
|
const l = document.createElement("input");
|
|
3659
|
-
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", o.appendChild(l);
|
|
3660
3688
|
const r = document.createElement("div");
|
|
3661
3689
|
r.className = "gstop-color-container";
|
|
3662
3690
|
const p = this.resolveGlobalVarColor(s.color), h = document.createElement("div");
|
|
3663
3691
|
h.className = "gstop-color-preview", h.style.backgroundColor = p;
|
|
3664
3692
|
const d = document.createElement("input");
|
|
3665
3693
|
d.type = "text", d.className = "gstop-color-input", d.value = p.replace("#", "").toUpperCase();
|
|
3666
|
-
const u = document.createElement("button");
|
|
3667
|
-
u.type = "button", u.className = "gstop-color-copy", u.textContent = "Copy", r.appendChild(h), r.appendChild(d), r.appendChild(u);
|
|
3668
3694
|
const g = document.createElement("button");
|
|
3669
|
-
g.type = "button", g.className = "gstop-
|
|
3695
|
+
g.type = "button", g.className = "gstop-color-copy", g.textContent = "Copy", r.appendChild(h), r.appendChild(d), r.appendChild(g);
|
|
3696
|
+
const C = document.createElement("button");
|
|
3697
|
+
C.type = "button", C.className = "gstop-del", C.innerHTML = Yt, C.disabled = (((S = (k = this.value) == null ? void 0 : k.stops) == null ? void 0 : S.length) || 0) <= 2, a.appendChild(o), a.appendChild(r), a.appendChild(C), e.appendChild(a);
|
|
3670
3698
|
const m = document.createElement("span");
|
|
3671
3699
|
m.className = "gstop-opacity-label", m.textContent = "Opacity";
|
|
3672
|
-
const
|
|
3673
|
-
|
|
3674
|
-
const
|
|
3675
|
-
|
|
3676
|
-
const
|
|
3677
|
-
|
|
3700
|
+
const u = document.createElement("div");
|
|
3701
|
+
u.className = "gstop-opacity-group";
|
|
3702
|
+
const f = document.createElement("input");
|
|
3703
|
+
f.type = "range", f.className = "gstop-opacity-slider", f.min = "0", f.max = "100", f.value = String(s.opacity ?? 100);
|
|
3704
|
+
const v = N(p);
|
|
3705
|
+
f.style.setProperty(
|
|
3678
3706
|
"--slider-color",
|
|
3679
|
-
`rgb(${
|
|
3707
|
+
`rgb(${v.r}, ${v.g}, ${v.b})`
|
|
3680
3708
|
);
|
|
3681
3709
|
const y = document.createElement("span");
|
|
3682
|
-
y.className = "gstop-opacity-value", y.textContent = `${s.opacity ?? 100}%`,
|
|
3710
|
+
y.className = "gstop-opacity-value", y.textContent = `${s.opacity ?? 100}%`, u.appendChild(f), u.appendChild(y);
|
|
3683
3711
|
const w = new dt((b, E) => {
|
|
3684
|
-
this.clearGlobalBindingForCustomChange(), d.value = b.replace("#", "").toUpperCase(), h.style.backgroundColor = b, this.value.stops[n].color = b, E !== void 0 && (this.value.stops[n].opacity = E,
|
|
3685
|
-
const M =
|
|
3686
|
-
|
|
3712
|
+
this.clearGlobalBindingForCustomChange(), d.value = b.replace("#", "").toUpperCase(), h.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
|
+
const M = N(b);
|
|
3714
|
+
f.style.setProperty(
|
|
3687
3715
|
"--slider-color",
|
|
3688
3716
|
`rgb(${M.r}, ${M.g}, ${M.b})`
|
|
3689
3717
|
), this.updateGradientPreview(), this.createHandles(
|
|
@@ -3700,15 +3728,15 @@ const H = class H extends x {
|
|
|
3700
3728
|
const b = d.value.trim(), E = b.startsWith("#") ? b : `#${b}`;
|
|
3701
3729
|
if (/^#[0-9A-Fa-f]{6}$/.test(E)) {
|
|
3702
3730
|
this.value.stops[n].color = E, h.style.backgroundColor = E;
|
|
3703
|
-
const M =
|
|
3704
|
-
|
|
3731
|
+
const M = N(E);
|
|
3732
|
+
f.style.setProperty(
|
|
3705
3733
|
"--slider-color",
|
|
3706
3734
|
`rgb(${M.r}, ${M.g}, ${M.b})`
|
|
3707
3735
|
), this.debouncedPreviewUpdate();
|
|
3708
3736
|
}
|
|
3709
3737
|
}), d.addEventListener("blur", () => {
|
|
3710
3738
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3711
|
-
}),
|
|
3739
|
+
}), g.addEventListener("click", async (b) => {
|
|
3712
3740
|
b.stopPropagation();
|
|
3713
3741
|
try {
|
|
3714
3742
|
await navigator.clipboard.writeText(`#${d.value}`);
|
|
@@ -3737,49 +3765,49 @@ const H = class H extends x {
|
|
|
3737
3765
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
3738
3766
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3739
3767
|
), this.updateStopsList(), this.updateUI(), this.triggerChange();
|
|
3740
|
-
}),
|
|
3768
|
+
}), C.addEventListener("click", () => {
|
|
3741
3769
|
var b;
|
|
3742
3770
|
(this.value.stops.length || 0) <= 2 || (this.clearGlobalBindingForCustomChange(), this.value.stops.splice(n, 1), this.createHandles(
|
|
3743
3771
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
3744
3772
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3745
3773
|
), this.updateStopsList(), this.updateGradientPreview(), this.updateUI(), ((b = document.activeElement) == null ? void 0 : b.tagName) !== "INPUT" && this.repositionPopover(), this.triggerChange());
|
|
3746
|
-
}),
|
|
3774
|
+
}), f.addEventListener("input", () => {
|
|
3747
3775
|
this.clearGlobalBindingForCustomChange();
|
|
3748
|
-
const b = parseInt(
|
|
3776
|
+
const b = parseInt(f.value, 10);
|
|
3749
3777
|
this.value.stops[n].opacity = Math.max(0, Math.min(100, b)), y.textContent = `${this.value.stops[n].opacity}%`, this.debouncedPreviewUpdate();
|
|
3750
|
-
}),
|
|
3778
|
+
}), f.addEventListener("change", () => {
|
|
3751
3779
|
this.clearGlobalBindingForCustomChange(), this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3752
3780
|
});
|
|
3753
3781
|
}));
|
|
3754
3782
|
}
|
|
3755
3783
|
addStop() {
|
|
3756
3784
|
if (!this.value || this.value.type === "solid" || !this.value.stops) return;
|
|
3757
|
-
const t = this.value.stops.map((
|
|
3785
|
+
const t = this.value.stops.map((a) => a.position).sort((a, o) => a - o);
|
|
3758
3786
|
let e = 50, i = 0;
|
|
3759
|
-
for (let
|
|
3760
|
-
const
|
|
3761
|
-
|
|
3787
|
+
for (let a = 0; a < t.length - 1; a++) {
|
|
3788
|
+
const o = t[a + 1] - t[a];
|
|
3789
|
+
o > i && (i = o, e = t[a] + o / 2);
|
|
3762
3790
|
}
|
|
3763
3791
|
const s = this.value.stops.reduce(
|
|
3764
|
-
(
|
|
3792
|
+
(a, o) => Math.abs(o.position - e) < Math.abs(a.position - e) ? o : a
|
|
3765
3793
|
), n = {
|
|
3766
3794
|
position: Math.round(e),
|
|
3767
3795
|
color: s.color,
|
|
3768
3796
|
opacity: s.opacity ?? 100
|
|
3769
3797
|
};
|
|
3770
|
-
this.value.stops.push(n), this.value.stops.sort((
|
|
3798
|
+
this.value.stops.push(n), this.value.stops.sort((a, o) => a.position - o.position);
|
|
3771
3799
|
}
|
|
3772
3800
|
openPopover() {
|
|
3773
|
-
if (this.popoverEl && (
|
|
3774
|
-
if (this.isPopoverOpen = !0,
|
|
3801
|
+
if (this.popoverEl && ($.openInstance && $.openInstance !== this && $.openInstance.closePopover(), !this.isPopoverOpen)) {
|
|
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) {
|
|
3775
3803
|
const t = this.element.getBoundingClientRect(), e = 306, i = window.innerWidth, s = window.innerHeight, n = 16;
|
|
3776
3804
|
this.popoverEl.style.position = "fixed", this.popoverEl.style.zIndex = "10000", this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3777
|
-
const
|
|
3778
|
-
let
|
|
3805
|
+
const a = this.popoverEl.offsetHeight;
|
|
3806
|
+
let o = t.right + 8, l = t.top;
|
|
3779
3807
|
const r = i - t.right, p = t.left, h = e + n;
|
|
3780
|
-
r < h && p > r + 100 && (
|
|
3781
|
-
const d = s - t.bottom,
|
|
3782
|
-
|
|
3808
|
+
r < h && p > r + 100 && (o = t.left - e - 8);
|
|
3809
|
+
const d = s - t.bottom, g = t.top;
|
|
3810
|
+
g >= a + n ? l = t.top - a - 8 : d >= a + n ? l = t.bottom + 8 : g > d ? (l = t.top - a - 8, l < n && (l = n)) : (l = t.bottom + 8, l + a > s - n && (l = s - a - n)), this.popoverEl.style.left = `${o}px`, this.popoverEl.style.top = `${l}px`, this.popoverPosition = { left: o, top: l };
|
|
3783
3811
|
}
|
|
3784
3812
|
setTimeout(
|
|
3785
3813
|
() => document.addEventListener("click", this.onBackgroundClick, !0),
|
|
@@ -3796,24 +3824,24 @@ const H = class H extends x {
|
|
|
3796
3824
|
}
|
|
3797
3825
|
requestAnimationFrame(() => {
|
|
3798
3826
|
if (!this.popoverEl || !this.element) return;
|
|
3799
|
-
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, a = 16;
|
|
3800
3828
|
this.popoverEl.style.left, this.popoverEl.style.top, this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3801
|
-
const
|
|
3829
|
+
const o = this.popoverEl.offsetHeight;
|
|
3802
3830
|
let l = e.right + 8, r = e.top;
|
|
3803
|
-
const p = s - e.right, h = e.left, d = i +
|
|
3831
|
+
const p = s - e.right, h = e.left, d = i + a;
|
|
3804
3832
|
p < d && h > p + 100 && (l = e.left - i - 8);
|
|
3805
|
-
const
|
|
3806
|
-
|
|
3833
|
+
const g = n - e.bottom, C = e.top;
|
|
3834
|
+
C >= o + a ? r = e.top - o - 8 : g >= o + a ? r = e.bottom + 8 : C > g ? (r = e.top - o - 8, r < a && (r = a)) : (r = e.bottom + 8, r + o > n - a && (r = n - o - a)), this.popoverEl.style.left = `${l}px`, this.popoverEl.style.top = `${r}px`;
|
|
3807
3835
|
});
|
|
3808
3836
|
}
|
|
3809
3837
|
}
|
|
3810
3838
|
refreshPopoverContent() {
|
|
3811
|
-
var n,
|
|
3839
|
+
var n, a;
|
|
3812
3840
|
if (!this.popoverEl) return;
|
|
3813
3841
|
const t = this.popoverEl.querySelectorAll(".gradient-type-tab");
|
|
3814
|
-
t.forEach((
|
|
3842
|
+
t.forEach((o) => o.classList.remove("active"));
|
|
3815
3843
|
const e = t[0], i = t[1];
|
|
3816
|
-
((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"), (a = this.recentGradientRefresh) == null || a.call(this)), this.popoverEl.offsetHeight;
|
|
3817
3845
|
const s = this.popoverEl.querySelector(".gradient-editor-content");
|
|
3818
3846
|
s && this.updatePopoverContent(s);
|
|
3819
3847
|
}
|
|
@@ -3824,7 +3852,7 @@ const H = class H extends x {
|
|
|
3824
3852
|
const e = O(this.value);
|
|
3825
3853
|
D.addColor(e, "gradient"), (t = this.recentGradientRefresh) == null || t.call(this);
|
|
3826
3854
|
}
|
|
3827
|
-
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null),
|
|
3855
|
+
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), $.openInstance === this && ($.openInstance = null);
|
|
3828
3856
|
}
|
|
3829
3857
|
}
|
|
3830
3858
|
commitPendingSolidColor() {
|
|
@@ -3841,8 +3869,10 @@ const H = class H extends x {
|
|
|
3841
3869
|
this.parseAndSet(e.value);
|
|
3842
3870
|
}
|
|
3843
3871
|
parseAndSet(t) {
|
|
3844
|
-
|
|
3845
|
-
e && this.
|
|
3872
|
+
let e = t.trim();
|
|
3873
|
+
e && !e.startsWith("#") && !e.startsWith("var(") && !e.startsWith("rgb") && !e.startsWith("hsl") && !e.includes("gradient") && /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/.test(e) && (e = "#" + e, this.inputEl && (this.inputEl.value = e));
|
|
3874
|
+
const i = I(e);
|
|
3875
|
+
i && this.setValue(i);
|
|
3846
3876
|
}
|
|
3847
3877
|
getChangePayload() {
|
|
3848
3878
|
var t;
|
|
@@ -3874,8 +3904,8 @@ const H = class H extends x {
|
|
|
3874
3904
|
return this.value;
|
|
3875
3905
|
}
|
|
3876
3906
|
};
|
|
3877
|
-
|
|
3878
|
-
let K =
|
|
3907
|
+
$.openInstance = null;
|
|
3908
|
+
let K = $;
|
|
3879
3909
|
const se = `
|
|
3880
3910
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
3881
3911
|
<path d="M5.625 9.5H5.6325M12.375 9.5H12.3825M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M2.25 6.35L2.25 12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75L5.85 2.75C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -3996,8 +4026,8 @@ class ke extends T {
|
|
|
3996
4026
|
});
|
|
3997
4027
|
}
|
|
3998
4028
|
getCssCode() {
|
|
3999
|
-
var
|
|
4000
|
-
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 a;
|
|
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 = ((a = this.settings.align) == null ? void 0 : a.value) ?? "left";
|
|
4001
4031
|
return `
|
|
4002
4032
|
color: ${t};
|
|
4003
4033
|
font-family: ${e};
|
|
@@ -4007,8 +4037,8 @@ class ke extends T {
|
|
|
4007
4037
|
`;
|
|
4008
4038
|
}
|
|
4009
4039
|
getTextGradientCss() {
|
|
4010
|
-
var
|
|
4011
|
-
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 o;
|
|
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 = ((o = this.settings.align) == null ? void 0 : o.value) ?? "left";
|
|
4012
4042
|
return `
|
|
4013
4043
|
${Object.entries(t).map(([l, r]) => `${l}: ${r};`).join(`
|
|
4014
4044
|
`)}
|
|
@@ -4027,11 +4057,11 @@ class q extends x {
|
|
|
4027
4057
|
}), this.inputType = "number", this.value = t.default !== void 0 ? t.default : "auto";
|
|
4028
4058
|
}
|
|
4029
4059
|
draw() {
|
|
4030
|
-
const t = this.value === "auto" ? "text" : "number", e = (
|
|
4031
|
-
this.value !== "auto" && (this.props.minValue !== void 0 && (
|
|
4060
|
+
const t = this.value === "auto" ? "text" : "number", e = (o) => {
|
|
4061
|
+
this.value !== "auto" && (this.props.minValue !== void 0 && (o.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (o.max = String(this.props.maxValue)), this.props.className && o.classList.add(this.props.className), o.addEventListener("input", () => {
|
|
4032
4062
|
const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
4033
|
-
let p = Number(
|
|
4034
|
-
p < l && (p = l), p > r && (p = r),
|
|
4063
|
+
let p = Number(o.value);
|
|
4064
|
+
p < l && (p = l), p > r && (p = r), o.value = String(p);
|
|
4035
4065
|
}));
|
|
4036
4066
|
}, i = this.createInput({
|
|
4037
4067
|
value: this.value,
|
|
@@ -4052,9 +4082,9 @@ class q extends x {
|
|
|
4052
4082
|
s && (s.style.paddingRight = "35px");
|
|
4053
4083
|
const n = document.createElement("span");
|
|
4054
4084
|
n.className = "suffix-label", n.textContent = this.props.suffix, i.appendChild(n);
|
|
4055
|
-
const
|
|
4056
|
-
return
|
|
4057
|
-
const l =
|
|
4085
|
+
const a = i.querySelector("input");
|
|
4086
|
+
return a && (a.oninput = (o) => {
|
|
4087
|
+
const l = o.target.value.trim();
|
|
4058
4088
|
if (l.toLowerCase() === "auto")
|
|
4059
4089
|
this.value = "auto";
|
|
4060
4090
|
else {
|
|
@@ -4127,7 +4157,7 @@ class Se extends T {
|
|
|
4127
4157
|
...t == null ? void 0 : t.uploadProps,
|
|
4128
4158
|
default: (t == null ? void 0 : t.backgroundImage) ?? ""
|
|
4129
4159
|
}),
|
|
4130
|
-
opacity: new
|
|
4160
|
+
opacity: new Vt({
|
|
4131
4161
|
default: (t == null ? void 0 : t.opacity) ?? 100
|
|
4132
4162
|
}),
|
|
4133
4163
|
backgroundColor: new F({
|
|
@@ -4139,10 +4169,10 @@ class Se extends T {
|
|
|
4139
4169
|
draw() {
|
|
4140
4170
|
const t = super.draw(), e = t.querySelector(".setting-group-content");
|
|
4141
4171
|
if (!e) return t;
|
|
4142
|
-
const i = Array.from(e.children), [s, n,
|
|
4172
|
+
const i = Array.from(e.children), [s, n, a] = i;
|
|
4143
4173
|
e.innerHTML = "", e.appendChild(s), e.appendChild(n);
|
|
4144
|
-
const
|
|
4145
|
-
return
|
|
4174
|
+
const o = document.createElement("div");
|
|
4175
|
+
return o.className = "bgset-or-label", o.textContent = "OR", e.appendChild(o), e.appendChild(a), t;
|
|
4146
4176
|
}
|
|
4147
4177
|
getCssCode() {
|
|
4148
4178
|
const t = this.settings.backgroundImage.value || "", e = this.settings.opacity.value ?? 100, i = this.settings.backgroundColor.value || "#000000";
|
|
@@ -4156,7 +4186,7 @@ class Se extends T {
|
|
|
4156
4186
|
`;
|
|
4157
4187
|
}
|
|
4158
4188
|
}
|
|
4159
|
-
class
|
|
4189
|
+
class Ie extends T {
|
|
4160
4190
|
constructor(t) {
|
|
4161
4191
|
super({
|
|
4162
4192
|
title: (t == null ? void 0 : t.title) ?? "Image",
|
|
@@ -4184,7 +4214,7 @@ export {
|
|
|
4184
4214
|
Se as BackgroundSettingSet,
|
|
4185
4215
|
Le as BorderSettingSet,
|
|
4186
4216
|
me as ButtonSetting,
|
|
4187
|
-
|
|
4217
|
+
V as ColorSetting,
|
|
4188
4218
|
F as ColorWithOpacitySetting,
|
|
4189
4219
|
fe as DimensionSetting,
|
|
4190
4220
|
ye as GapSetting,
|
|
@@ -4192,13 +4222,13 @@ export {
|
|
|
4192
4222
|
ke as HeaderTypographySettingSet,
|
|
4193
4223
|
Gt as HeightSetting,
|
|
4194
4224
|
ge as HtmlSetting,
|
|
4195
|
-
|
|
4225
|
+
Ie as ImageSettingSet,
|
|
4196
4226
|
be as MarginBottomSetting,
|
|
4197
4227
|
Me as MarginSettingGroup,
|
|
4198
4228
|
Ee as MarginTopSetting,
|
|
4199
4229
|
we as MultiLanguageSetting,
|
|
4200
4230
|
P as NumberSetting,
|
|
4201
|
-
|
|
4231
|
+
Vt as OpacitySetting,
|
|
4202
4232
|
ve as SelectApiSettings,
|
|
4203
4233
|
et as SelectSetting,
|
|
4204
4234
|
x as Setting,
|