builder-settings-types 0.0.95 → 0.0.96

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,20 +1,20 @@
1
- const B = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2
- let R = (c = 21) => {
3
- let t = "", e = crypto.getRandomValues(new Uint8Array(c |= 0));
4
- for (; c--; )
5
- t += B[e[c] & 63];
1
+ const R = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2
+ let I = (r = 21) => {
3
+ let t = "", e = crypto.getRandomValues(new Uint8Array(r |= 0));
4
+ for (; r--; )
5
+ t += R[e[r] & 63];
6
6
  return t;
7
7
  };
8
- function O(c, t) {
9
- for (const e in c)
10
- if (c.hasOwnProperty(e)) {
11
- const i = c[e];
8
+ function B(r, t) {
9
+ for (const e in r)
10
+ if (r.hasOwnProperty(e)) {
11
+ const i = r[e];
12
12
  t(e, i);
13
13
  }
14
14
  }
15
- const b = class b {
15
+ const x = class x {
16
16
  constructor(t) {
17
- this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.id = t.id || R(), this.title = t.title, this.settings = t.settings, this.description = t.description, this.icon = t.icon, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.hideCondition = t.hideCondition, this.onBlur = t.onBlur, Object.assign(this, t.settings), this.initialValues = this.getValues();
17
+ this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.id = t.id || I(), this.title = t.title, this.settings = t.settings, this.description = t.description, this.icon = t.icon, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.hideCondition = t.hideCondition, this.onBlur = t.onBlur, Object.assign(this, t.settings), this.initialValues = this.getValues();
18
18
  }
19
19
  static hide() {
20
20
  this.hiddenElements.forEach((t) => {
@@ -27,29 +27,37 @@ const b = class b {
27
27
  });
28
28
  }
29
29
  setOnChange(t) {
30
- return this.onChange = t, O(this.settings, (e, i) => {
30
+ return this.onChange = t, B(this.settings, (e, i) => {
31
31
  i.setOnChange((s) => {
32
32
  t(s), this.updateVisibility();
33
33
  });
34
34
  }), this;
35
35
  }
36
36
  setOnBlur(t) {
37
- return this.onBlur = t, this.elementRef && this.elementRef.addEventListener("mouseleave", () => {
38
- const e = this.getValues();
39
- this.calculateChanges(this.initialValues, e), t(), this.updateVisibility(), this.initialValues = e;
40
- }), O(this.settings, (e, i) => {
41
- i instanceof b && i.setOnBlur(() => {
42
- const s = this.getValues();
43
- t(), this.updateVisibility(), this.initialValues = s;
44
- });
45
- }), this;
37
+ return this.onBlur = t, this.elementRef && this.elementRef.addEventListener(
38
+ "blur",
39
+ (e) => {
40
+ var i;
41
+ if (!((i = this.elementRef) != null && i.contains(e.relatedTarget))) {
42
+ const s = this.getValues();
43
+ this.calculateChanges(
44
+ this.initialValues,
45
+ s
46
+ ), t(), this.updateVisibility(), this.initialValues = s;
47
+ }
48
+ },
49
+ !0
50
+ ), this;
46
51
  }
47
52
  calculateChanges(t, e) {
48
53
  const i = {};
49
54
  for (const s in e)
50
55
  if (e.hasOwnProperty(s))
51
56
  if (typeof e[s] == "object" && e[s] !== null) {
52
- const n = this.calculateChanges(t[s] || {}, e[s]);
57
+ const n = this.calculateChanges(
58
+ t[s] || {},
59
+ e[s]
60
+ );
53
61
  Object.keys(n).length > 0 && (i[s] = n);
54
62
  } else t[s] !== e[s] && (i[s] = {
55
63
  from: t[s],
@@ -69,17 +77,17 @@ const b = class b {
69
77
  for (const i in this.settings)
70
78
  if (this.settings.hasOwnProperty(i)) {
71
79
  const s = this.settings[i];
72
- s instanceof b ? e[i] = s.getValues() : e[i] = s.value;
80
+ s instanceof x ? e[i] = s.getValues() : e[i] = s.value;
73
81
  }
74
82
  return e;
75
83
  } else {
76
84
  const e = this.settings[t];
77
- return e ? e instanceof b ? e.getValues() : e.value : void 0;
85
+ return e ? e instanceof x ? e.getValues() : e.value : void 0;
78
86
  }
79
87
  }
80
88
  draw() {
81
89
  const t = document.createElement("div");
82
- t.className = "setting-group", t.id = `setting-group-${this.id}`, b.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
90
+ t.className = "setting-group", t.id = `setting-group-${this.id}`, x.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
83
91
  const e = document.createElement("div");
84
92
  e.className = "setting-group-title", this.isCollapsed && e.classList.add("collapsed-view"), e.setAttribute("role", "button"), e.setAttribute(
85
93
  "aria-expanded",
@@ -183,10 +191,10 @@ const b = class b {
183
191
  this.isHidden ? this.show() : this.hide();
184
192
  }
185
193
  };
186
- b.hiddenElements = /* @__PURE__ */ new Set();
187
- let v = b;
188
- function W(c) {
189
- switch (c) {
194
+ x.hiddenElements = /* @__PURE__ */ new Set();
195
+ let f = x;
196
+ function W(r) {
197
+ switch (r) {
190
198
  case "number":
191
199
  return 0;
192
200
  case "text":
@@ -203,9 +211,9 @@ function W(c) {
203
211
  return "";
204
212
  }
205
213
  }
206
- class C {
214
+ class m {
207
215
  constructor(t = {}) {
208
- this.props = t, this.id = t.id || R(), this.value = this.props.default, this.title = t.title || "";
216
+ this.props = t, this.id = t.id || I(), this.value = this.props.default, this.title = t.title || "";
209
217
  }
210
218
  destroy() {
211
219
  throw new Error("Method not implemented.");
@@ -273,7 +281,7 @@ class C {
273
281
  return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
274
282
  }
275
283
  }
276
- class H extends C {
284
+ class H extends m {
277
285
  constructor(t = {}) {
278
286
  super(t), this.inputType = "text", t.onChange && this.setOnChange(t.onChange);
279
287
  }
@@ -293,12 +301,12 @@ class H extends C {
293
301
  });
294
302
  }
295
303
  }
296
- const T = "<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";
304
+ const N = "<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";
297
305
  class S extends H {
298
306
  constructor(t) {
299
307
  super({
300
308
  ...t,
301
- icon: t.icon || T,
309
+ icon: t.icon || N,
302
310
  title: t.title || "Color"
303
311
  }), this.inputType = "color", this.detectChange = t.detectChange;
304
312
  }
@@ -321,15 +329,15 @@ class S extends H {
321
329
  t.className = "color-setting-wrapper";
322
330
  const e = document.createElement("div");
323
331
  e.className = "icon-container";
324
- const i = this.createIcon(this.props.icon || T), s = this.createLabel(this.title || "Color");
332
+ const i = this.createIcon(this.props.icon || N), s = this.createLabel(this.title || "Color");
325
333
  e.appendChild(i), e.appendChild(s);
326
334
  const n = document.createElement("div");
327
335
  n.className = "color-input-wrapper";
328
336
  const a = (p) => {
329
- const g = p.value.split(",").map((N) => parseInt(N.trim()));
337
+ const g = p.value.split(",").map((O) => parseInt(O.trim()));
330
338
  if (g.length !== 3 || g.some(isNaN))
331
339
  return p.style.border = "1px solid red", !1;
332
- const [d, m, f] = g, L = d >= 0 && d <= 255 && m >= 0 && m <= 255 && f >= 0 && f <= 255;
340
+ const [d, C, v] = g, L = d >= 0 && d <= 255 && C >= 0 && C <= 255 && v >= 0 && v <= 255;
333
341
  return p.style.border = L ? "" : "1px solid red", L;
334
342
  }, o = document.createElement("div");
335
343
  o.className = "color-preview", o.style.backgroundColor = this.value ? `rgb(${this.value})` : "";
@@ -337,27 +345,27 @@ class S extends H {
337
345
  value: this.value,
338
346
  inputType: "text",
339
347
  inputClassName: "color-text-input"
340
- }), r = l.querySelector("input"), h = this.createInput({
348
+ }), c = l.querySelector("input"), h = this.createInput({
341
349
  value: this.value ? this.rgbToHex(this.value) : "",
342
350
  inputType: this.inputType,
343
351
  inputClassName: "color-picker"
344
352
  }), u = h.querySelector("input");
345
- return r.oninput = (p) => {
353
+ return c.oninput = (p) => {
346
354
  var d;
347
355
  let g = p.target.value.trim();
348
- a(r) && (this.value = g, (d = this.onChange) == null || d.call(this, g), u.value = this.rgbToHex(g), o.style.backgroundColor = `rgb(${g})`);
356
+ a(c) && (this.value = g, (d = this.onChange) == null || d.call(this, g), u.value = this.rgbToHex(g), o.style.backgroundColor = `rgb(${g})`);
349
357
  }, u.oninput = (p) => {
350
- var m, f;
358
+ var C, v;
351
359
  const g = p.target.value, d = this.hexToRgb(g);
352
- this.value = d, (m = this.onChange) == null || m.call(this, d), (f = this.detectChange) == null || f.call(this, d), r.value = d, o.style.backgroundColor = `rgb(${d})`;
360
+ this.value = d, (C = this.onChange) == null || C.call(this, d), (v = this.detectChange) == null || v.call(this, d), c.value = d, o.style.backgroundColor = `rgb(${d})`;
353
361
  }, u.onchange = (p) => {
354
- var m, f;
362
+ var C, v;
355
363
  const g = p.target.value, d = this.hexToRgb(g);
356
- this.value = d, (m = this.onChange) == null || m.call(this, d), (f = this.detectChange) == null || f.call(this, d), r.value = d, o.style.backgroundColor = `rgb(${d})`;
357
- }, n.appendChild(o), n.appendChild(h), n.appendChild(l), t.appendChild(e), t.appendChild(n), this.value && (r.value = this.value, u.value = this.rgbToHex(this.value), o.style.backgroundColor = `rgb(${this.value})`), t;
364
+ this.value = d, (C = this.onChange) == null || C.call(this, d), (v = this.detectChange) == null || v.call(this, d), c.value = d, o.style.backgroundColor = `rgb(${d})`;
365
+ }, n.appendChild(o), n.appendChild(h), n.appendChild(l), t.appendChild(e), t.appendChild(n), this.value && (c.value = this.value, u.value = this.rgbToHex(this.value), o.style.backgroundColor = `rgb(${this.value})`), t;
358
366
  }
359
367
  }
360
- class w extends C {
368
+ class w extends m {
361
369
  constructor(t = {}) {
362
370
  super(t), this.inputType = "number";
363
371
  }
@@ -412,7 +420,7 @@ const A = `
412
420
  <polyline points="6 9 12 15 18 9"></polyline>
413
421
  </svg>
414
422
  `;
415
- class V extends C {
423
+ class T extends m {
416
424
  constructor(t = {}) {
417
425
  if (super(t), this.inputType = "select", this._options = [], this.isOpen = !1, this.selectedOptionIndex = null, this.optionsListEl = null, this.svgContainer = null, this.buttonEl = null, this.isLoading = !1, this.container = null, this.clickOutsideListener = null, t.options && (this._options = [...t.options]), t.getOptions && this._options.push(...t.getOptions()), t.getOptionsAsync && (this.isLoading = !0), this.value !== void 0) {
418
426
  const e = this._options.findIndex((i) => i.value === this.value);
@@ -463,8 +471,8 @@ class V extends C {
463
471
  selectOption(t, e, i) {
464
472
  var n, a, o;
465
473
  const s = this._options[e];
466
- s && (this.value = s.value, (n = this.onChange) == null || n.call(this, this.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((r, h) => {
467
- h === e ? r.classList.add("selected") : r.classList.remove("selected");
474
+ s && (this.value = s.value, (n = this.onChange) == null || n.call(this, this.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((c, h) => {
475
+ h === e ? c.classList.add("selected") : c.classList.remove("selected");
468
476
  }));
469
477
  }
470
478
  updateOptionsList() {
@@ -496,7 +504,7 @@ class V extends C {
496
504
  this.clickOutsideListener && (document.removeEventListener("click", this.clickOutsideListener), this.clickOutsideListener = null), super.destroy();
497
505
  }
498
506
  }
499
- class _ extends C {
507
+ class _ extends m {
500
508
  constructor(t = {}) {
501
509
  super(t), this.inputType = "button", this.value || (this.value = "center");
502
510
  }
@@ -549,7 +557,7 @@ class _ extends C {
549
557
  }), t.appendChild(i), t;
550
558
  }
551
559
  }
552
- class nt extends C {
560
+ class nt extends m {
553
561
  constructor(t) {
554
562
  super(t), this.inputType = "button";
555
563
  }
@@ -562,7 +570,7 @@ class nt extends C {
562
570
  return e.className = "button-setting-wrapper " + (this.props.wrapperClassName || ""), e.appendChild(t), e;
563
571
  }
564
572
  }
565
- class at extends C {
573
+ class at extends m {
566
574
  constructor(t = {}) {
567
575
  super(t), this.inputType = { width: "number", height: "number" }, this.aspectRatio = 1, this.isUpdating = !1;
568
576
  const e = t.width || 100, i = t.height || 100;
@@ -575,14 +583,14 @@ class at extends C {
575
583
  suffix: "px",
576
584
  minValue: this.minWidth,
577
585
  maxValue: this.maxWidth,
578
- icon: j
586
+ icon: G
579
587
  }), this.heightSetting = new w({
580
588
  title: "Height",
581
589
  default: this.value.height,
582
590
  suffix: "px",
583
591
  minValue: this.minHeight,
584
592
  maxValue: this.maxHeight,
585
- icon: G
593
+ icon: j
586
594
  }), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
587
595
  }
588
596
  handleWidthChange(t) {
@@ -674,15 +682,15 @@ class at extends C {
674
682
  }
675
683
  }
676
684
  }
677
- const j = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
685
+ const G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
678
686
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
679
- </svg>`, G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
687
+ </svg>`, j = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
680
688
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
681
689
  </svg>`, y = `
682
690
  <svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
683
691
  <path d="M5 10.5L7.5 8M7.5 8L10 10.5M7.5 8V13.625M12.5 10.9643C13.2634 10.3338 13.75 9.37996 13.75 8.3125C13.75 6.41402 12.211 4.875 10.3125 4.875C10.1759 4.875 10.0482 4.80375 9.97882 4.68609C9.16379 3.30302 7.65902 2.375 5.9375 2.375C3.34867 2.375 1.25 4.47367 1.25 7.0625C1.25 8.35381 1.77215 9.52317 2.61684 10.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
684
692
  </svg>
685
- `, I = `
693
+ `, V = `
686
694
  <svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
687
695
  <rect width="91" height="71" rx="4" fill="#F2F4F7"/>
688
696
  <path d="M37 31.5L39.5 29M39.5 29L42 31.5M39.5 29V34.625M44.5 31.9643C45.2634 31.3338 45.75 30.38 45.75 29.3125C45.75 27.414 44.211 25.875 42.3125 25.875C42.1759 25.875 42.0482 25.8037 41.9788 25.6861C41.1638 24.303 39.659 23.375 37.9375 23.375C35.3487 23.375 33.25 25.4737 33.25 28.0625C33.25 29.3538 33.7721 30.5232 34.6168 31.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
@@ -692,7 +700,7 @@ const j = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBo
692
700
  <path d="M8 3V2.6C8 2.03995 8 1.75992 7.89101 1.54601C7.79513 1.35785 7.64215 1.20487 7.45399 1.10899C7.24008 1 6.96005 1 6.4 1H5.6C5.03995 1 4.75992 1 4.54601 1.10899C4.35785 1.20487 4.20487 1.35785 4.10899 1.54601C4 1.75992 4 2.03995 4 2.6V3M5 5.75V8.25M7 5.75V8.25M1.5 3H10.5M9.5 3V8.6C9.5 9.44008 9.5 9.86012 9.33651 10.181C9.1927 10.4632 8.96323 10.6927 8.68099 10.8365C8.36012 11 7.94008 11 7.1 11H4.9C4.05992 11 3.63988 11 3.31901 10.8365C3.03677 10.6927 2.8073 10.4632 2.66349 10.181C2.5 9.86012 2.5 9.44008 2.5 8.6V3" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
693
701
  </svg>
694
702
  `;
695
- class F extends C {
703
+ class F extends m {
696
704
  constructor(t = {}) {
697
705
  super(t), this.inputType = "button", this.previewWrapper = null, this.previewEl = null, this.emptyStateEl = null, !this.value && t.defaultUrl && t.defaultUrl !== "" && (this.value = t.defaultUrl);
698
706
  }
@@ -714,23 +722,23 @@ class F extends C {
714
722
  t.className = "upload-setting-wrapper";
715
723
  const e = !!(this.props.title || this.props.icon);
716
724
  if (e || t.classList.add("no-label"), e) {
717
- const r = document.createElement("div");
718
- if (r.className = "icon-title-container", this.props.icon) {
725
+ const c = document.createElement("div");
726
+ if (c.className = "icon-title-container", this.props.icon) {
719
727
  const h = this.createIcon(this.props.icon);
720
- r.appendChild(h);
728
+ c.appendChild(h);
721
729
  }
722
730
  if (this.props.title) {
723
731
  const h = this.createLabel(this.props.title);
724
- r.appendChild(h);
732
+ c.appendChild(h);
725
733
  }
726
- t.appendChild(r);
734
+ t.appendChild(c);
727
735
  }
728
736
  const i = document.createElement("div");
729
737
  i.className = "preview-button-container";
730
738
  const s = this.value && this.value !== "";
731
739
  s || i.classList.add("no-image");
732
740
  const n = document.createElement("div");
733
- n.className = "preview-placeholder", n.innerHTML = I, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.emptyStateEl = document.createElement("div"), this.emptyStateEl.className = "empty-state", this.emptyStateEl.innerHTML = I, this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview";
741
+ n.className = "preview-placeholder", n.innerHTML = V, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.emptyStateEl = document.createElement("div"), this.emptyStateEl.className = "empty-state", this.emptyStateEl.innerHTML = V, this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview";
734
742
  const a = document.createElement("button");
735
743
  a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML = q, this.previewWrapper.appendChild(this.emptyStateEl), this.previewWrapper.appendChild(this.previewEl), this.previewWrapper.appendChild(a);
736
744
  const o = document.createElement("button");
@@ -739,35 +747,35 @@ class F extends C {
739
747
  <span class="upload-label">Upload</span>
740
748
  `;
741
749
  const l = document.createElement("input");
742
- return l.type = "file", l.accept = "image/*", l.style.display = "none", i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(o), t.appendChild(i), t.appendChild(l), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), a.onclick = (r) => {
750
+ return l.type = "file", l.accept = "image/*", l.style.display = "none", i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(o), t.appendChild(i), t.appendChild(l), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), a.onclick = (c) => {
743
751
  var h;
744
- r.stopPropagation(), this.value = "", this.updatePreviewState(null), (h = this.onChange) == null || h.call(this, "");
752
+ c.stopPropagation(), this.value = "", this.updatePreviewState(null), (h = this.onChange) == null || h.call(this, "");
745
753
  }, o.onclick = () => {
746
754
  l.click();
747
755
  }, l.onchange = async () => {
748
756
  var h, u, p;
749
- const r = (h = l.files) == null ? void 0 : h[0];
750
- if (r)
757
+ const c = (h = l.files) == null ? void 0 : h[0];
758
+ if (c)
751
759
  try {
752
760
  o.classList.add("loading"), o.disabled = !0;
753
761
  const g = new FormData(), d = this.props.formFieldName || "file";
754
- g.append(d, r, r.name);
755
- const m = this.props.uploadUrl;
756
- if (!m)
762
+ g.append(d, c, c.name);
763
+ const C = this.props.uploadUrl;
764
+ if (!C)
757
765
  throw new Error("No uploadUrl provided to UploadSetting.");
758
- const f = this.props.requestMethod || "POST", L = { ...this.props.requestHeaders || {} }, E = await (await fetch(m, {
759
- method: f,
766
+ const v = this.props.requestMethod || "POST", L = { ...this.props.requestHeaders || {} }, E = await (await fetch(C, {
767
+ method: v,
760
768
  body: g,
761
769
  headers: L
762
770
  })).json();
763
- let x;
771
+ let b;
764
772
  if (this.props.parseResponse)
765
- x = this.props.parseResponse(E);
766
- else if (x = (u = E == null ? void 0 : E.data) == null ? void 0 : u.url, !x)
773
+ b = this.props.parseResponse(E);
774
+ else if (b = (u = E == null ? void 0 : E.data) == null ? void 0 : u.url, !b)
767
775
  throw new Error(
768
776
  "No URL found in response. Provide a parseResponse if needed."
769
777
  );
770
- this.value = x, this.updatePreviewState(x), (p = this.onChange) == null || p.call(this, x);
778
+ this.value = b, this.updatePreviewState(b), (p = this.onChange) == null || p.call(this, b);
771
779
  } catch (g) {
772
780
  console.error("Error uploading file:", g), this.updatePreviewState(null);
773
781
  } finally {
@@ -776,7 +784,7 @@ class F extends C {
776
784
  }, t;
777
785
  }
778
786
  }
779
- class ot extends C {
787
+ class ot extends m {
780
788
  constructor(t = {}) {
781
789
  super(t), this.inputType = "number", this.value = this.value ?? 100, this.numberSetting = new w({
782
790
  title: "Height",
@@ -797,7 +805,7 @@ class ot extends C {
797
805
  const z = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
798
806
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
799
807
  </svg>`;
800
- class lt extends C {
808
+ class lt extends m {
801
809
  constructor(t = {}) {
802
810
  super(t), this.inputType = "number", this.value = this.value ?? 100, this.numberSetting = new w({
803
811
  title: "Width",
@@ -822,7 +830,7 @@ const U = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBo
822
830
  <polyline points="6 9 12 15 18 9"></polyline>
823
831
  </svg>
824
832
  `;
825
- class ht extends C {
833
+ class ht extends m {
826
834
  constructor(t = {}) {
827
835
  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.initializeOptions(t), t.default !== void 0 && (this.value = t.default, this.selectedOptionIndex = this._options.findIndex(
828
836
  (e) => JSON.stringify(e.value) === JSON.stringify(t.default)
@@ -888,8 +896,8 @@ class ht extends C {
888
896
  const o = s.value;
889
897
  this.value = o, this.onChange && this.onChange(o), this.detectChangeCallback && this.detectChangeCallback(o), this.selectedOptionIndex = e, this.isOpen = !1, this.updateButtonText(), (n = this.optionsListEl) == null || n.classList.remove("open"), (a = this.svgContainer) == null || a.classList.remove("open"), this.optionsListEl && this.optionsListEl.querySelectorAll(
890
898
  ".select-api-radio"
891
- ).forEach((r, h) => {
892
- r.checked = h === e;
899
+ ).forEach((c, h) => {
900
+ c.checked = h === e;
893
901
  });
894
902
  }
895
903
  }
@@ -945,7 +953,7 @@ class ht extends C {
945
953
  this.detectChangeCallback = t;
946
954
  }
947
955
  }
948
- class rt extends C {
956
+ class rt extends m {
949
957
  constructor(t) {
950
958
  super(t), this.inputType = "text", this.value = t.default ?? !1;
951
959
  }
@@ -975,7 +983,7 @@ class rt extends C {
975
983
  const Z = `<svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
976
984
  <path d="M1.25 7.5H1.2575M4.625 7.5H4.6325M11.375 7.5H11.3825M8 7.5H8.0075M14.75 7.5H14.7575M14.75 14.25V13.65C14.75 12.8099 14.75 12.3899 14.5865 12.069C14.4427 11.7868 14.2132 11.5573 13.931 11.4135C13.6101 11.25 13.1901 11.25 12.35 11.25H3.65C2.80992 11.25 2.38988 11.25 2.06901 11.4135C1.78677 11.5573 1.5573 11.7868 1.41349 12.069C1.25 12.3899 1.25 12.8099 1.25 13.65V14.25M14.75 0.75V1.35C14.75 2.19008 14.75 2.61012 14.5865 2.93099C14.4427 3.21323 14.2132 3.4427 13.931 3.58651C13.6101 3.75 13.1901 3.75 12.35 3.75H3.65C2.80992 3.75 2.38988 3.75 2.06901 3.58651C1.78677 3.4427 1.5573 3.21323 1.41349 2.93099C1.25 2.61012 1.25 2.19008 1.25 1.35V0.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
977
985
  </svg>`;
978
- class ct extends C {
986
+ class ct extends m {
979
987
  constructor(t = {}) {
980
988
  super(t), this.inputType = "number", this.inputValues = {};
981
989
  }
@@ -1017,10 +1025,10 @@ class ct extends C {
1017
1025
  a.classList.add("gap-input-label"), a.textContent = t, s.appendChild(a), i.appendChild(s);
1018
1026
  const o = (u) => {
1019
1027
  this.props.minValue !== void 0 && (u.min = String(this.props.minValue)), this.props.maxValue !== void 0 && (u.max = String(this.props.maxValue)), this.props.className && u.classList.add(this.props.className), u.addEventListener("input", () => {
1020
- var m;
1028
+ var C;
1021
1029
  const p = this.props.minValue ?? 0, g = this.props.maxValue ?? 100;
1022
1030
  let d = Number(u.value);
1023
- d < p && (d = p), d > g && (d = g), u.value = String(d), this.value = d, this.inputValues[t] = d, console.log(`Gap Setting (${t}): ${d}${this.props.suffix || ""}`), (m = this.onChange) == null || m.call(this, d);
1031
+ d < p && (d = p), d > g && (d = g), u.value = String(d), this.value = d, this.inputValues[t] = d, console.log(`Gap Setting (${t}): ${d}${this.props.suffix || ""}`), (C = this.onChange) == null || C.call(this, d);
1024
1032
  });
1025
1033
  }, l = this.createInput({
1026
1034
  value: e,
@@ -1032,18 +1040,35 @@ class ct extends C {
1032
1040
  if (!this.props.suffix || this.props.suffix === "none")
1033
1041
  return i.appendChild(l), i;
1034
1042
  l.classList.add("suffix-wrapper");
1035
- const r = l.querySelector("input.gap-setting-input");
1036
- r && (r.style.paddingRight = "35px");
1043
+ const c = l.querySelector("input.gap-setting-input");
1044
+ c && (c.style.paddingRight = "35px");
1037
1045
  const h = document.createElement("span");
1038
1046
  return h.className = "suffix-label", h.textContent = this.props.suffix, l.appendChild(h), i.appendChild(l), i;
1039
1047
  }
1040
1048
  }
1041
- class dt extends C {
1049
+ class dt extends m {
1042
1050
  constructor(t) {
1043
1051
  var e;
1044
1052
  if (!t.tabs)
1045
1053
  throw new Error("Tabs array is required for TabsSettings");
1046
- super(t), this.inputType = "tabs", this.tabs = [], this.activeTabId = "", this.tabsContainer = null, this.contentContainer = null, this.previousTabId = "", this.tabs = t.tabs, this.activeTabId = t.activeTabId || ((e = this.tabs[0]) == null ? void 0 : e.id) || "", this.previousTabId = this.activeTabId, t.onChange && this.setOnChange(t.onChange);
1054
+ super(t), this.inputType = "tabs", this.tabs = [], this.activeTabId = "", this.tabsContainer = null, this.contentContainer = null, this.previousTabId = "", this.tabValues = /* @__PURE__ */ new Map(), this.settingGroups = /* @__PURE__ */ new Map(), this.tabs = t.tabs, this.activeTabId = t.activeTabId || ((e = this.tabs[0]) == null ? void 0 : e.id) || "", this.previousTabId = this.activeTabId, this.onStateChangeCallback = t.onStateChange, this.tabs.forEach((i) => {
1055
+ if (i.custom)
1056
+ this.tabValues.set(i.id, i.settings);
1057
+ else {
1058
+ const s = new f({
1059
+ title: i.title || i.label,
1060
+ collapsed: i.collapsed,
1061
+ settings: i.settings,
1062
+ description: i.description,
1063
+ icon: i.icon,
1064
+ main: i.main,
1065
+ custom: i.custom,
1066
+ hideCondition: i.hideCondition,
1067
+ onBlur: i.onBlur
1068
+ });
1069
+ this.settingGroups.set(i.id, s), this.tabValues.set(i.id, s.getValues());
1070
+ }
1071
+ }), t.onChange && this.setOnChange(t.onChange);
1047
1072
  }
1048
1073
  draw() {
1049
1074
  const t = document.createElement("div");
@@ -1056,28 +1081,86 @@ class dt extends C {
1056
1081
  const i = document.createElement("div");
1057
1082
  return i.classList.add("tab-content"), this.contentContainer = i, this.tabs.forEach((s) => {
1058
1083
  const n = document.createElement("div");
1059
- n.classList.add("tab-panel"), s.id === this.activeTabId && n.classList.add("active"), s.content instanceof v ? n.appendChild(s.content.draw()) : n.appendChild(s.content), i.appendChild(n);
1084
+ if (n.classList.add("tab-panel"), s.id === this.activeTabId && n.classList.add("active"), s.custom)
1085
+ Object.entries(s.settings).forEach(([a, o]) => {
1086
+ if (o instanceof m)
1087
+ n.appendChild(o.draw()), o.setOnChange(() => {
1088
+ this.updateTabValues(s.id), this.handleTabChange(s.id);
1089
+ });
1090
+ else if (o instanceof f) {
1091
+ const l = o.draw();
1092
+ n.appendChild(l), this.addChangeListeners(o, s.id);
1093
+ }
1094
+ });
1095
+ else {
1096
+ const a = this.settingGroups.get(s.id);
1097
+ if (a) {
1098
+ const o = a.draw();
1099
+ n.appendChild(o), this.addChangeListeners(a, s.id);
1100
+ }
1101
+ }
1102
+ i.appendChild(n);
1060
1103
  }), t.appendChild(i), t;
1061
1104
  }
1062
- handleTabClick(t) {
1105
+ addChangeListeners(t, e) {
1106
+ const i = t.settings;
1107
+ Object.values(i).forEach((s) => {
1108
+ s instanceof f ? this.addChangeListeners(s, e) : s.setOnChange(() => {
1109
+ this.updateTabValues(e), this.handleTabChange(e);
1110
+ });
1111
+ });
1112
+ }
1113
+ updateTabValues(t) {
1114
+ const e = this.tabs.find((i) => i.id === t);
1115
+ if (e)
1116
+ if (e.custom) {
1117
+ const i = {};
1118
+ Object.entries(e.settings).forEach(([s, n]) => {
1119
+ n instanceof m ? i[s] = n.value : n instanceof f && (i[s] = n.getValues());
1120
+ }), this.tabValues.set(t, i);
1121
+ } else {
1122
+ const i = this.settingGroups.get(t);
1123
+ i && this.tabValues.set(t, i.getValues());
1124
+ }
1125
+ }
1126
+ handleTabChange(t) {
1063
1127
  var i, s;
1128
+ const e = this.tabValues.get(t) || {};
1129
+ (i = this.onStateChangeCallback) == null || i.call(this, t, e), (s = this.onChangeCallback) == null || s.call(this, {
1130
+ tabId: t,
1131
+ contentValues: e,
1132
+ previousTabId: this.previousTabId
1133
+ });
1134
+ }
1135
+ handleTabClick(t) {
1136
+ var i;
1064
1137
  if (t === this.activeTabId) return;
1065
1138
  this.previousTabId = this.activeTabId, this.activeTabId = t;
1066
1139
  const e = (i = this.tabsContainer) == null ? void 0 : i.querySelectorAll(".tab-button");
1067
- if (e == null || e.forEach((n) => {
1068
- var a;
1069
- n instanceof HTMLElement && n.classList.toggle("active", n.textContent === ((a = this.tabs.find((o) => o.id === t)) == null ? void 0 : a.label));
1140
+ if (e == null || e.forEach((s) => {
1141
+ var n;
1142
+ s instanceof HTMLElement && s.classList.toggle(
1143
+ "active",
1144
+ s.textContent === ((n = this.tabs.find((a) => a.id === t)) == null ? void 0 : n.label)
1145
+ );
1070
1146
  }), this.contentContainer) {
1071
- const n = this.contentContainer.querySelectorAll(".tab-panel"), a = this.tabs.findIndex((l) => l.id === this.previousTabId), o = this.tabs.findIndex((l) => l.id === t);
1072
- n.forEach((l, r) => {
1073
- l instanceof HTMLElement && (r === o ? (l.classList.add("active"), l.classList.remove("slide-left", "slide-right")) : r === a ? (l.classList.remove("active"), l.classList.add(o > a ? "slide-left" : "slide-right")) : l.classList.remove("active", "slide-left", "slide-right"));
1147
+ const s = this.contentContainer.querySelectorAll(".tab-panel"), n = this.tabs.findIndex(
1148
+ (o) => o.id === this.previousTabId
1149
+ ), a = this.tabs.findIndex((o) => o.id === t);
1150
+ s.forEach((o, l) => {
1151
+ o instanceof HTMLElement && (l === a ? (o.classList.add("active"), o.classList.remove("slide-left", "slide-right")) : l === n ? (o.classList.remove("active"), o.classList.add(
1152
+ a > n ? "slide-left" : "slide-right"
1153
+ )) : o.classList.remove("active", "slide-left", "slide-right"));
1074
1154
  });
1075
1155
  }
1076
- (s = this.onChangeCallback) == null || s.call(this, t);
1156
+ this.handleTabChange(t);
1077
1157
  }
1078
1158
  setOnChange(t) {
1079
1159
  return this.onChangeCallback = t, this;
1080
1160
  }
1161
+ setOnStateChange(t) {
1162
+ return this.onStateChangeCallback = t, this;
1163
+ }
1081
1164
  }
1082
1165
  const J = `
1083
1166
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
@@ -1088,7 +1171,7 @@ const J = `
1088
1171
  <path d="M6 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V6.5M6 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V12.5M15.75 6.5V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H12M15.75 12.5V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H12" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
1089
1172
  </svg>
1090
1173
  `;
1091
- class pt extends v {
1174
+ class pt extends f {
1092
1175
  constructor(t) {
1093
1176
  super({
1094
1177
  title: "Border",
@@ -1144,7 +1227,7 @@ const X = `
1144
1227
  <path d="M6 5.75H12M9 5.75V13.25M5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
1145
1228
  </svg>
1146
1229
  `;
1147
- class ut extends v {
1230
+ class ut extends f {
1148
1231
  constructor(t = {}) {
1149
1232
  super({
1150
1233
  title: t.title || "Typography",
@@ -1157,7 +1240,7 @@ class ut extends v {
1157
1240
  opacity: new M({
1158
1241
  default: t.colorOpacityDefault ?? 100
1159
1242
  }),
1160
- fontFamily: new V({
1243
+ fontFamily: new T({
1161
1244
  title: "Font",
1162
1245
  icon: X,
1163
1246
  default: t.fontFamilyDefault ?? "Satoshi",
@@ -1169,7 +1252,7 @@ class ut extends v {
1169
1252
  getOptions: t.fontFamilyGetOptions,
1170
1253
  getOptionsAsync: t.fontFamilyGetOptionsAsync
1171
1254
  }),
1172
- fontWeight: new V({
1255
+ fontWeight: new T({
1173
1256
  title: "Weight",
1174
1257
  icon: Q,
1175
1258
  default: t.fontWeightDefault ?? "400",
@@ -1206,7 +1289,7 @@ class ut extends v {
1206
1289
  `;
1207
1290
  }
1208
1291
  }
1209
- class k extends C {
1292
+ class k extends m {
1210
1293
  constructor(t) {
1211
1294
  super({
1212
1295
  ...t,
@@ -1216,9 +1299,9 @@ class k extends C {
1216
1299
  draw() {
1217
1300
  const t = this.value === "auto" ? "text" : "number", e = (o) => {
1218
1301
  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", () => {
1219
- const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, r = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
1302
+ const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, c = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
1220
1303
  let h = Number(o.value);
1221
- h < l && (h = l), h > r && (h = r), o.value = String(h);
1304
+ h < l && (h = l), h > c && (h = c), o.value = String(h);
1222
1305
  }));
1223
1306
  }, i = this.createInput({
1224
1307
  value: this.value,
@@ -1245,14 +1328,14 @@ class k extends C {
1245
1328
  if (l.toLowerCase() === "auto")
1246
1329
  this.value = "auto";
1247
1330
  else {
1248
- const r = Number(l);
1249
- isNaN(r) || (this.value = r);
1331
+ const c = Number(l);
1332
+ isNaN(c) || (this.value = c);
1250
1333
  }
1251
1334
  this.onChange && this.onChange(this.value);
1252
1335
  }), i;
1253
1336
  }
1254
1337
  }
1255
- class gt extends v {
1338
+ class gt extends f {
1256
1339
  constructor(t) {
1257
1340
  super({
1258
1341
  title: "Margins",
@@ -1305,7 +1388,7 @@ const K = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBo
1305
1388
  </svg>`, it = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
1306
1389
  <path d="M5.625 2.75H5.6325M5.625 9.5H5.6325M5.625 16.25H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M12.375 16.25H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 16.25H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 16.25H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
1307
1390
  </svg>`;
1308
- class st extends v {
1391
+ class st extends f {
1309
1392
  constructor(t, e, i) {
1310
1393
  super({
1311
1394
  title: `Tab ${t + 1}`,
@@ -1349,7 +1432,7 @@ class st extends v {
1349
1432
  return t;
1350
1433
  }
1351
1434
  }
1352
- class mt extends v {
1435
+ class mt extends f {
1353
1436
  // Store the rendered element
1354
1437
  constructor(t) {
1355
1438
  super({
@@ -1418,7 +1501,7 @@ class mt extends v {
1418
1501
  }));
1419
1502
  }
1420
1503
  }
1421
- class Ct extends v {
1504
+ class Ct extends f {
1422
1505
  /**
1423
1506
  * Constructs a new BackgroundSettingSet.
1424
1507
  *
@@ -1506,14 +1589,14 @@ export {
1506
1589
  w as NumberSetting,
1507
1590
  M as OpacitySetting,
1508
1591
  ht as SelectApiSettings,
1509
- V as SelectSetting,
1510
- C as Setting,
1511
- v as SettingGroup,
1592
+ T as SelectSetting,
1593
+ m as Setting,
1594
+ f as SettingGroup,
1512
1595
  H as StringSetting,
1513
1596
  mt as TabsContainerGroup,
1514
1597
  dt as TabsSettings,
1515
1598
  rt as Toggle,
1516
1599
  F as UploadSetting,
1517
1600
  lt as WidthSetting,
1518
- O as iterateSettings
1601
+ B as iterateSettings
1519
1602
  };