@useinsider/guido 3.2.0-beta.e01b42a → 3.2.0-beta.ec6228c

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 (109) hide show
  1. package/README.md +24 -0
  2. package/dist/@types/config/schemas.js +82 -68
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +92 -81
  5. package/dist/components/organisms/AutoSaveController.vue.js +17 -0
  6. package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
  9. package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
  10. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
  11. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  12. package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
  13. package/dist/components/organisms/header/RightSlot.vue.js +11 -11
  14. package/dist/components/organisms/header/RightSlot.vue2.js +17 -13
  15. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
  16. package/dist/composables/useActionsApi.js +4 -4
  17. package/dist/composables/useAutoSave.js +68 -0
  18. package/dist/composables/useFullStoryBridge.js +14 -0
  19. package/dist/composables/useHtmlCompiler.js +23 -21
  20. package/dist/composables/useHtmlValidator.js +40 -38
  21. package/dist/composables/usePreviewMode.js +20 -16
  22. package/dist/composables/useSave.js +23 -15
  23. package/dist/composables/useStripo.js +52 -47
  24. package/dist/composables/validators/useLiquidValidator.js +42 -0
  25. package/dist/config/compiler/liquidCompilerRules.js +15 -0
  26. package/dist/config/compiler/recommendationCompilerRules.js +162 -43
  27. package/dist/config/compiler/unsubscribeCompilerRules.js +37 -37
  28. package/dist/config/compiler/utils/recommendationCompilerUtils.js +52 -46
  29. package/dist/config/migrator/checkboxMigrator.js +5 -3
  30. package/dist/config/migrator/radioButtonMigrator.js +14 -12
  31. package/dist/config/migrator/recommendationMigrator.js +1 -1
  32. package/dist/enums/extensions/recommendationBlock.js +14 -11
  33. package/dist/enums/recommendation.js +2 -2
  34. package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
  35. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
  36. package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
  37. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  38. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  39. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  40. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
  41. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
  42. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -6
  43. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
  44. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +94 -92
  45. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
  46. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
  47. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +31 -31
  48. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
  49. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +29 -25
  50. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
  51. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  52. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  53. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
  54. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  55. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  56. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
  57. package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
  58. package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
  59. package/dist/guido.css +1 -1
  60. package/dist/package.json.js +1 -1
  61. package/dist/services/recommendationApi.js +15 -15
  62. package/dist/services/stripoApi.js +9 -9
  63. package/dist/services/templateLibraryApi.js +48 -46
  64. package/dist/src/@types/config/index.d.ts +1 -1
  65. package/dist/src/@types/config/schemas.d.ts +32 -0
  66. package/dist/src/@types/config/types.d.ts +3 -1
  67. package/dist/src/@types/generic.d.ts +0 -1
  68. package/dist/src/@types/save-as-template.d.ts +1 -0
  69. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
  70. package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
  71. package/dist/src/composables/useActionsApi.d.ts +1 -1
  72. package/dist/src/composables/useAutoSave.d.ts +3 -0
  73. package/dist/src/composables/useConfig.d.ts +14 -0
  74. package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
  75. package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
  76. package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
  77. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  78. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  79. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
  80. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
  81. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  82. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  83. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  84. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
  86. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
  87. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
  88. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  89. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  90. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  91. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +3 -3
  92. package/dist/src/services/templateLibraryApi.d.ts +1 -1
  93. package/dist/src/stores/autosave.d.ts +6 -0
  94. package/dist/src/stores/config.d.ts +126 -0
  95. package/dist/src/stores/preview.d.ts +3 -0
  96. package/dist/src/utils/genericUtil.d.ts +1 -1
  97. package/dist/src/utils/htmlCompiler.d.ts +2 -1
  98. package/dist/src/utils/timeUtil.d.ts +8 -0
  99. package/dist/static/styles/base.css.js +7 -2
  100. package/dist/static/styles/components/button.css.js +3 -2
  101. package/dist/static/styles/components/loader.css.js +4 -0
  102. package/dist/stores/autosave.js +11 -0
  103. package/dist/stores/preview.js +4 -3
  104. package/dist/utils/genericUtil.js +42 -20
  105. package/dist/utils/htmlCompiler.js +48 -41
  106. package/dist/utils/templatePreparation.js +36 -25
  107. package/dist/utils/timeUtil.js +19 -0
  108. package/dist/utils/tooltipUtils.js +4 -5
  109. package/package.json +3 -3
@@ -1,14 +1,15 @@
1
- import { ModificationDescription as a } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as d } from "../../../common-control.js";
3
- import { RecommendationBlockId as l } from "../../constants/blockIds.js";
4
- import { RecommendationControlId as m } from "../../constants/controlIds.js";
5
- import { BLOCK_ROOT_SELECTOR as u } from "../../constants/selectors.js";
6
- const i = {
1
+ import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as u } from "../../../common-control.js";
3
+ import { RecommendationBlockId as a } from "../../constants/blockIds.js";
4
+ import { RecommendationControlId as d } from "../../constants/controlIds.js";
5
+ import { BLOCK_ROOT_SELECTOR as m } from "../../constants/selectors.js";
6
+ import { CSS_CLASS_TEXT_TRIM as r, ensureTextTrimCssRulesExist as T } from "../shared/textTrimCssRules.js";
7
+ const s = {
7
8
  TEXT_TRIM_ENABLED: "textTrimEnabled"
8
- }, o = "text-trim-enabled", c = `.${o}`, T = `.${o} p`, p = `.${o} { max-width: 0; }`, _ = `.${o} p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; display: block; }`;
9
- class N extends d {
9
+ };
10
+ class N extends u {
10
11
  getId() {
11
- return m.NAME_TEXT_TRIM;
12
+ return d.NAME_TEXT_TRIM;
12
13
  }
13
14
  getTemplate() {
14
15
  return `
@@ -16,7 +17,7 @@ class N extends d {
16
17
  <div class="name-text-trim-control-container">
17
18
  ${this._GuTwoColumns([
18
19
  this._GuLabel({ text: this.api.translate("Trim Long Text") }),
19
- this._GuToggle(i.TEXT_TRIM_ENABLED)
20
+ this._GuToggle(s.TEXT_TRIM_ENABLED)
20
21
  ])}
21
22
  </div>
22
23
  `;
@@ -30,76 +31,45 @@ class N extends d {
30
31
  _setFormValues() {
31
32
  const e = this._getCurrentTrimState();
32
33
  this.api.updateValues({
33
- [i.TEXT_TRIM_ENABLED]: e
34
+ [s.TEXT_TRIM_ENABLED]: e
34
35
  });
35
36
  }
36
37
  _getCurrentTrimState() {
37
38
  if (!this.currentNode || !("hasClass" in this.currentNode))
38
39
  return !1;
39
- if (this.currentNode.hasClass(o))
40
+ if (this.currentNode.hasClass(r))
40
41
  return !0;
41
- const e = this.currentNode.closest(u);
42
+ const e = this.currentNode.closest(m);
42
43
  if (!e)
43
44
  return !1;
44
45
  const t = e.querySelector(
45
- `[esd-extension-block-id="${l.NAME}"]`
46
+ `[esd-extension-block-id="${a.NAME}"]`
46
47
  );
47
- return t && "hasClass" in t ? t.hasClass(o) : !1;
48
- }
49
- /**
50
- * Finds an existing CSS rule in the document stylesheet by exact query
51
- * @param query - The CSS query to search for (uses Stripo's CSS query syntax)
52
- * @returns The CSS rule node if found, undefined otherwise
53
- */
54
- _findCssRule(e) {
55
- const t = this.api.getDocumentRootCssNode();
56
- if (t)
57
- return t.querySelector(e);
58
- }
59
- /**
60
- * Finds the .text-trim-enabled p rule by searching all text-trim rules and comparing selectors
61
- * This is needed because Stripo's CSS query syntax interprets spaces as path separators
62
- * @returns true if the rule exists
63
- */
64
- _hasParagraphRule() {
65
- const e = this.api.getDocumentRootCssNode();
66
- return e ? e.querySelectorAll(`*${o}`).some((s) => "getSelector" in s && typeof s.getSelector == "function" ? s.getSelector() === T : !1) : !1;
67
- }
68
- /**
69
- * Ensures the text-trim CSS rules exist in the document stylesheet
70
- * Only adds rules if they don't already exist (prevents duplicates across multiple blocks)
71
- */
72
- _ensureCssRulesExist() {
73
- const e = this.api.getDocumentRootCssNode();
74
- if (!e)
75
- return;
76
- const t = this.api.getDocumentModifier();
77
- let s = !1;
78
- this._findCssRule(c) || (t.modifyCss(e).appendRule(p), s = !0), this._hasParagraphRule() || (t.modifyCss(e).appendRule(_), s = !0), s && t.apply(new a("Add text trim CSS rules"));
48
+ return t && "hasClass" in t ? t.hasClass(r) : !1;
79
49
  }
80
50
  _onTextTrimChange(e) {
81
51
  if (!this.currentNode || !("closest" in this.currentNode))
82
52
  return;
83
- const t = this.currentNode.closest(u);
53
+ const t = this.currentNode.closest(m);
84
54
  if (!t || !("querySelectorAll" in t))
85
55
  return;
86
- const s = Array.from(
87
- t.querySelectorAll(`[esd-extension-block-id="${l.NAME}"]`)
56
+ const i = Array.from(
57
+ t.querySelectorAll(`[esd-extension-block-id="${a.NAME}"]`)
88
58
  );
89
- if (!s.length)
59
+ if (!i.length)
90
60
  return;
91
- e && this._ensureCssRulesExist();
92
- const r = this.api.getDocumentModifier();
93
- s.forEach((n) => {
94
- e ? r.modifyHtml(n).setClass(o) : r.modifyHtml(n).removeClass(o);
95
- }), r.apply(
96
- new a(
61
+ e && T(this.api);
62
+ const o = this.api.getDocumentModifier();
63
+ i.forEach((n) => {
64
+ e ? o.modifyHtml(n).setClass(r) : o.modifyHtml(n).removeClass(r);
65
+ }), o.apply(
66
+ new l(
97
67
  e ? "Enable product name text trimming" : "Disable product name text trimming"
98
68
  )
99
69
  );
100
70
  }
101
71
  _listenToFormUpdates() {
102
- this.api.onValueChanged(i.TEXT_TRIM_ENABLED, (e) => {
72
+ this.api.onValueChanged(s.TEXT_TRIM_ENABLED, (e) => {
103
73
  this._onTextTrimChange(e);
104
74
  });
105
75
  }
@@ -0,0 +1,14 @@
1
+ import { ModificationDescription as r } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ const t = "text-trim-enabled", l = `.${t}`, c = `.${t} p`, S = `.${t} { max-width: 0; }`, T = `.${t} p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; display: block; }`;
3
+ function f(n) {
4
+ const e = n.getDocumentRootCssNode();
5
+ if (!e)
6
+ return;
7
+ const o = n.getDocumentModifier();
8
+ let i = !1;
9
+ e.querySelector(l) || (o.modifyCss(e).appendRule(S), i = !0), e.querySelectorAll(`*${t}`).some((s) => "getSelector" in s && typeof s.getSelector == "function" && s.getSelector() === c) || (o.modifyCss(e).appendRule(T), i = !0), i && o.apply(new r("Add text trim CSS rules"));
10
+ }
11
+ export {
12
+ t as CSS_CLASS_TEXT_TRIM,
13
+ f as ensureTextTrimCssRulesExist
14
+ };
@@ -1,13 +1,13 @@
1
- var P = Object.defineProperty;
2
- var R = (l, s, t) => s in l ? P(l, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[s] = t;
3
- var C = (l, s, t) => R(l, typeof s != "symbol" ? s + "" : s, t);
1
+ var G = Object.defineProperty;
2
+ var P = (u, s, t) => s in u ? G(u, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[s] = t;
3
+ var C = (u, s, t) => P(u, typeof s != "symbol" ? s + "" : s, t);
4
4
  import { ModificationDescription as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as w } from "../../../common-control.js";
6
- import { DESKTOP_CONTAINER_SELECTOR as S, MOBILE_CONTAINER_SELECTOR as E } from "../../constants/selectors.js";
7
- import { SPACING_STEP as _, MAX_SPACING as N, MIN_SPACING as b, DEFAULT_COLUMN_SPACING as g, DEFAULT_ROW_SPACING as G } from "../../constants/layout.js";
5
+ import { CommonControl as R } from "../../../common-control.js";
6
+ import { DESKTOP_CONTAINER_SELECTOR as S, MOBILE_CONTAINER_SELECTOR as M } from "../../constants/selectors.js";
7
+ import { SPACING_STEP as _, MAX_SPACING as N, MIN_SPACING as b, DEFAULT_COLUMN_SPACING as g, DEFAULT_ROW_SPACING as E } from "../../constants/layout.js";
8
8
  import { RecommendationConfigService as p } from "../../services/configService.js";
9
- import { useRecommendationExtensionStore as V } from "../../store/recommendation.js";
10
- import { safeGetStyle as L, safeGetParent as I } from "../../utils/tagName.js";
9
+ import { useRecommendationExtensionStore as w } from "../../store/recommendation.js";
10
+ import { safeGetStyle as L, safeGetParent as V } from "../../utils/tagName.js";
11
11
  import { getCurrentLayout as f, getBlockElement as B } from "../main/utils.js";
12
12
  import { useDebounceFn as O } from "../../../../../node_modules/@vueuse/shared/index.js";
13
13
  const U = "recommendation-spacing-control", n = {
@@ -25,16 +25,16 @@ const U = "recommendation-spacing-control", n = {
25
25
  MOBILE_COLUMN_SPACING: "data-mobile-column-spacing",
26
26
  MOBILE_ROW_SPACING: "data-mobile-row-spacing"
27
27
  };
28
- function y(l, s) {
29
- if (!l)
28
+ function I(u, s) {
29
+ if (!u)
30
30
  return s;
31
- const t = parseFloat(l);
31
+ const t = parseFloat(u);
32
32
  return Number.isNaN(t) ? s : t;
33
33
  }
34
- class j extends w {
34
+ class j extends R {
35
35
  constructor() {
36
36
  super(...arguments);
37
- C(this, "store", V());
37
+ C(this, "store", w());
38
38
  C(this, "unsubscribeOrientation", null);
39
39
  /**
40
40
  * Debounced version of _onColumnSpacingChange
@@ -168,17 +168,17 @@ class j extends w {
168
168
  return g;
169
169
  const t = this.currentNode.querySelector(S) ?? this.currentNode;
170
170
  if (f(this.currentNode) === "grid") {
171
- const h = t.querySelector(".recommendation-attribute-row"), u = h == null ? void 0 : h.querySelector("td"), d = L(u, "padding");
171
+ const h = t.querySelector(".recommendation-attribute-row"), l = (h == null ? void 0 : h.querySelector("td")) ?? null, d = L(l, "padding");
172
172
  if (!d)
173
173
  return g;
174
- const M = d.trim().split(/\s+/);
175
- return M.length < 2 ? g : y(M[1], g / 2) * 2;
174
+ const y = d.trim().split(/\s+/);
175
+ return y.length < 2 ? g : I(y[1], g / 2) * 2;
176
176
  }
177
- const o = t.querySelector(".product-card-wrapper"), i = I(o), a = L(i, "padding");
177
+ const o = t.querySelector(".product-card-wrapper") ?? null, i = V(o), a = L(i, "padding");
178
178
  if (!a)
179
179
  return g;
180
180
  const r = a.trim().split(/\s+/);
181
- return r.length < 2 ? g : y(r[1], g / 2) * 2;
181
+ return r.length < 2 ? g : I(r[1], g / 2) * 2;
182
182
  }
183
183
  /**
184
184
  * Gets stored row spacing from the first spacer element's height style
@@ -186,9 +186,9 @@ class j extends w {
186
186
  */
187
187
  _getStoredRowSpacing() {
188
188
  if (!this.currentNode)
189
- return G;
190
- const e = (this.currentNode.querySelector(S) ?? this.currentNode).querySelector(".spacer"), o = L(e, "height");
191
- return y(o, G);
189
+ return E;
190
+ const e = (this.currentNode.querySelector(S) ?? this.currentNode).querySelector(".spacer") ?? null, o = L(e, "height");
191
+ return I(o, E);
192
192
  }
193
193
  // ========================================================================
194
194
  // Desktop Spacing Handlers
@@ -209,12 +209,12 @@ class j extends w {
209
209
  const o = p.getConfig(this.currentNode).layout || f(this.currentNode), i = this.api.getDocumentModifier(), r = `0 ${t / 2}px`, c = this.currentNode.querySelector(S);
210
210
  c && (o === "grid" ? Array.from(
211
211
  c.querySelectorAll(".attribute-cell")
212
- ).forEach((u) => {
213
- i.modifyHtml(u).setStyle("padding", r);
212
+ ).forEach((l) => {
213
+ i.modifyHtml(l).setStyle("padding", r);
214
214
  }) : Array.from(
215
215
  c.querySelectorAll(".product-card-wrapper")
216
- ).forEach((u) => {
217
- const d = I(u);
216
+ ).forEach((l) => {
217
+ const d = "parent" in l ? l.parent() : void 0;
218
218
  d && i.modifyHtml(d).setStyle("padding", r);
219
219
  }), i.apply(new m(`Update column spacing to ${t}px`)));
220
220
  }
@@ -260,15 +260,15 @@ class j extends w {
260
260
  { mobileColumnSpacing: t },
261
261
  `Changed mobile column spacing to ${t}px`
262
262
  ), this._storeDataAttribute(A.MOBILE_COLUMN_SPACING, t);
263
- const o = p.getConfig(this.currentNode).layout || f(this.currentNode), i = this.api.getDocumentModifier(), r = `0 ${t / 2}px`, c = this.currentNode.querySelector(E);
263
+ const o = p.getConfig(this.currentNode).layout || f(this.currentNode), i = this.api.getDocumentModifier(), r = `0 ${t / 2}px`, c = this.currentNode.querySelector(M);
264
264
  c && (o === "grid" ? Array.from(
265
265
  c.querySelectorAll(".attribute-cell")
266
- ).forEach((u) => {
267
- i.modifyHtml(u).setStyle("padding", r);
266
+ ).forEach((l) => {
267
+ i.modifyHtml(l).setStyle("padding", r);
268
268
  }) : Array.from(
269
269
  c.querySelectorAll(".product-card-wrapper")
270
- ).forEach((u) => {
271
- const d = I(u);
270
+ ).forEach((l) => {
271
+ const d = "parent" in l ? l.parent() : void 0;
272
272
  d && i.modifyHtml(d).setStyle("padding", r);
273
273
  }), i.apply(new m(`Update mobile column spacing to ${t}px`)));
274
274
  }
@@ -285,7 +285,7 @@ class j extends w {
285
285
  { mobileRowSpacing: t },
286
286
  `Changed mobile row spacing to ${t}px`
287
287
  ), this._storeDataAttribute(A.MOBILE_ROW_SPACING, t);
288
- const e = this.currentNode.querySelector(E);
288
+ const e = this.currentNode.querySelector(M);
289
289
  if (!e)
290
290
  return;
291
291
  const o = Array.from(
@@ -1,6 +1,6 @@
1
1
  import { SettingsPanelRegistry as E, SettingsPanelTab as _, SettingsTab as O, ContainerControls as C, TextControls as R } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { BLOCK_ID as U } from "./block.js";
3
- import { RecommendationBlockId as N } from "./constants/blockIds.js";
3
+ import { RecommendationBlockId as S } from "./constants/blockIds.js";
4
4
  import { RecommendationControlId as T } from "./constants/controlIds.js";
5
5
  import { CONTROL_BLOCK_ID as A } from "./controls/main/index.js";
6
6
  import "./store/recommendation.js";
@@ -14,7 +14,7 @@ import "./controls/image/index.js";
14
14
  import { SPACING_CONTROL_ID as L } from "./controls/spacing/index.js";
15
15
  import { CARD_BACKGROUND_COLOR_CONTROL_ID as D } from "./controls/cardBackground/index.js";
16
16
  import { COMPOSITION_CONTROL_BLOCK_ID as B } from "./controls/cardComposition/index.js";
17
- import { SYNC_INFO_MESSAGE_CONTROL_ID as S } from "./controls/syncInfoMessage.js";
17
+ import { SYNC_INFO_MESSAGE_CONTROL_ID as N } from "./controls/syncInfoMessage.js";
18
18
  class Z extends E {
19
19
  registerBlockControls(I) {
20
20
  I[U] = [
@@ -39,11 +39,11 @@ class Z extends E {
39
39
  B
40
40
  ]
41
41
  ).withLabel(this.api.translate("Card Composition"))
42
- ], I[N.NAME] = [
42
+ ], I[S.NAME] = [
43
43
  new _(
44
44
  O.SETTINGS,
45
45
  [
46
- S,
46
+ N,
47
47
  T.NAME_STYLE,
48
48
  T.NAME_ALIGN,
49
49
  T.NAME_TEXT_TRIM,
@@ -59,11 +59,11 @@ class Z extends E {
59
59
  T.NAME_COLOR
60
60
  ]
61
61
  )
62
- ], I[N.PRICE] = [
62
+ ], I[S.PRICE] = [
63
63
  new _(
64
64
  O.SETTINGS,
65
65
  [
66
- S,
66
+ N,
67
67
  T.PRICE_STYLE,
68
68
  T.PRICE_ALIGN,
69
69
  T.PRICE_PADDINGS
@@ -78,11 +78,11 @@ class Z extends E {
78
78
  T.PRICE_COLOR
79
79
  ]
80
80
  )
81
- ], I[N.OLD_PRICE] = [
81
+ ], I[S.OLD_PRICE] = [
82
82
  new _(
83
83
  O.SETTINGS,
84
84
  [
85
- S,
85
+ N,
86
86
  T.OLD_PRICE_STYLE,
87
87
  T.OLD_PRICE_ALIGN,
88
88
  T.OLD_PRICE_PADDINGS
@@ -97,11 +97,11 @@ class Z extends E {
97
97
  T.OLD_PRICE_COLOR
98
98
  ]
99
99
  )
100
- ], I[N.OMNIBUS_PRICE] = [
100
+ ], I[S.OMNIBUS_PRICE] = [
101
101
  new _(
102
102
  O.SETTINGS,
103
103
  [
104
- S,
104
+ N,
105
105
  T.OMNIBUS_PRICE_TEXT_BEFORE,
106
106
  T.OMNIBUS_PRICE_TEXT_AFTER,
107
107
  T.OMNIBUS_PRICE_STYLE,
@@ -118,11 +118,11 @@ class Z extends E {
118
118
  T.OMNIBUS_PRICE_COLOR
119
119
  ]
120
120
  )
121
- ], I[N.OMNIBUS_DISCOUNT] = [
121
+ ], I[S.OMNIBUS_DISCOUNT] = [
122
122
  new _(
123
123
  O.SETTINGS,
124
124
  [
125
- S,
125
+ N,
126
126
  T.OMNIBUS_DISCOUNT_TEXT_BEFORE,
127
127
  T.OMNIBUS_DISCOUNT_TEXT_AFTER,
128
128
  T.OMNIBUS_DISCOUNT_STYLE,
@@ -139,11 +139,11 @@ class Z extends E {
139
139
  T.OMNIBUS_DISCOUNT_COLOR
140
140
  ]
141
141
  )
142
- ], I[N.BUTTON] = [
142
+ ], I[S.BUTTON] = [
143
143
  new _(
144
144
  O.SETTINGS,
145
145
  [
146
- S,
146
+ N,
147
147
  T.BUTTON_TEXT,
148
148
  T.BUTTON_ALIGN,
149
149
  T.BUTTON_PADDINGS,
@@ -162,12 +162,13 @@ class Z extends E {
162
162
  T.BUTTON_BORDER
163
163
  ]
164
164
  )
165
- ], I[N.CUSTOM_ATTRIBUTE] = [
165
+ ], I[S.CUSTOM_ATTRIBUTE] = [
166
166
  new _(
167
167
  O.SETTINGS,
168
168
  [
169
169
  T.CUSTOM_ATTR_STYLE,
170
170
  T.CUSTOM_ATTR_ALIGN,
171
+ T.CUSTOM_ATTR_TEXT_TRIM,
171
172
  T.CUSTOM_ATTR_PADDINGS
172
173
  ]
173
174
  ),
@@ -180,11 +181,11 @@ class Z extends E {
180
181
  T.CUSTOM_ATTR_COLOR
181
182
  ]
182
183
  )
183
- ], I[N.IMAGE] = [
184
+ ], I[S.IMAGE] = [
184
185
  new _(
185
186
  O.SETTINGS,
186
187
  [
187
- S,
188
+ N,
188
189
  T.IMAGE_SIZE,
189
190
  T.IMAGE_MARGINS
190
191
  ]
@@ -1,14 +1,14 @@
1
1
  import { RecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as k } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as C } from "../../../../stores/config.js";
2
+ import { useRecommendationApi as C } from "../../../../services/recommendationApi.js";
3
+ import { useConfigStore as y } from "../../../../stores/config.js";
4
4
  import { defineStore as G } from "pinia";
5
5
  import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
6
6
  import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
7
7
  import { getDefaultProducts as S } from "../templates/utils.js";
8
8
  import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
9
9
  import { isFilterValid as D } from "../validation/filterSchema.js";
10
- const h = y();
11
- let u = null, m = null, d = null;
10
+ const h = C();
11
+ let m = null, u = null, d = null;
12
12
  function I() {
13
13
  return {
14
14
  cardsInRow: F,
@@ -57,7 +57,7 @@ const v = () => ({
57
57
  blockStates: {},
58
58
  currentRecommendationId: null,
59
59
  configVersion: 0
60
- }), E = G("guidoRecommendationExtension", {
60
+ }), z = G("guidoRecommendationExtension", {
61
61
  state: () => v(),
62
62
  getters: {
63
63
  // ====================================================================
@@ -131,11 +131,10 @@ const v = () => ({
131
131
  })),
132
132
  getFilterList() {
133
133
  return Object.values(this.filterList).map((t) => {
134
- const r = t.type === "defaultAttribute", e = k.includes(t.attributeName);
135
- let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
136
- return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
134
+ let r;
135
+ return t.type === "productAttribute" ? r = `product_attributes.${t.attributeName}` : k.includes(t.attributeName) ? r = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : r = t.attributeName, {
137
136
  text: t.displayName,
138
- value: n,
137
+ value: r,
139
138
  type: t.attributeType
140
139
  };
141
140
  });
@@ -163,10 +162,15 @@ const v = () => ({
163
162
  * Resets currentRecommendationId if it was the deleted block.
164
163
  */
165
164
  removeBlockState(t) {
166
- const r = { ...this.blockStates };
167
- if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
168
- const e = Object.keys(this.blockStates).map(Number);
169
- this.currentRecommendationId = e.length > 0 ? e[0] : null;
165
+ const r = t.toString();
166
+ if (this.recommendationCampaignUrls[r]) {
167
+ const n = { ...this.recommendationCampaignUrls };
168
+ delete n[r], this.recommendationCampaignUrls = n;
169
+ }
170
+ const e = { ...this.blockStates };
171
+ if (delete e[t], this.blockStates = e, this.currentRecommendationId === t) {
172
+ const n = Object.keys(this.blockStates).map(Number);
173
+ this.currentRecommendationId = n.length > 0 ? n[0] : null;
170
174
  }
171
175
  },
172
176
  /**
@@ -251,11 +255,11 @@ const v = () => ({
251
255
  // ====================================================================
252
256
  async fetchRecommendationCreateData() {
253
257
  if (!this.activePredictiveAlgorithms.length) {
254
- if (u) {
255
- await u;
258
+ if (m) {
259
+ await m;
256
260
  return;
257
261
  }
258
- u = (async () => {
262
+ m = (async () => {
259
263
  const {
260
264
  activePredictiveAlgorithms: t,
261
265
  languages: r,
@@ -268,26 +272,26 @@ const v = () => ({
268
272
  this.currencyList = e;
269
273
  })();
270
274
  try {
271
- await u;
275
+ await m;
272
276
  } finally {
273
- u = null;
277
+ m = null;
274
278
  }
275
279
  }
276
280
  },
277
281
  async fetchRecommendationFilters() {
278
282
  if (!Object.keys(this.filterList).length) {
279
- if (m) {
280
- await m;
283
+ if (u) {
284
+ await u;
281
285
  return;
282
286
  }
283
- m = (async () => {
287
+ u = (async () => {
284
288
  const t = await h.fetchRecommendationFilters();
285
289
  this.filterList = t;
286
290
  })();
287
291
  try {
288
- await m;
292
+ await u;
289
293
  } finally {
290
- m = null;
294
+ u = null;
291
295
  }
292
296
  }
293
297
  },
@@ -375,7 +379,7 @@ const v = () => ({
375
379
  },
376
380
  async _doFetchProducts() {
377
381
  var p;
378
- const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid), c = b(n), i = ((p = g.find((a) => a.key === e.strategy)) == null ? void 0 : p.path) || "", o = C(), s = {
382
+ const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid), c = b(n), i = ((p = g.find((a) => a.key === e.strategy)) == null ? void 0 : p.path) || "", o = y(), s = {
379
383
  locale: e.language,
380
384
  currency: e.currencySettings.value,
381
385
  partnerName: o.partnerName,
@@ -399,5 +403,5 @@ const v = () => ({
399
403
  }
400
404
  });
401
405
  export {
402
- E as useRecommendationExtensionStore
406
+ z as useRecommendationExtensionStore
403
407
  };
@@ -1,11 +1,11 @@
1
1
  import { RecommendationBlockId as s } from "../../constants/blockIds.js";
2
- import { ATTR_PRODUCT_ATTR as g, ATTR_PRODUCT_BUTTON as u, ATTR_PRODUCT_OMNIBUS_DISCOUNT as m, ATTR_PRODUCT_OMNIBUS_PRICE as h, ATTR_PRODUCT_OLD_PRICE as y, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_NAME as f, ATTR_PRODUCT_IMAGE as _ } from "../../constants/selectors.js";
3
- import { useRecommendationExtensionStore as x } from "../../store/recommendation.js";
2
+ import { ATTR_PRODUCT_ATTR as g, ATTR_PRODUCT_BUTTON as u, ATTR_PRODUCT_OMNIBUS_DISCOUNT as m, ATTR_PRODUCT_OMNIBUS_PRICE as h, ATTR_PRODUCT_OLD_PRICE as y, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_NAME as f, ATTR_PRODUCT_IMAGE as x } from "../../constants/selectors.js";
3
+ import { useRecommendationExtensionStore as _ } from "../../store/recommendation.js";
4
4
  import { formatPrice as $ } from "../../utils/priceFormatter.js";
5
5
  import { sanitizeImageUrl as C, CUSTOM_CELL_HTML as R } from "../utils.js";
6
6
  const a = "0 5px", l = "attribute-cell";
7
7
  function p() {
8
- const t = x(), { currencySettings: e } = t.recommendationConfigs;
8
+ const t = _(), { currencySettings: e } = t.recommendationConfigs;
9
9
  return {
10
10
  code: e.value,
11
11
  symbol: e.symbol,
@@ -23,7 +23,7 @@ function r(t, e = "price") {
23
23
  });
24
24
  }
25
25
  const I = {
26
- [_]: (t) => `
26
+ [x]: (t) => `
27
27
  <td class="${l}" style="padding: ${a}; height: 100%;" valign="top">
28
28
  <table
29
29
  class="product-card-segment"
@@ -224,6 +224,8 @@ const I = {
224
224
  * Custom attribute cell template — same structure as built-in entries
225
225
  * (outer td → inner product-card-segment table).
226
226
  * Used by `buildElementRenderer` for `customAttr:*` composition entries.
227
+ * @param productAttrValue - Resolved product-attr value (e.g., "brand" for default, "product_attribute.rating_star" for custom)
228
+ * @param content - Display content for the cell
227
229
  */
228
230
  [R]: (t, e) => `
229
231
  <td class="${l}" style="padding: ${a}; height: 100%;" valign="middle">
@@ -238,7 +240,7 @@ const I = {
238
240
  <tbody>
239
241
  <tr valign="top">
240
242
  <td
241
- ${g}="product_attribute.${t}"
243
+ ${g}="${t}"
242
244
  class="esd-block-text product-custom-attribute es-p0t es-p0b es-p15l es-p15r"
243
245
  align="center"
244
246
  esd-extension-block-id="${s.CUSTOM_ATTRIBUTE}">
@@ -1,7 +1,7 @@
1
- import { DEFAULT_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
2
- import { DEFAULT_CARD_COMPOSITION as L, spacer as E, getDefaultProducts as I, createBlockTemplate as _, DEFAULTS as S, buildElementRenderer as b, DEFAULT_CARD_VISIBILITY as A } from "../utils.js";
3
- import { gridElementRenderer as f, ATTRIBUTE_CELL_CLASS as w, DEFAULT_CELL_PADDING as D } from "./elementRenderer.js";
4
- const C = `
1
+ import { DEFAULT_PRODUCTS_PER_ROW as L } from "../../constants/layout.js";
2
+ import { DEFAULT_CARD_COMPOSITION as E, spacer as I, getDefaultProducts as _, createBlockTemplate as S, DEFAULTS as b, buildElementRenderer as A, DEFAULT_CARD_VISIBILITY as f } from "../utils.js";
3
+ import { gridElementRenderer as w, ATTRIBUTE_CELL_CLASS as D, DEFAULT_CELL_PADDING as C } from "./elementRenderer.js";
4
+ const O = `
5
5
  <tr class="recommendation-product-row">
6
6
  <td>
7
7
  <table
@@ -18,7 +18,7 @@ const C = `
18
18
  </table>
19
19
  </td>
20
20
  </tr>
21
- `, O = `
21
+ `, g = `
22
22
  <tr
23
23
  class="recommendation-attribute-row"
24
24
  data-attribute-type="{-{-ATTR_TYPE-}-}"
@@ -27,37 +27,38 @@ const C = `
27
27
  {-{-CELLS-}-}
28
28
  </tr>
29
29
  `;
30
- function g(t, e, l, n = L) {
31
- const o = (100 / e).toFixed(2), a = e - t.length, r = `<td class="${w}" style="padding: ${D};" width="${o}%"></td>`, i = a > 0 ? r.repeat(a) : "", s = b(l, n);
32
- return n.filter((c) => s[c]).map((c) => {
33
- const p = A[c] ?? !0, T = p ? "" : 'style="display: none;"', u = t.map((R) => s[c](R).replace("<td", `<td width="${o}%"`)).join("");
34
- return O.replace("{-{-ATTR_TYPE-}-}", c).replace("{-{-VISIBILITY-}-}", p ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", T).replace("{-{-CELLS-}-}", u + i);
30
+ function P(t, e, o, r = E, n = {}) {
31
+ const c = (100 / e).toFixed(2), i = e - t.length, l = `<td class="${D}" style="padding: ${C};" width="${c}%"></td>`, d = i > 0 ? l.repeat(i) : "", a = A(o, r, n);
32
+ return r.filter((s) => a[s]).map((s) => {
33
+ const T = f[s] ?? !0, u = T ? "" : 'style="display: none;"', R = t.map((m) => a[s](m).replace("<td", `<td width="${c}%"`)).join("");
34
+ return g.replace("{-{-ATTR_TYPE-}-}", s).replace("{-{-VISIBILITY-}-}", T ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", u).replace("{-{-CELLS-}-}", R + d);
35
35
  }).join("");
36
36
  }
37
- function P(t, e, l, n) {
38
- const o = [];
39
- for (let r = 0; r < t.length; r += e)
40
- o.push(t.slice(r, r + e));
41
- return o.map((r, i) => {
42
- const s = g(
43
- r,
44
- e,
37
+ function U(t, e, o, r, n = {}) {
38
+ const c = [];
39
+ for (let l = 0; l < t.length; l += e)
40
+ c.push(t.slice(l, l + e));
41
+ return c.map((l, d) => {
42
+ const a = P(
45
43
  l,
44
+ e,
45
+ o,
46
+ r,
46
47
  n
47
- ), d = C.replace("{-{-ATTRIBUTE_ROWS-}-}", s);
48
- return i > 0 ? E + d : d;
48
+ ), p = O.replace("{-{-ATTRIBUTE_ROWS-}-}", a);
49
+ return d > 0 ? I + p : p;
49
50
  }).join("");
50
51
  }
51
- function U(t, e, l) {
52
- return P(t, e, f, l);
52
+ function h(t, e, o, r = {}) {
53
+ return U(t, e, w, o, r);
53
54
  }
54
- function W(t) {
55
- const e = t ? `ins-recommendation-v3-block-${t}` : void 0, l = _("grid", e), n = I(), o = U(n, m);
56
- return l.replace("{-{-TITLE-}-}", S.TITLE).replace("{-{-PRODUCT_ROWS-}-}", o).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
55
+ function F(t) {
56
+ const e = t ? `ins-recommendation-v3-block-${t}` : void 0, o = S("grid", e), r = _(), n = h(r, L);
57
+ return o.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", n).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", "");
57
58
  }
58
59
  export {
59
- W as getDefaultTemplate,
60
- g as prepareGridAttributeRows,
61
- P as prepareGridProductRows,
62
- U as prepareProductRows
60
+ F as getDefaultTemplate,
61
+ P as prepareGridAttributeRows,
62
+ U as prepareGridProductRows,
63
+ h as prepareProductRows
63
64
  };