builder-settings-types 0.0.293 → 0.0.295
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ft = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
2
2
|
let lt = (c = 21) => {
|
|
3
3
|
let t = "", e = crypto.getRandomValues(new Uint8Array(c |= 0));
|
|
4
4
|
for (; c--; )
|
|
5
|
-
t +=
|
|
5
|
+
t += ft[e[c] & 63];
|
|
6
6
|
return t;
|
|
7
7
|
};
|
|
8
|
-
function
|
|
8
|
+
function vt(c) {
|
|
9
9
|
let t = 0, e = c.parentElement;
|
|
10
10
|
for (; e; )
|
|
11
11
|
e.classList.contains("setting-group") && e !== c && t++, e = e.parentElement;
|
|
12
12
|
return t;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function j(c, t) {
|
|
15
15
|
const e = Math.min(Math.max(t, 0), 5);
|
|
16
16
|
c.setAttribute("data-nesting-level", e.toString()), e > 0 ? c.style.setProperty("--visual-indent", `${e * 2}px`) : (c.style.removeProperty("--visual-indent"), c.style.marginLeft = "");
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function Y(c, t = 0) {
|
|
19
19
|
c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach((i) => {
|
|
20
20
|
const s = i, n = t + 1;
|
|
21
|
-
|
|
21
|
+
j(s, n), Y(s, n);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const Ct = {
|
|
25
25
|
maxLevel: 5,
|
|
26
26
|
spacingMultiplier: 1,
|
|
27
27
|
visualIndentMultiplier: 2,
|
|
28
28
|
enableAutoDetection: !0
|
|
29
29
|
};
|
|
30
|
-
class
|
|
30
|
+
class yt {
|
|
31
31
|
constructor(t = {}) {
|
|
32
|
-
this.observedElements = /* @__PURE__ */ new Set(), this.config = { ...
|
|
32
|
+
this.observedElements = /* @__PURE__ */ new Set(), this.config = { ...Ct, ...t }, this.config.enableAutoDetection && this.setupAutoDetection();
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Setup automatic detection using MutationObserver
|
|
@@ -63,7 +63,7 @@ class vt {
|
|
|
63
63
|
* Update nesting for a specific element
|
|
64
64
|
*/
|
|
65
65
|
updateElementNesting(t) {
|
|
66
|
-
const e =
|
|
66
|
+
const e = vt(t);
|
|
67
67
|
this.applyNestingWithConfig(t, e);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
@@ -111,7 +111,7 @@ class vt {
|
|
|
111
111
|
this.observer && (this.observer.disconnect(), this.observer = void 0), this.observedElements.clear();
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
const it = new
|
|
114
|
+
const it = new yt();
|
|
115
115
|
function J(c) {
|
|
116
116
|
if (c === null || typeof c != "object") return c;
|
|
117
117
|
if (c instanceof Date) return new Date(c.getTime());
|
|
@@ -124,7 +124,7 @@ function J(c) {
|
|
|
124
124
|
}
|
|
125
125
|
return c;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function Et(c) {
|
|
128
128
|
switch (c) {
|
|
129
129
|
case "number":
|
|
130
130
|
return 0;
|
|
@@ -192,7 +192,7 @@ class b {
|
|
|
192
192
|
const i = document.createElement("div");
|
|
193
193
|
i.className = t.wrapperClassName || "";
|
|
194
194
|
const s = document.createElement("input");
|
|
195
|
-
this.inputEl = s, s.value = String(t.value ||
|
|
195
|
+
this.inputEl = s, s.value = String(t.value || Et(t.inputType)), s.type = t.inputType, s.placeholder = t.placeholder || "", s.className = t.inputClassName || "", this.dataPropsPath && s.setAttribute("data-test-id", this.dataPropsPath);
|
|
196
196
|
const n = (a) => {
|
|
197
197
|
const l = a.target;
|
|
198
198
|
let r = l.value;
|
|
@@ -233,30 +233,30 @@ class b {
|
|
|
233
233
|
return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function A(c) {
|
|
237
237
|
return c instanceof b;
|
|
238
238
|
}
|
|
239
239
|
function w(c) {
|
|
240
240
|
return c instanceof P;
|
|
241
241
|
}
|
|
242
242
|
function st(c) {
|
|
243
|
-
return
|
|
243
|
+
return A(c) || w(c);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function U(c, t) {
|
|
246
246
|
for (const e in c)
|
|
247
247
|
if (Object.prototype.hasOwnProperty.call(c, e)) {
|
|
248
248
|
const i = c[e];
|
|
249
249
|
t(e, i);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
const
|
|
252
|
+
const Z = class Z {
|
|
253
253
|
constructor(t) {
|
|
254
254
|
this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.changeTimeout = null, this.isHandlingChange = !1, this.changeHandlers = /* @__PURE__ */ new Set(), this.blurTimeout = null, this.lastChangeTime = 0, this.handleBlur = () => {
|
|
255
255
|
}, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.hide = !1, this.id = t.id || lt(), this.title = t.title, this.settings = t.settings, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = t.includeGetJson ?? !0, this.addItemCfg = t.addItem, this.deleteItemCfg = t.deleteItem, this.dataProps = t.dataProps, this.dataPropsPath = t.dataProps || "", this.hide = t.hide ?? !1, Object.assign(this, t.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath();
|
|
256
256
|
}
|
|
257
257
|
propagateNestingLevel() {
|
|
258
258
|
const t = this.nestingLevel + 1;
|
|
259
|
-
|
|
259
|
+
U(this.settings, (e, i) => {
|
|
260
260
|
w(i) && (i.nestingLevel = t, i.propagateNestingLevel());
|
|
261
261
|
});
|
|
262
262
|
}
|
|
@@ -273,13 +273,13 @@ const K = class K {
|
|
|
273
273
|
this.dataPropsPath = t, this.propagateDataPropsPath();
|
|
274
274
|
}
|
|
275
275
|
propagateDataPropsPath() {
|
|
276
|
-
|
|
276
|
+
U(this.settings, (t, e) => {
|
|
277
277
|
const i = String(t), s = this.dataPropsPath ? `${this.dataPropsPath}_${i}` : i;
|
|
278
|
-
(w(e) ||
|
|
278
|
+
(w(e) || A(e) && typeof e.setDataPropsPath == "function") && e.setDataPropsPath(s);
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
281
|
updateNestingStyles() {
|
|
282
|
-
this.elementRef && (
|
|
282
|
+
this.elementRef && (j(this.elementRef, this.nestingLevel), Y(this.elementRef, this.nestingLevel));
|
|
283
283
|
}
|
|
284
284
|
forceChildUIRefresh() {
|
|
285
285
|
Object.entries(this.settings).forEach(([t, e]) => {
|
|
@@ -328,7 +328,7 @@ const K = class K {
|
|
|
328
328
|
}
|
|
329
329
|
clone() {
|
|
330
330
|
const t = {};
|
|
331
|
-
|
|
331
|
+
U(this.settings, (s, n) => {
|
|
332
332
|
const o = String(s);
|
|
333
333
|
typeof n.clone == "function" ? t[o] = n.clone() : (console.warn(
|
|
334
334
|
`Setting with key '${o}' does not have a clone method. Copying reference.`
|
|
@@ -345,7 +345,7 @@ const K = class K {
|
|
|
345
345
|
deleteItem: this.deleteItemCfg,
|
|
346
346
|
dataProps: this.dataProps,
|
|
347
347
|
hide: this.hide
|
|
348
|
-
}, i =
|
|
348
|
+
}, i = wt(e);
|
|
349
349
|
return i.initialValues = this.getValues(), i;
|
|
350
350
|
}
|
|
351
351
|
resetDefault() {
|
|
@@ -355,7 +355,7 @@ const K = class K {
|
|
|
355
355
|
setMobileValues(t) {
|
|
356
356
|
!t || typeof t != "object" || (Object.entries(t).forEach(([e, i]) => {
|
|
357
357
|
const s = this.settings[e];
|
|
358
|
-
s && (w(s) ||
|
|
358
|
+
s && (w(s) || A(s)) && typeof s.setMobileValue == "function" && s.setMobileValue(i);
|
|
359
359
|
}), this.setValue(t), this.onChange && this.onChange(this.getValues()));
|
|
360
360
|
}
|
|
361
361
|
getMobileValues(t) {
|
|
@@ -391,14 +391,14 @@ const K = class K {
|
|
|
391
391
|
Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
|
|
392
392
|
}, 50));
|
|
393
393
|
};
|
|
394
|
-
return this.changeHandlers.clear(),
|
|
394
|
+
return this.changeHandlers.clear(), U(this.settings, (i, s) => {
|
|
395
395
|
var n;
|
|
396
396
|
if (w(s))
|
|
397
397
|
s.setOnChange(() => {
|
|
398
398
|
const o = this.getValues();
|
|
399
399
|
this.initialValues = o, t(o);
|
|
400
400
|
}), this.changeHandlers.add(() => t(this.getValues()));
|
|
401
|
-
else if (
|
|
401
|
+
else if (A(s)) {
|
|
402
402
|
const o = () => e();
|
|
403
403
|
this.changeHandlers.add(o), s.setOnChange(o);
|
|
404
404
|
} else {
|
|
@@ -424,7 +424,7 @@ const K = class K {
|
|
|
424
424
|
st(l) && (this.addSetting(i, l), n = l);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
n && (w(n) ||
|
|
427
|
+
n && (w(n) || A(n)) && typeof n.setValue == "function" && n.setValue(s);
|
|
428
428
|
}), setTimeout(() => {
|
|
429
429
|
this.forceChildUIRefresh();
|
|
430
430
|
}, 0);
|
|
@@ -438,7 +438,7 @@ const K = class K {
|
|
|
438
438
|
const s = this.getValues();
|
|
439
439
|
this.initialValues = s, (n = this.onChange) == null || n.call(this, s), this.updateVisibility();
|
|
440
440
|
};
|
|
441
|
-
w(t) ? t.setOnChange(() => e()) :
|
|
441
|
+
w(t) ? t.setOnChange(() => e()) : A(t) ? t.setOnChange(() => e()) : (i = t.setOnChange) == null || i.call(t, () => e());
|
|
442
442
|
}
|
|
443
443
|
addSetting(t, e) {
|
|
444
444
|
var s, n;
|
|
@@ -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
|
-
r ? o.insertBefore(a, r) : o.appendChild(a), it.trackElement(a),
|
|
458
|
-
const
|
|
459
|
-
a.style.display = "none", a.offsetHeight, a.style.display =
|
|
457
|
+
r ? o.insertBefore(a, r) : o.appendChild(a), it.trackElement(a), j(a, this.nestingLevel + 1), Y(a, this.nestingLevel + 1);
|
|
458
|
+
const d = a.style.display;
|
|
459
|
+
a.style.display = "none", a.offsetHeight, a.style.display = d, 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 d of r)
|
|
477
|
+
if (d.closest(".setting-group") === t) {
|
|
478
|
+
s = d;
|
|
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((d) => {
|
|
512
|
+
d && (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 d = (h) => {
|
|
610
|
+
h.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", d));
|
|
611
611
|
};
|
|
612
|
-
document.addEventListener("keydown",
|
|
612
|
+
document.addEventListener("keydown", d), 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
|
});
|
|
@@ -705,7 +705,7 @@ const K = class K {
|
|
|
705
705
|
}
|
|
706
706
|
draw() {
|
|
707
707
|
const t = document.createElement("div");
|
|
708
|
-
t.className = "setting-group", t.id = `setting-group-${this.id}`,
|
|
708
|
+
t.className = "setting-group", t.id = `setting-group-${this.id}`, Z.hiddenElements.add(t), this.hide && (t.style.display = "none"), this.isMain && t.classList.add("main-group"), this.custom && t.classList.add("custom_class"), j(t, this.nestingLevel);
|
|
709
709
|
const e = document.createElement("div");
|
|
710
710
|
e.className = "setting-group-title", this.isCollapsed && e.classList.add("collapsed-view"), e.setAttribute("role", "button"), e.setAttribute(
|
|
711
711
|
"aria-expanded",
|
|
@@ -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 = (d) => {
|
|
735
|
+
(d.key === "Enter" || d.key === " ") && (d.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
|
|
742
|
-
w(
|
|
737
|
+
for (const d in this.settings)
|
|
738
|
+
if (Object.prototype.hasOwnProperty.call(this.settings, d)) {
|
|
739
|
+
const h = this.settings[d];
|
|
740
|
+
w(h) && typeof h.setNestingLevel == "function" && h.setNestingLevel(this.nestingLevel + 1);
|
|
741
|
+
const p = h.draw();
|
|
742
|
+
w(h) && h.deleteItemCfg && this.addDeleteButtonToElement(
|
|
743
|
+
p,
|
|
743
744
|
d,
|
|
744
|
-
h
|
|
745
|
-
|
|
746
|
-
), a.appendChild(d);
|
|
745
|
+
h
|
|
746
|
+
), a.appendChild(p);
|
|
747
747
|
}
|
|
748
748
|
} else {
|
|
749
|
-
const
|
|
750
|
-
|
|
749
|
+
const d = document.createElement("div");
|
|
750
|
+
d.className = "setting-group-empty", d.textContent = "No settings in this group", a.appendChild(d);
|
|
751
751
|
}
|
|
752
752
|
if (this.addItemCfg) {
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
const
|
|
753
|
+
const d = document.createElement("button");
|
|
754
|
+
d.type = "button", d.className = "sg-add-button-bottom", d.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
|
-
|
|
762
|
-
|
|
763
|
-
const u = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix),
|
|
764
|
-
if (st(
|
|
761
|
+
d.innerHTML = `${h}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, d.addEventListener("click", (p) => {
|
|
762
|
+
p.stopPropagation(), p.preventDefault();
|
|
763
|
+
const u = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), g = this.addItemCfg.createItem(u);
|
|
764
|
+
if (st(g)) {
|
|
765
765
|
const f = `${this.addItemCfg.keyPrefix}${u}`;
|
|
766
|
-
this.addSetting(f,
|
|
766
|
+
this.addSetting(f, g);
|
|
767
767
|
}
|
|
768
|
-
}), a.appendChild(
|
|
768
|
+
}), a.appendChild(d);
|
|
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();
|
|
@@ -809,12 +809,12 @@ const K = class K {
|
|
|
809
809
|
}
|
|
810
810
|
}
|
|
811
811
|
};
|
|
812
|
-
|
|
813
|
-
let P =
|
|
812
|
+
Z.hiddenElements = /* @__PURE__ */ new Set();
|
|
813
|
+
let P = Z;
|
|
814
814
|
function oe(c) {
|
|
815
|
-
return new
|
|
815
|
+
return new bt(c);
|
|
816
816
|
}
|
|
817
|
-
class
|
|
817
|
+
class bt extends P {
|
|
818
818
|
constructor(t) {
|
|
819
819
|
super(t);
|
|
820
820
|
const e = Object.keys(this.settings)[0];
|
|
@@ -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 d = document.createElement("div");
|
|
856
|
+
d.className = "tab-panel", this.contentContainers[a] = d;
|
|
857
|
+
const h = this.settings[a];
|
|
858
|
+
h && (w(h) && typeof h.setNestingLevel == "function" && h.setNestingLevel(this.getNestingLevel() + 1), d.appendChild(
|
|
859
|
+
h.draw()
|
|
860
|
+
)), o.appendChild(d), 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 || "";
|
|
@@ -865,13 +865,13 @@ class yt extends P {
|
|
|
865
865
|
return this.updateTabUI(), t;
|
|
866
866
|
}
|
|
867
867
|
}
|
|
868
|
-
function
|
|
868
|
+
function wt(c) {
|
|
869
869
|
return new P(c);
|
|
870
870
|
}
|
|
871
871
|
function ae(c) {
|
|
872
872
|
return c;
|
|
873
873
|
}
|
|
874
|
-
class
|
|
874
|
+
class xt extends b {
|
|
875
875
|
constructor(t = {}) {
|
|
876
876
|
super(t), this.inputType = "text", t.onChange && this.setOnChange(t.onChange);
|
|
877
877
|
}
|
|
@@ -891,29 +891,29 @@ class bt extends b {
|
|
|
891
891
|
});
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
|
-
const
|
|
895
|
-
class
|
|
894
|
+
const Lt = "<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>";
|
|
895
|
+
class S extends xt {
|
|
896
896
|
constructor(t) {
|
|
897
897
|
super({
|
|
898
898
|
...t,
|
|
899
|
-
icon: t.icon ||
|
|
899
|
+
icon: t.icon || Lt,
|
|
900
900
|
title: t.title || "Color",
|
|
901
|
-
default: t.default ?
|
|
901
|
+
default: t.default ? S.normalizeColorValue(t.default) : "#000000"
|
|
902
902
|
}), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.detectChange = t.detectChange;
|
|
903
903
|
}
|
|
904
904
|
static normalizeColorValue(t) {
|
|
905
|
-
return t.startsWith("#") ?
|
|
905
|
+
return t.startsWith("#") ? S.normalizeHexValue(t) : t.includes(",") ? S.rgbToHexStatic(t) : S.normalizeHexValue(t);
|
|
906
906
|
}
|
|
907
907
|
static normalizeHexValue(t) {
|
|
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((d) => parseInt(d.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 = (d) => {
|
|
915
|
+
const h = d.toString(16);
|
|
916
|
+
return h.length === 1 ? "0" + h : h;
|
|
917
917
|
};
|
|
918
918
|
return `#${r(o)}${r(a)}${r(l)}`;
|
|
919
919
|
}
|
|
@@ -923,7 +923,7 @@ class M extends bt {
|
|
|
923
923
|
return;
|
|
924
924
|
}
|
|
925
925
|
if (typeof t == "string") {
|
|
926
|
-
const e =
|
|
926
|
+
const e = S.normalizeColorValue(t);
|
|
927
927
|
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);
|
|
928
928
|
} else
|
|
929
929
|
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");
|
|
@@ -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 d, h;
|
|
967
967
|
let r = l.target.value.trim();
|
|
968
968
|
if (this.textInputEl && i(this.textInputEl)) {
|
|
969
|
-
const
|
|
970
|
-
this.value =
|
|
969
|
+
const p = S.normalizeColorValue(r);
|
|
970
|
+
this.value = p, (d = this.onChange) == null || d.call(this, p), (h = this.detectChange) == null || h.call(this, p), this.colorInputEl && (this.colorInputEl.value = p), n.style.backgroundColor = p;
|
|
971
971
|
}
|
|
972
972
|
}), this.colorInputEl.addEventListener("input", (l) => {
|
|
973
|
-
var
|
|
974
|
-
const r = l.target.value,
|
|
975
|
-
this.value =
|
|
973
|
+
var h, p;
|
|
974
|
+
const r = l.target.value, d = S.normalizeColorValue(r);
|
|
975
|
+
this.value = d, (h = this.onChange) == null || h.call(this, d), (p = this.detectChange) == null || p.call(this, d), this.textInputEl && (this.textInputEl.value = d), n.style.backgroundColor = d, 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, p;
|
|
978
|
+
const r = l.target.value, d = S.normalizeColorValue(r);
|
|
979
|
+
this.value = d, (h = this.onChange) == null || h.call(this, d), (p = this.detectChange) == null || p.call(this, d), this.textInputEl && (this.textInputEl.value = d), n.style.backgroundColor = d;
|
|
980
980
|
}), e.appendChild(s), e.appendChild(n), e.appendChild(a), t.appendChild(e), this.element = t, t;
|
|
981
981
|
}
|
|
982
982
|
getElement() {
|
|
@@ -984,7 +984,7 @@ class M extends bt {
|
|
|
984
984
|
}
|
|
985
985
|
// Helper method to get normalized hex value
|
|
986
986
|
getNormalizedValue() {
|
|
987
|
-
return this.value ?
|
|
987
|
+
return this.value ? S.normalizeColorValue(this.value) : "#000000";
|
|
988
988
|
}
|
|
989
989
|
// Helper method to check if current value is valid hex
|
|
990
990
|
isValidHex() {
|
|
@@ -995,20 +995,20 @@ class M extends bt {
|
|
|
995
995
|
return this.isValidHex() ? this.hexToRgb(this.value) : "0, 0, 0";
|
|
996
996
|
}
|
|
997
997
|
}
|
|
998
|
-
const
|
|
998
|
+
const kt = `
|
|
999
999
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1000
1000
|
<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"/>
|
|
1001
1001
|
<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"/>
|
|
1002
1002
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
1003
1003
|
</svg>`;
|
|
1004
|
-
class
|
|
1004
|
+
class B extends b {
|
|
1005
1005
|
constructor(t = {}) {
|
|
1006
1006
|
super({
|
|
1007
1007
|
...t,
|
|
1008
|
-
icon: t.icon ||
|
|
1008
|
+
icon: t.icon || kt,
|
|
1009
1009
|
title: t.title || "Color & Opacity",
|
|
1010
1010
|
default: t.default || "#000000FF"
|
|
1011
|
-
}), 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 =
|
|
1011
|
+
}), 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 = B.normalizeHexWithOpacity(this.value));
|
|
1012
1012
|
}
|
|
1013
1013
|
static normalizeHexWithOpacity(t) {
|
|
1014
1014
|
return t = t.replace("#", ""), t.length === 3 && (t = t.split("").map((e) => e + e).join("")), t.length === 6 && (t = t + "FF"), t.length === 8 && /^[0-9A-Fa-f]{8}$/.test(t) ? `#${t.toUpperCase()}` : (console.warn(`Invalid hex value "${t}", using default "#000000FF"`), "#000000FF");
|
|
@@ -1026,7 +1026,7 @@ class R extends b {
|
|
|
1026
1026
|
return `#${i}${n}`;
|
|
1027
1027
|
}
|
|
1028
1028
|
setValue(t) {
|
|
1029
|
-
t === void 0 || t === "" ? this.value = "#000000FF" : this.value =
|
|
1029
|
+
t === void 0 || t === "" ? this.value = "#000000FF" : this.value = B.normalizeHexWithOpacity(t), this.updateInputElements(), this.updateColorPreview(), this.onChange && this.onChange(this.value), this.detectChange && this.detectChange(this.value);
|
|
1030
1030
|
}
|
|
1031
1031
|
updateInputElements() {
|
|
1032
1032
|
this.value && (this.colorInputEl && (this.colorInputEl.value = this.getRgbColor()), this.textInputEl && (this.textInputEl.value = this.value), this.opacityInputEl && (this.opacityInputEl.value = this.getOpacityPercent().toString()));
|
|
@@ -1037,7 +1037,7 @@ class R extends b {
|
|
|
1037
1037
|
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
1038
1038
|
}
|
|
1039
1039
|
handleColorChange(t) {
|
|
1040
|
-
const e = this.getOpacityPercent(), i =
|
|
1040
|
+
const e = this.getOpacityPercent(), i = B.combineColorOpacity(
|
|
1041
1041
|
t,
|
|
1042
1042
|
e
|
|
1043
1043
|
);
|
|
@@ -1048,7 +1048,7 @@ class R extends b {
|
|
|
1048
1048
|
return e || i ? (this.setValue(t), !0) : !1;
|
|
1049
1049
|
}
|
|
1050
1050
|
handleOpacityChange(t) {
|
|
1051
|
-
const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s =
|
|
1051
|
+
const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s = B.combineColorOpacity(
|
|
1052
1052
|
e,
|
|
1053
1053
|
i
|
|
1054
1054
|
);
|
|
@@ -1155,7 +1155,7 @@ class le extends b {
|
|
|
1155
1155
|
return e.addEventListener("input", i), e.addEventListener("change", i), e.addEventListener("blur", s), t.appendChild(e), t;
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
|
-
class
|
|
1158
|
+
class N extends b {
|
|
1159
1159
|
constructor(t) {
|
|
1160
1160
|
super(t), this.inputType = "number", this.inputElement = null, this.mobileValue = t.mobile, this.validateProps(), this.value = this.validateValue(this.value);
|
|
1161
1161
|
}
|
|
@@ -1214,12 +1214,12 @@ class S extends b {
|
|
|
1214
1214
|
);
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
|
-
const
|
|
1217
|
+
const Mt = `
|
|
1218
1218
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1219
1219
|
<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"/>
|
|
1220
1220
|
<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"/>
|
|
1221
1221
|
</svg>`;
|
|
1222
|
-
class
|
|
1222
|
+
class St extends N {
|
|
1223
1223
|
constructor(t = {}) {
|
|
1224
1224
|
const e = {
|
|
1225
1225
|
title: "Opacity",
|
|
@@ -1228,7 +1228,7 @@ class kt extends S {
|
|
|
1228
1228
|
maxValue: 100,
|
|
1229
1229
|
step: 1,
|
|
1230
1230
|
default: t.default ?? 100,
|
|
1231
|
-
icon:
|
|
1231
|
+
icon: Mt,
|
|
1232
1232
|
...t
|
|
1233
1233
|
};
|
|
1234
1234
|
super(e), this.inputType = "number", this.mobileValue = t.mobile;
|
|
@@ -1240,12 +1240,12 @@ class kt extends S {
|
|
|
1240
1240
|
this.mobileValue = t, t !== void 0 && this.setValue(t);
|
|
1241
1241
|
}
|
|
1242
1242
|
}
|
|
1243
|
-
const
|
|
1243
|
+
const Nt = `
|
|
1244
1244
|
<svg xmlns="http://www.w3.org/2000/svg" class="svg-select" 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">
|
|
1245
1245
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
1246
1246
|
</svg>
|
|
1247
1247
|
`;
|
|
1248
|
-
class
|
|
1248
|
+
class Q extends b {
|
|
1249
1249
|
constructor(t = {}) {
|
|
1250
1250
|
if (super(t), this.inputType = "select", this._options = [], this.isOpen = !1, this.selectedOptionIndex = null, this.optionsListEl = null, this.svgContainer = null, this.buttonEl = null, this.isLoading = !1, this.container = null, this.clickOutsideListener = null, this.resizeListener = null, t.options && (this._options = [...t.options]), t.getOptions && this._options.push(...t.getOptions()), t.getOptionsAsync && (this.isLoading = !0), this.value !== void 0) {
|
|
1251
1251
|
const e = this._options.findIndex((i) => i.value === this.value);
|
|
@@ -1289,7 +1289,7 @@ class tt extends b {
|
|
|
1289
1289
|
a.onclick = (l) => this.selectOption(l, o, e), i.appendChild(a);
|
|
1290
1290
|
}), document.body.appendChild(i);
|
|
1291
1291
|
const s = document.createElement("div");
|
|
1292
|
-
return s.classList.add("svg-container"), s.innerHTML =
|
|
1292
|
+
return s.classList.add("svg-container"), s.innerHTML = Nt, t.appendChild(s), this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
1293
1293
|
this._options.push(...n), this.isLoading = !1, this.updateOptionsList(), this.updateButtonText();
|
|
1294
1294
|
}).catch((n) => {
|
|
1295
1295
|
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText("Failed to load options");
|
|
@@ -1352,7 +1352,7 @@ class tt extends b {
|
|
|
1352
1352
|
this.clickOutsideListener && (document.removeEventListener("click", this.clickOutsideListener), this.clickOutsideListener = null), this.resizeListener && (window.removeEventListener("resize", this.resizeListener), this.resizeListener = null), this.cleanupDropdownPosition(), this.optionsListEl && this.optionsListEl.parentNode && this.optionsListEl.parentNode.removeChild(this.optionsListEl), super.destroy();
|
|
1353
1353
|
}
|
|
1354
1354
|
}
|
|
1355
|
-
class
|
|
1355
|
+
class It extends b {
|
|
1356
1356
|
constructor(t = {}) {
|
|
1357
1357
|
super(t), this.inputType = "button", this.value || (this.value = "center");
|
|
1358
1358
|
}
|
|
@@ -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], d = +n[4];
|
|
1426
|
+
d >= 1 ? (a = Math.round(a * 0.9), l = Math.round(l * 0.9), r = Math.round(r * 0.9)) : d = Math.min(1, d + 0.12), s = `rgba(${a},${l},${r},${d})`;
|
|
1427
1427
|
}
|
|
1428
1428
|
t.addEventListener("mouseenter", () => {
|
|
1429
1429
|
console.log("hoverBg", s), t.style.setProperty("background-color", s, "important");
|
|
@@ -1444,20 +1444,20 @@ class ce extends b {
|
|
|
1444
1444
|
this.value || (this.value = {
|
|
1445
1445
|
width: e,
|
|
1446
1446
|
height: i
|
|
1447
|
-
}), this.minWidth = t.minWidth ?? 0, this.maxWidth = t.maxWidth, this.minHeight = t.minHeight ?? 0, this.maxHeight = t.maxHeight, this.locked = t.locked ?? !1, this.value.height > 0 && (this.aspectRatio = this.value.width / this.value.height), this.widthSetting = new
|
|
1447
|
+
}), this.minWidth = t.minWidth ?? 0, this.maxWidth = t.maxWidth, this.minHeight = t.minHeight ?? 0, this.maxHeight = t.maxHeight, this.locked = t.locked ?? !1, this.value.height > 0 && (this.aspectRatio = this.value.width / this.value.height), this.widthSetting = new N({
|
|
1448
1448
|
title: "Width",
|
|
1449
1449
|
default: this.value.width,
|
|
1450
1450
|
suffix: "px",
|
|
1451
1451
|
minValue: this.minWidth,
|
|
1452
1452
|
maxValue: this.maxWidth,
|
|
1453
|
-
icon:
|
|
1454
|
-
}), this.heightSetting = new
|
|
1453
|
+
icon: Vt
|
|
1454
|
+
}), this.heightSetting = new N({
|
|
1455
1455
|
title: "Height",
|
|
1456
1456
|
default: this.value.height,
|
|
1457
1457
|
suffix: "px",
|
|
1458
1458
|
minValue: this.minHeight,
|
|
1459
1459
|
maxValue: this.maxHeight,
|
|
1460
|
-
icon:
|
|
1460
|
+
icon: Pt
|
|
1461
1461
|
}), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
|
|
1462
1462
|
}
|
|
1463
1463
|
handleWidthChange(t) {
|
|
@@ -1551,24 +1551,24 @@ class ce extends b {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
1554
|
-
const
|
|
1554
|
+
const Vt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1555
1555
|
<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"/>
|
|
1556
|
-
</svg>`,
|
|
1556
|
+
</svg>`, Pt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1557
1557
|
<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"/>
|
|
1558
|
-
</svg>`,
|
|
1558
|
+
</svg>`, K = `
|
|
1559
1559
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
1560
1560
|
<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"/>
|
|
1561
1561
|
</svg>
|
|
1562
|
-
`,
|
|
1562
|
+
`, Tt = `
|
|
1563
1563
|
<svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1564
1564
|
<rect width="91" height="71" rx="4" fill="#F2F4F7"/>
|
|
1565
1565
|
<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"/>
|
|
1566
1566
|
</svg>
|
|
1567
|
-
`,
|
|
1567
|
+
`, Ot = `
|
|
1568
1568
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" fill="none">
|
|
1569
1569
|
<path d="M8 3V2.6C8 2.03995 8 1.75992 7.89101 1.54601C7.79513 1.35785 7.64215 1.20487 7.45399 1.10899C7.24008 1 6.96005 1 6.4 1H5.6C5.03995 1 4.75992 1 4.54601 1.10899C4.35785 1.20487 4.20487 1.35785 4.10899 1.54601C4 1.75992 4 2.03995 4 2.6V3M5 5.75V8.25M7 5.75V8.25M1.5 3H10.5M9.5 3V8.6C9.5 9.44008 9.5 9.86012 9.33651 10.181C9.1927 10.4632 8.96323 10.6927 8.68099 10.8365C8.36012 11 7.94008 11 7.1 11H4.9C4.05992 11 3.63988 11 3.31901 10.8365C3.03677 10.6927 2.8073 10.4632 2.66349 10.181C2.5 9.86012 2.5 9.44008 2.5 8.6V3" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1570
1570
|
</svg>
|
|
1571
|
-
`,
|
|
1571
|
+
`, Ht = `
|
|
1572
1572
|
<svg xmlns="http://www.w3.org/2000/svg" width="29" height="29" viewBox="0 0 29 29" fill="none">
|
|
1573
1573
|
<!-- Top dot -->
|
|
1574
1574
|
<circle cx="14.5" cy="3" r="1.5" fill="#02CC59" opacity="1"/>
|
|
@@ -1641,7 +1641,7 @@ class rt extends b {
|
|
|
1641
1641
|
);
|
|
1642
1642
|
if (t && t !== "") {
|
|
1643
1643
|
this.showLoading(), s && s instanceof HTMLElement && (s.style.display = "none"), e && e.classList.remove("no-image"), i && (i.innerHTML = `
|
|
1644
|
-
<span class="upload-icon">${
|
|
1644
|
+
<span class="upload-icon">${K}</span>
|
|
1645
1645
|
<span class="upload-label">Replace</span>
|
|
1646
1646
|
`);
|
|
1647
1647
|
const n = () => {
|
|
@@ -1652,7 +1652,7 @@ class rt extends b {
|
|
|
1652
1652
|
this.previewEl.addEventListener("load", n), this.previewEl.addEventListener("error", o), this.previewEl.src = t;
|
|
1653
1653
|
} else
|
|
1654
1654
|
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 = `
|
|
1655
|
-
<span class="upload-icon">${
|
|
1655
|
+
<span class="upload-icon">${K}</span>
|
|
1656
1656
|
<span class="upload-label">Upload</span>
|
|
1657
1657
|
`);
|
|
1658
1658
|
}
|
|
@@ -1685,9 +1685,9 @@ class rt extends b {
|
|
|
1685
1685
|
const s = this.value && this.value !== "";
|
|
1686
1686
|
s || i.classList.add("no-image");
|
|
1687
1687
|
const n = document.createElement("div");
|
|
1688
|
-
if (n.className = "preview-placeholder", n.innerHTML =
|
|
1688
|
+
if (n.className = "preview-placeholder", n.innerHTML = Tt, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.loadingSpinner = document.createElement("div"), this.loadingSpinner.className = "loading-spinner", this.loadingSpinner.innerHTML = Ht, this.loadingSpinner.style.display = "none", this.previewWrapper.appendChild(this.loadingSpinner), this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
|
|
1689
1689
|
const a = document.createElement("button");
|
|
1690
|
-
a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML =
|
|
1690
|
+
a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML = Ot, this.previewWrapper.appendChild(a), a.onclick = (l) => {
|
|
1691
1691
|
var r;
|
|
1692
1692
|
l.stopPropagation(), this.value = "", this.updatePreviewState(null), (r = this.onChange) == null || r.call(this, ""), this.hideError();
|
|
1693
1693
|
};
|
|
@@ -1695,7 +1695,7 @@ class rt extends b {
|
|
|
1695
1695
|
this.previewWrapper.appendChild(this.previewEl);
|
|
1696
1696
|
const o = document.createElement("button");
|
|
1697
1697
|
return o.className = "upload-button", this.getDataPropsPath() && o.setAttribute("data-test-id", this.getDataPropsPath()), o.innerHTML = `
|
|
1698
|
-
<span class="upload-icon">${
|
|
1698
|
+
<span class="upload-icon">${K}</span>
|
|
1699
1699
|
<span class="upload-label">Upload</span>
|
|
1700
1700
|
`, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(o), t.appendChild(i), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), o.onclick = () => {
|
|
1701
1701
|
window.postMessage(
|
|
@@ -1708,14 +1708,14 @@ class rt extends b {
|
|
|
1708
1708
|
}, t;
|
|
1709
1709
|
}
|
|
1710
1710
|
}
|
|
1711
|
-
class he extends
|
|
1711
|
+
class he extends N {
|
|
1712
1712
|
constructor(t = {}) {
|
|
1713
1713
|
super({
|
|
1714
1714
|
...t,
|
|
1715
1715
|
title: t.title || "Height",
|
|
1716
1716
|
suffix: t.suffix || "px",
|
|
1717
1717
|
minValue: t.minValue ?? 0,
|
|
1718
|
-
icon: t.icon ||
|
|
1718
|
+
icon: t.icon || $t,
|
|
1719
1719
|
default: t.default ?? 100
|
|
1720
1720
|
}), this.inputType = "number", this.mobileValue = t.mobile;
|
|
1721
1721
|
}
|
|
@@ -1726,17 +1726,17 @@ class he extends S {
|
|
|
1726
1726
|
this.mobileValue = t, t !== void 0 && this.setValue(t);
|
|
1727
1727
|
}
|
|
1728
1728
|
}
|
|
1729
|
-
const
|
|
1729
|
+
const $t = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1730
1730
|
<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="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1731
1731
|
</svg>`;
|
|
1732
|
-
class pe extends
|
|
1732
|
+
class pe extends N {
|
|
1733
1733
|
constructor(t = {}) {
|
|
1734
1734
|
super({
|
|
1735
1735
|
...t,
|
|
1736
1736
|
title: t.title || "Width",
|
|
1737
1737
|
suffix: t.suffix || "px",
|
|
1738
1738
|
minValue: t.minValue ?? 0,
|
|
1739
|
-
icon: t.icon ||
|
|
1739
|
+
icon: t.icon || At,
|
|
1740
1740
|
default: t.default ?? 100
|
|
1741
1741
|
}), this.inputType = "number", this.mobileValue = t.mobile;
|
|
1742
1742
|
}
|
|
@@ -1747,9 +1747,9 @@ class pe extends S {
|
|
|
1747
1747
|
this.mobileValue = t, t !== void 0 && this.setValue(t);
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
|
-
const
|
|
1750
|
+
const At = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1751
1751
|
<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"/>
|
|
1752
|
-
</svg>`,
|
|
1752
|
+
</svg>`, Bt = `
|
|
1753
1753
|
<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">
|
|
1754
1754
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
1755
1755
|
</svg>
|
|
@@ -1809,7 +1809,7 @@ class de extends b {
|
|
|
1809
1809
|
a.onclick = (l) => this.selectApiOption(l, o, e), i.appendChild(a);
|
|
1810
1810
|
}), t.appendChild(i);
|
|
1811
1811
|
const s = document.createElement("div");
|
|
1812
|
-
return s.classList.add("svg-container"), s.innerHTML =
|
|
1812
|
+
return s.classList.add("svg-container"), s.innerHTML = Bt, t.appendChild(s), s.onclick = () => {
|
|
1813
1813
|
var n, o;
|
|
1814
1814
|
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (o = this.svgContainer) == null || o.classList.toggle("open", this.isOpen));
|
|
1815
1815
|
}, this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && !this.hasInitializedOptions ? (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
@@ -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, d, 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;
|
|
@@ -1865,10 +1865,10 @@ class de extends b {
|
|
|
1865
1865
|
if (a)
|
|
1866
1866
|
a.textContent = this._options[e].name;
|
|
1867
1867
|
else {
|
|
1868
|
-
const
|
|
1869
|
-
|
|
1868
|
+
const p = i.firstChild;
|
|
1869
|
+
p && p.tagName === "SPAN" && (p.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"), (d = this.svgContainer) == null || d.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, d;
|
|
1928
|
+
const l = ((d = (r = this.props.options) == null ? void 0 : r.find((h) => h.status === s.checked)) == null ? void 0 : d.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", d = 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: ${d};
|
|
1940
1940
|
}
|
|
1941
1941
|
`, document.head.appendChild(l);
|
|
1942
1942
|
}
|
|
@@ -1951,13 +1951,13 @@ class ue extends b {
|
|
|
1951
1951
|
this.detectChangeCallback = t;
|
|
1952
1952
|
}
|
|
1953
1953
|
}
|
|
1954
|
-
const
|
|
1954
|
+
const Dt = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1955
1955
|
<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"/>
|
|
1956
1956
|
</svg>`;
|
|
1957
1957
|
class ge extends b {
|
|
1958
1958
|
// Store mobile value
|
|
1959
1959
|
constructor(t = {}) {
|
|
1960
|
-
t.rowGap = t.rowGap ?? !0, t.columnGap = t.columnGap ?? !0, t.title = t.title ?? "Gap", t.icon = t.icon ??
|
|
1960
|
+
t.rowGap = t.rowGap ?? !0, t.columnGap = t.columnGap ?? !0, t.title = t.title ?? "Gap", t.icon = t.icon ?? Dt, 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);
|
|
1961
1961
|
}
|
|
1962
1962
|
draw() {
|
|
1963
1963
|
const t = document.createElement("div");
|
|
@@ -2008,33 +2008,33 @@ class ge extends b {
|
|
|
2008
2008
|
this.mobileValue = t, t !== void 0 && this.setValue(t);
|
|
2009
2009
|
}
|
|
2010
2010
|
}
|
|
2011
|
-
const
|
|
2011
|
+
const Rt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
2012
2012
|
<path d="M2.25 11.75H15.75M5.85 2.75H12.15C13.4101 2.75 14.0402 2.75 14.5215 2.99524C14.9448 3.21095 15.289 3.55516 15.5048 3.97852C15.75 4.45982 15.75 5.08988 15.75 6.35V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V6.35C2.25 5.08988 2.25 4.45982 2.49524 3.97852C2.71095 3.55516 3.05516 3.21095 3.47852 2.99524C3.95982 2.75 4.58988 2.75 5.85 2.75Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2013
2013
|
</svg>`;
|
|
2014
|
-
class me extends
|
|
2014
|
+
class me extends N {
|
|
2015
2015
|
constructor(t = {}) {
|
|
2016
2016
|
super({
|
|
2017
2017
|
...t,
|
|
2018
2018
|
minValue: t.minValue ?? 0,
|
|
2019
2019
|
maxValue: t.maxValue ?? 1e3,
|
|
2020
|
-
icon: t.icon ||
|
|
2020
|
+
icon: t.icon || Rt,
|
|
2021
2021
|
title: t.title || "Margin Bottom",
|
|
2022
2022
|
default: t.default ?? 20,
|
|
2023
2023
|
wrapperClassName: "margin-bottom-wrapper " + (t.wrapperClassName || "")
|
|
2024
2024
|
}), this.inputType = "number";
|
|
2025
2025
|
}
|
|
2026
2026
|
}
|
|
2027
|
-
const
|
|
2027
|
+
const Ft = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
2028
2028
|
<path d="M15.75 7.25H2.25m9.9 9h-6.3c-1.26 0-1.89 0-2.371-.245a2.25 2.25 0 0 1-.984-.983c-.245-.482-.245-1.112-.245-2.372v-6.3c0-1.26 0-1.89.245-2.371a2.25 2.25 0 0 1 .984-.984c.48-.245 1.11-.245 2.371-.245h6.3c1.26 0 1.89 0 2.371.245.424.216.768.56.984.984.245.48.245 1.11.245 2.371v6.3c0 1.26 0 1.89-.245 2.371-.216.424-.56.768-.984.984-.48.245-1.11.245-2.371.245"
|
|
2029
2029
|
stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2030
2030
|
</svg>`;
|
|
2031
|
-
class fe extends
|
|
2031
|
+
class fe extends N {
|
|
2032
2032
|
constructor(t = {}) {
|
|
2033
2033
|
super({
|
|
2034
2034
|
...t,
|
|
2035
2035
|
minValue: t.minValue ?? 0,
|
|
2036
2036
|
maxValue: t.maxValue ?? 1e3,
|
|
2037
|
-
icon: t.icon ||
|
|
2037
|
+
icon: t.icon || Ft,
|
|
2038
2038
|
title: t.title || "Margin Top",
|
|
2039
2039
|
default: t.default ?? 20,
|
|
2040
2040
|
wrapperClassName: "margin-top-wrapper " + (t.wrapperClassName || "")
|
|
@@ -2073,14 +2073,14 @@ 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(
|
|
2076
|
+
const d = "...";
|
|
2077
|
+
let h = 0, p = e.length, u = 0;
|
|
2078
|
+
for (; h <= p; ) {
|
|
2079
|
+
const f = Math.floor((h + p) / 2), m = e.slice(0, f).trimEnd() + d;
|
|
2080
|
+
this.measureTextWidth(m, i) <= l ? (u = f, h = f + 1) : p = f - 1;
|
|
2081
2081
|
}
|
|
2082
|
-
const
|
|
2083
|
-
t.placeholder =
|
|
2082
|
+
const g = e.slice(0, u).trimEnd() + d;
|
|
2083
|
+
t.placeholder = g;
|
|
2084
2084
|
}
|
|
2085
2085
|
autosizeTextarea(t, e = 3) {
|
|
2086
2086
|
t.style.height = "auto";
|
|
@@ -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 d = n.getAttribute("data-full-placeholder") || "";
|
|
2119
|
+
d && this.adaptPlaceholderToSingleLine(n, d);
|
|
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") || "";
|
|
@@ -2199,7 +2199,7 @@ class Ce extends b {
|
|
|
2199
2199
|
{ name: "Bounce", value: "bounce 1.5s ease-in-out infinite" },
|
|
2200
2200
|
{ name: "Pulse", value: "pulse 1.5s ease-in-out infinite" }
|
|
2201
2201
|
];
|
|
2202
|
-
this.selectSetting = new
|
|
2202
|
+
this.selectSetting = new Q({
|
|
2203
2203
|
title: this.title || "Animation",
|
|
2204
2204
|
options: e,
|
|
2205
2205
|
default: this.props.default || "none"
|
|
@@ -2217,49 +2217,49 @@ 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 =
|
|
2223
|
-
const
|
|
2224
|
-
o =
|
|
2225
|
-
}, r = (
|
|
2220
|
+
const l = (h) => {
|
|
2221
|
+
if (h.target.closest("button")) return;
|
|
2222
|
+
i = !0, s = h.clientX, n = h.clientY;
|
|
2223
|
+
const p = t.getBoundingClientRect();
|
|
2224
|
+
o = p.left, a = p.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup", d), document.body.style.userSelect = "none";
|
|
2225
|
+
}, r = (h) => {
|
|
2226
2226
|
if (!i) return;
|
|
2227
|
-
const
|
|
2228
|
-
let
|
|
2229
|
-
|
|
2230
|
-
},
|
|
2231
|
-
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup",
|
|
2227
|
+
const p = h.clientX - s, u = h.clientY - n, g = window.innerWidth, f = window.innerHeight, m = t.offsetWidth, v = t.offsetHeight;
|
|
2228
|
+
let C = o + p, x = a + u;
|
|
2229
|
+
C = Math.max(8, Math.min(g - m - 8, C)), x = Math.max(8, Math.min(f - v - 8, x)), t.style.left = `${C}px`, t.style.top = `${x}px`, e == null || e(C, x);
|
|
2230
|
+
}, d = () => {
|
|
2231
|
+
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", d), document.body.style.userSelect = "";
|
|
2232
2232
|
};
|
|
2233
2233
|
c.addEventListener("mousedown", l);
|
|
2234
|
-
},
|
|
2234
|
+
}, F = (c) => {
|
|
2235
2235
|
if (!c) return null;
|
|
2236
2236
|
let t = c.trim();
|
|
2237
2237
|
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()}`;
|
|
2238
|
-
},
|
|
2238
|
+
}, _ = (c, t, e) => `#${[c, t, e].map((i) => Math.max(0, Math.min(255, i)).toString(16).padStart(2, "0")).join("")}`, M = (c) => {
|
|
2239
2239
|
const t = c.replace("#", ""), e = t.length === 3 ? t.split("").map((i) => i + i).join("") : t;
|
|
2240
2240
|
return {
|
|
2241
2241
|
r: parseInt(e.slice(0, 2), 16),
|
|
2242
2242
|
g: parseInt(e.slice(2, 4), 16),
|
|
2243
2243
|
b: parseInt(e.slice(4, 6), 16)
|
|
2244
2244
|
};
|
|
2245
|
-
},
|
|
2246
|
-
const { r: t, g: e, b: i } =
|
|
2247
|
-
let
|
|
2248
|
-
r !== 0 && (a === s ?
|
|
2249
|
-
const
|
|
2250
|
-
return { h:
|
|
2251
|
-
},
|
|
2245
|
+
}, D = (c) => {
|
|
2246
|
+
const { r: t, g: e, b: i } = M(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 d = 0;
|
|
2248
|
+
r !== 0 && (a === s ? d = (n - o) / r % 6 : a === n ? d = (o - s) / r + 2 : d = (s - n) / r + 4), d < 0 && (d += 6);
|
|
2249
|
+
const h = a === 0 ? 0 : r / a, p = a;
|
|
2250
|
+
return { h: d * 60, s: h, v: p };
|
|
2251
|
+
}, R = (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;
|
|
2254
|
-
return i < 60 ? (a = s, l = n, r = 0) : i < 120 ? (a = n, l = s, r = 0) : i < 180 ? (a = 0, l = s, r = n) : i < 240 ? (a = 0, l = n, r = s) : i < 300 ? (a = n, l = 0, r = s) : (a = s, l = 0, r = n),
|
|
2254
|
+
return i < 60 ? (a = s, l = n, r = 0) : i < 120 ? (a = n, l = s, r = 0) : i < 180 ? (a = 0, l = s, r = n) : i < 240 ? (a = 0, l = n, r = s) : i < 300 ? (a = n, l = 0, r = s) : (a = s, l = 0, r = n), _(
|
|
2255
2255
|
Math.round((a + o) * 255),
|
|
2256
2256
|
Math.round((l + o) * 255),
|
|
2257
2257
|
Math.round((r + o) * 255)
|
|
2258
2258
|
);
|
|
2259
|
-
},
|
|
2259
|
+
}, ht = (c, t, e) => {
|
|
2260
2260
|
const i = e * (1 - t / 2), s = i === 0 || i === 1 ? 0 : (e - i) / Math.min(i, 1 - i);
|
|
2261
2261
|
return { hue: c, sat: s, lightness: i };
|
|
2262
|
-
},
|
|
2262
|
+
}, tt = (c, t, e) => {
|
|
2263
2263
|
const i = (1 - Math.abs(2 * e - 1)) * t, s = i * (1 - Math.abs(c / 60 % 2 - 1)), n = e - i / 2;
|
|
2264
2264
|
let o = 0, a = 0, l = 0;
|
|
2265
2265
|
return c < 60 ? (o = i, a = s, l = 0) : c < 120 ? (o = s, a = i, l = 0) : c < 180 ? (o = 0, a = i, l = s) : c < 240 ? (o = 0, a = s, l = i) : c < 300 ? (o = s, a = 0, l = i) : (o = i, a = 0, l = s), {
|
|
@@ -2267,10 +2267,10 @@ const ct = (c, t, e) => {
|
|
|
2267
2267
|
g: Math.round((a + n) * 255),
|
|
2268
2268
|
b: Math.round((l + n) * 255)
|
|
2269
2269
|
};
|
|
2270
|
-
},
|
|
2270
|
+
}, pt = (c, t) => {
|
|
2271
2271
|
const e = Math.max(0, Math.min(100, t)) / 100;
|
|
2272
2272
|
if (c.startsWith("#")) {
|
|
2273
|
-
const { r: s, g: n, b: o } =
|
|
2273
|
+
const { r: s, g: n, b: o } = M(c);
|
|
2274
2274
|
return `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
2275
2275
|
}
|
|
2276
2276
|
if (c.startsWith("rgba("))
|
|
@@ -2280,7 +2280,7 @@ const ct = (c, t, e) => {
|
|
|
2280
2280
|
if (c.startsWith("hsl(")) {
|
|
2281
2281
|
const s = c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2282
2282
|
if (s) {
|
|
2283
|
-
const { r: n, g: o, b: a } =
|
|
2283
|
+
const { r: n, g: o, b: a } = tt(
|
|
2284
2284
|
parseInt(s[1]),
|
|
2285
2285
|
parseInt(s[2]) / 100,
|
|
2286
2286
|
parseInt(s[3]) / 100
|
|
@@ -2291,7 +2291,7 @@ const ct = (c, t, e) => {
|
|
|
2291
2291
|
if (c.startsWith("hsla(")) {
|
|
2292
2292
|
const s = c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);
|
|
2293
2293
|
if (s) {
|
|
2294
|
-
const { r: n, g: o, b: a } =
|
|
2294
|
+
const { r: n, g: o, b: a } = tt(
|
|
2295
2295
|
parseInt(s[1]),
|
|
2296
2296
|
parseInt(s[2]) / 100,
|
|
2297
2297
|
parseInt(s[3]) / 100
|
|
@@ -2299,13 +2299,13 @@ const ct = (c, t, e) => {
|
|
|
2299
2299
|
return `rgba(${n}, ${o}, ${a}, ${e})`;
|
|
2300
2300
|
}
|
|
2301
2301
|
}
|
|
2302
|
-
const i =
|
|
2302
|
+
const i = F(c);
|
|
2303
2303
|
if (i) {
|
|
2304
|
-
const { r: s, g: n, b: o } =
|
|
2304
|
+
const { r: s, g: n, b: o } = M(i);
|
|
2305
2305
|
return `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
2306
2306
|
}
|
|
2307
2307
|
return c;
|
|
2308
|
-
},
|
|
2308
|
+
}, Gt = (c) => [
|
|
2309
2309
|
"red",
|
|
2310
2310
|
"green",
|
|
2311
2311
|
"blue",
|
|
@@ -2329,22 +2329,22 @@ const ct = (c, t, e) => {
|
|
|
2329
2329
|
"teal",
|
|
2330
2330
|
"fuchsia",
|
|
2331
2331
|
"transparent"
|
|
2332
|
-
].includes(c.toLowerCase()),
|
|
2332
|
+
].includes(c.toLowerCase()), dt = (c) => [
|
|
2333
2333
|
/^#[0-9a-fA-F]{3,8}$/,
|
|
2334
2334
|
/^rgba?\s*\([^)]+\)$/,
|
|
2335
2335
|
/^hsla?\s*\([^)]+\)$/,
|
|
2336
2336
|
/^[a-zA-Z]+$/
|
|
2337
|
-
].some((e) => e.test(c.trim())),
|
|
2337
|
+
].some((e) => e.test(c.trim())), zt = (c) => {
|
|
2338
2338
|
if (typeof document > "u")
|
|
2339
|
-
return
|
|
2339
|
+
return dt(c) || !!F(c);
|
|
2340
2340
|
const t = document.createElement("div");
|
|
2341
2341
|
return t.style.color = c, t.style.color !== "";
|
|
2342
|
-
},
|
|
2342
|
+
}, ut = (c) => {
|
|
2343
2343
|
const t = c.trim();
|
|
2344
2344
|
if (/^#[0-9A-Fa-f]{8}$/.test(t)) {
|
|
2345
2345
|
const n = t.slice(1), o = parseInt(n.slice(0, 2), 16), a = parseInt(n.slice(2, 4), 16), l = parseInt(n.slice(4, 6), 16), r = parseInt(n.slice(6, 8), 16);
|
|
2346
2346
|
return {
|
|
2347
|
-
color:
|
|
2347
|
+
color: _(o, a, l),
|
|
2348
2348
|
position: 0,
|
|
2349
2349
|
opacity: Math.round(r / 255 * 100)
|
|
2350
2350
|
};
|
|
@@ -2355,7 +2355,7 @@ const ct = (c, t, e) => {
|
|
|
2355
2355
|
if (e) {
|
|
2356
2356
|
const n = parseInt(e[1]), o = parseInt(e[2]), a = parseInt(e[3]), l = e[4] ? parseFloat(e[4]) : 1;
|
|
2357
2357
|
return {
|
|
2358
|
-
color:
|
|
2358
|
+
color: _(n, o, a),
|
|
2359
2359
|
position: 0,
|
|
2360
2360
|
opacity: Math.round(l * 100)
|
|
2361
2361
|
};
|
|
@@ -2364,18 +2364,18 @@ const ct = (c, t, e) => {
|
|
|
2364
2364
|
/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/
|
|
2365
2365
|
);
|
|
2366
2366
|
if (i) {
|
|
2367
|
-
const { r: n, g: o, b: a } =
|
|
2367
|
+
const { r: n, g: o, b: a } = tt(
|
|
2368
2368
|
parseFloat(i[1]),
|
|
2369
2369
|
parseFloat(i[2]) / 100,
|
|
2370
2370
|
parseFloat(i[3]) / 100
|
|
2371
2371
|
), l = i[4] ? parseFloat(i[4]) : 1;
|
|
2372
2372
|
return {
|
|
2373
|
-
color:
|
|
2373
|
+
color: _(n, o, a),
|
|
2374
2374
|
position: 0,
|
|
2375
2375
|
opacity: Math.round(l * 100)
|
|
2376
2376
|
};
|
|
2377
2377
|
}
|
|
2378
|
-
return { color:
|
|
2378
|
+
return { color: F(t) || t, position: 0, opacity: 100 };
|
|
2379
2379
|
}, nt = (c) => {
|
|
2380
2380
|
const t = [];
|
|
2381
2381
|
let e = "", i = 0;
|
|
@@ -2398,7 +2398,7 @@ const ct = (c, t, e) => {
|
|
|
2398
2398
|
for (let a = s; a < c.length && n > 0; a++)
|
|
2399
2399
|
c[a] === "(" ? n++ : c[a] === ")" && n--, o = a;
|
|
2400
2400
|
return n === 0 ? c.substring(s, o) : null;
|
|
2401
|
-
},
|
|
2401
|
+
}, Ut = (c) => {
|
|
2402
2402
|
const t = c.split(" ")[0].toLowerCase();
|
|
2403
2403
|
return [
|
|
2404
2404
|
"circle",
|
|
@@ -2410,7 +2410,7 @@ const ct = (c, t, e) => {
|
|
|
2410
2410
|
"at",
|
|
2411
2411
|
"contain",
|
|
2412
2412
|
"cover"
|
|
2413
|
-
].includes(t) ? !1 : /^#[0-9a-f]{3,8}$/i.test(t) || /^rgb/i.test(c) || /^hsl/i.test(c) ||
|
|
2413
|
+
].includes(t) ? !1 : /^#[0-9a-f]{3,8}$/i.test(t) || /^rgb/i.test(c) || /^hsl/i.test(c) || Gt(t);
|
|
2414
2414
|
}, at = (c) => {
|
|
2415
2415
|
const t = [];
|
|
2416
2416
|
return c.forEach((e, i) => {
|
|
@@ -2418,11 +2418,11 @@ const ct = (c, t, e) => {
|
|
|
2418
2418
|
if (!s) return;
|
|
2419
2419
|
let n = "", o = 0;
|
|
2420
2420
|
const a = s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);
|
|
2421
|
-
a &&
|
|
2422
|
-
const l =
|
|
2421
|
+
a && dt(a[1].trim()) ? (n = a[1].trim(), o = parseFloat(a[2])) : (n = s, o = c.length === 1 ? 0 : i / (c.length - 1) * 100);
|
|
2422
|
+
const l = ut(n);
|
|
2423
2423
|
l.position = Math.max(0, Math.min(100, Math.round(o))), t.push(l);
|
|
2424
2424
|
}), t;
|
|
2425
|
-
},
|
|
2425
|
+
}, H = (c) => {
|
|
2426
2426
|
const t = c.stops && c.stops.length ? c.stops : [{ color: "#000000", position: 0, opacity: 100 }];
|
|
2427
2427
|
return {
|
|
2428
2428
|
type: c.type && ["linear", "radial", "solid"].includes(c.type) ? c.type : "linear",
|
|
@@ -2435,9 +2435,9 @@ const ct = (c, t, e) => {
|
|
|
2435
2435
|
};
|
|
2436
2436
|
}, T = (c) => {
|
|
2437
2437
|
const t = c.replace(/;$/, "").trim();
|
|
2438
|
-
if (
|
|
2439
|
-
const s =
|
|
2440
|
-
return
|
|
2438
|
+
if (zt(t)) {
|
|
2439
|
+
const s = ut(t);
|
|
2440
|
+
return H({ type: "solid", angle: 0, stops: [s] });
|
|
2441
2441
|
}
|
|
2442
2442
|
const e = ot(t, "linear-gradient");
|
|
2443
2443
|
if (e) {
|
|
@@ -2458,24 +2458,24 @@ const ct = (c, t, e) => {
|
|
|
2458
2458
|
"to top left": 315
|
|
2459
2459
|
}[a] ?? 90, o = s.slice(1));
|
|
2460
2460
|
const l = at(o);
|
|
2461
|
-
return l.length ?
|
|
2461
|
+
return l.length ? H({ type: "linear", angle: n, stops: l }) : null;
|
|
2462
2462
|
}
|
|
2463
2463
|
const i = ot(t, "radial-gradient");
|
|
2464
2464
|
if (i) {
|
|
2465
|
-
const s = nt(i), n = s[0] && !
|
|
2466
|
-
return o.length ?
|
|
2465
|
+
const s = nt(i), n = s[0] && !Ut(s[0]) ? s.slice(1) : s, o = at(n);
|
|
2466
|
+
return o.length ? H({ type: "radial", angle: 0, stops: o }) : null;
|
|
2467
2467
|
}
|
|
2468
2468
|
return null;
|
|
2469
|
-
},
|
|
2469
|
+
}, I = (c) => {
|
|
2470
2470
|
if (c.type === "solid") {
|
|
2471
2471
|
const e = c.stops[0], i = e.opacity ?? 100, s = e.color.replace("#", ""), n = Math.round(i / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
2472
2472
|
return `#${s}${n}`;
|
|
2473
2473
|
}
|
|
2474
2474
|
const t = c.stops.map(
|
|
2475
|
-
(e) => `${
|
|
2475
|
+
(e) => `${pt(e.color, e.opacity ?? 100)} ${e.position}%`
|
|
2476
2476
|
).join(", ");
|
|
2477
2477
|
return c.type === "radial" ? `radial-gradient(circle, ${t})` : `linear-gradient(${c.angle}deg, ${t})`;
|
|
2478
|
-
},
|
|
2478
|
+
}, Wt = (c) => Math.round(c / 100 * 255).toString(16).toUpperCase().padStart(2, "0"), q = (c) => {
|
|
2479
2479
|
if (c.type === "solid") {
|
|
2480
2480
|
const t = c.stops[0];
|
|
2481
2481
|
if (t) {
|
|
@@ -2483,7 +2483,7 @@ const ct = (c, t, e) => {
|
|
|
2483
2483
|
if (i === 100)
|
|
2484
2484
|
return e;
|
|
2485
2485
|
{
|
|
2486
|
-
const s =
|
|
2486
|
+
const s = Wt(i);
|
|
2487
2487
|
return `${e}${s}`;
|
|
2488
2488
|
}
|
|
2489
2489
|
}
|
|
@@ -2500,7 +2500,7 @@ const ct = (c, t, e) => {
|
|
|
2500
2500
|
static normalizeList(t) {
|
|
2501
2501
|
const e = /* @__PURE__ */ new Set(), i = [];
|
|
2502
2502
|
return t.forEach((s) => {
|
|
2503
|
-
let n =
|
|
2503
|
+
let n = F(s);
|
|
2504
2504
|
n || T(s) && (n = s), n && (e.has(n) || (e.add(n), i.push(n)));
|
|
2505
2505
|
}), i.slice(0, this.MAX_COLORS);
|
|
2506
2506
|
}
|
|
@@ -2544,7 +2544,7 @@ const ct = (c, t, e) => {
|
|
|
2544
2544
|
}
|
|
2545
2545
|
static addColor(t, e) {
|
|
2546
2546
|
if (!t) return;
|
|
2547
|
-
let i =
|
|
2547
|
+
let i = F(t), s = "solid";
|
|
2548
2548
|
if (i)
|
|
2549
2549
|
s = "solid";
|
|
2550
2550
|
else {
|
|
@@ -2557,65 +2557,67 @@ const ct = (c, t, e) => {
|
|
|
2557
2557
|
}
|
|
2558
2558
|
};
|
|
2559
2559
|
z.STORAGE_KEY = "settingsLib_recentColors", z.MAX_COLORS = 12, z.colors = null;
|
|
2560
|
-
let
|
|
2560
|
+
let $ = z;
|
|
2561
2561
|
const et = (c, t) => {
|
|
2562
2562
|
const e = document.createElement("div");
|
|
2563
2563
|
e.className = "color-picker-recent-section";
|
|
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 = (d, h) => {
|
|
2571
|
+
const p = d.getBoundingClientRect();
|
|
2572
|
+
s.textContent = h, s.style.left = `${p.left + p.width / 2}px`, s.style.top = `${p.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 d = $.getColors(t);
|
|
2580
|
+
if (d.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", d.forEach((h) => {
|
|
2585
|
+
const p = document.createElement("button");
|
|
2586
|
+
p.type = "button", p.className = "color-picker-recent-swatch";
|
|
2587
|
+
const u = jt(h);
|
|
2588
|
+
p.title = u, p.setAttribute("aria-label", `Use color: ${u}`), p.style.background = h, p.style.borderColor = h, p.addEventListener("mouseenter", () => o(p, u)), p.addEventListener("mouseleave", () => {
|
|
2589
|
+
n(), p.style.boxShadow = "";
|
|
2590
|
+
}), p.addEventListener("mousedown", () => {
|
|
2591
|
+
p.style.boxShadow = "0px 0px 0px 2px var(--grey40)";
|
|
2592
|
+
}), p.addEventListener("mouseup", () => {
|
|
2591
2593
|
setTimeout(() => {
|
|
2592
|
-
|
|
2594
|
+
p.style.boxShadow = "";
|
|
2593
2595
|
}, 150);
|
|
2594
|
-
}),
|
|
2595
|
-
|
|
2596
|
-
}),
|
|
2596
|
+
}), p.addEventListener("click", () => {
|
|
2597
|
+
n(), c(h);
|
|
2598
|
+
}), a.appendChild(p);
|
|
2597
2599
|
});
|
|
2598
2600
|
};
|
|
2599
|
-
return
|
|
2600
|
-
},
|
|
2601
|
+
return r(), { container: e, refresh: r };
|
|
2602
|
+
}, jt = (c) => {
|
|
2601
2603
|
const t = T(c);
|
|
2602
2604
|
if (t)
|
|
2603
|
-
return
|
|
2604
|
-
const e =
|
|
2605
|
+
return q(t);
|
|
2606
|
+
const e = F(c);
|
|
2605
2607
|
if (e) {
|
|
2606
|
-
const i =
|
|
2608
|
+
const i = M(e);
|
|
2607
2609
|
return `${e} (RGB: ${i.r}, ${i.g}, ${i.b})`;
|
|
2608
2610
|
}
|
|
2609
2611
|
return c;
|
|
2610
|
-
},
|
|
2612
|
+
}, gt = `<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2611
2613
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
2612
2614
|
d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
|
|
2613
2615
|
fill="#919EAB"/>
|
|
2614
|
-
</svg>`,
|
|
2616
|
+
</svg>`, mt = `<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2615
2617
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.1972 3.29156C18.936 3.03034 18.6259 2.82313 18.2847 2.68176C17.9434 2.54039 17.5777 2.46763 17.2083 2.46763C16.8389 2.46763 16.4731 2.54039 16.1319 2.68176C15.7906 2.82313 15.4805 3.03034 15.2194 3.29156L13.7822 4.72875C13.2585 4.4772 12.6697 4.39449 12.097 4.49207C11.5243 4.58964 10.9961 4.86267 10.5853 5.27343L9.91687 5.94281C9.74268 6.11693 9.6045 6.32366 9.51023 6.5512C9.41595 6.77873 9.36743 7.02261 9.36743 7.2689C9.36743 7.5152 9.41595 7.75907 9.51023 7.98661C9.6045 8.21414 9.74268 8.42088 9.91687 8.595L3.83625 14.6747C3.57512 14.936 3.36803 15.2462 3.2268 15.5875C3.08556 15.9288 3.01296 16.2947 3.01312 16.6641V18.3516C3.01312 18.6499 3.13165 18.9361 3.34263 19.1471C3.55361 19.358 3.83975 19.4766 4.13812 19.4766H5.82562C6.57129 19.4759 7.28618 19.1792 7.81312 18.6516L13.8937 12.5728C14.0679 12.747 14.2746 12.8852 14.5021 12.9795C14.7297 13.0737 14.9735 13.1223 15.2198 13.1223C15.4661 13.1223 15.71 13.0737 15.9375 12.9795C16.1651 12.8852 16.3718 12.747 16.5459 12.5728L17.2153 11.9025C17.6261 11.4917 17.8991 10.9635 17.9967 10.3908C18.0942 9.81811 18.0115 9.22926 17.76 8.70562L19.1972 7.26937C19.4584 7.0082 19.6656 6.69813 19.807 6.35687C19.9484 6.01561 20.0211 5.64985 20.0211 5.28047C20.0211 4.91108 19.9484 4.54532 19.807 4.20406C19.6656 3.8628 19.4584 3.55273 19.1972 3.29156ZM5.16281 16.0012L11.2425 9.92062L12.5681 11.2462L6.48844 17.3269C6.31266 17.5027 6.07424 17.6015 5.82562 17.6016H4.88812V16.6641C4.88818 16.4154 4.98698 16.177 5.16281 16.0012Z" fill="#353C47"/>
|
|
2616
|
-
</svg>`,
|
|
2618
|
+
</svg>`, _t = `<svg width="15" height="17" viewBox="0 0 15 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2617
2619
|
<path d="M14.1333 12.4667H0.8M0.8 12.4667L4.13333 9.13332M0.8 12.4667L4.13333 15.8M0.8 4.13332H14.1333M14.1333 4.13332L10.8 0.799988M14.1333 4.13332L10.8 7.46665" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2618
|
-
</svg>`,
|
|
2620
|
+
</svg>`, qt = `<svg width="14" height="2" viewBox="0 0 14 2" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2619
2621
|
<path d="M0.8 0.800003H12.4667" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2620
2622
|
</svg>`;
|
|
2621
2623
|
class Jt {
|
|
@@ -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")
|
|
@@ -2652,7 +2662,7 @@ class Jt {
|
|
|
2652
2662
|
const i = document.createElement("span");
|
|
2653
2663
|
i.textContent = "Color";
|
|
2654
2664
|
const s = document.createElement("button");
|
|
2655
|
-
s.className = "color-picker-close", s.innerHTML =
|
|
2665
|
+
s.className = "color-picker-close", s.innerHTML = gt, s.addEventListener("click", () => this.close(!0)), e.appendChild(i), e.appendChild(s), ct(e, t);
|
|
2656
2666
|
const n = document.createElement("div");
|
|
2657
2667
|
n.className = "color-picker-area", this.colorArea = n;
|
|
2658
2668
|
const o = document.createElement("div");
|
|
@@ -2660,38 +2670,38 @@ class Jt {
|
|
|
2660
2670
|
const a = document.createElement("div");
|
|
2661
2671
|
a.className = "color-picker-sliders-container";
|
|
2662
2672
|
const l = document.createElement("button");
|
|
2663
|
-
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML =
|
|
2673
|
+
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML = mt;
|
|
2664
2674
|
const r = document.createElement("div");
|
|
2665
2675
|
r.className = "color-picker-sliders-group";
|
|
2676
|
+
const d = document.createElement("div");
|
|
2677
|
+
d.className = "color-picker-hue", this.hueSlider = d;
|
|
2666
2678
|
const h = document.createElement("div");
|
|
2667
|
-
h.className = "color-picker-hue", this.
|
|
2679
|
+
h.className = "color-picker-hue-marker", this.hueMarker = h, d.appendChild(h);
|
|
2668
2680
|
const p = document.createElement("div");
|
|
2669
|
-
p.className = "color-picker-
|
|
2670
|
-
const d = document.createElement("div");
|
|
2671
|
-
d.className = "color-picker-opacity", this.opacitySlider = d;
|
|
2681
|
+
p.className = "color-picker-opacity", this.opacitySlider = p;
|
|
2672
2682
|
const u = document.createElement("div");
|
|
2673
|
-
u.className = "color-picker-opacity-marker", this.opacityMarker = u,
|
|
2674
|
-
const
|
|
2675
|
-
var
|
|
2676
|
-
this.setColor(E), (
|
|
2683
|
+
u.className = "color-picker-opacity-marker", this.opacityMarker = u, p.appendChild(u), r.appendChild(d), r.appendChild(p), a.appendChild(l), a.appendChild(r);
|
|
2684
|
+
const g = et((E) => {
|
|
2685
|
+
var L;
|
|
2686
|
+
this.setColor(E), (L = this.onChange) == null || L.call(this, E, this.currentOpacity);
|
|
2677
2687
|
}, this.recentScope);
|
|
2678
|
-
this.recentSectionRefresh =
|
|
2688
|
+
this.recentSectionRefresh = g.refresh;
|
|
2679
2689
|
const f = document.createElement("div");
|
|
2680
2690
|
f.className = "color-picker-format-section";
|
|
2681
|
-
const
|
|
2682
|
-
|
|
2691
|
+
const m = document.createElement("select");
|
|
2692
|
+
m.className = "color-picker-format-select", this.select = m;
|
|
2693
|
+
const v = document.createElement("option");
|
|
2694
|
+
v.value = "hex", v.textContent = "HEX";
|
|
2683
2695
|
const C = document.createElement("option");
|
|
2684
|
-
C.value = "
|
|
2685
|
-
const
|
|
2686
|
-
|
|
2687
|
-
const
|
|
2688
|
-
|
|
2689
|
-
const I = document.createElement("input");
|
|
2690
|
-
I.type = "text", I.className = "color-picker-color-input", I.value = this.currentColor, this.input = I;
|
|
2696
|
+
C.value = "rgb", C.textContent = "RGB";
|
|
2697
|
+
const x = document.createElement("option");
|
|
2698
|
+
x.value = "hsl", x.textContent = "HSL", m.appendChild(v), m.appendChild(C), m.appendChild(x);
|
|
2699
|
+
const k = document.createElement("input");
|
|
2700
|
+
k.type = "text", k.className = "color-picker-color-input", k.value = this.currentColor, this.input = k;
|
|
2691
2701
|
const O = document.createElement("div");
|
|
2692
2702
|
O.className = "color-picker-input-container";
|
|
2693
|
-
const
|
|
2694
|
-
return
|
|
2703
|
+
const y = document.createElement("button");
|
|
2704
|
+
return y.className = "color-picker-copy-inside", y.textContent = "Copy", O.appendChild(k), O.appendChild(y), f.appendChild(m), f.appendChild(O), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(g.container), t.appendChild(f), t.addEventListener("click", (E) => E.stopPropagation()), this.bind(n, d, p, k, m, y, 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 = (
|
|
2704
|
-
var
|
|
2705
|
-
const
|
|
2706
|
-
this.colorMarker.style.left = `${u * 100}%`, this.colorMarker.style.top = `${
|
|
2707
|
-
const
|
|
2708
|
-
this.currentColor =
|
|
2709
|
-
}, r = (
|
|
2710
|
-
var
|
|
2711
|
-
const
|
|
2712
|
-
let u = Math.max(0, Math.min(1, (
|
|
2713
|
+
const l = (h) => {
|
|
2714
|
+
var C;
|
|
2715
|
+
const p = t.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width)), g = Math.max(0, Math.min(1, (h.clientY - p.top) / p.height));
|
|
2716
|
+
this.colorMarker.style.left = `${u * 100}%`, this.colorMarker.style.top = `${g * 100}%`;
|
|
2717
|
+
const m = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, v = R(m, u, 1 - g);
|
|
2718
|
+
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), (C = this.onChange) == null || C.call(this, v, this.currentOpacity);
|
|
2719
|
+
}, r = (h) => {
|
|
2720
|
+
var C;
|
|
2721
|
+
const p = e.getBoundingClientRect();
|
|
2722
|
+
let u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width));
|
|
2713
2723
|
this.hueMarker.style.left = `${u * 100}%`;
|
|
2714
|
-
const
|
|
2715
|
-
this.currentColor =
|
|
2716
|
-
},
|
|
2717
|
-
var
|
|
2718
|
-
const
|
|
2719
|
-
this.opacityMarker.style.left = `${u * 100}%`, this.currentOpacity = Math.round(u * 100), (
|
|
2724
|
+
const g = u * 360, f = this.parsePercentage(this.colorMarker.style.left || "0%"), m = this.parsePercentage(this.colorMarker.style.top || "0%"), v = R(g, f, 1 - m);
|
|
2725
|
+
this.currentColor = v, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (C = this.onChange) == null || C.call(this, v, this.currentOpacity);
|
|
2726
|
+
}, d = (h) => {
|
|
2727
|
+
var g;
|
|
2728
|
+
const p = i.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width));
|
|
2729
|
+
this.opacityMarker.style.left = `${u * 100}%`, this.currentOpacity = Math.round(u * 100), (g = this.onChange) == null || g.call(this, this.currentColor, this.currentOpacity);
|
|
2720
2730
|
};
|
|
2721
|
-
t.addEventListener("mousedown", (
|
|
2722
|
-
|
|
2723
|
-
const
|
|
2724
|
-
document.removeEventListener("mousemove",
|
|
2731
|
+
t.addEventListener("mousedown", (h) => {
|
|
2732
|
+
h.preventDefault(), l(h);
|
|
2733
|
+
const p = (g) => l(g), u = () => {
|
|
2734
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2725
2735
|
};
|
|
2726
|
-
document.addEventListener("mousemove",
|
|
2727
|
-
}), e.addEventListener("mousedown", (
|
|
2728
|
-
|
|
2729
|
-
const
|
|
2730
|
-
document.removeEventListener("mousemove",
|
|
2736
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2737
|
+
}), e.addEventListener("mousedown", (h) => {
|
|
2738
|
+
h.preventDefault(), r(h);
|
|
2739
|
+
const p = (g) => r(g), u = () => {
|
|
2740
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2731
2741
|
};
|
|
2732
|
-
document.addEventListener("mousemove",
|
|
2733
|
-
}), i.addEventListener("mousedown", (
|
|
2734
|
-
|
|
2735
|
-
const
|
|
2736
|
-
document.removeEventListener("mousemove",
|
|
2742
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2743
|
+
}), i.addEventListener("mousedown", (h) => {
|
|
2744
|
+
h.preventDefault(), d(h);
|
|
2745
|
+
const p = (g) => d(g), u = () => {
|
|
2746
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2737
2747
|
};
|
|
2738
|
-
document.addEventListener("mousemove",
|
|
2739
|
-
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (
|
|
2740
|
-
|
|
2748
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
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
|
-
const
|
|
2755
|
-
this.setColor(u), (
|
|
2764
|
+
const p = new window.EyeDropper(), { sRGBHex: u } = await p.open();
|
|
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(
|
|
@@ -2763,17 +2773,17 @@ class Jt {
|
|
|
2763
2773
|
setColor(t) {
|
|
2764
2774
|
var o;
|
|
2765
2775
|
this.currentColor = t;
|
|
2766
|
-
const { h: e, s: i, v: s } =
|
|
2776
|
+
const { h: e, s: i, v: s } = D(t), n = e >= 360 ? e % 360 : e;
|
|
2767
2777
|
this.hueMarker.style.left = `${n / 360 * 100}%`, this.colorMarker.style.left = `${i * 100}%`, this.colorMarker.style.top = `${(1 - s) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (o = this.onChange) == null || o.call(this, t, this.currentOpacity);
|
|
2768
2778
|
}
|
|
2769
2779
|
syncInput() {
|
|
2770
|
-
const t = this.select.value, { h: e, s: i, v: s } =
|
|
2780
|
+
const t = this.select.value, { h: e, s: i, v: s } = D(this.currentColor);
|
|
2771
2781
|
if (t === "hex") this.input.value = this.currentColor;
|
|
2772
2782
|
else if (t === "rgb") {
|
|
2773
|
-
const { r: n, g: o, b: a } =
|
|
2783
|
+
const { r: n, g: o, b: a } = M(this.currentColor);
|
|
2774
2784
|
this.input.value = `rgb(${n}, ${o}, ${a})`;
|
|
2775
2785
|
} else {
|
|
2776
|
-
const { hue: n, sat: o, lightness: a } =
|
|
2786
|
+
const { hue: n, sat: o, lightness: a } = ht(e, i, s);
|
|
2777
2787
|
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
2778
2788
|
o * 100
|
|
2779
2789
|
)}%, ${Math.round(a * 100)}%)`;
|
|
@@ -2792,34 +2802,34 @@ class Jt {
|
|
|
2792
2802
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2793
2803
|
if (s) {
|
|
2794
2804
|
const n = parseInt(s[1]), o = parseInt(s[2]) / 100, a = parseInt(s[3]) / 100, l = a + o * Math.min(a, 1 - a), r = l === 0 ? 0 : 2 * (1 - a / l);
|
|
2795
|
-
e =
|
|
2805
|
+
e = R(n, r, l);
|
|
2796
2806
|
}
|
|
2797
2807
|
}
|
|
2798
2808
|
}
|
|
2799
2809
|
e && this.setColor(e);
|
|
2800
2810
|
}
|
|
2801
2811
|
updateOpacityBg() {
|
|
2802
|
-
const { r: t, g: e, b: i } =
|
|
2812
|
+
const { r: t, g: e, b: i } = M(this.currentColor);
|
|
2803
2813
|
this.opacitySlider.style.setProperty(
|
|
2804
2814
|
"--base-color",
|
|
2805
2815
|
`rgb(${t}, ${e}, ${i})`
|
|
2806
2816
|
);
|
|
2807
2817
|
}
|
|
2808
2818
|
open(t, e, i) {
|
|
2809
|
-
var
|
|
2819
|
+
var x;
|
|
2810
2820
|
this.currentColor = t, this.currentOpacity = i ?? 100, this.syncInput();
|
|
2811
|
-
const { h: s, s: n, v: o } =
|
|
2812
|
-
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}%`, (
|
|
2813
|
-
const a = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(),
|
|
2814
|
-
let u = r.right + 8,
|
|
2815
|
-
const f =
|
|
2816
|
-
f >= a +
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2821
|
+
const { h: s, s: n, v: o } = D(t);
|
|
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}%`, (x = this.recentSectionRefresh) == null || x.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);
|
|
2823
|
+
const a = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(), d = window.innerWidth, h = window.innerHeight, p = 16;
|
|
2824
|
+
let u = r.right + 8, g = r.top;
|
|
2825
|
+
const f = d - r.right, m = r.left;
|
|
2826
|
+
f >= a + p ? u = r.right + 8 : m >= a + p ? u = r.left - a - 8 : u = Math.max(p, (d - a) / 2);
|
|
2827
|
+
const v = h - r.bottom, C = r.top;
|
|
2828
|
+
v >= l + p ? g = r.bottom + 8 : C >= l + p ? g = r.top - l - 8 : v > C ? (g = r.bottom + 8, g + l > h - p && (g = h - l - p)) : (g = r.top - l - 8, g < p && (g = p)), this.element.style.left = `${u}px`, this.element.style.top = `${g}px`;
|
|
2819
2829
|
}
|
|
2820
2830
|
close(t) {
|
|
2821
2831
|
var e;
|
|
2822
|
-
this.isOpen && (this.isOpen = !1, this.backdrop.style.display = "none", this.element.style.display = "none", document.removeEventListener("click", this.outsideClick, !0), document.removeEventListener("keydown", this.keyDown, !0), t && this.onChange && this.recentScope === "solid" && (
|
|
2832
|
+
this.isOpen && (this.isOpen = !1, this.backdrop.style.display = "none", this.element.style.display = "none", document.removeEventListener("click", this.outsideClick, !0), document.removeEventListener("keydown", this.keyDown, !0), t && this.onChange && this.recentScope === "solid" && ($.addColor(this.currentColor, this.recentScope), (e = this.recentSectionRefresh) == null || e.call(this)));
|
|
2823
2833
|
}
|
|
2824
2834
|
getElement() {
|
|
2825
2835
|
return this.element;
|
|
@@ -2827,264 +2837,178 @@ class Jt {
|
|
|
2827
2837
|
}
|
|
2828
2838
|
class Xt {
|
|
2829
2839
|
constructor(t) {
|
|
2830
|
-
this.
|
|
2840
|
+
this.currentColor = t.initialColor, this.currentOpacity = t.initialOpacity, this.onColorChange = t.onColorChange, this.recentScope = t.scope ?? "solid", this.element = this.build(), this.initFromColor(this.currentColor, this.currentOpacity);
|
|
2841
|
+
}
|
|
2842
|
+
parsePercentage(t) {
|
|
2843
|
+
const e = parseFloat(t);
|
|
2844
|
+
return isNaN(e) ? 0 : e / 100;
|
|
2831
2845
|
}
|
|
2832
|
-
|
|
2846
|
+
build() {
|
|
2833
2847
|
const t = document.createElement("div");
|
|
2834
|
-
t.className = "embedded-color-picker
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
<option value="hex">HEX</option>
|
|
2856
|
-
<option value="rgb">RGB</option>
|
|
2857
|
-
<option value="hsl">HSL</option>
|
|
2858
|
-
</select>
|
|
2859
|
-
<div class="color-picker-input-container">
|
|
2860
|
-
<input type="text" class="color-picker-color-input" />
|
|
2861
|
-
<button class="color-picker-copy-inside">Copy</button>
|
|
2862
|
-
</div>
|
|
2863
|
-
</div>
|
|
2864
|
-
`;
|
|
2865
|
-
const e = et((i) => {
|
|
2866
|
-
this.applyRecentColor(i);
|
|
2848
|
+
t.className = "embedded-color-picker";
|
|
2849
|
+
const e = document.createElement("div");
|
|
2850
|
+
e.className = "color-picker-area embedded", this.colorArea = e;
|
|
2851
|
+
const i = document.createElement("div");
|
|
2852
|
+
i.className = "color-picker-marker", this.colorMarker = i, e.appendChild(i);
|
|
2853
|
+
const s = document.createElement("div");
|
|
2854
|
+
s.className = "color-picker-sliders-container embedded";
|
|
2855
|
+
const n = document.createElement("button");
|
|
2856
|
+
n.className = "color-picker-eyedropper", n.type = "button", n.innerHTML = mt;
|
|
2857
|
+
const o = document.createElement("div");
|
|
2858
|
+
o.className = "color-picker-sliders-group";
|
|
2859
|
+
const a = document.createElement("div");
|
|
2860
|
+
a.className = "color-picker-hue embedded", this.hueSlider = a;
|
|
2861
|
+
const l = document.createElement("div");
|
|
2862
|
+
l.className = "color-picker-hue-marker", this.hueMarker = l, a.appendChild(l);
|
|
2863
|
+
const r = document.createElement("div");
|
|
2864
|
+
r.className = "color-picker-opacity embedded", this.opacitySlider = r;
|
|
2865
|
+
const d = document.createElement("div");
|
|
2866
|
+
d.className = "color-picker-opacity-marker", this.opacityMarker = d, r.appendChild(d), o.appendChild(a), o.appendChild(r), s.appendChild(n), s.appendChild(o);
|
|
2867
|
+
const h = et((k) => {
|
|
2868
|
+
this.setColor(k), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
2867
2869
|
}, this.recentScope);
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
), this.colorInput = this.container.querySelector(
|
|
2886
|
-
".color-picker-color-input"
|
|
2887
|
-
);
|
|
2888
|
-
const t = this.container.querySelector(
|
|
2889
|
-
".color-picker-copy-inside"
|
|
2890
|
-
), { 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);
|
|
2892
|
-
}
|
|
2893
|
-
scheduleInputUpdate() {
|
|
2894
|
-
this.inputUpdateTimeout && clearTimeout(this.inputUpdateTimeout), this.inputUpdateTimeout = window.setTimeout(() => {
|
|
2895
|
-
this.updateColorInput(this.formatSelect, this.colorInput);
|
|
2896
|
-
}, 16);
|
|
2897
|
-
}
|
|
2898
|
-
addPointerDrag(t, e, i) {
|
|
2899
|
-
t.style.touchAction = "none", t.addEventListener("pointerdown", (s) => {
|
|
2900
|
-
s.preventDefault(), this.isDragging = !0, this.pendingExternalUpdate = void 0;
|
|
2901
|
-
const n = s.pointerId;
|
|
2902
|
-
if (t.setPointerCapture)
|
|
2903
|
-
try {
|
|
2904
|
-
t.setPointerCapture(n);
|
|
2905
|
-
} catch {
|
|
2906
|
-
}
|
|
2907
|
-
e(s);
|
|
2908
|
-
const o = (h) => {
|
|
2909
|
-
h.pointerId === n && e(h);
|
|
2910
|
-
}, a = () => {
|
|
2911
|
-
if (t.releasePointerCapture)
|
|
2912
|
-
try {
|
|
2913
|
-
t.releasePointerCapture(n);
|
|
2914
|
-
} catch {
|
|
2915
|
-
}
|
|
2916
|
-
document.removeEventListener("pointermove", o), document.removeEventListener("pointerup", l), document.removeEventListener("pointercancel", r);
|
|
2917
|
-
}, l = (h) => {
|
|
2918
|
-
if (h.pointerId === n) {
|
|
2919
|
-
if (a(), this.isDragging = !1, this.pendingExternalUpdate) {
|
|
2920
|
-
const { color: p, opacity: d } = this.pendingExternalUpdate;
|
|
2921
|
-
this.applyExternalUpdate(p, d), this.pendingExternalUpdate = void 0;
|
|
2922
|
-
}
|
|
2923
|
-
i == null || i();
|
|
2924
|
-
}
|
|
2925
|
-
}, r = (h) => {
|
|
2926
|
-
h.pointerId === n && a();
|
|
2927
|
-
};
|
|
2928
|
-
document.addEventListener("pointermove", o), document.addEventListener("pointerup", l), document.addEventListener("pointercancel", r);
|
|
2929
|
-
});
|
|
2930
|
-
}
|
|
2931
|
-
updateOpacityBackground(t) {
|
|
2932
|
-
const e = k(this.currentColor);
|
|
2933
|
-
t.style.setProperty(
|
|
2934
|
-
"--base-color",
|
|
2935
|
-
`rgb(${e.r}, ${e.g}, ${e.b})`
|
|
2936
|
-
);
|
|
2937
|
-
}
|
|
2938
|
-
updateColorInput(t, e) {
|
|
2939
|
-
switch (t.value) {
|
|
2940
|
-
case "hex":
|
|
2941
|
-
e.value = this.currentColor;
|
|
2942
|
-
break;
|
|
2943
|
-
case "rgb":
|
|
2944
|
-
const s = k(this.currentColor);
|
|
2945
|
-
e.value = `rgb(${s.r}, ${s.g}, ${s.b})`;
|
|
2946
|
-
break;
|
|
2947
|
-
case "hsl":
|
|
2948
|
-
const { h: n, s: o, v: a } = H(this.currentColor), l = a * (1 - o / 2), r = l === 0 || l === 1 ? 0 : (a - l) / Math.min(l, 1 - l);
|
|
2949
|
-
e.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
2950
|
-
r * 100
|
|
2951
|
-
)}%, ${Math.round(l * 100)}%)`;
|
|
2952
|
-
break;
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
applyRecentColor(t) {
|
|
2956
|
-
this.currentColor = t, t.includes("gradient") || t.includes("radial") || (this.updatePickerVisualState(), this.updateColorInput(this.formatSelect, this.colorInput)), this.triggerChange();
|
|
2957
|
-
}
|
|
2958
|
-
commitRecentColor() {
|
|
2959
|
-
var t;
|
|
2960
|
-
B.addColor(this.currentColor, this.recentScope), (t = this.recentSectionRefresh) == null || t.call(this);
|
|
2961
|
-
}
|
|
2962
|
-
setupColorAreaEvents() {
|
|
2963
|
-
const t = (e) => {
|
|
2964
|
-
const i = this.colorArea.getBoundingClientRect(), s = Math.max(0, Math.min(1, (e.clientX - i.left) / i.width)), n = Math.max(0, Math.min(1, (e.clientY - i.top) / i.height));
|
|
2965
|
-
this.colorMarker.style.left = `${s * 100}%`, this.colorMarker.style.top = `${n * 100}%`;
|
|
2966
|
-
const o = parseFloat(this.hueMarker.style.left || "0%"), a = Math.max(0, Math.min(360, o / 100 * 360)), l = Math.max(0, Math.min(1, s)), r = Math.max(0, Math.min(1, 1 - n)), h = G(a, l, r);
|
|
2967
|
-
this.currentColor = h, this.updateOpacityBackground(this.opacitySlider), this.scheduleInputUpdate(), this.triggerChange();
|
|
2968
|
-
};
|
|
2969
|
-
this.addPointerDrag(this.colorArea, t, () => {
|
|
2970
|
-
this.updateColorInput(this.formatSelect, this.colorInput), this.updateOpacityBackground(this.opacitySlider);
|
|
2971
|
-
});
|
|
2870
|
+
this.recentSectionRefresh = h.refresh;
|
|
2871
|
+
const p = document.createElement("div");
|
|
2872
|
+
p.className = "color-picker-format-section embedded";
|
|
2873
|
+
const u = document.createElement("select");
|
|
2874
|
+
u.className = "color-picker-format-select", this.select = u;
|
|
2875
|
+
const g = document.createElement("option");
|
|
2876
|
+
g.value = "hex", g.textContent = "HEX";
|
|
2877
|
+
const f = document.createElement("option");
|
|
2878
|
+
f.value = "rgb", f.textContent = "RGB";
|
|
2879
|
+
const m = document.createElement("option");
|
|
2880
|
+
m.value = "hsl", m.textContent = "HSL", u.appendChild(g), u.appendChild(f), u.appendChild(m);
|
|
2881
|
+
const v = document.createElement("input");
|
|
2882
|
+
v.type = "text", v.className = "color-picker-color-input", this.input = v;
|
|
2883
|
+
const C = document.createElement("div");
|
|
2884
|
+
C.className = "color-picker-input-container";
|
|
2885
|
+
const x = document.createElement("button");
|
|
2886
|
+
return x.className = "color-picker-copy-inside", x.textContent = "Copy", C.appendChild(v), C.appendChild(x), p.appendChild(u), p.appendChild(C), t.appendChild(e), t.appendChild(s), t.appendChild(h.container), t.appendChild(p), this.bind(e, a, r, v, u, x, n), t;
|
|
2972
2887
|
}
|
|
2973
|
-
|
|
2974
|
-
const
|
|
2975
|
-
const
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
),
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
);
|
|
2987
|
-
this.
|
|
2988
|
-
const h = G(n, l, 1 - r);
|
|
2989
|
-
this.currentColor = h, this.updateOpacityBackground(this.opacitySlider), this.scheduleInputUpdate(), this.triggerChange();
|
|
2888
|
+
bind(t, e, i, s, n, o, a) {
|
|
2889
|
+
const l = (h) => {
|
|
2890
|
+
const p = t.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width)), g = Math.max(0, Math.min(1, (h.clientY - p.top) / p.height));
|
|
2891
|
+
this.colorMarker.style.left = `${u * 100}%`, this.colorMarker.style.top = `${g * 100}%`;
|
|
2892
|
+
const m = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, v = R(m, u, 1 - g);
|
|
2893
|
+
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
2894
|
+
}, r = (h) => {
|
|
2895
|
+
const p = e.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width));
|
|
2896
|
+
this.hueMarker.style.left = `${u * 100}%`;
|
|
2897
|
+
const g = u * 360, f = this.parsePercentage(this.colorMarker.style.left || "0%"), m = this.parsePercentage(this.colorMarker.style.top || "0%"), v = R(g, f, 1 - m);
|
|
2898
|
+
this.currentColor = v, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
2899
|
+
linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
2900
|
+
}, d = (h) => {
|
|
2901
|
+
const p = i.getBoundingClientRect(), u = Math.max(0, Math.min(1, (h.clientX - p.left) / p.width));
|
|
2902
|
+
this.opacityMarker.style.left = `${u * 100}%`, this.currentOpacity = Math.round(u * 100), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
2990
2903
|
};
|
|
2991
|
-
|
|
2992
|
-
|
|
2904
|
+
t.addEventListener("mousedown", (h) => {
|
|
2905
|
+
h.preventDefault(), l(h);
|
|
2906
|
+
const p = (g) => l(g), u = () => {
|
|
2907
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2908
|
+
};
|
|
2909
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2910
|
+
}), e.addEventListener("mousedown", (h) => {
|
|
2911
|
+
h.preventDefault(), r(h);
|
|
2912
|
+
const p = (g) => r(g), u = () => {
|
|
2913
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2914
|
+
};
|
|
2915
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2916
|
+
}), i.addEventListener("mousedown", (h) => {
|
|
2917
|
+
h.preventDefault(), d(h);
|
|
2918
|
+
const p = (g) => d(g), u = () => {
|
|
2919
|
+
document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", u);
|
|
2920
|
+
};
|
|
2921
|
+
document.addEventListener("mousemove", p), document.addEventListener("mouseup", u);
|
|
2922
|
+
}), n.addEventListener("change", () => {
|
|
2923
|
+
this.syncInput();
|
|
2924
|
+
}), s.addEventListener("input", () => {
|
|
2925
|
+
this.applyFromInput();
|
|
2926
|
+
}), s.addEventListener("blur", () => {
|
|
2927
|
+
this.syncInput();
|
|
2928
|
+
}), s.addEventListener("keydown", (h) => {
|
|
2929
|
+
h.key === "Enter" && (h.preventDefault(), this.syncInput(), s.blur());
|
|
2930
|
+
}), o.addEventListener("click", async () => {
|
|
2931
|
+
try {
|
|
2932
|
+
await navigator.clipboard.writeText(s.value);
|
|
2933
|
+
} catch {
|
|
2934
|
+
s.select(), document.execCommand("copy");
|
|
2935
|
+
}
|
|
2936
|
+
}), a.addEventListener("click", async () => {
|
|
2937
|
+
if (!("EyeDropper" in window)) {
|
|
2938
|
+
alert("EyeDropper API is not supported in this browser.");
|
|
2939
|
+
return;
|
|
2940
|
+
}
|
|
2941
|
+
try {
|
|
2942
|
+
const h = new window.EyeDropper(), { sRGBHex: p } = await h.open();
|
|
2943
|
+
this.setColor(p), this.onColorChange(this.currentColor, this.currentOpacity);
|
|
2944
|
+
} catch {
|
|
2945
|
+
}
|
|
2993
2946
|
});
|
|
2994
2947
|
}
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
this.addPointerDrag(this.opacitySlider, t);
|
|
3001
|
-
}
|
|
3002
|
-
setupFormatEvents(t) {
|
|
3003
|
-
this.formatSelect.addEventListener("change", () => {
|
|
3004
|
-
this.updateColorInput(this.formatSelect, this.colorInput);
|
|
3005
|
-
}), t.addEventListener("click", () => {
|
|
3006
|
-
navigator.clipboard.writeText(this.colorInput.value).catch(() => {
|
|
3007
|
-
this.colorInput.select(), document.execCommand("copy");
|
|
3008
|
-
});
|
|
3009
|
-
}), this.colorInput.addEventListener("input", () => {
|
|
3010
|
-
this.handleManualColorInput(this.colorInput.value, this.formatSelect);
|
|
3011
|
-
}), this.colorInput.addEventListener("blur", () => {
|
|
3012
|
-
this.updateColorInput(this.formatSelect, this.colorInput);
|
|
3013
|
-
});
|
|
2948
|
+
setColor(t) {
|
|
2949
|
+
this.currentColor = t;
|
|
2950
|
+
const { h: e, s: i, v: s } = D(t), n = e >= 360 ? e % 360 : e;
|
|
2951
|
+
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),
|
|
2952
|
+
linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg();
|
|
3014
2953
|
}
|
|
3015
|
-
|
|
3016
|
-
const i =
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
break;
|
|
3028
|
-
}
|
|
3029
|
-
s || (s = this.autoDetectColorFormat(i)), s && (this.currentColor = s, this.updatePickerVisualState(), this.triggerChange());
|
|
3030
|
-
}
|
|
3031
|
-
parseHexInput(t) {
|
|
3032
|
-
const e = t.startsWith("#") ? t : `#${t}`;
|
|
3033
|
-
return A(e);
|
|
3034
|
-
}
|
|
3035
|
-
parseRgbInput(t) {
|
|
3036
|
-
const e = t.match(
|
|
3037
|
-
/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/
|
|
3038
|
-
);
|
|
3039
|
-
if (e) {
|
|
3040
|
-
const i = parseInt(e[1]), s = parseInt(e[2]), n = parseInt(e[3]);
|
|
3041
|
-
if (i <= 255 && s <= 255 && n <= 255)
|
|
3042
|
-
return F(i, s, n);
|
|
2954
|
+
syncInput() {
|
|
2955
|
+
const t = this.select.value, { h: e, s: i, v: s } = D(this.currentColor);
|
|
2956
|
+
if (t === "hex")
|
|
2957
|
+
this.input.value = this.currentColor;
|
|
2958
|
+
else if (t === "rgb") {
|
|
2959
|
+
const { r: n, g: o, b: a } = M(this.currentColor);
|
|
2960
|
+
this.input.value = `rgb(${n}, ${o}, ${a})`;
|
|
2961
|
+
} else {
|
|
2962
|
+
const { hue: n, sat: o, lightness: a } = ht(e, i, s);
|
|
2963
|
+
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
2964
|
+
o * 100
|
|
2965
|
+
)}%, ${Math.round(a * 100)}%)`;
|
|
3043
2966
|
}
|
|
3044
|
-
return null;
|
|
3045
2967
|
}
|
|
3046
|
-
|
|
3047
|
-
const
|
|
3048
|
-
|
|
3049
|
-
)
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
2968
|
+
applyFromInput() {
|
|
2969
|
+
const t = this.input.value.trim();
|
|
2970
|
+
let e = "";
|
|
2971
|
+
if (/^#[0-9A-Fa-f]{6}$/.test(t))
|
|
2972
|
+
e = t;
|
|
2973
|
+
else {
|
|
2974
|
+
const i = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
2975
|
+
if (i) {
|
|
2976
|
+
const s = parseInt(i[1], 10), n = parseInt(i[2], 10), o = parseInt(i[3], 10);
|
|
2977
|
+
s <= 255 && n <= 255 && o <= 255 && (e = "#" + [s, n, o].map((a) => a.toString(16).padStart(2, "0")).join(""));
|
|
2978
|
+
} else {
|
|
2979
|
+
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2980
|
+
if (s) {
|
|
2981
|
+
const n = parseInt(s[1], 10), o = parseInt(s[2], 10) / 100, a = parseInt(s[3], 10) / 100, l = a + o * Math.min(a, 1 - a), r = l === 0 ? 0 : 2 * (1 - a / l);
|
|
2982
|
+
e = R(n, r, l);
|
|
2983
|
+
}
|
|
3055
2984
|
}
|
|
3056
2985
|
}
|
|
3057
|
-
|
|
2986
|
+
e && (this.setColor(e), this.onColorChange(this.currentColor, this.currentOpacity));
|
|
3058
2987
|
}
|
|
3059
|
-
|
|
3060
|
-
const e = this.
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
return s || null;
|
|
2988
|
+
updateOpacityBg() {
|
|
2989
|
+
const { r: t, g: e, b: i } = M(this.currentColor);
|
|
2990
|
+
this.opacitySlider.style.setProperty(
|
|
2991
|
+
"--base-color",
|
|
2992
|
+
`rgb(${t}, ${e}, ${i})`
|
|
2993
|
+
);
|
|
3066
2994
|
}
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
this.
|
|
2995
|
+
initFromColor(t, e) {
|
|
2996
|
+
var a;
|
|
2997
|
+
this.currentColor = t, this.currentOpacity = e;
|
|
2998
|
+
const { h: i, s, v: n } = D(t), o = i >= 360 ? i % 360 : i;
|
|
2999
|
+
this.hueMarker.style.left = `${o / 360 * 100}%`, this.colorMarker.style.left = `${s * 100}%`, this.colorMarker.style.top = `${(1 - n) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
3000
|
+
linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`, this.opacityMarker.style.left = `${e}%`, this.updateOpacityBg(), this.syncInput(), (a = this.recentSectionRefresh) == null || a.call(this);
|
|
3070
3001
|
}
|
|
3071
|
-
|
|
3072
|
-
|
|
3002
|
+
commitRecentColor() {
|
|
3003
|
+
var t;
|
|
3004
|
+
this.recentScope === "solid" && ($.addColor(this.currentColor, this.recentScope), (t = this.recentSectionRefresh) == null || t.call(this));
|
|
3073
3005
|
}
|
|
3074
3006
|
getElement() {
|
|
3075
|
-
return this.
|
|
3007
|
+
return this.element;
|
|
3076
3008
|
}
|
|
3009
|
+
/** For external updates, e.g. when gradient stop changes from outside */
|
|
3077
3010
|
updateColor(t, e) {
|
|
3078
|
-
|
|
3079
|
-
this.pendingExternalUpdate = { color: t, opacity: e };
|
|
3080
|
-
return;
|
|
3081
|
-
}
|
|
3082
|
-
this.applyExternalUpdate(t, e);
|
|
3083
|
-
}
|
|
3084
|
-
applyExternalUpdate(t, e) {
|
|
3085
|
-
this.currentColor = t, this.currentOpacity = e;
|
|
3086
|
-
const { h: i, s, v: n } = H(t), o = i >= 360 ? i % 360 : i;
|
|
3087
|
-
this.hueMarker.style.left = `${o / 360 * 100}%`, this.colorMarker.style.left = `${s * 100}%`, this.colorMarker.style.top = `${(1 - n) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${o}, 100%, 50%))`, this.opacityMarker.style.left = `${e}%`, this.updateOpacityBackground(this.opacitySlider), this.updateColorInput(this.formatSelect, this.colorInput);
|
|
3011
|
+
this.initFromColor(t, e);
|
|
3088
3012
|
}
|
|
3089
3013
|
}
|
|
3090
3014
|
const V = class V extends b {
|
|
@@ -3099,16 +3023,16 @@ const V = class V extends b {
|
|
|
3099
3023
|
angle: "number",
|
|
3100
3024
|
stops: "text"
|
|
3101
3025
|
}, 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.onBackgroundClick = (i) => {
|
|
3102
|
-
var
|
|
3026
|
+
var p;
|
|
3103
3027
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
3104
|
-
const s = i.target, n = this.popoverEl.contains(s), o = (
|
|
3028
|
+
const s = i.target, n = this.popoverEl.contains(s), o = (p = this.element) == null ? void 0 : p.contains(s), a = document.querySelectorAll(".custom-color-picker"), l = Array.from(a).some((u) => u.contains(s)), r = s.closest(
|
|
3105
3029
|
".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"
|
|
3106
|
-
),
|
|
3030
|
+
), d = s.classList.contains(
|
|
3107
3031
|
"color-picker-backdrop"
|
|
3108
|
-
),
|
|
3032
|
+
), h = s.classList.contains(
|
|
3109
3033
|
"gradient-popover-backdrop"
|
|
3110
3034
|
);
|
|
3111
|
-
!n && !o && !l && !r && !
|
|
3035
|
+
!n && !o && !l && !r && !d && !h && this.closePopover();
|
|
3112
3036
|
}, this.handlePopoverKeydown = (i) => {
|
|
3113
3037
|
if (this.isPopoverOpen) {
|
|
3114
3038
|
if (i.key === "Escape") {
|
|
@@ -3129,9 +3053,9 @@ const V = class V extends b {
|
|
|
3129
3053
|
if (typeof t == "string") {
|
|
3130
3054
|
const i = T(t);
|
|
3131
3055
|
if (i)
|
|
3132
|
-
return
|
|
3056
|
+
return H(i);
|
|
3133
3057
|
}
|
|
3134
|
-
return
|
|
3058
|
+
return H(t && typeof t == "object" ? t : {
|
|
3135
3059
|
type: "linear",
|
|
3136
3060
|
angle: 90,
|
|
3137
3061
|
stops: [
|
|
@@ -3143,20 +3067,20 @@ const V = class V extends b {
|
|
|
3143
3067
|
setValue(t) {
|
|
3144
3068
|
var i, s;
|
|
3145
3069
|
let e = null;
|
|
3146
|
-
typeof t == "string" ? e = T(t) : t && typeof t == "object" && (e =
|
|
3070
|
+
typeof t == "string" ? e = T(t) : t && typeof t == "object" && (e = H(t)), e || (e = this.defaultValue()), this.value = e, this.updateUI(), this.isPopoverOpen && this.refreshPopoverContent(), (i = this.onChange) == null || i.call(this, this.value), (s = this.detectChange) == null || s.call(this, this.value), this.pendingSolidColor = null;
|
|
3147
3071
|
}
|
|
3148
3072
|
updateUI() {
|
|
3149
3073
|
if (this.previewEl && this.value)
|
|
3150
3074
|
if (this.value.type === "solid") {
|
|
3151
3075
|
const t = this.value.stops[0], e = t.opacity ?? 100;
|
|
3152
|
-
this.previewEl.style.background =
|
|
3076
|
+
this.previewEl.style.background = pt(t.color, e);
|
|
3153
3077
|
} else
|
|
3154
|
-
this.previewEl.style.background =
|
|
3155
|
-
this.inputEl && this.value && !this.isEditing && (this.inputEl.value =
|
|
3078
|
+
this.previewEl.style.background = I(this.value);
|
|
3079
|
+
this.inputEl && this.value && !this.isEditing && (this.inputEl.value = q(this.value));
|
|
3156
3080
|
}
|
|
3157
3081
|
cssForTextValue() {
|
|
3158
3082
|
return this.value ? {
|
|
3159
|
-
background:
|
|
3083
|
+
background: I(this.value),
|
|
3160
3084
|
"-webkit-background-clip": "text",
|
|
3161
3085
|
"background-clip": "text",
|
|
3162
3086
|
color: "transparent",
|
|
@@ -3172,9 +3096,9 @@ const V = class V extends b {
|
|
|
3172
3096
|
s.className = "input-label", s.textContent = this.props.title, i.appendChild(s), t.appendChild(i);
|
|
3173
3097
|
}
|
|
3174
3098
|
const e = document.createElement("div");
|
|
3175
|
-
return e.className = "gradient-input-wrapper", this.previewEl = document.createElement("div"), this.previewEl.className = "gradient-mini-preview", this.previewEl.style.background = this.value ?
|
|
3099
|
+
return e.className = "gradient-input-wrapper", this.previewEl = document.createElement("div"), this.previewEl.className = "gradient-mini-preview", this.previewEl.style.background = this.value ? I(this.value) : "linear-gradient(90deg, #a84b4b 0%, #786666 100%)", this.previewEl.addEventListener("click", (i) => {
|
|
3176
3100
|
i.preventDefault(), i.stopPropagation(), this.openPopover();
|
|
3177
|
-
}), this.inputEl = document.createElement("input"), this.inputEl.type = "text", this.inputEl.className = "gradient-text-input", this.inputEl.placeholder = "Enter gradient CSS or paste color...", this.inputEl.value = this.value ?
|
|
3101
|
+
}), this.inputEl = document.createElement("input"), this.inputEl.type = "text", this.inputEl.className = "gradient-text-input", this.inputEl.placeholder = "Enter gradient CSS or paste color...", this.inputEl.value = this.value ? q(this.value) : "", this.inputEl.readOnly = !1, this.inputEl.addEventListener("focus", () => {
|
|
3178
3102
|
if (this.isEditing = !0, this.value)
|
|
3179
3103
|
if (this.value.type === "solid") {
|
|
3180
3104
|
const i = this.value.stops[0];
|
|
@@ -3188,14 +3112,14 @@ const V = class V extends b {
|
|
|
3188
3112
|
}
|
|
3189
3113
|
}
|
|
3190
3114
|
} else
|
|
3191
|
-
this.inputEl.value =
|
|
3115
|
+
this.inputEl.value = I(this.value);
|
|
3192
3116
|
}), this.inputEl.addEventListener("blur", () => {
|
|
3193
|
-
this.isEditing = !1, this.value && (this.inputEl.value =
|
|
3117
|
+
this.isEditing = !1, this.value && (this.inputEl.value = q(this.value));
|
|
3194
3118
|
}), this.inputEl.addEventListener(
|
|
3195
3119
|
"paste",
|
|
3196
3120
|
(i) => this.handlePaste(i)
|
|
3197
3121
|
), this.inputEl.addEventListener("input", (i) => this.handleTextInput(i)), this.inputEl.addEventListener("keydown", (i) => {
|
|
3198
|
-
i.key === "Enter" && (this.handleTextInput(i), this.inputEl.blur()), i.key === "Escape" && (this.value && (this.inputEl.value =
|
|
3122
|
+
i.key === "Enter" && (this.handleTextInput(i), this.inputEl.blur()), i.key === "Escape" && (this.value && (this.inputEl.value = I(this.value)), this.inputEl.blur());
|
|
3199
3123
|
}), e.appendChild(this.previewEl), e.appendChild(this.inputEl), t.appendChild(e), this.createPopover(), this.element = t, t;
|
|
3200
3124
|
}
|
|
3201
3125
|
createPopover() {
|
|
@@ -3210,7 +3134,7 @@ const V = class V extends b {
|
|
|
3210
3134
|
const e = document.createElement("span");
|
|
3211
3135
|
e.textContent = "Fill";
|
|
3212
3136
|
const i = document.createElement("button");
|
|
3213
|
-
i.type = "button", i.className = "gradient-popover-close", i.innerHTML =
|
|
3137
|
+
i.type = "button", i.className = "gradient-popover-close", i.innerHTML = gt, i.addEventListener("click", () => this.closePopover()), t.appendChild(e), t.appendChild(i), ct(t, this.popoverEl, (a, l) => {
|
|
3214
3138
|
this.popoverPosition = { left: a, top: l };
|
|
3215
3139
|
});
|
|
3216
3140
|
const s = document.createElement("div");
|
|
@@ -3282,42 +3206,42 @@ const V = class V extends b {
|
|
|
3282
3206
|
const o = document.createElement("input");
|
|
3283
3207
|
o.type = "text", o.inputMode = "numeric", o.className = "gradient-degree-input", o.value = `${this.value.angle ?? 90}°`, o.style.width = "75px", o.style.textAlign = "center", (!this.value.angle || this.value.stops.length < 2) && (this.value.angle = 90, o.value = "90°");
|
|
3284
3208
|
const a = document.createElement("button");
|
|
3285
|
-
a.type = "button", a.className = "gradient-flip-btn", a.innerHTML =
|
|
3209
|
+
a.type = "button", a.className = "gradient-flip-btn", a.innerHTML = _t, i.addEventListener("change", () => {
|
|
3286
3210
|
this.switchType(i.value === "radial" ? "radial" : "linear"), this.updateDegreeVisibility(o);
|
|
3287
3211
|
}), o.addEventListener("focus", (f) => {
|
|
3288
|
-
const
|
|
3289
|
-
|
|
3212
|
+
const m = f.target;
|
|
3213
|
+
m.value = m.value.replace(/[^0-9-]/g, ""), setTimeout(() => m.select(), 0);
|
|
3290
3214
|
}), o.addEventListener("input", (f) => {
|
|
3291
|
-
const
|
|
3292
|
-
!Number.isNaN(
|
|
3215
|
+
const m = parseInt(f.target.value);
|
|
3216
|
+
!Number.isNaN(m) && this.value && (this.value.angle = Math.max(0, Math.min(360, m)), this.debouncedPreviewUpdate());
|
|
3293
3217
|
}), o.addEventListener("blur", (f) => {
|
|
3294
|
-
var
|
|
3218
|
+
var C;
|
|
3295
3219
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
3296
|
-
const
|
|
3297
|
-
let
|
|
3298
|
-
Number.isNaN(
|
|
3220
|
+
const m = f.target;
|
|
3221
|
+
let v = parseInt(m.value);
|
|
3222
|
+
Number.isNaN(v) && (v = ((C = this.value) == null ? void 0 : C.angle) ?? 0), v = Math.max(0, Math.min(360, v)), this.value && (this.value.angle = v), m.value = `${v}°`, this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3299
3223
|
}), a.addEventListener("click", () => {
|
|
3300
3224
|
!this.value || !this.value.stops || (this.value.stops.forEach((f) => {
|
|
3301
3225
|
f.position = 100 - f.position;
|
|
3302
|
-
}), this.value.stops.sort((f,
|
|
3226
|
+
}), this.value.stops.sort((f, m) => f.position - m.position), this.updateGradientPreview(l), this.createHandles(r, l), this.updateStopsList(u), this.updateUI(), this.triggerChange());
|
|
3303
3227
|
}), e.appendChild(i), e.appendChild(o), e.appendChild(a), t.appendChild(e), this.updateDegreeVisibility(o);
|
|
3304
3228
|
const l = document.createElement("div");
|
|
3305
3229
|
l.className = "gradient-preview", this.updateGradientPreview(l);
|
|
3306
3230
|
const r = document.createElement("div");
|
|
3307
3231
|
r.className = "gradient-handles", l.appendChild(r), t.appendChild(l), this.createHandles(r, l);
|
|
3308
|
-
const
|
|
3309
|
-
|
|
3310
|
-
const
|
|
3311
|
-
|
|
3312
|
-
const
|
|
3313
|
-
|
|
3232
|
+
const d = document.createElement("div");
|
|
3233
|
+
d.className = "gradient-stops-header";
|
|
3234
|
+
const h = document.createElement("span");
|
|
3235
|
+
h.textContent = "Stops";
|
|
3236
|
+
const p = document.createElement("button");
|
|
3237
|
+
p.type = "button", p.className = "gradient-add-stop", p.textContent = "+", d.appendChild(h), d.appendChild(p);
|
|
3314
3238
|
const u = document.createElement("div");
|
|
3315
|
-
u.className = "gradient-stops", t.appendChild(
|
|
3316
|
-
const
|
|
3317
|
-
const
|
|
3318
|
-
|
|
3239
|
+
u.className = "gradient-stops", t.appendChild(d), t.appendChild(u), this.updateStopsList(u);
|
|
3240
|
+
const g = et((f) => {
|
|
3241
|
+
const m = T(f);
|
|
3242
|
+
m && (this.value = m, this.switchType(m.type), this.updateUI(), this.triggerChange());
|
|
3319
3243
|
}, "all");
|
|
3320
|
-
this.recentGradientRefresh =
|
|
3244
|
+
this.recentGradientRefresh = g.refresh, t.appendChild(g.container), p.addEventListener("click", () => {
|
|
3321
3245
|
var f;
|
|
3322
3246
|
this.addStop(), this.updateStopsList(u), this.updateGradientPreview(l), this.createHandles(r, l), this.updateUI(), ((f = document.activeElement) == null ? void 0 : f.tagName) !== "INPUT" && this.repositionPopover(), this.triggerChange();
|
|
3323
3247
|
});
|
|
@@ -3329,7 +3253,7 @@ const V = class V extends b {
|
|
|
3329
3253
|
updateGradientPreview(t) {
|
|
3330
3254
|
var i;
|
|
3331
3255
|
const e = t || ((i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-preview"));
|
|
3332
|
-
e && this.value && (e.style.background =
|
|
3256
|
+
e && this.value && (e.style.background = I(this.value));
|
|
3333
3257
|
}
|
|
3334
3258
|
debouncedPreviewUpdate(t) {
|
|
3335
3259
|
this.previewUpdateTimeout && clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = window.setTimeout(() => {
|
|
@@ -3343,24 +3267,24 @@ const V = class V extends b {
|
|
|
3343
3267
|
const o = document.createElement("div");
|
|
3344
3268
|
o.className = "gstop-chip", o.style.backgroundColor = i.color, n.appendChild(o);
|
|
3345
3269
|
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
|
-
},
|
|
3270
|
+
const d = (u) => {
|
|
3271
|
+
a = !0, l = u.clientX, r = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove", h), document.addEventListener("mouseup", p), u.preventDefault(), u.stopPropagation();
|
|
3272
|
+
}, h = (u) => {
|
|
3349
3273
|
if (!a || !this.value) return;
|
|
3350
|
-
const
|
|
3351
|
-
let
|
|
3352
|
-
|
|
3353
|
-
},
|
|
3354
|
-
a && (a = !1, n.classList.remove("selected"), document.removeEventListener("mousemove",
|
|
3274
|
+
const g = e.getBoundingClientRect(), f = u.clientX - l;
|
|
3275
|
+
let m = r + f / g.width * 100;
|
|
3276
|
+
m = Math.max(0, Math.min(100, m)), this.value.stops[s].position = Math.round(m), n.style.left = `${m}%`, this.updateGradientPreview();
|
|
3277
|
+
}, p = () => {
|
|
3278
|
+
a && (a = !1, n.classList.remove("selected"), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", p), this.value && (this.value.stops.sort((u, g) => u.position - g.position), this.createHandles(t, e), this.updateStopsList()), this.updateUI(), this.triggerChange());
|
|
3355
3279
|
};
|
|
3356
|
-
n.addEventListener("mousedown",
|
|
3280
|
+
n.addEventListener("mousedown", d), t.appendChild(n);
|
|
3357
3281
|
});
|
|
3358
3282
|
}
|
|
3359
3283
|
updateStopsList(t) {
|
|
3360
3284
|
var i;
|
|
3361
3285
|
const e = t || ((i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-stops"));
|
|
3362
3286
|
!e || !this.value || this.value.type === "solid" || !this.value.stops || (e.innerHTML = "", this.value.stops.forEach((s, n) => {
|
|
3363
|
-
var
|
|
3287
|
+
var k, O;
|
|
3364
3288
|
const o = document.createElement("div");
|
|
3365
3289
|
o.className = "gstop-row";
|
|
3366
3290
|
const a = document.createElement("div");
|
|
@@ -3369,90 +3293,90 @@ const V = class V extends b {
|
|
|
3369
3293
|
l.type = "text", l.className = "gstop-position-input", l.value = `${s.position}%`, l.style.width = "60px", a.appendChild(l);
|
|
3370
3294
|
const r = document.createElement("div");
|
|
3371
3295
|
r.className = "gstop-color-container";
|
|
3372
|
-
const
|
|
3373
|
-
|
|
3374
|
-
const
|
|
3375
|
-
|
|
3376
|
-
const
|
|
3377
|
-
|
|
3296
|
+
const d = document.createElement("div");
|
|
3297
|
+
d.className = "gstop-color-preview", d.style.backgroundColor = s.color;
|
|
3298
|
+
const h = document.createElement("input");
|
|
3299
|
+
h.type = "text", h.className = "gstop-color-input", h.value = s.color.replace("#", "").toUpperCase();
|
|
3300
|
+
const p = document.createElement("button");
|
|
3301
|
+
p.type = "button", p.className = "gstop-color-copy", p.textContent = "Copy", r.appendChild(d), r.appendChild(h), r.appendChild(p);
|
|
3378
3302
|
const u = document.createElement("button");
|
|
3379
|
-
u.type = "button", u.className = "gstop-del", u.innerHTML =
|
|
3380
|
-
const
|
|
3381
|
-
|
|
3303
|
+
u.type = "button", u.className = "gstop-del", u.innerHTML = qt, u.disabled = (((O = (k = this.value) == null ? void 0 : k.stops) == null ? void 0 : O.length) || 0) <= 2, o.appendChild(a), o.appendChild(r), o.appendChild(u), e.appendChild(o);
|
|
3304
|
+
const g = document.createElement("span");
|
|
3305
|
+
g.className = "gstop-opacity-label", g.textContent = "Opacity";
|
|
3382
3306
|
const f = document.createElement("div");
|
|
3383
3307
|
f.className = "gstop-opacity-group";
|
|
3384
|
-
const
|
|
3385
|
-
|
|
3386
|
-
const
|
|
3387
|
-
|
|
3308
|
+
const m = document.createElement("input");
|
|
3309
|
+
m.type = "range", m.className = "gstop-opacity-slider", m.min = "0", m.max = "100", m.value = String(s.opacity ?? 100);
|
|
3310
|
+
const v = M(s.color);
|
|
3311
|
+
m.style.setProperty(
|
|
3388
3312
|
"--slider-color",
|
|
3389
|
-
`rgb(${
|
|
3313
|
+
`rgb(${v.r}, ${v.g}, ${v.b})`
|
|
3390
3314
|
);
|
|
3391
|
-
const
|
|
3392
|
-
|
|
3393
|
-
const
|
|
3394
|
-
|
|
3395
|
-
const
|
|
3396
|
-
|
|
3315
|
+
const C = document.createElement("span");
|
|
3316
|
+
C.className = "gstop-opacity-value", C.textContent = `${s.opacity ?? 100}%`, f.appendChild(m), f.appendChild(C);
|
|
3317
|
+
const x = new Jt((y, E) => {
|
|
3318
|
+
h.value = y.replace("#", "").toUpperCase(), d.style.backgroundColor = y, this.value.stops[n].color = y, E !== void 0 && (this.value.stops[n].opacity = E, m.value = String(E), C.textContent = `${E}%`);
|
|
3319
|
+
const L = M(y);
|
|
3320
|
+
m.style.setProperty(
|
|
3397
3321
|
"--slider-color",
|
|
3398
|
-
`rgb(${
|
|
3322
|
+
`rgb(${L.r}, ${L.g}, ${L.b})`
|
|
3399
3323
|
), this.updateGradientPreview(), this.createHandles(
|
|
3400
3324
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
3401
3325
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3402
3326
|
), this.updateUI(), this.triggerChange();
|
|
3403
3327
|
}, "solid");
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
}),
|
|
3407
|
-
const
|
|
3328
|
+
h.addEventListener("click", (y) => {
|
|
3329
|
+
y.preventDefault(), y.stopPropagation(), x.open(s.color, h, s.opacity ?? 100);
|
|
3330
|
+
}), h.addEventListener("input", () => {
|
|
3331
|
+
const y = h.value.trim(), E = y.startsWith("#") ? y : `#${y}`;
|
|
3408
3332
|
if (/^#[0-9A-Fa-f]{6}$/.test(E)) {
|
|
3409
|
-
this.value.stops[n].color = E,
|
|
3410
|
-
const
|
|
3411
|
-
|
|
3333
|
+
this.value.stops[n].color = E, d.style.backgroundColor = E;
|
|
3334
|
+
const L = M(E);
|
|
3335
|
+
m.style.setProperty(
|
|
3412
3336
|
"--slider-color",
|
|
3413
|
-
`rgb(${
|
|
3337
|
+
`rgb(${L.r}, ${L.g}, ${L.b})`
|
|
3414
3338
|
), this.debouncedPreviewUpdate();
|
|
3415
3339
|
}
|
|
3416
|
-
}),
|
|
3340
|
+
}), h.addEventListener("blur", () => {
|
|
3417
3341
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3418
|
-
}),
|
|
3419
|
-
|
|
3342
|
+
}), p.addEventListener("click", async (y) => {
|
|
3343
|
+
y.stopPropagation();
|
|
3420
3344
|
try {
|
|
3421
|
-
await navigator.clipboard.writeText(`#${
|
|
3345
|
+
await navigator.clipboard.writeText(`#${h.value}`);
|
|
3422
3346
|
} catch {
|
|
3423
3347
|
}
|
|
3424
|
-
}), l.addEventListener("focus", (
|
|
3425
|
-
const E =
|
|
3348
|
+
}), l.addEventListener("focus", (y) => {
|
|
3349
|
+
const E = y.target;
|
|
3426
3350
|
E.value = E.value.replace("%", ""), E.select();
|
|
3427
|
-
}), l.addEventListener("input", (
|
|
3428
|
-
const E =
|
|
3429
|
-
if (!Number.isNaN(
|
|
3430
|
-
const
|
|
3431
|
-
this.value.stops[n].position =
|
|
3351
|
+
}), l.addEventListener("input", (y) => {
|
|
3352
|
+
const E = y.target, L = parseInt(E.value.replace(/[^\d]/g, ""), 10);
|
|
3353
|
+
if (!Number.isNaN(L)) {
|
|
3354
|
+
const G = Math.max(0, Math.min(100, L));
|
|
3355
|
+
this.value.stops[n].position = G, E.value = `${G}%`, this.debouncedPreviewUpdate();
|
|
3432
3356
|
}
|
|
3433
|
-
}), l.addEventListener("blur", (
|
|
3357
|
+
}), l.addEventListener("blur", (y) => {
|
|
3434
3358
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
3435
|
-
const E =
|
|
3436
|
-
if (Number.isNaN(
|
|
3359
|
+
const E = y.target, L = parseInt(E.value.replace(/[^\d]/g, ""), 10);
|
|
3360
|
+
if (Number.isNaN(L))
|
|
3437
3361
|
E.value = `${this.value.stops[n].position}%`;
|
|
3438
3362
|
else {
|
|
3439
|
-
const
|
|
3440
|
-
this.value.stops[n].position =
|
|
3363
|
+
const G = Math.max(0, Math.min(100, L));
|
|
3364
|
+
this.value.stops[n].position = G, E.value = `${G}%`;
|
|
3441
3365
|
}
|
|
3442
3366
|
this.updateGradientPreview(), this.createHandles(
|
|
3443
3367
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
3444
3368
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3445
3369
|
), this.updateStopsList(), this.updateUI(), this.triggerChange();
|
|
3446
3370
|
}), u.addEventListener("click", () => {
|
|
3447
|
-
var
|
|
3371
|
+
var y;
|
|
3448
3372
|
(this.value.stops.length || 0) <= 2 || (this.value.stops.splice(n, 1), this.createHandles(
|
|
3449
3373
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
3450
3374
|
this.popoverEl.querySelector(".gradient-preview")
|
|
3451
|
-
), this.updateStopsList(), this.updateGradientPreview(), this.updateUI(), ((
|
|
3452
|
-
}),
|
|
3453
|
-
const
|
|
3454
|
-
this.value.stops[n].opacity = Math.max(0, Math.min(100,
|
|
3455
|
-
}),
|
|
3375
|
+
), this.updateStopsList(), this.updateGradientPreview(), this.updateUI(), ((y = document.activeElement) == null ? void 0 : y.tagName) !== "INPUT" && this.repositionPopover(), this.triggerChange());
|
|
3376
|
+
}), m.addEventListener("input", () => {
|
|
3377
|
+
const y = parseInt(m.value, 10);
|
|
3378
|
+
this.value.stops[n].opacity = Math.max(0, Math.min(100, y)), C.textContent = `${this.value.stops[n].opacity}%`, this.debouncedPreviewUpdate();
|
|
3379
|
+
}), m.addEventListener("change", () => {
|
|
3456
3380
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3457
3381
|
});
|
|
3458
3382
|
}));
|
|
@@ -3481,10 +3405,10 @@ const V = class V extends b {
|
|
|
3481
3405
|
this.popoverEl.style.position = "fixed", this.popoverEl.style.zIndex = "10000", this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3482
3406
|
const o = this.popoverEl.offsetHeight;
|
|
3483
3407
|
let a = t.right + 8, l = t.top;
|
|
3484
|
-
const r = i - t.right,
|
|
3485
|
-
r <
|
|
3486
|
-
const
|
|
3487
|
-
u >= o + n ? l = t.top - o - 8 :
|
|
3408
|
+
const r = i - t.right, d = t.left, h = e + n;
|
|
3409
|
+
r < h && d > r + 100 && (a = t.left - e - 8);
|
|
3410
|
+
const p = s - t.bottom, u = t.top;
|
|
3411
|
+
u >= o + n ? l = t.top - o - 8 : p >= o + n ? l = t.bottom + 8 : u > p ? (l = t.top - o - 8, l < n && (l = n)) : (l = t.bottom + 8, l + o > s - n && (l = s - o - n)), this.popoverEl.style.left = `${a}px`, this.popoverEl.style.top = `${l}px`, this.popoverPosition = { left: a, top: l };
|
|
3488
3412
|
}
|
|
3489
3413
|
setTimeout(
|
|
3490
3414
|
() => document.addEventListener("click", this.onBackgroundClick, !0),
|
|
@@ -3505,10 +3429,10 @@ const V = class V extends b {
|
|
|
3505
3429
|
this.popoverEl.style.left, this.popoverEl.style.top, this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3506
3430
|
const a = this.popoverEl.offsetHeight;
|
|
3507
3431
|
let l = e.right + 8, r = e.top;
|
|
3508
|
-
const
|
|
3509
|
-
|
|
3510
|
-
const u = n - e.bottom,
|
|
3511
|
-
|
|
3432
|
+
const d = s - e.right, h = e.left, p = i + o;
|
|
3433
|
+
d < p && h > d + 100 && (l = e.left - i - 8);
|
|
3434
|
+
const u = n - e.bottom, g = e.top;
|
|
3435
|
+
g >= a + o ? r = e.top - a - 8 : u >= a + o ? r = e.bottom + 8 : g > 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
3436
|
});
|
|
3513
3437
|
}
|
|
3514
3438
|
}
|
|
@@ -3526,14 +3450,14 @@ const V = class V extends b {
|
|
|
3526
3450
|
var t;
|
|
3527
3451
|
if (!(!this.popoverEl || !this.isPopoverOpen)) {
|
|
3528
3452
|
if (this.isPopoverOpen = !1, this.popoverPosition = null, this.backdropEl && (this.backdropEl.style.display = "none"), this.popoverEl.style.display = "none", document.removeEventListener("click", this.onBackgroundClick, !0), document.removeEventListener("keydown", this.handlePopoverKeydown, !0), this.commitPendingSolidColor(), this.value && this.value.type !== "solid") {
|
|
3529
|
-
const e =
|
|
3530
|
-
|
|
3453
|
+
const e = I(this.value);
|
|
3454
|
+
$.addColor(e, "gradient"), (t = this.recentGradientRefresh) == null || t.call(this);
|
|
3531
3455
|
}
|
|
3532
3456
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), V.openInstance === this && (V.openInstance = null);
|
|
3533
3457
|
}
|
|
3534
3458
|
}
|
|
3535
3459
|
commitPendingSolidColor() {
|
|
3536
|
-
this.pendingSolidColor && (this.solidPicker ? this.solidPicker.commitRecentColor() :
|
|
3460
|
+
this.pendingSolidColor && (this.solidPicker ? this.solidPicker.commitRecentColor() : $.addColor(this.pendingSolidColor, "solid"), this.pendingSolidColor = null);
|
|
3537
3461
|
}
|
|
3538
3462
|
handlePaste(t) {
|
|
3539
3463
|
var i;
|
|
@@ -3557,10 +3481,10 @@ const V = class V extends b {
|
|
|
3557
3481
|
return this.element;
|
|
3558
3482
|
}
|
|
3559
3483
|
getValue() {
|
|
3560
|
-
return this.value ?
|
|
3484
|
+
return this.value ? I(this.value) : "";
|
|
3561
3485
|
}
|
|
3562
3486
|
getCSSValue() {
|
|
3563
|
-
return this.value ?
|
|
3487
|
+
return this.value ? I(this.value) : "";
|
|
3564
3488
|
}
|
|
3565
3489
|
getCSSForText() {
|
|
3566
3490
|
return this.value ? this.cssForTextValue() : {};
|
|
@@ -3570,7 +3494,7 @@ const V = class V extends b {
|
|
|
3570
3494
|
}
|
|
3571
3495
|
};
|
|
3572
3496
|
V.openInstance = null;
|
|
3573
|
-
let
|
|
3497
|
+
let X = V;
|
|
3574
3498
|
const Zt = `
|
|
3575
3499
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
3576
3500
|
<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"/>
|
|
@@ -3586,17 +3510,17 @@ class ye extends P {
|
|
|
3586
3510
|
title: "Border",
|
|
3587
3511
|
collapsed: t == null ? void 0 : t.collapsed,
|
|
3588
3512
|
settings: {
|
|
3589
|
-
size: new
|
|
3513
|
+
size: new N({
|
|
3590
3514
|
title: "Size",
|
|
3591
3515
|
icon: Kt,
|
|
3592
3516
|
default: (t == null ? void 0 : t.size) ?? 0,
|
|
3593
3517
|
suffix: "px"
|
|
3594
3518
|
}),
|
|
3595
|
-
color: new
|
|
3519
|
+
color: new X({
|
|
3596
3520
|
title: "Border Color",
|
|
3597
3521
|
default: (t == null ? void 0 : t.color) || "#000000"
|
|
3598
3522
|
}),
|
|
3599
|
-
radius: new
|
|
3523
|
+
radius: new N({
|
|
3600
3524
|
title: "Radius",
|
|
3601
3525
|
icon: Zt,
|
|
3602
3526
|
default: (t == null ? void 0 : t.radius) ?? 12,
|
|
@@ -3643,11 +3567,11 @@ class Ee extends P {
|
|
|
3643
3567
|
collapsed: i.collapsed,
|
|
3644
3568
|
settings: (() => {
|
|
3645
3569
|
const s = {
|
|
3646
|
-
color: new
|
|
3570
|
+
color: new X({
|
|
3647
3571
|
title: "Color",
|
|
3648
3572
|
default: i.colorDefault ?? "#001E1E"
|
|
3649
3573
|
}),
|
|
3650
|
-
fontFamily: new
|
|
3574
|
+
fontFamily: new Q({
|
|
3651
3575
|
title: "Font",
|
|
3652
3576
|
icon: Yt,
|
|
3653
3577
|
default: i.fontFamilyDefault ?? "Satoshi",
|
|
@@ -3660,7 +3584,7 @@ class Ee extends P {
|
|
|
3660
3584
|
getOptions: i.fontFamilyGetOptions,
|
|
3661
3585
|
getOptionsAsync: i.fontFamilyGetOptionsAsync
|
|
3662
3586
|
}),
|
|
3663
|
-
fontWeight: new
|
|
3587
|
+
fontWeight: new Q({
|
|
3664
3588
|
title: "Weight",
|
|
3665
3589
|
icon: Qt,
|
|
3666
3590
|
default: i.fontWeightDefault ?? "400",
|
|
@@ -3672,7 +3596,7 @@ class Ee extends P {
|
|
|
3672
3596
|
getOptions: i.fontWeightGetOptions,
|
|
3673
3597
|
getOptionsAsync: i.fontWeightGetOptionsAsync
|
|
3674
3598
|
}),
|
|
3675
|
-
fontSize: new
|
|
3599
|
+
fontSize: new N({
|
|
3676
3600
|
title: "Size",
|
|
3677
3601
|
icon: te,
|
|
3678
3602
|
default: i.fontSizeDefault ?? 12,
|
|
@@ -3682,7 +3606,7 @@ class Ee extends P {
|
|
|
3682
3606
|
};
|
|
3683
3607
|
return e ? {
|
|
3684
3608
|
...s,
|
|
3685
|
-
align: new
|
|
3609
|
+
align: new It({
|
|
3686
3610
|
title: "Align",
|
|
3687
3611
|
default: i.alignDefault ?? "center"
|
|
3688
3612
|
})
|
|
@@ -3714,7 +3638,7 @@ class Ee extends P {
|
|
|
3714
3638
|
`;
|
|
3715
3639
|
}
|
|
3716
3640
|
}
|
|
3717
|
-
class
|
|
3641
|
+
class W extends b {
|
|
3718
3642
|
constructor(t) {
|
|
3719
3643
|
super({
|
|
3720
3644
|
...t,
|
|
@@ -3725,8 +3649,8 @@ class j extends b {
|
|
|
3725
3649
|
const t = this.value === "auto" ? "text" : "number", e = (a) => {
|
|
3726
3650
|
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
3651
|
const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
3728
|
-
let
|
|
3729
|
-
|
|
3652
|
+
let d = Number(a.value);
|
|
3653
|
+
d < l && (d = l), d > r && (d = r), a.value = String(d);
|
|
3730
3654
|
}));
|
|
3731
3655
|
}, i = this.createInput({
|
|
3732
3656
|
value: this.value,
|
|
@@ -3766,25 +3690,25 @@ class be extends P {
|
|
|
3766
3690
|
title: "Margins",
|
|
3767
3691
|
collapsed: t == null ? void 0 : t.collapsed,
|
|
3768
3692
|
settings: {
|
|
3769
|
-
marginTop: new
|
|
3693
|
+
marginTop: new W({
|
|
3770
3694
|
title: "Top",
|
|
3771
3695
|
icon: ee,
|
|
3772
3696
|
suffix: "px",
|
|
3773
3697
|
default: (t == null ? void 0 : t.marginTop) ?? "auto"
|
|
3774
3698
|
}),
|
|
3775
|
-
marginRight: new
|
|
3699
|
+
marginRight: new W({
|
|
3776
3700
|
title: "Right",
|
|
3777
3701
|
icon: ie,
|
|
3778
3702
|
suffix: "px",
|
|
3779
3703
|
default: (t == null ? void 0 : t.marginRight) ?? 0
|
|
3780
3704
|
}),
|
|
3781
|
-
marginBottom: new
|
|
3705
|
+
marginBottom: new W({
|
|
3782
3706
|
title: "Bottom",
|
|
3783
3707
|
icon: se,
|
|
3784
3708
|
suffix: "px",
|
|
3785
3709
|
default: (t == null ? void 0 : t.marginBottom) ?? 0
|
|
3786
3710
|
}),
|
|
3787
|
-
marginLeft: new
|
|
3711
|
+
marginLeft: new W({
|
|
3788
3712
|
title: "Left",
|
|
3789
3713
|
icon: ne,
|
|
3790
3714
|
suffix: "px",
|
|
@@ -3822,10 +3746,10 @@ class we extends P {
|
|
|
3822
3746
|
...t == null ? void 0 : t.uploadProps,
|
|
3823
3747
|
default: (t == null ? void 0 : t.backgroundImage) ?? ""
|
|
3824
3748
|
}),
|
|
3825
|
-
opacity: new
|
|
3749
|
+
opacity: new St({
|
|
3826
3750
|
default: (t == null ? void 0 : t.opacity) ?? 100
|
|
3827
3751
|
}),
|
|
3828
|
-
backgroundColor: new
|
|
3752
|
+
backgroundColor: new B({
|
|
3829
3753
|
default: (t == null ? void 0 : t.backgroundColor) ?? "0, 0, 30"
|
|
3830
3754
|
})
|
|
3831
3755
|
}
|
|
@@ -3852,16 +3776,16 @@ class we extends P {
|
|
|
3852
3776
|
}
|
|
3853
3777
|
}
|
|
3854
3778
|
export {
|
|
3855
|
-
|
|
3779
|
+
It as AlignSetting,
|
|
3856
3780
|
Ce as AnimationSetting,
|
|
3857
3781
|
we as BackgroundSettingSet,
|
|
3858
3782
|
ye as BorderSettingSet,
|
|
3859
3783
|
re as ButtonSetting,
|
|
3860
|
-
|
|
3861
|
-
|
|
3784
|
+
S as ColorSetting,
|
|
3785
|
+
B as ColorWithOpacitySetting,
|
|
3862
3786
|
ce as DimensionSetting,
|
|
3863
3787
|
ge as GapSetting,
|
|
3864
|
-
|
|
3788
|
+
X as GradientSetting,
|
|
3865
3789
|
Ee as HeaderTypographySettingSet,
|
|
3866
3790
|
he as HeightSetting,
|
|
3867
3791
|
le as HtmlSetting,
|
|
@@ -3869,23 +3793,23 @@ export {
|
|
|
3869
3793
|
be as MarginSettingGroup,
|
|
3870
3794
|
fe as MarginTopSetting,
|
|
3871
3795
|
ve as MultiLanguageSetting,
|
|
3872
|
-
|
|
3873
|
-
|
|
3796
|
+
N as NumberSetting,
|
|
3797
|
+
St as OpacitySetting,
|
|
3874
3798
|
de as SelectApiSettings,
|
|
3875
|
-
|
|
3799
|
+
Q as SelectSetting,
|
|
3876
3800
|
b as Setting,
|
|
3877
3801
|
P as SettingGroup,
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3802
|
+
xt as StringSetting,
|
|
3803
|
+
bt as TabSettingGroup,
|
|
3804
|
+
bt as TabsSettingGroup,
|
|
3881
3805
|
ue as Toggle,
|
|
3882
3806
|
rt as UploadSetting,
|
|
3883
3807
|
pe as WidthSetting,
|
|
3884
3808
|
ae as asSettingGroupWithSettings,
|
|
3885
|
-
|
|
3809
|
+
wt as createSettingGroup,
|
|
3886
3810
|
oe as createTabSettingGroup,
|
|
3887
|
-
|
|
3811
|
+
A as isSetting,
|
|
3888
3812
|
st as isSettingChild,
|
|
3889
3813
|
w as isSettingGroup,
|
|
3890
|
-
|
|
3814
|
+
U as iterateSettings
|
|
3891
3815
|
};
|