@useinsider/guido 2.1.0-beta.411f2a9 → 2.1.0-beta.425dfd0

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 (36) hide show
  1. package/dist/config/migrator/itemsBlockMigrator.js +123 -140
  2. package/dist/extensions/Blocks/Items/block.js +28 -19
  3. package/dist/extensions/Blocks/Items/controls/button/link.js +31 -19
  4. package/dist/extensions/Blocks/Items/controls/cardComposition.js +81 -97
  5. package/dist/extensions/Blocks/Items/controls/image/link.js +31 -19
  6. package/dist/extensions/Blocks/Items/controls/name/trimming.js +40 -28
  7. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +46 -34
  8. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +50 -45
  9. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +51 -40
  10. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +35 -23
  11. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +57 -45
  12. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +62 -42
  13. package/dist/extensions/Blocks/Items/controls/settingsControl.js +191 -184
  14. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -0
  15. package/dist/extensions/Blocks/Items/extension.js +9 -8
  16. package/dist/extensions/Blocks/Items/store/items-block.js +79 -0
  17. package/dist/extensions/Blocks/Items/template.js +175 -181
  18. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  19. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
  20. package/dist/extensions/Blocks/common-control.js +92 -91
  21. package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
  22. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +1 -0
  23. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
  24. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +1 -0
  25. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +1 -0
  26. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +1 -0
  27. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +1 -0
  28. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +1 -0
  29. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +1 -0
  30. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -0
  31. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +5 -0
  32. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +12 -10
  33. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +45 -0
  34. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -2
  35. package/dist/src/extensions/Blocks/common-control.d.ts +5 -4
  36. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
- var B = Object.defineProperty;
2
- var U = (r, t, e) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var M = (r, t, e) => U(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { productPairs as v } from "../../extensions/Blocks/Items/enums/productEnums.js";
5
- import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as d } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
6
- import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
1
+ var L = Object.defineProperty;
2
+ var K = (o, t, r) => t in o ? L(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
3
+ var R = (o, t, r) => K(o, typeof t != "symbol" ? t + "" : t, r);
4
+ import { productPairs as B } from "../../extensions/Blocks/Items/enums/productEnums.js";
5
+ import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
6
+ import { getDefaultTemplate as U } from "../../extensions/Blocks/Items/template.js";
7
7
  const w = {
8
8
  img: {
9
9
  pairsKey: "imageSrc",
@@ -74,118 +74,102 @@ const w = {
74
74
  function F() {
75
75
  return String(Date.now() + Math.floor(Math.random() * 1e3));
76
76
  }
77
- function q(r) {
78
- return r ? {
79
- CartItems: d.ITEMS_TYPE.CART_ITEMS,
80
- BrowsedItems: d.ITEMS_TYPE.BROWSED_ITEMS,
81
- PurchasedItems: d.ITEMS_TYPE.PURCHASED_ITEMS,
82
- CART_ITEMS: d.ITEMS_TYPE.CART_ITEMS,
83
- BROWSED_ITEMS: d.ITEMS_TYPE.BROWSED_ITEMS,
84
- PURCHASED_ITEMS: d.ITEMS_TYPE.PURCHASED_ITEMS
85
- }[r] || d.ITEMS_TYPE.CART_ITEMS : d.ITEMS_TYPE.CART_ITEMS;
77
+ function q(o) {
78
+ return o ? {
79
+ CartItems: _.ITEMS_TYPE.CART_ITEMS,
80
+ BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
81
+ PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
82
+ CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
83
+ BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
84
+ PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
85
+ }[o] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
86
86
  }
87
- function R(r) {
88
- const t = (a, o) => a == null ? o : a === "1" || a === "true", e = (a, o) => a || o, i = r["data-type"] || r["data-source"], l = q(i);
89
- let n = r["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
90
- if (n && !n.includes("{{") && /^\d+$/.test(n)) {
91
- const a = parseInt(n) - 1, o = E[l];
92
- o && o[a] && (n = o[a].value);
87
+ function M(o) {
88
+ const t = (e, a) => e == null ? a : e === "1" || e === "true", r = (e, a) => e || a, c = o["data-type"] || o["data-source"], n = q(c);
89
+ let i = o["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
90
+ if (i && !i.includes("{{") && /^\d+$/.test(i)) {
91
+ const e = parseInt(i) - 1, a = E[n];
92
+ a && a[e] && (i = a[e].value);
93
93
  }
94
94
  return {
95
95
  initialized: !0,
96
- blockInstanceId: e(r["data-block-instance-id"], F()),
97
- source: l,
98
- type: l,
99
- itemsSelectValue: n,
100
- orientation: r["data-card_orientation_control_value"] || d.ORIENTATION.VERTICAL,
101
- nameTrimming: t(r["data-product_name_control_trim"], !0),
102
- priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
103
- priceFormatted: t(r["data-product_price_control_formated"], !0),
104
- priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
105
- priceCurrencySymbol: e(
106
- r["data-product_price_control_currency_symbol"],
96
+ blockInstanceId: r(o["data-block-instance-id"], F()),
97
+ source: n,
98
+ type: n,
99
+ itemsSelectValue: i,
100
+ orientation: o["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
101
+ nameTrimming: t(o["data-product_name_control_trim"], !0),
102
+ priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
103
+ priceFormatted: t(o["data-product_price_control_formated"], !0),
104
+ priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
105
+ priceCurrencySymbol: r(
106
+ o["data-product_price_currency_symbol"],
107
107
  g.productPriceCurrencySymbolControlValue
108
108
  ),
109
- priceCurrencyLocation: e(
110
- r["data-product_price_currency_location"],
109
+ priceCurrencyLocation: r(
110
+ o["data-product_price_currency_location"],
111
111
  g.productPriceCurrencyLocationControlValue
112
112
  ),
113
- priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
114
- quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
115
- buttonLink: e(r["data-product_button_link"], g.productButtonLinkControlValue),
116
- imageLink: e(r["data-product_image_link"], g.productImageLinkControlValue),
117
- buttonLabel: e(r["data-product_button_control_label"], "Buy"),
118
- buttonFullWidth: t(r["data-product_button_control_atw"], !0),
119
- imageVisible: t(r["data-product_image_control_enabled"], !0),
120
- nameVisible: t(r["data-product_name_control_enabled"], !0),
121
- quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
122
- priceVisible: t(r["data-product_price_control_enabled"], !0),
123
- originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
124
- buttonVisible: t(r["data-product_button_control_enabled"], !0)
113
+ priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
114
+ quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
115
+ buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
116
+ imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
117
+ buttonLabel: r(o["data-product_button_control_label"], "Buy"),
118
+ buttonFullWidth: t(o["data-product_button_control_atw"], !0),
119
+ imageVisible: t(o["data-product_image_control_enabled"], !0),
120
+ nameVisible: t(o["data-product_name_control_enabled"], !0),
121
+ quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
122
+ priceVisible: t(o["data-product_price_control_enabled"], !0),
123
+ originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
124
+ buttonVisible: t(o["data-product_button_control_enabled"], !0)
125
125
  };
126
126
  }
127
- const $ = {
127
+ const x = {
128
128
  ins_apr: "CART_ITEMS",
129
129
  browsed_item: "BROWSED_ITEMS",
130
130
  purchased_item: "PURCHASED_ITEMS"
131
131
  };
132
- function x(r, t) {
133
- const e = {
134
- CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
135
- BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
136
- PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
137
- };
138
- return e[r] || e.CART_ITEMS;
139
- }
140
- function O(r, t) {
141
- const e = {
142
- CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
143
- BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
144
- PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
145
- };
146
- return e[r] || e.CART_ITEMS;
147
- }
148
- class V {
132
+ class N {
149
133
  constructor() {
150
- M(this, "parser");
134
+ R(this, "parser");
151
135
  this.parser = new DOMParser();
152
136
  }
153
137
  migrate(t) {
154
138
  try {
155
- let e = this.removeJinjaConditionals(t);
156
- e = this.replaceTemplateVariables(e);
157
- const i = this.parser.parseFromString(e, "text/html"), l = i.querySelectorAll(
139
+ let r = this.removeJinjaConditionals(t);
140
+ r = this.replaceTemplateVariables(r);
141
+ const c = this.parser.parseFromString(r, "text/html"), n = c.querySelectorAll(
158
142
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
159
143
  );
160
- return l.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (l.forEach((n) => {
161
- const a = this.extractConfiguration(n), o = K({
162
- orientation: a.orientation,
163
- itemsType: a.itemsType,
164
- itemId: a.itemId,
165
- currencySymbol: a.currencySymbol,
166
- currencyLocation: a.currencyLocation,
167
- formattedPrice: a.formattedPrice,
168
- configBlockAttributes: a.configBlockAttributes,
144
+ return n.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (n.forEach((i) => {
145
+ const e = this.extractConfiguration(i), a = U({
146
+ orientation: e.orientation,
147
+ itemsType: e.itemsType,
148
+ itemId: e.itemId,
149
+ currencySymbol: e.currencySymbol,
150
+ currencyLocation: e.currencyLocation,
151
+ formattedPrice: e.formattedPrice,
152
+ configBlockAttributes: e.configBlockAttributes,
169
153
  migrate: !0,
170
- nameStyles: a.nameStyles,
171
- buttonStyles: a.buttonStyles,
172
- priceStyles: a.priceStyles,
173
- originalPriceStyles: a.originalPriceStyles,
174
- quantityStyles: a.quantityStyles,
175
- nodeConfig: R(a.configBlockAttributes)
176
- }), c = this.parser.parseFromString(
177
- `<table><tbody><tr>${o}</tr></tbody></table>`,
154
+ nameStyles: e.nameStyles,
155
+ buttonStyles: e.buttonStyles,
156
+ priceStyles: e.priceStyles,
157
+ originalPriceStyles: e.originalPriceStyles,
158
+ quantityStyles: e.quantityStyles,
159
+ nodeConfig: M(e.configBlockAttributes)
160
+ }), l = this.parser.parseFromString(
161
+ `<table><tbody><tr>${a}</tr></tbody></table>`,
178
162
  "text/html"
179
163
  ).querySelector("td");
180
- if (c && n.parentNode) {
181
- const f = R(a.configBlockAttributes);
182
- c.setAttribute("esd-ext-config", JSON.stringify(f));
183
- const u = c.querySelector("esd-config-block");
184
- u && u.remove(), n.parentNode.replaceChild(c, n);
164
+ if (l && i.parentNode) {
165
+ const f = M(e.configBlockAttributes);
166
+ l.setAttribute("esd-ext-config", JSON.stringify(f));
167
+ const u = l.querySelector("esd-config-block");
168
+ u && u.remove(), i.parentNode.replaceChild(l, i);
185
169
  }
186
- }), i.documentElement.outerHTML);
187
- } catch (e) {
188
- return console.error("ItemsBlockMigrator failed:", e), t;
170
+ }), c.documentElement.outerHTML);
171
+ } catch (r) {
172
+ return console.error("ItemsBlockMigrator failed:", r), t;
189
173
  }
190
174
  }
191
175
  /**
@@ -196,23 +180,23 @@ class V {
196
180
  */
197
181
  extractConfiguration(t) {
198
182
  var C, D, P;
199
- const e = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", i = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", l = parseInt(i) - 1, n = E[e], a = ((P = n == null ? void 0 : n[l]) == null ? void 0 : P.value) || n[0].value, o = t.querySelector('[product-attr="price"]'), _ = (o == null ? void 0 : o.getAttribute("data-currency_symbol")) || "USD", f = ((o == null ? void 0 : o.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", u = (o == null ? void 0 : o.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, e, i), b = s["data-card_orientation_control_value"];
183
+ const r = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", n = parseInt(c) - 1, i = E[r], e = ((P = i == null ? void 0 : i[n]) == null ? void 0 : P.value) || i[0].value, a = t.querySelector('[product-attr="price"]'), d = (a == null ? void 0 : a.getAttribute("data-currency_symbol")) || "USD", f = ((a == null ? void 0 : a.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", u = (a == null ? void 0 : a.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, r), b = s["data-card_orientation_control_value"];
200
184
  let S;
201
185
  b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
202
- const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, k = (o == null ? void 0 : o.getAttribute("style")) || void 0, I = t.querySelector("p.original-price"), h = (I == null ? void 0 : I.getAttribute("style")) || void 0, A = t.querySelector('[product-attr="quantity"]'), L = (A == null ? void 0 : A.getAttribute("style")) || void 0;
186
+ const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, h = (a == null ? void 0 : a.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), k = (A == null ? void 0 : A.getAttribute("style")) || void 0, I = t.querySelector('[product-attr="quantity"]'), v = (I == null ? void 0 : I.getAttribute("style")) || void 0;
203
187
  return {
204
188
  orientation: S,
205
- itemsType: e,
206
- itemId: a,
207
- currencySymbol: _,
189
+ itemsType: r,
190
+ itemId: e,
191
+ currencySymbol: d,
208
192
  currencyLocation: f,
209
193
  formattedPrice: u,
210
194
  configBlockAttributes: s,
211
195
  nameStyles: T,
212
196
  buttonStyles: m,
213
- priceStyles: k,
214
- originalPriceStyles: h,
215
- quantityStyles: L
197
+ priceStyles: h,
198
+ originalPriceStyles: k,
199
+ quantityStyles: v
216
200
  };
217
201
  }
218
202
  /**
@@ -220,29 +204,28 @@ class V {
220
204
  * Returns a key-value mapping of all configuration attributes
221
205
  * @param block - The block element containing the esd-config-block
222
206
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
223
- * @param itemNumber - The item number (1-based index)
224
207
  */
225
- extractConfigBlockAttributes(t, e, i) {
226
- const l = t.querySelector("esd-config-block"), n = {};
227
- if (!l)
208
+ extractConfigBlockAttributes(t, r) {
209
+ const c = t.querySelector("esd-config-block"), n = {};
210
+ if (!c)
228
211
  return this.getDefaultConfigBlockAttributes();
229
- if (Array.from(l.attributes).forEach((o) => {
230
- o.name.startsWith("data-") && (n[o.name] = o.value);
212
+ if (Array.from(c.attributes).forEach((e) => {
213
+ e.name.startsWith("data-") && (n[e.name] = e.value);
231
214
  }), n["data-cart_items_select_control_value"]) {
232
- const o = n["data-cart_items_select_control_value"];
233
- if (/^\d+$/.test(o)) {
234
- const _ = parseInt(o) - 1, c = E[e];
235
- c && c[_] && (n["data-cart_items_select_control_value"] = c[_].value);
215
+ const e = n["data-cart_items_select_control_value"];
216
+ if (/^\d+$/.test(e)) {
217
+ const a = parseInt(e) - 1, d = E[r];
218
+ d && d[a] && (n["data-cart_items_select_control_value"] = d[a].value);
236
219
  }
237
220
  }
238
221
  if (n["data-product_price_control_curency"]) {
239
- const o = n["data-product_price_control_curency"];
240
- let _ = o;
241
- o === "before" ? _ = "0" : o === "after" && (_ = "1"), n["data-product_price_control_curency"] = _, n["data-product_price_currency_location"] = _;
222
+ const e = n["data-product_price_control_curency"];
223
+ let a = e;
224
+ e === "before" ? a = "0" : e === "after" && (a = "1"), n["data-product_price_control_curency"] = a, n["data-product_price_currency_location"] = a;
242
225
  }
243
- (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
244
- const a = { ...this.getDefaultConfigBlockAttributes(), ...n };
245
- return a["data-type"] = e, a["data-source"] = e, a["data-product_image_link"] = x(e, i), a["data-product_button_link"] = O(e, i), a;
226
+ (!n["data-product_price_currency_symbol"] || n["data-product_price_currency_symbol"].trim() === "") && (n["data-product_price_currency_symbol"] = "USD");
227
+ const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
228
+ return i["data-type"] = r, i["data-source"] = r, i;
246
229
  }
247
230
  /**
248
231
  * Returns default esd-config-block attributes based on the old template structure
@@ -271,7 +254,7 @@ class V {
271
254
  "data-product_price_control_color": "#060606",
272
255
  "data-product_price_control_curency": "0",
273
256
  "data-product_price_currency_location": "0",
274
- "data-product_price_control_currency_symbol": "USD",
257
+ "data-product_price_currency_symbol": "USD",
275
258
  "data-product_price_control_formated": "1",
276
259
  "data-product_price_control_nodup": "1",
277
260
  "data-product_price_control_single_price": "false",
@@ -299,16 +282,16 @@ class V {
299
282
  * - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
300
283
  */
301
284
  removeJinjaConditionals(t) {
302
- let e = t.replace(
285
+ let r = t.replace(
303
286
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
304
287
  ""
305
288
  );
306
- return e = e.replace(
289
+ return r = r.replace(
307
290
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
308
291
  ""
309
- ), e = e.replace(/\{%\s*endif\s*%\}/g, ""), e = e.replace(/\n\s*\n\s*\n/g, `
292
+ ), r = r.replace(/\{%\s*endif\s*%\}/g, ""), r = r.replace(/\n\s*\n\s*\n/g, `
310
293
 
311
- `), e;
294
+ `), r;
312
295
  }
313
296
  /**
314
297
  * Replaces template variables with default values from productPairs
@@ -320,32 +303,32 @@ class V {
320
303
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
321
304
  */
322
305
  replaceTemplateVariables(t) {
323
- const { PAIRS_FOR_EXTENSION: e } = v;
324
- return t.replace(/{{([^}]+)}}/g, (i, l) => {
325
- const n = l.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
326
- if (!n)
327
- return i;
328
- const [, a, o, _] = n, c = $[a];
329
- if (!c)
330
- return console.warn(`Unknown variable prefix: ${a}`), i;
331
- const f = w[o];
306
+ const { PAIRS_FOR_EXTENSION: r } = B;
307
+ return t.replace(/{{([^}]+)}}/g, (c, n) => {
308
+ const i = n.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
309
+ if (!i)
310
+ return c;
311
+ const [, e, a, d] = i, l = x[e];
312
+ if (!l)
313
+ return console.warn(`Unknown variable prefix: ${e}`), c;
314
+ const f = w[a];
332
315
  if (!f)
333
- return console.warn(`Unknown variable suffix mapping for: ${o}`), i;
334
- const { pairsKey: u, defaultKey: s, isArray: b } = f, p = e[u][c];
316
+ return console.warn(`Unknown variable suffix mapping for: ${a}`), c;
317
+ const { pairsKey: u, defaultKey: s, isArray: b } = f, p = r[u][l];
335
318
  if (!p)
336
- return console.warn(`No data found for: ${u}.${c}`), i;
319
+ return console.warn(`No data found for: ${u}.${l}`), c;
337
320
  if (b) {
338
- const y = parseInt(_) - 1, m = p[s];
339
- return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${c}.${s}[${y}]`), i);
321
+ const y = parseInt(d) - 1, m = p[s];
322
+ return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${l}.${s}[${y}]`), c);
340
323
  }
341
324
  const T = p[s];
342
- return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${c}.${s}`), i);
325
+ return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${l}.${s}`), c);
343
326
  });
344
327
  }
345
328
  }
346
- function G(r) {
347
- return new V().migrate(r);
329
+ function Y(o) {
330
+ return new N().migrate(o);
348
331
  }
349
332
  export {
350
- G as migrateItemsBlock
333
+ Y as migrateItemsBlock
351
334
  };
@@ -1,10 +1,11 @@
1
- import { useOnboardingStore as d } from "../../../stores/onboarding.js";
2
- import { Block as g, BlockCompositionType as f, ModificationDescription as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
- import { SETTINGS_ENUMS as c, DefaultConfigValues as i } from "./enums/settingsEnums.js";
4
- import { getDefaultTemplate as p } from "./template.js";
5
- import { getItemsBlockContainer as u, getItemsBlockConfig as C, getDefaultItemsBlockConfig as I } from "./utils/nodeConfigUtils.js";
1
+ import { useOnboardingStore as m } from "../../../stores/onboarding.js";
2
+ import { Block as u, BlockCompositionType as d, ModificationDescription as i } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { SETTINGS_ENUMS as c, DefaultConfigValues as o } from "./enums/settingsEnums.js";
4
+ import { useItemsBlockStore as p } from "./store/items-block.js";
5
+ import { getDefaultTemplate as f } from "./template.js";
6
+ import { getItemsBlockContainer as g, getItemsBlockConfig as a, getDefaultItemsBlockConfig as C } from "./utils/nodeConfigUtils.js";
6
7
  const y = "items-block";
7
- class B extends g {
8
+ class B extends u {
8
9
  getId() {
9
10
  return y;
10
11
  }
@@ -12,7 +13,7 @@ class B extends g {
12
13
  return "items-icon";
13
14
  }
14
15
  getBlockCompositionType() {
15
- return f.CONTAINER;
16
+ return d.CONTAINER;
16
17
  }
17
18
  getName() {
18
19
  return this.api.translate("Items");
@@ -21,32 +22,40 @@ class B extends g {
21
22
  return this.api.translate("Items lets you display personalized products based on user behavior.");
22
23
  }
23
24
  getTemplate() {
24
- return p({
25
+ return f({
25
26
  orientation: c.ORIENTATION.VERTICAL,
26
27
  itemsType: c.ITEMS_TYPE.CART_ITEMS,
27
28
  itemId: "{{Abandoned Cart Item (1) Url}}",
28
- currencySymbol: i.productPriceCurrencySymbolControlValue,
29
- currencyLocation: i.productPriceCurrencyLocationControlValue,
30
- formattedPrice: i.productPriceFormattedControlValue === "1"
29
+ currencySymbol: o.productPriceCurrencySymbolControlValue,
30
+ currencyLocation: o.productPriceCurrencyLocationControlValue,
31
+ formattedPrice: o.productPriceFormattedControlValue === "1"
31
32
  });
32
33
  }
33
34
  allowInnerBlocksDND() {
34
35
  return !1;
35
36
  }
36
37
  onCreated(n) {
37
- const s = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
38
- r.querySelector('[product-attr="imageSrc"] img') || s.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
39
- const e = u(n);
38
+ const e = g(n);
40
39
  if (!e)
41
40
  return;
42
- const a = e.getNodeConfig(), l = a && Object.keys(a).length > 0, t = C(n);
43
- if (t != null && t.initialized)
44
- l ? t.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...t, blockInstanceId: String(Date.now()) }).apply(new o("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(t).apply(new o("Migrate legacy config to nodeConfig"));
41
+ const t = e.getNodeConfig(), l = t && Object.keys(t).length > 0, r = a(n);
42
+ if (r != null && r.initialized)
43
+ l ? r.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...r, blockInstanceId: String(Date.now()) }).apply(new i("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(r).apply(new i("Migrate legacy config to nodeConfig"));
45
44
  else {
46
- const m = I();
47
- this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(m).apply(new o("Initialize Items block with default configuration")), d().startOnboarding("itemsOnboarding");
45
+ const s = C();
46
+ this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(s).apply(new i("Initialize Items block with default configuration")), m().startOnboarding("itemsOnboarding");
48
47
  }
49
48
  }
49
+ onSelect(n) {
50
+ const e = p(), t = a(n);
51
+ t && (e.setItemsType(t.type || o.itemsType), e.setItemIds(t.itemsSelectValue || o.cartItemsSelectControlValue), e.setOrientation(t.orientation || o.cardOrientationControlValue), e.setCurrencySymbol(
52
+ t.priceCurrencySymbol || o.productPriceCurrencySymbolControlValue
53
+ ), e.setCurrencyLocation(
54
+ t.priceCurrencyLocation || o.productPriceCurrencyLocationControlValue
55
+ ), e.setFormattedPrice(
56
+ t.priceFormatted ?? o.productPriceFormattedControlValue === "1"
57
+ ));
58
+ }
50
59
  }
51
60
  export {
52
61
  y as BLOCK_ID,
@@ -1,40 +1,52 @@
1
- import { CommonControl as r } from "../../../common-control.js";
2
- import { ItemsBlockControlId as i } from "../../enums/controlEnums.js";
3
- import { getItemsBlockConfig as o } from "../../utils/nodeConfigUtils.js";
4
- const s = i.BUTTON_LINK, n = {
1
+ var a = Object.defineProperty;
2
+ var l = (e, t, n) => t in e ? a(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var i = (e, t, n) => l(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { CommonControl as u } from "../../../common-control.js";
5
+ import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
6
+ import { useItemsBlockStore as m } from "../../store/items-block.js";
7
+ import { getItemsBlockConfig as L } from "../../utils/nodeConfigUtils.js";
8
+ const r = d.BUTTON_LINK, s = {
5
9
  LINK: "link"
6
10
  };
7
- class m extends r {
11
+ class N extends u {
12
+ constructor() {
13
+ super(...arguments);
14
+ i(this, "store", m());
15
+ }
8
16
  getId() {
9
- return s;
17
+ return r;
10
18
  }
11
19
  getTemplate() {
12
20
  return `
13
- <div class="container ${s}">
21
+ <div class="container ${r}">
14
22
  ${this._getLink()}
15
23
  </div>
16
24
  `;
17
25
  }
18
26
  onRender() {
19
- const t = o(this.currentNode);
20
27
  this.api.updateValues({
21
- [n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
28
+ [s.LINK]: this.store.buttonLink
22
29
  });
23
30
  }
24
- onTemplateNodeUpdated(t) {
25
- super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
26
- const e = o(this.currentNode);
27
- this.api.updateValues({
28
- [n.LINK]: (e == null ? void 0 : e.buttonLink) ?? ""
29
- });
30
- });
31
+ onTemplateNodeUpdated(n) {
32
+ super.onTemplateNodeUpdated(n), this.handleBlockInstanceChange(
33
+ () => {
34
+ const o = L(this.currentNode);
35
+ o != null && o.buttonLink && this.store.setButtonLink(o.buttonLink);
36
+ },
37
+ () => {
38
+ this.api.updateValues({
39
+ [s.LINK]: this.store.buttonLink
40
+ });
41
+ }
42
+ );
31
43
  }
32
44
  _getLink() {
33
45
  return `
34
46
  ${this._GuOneColumn([
35
47
  this._GuLabel({ text: "Link" }),
36
48
  this._GuTextInput({
37
- name: n.LINK,
49
+ name: s.LINK,
38
50
  placeholder: "Enter Link",
39
51
  className: "es-100",
40
52
  disabled: !0
@@ -44,6 +56,6 @@ class m extends r {
44
56
  }
45
57
  }
46
58
  export {
47
- m as ButtonLinkControl,
48
- s as CONTROL_BLOCK_ID
59
+ N as ButtonLinkControl,
60
+ r as CONTROL_BLOCK_ID
49
61
  };