@useinsider/guido 2.1.0-beta.a720424 → 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 (117) hide show
  1. package/dist/config/migrator/recommendationMigrator.js +2 -2
  2. package/dist/extensions/Blocks/Recommendation/block.js +40 -6
  3. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
  4. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
  5. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +64 -0
  6. package/dist/extensions/Blocks/Recommendation/constants/layout.js +20 -0
  7. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +19 -0
  8. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
  9. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
  10. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
  11. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
  12. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +96 -0
  13. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +110 -0
  14. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +204 -0
  15. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +54 -0
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +205 -0
  17. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +74 -0
  18. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +118 -0
  19. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +71 -0
  20. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -0
  21. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
  22. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +76 -0
  23. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
  24. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
  25. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
  26. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
  27. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
  28. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
  29. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
  30. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
  31. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
  32. package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
  33. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
  34. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
  35. package/dist/extensions/Blocks/Recommendation/services/configService.js +239 -0
  36. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
  37. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +41 -36
  38. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +233 -0
  39. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  40. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +69 -0
  41. package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
  42. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +174 -0
  43. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
  44. package/dist/extensions/Blocks/Recommendation/templates/utils.js +121 -0
  45. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
  46. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  47. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
  48. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
  49. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  50. package/dist/extensions/Blocks/controlFactories.js +125 -93
  51. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +223 -169
  52. package/dist/services/recommendationApi.js +10 -9
  53. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  54. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +34 -0
  55. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
  56. package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
  57. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
  58. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
  59. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +35 -0
  60. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +31 -0
  61. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
  62. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
  63. package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
  64. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
  65. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
  66. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
  67. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
  68. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +45 -0
  69. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +57 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +42 -0
  73. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
  74. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +214 -0
  75. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
  76. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +16 -0
  77. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
  78. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
  79. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
  80. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
  81. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
  82. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
  83. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
  84. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
  85. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
  86. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
  87. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
  88. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
  89. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +17 -16
  90. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
  91. package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
  92. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
  93. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +39 -0
  94. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
  95. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
  96. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
  97. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +54 -0
  98. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
  99. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +154 -0
  100. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
  101. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  102. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  103. package/dist/static/styles/customEditorStyle.css.js +25 -2
  104. package/package.json +1 -1
  105. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
  106. package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
  107. package/dist/extensions/Blocks/Recommendation/control.js +0 -336
  108. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
  109. package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
  110. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
  111. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
  112. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
  113. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
  114. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
  115. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
  116. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
  117. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
@@ -0,0 +1,96 @@
1
+ var c = Object.defineProperty;
2
+ var d = (o, e, t) => e in o ? c(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var n = (o, e, t) => d(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { ModificationDescription as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
+ import { LAYOUT_OPTIONS as g } from "../../constants/layout.js";
7
+ import { RecommendationConfigService as i } from "../../services/configService.js";
8
+ import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
9
+ import { getCurrentLayout as u, getBlockElement as f, regenerateProductRowsWithStyles as p } from "../main/utils.js";
10
+ const L = "recommendation-layout-control", r = {
11
+ LAYOUT: "layout"
12
+ }, T = {
13
+ LAYOUT: "data-layout"
14
+ };
15
+ class Y extends h {
16
+ constructor() {
17
+ super(...arguments);
18
+ n(this, "store", l());
19
+ n(this, "isChangingLayout", !1);
20
+ }
21
+ getId() {
22
+ return L;
23
+ }
24
+ getTemplate() {
25
+ return `
26
+ <div class="layout-control-container">
27
+ ${this._GuTwoColumns([
28
+ this._GuLabel({ text: "Layout Orientation" }),
29
+ this._GuRadioButton({
30
+ name: r.LAYOUT,
31
+ buttons: g
32
+ })
33
+ ])}
34
+ </div>
35
+ `;
36
+ }
37
+ onRender() {
38
+ this._setFormValues(), this._listenToFormUpdates();
39
+ }
40
+ onTemplateNodeUpdated(t) {
41
+ super.onTemplateNodeUpdated(t), this._setFormValues();
42
+ }
43
+ _setFormValues() {
44
+ const s = i.getConfig(this.currentNode).layout || u(this.currentNode);
45
+ this.api.updateValues({
46
+ [r.LAYOUT]: s
47
+ });
48
+ }
49
+ /**
50
+ * Handles layout change
51
+ * Updates node config, data attribute and regenerates product rows
52
+ */
53
+ _onLayoutChange(t) {
54
+ if (this.isChangingLayout || !this.currentNode || (i.getConfig(this.currentNode).layout || u(this.currentNode)) === t)
55
+ return;
56
+ const a = f(this.currentNode);
57
+ if (a) {
58
+ this.isChangingLayout = !0;
59
+ try {
60
+ i.updateConfig(
61
+ this.api,
62
+ this.currentNode,
63
+ { layout: t },
64
+ `Changed layout to ${t}`
65
+ ), this.store.$patch({
66
+ recommendationConfigs: {
67
+ orientation: t
68
+ }
69
+ }), this.api.getDocumentModifier().modifyHtml(a).setAttribute(T.LAYOUT, t).apply(new m(`Update layout to ${t}`)), this._regenerateProductRows(t);
70
+ } finally {
71
+ this.isChangingLayout = !1;
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Regenerates product rows based on the selected layout
77
+ * Uses unified style-preserving regeneration to maintain user customizations
78
+ * @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
79
+ */
80
+ _regenerateProductRows(t) {
81
+ this.currentNode && p({
82
+ currentNode: this.currentNode,
83
+ documentModifier: this.api.getDocumentModifier(),
84
+ layout: t
85
+ });
86
+ }
87
+ _listenToFormUpdates() {
88
+ this.api.onValueChanged(r.LAYOUT, (t) => {
89
+ this._onLayoutChange(t);
90
+ });
91
+ }
92
+ }
93
+ export {
94
+ L as LAYOUT_CONTROL_ID,
95
+ Y as LayoutControl
96
+ };
@@ -0,0 +1,110 @@
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";
6
+ import { RecommendationConfigService as n } from "../../services/configService.js";
7
+ import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
8
+ const g = "recommendation-algorithm-control", e = {
9
+ ALGORITHM: "strategy",
10
+ PRODUCT_IDS: "productIds"
11
+ };
12
+ class T extends l {
13
+ constructor() {
14
+ super(...arguments);
15
+ // Store is used ONLY for API-fetched data (algorithms list), not for config
16
+ a(this, "store", m());
17
+ }
18
+ getId() {
19
+ return g;
20
+ }
21
+ getTemplate() {
22
+ return `
23
+ <div class="algorithm-control-container">
24
+ ${this._GuTwoColumns([
25
+ this._GuLabel({ text: "Recommendation Algorithm" }),
26
+ this._GuSelect({
27
+ name: e.ALGORITHM,
28
+ placeholder: "Select Recommendation Algorithm",
29
+ options: this.store.getActivePredictiveAlgorithms
30
+ }),
31
+ this._GuLabel({ text: "Product Ids", name: `${e.PRODUCT_IDS}_label` }),
32
+ this._GuTextInput({
33
+ name: e.PRODUCT_IDS,
34
+ placeholder: "Enter Product Ids",
35
+ className: "es-180w"
36
+ })
37
+ ])}
38
+ </div>
39
+ `;
40
+ }
41
+ onRender() {
42
+ this._initializeSelectItems(), this._setFormValues(), this._listenToFormUpdates();
43
+ }
44
+ onTemplateNodeUpdated(t) {
45
+ super.onTemplateNodeUpdated(t), this._setFormValues();
46
+ }
47
+ _setFormValues() {
48
+ const t = n.getConfig(this.currentNode);
49
+ this._setProductIdsVisibility(t.strategy), this.api.updateValues({
50
+ [e.ALGORITHM]: t.strategy,
51
+ [e.PRODUCT_IDS]: t.productIds.join(",")
52
+ });
53
+ }
54
+ _initializeSelectItems() {
55
+ var s;
56
+ const t = (s = this.store) == null ? void 0 : s.getActivePredictiveAlgorithms;
57
+ if (t != null && t.length)
58
+ try {
59
+ this.api.setUIEAttribute(
60
+ e.ALGORITHM,
61
+ h.SELECTPICKER.items,
62
+ t
63
+ );
64
+ } catch (r) {
65
+ console.warn("[AlgorithmControl] Failed to set algorithm options:", r);
66
+ }
67
+ }
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);
71
+ }
72
+ _onAlgorithmChange(t) {
73
+ this.currentNode && (n.updateConfig(
74
+ this.api,
75
+ this.currentNode,
76
+ { strategy: t },
77
+ `Changed algorithm to ${t}`
78
+ ), this.store.$patch({
79
+ recommendationConfigs: {
80
+ strategy: t
81
+ }
82
+ }), this._setProductIdsVisibility(t));
83
+ }
84
+ _onProductIdsChange(t) {
85
+ if (!this.currentNode)
86
+ return;
87
+ const s = t.split(",").map((r) => r.trim()).filter(Boolean);
88
+ n.updateConfig(
89
+ this.api,
90
+ this.currentNode,
91
+ { productIds: s },
92
+ "Updated product IDs"
93
+ ), this.store.$patch({
94
+ recommendationConfigs: {
95
+ productIds: s
96
+ }
97
+ });
98
+ }
99
+ _listenToFormUpdates() {
100
+ this.api.onValueChanged(e.ALGORITHM, (t) => {
101
+ this._onAlgorithmChange(t);
102
+ }), this.api.onValueChanged(e.PRODUCT_IDS, (t) => {
103
+ this._onProductIdsChange(t);
104
+ });
105
+ }
106
+ }
107
+ export {
108
+ g as ALGORITHM_CONTROL_ID,
109
+ T as AlgorithmControl
110
+ };
@@ -0,0 +1,204 @@
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";
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 = {
11
+ CURRENCY: "currencyCode",
12
+ CURRENCY_LOCATION: "currencyAlignment",
13
+ CURRENCY_SYMBOL: "currencySymbol",
14
+ CURRENCY_THOUSAND_SEPARATOR: "currencyThousandSeparator",
15
+ CURRENCY_DECIMAL_SEPARATOR: "currencyDecimalSeparator",
16
+ CURRENCY_DECIMAL_COUNT: "currencyDecimalCount"
17
+ };
18
+ class b extends m {
19
+ constructor() {
20
+ super(...arguments);
21
+ // Store is used ONLY for API-fetched data (currency list), not for config
22
+ c(this, "store", d());
23
+ c(this, "storeUnsubscription", () => {
24
+ });
25
+ }
26
+ getId() {
27
+ return N;
28
+ }
29
+ getTemplate() {
30
+ return `
31
+ <div class="currency-control-container">
32
+ ${this._GuTwoColumns([
33
+ this._GuLabel({ text: "Currency" }),
34
+ this._GuSelect({
35
+ name: t.CURRENCY,
36
+ placeholder: "Select Currency",
37
+ options: this.store.currencyList
38
+ }),
39
+ this._GuLabel({ text: "Currency Location" }),
40
+ this._GuSelect({
41
+ name: t.CURRENCY_LOCATION,
42
+ placeholder: "Select Currency Location",
43
+ options: u
44
+ }),
45
+ this._GuLabel({ text: "Currency Symbol" }),
46
+ this._GuTextInput({
47
+ name: t.CURRENCY_SYMBOL,
48
+ placeholder: "Enter Currency Symbol",
49
+ className: "es-180w"
50
+ }),
51
+ this._GuLabel({ text: "Thousand Separator" }),
52
+ this._GuSelect({
53
+ name: t.CURRENCY_THOUSAND_SEPARATOR,
54
+ placeholder: "Select Thousand Separator",
55
+ options: a
56
+ }),
57
+ this._GuLabel({ text: "Decimal Separator" }),
58
+ this._GuSelect({
59
+ name: t.CURRENCY_DECIMAL_SEPARATOR,
60
+ placeholder: "Select Decimal Separator",
61
+ options: a
62
+ }),
63
+ this._GuLabel({ text: "Decimal Count" }),
64
+ this._GuSelect({
65
+ name: t.CURRENCY_DECIMAL_COUNT,
66
+ placeholder: "Select Decimal Count",
67
+ options: l
68
+ })
69
+ ])}
70
+ </div>
71
+ `;
72
+ }
73
+ onRender() {
74
+ this._initializeSelectItems(), this._setFormValues(), setTimeout(() => {
75
+ this._listenToFormUpdates();
76
+ }, 0), this._subscribeToStoreChanges();
77
+ }
78
+ onTemplateNodeUpdated(e) {
79
+ super.onTemplateNodeUpdated(e), this._setFormValues();
80
+ }
81
+ onDestroy() {
82
+ this.storeUnsubscription();
83
+ }
84
+ _setFormValues() {
85
+ const e = C.getConfig(this.currentNode), { currency: r } = e;
86
+ this.api.updateValues({
87
+ [t.CURRENCY]: `price.${r.code}`,
88
+ [t.CURRENCY_LOCATION]: r.alignment === "before" ? "0" : "1",
89
+ [t.CURRENCY_SYMBOL]: r.symbol,
90
+ [t.CURRENCY_THOUSAND_SEPARATOR]: r.thousandSeparator,
91
+ [t.CURRENCY_DECIMAL_SEPARATOR]: r.decimalSeparator,
92
+ [t.CURRENCY_DECIMAL_COUNT]: r.decimalCount.toString()
93
+ });
94
+ }
95
+ _initializeSelectItems() {
96
+ const { store: e } = this, r = {
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
102
+ };
103
+ Object.entries(r).forEach(([n, s]) => {
104
+ this.api.setUIEAttribute(n, _.SELECTPICKER.items, s);
105
+ });
106
+ }
107
+ _updateCurrency(e) {
108
+ if (!this.currentNode)
109
+ return;
110
+ const n = { ...C.getConfig(this.currentNode).currency, ...e };
111
+ C.updateConfig(
112
+ this.api,
113
+ this.currentNode,
114
+ { currency: n },
115
+ "Updated currency settings"
116
+ );
117
+ const s = this.api.getDocumentModifier();
118
+ p({
119
+ currentNode: this.currentNode,
120
+ documentModifier: s,
121
+ 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
+ }
133
+ }
134
+ }), S({
135
+ currentNode: this.currentNode,
136
+ documentModifier: s
137
+ }) || E({
138
+ currentNode: this.currentNode,
139
+ documentModifier: s
140
+ });
141
+ }
142
+ _onCurrencyChange(e) {
143
+ const [, r] = e.includes(".") ? e.split(".") : [null, e];
144
+ this._updateCurrency({
145
+ code: r,
146
+ symbol: r
147
+ }), this.api.updateValues({
148
+ [t.CURRENCY_SYMBOL]: r
149
+ });
150
+ }
151
+ _onCurrencyLocationChange(e) {
152
+ this._updateCurrency({
153
+ alignment: e === "0" ? "before" : "after"
154
+ });
155
+ }
156
+ _onCurrencySymbolChange(e) {
157
+ this._updateCurrency({ symbol: e });
158
+ }
159
+ _onThousandSeparatorChange(e) {
160
+ this._updateCurrency({
161
+ thousandSeparator: e
162
+ });
163
+ }
164
+ _onDecimalSeparatorChange(e) {
165
+ this._updateCurrency({
166
+ decimalSeparator: e
167
+ });
168
+ }
169
+ _onDecimalCountChange(e) {
170
+ this._updateCurrency({
171
+ decimalCount: parseInt(e) || 2
172
+ });
173
+ }
174
+ _listenToFormUpdates() {
175
+ this.api.onValueChanged(t.CURRENCY, (e) => {
176
+ this._onCurrencyChange(e);
177
+ }), this.api.onValueChanged(t.CURRENCY_LOCATION, (e) => {
178
+ this._onCurrencyLocationChange(e);
179
+ }), this.api.onValueChanged(t.CURRENCY_SYMBOL, (e) => {
180
+ this._onCurrencySymbolChange(e);
181
+ }), this.api.onValueChanged(t.CURRENCY_THOUSAND_SEPARATOR, (e) => {
182
+ this._onThousandSeparatorChange(e);
183
+ }), this.api.onValueChanged(t.CURRENCY_DECIMAL_SEPARATOR, (e) => {
184
+ this._onDecimalSeparatorChange(e);
185
+ }), this.api.onValueChanged(t.CURRENCY_DECIMAL_COUNT, (e) => {
186
+ this._onDecimalCountChange(e);
187
+ });
188
+ }
189
+ /**
190
+ * Subscribe to store changes to update currency selects when API data arrives
191
+ * This handles the case where the control renders before currency list is loaded
192
+ */
193
+ _subscribeToStoreChanges() {
194
+ let e = this.store.currencyList.length;
195
+ this.storeUnsubscription = this.store.$subscribe(() => {
196
+ const r = this.store.currencyList.length;
197
+ r > 0 && r !== e && (e = r, this._initializeSelectItems(), this._setFormValues());
198
+ });
199
+ }
200
+ }
201
+ export {
202
+ N as CURRENCY_CONTROL_ID,
203
+ b as CurrencyControl
204
+ };
@@ -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
+ };