@useinsider/guido 3.7.0-beta.830822b → 3.7.0-beta.9fddd7d

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 (42) hide show
  1. package/dist/@types/config/schemas.js +70 -66
  2. package/dist/composables/usePreviewMode.js +15 -14
  3. package/dist/composables/useRecommendationPreview.js +100 -0
  4. package/dist/config/compiler/utils/recommendationCompilerUtils.js +90 -82
  5. package/dist/config/migrator/recommendation/htmlBuilder.js +59 -58
  6. package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
  7. package/dist/enums/extensions/recommendationBlock.js +1 -3
  8. package/dist/extensions/Blocks/Recommendation/block.js +58 -39
  9. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
  10. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +369 -288
  11. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +84 -72
  12. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
  13. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +68 -66
  14. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
  15. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
  16. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +12 -10
  17. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +101 -72
  18. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +31 -30
  19. package/dist/extensions/Blocks/Recommendation/templates/index.js +9 -7
  20. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +74 -59
  21. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  22. package/dist/extensions/Blocks/Recommendation/templates/utils.js +88 -57
  23. package/dist/services/recommendationApi.js +19 -31
  24. package/dist/src/@types/config/schemas.d.ts +16 -0
  25. package/dist/src/composables/useConfig.d.ts +4 -0
  26. package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
  27. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  28. package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -1
  29. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  30. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +29 -3
  31. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  32. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
  33. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
  34. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  35. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +16 -0
  36. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  37. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +13 -0
  38. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
  39. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +33 -1
  40. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
  41. package/dist/src/stores/config.d.ts +36 -0
  42. package/package.json +1 -1
@@ -1,33 +1,85 @@
1
1
  import { RecommendationBlockId as l } from "../../constants/blockIds.js";
2
- import { ATTR_PRODUCT_ATTR as u, CSS_CLASS_RECO_BUTTON as p, ATTR_PRODUCT_BUTTON as m, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as $, ATTR_PRODUCT_IMAGE as _ } from "../../constants/selectors.js";
3
- import { useRecommendationExtensionStore as x } from "../../store/recommendation.js";
4
- import { formatPrice as C } from "../../utils/priceFormatter.js";
5
- import { CUSTOM_CELL_HTML as R, sanitizeImageUrl as O } from "../utils.js";
6
- const s = "0 5px", a = "attribute-cell";
7
- function S(t, e = s) {
8
- return `<td class="${a}" style="padding: ${e};" width="${t}%"></td>`;
2
+ import { ATTR_PRODUCT_ATTR as b, CSS_CLASS_RECO_BUTTON as g, ATTR_PRODUCT_BUTTON as u, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OLD_PRICE as $, ATTR_PRODUCT_PRICE as m, ATTR_PRODUCT_NAME as T, ATTR_PRODUCT_IMAGE as x } from "../../constants/selectors.js";
3
+ import { formatProductPrice as i, CUSTOM_CELL_HTML as f, getCurrentCurrencyConfig as _, sanitizeImageUrl as C } from "../utils.js";
4
+ const s = "0 5px", d = "attribute-cell";
5
+ function O(t, e = s) {
6
+ return `<td class="${d}" style="padding: ${e};" width="${t}%"></td>`;
9
7
  }
10
- function g() {
11
- const t = x(), { currencySettings: e } = t.recommendationConfigs;
12
- return {
13
- code: e.value,
14
- symbol: e.symbol,
15
- alignment: e.alignment === "0" ? "before" : "after",
16
- decimalCount: parseInt(e.decimalCount) || 2,
17
- decimalSeparator: e.decimalSeparator,
18
- thousandSeparator: e.thousandSeparator
19
- };
8
+ function U(t, e = !0) {
9
+ const a = `<s><strong>${i(t, "original_price")}</strong></s>`, r = (n) => `<td
10
+ class="esd-block-text product-price ${n}"
11
+ align="center"
12
+ valign="middle"
13
+ esd-extension-block-id="${l.PRICE}">
14
+ <p contenteditable="false" style="font-size: 16px; color: #333333;">
15
+ <strong>${i(t, "price")}</strong>
16
+ </p>
17
+ </td>`, o = (n) => `<td
18
+ class="esd-block-text product-old-price ${n}"
19
+ align="center"
20
+ valign="middle"
21
+ esd-extension-block-id="${l.OLD_PRICE}">
22
+ <p contenteditable="false" style="font-size: 14px; color: #999999;">
23
+ ${a}
24
+ </p>
25
+ </td>`, p = e ? o("es-p15l es-p5r") : r("es-p15l es-p5r"), c = e ? r("es-p5l es-p15r") : o("es-p5l es-p15r");
26
+ return `
27
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="top">
28
+ <table
29
+ class="product-card-segment"
30
+ width="100%"
31
+ height="100%"
32
+ cellpadding="0"
33
+ cellspacing="0"
34
+ border="0">
35
+ <tbody>
36
+ <tr valign="top">
37
+ <td align="center">
38
+ <table cellpadding="0" cellspacing="0" border="0" align="center" style="margin: 0 auto;">
39
+ <tbody>
40
+ <tr valign="middle">
41
+ ${p}
42
+ ${c}
43
+ </tr>
44
+ </tbody>
45
+ </table>
46
+ </td>
47
+ </tr>
48
+ </tbody>
49
+ </table>
50
+ </td>
51
+ `;
20
52
  }
21
- function i(t, e = "price") {
22
- const o = g(), n = t[e], d = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
23
- return C({
24
- price: d,
25
- currency: o
26
- });
53
+ function R(t) {
54
+ const e = `<s><strong>${i(t, "original_price")}</strong></s>`;
55
+ return `
56
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="top">
57
+ <table
58
+ class="product-card-segment"
59
+ width="100%"
60
+ height="100%"
61
+ cellpadding="0"
62
+ cellspacing="0"
63
+ border="0">
64
+ <tbody>
65
+ <tr valign="top">
66
+ <td
67
+ class="esd-block-text product-old-price es-p15l es-p15r"
68
+ align="center"
69
+ esd-extension-block-id="${l.OLD_PRICE}">
70
+ <p contenteditable="false" style="font-size: 14px; color: #999999;">
71
+ ${e}
72
+ </p>
73
+ </td>
74
+ </tr>
75
+ </tbody>
76
+ </table>
77
+ </td>
78
+ `;
27
79
  }
28
- const A = {
29
- [_]: (t) => `
30
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
80
+ const I = {
81
+ [x]: (t) => `
82
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="top">
31
83
  <table
32
84
  class="product-card-segment"
33
85
  width="100%"
@@ -41,9 +93,9 @@ const A = {
41
93
  class="esd-block-image product-image"
42
94
  align="center"
43
95
  esd-extension-block-id="${l.IMAGE}">
44
- <a target="_blank" href="${t.url}" class="${p}">
96
+ <a target="_blank" href="${t.url}" class="${g}">
45
97
  <img
46
- src="${O(t.image_url)}"
98
+ src="${C(t.image_url)}"
47
99
  alt="${t.name}"
48
100
  style="display: block; max-width: 100%; height: auto;"
49
101
  class="adapt-img">
@@ -54,8 +106,8 @@ const A = {
54
106
  </table>
55
107
  </td>
56
108
  `,
57
- [$]: (t) => `
58
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="middle">
109
+ [T]: (t) => `
110
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="middle">
59
111
  <table
60
112
  class="product-card-segment"
61
113
  width="100%"
@@ -79,8 +131,8 @@ const A = {
79
131
  </table>
80
132
  </td>
81
133
  `,
82
- [f]: (t) => `
83
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
134
+ [m]: (t) => `
135
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="top">
84
136
  <table
85
137
  class="product-card-segment"
86
138
  width="100%"
@@ -103,34 +155,9 @@ const A = {
103
155
  </table>
104
156
  </td>
105
157
  `,
106
- [T]: (t) => `
107
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
108
- <table
109
- class="product-card-segment"
110
- width="100%"
111
- height="100%"
112
- cellpadding="0"
113
- cellspacing="0"
114
- border="0">
115
- <tbody>
116
- <tr valign="top">
117
- <td
118
- class="esd-block-text product-old-price es-p15l es-p15r"
119
- align="center"
120
- esd-extension-block-id="${l.OLD_PRICE}">
121
- <p
122
- contenteditable="false"
123
- style="font-size: 14px; color: #999999;">
124
- <s><strong>${i(t, "original_price")}</strong></s>
125
- </p>
126
- </td>
127
- </tr>
128
- </tbody>
129
- </table>
130
- </td>
131
- `,
158
+ [$]: (t) => R(t),
132
159
  [y]: (t) => `
133
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
160
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="top">
134
161
  <table
135
162
  class="product-card-segment"
136
163
  width="100%"
@@ -158,10 +185,10 @@ const A = {
158
185
  </td>
159
186
  `,
160
187
  [h]: (t) => {
161
- var r, c;
162
- const e = g(), o = ((r = t.original_price) == null ? void 0 : r[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((c = t.price) == null ? void 0 : c[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, d = o > 0 ? Math.round((o - n) / o * 100) : 0, b = d > 0 ? `-${d}%` : "0%";
188
+ var c, n;
189
+ const e = _(), a = ((c = t.original_price) == null ? void 0 : c[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, r = ((n = t.price) == null ? void 0 : n[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, o = a > 0 ? Math.round((a - r) / a * 100) : 0, p = o > 0 ? `-${o}%` : "0%";
163
190
  return `
164
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
191
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="top">
165
192
  <table
166
193
  class="product-card-segment"
167
194
  width="100%"
@@ -179,7 +206,7 @@ const A = {
179
206
  esd-extension-block-id="${l.OMNIBUS_DISCOUNT}">
180
207
  <p contenteditable="false" style="font-size: 12px; color: #666666;">
181
208
  <span class="omnibus-text-before"></span>
182
- <span class="omnibus-discount-value">${b}</span>
209
+ <span class="omnibus-discount-value">${p}</span>
183
210
  <span class="omnibus-text-after"></span>
184
211
  </p>
185
212
  </td>
@@ -189,8 +216,8 @@ const A = {
189
216
  </td>
190
217
  `;
191
218
  },
192
- [m]: () => `
193
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="top">
219
+ [u]: () => `
220
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="top">
194
221
  <table
195
222
  class="product-card-segment"
196
223
  width="100%"
@@ -213,7 +240,7 @@ const A = {
213
240
  ">
214
241
  <a
215
242
  href="#"
216
- class="es-button ${p}"
243
+ class="es-button ${g}"
217
244
  target="_blank"
218
245
  style="
219
246
  color: rgb(56, 118, 29);
@@ -241,8 +268,8 @@ const A = {
241
268
  * @param productAttrValue - Resolved product-attr value (e.g., "brand" for default, "product_attribute.rating_star" for custom)
242
269
  * @param content - Display content for the cell
243
270
  */
244
- [R]: (t, e) => `
245
- <td class="${a}" style="padding: ${s}; height: 100%;" valign="middle">
271
+ [f]: (t, e) => `
272
+ <td class="${d}" style="padding: ${s}; height: 100%;" valign="middle">
246
273
  <table
247
274
  class="product-card-segment"
248
275
  width="100%"
@@ -254,7 +281,7 @@ const A = {
254
281
  <tbody>
255
282
  <tr valign="top">
256
283
  <td
257
- ${u}="${t}"
284
+ ${b}="${t}"
258
285
  class="esd-block-text product-custom-attribute es-p0t es-p0b es-p15l es-p15r"
259
286
  align="center"
260
287
  esd-extension-block-id="${l.CUSTOM_ATTRIBUTE}">
@@ -267,8 +294,10 @@ const A = {
267
294
  `
268
295
  };
269
296
  export {
270
- a as ATTRIBUTE_CELL_CLASS,
297
+ d as ATTRIBUTE_CELL_CLASS,
271
298
  s as DEFAULT_CELL_PADDING,
272
- S as buildFillerCell,
273
- A as gridElementRenderer
299
+ O as buildFillerCell,
300
+ I as gridElementRenderer,
301
+ R as renderGridOldPriceCell,
302
+ U as renderInlineGridPriceCell
274
303
  };
@@ -1,7 +1,7 @@
1
- import { DEFAULT_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
2
- import { getDefaultProducts as I, DEFAULTS as b, createBlockTemplate as E, DEFAULT_CARD_COMPOSITION as L, spacer as S, buildElementRenderer as _, DEFAULT_CARD_VISIBILITY as f } from "../utils.js";
3
- import { buildFillerCell as w, gridElementRenderer as A } from "./elementRenderer.js";
4
- const D = `
1
+ import { DEFAULT_PRODUCTS_PER_ROW as E } from "../../constants/layout.js";
2
+ import { getDefaultProducts as L, DEFAULTS as S, createBlockTemplate as _, DEFAULT_CARD_COMPOSITION as w, spacer as C, buildElementRenderer as O, resolveInlinePriceOrder as A, DEFAULT_CARD_VISIBILITY as D } from "../utils.js";
3
+ import { renderInlineGridPriceCell as P, buildFillerCell as g, gridElementRenderer as h } from "./elementRenderer.js";
4
+ const U = `
5
5
  <tr class="recommendation-product-row">
6
6
  <td>
7
7
  <table
@@ -18,7 +18,7 @@ const D = `
18
18
  </table>
19
19
  </td>
20
20
  </tr>
21
- `, C = `
21
+ `, Y = `
22
22
  <tr
23
23
  class="recommendation-attribute-row"
24
24
  data-attribute-type="{-{-ATTR_TYPE-}-}"
@@ -27,38 +27,39 @@ const D = `
27
27
  {-{-CELLS-}-}
28
28
  </tr>
29
29
  `;
30
- function O(t, e, n, r = L, c = {}) {
31
- const a = (100 / e).toFixed(2), s = e - t.length, l = s > 0 ? w(a).repeat(s) : "", i = _(n, r, c);
32
- return r.filter((o) => i[o]).map((o) => {
33
- const p = f[o] ?? !0, u = p ? "" : 'style="display: none;"', T = t.map((R) => i[o](R).replace("<td", `<td width="${a}%"`)).join("");
34
- return C.replace("{-{-ATTR_TYPE-}-}", o).replace("{-{-VISIBILITY-}-}", p ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", u).replace("{-{-CELLS-}-}", T + l);
30
+ function y(e, t, o, r = w, i = {}, p = {}) {
31
+ const { priceInline: s = !1 } = p, u = (100 / t).toFixed(2), n = t - e.length, T = n > 0 ? g(u).repeat(n) : "", d = O(o, r, i), c = A(r), R = s ? r.filter((l) => l !== c.skip) : r, I = (l, a) => s && l === c.anchor ? P(a, c.originalFirst) : d[l](a);
32
+ return R.filter((l) => d[l]).map((l) => {
33
+ const a = D[l] ?? !0, m = a ? "" : 'style="display: none;"', b = e.map((f) => I(l, f).replace("<td", `<td width="${u}%"`)).join("");
34
+ return Y.replace("{-{-ATTR_TYPE-}-}", l).replace("{-{-VISIBILITY-}-}", a ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", m).replace("{-{-CELLS-}-}", b + T);
35
35
  }).join("");
36
36
  }
37
- function g(t, e, n, r, c = {}) {
38
- const a = [];
39
- for (let l = 0; l < t.length; l += e)
40
- a.push(t.slice(l, l + e));
41
- return a.map((l, i) => {
42
- const d = O(
43
- l,
44
- e,
37
+ function B(e, t, o, r, i = {}, p = {}) {
38
+ const s = [];
39
+ for (let n = 0; n < e.length; n += t)
40
+ s.push(e.slice(n, n + t));
41
+ return s.map((n, T) => {
42
+ const d = y(
45
43
  n,
44
+ t,
45
+ o,
46
46
  r,
47
- c
48
- ), o = D.replace("{-{-ATTRIBUTE_ROWS-}-}", d);
49
- return i > 0 ? S + o : o;
47
+ i,
48
+ p
49
+ ), c = U.replace("{-{-ATTRIBUTE_ROWS-}-}", d);
50
+ return T > 0 ? C + c : c;
50
51
  }).join("");
51
52
  }
52
- function P(t, e, n, r = {}) {
53
- return g(t, e, A, n, r);
53
+ function F(e, t, o, r = {}, i = {}) {
54
+ return B(e, t, h, o, r, i);
54
55
  }
55
- function B(t) {
56
- const e = t ? `ins-recommendation-v3-block-${t}` : void 0, n = E("grid", e), r = I(), c = P(r, m);
57
- return n.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
56
+ function j(e) {
57
+ const t = e ? `ins-recommendation-v3-block-${e}` : void 0, o = _("grid", t), r = L(), i = F(r, E);
58
+ return o.replace("{-{-TITLE-}-}", S.TITLE).replace("{-{-PRODUCT_ROWS-}-}", i).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
58
59
  }
59
60
  export {
60
- B as getDefaultTemplate,
61
- O as prepareGridAttributeRows,
62
- g as prepareGridProductRows,
63
- P as prepareProductRows
61
+ j as getDefaultTemplate,
62
+ y as prepareGridAttributeRows,
63
+ B as prepareGridProductRows,
64
+ F as prepareProductRows
64
65
  };
@@ -1,12 +1,14 @@
1
1
  import { DEFAULT_PRODUCTS_PER_ROW as s } from "../constants/layout.js";
2
- import { prepareProductRows as c } from "./grid/template.js";
3
- import { prepareProductRows as R } from "./list/template.js";
4
- function a(o, t, r = {}) {
2
+ import { prepareProductRows as m } from "./grid/template.js";
3
+ import { prepareProductRows as n } from "./list/template.js";
4
+ import "../store/recommendation.js";
5
+ function P(o, t, r = {}) {
6
+ const e = { priceInline: r.priceInline };
5
7
  if (t === "list")
6
- return R(o, r.composition, r.filterList);
7
- const { productsPerRow: e = s, composition: p, filterList: i } = r;
8
- return c(o, e, p, i);
8
+ return n(o, r.composition, r.filterList, e);
9
+ const { productsPerRow: i = s, composition: p, filterList: c } = r;
10
+ return m(o, i, p, c, e);
9
11
  }
10
12
  export {
11
- a as prepareProductRows
13
+ P as prepareProductRows
12
14
  };
@@ -1,43 +1,69 @@
1
- import { RecommendationBlockId as o } from "../../constants/blockIds.js";
2
- import { ATTR_PRODUCT_ATTR as u, ATTR_PRODUCT_BUTTON as c, CSS_CLASS_RECO_BUTTON as d, ATTR_PRODUCT_IMAGE as p, ATTR_PRODUCT_OMNIBUS_DISCOUNT as g, ATTR_PRODUCT_OMNIBUS_PRICE as f, ATTR_PRODUCT_OLD_PRICE as T, ATTR_PRODUCT_PRICE as x, ATTR_PRODUCT_NAME as _ } from "../../constants/selectors.js";
3
- import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
4
- import { formatPrice as R } from "../../utils/priceFormatter.js";
5
- import { CUSTOM_CELL_HTML as O, sanitizeImageUrl as $ } from "../utils.js";
6
- function b() {
7
- const t = C(), { currencySettings: e } = t.recommendationConfigs;
8
- return {
9
- code: e.value,
10
- symbol: e.symbol,
11
- alignment: e.alignment === "0" ? "before" : "after",
12
- decimalCount: parseInt(e.decimalCount) || 2,
13
- decimalSeparator: e.decimalSeparator,
14
- thousandSeparator: e.thousandSeparator
15
- };
1
+ import { RecommendationBlockId as e } from "../../constants/blockIds.js";
2
+ import { ATTR_PRODUCT_ATTR as g, ATTR_PRODUCT_BUTTON as d, CSS_CLASS_RECO_BUTTON as p, ATTR_PRODUCT_IMAGE as b, ATTR_PRODUCT_OMNIBUS_DISCOUNT as u, ATTR_PRODUCT_OMNIBUS_PRICE as f, ATTR_PRODUCT_OLD_PRICE as m, ATTR_PRODUCT_PRICE as x, ATTR_PRODUCT_NAME as T } from "../../constants/selectors.js";
3
+ import { formatProductPrice as r, CUSTOM_CELL_HTML as _, getCurrentCurrencyConfig as $, sanitizeImageUrl as C } from "../utils.js";
4
+ function R(t) {
5
+ const o = `<s><strong>${r(t, "original_price")}</strong></s>`;
6
+ return `
7
+ <tr>
8
+ <td
9
+ class="esd-block-text product-old-price"
10
+ esd-extension-block-id="${e.OLD_PRICE}"
11
+ align="left">
12
+ <p
13
+ contenteditable="false"
14
+ style="font-size: 14px; color: #999999; margin: 0;">
15
+ ${o}
16
+ </p>
17
+ </td>
18
+ </tr>
19
+ `;
16
20
  }
17
- function r(t, e = "price") {
18
- const n = b(), s = t[e], a = (s == null ? void 0 : s[n.code]) ?? Object.values(s ?? {})[0] ?? 0;
19
- return R({
20
- price: a,
21
- currency: n
22
- });
21
+ function y(t, o = !0) {
22
+ const n = `<s><strong>${r(t, "original_price")}</strong></s>`, l = (s) => `<td
23
+ class="esd-block-text product-price"
24
+ esd-extension-block-id="${e.PRICE}"
25
+ align="left"
26
+ valign="middle"
27
+ style="width: auto;${s}">
28
+ <p contenteditable="false" style="font-size: 16px; color: #333333; font-weight: bold; margin: 0;">
29
+ <strong>${r(t, "price")}</strong>
30
+ </p>
31
+ </td>`, i = (s) => `<td
32
+ class="esd-block-text product-old-price"
33
+ esd-extension-block-id="${e.OLD_PRICE}"
34
+ align="left"
35
+ valign="middle"
36
+ style="width: auto;${s}">
37
+ <p
38
+ contenteditable="false"
39
+ style="font-size: 14px; color: #999999; margin: 0;">
40
+ ${n}
41
+ </p>
42
+ </td>`, c = o ? i(" padding-right: 8px;") : l(" padding-right: 8px;"), a = o ? l("") : i("");
43
+ return `
44
+ <tr>
45
+ ${c}
46
+ ${a}
47
+ </tr>
48
+ `;
23
49
  }
24
- const I = {
50
+ const h = {
25
51
  /**
26
52
  * Image cell - left column (120px fixed width)
27
53
  * Has recommendation-attribute-row class and data attributes for Card Composition control
28
54
  */
29
- [p]: (t) => `
55
+ [b]: (t) => `
30
56
  <td
31
57
  width="120"
32
58
  class="esd-block-image product-image-cell recommendation-attribute-row es-p5"
33
- esd-extension-block-id="${o.IMAGE}"
34
- data-attribute-type="${p}"
59
+ esd-extension-block-id="${e.IMAGE}"
60
+ data-attribute-type="${b}"
35
61
  data-visibility="1"
36
62
  align="center"
37
63
  valign="middle">
38
- <a target="_blank" href="${t.url}" class="${d}">
64
+ <a target="_blank" href="${t.url}" class="${p}">
39
65
  <img
40
- src="${$(t.image_url)}"
66
+ src="${C(t.image_url)}"
41
67
  alt="${t.name}"
42
68
  style="display: block; max-width: 100%; height: auto;"
43
69
  class="adapt-img product-image">
@@ -47,11 +73,11 @@ const I = {
47
73
  /**
48
74
  * Name element - row for info cell table
49
75
  */
50
- [_]: (t) => `
76
+ [T]: (t) => `
51
77
  <tr>
52
78
  <td
53
79
  class="esd-block-text product-name"
54
- esd-extension-block-id="${o.NAME}"
80
+ esd-extension-block-id="${e.NAME}"
55
81
  align="left">
56
82
  <p contenteditable="false" style="font-size: 16px; color: #333333; font-weight: 600; margin: 0;">
57
83
  <strong>${t.name}</strong>
@@ -66,7 +92,7 @@ const I = {
66
92
  <tr>
67
93
  <td
68
94
  class="esd-block-text product-price"
69
- esd-extension-block-id="${o.PRICE}"
95
+ esd-extension-block-id="${e.PRICE}"
70
96
  align="left">
71
97
  <p contenteditable="false" style="font-size: 16px; color: #333333; font-weight: bold; margin: 0;">
72
98
  <strong>${r(t, "price")}</strong>
@@ -77,20 +103,7 @@ const I = {
77
103
  /**
78
104
  * Old price element - row for info cell table
79
105
  */
80
- [T]: (t) => `
81
- <tr>
82
- <td
83
- class="esd-block-text product-old-price"
84
- esd-extension-block-id="${o.OLD_PRICE}"
85
- align="left">
86
- <p
87
- contenteditable="false"
88
- style="font-size: 14px; color: #999999; margin: 0;">
89
- <s><strong>${r(t, "original_price")}</strong></s>
90
- </p>
91
- </td>
92
- </tr>
93
- `,
106
+ [m]: (t) => R(t),
94
107
  /**
95
108
  * Omnibus price element - row for info cell table
96
109
  */
@@ -100,7 +113,7 @@ const I = {
100
113
  class="esd-block-text product-omnibus-price"
101
114
  data-text-before="Lowest 30-day price: "
102
115
  data-text-after=""
103
- esd-extension-block-id="${o.OMNIBUS_PRICE}"
116
+ esd-extension-block-id="${e.OMNIBUS_PRICE}"
104
117
  align="left">
105
118
  <p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">
106
119
  <span class="omnibus-text-before">Lowest 30-day price: </span>
@@ -113,20 +126,20 @@ const I = {
113
126
  /**
114
127
  * Omnibus discount element - row for info cell table
115
128
  */
116
- [g]: (t) => {
117
- var i, l;
118
- const e = b(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, s = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, a = n > 0 ? Math.round((n - s) / n * 100) : 0, m = a > 0 ? `-${a}%` : "0%";
129
+ [u]: (t) => {
130
+ var a, s;
131
+ const o = $(), n = ((a = t.original_price) == null ? void 0 : a[o.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, l = ((s = t.price) == null ? void 0 : s[o.code]) ?? Object.values(t.price ?? {})[0] ?? 0, i = n > 0 ? Math.round((n - l) / n * 100) : 0, c = i > 0 ? `-${i}%` : "0%";
119
132
  return `
120
133
  <tr>
121
134
  <td
122
135
  class="esd-block-text product-omnibus-discount"
123
136
  data-text-before=""
124
137
  data-text-after=""
125
- esd-extension-block-id="${o.OMNIBUS_DISCOUNT}"
138
+ esd-extension-block-id="${e.OMNIBUS_DISCOUNT}"
126
139
  align="left">
127
140
  <p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">
128
141
  <span class="omnibus-text-before"></span>
129
- <span class="omnibus-discount-value">${m}</span>
142
+ <span class="omnibus-discount-value">${c}</span>
130
143
  <span class="omnibus-text-after"></span>
131
144
  </p>
132
145
  </td>
@@ -137,12 +150,12 @@ const I = {
137
150
  * Button cell - right column (100px fixed width)
138
151
  * Has recommendation-attribute-row class and data attributes for Card Composition control
139
152
  */
140
- [c]: (t) => `
153
+ [d]: (t) => `
141
154
  <td
142
155
  width="100"
143
156
  class="esd-block-button button-cell recommendation-attribute-row product-button es-p5l es-p5r"
144
- esd-extension-block-id="${o.BUTTON}"
145
- data-attribute-type="${c}"
157
+ esd-extension-block-id="${e.BUTTON}"
158
+ data-attribute-type="${d}"
146
159
  data-visibility="1"
147
160
  align="center"
148
161
  valign="middle">
@@ -156,7 +169,7 @@ const I = {
156
169
  <a
157
170
  href="${t.url}"
158
171
  target="_blank"
159
- class="es-button ${d}"
172
+ class="es-button ${p}"
160
173
  style="
161
174
  color: rgb(56, 118, 29);
162
175
  background: rgb(217, 234, 211);
@@ -179,18 +192,20 @@ const I = {
179
192
  * @param productAttrValue - Resolved product-attr value (e.g., "brand" for default, "product_attribute.rating_star" for custom)
180
193
  * @param content - Display content for the cell
181
194
  */
182
- [O]: (t, e) => `
195
+ [_]: (t, o) => `
183
196
  <tr>
184
197
  <td
185
- ${u}="${t}"
198
+ ${g}="${t}"
186
199
  class="esd-block-text product-custom-attribute"
187
- esd-extension-block-id="${o.CUSTOM_ATTRIBUTE}"
200
+ esd-extension-block-id="${e.CUSTOM_ATTRIBUTE}"
188
201
  align="left">
189
- <p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">${e}</p>
202
+ <p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">${o}</p>
190
203
  </td>
191
204
  </tr>
192
205
  `
193
206
  };
194
207
  export {
195
- I as listElementRenderer
208
+ h as listElementRenderer,
209
+ y as renderInlineListPriceRow,
210
+ R as renderListOldPriceRow
196
211
  };