@useinsider/guido 2.1.0-beta.425dfd0 → 2.1.0-beta.42f5dfa
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/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
- package/dist/composables/useActionsApi.js +15 -13
- package/dist/composables/useHtmlValidator.js +106 -84
- package/dist/composables/useRecommendation.js +54 -21
- package/dist/config/compiler/recommendationCompilerRules.js +45 -39
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +116 -0
- package/dist/config/migrator/itemsBlockMigrator.js +140 -123
- 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/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 +130 -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 +65 -0
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +20 -0
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +19 -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 +217 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +70 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +110 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +67 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -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 +230 -193
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +233 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +69 -0
- package/dist/extensions/Blocks/Recommendation/templates/index.js +12 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +174 -0
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +73 -0
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +122 -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/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +223 -169
- package/dist/services/recommendationApi.js +10 -9
- package/dist/services/templateLibraryApi.js +16 -13
- 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/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 +35 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +31 -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 +68 -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 +42 -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 +214 -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 +131 -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 +39 -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 +57 -0
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +160 -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/static/styles/customEditorStyle.css.js +25 -2
- package/dist/utils/pairProductVariables.js +57 -56
- package/dist/utils/templatePreparation.js +15 -14
- package/package.json +1 -1
- 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,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,217 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var m = (l, n, t) => n in l ? d(l, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[n] = t;
|
|
3
|
+
var i = (l, n, t) => m(l, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { CommonControl as h } from "../../../common-control.js";
|
|
5
|
+
import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
|
|
6
|
+
import { AlgorithmControl as f } from "./algorithm.js";
|
|
7
|
+
import { ALGORITHM_CONTROL_ID as M } from "./algorithm.js";
|
|
8
|
+
import { CurrencyControl as p } from "./currency.js";
|
|
9
|
+
import { CURRENCY_CONTROL_ID as W } from "./currency.js";
|
|
10
|
+
import { FiltersControl as g } from "./filters.js";
|
|
11
|
+
import { FILTERS_CONTROL_ID as H } from "./filters.js";
|
|
12
|
+
import { LocaleControl as R } from "./locale.js";
|
|
13
|
+
import { LOCALE_CONTROL_ID as j } from "./locale.js";
|
|
14
|
+
import { ProductLayoutControl as _ } from "./productLayout.js";
|
|
15
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as K } from "./productLayout.js";
|
|
16
|
+
import { ShuffleControl as N } from "./shuffle.js";
|
|
17
|
+
import { SHUFFLE_CONTROL_ID as J } from "./shuffle.js";
|
|
18
|
+
import { regenerateProductRowsWithStyles as P, getBlockElement as b, updateProductContentInPlace as y } from "./utils.js";
|
|
19
|
+
import { formatProductPrice as X, getCardComposition as Z, getCurrentLayout as tt, reapplySpacing as et, regenerateProductRows as ot, setCurrencyAttributes as rt, updatePricesInPlace as it, updateSingleProductContent as nt } from "./utils.js";
|
|
20
|
+
import { useDebounceFn as c } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
21
|
+
const T = "recommendation-id", L = "ui-elements-recommendation-block";
|
|
22
|
+
class x extends h {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
i(this, "store", C());
|
|
26
|
+
i(this, "storeUnsubscription", () => {
|
|
27
|
+
});
|
|
28
|
+
// Track if initial data has been fetched per block ID to avoid redundant API calls
|
|
29
|
+
i(this, "initializedBlocks", /* @__PURE__ */ new Map());
|
|
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", c(() => {
|
|
41
|
+
this.store.fetchRecommendationProducts();
|
|
42
|
+
}, 500));
|
|
43
|
+
/**
|
|
44
|
+
* Debounced regeneration when products arrive from API
|
|
45
|
+
* Tries in-place update first to preserve styles, falls back to full regeneration
|
|
46
|
+
*/
|
|
47
|
+
i(this, "_debouncedRegenerateWithProducts", c(() => {
|
|
48
|
+
const t = this.store.recommendationProducts;
|
|
49
|
+
if (!this.currentNode || !this.api)
|
|
50
|
+
return;
|
|
51
|
+
const e = this.api.getDocumentModifier();
|
|
52
|
+
y({
|
|
53
|
+
currentNode: this.currentNode,
|
|
54
|
+
documentModifier: e,
|
|
55
|
+
products: t
|
|
56
|
+
}) || this._regenerateWithProducts(t);
|
|
57
|
+
}, 100));
|
|
58
|
+
}
|
|
59
|
+
getId() {
|
|
60
|
+
return L;
|
|
61
|
+
}
|
|
62
|
+
getTemplate() {
|
|
63
|
+
return this.algorithmControl = new f(), this.localeControl = new R(), this.currencyControl = new p(), this.productLayoutControl = new _(), this.filtersControl = new g(), this.shuffleControl = new N(), `
|
|
64
|
+
<div class="recommendation-controls-container">
|
|
65
|
+
${this.algorithmControl.getTemplate()}
|
|
66
|
+
${this.localeControl.getTemplate()}
|
|
67
|
+
${this.currencyControl.getTemplate()}
|
|
68
|
+
${this.filtersControl.getTemplate()}
|
|
69
|
+
${this.productLayoutControl.getTemplate()}
|
|
70
|
+
${this.shuffleControl.getTemplate()}
|
|
71
|
+
</div>
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
async onRender() {
|
|
75
|
+
const t = this._getRecommendationIdFromNode(this.currentNode) ?? this.store.currentRecommendationId;
|
|
76
|
+
if (t !== null && this.store.setCurrentBlock(t), this._listenStateUpdates(), t !== null && this.initializedBlocks.get(t)) {
|
|
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
|
+
P({
|
|
92
|
+
currentNode: this.currentNode,
|
|
93
|
+
documentModifier: this.api.getDocumentModifier(),
|
|
94
|
+
products: t
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
onTemplateNodeUpdated(t) {
|
|
98
|
+
super.onTemplateNodeUpdated(t);
|
|
99
|
+
const e = this._getRecommendationIdFromNode(t);
|
|
100
|
+
e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.initializedBlocks.get(e) && this._fetchBlockData(e), [
|
|
101
|
+
this.algorithmControl,
|
|
102
|
+
this.localeControl,
|
|
103
|
+
this.currencyControl,
|
|
104
|
+
this.productLayoutControl,
|
|
105
|
+
this.filtersControl,
|
|
106
|
+
this.shuffleControl
|
|
107
|
+
].forEach((r) => {
|
|
108
|
+
var s;
|
|
109
|
+
r != null && r.api && (r.currentNode = t, (s = r.onTemplateNodeUpdated) == null || s.call(r, t));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
onDestroy() {
|
|
113
|
+
this.storeUnsubscription(), [
|
|
114
|
+
this.algorithmControl,
|
|
115
|
+
this.localeControl,
|
|
116
|
+
this.currencyControl,
|
|
117
|
+
this.productLayoutControl,
|
|
118
|
+
this.filtersControl,
|
|
119
|
+
this.shuffleControl
|
|
120
|
+
].forEach((e) => {
|
|
121
|
+
var o;
|
|
122
|
+
return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Initialize all sub-controls with the shared API context
|
|
127
|
+
* Each sub-control manages its own form values and event listeners
|
|
128
|
+
*/
|
|
129
|
+
_initializeSubControls() {
|
|
130
|
+
[
|
|
131
|
+
this.algorithmControl,
|
|
132
|
+
this.localeControl,
|
|
133
|
+
this.currencyControl,
|
|
134
|
+
this.productLayoutControl,
|
|
135
|
+
this.filtersControl,
|
|
136
|
+
this.shuffleControl
|
|
137
|
+
].forEach((e) => {
|
|
138
|
+
var o;
|
|
139
|
+
e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Fetches initial data for a block (filters, algorithms, products).
|
|
144
|
+
* Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
|
|
145
|
+
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
146
|
+
*/
|
|
147
|
+
async _fetchBlockData(t) {
|
|
148
|
+
t !== null && this.initializedBlocks.set(t, !0), (await Promise.allSettled([
|
|
149
|
+
this.store.fetchRecommendationFilters(),
|
|
150
|
+
this.store.fetchRecommendationCreateData(),
|
|
151
|
+
this.store.fetchRecommendationProducts()
|
|
152
|
+
])).forEach((o, r) => {
|
|
153
|
+
o.status === "rejected" && console.warn(`Recommendation block: ${[
|
|
154
|
+
"fetchRecommendationFilters",
|
|
155
|
+
"fetchRecommendationCreateData",
|
|
156
|
+
"fetchRecommendationProducts"
|
|
157
|
+
][r]} failed`, o.reason);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Reads the recommendation-id attribute from the block element within the node
|
|
162
|
+
*/
|
|
163
|
+
_getRecommendationIdFromNode(t) {
|
|
164
|
+
const e = b(t);
|
|
165
|
+
if (!e || !("getAttribute" in e))
|
|
166
|
+
return null;
|
|
167
|
+
const o = e.getAttribute(T);
|
|
168
|
+
if (!o)
|
|
169
|
+
return null;
|
|
170
|
+
const r = parseInt(o);
|
|
171
|
+
return Number.isNaN(r) ? null : r;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Listen to store changes that require product refresh or regeneration.
|
|
175
|
+
*
|
|
176
|
+
* Uses configVersion counter (incremented only by patchCurrentBlockConfig)
|
|
177
|
+
* to distinguish user-initiated config changes from internal mutations
|
|
178
|
+
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
179
|
+
*/
|
|
180
|
+
_listenStateUpdates() {
|
|
181
|
+
const { store: t } = this;
|
|
182
|
+
let e = t.recommendationProducts, o = t.$state.configVersion;
|
|
183
|
+
this.storeUnsubscription = t.$subscribe(() => {
|
|
184
|
+
const r = t.$state.configVersion;
|
|
185
|
+
r !== o && (o = r, this._debouncedFetchProducts());
|
|
186
|
+
const s = t.recommendationProducts, a = s !== e, u = Array.isArray(s) && s.length > 0;
|
|
187
|
+
a && u && (e = s, this._debouncedRegenerateWithProducts());
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export {
|
|
192
|
+
M as ALGORITHM_CONTROL_ID,
|
|
193
|
+
f as AlgorithmControl,
|
|
194
|
+
L as CONTROL_BLOCK_ID,
|
|
195
|
+
W as CURRENCY_CONTROL_ID,
|
|
196
|
+
p as CurrencyControl,
|
|
197
|
+
H as FILTERS_CONTROL_ID,
|
|
198
|
+
g as FiltersControl,
|
|
199
|
+
j as LOCALE_CONTROL_ID,
|
|
200
|
+
R as LocaleControl,
|
|
201
|
+
K as PRODUCT_LAYOUT_CONTROL_ID,
|
|
202
|
+
_ as ProductLayoutControl,
|
|
203
|
+
x as RecommendationBlockControl,
|
|
204
|
+
J as SHUFFLE_CONTROL_ID,
|
|
205
|
+
N as ShuffleControl,
|
|
206
|
+
X as formatProductPrice,
|
|
207
|
+
b as getBlockElement,
|
|
208
|
+
Z as getCardComposition,
|
|
209
|
+
tt as getCurrentLayout,
|
|
210
|
+
et as reapplySpacing,
|
|
211
|
+
ot as regenerateProductRows,
|
|
212
|
+
P as regenerateProductRowsWithStyles,
|
|
213
|
+
rt as setCurrencyAttributes,
|
|
214
|
+
it as updatePricesInPlace,
|
|
215
|
+
y as updateProductContentInPlace,
|
|
216
|
+
nt as updateSingleProductContent
|
|
217
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var a = (i, e, t) => e in i ? d(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var n = (i, e, t) => a(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { CommonControl as c } from "../../../common-control.js";
|
|
5
|
+
import { MAX_PRODUCT_COUNT as _, MAX_PRODUCTS_PER_ROW as h } from "../../constants/layout.js";
|
|
6
|
+
import { RecommendationConfigService as r } from "../../services/configService.js";
|
|
7
|
+
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
8
|
+
import { getCurrentLayout as C, regenerateProductRowsWithStyles as p } from "./utils.js";
|
|
9
|
+
import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
10
|
+
const l = "recommendation-product-layout-control", o = {
|
|
11
|
+
PRODUCT_COUNT: "size",
|
|
12
|
+
PRODUCT_IN_ROW: "cardsInRow",
|
|
13
|
+
PRODUCT_IN_ROW_LABEL: "cardsInRowLabel"
|
|
14
|
+
};
|
|
15
|
+
class I extends c {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
// Store is used for backward compatibility with product fetching and regeneration
|
|
19
|
+
n(this, "store", R());
|
|
20
|
+
n(this, "storeUnsubscription", () => {
|
|
21
|
+
});
|
|
22
|
+
n(this, "_debouncedRegenerateProductRows", m(() => {
|
|
23
|
+
this._regenerateProductRows();
|
|
24
|
+
}, 500));
|
|
25
|
+
}
|
|
26
|
+
getId() {
|
|
27
|
+
return l;
|
|
28
|
+
}
|
|
29
|
+
getTemplate() {
|
|
30
|
+
return `
|
|
31
|
+
<div class="product-layout-control-container">
|
|
32
|
+
${this._GuTwoColumns([
|
|
33
|
+
this._GuLabel({ text: "Number of Products" }),
|
|
34
|
+
this._GuCounter({ name: o.PRODUCT_COUNT, maxValue: _ }),
|
|
35
|
+
this._GuLabel({ text: "Products in One Row", name: o.PRODUCT_IN_ROW_LABEL }),
|
|
36
|
+
this._GuCounter({ name: o.PRODUCT_IN_ROW, maxValue: h })
|
|
37
|
+
])}
|
|
38
|
+
</div>
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
onRender() {
|
|
42
|
+
this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates();
|
|
43
|
+
}
|
|
44
|
+
onTemplateNodeUpdated(t) {
|
|
45
|
+
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
|
|
46
|
+
}
|
|
47
|
+
onDestroy() {
|
|
48
|
+
this.storeUnsubscription();
|
|
49
|
+
}
|
|
50
|
+
_setFormValues() {
|
|
51
|
+
const t = r.getConfig(this.currentNode);
|
|
52
|
+
this.api.updateValues({
|
|
53
|
+
[o.PRODUCT_COUNT]: t.size,
|
|
54
|
+
[o.PRODUCT_IN_ROW]: t.cardsInRow
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Updates "Products in One Row" visibility based on layout orientation
|
|
59
|
+
* This control is hidden for list layout (products always take full width)
|
|
60
|
+
* Reads from node config first, falls back to DOM
|
|
61
|
+
*/
|
|
62
|
+
_updateProductsInRowVisibility() {
|
|
63
|
+
const u = (r.getConfig(this.currentNode).layout || C(this.currentNode)) === "grid";
|
|
64
|
+
this.api.setVisibility(o.PRODUCT_IN_ROW, u), this.api.setVisibility(o.PRODUCT_IN_ROW_LABEL, u);
|
|
65
|
+
}
|
|
66
|
+
_onProductCountChange(t) {
|
|
67
|
+
this.currentNode && (r.updateConfig(
|
|
68
|
+
this.api,
|
|
69
|
+
this.currentNode,
|
|
70
|
+
{ size: t },
|
|
71
|
+
`Changed product count to ${t}`
|
|
72
|
+
), this.store.patchCurrentBlockConfig({ size: t }), this._debouncedRegenerateProductRows());
|
|
73
|
+
}
|
|
74
|
+
_onProductsInRowChange(t) {
|
|
75
|
+
this.currentNode && (r.updateConfig(
|
|
76
|
+
this.api,
|
|
77
|
+
this.currentNode,
|
|
78
|
+
{ cardsInRow: t },
|
|
79
|
+
`Changed products per row to ${t}`
|
|
80
|
+
), this.store.patchCurrentBlockConfig({ cardsInRow: t }), this._debouncedRegenerateProductRows());
|
|
81
|
+
}
|
|
82
|
+
_regenerateProductRows() {
|
|
83
|
+
p({
|
|
84
|
+
currentNode: this.currentNode,
|
|
85
|
+
documentModifier: this.api.getDocumentModifier()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
_listenToFormUpdates() {
|
|
89
|
+
this.api.onValueChanged(o.PRODUCT_COUNT, (t) => {
|
|
90
|
+
this._onProductCountChange(t.toString());
|
|
91
|
+
}), this.api.onValueChanged(o.PRODUCT_IN_ROW, (t) => {
|
|
92
|
+
this._onProductsInRowChange(Number(t));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Subscribe to store changes to update visibility when layout changes
|
|
97
|
+
* This is still needed because layout changes come from LayoutControl
|
|
98
|
+
*/
|
|
99
|
+
_listenStateUpdates() {
|
|
100
|
+
let t = this.store.recommendationConfigs.orientation;
|
|
101
|
+
this.storeUnsubscription = this.store.$subscribe(() => {
|
|
102
|
+
const s = this.store.recommendationConfigs.orientation;
|
|
103
|
+
s !== t && (t = s, this._updateProductsInRowVisibility());
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
l as PRODUCT_LAYOUT_CONTROL_ID,
|
|
109
|
+
I as ProductLayoutControl
|
|
110
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var r = Object.defineProperty;
|
|
2
|
+
var u = (o, t, e) => t in o ? r(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var n = (o, t, e) => u(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 f } from "../../../common-control.js";
|
|
6
|
+
import { RecommendationConfigService as i } from "../../services/configService.js";
|
|
7
|
+
import { useRecommendationExtensionStore as d } from "../../store/recommendation.js";
|
|
8
|
+
const h = "recommendation-shuffle-control", s = {
|
|
9
|
+
SHUFFLE_PRODUCTS: "shuffleProducts"
|
|
10
|
+
};
|
|
11
|
+
class g extends f {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
// Store is used for backward compatibility with product fetching
|
|
15
|
+
n(this, "store", d());
|
|
16
|
+
}
|
|
17
|
+
getId() {
|
|
18
|
+
return h;
|
|
19
|
+
}
|
|
20
|
+
getTemplate() {
|
|
21
|
+
return `
|
|
22
|
+
<div class="shuffle-control-container">
|
|
23
|
+
${this._GuTwoColumns([
|
|
24
|
+
this._GuLabel({ text: "Shuffle Recommended Products" }),
|
|
25
|
+
this._GuToggle(s.SHUFFLE_PRODUCTS)
|
|
26
|
+
])}
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
onRender() {
|
|
31
|
+
this._initializeToggle(), this._setFormValues(), this._listenToFormUpdates();
|
|
32
|
+
}
|
|
33
|
+
onTemplateNodeUpdated(e) {
|
|
34
|
+
super.onTemplateNodeUpdated(e), this._setFormValues();
|
|
35
|
+
}
|
|
36
|
+
_setFormValues() {
|
|
37
|
+
const e = i.getConfig(this.currentNode);
|
|
38
|
+
this.api.updateValues({
|
|
39
|
+
[s.SHUFFLE_PRODUCTS]: e.shuffleProducts
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
_initializeToggle() {
|
|
43
|
+
const e = i.getConfig(this.currentNode);
|
|
44
|
+
this.api.setUIEAttribute(
|
|
45
|
+
s.SHUFFLE_PRODUCTS,
|
|
46
|
+
l.SELECTPICKER.items,
|
|
47
|
+
e.shuffleProducts
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
_onShuffleChange(e) {
|
|
51
|
+
this.currentNode && (i.updateConfig(
|
|
52
|
+
this.api,
|
|
53
|
+
this.currentNode,
|
|
54
|
+
{ shuffleProducts: e },
|
|
55
|
+
`${e ? "Enabled" : "Disabled"} product shuffle`
|
|
56
|
+
), this.store.patchCurrentBlockConfig({ shuffleProducts: e }));
|
|
57
|
+
}
|
|
58
|
+
_listenToFormUpdates() {
|
|
59
|
+
this.api.onValueChanged(s.SHUFFLE_PRODUCTS, (e) => {
|
|
60
|
+
this._onShuffleChange(!!e);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
h as SHUFFLE_CONTROL_ID,
|
|
66
|
+
g as ShuffleControl
|
|
67
|
+
};
|