@useinsider/guido 3.19.0-beta.f02eaa1 → 3.19.0-beta.f884c35
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/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +59 -53
- package/dist/components/organisms/base/Toaster.vue2.js +13 -12
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +9 -7
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +69 -52
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -44
- package/dist/components/organisms/header/EditorActions.vue.js +4 -4
- package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +3 -3
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +21 -20
- package/dist/composables/useActionsApi.js +52 -47
- package/dist/composables/useCodeEditorApi.js +23 -9
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useCustomInterfaceAppearance.js +61 -51
- package/dist/composables/useEmailTemplateApplier.js +106 -50
- package/dist/composables/useHtmlValidator.js +87 -82
- package/dist/composables/useRecommendation.js +40 -35
- package/dist/composables/useStripo.js +30 -30
- package/dist/composables/useToaster.js +14 -20
- package/dist/composables/useTranslations.js +3 -2
- package/dist/composables/useVersionHistoryApi.js +33 -24
- package/dist/enums/extensions/recommendationBlock.js +32 -25
- package/dist/extensions/Blocks/Recommendation/block.js +61 -42
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +63 -58
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +109 -78
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +96 -97
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +209 -92
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
- package/dist/guido.css +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -6
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +92 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/utils/stripoEditorApi.d.ts +4 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +34 -4
- package/dist/static/styles/components/skeleton.css.js +23 -0
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/unsubscribe.js +3 -3
- package/dist/utils/stripoEditorApi.js +11 -0
- package/dist/utils/templatePreparation.js +55 -55
- package/package.json +2 -1
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var A = (l, c, t) => c in l ? y(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
+
var g = (l, c, t) => A(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as h } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as D } from "../../../enums/block.js";
|
|
6
6
|
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
-
import { Block as
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
7
|
+
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
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
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as
|
|
10
|
+
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
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
13
|
import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
|
|
14
|
-
import { getDefaultTemplate as
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
class
|
|
14
|
+
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as x } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
const k = D.Recommendation, u = "recommendation-block-v2", B = "hide-price";
|
|
17
|
+
let b = !1;
|
|
18
|
+
class j extends E {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
/**
|
|
22
22
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
23
23
|
* This avoids generating a new (different) ID in onCreated().
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
g(this, "_pendingBlockId", null);
|
|
26
|
+
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
27
|
+
g(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
26
28
|
}
|
|
27
29
|
getId() {
|
|
28
|
-
return
|
|
30
|
+
return k;
|
|
29
31
|
}
|
|
30
32
|
getIcon() {
|
|
31
33
|
return "recommendation-icon";
|
|
32
34
|
}
|
|
33
35
|
getBlockCompositionType() {
|
|
34
|
-
return
|
|
36
|
+
return S.CONTAINER;
|
|
35
37
|
}
|
|
36
38
|
getName() {
|
|
37
39
|
return this.api.translate("Recommendation Block");
|
|
@@ -43,7 +45,7 @@ class W extends b {
|
|
|
43
45
|
}
|
|
44
46
|
getSettingsPanelTitleHtml() {
|
|
45
47
|
return C(
|
|
46
|
-
|
|
48
|
+
k,
|
|
47
49
|
this.api.translate("Recommendation Block"),
|
|
48
50
|
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.")
|
|
49
51
|
);
|
|
@@ -66,7 +68,7 @@ class W extends b {
|
|
|
66
68
|
*/
|
|
67
69
|
getTemplate() {
|
|
68
70
|
const t = this._generateNextId();
|
|
69
|
-
return this._pendingBlockId = t,
|
|
71
|
+
return this._pendingBlockId = t, T(t);
|
|
70
72
|
}
|
|
71
73
|
/**
|
|
72
74
|
* Called when a new block is dropped into the template
|
|
@@ -79,33 +81,37 @@ class W extends b {
|
|
|
79
81
|
const e = this._getRecommendationId(t);
|
|
80
82
|
if (e !== null && e > 0) {
|
|
81
83
|
if (this._detectDuplicate(e)) {
|
|
82
|
-
this._handleDuplicate(t, e);
|
|
84
|
+
this._handleDuplicate(t, e), this._scheduleArrivalReset(t);
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
this._pendingBlockId === null && setTimeout(() => {
|
|
86
88
|
this._getBlockElement(t) && this._detectDuplicate(e) && this._handleDuplicate(t, e);
|
|
87
|
-
}, 0);
|
|
89
|
+
}, 0), this._scheduleArrivalReset(t);
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
91
93
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
92
|
-
const { config:
|
|
94
|
+
const n = h().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
|
|
93
95
|
this.api,
|
|
94
96
|
t,
|
|
95
97
|
{
|
|
96
98
|
recommendationId: i,
|
|
97
|
-
configVersion:
|
|
99
|
+
configVersion: n ? N : O,
|
|
100
|
+
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
101
|
+
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
102
|
+
// at save for a block the user never configured.
|
|
103
|
+
...o ? { strategy: "" } : {}
|
|
98
104
|
}
|
|
99
|
-
),
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
105
|
+
), f = d();
|
|
106
|
+
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
107
|
+
I(this.api);
|
|
108
|
+
const _ = this._getBlockElement(t);
|
|
109
|
+
_ && (R(this.api, _, !0), M({
|
|
104
110
|
currentNode: t,
|
|
105
111
|
documentModifier: this.api.getDocumentModifier()
|
|
106
112
|
}));
|
|
107
113
|
}
|
|
108
|
-
|
|
114
|
+
f.patchCurrentBlockConfig({ language: r.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
111
117
|
* Called when the document changes or template is loaded
|
|
@@ -127,11 +133,11 @@ class W extends b {
|
|
|
127
133
|
}
|
|
128
134
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
129
135
|
try {
|
|
130
|
-
|
|
136
|
+
b || (I(this.api), b = !0);
|
|
131
137
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
132
138
|
if (i) {
|
|
133
139
|
const n = !e.mobileLayoutEnabled;
|
|
134
|
-
|
|
140
|
+
w(i) !== n && R(this.api, i, n);
|
|
135
141
|
}
|
|
136
142
|
} catch {
|
|
137
143
|
}
|
|
@@ -161,7 +167,7 @@ class W extends b {
|
|
|
161
167
|
*/
|
|
162
168
|
_warnIfMultipleBlocks() {
|
|
163
169
|
try {
|
|
164
|
-
|
|
170
|
+
x().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
165
171
|
} catch {
|
|
166
172
|
}
|
|
167
173
|
}
|
|
@@ -183,6 +189,19 @@ class W extends b {
|
|
|
183
189
|
}
|
|
184
190
|
return t + 1;
|
|
185
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Drops the "already fetched" claims of a block that arrived holding a baked id
|
|
194
|
+
* (saved module, paste, duplicate), so the settings panel reads its strategy again.
|
|
195
|
+
*
|
|
196
|
+
* Deferred a tick: the collision handlers rename a sibling first, and either sibling can be
|
|
197
|
+
* the renamed one depending on where the module was dropped (SD-149916).
|
|
198
|
+
*/
|
|
199
|
+
_scheduleArrivalReset(t) {
|
|
200
|
+
h().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
201
|
+
const e = this._getRecommendationId(t);
|
|
202
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && d().resetArrivedBlock(e);
|
|
203
|
+
}, 0);
|
|
204
|
+
}
|
|
186
205
|
/**
|
|
187
206
|
* Heals a duplicate that slipped past the create-time `_detectDuplicate`
|
|
188
207
|
* scan (or that was persisted by an older template before SD-142352).
|
|
@@ -211,9 +230,9 @@ class W extends b {
|
|
|
211
230
|
if (!o)
|
|
212
231
|
return;
|
|
213
232
|
let r = -1;
|
|
214
|
-
for (let
|
|
215
|
-
if (n[
|
|
216
|
-
r =
|
|
233
|
+
for (let a = 0; a < n.length; a++)
|
|
234
|
+
if (n[a] === o) {
|
|
235
|
+
r = a;
|
|
217
236
|
break;
|
|
218
237
|
}
|
|
219
238
|
if (r <= 0)
|
|
@@ -237,7 +256,7 @@ class W extends b {
|
|
|
237
256
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
238
257
|
_handleDuplicate(t, e) {
|
|
239
258
|
const i = this._reassignDuplicateId(t, e), n = d();
|
|
240
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i), this._warnIfMultipleBlocks();
|
|
259
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), n.resetArrivedBlock(i)), this._warnIfMultipleBlocks();
|
|
241
260
|
}
|
|
242
261
|
/**
|
|
243
262
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -270,7 +289,7 @@ class W extends b {
|
|
|
270
289
|
if (!("getAttribute" in t))
|
|
271
290
|
return;
|
|
272
291
|
const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, r = this.api.getDocumentModifier();
|
|
273
|
-
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new
|
|
292
|
+
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new p(
|
|
274
293
|
`Reassign recommendation instance class ${n} -> ${o}`
|
|
275
294
|
));
|
|
276
295
|
}
|
|
@@ -285,7 +304,7 @@ class W extends b {
|
|
|
285
304
|
if (!i)
|
|
286
305
|
return;
|
|
287
306
|
const n = this.api.getDocumentModifier();
|
|
288
|
-
n.modifyHtml(i).setAttribute(m, e.toString()), n.apply(new
|
|
307
|
+
n.modifyHtml(i).setAttribute(m, e.toString()), n.apply(new p(`Assign recommendation ID ${e}`));
|
|
289
308
|
}
|
|
290
309
|
/**
|
|
291
310
|
* Stamps the `hide-price` attribute (read by email-service at send time) on
|
|
@@ -293,7 +312,7 @@ class W extends b {
|
|
|
293
312
|
*/
|
|
294
313
|
_stampHidePrice(t, e) {
|
|
295
314
|
const i = this._getBlockElement(t);
|
|
296
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
315
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new p("Stamp hide-price"));
|
|
297
316
|
}
|
|
298
317
|
/**
|
|
299
318
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -301,7 +320,7 @@ class W extends b {
|
|
|
301
320
|
*/
|
|
302
321
|
_healHidePriceAttr(t) {
|
|
303
322
|
const e = this._getBlockElement(t);
|
|
304
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
323
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(B) !== null)
|
|
305
324
|
return;
|
|
306
325
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
307
326
|
this._stampHidePrice(t, i);
|
|
@@ -338,6 +357,6 @@ class W extends b {
|
|
|
338
357
|
}
|
|
339
358
|
}
|
|
340
359
|
export {
|
|
341
|
-
|
|
342
|
-
|
|
360
|
+
k as BLOCK_ID,
|
|
361
|
+
j as RecommendationBlock
|
|
343
362
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DEFAULT_COLUMN_SPACING as
|
|
2
|
-
import { ATTR_PRODUCT_IMAGE as o, ATTR_PRODUCT_NAME as t, ATTR_PRODUCT_OLD_PRICE as _, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as
|
|
3
|
-
const
|
|
1
|
+
import { DEFAULT_COLUMN_SPACING as i, DEFAULT_ROW_SPACING as s, DEFAULT_MOBILE_ROW_SPACING as n, DEFAULT_MOBILE_COLUMN_SPACING as O, DEFAULT_MOBILE_CARDS_IN_ROW as e, DEFAULT_CARDS_IN_ROW as C } from "./layout.js";
|
|
2
|
+
import { ATTR_PRODUCT_IMAGE as o, ATTR_PRODUCT_NAME as t, ATTR_PRODUCT_OLD_PRICE as _, ATTR_PRODUCT_PRICE as T, ATTR_PRODUCT_OMNIBUS_PRICE as I, ATTR_PRODUCT_OMNIBUS_DISCOUNT as R, ATTR_PRODUCT_BUTTON as r, ATTR_RECOMMENDATION_TITLE as E } from "./selectors.js";
|
|
3
|
+
const U = 1, u = 2, m = 2, A = {
|
|
4
4
|
code: "USD",
|
|
5
5
|
symbol: "USD",
|
|
6
6
|
alignment: "after",
|
|
7
7
|
decimalCount: 2,
|
|
8
8
|
decimalSeparator: ".",
|
|
9
9
|
thousandSeparator: ","
|
|
10
|
-
},
|
|
10
|
+
}, D = {
|
|
11
11
|
textBefore: "",
|
|
12
12
|
textAfter: ""
|
|
13
13
|
}, a = {
|
|
@@ -18,26 +18,26 @@ const A = 1, u = 2, D = {
|
|
|
18
18
|
t,
|
|
19
19
|
_,
|
|
20
20
|
T,
|
|
21
|
-
r,
|
|
22
21
|
I,
|
|
23
|
-
|
|
22
|
+
R,
|
|
23
|
+
r
|
|
24
24
|
], N = {
|
|
25
|
-
[
|
|
25
|
+
[E]: !0,
|
|
26
26
|
[o]: !0,
|
|
27
27
|
[t]: !0,
|
|
28
28
|
[T]: !0,
|
|
29
29
|
[_]: !0,
|
|
30
|
-
[r]: !1,
|
|
31
30
|
[I]: !1,
|
|
32
|
-
[
|
|
33
|
-
|
|
31
|
+
[R]: !1,
|
|
32
|
+
[r]: !0
|
|
33
|
+
}, L = {
|
|
34
34
|
// Settings
|
|
35
35
|
strategy: "mostPopular",
|
|
36
36
|
productIds: [],
|
|
37
37
|
size: "6",
|
|
38
38
|
shuffleProducts: !1,
|
|
39
39
|
language: "en_US",
|
|
40
|
-
currency:
|
|
40
|
+
currency: A,
|
|
41
41
|
filters: [],
|
|
42
42
|
strategyId: "",
|
|
43
43
|
// Layout
|
|
@@ -46,7 +46,7 @@ const A = 1, u = 2, D = {
|
|
|
46
46
|
mobileCardsInRow: e,
|
|
47
47
|
mobileLayoutEnabled: !1,
|
|
48
48
|
previousMobileCardsInRow: e,
|
|
49
|
-
columnSpacing:
|
|
49
|
+
columnSpacing: i,
|
|
50
50
|
rowSpacing: s,
|
|
51
51
|
mobileColumnSpacing: O,
|
|
52
52
|
mobileRowSpacing: n,
|
|
@@ -55,7 +55,7 @@ const A = 1, u = 2, D = {
|
|
|
55
55
|
visibility: N,
|
|
56
56
|
previousTitleHtml: "",
|
|
57
57
|
// Element settings
|
|
58
|
-
omnibusPrice:
|
|
58
|
+
omnibusPrice: D,
|
|
59
59
|
omnibusDiscount: a,
|
|
60
60
|
textTrimming: !1,
|
|
61
61
|
// Price placement (block-level, affects all cards)
|
|
@@ -66,17 +66,18 @@ const A = 1, u = 2, D = {
|
|
|
66
66
|
// of "false" (the actual hiding happens server-side at send).
|
|
67
67
|
priceHideIfSameAsDiscounted: !1,
|
|
68
68
|
// Meta
|
|
69
|
-
configVersion:
|
|
69
|
+
configVersion: U,
|
|
70
70
|
recommendationId: 0
|
|
71
|
-
},
|
|
71
|
+
}, P = [11, 12];
|
|
72
72
|
export {
|
|
73
73
|
u as CURRENT_CONFIG_VERSION,
|
|
74
74
|
c as DEFAULT_COMPOSITION,
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
A as DEFAULT_CURRENCY,
|
|
76
|
+
L as DEFAULT_NODE_CONFIG,
|
|
77
77
|
a as DEFAULT_OMNIBUS_DISCOUNT,
|
|
78
|
-
|
|
78
|
+
D as DEFAULT_OMNIBUS_PRICE,
|
|
79
79
|
N as DEFAULT_VISIBILITY,
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
P as EXCLUDED_ALGORITHM_IDS,
|
|
81
|
+
U as PRE_RRS_CONFIG_VERSION,
|
|
82
|
+
m as RRS_CONFIG_VERSION
|
|
82
83
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var m = Object.defineProperty;
|
|
2
|
-
var C = (g,
|
|
3
|
-
var
|
|
2
|
+
var C = (g, c, t) => c in g ? m(g, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[c] = t;
|
|
3
|
+
var i = (g, c, t) => C(g, typeof c != "symbol" ? c + "" : c, t);
|
|
4
4
|
import { useConfig as p } 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 N } from "../../../common-control.js";
|
|
7
|
-
import {
|
|
7
|
+
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
|
|
8
8
|
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
-
import { RecommendationConfigService as
|
|
9
|
+
import { RecommendationConfigService as l } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
11
|
import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
|
|
12
12
|
import { AlgorithmControl as T } from "./algorithm.js";
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as dt } from "./algorithm.js";
|
|
14
14
|
import { CurrencyControl as P } from "./currency.js";
|
|
15
15
|
import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
|
|
16
16
|
import { FiltersControl as S } from "./filters.js";
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
17
|
+
import { FILTERS_CONTROL_ID as ft } from "./filters.js";
|
|
18
18
|
import { LayoutOrientationControl as O } from "./layoutOrientation.js";
|
|
19
19
|
import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
|
|
20
20
|
import { LocaleControl as L } from "./locale.js";
|
|
@@ -31,34 +31,34 @@ import { StrategyControl as w } from "./strategy.js";
|
|
|
31
31
|
import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
|
|
32
32
|
import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
|
|
33
33
|
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
|
|
34
|
-
import { useDebounceFn as
|
|
35
|
-
const
|
|
34
|
+
import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
|
+
const W = "ui-elements-recommendation-block";
|
|
36
36
|
class at extends N {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
i(this, "store", R());
|
|
40
|
+
i(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
43
43
|
// re-render's single apply() — one user action must cost one undo press.
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
i(this, "pendingNodeConfigWrite", null);
|
|
45
|
+
i(this, "pendingConfigFlushTimer", null);
|
|
46
46
|
// Sub-control instances for lifecycle management
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
i(this, "algorithmControl", null);
|
|
48
|
+
i(this, "localeControl", null);
|
|
49
|
+
i(this, "currencyControl", null);
|
|
50
|
+
i(this, "productCountControl", null);
|
|
51
|
+
i(this, "productLayoutControl", null);
|
|
52
|
+
i(this, "filtersControl", null);
|
|
53
|
+
i(this, "shuffleControl", null);
|
|
54
|
+
i(this, "pricePlacementControl", null);
|
|
55
|
+
i(this, "layoutOrientationControl", null);
|
|
56
|
+
i(this, "strategyControl", null);
|
|
57
|
+
i(this, "rrsEnabled", !1);
|
|
58
58
|
/**
|
|
59
59
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
i(this, "_debouncedFetchProducts", h(async () => {
|
|
62
62
|
try {
|
|
63
63
|
await this.store.fetchRecommendationProducts();
|
|
64
64
|
} finally {
|
|
@@ -76,7 +76,7 @@ class at extends N {
|
|
|
76
76
|
* count. The store pads products to the configured size, so in-place only
|
|
77
77
|
* fails when the size actually changed.
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
80
80
|
const t = this.store.recommendationProducts;
|
|
81
81
|
if (!this.currentNode || !this.api)
|
|
82
82
|
return;
|
|
@@ -97,7 +97,7 @@ class at extends N {
|
|
|
97
97
|
}, 100));
|
|
98
98
|
}
|
|
99
99
|
getId() {
|
|
100
|
-
return
|
|
100
|
+
return W;
|
|
101
101
|
}
|
|
102
102
|
get _subControls() {
|
|
103
103
|
return [
|
|
@@ -136,18 +136,18 @@ class at extends N {
|
|
|
136
136
|
`;
|
|
137
137
|
}
|
|
138
138
|
_showControlsForBlock(t) {
|
|
139
|
-
var
|
|
140
|
-
const e = (
|
|
139
|
+
var r;
|
|
140
|
+
const e = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
|
|
141
141
|
if (!e)
|
|
142
142
|
return;
|
|
143
|
-
const o = this._getRecommendationIdFromNode(t) === null ? null :
|
|
143
|
+
const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
|
|
144
144
|
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
145
145
|
}
|
|
146
146
|
async onRender() {
|
|
147
147
|
var o;
|
|
148
148
|
b(this.api);
|
|
149
149
|
const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
|
|
150
|
-
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
150
|
+
if (e !== null && this.store.setCurrentBlock(e), t !== null && this._syncNodeConfigIfChanged(t), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), t !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
|
|
151
151
|
this._initializeSubControls();
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
@@ -209,18 +209,23 @@ class at extends N {
|
|
|
209
209
|
const e = this.store.blockStates[t];
|
|
210
210
|
if (!e)
|
|
211
211
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
212
|
+
const o = JSON.stringify(l.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
|
|
213
213
|
e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
214
214
|
}
|
|
215
|
+
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
216
|
+
_isPendingStrategyIdChange() {
|
|
217
|
+
const t = this.pendingNodeConfigWrite;
|
|
218
|
+
return t ? l.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
|
|
219
|
+
}
|
|
215
220
|
_capturePendingNodeConfigWrite() {
|
|
216
221
|
const t = this.store.currentRecommendationId;
|
|
217
222
|
if (!this.currentNode || !this.api || t === null)
|
|
218
223
|
return;
|
|
219
|
-
const { filters: e,
|
|
224
|
+
const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs;
|
|
220
225
|
this.pendingNodeConfigWrite = {
|
|
221
226
|
blockId: t,
|
|
222
227
|
node: this.currentNode,
|
|
223
|
-
updates: { filters: e,
|
|
228
|
+
updates: { filters: e, strategy: o, strategyId: n, size: s, configVersion: r }
|
|
224
229
|
};
|
|
225
230
|
}
|
|
226
231
|
/**
|
|
@@ -235,7 +240,7 @@ class at extends N {
|
|
|
235
240
|
*/
|
|
236
241
|
_stagePendingNodeConfig(t) {
|
|
237
242
|
const e = this.pendingNodeConfigWrite;
|
|
238
|
-
return !e || !this.currentNode ? !1 : (
|
|
243
|
+
return !e || !this.currentNode ? !1 : (l.stageConfig(t, this.currentNode, e.updates), !0);
|
|
239
244
|
}
|
|
240
245
|
/**
|
|
241
246
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -259,12 +264,12 @@ class at extends N {
|
|
|
259
264
|
const t = this.pendingNodeConfigWrite;
|
|
260
265
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
261
266
|
return;
|
|
262
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
263
|
-
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size ||
|
|
267
|
+
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = l.getConfig(e);
|
|
268
|
+
JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || l.updateConfig(this.api, e, t.updates, "Update recommendation filters");
|
|
264
269
|
}
|
|
265
270
|
_syncNodeConfigToStore() {
|
|
266
271
|
var n;
|
|
267
|
-
const t =
|
|
272
|
+
const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
268
273
|
this.store.patchCurrentBlockConfig({
|
|
269
274
|
strategy: t.strategy,
|
|
270
275
|
strategyId: t.strategyId,
|
|
@@ -329,31 +334,31 @@ class at extends N {
|
|
|
329
334
|
_applySmartDefaults() {
|
|
330
335
|
if (!this.currentNode || !this.api)
|
|
331
336
|
return;
|
|
332
|
-
const t =
|
|
337
|
+
const t = l.getConfig(this.currentNode), e = {};
|
|
333
338
|
let o = null, n = null, s = null;
|
|
334
339
|
if (t.currency.code === a.currency.code) {
|
|
335
|
-
const { currencyList:
|
|
336
|
-
|
|
337
|
-
(
|
|
338
|
-
) || (o =
|
|
340
|
+
const { currencyList: r } = this.store;
|
|
341
|
+
r.length > 0 && (r.some(
|
|
342
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
343
|
+
) || (o = r[0].value.replace("price.", ""), e.currency = {
|
|
339
344
|
...a.currency,
|
|
340
345
|
code: o,
|
|
341
346
|
symbol: o
|
|
342
347
|
}));
|
|
343
348
|
}
|
|
344
349
|
if (t.strategy === a.strategy) {
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
(
|
|
348
|
-
) || (n =
|
|
350
|
+
const r = this.store.getActivePredictiveAlgorithms;
|
|
351
|
+
r.length > 0 && (r.some(
|
|
352
|
+
(u) => u.value === a.strategy
|
|
353
|
+
) || (n = r[0].value, e.strategy = n));
|
|
349
354
|
}
|
|
350
355
|
if (t.language === a.language) {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
(
|
|
354
|
-
) || (s =
|
|
356
|
+
const r = this.store.getLanguages;
|
|
357
|
+
r.length > 0 && (r.some(
|
|
358
|
+
(u) => u.value === a.language
|
|
359
|
+
) || (s = r[0].value, e.language = s));
|
|
355
360
|
}
|
|
356
|
-
!o && !n && !s || (
|
|
361
|
+
!o && !n && !s || (l.updateConfig(
|
|
357
362
|
this.api,
|
|
358
363
|
this.currentNode,
|
|
359
364
|
e,
|
|
@@ -413,20 +418,20 @@ class at extends N {
|
|
|
413
418
|
n = s, e = t.recommendationProducts, o = t.$state.configVersion;
|
|
414
419
|
return;
|
|
415
420
|
}
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
const
|
|
419
|
-
|
|
421
|
+
const r = t.$state.configVersion;
|
|
422
|
+
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
423
|
+
const d = t.recommendationProducts, u = d !== e, f = Array.isArray(d) && d.length > 0;
|
|
424
|
+
u && f && (e = d, this._debouncedRegenerateWithProducts());
|
|
420
425
|
});
|
|
421
426
|
}
|
|
422
427
|
}
|
|
423
428
|
export {
|
|
424
|
-
|
|
429
|
+
dt as ALGORITHM_CONTROL_ID,
|
|
425
430
|
T as AlgorithmControl,
|
|
426
|
-
|
|
431
|
+
W as CONTROL_BLOCK_ID,
|
|
427
432
|
gt as CURRENCY_CONTROL_ID,
|
|
428
433
|
P as CurrencyControl,
|
|
429
|
-
|
|
434
|
+
ft as FILTERS_CONTROL_ID,
|
|
430
435
|
S as FiltersControl,
|
|
431
436
|
Ct as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
432
437
|
yt as LOCALE_CONTROL_ID,
|