@useinsider/guido 2.1.0-beta.67fc452 → 2.1.0-beta.e13d291

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 (119) hide show
  1. package/dist/@types/config/schemas.js +17 -17
  2. package/dist/config/migrator/recommendationMigrator.js +2 -2
  3. package/dist/extensions/Blocks/Recommendation/block.js +40 -6
  4. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  5. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  6. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +64 -0
  7. package/dist/extensions/Blocks/Recommendation/constants/layout.js +20 -0
  8. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +19 -0
  9. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  10. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  11. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  12. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  13. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +96 -0
  14. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +110 -0
  15. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +204 -0
  16. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +54 -0
  17. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +205 -0
  18. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +74 -0
  19. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +118 -0
  20. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +71 -0
  21. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -0
  22. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  23. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +76 -0
  24. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  25. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  26. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  27. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  28. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  29. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  30. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
  31. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  32. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
  33. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  34. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  35. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  36. package/dist/extensions/Blocks/Recommendation/services/configService.js +239 -0
  37. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  38. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +41 -36
  39. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +233 -0
  40. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  41. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +69 -0
  42. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  43. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +174 -0
  44. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  45. package/dist/extensions/Blocks/Recommendation/templates/utils.js +121 -0
  46. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  47. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  48. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
  49. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  50. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  51. package/dist/extensions/Blocks/controlFactories.js +125 -93
  52. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +223 -169
  53. package/dist/services/recommendationApi.js +10 -9
  54. package/dist/src/@types/config/schemas.d.ts +2 -2
  55. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  56. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +34 -0
  57. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  58. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  59. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
  60. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  61. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +35 -0
  62. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +31 -0
  63. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  64. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  65. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  66. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  67. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  68. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  69. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +45 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +57 -0
  73. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  74. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +42 -0
  75. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  76. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +214 -0
  77. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  78. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +16 -0
  79. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  80. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  81. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  82. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  83. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  84. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  86. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  87. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
  88. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  89. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  90. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  91. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +17 -16
  92. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  93. package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
  94. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  95. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +39 -0
  96. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  97. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  98. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  99. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +54 -0
  100. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  101. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +154 -0
  102. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  103. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  104. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  105. package/dist/static/styles/customEditorStyle.css.js +25 -2
  106. package/package.json +1 -1
  107. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  108. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  109. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  110. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  111. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  112. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  113. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  114. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  115. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  116. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  117. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  118. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  119. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
@@ -0,0 +1,54 @@
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.$patch({
43
+ filterSelectionDrawerStatus: !0
44
+ });
45
+ }
46
+ _setupButtonListener() {
47
+ var t;
48
+ this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (t = this.addFilterButton) == null || t.addEventListener("click", this.addFilterListener);
49
+ }
50
+ }
51
+ export {
52
+ d as FILTERS_CONTROL_ID,
53
+ h as FiltersControl
54
+ };
@@ -0,0 +1,205 @@
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 {
30
+ constructor() {
31
+ super(...arguments);
32
+ r(this, "store", P());
33
+ r(this, "storeUnsubscription", () => {
34
+ });
35
+ // Track if initial data has been fetched to avoid redundant API calls
36
+ r(this, "hasInitializedData", !1);
37
+ // 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);
44
+ /**
45
+ * Debounced product fetch to prevent rapid API calls during config changes
46
+ */
47
+ r(this, "_debouncedFetchProducts", h(() => {
48
+ this.store.fetchRecommendationProducts();
49
+ }, 500));
50
+ /**
51
+ * Debounced regeneration when products arrive from API
52
+ * Tries in-place update first to preserve styles, falls back to full regeneration
53
+ */
54
+ r(this, "_debouncedRegenerateWithProducts", h(() => {
55
+ const t = this.store.recommendationProducts;
56
+ if (!this.currentNode || !this.api)
57
+ return;
58
+ const e = this.api.getDocumentModifier();
59
+ S({
60
+ currentNode: this.currentNode,
61
+ documentModifier: e,
62
+ products: t
63
+ }) || this._regenerateWithProducts(t);
64
+ }, 100));
65
+ }
66
+ getId() {
67
+ return w;
68
+ }
69
+ 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(), `
71
+ <div class="recommendation-controls-container">
72
+ ${this.algorithmControl.getTemplate()}
73
+ ${this.localeControl.getTemplate()}
74
+ ${this.currencyControl.getTemplate()}
75
+ ${this.filtersControl.getTemplate()}
76
+ ${this.productLayoutControl.getTemplate()}
77
+ ${this.shuffleControl.getTemplate()}
78
+ </div>
79
+ `;
80
+ }
81
+ async onRender() {
82
+ if (this._listenStateUpdates(), this.hasInitializedData) {
83
+ this._initializeSubControls();
84
+ return;
85
+ }
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();
97
+ }
98
+ /**
99
+ * Immediately regenerate products with styles (no debounce)
100
+ * Used for initial load after fetch completes
101
+ */
102
+ _regenerateWithProducts(t) {
103
+ if (!this.currentNode || !this.api) {
104
+ console.warn("[Recommendation] Cannot regenerate - missing currentNode or api");
105
+ return;
106
+ }
107
+ D({
108
+ currentNode: this.currentNode,
109
+ documentModifier: this.api.getDocumentModifier(),
110
+ products: t
111
+ });
112
+ }
113
+ onTemplateNodeUpdated(t) {
114
+ super.onTemplateNodeUpdated(t), [
115
+ this.algorithmControl,
116
+ this.localeControl,
117
+ this.currencyControl,
118
+ this.productLayoutControl,
119
+ this.filtersControl,
120
+ this.shuffleControl
121
+ ].forEach((o) => {
122
+ var i;
123
+ o != null && o.api && (o.currentNode = t, (i = o.onTemplateNodeUpdated) == null || i.call(o, t));
124
+ });
125
+ }
126
+ onDestroy() {
127
+ this.storeUnsubscription(), [
128
+ this.algorithmControl,
129
+ this.localeControl,
130
+ this.currencyControl,
131
+ this.productLayoutControl,
132
+ this.filtersControl,
133
+ this.shuffleControl
134
+ ].forEach((e) => {
135
+ var o;
136
+ return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
137
+ });
138
+ }
139
+ /**
140
+ * Initialize all sub-controls with the shared API context
141
+ * Each sub-control manages its own form values and event listeners
142
+ */
143
+ _initializeSubControls() {
144
+ [
145
+ this.algorithmControl,
146
+ this.localeControl,
147
+ this.currencyControl,
148
+ this.productLayoutControl,
149
+ this.filtersControl,
150
+ this.shuffleControl
151
+ ].forEach((e) => {
152
+ var o;
153
+ e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
154
+ });
155
+ }
156
+ /**
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
161
+ */
162
+ _listenStateUpdates() {
163
+ 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());
176
+ });
177
+ }
178
+ }
179
+ 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
205
+ };
@@ -0,0 +1,74 @@
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 m } from "../../../common-control.js";
6
+ import { RecommendationConfigService as i } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as c } from "../../store/recommendation.js";
8
+ const g = "recommendation-locale-control", n = {
9
+ LOCALE: "language"
10
+ };
11
+ class C extends m {
12
+ constructor() {
13
+ super(...arguments);
14
+ // Store is used ONLY for API-fetched data (language options), not for config
15
+ a(this, "store", c());
16
+ }
17
+ getId() {
18
+ return g;
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.updateConfig(
55
+ this.api,
56
+ this.currentNode,
57
+ { language: e },
58
+ `Changed language to ${e}`
59
+ ), this.store.$patch({
60
+ recommendationConfigs: {
61
+ language: e
62
+ }
63
+ }));
64
+ }
65
+ _listenToFormUpdates() {
66
+ this.api.onValueChanged(n.LOCALE, (e) => {
67
+ this._onLocaleChange(e);
68
+ });
69
+ }
70
+ }
71
+ export {
72
+ g as LOCALE_CONTROL_ID,
73
+ C as LocaleControl
74
+ };
@@ -0,0 +1,118 @@
1
+ var u = Object.defineProperty;
2
+ var a = (i, e, t) => e in i ? u(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var n = (i, e, t) => a(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommonControl as c } from "../../../common-control.js";
5
+ import { MAX_PRODUCT_COUNT as _, MAX_PRODUCTS_PER_ROW as h } from "../../constants/layout.js";
6
+ import { RecommendationConfigService as s } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
8
+ import { getCurrentLayout as C, regenerateProductRowsWithStyles as m } from "./utils.js";
9
+ import { useDebounceFn as p } from "../../../../../node_modules/@vueuse/shared/index.js";
10
+ const O = "recommendation-product-layout-control", o = {
11
+ PRODUCT_COUNT: "size",
12
+ PRODUCT_IN_ROW: "cardsInRow",
13
+ PRODUCT_IN_ROW_LABEL: "cardsInRowLabel"
14
+ };
15
+ class I extends c {
16
+ constructor() {
17
+ super(...arguments);
18
+ // Store is used for backward compatibility with product fetching and regeneration
19
+ n(this, "store", R());
20
+ n(this, "storeUnsubscription", () => {
21
+ });
22
+ n(this, "_debouncedRegenerateProductRows", p(() => {
23
+ this._regenerateProductRows();
24
+ }, 500));
25
+ }
26
+ getId() {
27
+ return O;
28
+ }
29
+ getTemplate() {
30
+ return `
31
+ <div class="product-layout-control-container">
32
+ ${this._GuTwoColumns([
33
+ this._GuLabel({ text: "Number of Products" }),
34
+ this._GuCounter({ name: o.PRODUCT_COUNT, maxValue: _ }),
35
+ this._GuLabel({ text: "Products in One Row", name: o.PRODUCT_IN_ROW_LABEL }),
36
+ this._GuCounter({ name: o.PRODUCT_IN_ROW, maxValue: h })
37
+ ])}
38
+ </div>
39
+ `;
40
+ }
41
+ onRender() {
42
+ this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates();
43
+ }
44
+ onTemplateNodeUpdated(t) {
45
+ super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
46
+ }
47
+ onDestroy() {
48
+ this.storeUnsubscription();
49
+ }
50
+ _setFormValues() {
51
+ const t = s.getConfig(this.currentNode);
52
+ this.api.updateValues({
53
+ [o.PRODUCT_COUNT]: t.size,
54
+ [o.PRODUCT_IN_ROW]: t.cardsInRow
55
+ });
56
+ }
57
+ /**
58
+ * Updates "Products in One Row" visibility based on layout orientation
59
+ * This control is hidden for list layout (products always take full width)
60
+ * Reads from node config first, falls back to DOM
61
+ */
62
+ _updateProductsInRowVisibility() {
63
+ const d = (s.getConfig(this.currentNode).layout || C(this.currentNode)) === "grid";
64
+ this.api.setVisibility(o.PRODUCT_IN_ROW, d), this.api.setVisibility(o.PRODUCT_IN_ROW_LABEL, d);
65
+ }
66
+ _onProductCountChange(t) {
67
+ this.currentNode && (s.updateConfig(
68
+ this.api,
69
+ this.currentNode,
70
+ { size: t },
71
+ `Changed product count to ${t}`
72
+ ), this.store.$patch({
73
+ recommendationConfigs: {
74
+ size: t
75
+ }
76
+ }), this._debouncedRegenerateProductRows());
77
+ }
78
+ _onProductsInRowChange(t) {
79
+ this.currentNode && (s.updateConfig(
80
+ this.api,
81
+ this.currentNode,
82
+ { cardsInRow: t },
83
+ `Changed products per row to ${t}`
84
+ ), this.store.$patch({
85
+ recommendationConfigs: {
86
+ cardsInRow: t
87
+ }
88
+ }), this._debouncedRegenerateProductRows());
89
+ }
90
+ _regenerateProductRows() {
91
+ m({
92
+ currentNode: this.currentNode,
93
+ documentModifier: this.api.getDocumentModifier()
94
+ });
95
+ }
96
+ _listenToFormUpdates() {
97
+ this.api.onValueChanged(o.PRODUCT_COUNT, (t) => {
98
+ this._onProductCountChange(t.toString());
99
+ }), this.api.onValueChanged(o.PRODUCT_IN_ROW, (t) => {
100
+ this._onProductsInRowChange(Number(t));
101
+ });
102
+ }
103
+ /**
104
+ * Subscribe to store changes to update visibility when layout changes
105
+ * This is still needed because layout changes come from LayoutControl
106
+ */
107
+ _listenStateUpdates() {
108
+ let t = this.store.recommendationConfigs.orientation;
109
+ this.storeUnsubscription = this.store.$subscribe(() => {
110
+ const r = this.store.recommendationConfigs.orientation;
111
+ r !== t && (t = r, this._updateProductsInRowVisibility());
112
+ });
113
+ }
114
+ }
115
+ export {
116
+ O as PRODUCT_LAYOUT_CONTROL_ID,
117
+ I as ProductLayoutControl
118
+ };
@@ -0,0 +1,71 @@
1
+ var r = Object.defineProperty;
2
+ var u = (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) => u(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { UEAttr as f } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as l } from "../../../common-control.js";
6
+ import { RecommendationConfigService as i } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
8
+ const a = "recommendation-shuffle-control", s = {
9
+ SHUFFLE_PRODUCTS: "shuffleProducts"
10
+ };
11
+ class C 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 a;
19
+ }
20
+ getTemplate() {
21
+ return `
22
+ <div class="shuffle-control-container">
23
+ ${this._GuTwoColumns([
24
+ this._GuLabel({ text: "Shuffle Recommended Products" }),
25
+ this._GuToggle(s.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 = i.getConfig(this.currentNode);
38
+ this.api.updateValues({
39
+ [s.SHUFFLE_PRODUCTS]: e.shuffleProducts
40
+ });
41
+ }
42
+ _initializeToggle() {
43
+ const e = i.getConfig(this.currentNode);
44
+ this.api.setUIEAttribute(
45
+ s.SHUFFLE_PRODUCTS,
46
+ f.SELECTPICKER.items,
47
+ e.shuffleProducts
48
+ );
49
+ }
50
+ _onShuffleChange(e) {
51
+ this.currentNode && (i.updateConfig(
52
+ this.api,
53
+ this.currentNode,
54
+ { shuffleProducts: e },
55
+ `${e ? "Enabled" : "Disabled"} product shuffle`
56
+ ), this.store.$patch({
57
+ recommendationConfigs: {
58
+ shuffleProducts: e
59
+ }
60
+ }));
61
+ }
62
+ _listenToFormUpdates() {
63
+ this.api.onValueChanged(s.SHUFFLE_PRODUCTS, (e) => {
64
+ this._onShuffleChange(!!e);
65
+ });
66
+ }
67
+ }
68
+ export {
69
+ a as SHUFFLE_CONTROL_ID,
70
+ C as ShuffleControl
71
+ };