@useinsider/guido 2.1.0-beta.c1e85ba → 2.1.0-beta.c2eabd2
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 +1 -3
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +39 -36
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
- package/dist/composables/useHtmlValidator.js +114 -104
- package/dist/composables/useRecommendation.js +54 -21
- package/dist/composables/useSave.js +12 -16
- package/dist/composables/useStripo.js +54 -58
- package/dist/composables/useStripoEventHandler.js +12 -27
- package/dist/config/compiler/recommendationCompilerRules.js +45 -39
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
- package/dist/config/migrator/itemsBlockMigrator.js +101 -97
- package/dist/config/migrator/recommendationMigrator.js +2 -2
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/enums/recommendation.js +16 -15
- package/dist/enums/unsubscribe.js +21 -25
- package/dist/extensions/Blocks/Recommendation/block.js +133 -9
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +66 -0
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +22 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +64 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +80 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +232 -0
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +19 -0
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +92 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +102 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +209 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +52 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +250 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +160 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +307 -0
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +46 -0
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +108 -0
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextAfterControl.js → omnibusDiscount/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscountTextBeforeControl.js → omnibusDiscount/textBefore.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +48 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextAfterControl.js → omnibusPrice/textAfter.js} +16 -14
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPriceTextBeforeControl.js → omnibusPrice/textBefore.js} +14 -12
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +44 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +222 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +40 -17
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +19 -3
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +13 -4
- package/dist/extensions/Blocks/Recommendation/services/configService.js +240 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +21 -10
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +254 -207
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +228 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +66 -0
- package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +169 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +134 -0
- package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +6 -0
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +26 -15
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +29 -0
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
- package/dist/extensions/Blocks/controlFactories.js +125 -93
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +242 -186
- package/dist/services/recommendationApi.js +11 -8
- package/dist/services/stripoApi.js +12 -48
- package/dist/services/templateLibraryApi.js +16 -13
- package/dist/src/@types/events.d.ts +2 -38
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/composables/useRecommendation.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
- package/dist/src/enums/unsubscribe.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +67 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/{constants.d.ts → constants/controlIds.d.ts} +0 -24
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +49 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +13 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +143 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +31 -0
- package/dist/src/extensions/Blocks/Recommendation/{cardCompositionControl.d.ts → controls/cardComposition/index.d.ts} +23 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +21 -589
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +37 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +52 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +22 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +79 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +24 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +60 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +221 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +97 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +34 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +100 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +95 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +83 -0
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +151 -0
- package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -468
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/{migrationTemplate.d.ts → grid/migration.d.ts} +11 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +41 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +25 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +18 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +66 -0
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +166 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
- package/dist/src/services/stripoApi.d.ts +0 -5
- package/dist/src/stores/editor.d.ts +0 -23
- package/dist/static/styles/customEditorStyle.css.js +35 -11
- package/dist/stores/editor.js +1 -2
- package/dist/utils/pairProductVariables.js +57 -56
- package/dist/utils/templatePreparation.js +15 -14
- package/package.json +1 -1
- package/dist/composables/useSyncModuleExtractor.js +0 -45
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +0 -187
- package/dist/extensions/Blocks/Recommendation/constants.js +0 -13
- package/dist/extensions/Blocks/Recommendation/control.js +0 -336
- package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +0 -68
- package/dist/extensions/Blocks/Recommendation/controls/index.js +0 -245
- package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +0 -74
- package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +0 -188
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +0 -181
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +0 -189
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +0 -209
- package/dist/src/composables/useSyncModuleExtractor.d.ts +0 -4
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +0 -38
- package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +0 -16
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +0 -52
- package/dist/src/mock/api/settings.d.ts +0 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
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
|
+
import { RecommendationConfigService as n } from "../../services/configService.js";
|
|
7
|
+
import { useRecommendationExtensionStore as m } from "../../store/recommendation.js";
|
|
8
|
+
const u = "recommendation-algorithm-control", e = {
|
|
9
|
+
ALGORITHM: "strategy",
|
|
10
|
+
PRODUCT_IDS: "productIds"
|
|
11
|
+
};
|
|
12
|
+
class T extends h {
|
|
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 u;
|
|
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 r;
|
|
56
|
+
const t = (r = this.store) == null ? void 0 : r.getActivePredictiveAlgorithms;
|
|
57
|
+
if (t != null && t.length)
|
|
58
|
+
try {
|
|
59
|
+
this.api.setUIEAttribute(
|
|
60
|
+
e.ALGORITHM,
|
|
61
|
+
c.SELECTPICKER.items,
|
|
62
|
+
t
|
|
63
|
+
);
|
|
64
|
+
} catch (s) {
|
|
65
|
+
console.warn("[AlgorithmControl] Failed to set algorithm options:", s);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_setProductIdsVisibility(t) {
|
|
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
|
+
}
|
|
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.patchCurrentBlockConfig({ strategy: t }), this._setProductIdsVisibility(t));
|
|
79
|
+
}
|
|
80
|
+
_onProductIdsChange(t) {
|
|
81
|
+
if (!this.currentNode)
|
|
82
|
+
return;
|
|
83
|
+
const r = t.split(",").map((s) => s.trim()).filter(Boolean);
|
|
84
|
+
n.updateConfig(
|
|
85
|
+
this.api,
|
|
86
|
+
this.currentNode,
|
|
87
|
+
{ productIds: r },
|
|
88
|
+
"Updated product IDs"
|
|
89
|
+
), this.store.patchCurrentBlockConfig({ productIds: r });
|
|
90
|
+
}
|
|
91
|
+
_listenToFormUpdates() {
|
|
92
|
+
this.api.onValueChanged(e.ALGORITHM, (t) => {
|
|
93
|
+
this._onAlgorithmChange(t);
|
|
94
|
+
}), this.api.onValueChanged(e.PRODUCT_IDS, (t) => {
|
|
95
|
+
this._onProductIdsChange(t);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
u as ALGORITHM_CONTROL_ID,
|
|
101
|
+
T as AlgorithmControl
|
|
102
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
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
|
+
import { RecommendationConfigService as C } from "../../services/configService.js";
|
|
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
|
+
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 D extends d {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
// Store is used ONLY for API-fetched data (currency list), not for config
|
|
22
|
+
c(this, "store", p());
|
|
23
|
+
c(this, "storeUnsubscription", () => {
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
getId() {
|
|
27
|
+
return y;
|
|
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: l
|
|
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: i
|
|
56
|
+
}),
|
|
57
|
+
this._GuLabel({ text: "Decimal Separator" }),
|
|
58
|
+
this._GuSelect({
|
|
59
|
+
name: t.CURRENCY_DECIMAL_SEPARATOR,
|
|
60
|
+
placeholder: "Select Decimal Separator",
|
|
61
|
+
options: i
|
|
62
|
+
}),
|
|
63
|
+
this._GuLabel({ text: "Decimal Count" }),
|
|
64
|
+
this._GuSelect({
|
|
65
|
+
name: t.CURRENCY_DECIMAL_COUNT,
|
|
66
|
+
placeholder: "Select Decimal Count",
|
|
67
|
+
options: h
|
|
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]: l,
|
|
99
|
+
[t.CURRENCY_THOUSAND_SEPARATOR]: i,
|
|
100
|
+
[t.CURRENCY_DECIMAL_SEPARATOR]: i,
|
|
101
|
+
[t.CURRENCY_DECIMAL_COUNT]: h
|
|
102
|
+
};
|
|
103
|
+
Object.entries(r).forEach(([u, n]) => {
|
|
104
|
+
this.api.setUIEAttribute(u, m.SELECTPICKER.items, n);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
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) {
|
|
115
|
+
if (!this.currentNode)
|
|
116
|
+
return;
|
|
117
|
+
const n = { ...C.getConfig(this.currentNode).currency, ...e };
|
|
118
|
+
C.updateConfig(
|
|
119
|
+
this.api,
|
|
120
|
+
this.currentNode,
|
|
121
|
+
{ currency: n },
|
|
122
|
+
"Updated currency settings"
|
|
123
|
+
);
|
|
124
|
+
const a = this.api.getDocumentModifier();
|
|
125
|
+
S({
|
|
126
|
+
currentNode: this.currentNode,
|
|
127
|
+
documentModifier: a,
|
|
128
|
+
currency: n
|
|
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
|
|
138
|
+
}
|
|
139
|
+
}, { triggerRefetch: r }), E({
|
|
140
|
+
currentNode: this.currentNode,
|
|
141
|
+
documentModifier: a
|
|
142
|
+
}) || N({
|
|
143
|
+
currentNode: this.currentNode,
|
|
144
|
+
documentModifier: a
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
_onCurrencyChange(e) {
|
|
148
|
+
const [, r] = e.includes(".") ? e.split(".") : [null, e];
|
|
149
|
+
this._updateCurrency({
|
|
150
|
+
code: r,
|
|
151
|
+
symbol: r
|
|
152
|
+
}, !0), this.api.updateValues({
|
|
153
|
+
[t.CURRENCY_SYMBOL]: r
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
_onCurrencyLocationChange(e) {
|
|
157
|
+
this._updateCurrency({
|
|
158
|
+
alignment: e === "0" ? "before" : "after"
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
_onCurrencySymbolChange(e) {
|
|
162
|
+
this._updateCurrency({ symbol: e });
|
|
163
|
+
}
|
|
164
|
+
_onThousandSeparatorChange(e) {
|
|
165
|
+
this._updateCurrency({
|
|
166
|
+
thousandSeparator: e
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
_onDecimalSeparatorChange(e) {
|
|
170
|
+
this._updateCurrency({
|
|
171
|
+
decimalSeparator: e
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
_onDecimalCountChange(e) {
|
|
175
|
+
this._updateCurrency({
|
|
176
|
+
decimalCount: parseInt(e) || 2
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
_listenToFormUpdates() {
|
|
180
|
+
this.api.onValueChanged(t.CURRENCY, (e) => {
|
|
181
|
+
this._onCurrencyChange(e);
|
|
182
|
+
}), this.api.onValueChanged(t.CURRENCY_LOCATION, (e) => {
|
|
183
|
+
this._onCurrencyLocationChange(e);
|
|
184
|
+
}), this.api.onValueChanged(t.CURRENCY_SYMBOL, (e) => {
|
|
185
|
+
this._onCurrencySymbolChange(e);
|
|
186
|
+
}), this.api.onValueChanged(t.CURRENCY_THOUSAND_SEPARATOR, (e) => {
|
|
187
|
+
this._onThousandSeparatorChange(e);
|
|
188
|
+
}), this.api.onValueChanged(t.CURRENCY_DECIMAL_SEPARATOR, (e) => {
|
|
189
|
+
this._onDecimalSeparatorChange(e);
|
|
190
|
+
}), this.api.onValueChanged(t.CURRENCY_DECIMAL_COUNT, (e) => {
|
|
191
|
+
this._onDecimalCountChange(e);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Subscribe to store changes to update currency selects when API data arrives
|
|
196
|
+
* This handles the case where the control renders before currency list is loaded
|
|
197
|
+
*/
|
|
198
|
+
_subscribeToStoreChanges() {
|
|
199
|
+
let e = this.store.currencyList.length;
|
|
200
|
+
this.storeUnsubscription = this.store.$subscribe(() => {
|
|
201
|
+
const r = this.store.currencyList.length;
|
|
202
|
+
r > 0 && r !== e && (e = r, this._initializeSelectItems(), this._setFormValues());
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
y as CURRENCY_CONTROL_ID,
|
|
208
|
+
D as CurrencyControl
|
|
209
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var n = Object.defineProperty;
|
|
2
|
+
var o = (i, e, t) => e in i ? n(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var r = (i, e, t) => o(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { CommonControl as s } from "../../../common-control.js";
|
|
5
|
+
import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
|
|
6
|
+
const d = "recommendation-filters-control", a = {
|
|
7
|
+
FILTERS: "filterStatus"
|
|
8
|
+
};
|
|
9
|
+
class h extends s {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
r(this, "store", l());
|
|
13
|
+
r(this, "addFilterListener", () => {
|
|
14
|
+
});
|
|
15
|
+
r(this, "addFilterButton", null);
|
|
16
|
+
}
|
|
17
|
+
getId() {
|
|
18
|
+
return d;
|
|
19
|
+
}
|
|
20
|
+
getTemplate() {
|
|
21
|
+
return `
|
|
22
|
+
<div class="filters-control-container">
|
|
23
|
+
${this._GuTwoColumns([
|
|
24
|
+
this._GuLabel({ text: "Filters" }),
|
|
25
|
+
this._GuButton({
|
|
26
|
+
name: a.FILTERS,
|
|
27
|
+
label: "Add Filter",
|
|
28
|
+
id: "guido__btn-add-filter"
|
|
29
|
+
})
|
|
30
|
+
])}
|
|
31
|
+
</div>
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
onRender() {
|
|
35
|
+
this._setupButtonListener();
|
|
36
|
+
}
|
|
37
|
+
onDestroy() {
|
|
38
|
+
var t;
|
|
39
|
+
(t = this.addFilterButton) == null || t.removeEventListener("click", this.addFilterListener);
|
|
40
|
+
}
|
|
41
|
+
_onFilterSelectClick() {
|
|
42
|
+
this.store.openFilterDrawer();
|
|
43
|
+
}
|
|
44
|
+
_setupButtonListener() {
|
|
45
|
+
var t;
|
|
46
|
+
this.addFilterListener = this._onFilterSelectClick.bind(this), this.addFilterButton = this.getContainer().querySelector("#guido__btn-add-filter"), (t = this.addFilterButton) == null || t.addEventListener("click", this.addFilterListener);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
d as FILTERS_CONTROL_ID,
|
|
51
|
+
h as FiltersControl
|
|
52
|
+
};
|
|
@@ -0,0 +1,250 @@
|
|
|
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 {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
n(this, "store", C());
|
|
27
|
+
n(this, "storeUnsubscription", () => {
|
|
28
|
+
});
|
|
29
|
+
// Sub-control instances for lifecycle management
|
|
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);
|
|
36
|
+
/**
|
|
37
|
+
* Debounced product fetch to prevent rapid API calls during config changes
|
|
38
|
+
*/
|
|
39
|
+
n(this, "_debouncedFetchProducts", l(() => {
|
|
40
|
+
this.store.fetchRecommendationProducts();
|
|
41
|
+
}, 500));
|
|
42
|
+
/**
|
|
43
|
+
* Debounced regeneration when products arrive from API
|
|
44
|
+
* Tries in-place update first to preserve styles, falls back to full regeneration
|
|
45
|
+
*/
|
|
46
|
+
n(this, "_debouncedRegenerateWithProducts", l(() => {
|
|
47
|
+
const t = this.store.recommendationProducts;
|
|
48
|
+
if (!this.currentNode || !this.api)
|
|
49
|
+
return;
|
|
50
|
+
const e = this.api.getDocumentModifier();
|
|
51
|
+
I({
|
|
52
|
+
currentNode: this.currentNode,
|
|
53
|
+
documentModifier: e,
|
|
54
|
+
products: t
|
|
55
|
+
}) || this._regenerateWithProducts(t);
|
|
56
|
+
}, 100));
|
|
57
|
+
}
|
|
58
|
+
getId() {
|
|
59
|
+
return S;
|
|
60
|
+
}
|
|
61
|
+
getTemplate() {
|
|
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(), `
|
|
63
|
+
<div class="recommendation-controls-container">
|
|
64
|
+
${this.algorithmControl.getTemplate()}
|
|
65
|
+
${this.localeControl.getTemplate()}
|
|
66
|
+
${this.currencyControl.getTemplate()}
|
|
67
|
+
${this.filtersControl.getTemplate()}
|
|
68
|
+
${this.productLayoutControl.getTemplate()}
|
|
69
|
+
${this.shuffleControl.getTemplate()}
|
|
70
|
+
</div>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
async onRender() {
|
|
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)) {
|
|
77
|
+
this._initializeSubControls();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
await this._fetchBlockData(t), this._initializeSubControls();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Immediately regenerate products with styles (no debounce)
|
|
84
|
+
* Used for initial load after fetch completes
|
|
85
|
+
*/
|
|
86
|
+
_regenerateWithProducts(t) {
|
|
87
|
+
if (!this.currentNode || !this.api) {
|
|
88
|
+
console.warn("[Recommendation] Cannot regenerate - missing currentNode or api");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
b({
|
|
92
|
+
currentNode: this.currentNode,
|
|
93
|
+
documentModifier: this.api.getDocumentModifier(),
|
|
94
|
+
products: t
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
onTemplateNodeUpdated(t) {
|
|
98
|
+
var i;
|
|
99
|
+
super.onTemplateNodeUpdated(t);
|
|
100
|
+
const e = this._getRecommendationIdFromNode(t);
|
|
101
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
|
|
102
|
+
this.algorithmControl,
|
|
103
|
+
this.localeControl,
|
|
104
|
+
this.currencyControl,
|
|
105
|
+
this.productLayoutControl,
|
|
106
|
+
this.filtersControl,
|
|
107
|
+
this.shuffleControl
|
|
108
|
+
].forEach((r) => {
|
|
109
|
+
var a;
|
|
110
|
+
r != null && r.api && (r.currentNode = t, (a = r.onTemplateNodeUpdated) == null || a.call(r, t));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
onDestroy() {
|
|
114
|
+
this.storeUnsubscription(), [
|
|
115
|
+
this.algorithmControl,
|
|
116
|
+
this.localeControl,
|
|
117
|
+
this.currencyControl,
|
|
118
|
+
this.productLayoutControl,
|
|
119
|
+
this.filtersControl,
|
|
120
|
+
this.shuffleControl
|
|
121
|
+
].forEach((e) => {
|
|
122
|
+
var o;
|
|
123
|
+
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Initialize all sub-controls with the shared API context
|
|
128
|
+
* Each sub-control manages its own form values and event listeners
|
|
129
|
+
*/
|
|
130
|
+
_initializeSubControls() {
|
|
131
|
+
[
|
|
132
|
+
this.algorithmControl,
|
|
133
|
+
this.localeControl,
|
|
134
|
+
this.currencyControl,
|
|
135
|
+
this.productLayoutControl,
|
|
136
|
+
this.filtersControl,
|
|
137
|
+
this.shuffleControl
|
|
138
|
+
].forEach((e) => {
|
|
139
|
+
var o;
|
|
140
|
+
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
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).
|
|
211
|
+
*/
|
|
212
|
+
_listenStateUpdates() {
|
|
213
|
+
const { store: t } = this;
|
|
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());
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
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
|
|
250
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
var s = Object.defineProperty;
|
|
2
|
+
var r = (o, t, e) => t in o ? s(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var a = (o, t, e) => r(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { UEAttr as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as 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.patchCurrentBlockConfig({ language: e }));
|
|
60
|
+
}
|
|
61
|
+
_listenToFormUpdates() {
|
|
62
|
+
this.api.onValueChanged(n.LOCALE, (e) => {
|
|
63
|
+
this._onLocaleChange(e);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
g as LOCALE_CONTROL_ID,
|
|
69
|
+
C as LocaleControl
|
|
70
|
+
};
|