builder-settings-types 0.0.307 → 0.0.308
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,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const vt = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
2
2
|
let rt = (h = 21) => {
|
|
3
3
|
let t = "", e = crypto.getRandomValues(new Uint8Array(h |= 0));
|
|
4
4
|
for (; h--; )
|
|
5
|
-
t +=
|
|
5
|
+
t += vt[e[h] & 63];
|
|
6
6
|
return t;
|
|
7
7
|
};
|
|
8
8
|
function Ct(h) {
|
|
@@ -142,18 +142,18 @@ function Et(h) {
|
|
|
142
142
|
return "";
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
const
|
|
145
|
+
const B = class B {
|
|
146
146
|
constructor(t = {}) {
|
|
147
147
|
this.props = t, this.dataPropsPath = "", this.id = t.id || rt(), this.value = this.props.default, this.desktop = this.props.default, this.title = t.title || "", this.includeGetJson = t.includeGetJson !== void 0 ? t.includeGetJson : !0;
|
|
148
148
|
}
|
|
149
149
|
static SetUploadUrl(t) {
|
|
150
|
-
globalThis.DefaultUploadUrl = t,
|
|
150
|
+
globalThis.DefaultUploadUrl = t, B.DefaultUploadUrl = t;
|
|
151
151
|
}
|
|
152
152
|
static SetDefaultLanguage(t) {
|
|
153
|
-
globalThis.DefaultLanguage = t,
|
|
153
|
+
globalThis.DefaultLanguage = t, B.DefaultLanguage = t;
|
|
154
154
|
}
|
|
155
155
|
static SetGlobalVariables(t) {
|
|
156
|
-
|
|
156
|
+
B.GlobalVariables = { ...B.GlobalVariables, ...t };
|
|
157
157
|
}
|
|
158
158
|
destroy() {
|
|
159
159
|
throw new Error("Method not implemented.");
|
|
@@ -181,23 +181,23 @@ const A = class A {
|
|
|
181
181
|
t = { ...this.props.inputProps, ...t };
|
|
182
182
|
const e = document.createElement("div");
|
|
183
183
|
if (e.className = t.wrapperClassName || "", t.title || t.icon) {
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
184
|
+
const o = document.createElement("div");
|
|
185
|
+
if (o.className = "icon-container", t.icon) {
|
|
186
186
|
const l = this.createIcon(t.icon, t.iconClassName);
|
|
187
|
-
|
|
187
|
+
o.appendChild(l);
|
|
188
188
|
}
|
|
189
189
|
if (t.title) {
|
|
190
190
|
const l = this.createLabel(t.title, t.labelClassName);
|
|
191
|
-
|
|
191
|
+
o.appendChild(l);
|
|
192
192
|
}
|
|
193
|
-
e.appendChild(
|
|
193
|
+
e.appendChild(o);
|
|
194
194
|
}
|
|
195
195
|
const i = document.createElement("div");
|
|
196
196
|
i.className = t.wrapperClassName || "";
|
|
197
197
|
const s = document.createElement("input");
|
|
198
198
|
this.inputEl = s, s.value = String(t.value || Et(t.inputType)), s.type = t.inputType, s.placeholder = t.placeholder || "", s.className = t.inputClassName || "", this.dataPropsPath && s.setAttribute("data-test-id", this.dataPropsPath);
|
|
199
|
-
const n = (
|
|
200
|
-
const l =
|
|
199
|
+
const n = (o) => {
|
|
200
|
+
const l = o.target;
|
|
201
201
|
let r = l.value;
|
|
202
202
|
switch (t.inputType) {
|
|
203
203
|
case "number":
|
|
@@ -222,10 +222,10 @@ const A = class A {
|
|
|
222
222
|
r = l.value;
|
|
223
223
|
}
|
|
224
224
|
this.value = r, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
|
|
225
|
-
},
|
|
226
|
-
|
|
225
|
+
}, a = (o) => {
|
|
226
|
+
o.target, this.onBlur && this.onBlur(this.value);
|
|
227
227
|
};
|
|
228
|
-
return s.addEventListener("input", n), s.addEventListener("change", n), s.addEventListener("blur",
|
|
228
|
+
return s.addEventListener("input", n), s.addEventListener("change", n), s.addEventListener("blur", a), t.inputCustomizer && t.inputCustomizer(s), i.appendChild(s), e.appendChild(i), e;
|
|
229
229
|
}
|
|
230
230
|
createLabel(t, e) {
|
|
231
231
|
const i = document.createElement("span");
|
|
@@ -236,7 +236,7 @@ const A = class A {
|
|
|
236
236
|
return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
|
-
|
|
239
|
+
B.GlobalVariables = {
|
|
240
240
|
// Global Colors (each supports solid OR gradient)
|
|
241
241
|
primary: "#00141E",
|
|
242
242
|
secondary: "#00141E",
|
|
@@ -246,15 +246,15 @@ A.GlobalVariables = {
|
|
|
246
246
|
"text-dark": "#00141E",
|
|
247
247
|
"text-light": "#00141E"
|
|
248
248
|
};
|
|
249
|
-
let x =
|
|
250
|
-
function
|
|
249
|
+
let x = B;
|
|
250
|
+
function A(h) {
|
|
251
251
|
return h instanceof x;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function L(h) {
|
|
254
254
|
return h instanceof H;
|
|
255
255
|
}
|
|
256
256
|
function nt(h) {
|
|
257
|
-
return
|
|
257
|
+
return A(h) || L(h);
|
|
258
258
|
}
|
|
259
259
|
function z(h, t) {
|
|
260
260
|
for (const e in h)
|
|
@@ -271,7 +271,7 @@ const K = class K {
|
|
|
271
271
|
propagateNestingLevel() {
|
|
272
272
|
const t = this.nestingLevel + 1;
|
|
273
273
|
z(this.settings, (e, i) => {
|
|
274
|
-
|
|
274
|
+
L(i) && (i.nestingLevel = t, i.propagateNestingLevel());
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
277
|
getNestingLevel() {
|
|
@@ -289,7 +289,7 @@ const K = class K {
|
|
|
289
289
|
propagateDataPropsPath() {
|
|
290
290
|
z(this.settings, (t, e) => {
|
|
291
291
|
const i = String(t), s = this.dataPropsPath ? `${this.dataPropsPath}_${i}` : i;
|
|
292
|
-
(
|
|
292
|
+
(L(e) || A(e) && typeof e.setDataPropsPath == "function") && e.setDataPropsPath(s);
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
295
|
updateNestingStyles() {
|
|
@@ -298,7 +298,7 @@ const K = class K {
|
|
|
298
298
|
forceChildUIRefresh() {
|
|
299
299
|
Object.entries(this.settings).forEach(([t, e]) => {
|
|
300
300
|
try {
|
|
301
|
-
if (
|
|
301
|
+
if (L(e)) {
|
|
302
302
|
const i = e.getValues();
|
|
303
303
|
e.setValue(i);
|
|
304
304
|
} else if (typeof e.setValue == "function") {
|
|
@@ -321,13 +321,21 @@ const K = class K {
|
|
|
321
321
|
".setting-group-content"
|
|
322
322
|
);
|
|
323
323
|
if (n) {
|
|
324
|
-
const
|
|
325
|
-
n.querySelectorAll(
|
|
324
|
+
const a = Array.from(
|
|
325
|
+
n.querySelectorAll(
|
|
326
|
+
".setting-group, .setting, [data-setting-id]"
|
|
327
|
+
)
|
|
326
328
|
);
|
|
327
|
-
for (const
|
|
328
|
-
const l =
|
|
329
|
+
for (const o of a) {
|
|
330
|
+
const l = o.id, r = o.getAttribute(
|
|
331
|
+
"data-setting-id"
|
|
332
|
+
);
|
|
329
333
|
if (l && "id" in e && typeof e.id == "string" && l.includes(e.id)) {
|
|
330
|
-
|
|
334
|
+
o.remove();
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
if (r && "id" in e && typeof e.id == "string" && r === e.id) {
|
|
338
|
+
o.remove();
|
|
331
339
|
break;
|
|
332
340
|
}
|
|
333
341
|
}
|
|
@@ -340,13 +348,38 @@ const K = class K {
|
|
|
340
348
|
updateVisibility() {
|
|
341
349
|
this.elementRef;
|
|
342
350
|
}
|
|
351
|
+
updateSettings(t) {
|
|
352
|
+
var a;
|
|
353
|
+
const e = new Set(Object.keys(this.settings)), i = Object.keys(t), s = {};
|
|
354
|
+
i.forEach((o) => {
|
|
355
|
+
const l = this.settings[o];
|
|
356
|
+
l && (L(l) ? s[o] = l.getValues() : A(l) ? s[o] = l.value : typeof l.getValues == "function" ? s[o] = l.getValues() : l.value !== void 0 && (s[o] = l.value));
|
|
357
|
+
}), e.forEach((o) => {
|
|
358
|
+
i.includes(o) || this.removeSetting(o);
|
|
359
|
+
}), i.forEach((o) => {
|
|
360
|
+
var p;
|
|
361
|
+
const l = t[o], r = this.settings[o];
|
|
362
|
+
if (r !== l && (r && this.removeSetting(o), this.addSetting(o, l), o in s)) {
|
|
363
|
+
const c = s[o];
|
|
364
|
+
try {
|
|
365
|
+
L(l) ? l.setValue(
|
|
366
|
+
c
|
|
367
|
+
) : A(l) ? (p = l.setValue) == null || p.call(l, c) : l.setValue && l.setValue(c);
|
|
368
|
+
} catch (d) {
|
|
369
|
+
console.warn(`Could not preserve value for setting ${o}:`, d);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}), this.settings = t, this.propagateNestingLevel(), this.propagateDataPropsPath();
|
|
373
|
+
const n = this.getValues();
|
|
374
|
+
this.initialValues = n, (a = this.onChange) == null || a.call(this, n);
|
|
375
|
+
}
|
|
343
376
|
clone() {
|
|
344
377
|
const t = {};
|
|
345
378
|
z(this.settings, (s, n) => {
|
|
346
|
-
const
|
|
347
|
-
typeof n.clone == "function" ? t[
|
|
348
|
-
`Setting with key '${
|
|
349
|
-
), t[
|
|
379
|
+
const a = String(s);
|
|
380
|
+
typeof n.clone == "function" ? t[a] = n.clone() : (console.warn(
|
|
381
|
+
`Setting with key '${a}' does not have a clone method. Copying reference.`
|
|
382
|
+
), t[a] = n);
|
|
350
383
|
});
|
|
351
384
|
const e = {
|
|
352
385
|
title: this.title,
|
|
@@ -369,7 +402,7 @@ const K = class K {
|
|
|
369
402
|
setMobileValues(t) {
|
|
370
403
|
!t || typeof t != "object" || (Object.entries(t).forEach(([e, i]) => {
|
|
371
404
|
const s = this.settings[e];
|
|
372
|
-
s && (
|
|
405
|
+
s && (L(s) || A(s)) && typeof s.setMobileValue == "function" && s.setMobileValue(i);
|
|
373
406
|
}), this.setValue(t), this.onChange && this.onChange(this.getValues()));
|
|
374
407
|
}
|
|
375
408
|
getMobileValues(t) {
|
|
@@ -378,7 +411,7 @@ const K = class K {
|
|
|
378
411
|
for (const i in this.settings)
|
|
379
412
|
if (Object.prototype.hasOwnProperty.call(this.settings, i)) {
|
|
380
413
|
const s = this.settings[i];
|
|
381
|
-
if (
|
|
414
|
+
if (L(s))
|
|
382
415
|
e[i] = s.getMobileValues();
|
|
383
416
|
else {
|
|
384
417
|
const n = s;
|
|
@@ -389,7 +422,7 @@ const K = class K {
|
|
|
389
422
|
} else {
|
|
390
423
|
const e = this.settings[t];
|
|
391
424
|
if (!e) return;
|
|
392
|
-
if (
|
|
425
|
+
if (L(e)) return e.getMobileValues();
|
|
393
426
|
const i = e;
|
|
394
427
|
return i.mobileValue !== void 0 ? i.mobileValue : i.value;
|
|
395
428
|
}
|
|
@@ -407,17 +440,17 @@ const K = class K {
|
|
|
407
440
|
};
|
|
408
441
|
return this.changeHandlers.clear(), z(this.settings, (i, s) => {
|
|
409
442
|
var n;
|
|
410
|
-
if (
|
|
443
|
+
if (L(s))
|
|
411
444
|
s.setOnChange(() => {
|
|
412
|
-
const
|
|
413
|
-
this.initialValues =
|
|
445
|
+
const a = this.getValues();
|
|
446
|
+
this.initialValues = a, t(a);
|
|
414
447
|
}), this.changeHandlers.add(() => t(this.getValues()));
|
|
415
|
-
else if (
|
|
416
|
-
const
|
|
417
|
-
this.changeHandlers.add(
|
|
448
|
+
else if (A(s)) {
|
|
449
|
+
const a = () => e();
|
|
450
|
+
this.changeHandlers.add(a), s.setOnChange(a);
|
|
418
451
|
} else {
|
|
419
|
-
const
|
|
420
|
-
this.changeHandlers.add(
|
|
452
|
+
const a = () => e();
|
|
453
|
+
this.changeHandlers.add(a), (n = s.setOnChange) == null || n.call(s, a);
|
|
421
454
|
}
|
|
422
455
|
}), this;
|
|
423
456
|
}
|
|
@@ -432,13 +465,13 @@ const K = class K {
|
|
|
432
465
|
Object.entries(t).forEach(([i, s]) => {
|
|
433
466
|
let n = this.settings[i];
|
|
434
467
|
if (!n && this.addItemCfg && i.startsWith(this.addItemCfg.keyPrefix)) {
|
|
435
|
-
const
|
|
436
|
-
if (Number.isFinite(
|
|
437
|
-
const l = this.addItemCfg.createItem(
|
|
468
|
+
const a = i.slice(this.addItemCfg.keyPrefix.length), o = Number(a);
|
|
469
|
+
if (Number.isFinite(o)) {
|
|
470
|
+
const l = this.addItemCfg.createItem(o);
|
|
438
471
|
nt(l) && (this.addSetting(i, l), n = l);
|
|
439
472
|
}
|
|
440
473
|
}
|
|
441
|
-
n && (
|
|
474
|
+
n && (L(n) || A(n)) && typeof n.setValue == "function" && n.setValue(s);
|
|
442
475
|
}), setTimeout(() => {
|
|
443
476
|
this.forceChildUIRefresh();
|
|
444
477
|
}, 0);
|
|
@@ -452,25 +485,25 @@ const K = class K {
|
|
|
452
485
|
const s = this.getValues();
|
|
453
486
|
this.initialValues = s, (n = this.onChange) == null || n.call(this, s), this.updateVisibility();
|
|
454
487
|
};
|
|
455
|
-
|
|
488
|
+
L(t) ? t.setOnChange(() => e()) : A(t) ? t.setOnChange(() => e()) : (i = t.setOnChange) == null || i.call(t, () => e());
|
|
456
489
|
}
|
|
457
490
|
addSetting(t, e) {
|
|
458
491
|
var s, n;
|
|
459
492
|
if (this.settings[t] = e, this.wireChild(e), this.elementRef) {
|
|
460
|
-
const
|
|
493
|
+
const a = this.elementRef.querySelector(
|
|
461
494
|
".setting-group-content"
|
|
462
495
|
);
|
|
463
|
-
if (
|
|
464
|
-
|
|
465
|
-
const
|
|
496
|
+
if (a) {
|
|
497
|
+
L(e) && typeof e.setNestingLevel == "function" && e.setNestingLevel(this.nestingLevel + 1);
|
|
498
|
+
const o = e.draw(), l = this.deleteItemCfg ?? this.addItemCfg;
|
|
466
499
|
if (l) {
|
|
467
500
|
const c = l.keyPrefix ?? ((s = this.addItemCfg) == null ? void 0 : s.keyPrefix);
|
|
468
|
-
c && t.startsWith(c) && this.addDeleteButtonToElement(
|
|
501
|
+
c && t.startsWith(c) && this.addDeleteButtonToElement(o, t);
|
|
469
502
|
}
|
|
470
|
-
const r =
|
|
471
|
-
r ?
|
|
472
|
-
const p =
|
|
473
|
-
|
|
503
|
+
const r = a.querySelector(".sg-add-button-bottom");
|
|
504
|
+
r ? a.insertBefore(o, r) : a.appendChild(o), st.trackElement(o), q(o, this.nestingLevel + 1), Q(o, this.nestingLevel + 1);
|
|
505
|
+
const p = o.style.display;
|
|
506
|
+
o.style.display = "none", o.offsetHeight, o.style.display = p, this.updateNestingStyles();
|
|
474
507
|
}
|
|
475
508
|
}
|
|
476
509
|
const i = this.getValues();
|
|
@@ -497,8 +530,8 @@ const K = class K {
|
|
|
497
530
|
if (!s) return;
|
|
498
531
|
const n = s.querySelector(".actions-section");
|
|
499
532
|
if (!n) return;
|
|
500
|
-
const
|
|
501
|
-
|
|
533
|
+
const a = document.createElement("button");
|
|
534
|
+
a.type = "button", a.className = "sg-delete-button", i ? i.deleteItemCfg : this.deleteItemCfg ?? this.addItemCfg, a.title = "Delete", a.style.cssText = `
|
|
502
535
|
background: none;
|
|
503
536
|
border: none;
|
|
504
537
|
cursor: pointer;
|
|
@@ -511,23 +544,23 @@ const K = class K {
|
|
|
511
544
|
border-radius: 4px;
|
|
512
545
|
transition: background-color 0.2s;
|
|
513
546
|
`;
|
|
514
|
-
const
|
|
547
|
+
const o = `
|
|
515
548
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
516
549
|
<path d="M2 4h12M5.333 4V2.667a1.333 1.333 0 0 1 1.334-1.334h2.666a1.333 1.333 0 0 1 1.334 1.334V4m2 0v9.333a1.333 1.333 0 0 1-1.334 1.334H4.667a1.333 1.333 0 0 1-1.334-1.334V4h8.667Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
517
550
|
<path d="M6.667 7.333v4M9.333 7.333v4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
518
551
|
</svg>
|
|
519
552
|
`;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}),
|
|
523
|
-
|
|
524
|
-
}),
|
|
553
|
+
a.innerHTML = o, a.addEventListener("mouseenter", () => {
|
|
554
|
+
a.style.backgroundColor = "#fef2f2";
|
|
555
|
+
}), a.addEventListener("mouseleave", () => {
|
|
556
|
+
a.style.backgroundColor = "transparent";
|
|
557
|
+
}), a.addEventListener("click", (r) => {
|
|
525
558
|
r.stopPropagation(), r.preventDefault(), this.showDeleteConfirmation().then((p) => {
|
|
526
559
|
p && (i && i.deleteItemCfg ? this.removeSetting(e) : this.removeSetting(e));
|
|
527
560
|
});
|
|
528
561
|
});
|
|
529
562
|
const l = n.querySelector(".setting-group-arrow");
|
|
530
|
-
l ? n.insertBefore(
|
|
563
|
+
l ? n.insertBefore(a, l) : n.appendChild(a);
|
|
531
564
|
}
|
|
532
565
|
showDeleteConfirmation() {
|
|
533
566
|
return new Promise((t) => {
|
|
@@ -570,14 +603,14 @@ const K = class K {
|
|
|
570
603
|
font-size: 14px;
|
|
571
604
|
line-height: 1.5;
|
|
572
605
|
`;
|
|
573
|
-
const
|
|
574
|
-
|
|
606
|
+
const a = document.createElement("div");
|
|
607
|
+
a.style.cssText = `
|
|
575
608
|
display: flex;
|
|
576
609
|
gap: 12px;
|
|
577
610
|
justify-content: flex-end;
|
|
578
611
|
`;
|
|
579
|
-
const
|
|
580
|
-
|
|
612
|
+
const o = document.createElement("button");
|
|
613
|
+
o.textContent = "Cancel", o.type = "button", o.style.cssText = `
|
|
581
614
|
padding: 8px 16px;
|
|
582
615
|
border: 1px solid #d1d5db;
|
|
583
616
|
background: white;
|
|
@@ -599,10 +632,10 @@ const K = class K {
|
|
|
599
632
|
font-weight: 500;
|
|
600
633
|
cursor: pointer;
|
|
601
634
|
transition: all 0.2s;
|
|
602
|
-
`,
|
|
603
|
-
|
|
604
|
-
}),
|
|
605
|
-
|
|
635
|
+
`, o.addEventListener("mouseenter", () => {
|
|
636
|
+
o.style.backgroundColor = "#f9fafb", o.style.borderColor = "#9ca3af";
|
|
637
|
+
}), o.addEventListener("mouseleave", () => {
|
|
638
|
+
o.style.backgroundColor = "white", o.style.borderColor = "#d1d5db";
|
|
606
639
|
}), l.addEventListener("mouseenter", () => {
|
|
607
640
|
l.style.backgroundColor = "#dc2626";
|
|
608
641
|
}), l.addEventListener("mouseleave", () => {
|
|
@@ -613,7 +646,7 @@ const K = class K {
|
|
|
613
646
|
e.parentNode && e.parentNode.removeChild(e);
|
|
614
647
|
}, 200);
|
|
615
648
|
};
|
|
616
|
-
|
|
649
|
+
o.addEventListener("click", () => {
|
|
617
650
|
r(), t(!1);
|
|
618
651
|
}), l.addEventListener("click", () => {
|
|
619
652
|
r(), t(!0);
|
|
@@ -623,7 +656,7 @@ const K = class K {
|
|
|
623
656
|
const p = (c) => {
|
|
624
657
|
c.key === "Escape" && (r(), t(!1), document.removeEventListener("keydown", p));
|
|
625
658
|
};
|
|
626
|
-
document.addEventListener("keydown", p),
|
|
659
|
+
document.addEventListener("keydown", p), a.appendChild(o), a.appendChild(l), i.appendChild(s), i.appendChild(n), i.appendChild(a), e.appendChild(i), document.body.appendChild(e), requestAnimationFrame(() => {
|
|
627
660
|
e.style.opacity = "1", i.style.transform = "scale(1)";
|
|
628
661
|
}), setTimeout(() => l.focus(), 100);
|
|
629
662
|
});
|
|
@@ -641,8 +674,8 @@ const K = class K {
|
|
|
641
674
|
...Object.keys(t),
|
|
642
675
|
...Object.keys(e)
|
|
643
676
|
])).forEach((n) => {
|
|
644
|
-
const
|
|
645
|
-
JSON.stringify(
|
|
677
|
+
const a = t[n], o = e[n];
|
|
678
|
+
JSON.stringify(a) !== JSON.stringify(o) && (i[n] = { from: a, to: o });
|
|
646
679
|
}), i;
|
|
647
680
|
}
|
|
648
681
|
getValues(t) {
|
|
@@ -651,7 +684,7 @@ const K = class K {
|
|
|
651
684
|
for (const i in this.settings)
|
|
652
685
|
if (Object.prototype.hasOwnProperty.call(this.settings, i)) {
|
|
653
686
|
const s = this.settings[i];
|
|
654
|
-
if (
|
|
687
|
+
if (L(s))
|
|
655
688
|
e[i] = s.getValues();
|
|
656
689
|
else {
|
|
657
690
|
const n = s;
|
|
@@ -662,7 +695,7 @@ const K = class K {
|
|
|
662
695
|
} else {
|
|
663
696
|
const e = this.settings[t];
|
|
664
697
|
if (!e) return;
|
|
665
|
-
if (
|
|
698
|
+
if (L(e)) return e.getValues();
|
|
666
699
|
const i = e;
|
|
667
700
|
return i.getValue ? i.getValue() : i.value;
|
|
668
701
|
}
|
|
@@ -675,19 +708,19 @@ const K = class K {
|
|
|
675
708
|
for (const s in this.settings)
|
|
676
709
|
if (Object.prototype.hasOwnProperty.call(this.settings, s)) {
|
|
677
710
|
const n = this.settings[s];
|
|
678
|
-
if (
|
|
679
|
-
const
|
|
680
|
-
|
|
711
|
+
if (L(n)) {
|
|
712
|
+
const a = n.getValuesForJson();
|
|
713
|
+
a !== null && (i[s] = a);
|
|
681
714
|
} else {
|
|
682
|
-
const
|
|
683
|
-
|
|
715
|
+
const a = n;
|
|
716
|
+
a.includeGetJson !== !1 && (i[s] = a.value);
|
|
684
717
|
}
|
|
685
718
|
}
|
|
686
719
|
return (this.hide === !0 || ((e = this == null ? void 0 : this.groupProps) == null ? void 0 : e.hide) === !0) && (i.hide = !0), i;
|
|
687
720
|
} else {
|
|
688
721
|
const i = this.settings[t];
|
|
689
722
|
if (!i) return;
|
|
690
|
-
if (
|
|
723
|
+
if (L(i))
|
|
691
724
|
return i.includeGetJson === !1 ? null : i.getValuesForJson();
|
|
692
725
|
{
|
|
693
726
|
const s = i;
|
|
@@ -701,7 +734,7 @@ const K = class K {
|
|
|
701
734
|
for (const i in this.settings)
|
|
702
735
|
if (Object.prototype.hasOwnProperty.call(this.settings, i)) {
|
|
703
736
|
const s = this.settings[i];
|
|
704
|
-
if (
|
|
737
|
+
if (L(s))
|
|
705
738
|
e[i] = s.getDefaultValues();
|
|
706
739
|
else {
|
|
707
740
|
const n = s;
|
|
@@ -712,7 +745,7 @@ const K = class K {
|
|
|
712
745
|
} else {
|
|
713
746
|
const e = this.settings[t];
|
|
714
747
|
if (!e) return;
|
|
715
|
-
if (
|
|
748
|
+
if (L(e)) return e.getDefaultValues();
|
|
716
749
|
const i = e;
|
|
717
750
|
return i.default !== void 0 ? i.default : i.value;
|
|
718
751
|
}
|
|
@@ -731,16 +764,16 @@ const K = class K {
|
|
|
731
764
|
s.textContent = this.title, i.appendChild(s);
|
|
732
765
|
const n = document.createElement("div");
|
|
733
766
|
n.className = "actions-section";
|
|
734
|
-
const
|
|
735
|
-
|
|
767
|
+
const a = document.createElement("span");
|
|
768
|
+
a.className = "setting-group-arrow", a.innerHTML = `
|
|
736
769
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
737
770
|
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
738
771
|
</svg>
|
|
739
|
-
`, this.isCollapsed &&
|
|
740
|
-
const
|
|
741
|
-
|
|
772
|
+
`, this.isCollapsed && a.classList.add("rotated"), n.appendChild(a);
|
|
773
|
+
const o = document.createElement("div");
|
|
774
|
+
o.className = "setting-group-content", this.isCollapsed && (o.classList.add("collapsed"), e.classList.add("collapsed-view"), a.classList.add("rotated"), t.classList.add("collapsed")), this.isMain && o.classList.add("main-content");
|
|
742
775
|
const l = () => {
|
|
743
|
-
this.isCollapsed = !this.isCollapsed,
|
|
776
|
+
this.isCollapsed = !this.isCollapsed, o.classList.toggle("collapsed"), e.classList.toggle("collapsed-view"), a.classList.toggle("rotated"), t.classList.toggle("collapsed", this.isCollapsed), e.setAttribute(
|
|
744
777
|
"aria-expanded",
|
|
745
778
|
(!this.isCollapsed).toString()
|
|
746
779
|
);
|
|
@@ -751,17 +784,17 @@ const K = class K {
|
|
|
751
784
|
for (const p in this.settings)
|
|
752
785
|
if (Object.prototype.hasOwnProperty.call(this.settings, p)) {
|
|
753
786
|
const c = this.settings[p];
|
|
754
|
-
|
|
787
|
+
L(c) && typeof c.setNestingLevel == "function" && c.setNestingLevel(this.nestingLevel + 1);
|
|
755
788
|
const d = c.draw();
|
|
756
|
-
|
|
789
|
+
L(c) && c.deleteItemCfg && this.addDeleteButtonToElement(
|
|
757
790
|
d,
|
|
758
791
|
p,
|
|
759
792
|
c
|
|
760
|
-
),
|
|
793
|
+
), o.appendChild(d);
|
|
761
794
|
}
|
|
762
795
|
} else {
|
|
763
796
|
const p = document.createElement("div");
|
|
764
|
-
p.className = "setting-group-empty", p.textContent = "No settings in this group",
|
|
797
|
+
p.className = "setting-group-empty", p.textContent = "No settings in this group", o.appendChild(p);
|
|
765
798
|
}
|
|
766
799
|
if (this.addItemCfg) {
|
|
767
800
|
const p = document.createElement("button");
|
|
@@ -776,12 +809,12 @@ const K = class K {
|
|
|
776
809
|
d.stopPropagation(), d.preventDefault();
|
|
777
810
|
const u = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), g = this.addItemCfg.createItem(u);
|
|
778
811
|
if (nt(g)) {
|
|
779
|
-
const
|
|
780
|
-
this.addSetting(
|
|
812
|
+
const f = `${this.addItemCfg.keyPrefix}${u}`;
|
|
813
|
+
this.addSetting(f, g);
|
|
781
814
|
}
|
|
782
|
-
}),
|
|
815
|
+
}), o.appendChild(p);
|
|
783
816
|
}
|
|
784
|
-
return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(
|
|
817
|
+
return e.appendChild(i), e.appendChild(n), t.appendChild(e), t.appendChild(o), this.elementRef = t, st.trackElement(t), setTimeout(() => {
|
|
785
818
|
this.updateNestingStyles();
|
|
786
819
|
}, 0), this.pendingBlurHandler && (this.pendingBlurHandler = null), t;
|
|
787
820
|
}
|
|
@@ -812,10 +845,10 @@ const K = class K {
|
|
|
812
845
|
let i = e;
|
|
813
846
|
const s = Object.keys(this.settings), n = Object.keys(e);
|
|
814
847
|
if (!s.some(
|
|
815
|
-
(
|
|
848
|
+
(o) => n.includes(o)
|
|
816
849
|
) && n.length === 1) {
|
|
817
|
-
const
|
|
818
|
-
i = e[
|
|
850
|
+
const o = n[0];
|
|
851
|
+
i = e[o];
|
|
819
852
|
}
|
|
820
853
|
this.setValue(i);
|
|
821
854
|
} catch (e) {
|
|
@@ -862,19 +895,19 @@ class wt extends H {
|
|
|
862
895
|
s.textContent = this.title, i.appendChild(s);
|
|
863
896
|
const n = document.createElement("div");
|
|
864
897
|
n.className = "tabs-header", this.tabsContainer = n;
|
|
865
|
-
const
|
|
866
|
-
if (
|
|
898
|
+
const a = document.createElement("div");
|
|
899
|
+
if (a.className = "tab-content", this.contentContainers = {}, Object.keys(this.settings).forEach((o, l) => {
|
|
867
900
|
const r = document.createElement("button");
|
|
868
|
-
r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id",
|
|
901
|
+
r.className = "tab-button", r.type = "button", r.setAttribute("data-tab-id", o), r.textContent = o, r.addEventListener("click", () => this.switchToTab(o)), n.appendChild(r);
|
|
869
902
|
const p = document.createElement("div");
|
|
870
|
-
p.className = "tab-panel", this.contentContainers[
|
|
871
|
-
const c = this.settings[
|
|
872
|
-
c && (
|
|
903
|
+
p.className = "tab-panel", this.contentContainers[o] = p;
|
|
904
|
+
const c = this.settings[o];
|
|
905
|
+
c && (L(c) && typeof c.setNestingLevel == "function" && c.setNestingLevel(this.getNestingLevel() + 1), p.appendChild(
|
|
873
906
|
c.draw()
|
|
874
|
-
)),
|
|
875
|
-
}), e.appendChild(i), e.appendChild(n), e.appendChild(
|
|
876
|
-
const
|
|
877
|
-
this.activeTabId =
|
|
907
|
+
)), a.appendChild(p), l === 0 && !this.activeTabId && (this.activeTabId = o);
|
|
908
|
+
}), e.appendChild(i), e.appendChild(n), e.appendChild(a), !this.activeTabId) {
|
|
909
|
+
const o = Object.keys(this.settings)[0];
|
|
910
|
+
this.activeTabId = o || "";
|
|
878
911
|
}
|
|
879
912
|
return this.updateTabUI(), t;
|
|
880
913
|
}
|
|
@@ -925,11 +958,11 @@ class N extends Lt {
|
|
|
925
958
|
const e = t.split(",").map((p) => parseInt(p.trim()));
|
|
926
959
|
if (e.length !== 3 || e.some(isNaN))
|
|
927
960
|
return console.warn(`Invalid RGB value "${t}", using default "#000000"`), "#000000";
|
|
928
|
-
const [i, s, n] = e,
|
|
961
|
+
const [i, s, n] = e, a = Math.max(0, Math.min(255, i)), o = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (p) => {
|
|
929
962
|
const c = p.toString(16);
|
|
930
963
|
return c.length === 1 ? "0" + c : c;
|
|
931
964
|
};
|
|
932
|
-
return `#${r(
|
|
965
|
+
return `#${r(a)}${r(o)}${r(l)}`;
|
|
933
966
|
}
|
|
934
967
|
setValue(t) {
|
|
935
968
|
if (t === void 0) {
|
|
@@ -952,12 +985,12 @@ class N extends Lt {
|
|
|
952
985
|
if (t.className = "color-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
953
986
|
const g = document.createElement("div");
|
|
954
987
|
if (g.className = "icon-container", this.props.icon) {
|
|
955
|
-
const
|
|
956
|
-
|
|
988
|
+
const f = document.createElement("span");
|
|
989
|
+
f.className = "input-icon", f.innerHTML = this.props.icon, g.appendChild(f);
|
|
957
990
|
}
|
|
958
991
|
if (this.props.title) {
|
|
959
|
-
const
|
|
960
|
-
|
|
992
|
+
const f = document.createElement("span");
|
|
993
|
+
f.className = "input-label", f.textContent = this.props.title, g.appendChild(f);
|
|
961
994
|
}
|
|
962
995
|
t.appendChild(g);
|
|
963
996
|
}
|
|
@@ -969,50 +1002,50 @@ class N extends Lt {
|
|
|
969
1002
|
s.className = "color-tab active", s.textContent = "Solid";
|
|
970
1003
|
const n = document.createElement("button");
|
|
971
1004
|
n.className = "color-tab", n.textContent = "Global", i.appendChild(s), i.appendChild(n);
|
|
972
|
-
const o = document.createElement("div");
|
|
973
|
-
o.className = "color-content-solid";
|
|
974
1005
|
const a = document.createElement("div");
|
|
975
|
-
a.className = "color-content-
|
|
1006
|
+
a.className = "color-content-solid";
|
|
1007
|
+
const o = document.createElement("div");
|
|
1008
|
+
o.className = "color-content-global", o.style.display = "none", o.style.display = "grid", o.style.gridTemplateColumns = "repeat(auto-fill, minmax(30px, 1fr))", o.style.gap = "8px";
|
|
976
1009
|
const l = () => {
|
|
977
1010
|
try {
|
|
978
|
-
if (console.log("ColorSetting: renderGlobalOptions called"),
|
|
1011
|
+
if (console.log("ColorSetting: renderGlobalOptions called"), o.innerHTML = "", !x) {
|
|
979
1012
|
console.error("ColorSetting: Setting class is undefined");
|
|
980
|
-
const
|
|
981
|
-
|
|
1013
|
+
const f = document.createElement("div");
|
|
1014
|
+
f.textContent = "Error: System error (Setting undefined)", o.appendChild(f);
|
|
982
1015
|
return;
|
|
983
1016
|
}
|
|
984
1017
|
const g = x.GlobalVariables || {};
|
|
985
1018
|
if (console.log("ColorSetting: GlobalVariables:", g), !g || Object.keys(g).length === 0) {
|
|
986
|
-
const
|
|
987
|
-
|
|
1019
|
+
const f = document.createElement("div");
|
|
1020
|
+
f.textContent = "No global colors defined", f.style.gridColumn = "1 / -1", f.style.fontSize = "12px", f.style.color = "#666", o.appendChild(f);
|
|
988
1021
|
return;
|
|
989
1022
|
}
|
|
990
|
-
Object.entries(g).forEach(([
|
|
991
|
-
const
|
|
992
|
-
|
|
993
|
-
var E,
|
|
1023
|
+
Object.entries(g).forEach(([f, m]) => {
|
|
1024
|
+
const v = document.createElement("button");
|
|
1025
|
+
v.className = "global-color-btn", v.title = f, v.style.width = "30px", v.style.height = "30px", v.style.borderRadius = "50%", v.style.border = "1px solid #ddd", v.style.backgroundColor = m, v.style.cursor = "pointer", this.value === `var(--${f})` && (v.style.border = "2px solid #2196f3"), v.addEventListener("click", (C) => {
|
|
1026
|
+
var E, M;
|
|
994
1027
|
C.preventDefault();
|
|
995
|
-
const w = `var(--${
|
|
996
|
-
this.value = w, (E = this.onChange) == null || E.call(this, w), (
|
|
1028
|
+
const w = `var(--${f})`;
|
|
1029
|
+
this.value = w, (E = this.onChange) == null || E.call(this, w), (M = this.detectChange) == null || M.call(this, w), Array.from(o.children).forEach((y) => {
|
|
997
1030
|
y.style.border = "1px solid #ddd";
|
|
998
|
-
}),
|
|
999
|
-
}),
|
|
1031
|
+
}), v.style.border = "2px solid #2196f3", c.style.backgroundColor = m;
|
|
1032
|
+
}), o.appendChild(v);
|
|
1000
1033
|
});
|
|
1001
1034
|
} catch (g) {
|
|
1002
|
-
console.error("ColorSetting: Error in renderGlobalOptions", g),
|
|
1035
|
+
console.error("ColorSetting: Error in renderGlobalOptions", g), o.innerHTML = "Error loading global options";
|
|
1003
1036
|
}
|
|
1004
1037
|
};
|
|
1005
1038
|
l(), s.addEventListener("click", (g) => {
|
|
1006
|
-
g.preventDefault(), s.classList.add("active"), n.classList.remove("active"),
|
|
1039
|
+
g.preventDefault(), s.classList.add("active"), n.classList.remove("active"), a.style.display = "flex", o.style.display = "none", this.value && this.value.startsWith("var(--");
|
|
1007
1040
|
}), n.addEventListener("click", (g) => {
|
|
1008
|
-
g.preventDefault(), n.classList.add("active"), s.classList.remove("active"),
|
|
1041
|
+
g.preventDefault(), n.classList.add("active"), s.classList.remove("active"), a.style.display = "none", o.style.display = "grid", l();
|
|
1009
1042
|
}), this.value && this.value.startsWith("var(--") ? n.click() : s.click();
|
|
1010
1043
|
const r = (g) => {
|
|
1011
|
-
const
|
|
1012
|
-
if (!
|
|
1044
|
+
const f = g.value.trim();
|
|
1045
|
+
if (!f)
|
|
1013
1046
|
return e.classList.remove("error"), !0;
|
|
1014
|
-
const
|
|
1015
|
-
return
|
|
1047
|
+
const v = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(f);
|
|
1048
|
+
return v ? e.classList.remove("error") : e.classList.add("error"), v;
|
|
1016
1049
|
}, p = document.createElement("input");
|
|
1017
1050
|
p.type = "color", p.className = "color-picker", p.value = this.value && !this.value.startsWith("var(--") ? this.value : "#000000", p.setAttribute("aria-label", "Choose color"), p.setAttribute("title", "Click to open color picker"), this.getDataPropsPath() && p.setAttribute("data-test-id", this.getDataPropsPath()), this.colorInputEl = p;
|
|
1018
1051
|
const c = document.createElement("div");
|
|
@@ -1025,21 +1058,21 @@ class N extends Lt {
|
|
|
1025
1058
|
c.style.backgroundColor = d;
|
|
1026
1059
|
const u = document.createElement("input");
|
|
1027
1060
|
return u.type = "text", u.className = "color-text-input", u.value = this.value || "", u.placeholder = "#000000", u.setAttribute("pattern", "#[0-9A-Fa-f]{6}"), u.setAttribute("title", "Enter a hex color value (e.g., #ff0000)"), u.setAttribute("aria-label", "Hex color value"), u.setAttribute("maxlength", "7"), this.getDataPropsPath() && u.setAttribute("data-test-id", `${this.getDataPropsPath()}_text`), this.textInputEl = u, this.textInputEl.addEventListener("input", (g) => {
|
|
1028
|
-
var m,
|
|
1029
|
-
let
|
|
1061
|
+
var m, v;
|
|
1062
|
+
let f = g.target.value.trim();
|
|
1030
1063
|
if (this.textInputEl && r(this.textInputEl)) {
|
|
1031
|
-
const C = N.normalizeColorValue(
|
|
1032
|
-
this.value = C, (m = this.onChange) == null || m.call(this, C), (
|
|
1064
|
+
const C = N.normalizeColorValue(f);
|
|
1065
|
+
this.value = C, (m = this.onChange) == null || m.call(this, C), (v = this.detectChange) == null || v.call(this, C), this.colorInputEl && (this.colorInputEl.value = C), c.style.backgroundColor = C;
|
|
1033
1066
|
}
|
|
1034
1067
|
}), this.colorInputEl.addEventListener("input", (g) => {
|
|
1035
|
-
var
|
|
1036
|
-
const
|
|
1037
|
-
this.value = m, (
|
|
1068
|
+
var v, C;
|
|
1069
|
+
const f = g.target.value, m = N.normalizeColorValue(f);
|
|
1070
|
+
this.value = m, (v = this.onChange) == null || v.call(this, m), (C = this.detectChange) == null || C.call(this, m), this.textInputEl && (this.textInputEl.value = m), c.style.backgroundColor = m, e.classList.remove("error");
|
|
1038
1071
|
}), this.colorInputEl.addEventListener("change", (g) => {
|
|
1039
|
-
var
|
|
1040
|
-
const
|
|
1041
|
-
this.value = m, (
|
|
1042
|
-
}),
|
|
1072
|
+
var v, C;
|
|
1073
|
+
const f = g.target.value, m = N.normalizeColorValue(f);
|
|
1074
|
+
this.value = m, (v = this.onChange) == null || v.call(this, m), (C = this.detectChange) == null || C.call(this, m), this.textInputEl && (this.textInputEl.value = m), c.style.backgroundColor = m;
|
|
1075
|
+
}), a.appendChild(p), a.appendChild(c), a.appendChild(u), e.appendChild(i), e.appendChild(a), e.appendChild(o), t.appendChild(e), this.element = t, t;
|
|
1043
1076
|
}
|
|
1044
1077
|
getElement() {
|
|
1045
1078
|
return this.element;
|
|
@@ -1095,8 +1128,8 @@ class R extends x {
|
|
|
1095
1128
|
}
|
|
1096
1129
|
updateColorPreview() {
|
|
1097
1130
|
if (!this.colorPreviewEl || !this.value) return;
|
|
1098
|
-
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16),
|
|
1099
|
-
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${
|
|
1131
|
+
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16), a = parseInt(i.substring(4, 6), 16);
|
|
1132
|
+
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
1100
1133
|
}
|
|
1101
1134
|
handleColorChange(t) {
|
|
1102
1135
|
const e = this.getOpacityPercent(), i = R.combineColorOpacity(
|
|
@@ -1119,16 +1152,16 @@ class R extends x {
|
|
|
1119
1152
|
draw() {
|
|
1120
1153
|
const t = document.createElement("div");
|
|
1121
1154
|
if (t.className = "color-with-opacity-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
1122
|
-
const
|
|
1123
|
-
if (
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1155
|
+
const a = document.createElement("div");
|
|
1156
|
+
if (a.className = "icon-container", this.props.icon) {
|
|
1157
|
+
const o = document.createElement("span");
|
|
1158
|
+
o.className = "input-icon", o.innerHTML = this.props.icon, a.appendChild(o);
|
|
1126
1159
|
}
|
|
1127
1160
|
if (this.props.title) {
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1161
|
+
const o = document.createElement("span");
|
|
1162
|
+
o.className = "input-label", o.textContent = this.props.title, a.appendChild(o);
|
|
1130
1163
|
}
|
|
1131
|
-
t.appendChild(
|
|
1164
|
+
t.appendChild(a);
|
|
1132
1165
|
}
|
|
1133
1166
|
const e = document.createElement("div");
|
|
1134
1167
|
e.className = "color-with-opacity-input-wrapper", this.colorInputEl = document.createElement("input"), this.colorInputEl.type = "color", this.colorInputEl.className = "color-with-opacity-picker", this.getDataPropsPath() && this.colorInputEl.setAttribute(
|
|
@@ -1137,18 +1170,18 @@ class R extends x {
|
|
|
1137
1170
|
), this.colorPreviewEl = document.createElement("div"), this.colorPreviewEl.className = "color-with-opacity-preview", this.textInputEl = document.createElement("input"), this.textInputEl.type = "text", this.textInputEl.className = "color-with-opacity-text-input", this.textInputEl.placeholder = "#000000FF", this.getDataPropsPath() && this.textInputEl.setAttribute(
|
|
1138
1171
|
"data-test-id",
|
|
1139
1172
|
`${this.getDataPropsPath()}_text`
|
|
1140
|
-
), this.updateInputElements(), this.updateColorPreview(), this.colorInputEl.addEventListener("input", (
|
|
1141
|
-
const
|
|
1142
|
-
this.handleColorChange(
|
|
1143
|
-
}), this.textInputEl.addEventListener("input", (
|
|
1144
|
-
const
|
|
1145
|
-
this.handleTextInput(
|
|
1146
|
-
}), this.textInputEl.addEventListener("blur", (
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1173
|
+
), this.updateInputElements(), this.updateColorPreview(), this.colorInputEl.addEventListener("input", (a) => {
|
|
1174
|
+
const o = a.target;
|
|
1175
|
+
this.handleColorChange(o.value), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview();
|
|
1176
|
+
}), this.textInputEl.addEventListener("input", (a) => {
|
|
1177
|
+
const o = a.target;
|
|
1178
|
+
this.handleTextInput(o.value) ? (this.colorInputEl && (this.colorInputEl.value = this.getRgbColor()), this.updateColorPreview(), e.classList.remove("error")) : o.value.trim() === "" ? e.classList.remove("error") : e.classList.add("error");
|
|
1179
|
+
}), this.textInputEl.addEventListener("blur", (a) => {
|
|
1180
|
+
const o = a.target;
|
|
1181
|
+
o.value.trim() === "" && (o.value = this.value || "#000000FF", e.classList.remove("error"));
|
|
1149
1182
|
}), this.colorPreviewEl.addEventListener("click", () => {
|
|
1150
|
-
var
|
|
1151
|
-
(
|
|
1183
|
+
var a;
|
|
1184
|
+
(a = this.colorInputEl) == null || a.click();
|
|
1152
1185
|
}), e.appendChild(this.colorInputEl), e.appendChild(this.colorPreviewEl), e.appendChild(this.textInputEl);
|
|
1153
1186
|
const i = document.createElement("div");
|
|
1154
1187
|
i.className = "color-with-opacity-opacity-wrapper", this.opacityInputEl = document.createElement("input"), this.opacityInputEl.type = "number", this.opacityInputEl.className = "color-with-opacity-opacity-input", this.opacityInputEl.value = this.getOpacityPercent().toString(), this.opacityInputEl.min = "0", this.opacityInputEl.max = "100", this.opacityInputEl.step = "1", this.opacityInputEl.placeholder = "100", this.getDataPropsPath() && this.opacityInputEl.setAttribute(
|
|
@@ -1156,13 +1189,13 @@ class R extends x {
|
|
|
1156
1189
|
`${this.getDataPropsPath()}_opacity`
|
|
1157
1190
|
);
|
|
1158
1191
|
const s = document.createElement("span");
|
|
1159
|
-
s.className = "color-with-opacity-opacity-suffix", s.textContent = "%", this.opacityInputEl.addEventListener("input", (
|
|
1160
|
-
const
|
|
1192
|
+
s.className = "color-with-opacity-opacity-suffix", s.textContent = "%", this.opacityInputEl.addEventListener("input", (a) => {
|
|
1193
|
+
const o = a.target, l = parseFloat(o.value);
|
|
1161
1194
|
isNaN(l) || (this.handleOpacityChange(l), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview());
|
|
1162
|
-
}), this.opacityInputEl.addEventListener("blur", (
|
|
1163
|
-
const
|
|
1164
|
-
let l = parseFloat(
|
|
1165
|
-
isNaN(l) && (l = this.getOpacityPercent()), l = Math.max(0, Math.min(100, l)),
|
|
1195
|
+
}), this.opacityInputEl.addEventListener("blur", (a) => {
|
|
1196
|
+
const o = a.target;
|
|
1197
|
+
let l = parseFloat(o.value);
|
|
1198
|
+
isNaN(l) && (l = this.getOpacityPercent()), l = Math.max(0, Math.min(100, l)), o.value = l.toString(), this.handleOpacityChange(l), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview();
|
|
1166
1199
|
}), i.appendChild(this.opacityInputEl), i.appendChild(s);
|
|
1167
1200
|
const n = document.createElement("div");
|
|
1168
1201
|
return n.className = "color-with-opacity-controls-wrapper", n.appendChild(e), n.appendChild(i), t.appendChild(n), this.element = t, this.updateInputElements(), this.updateColorPreview(), t;
|
|
@@ -1175,8 +1208,8 @@ class R extends x {
|
|
|
1175
1208
|
}
|
|
1176
1209
|
getRgbaValue() {
|
|
1177
1210
|
if (!this.value) return "rgba(0, 0, 0, 1)";
|
|
1178
|
-
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16),
|
|
1179
|
-
return `rgba(${s}, ${n}, ${
|
|
1211
|
+
const t = this.getRgbColor(), e = this.getOpacityPercent() / 100, i = t.replace("#", ""), s = parseInt(i.substring(0, 2), 16), n = parseInt(i.substring(2, 4), 16), a = parseInt(i.substring(4, 6), 16);
|
|
1212
|
+
return `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
1180
1213
|
}
|
|
1181
1214
|
getColorAndOpacity() {
|
|
1182
1215
|
return {
|
|
@@ -1197,20 +1230,20 @@ class de extends x {
|
|
|
1197
1230
|
if (t.className = "html-setting-wrapper " + (this.props.wrapperClassName || ""), this.props.title || this.props.icon) {
|
|
1198
1231
|
const n = document.createElement("div");
|
|
1199
1232
|
if (n.className = "icon-container", this.props.icon) {
|
|
1200
|
-
const
|
|
1201
|
-
n.appendChild(
|
|
1233
|
+
const a = this.createIcon(this.props.icon);
|
|
1234
|
+
n.appendChild(a);
|
|
1202
1235
|
}
|
|
1203
1236
|
if (this.props.title) {
|
|
1204
|
-
const
|
|
1205
|
-
n.appendChild(
|
|
1237
|
+
const a = this.createLabel(this.props.title);
|
|
1238
|
+
n.appendChild(a);
|
|
1206
1239
|
}
|
|
1207
1240
|
t.appendChild(n);
|
|
1208
1241
|
}
|
|
1209
1242
|
const e = document.createElement("textarea");
|
|
1210
1243
|
this.textareaEl = e, e.value = this.value || "", e.placeholder = this.props.placeholder || "Paste your HTML here...", e.className = "html-setting-textarea " + (this.props.textareaClassName || ""), e.rows = this.props.rows || 6, this.getDataPropsPath() && e.setAttribute("data-test-id", this.getDataPropsPath()), this.props.maxLength !== void 0 && (e.maxLength = this.props.maxLength), this.props.className && e.classList.add(this.props.className);
|
|
1211
1244
|
const i = (n) => {
|
|
1212
|
-
const
|
|
1213
|
-
this.value =
|
|
1245
|
+
const o = n.target.value;
|
|
1246
|
+
this.value = o, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
|
|
1214
1247
|
}, s = (n) => {
|
|
1215
1248
|
this.onBlur && this.value !== void 0 && this.onBlur(this.value);
|
|
1216
1249
|
};
|
|
@@ -1240,12 +1273,12 @@ class V extends x {
|
|
|
1240
1273
|
const i = document.createElement("input");
|
|
1241
1274
|
if (i.type = "number", i.className = "number-setting-input " + (this.props.inputClassName || ""), i.value = String(this.value ?? ""), i.placeholder = this.props.placeholder || "", this.getDataPropsPath() && i.setAttribute("data-test-id", this.getDataPropsPath()), this.props.minValue !== void 0 && (i.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (i.max = String(this.props.maxValue)), this.props.step !== void 0 && (i.step = String(this.props.step)), i.addEventListener("input", () => {
|
|
1242
1275
|
const s = this.props.minValue ?? Number.MIN_SAFE_INTEGER, n = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
1243
|
-
let
|
|
1244
|
-
|
|
1276
|
+
let a = Number(i.value);
|
|
1277
|
+
a < s && (a = s), a > n && (a = n), String(a) !== i.value && (i.value = String(a)), this.setValue(a);
|
|
1245
1278
|
}), i.addEventListener("blur", () => {
|
|
1246
|
-
var n,
|
|
1279
|
+
var n, a;
|
|
1247
1280
|
const s = this.validateValue(Number(i.value));
|
|
1248
|
-
s !== Number(i.value) && (i.value = String(s), this.setValue(s)), (
|
|
1281
|
+
s !== Number(i.value) && (i.value = String(s), this.setValue(s)), (a = (n = this.props).onBlur) == null || a.call(n);
|
|
1249
1282
|
}), e.appendChild(i), this.props.suffix && this.props.suffix !== "none") {
|
|
1250
1283
|
const s = document.createElement("span");
|
|
1251
1284
|
s.className = "suffix-label", s.textContent = this.props.suffix, e.appendChild(s);
|
|
@@ -1328,12 +1361,12 @@ class tt extends x {
|
|
|
1328
1361
|
if (t.classList.add("select-container"), this.container = t, this.props.icon || this.props.title) {
|
|
1329
1362
|
const n = document.createElement("div");
|
|
1330
1363
|
if (n.className = "icon-container", this.props.icon) {
|
|
1331
|
-
const
|
|
1332
|
-
n.appendChild(
|
|
1364
|
+
const a = this.createIcon(this.props.icon);
|
|
1365
|
+
n.appendChild(a);
|
|
1333
1366
|
}
|
|
1334
1367
|
if (this.props.title) {
|
|
1335
|
-
const
|
|
1336
|
-
n.appendChild(
|
|
1368
|
+
const a = this.createLabel(this.props.title);
|
|
1369
|
+
n.appendChild(a);
|
|
1337
1370
|
}
|
|
1338
1371
|
t.appendChild(n);
|
|
1339
1372
|
} else {
|
|
@@ -1342,13 +1375,13 @@ class tt extends x {
|
|
|
1342
1375
|
}
|
|
1343
1376
|
const e = document.createElement("div");
|
|
1344
1377
|
e.classList.add("select-button"), this.getDataPropsPath() && e.setAttribute("data-test-id", this.getDataPropsPath()), this.isLoading ? e.classList.add("loading") : e.textContent = this.selectedOptionIndex !== null ? this._options[this.selectedOptionIndex].name : this.props.placeholder || "Select an option", e.onclick = () => {
|
|
1345
|
-
var n,
|
|
1346
|
-
this.isLoading || (this.isOpen = !this.isOpen, this.isOpen ? this.checkDropdownPosition() : this.cleanupDropdownPosition(), (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1378
|
+
var n, a;
|
|
1379
|
+
this.isLoading || (this.isOpen = !this.isOpen, this.isOpen ? this.checkDropdownPosition() : this.cleanupDropdownPosition(), (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (a = this.svgContainer) == null || a.classList.toggle("open", this.isOpen));
|
|
1347
1380
|
}, t.appendChild(e), this.buttonEl = e;
|
|
1348
1381
|
const i = document.createElement("ul");
|
|
1349
|
-
i.classList.add("select-options"), this._options.forEach((n,
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1382
|
+
i.classList.add("select-options"), this._options.forEach((n, a) => {
|
|
1383
|
+
const o = this.createOption(n, a);
|
|
1384
|
+
o.onclick = (l) => this.selectOption(l, a, e), i.appendChild(o);
|
|
1352
1385
|
}), document.body.appendChild(i);
|
|
1353
1386
|
const s = document.createElement("div");
|
|
1354
1387
|
return s.classList.add("svg-container"), s.innerHTML = It, t.appendChild(s), this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
@@ -1356,8 +1389,8 @@ class tt extends x {
|
|
|
1356
1389
|
}).catch((n) => {
|
|
1357
1390
|
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText("Failed to load options");
|
|
1358
1391
|
})), this.clickOutsideListener && document.removeEventListener("click", this.clickOutsideListener), this.clickOutsideListener = (n) => {
|
|
1359
|
-
var
|
|
1360
|
-
this.isOpen && !t.contains(n.target) && (this.isOpen = !1, (
|
|
1392
|
+
var a, o;
|
|
1393
|
+
this.isOpen && !t.contains(n.target) && (this.isOpen = !1, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.cleanupDropdownPosition());
|
|
1361
1394
|
}, document.addEventListener("click", this.clickOutsideListener), this.resizeListener && window.removeEventListener("resize", this.resizeListener), this.resizeListener = () => {
|
|
1362
1395
|
this.isOpen && this.checkDropdownPosition();
|
|
1363
1396
|
}, window.addEventListener("resize", this.resizeListener), t;
|
|
@@ -1376,9 +1409,9 @@ class tt extends x {
|
|
|
1376
1409
|
}
|
|
1377
1410
|
}
|
|
1378
1411
|
selectOption(t, e, i) {
|
|
1379
|
-
var n,
|
|
1412
|
+
var n, a;
|
|
1380
1413
|
const s = this._options[e];
|
|
1381
|
-
s && (this.setValue(s.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (n = this.optionsListEl) == null || n.classList.remove("open"), (
|
|
1414
|
+
s && (this.setValue(s.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (n = this.optionsListEl) == null || n.classList.remove("open"), (a = this.svgContainer) == null || a.classList.remove("open"), this.cleanupDropdownPosition(), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((l, r) => {
|
|
1382
1415
|
r === e ? l.classList.add("selected") : l.classList.remove("selected");
|
|
1383
1416
|
}));
|
|
1384
1417
|
}
|
|
@@ -1459,14 +1492,14 @@ class Vt extends x {
|
|
|
1459
1492
|
`
|
|
1460
1493
|
}
|
|
1461
1494
|
].forEach((n) => {
|
|
1462
|
-
const
|
|
1463
|
-
|
|
1495
|
+
const a = document.createElement("button");
|
|
1496
|
+
a.className = "align-option-button", a.innerHTML = n.icon, this.getDataPropsPath() && a.setAttribute(
|
|
1464
1497
|
"data-test-id",
|
|
1465
1498
|
`${this.getDataPropsPath()}_${n.name}`
|
|
1466
|
-
), this.value === n.name &&
|
|
1467
|
-
var
|
|
1468
|
-
i.querySelectorAll(".align-option-button").forEach((l) => l.classList.remove("selected")),
|
|
1469
|
-
}), i.appendChild(
|
|
1499
|
+
), this.value === n.name && a.classList.add("selected"), a.addEventListener("click", () => {
|
|
1500
|
+
var o;
|
|
1501
|
+
i.querySelectorAll(".align-option-button").forEach((l) => l.classList.remove("selected")), a.classList.add("selected"), this.value = n.name, (o = this.onChange) == null || o.call(this, this.value);
|
|
1502
|
+
}), i.appendChild(a);
|
|
1470
1503
|
}), t.appendChild(i), t;
|
|
1471
1504
|
}
|
|
1472
1505
|
}
|
|
@@ -1484,19 +1517,19 @@ class pe extends x {
|
|
|
1484
1517
|
/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i
|
|
1485
1518
|
);
|
|
1486
1519
|
if (n) {
|
|
1487
|
-
let
|
|
1488
|
-
p >= 1 ? (
|
|
1520
|
+
let o = +n[1], l = +n[2], r = +n[3], p = +n[4];
|
|
1521
|
+
p >= 1 ? (o = Math.round(o * 0.9), l = Math.round(l * 0.9), r = Math.round(r * 0.9)) : p = Math.min(1, p + 0.12), s = `rgba(${o},${l},${r},${p})`;
|
|
1489
1522
|
}
|
|
1490
1523
|
t.addEventListener("mouseenter", () => {
|
|
1491
1524
|
console.log("hoverBg", s), t.style.setProperty("background-color", s, "important");
|
|
1492
1525
|
}), t.addEventListener("mouseleave", () => {
|
|
1493
1526
|
t.style.setProperty("background-color", e, "important");
|
|
1494
1527
|
}), t.addEventListener("click", () => {
|
|
1495
|
-
var
|
|
1496
|
-
return (l = (
|
|
1528
|
+
var o, l;
|
|
1529
|
+
return (l = (o = this.props).onClick) == null ? void 0 : l.call(o);
|
|
1497
1530
|
});
|
|
1498
|
-
const
|
|
1499
|
-
return
|
|
1531
|
+
const a = document.createElement("div");
|
|
1532
|
+
return a.className = "button-setting-wrapper " + (this.props.wrapperClassName || ""), a.appendChild(t), a;
|
|
1500
1533
|
}
|
|
1501
1534
|
}
|
|
1502
1535
|
class ue extends x {
|
|
@@ -1589,8 +1622,8 @@ class ue extends x {
|
|
|
1589
1622
|
return n.className = "dimension-lock-icon", n.setAttribute("type", "button"), n.setAttribute("aria-pressed", String(this.locked)), n.setAttribute(
|
|
1590
1623
|
"aria-label",
|
|
1591
1624
|
this.locked ? "Unlock aspect ratio" : "Lock aspect ratio"
|
|
1592
|
-
), n.title = this.locked ? "Unlock aspect ratio" : "Lock aspect ratio", n.innerHTML = this.getLockSVG(this.locked), n.onclick = (
|
|
1593
|
-
|
|
1625
|
+
), n.title = this.locked ? "Unlock aspect ratio" : "Lock aspect ratio", n.innerHTML = this.getLockSVG(this.locked), n.onclick = (a) => {
|
|
1626
|
+
a.preventDefault(), this.toggleLock(n);
|
|
1594
1627
|
}, s.appendChild(n), t.appendChild(e), t.appendChild(s), t.appendChild(i), t;
|
|
1595
1628
|
}
|
|
1596
1629
|
isLocked() {
|
|
@@ -1707,11 +1740,11 @@ class ct extends x {
|
|
|
1707
1740
|
<span class="upload-label">Replace</span>
|
|
1708
1741
|
`);
|
|
1709
1742
|
const n = () => {
|
|
1710
|
-
this.hideLoading(), this.previewWrapper.classList.add("has-image"), this.previewEl.style.display = "block", this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error",
|
|
1711
|
-
},
|
|
1712
|
-
this.hideLoading(), this.showError("Failed to load image. Please try again."), this.previewWrapper.classList.remove("has-image"), this.previewEl.style.display = "none", this.previewWrapper.style.display = "none", s && s instanceof HTMLElement && (s.style.display = "block"), e && e.classList.add("no-image"), this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error",
|
|
1743
|
+
this.hideLoading(), this.previewWrapper.classList.add("has-image"), this.previewEl.style.display = "block", this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error", a);
|
|
1744
|
+
}, a = () => {
|
|
1745
|
+
this.hideLoading(), this.showError("Failed to load image. Please try again."), this.previewWrapper.classList.remove("has-image"), this.previewEl.style.display = "none", this.previewWrapper.style.display = "none", s && s instanceof HTMLElement && (s.style.display = "block"), e && e.classList.add("no-image"), this.previewEl.removeEventListener("load", n), this.previewEl.removeEventListener("error", a);
|
|
1713
1746
|
};
|
|
1714
|
-
this.previewEl.addEventListener("load", n), this.previewEl.addEventListener("error",
|
|
1747
|
+
this.previewEl.addEventListener("load", n), this.previewEl.addEventListener("error", a), this.previewEl.src = t;
|
|
1715
1748
|
} else
|
|
1716
1749
|
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 = `
|
|
1717
1750
|
<span class="upload-icon">${Y}</span>
|
|
@@ -1722,24 +1755,24 @@ class ct extends x {
|
|
|
1722
1755
|
const t = document.createElement("div");
|
|
1723
1756
|
t.className = "upload-setting-wrapper", t.setAttribute("data-setting-id", this.id), t.addEventListener(
|
|
1724
1757
|
"focusout",
|
|
1725
|
-
(
|
|
1758
|
+
(o) => {
|
|
1726
1759
|
var l;
|
|
1727
|
-
|
|
1760
|
+
o.relatedTarget && t.contains(o.relatedTarget) || (l = this.onBlur) == null || l.call(this, this.value ?? "");
|
|
1728
1761
|
},
|
|
1729
1762
|
!0
|
|
1730
1763
|
);
|
|
1731
1764
|
const e = !!(this.props.title || this.props.icon);
|
|
1732
1765
|
if (e || t.classList.add("no-label"), e) {
|
|
1733
|
-
const
|
|
1734
|
-
if (
|
|
1766
|
+
const o = document.createElement("div");
|
|
1767
|
+
if (o.className = "icon-title-container", this.props.icon) {
|
|
1735
1768
|
const l = this.createIcon(this.props.icon);
|
|
1736
|
-
|
|
1769
|
+
o.appendChild(l);
|
|
1737
1770
|
}
|
|
1738
1771
|
if (this.props.title) {
|
|
1739
1772
|
const l = this.createLabel(this.props.title);
|
|
1740
|
-
|
|
1773
|
+
o.appendChild(l);
|
|
1741
1774
|
}
|
|
1742
|
-
t.appendChild(
|
|
1775
|
+
t.appendChild(o);
|
|
1743
1776
|
}
|
|
1744
1777
|
this.errorContainer = document.createElement("div"), this.errorContainer.className = "error-message", this.errorContainer.style.display = "none", t.appendChild(this.errorContainer);
|
|
1745
1778
|
const i = document.createElement("div");
|
|
@@ -1748,18 +1781,18 @@ class ct extends x {
|
|
|
1748
1781
|
s || i.classList.add("no-image");
|
|
1749
1782
|
const n = document.createElement("div");
|
|
1750
1783
|
if (n.className = "preview-placeholder", n.innerHTML = Ot, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.loadingSpinner = document.createElement("div"), this.loadingSpinner.className = "loading-spinner", this.loadingSpinner.innerHTML = $t, this.loadingSpinner.style.display = "none", this.previewWrapper.appendChild(this.loadingSpinner), this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
|
|
1751
|
-
const
|
|
1752
|
-
|
|
1784
|
+
const o = document.createElement("button");
|
|
1785
|
+
o.className = "delete-button", o.type = "button", o.title = "Delete image", o.innerHTML = Ht, this.previewWrapper.appendChild(o), o.onclick = (l) => {
|
|
1753
1786
|
var r;
|
|
1754
1787
|
l.stopPropagation(), this.value = "", this.updatePreviewState(null), (r = this.onChange) == null || r.call(this, ""), this.hideError();
|
|
1755
1788
|
};
|
|
1756
1789
|
}
|
|
1757
1790
|
this.previewWrapper.appendChild(this.previewEl);
|
|
1758
|
-
const
|
|
1759
|
-
return
|
|
1791
|
+
const a = document.createElement("button");
|
|
1792
|
+
return a.className = "upload-button", this.getDataPropsPath() && a.setAttribute("data-test-id", this.getDataPropsPath()), a.innerHTML = `
|
|
1760
1793
|
<span class="upload-icon">${Y}</span>
|
|
1761
1794
|
<span class="upload-label">Upload</span>
|
|
1762
|
-
`, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(
|
|
1795
|
+
`, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(a), t.appendChild(i), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), a.onclick = () => {
|
|
1763
1796
|
window.postMessage(
|
|
1764
1797
|
{
|
|
1765
1798
|
type: "OPEN_FILE_MANAGER_MODAL",
|
|
@@ -1816,7 +1849,7 @@ const Bt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewB
|
|
|
1816
1849
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
1817
1850
|
</svg>
|
|
1818
1851
|
`;
|
|
1819
|
-
class
|
|
1852
|
+
class fe extends x {
|
|
1820
1853
|
constructor(t = {}) {
|
|
1821
1854
|
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.hasInitializedOptions = !1, this.selectedOptionIndex = null, t.default !== void 0 && (this.value = t.default), this.initializeOptions(t), !t.getOptionsAsync && this.value !== void 0) {
|
|
1822
1855
|
const e = this._options.findIndex(
|
|
@@ -1843,44 +1876,44 @@ class ve extends x {
|
|
|
1843
1876
|
e.classList.add("has-label");
|
|
1844
1877
|
const n = document.createElement("div");
|
|
1845
1878
|
n.className = "select-label", n.textContent = this.props.title, e.appendChild(n);
|
|
1846
|
-
const
|
|
1847
|
-
if (
|
|
1848
|
-
|
|
1879
|
+
const a = document.createElement("span");
|
|
1880
|
+
if (a.className = "select-value", this.isLoading)
|
|
1881
|
+
a.textContent = this.props.loadingText || "Loading options...";
|
|
1849
1882
|
else {
|
|
1850
|
-
const
|
|
1851
|
-
|
|
1883
|
+
const o = this.selectedOptionIndex !== null && this._options && this.selectedOptionIndex >= 0 && this.selectedOptionIndex < this._options.length ? this._options[this.selectedOptionIndex] : null, l = o && typeof o.name == "string" ? o.name : "Select an option";
|
|
1884
|
+
a.textContent = l;
|
|
1852
1885
|
}
|
|
1853
|
-
e.appendChild(
|
|
1886
|
+
e.appendChild(a);
|
|
1854
1887
|
} else {
|
|
1855
1888
|
const n = document.createElement("span");
|
|
1856
1889
|
if (this.isLoading)
|
|
1857
1890
|
n.textContent = this.props.loadingText || "Loading options...";
|
|
1858
1891
|
else {
|
|
1859
|
-
const
|
|
1860
|
-
n.textContent =
|
|
1892
|
+
const a = this.selectedOptionIndex !== null && this._options && this.selectedOptionIndex >= 0 && this.selectedOptionIndex < this._options.length ? this._options[this.selectedOptionIndex] : null, o = a && typeof a.name == "string" ? a.name : "Select an option";
|
|
1893
|
+
n.textContent = o;
|
|
1861
1894
|
}
|
|
1862
1895
|
e.appendChild(n);
|
|
1863
1896
|
}
|
|
1864
1897
|
e.onclick = () => {
|
|
1865
|
-
var n,
|
|
1866
|
-
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1898
|
+
var n, a;
|
|
1899
|
+
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (a = this.svgContainer) == null || a.classList.toggle("open", this.isOpen));
|
|
1867
1900
|
}, t.appendChild(e), this.buttonEl = e;
|
|
1868
1901
|
const i = document.createElement("ul");
|
|
1869
|
-
i.classList.add("select-api-options"), this._options.forEach((n,
|
|
1870
|
-
const
|
|
1871
|
-
|
|
1902
|
+
i.classList.add("select-api-options"), this._options.forEach((n, a) => {
|
|
1903
|
+
const o = this.createOption(n, a);
|
|
1904
|
+
o.onclick = (l) => this.selectApiOption(l, a, e), i.appendChild(o);
|
|
1872
1905
|
}), t.appendChild(i);
|
|
1873
1906
|
const s = document.createElement("div");
|
|
1874
1907
|
return s.classList.add("svg-container"), s.innerHTML = Dt, t.appendChild(s), s.onclick = () => {
|
|
1875
|
-
var n,
|
|
1876
|
-
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (
|
|
1908
|
+
var n, a;
|
|
1909
|
+
this.isLoading || (this.isOpen = !this.isOpen, (n = this.optionsListEl) == null || n.classList.toggle("open", this.isOpen), (a = this.svgContainer) == null || a.classList.toggle("open", this.isOpen));
|
|
1877
1910
|
}, this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && !this.hasInitializedOptions ? (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
1878
|
-
const
|
|
1911
|
+
const a = new Set(
|
|
1879
1912
|
this._options.map((l) => JSON.stringify(l.value))
|
|
1880
|
-
),
|
|
1881
|
-
(l) => !
|
|
1913
|
+
), o = n.filter(
|
|
1914
|
+
(l) => !a.has(JSON.stringify(l.value))
|
|
1882
1915
|
);
|
|
1883
|
-
if (this._options.push(...
|
|
1916
|
+
if (this._options.push(...o), this.isLoading = !1, this.hasInitializedOptions = !0, this.value !== void 0) {
|
|
1884
1917
|
const l = this._options.findIndex(
|
|
1885
1918
|
(r) => JSON.stringify(r.value) === JSON.stringify(this.value)
|
|
1886
1919
|
);
|
|
@@ -1894,12 +1927,12 @@ class ve extends x {
|
|
|
1894
1927
|
!0
|
|
1895
1928
|
);
|
|
1896
1929
|
})) : this.props.getOptionsAsync && this._options.length <= 1 && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
1897
|
-
const
|
|
1930
|
+
const a = new Set(
|
|
1898
1931
|
this._options.map((l) => JSON.stringify(l.value))
|
|
1899
|
-
),
|
|
1900
|
-
(l) => !
|
|
1932
|
+
), o = n.filter(
|
|
1933
|
+
(l) => !a.has(JSON.stringify(l.value))
|
|
1901
1934
|
);
|
|
1902
|
-
if (this._options.push(...
|
|
1935
|
+
if (this._options.push(...o), this.isLoading = !1, this.value !== void 0) {
|
|
1903
1936
|
const l = this._options.findIndex(
|
|
1904
1937
|
(r) => JSON.stringify(r.value) === JSON.stringify(this.value)
|
|
1905
1938
|
);
|
|
@@ -1918,19 +1951,11 @@ class ve extends x {
|
|
|
1918
1951
|
return JSON.stringify(t ? {} : { value: this.value }, null, 2);
|
|
1919
1952
|
}
|
|
1920
1953
|
selectApiOption(t, e, i) {
|
|
1921
|
-
var l, r
|
|
1922
|
-
const s = t.target, n = s.querySelector(".select-api-radio") || ((
|
|
1923
|
-
n && (n.checked = !0)
|
|
1924
|
-
const
|
|
1925
|
-
this.
|
|
1926
|
-
const a = i.querySelector(".select-value");
|
|
1927
|
-
if (a)
|
|
1928
|
-
a.textContent = this._options[e].name;
|
|
1929
|
-
else {
|
|
1930
|
-
const d = i.firstChild;
|
|
1931
|
-
d && d.tagName === "SPAN" && (d.textContent = this._options[e].name);
|
|
1932
|
-
}
|
|
1933
|
-
this.isOpen = !1, (r = this.optionsListEl) == null || r.classList.remove("open"), (p = this.svgContainer) == null || p.classList.remove("open"), (c = this.onChange) == null || c.call(this, o), this.detectChangeCallback && this.detectChangeCallback(o);
|
|
1954
|
+
var o, l, r;
|
|
1955
|
+
const s = t.target, n = s.querySelector(".select-api-radio") || ((o = s.closest(".select-api-option")) == null ? void 0 : o.querySelector(".select-api-radio"));
|
|
1956
|
+
n && (n.checked = !0);
|
|
1957
|
+
const a = this._options[e].value;
|
|
1958
|
+
this.setValue(a), this.isOpen = !1, (l = this.optionsListEl) == null || l.classList.remove("open"), (r = this.svgContainer) == null || r.classList.remove("open");
|
|
1934
1959
|
}
|
|
1935
1960
|
updateOptionsList() {
|
|
1936
1961
|
!this.optionsListEl || !this.buttonEl || (this.optionsListEl.innerHTML = "", this._options.forEach((t, e) => {
|
|
@@ -1954,22 +1979,32 @@ class ve extends x {
|
|
|
1954
1979
|
i.textContent = t || n, this.buttonEl.classList.remove("error"), this.buttonEl.removeAttribute("disabled"), this.svgContainer && (this.svgContainer.style.display = "");
|
|
1955
1980
|
}
|
|
1956
1981
|
}
|
|
1982
|
+
update(t = !1) {
|
|
1983
|
+
var e;
|
|
1984
|
+
if (this.selectedOptionIndex = this.value !== void 0 ? this._options.findIndex(
|
|
1985
|
+
(i) => JSON.stringify(i.value) === JSON.stringify(this.value)
|
|
1986
|
+
) : null, this.updateOptionsList(), this.updateButtonText(), t && this.value !== void 0) {
|
|
1987
|
+
(e = this.onChange) == null || e.call(this, this.value);
|
|
1988
|
+
const i = this.props.detectChange || this.detectChangeCallback;
|
|
1989
|
+
i == null || i(this.value);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1957
1992
|
setDetectChange(t) {
|
|
1958
|
-
this.detectChangeCallback = t;
|
|
1993
|
+
this.detectChangeCallback = t, this.props.detectChange = t;
|
|
1959
1994
|
}
|
|
1960
1995
|
setValue(t) {
|
|
1961
|
-
|
|
1996
|
+
super.setValue(t), this.selectedOptionIndex = this._options.findIndex(
|
|
1962
1997
|
(e) => JSON.stringify(e.value) === JSON.stringify(t)
|
|
1963
|
-
), this.updateButtonText();
|
|
1998
|
+
), this.updateButtonText(), this.updateOptionsList(), this.detectChangeCallback && this.detectChangeCallback !== this.props.detectChange && this.detectChangeCallback(t);
|
|
1964
1999
|
}
|
|
1965
2000
|
}
|
|
1966
|
-
class
|
|
2001
|
+
class ve extends x {
|
|
1967
2002
|
constructor(t) {
|
|
1968
2003
|
var e, i;
|
|
1969
2004
|
super(t), this.inputType = "text", this.value = t.default ?? ((i = (e = t.options) == null ? void 0 : e[0]) == null ? void 0 : i.value) ?? "", this.detectChangeCallback = t.detectChange;
|
|
1970
2005
|
}
|
|
1971
2006
|
draw() {
|
|
1972
|
-
var
|
|
2007
|
+
var a, o;
|
|
1973
2008
|
const t = document.createElement("div");
|
|
1974
2009
|
t.className = "toggle-setting-container", this.props.icon && t.classList.add("toggle-with-icon");
|
|
1975
2010
|
const e = document.createElement("div");
|
|
@@ -1985,7 +2020,7 @@ class fe extends x {
|
|
|
1985
2020
|
const i = document.createElement("label");
|
|
1986
2021
|
i.className = "toggle-switch";
|
|
1987
2022
|
const s = document.createElement("input");
|
|
1988
|
-
s.type = "checkbox", s.checked = ((
|
|
2023
|
+
s.type = "checkbox", s.checked = ((o = (a = this.props.options) == null ? void 0 : a.find((l) => l.value === this.value)) == null ? void 0 : o.status) ?? !1, this.getDataPropsPath() && s.setAttribute("data-test-id", this.getDataPropsPath()), s.addEventListener("change", () => {
|
|
1989
2024
|
var r, p;
|
|
1990
2025
|
const l = ((p = (r = this.props.options) == null ? void 0 : r.find((c) => c.status === s.checked)) == null ? void 0 : p.value) ?? "";
|
|
1991
2026
|
this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
|
|
@@ -2030,27 +2065,27 @@ class Ce extends x {
|
|
|
2030
2065
|
i.className = "setting-label", i.setAttribute("for", this.id + "-input");
|
|
2031
2066
|
const s = document.createElement("span");
|
|
2032
2067
|
if (s.textContent = this.props.title ?? "Gap", i.appendChild(s), this.props.icon) {
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2068
|
+
const o = document.createElement("span");
|
|
2069
|
+
o.className = "setting-icon", o.innerHTML = this.props.icon, i.insertBefore(o, s);
|
|
2035
2070
|
}
|
|
2036
2071
|
const n = document.createElement("div");
|
|
2037
2072
|
n.className = `setting-input-wrapper ${this.props.wrapperClassName || ""}`, n.classList.add("gap-setting-wrapper");
|
|
2038
|
-
const
|
|
2039
|
-
return
|
|
2073
|
+
const a = document.createElement("div");
|
|
2074
|
+
return a.className = "gap-inputs-container", this.props.rowGap && a.appendChild(this.createGapInput("row", "Row")), this.props.columnGap && a.appendChild(this.createGapInput("column", "Col")), n.appendChild(a), e.appendChild(i), e.appendChild(n), t.appendChild(e), t;
|
|
2040
2075
|
}
|
|
2041
2076
|
createGapInput(t, e) {
|
|
2042
2077
|
const i = document.createElement("div");
|
|
2043
2078
|
i.className = "gap-input-wrapper";
|
|
2044
2079
|
const s = document.createElement("input");
|
|
2045
2080
|
if (s.type = "number", s.className = `gap-input gap-${t}-input ${this.props.inputClassName || ""}`, s.id = `${this.id}-${t}-input`, s.min = String(this.props.minValue ?? 0), this.props.maxValue !== void 0 && (s.max = String(this.props.maxValue)), s.step = String(this.props.step ?? 1), s.value = String(this.inputValues[t] ?? this.value), s.title = e, this.getDataPropsPath() && s.setAttribute("data-test-id", `${this.getDataPropsPath()}_${t}`), s.addEventListener("input", (n) => {
|
|
2046
|
-
const
|
|
2047
|
-
let
|
|
2048
|
-
|
|
2081
|
+
const a = n.target;
|
|
2082
|
+
let o = parseFloat(a.value);
|
|
2083
|
+
o = this.validateValue(o), String(o) !== a.value && (a.value = String(o)), this.inputValues[t] = o, this.setValue(o);
|
|
2049
2084
|
}), s.addEventListener("blur", (n) => {
|
|
2050
2085
|
var l, r;
|
|
2051
|
-
const
|
|
2052
|
-
let
|
|
2053
|
-
|
|
2086
|
+
const a = n.target;
|
|
2087
|
+
let o = parseFloat(a.value);
|
|
2088
|
+
o = this.validateValue(o), String(o) !== a.value && (a.value = String(o), this.inputValues[t] = o, this.setValue(o)), (r = (l = this.props).onBlur) == null || r.call(l);
|
|
2054
2089
|
}), i.appendChild(s), this.props.suffix && this.props.suffix !== "none") {
|
|
2055
2090
|
const n = document.createElement("span");
|
|
2056
2091
|
n.className = "gap-suffix", n.textContent = this.props.suffix, i.appendChild(n), s.style.paddingRight = "30px";
|
|
@@ -2123,9 +2158,9 @@ class Ee extends x {
|
|
|
2123
2158
|
return i.font = s, i.measureText(t).width;
|
|
2124
2159
|
}
|
|
2125
2160
|
adaptPlaceholderToSingleLine(t, e) {
|
|
2126
|
-
const i = window.getComputedStyle(t), s = parseFloat(i.paddingLeft) || 0, n = parseFloat(i.paddingRight) || 0,
|
|
2161
|
+
const i = window.getComputedStyle(t), s = parseFloat(i.paddingLeft) || 0, n = parseFloat(i.paddingRight) || 0, a = parseFloat(i.borderLeftWidth) || 0, o = parseFloat(i.borderRightWidth) || 0, l = Math.max(
|
|
2127
2162
|
0,
|
|
2128
|
-
t.clientWidth - s - n -
|
|
2163
|
+
t.clientWidth - s - n - a - o
|
|
2129
2164
|
);
|
|
2130
2165
|
if (l <= 0) {
|
|
2131
2166
|
t.placeholder = e;
|
|
@@ -2138,16 +2173,16 @@ class Ee extends x {
|
|
|
2138
2173
|
const p = "...";
|
|
2139
2174
|
let c = 0, d = e.length, u = 0;
|
|
2140
2175
|
for (; c <= d; ) {
|
|
2141
|
-
const
|
|
2142
|
-
this.measureTextWidth(m, i) <= l ? (u =
|
|
2176
|
+
const f = Math.floor((c + d) / 2), m = e.slice(0, f).trimEnd() + p;
|
|
2177
|
+
this.measureTextWidth(m, i) <= l ? (u = f, c = f + 1) : d = f - 1;
|
|
2143
2178
|
}
|
|
2144
2179
|
const g = e.slice(0, u).trimEnd() + p;
|
|
2145
2180
|
t.placeholder = g;
|
|
2146
2181
|
}
|
|
2147
2182
|
autosizeTextarea(t, e = 3) {
|
|
2148
2183
|
t.style.height = "auto";
|
|
2149
|
-
const i = window.getComputedStyle(t), s = parseFloat(i.lineHeight) || 20, n = parseFloat(i.paddingTop) + parseFloat(i.paddingBottom),
|
|
2150
|
-
t.style.height = `${l}px`, t.scrollHeight >
|
|
2184
|
+
const i = window.getComputedStyle(t), s = parseFloat(i.lineHeight) || 20, n = parseFloat(i.paddingTop) + parseFloat(i.paddingBottom), a = parseFloat(i.borderTopWidth) + parseFloat(i.borderBottomWidth), o = s * e + n + a, l = Math.min(t.scrollHeight || 44, o);
|
|
2185
|
+
t.style.height = `${l}px`, t.scrollHeight > o ? t.style.overflowY = "auto" : t.style.overflowY = "hidden";
|
|
2151
2186
|
}
|
|
2152
2187
|
createTextareaRow(t, e) {
|
|
2153
2188
|
const i = document.createElement("div");
|
|
@@ -2159,19 +2194,19 @@ class Ee extends x {
|
|
|
2159
2194
|
title: "",
|
|
2160
2195
|
id: `${this.id}_upload_${t}`
|
|
2161
2196
|
});
|
|
2162
|
-
n.setOnChange((
|
|
2163
|
-
this.updateLanguageValue(t,
|
|
2197
|
+
n.setOnChange((o) => {
|
|
2198
|
+
this.updateLanguageValue(t, o), t === this.defaultLanguage && this.updateOtherLanguagePlaceholders(o);
|
|
2164
2199
|
}), this.uploadSettings.set(t, n);
|
|
2165
|
-
const
|
|
2166
|
-
|
|
2200
|
+
const a = n.draw();
|
|
2201
|
+
a.classList.add("simple-language-upload"), i.appendChild(a);
|
|
2167
2202
|
} else {
|
|
2168
2203
|
const n = document.createElement("textarea");
|
|
2169
2204
|
n.id = `textarea-${t}`, n.classList.add("simple-language-textarea"), n.value = e || "", n.rows = 1, n.style.overflowY = "hidden";
|
|
2170
|
-
let
|
|
2171
|
-
|
|
2205
|
+
let a = this.props.placeholder || "Enter text in {language}...";
|
|
2206
|
+
a.includes("{language}") && (a = a.replace(
|
|
2172
2207
|
"{language}",
|
|
2173
2208
|
t.toUpperCase()
|
|
2174
|
-
)), n.setAttribute("data-full-placeholder",
|
|
2209
|
+
)), n.setAttribute("data-full-placeholder", a), this.adaptPlaceholderToSingleLine(n, a), this.getDataPropsPath() && n.setAttribute(
|
|
2175
2210
|
"data-test-id",
|
|
2176
2211
|
`${this.getDataPropsPath()}_${t}`
|
|
2177
2212
|
), n.addEventListener("input", (l) => {
|
|
@@ -2200,11 +2235,11 @@ class Ee extends x {
|
|
|
2200
2235
|
`#textarea-${e}`
|
|
2201
2236
|
);
|
|
2202
2237
|
if (i && (!i.value || i.value.trim() === "")) {
|
|
2203
|
-
const
|
|
2238
|
+
const a = t || ((n = this.props.placeholder) == null ? void 0 : n.replace(
|
|
2204
2239
|
"{language}",
|
|
2205
2240
|
e.toUpperCase()
|
|
2206
2241
|
)) || `Enter text in ${e.toUpperCase()}...`;
|
|
2207
|
-
i.setAttribute("data-full-placeholder",
|
|
2242
|
+
i.setAttribute("data-full-placeholder", a), this.adaptPlaceholderToSingleLine(i, a);
|
|
2208
2243
|
}
|
|
2209
2244
|
});
|
|
2210
2245
|
}
|
|
@@ -2216,17 +2251,17 @@ class Ee extends x {
|
|
|
2216
2251
|
}
|
|
2217
2252
|
const e = document.createElement("div");
|
|
2218
2253
|
e.classList.add("simple-multi-language-content"), this.props.languages.forEach((s) => {
|
|
2219
|
-
var
|
|
2220
|
-
const n = ((
|
|
2221
|
-
e.appendChild(
|
|
2254
|
+
var o;
|
|
2255
|
+
const n = ((o = this.value) == null ? void 0 : o[s]) || "", a = this.createTextareaRow(s, n);
|
|
2256
|
+
e.appendChild(a);
|
|
2222
2257
|
}), t.appendChild(e), this.container = t;
|
|
2223
2258
|
const i = () => {
|
|
2224
2259
|
if (!this.container) return;
|
|
2225
2260
|
this.container.querySelectorAll(
|
|
2226
2261
|
".simple-language-textarea"
|
|
2227
2262
|
).forEach((n) => {
|
|
2228
|
-
const
|
|
2229
|
-
|
|
2263
|
+
const a = n.getAttribute("data-full-placeholder") || "";
|
|
2264
|
+
a && this.adaptPlaceholderToSingleLine(n, a);
|
|
2230
2265
|
});
|
|
2231
2266
|
};
|
|
2232
2267
|
return window.addEventListener("resize", i), t;
|
|
@@ -2278,17 +2313,17 @@ class we extends x {
|
|
|
2278
2313
|
}
|
|
2279
2314
|
}
|
|
2280
2315
|
const ht = (h, t, e) => {
|
|
2281
|
-
let i = !1, s = 0, n = 0,
|
|
2316
|
+
let i = !1, s = 0, n = 0, a = 0, o = 0;
|
|
2282
2317
|
const l = (c) => {
|
|
2283
2318
|
if (c.target.closest("button")) return;
|
|
2284
2319
|
i = !0, s = c.clientX, n = c.clientY;
|
|
2285
2320
|
const d = t.getBoundingClientRect();
|
|
2286
|
-
|
|
2321
|
+
a = d.left, o = d.top, document.addEventListener("mousemove", r), document.addEventListener("mouseup", p), document.body.style.userSelect = "none";
|
|
2287
2322
|
}, r = (c) => {
|
|
2288
2323
|
if (!i) return;
|
|
2289
|
-
const d = c.clientX - s, u = c.clientY - n, g = window.innerWidth,
|
|
2290
|
-
let C =
|
|
2291
|
-
C = Math.max(8, Math.min(g - m - 8, C)), w = Math.max(8, Math.min(
|
|
2324
|
+
const d = c.clientX - s, u = c.clientY - n, g = window.innerWidth, f = window.innerHeight, m = t.offsetWidth, v = t.offsetHeight;
|
|
2325
|
+
let C = a + d, w = o + u;
|
|
2326
|
+
C = Math.max(8, Math.min(g - m - 8, C)), w = Math.max(8, Math.min(f - v - 8, w)), t.style.left = `${C}px`, t.style.top = `${w}px`, e == null || e(C, w);
|
|
2292
2327
|
}, p = () => {
|
|
2293
2328
|
i = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", p), document.body.style.userSelect = "";
|
|
2294
2329
|
};
|
|
@@ -2305,35 +2340,35 @@ const ht = (h, t, e) => {
|
|
|
2305
2340
|
b: parseInt(e.slice(4, 6), 16)
|
|
2306
2341
|
};
|
|
2307
2342
|
}, G = (h) => {
|
|
2308
|
-
const { r: t, g: e, b: i } = S(h), s = t / 255, n = e / 255,
|
|
2343
|
+
const { r: t, g: e, b: i } = S(h), s = t / 255, n = e / 255, a = i / 255, o = Math.max(s, n, a), l = Math.min(s, n, a), r = o - l;
|
|
2309
2344
|
let p = 0;
|
|
2310
|
-
r !== 0 && (
|
|
2311
|
-
const c =
|
|
2345
|
+
r !== 0 && (o === s ? p = (n - a) / r % 6 : o === n ? p = (a - s) / r + 2 : p = (s - n) / r + 4), p < 0 && (p += 6);
|
|
2346
|
+
const c = o === 0 ? 0 : r / o, d = o;
|
|
2312
2347
|
return { h: p * 60, s: c, v: d };
|
|
2313
2348
|
}, F = (h, t, e) => {
|
|
2314
|
-
const i = (h % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)),
|
|
2315
|
-
let
|
|
2316
|
-
return i < 60 ? (
|
|
2317
|
-
Math.round((
|
|
2318
|
-
Math.round((l +
|
|
2319
|
-
Math.round((r +
|
|
2349
|
+
const i = (h % 360 + 360) % 360, s = e * t, n = s * (1 - Math.abs(i / 60 % 2 - 1)), a = e - s;
|
|
2350
|
+
let o = 0, l = 0, r = 0;
|
|
2351
|
+
return i < 60 ? (o = s, l = n, r = 0) : i < 120 ? (o = n, l = s, r = 0) : i < 180 ? (o = 0, l = s, r = n) : i < 240 ? (o = 0, l = n, r = s) : i < 300 ? (o = n, l = 0, r = s) : (o = s, l = 0, r = n), _(
|
|
2352
|
+
Math.round((o + a) * 255),
|
|
2353
|
+
Math.round((l + a) * 255),
|
|
2354
|
+
Math.round((r + a) * 255)
|
|
2320
2355
|
);
|
|
2321
2356
|
}, dt = (h, t, e) => {
|
|
2322
2357
|
const i = e * (1 - t / 2), s = i === 0 || i === 1 ? 0 : (e - i) / Math.min(i, 1 - i);
|
|
2323
2358
|
return { hue: h, sat: s, lightness: i };
|
|
2324
2359
|
}, et = (h, t, e) => {
|
|
2325
2360
|
const i = (1 - Math.abs(2 * e - 1)) * t, s = i * (1 - Math.abs(h / 60 % 2 - 1)), n = e - i / 2;
|
|
2326
|
-
let
|
|
2327
|
-
return h < 60 ? (
|
|
2328
|
-
r: Math.round((
|
|
2329
|
-
g: Math.round((
|
|
2361
|
+
let a = 0, o = 0, l = 0;
|
|
2362
|
+
return h < 60 ? (a = i, o = s, l = 0) : h < 120 ? (a = s, o = i, l = 0) : h < 180 ? (a = 0, o = i, l = s) : h < 240 ? (a = 0, o = s, l = i) : h < 300 ? (a = s, o = 0, l = i) : (a = i, o = 0, l = s), {
|
|
2363
|
+
r: Math.round((a + n) * 255),
|
|
2364
|
+
g: Math.round((o + n) * 255),
|
|
2330
2365
|
b: Math.round((l + n) * 255)
|
|
2331
2366
|
};
|
|
2332
2367
|
}, pt = (h, t) => {
|
|
2333
2368
|
const e = Math.max(0, Math.min(100, t)) / 100;
|
|
2334
2369
|
if (h.startsWith("#")) {
|
|
2335
|
-
const { r: s, g: n, b:
|
|
2336
|
-
return `rgba(${s}, ${n}, ${
|
|
2370
|
+
const { r: s, g: n, b: a } = S(h);
|
|
2371
|
+
return `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
2337
2372
|
}
|
|
2338
2373
|
if (h.startsWith("rgba("))
|
|
2339
2374
|
return h.replace(/,\s*[\d.]+\)$/, `, ${e})`);
|
|
@@ -2342,29 +2377,29 @@ const ht = (h, t, e) => {
|
|
|
2342
2377
|
if (h.startsWith("hsl(")) {
|
|
2343
2378
|
const s = h.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2344
2379
|
if (s) {
|
|
2345
|
-
const { r: n, g:
|
|
2380
|
+
const { r: n, g: a, b: o } = et(
|
|
2346
2381
|
parseInt(s[1]),
|
|
2347
2382
|
parseInt(s[2]) / 100,
|
|
2348
2383
|
parseInt(s[3]) / 100
|
|
2349
2384
|
);
|
|
2350
|
-
return `rgba(${n}, ${
|
|
2385
|
+
return `rgba(${n}, ${a}, ${o}, ${e})`;
|
|
2351
2386
|
}
|
|
2352
2387
|
}
|
|
2353
2388
|
if (h.startsWith("hsla(")) {
|
|
2354
2389
|
const s = h.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);
|
|
2355
2390
|
if (s) {
|
|
2356
|
-
const { r: n, g:
|
|
2391
|
+
const { r: n, g: a, b: o } = et(
|
|
2357
2392
|
parseInt(s[1]),
|
|
2358
2393
|
parseInt(s[2]) / 100,
|
|
2359
2394
|
parseInt(s[3]) / 100
|
|
2360
2395
|
);
|
|
2361
|
-
return `rgba(${n}, ${
|
|
2396
|
+
return `rgba(${n}, ${a}, ${o}, ${e})`;
|
|
2362
2397
|
}
|
|
2363
2398
|
}
|
|
2364
2399
|
const i = W(h);
|
|
2365
2400
|
if (i) {
|
|
2366
|
-
const { r: s, g: n, b:
|
|
2367
|
-
return `rgba(${s}, ${n}, ${
|
|
2401
|
+
const { r: s, g: n, b: a } = S(i);
|
|
2402
|
+
return `rgba(${s}, ${n}, ${a}, ${e})`;
|
|
2368
2403
|
}
|
|
2369
2404
|
return h;
|
|
2370
2405
|
}, Wt = (h) => [
|
|
@@ -2404,9 +2439,9 @@ const ht = (h, t, e) => {
|
|
|
2404
2439
|
}, gt = (h) => {
|
|
2405
2440
|
const t = h.trim();
|
|
2406
2441
|
if (/^#[0-9A-Fa-f]{8}$/.test(t)) {
|
|
2407
|
-
const n = t.slice(1),
|
|
2442
|
+
const n = t.slice(1), a = parseInt(n.slice(0, 2), 16), o = parseInt(n.slice(2, 4), 16), l = parseInt(n.slice(4, 6), 16), r = parseInt(n.slice(6, 8), 16);
|
|
2408
2443
|
return {
|
|
2409
|
-
color: _(
|
|
2444
|
+
color: _(a, o, l),
|
|
2410
2445
|
position: 0,
|
|
2411
2446
|
opacity: Math.round(r / 255 * 100)
|
|
2412
2447
|
};
|
|
@@ -2415,9 +2450,9 @@ const ht = (h, t, e) => {
|
|
|
2415
2450
|
/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/
|
|
2416
2451
|
);
|
|
2417
2452
|
if (e) {
|
|
2418
|
-
const n = parseInt(e[1]),
|
|
2453
|
+
const n = parseInt(e[1]), a = parseInt(e[2]), o = parseInt(e[3]), l = e[4] ? parseFloat(e[4]) : 1;
|
|
2419
2454
|
return {
|
|
2420
|
-
color: _(n,
|
|
2455
|
+
color: _(n, a, o),
|
|
2421
2456
|
position: 0,
|
|
2422
2457
|
opacity: Math.round(l * 100)
|
|
2423
2458
|
};
|
|
@@ -2426,13 +2461,13 @@ const ht = (h, t, e) => {
|
|
|
2426
2461
|
/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/
|
|
2427
2462
|
);
|
|
2428
2463
|
if (i) {
|
|
2429
|
-
const { r: n, g:
|
|
2464
|
+
const { r: n, g: a, b: o } = et(
|
|
2430
2465
|
parseFloat(i[1]),
|
|
2431
2466
|
parseFloat(i[2]) / 100,
|
|
2432
2467
|
parseFloat(i[3]) / 100
|
|
2433
2468
|
), l = i[4] ? parseFloat(i[4]) : 1;
|
|
2434
2469
|
return {
|
|
2435
|
-
color: _(n,
|
|
2470
|
+
color: _(n, a, o),
|
|
2436
2471
|
position: 0,
|
|
2437
2472
|
opacity: Math.round(l * 100)
|
|
2438
2473
|
};
|
|
@@ -2456,10 +2491,10 @@ const ht = (h, t, e) => {
|
|
|
2456
2491
|
const e = new RegExp(`${t}\\s*\\(`, "i"), i = h.match(e);
|
|
2457
2492
|
if (!i) return null;
|
|
2458
2493
|
const s = i.index + i[0].length;
|
|
2459
|
-
let n = 1,
|
|
2460
|
-
for (let
|
|
2461
|
-
h[
|
|
2462
|
-
return n === 0 ? h.substring(s,
|
|
2494
|
+
let n = 1, a = s;
|
|
2495
|
+
for (let o = s; o < h.length && n > 0; o++)
|
|
2496
|
+
h[o] === "(" ? n++ : h[o] === ")" && n--, a = o;
|
|
2497
|
+
return n === 0 ? h.substring(s, a) : null;
|
|
2463
2498
|
}, zt = (h) => {
|
|
2464
2499
|
const t = h.split(" ")[0].toLowerCase();
|
|
2465
2500
|
return [
|
|
@@ -2478,11 +2513,11 @@ const ht = (h, t, e) => {
|
|
|
2478
2513
|
return h.forEach((e, i) => {
|
|
2479
2514
|
const s = e.trim();
|
|
2480
2515
|
if (!s) return;
|
|
2481
|
-
let n = "",
|
|
2482
|
-
const
|
|
2483
|
-
|
|
2516
|
+
let n = "", a = 0;
|
|
2517
|
+
const o = s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);
|
|
2518
|
+
o && ut(o[1].trim()) ? (n = o[1].trim(), a = parseFloat(o[2])) : (n = s, a = h.length === 1 ? 0 : i / (h.length - 1) * 100);
|
|
2484
2519
|
const l = gt(n);
|
|
2485
|
-
l.position = Math.max(0, Math.min(100, Math.round(
|
|
2520
|
+
l.position = Math.max(0, Math.min(100, Math.round(a))), t.push(l);
|
|
2486
2521
|
}), t;
|
|
2487
2522
|
}, O = (h) => {
|
|
2488
2523
|
const t = h.stops && h.stops.length ? h.stops : [{ color: "#000000", position: 0, opacity: 100 }];
|
|
@@ -2504,12 +2539,12 @@ const ht = (h, t, e) => {
|
|
|
2504
2539
|
const e = at(t, "linear-gradient");
|
|
2505
2540
|
if (e) {
|
|
2506
2541
|
const s = ot(e);
|
|
2507
|
-
let n = 90,
|
|
2508
|
-
const
|
|
2509
|
-
if (
|
|
2510
|
-
const r =
|
|
2511
|
-
r && (n = parseFloat(r[1]),
|
|
2512
|
-
} else
|
|
2542
|
+
let n = 90, a = s;
|
|
2543
|
+
const o = s[0];
|
|
2544
|
+
if (o.includes("deg")) {
|
|
2545
|
+
const r = o.match(/(-?\d+(?:\.\d+)?)deg/);
|
|
2546
|
+
r && (n = parseFloat(r[1]), a = s.slice(1));
|
|
2547
|
+
} else o.includes("to ") && (n = {
|
|
2513
2548
|
"to right": 90,
|
|
2514
2549
|
"to left": 270,
|
|
2515
2550
|
"to bottom": 180,
|
|
@@ -2518,14 +2553,14 @@ const ht = (h, t, e) => {
|
|
|
2518
2553
|
"to bottom left": 225,
|
|
2519
2554
|
"to top right": 45,
|
|
2520
2555
|
"to top left": 315
|
|
2521
|
-
}[
|
|
2522
|
-
const l = lt(
|
|
2556
|
+
}[o] ?? 90, a = s.slice(1));
|
|
2557
|
+
const l = lt(a);
|
|
2523
2558
|
return l.length ? O({ type: "linear", angle: n, stops: l }) : null;
|
|
2524
2559
|
}
|
|
2525
2560
|
const i = at(t, "radial-gradient");
|
|
2526
2561
|
if (i) {
|
|
2527
|
-
const s = ot(i), n = s[0] && !zt(s[0]) ? s.slice(1) : s,
|
|
2528
|
-
return
|
|
2562
|
+
const s = ot(i), n = s[0] && !zt(s[0]) ? s.slice(1) : s, a = lt(n);
|
|
2563
|
+
return a.length ? O({ type: "radial", angle: 0, stops: a }) : null;
|
|
2529
2564
|
}
|
|
2530
2565
|
return null;
|
|
2531
2566
|
}, T = (h) => {
|
|
@@ -2533,8 +2568,8 @@ const ht = (h, t, e) => {
|
|
|
2533
2568
|
const e = h.stops[0], i = e.color;
|
|
2534
2569
|
if (i.startsWith("var(--"))
|
|
2535
2570
|
return i;
|
|
2536
|
-
const s = e.opacity ?? 100, n = i.replace("#", ""),
|
|
2537
|
-
return `#${n}${
|
|
2571
|
+
const s = e.opacity ?? 100, n = i.replace("#", ""), a = Math.round(s / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
2572
|
+
return `#${n}${a}`;
|
|
2538
2573
|
}
|
|
2539
2574
|
const t = h.stops.map(
|
|
2540
2575
|
(e) => `${pt(e.color, e.opacity ?? 100)} ${e.position}%`
|
|
@@ -2621,12 +2656,12 @@ const ht = (h, t, e) => {
|
|
|
2621
2656
|
l && (i = t, s = l.type === "solid" ? "solid" : "gradient");
|
|
2622
2657
|
}
|
|
2623
2658
|
if (!i) return;
|
|
2624
|
-
const n = e === "all" ? s : e,
|
|
2625
|
-
|
|
2659
|
+
const n = e === "all" ? s : e, a = this.list(n), o = a.indexOf(i);
|
|
2660
|
+
o !== -1 && a.splice(o, 1), a.unshift(i), a.length > this.MAX_COLORS && (a.length = this.MAX_COLORS), this.persist();
|
|
2626
2661
|
}
|
|
2627
2662
|
};
|
|
2628
2663
|
U.STORAGE_KEY = "settingsLib_recentColors", U.MAX_COLORS = 12, U.colors = null;
|
|
2629
|
-
let
|
|
2664
|
+
let D = U;
|
|
2630
2665
|
const it = (h, t) => {
|
|
2631
2666
|
const e = document.createElement("div");
|
|
2632
2667
|
e.className = "color-picker-recent-section";
|
|
@@ -2636,25 +2671,25 @@ const it = (h, t) => {
|
|
|
2636
2671
|
s.className = "color-picker-tooltip", s.style.display = "none", e.appendChild(s);
|
|
2637
2672
|
const n = () => {
|
|
2638
2673
|
s.style.display = "none";
|
|
2639
|
-
},
|
|
2674
|
+
}, a = (p, c) => {
|
|
2640
2675
|
const d = p.getBoundingClientRect();
|
|
2641
2676
|
s.textContent = c, s.style.left = `${d.left + d.width / 2}px`, s.style.top = `${d.bottom + 8}px`, s.style.display = "block";
|
|
2642
|
-
},
|
|
2643
|
-
|
|
2677
|
+
}, o = document.createElement("div");
|
|
2678
|
+
o.className = "color-picker-recent-grid";
|
|
2644
2679
|
const l = document.createElement("div");
|
|
2645
|
-
l.className = "color-picker-recent-placeholder", l.textContent = "No recent colors yet", e.appendChild(i), e.appendChild(
|
|
2680
|
+
l.className = "color-picker-recent-placeholder", l.textContent = "No recent colors yet", e.appendChild(i), e.appendChild(o), e.appendChild(l);
|
|
2646
2681
|
const r = () => {
|
|
2647
|
-
n(),
|
|
2648
|
-
const p =
|
|
2682
|
+
n(), o.innerHTML = "";
|
|
2683
|
+
const p = D.getColors(t);
|
|
2649
2684
|
if (p.length === 0) {
|
|
2650
|
-
|
|
2685
|
+
o.style.display = "none", l.style.display = "block";
|
|
2651
2686
|
return;
|
|
2652
2687
|
}
|
|
2653
|
-
|
|
2688
|
+
o.style.display = "grid", l.style.display = "none", p.forEach((c) => {
|
|
2654
2689
|
const d = document.createElement("button");
|
|
2655
2690
|
d.type = "button", d.className = "color-picker-recent-swatch";
|
|
2656
2691
|
const u = qt(c);
|
|
2657
|
-
d.title = u, d.setAttribute("aria-label", `Use color: ${u}`), d.style.background = c, d.style.borderColor = c, d.addEventListener("mouseenter", () =>
|
|
2692
|
+
d.title = u, d.setAttribute("aria-label", `Use color: ${u}`), d.style.background = c, d.style.borderColor = c, d.addEventListener("mouseenter", () => a(d, u)), d.addEventListener("mouseleave", () => {
|
|
2658
2693
|
n(), d.style.boxShadow = "";
|
|
2659
2694
|
}), d.addEventListener("mousedown", () => {
|
|
2660
2695
|
d.style.boxShadow = "0px 0px 0px 2px var(--grey40)";
|
|
@@ -2664,7 +2699,7 @@ const it = (h, t) => {
|
|
|
2664
2699
|
}, 150);
|
|
2665
2700
|
}), d.addEventListener("click", () => {
|
|
2666
2701
|
n(), h(c);
|
|
2667
|
-
}),
|
|
2702
|
+
}), o.appendChild(d);
|
|
2668
2703
|
});
|
|
2669
2704
|
};
|
|
2670
2705
|
return r(), { container: e, refresh: r };
|
|
@@ -2682,7 +2717,7 @@ const it = (h, t) => {
|
|
|
2682
2717
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
2683
2718
|
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"
|
|
2684
2719
|
fill="#919EAB"/>
|
|
2685
|
-
</svg>`,
|
|
2720
|
+
</svg>`, ft = `<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2686
2721
|
<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"/>
|
|
2687
2722
|
</svg>`, _t = `<svg width="15" height="17" viewBox="0 0 15 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2688
2723
|
<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"/>
|
|
@@ -2719,8 +2754,8 @@ class Yt {
|
|
|
2719
2754
|
if (Array.from(n).some(
|
|
2720
2755
|
(l) => l.contains(s)
|
|
2721
2756
|
)) return;
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2757
|
+
const o = document.querySelector(".gradient-popover");
|
|
2758
|
+
o && o.contains(s) || (i.preventDefault(), i.stopPropagation(), this.close(!0));
|
|
2724
2759
|
}, this.keyDown = (i) => {
|
|
2725
2760
|
if (this.isOpen) {
|
|
2726
2761
|
if (i.key === "Escape")
|
|
@@ -2748,12 +2783,12 @@ class Yt {
|
|
|
2748
2783
|
s.className = "color-picker-close", s.innerHTML = mt, s.addEventListener("click", () => this.close(!0)), e.appendChild(i), e.appendChild(s), ht(e, t);
|
|
2749
2784
|
const n = document.createElement("div");
|
|
2750
2785
|
n.className = "color-picker-area", this.colorArea = n;
|
|
2751
|
-
const o = document.createElement("div");
|
|
2752
|
-
o.className = "color-picker-marker", this.colorMarker = o, n.appendChild(o);
|
|
2753
2786
|
const a = document.createElement("div");
|
|
2754
|
-
a.className = "color-picker-
|
|
2787
|
+
a.className = "color-picker-marker", this.colorMarker = a, n.appendChild(a);
|
|
2788
|
+
const o = document.createElement("div");
|
|
2789
|
+
o.className = "color-picker-sliders-container";
|
|
2755
2790
|
const l = document.createElement("button");
|
|
2756
|
-
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML =
|
|
2791
|
+
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML = ft;
|
|
2757
2792
|
const r = document.createElement("div");
|
|
2758
2793
|
r.className = "color-picker-sliders-group";
|
|
2759
2794
|
const p = document.createElement("div");
|
|
@@ -2763,28 +2798,28 @@ class Yt {
|
|
|
2763
2798
|
const d = document.createElement("div");
|
|
2764
2799
|
d.className = "color-picker-opacity", this.opacitySlider = d;
|
|
2765
2800
|
const u = document.createElement("div");
|
|
2766
|
-
u.className = "color-picker-opacity-marker", this.opacityMarker = u, d.appendChild(u), r.appendChild(p), r.appendChild(d),
|
|
2801
|
+
u.className = "color-picker-opacity-marker", this.opacityMarker = u, d.appendChild(u), r.appendChild(p), r.appendChild(d), o.appendChild(l), o.appendChild(r);
|
|
2767
2802
|
const g = it((b) => {
|
|
2768
|
-
var
|
|
2769
|
-
this.setColor(b), (
|
|
2803
|
+
var k;
|
|
2804
|
+
this.setColor(b), (k = this.onChange) == null || k.call(this, b, this.currentOpacity);
|
|
2770
2805
|
}, this.recentScope);
|
|
2771
2806
|
this.recentSectionRefresh = g.refresh;
|
|
2772
|
-
const
|
|
2773
|
-
|
|
2807
|
+
const f = document.createElement("div");
|
|
2808
|
+
f.className = "color-picker-format-section";
|
|
2774
2809
|
const m = document.createElement("select");
|
|
2775
2810
|
m.className = "color-picker-format-select", this.select = m;
|
|
2776
|
-
const
|
|
2777
|
-
|
|
2811
|
+
const v = document.createElement("option");
|
|
2812
|
+
v.value = "hex", v.textContent = "HEX";
|
|
2778
2813
|
const C = document.createElement("option");
|
|
2779
2814
|
C.value = "rgb", C.textContent = "RGB";
|
|
2780
2815
|
const w = document.createElement("option");
|
|
2781
|
-
w.value = "hsl", w.textContent = "HSL", m.appendChild(
|
|
2816
|
+
w.value = "hsl", w.textContent = "HSL", m.appendChild(v), m.appendChild(C), m.appendChild(w);
|
|
2782
2817
|
const E = document.createElement("input");
|
|
2783
2818
|
E.type = "text", E.className = "color-picker-color-input", E.value = this.currentColor, this.input = E;
|
|
2784
|
-
const
|
|
2785
|
-
|
|
2819
|
+
const M = document.createElement("div");
|
|
2820
|
+
M.className = "color-picker-input-container";
|
|
2786
2821
|
const y = document.createElement("button");
|
|
2787
|
-
return y.className = "color-picker-copy-inside", y.textContent = "Copy",
|
|
2822
|
+
return y.className = "color-picker-copy-inside", y.textContent = "Copy", M.appendChild(E), M.appendChild(y), f.appendChild(m), f.appendChild(M), t.appendChild(e), t.appendChild(n), t.appendChild(o), t.appendChild(g.container), t.appendChild(f), t.addEventListener("click", (b) => b.stopPropagation()), this.bind(n, p, d, E, m, y, l), t;
|
|
2788
2823
|
}
|
|
2789
2824
|
createBackdrop() {
|
|
2790
2825
|
const t = document.createElement("div");
|
|
@@ -2792,20 +2827,20 @@ class Yt {
|
|
|
2792
2827
|
e.preventDefault(), e.stopPropagation(), this.close(!0);
|
|
2793
2828
|
}), t;
|
|
2794
2829
|
}
|
|
2795
|
-
bind(t, e, i, s, n,
|
|
2830
|
+
bind(t, e, i, s, n, a, o) {
|
|
2796
2831
|
const l = (c) => {
|
|
2797
2832
|
var C;
|
|
2798
2833
|
const d = t.getBoundingClientRect(), u = Math.max(0, Math.min(1, (c.clientX - d.left) / d.width)), g = Math.max(0, Math.min(1, (c.clientY - d.top) / d.height));
|
|
2799
2834
|
this.colorMarker.style.left = `${u * 100}%`, this.colorMarker.style.top = `${g * 100}%`;
|
|
2800
|
-
const m = this.parsePercentage(this.hueMarker.style.left || "0%") * 360,
|
|
2801
|
-
this.currentColor =
|
|
2835
|
+
const m = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, v = F(m, u, 1 - g);
|
|
2836
|
+
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), (C = this.onChange) == null || C.call(this, v, this.currentOpacity);
|
|
2802
2837
|
}, r = (c) => {
|
|
2803
2838
|
var C;
|
|
2804
2839
|
const d = e.getBoundingClientRect();
|
|
2805
2840
|
let u = Math.max(0, Math.min(1, (c.clientX - d.left) / d.width));
|
|
2806
2841
|
this.hueMarker.style.left = `${u * 100}%`;
|
|
2807
|
-
const g = u * 360,
|
|
2808
|
-
this.currentColor =
|
|
2842
|
+
const g = u * 360, f = this.parsePercentage(this.colorMarker.style.left || "0%"), m = this.parsePercentage(this.colorMarker.style.top || "0%"), v = F(g, f, 1 - m);
|
|
2843
|
+
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);
|
|
2809
2844
|
}, p = (c) => {
|
|
2810
2845
|
var g;
|
|
2811
2846
|
const d = i.getBoundingClientRect(), u = Math.max(0, Math.min(1, (c.clientX - d.left) / d.width));
|
|
@@ -2831,13 +2866,13 @@ class Yt {
|
|
|
2831
2866
|
document.addEventListener("mousemove", d), document.addEventListener("mouseup", u);
|
|
2832
2867
|
}), n.addEventListener("change", () => this.syncInput()), s.addEventListener("input", () => this.applyFromInput()), s.addEventListener("blur", () => this.syncInput()), s.addEventListener("keydown", (c) => {
|
|
2833
2868
|
c.key === "Enter" && (c.preventDefault(), this.syncInput(), s.blur());
|
|
2834
|
-
}),
|
|
2869
|
+
}), a.addEventListener("click", async () => {
|
|
2835
2870
|
try {
|
|
2836
2871
|
await navigator.clipboard.writeText(s.value);
|
|
2837
2872
|
} catch {
|
|
2838
2873
|
s.select(), document.execCommand("copy");
|
|
2839
2874
|
}
|
|
2840
|
-
}),
|
|
2875
|
+
}), o.addEventListener("click", async () => {
|
|
2841
2876
|
var c;
|
|
2842
2877
|
if (!("EyeDropper" in window)) {
|
|
2843
2878
|
alert("EyeDropper API is not supported in this browser.");
|
|
@@ -2854,22 +2889,22 @@ class Yt {
|
|
|
2854
2889
|
);
|
|
2855
2890
|
}
|
|
2856
2891
|
setColor(t) {
|
|
2857
|
-
var
|
|
2892
|
+
var a;
|
|
2858
2893
|
this.currentColor = t;
|
|
2859
2894
|
const { h: e, s: i, v: s } = G(t), n = e >= 360 ? e % 360 : e;
|
|
2860
|
-
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(), (
|
|
2895
|
+
this.hueMarker.style.left = `${n / 360 * 100}%`, this.colorMarker.style.left = `${i * 100}%`, this.colorMarker.style.top = `${(1 - s) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), (a = this.onChange) == null || a.call(this, t, this.currentOpacity);
|
|
2861
2896
|
}
|
|
2862
2897
|
syncInput() {
|
|
2863
2898
|
const t = this.select.value, { h: e, s: i, v: s } = G(this.currentColor);
|
|
2864
2899
|
if (t === "hex") this.input.value = this.currentColor;
|
|
2865
2900
|
else if (t === "rgb") {
|
|
2866
|
-
const { r: n, g:
|
|
2867
|
-
this.input.value = `rgb(${n}, ${
|
|
2901
|
+
const { r: n, g: a, b: o } = S(this.currentColor);
|
|
2902
|
+
this.input.value = `rgb(${n}, ${a}, ${o})`;
|
|
2868
2903
|
} else {
|
|
2869
|
-
const { hue: n, sat:
|
|
2904
|
+
const { hue: n, sat: a, lightness: o } = dt(e, i, s);
|
|
2870
2905
|
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
2871
|
-
|
|
2872
|
-
)}%, ${Math.round(
|
|
2906
|
+
a * 100
|
|
2907
|
+
)}%, ${Math.round(o * 100)}%)`;
|
|
2873
2908
|
}
|
|
2874
2909
|
}
|
|
2875
2910
|
applyFromInput() {
|
|
@@ -2879,12 +2914,12 @@ class Yt {
|
|
|
2879
2914
|
else {
|
|
2880
2915
|
const i = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
2881
2916
|
if (i) {
|
|
2882
|
-
const s = parseInt(i[1]), n = parseInt(i[2]),
|
|
2883
|
-
s <= 255 && n <= 255 &&
|
|
2917
|
+
const s = parseInt(i[1]), n = parseInt(i[2]), a = parseInt(i[3]);
|
|
2918
|
+
s <= 255 && n <= 255 && a <= 255 && (e = `#${[s, n, a].map((o) => o.toString(16).padStart(2, "0")).join("")}`);
|
|
2884
2919
|
} else {
|
|
2885
2920
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
2886
2921
|
if (s) {
|
|
2887
|
-
const n = parseInt(s[1]),
|
|
2922
|
+
const n = parseInt(s[1]), a = parseInt(s[2]) / 100, o = parseInt(s[3]) / 100, l = o + a * Math.min(o, 1 - o), r = l === 0 ? 0 : 2 * (1 - o / l);
|
|
2888
2923
|
e = F(n, r, l);
|
|
2889
2924
|
}
|
|
2890
2925
|
}
|
|
@@ -2901,18 +2936,18 @@ class Yt {
|
|
|
2901
2936
|
open(t, e, i) {
|
|
2902
2937
|
var w;
|
|
2903
2938
|
this.currentColor = t, this.currentOpacity = i ?? 100, this.syncInput();
|
|
2904
|
-
const { h: s, s: n, v:
|
|
2905
|
-
this.hueMarker.style.left = `${s / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 -
|
|
2906
|
-
const
|
|
2939
|
+
const { h: s, s: n, v: a } = G(t);
|
|
2940
|
+
this.hueMarker.style.left = `${s / 360 * 100}%`, this.colorMarker.style.left = `${n * 100}%`, this.colorMarker.style.top = `${(1 - a) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`, this.updateOpacityBg(), this.opacityMarker.style.left = `${this.currentOpacity}%`, (w = this.recentSectionRefresh) == null || w.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);
|
|
2941
|
+
const o = this.element.offsetWidth, l = this.element.offsetHeight, r = e.getBoundingClientRect(), p = window.innerWidth, c = window.innerHeight, d = 16;
|
|
2907
2942
|
let u = r.right + 8, g = r.top;
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2910
|
-
const
|
|
2911
|
-
|
|
2943
|
+
const f = p - r.right, m = r.left;
|
|
2944
|
+
f >= o + d ? u = r.right + 8 : m >= o + d ? u = r.left - o - 8 : u = Math.max(d, (p - o) / 2);
|
|
2945
|
+
const v = c - r.bottom, C = r.top;
|
|
2946
|
+
v >= l + d ? g = r.bottom + 8 : C >= l + d ? g = r.top - l - 8 : v > C ? (g = r.bottom + 8, g + l > c - d && (g = c - l - d)) : (g = r.top - l - 8, g < d && (g = d)), this.element.style.left = `${u}px`, this.element.style.top = `${g}px`;
|
|
2912
2947
|
}
|
|
2913
2948
|
close(t) {
|
|
2914
2949
|
var e;
|
|
2915
|
-
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" && (
|
|
2950
|
+
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" && (D.addColor(this.currentColor, this.recentScope), (e = this.recentSectionRefresh) == null || e.call(this)));
|
|
2916
2951
|
}
|
|
2917
2952
|
getElement() {
|
|
2918
2953
|
return this.element;
|
|
@@ -2936,20 +2971,20 @@ class Qt {
|
|
|
2936
2971
|
const s = document.createElement("div");
|
|
2937
2972
|
s.className = "color-picker-sliders-container embedded";
|
|
2938
2973
|
const n = document.createElement("button");
|
|
2939
|
-
n.className = "color-picker-eyedropper", n.type = "button", n.innerHTML =
|
|
2940
|
-
const o = document.createElement("div");
|
|
2941
|
-
o.className = "color-picker-sliders-group";
|
|
2974
|
+
n.className = "color-picker-eyedropper", n.type = "button", n.innerHTML = ft;
|
|
2942
2975
|
const a = document.createElement("div");
|
|
2943
|
-
a.className = "color-picker-
|
|
2976
|
+
a.className = "color-picker-sliders-group";
|
|
2977
|
+
const o = document.createElement("div");
|
|
2978
|
+
o.className = "color-picker-hue embedded", this.hueSlider = o;
|
|
2944
2979
|
const l = document.createElement("div");
|
|
2945
|
-
l.className = "color-picker-hue-marker", this.hueMarker = l,
|
|
2980
|
+
l.className = "color-picker-hue-marker", this.hueMarker = l, o.appendChild(l);
|
|
2946
2981
|
const r = document.createElement("div");
|
|
2947
2982
|
r.className = "color-picker-opacity embedded", this.opacitySlider = r;
|
|
2948
2983
|
const p = document.createElement("div");
|
|
2949
|
-
p.className = "color-picker-opacity-marker", this.opacityMarker = p, r.appendChild(p),
|
|
2984
|
+
p.className = "color-picker-opacity-marker", this.opacityMarker = p, r.appendChild(p), a.appendChild(o), a.appendChild(r), s.appendChild(n), s.appendChild(a);
|
|
2950
2985
|
const c = it((E) => {
|
|
2951
|
-
const
|
|
2952
|
-
|
|
2986
|
+
const M = I(E);
|
|
2987
|
+
M && M.type !== "solid" ? this.onColorChange(E, this.currentOpacity) : (this.setColor(E), this.onColorChange(this.currentColor, this.currentOpacity));
|
|
2953
2988
|
}, "all");
|
|
2954
2989
|
this.recentSectionRefresh = c.refresh;
|
|
2955
2990
|
const d = document.createElement("div");
|
|
@@ -2958,28 +2993,28 @@ class Qt {
|
|
|
2958
2993
|
u.className = "color-picker-format-select", this.select = u;
|
|
2959
2994
|
const g = document.createElement("option");
|
|
2960
2995
|
g.value = "hex", g.textContent = "HEX";
|
|
2961
|
-
const
|
|
2962
|
-
|
|
2996
|
+
const f = document.createElement("option");
|
|
2997
|
+
f.value = "rgb", f.textContent = "RGB";
|
|
2963
2998
|
const m = document.createElement("option");
|
|
2964
|
-
m.value = "hsl", m.textContent = "HSL", u.appendChild(g), u.appendChild(
|
|
2965
|
-
const
|
|
2966
|
-
|
|
2999
|
+
m.value = "hsl", m.textContent = "HSL", u.appendChild(g), u.appendChild(f), u.appendChild(m);
|
|
3000
|
+
const v = document.createElement("input");
|
|
3001
|
+
v.type = "text", v.className = "color-picker-color-input", this.input = v;
|
|
2967
3002
|
const C = document.createElement("div");
|
|
2968
3003
|
C.className = "color-picker-input-container";
|
|
2969
3004
|
const w = document.createElement("button");
|
|
2970
|
-
return w.className = "color-picker-copy-inside", w.textContent = "Copy", C.appendChild(
|
|
3005
|
+
return w.className = "color-picker-copy-inside", w.textContent = "Copy", C.appendChild(v), C.appendChild(w), d.appendChild(u), d.appendChild(C), t.appendChild(e), t.appendChild(s), t.appendChild(d), t.appendChild(c.container), this.bind(e, o, r, v, u, w, n), t;
|
|
2971
3006
|
}
|
|
2972
|
-
bind(t, e, i, s, n,
|
|
3007
|
+
bind(t, e, i, s, n, a, o) {
|
|
2973
3008
|
const l = (c) => {
|
|
2974
3009
|
const d = t.getBoundingClientRect(), u = Math.max(0, Math.min(1, (c.clientX - d.left) / d.width)), g = Math.max(0, Math.min(1, (c.clientY - d.top) / d.height));
|
|
2975
3010
|
this.colorMarker.style.left = `${u * 100}%`, this.colorMarker.style.top = `${g * 100}%`;
|
|
2976
|
-
const m = this.parsePercentage(this.hueMarker.style.left || "0%") * 360,
|
|
2977
|
-
this.currentColor =
|
|
3011
|
+
const m = this.parsePercentage(this.hueMarker.style.left || "0%") * 360, v = F(m, u, 1 - g);
|
|
3012
|
+
this.currentColor = v, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
2978
3013
|
}, r = (c) => {
|
|
2979
3014
|
const d = e.getBoundingClientRect(), u = Math.max(0, Math.min(1, (c.clientX - d.left) / d.width));
|
|
2980
3015
|
this.hueMarker.style.left = `${u * 100}%`;
|
|
2981
|
-
const g = u * 360,
|
|
2982
|
-
this.currentColor =
|
|
3016
|
+
const g = u * 360, f = this.parsePercentage(this.colorMarker.style.left || "0%"), m = this.parsePercentage(this.colorMarker.style.top || "0%"), v = F(g, f, 1 - m);
|
|
3017
|
+
this.currentColor = v, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
2983
3018
|
linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`, this.syncInput(), this.updateOpacityBg(), this.queueChange();
|
|
2984
3019
|
}, p = (c) => {
|
|
2985
3020
|
const d = i.getBoundingClientRect(), u = Math.max(0, Math.min(1, (c.clientX - d.left) / d.width));
|
|
@@ -3011,13 +3046,13 @@ class Qt {
|
|
|
3011
3046
|
this.syncInput();
|
|
3012
3047
|
}), s.addEventListener("keydown", (c) => {
|
|
3013
3048
|
c.key === "Enter" && (c.preventDefault(), this.syncInput(), s.blur());
|
|
3014
|
-
}),
|
|
3049
|
+
}), a.addEventListener("click", async () => {
|
|
3015
3050
|
try {
|
|
3016
3051
|
await navigator.clipboard.writeText(s.value);
|
|
3017
3052
|
} catch {
|
|
3018
3053
|
s.select(), document.execCommand("copy");
|
|
3019
3054
|
}
|
|
3020
|
-
}),
|
|
3055
|
+
}), o.addEventListener("click", async () => {
|
|
3021
3056
|
if (!("EyeDropper" in window)) {
|
|
3022
3057
|
alert("EyeDropper API is not supported in this browser.");
|
|
3023
3058
|
return;
|
|
@@ -3040,13 +3075,13 @@ class Qt {
|
|
|
3040
3075
|
if (t === "hex")
|
|
3041
3076
|
this.input.value = this.currentColor;
|
|
3042
3077
|
else if (t === "rgb") {
|
|
3043
|
-
const { r: n, g:
|
|
3044
|
-
this.input.value = `rgb(${n}, ${
|
|
3078
|
+
const { r: n, g: a, b: o } = S(this.currentColor);
|
|
3079
|
+
this.input.value = `rgb(${n}, ${a}, ${o})`;
|
|
3045
3080
|
} else {
|
|
3046
|
-
const { hue: n, sat:
|
|
3081
|
+
const { hue: n, sat: a, lightness: o } = dt(e, i, s);
|
|
3047
3082
|
this.input.value = `hsl(${Math.round(n)}, ${Math.round(
|
|
3048
|
-
|
|
3049
|
-
)}%, ${Math.round(
|
|
3083
|
+
a * 100
|
|
3084
|
+
)}%, ${Math.round(o * 100)}%)`;
|
|
3050
3085
|
}
|
|
3051
3086
|
}
|
|
3052
3087
|
applyFromInput() {
|
|
@@ -3057,12 +3092,12 @@ class Qt {
|
|
|
3057
3092
|
else {
|
|
3058
3093
|
const i = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
3059
3094
|
if (i) {
|
|
3060
|
-
const s = parseInt(i[1], 10), n = parseInt(i[2], 10),
|
|
3061
|
-
s <= 255 && n <= 255 &&
|
|
3095
|
+
const s = parseInt(i[1], 10), n = parseInt(i[2], 10), a = parseInt(i[3], 10);
|
|
3096
|
+
s <= 255 && n <= 255 && a <= 255 && (e = "#" + [s, n, a].map((o) => o.toString(16).padStart(2, "0")).join(""));
|
|
3062
3097
|
} else {
|
|
3063
3098
|
const s = t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);
|
|
3064
3099
|
if (s) {
|
|
3065
|
-
const n = parseInt(s[1], 10),
|
|
3100
|
+
const n = parseInt(s[1], 10), a = parseInt(s[2], 10) / 100, o = parseInt(s[3], 10) / 100, l = o + a * Math.min(o, 1 - o), r = l === 0 ? 0 : 2 * (1 - o / l);
|
|
3066
3101
|
e = F(n, r, l);
|
|
3067
3102
|
}
|
|
3068
3103
|
}
|
|
@@ -3090,15 +3125,15 @@ class Qt {
|
|
|
3090
3125
|
this.pendingExternalUpdate = void 0, this.initFromColor(t, e);
|
|
3091
3126
|
}
|
|
3092
3127
|
initFromColor(t, e) {
|
|
3093
|
-
var
|
|
3128
|
+
var o;
|
|
3094
3129
|
this.currentColor = t, this.currentOpacity = e;
|
|
3095
|
-
const { h: i, s, v: n } = G(t),
|
|
3096
|
-
this.hueMarker.style.left = `${
|
|
3097
|
-
linear-gradient(to right, #fff, hsl(${
|
|
3130
|
+
const { h: i, s, v: n } = G(t), a = i >= 360 ? i % 360 : i;
|
|
3131
|
+
this.hueMarker.style.left = `${a / 360 * 100}%`, this.colorMarker.style.left = `${s * 100}%`, this.colorMarker.style.top = `${(1 - n) * 100}%`, this.colorArea.style.background = `linear-gradient(to top, #000, transparent),
|
|
3132
|
+
linear-gradient(to right, #fff, hsl(${a}, 100%, 50%))`, this.opacityMarker.style.left = `${e}%`, this.updateOpacityBg(), this.syncInput(), (o = this.recentSectionRefresh) == null || o.call(this);
|
|
3098
3133
|
}
|
|
3099
3134
|
commitRecentColor() {
|
|
3100
3135
|
var t;
|
|
3101
|
-
this.recentScope === "solid" && (
|
|
3136
|
+
this.recentScope === "solid" && (D.addColor(this.currentColor, this.recentScope), (t = this.recentSectionRefresh) == null || t.call(this));
|
|
3102
3137
|
}
|
|
3103
3138
|
getElement() {
|
|
3104
3139
|
return this.element;
|
|
@@ -3125,14 +3160,14 @@ const P = class P extends x {
|
|
|
3125
3160
|
}, this.element = null, this.previewEl = null, this.inputEl = void 0, this.popoverEl = null, this.backdropEl = null, this.isPopoverOpen = !1, this.isEditing = !1, this.popoverPosition = null, this.previewUpdateTimeout = null, this.solidPicker = null, this.pendingSolidColor = null, this.variant = "default", this.globalLayoutMode = "list", this.globalSearchQuery = "", this.currentMode = "custom", this.unlinkButton = null, this.onBackgroundClick = (i) => {
|
|
3126
3161
|
var d;
|
|
3127
3162
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
3128
|
-
const s = i.target, n = this.popoverEl.contains(s),
|
|
3163
|
+
const s = i.target, n = this.popoverEl.contains(s), a = (d = this.element) == null ? void 0 : d.contains(s), o = document.querySelectorAll(".custom-color-picker"), l = Array.from(o).some((u) => u.contains(s)), r = s.closest(
|
|
3129
3164
|
".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"
|
|
3130
3165
|
), p = s.classList.contains(
|
|
3131
3166
|
"color-picker-backdrop"
|
|
3132
3167
|
), c = s.classList.contains(
|
|
3133
3168
|
"gradient-popover-backdrop"
|
|
3134
3169
|
);
|
|
3135
|
-
!n && !
|
|
3170
|
+
!n && !a && !l && !r && !p && !c && this.closePopover();
|
|
3136
3171
|
}, this.handlePopoverKeydown = (i) => {
|
|
3137
3172
|
if (this.isPopoverOpen) {
|
|
3138
3173
|
if (i.key === "Escape") {
|
|
@@ -3252,8 +3287,8 @@ const P = class P extends x {
|
|
|
3252
3287
|
if (n === 100)
|
|
3253
3288
|
this.inputEl.value = s;
|
|
3254
3289
|
else {
|
|
3255
|
-
const
|
|
3256
|
-
this.inputEl.value = `${s}${
|
|
3290
|
+
const o = Math.round(n / 100 * 255).toString(16).toUpperCase().padStart(2, "0");
|
|
3291
|
+
this.inputEl.value = `${s}${o}`;
|
|
3257
3292
|
}
|
|
3258
3293
|
}
|
|
3259
3294
|
} else
|
|
@@ -3298,12 +3333,12 @@ const P = class P extends x {
|
|
|
3298
3333
|
s.className = "gradient-editor";
|
|
3299
3334
|
const n = document.createElement("div");
|
|
3300
3335
|
n.className = "type-tabs-wrapper";
|
|
3301
|
-
const
|
|
3302
|
-
n.appendChild(
|
|
3303
|
-
const
|
|
3304
|
-
if (
|
|
3336
|
+
const a = this.createTypeTabs();
|
|
3337
|
+
n.appendChild(a), s.appendChild(n);
|
|
3338
|
+
const o = document.createElement("div");
|
|
3339
|
+
if (o.className = "gradient-editor-content", this.updatePopoverContent(o), s.appendChild(o), this.variant !== "global" && e) {
|
|
3305
3340
|
const c = e.children[0], d = e.children[1], u = (g) => {
|
|
3306
|
-
this.currentMode = g, g === "custom" ? (c.classList.add("active"), d.classList.remove("active"), n.style.display = "block") : (d.classList.add("active"), c.classList.remove("active"), n.style.display = "none"), this.updatePopoverContent(
|
|
3341
|
+
this.currentMode = g, g === "custom" ? (c.classList.add("active"), d.classList.remove("active"), n.style.display = "block") : (d.classList.add("active"), c.classList.remove("active"), n.style.display = "none"), this.updatePopoverContent(o);
|
|
3307
3342
|
};
|
|
3308
3343
|
c.addEventListener("click", () => u("custom")), d.addEventListener("click", () => u("global")), (p = (r = (l = this.value) == null ? void 0 : l.stops) == null ? void 0 : r[0]) != null && p.color.startsWith("var(--") ? (this.currentMode = "global", u("global")) : (this.currentMode = "custom", u("custom"));
|
|
3309
3344
|
}
|
|
@@ -3317,9 +3352,9 @@ const P = class P extends x {
|
|
|
3317
3352
|
e.type = "button", e.className = `gradient-type-tab ${((s = this.value) == null ? void 0 : s.type) === "solid" ? "active" : ""}`, e.innerHTML = Zt, e.style.minWidth = "32px", e.addEventListener("click", () => this.switchType("solid"));
|
|
3318
3353
|
const i = document.createElement("button");
|
|
3319
3354
|
return i.type = "button", i.className = `gradient-type-tab ${((n = this.value) == null ? void 0 : n.type) !== "solid" ? "active" : ""}`, i.innerHTML = Xt, i.style.minWidth = "32px", i.addEventListener("click", () => {
|
|
3320
|
-
var
|
|
3321
|
-
const
|
|
3322
|
-
this.switchType(
|
|
3355
|
+
var o, l;
|
|
3356
|
+
const a = ((o = this.value) == null ? void 0 : o.type) === "solid" ? "linear" : ((l = this.value) == null ? void 0 : l.type) || "linear";
|
|
3357
|
+
this.switchType(a);
|
|
3323
3358
|
}), t.appendChild(e), t.appendChild(i), t;
|
|
3324
3359
|
}
|
|
3325
3360
|
switchType(t) {
|
|
@@ -3331,8 +3366,8 @@ const P = class P extends x {
|
|
|
3331
3366
|
]), t !== "solid" && this.value.stops.length === 1) {
|
|
3332
3367
|
const n = this.value.stops[0].color;
|
|
3333
3368
|
if (n.startsWith("var(--")) {
|
|
3334
|
-
const
|
|
3335
|
-
|
|
3369
|
+
const a = this.resolveGlobalVarColor(n), o = I(a);
|
|
3370
|
+
o && o.type !== "solid" && o.stops.length >= 2 ? (this.value.stops = o.stops, this.value.angle = o.angle, this.value.type = o.type) : (this.value.stops.push({
|
|
3336
3371
|
color: "#786666",
|
|
3337
3372
|
position: 100,
|
|
3338
3373
|
opacity: 100
|
|
@@ -3346,9 +3381,9 @@ const P = class P extends x {
|
|
|
3346
3381
|
} else t !== "solid" && this.value.stops.length >= 2 && (this.value.angle || (this.value.angle = 90));
|
|
3347
3382
|
if (this.popoverEl) {
|
|
3348
3383
|
const s = this.popoverEl.querySelectorAll(".gradient-type-tab");
|
|
3349
|
-
s.forEach((
|
|
3350
|
-
const n = s[0],
|
|
3351
|
-
t === "solid" ? n == null || n.classList.add("active") :
|
|
3384
|
+
s.forEach((o) => o.classList.remove("active"));
|
|
3385
|
+
const n = s[0], a = s[1];
|
|
3386
|
+
t === "solid" ? n == null || n.classList.add("active") : a == null || a.classList.add("active");
|
|
3352
3387
|
}
|
|
3353
3388
|
const e = (i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-editor-content");
|
|
3354
3389
|
e && this.updatePopoverContent(e), this.updateUI(), this.triggerChange();
|
|
@@ -3387,32 +3422,32 @@ const P = class P extends x {
|
|
|
3387
3422
|
keys: ["text-dark", "text-light"]
|
|
3388
3423
|
}
|
|
3389
3424
|
], g = this.globalSearchQuery.toLowerCase();
|
|
3390
|
-
let
|
|
3391
|
-
this.globalLayoutMode === "list" ? (
|
|
3392
|
-
const
|
|
3393
|
-
|
|
3425
|
+
let f;
|
|
3426
|
+
this.globalLayoutMode === "list" ? (f = document.createElement("div"), f.className = "global-colors-list") : (f = document.createElement("div"), f.className = "global-colors-grid"), c.appendChild(f), u.forEach((m) => {
|
|
3427
|
+
const v = Object.entries(d).filter(([C]) => !m.keys.includes(C) && m.title !== "Global Colors" ? !1 : m.keys.includes(C) && C.toLowerCase().includes(g));
|
|
3428
|
+
v.length !== 0 && v.forEach(([C, w]) => {
|
|
3394
3429
|
if (this.globalLayoutMode === "list") {
|
|
3395
3430
|
const E = document.createElement("div");
|
|
3396
3431
|
E.className = "global-color-row";
|
|
3397
|
-
const
|
|
3398
|
-
|
|
3432
|
+
const M = document.createElement("div");
|
|
3433
|
+
M.className = "global-color-circle";
|
|
3399
3434
|
const y = this.resolveGlobalVarColor(w);
|
|
3400
|
-
|
|
3435
|
+
M.style.background = y, e.color === `var(--${C})` && M.classList.add("selected");
|
|
3401
3436
|
const b = document.createElement("span");
|
|
3402
|
-
b.className = "global-color-label", b.textContent = C.split("-").map((
|
|
3403
|
-
|
|
3437
|
+
b.className = "global-color-label", b.textContent = C.split("-").map((k) => k.charAt(0).toUpperCase() + k.slice(1)).join(" "), E.appendChild(M), E.appendChild(b), E.addEventListener("click", (k) => {
|
|
3438
|
+
k.preventDefault();
|
|
3404
3439
|
const $ = `var(--${C})`;
|
|
3405
3440
|
this.setValue($), this.pendingSolidColor = $, i(c);
|
|
3406
|
-
}),
|
|
3441
|
+
}), f.appendChild(E);
|
|
3407
3442
|
} else {
|
|
3408
3443
|
const E = document.createElement("div");
|
|
3409
3444
|
E.className = "global-color-circle";
|
|
3410
|
-
const
|
|
3411
|
-
E.style.background =
|
|
3445
|
+
const M = this.resolveGlobalVarColor(w);
|
|
3446
|
+
E.style.background = M, E.title = C.split("-").map((y) => y.charAt(0).toUpperCase() + y.slice(1)).join(" "), e.color === `var(--${C})` && E.classList.add("selected"), E.addEventListener("click", (y) => {
|
|
3412
3447
|
y.preventDefault();
|
|
3413
3448
|
const b = `var(--${C})`;
|
|
3414
3449
|
this.setValue(b), this.pendingSolidColor = b, i(c);
|
|
3415
|
-
}),
|
|
3450
|
+
}), f.appendChild(E);
|
|
3416
3451
|
}
|
|
3417
3452
|
});
|
|
3418
3453
|
});
|
|
@@ -3420,14 +3455,14 @@ const P = class P extends x {
|
|
|
3420
3455
|
s.className = "global-controls-row";
|
|
3421
3456
|
const n = document.createElement("div");
|
|
3422
3457
|
n.className = "global-search-container";
|
|
3423
|
-
const
|
|
3424
|
-
|
|
3425
|
-
const
|
|
3426
|
-
|
|
3458
|
+
const a = document.createElement("span");
|
|
3459
|
+
a.className = "global-search-icon", a.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>';
|
|
3460
|
+
const o = document.createElement("input");
|
|
3461
|
+
o.type = "text", o.className = "global-search-input", o.placeholder = "Search", o.value = this.globalSearchQuery;
|
|
3427
3462
|
const l = document.createElement("div");
|
|
3428
|
-
|
|
3463
|
+
o.addEventListener("input", (c) => {
|
|
3429
3464
|
this.globalSearchQuery = c.target.value, i(l);
|
|
3430
|
-
}), n.appendChild(
|
|
3465
|
+
}), n.appendChild(a), n.appendChild(o);
|
|
3431
3466
|
const r = document.createElement("button");
|
|
3432
3467
|
r.className = "global-layout-toggle", r.type = "button";
|
|
3433
3468
|
const p = () => {
|
|
@@ -3444,9 +3479,9 @@ const P = class P extends x {
|
|
|
3444
3479
|
initialOpacity: e.opacity ?? 100,
|
|
3445
3480
|
onColorChange: (s, n) => {
|
|
3446
3481
|
if (this.value) {
|
|
3447
|
-
const
|
|
3448
|
-
if (
|
|
3449
|
-
this.value =
|
|
3482
|
+
const a = I(s);
|
|
3483
|
+
if (a && a.type !== "solid") {
|
|
3484
|
+
this.value = a, this.switchType(a.type);
|
|
3450
3485
|
return;
|
|
3451
3486
|
}
|
|
3452
3487
|
this.value.stops[0].color = s, this.value.stops[0].opacity = n, this.updateUI(), this.triggerChange(), this.pendingSolidColor = s;
|
|
@@ -3468,39 +3503,39 @@ const P = class P extends x {
|
|
|
3468
3503
|
u.value = "linear", u.textContent = "Linear";
|
|
3469
3504
|
const g = document.createElement("option");
|
|
3470
3505
|
g.value = "radial", g.textContent = "Radial", d.appendChild(u), d.appendChild(g), d.value = this.value.type === "radial" ? "radial" : "linear", i = document.createElement("input"), i.type = "text", i.inputMode = "numeric", i.className = "gradient-degree-input", i.value = `${this.value.angle ?? 90}°`, i.style.width = "75px", i.style.textAlign = "center", (!this.value.angle || this.value.stops.length < 2) && (this.value.angle = 90, i.value = "90°");
|
|
3471
|
-
const
|
|
3472
|
-
|
|
3506
|
+
const f = document.createElement("button");
|
|
3507
|
+
f.type = "button", f.className = "gradient-flip-btn", f.innerHTML = _t, d.addEventListener("change", () => {
|
|
3473
3508
|
this.switchType(d.value === "radial" ? "radial" : "linear"), i && this.updateDegreeVisibility(i);
|
|
3474
3509
|
}), i.addEventListener("focus", (m) => {
|
|
3475
|
-
const
|
|
3476
|
-
|
|
3510
|
+
const v = m.target;
|
|
3511
|
+
v.value = v.value.replace(/[^0-9-]/g, ""), setTimeout(() => v.select(), 0);
|
|
3477
3512
|
}), i.addEventListener("input", (m) => {
|
|
3478
|
-
const
|
|
3479
|
-
!Number.isNaN(
|
|
3513
|
+
const v = parseInt(m.target.value);
|
|
3514
|
+
!Number.isNaN(v) && this.value && (this.value.angle = Math.max(0, Math.min(360, v)), this.debouncedPreviewUpdate());
|
|
3480
3515
|
}), i.addEventListener("blur", (m) => {
|
|
3481
3516
|
var w;
|
|
3482
3517
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
3483
|
-
const
|
|
3484
|
-
let C = parseInt(
|
|
3485
|
-
Number.isNaN(C) && (C = ((w = this.value) == null ? void 0 : w.angle) ?? 0), C = Math.max(0, Math.min(360, C)), this.value && (this.value.angle = C),
|
|
3486
|
-
}),
|
|
3518
|
+
const v = m.target;
|
|
3519
|
+
let C = parseInt(v.value);
|
|
3520
|
+
Number.isNaN(C) && (C = ((w = this.value) == null ? void 0 : w.angle) ?? 0), C = Math.max(0, Math.min(360, C)), this.value && (this.value.angle = C), v.value = `${C}°`, this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
3521
|
+
}), f.addEventListener("click", () => {
|
|
3487
3522
|
!this.value || !this.value.stops || (this.value.stops.forEach((m) => {
|
|
3488
3523
|
m.position = 100 - m.position;
|
|
3489
|
-
}), this.value.stops.sort((m,
|
|
3490
|
-
}), c.appendChild(d), c.appendChild(i), c.appendChild(
|
|
3524
|
+
}), this.value.stops.sort((m, v) => m.position - v.position), this.updateGradientPreview(s), this.createHandles(n, s), this.updateStopsList(r), this.updateUI(), this.triggerChange());
|
|
3525
|
+
}), c.appendChild(d), c.appendChild(i), c.appendChild(f), t.appendChild(c), this.updateDegreeVisibility(i);
|
|
3491
3526
|
}
|
|
3492
3527
|
const s = document.createElement("div");
|
|
3493
3528
|
s.className = "gradient-preview", this.updateGradientPreview(s);
|
|
3494
3529
|
const n = document.createElement("div");
|
|
3495
3530
|
n.className = "gradient-handles", s.appendChild(n), t.appendChild(s), this.createHandles(n, s);
|
|
3496
|
-
const
|
|
3497
|
-
|
|
3498
|
-
const
|
|
3499
|
-
|
|
3531
|
+
const a = document.createElement("div");
|
|
3532
|
+
a.className = "gradient-stops-header";
|
|
3533
|
+
const o = document.createElement("span");
|
|
3534
|
+
o.textContent = "Stops";
|
|
3500
3535
|
const l = document.createElement("button");
|
|
3501
|
-
l.type = "button", l.className = "gradient-add-stop", l.textContent = "+",
|
|
3536
|
+
l.type = "button", l.className = "gradient-add-stop", l.textContent = "+", a.appendChild(o), a.appendChild(l);
|
|
3502
3537
|
const r = document.createElement("div");
|
|
3503
|
-
r.className = "gradient-stops", t.appendChild(
|
|
3538
|
+
r.className = "gradient-stops", t.appendChild(a), t.appendChild(r), this.updateStopsList(r);
|
|
3504
3539
|
const p = it((c) => {
|
|
3505
3540
|
const d = I(c);
|
|
3506
3541
|
d && (this.value = d, this.switchType(d.type), this.updateUI(), this.triggerChange());
|
|
@@ -3528,18 +3563,18 @@ const P = class P extends x {
|
|
|
3528
3563
|
t.innerHTML = "", !(!this.value || this.value.type === "solid" || !this.value.stops) && this.value.stops.forEach((i, s) => {
|
|
3529
3564
|
const n = document.createElement("div");
|
|
3530
3565
|
n.className = "gstop-handle", n.style.left = `${Math.max(0, Math.min(100, i.position))}%`, n.style.top = "0%";
|
|
3531
|
-
const
|
|
3532
|
-
|
|
3533
|
-
let
|
|
3566
|
+
const a = document.createElement("div");
|
|
3567
|
+
a.className = "gstop-chip", a.style.backgroundColor = i.color, n.appendChild(a);
|
|
3568
|
+
let o = !1, l = 0, r = 0;
|
|
3534
3569
|
const p = (u) => {
|
|
3535
|
-
|
|
3570
|
+
o = !0, l = u.clientX, r = this.value.stops[s].position, n.classList.add("selected"), document.addEventListener("mousemove", c), document.addEventListener("mouseup", d), u.preventDefault(), u.stopPropagation();
|
|
3536
3571
|
}, c = (u) => {
|
|
3537
|
-
if (!
|
|
3538
|
-
const g = e.getBoundingClientRect(),
|
|
3539
|
-
let m = r +
|
|
3572
|
+
if (!o || !this.value) return;
|
|
3573
|
+
const g = e.getBoundingClientRect(), f = u.clientX - l;
|
|
3574
|
+
let m = r + f / g.width * 100;
|
|
3540
3575
|
m = Math.max(0, Math.min(100, m)), this.value.stops[s].position = Math.round(m), n.style.left = `${m}%`, this.updateGradientPreview();
|
|
3541
3576
|
}, d = () => {
|
|
3542
|
-
|
|
3577
|
+
o && (o = !1, n.classList.remove("selected"), document.removeEventListener("mousemove", c), document.removeEventListener("mouseup", d), this.value && (this.value.stops.sort((u, g) => u.position - g.position), this.createHandles(t, e), this.updateStopsList()), this.updateUI(), this.triggerChange());
|
|
3543
3578
|
};
|
|
3544
3579
|
n.addEventListener("mousedown", p), t.appendChild(n);
|
|
3545
3580
|
});
|
|
@@ -3548,13 +3583,13 @@ const P = class P extends x {
|
|
|
3548
3583
|
var i;
|
|
3549
3584
|
const e = t || ((i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-stops"));
|
|
3550
3585
|
!e || !this.value || this.value.type === "solid" || !this.value.stops || (e.innerHTML = "", this.value.stops.forEach((s, n) => {
|
|
3551
|
-
var E,
|
|
3552
|
-
const o = document.createElement("div");
|
|
3553
|
-
o.className = "gstop-row";
|
|
3586
|
+
var E, M;
|
|
3554
3587
|
const a = document.createElement("div");
|
|
3555
|
-
a.className = "gstop-
|
|
3588
|
+
a.className = "gstop-row";
|
|
3589
|
+
const o = document.createElement("div");
|
|
3590
|
+
o.className = "gstop-position-group";
|
|
3556
3591
|
const l = document.createElement("input");
|
|
3557
|
-
l.type = "text", l.className = "gstop-position-input", l.value = `${s.position}%`, l.style.width = "60px",
|
|
3592
|
+
l.type = "text", l.className = "gstop-position-input", l.value = `${s.position}%`, l.style.width = "60px", o.appendChild(l);
|
|
3558
3593
|
const r = document.createElement("div");
|
|
3559
3594
|
r.className = "gstop-color-container";
|
|
3560
3595
|
const p = document.createElement("div");
|
|
@@ -3564,26 +3599,26 @@ const P = class P extends x {
|
|
|
3564
3599
|
const d = document.createElement("button");
|
|
3565
3600
|
d.type = "button", d.className = "gstop-color-copy", d.textContent = "Copy", r.appendChild(p), r.appendChild(c), r.appendChild(d);
|
|
3566
3601
|
const u = document.createElement("button");
|
|
3567
|
-
u.type = "button", u.className = "gstop-del", u.innerHTML = Jt, u.disabled = (((
|
|
3602
|
+
u.type = "button", u.className = "gstop-del", u.innerHTML = Jt, u.disabled = (((M = (E = this.value) == null ? void 0 : E.stops) == null ? void 0 : M.length) || 0) <= 2, a.appendChild(o), a.appendChild(r), a.appendChild(u), e.appendChild(a);
|
|
3568
3603
|
const g = document.createElement("span");
|
|
3569
3604
|
g.className = "gstop-opacity-label", g.textContent = "Opacity";
|
|
3570
|
-
const
|
|
3571
|
-
|
|
3605
|
+
const f = document.createElement("div");
|
|
3606
|
+
f.className = "gstop-opacity-group";
|
|
3572
3607
|
const m = document.createElement("input");
|
|
3573
3608
|
m.type = "range", m.className = "gstop-opacity-slider", m.min = "0", m.max = "100", m.value = String(s.opacity ?? 100);
|
|
3574
|
-
const
|
|
3609
|
+
const v = S(s.color);
|
|
3575
3610
|
m.style.setProperty(
|
|
3576
3611
|
"--slider-color",
|
|
3577
|
-
`rgb(${
|
|
3612
|
+
`rgb(${v.r}, ${v.g}, ${v.b})`
|
|
3578
3613
|
);
|
|
3579
3614
|
const C = document.createElement("span");
|
|
3580
|
-
C.className = "gstop-opacity-value", C.textContent = `${s.opacity ?? 100}%`,
|
|
3615
|
+
C.className = "gstop-opacity-value", C.textContent = `${s.opacity ?? 100}%`, f.appendChild(m), f.appendChild(C);
|
|
3581
3616
|
const w = new Yt((y, b) => {
|
|
3582
3617
|
c.value = y.replace("#", "").toUpperCase(), p.style.backgroundColor = y, this.value.stops[n].color = y, b !== void 0 && (this.value.stops[n].opacity = b, m.value = String(b), C.textContent = `${b}%`);
|
|
3583
|
-
const
|
|
3618
|
+
const k = S(y);
|
|
3584
3619
|
m.style.setProperty(
|
|
3585
3620
|
"--slider-color",
|
|
3586
|
-
`rgb(${
|
|
3621
|
+
`rgb(${k.r}, ${k.g}, ${k.b})`
|
|
3587
3622
|
), this.updateGradientPreview(), this.createHandles(
|
|
3588
3623
|
this.popoverEl.querySelector(".gradient-handles"),
|
|
3589
3624
|
this.popoverEl.querySelector(".gradient-preview")
|
|
@@ -3595,10 +3630,10 @@ const P = class P extends x {
|
|
|
3595
3630
|
const y = c.value.trim(), b = y.startsWith("#") ? y : `#${y}`;
|
|
3596
3631
|
if (/^#[0-9A-Fa-f]{6}$/.test(b)) {
|
|
3597
3632
|
this.value.stops[n].color = b, p.style.backgroundColor = b;
|
|
3598
|
-
const
|
|
3633
|
+
const k = S(b);
|
|
3599
3634
|
m.style.setProperty(
|
|
3600
3635
|
"--slider-color",
|
|
3601
|
-
`rgb(${
|
|
3636
|
+
`rgb(${k.r}, ${k.g}, ${k.b})`
|
|
3602
3637
|
), this.debouncedPreviewUpdate();
|
|
3603
3638
|
}
|
|
3604
3639
|
}), c.addEventListener("blur", () => {
|
|
@@ -3613,18 +3648,18 @@ const P = class P extends x {
|
|
|
3613
3648
|
const b = y.target;
|
|
3614
3649
|
b.value = b.value.replace("%", ""), b.select();
|
|
3615
3650
|
}), l.addEventListener("input", (y) => {
|
|
3616
|
-
const b = y.target,
|
|
3617
|
-
if (!Number.isNaN(
|
|
3618
|
-
const $ = Math.max(0, Math.min(100,
|
|
3651
|
+
const b = y.target, k = parseInt(b.value.replace(/[^\d]/g, ""), 10);
|
|
3652
|
+
if (!Number.isNaN(k)) {
|
|
3653
|
+
const $ = Math.max(0, Math.min(100, k));
|
|
3619
3654
|
this.value.stops[n].position = $, b.value = `${$}%`, this.debouncedPreviewUpdate();
|
|
3620
3655
|
}
|
|
3621
3656
|
}), l.addEventListener("blur", (y) => {
|
|
3622
3657
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
3623
|
-
const b = y.target,
|
|
3624
|
-
if (Number.isNaN(
|
|
3658
|
+
const b = y.target, k = parseInt(b.value.replace(/[^\d]/g, ""), 10);
|
|
3659
|
+
if (Number.isNaN(k))
|
|
3625
3660
|
b.value = `${this.value.stops[n].position}%`;
|
|
3626
3661
|
else {
|
|
3627
|
-
const $ = Math.max(0, Math.min(100,
|
|
3662
|
+
const $ = Math.max(0, Math.min(100, k));
|
|
3628
3663
|
this.value.stops[n].position = $, b.value = `${$}%`;
|
|
3629
3664
|
}
|
|
3630
3665
|
this.updateGradientPreview(), this.createHandles(
|
|
@@ -3647,32 +3682,32 @@ const P = class P extends x {
|
|
|
3647
3682
|
}
|
|
3648
3683
|
addStop() {
|
|
3649
3684
|
if (!this.value || this.value.type === "solid" || !this.value.stops) return;
|
|
3650
|
-
const t = this.value.stops.map((
|
|
3685
|
+
const t = this.value.stops.map((a) => a.position).sort((a, o) => a - o);
|
|
3651
3686
|
let e = 50, i = 0;
|
|
3652
|
-
for (let
|
|
3653
|
-
const
|
|
3654
|
-
|
|
3687
|
+
for (let a = 0; a < t.length - 1; a++) {
|
|
3688
|
+
const o = t[a + 1] - t[a];
|
|
3689
|
+
o > i && (i = o, e = t[a] + o / 2);
|
|
3655
3690
|
}
|
|
3656
3691
|
const s = this.value.stops.reduce(
|
|
3657
|
-
(
|
|
3692
|
+
(a, o) => Math.abs(o.position - e) < Math.abs(a.position - e) ? o : a
|
|
3658
3693
|
), n = {
|
|
3659
3694
|
position: Math.round(e),
|
|
3660
3695
|
color: s.color,
|
|
3661
3696
|
opacity: s.opacity ?? 100
|
|
3662
3697
|
};
|
|
3663
|
-
this.value.stops.push(n), this.value.stops.sort((
|
|
3698
|
+
this.value.stops.push(n), this.value.stops.sort((a, o) => a.position - o.position);
|
|
3664
3699
|
}
|
|
3665
3700
|
openPopover() {
|
|
3666
3701
|
if (this.popoverEl && (P.openInstance && P.openInstance !== this && P.openInstance.closePopover(), !this.isPopoverOpen)) {
|
|
3667
3702
|
if (this.isPopoverOpen = !0, P.openInstance = this, this.backdropEl && (this.backdropEl.style.display = "block", this.backdropEl.parentElement || document.body.appendChild(this.backdropEl)), this.popoverEl.style.display = "flex", this.refreshPopoverContent(), this.element) {
|
|
3668
3703
|
const t = this.element.getBoundingClientRect(), e = 306, i = window.innerWidth, s = window.innerHeight, n = 16;
|
|
3669
3704
|
this.popoverEl.style.position = "fixed", this.popoverEl.style.zIndex = "10000", this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3670
|
-
const
|
|
3671
|
-
let
|
|
3705
|
+
const a = this.popoverEl.offsetHeight;
|
|
3706
|
+
let o = t.right + 8, l = t.top;
|
|
3672
3707
|
const r = i - t.right, p = t.left, c = e + n;
|
|
3673
|
-
r < c && p > r + 100 && (
|
|
3708
|
+
r < c && p > r + 100 && (o = t.left - e - 8);
|
|
3674
3709
|
const d = s - t.bottom, u = t.top;
|
|
3675
|
-
u >=
|
|
3710
|
+
u >= a + n ? l = t.top - a - 8 : d >= a + n ? l = t.bottom + 8 : u > d ? (l = t.top - a - 8, l < n && (l = n)) : (l = t.bottom + 8, l + a > s - n && (l = s - a - n)), this.popoverEl.style.left = `${o}px`, this.popoverEl.style.top = `${l}px`, this.popoverPosition = { left: o, top: l };
|
|
3676
3711
|
}
|
|
3677
3712
|
setTimeout(
|
|
3678
3713
|
() => document.addEventListener("click", this.onBackgroundClick, !0),
|
|
@@ -3689,24 +3724,24 @@ const P = class P extends x {
|
|
|
3689
3724
|
}
|
|
3690
3725
|
requestAnimationFrame(() => {
|
|
3691
3726
|
if (!this.popoverEl || !this.element) return;
|
|
3692
|
-
const e = this.element.getBoundingClientRect(), i = 306, s = window.innerWidth, n = window.innerHeight,
|
|
3727
|
+
const e = this.element.getBoundingClientRect(), i = 306, s = window.innerWidth, n = window.innerHeight, a = 16;
|
|
3693
3728
|
this.popoverEl.style.left, this.popoverEl.style.top, this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3694
|
-
const
|
|
3729
|
+
const o = this.popoverEl.offsetHeight;
|
|
3695
3730
|
let l = e.right + 8, r = e.top;
|
|
3696
|
-
const p = s - e.right, c = e.left, d = i +
|
|
3731
|
+
const p = s - e.right, c = e.left, d = i + a;
|
|
3697
3732
|
p < d && c > p + 100 && (l = e.left - i - 8);
|
|
3698
3733
|
const u = n - e.bottom, g = e.top;
|
|
3699
|
-
g >=
|
|
3734
|
+
g >= o + a ? r = e.top - o - 8 : u >= o + a ? r = e.bottom + 8 : g > u ? (r = e.top - o - 8, r < a && (r = a)) : (r = e.bottom + 8, r + o > n - a && (r = n - o - a)), this.popoverEl.style.left = `${l}px`, this.popoverEl.style.top = `${r}px`;
|
|
3700
3735
|
});
|
|
3701
3736
|
}
|
|
3702
3737
|
}
|
|
3703
3738
|
refreshPopoverContent() {
|
|
3704
|
-
var n,
|
|
3739
|
+
var n, a;
|
|
3705
3740
|
if (!this.popoverEl) return;
|
|
3706
3741
|
const t = this.popoverEl.querySelectorAll(".gradient-type-tab");
|
|
3707
|
-
t.forEach((
|
|
3742
|
+
t.forEach((o) => o.classList.remove("active"));
|
|
3708
3743
|
const e = t[0], i = t[1];
|
|
3709
|
-
((n = this.value) == null ? void 0 : n.type) === "solid" ? e.classList.add("active") : (i.classList.add("active"), (
|
|
3744
|
+
((n = this.value) == null ? void 0 : n.type) === "solid" ? e.classList.add("active") : (i.classList.add("active"), (a = this.recentGradientRefresh) == null || a.call(this)), this.popoverEl.offsetHeight;
|
|
3710
3745
|
const s = this.popoverEl.querySelector(".gradient-editor-content");
|
|
3711
3746
|
s && this.updatePopoverContent(s);
|
|
3712
3747
|
}
|
|
@@ -3715,13 +3750,13 @@ const P = class P extends x {
|
|
|
3715
3750
|
if (!(!this.popoverEl || !this.isPopoverOpen)) {
|
|
3716
3751
|
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") {
|
|
3717
3752
|
const e = T(this.value);
|
|
3718
|
-
|
|
3753
|
+
D.addColor(e, "gradient"), (t = this.recentGradientRefresh) == null || t.call(this);
|
|
3719
3754
|
}
|
|
3720
3755
|
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), P.openInstance === this && (P.openInstance = null);
|
|
3721
3756
|
}
|
|
3722
3757
|
}
|
|
3723
3758
|
commitPendingSolidColor() {
|
|
3724
|
-
this.pendingSolidColor && (this.solidPicker ? this.solidPicker.commitRecentColor() :
|
|
3759
|
+
this.pendingSolidColor && (this.solidPicker ? this.solidPicker.commitRecentColor() : D.addColor(this.pendingSolidColor, "solid"), this.pendingSolidColor = null);
|
|
3725
3760
|
}
|
|
3726
3761
|
handlePaste(t) {
|
|
3727
3762
|
var i;
|
|
@@ -3797,7 +3832,7 @@ class xe extends H {
|
|
|
3797
3832
|
const t = super.getValues(), e = this.settings.color.getValue();
|
|
3798
3833
|
return {
|
|
3799
3834
|
...t,
|
|
3800
|
-
color: e ? `${e}
|
|
3835
|
+
color: e ? `${e}` : t.color
|
|
3801
3836
|
};
|
|
3802
3837
|
}
|
|
3803
3838
|
getCssCode() {
|
|
@@ -3879,8 +3914,8 @@ class Le extends H {
|
|
|
3879
3914
|
});
|
|
3880
3915
|
}
|
|
3881
3916
|
getCssCode() {
|
|
3882
|
-
var
|
|
3883
|
-
const t = this.settings.color.getValue() ?? "#000000", e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((
|
|
3917
|
+
var a;
|
|
3918
|
+
const t = this.settings.color.getValue() ?? "#000000", e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((a = this.settings.align) == null ? void 0 : a.value) ?? "left";
|
|
3884
3919
|
return `
|
|
3885
3920
|
color: ${t};
|
|
3886
3921
|
font-family: ${e};
|
|
@@ -3890,8 +3925,8 @@ class Le extends H {
|
|
|
3890
3925
|
`;
|
|
3891
3926
|
}
|
|
3892
3927
|
getTextGradientCss() {
|
|
3893
|
-
var
|
|
3894
|
-
const t = this.settings.color.getCSSForText(), e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((
|
|
3928
|
+
var o;
|
|
3929
|
+
const t = this.settings.color.getCSSForText(), e = this.settings.fontFamily.value ?? "Satoshi", i = this.settings.fontWeight.value ?? "bold", s = this.settings.fontSize.value ?? 12, n = ((o = this.settings.align) == null ? void 0 : o.value) ?? "left";
|
|
3895
3930
|
return `
|
|
3896
3931
|
${Object.entries(t).map(([l, r]) => `${l}: ${r};`).join(`
|
|
3897
3932
|
`)}
|
|
@@ -3910,11 +3945,11 @@ class j extends x {
|
|
|
3910
3945
|
}), this.inputType = "number", this.value = t.default !== void 0 ? t.default : "auto";
|
|
3911
3946
|
}
|
|
3912
3947
|
draw() {
|
|
3913
|
-
const t = this.value === "auto" ? "text" : "number", e = (
|
|
3914
|
-
this.value !== "auto" && (this.props.minValue !== void 0 && (
|
|
3948
|
+
const t = this.value === "auto" ? "text" : "number", e = (o) => {
|
|
3949
|
+
this.value !== "auto" && (this.props.minValue !== void 0 && (o.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (o.max = String(this.props.maxValue)), this.props.className && o.classList.add(this.props.className), o.addEventListener("input", () => {
|
|
3915
3950
|
const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
3916
|
-
let p = Number(
|
|
3917
|
-
p < l && (p = l), p > r && (p = r),
|
|
3951
|
+
let p = Number(o.value);
|
|
3952
|
+
p < l && (p = l), p > r && (p = r), o.value = String(p);
|
|
3918
3953
|
}));
|
|
3919
3954
|
}, i = this.createInput({
|
|
3920
3955
|
value: this.value,
|
|
@@ -3935,9 +3970,9 @@ class j extends x {
|
|
|
3935
3970
|
s && (s.style.paddingRight = "35px");
|
|
3936
3971
|
const n = document.createElement("span");
|
|
3937
3972
|
n.className = "suffix-label", n.textContent = this.props.suffix, i.appendChild(n);
|
|
3938
|
-
const
|
|
3939
|
-
return
|
|
3940
|
-
const l =
|
|
3973
|
+
const a = i.querySelector("input");
|
|
3974
|
+
return a && (a.oninput = (o) => {
|
|
3975
|
+
const l = o.target.value.trim();
|
|
3941
3976
|
if (l.toLowerCase() === "auto")
|
|
3942
3977
|
this.value = "auto";
|
|
3943
3978
|
else {
|
|
@@ -4022,10 +4057,10 @@ class Me extends H {
|
|
|
4022
4057
|
draw() {
|
|
4023
4058
|
const t = super.draw(), e = t.querySelector(".setting-group-content");
|
|
4024
4059
|
if (!e) return t;
|
|
4025
|
-
const i = Array.from(e.children), [s, n,
|
|
4060
|
+
const i = Array.from(e.children), [s, n, a] = i;
|
|
4026
4061
|
e.innerHTML = "", e.appendChild(s), e.appendChild(n);
|
|
4027
|
-
const
|
|
4028
|
-
return
|
|
4062
|
+
const o = document.createElement("div");
|
|
4063
|
+
return o.className = "bgset-or-label", o.textContent = "OR", e.appendChild(o), e.appendChild(a), t;
|
|
4029
4064
|
}
|
|
4030
4065
|
getCssCode() {
|
|
4031
4066
|
const t = this.settings.backgroundImage.value || "", e = this.settings.opacity.value ?? 100, i = this.settings.backgroundColor.value || "#000000";
|
|
@@ -4059,21 +4094,21 @@ export {
|
|
|
4059
4094
|
Ee as MultiLanguageSetting,
|
|
4060
4095
|
V as NumberSetting,
|
|
4061
4096
|
Nt as OpacitySetting,
|
|
4062
|
-
|
|
4097
|
+
fe as SelectApiSettings,
|
|
4063
4098
|
tt as SelectSetting,
|
|
4064
4099
|
x as Setting,
|
|
4065
4100
|
H as SettingGroup,
|
|
4066
4101
|
Lt as StringSetting,
|
|
4067
4102
|
wt as TabSettingGroup,
|
|
4068
4103
|
wt as TabsSettingGroup,
|
|
4069
|
-
|
|
4104
|
+
ve as Toggle,
|
|
4070
4105
|
ct as UploadSetting,
|
|
4071
4106
|
me as WidthSetting,
|
|
4072
4107
|
he as asSettingGroupWithSettings,
|
|
4073
4108
|
xt as createSettingGroup,
|
|
4074
4109
|
ce as createTabSettingGroup,
|
|
4075
|
-
|
|
4110
|
+
A as isSetting,
|
|
4076
4111
|
nt as isSettingChild,
|
|
4077
|
-
|
|
4112
|
+
L as isSettingGroup,
|
|
4078
4113
|
z as iterateSettings
|
|
4079
4114
|
};
|