@useinsider/guido 3.20.0 → 3.20.1-beta.04cd240
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/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/composables/useStripo.js +11 -10
- package/dist/composables/useVersionHistoryApi.js +42 -37
- package/dist/config/compiler/itemsCompilerRules.js +21 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +64 -17
- package/dist/config/migrator/itemsBlockMigrator.js +112 -108
- package/dist/extensions/Blocks/Items/block.js +76 -64
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +60 -49
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +163 -149
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +102 -78
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +313 -210
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +15 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +17 -12
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +92 -84
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +219 -193
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +23 -18
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +1 -2
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +12 -9
- package/dist/extensions/Blocks/Recommendation/extension.js +4 -2
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +240 -190
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
- package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
- package/dist/extensions/Blocks/Recommendation/utils/followUpApply.js +34 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +73 -28
- package/dist/extensions/Blocks/Recommendation/utils/restoreRefresh.js +36 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +39 -20
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
- package/dist/package.json.js +1 -1
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +10 -0
- package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
- package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +22 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +1 -18
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +10 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +2 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +28 -6
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/followUpApply.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +15 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/restoreRefresh.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
- package/dist/src/stores/editor.d.ts +3 -1
- package/dist/src/utils/liquidProtection.d.ts +3 -0
- package/dist/static/styles/components/button.css.js +5 -0
- package/dist/stores/editor.js +5 -0
- package/dist/utils/liquidProtection.js +5 -0
- package/dist/utils/templatePreparation.js +61 -85
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const t = `{-{-TEMPLATE_FIRST_LINE-}-}
|
|
2
|
-
<table class="es-left ins-product-wrapper" cellspacing="0" cellpadding="0" align="left" width="100%">
|
|
2
|
+
<table class="es-left ins-product-wrapper" cellspacing="0" cellpadding="0" align="left" width="100%" style="width: 100%;">
|
|
3
3
|
<tbody>
|
|
4
4
|
<tr>
|
|
5
5
|
<td class="es-p20b es-p10r es-p10l es-m-p20b es-p10t" width="100%" align="center">
|
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
7
|
-
import { Block as
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
1
|
+
var b = Object.defineProperty;
|
|
2
|
+
var C = (a, l, t) => l in a ? b(a, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[l] = t;
|
|
3
|
+
var d = (a, l, t) => C(a, typeof l != "symbol" ? l + "" : l, t);
|
|
4
|
+
import { useConfig as g } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as A } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as E } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as S, BlockCompositionType as N, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as w, PRE_RRS_CONFIG_VERSION as M } from "./constants/defaultConfig.js";
|
|
9
9
|
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as
|
|
10
|
+
import { regenerateMobileProductRows as O } from "./controls/main/utils.js";
|
|
11
|
+
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as x } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
13
|
+
import { useRecommendationExtensionStore as h } from "./store/recommendation.js";
|
|
14
14
|
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
import { useRecommendationBlockWarning as H } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
import { registerNodeConfigWriter as k } from "./utils/nodeConfigWriter.js";
|
|
17
|
+
import { refreshDuplicatedStrategyBlocks as $ } from "./utils/strategyCommit.js";
|
|
18
|
+
const D = A.Recommendation, u = "recommendation-block-v2", y = "hide-price";
|
|
19
|
+
let B = !1;
|
|
20
|
+
class Y extends S {
|
|
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());
|
|
30
|
+
/** Ids handed to duplicates the document root does not show yet: a copied module renames all its blocks at once. */
|
|
31
|
+
d(this, "_unsettledDuplicateIds", /* @__PURE__ */ new Set());
|
|
28
32
|
}
|
|
29
33
|
getId() {
|
|
30
|
-
return
|
|
34
|
+
return D;
|
|
31
35
|
}
|
|
32
36
|
getIcon() {
|
|
33
37
|
return "recommendation-icon";
|
|
34
38
|
}
|
|
35
39
|
getBlockCompositionType() {
|
|
36
|
-
return
|
|
40
|
+
return N.CONTAINER;
|
|
37
41
|
}
|
|
38
42
|
getName() {
|
|
39
43
|
return this.api.translate("Recommendation Block");
|
|
@@ -44,8 +48,8 @@ class j extends E {
|
|
|
44
48
|
);
|
|
45
49
|
}
|
|
46
50
|
getSettingsPanelTitleHtml() {
|
|
47
|
-
return
|
|
48
|
-
|
|
51
|
+
return E(
|
|
52
|
+
D,
|
|
49
53
|
this.api.translate("Recommendation Block"),
|
|
50
54
|
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.")
|
|
51
55
|
);
|
|
@@ -70,6 +74,10 @@ class j extends E {
|
|
|
70
74
|
const t = this._generateNextId();
|
|
71
75
|
return this._pendingBlockId = t, T(t);
|
|
72
76
|
}
|
|
77
|
+
// A restore can redraw blocks before any settings panel registered a document handle this session.
|
|
78
|
+
onDocumentInit() {
|
|
79
|
+
k(this.api);
|
|
80
|
+
}
|
|
73
81
|
/**
|
|
74
82
|
* Called when a new block is dropped into the template
|
|
75
83
|
*
|
|
@@ -91,23 +99,23 @@ class j extends E {
|
|
|
91
99
|
}
|
|
92
100
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
93
101
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
94
|
-
const n =
|
|
102
|
+
const n = g().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: c } = s.initializeConfig(
|
|
95
103
|
this.api,
|
|
96
104
|
t,
|
|
97
105
|
{
|
|
98
106
|
recommendationId: i,
|
|
99
|
-
configVersion: n ?
|
|
100
|
-
...o ? { partnerName:
|
|
107
|
+
configVersion: n ? w : M,
|
|
108
|
+
...o ? { partnerName: g().partnerName.value } : {},
|
|
101
109
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
102
110
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
103
111
|
// at save for a block the user never configured.
|
|
104
112
|
...o ? { strategy: "" } : {}
|
|
105
113
|
}
|
|
106
|
-
), f =
|
|
107
|
-
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted),
|
|
114
|
+
), f = h();
|
|
115
|
+
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), c) {
|
|
108
116
|
I(this.api);
|
|
109
117
|
const _ = this._getBlockElement(t);
|
|
110
|
-
_ && (R(this.api, _, !0),
|
|
118
|
+
_ && (R(this.api, _, !0), O({
|
|
111
119
|
currentNode: t,
|
|
112
120
|
documentModifier: this.api.getDocumentModifier()
|
|
113
121
|
}));
|
|
@@ -134,11 +142,11 @@ class j extends E {
|
|
|
134
142
|
}
|
|
135
143
|
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
136
144
|
try {
|
|
137
|
-
|
|
145
|
+
B || (I(this.api), B = !0);
|
|
138
146
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
139
147
|
if (i) {
|
|
140
148
|
const n = !e.mobileLayoutEnabled;
|
|
141
|
-
|
|
149
|
+
x(i) !== n && R(this.api, i, n);
|
|
142
150
|
}
|
|
143
151
|
} catch {
|
|
144
152
|
}
|
|
@@ -152,7 +160,7 @@ class j extends E {
|
|
|
152
160
|
*/
|
|
153
161
|
onDelete(t) {
|
|
154
162
|
const e = this._getRecommendationId(t);
|
|
155
|
-
e &&
|
|
163
|
+
e && h().removeBlockState(e);
|
|
156
164
|
}
|
|
157
165
|
/**
|
|
158
166
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -168,7 +176,7 @@ class j extends E {
|
|
|
168
176
|
*/
|
|
169
177
|
_warnIfMultipleBlocks() {
|
|
170
178
|
try {
|
|
171
|
-
|
|
179
|
+
H().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
172
180
|
} catch {
|
|
173
181
|
}
|
|
174
182
|
}
|
|
@@ -178,17 +186,20 @@ class j extends E {
|
|
|
178
186
|
*/
|
|
179
187
|
_generateNextId() {
|
|
180
188
|
let t = 0;
|
|
189
|
+
const e = /* @__PURE__ */ new Set();
|
|
181
190
|
try {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
if ("getAttribute" in
|
|
185
|
-
const
|
|
186
|
-
|
|
191
|
+
const i = this.api.getDocumentRoot();
|
|
192
|
+
i && "querySelectorAll" in i && i.querySelectorAll(`.${u}`).forEach((o) => {
|
|
193
|
+
if ("getAttribute" in o) {
|
|
194
|
+
const r = o.getAttribute(m), c = r ? parseInt(r) : 0;
|
|
195
|
+
e.add(c), c > t && (t = c);
|
|
187
196
|
}
|
|
188
197
|
});
|
|
189
198
|
} catch {
|
|
190
199
|
}
|
|
191
|
-
return
|
|
200
|
+
return this._unsettledDuplicateIds.forEach((i) => {
|
|
201
|
+
e.has(i) && this._unsettledDuplicateIds.delete(i);
|
|
202
|
+
}), Math.max(t, ...this._unsettledDuplicateIds) + 1;
|
|
192
203
|
}
|
|
193
204
|
/**
|
|
194
205
|
* Drops the "already fetched" claims of a block that arrived holding a baked id
|
|
@@ -198,9 +209,9 @@ class j extends E {
|
|
|
198
209
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
199
210
|
*/
|
|
200
211
|
_scheduleArrivalReset(t) {
|
|
201
|
-
|
|
212
|
+
g().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
202
213
|
const e = this._getRecommendationId(t);
|
|
203
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
214
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && h().resetArrivedBlock(e);
|
|
204
215
|
}, 0);
|
|
205
216
|
}
|
|
206
217
|
/**
|
|
@@ -231,9 +242,9 @@ class j extends E {
|
|
|
231
242
|
if (!o)
|
|
232
243
|
return;
|
|
233
244
|
let r = -1;
|
|
234
|
-
for (let
|
|
235
|
-
if (n[
|
|
236
|
-
r =
|
|
245
|
+
for (let c = 0; c < n.length; c++)
|
|
246
|
+
if (n[c] === o) {
|
|
247
|
+
r = c;
|
|
237
248
|
break;
|
|
238
249
|
}
|
|
239
250
|
if (r <= 0)
|
|
@@ -256,8 +267,8 @@ class j extends E {
|
|
|
256
267
|
}
|
|
257
268
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
258
269
|
_handleDuplicate(t, e) {
|
|
259
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
260
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i),
|
|
270
|
+
const i = this._reassignDuplicateId(t, e), n = h();
|
|
271
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), g().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), k(this.api), $(e, i, s.getConfig(t)).catch((o) => console.error("[recommendation] refreshing a duplicated strategy failed", o))), this._warnIfMultipleBlocks();
|
|
261
272
|
}
|
|
262
273
|
/**
|
|
263
274
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -272,7 +283,7 @@ class j extends E {
|
|
|
272
283
|
*/
|
|
273
284
|
_reassignDuplicateId(t, e) {
|
|
274
285
|
const i = this._generateNextId(), n = this._getBlockElement(t);
|
|
275
|
-
return this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), s.hasConfig(t) && s.updateConfig(
|
|
286
|
+
return this._unsettledDuplicateIds.add(i), this._assignRecommendationId(t, i), n && this._reassignInstanceClass(n, e, i), s.hasConfig(t) && s.updateConfig(
|
|
276
287
|
this.api,
|
|
277
288
|
t,
|
|
278
289
|
{ recommendationId: i },
|
|
@@ -313,7 +324,7 @@ class j extends E {
|
|
|
313
324
|
*/
|
|
314
325
|
_stampHidePrice(t, e) {
|
|
315
326
|
const i = this._getBlockElement(t);
|
|
316
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(
|
|
327
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(y, String(e)).apply(new p("Stamp hide-price"));
|
|
317
328
|
}
|
|
318
329
|
/**
|
|
319
330
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -321,7 +332,7 @@ class j extends E {
|
|
|
321
332
|
*/
|
|
322
333
|
_healHidePriceAttr(t) {
|
|
323
334
|
const e = this._getBlockElement(t);
|
|
324
|
-
if (!e || !("getAttribute" in e) || e.getAttribute(
|
|
335
|
+
if (!e || !("getAttribute" in e) || e.getAttribute(y) !== null)
|
|
325
336
|
return;
|
|
326
337
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
327
338
|
this._stampHidePrice(t, i);
|
|
@@ -358,6 +369,6 @@ class j extends E {
|
|
|
358
369
|
}
|
|
359
370
|
}
|
|
360
371
|
export {
|
|
361
|
-
|
|
362
|
-
|
|
372
|
+
D as BLOCK_ID,
|
|
373
|
+
Y as RecommendationBlock
|
|
363
374
|
};
|