builder-settings-types 0.0.293 → 0.0.294
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.
|
@@ -450,13 +450,13 @@ const K = class K {
|
|
|
450
450
|
w(e) && typeof e.setNestingLevel == "function" && e.setNestingLevel(this.nestingLevel + 1);
|
|
451
451
|
const a = e.draw(), l = this.deleteItemCfg ?? this.addItemCfg;
|
|
452
452
|
if (l) {
|
|
453
|
-
const
|
|
454
|
-
|
|
453
|
+
const h = l.keyPrefix ?? ((s = this.addItemCfg) == null ? void 0 : s.keyPrefix);
|
|
454
|
+
h && t.startsWith(h) && this.addDeleteButtonToElement(a, t);
|
|
455
455
|
}
|
|
456
456
|
const r = o.querySelector(".sg-add-button-bottom");
|
|
457
457
|
r ? o.insertBefore(a, r) : o.appendChild(a), it.trackElement(a), q(a, this.nestingLevel + 1), Q(a, this.nestingLevel + 1);
|
|
458
|
-
const
|
|
459
|
-
a.style.display = "none", a.offsetHeight, a.style.display =
|
|
458
|
+
const p = a.style.display;
|
|
459
|
+
a.style.display = "none", a.offsetHeight, a.style.display = p, this.updateNestingStyles();
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
const i = this.getValues();
|
|
@@ -473,9 +473,9 @@ const K = class K {
|
|
|
473
473
|
const r = Array.from(
|
|
474
474
|
t.querySelectorAll(".setting-group-title")
|
|
475
475
|
);
|
|
476
|
-
for (const
|
|
477
|
-
if (
|
|
478
|
-
s =
|
|
476
|
+
for (const p of r)
|
|
477
|
+
if (p.closest(".setting-group") === t) {
|
|
478
|
+
s = p;
|
|
479
479
|
break;
|
|
480
480
|
}
|
|
481
481
|
s || (s = r[0] ?? null);
|
|
@@ -508,8 +508,8 @@ const K = class K {
|
|
|
508
508
|
}), o.addEventListener("mouseleave", () => {
|
|
509
509
|
o.style.backgroundColor = "transparent";
|
|
510
510
|
}), o.addEventListener("click", (r) => {
|
|
511
|
-
r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((
|
|
512
|
-
|
|
511
|
+
r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((p) => {
|
|
512
|
+
p && (i && i.deleteItemCfg ? this.removeSetting(e) : this.removeSetting(e));
|
|
513
513
|
});
|
|
514
514
|
});
|
|
515
515
|
const l = n.querySelector(".setting-group-arrow");
|
|
@@ -603,13 +603,13 @@ const K = class K {
|
|
|
603
603
|
r(), t(!1);
|
|
604
604
|
}), l.addEventListener("click", () => {
|
|
605
605
|
r(), t(!0);
|
|
606
|
-
}), e.addEventListener("click", (
|
|
607
|
-
|
|
606
|
+
}), e.addEventListener("click", (h) => {
|
|
607
|
+
h.target === e && (r(), t(!1));
|
|
608
608
|
});
|
|
609
|
-
const
|
|
610
|
-
|
|
609
|
+
const p = (h) => {
|
|
610
|
+
h.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", p));
|
|
611
611
|
};
|
|
612
|
-
document.addEventListener("keydown",
|
|
612
|
+
document.addEventListener("keydown", p), o.appendChild(a), o.appendChild(l), i.appendChild(s), i.appendChild(n), i.appendChild(o), e.appendChild(i), document.body.appendChild(e), requestAnimationFrame(() => {
|
|
613
613
|
e.style.opacity = "1", i.style.transform = "scale(1)";
|
|
614
614
|
}), setTimeout(() => l.focus(), 100);
|
|
615
615
|
});
|
|
@@ -731,41 +731,41 @@ const K = class K {
|
|
|
731
731
|
(!this.isCollapsed).toString()
|
|
732
732
|
);
|
|
733
733
|
};
|
|
734
|
-
if (e.onclick = l, e.onkeydown = (
|
|
735
|
-
(
|
|
734
|
+
if (e.onclick = l, e.onkeydown = (p) => {
|
|
735
|
+
(p.key === "Enter" || p.key === " ") && (p.preventDefault(), l());
|
|
736
736
|
}, Object.keys(this.settings).length > 0) {
|
|
737
|
-
for (const
|
|
738
|
-
if (Object.prototype.hasOwnProperty.call(this.settings,
|
|
739
|
-
const
|
|
740
|
-
w(
|
|
741
|
-
const d =
|
|
742
|
-
w(
|
|
737
|
+
for (const p in this.settings)
|
|
738
|
+
if (Object.prototype.hasOwnProperty.call(this.settings, p)) {
|
|
739
|
+
const h = this.settings[p];
|
|
740
|
+
w(h) && typeof h.setNestingLevel == "function" && h.setNestingLevel(this.nestingLevel + 1);
|
|
741
|
+
const d = h.draw();
|
|
742
|
+
w(h) && h.deleteItemCfg && this.addDeleteButtonToElement(
|
|
743
743
|
d,
|
|
744
|
-
|
|
745
|
-
|
|
744
|
+
p,
|
|
745
|
+
h
|
|
746
746
|
), a.appendChild(d);
|
|
747
747
|
}
|
|
748
748
|
} else {
|
|
749
|
-
const
|
|
750
|
-
|
|
749
|
+
const p = document.createElement("div");
|
|
750
|
+
p.className = "setting-group-empty", p.textContent = "No settings in this group", a.appendChild(p);
|
|
751
751
|
}
|
|
752
752
|
if (this.addItemCfg) {
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
const
|
|
753
|
+
const p = document.createElement("button");
|
|
754
|
+
p.type = "button", p.className = "sg-add-button-bottom", p.style.marginTop = "8px";
|
|
755
|
+
const h = `
|
|
756
756
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"
|
|
757
757
|
xmlns="http://www.w3.org/2000/svg">
|
|
758
758
|
<path d="M8 3.333v9.334M3.333 8h9.334" stroke="currentColor"
|
|
759
759
|
stroke-width="1.5" stroke-linecap="round"/>
|
|
760
760
|
</svg>`;
|
|
761
|
-
|
|
761
|
+
p.innerHTML = `${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, p.addEventListener("click", (d) => {
|
|
762
762
|
d.stopPropagation(), d.preventDefault();
|
|
763
763
|
const u = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), m = this.addItemCfg.createItem(u);
|
|
764
764
|
if (st(m)) {
|
|
765
765
|
const f = `${this.addItemCfg.keyPrefix}${u}`;
|
|
766
766
|
this.addSetting(f, m);
|
|
767
767
|
}
|
|
768
|
-
}), a.appendChild(
|
|
768
|
+
}), a.appendChild(p);
|
|
769
769
|
}
|
|
770
770
|
return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(a), this.elementRef = t, it.trackElement(t), setTimeout(() => {
|
|
771
771
|
this.updateNestingStyles();
|
|
@@ -852,12 +852,12 @@ class yt extends P {
|
|
|
852
852
|
if (o.className = "tab-content", this.contentContainers = {}, Object.keys(this.settings).forEach((a, l) => {
|
|
853
853
|
const r = document.createElement("button");
|
|
854
854
|
r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id", a), r.textContent = a, r.addEventListener("click", () => this.switchToTab(a)), n.appendChild(r);
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
)), o.appendChild(
|
|
855
|
+
const p = document.createElement("div");
|
|
856
|
+
p.className = "tab-panel", this.contentContainers[a] = p;
|
|
857
|
+
const h = this.settings[a];
|
|
858
|
+
h && (w(h) && typeof h.setNestingLevel == "function" && h.setNestingLevel(this.getNestingLevel() + 1), p.appendChild(
|
|
859
|
+
h.draw()
|
|
860
|
+
)), o.appendChild(p), l === 0 && !this.activeTabId && (this.activeTabId = a);
|
|
861
861
|
}), e.appendChild(i), e.appendChild(n), e.appendChild(o), !this.activeTabId) {
|
|
862
862
|
const a = Object.keys(this.settings)[0];
|
|
863
863
|
this.activeTabId = a || "";
|
|
@@ -908,12 +908,12 @@ class M extends bt {
|
|
|
908
908
|
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");
|
|
909
909
|
}
|
|
910
910
|
static rgbToHexStatic(t) {
|
|
911
|
-
const e = t.split(",").map((
|
|
911
|
+
const e = t.split(",").map((p) => parseInt(p.trim()));
|
|
912
912
|
if (e.length !== 3 || e.some(isNaN))
|
|
913
913
|
return console.warn(`Invalid RGB value "${t}", using default "#000000"`), "#000000";
|
|
914
|
-
const [i, s, n] = e, o = Math.max(0, Math.min(255, i)), a = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (
|
|
915
|
-
const
|
|
916
|
-
return
|
|
914
|
+
const [i, s, n] = e, o = Math.max(0, Math.min(255, i)), a = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (p) => {
|
|
915
|
+
const h = p.toString(16);
|
|
916
|
+
return h.length === 1 ? "0" + h : h;
|
|
917
917
|
};
|
|
918
918
|
return `#${r(o)}${r(a)}${r(l)}`;
|
|
919
919
|
}
|
|
@@ -953,8 +953,8 @@ class M extends bt {
|
|
|
953
953
|
const r = l.value.trim();
|
|
954
954
|
if (!r)
|
|
955
955
|
return e.classList.remove("error"), !0;
|
|
956
|
-
const
|
|
957
|
-
return
|
|
956
|
+
const h = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r);
|
|
957
|
+
return h ? e.classList.remove("error") : e.classList.add("error"), h;
|
|
958
958
|
}, s = document.createElement("input");
|
|
959
959
|
s.type = "color", s.className = "color-picker", s.value = this.value || "#000000", s.setAttribute("aria-label", "Choose color"), s.setAttribute("title", "Click to open color picker"), this.getDataPropsPath() && s.setAttribute("data-test-id", this.getDataPropsPath()), this.colorInputEl = s;
|
|
960
960
|
const n = document.createElement("div");
|
|
@@ -963,20 +963,20 @@ class M extends bt {
|
|
|
963
963
|
n.style.backgroundColor = o;
|
|
964
964
|
const a = document.createElement("input");
|
|
965
965
|
return a.type = "text", a.className = "color-text-input", a.value = this.value || "", a.placeholder = "#000000", a.setAttribute("pattern", "#[0-9A-Fa-f]{6}"), a.setAttribute("title", "Enter a hex color value (e.g., #ff0000)"), a.setAttribute("aria-label", "Hex color value"), a.setAttribute("maxlength", "7"), this.getDataPropsPath() && a.setAttribute("data-test-id", `${this.getDataPropsPath()}_text`), this.textInputEl = a, this.textInputEl.addEventListener("input", (l) => {
|
|
966
|
-
var
|
|
966
|
+
var p, h;
|
|
967
967
|
let r = l.target.value.trim();
|
|
968
968
|
if (this.textInputEl && i(this.textInputEl)) {
|
|
969
969
|
const d = M.normalizeColorValue(r);
|
|
970
|
-
this.value = d, (
|
|
970
|
+
this.value = d, (p = this.onChange) == null || p.call(this, d), (h = this.detectChange) == null || h.call(this, d), this.colorInputEl && (this.colorInputEl.value = d), n.style.backgroundColor = d;
|
|
971
971
|
}
|
|
972
972
|
}), this.colorInputEl.addEventListener("input", (l) => {
|
|
973
|
-
var
|
|
974
|
-
const r = l.target.value,
|
|
975
|
-
this.value =
|
|
973
|
+
var h, d;
|
|
974
|
+
const r = l.target.value, p = M.normalizeColorValue(r);
|
|
975
|
+
this.value = p, (h = this.onChange) == null || h.call(this, p), (d = this.detectChange) == null || d.call(this, p), this.textInputEl && (this.textInputEl.value = p), n.style.backgroundColor = p, e.classList.remove("error");
|
|
976
976
|
}), this.colorInputEl.addEventListener("change", (l) => {
|
|
977
|
-
var
|
|
978
|
-
const r = l.target.value,
|
|
979
|
-
this.value =
|
|
977
|
+
var h, d;
|
|
978
|
+
const r = l.target.value, p = M.normalizeColorValue(r);
|
|
979
|
+
this.value = p, (h = this.onChange) == null || h.call(this, p), (d = this.detectChange) == null || d.call(this, p), this.textInputEl && (this.textInputEl.value = p), n.style.backgroundColor = p;
|
|
980
980
|
}), e.appendChild(s), e.appendChild(n), e.appendChild(a), t.appendChild(e), this.element = t, t;
|
|
981
981
|
}
|
|
982
982
|
getElement() {
|
|
@@ -1422,8 +1422,8 @@ class re extends b {
|
|
|
1422
1422
|
/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i
|
|
1423
1423
|
);
|
|
1424
1424
|
if (n) {
|
|
1425
|
-
let a = +n[1], l = +n[2], r = +n[3],
|
|
1426
|
-
|
|
1425
|
+
let a = +n[1], l = +n[2], r = +n[3], p = +n[4];
|
|
1426
|
+
p >= 1 ? (a = Math.round(a * 0.9), l = Math.round(l * 0.9), r = Math.round(r * 0.9)) : p = Math.min(1, p + 0.12), s = `rgba(${a},${l},${r},${p})`;
|
|
1427
1427
|
}
|
|
1428
1428
|
t.addEventListener("mouseenter", () => {
|
|
1429
1429
|
console.log("hoverBg", s), t.style.setProperty("background-color", s, "important");
|
|
@@ -1856,7 +1856,7 @@ class de extends b {
|
|
|
1856
1856
|
return JSON.stringify(t ? {} : { value: this.value }, null, 2);
|
|
1857
1857
|
}
|
|
1858
1858
|
selectApiOption(t, e, i) {
|
|
1859
|
-
var l, r,
|
|
1859
|
+
var l, r, p, h;
|
|
1860
1860
|
const s = t.target, n = s.querySelector(".select-api-radio") || ((l = s.closest(".select-api-option")) == null ? void 0 : l.querySelector(".select-api-radio"));
|
|
1861
1861
|
n && (n.checked = !0), this.selectedOptionIndex = e;
|
|
1862
1862
|
const o = this._options[e].value;
|
|
@@ -1868,7 +1868,7 @@ class de extends b {
|
|
|
1868
1868
|
const d = i.firstChild;
|
|
1869
1869
|
d && d.tagName === "SPAN" && (d.textContent = this._options[e].name);
|
|
1870
1870
|
}
|
|
1871
|
-
this.isOpen = !1, (r = this.optionsListEl) == null || r.classList.remove("open"), (
|
|
1871
|
+
this.isOpen = !1, (r = this.optionsListEl) == null || r.classList.remove("open"), (p = this.svgContainer) == null || p.classList.remove("open"), (h = this.onChange) == null || h.call(this, o), this.detectChangeCallback && this.detectChangeCallback(o);
|
|
1872
1872
|
}
|
|
1873
1873
|
updateOptionsList() {
|
|
1874
1874
|
!this.optionsListEl || !this.buttonEl || (this.optionsListEl.innerHTML = "", this._options.forEach((t, e) => {
|
|
@@ -1924,19 +1924,19 @@ class ue extends b {
|
|
|
1924
1924
|
i.className = "toggle-switch";
|
|
1925
1925
|
const s = document.createElement("input");
|
|
1926
1926
|
s.type = "checkbox", s.checked = ((a = (o = this.props.options) == null ? void 0 : o.find((l) => l.value === this.value)) == null ? void 0 : a.status) ?? !1, this.getDataPropsPath() && s.setAttribute("data-test-id", this.getDataPropsPath()), s.addEventListener("change", () => {
|
|
1927
|
-
var r,
|
|
1928
|
-
const l = ((
|
|
1927
|
+
var r, p;
|
|
1928
|
+
const l = ((p = (r = this.props.options) == null ? void 0 : r.find((h) => h.status === s.checked)) == null ? void 0 : p.value) ?? "";
|
|
1929
1929
|
this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
|
|
1930
1930
|
});
|
|
1931
1931
|
const n = document.createElement("span");
|
|
1932
1932
|
if (n.className = "toggle-slider", this.props.activeColor || this.props.inactiveColor) {
|
|
1933
|
-
const l = document.createElement("style"), r = this.props.activeColor || "#4CAF50",
|
|
1933
|
+
const l = document.createElement("style"), r = this.props.activeColor || "#4CAF50", p = this.props.inactiveColor || "#ccc";
|
|
1934
1934
|
l.textContent = `
|
|
1935
1935
|
.toggle-switch input:checked + .toggle-slider {
|
|
1936
1936
|
background-color: ${r};
|
|
1937
1937
|
}
|
|
1938
1938
|
.toggle-switch .toggle-slider {
|
|
1939
|
-
background-color: ${
|
|
1939
|
+
background-color: ${p};
|
|
1940
1940
|
}
|
|
1941
1941
|
`, document.head.appendChild(l);
|
|
1942
1942
|
}
|
|
@@ -2073,13 +2073,13 @@ class ve extends b {
|
|
|
2073
2073
|
t.placeholder = e;
|
|
2074
2074
|
return;
|
|
2075
2075
|
}
|
|
2076
|
-
const
|
|
2077
|
-
let
|
|
2078
|
-
for (;
|
|
2079
|
-
const f = Math.floor((
|
|
2080
|
-
this.measureTextWidth(g, i) <= l ? (u = f,
|
|
2076
|
+
const p = "...";
|
|
2077
|
+
let h = 0, d = e.length, u = 0;
|
|
2078
|
+
for (; h <= d; ) {
|
|
2079
|
+
const f = Math.floor((h + d) / 2), g = e.slice(0, f).trimEnd() + p;
|
|
2080
|
+
this.measureTextWidth(g, i) <= l ? (u = f, h = f + 1) : d = f - 1;
|
|
2081
2081
|
}
|
|
2082
|
-
const m = e.slice(0, u).trimEnd() +
|
|
2082
|
+
const m = e.slice(0, u).trimEnd() + p;
|
|
2083
2083
|
t.placeholder = m;
|
|
2084
2084
|
}
|
|
2085
2085
|
autosizeTextarea(t, e = 3) {
|
|
@@ -2115,8 +2115,8 @@ class ve extends b {
|
|
|
2115
2115
|
), n.addEventListener("input", (l) => {
|
|
2116
2116
|
const r = l.target;
|
|
2117
2117
|
this.updateLanguageValue(t, r.value), t === this.defaultLanguage && this.updateOtherLanguagePlaceholders(r.value), this.autosizeTextarea(r, 3);
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2118
|
+
const p = n.getAttribute("data-full-placeholder") || "";
|
|
2119
|
+
p && this.adaptPlaceholderToSingleLine(n, p);
|
|
2120
2120
|
}), i.appendChild(n), ((l) => (typeof queueMicrotask == "function" ? queueMicrotask : (r) => setTimeout(r, 0))(l))(() => {
|
|
2121
2121
|
this.autosizeTextarea(n, 3);
|
|
2122
2122
|
const l = n.getAttribute("data-full-placeholder") || "";
|
|
@@ -2217,18 +2217,18 @@ class Ce extends b {
|
|
|
2217
2217
|
}
|
|
2218
2218
|
const ct = (c, t, e) => {
|
|
2219
2219
|
let i = !1, s = 0, n = 0, o = 0, a = 0;
|
|
2220
|
-
const l = (
|
|
2221
|
-
if (
|
|
2222
|
-
i = !0, s =
|
|
2220
|
+
const l = (h) => {
|
|
2221
|
+
if (h.target.closest("button")) return;
|
|
2222
|
+
i = !0, s = h.clientX, n = h.clientY;
|
|
2223
2223
|
const d = t.getBoundingClientRect();
|
|
2224
|
-
o = d.left, a = d.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup",
|
|
2225
|
-
}, r = (
|
|
2224
|
+
o = d.left, a = d.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup", p), document.body.style.userSelect = "none";
|
|
2225
|
+
}, r = (h) => {
|
|
2226
2226
|
if (!i) return;
|
|
2227
|
-
const d =
|
|
2227
|
+
const d = h.clientX - s, u = h.clientY - n, m = window.innerWidth, f = window.innerHeight, g = t.offsetWidth, C = t.offsetHeight;
|
|
2228
2228
|
let y = o + d, L = a + u;
|
|
2229
2229
|
y = Math.max(8, Math.min(m - g - 8, y)), L = Math.max(8, Math.min(f - C - 8, L)), t.style.left = `${y}px`, t.style.top = `${L}px`, e == null || e(y, L);
|
|
2230
|
-
},
|
|
2231
|
-
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup",
|
|
2230
|
+
}, p = () => {
|
|
2231
|
+
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", p), document.body.style.userSelect = "";
|
|
2232
2232
|
};
|
|
2233
2233
|
c.addEventListener("mousedown", l);
|
|
2234
2234
|
}, A = (c) => {
|
|
@@ -2244,10 +2244,10 @@ const ct = (c, t, e) => {
|
|
|
2244
2244
|
};
|
|
2245
2245
|
}, H = (c) => {
|
|
2246
2246
|
const { r: t, g: e, b: i } = k(c), s = t / 255, n = e / 255, o = i / 255, a = Math.max(s, n, o), l = Math.min(s, n, o), r = a - l;
|
|
2247
|
-
let
|
|
2248
|
-
r !== 0 && (a === s ?
|
|
2249
|
-
const
|
|
2250
|
-
return { h:
|
|
2247
|
+
let p = 0;
|
|
2248
|
+
r !== 0 && (a === s ? p = (n - o) / r % 6 : a === n ? p = (o - s) / r + 2 : p = (s - n) / r + 4), p < 0 && (p += 6);
|
|
2249
|
+
const h = a === 0 ? 0 : r / a, d = a;
|
|
2250
|
+
return { h: p * 60, s: h, v: d };
|
|
2251
2251
|
}, G = (c, t, e) => {
|
|
2252
2252
|
const i = (c % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)), o = e - s;
|
|
2253
2253
|
let a = 0, l = 0, r = 0;
|
|
@@ -2564,39 +2564,41 @@ const et = (c, t) => {
|
|
|
2564
2564
|
const i = document.createElement("div");
|
|
2565
2565
|
i.className = "color-picker-recent-title", i.textContent = "Recently Used";
|
|
2566
2566
|
const s = document.createElement("div");
|
|
2567
|
-
s.className = "color-picker-
|
|
2568
|
-
const n =
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2567
|
+
s.className = "color-picker-tooltip", s.style.display = "none", e.appendChild(s);
|
|
2568
|
+
const n = () => {
|
|
2569
|
+
s.style.display = "none";
|
|
2570
|
+
}, o = (p, h) => {
|
|
2571
|
+
const d = p.getBoundingClientRect();
|
|
2572
|
+
s.textContent = h, s.style.left = `${d.left + d.width / 2}px`, s.style.top = `${d.bottom + 8}px`, s.style.display = "block";
|
|
2573
|
+
}, a = document.createElement("div");
|
|
2574
|
+
a.className = "color-picker-recent-grid";
|
|
2575
|
+
const l = document.createElement("div");
|
|
2576
|
+
l.className = "color-picker-recent-placeholder", l.textContent = "No recent colors yet", e.appendChild(i), e.appendChild(a), e.appendChild(l);
|
|
2577
|
+
const r = () => {
|
|
2578
|
+
n(), a.innerHTML = "";
|
|
2579
|
+
const p = B.getColors(t);
|
|
2580
|
+
if (p.length === 0) {
|
|
2581
|
+
a.style.display = "none", l.style.display = "block";
|
|
2575
2582
|
return;
|
|
2576
2583
|
}
|
|
2577
|
-
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2580
|
-
const
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
}), r.addEventListener("mouseleave", () => {
|
|
2587
|
-
p.style.display = "none", r.style.boxShadow = "";
|
|
2588
|
-
}), r.addEventListener("mousedown", () => {
|
|
2589
|
-
r.style.boxShadow = "0px 0px 0px 2px var(--grey40)";
|
|
2590
|
-
}), r.addEventListener("mouseup", () => {
|
|
2584
|
+
a.style.display = "grid", l.style.display = "none", p.forEach((h) => {
|
|
2585
|
+
const d = document.createElement("button");
|
|
2586
|
+
d.type = "button", d.className = "color-picker-recent-swatch";
|
|
2587
|
+
const u = Wt(h);
|
|
2588
|
+
d.title = u, d.setAttribute("aria-label", `Use color: ${u}`), d.style.background = h, d.style.borderColor = h, d.addEventListener("mouseenter", () => o(d, u)), d.addEventListener("mouseleave", () => {
|
|
2589
|
+
n(), d.style.boxShadow = "";
|
|
2590
|
+
}), d.addEventListener("mousedown", () => {
|
|
2591
|
+
d.style.boxShadow = "0px 0px 0px 2px var(--grey40)";
|
|
2592
|
+
}), d.addEventListener("mouseup", () => {
|
|
2591
2593
|
setTimeout(() => {
|
|
2592
|
-
|
|
2594
|
+
d.style.boxShadow = "";
|
|
2593
2595
|
}, 150);
|
|
2594
|
-
}),
|
|
2595
|
-
|
|
2596
|
-
}),
|
|
2596
|
+
}), d.addEventListener("click", () => {
|
|
2597
|
+
n(), c(h);
|
|
2598
|
+
}), a.appendChild(d);
|
|
2597
2599
|
});
|
|
2598
2600
|
};
|
|
2599
|
-
return
|
|
2601
|
+
return r(), { container: e, refresh: r };
|
|
2600
2602
|
}, Wt = (c) => {
|
|
2601
2603
|
const t = T(c);
|
|
2602
2604
|
if (t)
|
|
@@ -2624,10 +2626,18 @@ class Jt {
|
|
|
2624
2626
|
if (!this.isOpen) return;
|
|
2625
2627
|
const s = i.target;
|
|
2626
2628
|
if (this.element.contains(s)) return;
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2629
|
+
if (this.backdrop.contains(s)) {
|
|
2630
|
+
i.preventDefault(), i.stopPropagation(), this.close(!0);
|
|
2631
|
+
return;
|
|
2632
|
+
}
|
|
2633
|
+
const n = document.querySelectorAll(
|
|
2634
|
+
".gstop-color-input, .gstop-color-preview, .gradient-mini-preview"
|
|
2635
|
+
);
|
|
2636
|
+
if (Array.from(n).some(
|
|
2637
|
+
(l) => l.contains(s)
|
|
2638
|
+
)) return;
|
|
2639
|
+
const a = document.querySelector(".gradient-popover");
|
|
2640
|
+
a && a.contains(s) || (i.preventDefault(), i.stopPropagation(), this.close(!0));
|
|
2631
2641
|
}, this.keyDown = (i) => {
|
|
2632
2642
|
if (this.isOpen) {
|
|
2633
2643
|
if (i.key === "Escape")
|
|
@@ -2663,14 +2673,14 @@ class Jt {
|
|
|
2663
2673
|
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML = jt;
|
|
2664
2674
|
const r = document.createElement("div");
|
|
2665
2675
|
r.className = "color-picker-sliders-group";
|
|
2666
|
-
const h = document.createElement("div");
|
|
2667
|
-
h.className = "color-picker-hue", this.hueSlider = h;
|
|
2668
2676
|
const p = document.createElement("div");
|
|
2669
|
-
p.className = "color-picker-hue
|
|
2677
|
+
p.className = "color-picker-hue", this.hueSlider = p;
|
|
2678
|
+
const h = document.createElement("div");
|
|
2679
|
+
h.className = "color-picker-hue-marker", this.hueMarker = h, p.appendChild(h);
|
|
2670
2680
|
const d = document.createElement("div");
|
|
2671
2681
|
d.className = "color-picker-opacity", this.opacitySlider = d;
|
|
2672
2682
|
const u = document.createElement("div");
|
|
2673
|
-
u.className = "color-picker-opacity-marker", this.opacityMarker = u, d.appendChild(u), r.appendChild(
|
|
2683
|
+
u.className = "color-picker-opacity-marker", this.opacityMarker = u, d.appendChild(u), r.appendChild(p), r.appendChild(d), a.appendChild(l), a.appendChild(r);
|
|
2674
2684
|
const m = et((E) => {
|
|
2675
2685
|
var x;
|
|
2676
2686
|
this.setColor(E), (x = this.onChange) == null || x.call(this, E, this.currentOpacity);
|
|
@@ -2691,7 +2701,7 @@ class Jt {
|
|
|
2691
2701
|
const O = document.createElement("div");
|
|
2692
2702
|
O.className = "color-picker-input-container";
|
|
2693
2703
|
const v = document.createElement("button");
|
|
2694
|
-
return v.className = "color-picker-copy-inside", v.textContent = "Copy", O.appendChild(I), O.appendChild(v), f.appendChild(g), f.appendChild(O), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(m.container), t.appendChild(f), t.addEventListener("click", (E) => E.stopPropagation()), this.bind(n,
|
|
2704
|
+
return v.className = "color-picker-copy-inside", v.textContent = "Copy", O.appendChild(I), O.appendChild(v), f.appendChild(g), f.appendChild(O), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(m.container), t.appendChild(f), t.addEventListener("click", (E) => E.stopPropagation()), this.bind(n, p, d, I, g, v, l), t;
|
|
2695
2705
|
}
|
|
2696
2706
|
createBackdrop() {
|
|
2697
2707
|
const t = document.createElement("div");
|
|
@@ -2700,44 +2710,44 @@ class Jt {
|
|
|
2700
2710
|
}), t;
|
|
2701
2711
|
}
|
|
2702
2712
|
bind(t, e, i, s, n, o, a) {
|
|
2703
|
-
const l = (
|
|
2713
|
+
const l = (h) => {
|
|
2704
2714
|
var y;
|
|
2705
|
-
const d = t.getBoundingClientRect(), u = Math.max(0, Math.min(1, (
|
|
2715
|
+
const d = t.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width)), m = Math.max(0, Math.min(1, (h.clientY - d.top) / d.height));
|
|
2706
2716
|
this.colorMarker.style.left = `${u * 100}%`, this.colorMarker.style.top = `${m * 100}%`;
|
|
2707
2717
|
const g = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, C = G(g, u, 1 - m);
|
|
2708
2718
|
this.currentColor = C, this.syncInput(), this.updateOpacityBg(), (y = this.onChange) == null || y.call(this, C, this.currentOpacity);
|
|
2709
|
-
}, r = (
|
|
2719
|
+
}, r = (h) => {
|
|
2710
2720
|
var y;
|
|
2711
2721
|
const d = e.getBoundingClientRect();
|
|
2712
|
-
let u = Math.max(0, Math.min(1, (
|
|
2722
|
+
let u = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width));
|
|
2713
2723
|
this.hueMarker.style.left = `${u * 100}%`;
|
|
2714
2724
|
const m = u * 360, f = this.parsePercentage(this.colorMarker.style.left || "0%"), g = this.parsePercentage(this.colorMarker.style.top || "0%"), C = G(m, f, 1 - g);
|
|
2715
2725
|
this.currentColor = C, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${m}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (y = this.onChange) == null || y.call(this, C, this.currentOpacity);
|
|
2716
|
-
},
|
|
2726
|
+
}, p = (h) => {
|
|
2717
2727
|
var m;
|
|
2718
|
-
const d = i.getBoundingClientRect(), u = Math.max(0, Math.min(1, (
|
|
2728
|
+
const d = i.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - d.left) / d.width));
|
|
2719
2729
|
this.opacityMarker.style.left = `${u * 100}%`, this.currentOpacity = Math.round(u * 100), (m = this.onChange) == null || m.call(this, this.currentColor, this.currentOpacity);
|
|
2720
2730
|
};
|
|
2721
|
-
t.addEventListener("mousedown", (
|
|
2722
|
-
|
|
2731
|
+
t.addEventListener("mousedown", (h) => {
|
|
2732
|
+
h.preventDefault(), l(h);
|
|
2723
2733
|
const d = (m) => l(m), u = () => {
|
|
2724
2734
|
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", u);
|
|
2725
2735
|
};
|
|
2726
2736
|
document.addEventListener("mousemove", d), document.addEventListener("mouseup", u);
|
|
2727
|
-
}), e.addEventListener("mousedown", (
|
|
2728
|
-
|
|
2737
|
+
}), e.addEventListener("mousedown", (h) => {
|
|
2738
|
+
h.preventDefault(), r(h);
|
|
2729
2739
|
const d = (m) => r(m), u = () => {
|
|
2730
2740
|
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", u);
|
|
2731
2741
|
};
|
|
2732
2742
|
document.addEventListener("mousemove", d), document.addEventListener("mouseup", u);
|
|
2733
|
-
}), i.addEventListener("mousedown", (
|
|
2734
|
-
|
|
2735
|
-
const d = (m) =>
|
|
2743
|
+
}), i.addEventListener("mousedown", (h) => {
|
|
2744
|
+
h.preventDefault(), p(h);
|
|
2745
|
+
const d = (m) => p(m), u = () => {
|
|
2736
2746
|
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", u);
|
|
2737
2747
|
};
|
|
2738
2748
|
document.addEventListener("mousemove", d), document.addEventListener("mouseup", u);
|
|
2739
|
-
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (
|
|
2740
|
-
|
|
2749
|
+
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (h) => {
|
|
2750
|
+
h.key === "Enter" && (h.preventDefault(), this.syncInput(), s.blur());
|
|
2741
2751
|
}), o.addEventListener("click", async () => {
|
|
2742
2752
|
try {
|
|
2743
2753
|
await navigator.clipboard.writeText(s.value);
|
|
@@ -2745,14 +2755,14 @@ class Jt {
|
|
|
2745
2755
|
s.select(), document.execCommand("copy");
|
|
2746
2756
|
}
|
|
2747
2757
|
}), a.addEventListener("click", async () => {
|
|
2748
|
-
var
|
|
2758
|
+
var h;
|
|
2749
2759
|
if (!("EyeDropper" in window)) {
|
|
2750
2760
|
alert("EyeDropper API is not supported in this browser.");
|
|
2751
2761
|
return;
|
|
2752
2762
|
}
|
|
2753
2763
|
try {
|
|
2754
2764
|
const d = new window.EyeDropper(), { sRGBHex: u } = await d.open();
|
|
2755
|
-
this.setColor(u), (
|
|
2765
|
+
this.setColor(u), (h = this.onChange) == null || h.call(this, u, this.currentOpacity);
|
|
2756
2766
|
} catch {
|
|
2757
2767
|
}
|
|
2758
2768
|
}), document.addEventListener("keydown", this.keyDown, !0), setTimeout(
|
|
@@ -2810,12 +2820,12 @@ class Jt {
|
|
|
2810
2820
|
this.currentColor = t, this.currentOpacity = i ?? 100, this.syncInput();
|
|
2811
2821
|
const { h: s, s: n, v: o } = H(t);
|
|
2812
2822
|
this.hueMarker.style.left = `${s / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 - o) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`, this.updateOpacityBg(), this.opacityMarker.style.left = `${this.currentOpacity}%`, (L = this.recentSectionRefresh) == null || L.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);
|
|
2813
|
-
const a = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(),
|
|
2823
|
+
const a = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(), p = window.innerWidth, h = window.innerHeight, d = 16;
|
|
2814
2824
|
let u = r.right + 8, m = r.top;
|
|
2815
|
-
const f =
|
|
2816
|
-
f >= a + d ? u = r.right + 8 : g >= a + d ? u = r.left - a - 8 : u = Math.max(d, (
|
|
2817
|
-
const C =
|
|
2818
|
-
C >= l + d ? m = r.bottom + 8 : y >= l + d ? m = r.top - l - 8 : C > y ? (m = r.bottom + 8, m + l >
|
|
2825
|
+
const f = p - r.right, g = r.left;
|
|
2826
|
+
f >= a + d ? u = r.right + 8 : g >= a + d ? u = r.left - a - 8 : u = Math.max(d, (p - a) / 2);
|
|
2827
|
+
const C = h - r.bottom, y = r.top;
|
|
2828
|
+
C >= l + d ? m = r.bottom + 8 : y >= l + d ? m = r.top - l - 8 : C > y ? (m = r.bottom + 8, m + l > h - d && (m = h - l - d)) : (m = r.top - l - 8, m < d && (m = d)), this.element.style.left = `${u}px`, this.element.style.top = `${m}px`;
|
|
2819
2829
|
}
|
|
2820
2830
|
close(t) {
|
|
2821
2831
|
var e;
|
|
@@ -2880,7 +2890,7 @@ class Xt {
|
|
|
2880
2890
|
".color-picker-opacity"
|
|
2881
2891
|
), this.opacityMarker = this.container.querySelector(
|
|
2882
2892
|
".color-picker-opacity-marker"
|
|
2883
|
-
), this.formatSelect = this.container.querySelector(
|
|
2893
|
+
), this.ensureMarkerSizes(), this.formatSelect = this.container.querySelector(
|
|
2884
2894
|
".color-picker-format-select"
|
|
2885
2895
|
), this.colorInput = this.container.querySelector(
|
|
2886
2896
|
".color-picker-color-input"
|
|
@@ -2888,44 +2898,54 @@ class Xt {
|
|
|
2888
2898
|
const t = this.container.querySelector(
|
|
2889
2899
|
".color-picker-copy-inside"
|
|
2890
2900
|
), { h: e, s: i, v: s } = H(this.currentColor);
|
|
2891
|
-
this.hueMarker.style.left = `${e / 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(${e}, 100%, 50%))`, this.opacityMarker.style.left = `${this.currentOpacity}%`, this.updateOpacityBackground(this.opacitySlider), this.updateColorInput(this.formatSelect, this.colorInput), this.setupColorAreaEvents(), this.setupHueSliderEvents(), this.setupOpacitySliderEvents(), this.setupFormatEvents(t);
|
|
2901
|
+
this.hueMarker.style.left = `${e / 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(${e}, 100%, 50%))`, this.opacityMarker.style.left = `${this.currentOpacity}%`, this.updateOpacityBackground(this.opacitySlider), this.updateColorInput(this.formatSelect, this.colorInput), this.ensureMarkerSizes(), this.setupColorAreaEvents(), this.setupHueSliderEvents(), this.setupOpacitySliderEvents(), this.setupFormatEvents(t);
|
|
2892
2902
|
}
|
|
2893
2903
|
scheduleInputUpdate() {
|
|
2894
2904
|
this.inputUpdateTimeout && clearTimeout(this.inputUpdateTimeout), this.inputUpdateTimeout = window.setTimeout(() => {
|
|
2895
2905
|
this.updateColorInput(this.formatSelect, this.colorInput);
|
|
2896
2906
|
}, 16);
|
|
2897
2907
|
}
|
|
2908
|
+
ensureMarkerSizes() {
|
|
2909
|
+
this.colorMarker && (this.colorMarker.style.width = "16px", this.colorMarker.style.height = "16px"), this.hueMarker && (this.hueMarker.style.width = "16px", this.hueMarker.style.height = "16px"), this.opacityMarker && (this.opacityMarker.style.width = "16px", this.opacityMarker.style.height = "16px");
|
|
2910
|
+
}
|
|
2898
2911
|
addPointerDrag(t, e, i) {
|
|
2899
|
-
t.style.touchAction = "none", t.addEventListener("pointerdown", (s) => {
|
|
2900
|
-
s.preventDefault(),
|
|
2901
|
-
const n =
|
|
2912
|
+
t.style.touchAction = "none", t.style.userSelect = "none", t.addEventListener("pointerdown", (s) => {
|
|
2913
|
+
s.preventDefault(), s.stopPropagation();
|
|
2914
|
+
const n = t.getBoundingClientRect();
|
|
2915
|
+
if (n.width === 0 || n.height === 0) {
|
|
2916
|
+
console.warn("Target has no dimensions for pointer events");
|
|
2917
|
+
return;
|
|
2918
|
+
}
|
|
2919
|
+
this.isDragging = !0, this.pendingExternalUpdate = void 0;
|
|
2920
|
+
const o = s.pointerId;
|
|
2902
2921
|
if (t.setPointerCapture)
|
|
2903
2922
|
try {
|
|
2904
|
-
t.setPointerCapture(
|
|
2905
|
-
} catch {
|
|
2923
|
+
t.setPointerCapture(o);
|
|
2924
|
+
} catch (h) {
|
|
2925
|
+
console.warn("Failed to capture pointer:", h);
|
|
2906
2926
|
}
|
|
2907
2927
|
e(s);
|
|
2908
|
-
const
|
|
2909
|
-
h.pointerId ===
|
|
2910
|
-
},
|
|
2928
|
+
const a = (h) => {
|
|
2929
|
+
h.pointerId === o && e(h);
|
|
2930
|
+
}, l = () => {
|
|
2911
2931
|
if (t.releasePointerCapture)
|
|
2912
2932
|
try {
|
|
2913
|
-
t.releasePointerCapture(
|
|
2933
|
+
t.releasePointerCapture(o);
|
|
2914
2934
|
} catch {
|
|
2915
2935
|
}
|
|
2916
|
-
document.removeEventListener("pointermove",
|
|
2917
|
-
},
|
|
2918
|
-
if (h.pointerId ===
|
|
2919
|
-
if (
|
|
2920
|
-
const { color:
|
|
2921
|
-
this.applyExternalUpdate(
|
|
2936
|
+
document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", r), document.removeEventListener("pointercancel", p);
|
|
2937
|
+
}, r = (h) => {
|
|
2938
|
+
if (h.pointerId === o) {
|
|
2939
|
+
if (l(), this.isDragging = !1, this.pendingExternalUpdate) {
|
|
2940
|
+
const { color: d, opacity: u } = this.pendingExternalUpdate;
|
|
2941
|
+
this.applyExternalUpdate(d, u), this.pendingExternalUpdate = void 0;
|
|
2922
2942
|
}
|
|
2923
2943
|
i == null || i();
|
|
2924
2944
|
}
|
|
2925
|
-
},
|
|
2926
|
-
h.pointerId ===
|
|
2945
|
+
}, p = (h) => {
|
|
2946
|
+
h.pointerId === o && l();
|
|
2927
2947
|
};
|
|
2928
|
-
document.addEventListener("pointermove",
|
|
2948
|
+
document.addEventListener("pointermove", a), document.addEventListener("pointerup", r), document.addEventListener("pointercancel", p);
|
|
2929
2949
|
});
|
|
2930
2950
|
}
|
|
2931
2951
|
updateOpacityBackground(t) {
|
|
@@ -2961,10 +2981,16 @@ class Xt {
|
|
|
2961
2981
|
}
|
|
2962
2982
|
setupColorAreaEvents() {
|
|
2963
2983
|
const t = (e) => {
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2984
|
+
e.stopPropagation();
|
|
2985
|
+
const i = this.colorArea.getBoundingClientRect();
|
|
2986
|
+
if (i.width === 0 || i.height === 0) {
|
|
2987
|
+
console.warn("Color area has no dimensions");
|
|
2988
|
+
return;
|
|
2989
|
+
}
|
|
2990
|
+
const s = (e.clientX - i.left) / i.width, n = (e.clientY - i.top) / i.height, o = Math.max(0, Math.min(1, s)), a = Math.max(0, Math.min(1, n));
|
|
2991
|
+
this.colorMarker.style.left = `${o * 100}%`, this.colorMarker.style.top = `${a * 100}%`;
|
|
2992
|
+
const l = parseFloat(this.hueMarker.style.left || "0%"), r = Math.max(0, Math.min(360, l / 100 * 360)), p = Math.max(0, Math.min(1, o)), h = Math.max(0, Math.min(1, 1 - a)), d = G(r, p, h);
|
|
2993
|
+
d !== this.currentColor && (this.currentColor = d, this.updateOpacityBackground(this.opacitySlider), this.scheduleInputUpdate(), this.triggerChange());
|
|
2968
2994
|
};
|
|
2969
2995
|
this.addPointerDrag(this.colorArea, t, () => {
|
|
2970
2996
|
this.updateColorInput(this.formatSelect, this.colorInput), this.updateOpacityBackground(this.opacitySlider);
|
|
@@ -2972,21 +2998,27 @@ class Xt {
|
|
|
2972
2998
|
}
|
|
2973
2999
|
setupHueSliderEvents() {
|
|
2974
3000
|
const t = (e) => {
|
|
3001
|
+
e.stopPropagation();
|
|
2975
3002
|
const i = this.hueSlider.getBoundingClientRect();
|
|
3003
|
+
if (i.width === 0) {
|
|
3004
|
+
console.warn("Hue slider has no width");
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
2976
3007
|
let s = (e.clientX - i.left) / i.width;
|
|
2977
|
-
|
|
2978
|
-
|
|
3008
|
+
const n = Math.max(0, Math.min(1, s));
|
|
3009
|
+
this.hueMarker.style.left = `${n * 100}%`;
|
|
3010
|
+
const o = Math.max(0, Math.min(360, n * 360)), a = parseFloat(
|
|
2979
3011
|
this.colorMarker.style.left || "50%"
|
|
2980
|
-
),
|
|
3012
|
+
), l = parseFloat(this.colorMarker.style.top || "50%"), r = Math.max(
|
|
2981
3013
|
0,
|
|
2982
|
-
Math.min(1,
|
|
2983
|
-
),
|
|
3014
|
+
Math.min(1, isNaN(a) ? 0.5 : a / 100)
|
|
3015
|
+
), p = Math.max(
|
|
2984
3016
|
0,
|
|
2985
|
-
Math.min(1,
|
|
3017
|
+
Math.min(1, isNaN(l) ? 0.5 : l / 100)
|
|
2986
3018
|
);
|
|
2987
|
-
this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${
|
|
2988
|
-
const h = G(
|
|
2989
|
-
this.currentColor = h, this.updateOpacityBackground(this.opacitySlider), this.scheduleInputUpdate(), this.triggerChange();
|
|
3019
|
+
this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`;
|
|
3020
|
+
const h = G(o, r, 1 - p);
|
|
3021
|
+
h !== this.currentColor && (this.currentColor = h, this.updateOpacityBackground(this.opacitySlider), this.scheduleInputUpdate(), this.triggerChange());
|
|
2990
3022
|
};
|
|
2991
3023
|
this.addPointerDrag(this.hueSlider, t, () => {
|
|
2992
3024
|
this.inputUpdateTimeout && clearTimeout(this.inputUpdateTimeout), this.updateColorInput(this.formatSelect, this.colorInput);
|
|
@@ -2994,8 +3026,16 @@ class Xt {
|
|
|
2994
3026
|
}
|
|
2995
3027
|
setupOpacitySliderEvents() {
|
|
2996
3028
|
const t = (e) => {
|
|
2997
|
-
|
|
2998
|
-
|
|
3029
|
+
e.stopPropagation();
|
|
3030
|
+
const i = this.opacitySlider.getBoundingClientRect();
|
|
3031
|
+
if (i.width === 0) {
|
|
3032
|
+
console.warn("Opacity slider has no width");
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
const s = (e.clientX - i.left) / i.width, n = Math.max(0, Math.min(1, s));
|
|
3036
|
+
this.opacityMarker.style.left = `${n * 100}%`;
|
|
3037
|
+
const o = Math.round(n * 100);
|
|
3038
|
+
o !== this.currentOpacity && (this.currentOpacity = o, this.triggerChange());
|
|
2999
3039
|
};
|
|
3000
3040
|
this.addPointerDrag(this.opacitySlider, t);
|
|
3001
3041
|
}
|
|
@@ -3103,12 +3143,12 @@ const V = class V extends b {
|
|
|
3103
3143
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
3104
3144
|
const s = i.target, n = this.popoverEl.contains(s), o = (d = this.element) == null ? void 0 : d.contains(s), a = document.querySelectorAll(".custom-color-picker"), l = Array.from(a).some((u) => u.contains(s)), r = s.closest(
|
|
3105
3145
|
".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"
|
|
3106
|
-
), h = s.classList.contains(
|
|
3107
|
-
"color-picker-backdrop"
|
|
3108
3146
|
), p = s.classList.contains(
|
|
3147
|
+
"color-picker-backdrop"
|
|
3148
|
+
), h = s.classList.contains(
|
|
3109
3149
|
"gradient-popover-backdrop"
|
|
3110
3150
|
);
|
|
3111
|
-
!n && !o && !l && !r && !
|
|
3151
|
+
!n && !o && !l && !r && !p && !h && this.closePopover();
|
|
3112
3152
|
}, this.handlePopoverKeydown = (i) => {
|
|
3113
3153
|
if (this.isPopoverOpen) {
|
|
3114
3154
|
if (i.key === "Escape") {
|
|
@@ -3305,14 +3345,14 @@ const V = class V extends b {
|
|
|
3305
3345
|
l.className = "gradient-preview", this.updateGradientPreview(l);
|
|
3306
3346
|
const r = document.createElement("div");
|
|
3307
3347
|
r.className = "gradient-handles", l.appendChild(r), t.appendChild(l), this.createHandles(r, l);
|
|
3308
|
-
const
|
|
3309
|
-
|
|
3310
|
-
const
|
|
3311
|
-
|
|
3348
|
+
const p = document.createElement("div");
|
|
3349
|
+
p.className = "gradient-stops-header";
|
|
3350
|
+
const h = document.createElement("span");
|
|
3351
|
+
h.textContent = "Stops";
|
|
3312
3352
|
const d = document.createElement("button");
|
|
3313
|
-
d.type = "button", d.className = "gradient-add-stop", d.textContent = "+",
|
|
3353
|
+
d.type = "button", d.className = "gradient-add-stop", d.textContent = "+", p.appendChild(h), p.appendChild(d);
|
|
3314
3354
|
const u = document.createElement("div");
|
|
3315
|
-
u.className = "gradient-stops", t.appendChild(
|
|
3355
|
+
u.className = "gradient-stops", t.appendChild(p), t.appendChild(u), this.updateStopsList(u);
|
|
3316
3356
|
const m = et((f) => {
|
|
3317
3357
|
const g = T(f);
|
|
3318
3358
|
g && (this.value = g, this.switchType(g.type), this.updateUI(), this.triggerChange());
|
|
@@ -3343,17 +3383,17 @@ const V = class V extends b {
|
|
|
3343
3383
|
const o = document.createElement("div");
|
|
3344
3384
|
o.className = "gstop-chip", o.style.backgroundColor = i.color, n.appendChild(o);
|
|
3345
3385
|
let a = !1, l = 0, r = 0;
|
|
3346
|
-
const
|
|
3347
|
-
a = !0, l = u.clientX, r = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove",
|
|
3348
|
-
},
|
|
3386
|
+
const p = (u) => {
|
|
3387
|
+
a = !0, l = u.clientX, r = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove", h), document.addEventListener("mouseup", d), u.preventDefault(), u.stopPropagation();
|
|
3388
|
+
}, h = (u) => {
|
|
3349
3389
|
if (!a || !this.value) return;
|
|
3350
3390
|
const m = e.getBoundingClientRect(), f = u.clientX - l;
|
|
3351
3391
|
let g = r + f / m.width * 100;
|
|
3352
3392
|
g = Math.max(0, Math.min(100, g)), this.value.stops[s].position = Math.round(g), n.style.left = `${g}%`, this.updateGradientPreview();
|
|
3353
3393
|
}, d = () => {
|
|
3354
|
-
a && (a = !1, n.classList.remove("selected"), document.removeEventListener("mousemove",
|
|
3394
|
+
a && (a = !1, n.classList.remove("selected"), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", d), this.value && (this.value.stops.sort((u, m) => u.position - m.position), this.createHandles(t, e), this.updateStopsList()), this.updateUI(), this.triggerChange());
|
|
3355
3395
|
};
|
|
3356
|
-
n.addEventListener("mousedown",
|
|
3396
|
+
n.addEventListener("mousedown", p), t.appendChild(n);
|
|
3357
3397
|
});
|
|
3358
3398
|
}
|
|
3359
3399
|
updateStopsList(t) {
|
|
@@ -3369,12 +3409,12 @@ const V = class V extends b {
|
|
|
3369
3409
|
l.type = "text", l.className = "gstop-position-input", l.value = `${s.position}%`, l.style.width = "60px", a.appendChild(l);
|
|
3370
3410
|
const r = document.createElement("div");
|
|
3371
3411
|
r.className = "gstop-color-container";
|
|
3372
|
-
const
|
|
3373
|
-
|
|
3374
|
-
const
|
|
3375
|
-
|
|
3412
|
+
const p = document.createElement("div");
|
|
3413
|
+
p.className = "gstop-color-preview", p.style.backgroundColor = s.color;
|
|
3414
|
+
const h = document.createElement("input");
|
|
3415
|
+
h.type = "text", h.className = "gstop-color-input", h.value = s.color.replace("#", "").toUpperCase();
|
|
3376
3416
|
const d = document.createElement("button");
|
|
3377
|
-
d.type = "button", d.className = "gstop-color-copy", d.textContent = "Copy", r.appendChild(
|
|
3417
|
+
d.type = "button", d.className = "gstop-color-copy", d.textContent = "Copy", r.appendChild(p), r.appendChild(h), r.appendChild(d);
|
|
3378
3418
|
const u = document.createElement("button");
|
|
3379
3419
|
u.type = "button", u.className = "gstop-del", u.innerHTML = _t, u.disabled = (((O = (I = this.value) == null ? void 0 : I.stops) == null ? void 0 : O.length) || 0) <= 2, o.appendChild(a), o.appendChild(r), o.appendChild(u), e.appendChild(o);
|
|
3380
3420
|
const m = document.createElement("span");
|
|
@@ -3391,7 +3431,7 @@ const V = class V extends b {
|
|
|
3391
3431
|
const y = document.createElement("span");
|
|
3392
3432
|
y.className = "gstop-opacity-value", y.textContent = `${s.opacity ?? 100}%`, f.appendChild(g), f.appendChild(y);
|
|
3393
3433
|
const L = new Jt((v, E) => {
|
|
3394
|
-
|
|
3434
|
+
h.value = v.replace("#", "").toUpperCase(), p.style.backgroundColor = v, this.value.stops[n].color = v, E !== void 0 && (this.value.stops[n].opacity = E, g.value = String(E), y.textContent = `${E}%`);
|
|
3395
3435
|
const x = k(v);
|
|
3396
3436
|
g.style.setProperty(
|
|
3397
3437
|
"--slider-color",
|
|
@@ -3401,24 +3441,24 @@ const V = class V extends b {
|
|
|
3401
3441
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3402
3442
|
), this.updateUI(), this.triggerChange();
|
|
3403
3443
|
}, "solid");
|
|
3404
|
-
|
|
3405
|
-
v.preventDefault(), v.stopPropagation(), L.open(s.color,
|
|
3406
|
-
}),
|
|
3407
|
-
const v =
|
|
3444
|
+
h.addEventListener("click", (v) => {
|
|
3445
|
+
v.preventDefault(), v.stopPropagation(), L.open(s.color, h, s.opacity ?? 100);
|
|
3446
|
+
}), h.addEventListener("input", () => {
|
|
3447
|
+
const v = h.value.trim(), E = v.startsWith("#") ? v : `#${v}`;
|
|
3408
3448
|
if (/^#[0-9A-Fa-f]{6}$/.test(E)) {
|
|
3409
|
-
this.value.stops[n].color = E,
|
|
3449
|
+
this.value.stops[n].color = E, p.style.backgroundColor = E;
|
|
3410
3450
|
const x = k(E);
|
|
3411
3451
|
g.style.setProperty(
|
|
3412
3452
|
"--slider-color",
|
|
3413
3453
|
`rgb(${x.r}, ${x.g}, ${x.b})`
|
|
3414
3454
|
), this.debouncedPreviewUpdate();
|
|
3415
3455
|
}
|
|
3416
|
-
}),
|
|
3456
|
+
}), h.addEventListener("blur", () => {
|
|
3417
3457
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3418
3458
|
}), d.addEventListener("click", async (v) => {
|
|
3419
3459
|
v.stopPropagation();
|
|
3420
3460
|
try {
|
|
3421
|
-
await navigator.clipboard.writeText(`#${
|
|
3461
|
+
await navigator.clipboard.writeText(`#${h.value}`);
|
|
3422
3462
|
} catch {
|
|
3423
3463
|
}
|
|
3424
3464
|
}), l.addEventListener("focus", (v) => {
|
|
@@ -3481,8 +3521,8 @@ const V = class V extends b {
|
|
|
3481
3521
|
this.popoverEl.style.position = "fixed", this.popoverEl.style.zIndex = "10000", this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3482
3522
|
const o = this.popoverEl.offsetHeight;
|
|
3483
3523
|
let a = t.right + 8, l = t.top;
|
|
3484
|
-
const r = i - t.right,
|
|
3485
|
-
r <
|
|
3524
|
+
const r = i - t.right, p = t.left, h = e + n;
|
|
3525
|
+
r < h && p > r + 100 && (a = t.left - e - 8);
|
|
3486
3526
|
const d = s - t.bottom, u = t.top;
|
|
3487
3527
|
u >= o + n ? l = t.top - o - 8 : d >= o + n ? l = t.bottom + 8 : u > d ? (l = t.top - o - 8, l < n && (l = n)) : (l = t.bottom + 8, l + o > s - n && (l = s - o - n)), this.popoverEl.style.left = `${a}px`, this.popoverEl.style.top = `${l}px`, this.popoverPosition = { left: a, top: l };
|
|
3488
3528
|
}
|
|
@@ -3505,8 +3545,8 @@ const V = class V extends b {
|
|
|
3505
3545
|
this.popoverEl.style.left, this.popoverEl.style.top, this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3506
3546
|
const a = this.popoverEl.offsetHeight;
|
|
3507
3547
|
let l = e.right + 8, r = e.top;
|
|
3508
|
-
const
|
|
3509
|
-
|
|
3548
|
+
const p = s - e.right, h = e.left, d = i + o;
|
|
3549
|
+
p < d && h > p + 100 && (l = e.left - i - 8);
|
|
3510
3550
|
const u = n - e.bottom, m = e.top;
|
|
3511
3551
|
m >= a + o ? r = e.top - a - 8 : u >= a + o ? r = e.bottom + 8 : m > u ? (r = e.top - a - 8, r < o && (r = o)) : (r = e.bottom + 8, r + a > n - o && (r = n - a - o)), this.popoverEl.style.left = `${l}px`, this.popoverEl.style.top = `${r}px`;
|
|
3512
3552
|
});
|
|
@@ -3725,8 +3765,8 @@ class j extends b {
|
|
|
3725
3765
|
const t = this.value === "auto" ? "text" : "number", e = (a) => {
|
|
3726
3766
|
this.value !== "auto" && (this.props.minValue !== void 0 && (a.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (a.max = String(this.props.maxValue)), this.props.className && a.classList.add(this.props.className), a.addEventListener("input", () => {
|
|
3727
3767
|
const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
3728
|
-
let
|
|
3729
|
-
|
|
3768
|
+
let p = Number(a.value);
|
|
3769
|
+
p < l && (p = l), p > r && (p = r), a.value = String(p);
|
|
3730
3770
|
}));
|
|
3731
3771
|
}, i = this.createInput({
|
|
3732
3772
|
value: this.value,
|