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