@useinsider/guido 2.2.0-beta.d819452 → 2.2.0-beta.eeefcc3
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/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/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/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 +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/common-control.js +91 -92
- 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/package.json.js +1 -1
- 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/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 +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/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 +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/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/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/Items/store/items-block.d.ts +0 -45
- 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,232 @@
|
|
|
1
|
+
var T = Object.defineProperty;
|
|
2
|
+
var C = (a, s, t) => s in a ? T(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
|
|
3
|
+
var l = (a, s, t) => C(a, typeof s != "symbol" ? s + "" : s, t);
|
|
4
|
+
import { ModificationDescription as u } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as f } from "../../../common-control.js";
|
|
6
|
+
import { ATTR_PRODUCT_IMAGE as O, ATTR_PRODUCT_NAME as g, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_OMNIBUS_PRICE as D, ATTR_PRODUCT_OMNIBUS_DISCOUNT as N, ATTR_PRODUCT_BUTTON as V } from "../../constants/selectors.js";
|
|
7
|
+
import { useRecommendationExtensionStore as E } from "../../store/recommendation.js";
|
|
8
|
+
import { getTableDisplayValue as I } from "../../utils/tagName.js";
|
|
9
|
+
import { getCurrentLayout as P } from "../main/utils.js";
|
|
10
|
+
const S = "ui-elements-recommendation-card-composition", k = {
|
|
11
|
+
ORDERABLE: "cardComposition"
|
|
12
|
+
}, c = ".recommendation-attribute-row", v = ".product-card-wrapper > tbody", _ = "data-card-composition", d = "data-attribute-type", m = "data-visibility", n = [
|
|
13
|
+
{ key: O, label: "Product Image", visible: !0 },
|
|
14
|
+
{ key: g, label: "Product Name", visible: !0 },
|
|
15
|
+
{ key: R, label: "Product Price", visible: !0 },
|
|
16
|
+
{ key: A, label: "Product Original Price", visible: !0 },
|
|
17
|
+
{ key: D, label: "Omnibus Price", visible: !1 },
|
|
18
|
+
{ key: N, label: "Omnibus Discount", visible: !1 },
|
|
19
|
+
{ key: V, label: "Product Button", visible: !0 }
|
|
20
|
+
];
|
|
21
|
+
class H extends f {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
l(this, "store", E());
|
|
25
|
+
l(this, "unsubscribeOrientation", null);
|
|
26
|
+
}
|
|
27
|
+
getId() {
|
|
28
|
+
return S;
|
|
29
|
+
}
|
|
30
|
+
getTemplate() {
|
|
31
|
+
const t = n.map((e) => ({
|
|
32
|
+
key: e.key,
|
|
33
|
+
label: e.label,
|
|
34
|
+
content: this._createItemContent(e.label, e.key)
|
|
35
|
+
}));
|
|
36
|
+
return `
|
|
37
|
+
<div class="container" data-card-composition-control>
|
|
38
|
+
${this._GuLabel({ text: "Card Element Order & Visibility" })}
|
|
39
|
+
${this._GuOrderable(k.ORDERABLE, t)}
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
onRender() {
|
|
44
|
+
this._initializeComposition(), this._registerValueChangeListeners(), this._updateOrderableState(), this._subscribeToOrientationChanges();
|
|
45
|
+
}
|
|
46
|
+
onTemplateNodeUpdated(t) {
|
|
47
|
+
super.onTemplateNodeUpdated(t), this._initializeComposition(), this._updateOrderableState();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates the HTML content for an orderable item with label and toggle
|
|
51
|
+
*/
|
|
52
|
+
_createItemContent(t, e) {
|
|
53
|
+
return `
|
|
54
|
+
<div style="display: flex; align-items: center; justify-content: space-between;
|
|
55
|
+
padding: 8px; gap: 8px;">
|
|
56
|
+
<span style="flex: 1;">${t}</span>
|
|
57
|
+
${this._GuToggle(`visibility_${e}`)}
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Registers event listeners for composition and visibility changes
|
|
63
|
+
*/
|
|
64
|
+
_registerValueChangeListeners() {
|
|
65
|
+
this.api.onValueChanged("cardComposition", (t) => {
|
|
66
|
+
this._applyCompositionToBlock(t);
|
|
67
|
+
}), n.forEach((t) => {
|
|
68
|
+
this.api.onValueChanged(`visibility_${t.key}`, (e) => {
|
|
69
|
+
this._applyVisibilityToBlock(t.key, e);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Initializes composition order and visibility state from the current node
|
|
75
|
+
*/
|
|
76
|
+
_initializeComposition() {
|
|
77
|
+
const t = this._readCompositionFromNode(), e = this._readVisibilityFromRows(), i = {
|
|
78
|
+
cardComposition: t,
|
|
79
|
+
...this._buildVisibilityValues(e)
|
|
80
|
+
};
|
|
81
|
+
this.api.updateValues(i);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Reads composition order from node's data-card-composition attribute
|
|
85
|
+
* Falls back to default order if attribute is not present
|
|
86
|
+
*/
|
|
87
|
+
_readCompositionFromNode() {
|
|
88
|
+
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
89
|
+
return n.map((e) => e.key);
|
|
90
|
+
const t = this.currentNode.getAttribute(_);
|
|
91
|
+
return t ? t.split(",").filter(Boolean) : n.map((e) => e.key);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Builds visibility values object from the visibility map
|
|
95
|
+
*/
|
|
96
|
+
_buildVisibilityValues(t) {
|
|
97
|
+
return n.reduce((e, i) => (e[`visibility_${i.key}`] = t[i.key] ?? !0, e), {});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Read visibility state from individual row elements' data-visibility attributes
|
|
101
|
+
* This ensures toggles reflect the actual DOM state
|
|
102
|
+
*/
|
|
103
|
+
_readVisibilityFromRows() {
|
|
104
|
+
if (!this.currentNode)
|
|
105
|
+
return this._getDefaultVisibilities();
|
|
106
|
+
const t = Array.from(this.currentNode.querySelectorAll(c)), e = this._extractVisibilityFromRows(t);
|
|
107
|
+
return this._mergeWithDefaults(e);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns default visibility values for all items
|
|
111
|
+
*/
|
|
112
|
+
_getDefaultVisibilities() {
|
|
113
|
+
return n.reduce((t, e) => (t[e.key] = e.visible, t), {});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Extracts visibility values from DOM nodes
|
|
117
|
+
*/
|
|
118
|
+
_extractVisibilityFromRows(t) {
|
|
119
|
+
const e = {};
|
|
120
|
+
return t.forEach((i) => {
|
|
121
|
+
if (!("getAttribute" in i))
|
|
122
|
+
return;
|
|
123
|
+
const o = i.getAttribute(d), r = i.getAttribute(m);
|
|
124
|
+
o && r !== null && (e[o] = this._parseVisibilityValue(r));
|
|
125
|
+
}), e;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Parses visibility value from string to boolean
|
|
129
|
+
* Accepts "1", "true" as true, everything else as false
|
|
130
|
+
*/
|
|
131
|
+
_parseVisibilityValue(t) {
|
|
132
|
+
return t === "1" || t === "true";
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Merges extracted visibilities with default values for missing keys
|
|
136
|
+
*/
|
|
137
|
+
_mergeWithDefaults(t) {
|
|
138
|
+
return n.forEach((e) => {
|
|
139
|
+
e.key in t || (t[e.key] = e.visible);
|
|
140
|
+
}), t;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Apply the reordered composition to the block's HTML structure
|
|
144
|
+
* Updates the data-card-composition attribute and reorders product attributes
|
|
145
|
+
* Note: Reordering is only applied for grid layout
|
|
146
|
+
*/
|
|
147
|
+
_applyCompositionToBlock(t) {
|
|
148
|
+
if (!this.currentNode)
|
|
149
|
+
return;
|
|
150
|
+
const e = this._getCurrentLayout();
|
|
151
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(_, t.join(",")).apply(new u("Update card composition")), e === "grid" && this._reorderProductAttributes(t);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Reorders attribute rows within each product card based on composition order
|
|
155
|
+
* Targets the tbody inside each product-attribute-cell to preserve card structure
|
|
156
|
+
*/
|
|
157
|
+
_reorderProductAttributes(t) {
|
|
158
|
+
if (!this.currentNode)
|
|
159
|
+
return;
|
|
160
|
+
const e = this.currentNode.querySelectorAll(v);
|
|
161
|
+
if (!(e != null && e.length))
|
|
162
|
+
return;
|
|
163
|
+
const i = this.api.getDocumentModifier();
|
|
164
|
+
e.forEach((o) => {
|
|
165
|
+
const r = this._buildCompositionHtml(o, t);
|
|
166
|
+
i.modifyHtml(o).setInnerHtml(r);
|
|
167
|
+
}), i.apply(new u("Reorder product attributes"));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Builds HTML string with attributes ordered according to composition
|
|
171
|
+
*/
|
|
172
|
+
_buildCompositionHtml(t, e) {
|
|
173
|
+
return e.reduce((i, o) => {
|
|
174
|
+
const r = t.querySelector(`${c}[${d}="${o}"]`);
|
|
175
|
+
return r && "getOuterHTML" in r ? i + r.getOuterHTML() : i;
|
|
176
|
+
}, "");
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Apply visibility changes to the block's HTML structure
|
|
180
|
+
* Updates display style and data-visibility attribute for all matching elements
|
|
181
|
+
* - <tr> elements: use display: none / table-row
|
|
182
|
+
* - <td> elements: use display: none / table-cell
|
|
183
|
+
*/
|
|
184
|
+
_applyVisibilityToBlock(t, e) {
|
|
185
|
+
if (!this.currentNode)
|
|
186
|
+
return;
|
|
187
|
+
const i = this.currentNode.querySelectorAll(`${c}[${d}="${t}"]`);
|
|
188
|
+
if (!(i != null && i.length))
|
|
189
|
+
return;
|
|
190
|
+
const o = e ? "1" : "0", r = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, b = this.api.getDocumentModifier();
|
|
191
|
+
i.forEach((p) => {
|
|
192
|
+
const y = I(p), h = e ? y : "none";
|
|
193
|
+
b.modifyHtml(p).setStyle("display", h).setAttribute(m, o);
|
|
194
|
+
}), b.apply(new u(r));
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Gets the current layout orientation from store or DOM
|
|
198
|
+
*/
|
|
199
|
+
_getCurrentLayout() {
|
|
200
|
+
return this.store.recommendationConfigs.orientation || P(this.currentNode);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Updates orderable state based on layout orientation
|
|
204
|
+
* Adds/removes disabled class to hide drag icons for list layout
|
|
205
|
+
*/
|
|
206
|
+
_updateOrderableState() {
|
|
207
|
+
const e = this._getCurrentLayout() === "list", i = this.getContainer();
|
|
208
|
+
if (!i)
|
|
209
|
+
return;
|
|
210
|
+
const o = i.querySelector("[data-card-composition-control]");
|
|
211
|
+
if (!o)
|
|
212
|
+
return;
|
|
213
|
+
const r = o.querySelector("ue-orderable");
|
|
214
|
+
r && r.classList.toggle("orderable-disabled", e);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Subscribe to store orientation changes
|
|
218
|
+
* Updates orderable state when layout changes via the layout control
|
|
219
|
+
*/
|
|
220
|
+
_subscribeToOrientationChanges() {
|
|
221
|
+
this.unsubscribeOrientation && this.unsubscribeOrientation();
|
|
222
|
+
let t = this.store.recommendationConfigs.orientation;
|
|
223
|
+
this.unsubscribeOrientation = this.store.$subscribe(() => {
|
|
224
|
+
const e = this.store.recommendationConfigs.orientation;
|
|
225
|
+
e !== t && (t = e, this._updateOrderableState());
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
export {
|
|
230
|
+
S as COMPOSITION_CONTROL_BLOCK_ID,
|
|
231
|
+
H as RecommendationCardCompositionControl
|
|
232
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createImageMarginsControl as m, createImageSizeControl as n } from "../../../controlFactories.js";
|
|
2
|
+
import { RecommendationBlockId as o } from "../../constants/blockIds.js";
|
|
3
|
+
import { RecommendationControlId as r } from "../../constants/controlIds.js";
|
|
4
|
+
import { CONTAINER_SELECTOR as t } from "../../constants/selectors.js";
|
|
5
|
+
const e = n(
|
|
6
|
+
r.IMAGE_SIZE,
|
|
7
|
+
o.IMAGE,
|
|
8
|
+
t
|
|
9
|
+
), i = m(
|
|
10
|
+
r.IMAGE_MARGINS,
|
|
11
|
+
o.IMAGE,
|
|
12
|
+
t
|
|
13
|
+
), C = {
|
|
14
|
+
size: e,
|
|
15
|
+
margins: i
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
C as ImageControls
|
|
19
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var d = (o, e, t) => e in o ? c(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var n = (o, e, t) => d(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { ModificationDescription as m } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { CommonControl as h } from "../../../common-control.js";
|
|
6
|
+
import { LAYOUT_OPTIONS as g } from "../../constants/layout.js";
|
|
7
|
+
import { RecommendationConfigService as r } from "../../services/configService.js";
|
|
8
|
+
import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
|
|
9
|
+
import { getCurrentLayout as u, getBlockElement as f, regenerateProductRowsWithStyles as p } from "../main/utils.js";
|
|
10
|
+
const L = "recommendation-layout-control", i = {
|
|
11
|
+
LAYOUT: "layout"
|
|
12
|
+
}, C = {
|
|
13
|
+
LAYOUT: "data-layout"
|
|
14
|
+
};
|
|
15
|
+
class Y extends h {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
n(this, "store", l());
|
|
19
|
+
n(this, "isChangingLayout", !1);
|
|
20
|
+
}
|
|
21
|
+
getId() {
|
|
22
|
+
return L;
|
|
23
|
+
}
|
|
24
|
+
getTemplate() {
|
|
25
|
+
return `
|
|
26
|
+
<div class="layout-control-container">
|
|
27
|
+
${this._GuTwoColumns([
|
|
28
|
+
this._GuLabel({ text: "Layout Orientation" }),
|
|
29
|
+
this._GuRadioButton({
|
|
30
|
+
name: i.LAYOUT,
|
|
31
|
+
buttons: g
|
|
32
|
+
})
|
|
33
|
+
])}
|
|
34
|
+
</div>
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
onRender() {
|
|
38
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
39
|
+
}
|
|
40
|
+
onTemplateNodeUpdated(t) {
|
|
41
|
+
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
42
|
+
}
|
|
43
|
+
_setFormValues() {
|
|
44
|
+
const s = r.getConfig(this.currentNode).layout || u(this.currentNode);
|
|
45
|
+
this.api.updateValues({
|
|
46
|
+
[i.LAYOUT]: s
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Handles layout change
|
|
51
|
+
* Updates node config, data attribute and regenerates product rows
|
|
52
|
+
*/
|
|
53
|
+
_onLayoutChange(t) {
|
|
54
|
+
if (this.isChangingLayout || !this.currentNode || (r.getConfig(this.currentNode).layout || u(this.currentNode)) === t)
|
|
55
|
+
return;
|
|
56
|
+
const a = f(this.currentNode);
|
|
57
|
+
if (a) {
|
|
58
|
+
this.isChangingLayout = !0;
|
|
59
|
+
try {
|
|
60
|
+
r.updateConfig(
|
|
61
|
+
this.api,
|
|
62
|
+
this.currentNode,
|
|
63
|
+
{ layout: t },
|
|
64
|
+
`Changed layout to ${t}`
|
|
65
|
+
), this.store.patchCurrentBlockConfig({ orientation: t }), this.api.getDocumentModifier().modifyHtml(a).setAttribute(C.LAYOUT, t).apply(new m(`Update layout to ${t}`)), this._regenerateProductRows(t);
|
|
66
|
+
} finally {
|
|
67
|
+
this.isChangingLayout = !1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Regenerates product rows based on the selected layout
|
|
73
|
+
* Uses unified style-preserving regeneration to maintain user customizations
|
|
74
|
+
* @param layout - The layout to use for regeneration (passed explicitly to avoid stale DOM reads)
|
|
75
|
+
*/
|
|
76
|
+
_regenerateProductRows(t) {
|
|
77
|
+
this.currentNode && p({
|
|
78
|
+
currentNode: this.currentNode,
|
|
79
|
+
documentModifier: this.api.getDocumentModifier(),
|
|
80
|
+
layout: t
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
_listenToFormUpdates() {
|
|
84
|
+
this.api.onValueChanged(i.LAYOUT, (t) => {
|
|
85
|
+
this._onLayoutChange(t);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
L as LAYOUT_CONTROL_ID,
|
|
91
|
+
Y as LayoutControl
|
|
92
|
+
};
|
|
@@ -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
|
+
};
|