@useinsider/guido 2.2.0-beta.8abc7b6 → 2.2.0-beta.953ff70
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 +14 -15
- package/dist/composables/useHtmlValidator.js +104 -114
- package/dist/composables/useRecommendation.js +21 -54
- package/dist/config/compiler/recommendationCompilerRules.js +39 -45
- package/dist/config/migrator/itemsBlockMigrator.js +97 -101
- package/dist/config/migrator/recommendationMigrator.js +2 -2
- package/dist/enums/extensions/recommendationBlock.js +1 -1
- package/dist/enums/recommendation.js +15 -16
- package/dist/extensions/Blocks/Recommendation/block.js +9 -133
- package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +187 -0
- package/dist/extensions/Blocks/Recommendation/constants.js +13 -0
- package/dist/extensions/Blocks/Recommendation/control.js +336 -0
- package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
- package/dist/extensions/Blocks/Recommendation/controls/index.js +245 -0
- package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textAfter.js → omnibusDiscountTextAfterControl.js} +14 -16
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textBefore.js → omnibusDiscountTextBeforeControl.js} +14 -16
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textAfter.js → omnibusPriceTextAfterControl.js} +14 -16
- package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textBefore.js → omnibusPriceTextBeforeControl.js} +12 -14
- package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
- package/dist/extensions/Blocks/Recommendation/extension.js +17 -40
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +3 -19
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -13
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +10 -21
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +207 -254
- package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +181 -0
- package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +189 -0
- package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +209 -0
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +15 -26
- package/dist/extensions/Blocks/controlFactories.js +93 -125
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +186 -242
- package/dist/services/recommendationApi.js +8 -11
- package/dist/services/templateLibraryApi.js +13 -16
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/composables/useRecommendation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -67
- package/dist/src/extensions/Blocks/Recommendation/{controls/cardComposition/index.d.ts → cardCompositionControl.d.ts} +3 -23
- package/dist/src/extensions/Blocks/Recommendation/{constants/controlIds.d.ts → constants.d.ts} +24 -0
- package/dist/src/extensions/Blocks/Recommendation/control.d.ts +38 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +589 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +0 -9
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +468 -138
- package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +16 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/{grid/migration.d.ts → migrationTemplate.d.ts} +4 -11
- package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +52 -0
- package/dist/static/styles/customEditorStyle.css.js +11 -35
- package/dist/utils/pairProductVariables.js +56 -57
- package/dist/utils/templatePreparation.js +14 -15
- package/package.json +1 -1
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +0 -121
- package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +0 -4
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +0 -4
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +0 -66
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +0 -22
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +0 -21
- package/dist/extensions/Blocks/Recommendation/controls/button/index.js +0 -64
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +0 -80
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +0 -232
- package/dist/extensions/Blocks/Recommendation/controls/image/index.js +0 -19
- package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +0 -92
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +0 -102
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +0 -209
- package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +0 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +0 -250
- package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +0 -70
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +0 -160
- package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +0 -67
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -307
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +0 -21
- package/dist/extensions/Blocks/Recommendation/controls/name/index.js +0 -46
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +0 -108
- package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +0 -44
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +0 -48
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +0 -48
- package/dist/extensions/Blocks/Recommendation/controls/price/index.js +0 -44
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +0 -222
- package/dist/extensions/Blocks/Recommendation/services/configService.js +0 -240
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +0 -228
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +0 -66
- package/dist/extensions/Blocks/Recommendation/templates/index.js +0 -12
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +0 -169
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +0 -73
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +0 -134
- package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +0 -6
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -29
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +0 -46
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +0 -17
- package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +0 -13
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -49
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +0 -13
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +0 -41
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -35
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -143
- package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -31
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -35
- package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +0 -37
- package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +0 -29
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +0 -52
- package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +0 -22
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -79
- package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +0 -24
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -60
- package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +0 -23
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -221
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +0 -29
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -97
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +0 -34
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -95
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -100
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -100
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +0 -15
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -95
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -83
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -151
- package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -20
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +0 -33
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +0 -41
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -8
- package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +0 -25
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +0 -18
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -66
- package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -166
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -33
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +0 -77
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
var _ = Object.defineProperty;
|
|
2
|
-
var c = (i, o, t) => o in i ? _(i, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[o] = t;
|
|
3
|
-
var d = (i, o, t) => c(i, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
-
import { EditorStatePropertyType as u, PreviewDeviceMode as R } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
-
import { CommonControl as h } from "../../../common-control.js";
|
|
6
|
-
import { MAX_PRODUCT_COUNT as C, MAX_PRODUCTS_PER_ROW as p, MAX_MOBILE_PRODUCTS_PER_ROW as m } from "../../constants/layout.js";
|
|
7
|
-
import { RecommendationConfigService as s } from "../../services/configService.js";
|
|
8
|
-
import { useRecommendationExtensionStore as l } from "../../store/recommendation.js";
|
|
9
|
-
import { ensureMobileCssRulesExist as O } from "../mobileLayout/cssRules.js";
|
|
10
|
-
import { getCurrentLayout as I, regenerateMobileProductRows as g, regenerateProductRowsWithStyles as b } from "./utils.js";
|
|
11
|
-
import { useDebounceFn as N } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
12
|
-
const P = "recommendation-product-layout-control", e = {
|
|
13
|
-
PRODUCT_COUNT: "size",
|
|
14
|
-
PRODUCT_IN_ROW: "cardsInRow",
|
|
15
|
-
PRODUCT_IN_ROW_LABEL: "cardsInRowLabel",
|
|
16
|
-
MOBILE_CARDS_IN_ROW: "mobileCardsInRow",
|
|
17
|
-
MOBILE_CARDS_IN_ROW_LABEL: "mobileCardsInRowLabel"
|
|
18
|
-
};
|
|
19
|
-
class S extends h {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
// Store is used for backward compatibility with product fetching and regeneration
|
|
23
|
-
d(this, "store", l());
|
|
24
|
-
d(this, "storeUnsubscription", () => {
|
|
25
|
-
});
|
|
26
|
-
d(this, "_debouncedRegenerateProductRows", N(() => {
|
|
27
|
-
this._regenerateProductRows();
|
|
28
|
-
}, 500));
|
|
29
|
-
}
|
|
30
|
-
getId() {
|
|
31
|
-
return P;
|
|
32
|
-
}
|
|
33
|
-
getTemplate() {
|
|
34
|
-
return `
|
|
35
|
-
<div class="product-layout-control-container">
|
|
36
|
-
${this._GuTwoColumns([
|
|
37
|
-
this._GuLabel({ text: "Number of Products" }),
|
|
38
|
-
this._GuCounter({ name: e.PRODUCT_COUNT, maxValue: C }),
|
|
39
|
-
this._GuLabel({
|
|
40
|
-
text: "Products in One Row on Desktop",
|
|
41
|
-
name: e.PRODUCT_IN_ROW_LABEL
|
|
42
|
-
}),
|
|
43
|
-
this._GuCounter({ name: e.PRODUCT_IN_ROW, maxValue: p }),
|
|
44
|
-
this._GuLabel({
|
|
45
|
-
text: "Products in One Row on Mobile",
|
|
46
|
-
name: e.MOBILE_CARDS_IN_ROW_LABEL
|
|
47
|
-
}),
|
|
48
|
-
this._GuCounter({
|
|
49
|
-
name: e.MOBILE_CARDS_IN_ROW,
|
|
50
|
-
maxValue: m
|
|
51
|
-
})
|
|
52
|
-
])}
|
|
53
|
-
</div>
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
56
|
-
onRender() {
|
|
57
|
-
this._setFormValues(), this._updateProductsInRowVisibility(), this._listenToFormUpdates(), this._listenStateUpdates(), this._subscribeToEditorModeChanges();
|
|
58
|
-
}
|
|
59
|
-
onTemplateNodeUpdated(t) {
|
|
60
|
-
super.onTemplateNodeUpdated(t), this._setFormValues(), this._updateProductsInRowVisibility();
|
|
61
|
-
}
|
|
62
|
-
onDestroy() {
|
|
63
|
-
this.storeUnsubscription();
|
|
64
|
-
}
|
|
65
|
-
_setFormValues() {
|
|
66
|
-
const t = s.getConfig(this.currentNode);
|
|
67
|
-
this.api.updateValues({
|
|
68
|
-
[e.PRODUCT_COUNT]: t.size,
|
|
69
|
-
[e.PRODUCT_IN_ROW]: t.cardsInRow,
|
|
70
|
-
[e.MOBILE_CARDS_IN_ROW]: t.mobileCardsInRow
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Checks if the editor is currently in mobile preview mode
|
|
75
|
-
* using Stripo's EditorStatePropertyType API.
|
|
76
|
-
*/
|
|
77
|
-
_isMobileMode() {
|
|
78
|
-
return this.api.getEditorState()[u.previewDeviceMode] === R.MOBILE;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Updates counter visibility based on layout orientation and editor mode.
|
|
82
|
-
* - List layout: hide both counters (products always full-width)
|
|
83
|
-
* - Grid + desktop mode: show desktop counter, hide mobile counter
|
|
84
|
-
* - Grid + mobile mode: show mobile counter, hide desktop counter
|
|
85
|
-
*/
|
|
86
|
-
_updateProductsInRowVisibility() {
|
|
87
|
-
const r = (s.getConfig(this.currentNode).layout || I(this.currentNode)) === "grid", n = this._isMobileMode();
|
|
88
|
-
this.api.setVisibility(e.PRODUCT_IN_ROW, r && !n), this.api.setVisibility(e.PRODUCT_IN_ROW_LABEL, r && !n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW, r && n), this.api.setVisibility(e.MOBILE_CARDS_IN_ROW_LABEL, r && n);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Subscribes to editor preview mode changes via Stripo API.
|
|
92
|
-
* When the user switches between desktop/mobile preview, toggles
|
|
93
|
-
* which "Products in One Row" counter is visible.
|
|
94
|
-
*/
|
|
95
|
-
_subscribeToEditorModeChanges() {
|
|
96
|
-
this.api.onEditorStatePropUpdated(
|
|
97
|
-
u.previewDeviceMode,
|
|
98
|
-
() => {
|
|
99
|
-
this._updateProductsInRowVisibility();
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
_onProductCountChange(t) {
|
|
104
|
-
this.currentNode && (s.updateConfig(
|
|
105
|
-
this.api,
|
|
106
|
-
this.currentNode,
|
|
107
|
-
{ size: t },
|
|
108
|
-
`Changed product count to ${t}`
|
|
109
|
-
), this.store.patchCurrentBlockConfig({ size: t }), this._debouncedRegenerateProductRows());
|
|
110
|
-
}
|
|
111
|
-
_onProductsInRowChange(t) {
|
|
112
|
-
this.currentNode && (s.updateConfig(
|
|
113
|
-
this.api,
|
|
114
|
-
this.currentNode,
|
|
115
|
-
{ cardsInRow: t },
|
|
116
|
-
`Changed products per row to ${t}`
|
|
117
|
-
), this.store.patchCurrentBlockConfig({ cardsInRow: t }), this._debouncedRegenerateProductRows());
|
|
118
|
-
}
|
|
119
|
-
_onMobileCardsInRowChange(t) {
|
|
120
|
-
this.currentNode && (s.updateConfig(
|
|
121
|
-
this.api,
|
|
122
|
-
this.currentNode,
|
|
123
|
-
{ mobileCardsInRow: t },
|
|
124
|
-
`Changed mobile products per row to ${t}`
|
|
125
|
-
), O(this.api), g({
|
|
126
|
-
currentNode: this.currentNode,
|
|
127
|
-
documentModifier: this.api.getDocumentModifier()
|
|
128
|
-
}));
|
|
129
|
-
}
|
|
130
|
-
_regenerateProductRows() {
|
|
131
|
-
b({
|
|
132
|
-
currentNode: this.currentNode,
|
|
133
|
-
documentModifier: this.api.getDocumentModifier()
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
_listenToFormUpdates() {
|
|
137
|
-
this.api.onValueChanged(e.PRODUCT_COUNT, (t) => {
|
|
138
|
-
this._onProductCountChange(t.toString());
|
|
139
|
-
}), this.api.onValueChanged(e.PRODUCT_IN_ROW, (t) => {
|
|
140
|
-
this._onProductsInRowChange(Number(t));
|
|
141
|
-
}), this.api.onValueChanged(e.MOBILE_CARDS_IN_ROW, (t) => {
|
|
142
|
-
this._onMobileCardsInRowChange(Number(t));
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Subscribe to store changes to update visibility when layout changes
|
|
147
|
-
* This is still needed because layout changes come from LayoutControl
|
|
148
|
-
*/
|
|
149
|
-
_listenStateUpdates() {
|
|
150
|
-
let t = this.store.recommendationConfigs.orientation;
|
|
151
|
-
this.storeUnsubscription = this.store.$subscribe(() => {
|
|
152
|
-
const a = this.store.recommendationConfigs.orientation;
|
|
153
|
-
a !== t && (t = a, this._updateProductsInRowVisibility());
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
export {
|
|
158
|
-
P as PRODUCT_LAYOUT_CONTROL_ID,
|
|
159
|
-
S as ProductLayoutControl
|
|
160
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import { ModificationDescription as S } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { RecommendationBlockId as m } from "../../constants/blockIds.js";
|
|
3
|
-
import { CURRENCY_ATTR as y, MOBILE_CONTAINER_SELECTOR as T, DESKTOP_CONTAINER_SELECTOR as w, CONTAINER_SELECTOR as _ } from "../../constants/selectors.js";
|
|
4
|
-
import { RecommendationConfigService as k } from "../../services/configService.js";
|
|
5
|
-
import { useRecommendationExtensionStore as b } from "../../store/recommendation.js";
|
|
6
|
-
import { prepareProductRows as R } from "../../templates/index.js";
|
|
7
|
-
import { formatPrice as D } from "../../utils/priceFormatter.js";
|
|
8
|
-
import { isTdNode as L } from "../../utils/tagName.js";
|
|
9
|
-
import { sanitizeImageUrl as U, getDefaultProducts as H, DEFAULT_CARD_COMPOSITION as C } from "../../templates/utils.js";
|
|
10
|
-
const q = "ins-recommendation-v3-block-v2";
|
|
11
|
-
function E(o) {
|
|
12
|
-
if (!o)
|
|
13
|
-
return null;
|
|
14
|
-
if ("getAttribute" in o) {
|
|
15
|
-
const e = o.getAttribute("class");
|
|
16
|
-
if (e && e.includes(q))
|
|
17
|
-
return o;
|
|
18
|
-
}
|
|
19
|
-
return "querySelector" in o ? o.querySelector(`.${q}`) : null;
|
|
20
|
-
}
|
|
21
|
-
function P(o) {
|
|
22
|
-
const e = E(o);
|
|
23
|
-
if (!e || !("getAttribute" in e))
|
|
24
|
-
return "grid";
|
|
25
|
-
const t = e.getAttribute("data-layout");
|
|
26
|
-
return t === "list" || t === "horizontal" ? "list" : "grid";
|
|
27
|
-
}
|
|
28
|
-
function N(o) {
|
|
29
|
-
const e = E(o);
|
|
30
|
-
if (!e || !("getAttribute" in e))
|
|
31
|
-
return C;
|
|
32
|
-
const t = e.getAttribute("data-card-composition");
|
|
33
|
-
return t ? t.split(",").filter(Boolean) : C;
|
|
34
|
-
}
|
|
35
|
-
function g(o, e, t) {
|
|
36
|
-
if (!e || !("childNodes" in e))
|
|
37
|
-
return !1;
|
|
38
|
-
const n = e.childNodes().find(
|
|
39
|
-
(i) => "getType" in i && i.getType() === "text"
|
|
40
|
-
);
|
|
41
|
-
return n ? (o.modifyHtml(n).setText(t), !0) : !1;
|
|
42
|
-
}
|
|
43
|
-
function h(o, e) {
|
|
44
|
-
return o && o.length > 0 ? o : e.length > 0 ? e : H();
|
|
45
|
-
}
|
|
46
|
-
function $(o) {
|
|
47
|
-
const { currentNode: e, documentModifier: t, products: r, layout: n } = o;
|
|
48
|
-
if (!e || !("querySelector" in e))
|
|
49
|
-
return;
|
|
50
|
-
const i = e.querySelector(T);
|
|
51
|
-
if (!i)
|
|
52
|
-
return;
|
|
53
|
-
const c = b(), u = k.getConfig(e), l = h(r, c.recommendationProducts), s = N(e), d = n ?? P(e), a = R(l, d, {
|
|
54
|
-
productsPerRow: u.mobileCardsInRow,
|
|
55
|
-
composition: s
|
|
56
|
-
});
|
|
57
|
-
t.modifyHtml(i).setInnerHtml(a).apply(new S("Updated mobile product rows"));
|
|
58
|
-
}
|
|
59
|
-
function x(o) {
|
|
60
|
-
const {
|
|
61
|
-
currentNode: e,
|
|
62
|
-
documentModifier: t,
|
|
63
|
-
afterRegenerate: r,
|
|
64
|
-
products: n,
|
|
65
|
-
layout: i
|
|
66
|
-
} = o;
|
|
67
|
-
if (!e || !("querySelector" in e))
|
|
68
|
-
return;
|
|
69
|
-
const c = e.querySelector(w) ?? e.querySelector(_);
|
|
70
|
-
if (!c)
|
|
71
|
-
return;
|
|
72
|
-
const u = b(), l = h(n, u.recommendationProducts), { cardsInRow: s } = u.recommendationConfigs, d = N(e), a = i ?? P(e), p = R(l, a, {
|
|
73
|
-
productsPerRow: s,
|
|
74
|
-
composition: d
|
|
75
|
-
});
|
|
76
|
-
t.modifyHtml(c).setInnerHtml(p).apply(new S("Updated product")), $(o), r == null || r();
|
|
77
|
-
}
|
|
78
|
-
function B(o, e, t, r) {
|
|
79
|
-
const i = `0 ${Math.floor(t / 2)}px`;
|
|
80
|
-
let c = !1;
|
|
81
|
-
return r === "grid" ? Array.from(
|
|
82
|
-
o.querySelectorAll(".attribute-cell")
|
|
83
|
-
).forEach((l) => {
|
|
84
|
-
e.modifyHtml(l).setStyle("padding", i), c = !0;
|
|
85
|
-
}) : Array.from(
|
|
86
|
-
o.querySelectorAll(".product-card-wrapper")
|
|
87
|
-
).forEach((l) => {
|
|
88
|
-
const s = "parentNode" in l ? l.parentNode : null;
|
|
89
|
-
s && L(s) && (e.modifyHtml(s).setStyle("padding", i), c = !0);
|
|
90
|
-
}), c;
|
|
91
|
-
}
|
|
92
|
-
function v(o, e, t) {
|
|
93
|
-
const r = `${t}px`, n = Array.from(o.querySelectorAll(".spacer"));
|
|
94
|
-
let i = !1;
|
|
95
|
-
return n.forEach((c) => {
|
|
96
|
-
e.modifyHtml(c).setStyle("height", r), i = !0;
|
|
97
|
-
}), i;
|
|
98
|
-
}
|
|
99
|
-
function V(o) {
|
|
100
|
-
const { currentNode: e, documentModifier: t } = o;
|
|
101
|
-
if (!e)
|
|
102
|
-
return;
|
|
103
|
-
const r = E(e);
|
|
104
|
-
if (!r || !("getAttribute" in r))
|
|
105
|
-
return;
|
|
106
|
-
const n = r.getAttribute("data-column-spacing"), i = r.getAttribute("data-row-spacing"), c = P(e);
|
|
107
|
-
let u = !1;
|
|
108
|
-
if (n) {
|
|
109
|
-
const l = parseInt(n);
|
|
110
|
-
Number.isNaN(l) || (u = B(
|
|
111
|
-
e,
|
|
112
|
-
t,
|
|
113
|
-
l,
|
|
114
|
-
c
|
|
115
|
-
));
|
|
116
|
-
}
|
|
117
|
-
if (i) {
|
|
118
|
-
const l = parseInt(i);
|
|
119
|
-
if (!Number.isNaN(l)) {
|
|
120
|
-
const s = v(e, t, l);
|
|
121
|
-
u = u || s;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
u && t.apply(new S("Reapply spacing after regeneration"));
|
|
125
|
-
}
|
|
126
|
-
function ee(o) {
|
|
127
|
-
const { currentNode: e, documentModifier: t, afterRegenerate: r, products: n, layout: i } = o;
|
|
128
|
-
e && x({
|
|
129
|
-
currentNode: e,
|
|
130
|
-
documentModifier: t,
|
|
131
|
-
products: n,
|
|
132
|
-
layout: i,
|
|
133
|
-
afterRegenerate: () => {
|
|
134
|
-
setTimeout(() => {
|
|
135
|
-
V({ currentNode: e, documentModifier: t });
|
|
136
|
-
}, 0), r == null || r();
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function M() {
|
|
141
|
-
const o = b(), { currencySettings: e } = o.recommendationConfigs;
|
|
142
|
-
return {
|
|
143
|
-
code: e.value,
|
|
144
|
-
symbol: e.symbol,
|
|
145
|
-
alignment: e.alignment === "0" ? "before" : "after",
|
|
146
|
-
decimalCount: parseInt(e.decimalCount) || 2,
|
|
147
|
-
decimalSeparator: e.decimalSeparator,
|
|
148
|
-
thousandSeparator: e.thousandSeparator
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function A(o, e = "price") {
|
|
152
|
-
const t = M(), r = o[e], n = (r == null ? void 0 : r[t.code]) ?? Object.values(r ?? {})[0] ?? 0;
|
|
153
|
-
return D({
|
|
154
|
-
price: n,
|
|
155
|
-
currency: t
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function j(o) {
|
|
159
|
-
var i, c;
|
|
160
|
-
const e = M(), t = ((i = o.original_price) == null ? void 0 : i[e.code]) ?? Object.values(o.original_price ?? {})[0] ?? 0, r = ((c = o.price) == null ? void 0 : c[e.code]) ?? Object.values(o.price ?? {})[0] ?? 0, n = t > 0 ? Math.round((t - r) / t * 100) : 0;
|
|
161
|
-
return n > 0 ? `-${n}%` : "0%";
|
|
162
|
-
}
|
|
163
|
-
function I(o) {
|
|
164
|
-
const { documentModifier: e, product: t, priceEl: r, oldPriceEl: n, omnibusPriceEl: i, omnibusDiscountEl: c } = o;
|
|
165
|
-
let u = !1;
|
|
166
|
-
if (r && "querySelector" in r) {
|
|
167
|
-
const l = r.querySelector("strong"), s = A(t, "price");
|
|
168
|
-
g(e, l, s) && (u = !0);
|
|
169
|
-
}
|
|
170
|
-
if (n && "querySelector" in n) {
|
|
171
|
-
const l = n.querySelector("strong"), s = A(t, "original_price");
|
|
172
|
-
g(e, l, s) && (u = !0);
|
|
173
|
-
}
|
|
174
|
-
if (i && "querySelector" in i) {
|
|
175
|
-
const l = i.querySelector(".omnibus-price-value"), s = A(t, "original_price");
|
|
176
|
-
g(e, l, s) && (u = !0);
|
|
177
|
-
}
|
|
178
|
-
if (c && "querySelector" in c) {
|
|
179
|
-
const l = c.querySelector(".omnibus-discount-value"), s = j(t);
|
|
180
|
-
g(e, l, s) && (u = !0);
|
|
181
|
-
}
|
|
182
|
-
return u;
|
|
183
|
-
}
|
|
184
|
-
function W(o) {
|
|
185
|
-
const {
|
|
186
|
-
documentModifier: e,
|
|
187
|
-
product: t,
|
|
188
|
-
imageEl: r,
|
|
189
|
-
nameEl: n,
|
|
190
|
-
priceEl: i,
|
|
191
|
-
oldPriceEl: c,
|
|
192
|
-
omnibusPriceEl: u,
|
|
193
|
-
omnibusDiscountEl: l,
|
|
194
|
-
buttonEl: s
|
|
195
|
-
} = o;
|
|
196
|
-
let d = !1;
|
|
197
|
-
if (r && "querySelector" in r) {
|
|
198
|
-
const a = r.querySelector("img");
|
|
199
|
-
a && (e.modifyHtml(a).setAttribute("src", U(t.image_url)).setAttribute("alt", t.name), d = !0);
|
|
200
|
-
const p = r.querySelector("a");
|
|
201
|
-
p && (e.modifyHtml(p).setAttribute("href", t.url), d = !0);
|
|
202
|
-
}
|
|
203
|
-
if (n && "querySelector" in n) {
|
|
204
|
-
const a = n.querySelector("strong");
|
|
205
|
-
g(e, a, t.name) && (d = !0);
|
|
206
|
-
}
|
|
207
|
-
if (I({
|
|
208
|
-
documentModifier: e,
|
|
209
|
-
product: t,
|
|
210
|
-
priceEl: i,
|
|
211
|
-
oldPriceEl: c,
|
|
212
|
-
omnibusPriceEl: u,
|
|
213
|
-
omnibusDiscountEl: l
|
|
214
|
-
}) && (d = !0), s && "querySelector" in s) {
|
|
215
|
-
const a = s.querySelector("a.es-button") || s.querySelector("a");
|
|
216
|
-
a && (e.modifyHtml(a).setAttribute("href", t.url), d = !0);
|
|
217
|
-
}
|
|
218
|
-
return d;
|
|
219
|
-
}
|
|
220
|
-
function te(o) {
|
|
221
|
-
const { currentNode: e, documentModifier: t, products: r } = o;
|
|
222
|
-
if (!e || !("querySelectorAll" in e))
|
|
223
|
-
return !1;
|
|
224
|
-
const n = e.querySelectorAll(
|
|
225
|
-
`[esd-extension-block-id="${m.IMAGE}"]`
|
|
226
|
-
), i = e.querySelectorAll(
|
|
227
|
-
`[esd-extension-block-id="${m.NAME}"]`
|
|
228
|
-
), c = e.querySelectorAll(
|
|
229
|
-
`[esd-extension-block-id="${m.PRICE}"]`
|
|
230
|
-
), u = e.querySelectorAll(
|
|
231
|
-
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
232
|
-
), l = e.querySelectorAll(
|
|
233
|
-
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
234
|
-
), s = e.querySelectorAll(
|
|
235
|
-
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
236
|
-
), d = e.querySelectorAll(
|
|
237
|
-
`[esd-extension-block-id="${m.BUTTON}"]`
|
|
238
|
-
);
|
|
239
|
-
if (n.length !== r.length)
|
|
240
|
-
return !1;
|
|
241
|
-
let a = !1;
|
|
242
|
-
return r.forEach((p, f) => {
|
|
243
|
-
const O = W({
|
|
244
|
-
documentModifier: t,
|
|
245
|
-
product: p,
|
|
246
|
-
imageEl: n[f] ?? null,
|
|
247
|
-
nameEl: i[f] ?? null,
|
|
248
|
-
priceEl: c[f] ?? null,
|
|
249
|
-
oldPriceEl: u[f] ?? null,
|
|
250
|
-
omnibusPriceEl: l[f] ?? null,
|
|
251
|
-
omnibusDiscountEl: s[f] ?? null,
|
|
252
|
-
buttonEl: d[f] ?? null
|
|
253
|
-
});
|
|
254
|
-
a = a || O;
|
|
255
|
-
}), a && t.apply(new S("Updated product content in-place")), !0;
|
|
256
|
-
}
|
|
257
|
-
function oe(o) {
|
|
258
|
-
const { currentNode: e, documentModifier: t } = o;
|
|
259
|
-
if (!e || !("querySelectorAll" in e))
|
|
260
|
-
return !1;
|
|
261
|
-
const n = b().recommendationProducts;
|
|
262
|
-
if (n.length === 0)
|
|
263
|
-
return !1;
|
|
264
|
-
const i = e.querySelectorAll(
|
|
265
|
-
`[esd-extension-block-id="${m.PRICE}"]`
|
|
266
|
-
), c = e.querySelectorAll(
|
|
267
|
-
`[esd-extension-block-id="${m.OLD_PRICE}"]`
|
|
268
|
-
), u = e.querySelectorAll(
|
|
269
|
-
`[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
|
|
270
|
-
), l = e.querySelectorAll(
|
|
271
|
-
`[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
|
|
272
|
-
);
|
|
273
|
-
let s = !1;
|
|
274
|
-
return n.forEach((d, a) => {
|
|
275
|
-
I({
|
|
276
|
-
documentModifier: t,
|
|
277
|
-
product: d,
|
|
278
|
-
priceEl: i[a] ?? null,
|
|
279
|
-
oldPriceEl: c[a] ?? null,
|
|
280
|
-
omnibusPriceEl: u[a] ?? null,
|
|
281
|
-
omnibusDiscountEl: l[a] ?? null
|
|
282
|
-
}) && (s = !0);
|
|
283
|
-
}), s && t.apply(new S("Updated price formatting in-place")), s;
|
|
284
|
-
}
|
|
285
|
-
function re(o) {
|
|
286
|
-
const { currentNode: e, documentModifier: t, currency: r } = o, n = E(e);
|
|
287
|
-
if (!n)
|
|
288
|
-
return;
|
|
289
|
-
const i = r.alignment === "before" ? "0" : "1", c = (u, l) => {
|
|
290
|
-
t.modifyHtml(n).setAttribute(u, l);
|
|
291
|
-
};
|
|
292
|
-
c(y.CURRENCY, r.code), c(y.SYMBOL, r.symbol), c(y.ALIGNMENT, i), c(y.THOUSAND_SEPARATOR, r.thousandSeparator), c(y.DECIMAL_SEPARATOR, r.decimalSeparator), c(y.DECIMAL_COUNT, r.decimalCount.toString()), t.apply(new S("Update currency attributes"));
|
|
293
|
-
}
|
|
294
|
-
export {
|
|
295
|
-
A as formatProductPrice,
|
|
296
|
-
E as getBlockElement,
|
|
297
|
-
N as getCardComposition,
|
|
298
|
-
P as getCurrentLayout,
|
|
299
|
-
V as reapplySpacing,
|
|
300
|
-
$ as regenerateMobileProductRows,
|
|
301
|
-
x as regenerateProductRows,
|
|
302
|
-
ee as regenerateProductRowsWithStyles,
|
|
303
|
-
re as setCurrencyAttributes,
|
|
304
|
-
oe as updatePricesInPlace,
|
|
305
|
-
te as updateProductContentInPlace,
|
|
306
|
-
W as updateSingleProductContent
|
|
307
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ModificationDescription as r } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
const i = "ins-recommendation-desktop-container", s = "ins-recommendation-mobile-container", l = `.${s} { display: none; }`, u = `@media only screen and (max-width: 480px) { .${i} { display: none !important; } .${s} { display: table !important; } }`, c = `.${s}`;
|
|
3
|
-
function a(o, e) {
|
|
4
|
-
return !!o.querySelector(e);
|
|
5
|
-
}
|
|
6
|
-
function d(o) {
|
|
7
|
-
return o.querySelectorAll(`*${i}`).length > 0;
|
|
8
|
-
}
|
|
9
|
-
function p(o) {
|
|
10
|
-
const e = o.getDocumentRootCssNode();
|
|
11
|
-
if (!e)
|
|
12
|
-
return;
|
|
13
|
-
const n = o.getDocumentModifier();
|
|
14
|
-
let t = !1;
|
|
15
|
-
a(e, c) || (n.modifyCss(e).appendRule(l), t = !0), d(e) || (n.modifyCss(e).appendRule(u), t = !0), t && n.apply(new r("Add mobile layout CSS rules"));
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
i as CSS_CLASS_DESKTOP_CONTAINER,
|
|
19
|
-
s as CSS_CLASS_MOBILE_CONTAINER,
|
|
20
|
-
p as ensureMobileCssRulesExist
|
|
21
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createPaddingsControl as n, createTextBackgroundColorControl as e, createTextFontFamilyControl as l, createTextStyleControl as C, createTextSizeControl as c, createTextColorControl as N, createTextAlignControl as a } from "../../../controlFactories.js";
|
|
2
|
-
import { RecommendationBlockId as o } from "../../constants/blockIds.js";
|
|
3
|
-
import { RecommendationControlId as t } from "../../constants/controlIds.js";
|
|
4
|
-
import { CONTAINER_SELECTOR as r } from "../../constants/selectors.js";
|
|
5
|
-
import { NameTextTrimControl as i } from "./textTrim.js";
|
|
6
|
-
const m = a(
|
|
7
|
-
t.NAME_ALIGN,
|
|
8
|
-
o.NAME,
|
|
9
|
-
r
|
|
10
|
-
), A = N(
|
|
11
|
-
t.NAME_COLOR,
|
|
12
|
-
o.NAME,
|
|
13
|
-
r
|
|
14
|
-
), E = c(
|
|
15
|
-
t.NAME_SIZE,
|
|
16
|
-
o.NAME,
|
|
17
|
-
r
|
|
18
|
-
), M = C(
|
|
19
|
-
t.NAME_STYLE,
|
|
20
|
-
o.NAME,
|
|
21
|
-
r
|
|
22
|
-
), s = l(
|
|
23
|
-
t.NAME_FONT_FAMILY,
|
|
24
|
-
o.NAME,
|
|
25
|
-
r
|
|
26
|
-
), d = e(
|
|
27
|
-
t.NAME_BACKGROUND,
|
|
28
|
-
o.NAME,
|
|
29
|
-
r
|
|
30
|
-
), T = n(
|
|
31
|
-
t.NAME_PADDINGS,
|
|
32
|
-
o.NAME,
|
|
33
|
-
r
|
|
34
|
-
), F = {
|
|
35
|
-
align: m,
|
|
36
|
-
color: A,
|
|
37
|
-
size: E,
|
|
38
|
-
style: M,
|
|
39
|
-
fontFamily: s,
|
|
40
|
-
background: d,
|
|
41
|
-
paddings: T,
|
|
42
|
-
textTrim: i
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
F as NameControls
|
|
46
|
-
};
|