@useinsider/guido 3.14.0 → 3.15.0

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.
@@ -88,11 +88,11 @@ function k(o) {
88
88
  }
89
89
  function h(o) {
90
90
  var e;
91
- const t = (c, u) => c == null ? u : c === "1" || c === "true", r = (c, u) => c || u, l = o["data-type"] || o["data-source"], a = k(l), i = I[a];
91
+ const t = (l, u) => l == null ? u : l === "1" || l === "true", r = (l, u) => l || u, c = o["data-type"] || o["data-source"], a = k(c), i = I[a];
92
92
  let n = o["data-cart_items_select_control_value"] || ((e = i == null ? void 0 : i[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
93
93
  if (n && !n.includes("{{") && /^\d+$/.test(n)) {
94
- const c = parseInt(n) - 1, u = I[a];
95
- u && u[c] && (n = u[c].value);
94
+ const l = parseInt(n) - 1, u = I[a];
95
+ u && u[l] && (n = u[l].value);
96
96
  }
97
97
  return {
98
98
  initialized: !0,
@@ -148,7 +148,7 @@ function N(o, t) {
148
148
  };
149
149
  return r[o] || r.CART_ITEMS;
150
150
  }
151
- class z {
151
+ class H {
152
152
  constructor() {
153
153
  M(this, "parser");
154
154
  this.parser = new DOMParser();
@@ -159,13 +159,13 @@ class z {
159
159
  return this.backfillV2ProductTdAttributes(t);
160
160
  let r = this.removeJinjaConditionals(t);
161
161
  r = this.replaceTemplateVariables(r);
162
- const l = this.parser.parseFromString(r, "text/html"), a = l.querySelectorAll(
162
+ const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
163
163
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
164
164
  );
165
165
  return q().$patch((n) => {
166
166
  n.migrations = { ...n.migrations, [w]: a.length };
167
167
  }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
168
- const e = this.extractConfiguration(n), c = F({
168
+ const e = this.extractConfiguration(n), l = F({
169
169
  orientation: e.orientation,
170
170
  itemsType: e.itemsType,
171
171
  itemId: e.itemId,
@@ -181,7 +181,7 @@ class z {
181
181
  quantityStyles: e.quantityStyles,
182
182
  nodeConfig: h(e.configBlockAttributes)
183
183
  }), s = this.parser.parseFromString(
184
- `<table><tbody><tr>${c}</tr></tbody></table>`,
184
+ `<table><tbody><tr>${l}</tr></tbody></table>`,
185
185
  "text/html"
186
186
  ).querySelector("td");
187
187
  if (s && n.parentNode) {
@@ -190,7 +190,7 @@ class z {
190
190
  const d = s.querySelector("esd-config-block");
191
191
  d && d.remove(), n.parentNode.replaceChild(s, n);
192
192
  }
193
- }), l.documentElement.outerHTML);
193
+ }), c.documentElement.outerHTML);
194
194
  } catch (r) {
195
195
  return console.error("ItemsBlockMigrator failed:", r), t;
196
196
  }
@@ -205,15 +205,15 @@ class z {
205
205
  var C, D, P;
206
206
  const r = k(
207
207
  ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
208
- ), l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, l), b = d["data-card_orientation_control_value"];
208
+ ), c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(c) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), l = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, c), b = d["data-card_orientation_control_value"];
209
209
  let S;
210
210
  b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
211
- const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, T = t.querySelector("p.original-price"), L = (T == null ? void 0 : T.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), B = (E == null ? void 0 : E.getAttribute("style")) || void 0;
211
+ const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
212
212
  return {
213
213
  orientation: S,
214
214
  itemsType: r,
215
215
  itemId: n,
216
- currencySymbol: c,
216
+ currencySymbol: l,
217
217
  currencyLocation: s,
218
218
  formattedPrice: _,
219
219
  configBlockAttributes: d,
@@ -231,7 +231,7 @@ class z {
231
231
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
232
232
  * @param itemNumber - The item number (1-based index)
233
233
  */
234
- extractConfigBlockAttributes(t, r, l) {
234
+ extractConfigBlockAttributes(t, r, c) {
235
235
  const a = t.querySelector("esd-config-block"), i = {};
236
236
  if (!a)
237
237
  return this.getDefaultConfigBlockAttributes();
@@ -240,18 +240,18 @@ class z {
240
240
  }), i["data-cart_items_select_control_value"]) {
241
241
  const e = i["data-cart_items_select_control_value"];
242
242
  if (/^\d+$/.test(e)) {
243
- const c = parseInt(e) - 1, u = I[r];
244
- u && u[c] && (i["data-cart_items_select_control_value"] = u[c].value);
243
+ const l = parseInt(e) - 1, u = I[r];
244
+ u && u[l] && (i["data-cart_items_select_control_value"] = u[l].value);
245
245
  }
246
246
  }
247
247
  if (i["data-product_price_control_curency"]) {
248
248
  const e = i["data-product_price_control_curency"];
249
- let c = e;
250
- e === "before" ? c = "0" : e === "after" && (c = "1"), i["data-product_price_control_curency"] = c, i["data-product_price_currency_location"] = c;
249
+ let l = e;
250
+ e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
251
251
  }
252
252
  (!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
253
253
  const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
254
- return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, l), n["data-product_button_link"] = N(r, l), n;
254
+ return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, c), n["data-product_button_link"] = N(r, c), n;
255
255
  }
256
256
  /**
257
257
  * Returns default esd-config-block attributes based on the old template structure
@@ -301,7 +301,7 @@ class z {
301
301
  };
302
302
  }
303
303
  /**
304
- * Backfills data-type (and data-number) onto v2 `.ins-product-td` elements
304
+ * Backfills data-type (and data-number, data-nodup) onto v2 `.ins-product-td` elements
305
305
  * from their persisted `esd-ext-config` nodeConfig, and strips the legacy
306
306
  * static `width` that older builds baked onto the product-td.
307
307
  *
@@ -326,22 +326,24 @@ class z {
326
326
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
327
327
  return t;
328
328
  const r = this.parser.parseFromString(t, "text/html");
329
- let l = !1;
329
+ let c = !1;
330
330
  return r.querySelectorAll(".ins-product-td").forEach((a) => {
331
- if (a.hasAttribute("width") && (a.removeAttribute("width"), l = !0), a.getAttribute("data-type"))
332
- return;
331
+ a.hasAttribute("width") && (a.removeAttribute("width"), c = !0);
333
332
  const i = a.getAttribute("esd-ext-config");
334
- if (i)
335
- try {
336
- const n = JSON.parse(i), e = n.type || n.source;
337
- if (!e)
338
- return;
339
- a.setAttribute("data-type", e), l = !0;
340
- const c = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
341
- c && a.getAttribute("data-number") !== c[1] && a.setAttribute("data-number", c[1]);
342
- } catch {
343
- }
344
- }), l ? r.documentElement.outerHTML : t;
333
+ let n = null;
334
+ try {
335
+ n = i ? JSON.parse(i) : null;
336
+ } catch {
337
+ }
338
+ if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
339
+ return;
340
+ const e = n.type || n.source;
341
+ if (!e)
342
+ return;
343
+ a.setAttribute("data-type", e), c = !0;
344
+ const l = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
345
+ l && a.getAttribute("data-number") !== l[1] && a.setAttribute("data-number", l[1]);
346
+ }), c ? r.documentElement.outerHTML : t;
345
347
  }
346
348
  /**
347
349
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -362,15 +364,15 @@ class z {
362
364
  * contains display condition Jinja scripts that should NOT be removed.
363
365
  */
364
366
  removeJinjaConditionals(t) {
365
- const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
366
- let a = l ? t.replace(l[0], r) : t;
367
+ const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
368
+ let a = c ? t.replace(c[0], r) : t;
367
369
  return a = a.replace(
368
370
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
369
371
  ""
370
372
  ), a = a.replace(
371
373
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
372
374
  ""
373
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(r, l[0])), a = a.replace(/\n\s*\n\s*\n/g, `
375
+ ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
374
376
 
375
377
  `), a;
376
378
  }
@@ -385,30 +387,30 @@ class z {
385
387
  */
386
388
  replaceTemplateVariables(t) {
387
389
  const { PAIRS_FOR_EXTENSION: r } = K;
388
- return t.replace(/{{([^}]+)}}/g, (l, a) => {
390
+ return t.replace(/{{([^}]+)}}/g, (c, a) => {
389
391
  const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
390
392
  if (!i)
391
- return l;
392
- const [, n, e, c] = i, u = V[n];
393
+ return c;
394
+ const [, n, e, l] = i, u = V[n];
393
395
  if (!u)
394
- return console.warn(`Unknown variable prefix: ${n}`), l;
396
+ return console.warn(`Unknown variable prefix: ${n}`), c;
395
397
  const s = x[e];
396
398
  if (!s)
397
- return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
399
+ return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
398
400
  const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
399
401
  if (!y)
400
- return console.warn(`No data found for: ${_}.${u}`), l;
402
+ return console.warn(`No data found for: ${_}.${u}`), c;
401
403
  if (b) {
402
- const f = parseInt(c) - 1, m = y[d];
403
- return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), l);
404
+ const f = parseInt(l) - 1, m = y[d];
405
+ return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
404
406
  }
405
407
  const A = y[d];
406
- return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), l);
408
+ return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
407
409
  });
408
410
  }
409
411
  }
410
412
  function Q(o) {
411
- return new z().migrate(o);
413
+ return new H().migrate(o);
412
414
  }
413
415
  export {
414
416
  Q as migrateItemsBlock
@@ -0,0 +1,27 @@
1
+ var n = Object.defineProperty;
2
+ var a = (e, r, t) => r in e ? n(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var o = (e, r, t) => a(e, typeof r != "symbol" ? r + "" : r, t);
4
+ import { unwrapProductNameLinks as i } from "../../utils/unwrapProductNameLink.js";
5
+ const c = /<a[^>]*product-attr="name"/i;
6
+ class s {
7
+ constructor() {
8
+ o(this, "parser");
9
+ this.parser = new DOMParser();
10
+ }
11
+ migrate(r) {
12
+ try {
13
+ if (!r.includes("items-block-v2") || !c.test(r))
14
+ return r;
15
+ const t = this.parser.parseFromString(r, "text/html");
16
+ return i(t), t.documentElement.outerHTML;
17
+ } catch (t) {
18
+ return console.error("ProductNameLinkMigrator failed:", t), r;
19
+ }
20
+ }
21
+ }
22
+ function d(e) {
23
+ return new s().migrate(e);
24
+ }
25
+ export {
26
+ d as migrateProductNameLink
27
+ };
@@ -1,14 +1,14 @@
1
- import { BlockId as g } from "../../../enums/block.js";
2
- import { useOnboardingStore as p } from "../../../stores/onboarding.js";
1
+ import { BlockId as f } from "../../../enums/block.js";
2
+ import { useOnboardingStore as g } from "../../../stores/onboarding.js";
3
3
  import { getMigrationBannerHtml as y } from "../../../utils/migrationBannerHtml.js";
4
4
  import { Block as I, BlockCompositionType as C, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { SETTINGS_ENUMS as l, DefaultConfigValues as m } from "./enums/settingsEnums.js";
5
+ import { SETTINGS_ENUMS as d, DefaultConfigValues as m } from "./enums/settingsEnums.js";
6
6
  import { getDefaultTemplate as b } from "./template.js";
7
- import { getItemsBlockContainer as d, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
- const f = g.Items;
9
- class P extends I {
7
+ import { getItemsBlockContainer as l, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
+ const p = f.Items;
9
+ class O extends I {
10
10
  getId() {
11
- return f;
11
+ return p;
12
12
  }
13
13
  getIcon() {
14
14
  return "items-icon";
@@ -24,15 +24,15 @@ class P extends I {
24
24
  }
25
25
  getSettingsPanelTitleHtml() {
26
26
  return y(
27
- f,
27
+ p,
28
28
  this.api.translate("Items"),
29
29
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
30
30
  );
31
31
  }
32
32
  getTemplate() {
33
33
  return b({
34
- orientation: l.ORIENTATION.VERTICAL,
35
- itemsType: l.ITEMS_TYPE.CART_ITEMS,
34
+ orientation: d.ORIENTATION.VERTICAL,
35
+ itemsType: d.ITEMS_TYPE.CART_ITEMS,
36
36
  itemId: "{{Abandoned Cart Item (1) Url}}",
37
37
  currencySymbol: m.productPriceCurrencySymbolControlValue,
38
38
  currencyLocation: m.productPriceCurrencyLocationControlValue,
@@ -45,23 +45,23 @@ class P extends I {
45
45
  canBeSavedAsModule() {
46
46
  return !0;
47
47
  }
48
- onCreated(o) {
49
- const t = this.api.getDocumentModifier(), i = this.api.getDocumentRootCssNode();
50
- i.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(i).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
- const e = d(o);
52
- if (!e)
48
+ onCreated(e) {
49
+ const t = this.api.getDocumentModifier(), o = this.api.getDocumentRootCssNode();
50
+ o.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(o).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
+ const i = l(e);
52
+ if (!i)
53
53
  return;
54
- const r = e.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(o);
54
+ const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(e);
55
55
  if (n != null && n.initialized)
56
56
  if (s)
57
- n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
57
+ n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(i).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
58
58
  else {
59
59
  const a = this.api.getDocumentModifier();
60
- a.modifyHtml(e).setNodeConfig(n), this._stampProductTdDomAttributes(e, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
60
+ a.modifyHtml(i).setNodeConfig(n), this._stampProductTdDomAttributes(i, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
61
61
  }
62
62
  else {
63
63
  const a = N();
64
- this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), p().startOnboarding("itemsOnboarding");
64
+ this.api.getDocumentModifier().modifyHtml(i).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), g().startOnboarding("itemsOnboarding");
65
65
  }
66
66
  }
67
67
  /**
@@ -70,33 +70,33 @@ class P extends I {
70
70
  * into nodeConfig, so without this a reused module would reset to defaults.
71
71
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
72
72
  */
73
- onDocumentChanged(o) {
74
- const t = d(o);
73
+ onDocumentChanged(e) {
74
+ const t = l(e);
75
75
  if (!t)
76
76
  return;
77
- const i = t.getNodeConfig();
78
- if (i && Object.keys(i).length > 0)
77
+ const o = t.getNodeConfig();
78
+ if (o && Object.keys(o).length > 0)
79
79
  return;
80
- const r = u(o);
80
+ const r = u(e);
81
81
  if (!(r != null && r.initialized))
82
82
  return;
83
83
  const s = this.api.getDocumentModifier();
84
84
  s.modifyHtml(t).setNodeConfig(r), this._stampProductTdDomAttributes(t, r, s), s.apply(new c("Recover Items block config from saved module"));
85
85
  }
86
86
  /**
87
- * Bakes the compiler-read DOM attributes (`data-type`, `data-number`) onto the
87
+ * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
88
88
  * `.ins-product-td` container from the recovered config. Required for saved modules:
89
89
  * `migrate()` (which backfills these) only runs at template load — never when a module
90
90
  * is dropped into a live editor — so this is the one place the namespace + index get
91
91
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
92
92
  * relies on this td-level fallback in pairProductVariables.
93
93
  */
94
- _stampProductTdDomAttributes(o, t, i) {
95
- const e = h(t.itemsSelectValue, t.type);
96
- i.modifyHtml(o).setAttribute("data-type", t.type), i.modifyHtml(o).setAttribute("data-number", e);
94
+ _stampProductTdDomAttributes(e, t, o) {
95
+ const i = h(t.itemsSelectValue, t.type);
96
+ o.modifyHtml(e).setAttribute("data-type", t.type), o.modifyHtml(e).setAttribute("data-number", i), o.modifyHtml(e).setAttribute("data-nodup", String(t.priceHideDiscount));
97
97
  }
98
98
  }
99
99
  export {
100
- f as BLOCK_ID,
101
- P as ItemsBlock
100
+ p as BLOCK_ID,
101
+ O as ItemsBlock
102
102
  };
@@ -1,30 +1,31 @@
1
- import { ModificationDescription as d, UIElementType as a, UEAttr as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as T } from "../../../common-control.js";
3
- import { ItemsBlockControlId as l } from "../../enums/controlEnums.js";
4
- import { getItemsBlockConfig as o, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
5
- const g = l.NAME_TRIMMING, i = {
1
+ import { ModificationDescription as l, UIElementType as s, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as p } from "../../../common-control.js";
3
+ import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
4
+ import { findNameTextNode as T } from "../../utils/nameNode.js";
5
+ import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
6
+ const g = a.NAME_TRIMMING, i = {
6
7
  TRIMMING: "trimming"
7
8
  };
8
- class y extends T {
9
+ class y extends p {
9
10
  getId() {
10
11
  return g;
11
12
  }
12
13
  getTemplate() {
13
14
  return `
14
- <div class="container ${l.NAME_TRIMMING}">
15
+ <div class="container ${a.NAME_TRIMMING}">
15
16
  ${this._getTextTrimming()}
16
17
  </div>
17
18
  `;
18
19
  }
19
20
  onRender() {
20
- const e = o(this.currentNode);
21
+ const e = r(this.currentNode);
21
22
  this.api.updateValues({ [i.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(i.TRIMMING, (t) => {
22
23
  this._onTrimmingChange(t);
23
24
  });
24
25
  }
25
26
  onTemplateNodeUpdated(e) {
26
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
27
- const t = o(this.currentNode);
28
+ const t = r(this.currentNode);
28
29
  this.api.updateValues({ [i.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
29
30
  });
30
31
  }
@@ -32,20 +33,19 @@ class y extends T {
32
33
  c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [i.TRIMMING]: e }), this._applyTrimmingStyles(e);
33
34
  }
34
35
  _applyTrimmingStyles(e) {
35
- var m;
36
- const t = (m = this.currentNode) == null ? void 0 : m.querySelector("p > a");
36
+ const t = T(this.currentNode);
37
37
  if (!t)
38
38
  return;
39
- const n = o(this.currentNode), s = e !== void 0 ? e : (n == null ? void 0 : n.nameTrimming) ?? !0, r = this.api.getDocumentModifier().modifyHtml(t);
40
- s ? r.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : r.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), r.setStyle("max-width", "100%").apply(new d(`Text Trimming ${s ? "Enabled" : "Disabled"}`));
39
+ const n = r(this.currentNode), m = e !== void 0 ? e : (n == null ? void 0 : n.nameTrimming) ?? !0, o = this.api.getDocumentModifier().modifyHtml(t);
40
+ m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", "100%").apply(new l(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
41
41
  }
42
42
  _getTextTrimming() {
43
43
  return `
44
44
  <div class="display-flex align-items-center justify-content-between">
45
- <${a.LABEL}
46
- ${p.LABEL.text}="${this.api.translate("Text Trimming")}"
45
+ <${s.LABEL}
46
+ ${d.LABEL.text}="${this.api.translate("Text Trimming")}"
47
47
  >
48
- </${a.LABEL}>
48
+ </${s.LABEL}>
49
49
  ${this._GuToggle(i.TRIMMING)}
50
50
  </div>
51
51
  `;
@@ -1,43 +1,47 @@
1
- import { UIElementType as o, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as r } from "../../../common-control.js";
3
- import { ItemsBlockControlId as n } from "../../enums/controlEnums.js";
4
- import { getItemsBlockConfig as s, setItemsBlockConfig as a } from "../../utils/nodeConfigUtils.js";
5
- const c = n.PRICE_HIDE_DISCOUNT, i = {
1
+ import { ModificationDescription as c, UIElementType as s, UEAttr as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as p } from "../../../common-control.js";
3
+ import { ItemsBlockControlId as r } from "../../enums/controlEnums.js";
4
+ import { getItemsBlockConfig as d, setItemsBlockConfig as u } from "../../utils/nodeConfigUtils.js";
5
+ const D = r.PRICE_HIDE_DISCOUNT, i = {
6
6
  HIDE_DISCOUNT: "hideDiscount"
7
7
  };
8
- class C extends r {
8
+ class E extends p {
9
9
  getId() {
10
- return c;
10
+ return D;
11
11
  }
12
12
  getTemplate() {
13
13
  return `
14
- <div class="container ${n.PRICE_HIDE_DISCOUNT}">
14
+ <div class="container ${r.PRICE_HIDE_DISCOUNT}">
15
15
  ${this._getHideDiscount()}
16
16
  </div>
17
17
  `;
18
18
  }
19
19
  onRender() {
20
- const e = s(this.currentNode);
21
- this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 }), this.api.onValueChanged(i.HIDE_DISCOUNT, (t) => {
22
- this._onHideDiscountChange(t);
20
+ const t = d(this.currentNode);
21
+ this.api.updateValues({ [i.HIDE_DISCOUNT]: (t == null ? void 0 : t.priceHideDiscount) ?? !0 }), this.api.onValueChanged(i.HIDE_DISCOUNT, (e) => {
22
+ this._onHideDiscountChange(e);
23
23
  });
24
24
  }
25
- onTemplateNodeUpdated(e) {
26
- super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
27
- const t = s(this.currentNode);
28
- this.api.updateValues({ [i.HIDE_DISCOUNT]: (t == null ? void 0 : t.priceHideDiscount) ?? !0 });
25
+ onTemplateNodeUpdated(t) {
26
+ super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
27
+ const e = d(this.currentNode);
28
+ this.api.updateValues({ [i.HIDE_DISCOUNT]: (e == null ? void 0 : e.priceHideDiscount) ?? !0 });
29
29
  });
30
30
  }
31
- _onHideDiscountChange(e) {
32
- a(this.currentNode, this.api, { priceHideDiscount: e }), this.api.updateValues({ [i.HIDE_DISCOUNT]: e });
31
+ _onHideDiscountChange(t) {
32
+ var n;
33
+ const e = this.api.getDocumentModifier();
34
+ u(this.currentNode, this.api, { priceHideDiscount: t }, e);
35
+ const o = (n = this.currentNode) == null ? void 0 : n.closest(".ins-product-td");
36
+ o && e.modifyHtml(o).setAttribute("data-nodup", String(t)), e.apply(new c("Update hide-discount setting")), this.api.updateValues({ [i.HIDE_DISCOUNT]: t });
33
37
  }
34
38
  _getHideDiscount() {
35
39
  return `
36
40
  <div class="display-flex align-items-center justify-content-between">
37
- <${o.LABEL}
38
- ${d.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
41
+ <${s.LABEL}
42
+ ${a.LABEL.text}="${this.api.translate("Hide if same as discounted ")}"
39
43
  >
40
- </${o.LABEL}>
44
+ </${s.LABEL}>
41
45
  ${this._GuToggle(i.HIDE_DISCOUNT)}
42
46
  </div>
43
47
  </div>
@@ -45,6 +49,6 @@ class C extends r {
45
49
  }
46
50
  }
47
51
  export {
48
- c as CONTROL_BLOCK_ID,
49
- C as PriceHideDiscountControl
52
+ D as CONTROL_BLOCK_ID,
53
+ E as PriceHideDiscountControl
50
54
  };