@useinsider/guido 2.1.0-beta.99bedd1 → 2.1.0-beta.9a6dc97

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 (150) hide show
  1. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  2. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  3. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  4. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  5. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
  6. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  7. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  8. package/dist/composables/useHtmlValidator.js +114 -104
  9. package/dist/composables/useRecommendation.js +54 -21
  10. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  11. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  12. package/dist/config/migrator/itemsBlockMigrator.js +127 -122
  13. package/dist/config/migrator/recommendationMigrator.js +3 -3
  14. package/dist/enums/extensions/recommendationBlock.js +1 -1
  15. package/dist/enums/recommendation.js +16 -15
  16. package/dist/extensions/Blocks/Recommendation/block.js +133 -9
  17. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  18. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  19. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +69 -0
  20. package/dist/extensions/Blocks/Recommendation/constants/layout.js +24 -0
  21. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +23 -0
  22. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  23. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  24. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  25. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  26. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +104 -0
  27. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
  28. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +207 -0
  29. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
  30. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +321 -0
  31. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
  32. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +168 -0
  33. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
  34. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +381 -0
  35. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  36. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  37. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
  38. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  39. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  40. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  41. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  42. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  44. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +17 -15
  45. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  46. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +346 -0
  47. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  48. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  49. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  50. package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
  51. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  52. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +297 -209
  53. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
  54. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  55. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
  56. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  57. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
  58. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  59. package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
  60. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  61. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  62. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
  63. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  64. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  65. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  66. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  67. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  68. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  69. package/dist/extensions/Blocks/controlFactories.js +125 -93
  70. package/dist/guido.css +1 -1
  71. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +242 -186
  72. package/dist/services/recommendationApi.js +11 -8
  73. package/dist/services/stripoApi.js +20 -17
  74. package/dist/services/templateLibraryApi.js +16 -13
  75. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  76. package/dist/src/composables/useRecommendation.d.ts +1 -0
  77. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  78. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
  79. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  80. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  81. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +55 -0
  82. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  83. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +45 -0
  84. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +42 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  86. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  87. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  88. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  89. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  90. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  91. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  92. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
  93. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  94. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +102 -0
  95. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  96. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
  97. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  98. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +234 -0
  99. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  100. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  101. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
  102. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  103. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  104. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  105. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  106. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  107. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  108. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  109. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  110. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +116 -0
  111. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  112. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  113. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  114. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +139 -468
  115. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  116. package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +23 -0
  117. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  118. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +43 -0
  119. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  120. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  121. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  122. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
  123. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  124. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +174 -0
  125. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  126. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  127. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  128. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  129. package/dist/static/styles/customEditorStyle.css.js +62 -11
  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 +1 -1
  136. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  137. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  138. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  139. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  140. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  141. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  142. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  143. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  144. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  145. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  146. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  147. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
  148. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  149. package/dist/src/extensions/Blocks/Recommendation/templates/migrationTemplate.d.ts +0 -16
  150. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
@@ -0,0 +1,52 @@
1
+ var n = Object.defineProperty;
2
+ var o = (i, e, t) => e in i ? n(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var r = (i, e, t) => o(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommonControl as s } from "../../../common-control.js";
5
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
6
+ const d = "recommendation-filters-control", a = {
7
+ FILTERS: "filterStatus"
8
+ };
9
+ class h extends s {
10
+ constructor() {
11
+ super(...arguments);
12
+ r(this, "store", l());
13
+ r(this, "addFilterListener", () => {
14
+ });
15
+ r(this, "addFilterButton", null);
16
+ }
17
+ getId() {
18
+ return d;
19
+ }
20
+ getTemplate() {
21
+ return `
22
+ <div class="filters-control-container">
23
+ ${this._GuTwoColumns([
24
+ this._GuLabel({ text: "Filters" }),
25
+ this._GuButton({
26
+ name: a.FILTERS,
27
+ label: "Add Filter",
28
+ id: "guido__btn-add-filter"
29
+ })
30
+ ])}
31
+ </div>
32
+ `;
33
+ }
34
+ onRender() {
35
+ this._setupButtonListener();
36
+ }
37
+ onDestroy() {
38
+ var t;
39
+ (t = this.addFilterButton) == null || t.removeEventListener("click", this.addFilterListener);
40
+ }
41
+ _onFilterSelectClick() {
42
+ this.store.openFilterDrawer();
43
+ }
44
+ _setupButtonListener() {
45
+ var t;
46
+ this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (t = this.addFilterButton) == null || t.addEventListener("click", this.addFilterListener);
47
+ }
48
+ }
49
+ export {
50
+ d as FILTERS_CONTROL_ID,
51
+ h as FiltersControl
52
+ };
@@ -0,0 +1,321 @@
1
+ var g = Object.defineProperty;
2
+ var C = (d, c, t) => c in d ? g(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
3
+ var i = (d, c, t) => C(d, typeof c != "symbol" ? c + "" : c, t);
4
+ import { CommonControl as p } from "../../../common-control.js";
5
+ import { DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
6
+ import { RecommendationConfigService as m } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
8
+ import { AlgorithmControl as R } from "./algorithm.js";
9
+ import { ALGORITHM_CONTROL_ID as H } from "./algorithm.js";
10
+ import { CurrencyControl as b } from "./currency.js";
11
+ import { CURRENCY_CONTROL_ID as K } from "./currency.js";
12
+ import { FiltersControl as N } from "./filters.js";
13
+ import { FILTERS_CONTROL_ID as J } from "./filters.js";
14
+ import { LocaleControl as _ } from "./locale.js";
15
+ import { LOCALE_CONTROL_ID as X } from "./locale.js";
16
+ import { ProductLayoutControl as S } from "./productLayout.js";
17
+ import { PRODUCT_LAYOUT_CONTROL_ID as tt } from "./productLayout.js";
18
+ import { ShuffleControl as I } from "./shuffle.js";
19
+ import { SHUFFLE_CONTROL_ID as ot } from "./shuffle.js";
20
+ import { getBlockElement as P, updateProductContentInPlace as L, regenerateProductRowsWithStyles as T } from "./utils.js";
21
+ import { adjustProductsToSize as nt, formatProductPrice as st, getCardComposition as it, getCurrentLayout as at, reapplySpacing as ct, regenerateMobileProductRows as lt, regenerateProductRows as ut, setCurrencyAttributes as dt, updatePricesInPlace as mt, updateSingleProductContent as ht } from "./utils.js";
22
+ import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
23
+ const k = "recommendation-id", D = "ui-elements-recommendation-block";
24
+ class W extends p {
25
+ constructor() {
26
+ super(...arguments);
27
+ i(this, "store", y());
28
+ i(this, "storeUnsubscription", () => {
29
+ });
30
+ // Sub-control instances for lifecycle management
31
+ i(this, "algorithmControl", null);
32
+ i(this, "localeControl", null);
33
+ i(this, "currencyControl", null);
34
+ i(this, "productLayoutControl", null);
35
+ i(this, "filtersControl", null);
36
+ i(this, "shuffleControl", null);
37
+ /**
38
+ * Debounced product fetch to prevent rapid API calls during config changes
39
+ */
40
+ i(this, "_debouncedFetchProducts", h(() => {
41
+ this.store.fetchRecommendationProducts();
42
+ }, 500));
43
+ /**
44
+ * Debounced content update when products arrive from API.
45
+ *
46
+ * Tries in-place update first (preserves user-applied styles) — this succeeds
47
+ * when the product count matches the DOM (algorithm/locale/currency changes).
48
+ *
49
+ * Falls back to full regeneration when product count differs from DOM — this
50
+ * happens after "Number of Products" changes where the DOM still has the old
51
+ * count. The store pads products to the configured size, so in-place only
52
+ * fails when the size actually changed.
53
+ */
54
+ i(this, "_debouncedRegenerateWithProducts", h(() => {
55
+ const t = this.store.recommendationProducts;
56
+ if (!this.currentNode || !this.api)
57
+ return;
58
+ const e = this.api.getDocumentModifier();
59
+ L({
60
+ currentNode: this.currentNode,
61
+ documentModifier: e,
62
+ products: t
63
+ }) || T({
64
+ currentNode: this.currentNode,
65
+ documentModifier: e,
66
+ products: t
67
+ });
68
+ }, 100));
69
+ }
70
+ getId() {
71
+ return D;
72
+ }
73
+ getTemplate() {
74
+ return this.algorithmControl = new R(), this.localeControl = new _(), this.currencyControl = new b(), this.productLayoutControl = new S(), this.filtersControl = new N(), this.shuffleControl = new I(), `
75
+ <div class="recommendation-controls-container">
76
+ ${this.algorithmControl.getTemplate()}
77
+ ${this.localeControl.getTemplate()}
78
+ ${this.currencyControl.getTemplate()}
79
+ ${this.filtersControl.getTemplate()}
80
+ ${this.productLayoutControl.getTemplate()}
81
+ ${this.shuffleControl.getTemplate()}
82
+ </div>
83
+ `;
84
+ }
85
+ async onRender() {
86
+ var e;
87
+ const t = this._getRecommendationIdFromNode(this.currentNode) ?? this.store.currentRecommendationId;
88
+ if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && ((e = this.store.blockStates[t]) != null && e.isInitialized)) {
89
+ this._initializeSubControls();
90
+ return;
91
+ }
92
+ await this._fetchBlockData(t), this._initializeSubControls();
93
+ }
94
+ onTemplateNodeUpdated(t) {
95
+ var s;
96
+ super.onTemplateNodeUpdated(t);
97
+ const e = this._getRecommendationIdFromNode(t);
98
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((s = this.store.blockStates[e]) != null && s.isInitialized) && this._fetchBlockData(e), [
99
+ this.algorithmControl,
100
+ this.localeControl,
101
+ this.currencyControl,
102
+ this.productLayoutControl,
103
+ this.filtersControl,
104
+ this.shuffleControl
105
+ ].forEach((r) => {
106
+ var n;
107
+ r != null && r.api && (r.currentNode = t, (n = r.onTemplateNodeUpdated) == null || n.call(r, t));
108
+ });
109
+ }
110
+ onDestroy() {
111
+ this.storeUnsubscription(), [
112
+ this.algorithmControl,
113
+ this.localeControl,
114
+ this.currencyControl,
115
+ this.productLayoutControl,
116
+ this.filtersControl,
117
+ this.shuffleControl
118
+ ].forEach((e) => {
119
+ var o;
120
+ return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
121
+ });
122
+ }
123
+ /**
124
+ * Initialize all sub-controls with the shared API context
125
+ * Each sub-control manages its own form values and event listeners
126
+ */
127
+ _initializeSubControls() {
128
+ [
129
+ this.algorithmControl,
130
+ this.localeControl,
131
+ this.currencyControl,
132
+ this.productLayoutControl,
133
+ this.filtersControl,
134
+ this.shuffleControl
135
+ ].forEach((e) => {
136
+ var o;
137
+ e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
138
+ });
139
+ }
140
+ /**
141
+ * Syncs persisted node config into the Pinia store's block state.
142
+ *
143
+ * setCurrentBlock() creates a default entry (USD, en_US, mostPopular).
144
+ * For saved templates, the real config lives in the node (e.g., TRY, tr_TR).
145
+ * This method reads it and patches the store so fetchRecommendationProducts()
146
+ * uses the correct values.
147
+ *
148
+ * Uses triggerRefetch: false because the fetch hasn't happened yet —
149
+ * values are being prepared for the upcoming initial fetch.
150
+ */
151
+ _syncNodeConfigToStore() {
152
+ const t = m.getConfig(this.currentNode);
153
+ this.store.patchCurrentBlockConfig({
154
+ strategy: t.strategy,
155
+ language: t.language,
156
+ size: t.size,
157
+ productIds: t.productIds,
158
+ filters: t.filters,
159
+ shuffleProducts: t.shuffleProducts,
160
+ currencySettings: {
161
+ name: t.currency.code,
162
+ value: t.currency.code,
163
+ symbol: t.currency.symbol,
164
+ alignment: t.currency.alignment === "before" ? "0" : "1",
165
+ decimalCount: t.currency.decimalCount.toString(),
166
+ decimalSeparator: t.currency.decimalSeparator,
167
+ thousandSeparator: t.currency.thousandSeparator
168
+ }
169
+ }, { triggerRefetch: !1 });
170
+ }
171
+ /**
172
+ * Fetches initial data for a block in three phases:
173
+ * 1. Shared reference data (algorithms, currencies, filters) — parallel
174
+ * 2. Smart defaults for new blocks (currency, algorithm) — sequential
175
+ * 3. Product data with correct defaults — sequential
176
+ *
177
+ * Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
178
+ * Marks the block as initialized to prevent redundant fetches on re-selection.
179
+ */
180
+ async _fetchBlockData(t) {
181
+ t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
182
+ this.store.fetchRecommendationCreateData(),
183
+ this.store.fetchRecommendationFilters()
184
+ ])).forEach((o, s) => {
185
+ o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][s]} failed`, o.reason);
186
+ }), this._applySmartDefaults();
187
+ try {
188
+ await this.store.fetchRecommendationProducts();
189
+ } catch (o) {
190
+ console.warn("Recommendation block: fetchRecommendationProducts failed", o);
191
+ }
192
+ }
193
+ /**
194
+ * Applies smart defaults for newly dropped blocks.
195
+ *
196
+ * For new blocks (config still matches hardcoded defaults), validates that
197
+ * the default currency and algorithm are available from the API response.
198
+ * If not, falls back to the first available option.
199
+ *
200
+ * Saved templates with user-customized config are left unchanged because
201
+ * their values won't match the hardcoded defaults.
202
+ */
203
+ _applySmartDefaults() {
204
+ if (!this.currentNode || !this.api)
205
+ return;
206
+ const t = m.getConfig(this.currentNode), e = {};
207
+ let o = null, s = null, r = null;
208
+ if (t.currency.code === a.currency.code) {
209
+ const { currencyList: n } = this.store;
210
+ n.length > 0 && (n.some(
211
+ (u) => u.value === `price.${a.currency.code}`
212
+ ) || (o = n[0].value.replace("price.", ""), e.currency = {
213
+ ...a.currency,
214
+ code: o,
215
+ symbol: o
216
+ }));
217
+ }
218
+ if (t.strategy === a.strategy) {
219
+ const n = this.store.getActivePredictiveAlgorithms;
220
+ n.length > 0 && (n.some(
221
+ (u) => u.value === a.strategy
222
+ ) || (s = n[0].value, e.strategy = s));
223
+ }
224
+ if (t.language === a.language) {
225
+ const n = this.store.getLanguages;
226
+ n.length > 0 && (n.some(
227
+ (u) => u.value === a.language
228
+ ) || (r = n[0].value, e.language = r));
229
+ }
230
+ !o && !s && !r || (m.updateConfig(
231
+ this.api,
232
+ this.currentNode,
233
+ e,
234
+ "Applied smart defaults"
235
+ ), this.store.patchCurrentBlockConfig({
236
+ ...o ? {
237
+ currencySettings: {
238
+ name: o,
239
+ value: o,
240
+ symbol: o,
241
+ alignment: a.currency.alignment === "before" ? "0" : "1",
242
+ decimalCount: a.currency.decimalCount.toString(),
243
+ decimalSeparator: a.currency.decimalSeparator,
244
+ thousandSeparator: a.currency.thousandSeparator
245
+ }
246
+ } : {},
247
+ ...s ? { strategy: s } : {},
248
+ ...r ? { language: r } : {}
249
+ }, { triggerRefetch: !1 }));
250
+ }
251
+ /**
252
+ * Reads the recommendation-id attribute from the block element within the node
253
+ */
254
+ _getRecommendationIdFromNode(t) {
255
+ const e = P(t);
256
+ if (!e || !("getAttribute" in e))
257
+ return null;
258
+ const o = e.getAttribute(k);
259
+ if (!o)
260
+ return null;
261
+ const s = parseInt(o);
262
+ return Number.isNaN(s) ? null : s;
263
+ }
264
+ /**
265
+ * Listen to store changes that require product refresh or regeneration.
266
+ *
267
+ * Uses configVersion counter (incremented only by patchCurrentBlockConfig)
268
+ * to distinguish user-initiated config changes from internal mutations
269
+ * (e.g., fetchRecommendationCreateData setting preferred currency).
270
+ *
271
+ * Tracks currentRecommendationId to detect block switches. When the user
272
+ * selects a different recommendation block, the proxy getters (e.g.,
273
+ * recommendationProducts) return the new block's data — a different array
274
+ * reference that would be falsely detected as "new products arrived".
275
+ * We skip that tick and update tracking references instead.
276
+ */
277
+ _listenStateUpdates() {
278
+ const { store: t } = this;
279
+ let e = t.recommendationProducts, o = t.$state.configVersion, s = t.currentRecommendationId;
280
+ this.storeUnsubscription = t.$subscribe(() => {
281
+ const r = t.currentRecommendationId;
282
+ if (r !== s) {
283
+ s = r, e = t.recommendationProducts, o = t.$state.configVersion;
284
+ return;
285
+ }
286
+ const n = t.$state.configVersion;
287
+ n !== o && (o = n, this._debouncedFetchProducts());
288
+ const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
289
+ u && f && (e = l, this._debouncedRegenerateWithProducts());
290
+ });
291
+ }
292
+ }
293
+ export {
294
+ H as ALGORITHM_CONTROL_ID,
295
+ R as AlgorithmControl,
296
+ D as CONTROL_BLOCK_ID,
297
+ K as CURRENCY_CONTROL_ID,
298
+ b as CurrencyControl,
299
+ J as FILTERS_CONTROL_ID,
300
+ N as FiltersControl,
301
+ X as LOCALE_CONTROL_ID,
302
+ _ as LocaleControl,
303
+ tt as PRODUCT_LAYOUT_CONTROL_ID,
304
+ S as ProductLayoutControl,
305
+ W as RecommendationBlockControl,
306
+ ot as SHUFFLE_CONTROL_ID,
307
+ I as ShuffleControl,
308
+ nt as adjustProductsToSize,
309
+ st as formatProductPrice,
310
+ P as getBlockElement,
311
+ it as getCardComposition,
312
+ at as getCurrentLayout,
313
+ ct as reapplySpacing,
314
+ lt as regenerateMobileProductRows,
315
+ ut as regenerateProductRows,
316
+ T as regenerateProductRowsWithStyles,
317
+ dt as setCurrencyAttributes,
318
+ mt as updatePricesInPlace,
319
+ L as updateProductContentInPlace,
320
+ ht as updateSingleProductContent
321
+ };
@@ -0,0 +1,70 @@
1
+ var s = Object.defineProperty;
2
+ var r = (o, t, e) => t in o ? s(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var a = (o, t, e) => r(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { UEAttr as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as c } from "../../../common-control.js";
6
+ import { RecommendationConfigService as i } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as g } from "../../store/recommendation.js";
8
+ const m = "recommendation-locale-control", n = {
9
+ LOCALE: "language"
10
+ };
11
+ class E extends c {
12
+ constructor() {
13
+ super(...arguments);
14
+ // Store is used ONLY for API-fetched data (language options), not for config
15
+ a(this, "store", g());
16
+ }
17
+ getId() {
18
+ return m;
19
+ }
20
+ getTemplate() {
21
+ return `
22
+ <div class="locale-control-container">
23
+ ${this._GuTwoColumns([
24
+ this._GuLabel({ text: "Recommendation Locale" }),
25
+ this._GuSelect({
26
+ name: n.LOCALE,
27
+ placeholder: "Select Recommendation Locale",
28
+ options: this.store.getLanguages
29
+ })
30
+ ])}
31
+ </div>
32
+ `;
33
+ }
34
+ onRender() {
35
+ this._initializeSelectItems(), this._setFormValues(), this._listenToFormUpdates();
36
+ }
37
+ onTemplateNodeUpdated(e) {
38
+ super.onTemplateNodeUpdated(e), this._setFormValues();
39
+ }
40
+ _setFormValues() {
41
+ const e = i.getConfig(this.currentNode);
42
+ this.api.updateValues({
43
+ [n.LOCALE]: e.language
44
+ });
45
+ }
46
+ _initializeSelectItems() {
47
+ this.api.setUIEAttribute(
48
+ n.LOCALE,
49
+ l.SELECTPICKER.items,
50
+ this.store.getLanguages
51
+ );
52
+ }
53
+ _onLocaleChange(e) {
54
+ !this.currentNode || i.getConfig(this.currentNode).language === e || (i.updateConfig(
55
+ this.api,
56
+ this.currentNode,
57
+ { language: e },
58
+ `Changed language to ${e}`
59
+ ), this.store.patchCurrentBlockConfig({ language: e }));
60
+ }
61
+ _listenToFormUpdates() {
62
+ this.api.onValueChanged(n.LOCALE, (e) => {
63
+ this._onLocaleChange(e);
64
+ });
65
+ }
66
+ }
67
+ export {
68
+ m as LOCALE_CONTROL_ID,
69
+ E as LocaleControl
70
+ };
@@ -0,0 +1,168 @@
1
+ var u = Object.defineProperty;
2
+ var _ = (n, r, t) => r in n ? u(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t;
3
+ var a = (n, r, t) => _(n, typeof r != "symbol" ? r + "" : r, t);
4
+ import { EditorStatePropertyType as c, PreviewDeviceMode as C } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as R } from "../../../common-control.js";
6
+ import { MAX_PRODUCT_COUNT as h, MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as g, DEFAULT_COLUMN_SPACING as m, DEFAULT_MOBILE_COLUMN_SPACING as O } from "../../constants/layout.js";
7
+ import { RecommendationConfigService as i } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
9
+ import { ensureMobileCssRulesExist as I } from "../mobileLayout/cssRules.js";
10
+ import { getCurrentLayout as N, regenerateMobileProductRows as f, adjustProductsToSize as b, regenerateProductRowsWithStyles as P } from "./utils.js";
11
+ import { useDebounceFn as L } from "../../../../../node_modules/@vueuse/shared/index.js";
12
+ const M = "recommendation-product-layout-control", e = {
13
+ PRODUCT_COUNT: "size",
14
+ PRODUCT_IN_ROW: "cardsInRow",
15
+ PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
16
+ MOBILE_CARDS_IN_ROW: "mobileCardsInRow",
17
+ MOBILE_CARDS_IN_ROW_LABEL: "mobileCardsInRowLabel"
18
+ };
19
+ class V extends R {
20
+ constructor() {
21
+ super(...arguments);
22
+ // Store is used for backward compatibility with product fetching and regeneration
23
+ a(this, "store", l());
24
+ a(this, "storeUnsubscription", () => {
25
+ });
26
+ a(this, "_debouncedRegenerateProductRows", L(() => {
27
+ this._regenerateProductRows();
28
+ }, 500));
29
+ }
30
+ getId() {
31
+ return M;
32
+ }
33
+ getTemplate() {
34
+ return `
35
+ <div class="product-layout-control-container">
36
+ ${this._GuTwoColumns([
37
+ this._GuLabel({ text: "Number of Products" }),
38
+ this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: h }),
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: g
51
+ })
52
+ ])}
53
+ </div>
54
+ `;
55
+ }
56
+ onRender() {
57
+ this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._subscribeToEditorModeChanges();
58
+ }
59
+ onTemplateNodeUpdated(t) {
60
+ super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
61
+ }
62
+ onDestroy() {
63
+ this.storeUnsubscription();
64
+ }
65
+ _setFormValues() {
66
+ const t = i.getConfig(this.currentNode);
67
+ this.api.updateValues({
68
+ [e.PRODUCT_COUNT]: t.size,
69
+ [e.PRODUCT_IN_ROW]: t.cardsInRow,
70
+ [e.MOBILE_CARDS_IN_ROW]: t.mobileCardsInRow
71
+ });
72
+ }
73
+ /**
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()[c.previewDeviceMode] === C.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
85
+ */
86
+ _updateProductsInRowVisibility() {
87
+ const o = (i.getConfig(this.currentNode).layout || N(this.currentNode)) === "grid", d = this._isMobileMode();
88
+ this.api.setVisibility(e.PRODUCT_IN_ROW, o && !d), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, o && !d), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, o && d), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, o && d);
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
+ c.previewDeviceMode,
98
+ () => {
99
+ this._updateProductsInRowVisibility();
100
+ }
101
+ );
102
+ }
103
+ _onProductCountChange(t) {
104
+ !this.currentNode || i.getConfig(this.currentNode).size === t || (i.updateConfig(
105
+ this.api,
106
+ this.currentNode,
107
+ { size: t },
108
+ `Changed product count to ${t}`
109
+ ), this.store.patchCurrentBlockConfig({ size: t }));
110
+ }
111
+ _onProductsInRowChange(t) {
112
+ if (!this.currentNode || i.getConfig(this.currentNode).cardsInRow === t)
113
+ return;
114
+ const o = t === 1 ? 0 : m;
115
+ i.updateConfig(
116
+ this.api,
117
+ this.currentNode,
118
+ { cardsInRow: t, columnSpacing: o },
119
+ `Changed products per row to ${t}`
120
+ ), this.store.patchCurrentBlockConfig({ cardsInRow: t }, { triggerRefetch: !1 }), this._debouncedRegenerateProductRows();
121
+ }
122
+ _onMobileCardsInRowChange(t) {
123
+ if (!this.currentNode || i.getConfig(this.currentNode).mobileCardsInRow === t)
124
+ return;
125
+ const o = t === 1 ? 0 : O;
126
+ i.updateConfig(
127
+ this.api,
128
+ this.currentNode,
129
+ { mobileCardsInRow: t, mobileColumnSpacing: o },
130
+ `Changed mobile products per row to ${t}`
131
+ ), I(this.api), f({
132
+ currentNode: this.currentNode,
133
+ documentModifier: this.api.getDocumentModifier()
134
+ });
135
+ }
136
+ _regenerateProductRows() {
137
+ const t = i.getConfig(this.currentNode), s = parseInt(t.size) || 6, o = b(this.store.recommendationProducts, s);
138
+ P({
139
+ currentNode: this.currentNode,
140
+ documentModifier: this.api.getDocumentModifier(),
141
+ products: o
142
+ });
143
+ }
144
+ _listenToFormUpdates() {
145
+ this.api.onValueChanged(e.PRODUCT_COUNT, (t) => {
146
+ this._onProductCountChange(t.toString());
147
+ }), this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
148
+ this._onProductsInRowChange(Number(t));
149
+ }), this.api.onValueChanged(e.MOBILE_CARDS_IN_ROW, (t) => {
150
+ this._onMobileCardsInRowChange(Number(t));
151
+ });
152
+ }
153
+ /**
154
+ * Subscribe to store changes to update visibility when layout changes
155
+ * This is still needed because layout changes come from LayoutControl
156
+ */
157
+ _listenStateUpdates() {
158
+ let t = this.store.recommendationConfigs.orientation;
159
+ this.storeUnsubscription = this.store.$subscribe(() => {
160
+ const s = this.store.recommendationConfigs.orientation;
161
+ s !== t && (t = s, this._updateProductsInRowVisibility());
162
+ });
163
+ }
164
+ }
165
+ export {
166
+ M as PRODUCT_LAYOUT_CONTROL_ID,
167
+ V as ProductLayoutControl
168
+ };
@@ -0,0 +1,67 @@
1
+ var r = Object.defineProperty;
2
+ var f = (o, t, e) => t in o ? r(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var n = (o, t, e) => f(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { UEAttr as u } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as l } from "../../../common-control.js";
6
+ import { RecommendationConfigService as s } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
8
+ const h = "recommendation-shuffle-control", i = {
9
+ SHUFFLE_PRODUCTS: "shuffleProducts"
10
+ };
11
+ class S extends l {
12
+ constructor() {
13
+ super(...arguments);
14
+ // Store is used for backward compatibility with product fetching
15
+ n(this, "store", d());
16
+ }
17
+ getId() {
18
+ return h;
19
+ }
20
+ getTemplate() {
21
+ return `
22
+ <div class="shuffle-control-container">
23
+ ${this._GuTwoColumns([
24
+ this._GuLabel({ text: "Shuffle Recommended Products" }),
25
+ this._GuToggle(i.SHUFFLE_PRODUCTS)
26
+ ])}
27
+ </div>
28
+ `;
29
+ }
30
+ onRender() {
31
+ this._initializeToggle(), this._setFormValues(), this._listenToFormUpdates();
32
+ }
33
+ onTemplateNodeUpdated(e) {
34
+ super.onTemplateNodeUpdated(e), this._setFormValues();
35
+ }
36
+ _setFormValues() {
37
+ const e = s.getConfig(this.currentNode);
38
+ this.api.updateValues({
39
+ [i.SHUFFLE_PRODUCTS]: e.shuffleProducts
40
+ });
41
+ }
42
+ _initializeToggle() {
43
+ const e = s.getConfig(this.currentNode);
44
+ this.api.setUIEAttribute(
45
+ i.SHUFFLE_PRODUCTS,
46
+ u.SELECTPICKER.items,
47
+ e.shuffleProducts
48
+ );
49
+ }
50
+ _onShuffleChange(e) {
51
+ !this.currentNode || s.getConfig(this.currentNode).shuffleProducts === e || (s.updateConfig(
52
+ this.api,
53
+ this.currentNode,
54
+ { shuffleProducts: e },
55
+ `${e ? "Enabled" : "Disabled"} product shuffle`
56
+ ), this.store.patchCurrentBlockConfig({ shuffleProducts: e }));
57
+ }
58
+ _listenToFormUpdates() {
59
+ this.api.onValueChanged(i.SHUFFLE_PRODUCTS, (e) => {
60
+ this._onShuffleChange(!!e);
61
+ });
62
+ }
63
+ }
64
+ export {
65
+ h as SHUFFLE_CONTROL_ID,
66
+ S as ShuffleControl
67
+ };