builder-settings-types 0.0.236 → 0.0.240

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,31 +5,31 @@ let N = (c = 21) => {
5
5
  t += T[e[c] & 63];
6
6
  return t;
7
7
  };
8
- function A(c) {
8
+ function P(c) {
9
9
  let t = 0, e = c.parentElement;
10
10
  for (; e; )
11
11
  e.classList.contains("setting-group") && e !== c && t++, e = e.parentElement;
12
12
  return t;
13
13
  }
14
- function b(c, t) {
14
+ function x(c, t) {
15
15
  const e = Math.min(Math.max(t, 0), 5);
16
16
  c.setAttribute("data-nesting-level", e.toString()), e > 0 ? c.style.setProperty("--visual-indent", `${e * 2}px`) : (c.style.removeProperty("--visual-indent"), c.style.marginLeft = "");
17
17
  }
18
18
  function V(c, t = 0) {
19
19
  c.querySelectorAll(":scope > .setting-group-content > .setting-group").forEach((i) => {
20
20
  const s = i, n = t + 1;
21
- b(s, n), V(s, n);
21
+ x(s, n), V(s, n);
22
22
  });
23
23
  }
24
- const B = {
24
+ const A = {
25
25
  maxLevel: 5,
26
26
  spacingMultiplier: 1,
27
27
  visualIndentMultiplier: 2,
28
28
  enableAutoDetection: !0
29
29
  };
30
- class $ {
30
+ class B {
31
31
  constructor(t = {}) {
32
- this.observedElements = /* @__PURE__ */ new Set(), this.config = { ...B, ...t }, this.config.enableAutoDetection && this.setupAutoDetection();
32
+ this.observedElements = /* @__PURE__ */ new Set(), this.config = { ...A, ...t }, this.config.enableAutoDetection && this.setupAutoDetection();
33
33
  }
34
34
  /**
35
35
  * Setup automatic detection using MutationObserver
@@ -63,7 +63,7 @@ class $ {
63
63
  * Update nesting for a specific element
64
64
  */
65
65
  updateElementNesting(t) {
66
- const e = A(t);
66
+ const e = P(t);
67
67
  this.applyNestingWithConfig(t, e);
68
68
  }
69
69
  /**
@@ -111,20 +111,20 @@ class $ {
111
111
  this.observer && (this.observer.disconnect(), this.observer = void 0), this.observedElements.clear();
112
112
  }
113
113
  }
114
- const S = new $();
115
- function x(c) {
114
+ const S = new B();
115
+ function y(c) {
116
116
  if (c === null || typeof c != "object") return c;
117
117
  if (c instanceof Date) return new Date(c.getTime());
118
- if (c instanceof Array) return c.map((t) => x(t));
118
+ if (c instanceof Array) return c.map((t) => y(t));
119
119
  if (typeof c == "object") {
120
120
  const t = {};
121
121
  for (const e in c)
122
- Object.prototype.hasOwnProperty.call(c, e) && (t[e] = x(c[e]));
122
+ Object.prototype.hasOwnProperty.call(c, e) && (t[e] = y(c[e]));
123
123
  return t;
124
124
  }
125
125
  return c;
126
126
  }
127
- function R(c) {
127
+ function D(c) {
128
128
  switch (c) {
129
129
  case "number":
130
130
  return 0;
@@ -144,7 +144,7 @@ function R(c) {
144
144
  }
145
145
  class g {
146
146
  constructor(t = {}) {
147
- this.props = t, this.id = t.id || N(), this.value = this.props.default, this.desktop = this.props.default, this.title = t.title || "", this.includeGetJson = t.includeGetJson !== void 0 ? t.includeGetJson : !0;
147
+ this.props = t, this.dataPropsPath = "", this.id = t.id || N(), 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
150
  globalThis.DefaultUploadUrl = t, g.DefaultUploadUrl = t;
@@ -158,12 +158,18 @@ class g {
158
158
  setOnBlur(t) {
159
159
  return this.onBlur = t, this;
160
160
  }
161
+ setDataPropsPath(t) {
162
+ this.dataPropsPath = t;
163
+ }
164
+ getDataPropsPath() {
165
+ return this.dataPropsPath;
166
+ }
161
167
  setValue(t) {
162
168
  this.value = t, this.inputEl && (this.inputEl.value = String(t)), this.onChange && this.onChange(t), this.props.detectChange && this.props.detectChange(t);
163
169
  }
164
170
  clone() {
165
- const t = this.constructor, e = x(this.props), i = new t(e);
166
- return i.value = x(this.value), i;
171
+ const t = this.constructor, e = y(this.props), i = new t(e);
172
+ return i.value = y(this.value), i;
167
173
  }
168
174
  createInput(t) {
169
175
  t = { ...this.props.inputProps, ...t };
@@ -183,7 +189,7 @@ class g {
183
189
  const i = document.createElement("div");
184
190
  i.className = t.wrapperClassName || "";
185
191
  const s = document.createElement("input");
186
- this.inputEl = s, s.value = String(t.value || R(t.inputType)), s.type = t.inputType, s.placeholder = t.placeholder || "", s.className = t.inputClassName || "";
192
+ this.inputEl = s, s.value = String(t.value || D(t.inputType)), s.type = t.inputType, s.placeholder = t.placeholder || "", s.className = t.inputClassName || "", this.dataPropsPath && s.setAttribute("data-test-id", this.dataPropsPath);
187
193
  const n = (o) => {
188
194
  const l = o.target;
189
195
  let r = l.value;
@@ -233,7 +239,7 @@ function p(c) {
233
239
  function ft(c) {
234
240
  return w(c) || p(c);
235
241
  }
236
- function k(c, t) {
242
+ function b(c, t) {
237
243
  for (const e in c)
238
244
  if (Object.prototype.hasOwnProperty.call(c, e)) {
239
245
  const i = c[e];
@@ -243,11 +249,11 @@ function k(c, t) {
243
249
  const L = class L {
244
250
  constructor(t) {
245
251
  this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.changeTimeout = null, this.isHandlingChange = !1, this.changeHandlers = /* @__PURE__ */ new Set(), this.blurTimeout = null, this.lastChangeTime = 0, this.handleBlur = () => {
246
- }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.id = t.id || N(), this.title = t.title, this.settings = t.settings, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = t.includeGetJson ?? !0, this.addItemCfg = t.addItem, this.deleteItemCfg = t.deleteItem, Object.assign(this, t.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel();
252
+ }, this.pendingBlurHandler = null, this.originalDefaultValues = {}, this.nestingLevel = 0, this.dataPropsPath = "", this.id = t.id || N(), this.title = t.title, this.settings = t.settings, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.nestingLevel = 0, this.includeGetJson = t.includeGetJson ?? !0, this.addItemCfg = t.addItem, this.deleteItemCfg = t.deleteItem, this.dataProps = t.dataProps, this.dataPropsPath = t.dataProps || "", Object.assign(this, t.settings), this.initialValues = this.getValues(), this.originalDefaultValues = this.getDefaultValues(), this.propagateNestingLevel(), this.propagateDataPropsPath();
247
253
  }
248
254
  propagateNestingLevel() {
249
255
  const t = this.nestingLevel + 1;
250
- k(this.settings, (e, i) => {
256
+ b(this.settings, (e, i) => {
251
257
  p(i) && (i.nestingLevel = t, i.propagateNestingLevel());
252
258
  });
253
259
  }
@@ -257,8 +263,20 @@ const L = class L {
257
263
  setNestingLevel(t) {
258
264
  this.nestingLevel = t, this.propagateNestingLevel(), this.elementRef && this.updateNestingStyles();
259
265
  }
266
+ getDataPropsPath() {
267
+ return this.dataPropsPath;
268
+ }
269
+ setDataPropsPath(t) {
270
+ this.dataPropsPath = t, this.propagateDataPropsPath();
271
+ }
272
+ propagateDataPropsPath() {
273
+ b(this.settings, (t, e) => {
274
+ const i = String(t), s = this.dataPropsPath ? `${this.dataPropsPath}_${i}` : i;
275
+ (p(e) || w(e) && typeof e.setDataPropsPath == "function") && e.setDataPropsPath(s);
276
+ });
277
+ }
260
278
  updateNestingStyles() {
261
- this.elementRef && (b(this.elementRef, this.nestingLevel), V(this.elementRef, this.nestingLevel));
279
+ this.elementRef && (x(this.elementRef, this.nestingLevel), V(this.elementRef, this.nestingLevel));
262
280
  }
263
281
  forceChildUIRefresh() {
264
282
  Object.entries(this.settings).forEach(([t, e]) => {
@@ -291,7 +309,7 @@ const L = class L {
291
309
  );
292
310
  for (const o of a) {
293
311
  const l = o.id;
294
- if (l && l.includes(e.id)) {
312
+ if (l && "id" in e && typeof e.id == "string" && l.includes(e.id)) {
295
313
  o.remove();
296
314
  break;
297
315
  }
@@ -307,7 +325,7 @@ const L = class L {
307
325
  }
308
326
  clone() {
309
327
  const t = {};
310
- k(this.settings, (s, n) => {
328
+ b(this.settings, (s, n) => {
311
329
  const a = String(s);
312
330
  typeof n.clone == "function" ? t[a] = n.clone() : (console.warn(
313
331
  `Setting with key '${a}' does not have a clone method. Copying reference.`
@@ -321,8 +339,9 @@ const L = class L {
321
339
  custom: this.custom,
322
340
  includeGetJson: this.includeGetJson,
323
341
  addItem: this.addItemCfg,
324
- deleteItem: this.deleteItemCfg
325
- }, i = z(e);
342
+ deleteItem: this.deleteItemCfg,
343
+ dataProps: this.dataProps
344
+ }, i = R(e);
326
345
  return i.initialValues = this.getValues(), i;
327
346
  }
328
347
  resetDefault() {
@@ -368,7 +387,7 @@ const L = class L {
368
387
  Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
369
388
  }, 50));
370
389
  };
371
- return this.changeHandlers.clear(), k(this.settings, (i, s) => {
390
+ return this.changeHandlers.clear(), b(this.settings, (i, s) => {
372
391
  var n;
373
392
  if (p(s))
374
393
  s.setOnChange(() => {
@@ -431,7 +450,7 @@ const L = class L {
431
450
  d && t.startsWith(d) && this.addDeleteButtonToElement(o, t);
432
451
  }
433
452
  const r = a.querySelector(".sg-add-button-bottom");
434
- r ? a.insertBefore(o, r) : a.appendChild(o), S.trackElement(o), b(o, this.nestingLevel + 1), V(o, this.nestingLevel + 1);
453
+ r ? a.insertBefore(o, r) : a.appendChild(o), S.trackElement(o), x(o, this.nestingLevel + 1), V(o, this.nestingLevel + 1);
435
454
  const h = o.style.display;
436
455
  o.style.display = "none", o.offsetHeight, o.style.display = h, this.updateNestingStyles();
437
456
  }
@@ -672,7 +691,7 @@ const L = class L {
672
691
  }
673
692
  draw() {
674
693
  const t = document.createElement("div");
675
- t.className = "setting-group", t.id = `setting-group-${this.id}`, L.hiddenElements.add(t), this.isMain && t.classList.add("main-group"), this.custom && t.classList.add("custom_class"), b(t, this.nestingLevel);
694
+ t.className = "setting-group", t.id = `setting-group-${this.id}`, L.hiddenElements.add(t), this.isMain && t.classList.add("main-group"), this.custom && t.classList.add("custom_class"), x(t, this.nestingLevel);
676
695
  const e = document.createElement("div");
677
696
  e.className = "setting-group-title", this.isCollapsed && e.classList.add("collapsed-view"), e.setAttribute("role", "button"), e.setAttribute(
678
697
  "aria-expanded",
@@ -727,7 +746,7 @@ const L = class L {
727
746
  </svg>`;
728
747
  h.innerHTML = `${d}<span style="margin-left:4px;">${this.addItemCfg.buttonLabel ?? "Add"}</span>`, h.addEventListener("click", (u) => {
729
748
  u.stopPropagation(), u.preventDefault();
730
- const y = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), O = this.addItemCfg.createItem(y), H = `${this.addItemCfg.keyPrefix}${y}`;
749
+ const k = this.getNextIndexFromPrefix(this.addItemCfg.keyPrefix), O = this.addItemCfg.createItem(k), H = `${this.addItemCfg.keyPrefix}${k}`;
731
750
  this.addSetting(H, O);
732
751
  }), o.appendChild(h);
733
752
  }
@@ -776,9 +795,9 @@ const L = class L {
776
795
  L.hiddenElements = /* @__PURE__ */ new Set();
777
796
  let v = L;
778
797
  function vt(c) {
779
- return new F(c);
798
+ return new $(c);
780
799
  }
781
- class F extends v {
800
+ class $ extends v {
782
801
  constructor(t) {
783
802
  super(t);
784
803
  const e = Object.keys(this.settings)[0];
@@ -829,13 +848,13 @@ class F extends v {
829
848
  return this.updateTabUI(), t;
830
849
  }
831
850
  }
832
- function z(c) {
851
+ function R(c) {
833
852
  return new v(c);
834
853
  }
835
854
  function Ct(c) {
836
855
  return c;
837
856
  }
838
- class G extends g {
857
+ class F extends g {
839
858
  constructor(t = {}) {
840
859
  super(t), this.inputType = "text", t.onChange && this.setOnChange(t.onChange);
841
860
  }
@@ -855,12 +874,12 @@ class G extends g {
855
874
  });
856
875
  }
857
876
  }
858
- const P = "<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>";
859
- class m extends G {
877
+ const z = "<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>";
878
+ class m extends F {
860
879
  constructor(t) {
861
880
  super({
862
881
  ...t,
863
- icon: t.icon || P,
882
+ icon: t.icon || z,
864
883
  title: t.title || "Color",
865
884
  default: t.default ? m.normalizeColorValue(t.default) : "#000000"
866
885
  }), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.detectChange = t.detectChange;
@@ -920,13 +939,13 @@ class m extends G {
920
939
  const d = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r);
921
940
  return d ? e.classList.remove("error") : e.classList.add("error"), d;
922
941
  }, s = document.createElement("input");
923
- s.type = "color", s.className = "color-picker", s.value = this.value || "#000000", s.setAttribute("aria-label", "Choose color"), s.setAttribute("title", "Click to open color picker"), this.colorInputEl = s;
942
+ s.type = "color", s.className = "color-picker", s.value = this.value || "#000000", s.setAttribute("aria-label", "Choose color"), s.setAttribute("title", "Click to open color picker"), this.getDataPropsPath() && s.setAttribute("data-test-id", this.getDataPropsPath()), this.colorInputEl = s;
924
943
  const n = document.createElement("div");
925
944
  n.className = "color-preview";
926
945
  const a = this.value || "#000000";
927
946
  n.style.backgroundColor = a;
928
947
  const o = document.createElement("input");
929
- return o.type = "text", o.className = "color-text-input", o.value = this.value || "", o.placeholder = "#000000", o.setAttribute("pattern", "#[0-9A-Fa-f]{6}"), o.setAttribute("title", "Enter a hex color value (e.g., #ff0000)"), o.setAttribute("aria-label", "Hex color value"), o.setAttribute("maxlength", "7"), this.textInputEl = o, this.textInputEl.addEventListener("input", (l) => {
948
+ return o.type = "text", o.className = "color-text-input", o.value = this.value || "", o.placeholder = "#000000", o.setAttribute("pattern", "#[0-9A-Fa-f]{6}"), o.setAttribute("title", "Enter a hex color value (e.g., #ff0000)"), o.setAttribute("aria-label", "Hex color value"), o.setAttribute("maxlength", "7"), this.getDataPropsPath() && o.setAttribute("data-test-id", `${this.getDataPropsPath()}_text`), this.textInputEl = o, this.textInputEl.addEventListener("input", (l) => {
930
949
  var h, d;
931
950
  let r = l.target.value.trim();
932
951
  if (this.textInputEl && i(this.textInputEl)) {
@@ -959,7 +978,7 @@ class m extends G {
959
978
  return this.isValidHex() ? this.hexToRgb(this.value) : "0, 0, 0";
960
979
  }
961
980
  }
962
- const j = `
981
+ const G = `
963
982
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
964
983
  <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"/>
965
984
  <path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
@@ -969,7 +988,7 @@ class C extends g {
969
988
  constructor(t = {}) {
970
989
  super({
971
990
  ...t,
972
- icon: t.icon || j,
991
+ icon: t.icon || G,
973
992
  title: t.title || "Color & Opacity",
974
993
  default: t.default || "#000000FF"
975
994
  }), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.opacityInputEl = null, this.colorPreviewEl = null, this.detectChange = t.detectChange, this.value && (this.value = C.normalizeHexWithOpacity(this.value));
@@ -1001,7 +1020,10 @@ class C extends g {
1001
1020
  this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${a}, ${e})`;
1002
1021
  }
1003
1022
  handleColorChange(t) {
1004
- const e = this.getOpacityPercent(), i = C.combineColorOpacity(t, e);
1023
+ const e = this.getOpacityPercent(), i = C.combineColorOpacity(
1024
+ t,
1025
+ e
1026
+ );
1005
1027
  this.setValue(i);
1006
1028
  }
1007
1029
  handleTextInput(t) {
@@ -1009,7 +1031,10 @@ class C extends g {
1009
1031
  return e || i ? (this.setValue(t), !0) : !1;
1010
1032
  }
1011
1033
  handleOpacityChange(t) {
1012
- const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s = C.combineColorOpacity(e, i);
1034
+ const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s = C.combineColorOpacity(
1035
+ e,
1036
+ i
1037
+ );
1013
1038
  this.setValue(s);
1014
1039
  }
1015
1040
  draw() {
@@ -1027,7 +1052,13 @@ class C extends g {
1027
1052
  t.appendChild(a);
1028
1053
  }
1029
1054
  const e = document.createElement("div");
1030
- e.className = "color-with-opacity-input-wrapper", this.colorInputEl = document.createElement("input"), this.colorInputEl.type = "color", this.colorInputEl.className = "color-with-opacity-picker", 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.updateInputElements(), this.updateColorPreview(), this.colorInputEl.addEventListener("input", (a) => {
1055
+ 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(
1056
+ "data-test-id",
1057
+ `${this.getDataPropsPath()}_color`
1058
+ ), 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(
1059
+ "data-test-id",
1060
+ `${this.getDataPropsPath()}_text`
1061
+ ), this.updateInputElements(), this.updateColorPreview(), this.colorInputEl.addEventListener("input", (a) => {
1031
1062
  const o = a.target;
1032
1063
  this.handleColorChange(o.value), this.textInputEl && (this.textInputEl.value = this.value || "#000000FF"), this.updateColorPreview();
1033
1064
  }), this.textInputEl.addEventListener("input", (a) => {
@@ -1041,7 +1072,10 @@ class C extends g {
1041
1072
  (a = this.colorInputEl) == null || a.click();
1042
1073
  }), e.appendChild(this.colorInputEl), e.appendChild(this.colorPreviewEl), e.appendChild(this.textInputEl);
1043
1074
  const i = document.createElement("div");
1044
- 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";
1075
+ 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(
1076
+ "data-test-id",
1077
+ `${this.getDataPropsPath()}_opacity`
1078
+ );
1045
1079
  const s = document.createElement("span");
1046
1080
  s.className = "color-with-opacity-opacity-suffix", s.textContent = "%", this.opacityInputEl.addEventListener("input", (a) => {
1047
1081
  const o = a.target, l = parseFloat(o.value);
@@ -1094,7 +1128,7 @@ class wt extends g {
1094
1128
  t.appendChild(n);
1095
1129
  }
1096
1130
  const e = document.createElement("textarea");
1097
- 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.props.maxLength !== void 0 && (e.maxLength = this.props.maxLength), this.props.className && e.classList.add(this.props.className);
1131
+ 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);
1098
1132
  const i = (n) => {
1099
1133
  const o = n.target.value;
1100
1134
  this.value = o, this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
@@ -1125,7 +1159,7 @@ class f extends g {
1125
1159
  const e = document.createElement("div");
1126
1160
  e.className = "number-setting-input-container";
1127
1161
  const i = document.createElement("input");
1128
- if (i.type = "number", i.className = "number-setting-input " + (this.props.inputClassName || ""), i.value = String(this.value ?? ""), i.placeholder = this.props.placeholder || "", 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", () => {
1162
+ 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", () => {
1129
1163
  const s = this.props.minValue ?? Number.MIN_SAFE_INTEGER, n = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
1130
1164
  let a = Number(i.value);
1131
1165
  a < s && (a = s), a > n && (a = n), String(a) !== i.value && (i.value = String(a)), this.setValue(a);
@@ -1163,12 +1197,12 @@ class f extends g {
1163
1197
  );
1164
1198
  }
1165
1199
  }
1166
- const W = `
1200
+ const j = `
1167
1201
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
1168
1202
  <path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
1169
1203
  <path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
1170
1204
  </svg>`;
1171
- class D extends f {
1205
+ class W extends f {
1172
1206
  constructor(t = {}) {
1173
1207
  const e = {
1174
1208
  title: "Opacity",
@@ -1177,7 +1211,7 @@ class D extends f {
1177
1211
  maxValue: 100,
1178
1212
  step: 1,
1179
1213
  default: t.default ?? 100,
1180
- icon: W,
1214
+ icon: j,
1181
1215
  ...t
1182
1216
  };
1183
1217
  super(e), this.inputType = "number", this.mobileValue = t.mobile;
@@ -1228,7 +1262,7 @@ class I extends g {
1228
1262
  t.appendChild(n);
1229
1263
  }
1230
1264
  const e = document.createElement("div");
1231
- e.classList.add("select-button"), this.isLoading ? e.classList.add("loading") : e.textContent = this.selectedOptionIndex !== null ? this._options[this.selectedOptionIndex].name : this.props.placeholder || "Select an option", e.onclick = () => {
1265
+ 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 = () => {
1232
1266
  var n, a;
1233
1267
  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));
1234
1268
  }, t.appendChild(e), this.buttonEl = e;
@@ -1353,20 +1387,23 @@ class J extends g {
1353
1387
  }
1354
1388
  ].forEach((n) => {
1355
1389
  const a = document.createElement("button");
1356
- a.className = "align-option-button", a.innerHTML = n.icon, this.value === n.name && a.classList.add("selected"), a.addEventListener("click", () => {
1390
+ a.className = "align-option-button", a.innerHTML = n.icon, this.getDataPropsPath() && a.setAttribute(
1391
+ "data-test-id",
1392
+ `${this.getDataPropsPath()}_${n.name}`
1393
+ ), this.value === n.name && a.classList.add("selected"), a.addEventListener("click", () => {
1357
1394
  var o;
1358
1395
  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);
1359
1396
  }), i.appendChild(a);
1360
1397
  }), t.appendChild(i), t;
1361
1398
  }
1362
1399
  }
1363
- class Et extends g {
1400
+ class bt extends g {
1364
1401
  constructor(t) {
1365
1402
  super(t), this.inputType = "button", this.bgWithAlpha = "rgba(145, 158, 171, 0.08)";
1366
1403
  }
1367
1404
  draw() {
1368
1405
  const t = document.createElement("button");
1369
- t.className = "button-setting " + (this.props.className || ""), t.textContent = this.props.label, t.style.borderColor = this.props.borderColor || "rgba(145, 158, 171, 0.32)";
1406
+ t.className = "button-setting " + (this.props.className || ""), t.textContent = this.props.label, t.style.borderColor = this.props.borderColor || "rgba(145, 158, 171, 0.32)", this.getDataPropsPath() && t.setAttribute("data-test-id", this.getDataPropsPath());
1370
1407
  const e = this.props.backgroundColor || "rgba(0,0,0,0)", i = this.props.textColor || "black";
1371
1408
  t.style.backgroundColor = e, t.style.color = i;
1372
1409
  let s = e;
@@ -1389,7 +1426,7 @@ class Et extends g {
1389
1426
  return a.className = "button-setting-wrapper " + (this.props.wrapperClassName || ""), a.appendChild(t), a;
1390
1427
  }
1391
1428
  }
1392
- class bt extends g {
1429
+ class Et extends g {
1393
1430
  constructor(t = {}) {
1394
1431
  super(t), this.inputType = { width: "number", height: "number" }, this.aspectRatio = 1, this.isUpdating = !1;
1395
1432
  const e = t.width || 0, i = t.height || 0;
@@ -1643,7 +1680,7 @@ class Q extends g {
1643
1680
  }
1644
1681
  this.previewWrapper.appendChild(this.previewEl);
1645
1682
  const a = document.createElement("button");
1646
- return a.className = "upload-button", a.innerHTML = `
1683
+ return a.className = "upload-button", this.getDataPropsPath() && a.setAttribute("data-test-id", this.getDataPropsPath()), a.innerHTML = `
1647
1684
  <span class="upload-icon">${M}</span>
1648
1685
  <span class="upload-label">Upload</span>
1649
1686
  `, i.appendChild(n), i.appendChild(this.previewWrapper), i.appendChild(a), t.appendChild(i), s ? this.updatePreviewState(this.value) : this.updatePreviewState(null), a.onclick = () => {
@@ -1678,7 +1715,7 @@ class xt extends f {
1678
1715
  const Y = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
1679
1716
  <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"/>
1680
1717
  </svg>`;
1681
- class Lt extends f {
1718
+ class yt extends f {
1682
1719
  constructor(t = {}) {
1683
1720
  super({
1684
1721
  ...t,
@@ -1703,7 +1740,7 @@ const tt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewB
1703
1740
  <polyline points="6 9 12 15 18 9"></polyline>
1704
1741
  </svg>
1705
1742
  `;
1706
- class yt extends g {
1743
+ class Lt extends g {
1707
1744
  constructor(t = {}) {
1708
1745
  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) {
1709
1746
  const e = this._options.findIndex(
@@ -1726,7 +1763,7 @@ class yt extends g {
1726
1763
  const t = document.createElement("div");
1727
1764
  t.classList.add("select-api-container"), this.container = t;
1728
1765
  const e = document.createElement("div");
1729
- if (e.classList.add("select-api-button"), this.props.title) {
1766
+ if (e.classList.add("select-api-button"), this.getDataPropsPath() && e.setAttribute("data-test-id", this.getDataPropsPath()), this.props.title) {
1730
1767
  e.classList.add("has-label");
1731
1768
  const n = document.createElement("div");
1732
1769
  n.className = "select-label", n.textContent = this.props.title, e.appendChild(n);
@@ -1872,7 +1909,7 @@ class kt extends g {
1872
1909
  const i = document.createElement("label");
1873
1910
  i.className = "toggle-switch";
1874
1911
  const s = document.createElement("input");
1875
- 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, s.addEventListener("change", () => {
1912
+ 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", () => {
1876
1913
  var r, h;
1877
1914
  const l = ((h = (r = this.props.options) == null ? void 0 : r.find((d) => d.status === s.checked)) == null ? void 0 : h.value) ?? "";
1878
1915
  this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
@@ -1924,7 +1961,7 @@ class Mt extends g {
1924
1961
  const i = document.createElement("div");
1925
1962
  i.className = "gap-input-wrapper";
1926
1963
  const s = document.createElement("input");
1927
- 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, s.addEventListener("input", (n) => {
1964
+ 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) => {
1928
1965
  const a = n.target;
1929
1966
  let o = parseFloat(a.value);
1930
1967
  o = this.validateValue(o), String(o) !== a.value && (a.value = String(o)), this.inputValues[t] = o, this.setValue(o);
@@ -2041,7 +2078,10 @@ class St extends g {
2041
2078
  const n = document.createElement("div");
2042
2079
  n.classList.add("language-input-group");
2043
2080
  const a = document.createElement("input");
2044
- a.type = "text", a.classList.add("language-input"), a.value = e || "", a.placeholder = this.props.placeholder || "Enter text...", a.addEventListener("input", (l) => {
2081
+ a.type = "text", a.classList.add("language-input"), a.value = e || "", a.placeholder = this.props.placeholder || "Enter text...", this.getDataPropsPath() && a.setAttribute(
2082
+ "data-test-id",
2083
+ `${this.getDataPropsPath()}_${t}`
2084
+ ), a.addEventListener("input", (l) => {
2045
2085
  const r = l.target;
2046
2086
  this.updateLanguageValue(t, r.value);
2047
2087
  });
@@ -2057,7 +2097,9 @@ class St extends g {
2057
2097
  var i;
2058
2098
  if (!this.value) return;
2059
2099
  delete this.value[t], this.onChange && this.onChange(this.value), this.props.detectChange && this.props.detectChange(this.value);
2060
- const e = (i = this.languagesContainer) == null ? void 0 : i.querySelector(`[data-language="${t}"]`);
2100
+ const e = (i = this.languagesContainer) == null ? void 0 : i.querySelector(
2101
+ `[data-language="${t}"]`
2102
+ );
2061
2103
  e && e.remove(), this.updateAddLanguageSelect();
2062
2104
  }
2063
2105
  addLanguage(t) {
@@ -2179,11 +2221,11 @@ class Ot extends v {
2179
2221
  `;
2180
2222
  }
2181
2223
  }
2182
- const ct = `
2224
+ const ht = `
2183
2225
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="13" viewBox="0 0 14 13" fill="none">
2184
2226
  <path d="M1 2.75C1 2.05109 1 1.70163 1.11418 1.42597C1.26642 1.05843 1.55843 0.766422 1.92597 0.614181C2.20163 0.5 2.55109 0.5 3.25 0.5H10.75C11.4489 0.5 11.7984 0.5 12.074 0.614181C12.4416 0.766422 12.7336 1.05843 12.8858 1.42597C13 1.70163 13 2.05109 13 2.75M4.75 12.5H9.25M7 0.5V12.5" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
2185
2227
  </svg>
2186
- `, ht = `
2228
+ `, ct = `
2187
2229
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
2188
2230
  <path d="M3 5.75C3 5.05109 3 4.70163 3.11418 4.42597C3.26642 4.05843 3.55843 3.76642 3.92597 3.61418C4.20163 3.5 4.55109 3.5 5.25 3.5H12.75C13.4489 3.5 13.7984 3.5 14.074 3.61418C14.4416 3.76642 14.7336 4.05843 14.8858 4.42597C15 4.70163 15 5.05109 15 5.75M6 15.5H12M7.6875 3.5V15.5M10.3125 3.5V15.5" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
2189
2231
  </svg>
@@ -2205,7 +2247,7 @@ class Ht extends v {
2205
2247
  }),
2206
2248
  fontFamily: new I({
2207
2249
  title: "Font",
2208
- icon: ct,
2250
+ icon: ht,
2209
2251
  default: i.fontFamilyDefault ?? "Satoshi",
2210
2252
  options: i.fontFamilyOptions ?? [
2211
2253
  { name: "Alt", value: "Croco Sans Black Caps Alt" },
@@ -2218,7 +2260,7 @@ class Ht extends v {
2218
2260
  }),
2219
2261
  fontWeight: new I({
2220
2262
  title: "Weight",
2221
- icon: ht,
2263
+ icon: ct,
2222
2264
  default: i.fontWeightDefault ?? "400",
2223
2265
  options: i.fontWeightOptions ?? [
2224
2266
  { name: "Regular", value: "400" },
@@ -2356,7 +2398,7 @@ const ut = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewB
2356
2398
  </svg>`, mt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
2357
2399
  <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"/>
2358
2400
  </svg>`;
2359
- class At extends v {
2401
+ class Pt extends v {
2360
2402
  constructor(t) {
2361
2403
  super({
2362
2404
  title: "Background Image",
@@ -2366,7 +2408,7 @@ class At extends v {
2366
2408
  ...t == null ? void 0 : t.uploadProps,
2367
2409
  default: (t == null ? void 0 : t.backgroundImage) ?? ""
2368
2410
  }),
2369
- opacity: new D({
2411
+ opacity: new W({
2370
2412
  default: (t == null ? void 0 : t.opacity) ?? 100
2371
2413
  }),
2372
2414
  backgroundColor: new C({
@@ -2395,21 +2437,15 @@ class At extends v {
2395
2437
  `;
2396
2438
  }
2397
2439
  }
2398
- function Bt(c) {
2399
- return p(c);
2400
- }
2401
- function $t(c) {
2402
- return w(c);
2403
- }
2404
2440
  export {
2405
2441
  J as AlignSetting,
2406
2442
  Nt as AnimationSetting,
2407
- At as BackgroundSettingSet,
2443
+ Pt as BackgroundSettingSet,
2408
2444
  Ot as BorderSettingSet,
2409
- Et as ButtonSetting,
2445
+ bt as ButtonSetting,
2410
2446
  m as ColorSetting,
2411
2447
  C as ColorWithOpacitySetting,
2412
- bt as DimensionSetting,
2448
+ Et as DimensionSetting,
2413
2449
  Mt as GapSetting,
2414
2450
  Ht as HeaderTypographySettingSet,
2415
2451
  xt as HeightSetting,
@@ -2419,22 +2455,22 @@ export {
2419
2455
  It as MarginTopSetting,
2420
2456
  St as MultiLanguageSetting,
2421
2457
  f as NumberSetting,
2422
- D as OpacitySetting,
2423
- yt as SelectApiSettings,
2458
+ W as OpacitySetting,
2459
+ Lt as SelectApiSettings,
2424
2460
  I as SelectSetting,
2425
2461
  g as Setting,
2426
2462
  v as SettingGroup,
2427
- G as StringSetting,
2428
- F as TabSettingGroup,
2429
- F as TabsSettingGroup,
2463
+ F as StringSetting,
2464
+ $ as TabSettingGroup,
2465
+ $ as TabsSettingGroup,
2430
2466
  kt as Toggle,
2431
2467
  Q as UploadSetting,
2432
- Lt as WidthSetting,
2468
+ yt as WidthSetting,
2433
2469
  Ct as asSettingGroupWithSettings,
2434
- z as createSettingGroup,
2470
+ R as createSettingGroup,
2435
2471
  vt as createTabSettingGroup,
2436
- $t as isSetting,
2472
+ w as isSetting,
2437
2473
  ft as isSettingChild,
2438
- Bt as isSettingGroup,
2439
- k as iterateSettings
2474
+ p as isSettingGroup,
2475
+ b as iterateSettings
2440
2476
  };
package/dist/index.d.ts CHANGED
@@ -28,3 +28,4 @@ export * from './groups/headerTypographySettingsSet';
28
28
  export * from './groups/margin-setting-group/marginSettingGroup';
29
29
  export * from './groups/background-setting-set/backgroundSettingsSet';
30
30
  export * from './utils/settingsTypes';
31
+ export * from './types/index';
@@ -1,9 +1,10 @@
1
1
  import { Setting, SettingProps, InputTypes, Primitive } from '../../base/settings';
2
+ import { SettingsMap } from '../../types';
2
3
  export interface SelectApiOption {
3
4
  name: string;
4
5
  value: string | object;
5
6
  }
6
- export interface SelectApiSettingProps<T = any> extends SettingProps<T> {
7
+ export interface SelectApiSettingProps<T = SettingsMap> extends SettingProps<T> {
7
8
  options?: SelectApiOption[];
8
9
  getOptions?: () => SelectApiOption[];
9
10
  getOptionsAsync?: () => Promise<SelectApiOption[]>;
@@ -12,7 +13,7 @@ export interface SelectApiSettingProps<T = any> extends SettingProps<T> {
12
13
  onChange?: (value: T) => void;
13
14
  detectChange?: (value: T | undefined) => void;
14
15
  }
15
- export declare class SelectApiSettings<T = any> extends Setting<T, SelectApiSettingProps<T>> {
16
+ export declare class SelectApiSettings<T = SettingsMap> extends Setting<T, SelectApiSettingProps<T>> {
16
17
  inputType: T extends Primitive ? InputTypes : Record<keyof T, InputTypes>;
17
18
  private _options;
18
19
  private isOpen;