@useinsider/guido 2.1.0-beta.e13d291 → 2.1.0-beta.e2153c2

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 (138) 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/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
  6. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  7. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  8. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  9. package/dist/composables/useActionsApi.js +15 -13
  10. package/dist/composables/useBlocksConfig.js +26 -16
  11. package/dist/composables/useHtmlValidator.js +114 -104
  12. package/dist/composables/useRecommendation.js +54 -21
  13. package/dist/composables/useStripo.js +25 -23
  14. package/dist/composables/useVersionHistoryApi.js +1 -1
  15. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  16. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  17. package/dist/config/i18n/en/index.js +11 -0
  18. package/dist/config/i18n/en/labels.json.js +7 -0
  19. package/dist/config/i18n/en/toasters.json.js +56 -0
  20. package/dist/config/i18n/en/tooltips.json.js +82 -0
  21. package/dist/config/i18n/index.js +7 -0
  22. package/dist/config/migrator/itemsBlockMigrator.js +142 -120
  23. package/dist/enums/defaults.js +8 -4
  24. package/dist/enums/extensions/recommendationBlock.js +1 -1
  25. package/dist/enums/recommendation.js +16 -15
  26. package/dist/extensions/Blocks/Items/block.js +19 -28
  27. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  28. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  29. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  30. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  31. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
  32. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
  33. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
  34. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
  35. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  36. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
  37. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  38. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  39. package/dist/extensions/Blocks/Items/extension.js +8 -9
  40. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  41. package/dist/extensions/Blocks/Items/template.js +181 -175
  42. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  43. package/dist/extensions/Blocks/Recommendation/block.js +117 -27
  44. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +33 -31
  45. package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
  46. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
  47. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +10 -14
  48. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +19 -27
  49. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +49 -44
  50. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +1 -3
  51. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +147 -102
  52. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +1 -5
  53. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +85 -43
  54. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +9 -13
  55. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
  56. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  57. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +66 -34
  58. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +2 -2
  59. package/dist/extensions/Blocks/Recommendation/services/configService.js +2 -1
  60. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +248 -206
  61. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +26 -31
  62. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
  63. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +31 -34
  64. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
  65. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +22 -22
  66. package/dist/extensions/Blocks/Recommendation/templates/utils.js +52 -39
  67. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +10 -10
  68. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  69. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  70. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  71. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  72. package/dist/extensions/Blocks/common-control.js +91 -92
  73. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  74. package/dist/guido.css +1 -1
  75. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
  76. package/dist/package.json.js +1 -1
  77. package/dist/services/recommendationApi.js +11 -9
  78. package/dist/services/stripoApi.js +20 -17
  79. package/dist/services/templateLibraryApi.js +16 -13
  80. package/dist/src/@types/config/schemas.d.ts +8 -0
  81. package/dist/src/composables/useConfig.d.ts +4 -0
  82. package/dist/src/composables/useRecommendation.d.ts +1 -0
  83. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  84. package/dist/src/config/i18n/en/index.d.ts +1 -0
  85. package/dist/src/config/i18n/index.d.ts +16 -0
  86. package/dist/src/enums/defaults.d.ts +4 -0
  87. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  88. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  89. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  90. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  91. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  92. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  93. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  94. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  95. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  96. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  97. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  98. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  99. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  100. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +44 -11
  101. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  102. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
  103. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
  104. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +8 -1
  105. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +27 -5
  106. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
  107. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
  108. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  109. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +19 -1
  110. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +2 -2
  111. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -469
  112. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +2 -2
  113. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  114. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
  115. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +2 -2
  116. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -2
  117. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +16 -4
  118. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +14 -2
  119. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +1 -1
  120. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  121. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  122. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  123. package/dist/src/stores/config.d.ts +36 -0
  124. package/dist/static/styles/components/notification.css.js +19 -0
  125. package/dist/static/styles/components/tools.css.js +6 -2
  126. package/dist/static/styles/components/version-history.css.js +10 -2
  127. package/dist/static/styles/components/wide-panel.css.js +18 -2
  128. package/dist/static/styles/customEditorStyle.css.js +10 -9
  129. package/dist/static/styles/variables.css.js +2 -0
  130. package/dist/static/templates/empty/index.html.js +74 -0
  131. package/dist/static/templates/empty/style.css.js +779 -0
  132. package/dist/stores/unsubscribe.js +37 -34
  133. package/dist/utils/pairProductVariables.js +57 -56
  134. package/dist/utils/templatePreparation.js +15 -14
  135. package/package.json +2 -2
  136. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  137. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
  138. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
@@ -1,22 +1,22 @@
1
1
  var d = Object.defineProperty;
2
- var c = (o, i, t) => i in o ? d(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
- var a = (o, i, t) => c(o, typeof i != "symbol" ? i + "" : i, t);
4
- import { UEAttr as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as l } from "../../../common-control.js";
2
+ var l = (o, i, t) => i in o ? d(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
+ var a = (o, i, t) => l(o, typeof i != "symbol" ? i + "" : i, t);
4
+ import { UEAttr as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
6
  import { RecommendationConfigService as n } from "../../services/configService.js";
7
7
  import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
8
- const g = "recommendation-algorithm-control", e = {
8
+ const u = "recommendation-algorithm-control", e = {
9
9
  ALGORITHM: "strategy",
10
10
  PRODUCT_IDS: "productIds"
11
11
  };
12
- class T extends l {
12
+ class T extends h {
13
13
  constructor() {
14
14
  super(...arguments);
15
15
  // Store is used ONLY for API-fetched data (algorithms list), not for config
16
16
  a(this, "store", m());
17
17
  }
18
18
  getId() {
19
- return g;
19
+ return u;
20
20
  }
21
21
  getTemplate() {
22
22
  return `
@@ -52,22 +52,22 @@ class T extends l {
52
52
  });
53
53
  }
54
54
  _initializeSelectItems() {
55
- var s;
56
- const t = (s = this.store) == null ? void 0 : s.getActivePredictiveAlgorithms;
55
+ var r;
56
+ const t = (r = this.store) == null ? void 0 : r.getActivePredictiveAlgorithms;
57
57
  if (t != null && t.length)
58
58
  try {
59
59
  this.api.setUIEAttribute(
60
60
  e.ALGORITHM,
61
- h.SELECTPICKER.items,
61
+ c.SELECTPICKER.items,
62
62
  t
63
63
  );
64
- } catch (r) {
65
- console.warn("[AlgorithmControl] Failed to set algorithm options:", r);
64
+ } catch (s) {
65
+ console.warn("[AlgorithmControl] Failed to set algorithm options:", s);
66
66
  }
67
67
  }
68
68
  _setProductIdsVisibility(t) {
69
- const r = (t ?? n.getConfig(this.currentNode).strategy) === "manualMerchandising";
70
- this.api.setVisibility(e.PRODUCT_IDS, r), this.api.setVisibility(`${e.PRODUCT_IDS}_label`, r);
69
+ const s = (t ?? n.getConfig(this.currentNode).strategy) === "manualMerchandising";
70
+ this.api.setVisibility(e.PRODUCT_IDS, s), this.api.setVisibility(`${e.PRODUCT_IDS}_label`, s);
71
71
  }
72
72
  _onAlgorithmChange(t) {
73
73
  this.currentNode && (n.updateConfig(
@@ -75,26 +75,18 @@ class T extends l {
75
75
  this.currentNode,
76
76
  { strategy: t },
77
77
  `Changed algorithm to ${t}`
78
- ), this.store.$patch({
79
- recommendationConfigs: {
80
- strategy: t
81
- }
82
- }), this._setProductIdsVisibility(t));
78
+ ), this.store.patchCurrentBlockConfig({ strategy: t }), this._setProductIdsVisibility(t));
83
79
  }
84
80
  _onProductIdsChange(t) {
85
81
  if (!this.currentNode)
86
82
  return;
87
- const s = t.split(",").map((r) => r.trim()).filter(Boolean);
83
+ const r = t.split(",").map((s) => s.trim()).filter(Boolean);
88
84
  n.updateConfig(
89
85
  this.api,
90
86
  this.currentNode,
91
- { productIds: s },
87
+ { productIds: r },
92
88
  "Updated product IDs"
93
- ), this.store.$patch({
94
- recommendationConfigs: {
95
- productIds: s
96
- }
97
- });
89
+ ), this.store.patchCurrentBlockConfig({ productIds: r });
98
90
  }
99
91
  _listenToFormUpdates() {
100
92
  this.api.onValueChanged(e.ALGORITHM, (t) => {
@@ -105,6 +97,6 @@ class T extends l {
105
97
  }
106
98
  }
107
99
  export {
108
- g as ALGORITHM_CONTROL_ID,
100
+ u as ALGORITHM_CONTROL_ID,
109
101
  T as AlgorithmControl
110
102
  };
@@ -1,13 +1,13 @@
1
- var h = Object.defineProperty;
2
- var R = (i, o, e) => o in i ? h(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
3
- var c = (i, o, e) => R(i, typeof o != "symbol" ? o + "" : o, e);
4
- import { currencyLocationMaps as u, currencyOperators as a, currencyDecimalCounts as l } from "../../../../../enums/extensions/recommendationBlock.js";
5
- import { UEAttr as _ } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
- import { CommonControl as m } from "../../../common-control.js";
1
+ var R = Object.defineProperty;
2
+ var _ = (s, o, e) => o in s ? R(s, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[o] = e;
3
+ var c = (s, o, e) => _(s, typeof o != "symbol" ? o + "" : o, e);
4
+ import { currencyLocationMaps as l, currencyOperators as i, currencyDecimalCounts as h } from "../../../../../enums/extensions/recommendationBlock.js";
5
+ import { UEAttr as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { CommonControl as d } from "../../../common-control.js";
7
7
  import { RecommendationConfigService as C } from "../../services/configService.js";
8
- import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
9
- import { setCurrencyAttributes as p, updatePricesInPlace as S, regenerateProductRowsWithStyles as E } from "./utils.js";
10
- const N = "recommendation-currency-control", t = {
8
+ import { useRecommendationExtensionStore as p } from "../../store/recommendation.js";
9
+ import { setCurrencyAttributes as S, updatePricesInPlace as E, regenerateProductRowsWithStyles as N } from "./utils.js";
10
+ const y = "recommendation-currency-control", t = {
11
11
  CURRENCY: "currencyCode",
12
12
  CURRENCY_LOCATION: "currencyAlignment",
13
13
  CURRENCY_SYMBOL: "currencySymbol",
@@ -15,16 +15,16 @@ const N = "recommendation-currency-control", t = {
15
15
  CURRENCY_DECIMAL_SEPARATOR: "currencyDecimalSeparator",
16
16
  CURRENCY_DECIMAL_COUNT: "currencyDecimalCount"
17
17
  };
18
- class b extends m {
18
+ class D extends d {
19
19
  constructor() {
20
20
  super(...arguments);
21
21
  // Store is used ONLY for API-fetched data (currency list), not for config
22
- c(this, "store", d());
22
+ c(this, "store", p());
23
23
  c(this, "storeUnsubscription", () => {
24
24
  });
25
25
  }
26
26
  getId() {
27
- return N;
27
+ return y;
28
28
  }
29
29
  getTemplate() {
30
30
  return `
@@ -40,7 +40,7 @@ class b extends m {
40
40
  this._GuSelect({
41
41
  name: t.CURRENCY_LOCATION,
42
42
  placeholder: "Select Currency Location",
43
- options: u
43
+ options: l
44
44
  }),
45
45
  this._GuLabel({ text: "Currency Symbol" }),
46
46
  this._GuTextInput({
@@ -52,19 +52,19 @@ class b extends m {
52
52
  this._GuSelect({
53
53
  name: t.CURRENCY_THOUSAND_SEPARATOR,
54
54
  placeholder: "Select Thousand Separator",
55
- options: a
55
+ options: i
56
56
  }),
57
57
  this._GuLabel({ text: "Decimal Separator" }),
58
58
  this._GuSelect({
59
59
  name: t.CURRENCY_DECIMAL_SEPARATOR,
60
60
  placeholder: "Select Decimal Separator",
61
- options: a
61
+ options: i
62
62
  }),
63
63
  this._GuLabel({ text: "Decimal Count" }),
64
64
  this._GuSelect({
65
65
  name: t.CURRENCY_DECIMAL_COUNT,
66
66
  placeholder: "Select Decimal Count",
67
- options: l
67
+ options: h
68
68
  })
69
69
  ])}
70
70
  </div>
@@ -95,16 +95,23 @@ class b extends m {
95
95
  _initializeSelectItems() {
96
96
  const { store: e } = this, r = {
97
97
  [t.CURRENCY]: e.currencyList,
98
- [t.CURRENCY_LOCATION]: u,
99
- [t.CURRENCY_THOUSAND_SEPARATOR]: a,
100
- [t.CURRENCY_DECIMAL_SEPARATOR]: a,
101
- [t.CURRENCY_DECIMAL_COUNT]: l
98
+ [t.CURRENCY_LOCATION]: l,
99
+ [t.CURRENCY_THOUSAND_SEPARATOR]: i,
100
+ [t.CURRENCY_DECIMAL_SEPARATOR]: i,
101
+ [t.CURRENCY_DECIMAL_COUNT]: h
102
102
  };
103
- Object.entries(r).forEach(([n, s]) => {
104
- this.api.setUIEAttribute(n, _.SELECTPICKER.items, s);
103
+ Object.entries(r).forEach(([u, n]) => {
104
+ this.api.setUIEAttribute(u, m.SELECTPICKER.items, n);
105
105
  });
106
106
  }
107
- _updateCurrency(e) {
107
+ /**
108
+ * Applies currency updates to node config, HTML attributes, Pinia store, and DOM.
109
+ * @param updates - Partial currency config to merge
110
+ * @param triggerRefetch - Whether to trigger a product API refetch.
111
+ * true for currency code changes (different prices from API),
112
+ * false for display-only changes (symbol, separators, alignment, decimal count).
113
+ */
114
+ _updateCurrency(e, r = !1) {
108
115
  if (!this.currentNode)
109
116
  return;
110
117
  const n = { ...C.getConfig(this.currentNode).currency, ...e };
@@ -114,29 +121,27 @@ class b extends m {
114
121
  { currency: n },
115
122
  "Updated currency settings"
116
123
  );
117
- const s = this.api.getDocumentModifier();
118
- p({
124
+ const a = this.api.getDocumentModifier();
125
+ S({
119
126
  currentNode: this.currentNode,
120
- documentModifier: s,
127
+ documentModifier: a,
121
128
  currency: n
122
- }), this.store.$patch({
123
- recommendationConfigs: {
124
- currencySettings: {
125
- name: n.code,
126
- value: n.code,
127
- symbol: n.symbol,
128
- alignment: n.alignment === "before" ? "0" : "1",
129
- decimalCount: n.decimalCount.toString(),
130
- decimalSeparator: n.decimalSeparator,
131
- thousandSeparator: n.thousandSeparator
132
- }
129
+ }), this.store.patchCurrentBlockConfig({
130
+ currencySettings: {
131
+ name: n.code,
132
+ value: n.code,
133
+ symbol: n.symbol,
134
+ alignment: n.alignment === "before" ? "0" : "1",
135
+ decimalCount: n.decimalCount.toString(),
136
+ decimalSeparator: n.decimalSeparator,
137
+ thousandSeparator: n.thousandSeparator
133
138
  }
134
- }), S({
139
+ }, { triggerRefetch: r }), E({
135
140
  currentNode: this.currentNode,
136
- documentModifier: s
137
- }) || E({
141
+ documentModifier: a
142
+ }) || N({
138
143
  currentNode: this.currentNode,
139
- documentModifier: s
144
+ documentModifier: a
140
145
  });
141
146
  }
142
147
  _onCurrencyChange(e) {
@@ -144,7 +149,7 @@ class b extends m {
144
149
  this._updateCurrency({
145
150
  code: r,
146
151
  symbol: r
147
- }), this.api.updateValues({
152
+ }, !0), this.api.updateValues({
148
153
  [t.CURRENCY_SYMBOL]: r
149
154
  });
150
155
  }
@@ -199,6 +204,6 @@ class b extends m {
199
204
  }
200
205
  }
201
206
  export {
202
- N as CURRENCY_CONTROL_ID,
203
- b as CurrencyControl
207
+ y as CURRENCY_CONTROL_ID,
208
+ D as CurrencyControl
204
209
  };
@@ -39,9 +39,7 @@ class h extends s {
39
39
  (t = this.addFilterButton) == null || t.removeEventListener("click", this.addFilterListener);
40
40
  }
41
41
  _onFilterSelectClick() {
42
- this.store.$patch({
43
- filterSelectionDrawerStatus: !0
44
- });
42
+ this.store.openFilterDrawer();
45
43
  }
46
44
  _setupButtonListener() {
47
45
  var t;
@@ -1,62 +1,54 @@
1
- var g = Object.defineProperty;
2
- var y = (n, s, t) => s in n ? g(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
3
- var r = (n, s, t) => y(n, typeof s != "symbol" ? s + "" : s, t);
4
- import { CommonControl as R } from "../../../common-control.js";
5
- import { useRecommendationExtensionStore as P } from "../../store/recommendation.js";
6
- import { AlgorithmControl as _ } from "./algorithm.js";
7
- import { ALGORITHM_CONTROL_ID as j } from "./algorithm.js";
8
- import { CurrencyControl as b } from "./currency.js";
9
- import { CURRENCY_CONTROL_ID as q } from "./currency.js";
10
- import { FiltersControl as L } from "./filters.js";
11
- import { FILTERS_CONTROL_ID as Q } from "./filters.js";
12
- import { LocaleControl as N } from "./locale.js";
13
- import { LOCALE_CONTROL_ID as X } from "./locale.js";
14
- import { ProductLayoutControl as T } from "./productLayout.js";
15
- import { PRODUCT_LAYOUT_CONTROL_ID as tt } from "./productLayout.js";
16
- import { ShuffleControl as O } from "./shuffle.js";
17
- import { SHUFFLE_CONTROL_ID as ot } from "./shuffle.js";
18
- import { regenerateProductRowsWithStyles as D, updateProductContentInPlace as S } from "./utils.js";
19
- import { formatProductPrice as st, getBlockElement as nt, getCardComposition as it, getCurrentLayout as at, reapplySpacing as ct, regenerateProductRows as lt, setCurrencyAttributes as ut, updatePricesInPlace as dt, updateSingleProductContent as ht } from "./utils.js";
20
- import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
21
- const I = /* @__PURE__ */ new Set([
22
- "size",
23
- "strategy",
24
- "filters",
25
- "productIds",
26
- "language",
27
- "shuffleProducts"
28
- ]), w = "ui-elements-recommendation-block";
29
- class B extends R {
1
+ var d = Object.defineProperty;
2
+ var m = (c, s, t) => s in c ? d(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
+ var n = (c, s, t) => m(c, typeof s != "symbol" ? s + "" : s, t);
4
+ import { CommonControl as h } from "../../../common-control.js";
5
+ import { RecommendationConfigService as f } from "../../services/configService.js";
6
+ import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
7
+ import { AlgorithmControl as p } from "./algorithm.js";
8
+ import { ALGORITHM_CONTROL_ID as W } from "./algorithm.js";
9
+ import { CurrencyControl as g } from "./currency.js";
10
+ import { CURRENCY_CONTROL_ID as H } from "./currency.js";
11
+ import { FiltersControl as R } from "./filters.js";
12
+ import { FILTERS_CONTROL_ID as j } from "./filters.js";
13
+ import { LocaleControl as y } from "./locale.js";
14
+ import { LOCALE_CONTROL_ID as K } from "./locale.js";
15
+ import { ProductLayoutControl as _ } from "./productLayout.js";
16
+ import { PRODUCT_LAYOUT_CONTROL_ID as J } from "./productLayout.js";
17
+ import { ShuffleControl as N } from "./shuffle.js";
18
+ import { SHUFFLE_CONTROL_ID as X } from "./shuffle.js";
19
+ import { regenerateProductRowsWithStyles as b, getBlockElement as P, updateProductContentInPlace as I } from "./utils.js";
20
+ import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as nt, regenerateProductRows as it, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
21
+ import { useDebounceFn as l } from "../../../../../node_modules/@vueuse/shared/index.js";
22
+ const T = "recommendation-id", S = "ui-elements-recommendation-block";
23
+ class $ extends h {
30
24
  constructor() {
31
25
  super(...arguments);
32
- r(this, "store", P());
33
- r(this, "storeUnsubscription", () => {
26
+ n(this, "store", C());
27
+ n(this, "storeUnsubscription", () => {
34
28
  });
35
- // Track if initial data has been fetched to avoid redundant API calls
36
- r(this, "hasInitializedData", !1);
37
29
  // Sub-control instances for lifecycle management
38
- r(this, "algorithmControl", null);
39
- r(this, "localeControl", null);
40
- r(this, "currencyControl", null);
41
- r(this, "productLayoutControl", null);
42
- r(this, "filtersControl", null);
43
- r(this, "shuffleControl", null);
30
+ n(this, "algorithmControl", null);
31
+ n(this, "localeControl", null);
32
+ n(this, "currencyControl", null);
33
+ n(this, "productLayoutControl", null);
34
+ n(this, "filtersControl", null);
35
+ n(this, "shuffleControl", null);
44
36
  /**
45
37
  * Debounced product fetch to prevent rapid API calls during config changes
46
38
  */
47
- r(this, "_debouncedFetchProducts", h(() => {
39
+ n(this, "_debouncedFetchProducts", l(() => {
48
40
  this.store.fetchRecommendationProducts();
49
41
  }, 500));
50
42
  /**
51
43
  * Debounced regeneration when products arrive from API
52
44
  * Tries in-place update first to preserve styles, falls back to full regeneration
53
45
  */
54
- r(this, "_debouncedRegenerateWithProducts", h(() => {
46
+ n(this, "_debouncedRegenerateWithProducts", l(() => {
55
47
  const t = this.store.recommendationProducts;
56
48
  if (!this.currentNode || !this.api)
57
49
  return;
58
50
  const e = this.api.getDocumentModifier();
59
- S({
51
+ I({
60
52
  currentNode: this.currentNode,
61
53
  documentModifier: e,
62
54
  products: t
@@ -64,10 +56,10 @@ class B extends R {
64
56
  }, 100));
65
57
  }
66
58
  getId() {
67
- return w;
59
+ return S;
68
60
  }
69
61
  getTemplate() {
70
- return this.algorithmControl = new _(), this.localeControl = new N(), this.currencyControl = new b(), this.productLayoutControl = new T(), this.filtersControl = new L(), this.shuffleControl = new O(), `
62
+ return this.algorithmControl = new p(), this.localeControl = new y(), this.currencyControl = new g(), this.productLayoutControl = new _(), this.filtersControl = new R(), this.shuffleControl = new N(), `
71
63
  <div class="recommendation-controls-container">
72
64
  ${this.algorithmControl.getTemplate()}
73
65
  ${this.localeControl.getTemplate()}
@@ -79,21 +71,13 @@ class B extends R {
79
71
  `;
80
72
  }
81
73
  async onRender() {
82
- if (this._listenStateUpdates(), this.hasInitializedData) {
74
+ var e;
75
+ const t = this._getRecommendationIdFromNode(this.currentNode) ?? this.store.currentRecommendationId;
76
+ if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && ((e = this.store.blockStates[t]) != null && e.isInitialized)) {
83
77
  this._initializeSubControls();
84
78
  return;
85
79
  }
86
- (await Promise.allSettled([
87
- this.store.fetchRecommendationFilters(),
88
- this.store.fetchRecommendationCreateData(),
89
- this.store.fetchRecommendationProducts()
90
- ])).forEach((e, o) => {
91
- e.status === "rejected" && console.warn(`Recommendation block: ${[
92
- "fetchRecommendationFilters",
93
- "fetchRecommendationCreateData",
94
- "fetchRecommendationProducts"
95
- ][o]} failed`, e.reason);
96
- }), this.hasInitializedData = !0, this._initializeSubControls();
80
+ await this._fetchBlockData(t), this._initializeSubControls();
97
81
  }
98
82
  /**
99
83
  * Immediately regenerate products with styles (no debounce)
@@ -104,23 +88,26 @@ class B extends R {
104
88
  console.warn("[Recommendation] Cannot regenerate - missing currentNode or api");
105
89
  return;
106
90
  }
107
- D({
91
+ b({
108
92
  currentNode: this.currentNode,
109
93
  documentModifier: this.api.getDocumentModifier(),
110
94
  products: t
111
95
  });
112
96
  }
113
97
  onTemplateNodeUpdated(t) {
114
- super.onTemplateNodeUpdated(t), [
98
+ var i;
99
+ super.onTemplateNodeUpdated(t);
100
+ const e = this._getRecommendationIdFromNode(t);
101
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
115
102
  this.algorithmControl,
116
103
  this.localeControl,
117
104
  this.currencyControl,
118
105
  this.productLayoutControl,
119
106
  this.filtersControl,
120
107
  this.shuffleControl
121
- ].forEach((o) => {
122
- var i;
123
- o != null && o.api && (o.currentNode = t, (i = o.onTemplateNodeUpdated) == null || i.call(o, t));
108
+ ].forEach((r) => {
109
+ var a;
110
+ r != null && r.api && (r.currentNode = t, (a = r.onTemplateNodeUpdated) == null || a.call(r, t));
124
111
  });
125
112
  }
126
113
  onDestroy() {
@@ -154,52 +141,110 @@ class B extends R {
154
141
  });
155
142
  }
156
143
  /**
157
- * Listen to store changes that require product refresh or regeneration
158
- * - Config changes (size, strategy, filters, etc.) trigger API refetch
159
- * - Currency code changes trigger API refetch (formatting changes are handled in-place)
160
- * - Products array changes (API response) trigger HTML regeneration
144
+ * Syncs persisted node config into the Pinia store's block state.
145
+ *
146
+ * setCurrentBlock() creates a default entry (USD, en_US, mostPopular).
147
+ * For saved templates, the real config lives in the node (e.g., TRY, tr_TR).
148
+ * This method reads it and patches the store so fetchRecommendationProducts()
149
+ * uses the correct values.
150
+ *
151
+ * Uses triggerRefetch: false because the fetch hasn't happened yet —
152
+ * values are being prepared for the upcoming initial fetch.
153
+ */
154
+ _syncNodeConfigToStore() {
155
+ const t = f.getConfig(this.currentNode);
156
+ this.store.patchCurrentBlockConfig({
157
+ strategy: t.strategy,
158
+ language: t.language,
159
+ size: t.size,
160
+ productIds: t.productIds,
161
+ filters: t.filters,
162
+ shuffleProducts: t.shuffleProducts,
163
+ currencySettings: {
164
+ name: t.currency.code,
165
+ value: t.currency.code,
166
+ symbol: t.currency.symbol,
167
+ alignment: t.currency.alignment === "before" ? "0" : "1",
168
+ decimalCount: t.currency.decimalCount.toString(),
169
+ decimalSeparator: t.currency.decimalSeparator,
170
+ thousandSeparator: t.currency.thousandSeparator
171
+ }
172
+ }, { triggerRefetch: !1 });
173
+ }
174
+ /**
175
+ * Fetches initial data for a block (filters, algorithms, products).
176
+ * Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
177
+ * Marks the block as initialized to prevent redundant fetches on re-selection.
178
+ */
179
+ async _fetchBlockData(t) {
180
+ t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
181
+ this.store.fetchRecommendationFilters(),
182
+ this.store.fetchRecommendationCreateData(),
183
+ this.store.fetchRecommendationProducts()
184
+ ])).forEach((o, i) => {
185
+ o.status === "rejected" && console.warn(`Recommendation block: ${[
186
+ "fetchRecommendationFilters",
187
+ "fetchRecommendationCreateData",
188
+ "fetchRecommendationProducts"
189
+ ][i]} failed`, o.reason);
190
+ });
191
+ }
192
+ /**
193
+ * Reads the recommendation-id attribute from the block element within the node
194
+ */
195
+ _getRecommendationIdFromNode(t) {
196
+ const e = P(t);
197
+ if (!e || !("getAttribute" in e))
198
+ return null;
199
+ const o = e.getAttribute(T);
200
+ if (!o)
201
+ return null;
202
+ const i = parseInt(o);
203
+ return Number.isNaN(i) ? null : i;
204
+ }
205
+ /**
206
+ * Listen to store changes that require product refresh or regeneration.
207
+ *
208
+ * Uses configVersion counter (incremented only by patchCurrentBlockConfig)
209
+ * to distinguish user-initiated config changes from internal mutations
210
+ * (e.g., fetchRecommendationCreateData setting preferred currency).
161
211
  */
162
212
  _listenStateUpdates() {
163
213
  const { store: t } = this;
164
- let e = t.recommendationProducts, o = t.recommendationConfigs.currencySettings.value;
165
- this.storeUnsubscription = t.$subscribe((i) => {
166
- var u;
167
- if ("payload" in i) {
168
- const c = i.payload.recommendationConfigs;
169
- if (c) {
170
- const f = Object.keys(c).some((p) => I.has(p)), l = (u = c.currencySettings) == null ? void 0 : u.value, d = l !== void 0 && l !== o;
171
- d && (o = l), (f || d) && this._debouncedFetchProducts();
172
- }
173
- }
174
- const a = t.recommendationProducts, m = a !== e, C = Array.isArray(a) && a.length > 0;
175
- m && C && (e = a, this._debouncedRegenerateWithProducts());
214
+ let e = t.recommendationProducts, o = t.$state.configVersion;
215
+ this.storeUnsubscription = t.$subscribe(() => {
216
+ const i = t.$state.configVersion;
217
+ i !== o && (o = i, this._debouncedFetchProducts());
218
+ const r = t.recommendationProducts, a = r !== e, u = Array.isArray(r) && r.length > 0;
219
+ a && u && (e = r, this._debouncedRegenerateWithProducts());
176
220
  });
177
221
  }
178
222
  }
179
223
  export {
180
- j as ALGORITHM_CONTROL_ID,
181
- _ as AlgorithmControl,
182
- w as CONTROL_BLOCK_ID,
183
- q as CURRENCY_CONTROL_ID,
184
- b as CurrencyControl,
185
- Q as FILTERS_CONTROL_ID,
186
- L as FiltersControl,
187
- X as LOCALE_CONTROL_ID,
188
- N as LocaleControl,
189
- tt as PRODUCT_LAYOUT_CONTROL_ID,
190
- T as ProductLayoutControl,
191
- B as RecommendationBlockControl,
192
- ot as SHUFFLE_CONTROL_ID,
193
- O as ShuffleControl,
194
- st as formatProductPrice,
195
- nt as getBlockElement,
196
- it as getCardComposition,
197
- at as getCurrentLayout,
198
- ct as reapplySpacing,
199
- lt as regenerateProductRows,
200
- D as regenerateProductRowsWithStyles,
201
- ut as setCurrencyAttributes,
202
- dt as updatePricesInPlace,
203
- S as updateProductContentInPlace,
204
- ht as updateSingleProductContent
224
+ W as ALGORITHM_CONTROL_ID,
225
+ p as AlgorithmControl,
226
+ S as CONTROL_BLOCK_ID,
227
+ H as CURRENCY_CONTROL_ID,
228
+ g as CurrencyControl,
229
+ j as FILTERS_CONTROL_ID,
230
+ R as FiltersControl,
231
+ K as LOCALE_CONTROL_ID,
232
+ y as LocaleControl,
233
+ J as PRODUCT_LAYOUT_CONTROL_ID,
234
+ _ as ProductLayoutControl,
235
+ $ as RecommendationBlockControl,
236
+ X as SHUFFLE_CONTROL_ID,
237
+ N as ShuffleControl,
238
+ tt as formatProductPrice,
239
+ P as getBlockElement,
240
+ et as getCardComposition,
241
+ ot as getCurrentLayout,
242
+ rt as reapplySpacing,
243
+ nt as regenerateMobileProductRows,
244
+ it as regenerateProductRows,
245
+ b as regenerateProductRowsWithStyles,
246
+ st as setCurrencyAttributes,
247
+ ct as updatePricesInPlace,
248
+ I as updateProductContentInPlace,
249
+ at as updateSingleProductContent
205
250
  };
@@ -56,11 +56,7 @@ class C extends m {
56
56
  this.currentNode,
57
57
  { language: e },
58
58
  `Changed language to ${e}`
59
- ), this.store.$patch({
60
- recommendationConfigs: {
61
- language: e
62
- }
63
- }));
59
+ ), this.store.patchCurrentBlockConfig({ language: e }));
64
60
  }
65
61
  _listenToFormUpdates() {
66
62
  this.api.onValueChanged(n.LOCALE, (e) => {