@useinsider/guido 3.19.0-beta.21d256c → 3.19.0-beta.29a9026
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/extensions/Blocks/Recommendation/block.js +22 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +108 -83
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +51 -16
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +13 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var C = (l, c, t) => c in l ? b(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
+
var d = (l, c, t) => C(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
4
|
import { useConfig as h } from "../../../composables/useConfig.js";
|
|
5
5
|
import { BlockId as D } from "../../../enums/block.js";
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
6
|
+
import { getMigrationBannerHtml as A } from "../../../utils/migrationBannerHtml.js";
|
|
7
7
|
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
8
|
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as O } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
10
|
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
11
|
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as w } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
13
|
+
import { useRecommendationExtensionStore as g } from "./store/recommendation.js";
|
|
14
14
|
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
15
|
import { useRecommendationBlockWarning as x } from "./useRecommendationBlockWarning.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import { registerNodeConfigWriter as H } from "./utils/nodeConfigWriter.js";
|
|
17
|
+
import { refreshDuplicatedStrategyBlocks as $ } from "./utils/strategyCommit.js";
|
|
18
|
+
const k = D.Recommendation, u = "recommendation-block-v2", y = "hide-price";
|
|
19
|
+
let B = !1;
|
|
20
|
+
class Y extends E {
|
|
19
21
|
constructor() {
|
|
20
22
|
super();
|
|
21
23
|
/**
|
|
22
24
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
25
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
26
|
*/
|
|
25
|
-
|
|
27
|
+
d(this, "_pendingBlockId", null);
|
|
26
28
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
27
|
-
|
|
29
|
+
d(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
28
30
|
}
|
|
29
31
|
getId() {
|
|
30
32
|
return k;
|
|
@@ -44,7 +46,7 @@ class j extends E {
|
|
|
44
46
|
);
|
|
45
47
|
}
|
|
46
48
|
getSettingsPanelTitleHtml() {
|
|
47
|
-
return
|
|
49
|
+
return A(
|
|
48
50
|
k,
|
|
49
51
|
this.api.translate("Recommendation Block"),
|
|
50
52
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
@@ -102,7 +104,7 @@ class j extends E {
|
|
|
102
104
|
// at save for a block the user never configured.
|
|
103
105
|
...o ? { strategy: "" } : {}
|
|
104
106
|
}
|
|
105
|
-
), f =
|
|
107
|
+
), f = g();
|
|
106
108
|
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
107
109
|
I(this.api);
|
|
108
110
|
const _ = this._getBlockElement(t);
|
|
@@ -133,7 +135,7 @@ class j extends E {
|
|
|
133
135
|
}
|
|
134
136
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
135
137
|
try {
|
|
136
|
-
|
|
138
|
+
B || (I(this.api), B = !0);
|
|
137
139
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
138
140
|
if (i) {
|
|
139
141
|
const n = !e.mobileLayoutEnabled;
|
|
@@ -151,7 +153,7 @@ class j extends E {
|
|
|
151
153
|
*/
|
|
152
154
|
onDelete(t) {
|
|
153
155
|
const e = this._getRecommendationId(t);
|
|
154
|
-
e &&
|
|
156
|
+
e && g().removeBlockState(e);
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
157
159
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -199,7 +201,7 @@ class j extends E {
|
|
|
199
201
|
_scheduleArrivalReset(t) {
|
|
200
202
|
h().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
201
203
|
const e = this._getRecommendationId(t);
|
|
202
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
204
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && g().resetArrivedBlock(e);
|
|
203
205
|
}, 0);
|
|
204
206
|
}
|
|
205
207
|
/**
|
|
@@ -255,8 +257,8 @@ class j extends E {
|
|
|
255
257
|
}
|
|
256
258
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
257
259
|
_handleDuplicate(t, e) {
|
|
258
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
259
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e),
|
|
260
|
+
const i = this._reassignDuplicateId(t, e), n = g();
|
|
261
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), H(this.api), $(e, i, s.getConfig(t)).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o))), this._warnIfMultipleBlocks();
|
|
260
262
|
}
|
|
261
263
|
/**
|
|
262
264
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -312,7 +314,7 @@ class j extends E {
|
|
|
312
314
|
*/
|
|
313
315
|
_stampHidePrice(t, e) {
|
|
314
316
|
const i = this._getBlockElement(t);
|
|
315
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
317
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(y, String(e)).apply(new p("Stamp hide-price"));
|
|
316
318
|
}
|
|
317
319
|
/**
|
|
318
320
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -320,7 +322,7 @@ class j extends E {
|
|
|
320
322
|
*/
|
|
321
323
|
_healHidePriceAttr(t) {
|
|
322
324
|
const e = this._getBlockElement(t);
|
|
323
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
325
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(y) !== null)
|
|
324
326
|
return;
|
|
325
327
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
326
328
|
this._stampHidePrice(t, i);
|
|
@@ -358,5 +360,5 @@ class j extends E {
|
|
|
358
360
|
}
|
|
359
361
|
export {
|
|
360
362
|
k as BLOCK_ID,
|
|
361
|
-
|
|
363
|
+
Y as RecommendationBlock
|
|
362
364
|
};
|
|
@@ -29,8 +29,8 @@ import { ShuffleControl as D } from "./shuffle.js";
|
|
|
29
29
|
import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
|
|
30
30
|
import { StrategyControl as w } from "./strategy.js";
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as
|
|
32
|
+
import { setCurrencyAttributes as B, getBlockElement as A, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as Bt, regenerateMobileProductRows as At, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
34
|
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
@@ -77,22 +77,22 @@ class at extends N {
|
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
79
|
i(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
80
|
-
|
|
80
|
+
var r;
|
|
81
81
|
if (!this.currentNode || !this.api)
|
|
82
82
|
return;
|
|
83
|
-
const e = this.api.getDocumentModifier(),
|
|
83
|
+
const t = this._getRecommendationIdFromNode(this.currentNode), e = t !== null && t !== this.store.currentRecommendationId ? ((r = this.store.blockStates[t]) == null ? void 0 : r.recommendationProducts) ?? this.store.recommendationProducts : this.store.recommendationProducts, o = this.api.getDocumentModifier(), n = this._stagePendingNodeConfig(o);
|
|
84
84
|
if (v(this.currentNode)) {
|
|
85
|
-
|
|
85
|
+
n && (o.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
x({
|
|
89
89
|
currentNode: this.currentNode,
|
|
90
|
-
documentModifier:
|
|
91
|
-
products:
|
|
90
|
+
documentModifier: o,
|
|
91
|
+
products: e
|
|
92
92
|
}) || U({
|
|
93
93
|
currentNode: this.currentNode,
|
|
94
|
-
documentModifier:
|
|
95
|
-
products:
|
|
94
|
+
documentModifier: o,
|
|
95
|
+
products: e
|
|
96
96
|
});
|
|
97
97
|
}, 100));
|
|
98
98
|
}
|
|
@@ -363,7 +363,7 @@ class at extends N {
|
|
|
363
363
|
this.currentNode,
|
|
364
364
|
e,
|
|
365
365
|
"Applied smart defaults"
|
|
366
|
-
), o && e.currency &&
|
|
366
|
+
), o && e.currency && B({
|
|
367
367
|
currentNode: this.currentNode,
|
|
368
368
|
documentModifier: this.api.getDocumentModifier(),
|
|
369
369
|
currency: e.currency
|
|
@@ -387,7 +387,7 @@ class at extends N {
|
|
|
387
387
|
* Reads the recommendation-id attribute from the block element within the node
|
|
388
388
|
*/
|
|
389
389
|
_getRecommendationIdFromNode(t) {
|
|
390
|
-
const e =
|
|
390
|
+
const e = A(t);
|
|
391
391
|
if (!e || !("getAttribute" in e))
|
|
392
392
|
return null;
|
|
393
393
|
const o = e.getAttribute(I);
|
|
@@ -450,14 +450,14 @@ export {
|
|
|
450
450
|
w as StrategyControl,
|
|
451
451
|
Et as adjustProductsToSize,
|
|
452
452
|
Ft as formatProductPrice,
|
|
453
|
-
|
|
453
|
+
A as getBlockElement,
|
|
454
454
|
Dt as getCardComposition,
|
|
455
455
|
wt as getCurrentLayout,
|
|
456
|
-
|
|
456
|
+
Bt as getMainContainerTbody,
|
|
457
457
|
v as isPartnerManagedBlock,
|
|
458
|
-
|
|
458
|
+
At as regenerateMobileProductRows,
|
|
459
459
|
U as regenerateProductRowsWithStyles,
|
|
460
|
-
|
|
460
|
+
B as setCurrencyAttributes,
|
|
461
461
|
vt as updatePricesInPlace,
|
|
462
462
|
x as updateProductContentInPlace,
|
|
463
463
|
xt as updateSingleProductContent
|