@useinsider/guido 2.1.0-beta.42f5dfa → 2.1.0-beta.486ee9c

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 (112) hide show
  1. package/README.md +36 -0
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  6. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  9. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +11 -13
  10. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +54 -23
  11. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +7 -5
  12. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +34 -21
  13. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +11 -11
  14. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +48 -36
  15. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
  16. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  17. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  18. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  19. package/dist/composables/useBlocksConfig.js +26 -16
  20. package/dist/composables/useHtmlValidator.js +107 -119
  21. package/dist/composables/useRecommendation.js +9 -9
  22. package/dist/composables/useStripo.js +25 -23
  23. package/dist/composables/useVersionHistoryApi.js +1 -1
  24. package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -23
  25. package/dist/config/i18n/en/index.js +11 -0
  26. package/dist/config/i18n/en/labels.json.js +7 -0
  27. package/dist/config/i18n/en/toasters.json.js +56 -0
  28. package/dist/config/i18n/en/tooltips.json.js +82 -0
  29. package/dist/config/i18n/index.js +7 -0
  30. package/dist/config/migrator/itemsBlockMigrator.js +127 -122
  31. package/dist/config/migrator/recommendationMigrator.js +1 -1
  32. package/dist/enums/defaults.js +8 -4
  33. package/dist/extensions/Blocks/Recommendation/block.js +26 -23
  34. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +37 -33
  35. package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -12
  36. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -11
  37. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
  38. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
  39. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +41 -29
  40. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
  41. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
  42. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +217 -94
  43. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
  44. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +97 -39
  45. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
  46. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +304 -209
  47. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  48. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
  49. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  50. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
  51. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
  52. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
  53. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
  54. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
  55. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
  56. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +13 -13
  57. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
  58. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
  59. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +237 -140
  60. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +27 -32
  61. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
  62. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
  63. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +22 -27
  64. package/dist/extensions/Blocks/Recommendation/templates/utils.js +50 -38
  65. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
  66. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +29 -0
  67. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  68. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  69. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  70. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  71. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  72. package/dist/guido.css +1 -1
  73. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
  74. package/dist/services/recommendationApi.js +11 -9
  75. package/dist/services/stripoApi.js +20 -17
  76. package/dist/src/@types/config/schemas.d.ts +8 -0
  77. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +1 -0
  78. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +17 -1
  79. package/dist/src/composables/useConfig.d.ts +4 -0
  80. package/dist/src/config/i18n/en/index.d.ts +1 -0
  81. package/dist/src/config/i18n/index.d.ts +16 -0
  82. package/dist/src/enums/defaults.d.ts +4 -0
  83. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
  84. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
  85. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +12 -2
  86. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -1
  87. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +50 -11
  88. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
  89. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +36 -16
  90. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  91. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
  92. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +26 -2
  93. package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
  94. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
  95. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -0
  96. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
  97. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -3
  98. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +14 -0
  99. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +15 -0
  100. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  101. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  102. package/dist/src/stores/config.d.ts +36 -0
  103. package/dist/static/styles/components/notification.css.js +19 -0
  104. package/dist/static/styles/components/tools.css.js +6 -2
  105. package/dist/static/styles/components/version-history.css.js +10 -2
  106. package/dist/static/styles/components/wide-panel.css.js +18 -2
  107. package/dist/static/styles/customEditorStyle.css.js +59 -31
  108. package/dist/static/styles/variables.css.js +2 -0
  109. package/dist/static/templates/empty/index.html.js +74 -0
  110. package/dist/static/templates/empty/style.css.js +779 -0
  111. package/dist/stores/unsubscribe.js +37 -34
  112. package/package.json +2 -2
@@ -1,286 +1,381 @@
1
- import { ModificationDescription as g } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { RecommendationBlockId as f } from "../../constants/blockIds.js";
3
- import { CURRENCY_ATTR as y, CONTAINER_SELECTOR as I } from "../../constants/selectors.js";
4
- import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
5
- import { prepareProductRows as R } from "../../templates/index.js";
6
- import { formatPrice as O } from "../../utils/priceFormatter.js";
7
- import { isTdNode as T } from "../../utils/tagName.js";
8
- import { sanitizeImageUrl as k, getDefaultProducts as _, DEFAULT_CARD_COMPOSITION as P } from "../../templates/utils.js";
9
- const C = "ins-recommendation-v3-block-v2";
10
- function b(o) {
11
- if (!o)
1
+ import { ModificationDescription as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RecommendationBlockId as m } from "../../constants/blockIds.js";
3
+ import { MOBILE_CONTAINER_SELECTOR as g, CURRENCY_ATTR as y, DESKTOP_CONTAINER_SELECTOR as q, CONTAINER_SELECTOR as $, MOBILE_ROW_SELECTOR as O } from "../../constants/selectors.js";
4
+ import { RecommendationConfigService as N } from "../../services/configService.js";
5
+ import { useRecommendationExtensionStore as E } from "../../store/recommendation.js";
6
+ import { prepareProductRows as k } from "../../templates/index.js";
7
+ import { formatPrice as B } from "../../utils/priceFormatter.js";
8
+ import { isTdNode as v } from "../../utils/tagName.js";
9
+ import { getDefaultProducts as T, DEFAULT_CARD_COMPOSITION as P, sanitizeImageUrl as j } from "../../templates/utils.js";
10
+ const M = "recommendation-block-v2";
11
+ function A(t) {
12
+ if (!t)
12
13
  return null;
13
- if ("getAttribute" in o) {
14
- const e = o.getAttribute("class");
15
- if (e && e.includes(C))
16
- return o;
14
+ if ("getAttribute" in t) {
15
+ const e = t.getAttribute("class");
16
+ if (e && e.includes(M))
17
+ return t;
17
18
  }
18
- return "querySelector" in o ? o.querySelector(`.${C}`) : null;
19
+ return "querySelector" in t ? t.querySelector(`.${M}`) : null;
19
20
  }
20
- function q(o) {
21
- const e = b(o);
21
+ function b(t) {
22
+ const e = A(t);
22
23
  if (!e || !("getAttribute" in e))
23
24
  return "grid";
24
- const t = e.getAttribute("data-layout");
25
- return t === "list" || t === "horizontal" ? "list" : "grid";
25
+ const o = e.getAttribute("data-layout");
26
+ return o === "list" || o === "horizontal" ? "list" : "grid";
26
27
  }
27
- function D(o) {
28
- const e = b(o);
28
+ function _(t) {
29
+ const e = A(t);
29
30
  if (!e || !("getAttribute" in e))
30
31
  return P;
31
- const t = e.getAttribute("data-card-composition");
32
- return t ? t.split(",").filter(Boolean) : P;
32
+ const o = e.getAttribute("data-card-composition");
33
+ return o ? o.split(",").filter(Boolean) : P;
33
34
  }
34
- function S(o, e, t) {
35
+ function S(t, e, o) {
35
36
  if (!e || !("childNodes" in e))
36
37
  return !1;
37
- const n = e.childNodes().find(
38
- (i) => "getType" in i && i.getType() === "text"
38
+ const r = e.childNodes().find(
39
+ (c) => "getType" in c && c.getType() === "text"
39
40
  );
40
- return n ? (o.modifyHtml(n).setText(t), !0) : !1;
41
+ return r ? (t.modifyHtml(r).setText(o), !0) : !1;
41
42
  }
42
- function w(o, e) {
43
- return o && o.length > 0 ? o : e.length > 0 ? e : _();
43
+ function x(t, e) {
44
+ return t && t.length > 0 ? t : e.length > 0 ? e : T();
44
45
  }
45
- function U(o) {
46
- const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
46
+ function V(t) {
47
+ const { currentNode: e, documentModifier: o } = t;
47
48
  if (!e || !("querySelector" in e))
48
49
  return;
49
- const c = e.querySelector(I);
50
- if (!c)
50
+ const n = e.querySelector(O), r = e.querySelector(g);
51
+ n && o.modifyHtml(n).setStyle("display", "none"), r && o.modifyHtml(r).setInnerHtml(""), (n || r) && o.apply(new p("Hide mobile row for list layout"));
52
+ }
53
+ function W(t) {
54
+ const { currentNode: e, documentModifier: o } = t;
55
+ if (!e || !("querySelector" in e))
56
+ return;
57
+ const n = e.querySelector(O);
58
+ n && o.modifyHtml(n).removeStyle("display").apply(new p("Show mobile row for grid layout"));
59
+ }
60
+ function G(t) {
61
+ const { currentNode: e, documentModifier: o, products: n, layout: r } = t;
62
+ if (!e || !("querySelector" in e))
63
+ return;
64
+ const c = r ?? b(e);
65
+ if (c === "list") {
66
+ V({ currentNode: e, documentModifier: o });
67
+ return;
68
+ }
69
+ W({ currentNode: e, documentModifier: o });
70
+ const i = e.querySelector(g);
71
+ if (!i)
51
72
  return;
52
- const s = A(), l = w(n, s.recommendationProducts), { cardsInRow: u } = s.recommendationConfigs, d = D(e), a = i ?? q(e), p = R(l, a, {
53
- productsPerRow: u,
54
- composition: d
73
+ const s = E(), u = N.getConfig(e), l = x(n, s.recommendationProducts), f = _(e), a = k(l, c, {
74
+ productsPerRow: u.mobileCardsInRow,
75
+ composition: f
55
76
  });
56
- t.modifyHtml(c).setInnerHtml(p).apply(new g("Updated product")), r == null || r();
77
+ o.modifyHtml(i).setInnerHtml(a).apply(new p("Updated mobile product rows"));
57
78
  }
58
- function $(o, e, t, r) {
59
- const i = `0 ${Math.floor(t / 2)}px`;
60
- let c = !1;
61
- return r === "grid" ? Array.from(
62
- o.querySelectorAll(".attribute-cell")
63
- ).forEach((l) => {
64
- e.modifyHtml(l).setStyle("padding", i), c = !0;
65
- }) : Array.from(
66
- o.querySelectorAll(".product-card-wrapper")
67
- ).forEach((l) => {
68
- const u = "parentNode" in l ? l.parentNode : null;
69
- u && T(u) && (e.modifyHtml(u).setStyle("padding", i), c = !0);
70
- }), c;
79
+ function Y(t) {
80
+ const {
81
+ currentNode: e,
82
+ documentModifier: o,
83
+ afterRegenerate: n,
84
+ products: r,
85
+ layout: c
86
+ } = t;
87
+ if (!e || !("querySelector" in e))
88
+ return;
89
+ const i = e.querySelector(q) ?? e.querySelector($);
90
+ if (!i)
91
+ return;
92
+ const s = E(), u = x(r, s.recommendationProducts), { cardsInRow: l } = s.recommendationConfigs, f = _(e), a = c ?? b(e), d = k(u, a, {
93
+ productsPerRow: l,
94
+ composition: f
95
+ });
96
+ o.modifyHtml(i).setInnerHtml(d).apply(new p("Updated product")), G(t), n == null || n();
71
97
  }
72
- function L(o, e, t) {
73
- const r = `${t}px`, n = Array.from(o.querySelectorAll(".spacer"));
98
+ function h(t, e, o, n) {
99
+ const c = `0 ${Math.floor(o / 2)}px`;
74
100
  let i = !1;
75
- return n.forEach((c) => {
76
- e.modifyHtml(c).setStyle("height", r), i = !0;
101
+ return n === "grid" ? Array.from(
102
+ t.querySelectorAll(".attribute-cell")
103
+ ).forEach((u) => {
104
+ e.modifyHtml(u).setStyle("padding", c), i = !0;
105
+ }) : Array.from(
106
+ t.querySelectorAll(".product-card-wrapper")
107
+ ).forEach((u) => {
108
+ const l = "parentNode" in u ? u.parentNode : null;
109
+ l && v(l) && (e.modifyHtml(l).setStyle("padding", c), i = !0);
77
110
  }), i;
78
111
  }
79
- function H(o) {
80
- const { currentNode: e, documentModifier: t } = o;
112
+ function R(t, e, o) {
113
+ const n = `${o}px`, r = Array.from(t.querySelectorAll(".spacer"));
114
+ let c = !1;
115
+ return r.forEach((i) => {
116
+ e.modifyHtml(i).setStyle("height", n), c = !0;
117
+ }), c;
118
+ }
119
+ function F(t) {
120
+ const { currentNode: e, documentModifier: o } = t;
81
121
  if (!e)
82
122
  return;
83
- const r = b(e);
84
- if (!r || !("getAttribute" in r))
85
- return;
86
- const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c = q(e);
87
- let s = !1;
88
- if (n) {
89
- const l = parseInt(n);
90
- Number.isNaN(l) || (s = $(
91
- e,
92
- t,
93
- l,
94
- c
95
- ));
96
- }
123
+ const n = N.getConfig(e), r = b(e);
124
+ let c = !1;
125
+ const i = e.querySelector(q);
97
126
  if (i) {
98
- const l = parseInt(i);
99
- if (!Number.isNaN(l)) {
100
- const u = L(e, t, l);
101
- s = s || u;
102
- }
127
+ c = h(
128
+ i,
129
+ o,
130
+ n.columnSpacing,
131
+ r
132
+ );
133
+ const l = R(
134
+ i,
135
+ o,
136
+ n.rowSpacing
137
+ );
138
+ c = c || l;
139
+ }
140
+ const s = e.querySelector(g);
141
+ if (s) {
142
+ const u = h(
143
+ s,
144
+ o,
145
+ n.mobileColumnSpacing,
146
+ r
147
+ );
148
+ c = c || u;
149
+ const l = R(
150
+ s,
151
+ o,
152
+ n.mobileRowSpacing
153
+ );
154
+ c = c || l;
103
155
  }
104
- s && t.apply(new g("Reapply spacing after regeneration"));
156
+ c && o.apply(new p("Reapply spacing after regeneration"));
105
157
  }
106
- function K(o) {
107
- const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
108
- e && U({
158
+ function ie(t) {
159
+ const { currentNode: e, documentModifier: o, afterRegenerate: n, products: r, layout: c } = t;
160
+ e && Y({
109
161
  currentNode: e,
110
- documentModifier: t,
111
- products: n,
112
- layout: i,
162
+ documentModifier: o,
163
+ products: r,
164
+ layout: c,
113
165
  afterRegenerate: () => {
114
166
  setTimeout(() => {
115
- H({ currentNode: e, documentModifier: t });
116
- }, 0), r == null || r();
167
+ F({ currentNode: e, documentModifier: o });
168
+ }, 0), n == null || n();
117
169
  }
118
170
  });
119
171
  }
120
- function h() {
121
- const o = A(), { currencySettings: e } = o.recommendationConfigs;
172
+ function ce(t, e) {
173
+ return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...T(e - t.length)];
174
+ }
175
+ function D() {
176
+ const t = E(), { currencySettings: e } = t.recommendationConfigs, o = parseInt(e.decimalCount);
122
177
  return {
123
178
  code: e.value,
124
179
  symbol: e.symbol,
125
180
  alignment: e.alignment === "0" ? "before" : "after",
126
- decimalCount: parseInt(e.decimalCount) || 2,
181
+ decimalCount: Number.isNaN(o) ? 2 : o,
127
182
  decimalSeparator: e.decimalSeparator,
128
183
  thousandSeparator: e.thousandSeparator
129
184
  };
130
185
  }
131
- function E(o, e = "price") {
132
- const t = h(), r = o[e], n = (r == null ? void 0 : r[t.code]) ?? Object.values(r ?? {})[0] ?? 0;
133
- return O({
134
- price: n,
135
- currency: t
186
+ function C(t, e = "price") {
187
+ const o = D(), n = t[e], r = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
188
+ return B({
189
+ price: r,
190
+ currency: o
136
191
  });
137
192
  }
138
- function x(o) {
139
- var i, c;
140
- const e = h(), t = ((i = o.original_price) == null ? void 0 : i[e.code]) ?? Object.values(o.original_price ?? {})[0] ?? 0, r = ((c = o.price) == null ? void 0 : c[e.code]) ?? Object.values(o.price ?? {})[0] ?? 0, n = t > 0 ? Math.round((t - r) / t * 100) : 0;
141
- return n > 0 ? `-${n}%` : "0%";
193
+ function K(t) {
194
+ var c, i;
195
+ const e = D(), o = ((c = t.original_price) == null ? void 0 : c[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((i = t.price) == null ? void 0 : i[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = o > 0 ? Math.round((o - n) / o * 100) : 0;
196
+ return r > 0 ? `-${r}%` : "0%";
142
197
  }
143
- function N(o) {
144
- const { documentModifier: e, product: t, priceEl: r, oldPriceEl: n, omnibusPriceEl: i, omnibusDiscountEl: c } = o;
198
+ function H(t) {
199
+ const { documentModifier: e, product: o, priceEl: n, oldPriceEl: r, omnibusPriceEl: c, omnibusDiscountEl: i } = t;
145
200
  let s = !1;
146
- if (r && "querySelector" in r) {
147
- const l = r.querySelector("strong"), u = E(t, "price");
148
- S(e, l, u) && (s = !0);
149
- }
150
201
  if (n && "querySelector" in n) {
151
- const l = n.querySelector("strong"), u = E(t, "original_price");
152
- S(e, l, u) && (s = !0);
202
+ const u = n.querySelector("strong"), l = C(o, "price");
203
+ S(e, u, l) && (s = !0);
153
204
  }
154
- if (i && "querySelector" in i) {
155
- const l = i.querySelector(".omnibus-price-value"), u = E(t, "original_price");
156
- S(e, l, u) && (s = !0);
205
+ if (r && "querySelector" in r) {
206
+ const u = r.querySelector("strong"), l = C(o, "original_price");
207
+ S(e, u, l) && (s = !0);
157
208
  }
158
209
  if (c && "querySelector" in c) {
159
- const l = c.querySelector(".omnibus-discount-value"), u = x(t);
160
- S(e, l, u) && (s = !0);
210
+ const u = c.querySelector(".omnibus-price-value"), l = C(o, "original_price");
211
+ S(e, u, l) && (s = !0);
212
+ }
213
+ if (i && "querySelector" in i) {
214
+ const u = i.querySelector(".omnibus-discount-value"), l = K(o);
215
+ S(e, u, l) && (s = !0);
161
216
  }
162
217
  return s;
163
218
  }
164
- function B(o) {
219
+ function z(t) {
165
220
  const {
166
221
  documentModifier: e,
167
- product: t,
168
- imageEl: r,
169
- nameEl: n,
170
- priceEl: i,
171
- oldPriceEl: c,
222
+ product: o,
223
+ imageEl: n,
224
+ nameEl: r,
225
+ priceEl: c,
226
+ oldPriceEl: i,
172
227
  omnibusPriceEl: s,
173
- omnibusDiscountEl: l,
174
- buttonEl: u
175
- } = o;
176
- let d = !1;
177
- if (r && "querySelector" in r) {
178
- const a = r.querySelector("img");
179
- a && (e.modifyHtml(a).setAttribute("src", k(t.image_url)).setAttribute("alt", t.name), d = !0);
180
- const p = r.querySelector("a");
181
- p && (e.modifyHtml(p).setAttribute("href", t.url), d = !0);
182
- }
228
+ omnibusDiscountEl: u,
229
+ buttonEl: l
230
+ } = t;
231
+ let f = !1;
183
232
  if (n && "querySelector" in n) {
184
- const a = n.querySelector("strong");
185
- S(e, a, t.name) && (d = !0);
233
+ const a = n.querySelector("img");
234
+ a && (e.modifyHtml(a).setAttribute("src", j(o.image_url)).setAttribute("alt", o.name), f = !0);
235
+ const d = n.querySelector("a");
236
+ d && (e.modifyHtml(d).setAttribute("href", o.url), f = !0);
237
+ }
238
+ if (r && "querySelector" in r) {
239
+ const a = r.querySelector("strong");
240
+ S(e, a, o.name) && (f = !0);
186
241
  }
187
- if (N({
242
+ if (H({
188
243
  documentModifier: e,
189
- product: t,
190
- priceEl: i,
191
- oldPriceEl: c,
244
+ product: o,
245
+ priceEl: c,
246
+ oldPriceEl: i,
192
247
  omnibusPriceEl: s,
193
- omnibusDiscountEl: l
194
- }) && (d = !0), u && "querySelector" in u) {
195
- const a = u.querySelector("a.es-button") || u.querySelector("a");
196
- a && (e.modifyHtml(a).setAttribute("href", t.url), d = !0);
248
+ omnibusDiscountEl: u
249
+ }) && (f = !0), l && "querySelector" in l) {
250
+ const a = l.querySelector("a.es-button") || l.querySelector("a");
251
+ a && (e.modifyHtml(a).setAttribute("href", o.url), f = !0);
197
252
  }
198
- return d;
253
+ return f;
199
254
  }
200
- function J(o) {
201
- const { currentNode: e, documentModifier: t, products: r } = o;
202
- if (!e || !("querySelectorAll" in e))
203
- return !1;
204
- const n = e.querySelectorAll(
205
- `[esd-extension-block-id="${f.IMAGE}"]`
206
- ), i = e.querySelectorAll(
207
- `[esd-extension-block-id="${f.NAME}"]`
208
- ), c = e.querySelectorAll(
209
- `[esd-extension-block-id="${f.PRICE}"]`
210
- ), s = e.querySelectorAll(
211
- `[esd-extension-block-id="${f.OLD_PRICE}"]`
212
- ), l = e.querySelectorAll(
213
- `[esd-extension-block-id="${f.OMNIBUS_PRICE}"]`
214
- ), u = e.querySelectorAll(
215
- `[esd-extension-block-id="${f.OMNIBUS_DISCOUNT}"]`
216
- ), d = e.querySelectorAll(
217
- `[esd-extension-block-id="${f.BUTTON}"]`
218
- );
219
- if (n.length !== r.length)
255
+ function L(t) {
256
+ return "querySelector" in t ? t.querySelector(q) ?? t : t;
257
+ }
258
+ function I(t, e, o) {
259
+ if (!("querySelectorAll" in t))
220
260
  return !1;
261
+ const n = t.querySelectorAll(
262
+ `[esd-extension-block-id="${m.IMAGE}"]`
263
+ ), r = t.querySelectorAll(
264
+ `[esd-extension-block-id="${m.NAME}"]`
265
+ ), c = t.querySelectorAll(
266
+ `[esd-extension-block-id="${m.PRICE}"]`
267
+ ), i = t.querySelectorAll(
268
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
269
+ ), s = t.querySelectorAll(
270
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
271
+ ), u = t.querySelectorAll(
272
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
273
+ ), l = t.querySelectorAll(
274
+ `[esd-extension-block-id="${m.BUTTON}"]`
275
+ ), f = Math.min(n.length, o.length);
221
276
  let a = !1;
222
- return r.forEach((p, m) => {
223
- const M = B({
224
- documentModifier: t,
225
- product: p,
226
- imageEl: n[m] ?? null,
227
- nameEl: i[m] ?? null,
228
- priceEl: c[m] ?? null,
229
- oldPriceEl: s[m] ?? null,
230
- omnibusPriceEl: l[m] ?? null,
231
- omnibusDiscountEl: u[m] ?? null,
232
- buttonEl: d[m] ?? null
277
+ for (let d = 0; d < f; d++) {
278
+ const U = z({
279
+ documentModifier: e,
280
+ product: o[d],
281
+ imageEl: n[d] ?? null,
282
+ nameEl: r[d] ?? null,
283
+ priceEl: c[d] ?? null,
284
+ oldPriceEl: i[d] ?? null,
285
+ omnibusPriceEl: s[d] ?? null,
286
+ omnibusDiscountEl: u[d] ?? null,
287
+ buttonEl: l[d] ?? null
233
288
  });
234
- a = a || M;
235
- }), a && t.apply(new g("Updated product content in-place")), !0;
289
+ a = a || U;
290
+ }
291
+ return a;
236
292
  }
237
- function Q(o) {
238
- const { currentNode: e, documentModifier: t } = o;
293
+ function le(t) {
294
+ const { currentNode: e, documentModifier: o, products: n } = t;
239
295
  if (!e || !("querySelectorAll" in e))
240
296
  return !1;
241
- const n = A().recommendationProducts;
242
- if (n.length === 0)
297
+ const r = L(e);
298
+ if (!("querySelectorAll" in r) || r.querySelectorAll(
299
+ `[esd-extension-block-id="${m.IMAGE}"]`
300
+ ).length !== n.length)
243
301
  return !1;
244
- const i = e.querySelectorAll(
245
- `[esd-extension-block-id="${f.PRICE}"]`
246
- ), c = e.querySelectorAll(
247
- `[esd-extension-block-id="${f.OLD_PRICE}"]`
248
- ), s = e.querySelectorAll(
249
- `[esd-extension-block-id="${f.OMNIBUS_PRICE}"]`
250
- ), l = e.querySelectorAll(
251
- `[esd-extension-block-id="${f.OMNIBUS_DISCOUNT}"]`
252
- );
302
+ let i = I(r, o, n);
303
+ if (b(e) !== "list" && "querySelector" in e) {
304
+ const u = e.querySelector(g);
305
+ if (u) {
306
+ const l = I(
307
+ u,
308
+ o,
309
+ n
310
+ );
311
+ i = i || l;
312
+ }
313
+ }
314
+ return i && o.apply(new p("Updated product content in-place")), !0;
315
+ }
316
+ function w(t, e, o) {
317
+ if (!("querySelectorAll" in t))
318
+ return !1;
319
+ const n = t.querySelectorAll(
320
+ `[esd-extension-block-id="${m.PRICE}"]`
321
+ ), r = t.querySelectorAll(
322
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
323
+ ), c = t.querySelectorAll(
324
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
325
+ ), i = t.querySelectorAll(
326
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
327
+ ), s = Math.min(n.length, o.length);
253
328
  let u = !1;
254
- return n.forEach((d, a) => {
255
- N({
256
- documentModifier: t,
257
- product: d,
258
- priceEl: i[a] ?? null,
259
- oldPriceEl: c[a] ?? null,
260
- omnibusPriceEl: s[a] ?? null,
261
- omnibusDiscountEl: l[a] ?? null
329
+ for (let l = 0; l < s; l++)
330
+ H({
331
+ documentModifier: e,
332
+ product: o[l],
333
+ priceEl: n[l] ?? null,
334
+ oldPriceEl: r[l] ?? null,
335
+ omnibusPriceEl: c[l] ?? null,
336
+ omnibusDiscountEl: i[l] ?? null
262
337
  }) && (u = !0);
263
- }), u && t.apply(new g("Updated price formatting in-place")), u;
338
+ return u;
339
+ }
340
+ function ue(t) {
341
+ const { currentNode: e, documentModifier: o } = t;
342
+ if (!e || !("querySelectorAll" in e))
343
+ return !1;
344
+ const r = E().recommendationProducts;
345
+ if (r.length === 0)
346
+ return !1;
347
+ const c = L(e);
348
+ let i = w(c, o, r);
349
+ if (b(e) !== "list" && "querySelector" in e) {
350
+ const u = e.querySelector(g);
351
+ if (u) {
352
+ const l = w(u, o, r);
353
+ i = i || l;
354
+ }
355
+ }
356
+ return i && o.apply(new p("Updated price formatting in-place")), i;
264
357
  }
265
- function X(o) {
266
- const { currentNode: e, documentModifier: t, currency: r } = o, n = b(e);
267
- if (!n)
358
+ function se(t) {
359
+ const { currentNode: e, documentModifier: o, currency: n } = t, r = A(e);
360
+ if (!r)
268
361
  return;
269
- const i = r.alignment === "before" ? "0" : "1", c = (s, l) => {
270
- t.modifyHtml(n).setAttribute(s, l);
362
+ const c = n.alignment === "before" ? "0" : "1", i = (s, u) => {
363
+ o.modifyHtml(r).setAttribute(s, u);
271
364
  };
272
- c(y.CURRENCY, r.code), c(y.SYMBOL, r.symbol), c(y.ALIGNMENT, i), c(y.THOUSAND_SEPARATOR, r.thousandSeparator), c(y.DECIMAL_SEPARATOR, r.decimalSeparator), c(y.DECIMAL_COUNT, r.decimalCount.toString()), t.apply(new g("Update currency attributes"));
365
+ i(y.CURRENCY, n.code), i(y.SYMBOL, n.symbol), i(y.ALIGNMENT, c), i(y.THOUSAND_SEPARATOR, n.thousandSeparator), i(y.DECIMAL_SEPARATOR, n.decimalSeparator), i(y.DECIMAL_COUNT, n.decimalCount.toString()), o.apply(new p("Update currency attributes"));
273
366
  }
274
367
  export {
275
- E as formatProductPrice,
276
- b as getBlockElement,
277
- D as getCardComposition,
278
- q as getCurrentLayout,
279
- H as reapplySpacing,
280
- U as regenerateProductRows,
281
- K as regenerateProductRowsWithStyles,
282
- X as setCurrencyAttributes,
283
- Q as updatePricesInPlace,
284
- J as updateProductContentInPlace,
285
- B as updateSingleProductContent
368
+ ce as adjustProductsToSize,
369
+ C as formatProductPrice,
370
+ A as getBlockElement,
371
+ _ as getCardComposition,
372
+ b as getCurrentLayout,
373
+ F as reapplySpacing,
374
+ G as regenerateMobileProductRows,
375
+ Y as regenerateProductRows,
376
+ ie as regenerateProductRowsWithStyles,
377
+ se as setCurrencyAttributes,
378
+ ue as updatePricesInPlace,
379
+ le as updateProductContentInPlace,
380
+ z as updateSingleProductContent
286
381
  };
@@ -0,0 +1,21 @@
1
+ import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ const s = "ins-recommendation-desktop-container", i = "ins-recommendation-mobile-container", o = "ins-recommendation-list-layout", a = `.${i} { display: none; }`, d = `@media only screen and (max-width: 480px) { .${s} { display: none !important; } .${i} { display: table !important; } .${o} .${s} { display: table !important; } .${o} .${i}, .${o} .ins-recommendation-mobile-row { display: none !important; } .${o} .product-image-cell { width: 80px !important; } .${o} .product-image-cell img { max-width: 80px !important; } .${o} .button-cell { width: 80px !important; } .${o} .product-info-cell { padding: 5px 8px !important; } }`, p = `.${i}`;
3
+ function c(t, e) {
4
+ return !!t.querySelector(e);
5
+ }
6
+ function m(t) {
7
+ return t.querySelectorAll(`*${s}`).length > 0;
8
+ }
9
+ function S(t) {
10
+ const e = t.getDocumentRootCssNode();
11
+ if (!e)
12
+ return;
13
+ const n = t.getDocumentModifier();
14
+ let r = !1;
15
+ c(e, p) || (n.modifyCss(e).appendRule(a), r = !0), m(e) || (n.modifyCss(e).appendRule(d), r = !0), r && n.apply(new l("Add mobile layout CSS rules"));
16
+ }
17
+ export {
18
+ s as CSS_CLASS_DESKTOP_CONTAINER,
19
+ i as CSS_CLASS_MOBILE_CONTAINER,
20
+ S as ensureMobileCssRulesExist
21
+ };
@@ -1,13 +1,13 @@
1
- import { createPaddingsControl as n, createTextBackgroundColorControl as e, createTextFontFamilyControl as l, createTextStyleControl as C, createTextSizeControl as c, createTextColorControl as N, createTextAlignControl as a } from "../../../controlFactories.js";
1
+ import { createPaddingsControl as n, createTextBackgroundColorControl as e, createTextFontFamilyControl as l, createTextStyleControl as C, createTextSizeControl as c, createTextColorControl as a, createTextAlignControl as i } from "../../../controlFactories.js";
2
2
  import { RecommendationBlockId as o } from "../../constants/blockIds.js";
3
3
  import { RecommendationControlId as t } from "../../constants/controlIds.js";
4
- import { CONTAINER_SELECTOR as r } from "../../constants/selectors.js";
5
- import { NameTextTrimControl as i } from "./textTrim.js";
6
- const m = a(
4
+ import { BLOCK_ROOT_SELECTOR as r } from "../../constants/selectors.js";
5
+ import { NameTextTrimControl as m } from "./textTrim.js";
6
+ const A = i(
7
7
  t.NAME_ALIGN,
8
8
  o.NAME,
9
9
  r
10
- ), A = N(
10
+ ), N = a(
11
11
  t.NAME_COLOR,
12
12
  o.NAME,
13
13
  r
@@ -31,16 +31,16 @@ const m = a(
31
31
  t.NAME_PADDINGS,
32
32
  o.NAME,
33
33
  r
34
- ), F = {
35
- align: m,
36
- color: A,
34
+ ), p = {
35
+ align: A,
36
+ color: N,
37
37
  size: E,
38
38
  style: M,
39
39
  fontFamily: s,
40
40
  background: d,
41
41
  paddings: T,
42
- textTrim: i
42
+ textTrim: m
43
43
  };
44
44
  export {
45
- F as NameControls
45
+ p as NameControls
46
46
  };