builder-settings-types 0.0.122 → 0.0.124

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.
@@ -5,7 +5,117 @@ let R = (c = 21) => {
5
5
  t += A[e[c] & 63];
6
6
  return t;
7
7
  };
8
- function S(c, t) {
8
+ function M(c) {
9
+ if (c === null || typeof c != "object")
10
+ return c;
11
+ if (c instanceof Date)
12
+ return new Date(c.getTime());
13
+ if (Array.isArray(c)) {
14
+ const i = [];
15
+ for (let s = 0; s < c.length; s++)
16
+ i[s] = M(c[s]);
17
+ return i;
18
+ }
19
+ const t = {};
20
+ for (const i in c)
21
+ Object.prototype.hasOwnProperty.call(c, i) && (t[i] = M(c[i]));
22
+ const e = Object.getPrototypeOf(c);
23
+ return e !== Object.prototype && Object.setPrototypeOf(t, e), t;
24
+ }
25
+ function $(c) {
26
+ switch (c) {
27
+ case "number":
28
+ return 0;
29
+ case "text":
30
+ return "";
31
+ case "select":
32
+ return null;
33
+ case "color":
34
+ return "#000000";
35
+ case "date":
36
+ return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
37
+ case "button":
38
+ return "";
39
+ default:
40
+ return "";
41
+ }
42
+ }
43
+ class C {
44
+ constructor(t = {}) {
45
+ this.props = t, this.id = t.id || R(), this.value = this.props.default, this.title = t.title || "";
46
+ }
47
+ destroy() {
48
+ throw new Error("Method not implemented.");
49
+ }
50
+ setOnChange(t) {
51
+ return this.onChange = t, this;
52
+ }
53
+ setValue(t) {
54
+ this.value = t, this.inputEl && (this.inputEl.value = String(t)), this.onChange && this.onChange(t), this.props.detectChange && this.props.detectChange(t);
55
+ }
56
+ // Basic clone method
57
+ clone() {
58
+ const t = this.constructor, e = M(this.props), i = new t(e);
59
+ return i.value = M(this.value), i;
60
+ }
61
+ createInput(t) {
62
+ t = { ...this.props.inputProps, ...t };
63
+ const e = document.createElement("div");
64
+ if (e.className = t.wrapperClassName || "", t.title || t.icon) {
65
+ const a = document.createElement("div");
66
+ if (a.className = "icon-container", t.icon) {
67
+ const o = this.createIcon(t.icon, t.iconClassName);
68
+ a.appendChild(o);
69
+ }
70
+ if (t.title) {
71
+ const o = this.createLabel(t.title, t.labelClassName);
72
+ a.appendChild(o);
73
+ }
74
+ e.appendChild(a);
75
+ }
76
+ const i = document.createElement("div");
77
+ i.className = t.wrapperClassName || "";
78
+ const s = document.createElement("input");
79
+ this.inputEl = s, s.value = String(t.value || $(t.inputType)), s.type = t.inputType, s.placeholder = t.placeholder || "", s.className = t.inputClassName || "";
80
+ const n = (a) => {
81
+ const o = a.target;
82
+ let l = o.value;
83
+ switch (t.inputType) {
84
+ case "number":
85
+ l = Number(o.value);
86
+ break;
87
+ case "color":
88
+ l = o.value;
89
+ break;
90
+ case "date":
91
+ l = o.value;
92
+ break;
93
+ case "select":
94
+ l = o.value;
95
+ break;
96
+ case "text":
97
+ l = o.value;
98
+ break;
99
+ case "button":
100
+ l = o.value;
101
+ break;
102
+ default:
103
+ l = o.value;
104
+ }
105
+ this.value = l, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
106
+ };
107
+ return s.addEventListener("input", n), s.addEventListener("change", n), t.inputCustomizer && t.inputCustomizer(s), i.appendChild(s), e.appendChild(i), e;
108
+ }
109
+ createLabel(t, e) {
110
+ const i = document.createElement("span");
111
+ return i.textContent = t, i.className = "input-label " + (e || ""), i;
112
+ }
113
+ createIcon(t, e) {
114
+ const i = document.createElement("span");
115
+ return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
116
+ }
117
+ }
118
+ function V(c, t) {
9
119
  for (const e in c)
10
120
  if (c.hasOwnProperty(e)) {
11
121
  const i = c[e];
@@ -35,14 +145,27 @@ const b = class b {
35
145
  this.initialValues,
36
146
  i
37
147
  );
38
- Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), t(i), this.updateVisibility(), this.initialValues = i), this.isHandlingChange = !1;
148
+ Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
39
149
  }, 50));
40
150
  };
41
- return this.changeHandlers.clear(), S(this.settings, (i, s) => {
42
- const n = () => {
43
- this.isHandlingChange || e();
44
- };
45
- this.changeHandlers.add(n), s instanceof b, s.setOnChange(n);
151
+ return this.changeHandlers.clear(), V(this.settings, (i, s) => {
152
+ var n;
153
+ if (s instanceof b)
154
+ s.setOnChange((a) => {
155
+ const o = this.getValues();
156
+ this.initialValues = o, t(o);
157
+ }), this.changeHandlers.add(() => t(this.getValues()));
158
+ else if (s instanceof C) {
159
+ const a = () => {
160
+ e();
161
+ };
162
+ this.changeHandlers.add(a), s.setOnChange(a);
163
+ } else {
164
+ const a = () => {
165
+ e();
166
+ };
167
+ this.changeHandlers.add(a), (n = s.setOnChange) == null || n.call(s, a);
168
+ }
46
169
  }), this;
47
170
  }
48
171
  setOnBlur(t) {
@@ -53,7 +176,7 @@ const b = class b {
53
176
  }, this.elementRef && this.setupBlurHandlers(), this;
54
177
  }
55
178
  setupBlurHandlers() {
56
- this.elementRef && this.elementRef.removeEventListener("focusout", this.handleBlur), this.elementRef && this.elementRef.addEventListener("focusout", this.handleBlur, !0), S(this.settings, (t, e) => {
179
+ this.elementRef && this.elementRef.removeEventListener("focusout", this.handleBlur), this.elementRef && this.elementRef.addEventListener("focusout", this.handleBlur, !0), V(this.settings, (t, e) => {
57
180
  var i;
58
181
  if (e instanceof b)
59
182
  e.setOnBlur(this.handleBlur);
@@ -70,7 +193,7 @@ const b = class b {
70
193
  // Add the clone method here
71
194
  clone() {
72
195
  const t = {};
73
- S(this.settings, (n, a) => {
196
+ V(this.settings, (n, a) => {
74
197
  typeof a.clone == "function" ? t[n] = a.clone() : (console.warn(`Setting with key '${n}' does not have a clone method. Copying reference.`), t[n] = a);
75
198
  });
76
199
  const e = {
@@ -92,19 +215,13 @@ const b = class b {
92
215
  }
93
216
  calculateChanges(t, e) {
94
217
  const i = {};
95
- for (const s in e)
96
- if (e.hasOwnProperty(s))
97
- if (typeof e[s] == "object" && e[s] !== null) {
98
- const n = this.calculateChanges(
99
- t[s] || {},
100
- e[s]
101
- );
102
- Object.keys(n).length > 0 && (i[s] = n);
103
- } else t[s] !== e[s] && (i[s] = {
104
- from: t[s],
105
- to: e[s]
106
- });
107
- return i;
218
+ return (/* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(e)])).forEach((n) => {
219
+ const a = t[n], o = e[n];
220
+ JSON.stringify(a) !== JSON.stringify(o) && (i[n] = {
221
+ from: a,
222
+ to: o
223
+ });
224
+ }), i;
108
225
  }
109
226
  hide() {
110
227
  this.elementRef && (this.elementRef.style.display = "none", this.isHidden = !0);
@@ -234,116 +351,6 @@ const b = class b {
234
351
  };
235
352
  b.hiddenElements = /* @__PURE__ */ new Set();
236
353
  let f = b;
237
- function M(c) {
238
- if (c === null || typeof c != "object")
239
- return c;
240
- if (c instanceof Date)
241
- return new Date(c.getTime());
242
- if (Array.isArray(c)) {
243
- const i = [];
244
- for (let s = 0; s < c.length; s++)
245
- i[s] = M(c[s]);
246
- return i;
247
- }
248
- const t = {};
249
- for (const i in c)
250
- Object.prototype.hasOwnProperty.call(c, i) && (t[i] = M(c[i]));
251
- const e = Object.getPrototypeOf(c);
252
- return e !== Object.prototype && Object.setPrototypeOf(t, e), t;
253
- }
254
- function $(c) {
255
- switch (c) {
256
- case "number":
257
- return 0;
258
- case "text":
259
- return "";
260
- case "select":
261
- return null;
262
- case "color":
263
- return "#000000";
264
- case "date":
265
- return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
266
- case "button":
267
- return "";
268
- default:
269
- return "";
270
- }
271
- }
272
- class C {
273
- constructor(t = {}) {
274
- this.props = t, this.id = t.id || R(), this.value = this.props.default, this.title = t.title || "";
275
- }
276
- destroy() {
277
- throw new Error("Method not implemented.");
278
- }
279
- setOnChange(t) {
280
- return this.onChange = t, this;
281
- }
282
- setValue(t) {
283
- this.value = t, this.inputEl && (this.inputEl.value = String(t)), this.onChange && this.onChange(t), this.props.detectChange && this.props.detectChange(t);
284
- }
285
- // Basic clone method
286
- clone() {
287
- const t = this.constructor, e = M(this.props), i = new t(e);
288
- return i.value = M(this.value), i;
289
- }
290
- createInput(t) {
291
- t = { ...this.props.inputProps, ...t };
292
- const e = document.createElement("div");
293
- if (e.className = t.wrapperClassName || "", t.title || t.icon) {
294
- const a = document.createElement("div");
295
- if (a.className = "icon-container", t.icon) {
296
- const o = this.createIcon(t.icon, t.iconClassName);
297
- a.appendChild(o);
298
- }
299
- if (t.title) {
300
- const o = this.createLabel(t.title, t.labelClassName);
301
- a.appendChild(o);
302
- }
303
- e.appendChild(a);
304
- }
305
- const i = document.createElement("div");
306
- i.className = t.wrapperClassName || "";
307
- const s = document.createElement("input");
308
- this.inputEl = s, s.value = String(t.value || $(t.inputType)), s.type = t.inputType, s.placeholder = t.placeholder || "", s.className = t.inputClassName || "";
309
- const n = (a) => {
310
- const o = a.target;
311
- let l = o.value;
312
- switch (t.inputType) {
313
- case "number":
314
- l = Number(o.value);
315
- break;
316
- case "color":
317
- l = o.value;
318
- break;
319
- case "date":
320
- l = o.value;
321
- break;
322
- case "select":
323
- l = o.value;
324
- break;
325
- case "text":
326
- l = o.value;
327
- break;
328
- case "button":
329
- l = o.value;
330
- break;
331
- default:
332
- l = o.value;
333
- }
334
- this.value = l, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
335
- };
336
- return s.addEventListener("input", n), s.addEventListener("change", n), t.inputCustomizer && t.inputCustomizer(s), i.appendChild(s), e.appendChild(i), e;
337
- }
338
- createLabel(t, e) {
339
- const i = document.createElement("span");
340
- return i.textContent = t, i.className = "input-label " + (e || ""), i;
341
- }
342
- createIcon(t, e) {
343
- const i = document.createElement("span");
344
- return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
345
- }
346
- }
347
354
  class O extends C {
348
355
  constructor(t = {}) {
349
356
  super(t), this.inputType = "text", t.onChange && this.setOnChange(t.onChange);
@@ -397,11 +404,11 @@ class N extends O {
397
404
  const n = document.createElement("div");
398
405
  n.className = "color-input-wrapper";
399
406
  const a = (p) => {
400
- const g = p.value.split(",").map((T) => parseInt(T.trim()));
407
+ const g = p.value.split(",").map((H) => parseInt(H.trim()));
401
408
  if (g.length !== 3 || g.some(isNaN))
402
409
  return p.style.border = "1px solid red", !1;
403
- const [d, m, v] = g, L = d >= 0 && d <= 255 && m >= 0 && m <= 255 && v >= 0 && v <= 255;
404
- return p.style.border = L ? "" : "1px solid red", L;
410
+ const [d, m, v] = g, k = d >= 0 && d <= 255 && m >= 0 && m <= 255 && v >= 0 && v <= 255;
411
+ return p.style.border = k ? "" : "1px solid red", k;
405
412
  }, o = document.createElement("div");
406
413
  o.className = "color-preview", o.style.backgroundColor = this.value ? `rgb(${this.value})` : "";
407
414
  const l = this.createInput({
@@ -468,7 +475,7 @@ class w extends C {
468
475
  return s < e && (s = e), s > i && (s = i), s;
469
476
  }
470
477
  }
471
- class H extends w {
478
+ class T extends w {
472
479
  constructor(t) {
473
480
  super({
474
481
  ...t,
@@ -576,7 +583,7 @@ class B extends C {
576
583
  this.clickOutsideListener && (document.removeEventListener("click", this.clickOutsideListener), this.clickOutsideListener = null), super.destroy();
577
584
  }
578
585
  }
579
- class G extends C {
586
+ class j extends C {
580
587
  constructor(t = {}) {
581
588
  super(t), this.inputType = "button", this.value || (this.value = "center");
582
589
  }
@@ -655,14 +662,14 @@ class ht extends C {
655
662
  suffix: "px",
656
663
  minValue: this.minWidth,
657
664
  maxValue: this.maxWidth,
658
- icon: j
665
+ icon: G
659
666
  }), this.heightSetting = new w({
660
667
  title: "Height",
661
668
  default: this.value.height,
662
669
  suffix: "px",
663
670
  minValue: this.minHeight,
664
671
  maxValue: this.maxHeight,
665
- icon: q
672
+ icon: D
666
673
  }), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
667
674
  }
668
675
  handleWidthChange(t) {
@@ -754,25 +761,25 @@ class ht extends C {
754
761
  }
755
762
  }
756
763
  }
757
- const j = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
764
+ const G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
758
765
  <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"/>
759
- </svg>`, q = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
766
+ </svg>`, D = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
760
767
  <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"/>
761
- </svg>`, V = `
768
+ </svg>`, S = `
762
769
  <svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
763
770
  <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"/>
764
771
  </svg>
765
- `, F = `
772
+ `, q = `
766
773
  <svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
767
774
  <rect width="91" height="71" rx="4" fill="#F2F4F7"/>
768
775
  <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"/>
769
776
  </svg>
770
- `, U = `
777
+ `, F = `
771
778
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" fill="none">
772
779
  <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"/>
773
780
  </svg>
774
781
  `;
775
- class z extends C {
782
+ class U extends C {
776
783
  constructor(t = {}) {
777
784
  super(t), this.inputType = "button", this.previewWrapper = null, this.previewEl = null, this.emptyStateEl = null, !this.value && t.defaultUrl && t.defaultUrl !== "" && (this.value = t.defaultUrl);
778
785
  }
@@ -780,10 +787,10 @@ class z extends C {
780
787
  if (!this.previewWrapper || !this.previewEl) return;
781
788
  const e = this.previewWrapper.parentElement, i = e == null ? void 0 : e.querySelector(".upload-button"), s = e == null ? void 0 : e.querySelector(".preview-placeholder");
782
789
  t && t !== "" ? (this.previewWrapper.classList.add("has-image"), this.previewEl.src = t, this.previewWrapper.style.display = "block", this.previewEl.style.display = "block", s && s instanceof HTMLElement && (s.style.display = "none"), e && e.classList.remove("no-image"), i && (i.innerHTML = `
783
- <span class="upload-icon">${V}</span>
790
+ <span class="upload-icon">${S}</span>
784
791
  <span class="upload-label">Replace</span>
785
792
  `)) : (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 = `
786
- <span class="upload-icon">${V}</span>
793
+ <span class="upload-icon">${S}</span>
787
794
  <span class="upload-label">Upload</span>
788
795
  `));
789
796
  }
@@ -811,12 +818,12 @@ class z extends C {
811
818
  const s = this.value && this.value !== "";
812
819
  s || i.classList.add("no-image");
813
820
  const n = document.createElement("div");
814
- n.className = "preview-placeholder", n.innerHTML = F, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview";
821
+ n.className = "preview-placeholder", n.innerHTML = q, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview";
815
822
  const a = document.createElement("button");
816
- a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML = U, this.previewWrapper.appendChild(this.previewEl), this.previewWrapper.appendChild(a);
823
+ a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML = F, this.previewWrapper.appendChild(this.previewEl), this.previewWrapper.appendChild(a);
817
824
  const o = document.createElement("button");
818
825
  o.className = "upload-button", o.innerHTML = `
819
- <span class="upload-icon">${V}</span>
826
+ <span class="upload-icon">${S}</span>
820
827
  <span class="upload-label">Upload</span>
821
828
  `;
822
829
  const l = document.createElement("input");
@@ -836,20 +843,20 @@ class z extends C {
836
843
  const v = this.props.uploadUrl;
837
844
  if (!v)
838
845
  throw new Error("No uploadUrl provided to UploadSetting.");
839
- const L = this.props.requestMethod || "POST", T = { ...this.props.requestHeaders || {} }, E = await (await fetch(v, {
840
- method: L,
846
+ const k = this.props.requestMethod || "POST", H = { ...this.props.requestHeaders || {} }, L = await (await fetch(v, {
847
+ method: k,
841
848
  body: d,
842
- headers: T
849
+ headers: H
843
850
  })).json();
844
- console.log("Upload response:", E);
845
- let x;
851
+ console.log("Upload response:", L);
852
+ let E;
846
853
  if (this.props.parseResponse)
847
- x = this.props.parseResponse(E);
848
- else if (x = (u = E == null ? void 0 : E.data) == null ? void 0 : u.url, !x)
854
+ E = this.props.parseResponse(L);
855
+ else if (E = (u = L == null ? void 0 : L.data) == null ? void 0 : u.url, !E)
849
856
  throw new Error(
850
857
  "No URL found in response. Provide a parseResponse if needed."
851
858
  );
852
- console.log("Final URL:", x), this.value = x, this.updatePreviewState(x), (p = this.onChange) == null || p.call(this, x), (g = this.onBlur) == null || g.call(this);
859
+ console.log("Final URL:", E), this.value = E, this.updatePreviewState(E), (p = this.onChange) == null || p.call(this, E), (g = this.onBlur) == null || g.call(this);
853
860
  } catch (d) {
854
861
  console.error("Error uploading file:", d), this.updatePreviewState(null);
855
862
  } finally {
@@ -866,11 +873,11 @@ class rt extends w {
866
873
  suffix: "px",
867
874
  minValue: t.minValue ?? 0,
868
875
  maxValue: t.maxValue,
869
- icon: t.icon || D
876
+ icon: t.icon || z
870
877
  }), this.inputType = "number";
871
878
  }
872
879
  }
873
- const D = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
880
+ const z = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
874
881
  <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"/>
875
882
  </svg>`;
876
883
  class ct extends w {
@@ -1015,7 +1022,7 @@ class dt extends C {
1015
1022
  this.detectChangeCallback = t;
1016
1023
  }
1017
1024
  }
1018
- class pt extends C {
1025
+ class ut extends C {
1019
1026
  constructor(t) {
1020
1027
  var e, i;
1021
1028
  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;
@@ -1063,7 +1070,7 @@ class pt extends C {
1063
1070
  const J = `<svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
1064
1071
  <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"/>
1065
1072
  </svg>`;
1066
- class ut extends C {
1073
+ class pt extends C {
1067
1074
  constructor(t = {}) {
1068
1075
  super(t), this.inputType = "number", this.inputValues = {};
1069
1076
  }
@@ -1126,7 +1133,8 @@ class ut extends C {
1126
1133
  return h.className = "suffix-label", h.textContent = this.props.suffix, l.appendChild(h), i.appendChild(l), i;
1127
1134
  }
1128
1135
  }
1129
- class y extends f {
1136
+ class x extends f {
1137
+ // ms
1130
1138
  constructor(t) {
1131
1139
  var o;
1132
1140
  if (!t.tabs)
@@ -1142,11 +1150,16 @@ class y extends f {
1142
1150
  hideCondition: t.hideCondition,
1143
1151
  onBlur: t.onBlur
1144
1152
  };
1145
- super(a), this.tabs = [], this.activeTabId = "", this.tabsContainer = null, this.previousTabId = "", this.container = null, this.tabValues = {}, this.tabs = e, this.activeTabId = i, this.previousTabId = i, this.onStateChangeCallback = t.onStateChange, this.detectChangeCallback = t.detectChange, this.initializeTabValues(), this.connectChildChangeHandlers();
1153
+ super(a), this.tabs = [], this.activeTabId = "", this.tabsContainer = null, this.previousTabId = "", this.container = null, this.tabValues = {}, this.internalChangeTimeout = null, this.isHandlingInternalChange = !1, this.INTERNAL_CHANGE_DEBOUNCE = 50, this.tabs = e, this.activeTabId = i, this.previousTabId = i, this.onStateChangeCallback = t.onStateChange, this.detectChangeCallback = t.detectChange, this.initializeTabValues(), this.connectChildChangeHandlers();
1146
1154
  }
1147
1155
  updateSettingsFromTab(t) {
1148
1156
  const e = this.tabs.find((i) => i.id === t);
1149
- e && (this.settings = e.settings, this.connectChildChangeHandlers());
1157
+ e && (this.settings = e.settings, this.tabValues[t] = this.getTabValues(e), this.initialValues = {
1158
+ tabs: this.tabValues,
1159
+ activeTabId: this.activeTabId
1160
+ }, Object.values(e.settings).forEach((i) => {
1161
+ i instanceof x && (i._parentTabsSettings = this);
1162
+ }), this.connectChildChangeHandlers());
1150
1163
  }
1151
1164
  /**
1152
1165
  * Connect all child settings' onChange events to trigger the parent's onChange
@@ -1161,7 +1174,7 @@ class y extends f {
1161
1174
  this.initialValues = {
1162
1175
  tabs: this.tabValues,
1163
1176
  activeTabId: this.activeTabId
1164
- }, this.onChange && this.onChange(this.getValues());
1177
+ }, this.triggerDebouncedChange();
1165
1178
  };
1166
1179
  Object.values(this.settings).forEach((e) => {
1167
1180
  e instanceof f ? e.setOnChange(() => {
@@ -1170,10 +1183,14 @@ class y extends f {
1170
1183
  t();
1171
1184
  });
1172
1185
  }), this.tabs.forEach((e) => {
1173
- Object.values(e.settings).forEach((i) => {
1174
- (i instanceof f || i instanceof C) && i instanceof y && i.setOnChange((s) => {
1175
- this.tabValues[e.id] = this.getTabValues(e), this.onChange && this.onChange(this.getValues());
1176
- });
1186
+ Object.entries(e.settings).forEach(([i, s]) => {
1187
+ (s instanceof f || s instanceof C) && (s instanceof x ? (s._parentTabsSettings = this, s.setOnChange((n) => {
1188
+ this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
1189
+ })) : s instanceof f ? s.setOnChange(() => {
1190
+ this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
1191
+ }) : s instanceof C && s.setOnChange(() => {
1192
+ this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
1193
+ }));
1177
1194
  });
1178
1195
  });
1179
1196
  }
@@ -1189,30 +1206,38 @@ class y extends f {
1189
1206
  return i && t.insertBefore(e, i), t;
1190
1207
  }
1191
1208
  handleTabClick(t) {
1192
- var a, o;
1209
+ var o, l;
1193
1210
  if (t === this.activeTabId) return;
1194
- const e = this.tabs.find((l) => l.id === this.activeTabId);
1211
+ const e = this.tabs.find((r) => r.id === this.activeTabId);
1195
1212
  e && (this.tabValues[this.activeTabId] = this.getTabValues(e)), this.previousTabId = this.activeTabId, this.activeTabId = t;
1196
- const i = (a = this.tabsContainer) == null ? void 0 : a.querySelectorAll(".tab-button");
1197
- i == null || i.forEach((l) => {
1198
- if (l instanceof HTMLElement) {
1199
- const r = this.tabs.find((h) => h.label === l.textContent);
1200
- l.classList.toggle("active", (r == null ? void 0 : r.id) === t);
1213
+ const i = (o = this.tabsContainer) == null ? void 0 : o.querySelectorAll(".tab-button");
1214
+ i == null || i.forEach((r) => {
1215
+ if (r instanceof HTMLElement) {
1216
+ const h = this.tabs.find((u) => u.label === r.textContent);
1217
+ r.classList.toggle("active", (h == null ? void 0 : h.id) === t);
1201
1218
  }
1202
1219
  }), this.updateSettingsFromTab(t);
1203
- const s = (o = this.container) == null ? void 0 : o.querySelector(".setting-group-content");
1220
+ const s = (l = this.container) == null ? void 0 : l.querySelector(".setting-group-content");
1204
1221
  if (s) {
1205
1222
  s.innerHTML = "";
1206
- const l = this.settings;
1207
- Object.values(l).forEach((r) => {
1208
- s.appendChild(r.draw());
1223
+ const r = this.settings;
1224
+ Object.values(r).forEach((h) => {
1225
+ s.appendChild(h.draw());
1209
1226
  });
1210
1227
  }
1211
1228
  const n = this.getValues();
1212
1229
  this.initialValues = {
1213
1230
  tabs: this.tabValues,
1214
1231
  activeTabId: this.activeTabId
1215
- }, this.onStateChangeCallback && this.onStateChangeCallback(t, n), this.detectChangeCallback && this.detectChangeCallback(t, n), this.onChange && this.onChange(n);
1232
+ }, this.connectChildChangeHandlers(), this.onStateChangeCallback && this.onStateChangeCallback(t, n), this.detectChangeCallback && this.detectChangeCallback(t, n), this.onChange && this.onChange(n);
1233
+ const a = this.findParentTabsSettings();
1234
+ a && a.onChange && a.onChange(a.getValues());
1235
+ }
1236
+ /**
1237
+ * Attempts to find a parent TabsSettings component, if this is nested inside one
1238
+ */
1239
+ findParentTabsSettings() {
1240
+ return this._parentTabsSettings || null;
1216
1241
  }
1217
1242
  setOnStateChange(t) {
1218
1243
  return this.onStateChangeCallback = t, this;
@@ -1237,6 +1262,23 @@ class y extends f {
1237
1262
  this.tabValues[t.id] = this.getTabValues(t);
1238
1263
  });
1239
1264
  }
1265
+ /**
1266
+ * Propagates changes upward to parent TabsSettings if this is a nested component
1267
+ */
1268
+ propagateChanges() {
1269
+ const t = this.findParentTabsSettings();
1270
+ t && (t.updateTabValues(), t.triggerDebouncedChange());
1271
+ }
1272
+ /**
1273
+ * Triggers the external onChange callback after debouncing.
1274
+ */
1275
+ triggerDebouncedChange() {
1276
+ this.isHandlingInternalChange || (this.isHandlingInternalChange = !0, this.internalChangeTimeout && clearTimeout(this.internalChangeTimeout), this.internalChangeTimeout = setTimeout(() => {
1277
+ this.onChange && this.onChange(this.getValues()), this.isHandlingInternalChange = !1, this.internalChangeTimeout = null;
1278
+ const t = this.findParentTabsSettings();
1279
+ t && t.triggerDebouncedChange();
1280
+ }, this.INTERNAL_CHANGE_DEBOUNCE));
1281
+ }
1240
1282
  /**
1241
1283
  * Updates the initialValues property to include values from all tabs
1242
1284
  */
@@ -1246,12 +1288,12 @@ class y extends f {
1246
1288
  activeTabId: this.activeTabId
1247
1289
  }, this.tabs.forEach((t) => {
1248
1290
  Object.values(t.settings).forEach((e) => {
1249
- e instanceof y && e.updateInitialValues();
1291
+ e instanceof x && e.updateInitialValues();
1250
1292
  });
1251
1293
  }));
1252
1294
  }
1253
1295
  setOnChange(t) {
1254
- return this.onChange = t, this.connectChildChangeHandlers(), this;
1296
+ return this.onChange = t, this.connectChildChangeHandlers(), this.updateTabValues(), this;
1255
1297
  }
1256
1298
  /**
1257
1299
  * Initialize the tabValues with data from all tabs
@@ -1270,7 +1312,7 @@ class y extends f {
1270
1312
  getTabValues(t) {
1271
1313
  const e = {};
1272
1314
  return Object.entries(t.settings).forEach(([i, s]) => {
1273
- s instanceof f ? e[i] = s.getValues() : e[i] = s.value;
1315
+ s instanceof x || s instanceof f ? e[i] = s.getValues() : (s instanceof C, e[i] = s.value);
1274
1316
  }), e;
1275
1317
  }
1276
1318
  /**
@@ -1298,7 +1340,28 @@ class y extends f {
1298
1340
  settings: {}
1299
1341
  // We don't clone callbacks - they should be set up again on the clone
1300
1342
  };
1301
- return new y(e);
1343
+ return new x(e);
1344
+ }
1345
+ /**
1346
+ * Override setValue method to update the TabsSettings state
1347
+ */
1348
+ setValue(t) {
1349
+ t && typeof t == "object" && (t.activeTabId && (this.activeTabId = t.activeTabId), t.tabs && typeof t.tabs == "object" && Object.entries(t.tabs).forEach(([e, i]) => {
1350
+ const s = this.tabs.find((n) => n.id === e);
1351
+ s && i && typeof i == "object" && Object.entries(i).forEach(([n, a]) => {
1352
+ s.settings[n] && typeof s.settings[n].setValue == "function" && s.settings[n].setValue(a);
1353
+ });
1354
+ }), this.updateTabValues(), this.propagateChanges());
1355
+ }
1356
+ /**
1357
+ * Direct method to update a setting within a specific tab
1358
+ * This allows programmatic updates to any tab, not just the active one
1359
+ */
1360
+ updateTabSetting(t, e, i) {
1361
+ const s = this.tabs.find((a) => a.id === t);
1362
+ if (!s || !s.settings[e]) return;
1363
+ const n = s.settings[e];
1364
+ typeof n.setValue == "function" && (n.setValue(i), this.tabValues[t] = this.getTabValues(s), t !== this.activeTabId && this.onChange && this.onChange(this.getValues()));
1302
1365
  }
1303
1366
  }
1304
1367
  const X = `
@@ -1326,7 +1389,7 @@ class gt extends f {
1326
1389
  color: new N({
1327
1390
  default: (t == null ? void 0 : t.color) ?? "0, 0, 30"
1328
1391
  }),
1329
- opacity: new H({
1392
+ opacity: new T({
1330
1393
  default: (t == null ? void 0 : t.opacity) ?? 100,
1331
1394
  minValue: 0,
1332
1395
  maxValue: 100
@@ -1366,7 +1429,7 @@ const Y = `
1366
1429
  <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"/>
1367
1430
  </svg>
1368
1431
  `;
1369
- class mt extends f {
1432
+ class Ct extends f {
1370
1433
  constructor(t = {}) {
1371
1434
  super({
1372
1435
  title: t.title || "Typography",
@@ -1376,7 +1439,7 @@ class mt extends f {
1376
1439
  color: new N({
1377
1440
  default: t.colorDefault ?? "0, 0, 30"
1378
1441
  }),
1379
- opacity: new H({
1442
+ opacity: new T({
1380
1443
  default: t.colorOpacityDefault ?? 100
1381
1444
  }),
1382
1445
  fontFamily: new B({
@@ -1409,7 +1472,7 @@ class mt extends f {
1409
1472
  default: t.fontSizeDefault ?? 12,
1410
1473
  suffix: "px"
1411
1474
  }),
1412
- align: new G({
1475
+ align: new j({
1413
1476
  title: "Align",
1414
1477
  default: t.alignDefault ?? "center"
1415
1478
  })
@@ -1428,7 +1491,7 @@ class mt extends f {
1428
1491
  `;
1429
1492
  }
1430
1493
  }
1431
- class k extends C {
1494
+ class y extends C {
1432
1495
  constructor(t) {
1433
1496
  super({
1434
1497
  ...t,
@@ -1474,32 +1537,32 @@ class k extends C {
1474
1537
  }), i;
1475
1538
  }
1476
1539
  }
1477
- class Ct extends f {
1540
+ class mt extends f {
1478
1541
  constructor(t) {
1479
1542
  super({
1480
1543
  title: "Margins",
1481
1544
  collapsed: t == null ? void 0 : t.collapsed,
1482
1545
  hideCondition: t == null ? void 0 : t.hideCondition,
1483
1546
  settings: {
1484
- marginTop: new k({
1547
+ marginTop: new y({
1485
1548
  title: "Top",
1486
1549
  icon: et,
1487
1550
  suffix: "px",
1488
1551
  default: (t == null ? void 0 : t.marginTop) ?? "auto"
1489
1552
  }),
1490
- marginRight: new k({
1553
+ marginRight: new y({
1491
1554
  title: "Right",
1492
1555
  icon: it,
1493
1556
  suffix: "px",
1494
1557
  default: (t == null ? void 0 : t.marginRight) ?? 0
1495
1558
  }),
1496
- marginBottom: new k({
1559
+ marginBottom: new y({
1497
1560
  title: "Bottom",
1498
1561
  icon: st,
1499
1562
  suffix: "px",
1500
1563
  default: (t == null ? void 0 : t.marginBottom) ?? 0
1501
1564
  }),
1502
- marginLeft: new k({
1565
+ marginLeft: new y({
1503
1566
  title: "Left",
1504
1567
  icon: nt,
1505
1568
  suffix: "px",
@@ -1671,17 +1734,17 @@ class vt extends f {
1671
1734
  collapsed: t == null ? void 0 : t.collapsed,
1672
1735
  hideCondition: t == null ? void 0 : t.hideCondition,
1673
1736
  settings: {
1674
- backgroundImage: new z({
1737
+ backgroundImage: new U({
1675
1738
  ...t == null ? void 0 : t.uploadProps,
1676
1739
  default: (t == null ? void 0 : t.backgroundImage) ?? ""
1677
1740
  }),
1678
- opacity: new H({
1741
+ opacity: new T({
1679
1742
  default: (t == null ? void 0 : t.opacity) ?? 100
1680
1743
  }),
1681
1744
  backgroundColor: new N({
1682
1745
  default: (t == null ? void 0 : t.backgroundColor) ?? "0, 0, 30"
1683
1746
  }),
1684
- opacityBG: new H({
1747
+ opacityBG: new T({
1685
1748
  default: (t == null ? void 0 : t.opacityBG) ?? 100
1686
1749
  })
1687
1750
  }
@@ -1715,27 +1778,27 @@ class vt extends f {
1715
1778
  }
1716
1779
  }
1717
1780
  export {
1718
- G as AlignSetting,
1781
+ j as AlignSetting,
1719
1782
  vt as BackgroundSettingSet,
1720
1783
  gt as BorderSettingSet,
1721
1784
  lt as ButtonSetting,
1722
1785
  N as ColorSetting,
1723
1786
  ht as DimensionSetting,
1724
- ut as GapSetting,
1725
- mt as HeaderTypographySettingSet,
1787
+ pt as GapSetting,
1788
+ Ct as HeaderTypographySettingSet,
1726
1789
  rt as HeightSetting,
1727
- Ct as MarginSettingGroup,
1790
+ mt as MarginSettingGroup,
1728
1791
  w as NumberSetting,
1729
- H as OpacitySetting,
1792
+ T as OpacitySetting,
1730
1793
  dt as SelectApiSettings,
1731
1794
  B as SelectSetting,
1732
1795
  C as Setting,
1733
1796
  f as SettingGroup,
1734
1797
  O as StringSetting,
1735
1798
  ft as TabsContainerGroup,
1736
- y as TabsSettings,
1737
- pt as Toggle,
1738
- z as UploadSetting,
1799
+ x as TabsSettings,
1800
+ ut as Toggle,
1801
+ U as UploadSetting,
1739
1802
  ct as WidthSetting,
1740
- S as iterateSettings
1803
+ V as iterateSettings
1741
1804
  };