@useinsider/guido 2.1.0-beta.9ba2e9d → 2.1.0-beta.9ed76a4

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 (65) 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/header/HeaderWrapper.vue.js +9 -9
  6. package/dist/composables/useBlocksConfig.js +26 -16
  7. package/dist/composables/useHtmlValidator.js +107 -119
  8. package/dist/composables/useStripo.js +25 -23
  9. package/dist/composables/useVersionHistoryApi.js +1 -1
  10. package/dist/config/compiler/utils/recommendationCompilerUtils.js +70 -96
  11. package/dist/config/i18n/en/index.js +11 -0
  12. package/dist/config/i18n/en/labels.json.js +7 -0
  13. package/dist/config/i18n/en/toasters.json.js +56 -0
  14. package/dist/config/i18n/en/tooltips.json.js +82 -0
  15. package/dist/config/i18n/index.js +7 -0
  16. package/dist/config/migrator/itemsBlockMigrator.js +101 -97
  17. package/dist/enums/defaults.js +8 -4
  18. package/dist/enums/extensions/recommendationBlock.js +1 -1
  19. package/dist/extensions/Blocks/Recommendation/block.js +26 -23
  20. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +27 -26
  21. package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
  22. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
  23. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -70
  24. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +87 -37
  25. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
  26. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  27. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +117 -107
  28. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
  29. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
  30. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
  31. package/dist/extensions/Blocks/Recommendation/templates/utils.js +43 -31
  32. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  33. package/dist/guido.css +1 -1
  34. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
  35. package/dist/services/recommendationApi.js +11 -9
  36. package/dist/services/stripoApi.js +20 -17
  37. package/dist/src/@types/config/schemas.d.ts +8 -0
  38. package/dist/src/composables/useConfig.d.ts +4 -0
  39. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  40. package/dist/src/config/i18n/en/index.d.ts +1 -0
  41. package/dist/src/config/i18n/index.d.ts +16 -0
  42. package/dist/src/enums/defaults.d.ts +4 -0
  43. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  44. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
  45. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
  46. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -1
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
  48. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
  49. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  50. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -0
  51. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
  53. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -3
  54. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  55. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  56. package/dist/src/stores/config.d.ts +36 -0
  57. package/dist/static/styles/components/notification.css.js +19 -0
  58. package/dist/static/styles/components/tools.css.js +6 -2
  59. package/dist/static/styles/components/version-history.css.js +10 -2
  60. package/dist/static/styles/components/wide-panel.css.js +18 -2
  61. package/dist/static/styles/customEditorStyle.css.js +10 -9
  62. package/dist/static/styles/variables.css.js +2 -0
  63. package/dist/static/templates/empty/index.html.js +74 -0
  64. package/dist/static/templates/empty/style.css.js +779 -0
  65. package/package.json +1 -1
@@ -1,45 +1,60 @@
1
- var d = Object.defineProperty;
2
- var a = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var n = (i, e, t) => a(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommonControl as c } from "../../../common-control.js";
5
- import { MAX_PRODUCT_COUNT as _, MAX_PRODUCTS_PER_ROW as h } from "../../constants/layout.js";
6
- import { RecommendationConfigService as r } from "../../services/configService.js";
7
- import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
8
- import { getCurrentLayout as C, regenerateProductRowsWithStyles as p } from "./utils.js";
9
- import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
10
- const l = "recommendation-product-layout-control", o = {
1
+ var _ = Object.defineProperty;
2
+ var c = (i, o, t) => o in i ? _(i, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[o] = t;
3
+ var d = (i, o, t) => c(i, typeof o != "symbol" ? o + "" : o, t);
4
+ import { EditorStatePropertyType as u, PreviewDeviceMode as R } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
+ import { MAX_PRODUCT_COUNT as C, MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
7
+ import { RecommendationConfigService as s } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
9
+ import { ensureMobileCssRulesExist as O } from "../mobileLayout/cssRules.js";
10
+ import { getCurrentLayout as I, regenerateMobileProductRows as g, regenerateProductRowsWithStyles as b } from "./utils.js";
11
+ import { useDebounceFn as N } from "../../../../../node_modules/@vueuse/shared/index.js";
12
+ const P = "recommendation-product-layout-control", e = {
11
13
  PRODUCT_COUNT: "size",
12
14
  PRODUCT_IN_ROW: "cardsInRow",
13
- PRODUCT_IN_ROW_LABEL: "cardsInRowLabel"
15
+ PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
16
+ MOBILE_CARDS_IN_ROW: "mobileCardsInRow",
17
+ MOBILE_CARDS_IN_ROW_LABEL: "mobileCardsInRowLabel"
14
18
  };
15
- class I extends c {
19
+ class S extends h {
16
20
  constructor() {
17
21
  super(...arguments);
18
22
  // Store is used for backward compatibility with product fetching and regeneration
19
- n(this, "store", R());
20
- n(this, "storeUnsubscription", () => {
23
+ d(this, "store", l());
24
+ d(this, "storeUnsubscription", () => {
21
25
  });
22
- n(this, "_debouncedRegenerateProductRows", m(() => {
26
+ d(this, "_debouncedRegenerateProductRows", N(() => {
23
27
  this._regenerateProductRows();
24
28
  }, 500));
25
29
  }
26
30
  getId() {
27
- return l;
31
+ return P;
28
32
  }
29
33
  getTemplate() {
30
34
  return `
31
35
  <div class="product-layout-control-container">
32
36
  ${this._GuTwoColumns([
33
37
  this._GuLabel({ text: "Number of Products" }),
34
- this._GuCounter({ name: o.PRODUCT_COUNT, maxValue: _ }),
35
- this._GuLabel({ text: "Products in One Row", name: o.PRODUCT_IN_ROW_LABEL }),
36
- this._GuCounter({ name: o.PRODUCT_IN_ROW, maxValue: h })
38
+ this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: C }),
39
+ this._GuLabel({
40
+ text: "Products in One Row on Desktop",
41
+ name: e.PRODUCT_IN_ROW_LABEL
42
+ }),
43
+ this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: p }),
44
+ this._GuLabel({
45
+ text: "Products in One Row on Mobile",
46
+ name: e.MOBILE_CARDS_IN_ROW_LABEL
47
+ }),
48
+ this._GuCounter({
49
+ name: e.MOBILE_CARDS_IN_ROW,
50
+ maxValue: m
51
+ })
37
52
  ])}
38
53
  </div>
39
54
  `;
40
55
  }
41
56
  onRender() {
42
- this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates();
57
+ this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._subscribeToEditorModeChanges();
43
58
  }
44
59
  onTemplateNodeUpdated(t) {
45
60
  super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
@@ -48,23 +63,45 @@ class I extends c {
48
63
  this.storeUnsubscription();
49
64
  }
50
65
  _setFormValues() {
51
- const t = r.getConfig(this.currentNode);
66
+ const t = s.getConfig(this.currentNode);
52
67
  this.api.updateValues({
53
- [o.PRODUCT_COUNT]: t.size,
54
- [o.PRODUCT_IN_ROW]: t.cardsInRow
68
+ [e.PRODUCT_COUNT]: t.size,
69
+ [e.PRODUCT_IN_ROW]: t.cardsInRow,
70
+ [e.MOBILE_CARDS_IN_ROW]: t.mobileCardsInRow
55
71
  });
56
72
  }
57
73
  /**
58
- * Updates "Products in One Row" visibility based on layout orientation
59
- * This control is hidden for list layout (products always take full width)
60
- * Reads from node config first, falls back to DOM
74
+ * Checks if the editor is currently in mobile preview mode
75
+ * using Stripo's EditorStatePropertyType API.
76
+ */
77
+ _isMobileMode() {
78
+ return this.api.getEditorState()[u.previewDeviceMode] === R.MOBILE;
79
+ }
80
+ /**
81
+ * Updates counter visibility based on layout orientation and editor mode.
82
+ * - List layout: hide both counters (products always full-width)
83
+ * - Grid + desktop mode: show desktop counter, hide mobile counter
84
+ * - Grid + mobile mode: show mobile counter, hide desktop counter
61
85
  */
62
86
  _updateProductsInRowVisibility() {
63
- const u = (r.getConfig(this.currentNode).layout || C(this.currentNode)) === "grid";
64
- this.api.setVisibility(o.PRODUCT_IN_ROW, u), this.api.setVisibility(o.PRODUCT_IN_ROW_LABEL, u);
87
+ const r = (s.getConfig(this.currentNode).layout || I(this.currentNode)) === "grid", n = this._isMobileMode();
88
+ this.api.setVisibility(e.PRODUCT_IN_ROW, r && !n), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, r && !n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, r && n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, r && n);
89
+ }
90
+ /**
91
+ * Subscribes to editor preview mode changes via Stripo API.
92
+ * When the user switches between desktop/mobile preview, toggles
93
+ * which "Products in One Row" counter is visible.
94
+ */
95
+ _subscribeToEditorModeChanges() {
96
+ this.api.onEditorStatePropUpdated(
97
+ u.previewDeviceMode,
98
+ () => {
99
+ this._updateProductsInRowVisibility();
100
+ }
101
+ );
65
102
  }
66
103
  _onProductCountChange(t) {
67
- this.currentNode && (r.updateConfig(
104
+ this.currentNode && (s.updateConfig(
68
105
  this.api,
69
106
  this.currentNode,
70
107
  { size: t },
@@ -72,24 +109,37 @@ class I extends c {
72
109
  ), this.store.patchCurrentBlockConfig({ size: t }), this._debouncedRegenerateProductRows());
73
110
  }
74
111
  _onProductsInRowChange(t) {
75
- this.currentNode && (r.updateConfig(
112
+ this.currentNode && (s.updateConfig(
76
113
  this.api,
77
114
  this.currentNode,
78
115
  { cardsInRow: t },
79
116
  `Changed products per row to ${t}`
80
117
  ), this.store.patchCurrentBlockConfig({ cardsInRow: t }), this._debouncedRegenerateProductRows());
81
118
  }
119
+ _onMobileCardsInRowChange(t) {
120
+ this.currentNode && (s.updateConfig(
121
+ this.api,
122
+ this.currentNode,
123
+ { mobileCardsInRow: t },
124
+ `Changed mobile products per row to ${t}`
125
+ ), O(this.api), g({
126
+ currentNode: this.currentNode,
127
+ documentModifier: this.api.getDocumentModifier()
128
+ }));
129
+ }
82
130
  _regenerateProductRows() {
83
- p({
131
+ b({
84
132
  currentNode: this.currentNode,
85
133
  documentModifier: this.api.getDocumentModifier()
86
134
  });
87
135
  }
88
136
  _listenToFormUpdates() {
89
- this.api.onValueChanged(o.PRODUCT_COUNT, (t) => {
137
+ this.api.onValueChanged(e.PRODUCT_COUNT, (t) => {
90
138
  this._onProductCountChange(t.toString());
91
- }), this.api.onValueChanged(o.PRODUCT_IN_ROW, (t) => {
139
+ }), this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
92
140
  this._onProductsInRowChange(Number(t));
141
+ }), this.api.onValueChanged(e.MOBILE_CARDS_IN_ROW, (t) => {
142
+ this._onMobileCardsInRowChange(Number(t));
93
143
  });
94
144
  }
95
145
  /**
@@ -99,12 +149,12 @@ class I extends c {
99
149
  _listenStateUpdates() {
100
150
  let t = this.store.recommendationConfigs.orientation;
101
151
  this.storeUnsubscription = this.store.$subscribe(() => {
102
- const s = this.store.recommendationConfigs.orientation;
103
- s !== t && (t = s, this._updateProductsInRowVisibility());
152
+ const a = this.store.recommendationConfigs.orientation;
153
+ a !== t && (t = a, this._updateProductsInRowVisibility());
104
154
  });
105
155
  }
106
156
  }
107
157
  export {
108
- l as PRODUCT_LAYOUT_CONTROL_ID,
109
- I as ProductLayoutControl
158
+ P as PRODUCT_LAYOUT_CONTROL_ID,
159
+ S as ProductLayoutControl
110
160
  };
@@ -1,37 +1,38 @@
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";
1
+ import { ModificationDescription as S } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RecommendationBlockId as m } from "../../constants/blockIds.js";
3
+ import { CURRENCY_ATTR as y, MOBILE_CONTAINER_SELECTOR as T, DESKTOP_CONTAINER_SELECTOR as w, CONTAINER_SELECTOR as _ } from "../../constants/selectors.js";
4
+ import { RecommendationConfigService as k } from "../../services/configService.js";
5
+ import { useRecommendationExtensionStore as b } from "../../store/recommendation.js";
5
6
  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) {
7
+ import { formatPrice as D } from "../../utils/priceFormatter.js";
8
+ import { isTdNode as L } from "../../utils/tagName.js";
9
+ import { sanitizeImageUrl as U, getDefaultProducts as H, DEFAULT_CARD_COMPOSITION as C } from "../../templates/utils.js";
10
+ const q = "ins-recommendation-v3-block-v2";
11
+ function E(o) {
11
12
  if (!o)
12
13
  return null;
13
14
  if ("getAttribute" in o) {
14
15
  const e = o.getAttribute("class");
15
- if (e && e.includes(C))
16
+ if (e && e.includes(q))
16
17
  return o;
17
18
  }
18
- return "querySelector" in o ? o.querySelector(`.${C}`) : null;
19
+ return "querySelector" in o ? o.querySelector(`.${q}`) : null;
19
20
  }
20
- function q(o) {
21
- const e = b(o);
21
+ function P(o) {
22
+ const e = E(o);
22
23
  if (!e || !("getAttribute" in e))
23
24
  return "grid";
24
25
  const t = e.getAttribute("data-layout");
25
26
  return t === "list" || t === "horizontal" ? "list" : "grid";
26
27
  }
27
- function D(o) {
28
- const e = b(o);
28
+ function N(o) {
29
+ const e = E(o);
29
30
  if (!e || !("getAttribute" in e))
30
- return P;
31
+ return C;
31
32
  const t = e.getAttribute("data-card-composition");
32
- return t ? t.split(",").filter(Boolean) : P;
33
+ return t ? t.split(",").filter(Boolean) : C;
33
34
  }
34
- function S(o, e, t) {
35
+ function g(o, e, t) {
35
36
  if (!e || !("childNodes" in e))
36
37
  return !1;
37
38
  const n = e.childNodes().find(
@@ -39,23 +40,42 @@ function S(o, e, t) {
39
40
  );
40
41
  return n ? (o.modifyHtml(n).setText(t), !0) : !1;
41
42
  }
42
- function w(o, e) {
43
- return o && o.length > 0 ? o : e.length > 0 ? e : _();
43
+ function h(o, e) {
44
+ return o && o.length > 0 ? o : e.length > 0 ? e : H();
44
45
  }
45
- function U(o) {
46
- const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
46
+ function $(o) {
47
+ const { currentNode: e, documentModifier: t, products: r, layout: n } = o;
48
+ if (!e || !("querySelector" in e))
49
+ return;
50
+ const i = e.querySelector(T);
51
+ if (!i)
52
+ return;
53
+ const c = b(), u = k.getConfig(e), l = h(r, c.recommendationProducts), s = N(e), d = n ?? P(e), a = R(l, d, {
54
+ productsPerRow: u.mobileCardsInRow,
55
+ composition: s
56
+ });
57
+ t.modifyHtml(i).setInnerHtml(a).apply(new S("Updated mobile product rows"));
58
+ }
59
+ function x(o) {
60
+ const {
61
+ currentNode: e,
62
+ documentModifier: t,
63
+ afterRegenerate: r,
64
+ products: n,
65
+ layout: i
66
+ } = o;
47
67
  if (!e || !("querySelector" in e))
48
68
  return;
49
- const c = e.querySelector(I);
69
+ const c = e.querySelector(w) ?? e.querySelector(_);
50
70
  if (!c)
51
71
  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,
72
+ const u = b(), l = h(n, u.recommendationProducts), { cardsInRow: s } = u.recommendationConfigs, d = N(e), a = i ?? P(e), p = R(l, a, {
73
+ productsPerRow: s,
54
74
  composition: d
55
75
  });
56
- t.modifyHtml(c).setInnerHtml(p).apply(new g("Updated product")), r == null || r();
76
+ t.modifyHtml(c).setInnerHtml(p).apply(new S("Updated product")), $(o), r == null || r();
57
77
  }
58
- function $(o, e, t, r) {
78
+ function B(o, e, t, r) {
59
79
  const i = `0 ${Math.floor(t / 2)}px`;
60
80
  let c = !1;
61
81
  return r === "grid" ? Array.from(
@@ -65,29 +85,29 @@ function $(o, e, t, r) {
65
85
  }) : Array.from(
66
86
  o.querySelectorAll(".product-card-wrapper")
67
87
  ).forEach((l) => {
68
- const u = "parentNode" in l ? l.parentNode : null;
69
- u && T(u) && (e.modifyHtml(u).setStyle("padding", i), c = !0);
88
+ const s = "parentNode" in l ? l.parentNode : null;
89
+ s && L(s) && (e.modifyHtml(s).setStyle("padding", i), c = !0);
70
90
  }), c;
71
91
  }
72
- function L(o, e, t) {
92
+ function v(o, e, t) {
73
93
  const r = `${t}px`, n = Array.from(o.querySelectorAll(".spacer"));
74
94
  let i = !1;
75
95
  return n.forEach((c) => {
76
96
  e.modifyHtml(c).setStyle("height", r), i = !0;
77
97
  }), i;
78
98
  }
79
- function H(o) {
99
+ function V(o) {
80
100
  const { currentNode: e, documentModifier: t } = o;
81
101
  if (!e)
82
102
  return;
83
- const r = b(e);
103
+ const r = E(e);
84
104
  if (!r || !("getAttribute" in r))
85
105
  return;
86
- const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c = q(e);
87
- let s = !1;
106
+ const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c = P(e);
107
+ let u = !1;
88
108
  if (n) {
89
109
  const l = parseInt(n);
90
- Number.isNaN(l) || (s = $(
110
+ Number.isNaN(l) || (u = B(
91
111
  e,
92
112
  t,
93
113
  l,
@@ -97,28 +117,28 @@ function H(o) {
97
117
  if (i) {
98
118
  const l = parseInt(i);
99
119
  if (!Number.isNaN(l)) {
100
- const u = L(e, t, l);
101
- s = s || u;
120
+ const s = v(e, t, l);
121
+ u = u || s;
102
122
  }
103
123
  }
104
- s && t.apply(new g("Reapply spacing after regeneration"));
124
+ u && t.apply(new S("Reapply spacing after regeneration"));
105
125
  }
106
- function K(o) {
126
+ function ee(o) {
107
127
  const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
108
- e && U({
128
+ e && x({
109
129
  currentNode: e,
110
130
  documentModifier: t,
111
131
  products: n,
112
132
  layout: i,
113
133
  afterRegenerate: () => {
114
134
  setTimeout(() => {
115
- H({ currentNode: e, documentModifier: t });
135
+ V({ currentNode: e, documentModifier: t });
116
136
  }, 0), r == null || r();
117
137
  }
118
138
  });
119
139
  }
120
- function h() {
121
- const o = A(), { currencySettings: e } = o.recommendationConfigs;
140
+ function M() {
141
+ const o = b(), { currencySettings: e } = o.recommendationConfigs;
122
142
  return {
123
143
  code: e.value,
124
144
  symbol: e.symbol,
@@ -128,40 +148,40 @@ function h() {
128
148
  thousandSeparator: e.thousandSeparator
129
149
  };
130
150
  }
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({
151
+ function A(o, e = "price") {
152
+ const t = M(), r = o[e], n = (r == null ? void 0 : r[t.code]) ?? Object.values(r ?? {})[0] ?? 0;
153
+ return D({
134
154
  price: n,
135
155
  currency: t
136
156
  });
137
157
  }
138
- function x(o) {
158
+ function j(o) {
139
159
  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;
160
+ const e = M(), 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
161
  return n > 0 ? `-${n}%` : "0%";
142
162
  }
143
- function N(o) {
163
+ function I(o) {
144
164
  const { documentModifier: e, product: t, priceEl: r, oldPriceEl: n, omnibusPriceEl: i, omnibusDiscountEl: c } = o;
145
- let s = !1;
165
+ let u = !1;
146
166
  if (r && "querySelector" in r) {
147
- const l = r.querySelector("strong"), u = E(t, "price");
148
- S(e, l, u) && (s = !0);
167
+ const l = r.querySelector("strong"), s = A(t, "price");
168
+ g(e, l, s) && (u = !0);
149
169
  }
150
170
  if (n && "querySelector" in n) {
151
- const l = n.querySelector("strong"), u = E(t, "original_price");
152
- S(e, l, u) && (s = !0);
171
+ const l = n.querySelector("strong"), s = A(t, "original_price");
172
+ g(e, l, s) && (u = !0);
153
173
  }
154
174
  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);
175
+ const l = i.querySelector(".omnibus-price-value"), s = A(t, "original_price");
176
+ g(e, l, s) && (u = !0);
157
177
  }
158
178
  if (c && "querySelector" in c) {
159
- const l = c.querySelector(".omnibus-discount-value"), u = x(t);
160
- S(e, l, u) && (s = !0);
179
+ const l = c.querySelector(".omnibus-discount-value"), s = j(t);
180
+ g(e, l, s) && (u = !0);
161
181
  }
162
- return s;
182
+ return u;
163
183
  }
164
- function B(o) {
184
+ function W(o) {
165
185
  const {
166
186
  documentModifier: e,
167
187
  product: t,
@@ -169,118 +189,119 @@ function B(o) {
169
189
  nameEl: n,
170
190
  priceEl: i,
171
191
  oldPriceEl: c,
172
- omnibusPriceEl: s,
192
+ omnibusPriceEl: u,
173
193
  omnibusDiscountEl: l,
174
- buttonEl: u
194
+ buttonEl: s
175
195
  } = o;
176
196
  let d = !1;
177
197
  if (r && "querySelector" in r) {
178
198
  const a = r.querySelector("img");
179
- a && (e.modifyHtml(a).setAttribute("src", k(t.image_url)).setAttribute("alt", t.name), d = !0);
199
+ a && (e.modifyHtml(a).setAttribute("src", U(t.image_url)).setAttribute("alt", t.name), d = !0);
180
200
  const p = r.querySelector("a");
181
201
  p && (e.modifyHtml(p).setAttribute("href", t.url), d = !0);
182
202
  }
183
203
  if (n && "querySelector" in n) {
184
204
  const a = n.querySelector("strong");
185
- S(e, a, t.name) && (d = !0);
205
+ g(e, a, t.name) && (d = !0);
186
206
  }
187
- if (N({
207
+ if (I({
188
208
  documentModifier: e,
189
209
  product: t,
190
210
  priceEl: i,
191
211
  oldPriceEl: c,
192
- omnibusPriceEl: s,
212
+ omnibusPriceEl: u,
193
213
  omnibusDiscountEl: l
194
- }) && (d = !0), u && "querySelector" in u) {
195
- const a = u.querySelector("a.es-button") || u.querySelector("a");
214
+ }) && (d = !0), s && "querySelector" in s) {
215
+ const a = s.querySelector("a.es-button") || s.querySelector("a");
196
216
  a && (e.modifyHtml(a).setAttribute("href", t.url), d = !0);
197
217
  }
198
218
  return d;
199
219
  }
200
- function J(o) {
220
+ function te(o) {
201
221
  const { currentNode: e, documentModifier: t, products: r } = o;
202
222
  if (!e || !("querySelectorAll" in e))
203
223
  return !1;
204
224
  const n = e.querySelectorAll(
205
- `[esd-extension-block-id="${f.IMAGE}"]`
225
+ `[esd-extension-block-id="${m.IMAGE}"]`
206
226
  ), i = e.querySelectorAll(
207
- `[esd-extension-block-id="${f.NAME}"]`
227
+ `[esd-extension-block-id="${m.NAME}"]`
208
228
  ), 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}"]`
229
+ `[esd-extension-block-id="${m.PRICE}"]`
214
230
  ), u = e.querySelectorAll(
215
- `[esd-extension-block-id="${f.OMNIBUS_DISCOUNT}"]`
231
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
232
+ ), l = e.querySelectorAll(
233
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
234
+ ), s = e.querySelectorAll(
235
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
216
236
  ), d = e.querySelectorAll(
217
- `[esd-extension-block-id="${f.BUTTON}"]`
237
+ `[esd-extension-block-id="${m.BUTTON}"]`
218
238
  );
219
239
  if (n.length !== r.length)
220
240
  return !1;
221
241
  let a = !1;
222
- return r.forEach((p, m) => {
223
- const M = B({
242
+ return r.forEach((p, f) => {
243
+ const O = W({
224
244
  documentModifier: t,
225
245
  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
246
+ imageEl: n[f] ?? null,
247
+ nameEl: i[f] ?? null,
248
+ priceEl: c[f] ?? null,
249
+ oldPriceEl: u[f] ?? null,
250
+ omnibusPriceEl: l[f] ?? null,
251
+ omnibusDiscountEl: s[f] ?? null,
252
+ buttonEl: d[f] ?? null
233
253
  });
234
- a = a || M;
235
- }), a && t.apply(new g("Updated product content in-place")), !0;
254
+ a = a || O;
255
+ }), a && t.apply(new S("Updated product content in-place")), !0;
236
256
  }
237
- function Q(o) {
257
+ function oe(o) {
238
258
  const { currentNode: e, documentModifier: t } = o;
239
259
  if (!e || !("querySelectorAll" in e))
240
260
  return !1;
241
- const n = A().recommendationProducts;
261
+ const n = b().recommendationProducts;
242
262
  if (n.length === 0)
243
263
  return !1;
244
264
  const i = e.querySelectorAll(
245
- `[esd-extension-block-id="${f.PRICE}"]`
265
+ `[esd-extension-block-id="${m.PRICE}"]`
246
266
  ), c = e.querySelectorAll(
247
- `[esd-extension-block-id="${f.OLD_PRICE}"]`
248
- ), s = e.querySelectorAll(
249
- `[esd-extension-block-id="${f.OMNIBUS_PRICE}"]`
267
+ `[esd-extension-block-id="${m.OLD_PRICE}"]`
268
+ ), u = e.querySelectorAll(
269
+ `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
250
270
  ), l = e.querySelectorAll(
251
- `[esd-extension-block-id="${f.OMNIBUS_DISCOUNT}"]`
271
+ `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
252
272
  );
253
- let u = !1;
273
+ let s = !1;
254
274
  return n.forEach((d, a) => {
255
- N({
275
+ I({
256
276
  documentModifier: t,
257
277
  product: d,
258
278
  priceEl: i[a] ?? null,
259
279
  oldPriceEl: c[a] ?? null,
260
- omnibusPriceEl: s[a] ?? null,
280
+ omnibusPriceEl: u[a] ?? null,
261
281
  omnibusDiscountEl: l[a] ?? null
262
- }) && (u = !0);
263
- }), u && t.apply(new g("Updated price formatting in-place")), u;
282
+ }) && (s = !0);
283
+ }), s && t.apply(new S("Updated price formatting in-place")), s;
264
284
  }
265
- function X(o) {
266
- const { currentNode: e, documentModifier: t, currency: r } = o, n = b(e);
285
+ function re(o) {
286
+ const { currentNode: e, documentModifier: t, currency: r } = o, n = E(e);
267
287
  if (!n)
268
288
  return;
269
- const i = r.alignment === "before" ? "0" : "1", c = (s, l) => {
270
- t.modifyHtml(n).setAttribute(s, l);
289
+ const i = r.alignment === "before" ? "0" : "1", c = (u, l) => {
290
+ t.modifyHtml(n).setAttribute(u, l);
271
291
  };
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"));
292
+ 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 S("Update currency attributes"));
273
293
  }
274
294
  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
295
+ A as formatProductPrice,
296
+ E as getBlockElement,
297
+ N as getCardComposition,
298
+ P as getCurrentLayout,
299
+ V as reapplySpacing,
300
+ $ as regenerateMobileProductRows,
301
+ x as regenerateProductRows,
302
+ ee as regenerateProductRowsWithStyles,
303
+ re as setCurrencyAttributes,
304
+ oe as updatePricesInPlace,
305
+ te as updateProductContentInPlace,
306
+ W as updateSingleProductContent
286
307
  };
@@ -0,0 +1,21 @@
1
+ import { ModificationDescription as r } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ const i = "ins-recommendation-desktop-container", s = "ins-recommendation-mobile-container", l = `.${s} { display: none; }`, u = `@media only screen and (max-width: 480px) { .${i} { display: none !important; } .${s} { display: table !important; } }`, c = `.${s}`;
3
+ function a(o, e) {
4
+ return !!o.querySelector(e);
5
+ }
6
+ function d(o) {
7
+ return o.querySelectorAll(`*${i}`).length > 0;
8
+ }
9
+ function p(o) {
10
+ const e = o.getDocumentRootCssNode();
11
+ if (!e)
12
+ return;
13
+ const n = o.getDocumentModifier();
14
+ let t = !1;
15
+ a(e, c) || (n.modifyCss(e).appendRule(l), t = !0), d(e) || (n.modifyCss(e).appendRule(u), t = !0), t && n.apply(new r("Add mobile layout CSS rules"));
16
+ }
17
+ export {
18
+ i as CSS_CLASS_DESKTOP_CONTAINER,
19
+ s as CSS_CLASS_MOBILE_CONTAINER,
20
+ p as ensureMobileCssRulesExist
21
+ };