@useinsider/guido 2.1.0-beta.bc18abc → 2.1.0-beta.e2d48fe

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 +140 -123
  2. package/dist/extensions/Blocks/Items/block.js +19 -28
  3. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  4. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  5. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  6. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  7. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -46
  8. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +45 -50
  9. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +40 -51
  10. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -35
  11. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  12. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -62
  13. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  14. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  15. package/dist/extensions/Blocks/Items/extension.js +8 -9
  16. package/dist/extensions/Blocks/Items/template.js +181 -175
  17. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  18. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
  19. package/dist/extensions/Blocks/common-control.js +91 -92
  20. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  21. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  22. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  23. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  24. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  25. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  26. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  27. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  28. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  29. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  30. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  31. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  32. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  33. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  34. package/package.json +1 -1
  35. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  36. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
@@ -1,9 +1,9 @@
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";
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";
7
7
  const w = {
8
8
  img: {
9
9
  pairsKey: "imageSrc",
@@ -74,102 +74,118 @@ const w = {
74
74
  function F() {
75
75
  return String(Date.now() + Math.floor(Math.random() * 1e3));
76
76
  }
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;
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;
86
86
  }
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);
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);
93
93
  }
94
94
  return {
95
95
  initialized: !0,
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"],
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"],
107
107
  g.productPriceCurrencySymbolControlValue
108
108
  ),
109
- priceCurrencyLocation: r(
110
- o["data-product_price_currency_location"],
109
+ priceCurrencyLocation: e(
110
+ r["data-product_price_currency_location"],
111
111
  g.productPriceCurrencyLocationControlValue
112
112
  ),
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)
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)
125
125
  };
126
126
  }
127
- const x = {
127
+ const $ = {
128
128
  ins_apr: "CART_ITEMS",
129
129
  browsed_item: "BROWSED_ITEMS",
130
130
  purchased_item: "PURCHASED_ITEMS"
131
131
  };
132
- class N {
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 {
133
149
  constructor() {
134
- R(this, "parser");
150
+ M(this, "parser");
135
151
  this.parser = new DOMParser();
136
152
  }
137
153
  migrate(t) {
138
154
  try {
139
- let r = this.removeJinjaConditionals(t);
140
- r = this.replaceTemplateVariables(r);
141
- const c = this.parser.parseFromString(r, "text/html"), n = c.querySelectorAll(
155
+ let e = this.removeJinjaConditionals(t);
156
+ e = this.replaceTemplateVariables(e);
157
+ const i = this.parser.parseFromString(e, "text/html"), l = i.querySelectorAll(
142
158
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
143
159
  );
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,
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,
153
169
  migrate: !0,
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>`,
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>`,
162
178
  "text/html"
163
179
  ).querySelector("td");
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);
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);
169
185
  }
170
- }), c.documentElement.outerHTML);
171
- } catch (r) {
172
- return console.error("ItemsBlockMigrator failed:", r), t;
186
+ }), i.documentElement.outerHTML);
187
+ } catch (e) {
188
+ return console.error("ItemsBlockMigrator failed:", e), t;
173
189
  }
174
190
  }
175
191
  /**
@@ -180,23 +196,23 @@ class N {
180
196
  */
181
197
  extractConfiguration(t) {
182
198
  var C, D, P;
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"];
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"];
184
200
  let S;
185
201
  b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
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;
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;
187
203
  return {
188
204
  orientation: S,
189
- itemsType: r,
190
- itemId: e,
191
- currencySymbol: d,
205
+ itemsType: e,
206
+ itemId: a,
207
+ currencySymbol: _,
192
208
  currencyLocation: f,
193
209
  formattedPrice: u,
194
210
  configBlockAttributes: s,
195
211
  nameStyles: T,
196
212
  buttonStyles: m,
197
- priceStyles: h,
198
- originalPriceStyles: k,
199
- quantityStyles: v
213
+ priceStyles: k,
214
+ originalPriceStyles: h,
215
+ quantityStyles: L
200
216
  };
201
217
  }
202
218
  /**
@@ -204,28 +220,29 @@ class N {
204
220
  * Returns a key-value mapping of all configuration attributes
205
221
  * @param block - The block element containing the esd-config-block
206
222
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
223
+ * @param itemNumber - The item number (1-based index)
207
224
  */
208
- extractConfigBlockAttributes(t, r) {
209
- const c = t.querySelector("esd-config-block"), n = {};
210
- if (!c)
225
+ extractConfigBlockAttributes(t, e, i) {
226
+ const l = t.querySelector("esd-config-block"), n = {};
227
+ if (!l)
211
228
  return this.getDefaultConfigBlockAttributes();
212
- if (Array.from(c.attributes).forEach((e) => {
213
- e.name.startsWith("data-") && (n[e.name] = e.value);
229
+ if (Array.from(l.attributes).forEach((o) => {
230
+ o.name.startsWith("data-") && (n[o.name] = o.value);
214
231
  }), n["data-cart_items_select_control_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);
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);
219
236
  }
220
237
  }
221
238
  if (n["data-product_price_control_curency"]) {
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;
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"] = _;
225
242
  }
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;
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;
229
246
  }
230
247
  /**
231
248
  * Returns default esd-config-block attributes based on the old template structure
@@ -254,7 +271,7 @@ class N {
254
271
  "data-product_price_control_color": "#060606",
255
272
  "data-product_price_control_curency": "0",
256
273
  "data-product_price_currency_location": "0",
257
- "data-product_price_currency_symbol": "USD",
274
+ "data-product_price_control_currency_symbol": "USD",
258
275
  "data-product_price_control_formated": "1",
259
276
  "data-product_price_control_nodup": "1",
260
277
  "data-product_price_control_single_price": "false",
@@ -282,16 +299,16 @@ class N {
282
299
  * - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
283
300
  */
284
301
  removeJinjaConditionals(t) {
285
- let r = t.replace(
302
+ let e = t.replace(
286
303
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
287
304
  ""
288
305
  );
289
- return r = r.replace(
306
+ return e = e.replace(
290
307
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
291
308
  ""
292
- ), r = r.replace(/\{%\s*endif\s*%\}/g, ""), r = r.replace(/\n\s*\n\s*\n/g, `
309
+ ), e = e.replace(/\{%\s*endif\s*%\}/g, ""), e = e.replace(/\n\s*\n\s*\n/g, `
293
310
 
294
- `), r;
311
+ `), e;
295
312
  }
296
313
  /**
297
314
  * Replaces template variables with default values from productPairs
@@ -303,32 +320,32 @@ class N {
303
320
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
304
321
  */
305
322
  replaceTemplateVariables(t) {
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];
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];
315
332
  if (!f)
316
- return console.warn(`Unknown variable suffix mapping for: ${a}`), c;
317
- const { pairsKey: u, defaultKey: s, isArray: b } = f, p = r[u][l];
333
+ return console.warn(`Unknown variable suffix mapping for: ${o}`), i;
334
+ const { pairsKey: u, defaultKey: s, isArray: b } = f, p = e[u][c];
318
335
  if (!p)
319
- return console.warn(`No data found for: ${u}.${l}`), c;
336
+ return console.warn(`No data found for: ${u}.${c}`), i;
320
337
  if (b) {
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);
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);
323
340
  }
324
341
  const T = p[s];
325
- return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${l}.${s}`), c);
342
+ return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${c}.${s}`), i);
326
343
  });
327
344
  }
328
345
  }
329
- function Y(o) {
330
- return new N().migrate(o);
346
+ function G(r) {
347
+ return new V().migrate(r);
331
348
  }
332
349
  export {
333
- Y as migrateItemsBlock
350
+ G as migrateItemsBlock
334
351
  };
@@ -1,11 +1,10 @@
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";
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";
7
6
  const y = "items-block";
8
- class B extends u {
7
+ class B extends g {
9
8
  getId() {
10
9
  return y;
11
10
  }
@@ -13,7 +12,7 @@ class B extends u {
13
12
  return "items-icon";
14
13
  }
15
14
  getBlockCompositionType() {
16
- return d.CONTAINER;
15
+ return f.CONTAINER;
17
16
  }
18
17
  getName() {
19
18
  return this.api.translate("Items");
@@ -22,40 +21,32 @@ class B extends u {
22
21
  return this.api.translate("Items lets you display personalized products based on user behavior.");
23
22
  }
24
23
  getTemplate() {
25
- return f({
24
+ return p({
26
25
  orientation: c.ORIENTATION.VERTICAL,
27
26
  itemsType: c.ITEMS_TYPE.CART_ITEMS,
28
27
  itemId: "{{Abandoned Cart Item (1) Url}}",
29
- currencySymbol: o.productPriceCurrencySymbolControlValue,
30
- currencyLocation: o.productPriceCurrencyLocationControlValue,
31
- formattedPrice: o.productPriceFormattedControlValue === "1"
28
+ currencySymbol: i.productPriceCurrencySymbolControlValue,
29
+ currencyLocation: i.productPriceCurrencyLocationControlValue,
30
+ formattedPrice: i.productPriceFormattedControlValue === "1"
32
31
  });
33
32
  }
34
33
  allowInnerBlocksDND() {
35
34
  return !1;
36
35
  }
37
36
  onCreated(n) {
38
- const e = g(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);
39
40
  if (!e)
40
41
  return;
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"));
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"));
44
45
  else {
45
- const s = C();
46
- this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(s).apply(new i("Initialize Items block with default configuration")), m().startOnboarding("itemsOnboarding");
46
+ const m = I();
47
+ this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(m).apply(new o("Initialize Items block with default configuration")), d().startOnboarding("itemsOnboarding");
47
48
  }
48
49
  }
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
- }
59
50
  }
60
51
  export {
61
52
  y as BLOCK_ID,
@@ -1,52 +1,40 @@
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 = {
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 = {
9
5
  LINK: "link"
10
6
  };
11
- class N extends u {
12
- constructor() {
13
- super(...arguments);
14
- i(this, "store", m());
15
- }
7
+ class m extends r {
16
8
  getId() {
17
- return r;
9
+ return s;
18
10
  }
19
11
  getTemplate() {
20
12
  return `
21
- <div class="container ${r}">
13
+ <div class="container ${s}">
22
14
  ${this._getLink()}
23
15
  </div>
24
16
  `;
25
17
  }
26
18
  onRender() {
19
+ const t = o(this.currentNode);
27
20
  this.api.updateValues({
28
- [s.LINK]: this.store.buttonLink
21
+ [n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
29
22
  });
30
23
  }
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
- );
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
+ });
43
31
  }
44
32
  _getLink() {
45
33
  return `
46
34
  ${this._GuOneColumn([
47
35
  this._GuLabel({ text: "Link" }),
48
36
  this._GuTextInput({
49
- name: s.LINK,
37
+ name: n.LINK,
50
38
  placeholder: "Enter Link",
51
39
  className: "es-100",
52
40
  disabled: !0
@@ -56,6 +44,6 @@ class N extends u {
56
44
  }
57
45
  }
58
46
  export {
59
- N as ButtonLinkControl,
60
- r as CONTROL_BLOCK_ID
47
+ m as ButtonLinkControl,
48
+ s as CONTROL_BLOCK_ID
61
49
  };