@useinsider/guido 2.0.0-beta.bf65edd → 2.0.0-beta.c0d8594

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.
Files changed (61) hide show
  1. package/README.md +2 -0
  2. package/dist/@types/config/schemas.js +3 -1
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +57 -61
  5. package/dist/components/organisms/base/Toaster.vue.js +6 -6
  6. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +6 -6
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  9. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
  10. package/dist/components/organisms/header/LeftSlot.vue.js +12 -12
  11. package/dist/components/organisms/header/LeftSlot.vue2.js +6 -6
  12. package/dist/composables/useStripo.js +40 -40
  13. package/dist/config/migrator/index.js +9 -8
  14. package/dist/config/migrator/itemsBlockMigrator.js +283 -0
  15. package/dist/extensions/Blocks/CouponBlock/constants.js +4 -0
  16. package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
  17. package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
  18. package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
  19. package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
  20. package/dist/extensions/Blocks/Items/block.js +39 -40
  21. package/dist/extensions/Blocks/Items/controls/button/link.js +22 -29
  22. package/dist/extensions/Blocks/Items/controls/cardComposition.js +46 -49
  23. package/dist/extensions/Blocks/Items/controls/image/link.js +23 -30
  24. package/dist/extensions/Blocks/Items/controls/name/trimming.js +13 -15
  25. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +1 -1
  26. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
  27. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +15 -17
  28. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -15
  29. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +29 -27
  30. package/dist/extensions/Blocks/Items/controls/settingsControl.js +145 -136
  31. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -2
  32. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -48
  33. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -58
  34. package/dist/extensions/Blocks/Items/settingsPanel.js +4 -4
  35. package/dist/extensions/Blocks/Items/store/items-block.js +2 -2
  36. package/dist/extensions/Blocks/Items/template.js +312 -125
  37. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +172 -0
  38. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +17 -44
  39. package/dist/extensions/Blocks/Recommendation/control.js +1 -1
  40. package/dist/extensions/Blocks/common-control.js +64 -53
  41. package/dist/extensions/Blocks/controlFactories.js +139 -118
  42. package/dist/guido.css +1 -1
  43. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +370 -286
  44. package/dist/package.json.js +1 -1
  45. package/dist/services/stripoApi.js +6 -10
  46. package/dist/src/@types/config/schemas.d.ts +4 -0
  47. package/dist/src/composables/useConfig.d.ts +2 -0
  48. package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
  49. package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
  50. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
  51. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -2
  53. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -2
  54. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
  56. package/dist/src/extensions/Blocks/Items/template.d.ts +20 -1
  57. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +71 -0
  58. package/dist/src/extensions/Blocks/common-control.d.ts +13 -8
  59. package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
  60. package/dist/src/stores/config.d.ts +17 -0
  61. package/package.json +3 -3
@@ -1,76 +1,49 @@
1
- import { useItemsBlockStore as e } from "../store/items-block.js";
2
- import { syncAttributeFromConfigBlock as r, createBooleanSyncConfig as i, createStringSyncConfig as s } from "./syncAttributeFromConfigBlock.js";
3
- function m(t) {
4
- const o = e(), n = i(
1
+ import { useItemsBlockStore as r } from "../store/items-block.js";
2
+ import { syncAttributeFromConfigBlock as e, createBooleanSyncConfig as s, createStringSyncConfig as i } from "./syncAttributeFromConfigBlock.js";
3
+ function u(t) {
4
+ const o = r(), n = s(
5
5
  "PRODUCT_NAME_TRIMMING",
6
6
  (c) => o.setNameTrimming(c),
7
7
  !1
8
8
  );
9
- r(t, n);
9
+ e(t, n);
10
10
  }
11
11
  function f(t) {
12
- const o = e(), n = i(
12
+ const o = r(), n = s(
13
13
  "PRODUCT_PRICE_HIDE_DISCOUNT",
14
14
  (c) => o.setHideDiscount(c),
15
- !1
15
+ !0
16
16
  );
17
- r(t, n);
17
+ e(t, n);
18
18
  }
19
19
  function R(t) {
20
- const o = e(), n = i(
20
+ const o = r(), n = s(
21
21
  "PRODUCT_PRICE_FORMATTED",
22
22
  (c) => o.setFormattedPrice(c),
23
23
  !0
24
24
  );
25
- r(t, n);
25
+ e(t, n);
26
26
  }
27
- function O(t) {
28
- const o = e(), n = s(
27
+ function y(t) {
28
+ const o = r(), n = i(
29
29
  "PRODUCT_PRICE_CURRENCY_SYMBOL",
30
30
  (c) => o.setCurrencySymbol(c),
31
31
  ""
32
32
  );
33
- r(t, n);
33
+ e(t, n);
34
34
  }
35
35
  function _(t) {
36
- const o = e(), n = s(
36
+ const o = r(), n = i(
37
37
  "PRODUCT_PRICE_CURRENCY_LOCATION",
38
38
  (c) => o.setCurrencyLocation(c),
39
39
  "0"
40
40
  );
41
- r(t, n);
42
- }
43
- function I(t) {
44
- const o = e(), n = s(
45
- "PRODUCT_BUTTON_LINK",
46
- (c) => o.setButtonLink(c),
47
- ""
48
- );
49
- r(t, n);
50
- }
51
- function T(t) {
52
- const o = e(), n = s(
53
- "PRODUCT_IMAGE_LINK",
54
- (c) => o.setImageLink(c),
55
- ""
56
- );
57
- r(t, n);
58
- }
59
- function y(t) {
60
- const o = e(), n = s(
61
- "PRODUCT_ORIGINAL_PRICE_CONTROL_ORIENTATION",
62
- (c) => o.setPriceOrientation(c),
63
- "horizontal"
64
- );
65
- r(t, n);
41
+ e(t, n);
66
42
  }
67
43
  export {
68
- I as syncButtonLinkFromAttributes,
69
44
  _ as syncCurrencyLocationFromAttributes,
70
- O as syncCurrencySymbolFromAttributes,
45
+ y as syncCurrencySymbolFromAttributes,
71
46
  R as syncFormattedPriceFromAttributes,
72
47
  f as syncHideDiscountFromAttributes,
73
- T as syncImageLinkFromAttributes,
74
- m as syncNameTrimmingFromAttributes,
75
- y as syncPriceOrientationFromAttributes
48
+ u as syncNameTrimmingFromAttributes
76
49
  };
@@ -289,7 +289,7 @@ class b extends g {
289
289
  t.CURRENCY_DECIMAL_COUNT
290
290
  ].forEach((i) => {
291
291
  this.api.onValueChanged(i, (a) => this._onCurrencyConfigChange(i, a));
292
- }), this.api.onValueChanged(t.PRODUCT_COUNT, (i) => this._onDataChange(t.PRODUCT_COUNT, i.toString())), this.api.onValueChanged(t.PRODUCT_IN_ROW, (i) => this._onDataChange(t.PRODUCT_IN_ROW, i)), this.api.onValueChanged(t.SHUFFLE_PRODUCTS, (i) => this._onDataChange(t.SHUFFLE_PRODUCTS, i)), this.api.onValueChanged(t.RESPONSIVE, (i) => this._onDataChange(t.RESPONSIVE, i)), this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (o = this.addFilterButton) == null || o.addEventListener("click", this.addFilterListener);
292
+ }), this.api.onValueChanged(t.PRODUCT_COUNT, (i) => this._onDataChange(t.PRODUCT_COUNT, String(i))), this.api.onValueChanged(t.PRODUCT_IN_ROW, (i) => this._onDataChange(t.PRODUCT_IN_ROW, i)), this.api.onValueChanged(t.SHUFFLE_PRODUCTS, (i) => this._onDataChange(t.SHUFFLE_PRODUCTS, i)), this.api.onValueChanged(t.RESPONSIVE, (i) => this._onDataChange(t.RESPONSIVE, i)), this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (o = this.addFilterButton) == null || o.addEventListener("click", this.addFilterListener);
293
293
  }
294
294
  _listenStateUpdates() {
295
295
  this.storeUnsubscription = this.store.$subscribe((e) => {
@@ -1,8 +1,8 @@
1
1
  var c = Object.defineProperty;
2
- var I = (a, r, e) => r in a ? c(a, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[r] = e;
3
- var l = (a, r, e) => I(a, typeof r != "symbol" ? r + "" : r, e);
4
- import { Control as O, UIElementType as t, UEAttr as $ } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- class _ extends O {
2
+ var I = (T, r, e) => r in T ? c(T, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : T[r] = e;
3
+ var l = (T, r, e) => I(T, typeof r != "symbol" ? r + "" : r, e);
4
+ import { Control as s, UIElementType as t, UEAttr as $ } from "../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ class B extends s {
6
6
  constructor() {
7
7
  super(...arguments);
8
8
  l(this, "currentNode");
@@ -19,43 +19,54 @@ class _ extends O {
19
19
  this.lastBlockInstanceId = null;
20
20
  }
21
21
  /**
22
- * Gets the config block element from the current node.
22
+ * Gets the Items block container element from the current node.
23
+ * @returns The container element or null if not found
24
+ */
25
+ getItemsBlockContainer() {
26
+ return this.currentNode ? this.currentNode.closest(".items-block-v2") : null;
27
+ }
28
+ /**
29
+ * Gets the config block element from the current node (legacy support).
30
+ * @deprecated Use getNodeConfig() from nodeConfigUtils instead for Stripo V2
23
31
  * @returns The config block element or null if not found
24
32
  */
25
33
  getConfigBlock() {
26
- if (!this.currentNode)
27
- return null;
28
- const e = this.currentNode.closest(".items-block-v2");
34
+ const e = this.getItemsBlockContainer();
29
35
  return e ? e.querySelector("esd-config-block") : null;
30
36
  }
31
37
  /**
32
- * Gets the current block instance ID from the config block.
33
- * @param blockInstanceIdAttribute - The attribute name for block instance ID (default: 'data-block-instance-id')
38
+ * Gets the current block instance ID from the node config (Stripo V2) or legacy config block.
34
39
  * @returns The block instance ID or null if not found
35
40
  */
36
- getBlockInstanceId(e = "data-block-instance-id") {
37
- const n = this.getConfigBlock();
38
- return n ? n.getAttribute(e) : null;
41
+ getBlockInstanceId() {
42
+ const e = this.getItemsBlockContainer();
43
+ if (!e)
44
+ return null;
45
+ const n = e.getNodeConfig();
46
+ if (n && typeof n.blockInstanceId == "string")
47
+ return n.blockInstanceId;
48
+ const o = this.getConfigBlock();
49
+ return o ? o.getAttribute("data-block-instance-id") : null;
39
50
  }
40
51
  /**
41
52
  * Handles block instance change detection and syncing.
42
- * This is a helper method for controls that need to sync attributes when switching between block instances.
43
- * @param syncFunction - Function to call when block instance changes (to sync from attributes)
53
+ * This is a helper method for controls that need to sync config when switching between block instances.
54
+ * Uses Stripo V2 nodeConfig API for block instance tracking.
55
+ * @param syncFunction - Function to call when block instance changes (to sync from node config)
44
56
  * @param updateUI - Function to call to update the UI (called both on change and when same block)
45
- * @param blockInstanceIdAttribute - The attribute name for block instance ID (default: 'data-block-instance-id')
46
57
  * @returns true if block instance changed, false otherwise
47
58
  */
48
- handleBlockInstanceChange(e, n, E = "data-block-instance-id") {
49
- const o = this.getBlockInstanceId(E);
59
+ handleBlockInstanceChange(e, n) {
60
+ const o = this.getBlockInstanceId();
50
61
  if (!o)
51
62
  return !1;
52
- const T = o !== this.lastBlockInstanceId;
53
- return T ? (this.currentNode && e(this.currentNode), n(), this.lastBlockInstanceId = o) : n(), T;
63
+ const E = o !== this.lastBlockInstanceId;
64
+ return E ? (this.currentNode && e(this.currentNode), n(), this.lastBlockInstanceId = o) : n(), E;
54
65
  }
55
- _GuLabel({ text: e, name: n = "", position: E = "top" }) {
66
+ _GuLabel({ text: e, name: n = "", position: o = "top" }) {
56
67
  return `
57
68
  <${t.LABEL}
58
- style="${E === "top" ? "margin-bottom: 8px;" : ""}"
69
+ style="${o === "top" ? "margin-bottom: 8px;" : ""}"
59
70
  ${$.LABEL.text}="${e}"
60
71
  ${$.LABEL.name}="${n || `${e} Label`}">
61
72
  </${t.LABEL}>
@@ -75,59 +86,59 @@ class _ extends O {
75
86
  ${$.SELECT_ITEM.value}="${n}">
76
87
  </${t.SELECT_ITEM}>`;
77
88
  }
78
- _GuSelect({ name: e, placeholder: n, options: E, className: o = "es-180w" }) {
89
+ _GuSelect({ name: e, placeholder: n, options: o, className: E = "es-180w" }) {
79
90
  return `
80
91
  <${t.SELECTPICKER}
81
- class="${o}"
92
+ class="${E}"
82
93
  ${$.SELECTPICKER.name}="${e}"
83
94
  ${$.SELECTPICKER.placeholder}="${n}">
84
- ${E.map((T) => this._GuSelectItem(T)).join("")}
95
+ ${o.map((a) => this._GuSelectItem(a)).join("")}
85
96
  </${t.SELECTPICKER}>
86
97
  `;
87
98
  }
88
- _GuTextInput({ name: e, placeholder: n, className: E = "", disabled: o = !1 }) {
99
+ _GuTextInput({ name: e, placeholder: n, className: o = "", disabled: E = !1 }) {
89
100
  return `
90
101
  <${t.TEXT}
91
- class=${E}
102
+ class=${o}
92
103
  ${$.TEXT.name}="${e}"
93
104
  placeholder="${n || e}"
94
- ${o ? `${$.TEXT.disabled}="true"` : ""}>
105
+ ${E ? `${$.TEXT.disabled}="true"` : ""}>
95
106
  </${t.TEXT}>
96
107
  `;
97
108
  }
98
- _GuCounter({ name: e, maxValue: n, minValue: E = 1, step: o = 1 }) {
109
+ _GuCounter({ name: e, maxValue: n, minValue: o = 1, step: E = 1 }) {
99
110
  return `
100
111
  <${t.COUNTER}
101
112
  ${$.COUNTER.name}="${e}"
102
- ${$.COUNTER.minValue}="${E}"
113
+ ${$.COUNTER.minValue}="${o}"
103
114
  ${$.COUNTER.maxValue}="${n}"
104
- ${$.COUNTER.step}="${o}">
115
+ ${$.COUNTER.step}="${E}">
105
116
  </${t.COUNTER}>
106
117
  `;
107
118
  }
108
- _GuRadioButtonItem({ text: e, value: n, icon: E }) {
119
+ _GuRadioButtonItem({ text: e, value: n, icon: o }) {
109
120
  return `
110
121
  <${t.RADIO_ITEM}
111
122
  ${$.RADIO_ITEM.value}="${n}"
112
123
  ${e ? `${$.RADIO_ITEM.text}="${e}"` : ""}
113
- ${E ? `${$.RADIO_ITEM.icon}="${E}"` : ""}>
124
+ ${o ? `${$.RADIO_ITEM.icon}="${o}"` : ""}>
114
125
  </${t.RADIO_ITEM}>
115
126
  `;
116
127
  }
117
- _GuRadioButton({ name: e, buttons: n, id: E = "" }) {
128
+ _GuRadioButton({ name: e, buttons: n, id: o = "" }) {
118
129
  return `
119
130
  <${t.RADIO_BUTTONS}
120
- ${E ? `id="${E}"` : ""}
131
+ ${o ? `id="${o}"` : ""}
121
132
  ${$.RADIO_BUTTONS.name}="${e}">
122
- ${n.map((o) => this._GuRadioButtonItem(o)).join("")}
133
+ ${n.map((E) => this._GuRadioButtonItem(E)).join("")}
123
134
  </${t.RADIO_BUTTONS}>
124
135
  `;
125
136
  }
126
- _GuButton({ name: e, label: n, id: E = "" }) {
137
+ _GuButton({ name: e, label: n, id: o = "" }) {
127
138
  return `
128
139
  <${t.BUTTON}
129
140
  ${$.BUTTON.name}="${e}"
130
- ${E ? `id="${E}"` : ""}
141
+ ${o ? `id="${o}"` : ""}
131
142
  ${$.BUTTON.caption}="${n}"}>
132
143
  </${t.BUTTON}>
133
144
  `;
@@ -137,10 +148,10 @@ class _ extends O {
137
148
  * @param param0
138
149
  * @returns It returns a button with an icon.
139
150
  */
140
- _GuIconButton({ name: e, icon: n, className: E = "" }) {
151
+ _GuIconButton({ name: e, icon: n, className: o = "" }) {
141
152
  return `
142
153
  <${t.BUTTON}
143
- class="${E}"
154
+ class="${o}"
144
155
  ${$.BUTTON.name}="${e}"
145
156
  ${$.BUTTON.icon}="${n}">
146
157
  </${t.BUTTON}>
@@ -168,19 +179,19 @@ class _ extends O {
168
179
  * @returns HTML string for the orderable control
169
180
  */
170
181
  _GuOrderable(e, n) {
171
- let E = "";
172
- n.forEach((T) => {
182
+ let o = "";
183
+ n.forEach((a) => {
173
184
  const u = $.ORDERABLE_ITEM && "name" in $.ORDERABLE_ITEM ? $.ORDERABLE_ITEM.name : "name";
174
- E += `
175
- <${t.ORDERABLE_ITEM} ${u}="${T.key}">
176
- ${T.content}
185
+ o += `
186
+ <${t.ORDERABLE_ITEM} ${u}="${a.key}">
187
+ ${a.content}
177
188
  </${t.ORDERABLE_ITEM}>
178
189
  `;
179
190
  });
180
- const o = $.ORDERABLE && "name" in $.ORDERABLE ? $.ORDERABLE.name : "name";
191
+ const E = $.ORDERABLE && "name" in $.ORDERABLE ? $.ORDERABLE.name : "name";
181
192
  return `
182
- <${t.ORDERABLE} ${o}="${e}">
183
- ${E}
193
+ <${t.ORDERABLE} ${E}="${e}">
194
+ ${o}
184
195
  </${t.ORDERABLE}>
185
196
  `;
186
197
  }
@@ -221,16 +232,16 @@ class _ extends O {
221
232
  `;
222
233
  }
223
234
  _GuRadioButtons(e, n) {
224
- const E = n.map((o) => `
235
+ const o = n.map((E) => `
225
236
  <${t.RADIO_ITEM}
226
- ${$.RADIO_ITEM.text}="${o.text}"
227
- ${$.RADIO_ITEM.value}="${o.value}">
237
+ ${$.RADIO_ITEM.text}="${E.text}"
238
+ ${$.RADIO_ITEM.value}="${E.value}">
228
239
  </${t.RADIO_ITEM}>
229
240
  `).join("");
230
241
  return `
231
242
  <${t.RADIO_BUTTONS}
232
243
  ${$.RADIO_BUTTONS.name}="${e}">
233
- ${E}
244
+ ${o}
234
245
  </${t.RADIO_BUTTONS}>
235
246
  `;
236
247
  }
@@ -244,5 +255,5 @@ class _ extends O {
244
255
  }
245
256
  }
246
257
  export {
247
- _ as CommonControl
258
+ B as CommonControl
248
259
  };