@useinsider/guido 3.22.0-beta.3f91a42 → 3.22.0-beta.696e3c7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/@types/config/schemas.js +41 -39
- package/dist/@types/display-condition.js +25 -0
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +84 -82
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
- package/dist/composables/useBlocksConfig.js +32 -24
- package/dist/composables/useDisplayConditions.js +109 -0
- package/dist/enums/academy.js +1 -0
- package/dist/enums/display-condition.js +12 -0
- package/dist/extensions/Blocks/Items/controls/button/link.js +17 -14
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +17 -14
- package/dist/extensions/Blocks/Items/controls/image/link.js +17 -14
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +10 -9
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +13 -12
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +30 -29
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +16 -15
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +26 -25
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +28 -27
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +80 -75
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +7 -7
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +116 -121
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
- package/dist/extensions/Blocks/common-control.js +55 -62
- package/dist/extensions/DisplayConditions/bridge.js +18 -0
- package/dist/extensions/DisplayConditions/constants.js +17 -0
- package/dist/extensions/DisplayConditions/control.js +182 -0
- package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
- package/dist/extensions/DisplayConditions/extension.js +28 -0
- package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
- package/dist/extensions/DisplayConditions/library.js +27 -0
- package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
- package/dist/node_modules/valibot/dist/index.js +297 -261
- package/dist/package.json.js +2 -2
- package/dist/services/displayConditionApi.js +39 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/display-condition.d.ts +60 -0
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useDisplayConditions.d.ts +16 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/display-condition.d.ts +15 -0
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -3
- package/dist/src/extensions/Blocks/common-control.d.ts +0 -2
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +6 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +23 -0
- package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
- package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
- package/dist/src/mock/api/display-conditions.d.ts +2 -0
- package/dist/src/services/displayConditionApi.d.ts +8 -0
- package/dist/src/stores/config.d.ts +166 -0
- package/dist/src/stores/display-condition.d.ts +84 -0
- package/dist/src/utils/displayCondition.d.ts +10 -0
- package/dist/src/utils/protectTableText.d.ts +2 -0
- package/dist/stores/config.js +13 -6
- package/dist/stores/display-condition.js +29 -0
- package/dist/utils/displayCondition.js +26 -0
- package/dist/utils/pairProductVariables.js +30 -29
- package/dist/utils/protectTableText.js +22 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _ = Object.defineProperty;
|
|
2
|
-
var N = (u,
|
|
3
|
-
var s = (u,
|
|
2
|
+
var N = (u, d, e) => d in u ? _(u, d, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[d] = e;
|
|
3
|
+
var s = (u, d, e) => N(u, typeof d != "symbol" ? d + "" : d, e);
|
|
4
4
|
import { useConfig as g } from "../../../../../composables/useConfig.js";
|
|
5
5
|
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
6
|
import { CommonControl as P } from "../../../common-control.js";
|
|
@@ -9,10 +9,10 @@ import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
|
9
9
|
import { RecommendationConfigService as l } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as k } from "../../store/recommendation.js";
|
|
11
11
|
import { refreshBlockOutsidePanel as S } from "../../utils/blockRefresh.js";
|
|
12
|
-
import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as O, pickConfigDescription as b, isProductIdsChange as B, PRODUCT_IDS_DESCRIPTION as
|
|
12
|
+
import { registerNodeConfigWriter as T, writeBlockConfigOutsidePanel as m, hasEditedConfigChange as O, pickConfigDescription as b, isProductIdsChange as B, PRODUCT_IDS_DESCRIPTION as F } from "../../utils/nodeConfigWriter.js";
|
|
13
13
|
import { AlgorithmControl as E } from "./algorithm.js";
|
|
14
14
|
import { ALGORITHM_CONTROL_ID as _e } from "./algorithm.js";
|
|
15
|
-
import { CurrencyControl as
|
|
15
|
+
import { CurrencyControl as L } from "./currency.js";
|
|
16
16
|
import { CURRENCY_CONTROL_ID as ye } from "./currency.js";
|
|
17
17
|
import { FiltersControl as D } from "./filters.js";
|
|
18
18
|
import { FILTERS_CONTROL_ID as Re } from "./filters.js";
|
|
@@ -20,18 +20,18 @@ import { LayoutOrientationControl as U } from "./layoutOrientation.js";
|
|
|
20
20
|
import { LAYOUT_ORIENTATION_CONTROL_ID as ke } from "./layoutOrientation.js";
|
|
21
21
|
import { LocaleControl as v } from "./locale.js";
|
|
22
22
|
import { LOCALE_CONTROL_ID as Te } from "./locale.js";
|
|
23
|
-
import { PricePlacementControl as
|
|
23
|
+
import { PricePlacementControl as w } from "./pricePlacement.js";
|
|
24
24
|
import { PRICE_PLACEMENT_CONTROL_ID as be } from "./pricePlacement.js";
|
|
25
|
-
import { ProductCountControl as
|
|
26
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
25
|
+
import { ProductCountControl as A } from "./productCount.js";
|
|
26
|
+
import { PRODUCT_COUNT_CONTROL_ID as Fe } from "./productCount.js";
|
|
27
27
|
import { ProductLayoutControl as V } from "./productLayout.js";
|
|
28
|
-
import { PRODUCT_LAYOUT_CONTROL_ID as
|
|
28
|
+
import { PRODUCT_LAYOUT_CONTROL_ID as Le } from "./productLayout.js";
|
|
29
29
|
import { ShuffleControl as W } from "./shuffle.js";
|
|
30
30
|
import { SHUFFLE_CONTROL_ID as Ue } from "./shuffle.js";
|
|
31
31
|
import { StrategyControl as x } from "./strategy.js";
|
|
32
|
-
import { STRATEGY_CONTROL_ID as
|
|
33
|
-
import { setCurrencyAttributes as M, getBlockElement as G, isPartnerManagedBlock as
|
|
34
|
-
import { adjustProductsToSize as Ve, formatProductPrice as We, getCardComposition as xe, getCurrentLayout as Me, getMainContainerTbody as Ge, regenerateMobileProductRows as
|
|
32
|
+
import { STRATEGY_CONTROL_ID as we } from "./strategy.js";
|
|
33
|
+
import { setCurrencyAttributes as M, getBlockElement as G, isPartnerManagedBlock as z, updateProductContentInPlace as $, regenerateProductRowsWithStyles as H } from "./utils.js";
|
|
34
|
+
import { adjustProductsToSize as Ve, formatProductPrice as We, getCardComposition as xe, getCurrentLayout as Me, getMainContainerTbody as Ge, regenerateMobileProductRows as ze, updatePricesInPlace as $e, updateSingleProductContent as He } from "./utils.js";
|
|
35
35
|
import { useDebounceFn as C } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
36
36
|
const f = "Update recommendation filters", Y = "ui-elements-recommendation-block";
|
|
37
37
|
class me extends P {
|
|
@@ -69,11 +69,11 @@ class me extends P {
|
|
|
69
69
|
s(this, "_debouncedFetchProducts", C(async (e, t) => {
|
|
70
70
|
if (t !== this.panelGeneration)
|
|
71
71
|
return;
|
|
72
|
-
const
|
|
72
|
+
const o = this._getBlockConfigVersion(e);
|
|
73
73
|
try {
|
|
74
|
-
await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion,
|
|
74
|
+
await (e === null ? this.store.fetchRecommendationProducts() : this.store.fetchRecommendationProductsForBlock(e)), t === this.panelGeneration && (this.fetchedConfigVersion = Math.max(this.fetchedConfigVersion, o));
|
|
75
75
|
} finally {
|
|
76
|
-
t === this.panelGeneration &&
|
|
76
|
+
t === this.panelGeneration && o === this._getBlockConfigVersion(e) && this._scheduleConfigFlush();
|
|
77
77
|
}
|
|
78
78
|
}, 500));
|
|
79
79
|
/**
|
|
@@ -90,8 +90,8 @@ class me extends P {
|
|
|
90
90
|
s(this, "_debouncedRegenerateWithProducts", C((e) => {
|
|
91
91
|
if (e !== this.panelGeneration || !this.currentNode || !this.api)
|
|
92
92
|
return;
|
|
93
|
-
const t = this._getRecommendationIdFromNode(this.currentNode),
|
|
94
|
-
if (t === null ||
|
|
93
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), o = this.store.currentRecommendationId;
|
|
94
|
+
if (t === null || o === null || t === o || !this.store.blockStates[t]) {
|
|
95
95
|
this.hasUnrenderedProducts = !1, this._regenerateWithProducts();
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
@@ -100,7 +100,7 @@ class me extends P {
|
|
|
100
100
|
try {
|
|
101
101
|
this._regenerateWithProducts();
|
|
102
102
|
} finally {
|
|
103
|
-
this.store.setCurrentBlock(
|
|
103
|
+
this.store.setCurrentBlock(o);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}, 100));
|
|
@@ -125,9 +125,9 @@ class me extends P {
|
|
|
125
125
|
getTemplate() {
|
|
126
126
|
var e;
|
|
127
127
|
return this.rrsEnabled = g().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
128
|
-
var
|
|
129
|
-
return (
|
|
130
|
-
}), this.algorithmControl = new E(), this.localeControl = new v(), this.currencyControl = new
|
|
128
|
+
var o;
|
|
129
|
+
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
130
|
+
}), this.algorithmControl = new E(), this.localeControl = new v(), this.currencyControl = new L(), this.productCountControl = new A(), this.productLayoutControl = new V(), this.filtersControl = new D(), this.shuffleControl = new W(), this.pricePlacementControl = new w(), this.layoutOrientationControl = new U(), this.strategyControl = this.rrsEnabled ? new x() : null, this._subControls.forEach((t) => {
|
|
131
131
|
t && (t.api = this.api);
|
|
132
132
|
}), `
|
|
133
133
|
<div class="recommendation-controls-container">
|
|
@@ -149,25 +149,32 @@ class me extends P {
|
|
|
149
149
|
const t = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
150
150
|
if (!t)
|
|
151
151
|
return;
|
|
152
|
-
const
|
|
153
|
-
t.classList.toggle("strategy-block",
|
|
152
|
+
const o = this._getRecommendationIdFromNode(e) === null ? null : l.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= R), i = this.rrsEnabled && !!o && !n;
|
|
153
|
+
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", i);
|
|
154
154
|
}
|
|
155
|
-
onRender() {
|
|
156
|
-
|
|
155
|
+
async onRender() {
|
|
156
|
+
var o;
|
|
157
|
+
T(this.api);
|
|
158
|
+
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
159
|
+
if (t !== null && this.store.setCurrentBlock(t), e !== null && this._syncNodeConfigIfChanged(e), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), t !== null && ((o = this.store.blockStates[t]) != null && o.isInitialized)) {
|
|
160
|
+
this._initializeSubControls();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await this._fetchBlockData(t), this._initializeSubControls();
|
|
157
164
|
}
|
|
158
165
|
onTemplateNodeUpdated(e) {
|
|
159
|
-
var
|
|
166
|
+
var o;
|
|
160
167
|
super.onTemplateNodeUpdated(e);
|
|
161
168
|
const t = this._getRecommendationIdFromNode(e);
|
|
162
|
-
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e),
|
|
169
|
+
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), t !== null && !((o = this.store.blockStates[t]) != null && o.isInitialized) && this._fetchBlockData(t).then(() => {
|
|
163
170
|
this._initializeSubControls();
|
|
164
|
-
}), this._subControls.forEach((
|
|
171
|
+
}), this._subControls.forEach((n) => {
|
|
165
172
|
var i;
|
|
166
|
-
|
|
173
|
+
n != null && n.api && (n.currentNode = e, (i = n.onTemplateNodeUpdated) == null || i.call(n, e));
|
|
167
174
|
});
|
|
168
175
|
}
|
|
169
176
|
onDestroy() {
|
|
170
|
-
this.panelGeneration++, this.isPanelAlive = !1, this.
|
|
177
|
+
this.panelGeneration++, this.isPanelAlive = !1, this.storeUnsubscription(), this._finishBlockOutsidePanel(), this.hasUnrenderedProducts = !1, this._subControls.forEach((e) => {
|
|
171
178
|
var t;
|
|
172
179
|
return (t = e == null ? void 0 : e.onDestroy) == null ? void 0 : t.call(e);
|
|
173
180
|
});
|
|
@@ -177,23 +184,11 @@ class me extends P {
|
|
|
177
184
|
* Each sub-control manages its own form values and event listeners
|
|
178
185
|
*/
|
|
179
186
|
_initializeSubControls() {
|
|
180
|
-
this.
|
|
187
|
+
this._subControls.forEach((e) => {
|
|
181
188
|
var t;
|
|
182
189
|
e && (e.api = this.api, e.currentNode = this.currentNode, (t = e.onRender) == null || t.call(e));
|
|
183
190
|
});
|
|
184
191
|
}
|
|
185
|
-
// The panel's own node, not the store's last focused block, decides what to render; the caller
|
|
186
|
-
// fetches an uninitialized block once its config is synced.
|
|
187
|
-
_renderWithPanelNode(e) {
|
|
188
|
-
var t;
|
|
189
|
-
if (!(!this.isAwaitingPanelNode || e === null)) {
|
|
190
|
-
if (this.isAwaitingPanelNode = !1, (t = this.store.blockStates[e]) != null && t.isInitialized) {
|
|
191
|
-
this._initializeSubControls();
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender());
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
192
|
/**
|
|
198
193
|
* Syncs persisted node config into the Pinia store's block state.
|
|
199
194
|
*
|
|
@@ -224,8 +219,8 @@ class me extends P {
|
|
|
224
219
|
const t = this.store.blockStates[e];
|
|
225
220
|
if (!t)
|
|
226
221
|
return;
|
|
227
|
-
const
|
|
228
|
-
t.syncedConfigFingerprint =
|
|
222
|
+
const o = JSON.stringify(l.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
223
|
+
t.syncedConfigFingerprint = o, n !== o && ((i = this.pendingNodeConfigWrite) == null ? void 0 : i.blockId) !== e && this._syncNodeConfigToStore();
|
|
229
224
|
}
|
|
230
225
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
231
226
|
_isPendingStrategyIdChange() {
|
|
@@ -245,15 +240,15 @@ class me extends P {
|
|
|
245
240
|
return !e || t !== null && e.blockId !== t ? null : e;
|
|
246
241
|
}
|
|
247
242
|
_getNodeConfigUpdates(e) {
|
|
248
|
-
const { filters: t, strategy:
|
|
243
|
+
const { filters: t, strategy: o, strategyId: n, size: i, productIds: r, nodeConfigVersion: h } = e, { partnerName: c } = g();
|
|
249
244
|
return {
|
|
250
245
|
filters: t,
|
|
251
|
-
strategy:
|
|
252
|
-
strategyId:
|
|
246
|
+
strategy: o,
|
|
247
|
+
strategyId: n,
|
|
253
248
|
size: i,
|
|
254
249
|
productIds: r,
|
|
255
250
|
configVersion: h,
|
|
256
|
-
...
|
|
251
|
+
...c.value ? { partnerName: c.value } : {}
|
|
257
252
|
};
|
|
258
253
|
}
|
|
259
254
|
/**
|
|
@@ -292,8 +287,8 @@ class me extends P {
|
|
|
292
287
|
const e = this.pendingNodeConfigWrite;
|
|
293
288
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !(!e || !this.api)) {
|
|
294
289
|
if (e.blockId !== this.store.currentRecommendationId || !this.currentNode) {
|
|
295
|
-
const { blockId: t, updates:
|
|
296
|
-
!m(t,
|
|
290
|
+
const { blockId: t, updates: o } = e;
|
|
291
|
+
!m(t, o, f) && this.store.blockStates[t] && console.error("[recommendation] pending config write did not reach a node", { blockId: t });
|
|
297
292
|
return;
|
|
298
293
|
}
|
|
299
294
|
O(this.currentNode, e.updates) && l.updateConfig(
|
|
@@ -312,11 +307,11 @@ class me extends P {
|
|
|
312
307
|
_pendingDescription() {
|
|
313
308
|
const e = this._pendingWriteForNode();
|
|
314
309
|
if (!(!e || !this.currentNode || !B(this.currentNode, e.updates)))
|
|
315
|
-
return
|
|
310
|
+
return F;
|
|
316
311
|
}
|
|
317
312
|
_syncNodeConfigToStore() {
|
|
318
|
-
var
|
|
319
|
-
const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId,
|
|
313
|
+
var n;
|
|
314
|
+
const e = l.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
320
315
|
this.store.patchCurrentBlockConfig({
|
|
321
316
|
strategy: e.strategy,
|
|
322
317
|
strategyId: e.strategyId,
|
|
@@ -331,7 +326,7 @@ class me extends P {
|
|
|
331
326
|
// Only sync filters from node config during initial load.
|
|
332
327
|
// After initialization, the Pinia store is the source of truth
|
|
333
328
|
// for filters (edited via the filter drawer).
|
|
334
|
-
...
|
|
329
|
+
...o ? {} : { filters: e.filters },
|
|
335
330
|
shuffleProducts: e.shuffleProducts,
|
|
336
331
|
priceMovedToNextLine: e.priceMovedToNextLine,
|
|
337
332
|
priceHideIfSameAsDiscounted: e.priceHideIfSameAsDiscounted,
|
|
@@ -352,27 +347,27 @@ class me extends P {
|
|
|
352
347
|
* 2. Smart defaults for new blocks (currency, algorithm) — sequential
|
|
353
348
|
* 3. Product data with correct defaults — sequential
|
|
354
349
|
*
|
|
355
|
-
*
|
|
350
|
+
* Shared by onRender() and onTemplateNodeUpdated() to avoid duplication.
|
|
356
351
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
357
352
|
*/
|
|
358
353
|
async _fetchBlockData(e) {
|
|
359
354
|
if (e !== null && this.store.markBlockInitialized(e), (await Promise.allSettled([
|
|
360
355
|
this.store.fetchRecommendationCreateData(),
|
|
361
356
|
this.store.fetchRecommendationFilters()
|
|
362
|
-
])).forEach((
|
|
363
|
-
|
|
357
|
+
])).forEach((n, i) => {
|
|
358
|
+
n.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][i]} failed`, n.reason);
|
|
364
359
|
}), e !== null && this.store.currentRecommendationId !== e) {
|
|
365
360
|
this._refreshOutsidePanel(e, !0);
|
|
366
361
|
return;
|
|
367
362
|
}
|
|
368
363
|
this._applySmartDefaults();
|
|
369
|
-
const
|
|
364
|
+
const o = this._getBlockConfigVersion(e);
|
|
370
365
|
try {
|
|
371
366
|
await this.store.fetchRecommendationProducts();
|
|
372
|
-
} catch (
|
|
373
|
-
console.warn("Recommendation block: fetchRecommendationProducts failed",
|
|
367
|
+
} catch (n) {
|
|
368
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", n);
|
|
374
369
|
}
|
|
375
|
-
e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !==
|
|
370
|
+
e !== null && !this._isPanelOn(e) && this._refreshOutsidePanel(e, this._getBlockConfigVersion(e) !== o);
|
|
376
371
|
}
|
|
377
372
|
_isPanelOn(e) {
|
|
378
373
|
return this.isPanelAlive && this.store.currentRecommendationId === e;
|
|
@@ -391,51 +386,51 @@ class me extends P {
|
|
|
391
386
|
if (!this.currentNode || !this.api)
|
|
392
387
|
return;
|
|
393
388
|
const e = l.getConfig(this.currentNode), t = {};
|
|
394
|
-
let
|
|
389
|
+
let o = null, n = null, i = null;
|
|
395
390
|
if (e.currency.code === a.currency.code) {
|
|
396
391
|
const { currencyList: r } = this.store;
|
|
397
392
|
r.length > 0 && (r.some(
|
|
398
|
-
(
|
|
399
|
-
) || (
|
|
393
|
+
(c) => c.value === `price.${a.currency.code}`
|
|
394
|
+
) || (o = r[0].value.replace("price.", ""), t.currency = {
|
|
400
395
|
...a.currency,
|
|
401
|
-
code:
|
|
402
|
-
symbol:
|
|
396
|
+
code: o,
|
|
397
|
+
symbol: o
|
|
403
398
|
}));
|
|
404
399
|
}
|
|
405
400
|
if (e.strategy === a.strategy) {
|
|
406
401
|
const r = this.store.getActivePredictiveAlgorithms;
|
|
407
402
|
r.length > 0 && (r.some(
|
|
408
|
-
(
|
|
409
|
-
) || (
|
|
403
|
+
(c) => c.value === a.strategy
|
|
404
|
+
) || (n = r[0].value, t.strategy = n));
|
|
410
405
|
}
|
|
411
406
|
if (e.language === a.language) {
|
|
412
407
|
const r = this.store.getLanguages;
|
|
413
408
|
r.length > 0 && (r.some(
|
|
414
|
-
(
|
|
409
|
+
(c) => c.value === a.language
|
|
415
410
|
) || (i = r[0].value, t.language = i));
|
|
416
411
|
}
|
|
417
|
-
!
|
|
412
|
+
!o && !n && !i || (l.updateConfig(
|
|
418
413
|
this.api,
|
|
419
414
|
this.currentNode,
|
|
420
415
|
t,
|
|
421
416
|
"Applied smart defaults"
|
|
422
|
-
),
|
|
417
|
+
), o && t.currency && M({
|
|
423
418
|
currentNode: this.currentNode,
|
|
424
419
|
documentModifier: this.api.getDocumentModifier(),
|
|
425
420
|
currency: t.currency
|
|
426
421
|
}), this.store.patchCurrentBlockConfig({
|
|
427
|
-
...
|
|
422
|
+
...o ? {
|
|
428
423
|
currencySettings: {
|
|
429
|
-
name:
|
|
430
|
-
value:
|
|
431
|
-
symbol:
|
|
424
|
+
name: o,
|
|
425
|
+
value: o,
|
|
426
|
+
symbol: o,
|
|
432
427
|
alignment: a.currency.alignment === "before" ? "0" : "1",
|
|
433
428
|
decimalCount: a.currency.decimalCount.toString(),
|
|
434
429
|
decimalSeparator: a.currency.decimalSeparator,
|
|
435
430
|
thousandSeparator: a.currency.thousandSeparator
|
|
436
431
|
}
|
|
437
432
|
} : {},
|
|
438
|
-
...
|
|
433
|
+
...n ? { strategy: n } : {},
|
|
439
434
|
...i ? { language: i } : {}
|
|
440
435
|
}, { triggerRefetch: !1 }));
|
|
441
436
|
}
|
|
@@ -446,30 +441,30 @@ class me extends P {
|
|
|
446
441
|
const t = G(e);
|
|
447
442
|
if (!t || !("getAttribute" in t))
|
|
448
443
|
return null;
|
|
449
|
-
const
|
|
450
|
-
if (!
|
|
444
|
+
const o = t.getAttribute(I);
|
|
445
|
+
if (!o)
|
|
451
446
|
return null;
|
|
452
|
-
const
|
|
453
|
-
return Number.isNaN(
|
|
447
|
+
const n = parseInt(o);
|
|
448
|
+
return Number.isNaN(n) ? null : n;
|
|
454
449
|
}
|
|
455
450
|
/**
|
|
456
451
|
* Lands what the panel still owes its block before it stops watching it: the config now, the
|
|
457
452
|
* products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
|
|
458
453
|
*/
|
|
459
|
-
_finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts:
|
|
454
|
+
_finishBlockOutsidePanel({ blockId: e, fetchedConfigVersion: t, hasUnrenderedProducts: o } = this._trackedBlockSnapshot()) {
|
|
460
455
|
try {
|
|
461
456
|
this._flushPendingNodeConfig();
|
|
462
|
-
const
|
|
463
|
-
if (e === null || !
|
|
457
|
+
const n = e === null ? void 0 : this.store.blockStates[e];
|
|
458
|
+
if (e === null || !n)
|
|
464
459
|
return;
|
|
465
|
-
const i = t !==
|
|
460
|
+
const i = t !== n.configVersion;
|
|
466
461
|
i && !m(
|
|
467
462
|
e,
|
|
468
|
-
this._getNodeConfigUpdates(
|
|
463
|
+
this._getNodeConfigUpdates(n.recommendationConfigs),
|
|
469
464
|
f
|
|
470
|
-
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i ||
|
|
471
|
-
} catch (
|
|
472
|
-
console.error("[recommendation] finishing the block outside the panel failed",
|
|
465
|
+
) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
|
|
466
|
+
} catch (n) {
|
|
467
|
+
console.error("[recommendation] finishing the block outside the panel failed", n);
|
|
473
468
|
}
|
|
474
469
|
}
|
|
475
470
|
_trackedBlockSnapshot() {
|
|
@@ -481,13 +476,13 @@ class me extends P {
|
|
|
481
476
|
}
|
|
482
477
|
_refreshOutsidePanel(e, t) {
|
|
483
478
|
S(e, {
|
|
484
|
-
pickUpdates: (
|
|
479
|
+
pickUpdates: (o) => this._getNodeConfigUpdates(o),
|
|
485
480
|
description: "Update recommendation configuration",
|
|
486
481
|
fetch: t
|
|
487
|
-
}).then((
|
|
488
|
-
!
|
|
489
|
-
}).catch((
|
|
490
|
-
console.error("[recommendation] refresh outside the panel failed",
|
|
482
|
+
}).then((o) => {
|
|
483
|
+
!o && this.store.blockStates[e] && console.error("[recommendation] refresh outside the panel did not reach a node", { blockId: e });
|
|
484
|
+
}).catch((o) => {
|
|
485
|
+
console.error("[recommendation] refresh outside the panel failed", o);
|
|
491
486
|
});
|
|
492
487
|
}
|
|
493
488
|
_getBlockConfigVersion(e) {
|
|
@@ -502,25 +497,25 @@ class me extends P {
|
|
|
502
497
|
this.hasUnrenderedProducts = !0;
|
|
503
498
|
return;
|
|
504
499
|
}
|
|
505
|
-
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(),
|
|
506
|
-
if (
|
|
507
|
-
|
|
508
|
-
new y(
|
|
500
|
+
const e = this.store.recommendationProducts, t = this.api.getDocumentModifier(), o = this._pendingDescription(), n = this._stagePendingNodeConfig(t);
|
|
501
|
+
if (z(this.currentNode)) {
|
|
502
|
+
n && (t.apply(
|
|
503
|
+
new y(o ?? "Update recommendation configuration")
|
|
509
504
|
), this._consumePendingNodeConfig());
|
|
510
505
|
return;
|
|
511
506
|
}
|
|
512
|
-
|
|
507
|
+
$({
|
|
513
508
|
currentNode: this.currentNode,
|
|
514
509
|
documentModifier: t,
|
|
515
510
|
products: e,
|
|
516
|
-
description:
|
|
517
|
-
onApplied:
|
|
511
|
+
description: o,
|
|
512
|
+
onApplied: n ? () => this._consumePendingNodeConfig() : void 0
|
|
518
513
|
}) || H({
|
|
519
514
|
currentNode: this.currentNode,
|
|
520
515
|
documentModifier: t,
|
|
521
516
|
products: e,
|
|
522
|
-
description:
|
|
523
|
-
}) &&
|
|
517
|
+
description: o
|
|
518
|
+
}) && n && this._consumePendingNodeConfig();
|
|
524
519
|
}
|
|
525
520
|
// Spent only once it landed with the cards (never when another block's write stayed unstaged):
|
|
526
521
|
// kept alive, it blocks the store resync an Undo needs and the flush writes the undone ids back.
|
|
@@ -542,18 +537,18 @@ class me extends P {
|
|
|
542
537
|
*/
|
|
543
538
|
_listenStateUpdates() {
|
|
544
539
|
const { store: e } = this;
|
|
545
|
-
let t = e.recommendationProducts,
|
|
546
|
-
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion =
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
540
|
+
let t = e.recommendationProducts, o = this._getBlockConfigVersion(e.currentRecommendationId);
|
|
541
|
+
this.panelGeneration++, this.isPanelAlive = !0, this.trackedBlockId = e.currentRecommendationId, this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
542
|
+
const n = e.currentRecommendationId;
|
|
543
|
+
if (n !== this.trackedBlockId) {
|
|
549
544
|
const p = this._trackedBlockSnapshot();
|
|
550
|
-
this.panelGeneration++, this.trackedBlockId =
|
|
545
|
+
this.panelGeneration++, this.trackedBlockId = n, t = e.recommendationProducts, o = this._getBlockConfigVersion(n), this.fetchedConfigVersion = o, this.hasUnrenderedProducts = !1, this._finishBlockOutsidePanel(p);
|
|
551
546
|
return;
|
|
552
547
|
}
|
|
553
|
-
const i = this._getBlockConfigVersion(
|
|
554
|
-
i !==
|
|
555
|
-
const r = e.recommendationProducts, h = r !== t,
|
|
556
|
-
h &&
|
|
548
|
+
const i = this._getBlockConfigVersion(n);
|
|
549
|
+
i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts(n, this.panelGeneration));
|
|
550
|
+
const r = e.recommendationProducts, h = r !== t, c = Array.isArray(r) && r.length > 0;
|
|
551
|
+
h && c && (t = r, this.hasUnrenderedProducts = !0, this._debouncedRegenerateWithProducts(this.panelGeneration));
|
|
557
552
|
});
|
|
558
553
|
}
|
|
559
554
|
}
|
|
@@ -562,7 +557,7 @@ export {
|
|
|
562
557
|
E as AlgorithmControl,
|
|
563
558
|
Y as CONTROL_BLOCK_ID,
|
|
564
559
|
ye as CURRENCY_CONTROL_ID,
|
|
565
|
-
|
|
560
|
+
L as CurrencyControl,
|
|
566
561
|
Re as FILTERS_CONTROL_ID,
|
|
567
562
|
D as FiltersControl,
|
|
568
563
|
ke as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
@@ -570,14 +565,14 @@ export {
|
|
|
570
565
|
U as LayoutOrientationControl,
|
|
571
566
|
v as LocaleControl,
|
|
572
567
|
be as PRICE_PLACEMENT_CONTROL_ID,
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
568
|
+
Fe as PRODUCT_COUNT_CONTROL_ID,
|
|
569
|
+
Le as PRODUCT_LAYOUT_CONTROL_ID,
|
|
570
|
+
w as PricePlacementControl,
|
|
571
|
+
A as ProductCountControl,
|
|
577
572
|
V as ProductLayoutControl,
|
|
578
573
|
me as RecommendationBlockControl,
|
|
579
574
|
Ue as SHUFFLE_CONTROL_ID,
|
|
580
|
-
|
|
575
|
+
we as STRATEGY_CONTROL_ID,
|
|
581
576
|
W as ShuffleControl,
|
|
582
577
|
x as StrategyControl,
|
|
583
578
|
Ve as adjustProductsToSize,
|
|
@@ -586,11 +581,11 @@ export {
|
|
|
586
581
|
xe as getCardComposition,
|
|
587
582
|
Me as getCurrentLayout,
|
|
588
583
|
Ge as getMainContainerTbody,
|
|
589
|
-
|
|
590
|
-
|
|
584
|
+
z as isPartnerManagedBlock,
|
|
585
|
+
ze as regenerateMobileProductRows,
|
|
591
586
|
H as regenerateProductRowsWithStyles,
|
|
592
587
|
M as setCurrencyAttributes,
|
|
593
|
-
|
|
594
|
-
|
|
588
|
+
$e as updatePricesInPlace,
|
|
589
|
+
$ as updateProductContentInPlace,
|
|
595
590
|
He as updateSingleProductContent
|
|
596
591
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ModificationDescription as l } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { CommonControl as
|
|
2
|
+
import { CommonControl as u } from "../../../common-control.js";
|
|
3
3
|
import { RecommendationBlockId as a } from "../../constants/blockIds.js";
|
|
4
|
-
import { RecommendationControlId as
|
|
4
|
+
import { RecommendationControlId as d } from "../../constants/controlIds.js";
|
|
5
5
|
import { BLOCK_ROOT_SELECTOR as m } from "../../constants/selectors.js";
|
|
6
6
|
import { CSS_CLASS_TEXT_TRIM as r, ensureTextTrimCssRulesExist as T } from "../shared/textTrimCssRules.js";
|
|
7
7
|
const s = {
|
|
8
8
|
TEXT_TRIM_ENABLED: "textTrimEnabled"
|
|
9
9
|
};
|
|
10
|
-
class N extends
|
|
10
|
+
class N extends u {
|
|
11
11
|
getId() {
|
|
12
|
-
return
|
|
12
|
+
return d.NAME_TEXT_TRIM;
|
|
13
13
|
}
|
|
14
14
|
getTemplate() {
|
|
15
15
|
return `
|
|
@@ -23,7 +23,7 @@ class N extends d {
|
|
|
23
23
|
`;
|
|
24
24
|
}
|
|
25
25
|
onRender() {
|
|
26
|
-
this.
|
|
26
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
27
27
|
}
|
|
28
28
|
onTemplateNodeUpdated(e) {
|
|
29
29
|
super.onTemplateNodeUpdated(e), this._setFormValues();
|
|
@@ -4,8 +4,8 @@ import { CommonControl as l } from "../../../common-control.js";
|
|
|
4
4
|
import { RecommendationBlockId as d } from "../../constants/blockIds.js";
|
|
5
5
|
import { RecommendationControlId as T } from "../../constants/controlIds.js";
|
|
6
6
|
import { BLOCK_ROOT_SELECTOR as f } from "../../constants/selectors.js";
|
|
7
|
-
const
|
|
8
|
-
class
|
|
7
|
+
const i = "data-text-after", u = "", p = ".omnibus-text-after";
|
|
8
|
+
class g extends l {
|
|
9
9
|
getId() {
|
|
10
10
|
return T.OMNIBUS_DISCOUNT_TEXT_AFTER;
|
|
11
11
|
}
|
|
@@ -24,7 +24,7 @@ class N extends l {
|
|
|
24
24
|
`;
|
|
25
25
|
}
|
|
26
26
|
onRender() {
|
|
27
|
-
this.
|
|
27
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
28
28
|
}
|
|
29
29
|
onTemplateNodeUpdated(t) {
|
|
30
30
|
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
@@ -38,7 +38,7 @@ class N extends l {
|
|
|
38
38
|
_getCurrentText() {
|
|
39
39
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
40
40
|
return u;
|
|
41
|
-
const t = this.currentNode.getAttribute(
|
|
41
|
+
const t = this.currentNode.getAttribute(i);
|
|
42
42
|
return t === null ? u : t;
|
|
43
43
|
}
|
|
44
44
|
_onTextChange(t) {
|
|
@@ -53,9 +53,9 @@ class N extends l {
|
|
|
53
53
|
if (!n.length)
|
|
54
54
|
return;
|
|
55
55
|
const o = this.api.getDocumentModifier();
|
|
56
|
-
n.forEach((
|
|
57
|
-
o.modifyHtml(
|
|
58
|
-
const r =
|
|
56
|
+
n.forEach((s) => {
|
|
57
|
+
o.modifyHtml(s).setAttribute(i, t);
|
|
58
|
+
const r = s.querySelector(p);
|
|
59
59
|
if (r) {
|
|
60
60
|
const a = m(r, t);
|
|
61
61
|
o.modifyHtml(r).setInnerHtml(a);
|
|
@@ -69,5 +69,5 @@ class N extends l {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
g as OmnibusDiscountTextAfterControl
|
|
73
73
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { preserveTextStyles as
|
|
1
|
+
import { preserveTextStyles as a } from "../../../../../utils/preserveTextStyles.js";
|
|
2
2
|
import { ModificationDescription as c } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
3
|
import { CommonControl as l } from "../../../common-control.js";
|
|
4
4
|
import { RecommendationBlockId as d } from "../../constants/blockIds.js";
|
|
5
|
-
import { RecommendationControlId as
|
|
6
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
7
|
-
const
|
|
8
|
-
class
|
|
5
|
+
import { RecommendationControlId as T } from "../../constants/controlIds.js";
|
|
6
|
+
import { BLOCK_ROOT_SELECTOR as f } from "../../constants/selectors.js";
|
|
7
|
+
const i = "data-text-before", u = "", p = ".omnibus-text-before";
|
|
8
|
+
class g extends l {
|
|
9
9
|
getId() {
|
|
10
|
-
return
|
|
10
|
+
return T.OMNIBUS_DISCOUNT_TEXT_BEFORE;
|
|
11
11
|
}
|
|
12
12
|
getTemplate() {
|
|
13
13
|
return `
|
|
@@ -24,7 +24,7 @@ class B extends l {
|
|
|
24
24
|
`;
|
|
25
25
|
}
|
|
26
26
|
onRender() {
|
|
27
|
-
this.
|
|
27
|
+
this._setFormValues(), this._listenToFormUpdates();
|
|
28
28
|
}
|
|
29
29
|
onTemplateNodeUpdated(t) {
|
|
30
30
|
super.onTemplateNodeUpdated(t), this._setFormValues();
|
|
@@ -38,13 +38,13 @@ class B extends l {
|
|
|
38
38
|
_getCurrentText() {
|
|
39
39
|
if (!this.currentNode || !("getAttribute" in this.currentNode))
|
|
40
40
|
return u;
|
|
41
|
-
const t = this.currentNode.getAttribute(
|
|
41
|
+
const t = this.currentNode.getAttribute(i);
|
|
42
42
|
return t === null ? u : t;
|
|
43
43
|
}
|
|
44
44
|
_onTextChange(t) {
|
|
45
45
|
if (!this.currentNode || !("closest" in this.currentNode))
|
|
46
46
|
return;
|
|
47
|
-
const e = this.currentNode.closest(
|
|
47
|
+
const e = this.currentNode.closest(f);
|
|
48
48
|
if (!e || !("querySelectorAll" in e))
|
|
49
49
|
return;
|
|
50
50
|
const n = Array.from(
|
|
@@ -53,12 +53,12 @@ class B extends l {
|
|
|
53
53
|
if (!n.length)
|
|
54
54
|
return;
|
|
55
55
|
const o = this.api.getDocumentModifier();
|
|
56
|
-
n.forEach((
|
|
57
|
-
o.modifyHtml(
|
|
58
|
-
const r =
|
|
56
|
+
n.forEach((s) => {
|
|
57
|
+
o.modifyHtml(s).setAttribute(i, t);
|
|
58
|
+
const r = s.querySelector(p);
|
|
59
59
|
if (r) {
|
|
60
|
-
const
|
|
61
|
-
o.modifyHtml(r).setInnerHtml(
|
|
60
|
+
const m = a(r, t);
|
|
61
|
+
o.modifyHtml(r).setInnerHtml(m);
|
|
62
62
|
}
|
|
63
63
|
}), o.apply(new c("Update omnibus discount text before"));
|
|
64
64
|
}
|
|
@@ -69,5 +69,5 @@ class B extends l {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
g as OmnibusDiscountTextBeforeControl
|
|
73
73
|
};
|