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