@useinsider/guido 3.8.1-beta.6c331cf → 3.8.1-beta.84abfcd
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/Items/block.js +29 -48
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +45 -62
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +10 -10
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -8
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BlockId as
|
|
1
|
+
import { BlockId as g } from "../../../enums/block.js";
|
|
2
2
|
import { useOnboardingStore as p } from "../../../stores/onboarding.js";
|
|
3
|
-
import { getMigrationBannerHtml as
|
|
4
|
-
import { Block as
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const
|
|
9
|
-
class E extends
|
|
3
|
+
import { getMigrationBannerHtml as f } from "../../../utils/migrationBannerHtml.js";
|
|
4
|
+
import { Block as u, BlockCompositionType as I, ModificationDescription as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { SETTINGS_ENUMS as a, DefaultConfigValues as i } from "./enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as C } from "./template.js";
|
|
7
|
+
import { getItemsBlockContainer as y, getItemsBlockConfig as b, getDefaultItemsBlockConfig as h } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const c = g.Items;
|
|
9
|
+
class E extends u {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return c;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
15
15
|
}
|
|
16
16
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
17
|
+
return I.CONTAINER;
|
|
18
18
|
}
|
|
19
19
|
getName() {
|
|
20
20
|
return this.api.translate("Items");
|
|
@@ -23,60 +23,41 @@ class E extends I {
|
|
|
23
23
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
|
-
return
|
|
27
|
-
|
|
26
|
+
return f(
|
|
27
|
+
c,
|
|
28
28
|
this.api.translate("Items"),
|
|
29
29
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
getTemplate() {
|
|
33
|
-
return
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
33
|
+
return C({
|
|
34
|
+
orientation: a.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: a.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
37
|
+
currencySymbol: i.productPriceCurrencySymbolControlValue,
|
|
38
|
+
currencyLocation: i.productPriceCurrencyLocationControlValue,
|
|
39
|
+
formattedPrice: i.productPriceFormattedControlValue === "1"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
allowInnerBlocksDND() {
|
|
43
43
|
return !1;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
r.querySelector('[product-attr="imageSrc"] img') || n.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
-
const t = l(i);
|
|
52
|
-
if (!t)
|
|
45
|
+
onCreated(n) {
|
|
46
|
+
const l = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
|
|
47
|
+
r.querySelector('[product-attr="imageSrc"] img') || l.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
48
|
+
const e = y(n);
|
|
49
|
+
if (!e)
|
|
53
50
|
return;
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
|
|
51
|
+
const s = e.getNodeConfig(), m = s && Object.keys(s).length > 0, t = b(n);
|
|
52
|
+
if (t != null && t.initialized)
|
|
53
|
+
m ? t.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...t, blockInstanceId: String(Date.now()) }).apply(new o("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(t).apply(new o("Migrate legacy config to nodeConfig"));
|
|
57
54
|
else {
|
|
58
|
-
const
|
|
59
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
55
|
+
const d = h();
|
|
56
|
+
this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(d).apply(new o("Initialize Items block with default configuration")), p().startOnboarding("itemsOnboarding");
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
64
|
-
* surfaces via document load. Stripo strips esd-ext-config and never restores it
|
|
65
|
-
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
66
|
-
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
67
|
-
*/
|
|
68
|
-
onDocumentChanged(i) {
|
|
69
|
-
const n = l(i);
|
|
70
|
-
if (!n)
|
|
71
|
-
return;
|
|
72
|
-
const r = n.getNodeConfig();
|
|
73
|
-
if (r && Object.keys(r).length > 0)
|
|
74
|
-
return;
|
|
75
|
-
const e = m(i);
|
|
76
|
-
e != null && e.initialized && this.api.getDocumentModifier().modifyHtml(n).setNodeConfig(e).apply(new s("Recover Items block config from saved module"));
|
|
77
|
-
}
|
|
78
59
|
}
|
|
79
60
|
export {
|
|
80
|
-
|
|
61
|
+
c as BLOCK_ID,
|
|
81
62
|
E as ItemsBlock
|
|
82
63
|
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { ModificationDescription as b } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { DefaultConfigValues as
|
|
2
|
+
import { DefaultConfigValues as o, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
|
|
3
3
|
function _() {
|
|
4
4
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
5
5
|
}
|
|
6
6
|
const E = (r) => r.replace(/\$/g, "$$$$");
|
|
7
|
-
function
|
|
7
|
+
function S() {
|
|
8
8
|
return {
|
|
9
9
|
initialized: !0,
|
|
10
10
|
blockInstanceId: _(),
|
|
11
11
|
source: n.ITEMS_TYPE.CART_ITEMS,
|
|
12
12
|
type: n.ITEMS_TYPE.CART_ITEMS,
|
|
13
|
-
itemsSelectValue:
|
|
13
|
+
itemsSelectValue: o.cartItemsSelectControlValue,
|
|
14
14
|
orientation: n.ORIENTATION.VERTICAL,
|
|
15
|
-
nameTrimming:
|
|
16
|
-
priceHideDiscount:
|
|
17
|
-
priceFormatted:
|
|
15
|
+
nameTrimming: o.productNameTrimmingControlValue === "1",
|
|
16
|
+
priceHideDiscount: o.productPriceHideDiscountControlValue === "1",
|
|
17
|
+
priceFormatted: o.productPriceFormattedControlValue === "1",
|
|
18
18
|
priceSinglePrice: !1,
|
|
19
|
-
priceCurrencySymbol:
|
|
20
|
-
priceCurrencyLocation:
|
|
19
|
+
priceCurrencySymbol: o.productPriceCurrencySymbolControlValue,
|
|
20
|
+
priceCurrencyLocation: o.productPriceCurrencyLocationControlValue,
|
|
21
21
|
priceOrientation: "horizontal",
|
|
22
|
-
quantityControlEnabled:
|
|
23
|
-
buttonLink:
|
|
24
|
-
imageLink:
|
|
22
|
+
quantityControlEnabled: o.productQuantityControlEnabled === "1",
|
|
23
|
+
buttonLink: o.productButtonLinkControlValue,
|
|
24
|
+
imageLink: o.productImageLinkControlValue,
|
|
25
25
|
buttonLabel: "Buy",
|
|
26
26
|
buttonFullWidth: !0,
|
|
27
27
|
// Default to full width (es-fw class)
|
|
28
|
-
imageVisible:
|
|
29
|
-
nameVisible:
|
|
30
|
-
quantityVisible:
|
|
31
|
-
priceVisible:
|
|
32
|
-
originalPriceVisible:
|
|
33
|
-
buttonVisible:
|
|
28
|
+
imageVisible: o.productImageVisible === "1",
|
|
29
|
+
nameVisible: o.productNameVisible === "1",
|
|
30
|
+
quantityVisible: o.productQuantityVisible === "1",
|
|
31
|
+
priceVisible: o.productPriceVisible === "1",
|
|
32
|
+
originalPriceVisible: o.productOriginalPriceVisible === "1",
|
|
33
|
+
buttonVisible: o.productButtonVisible === "1"
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function p(r) {
|
|
@@ -50,26 +50,26 @@ function m(r) {
|
|
|
50
50
|
PURCHASED_ITEMS: n.ITEMS_TYPE.PURCHASED_ITEMS
|
|
51
51
|
}[r] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function I(r, t) {
|
|
54
54
|
if (!r)
|
|
55
|
-
return
|
|
55
|
+
return o.cartItemsSelectControlValue;
|
|
56
56
|
if (r.includes("{{"))
|
|
57
57
|
return r;
|
|
58
58
|
if (/^\d+$/.test(r)) {
|
|
59
|
-
const e = parseInt(r) - 1,
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
59
|
+
const e = parseInt(r) - 1, i = g[t];
|
|
60
|
+
if (i && i[e])
|
|
61
|
+
return i[e].value;
|
|
62
62
|
}
|
|
63
|
-
return
|
|
63
|
+
return o.cartItemsSelectControlValue;
|
|
64
64
|
}
|
|
65
65
|
function C(r) {
|
|
66
66
|
const t = r.querySelector("esd-config-block");
|
|
67
67
|
if (!t)
|
|
68
68
|
return null;
|
|
69
|
-
const e = (
|
|
69
|
+
const e = (c, s) => c == null ? s : c === "1" || c === "true", i = (c, s) => c || s, u = t.getAttribute("data-type"), a = m(u), d = t.getAttribute("data-cart_items_select_control_value"), l = I(d, a);
|
|
70
70
|
return {
|
|
71
71
|
initialized: e(t.getAttribute("data-initialized"), !1),
|
|
72
|
-
blockInstanceId:
|
|
72
|
+
blockInstanceId: i(
|
|
73
73
|
t.getAttribute("data-block-instance-id"),
|
|
74
74
|
_()
|
|
75
75
|
),
|
|
@@ -93,28 +93,28 @@ function C(r) {
|
|
|
93
93
|
t.getAttribute("data-product_price_control_single_price"),
|
|
94
94
|
!1
|
|
95
95
|
),
|
|
96
|
-
priceCurrencySymbol:
|
|
96
|
+
priceCurrencySymbol: i(
|
|
97
97
|
t.getAttribute("data-product_price_control_currency_symbol"),
|
|
98
|
-
|
|
98
|
+
o.productPriceCurrencySymbolControlValue
|
|
99
99
|
),
|
|
100
|
-
priceCurrencyLocation:
|
|
100
|
+
priceCurrencyLocation: i(
|
|
101
101
|
t.getAttribute("data-product_price_currency_location"),
|
|
102
|
-
|
|
102
|
+
o.productPriceCurrencyLocationControlValue
|
|
103
103
|
),
|
|
104
104
|
priceOrientation: t.getAttribute("data-product_original_price_control_orientation") || "horizontal",
|
|
105
105
|
quantityControlEnabled: e(
|
|
106
106
|
t.getAttribute("data-product_quantity_control_enabled"),
|
|
107
107
|
!0
|
|
108
108
|
),
|
|
109
|
-
buttonLink:
|
|
109
|
+
buttonLink: i(
|
|
110
110
|
t.getAttribute("data-product_button_link"),
|
|
111
|
-
|
|
111
|
+
o.productButtonLinkControlValue
|
|
112
112
|
),
|
|
113
|
-
imageLink:
|
|
113
|
+
imageLink: i(
|
|
114
114
|
t.getAttribute("data-product_image_link"),
|
|
115
|
-
|
|
115
|
+
o.productImageLinkControlValue
|
|
116
116
|
),
|
|
117
|
-
buttonLabel:
|
|
117
|
+
buttonLabel: i(
|
|
118
118
|
t.getAttribute("data-product_button_control_label"),
|
|
119
119
|
"Buy"
|
|
120
120
|
),
|
|
@@ -149,45 +149,28 @@ function C(r) {
|
|
|
149
149
|
)
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
if (typeof r.getAttribute != "function")
|
|
154
|
-
return null;
|
|
155
|
-
const t = r.getAttribute("esd-ext-config");
|
|
156
|
-
if (!t)
|
|
157
|
-
return null;
|
|
158
|
-
try {
|
|
159
|
-
const e = JSON.parse(t);
|
|
160
|
-
if (e && e.initialized)
|
|
161
|
-
return e;
|
|
162
|
-
} catch {
|
|
163
|
-
}
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
function A(r) {
|
|
152
|
+
function y(r) {
|
|
167
153
|
const t = p(r);
|
|
168
154
|
if (!t)
|
|
169
155
|
return null;
|
|
170
156
|
const e = t.getNodeConfig();
|
|
171
157
|
if (e && e.initialized)
|
|
172
158
|
return e;
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
return o;
|
|
176
|
-
const c = C(t);
|
|
177
|
-
return c || null;
|
|
159
|
+
const i = C(t);
|
|
160
|
+
return i || null;
|
|
178
161
|
}
|
|
179
|
-
function
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
162
|
+
function A(r, t, e, i) {
|
|
163
|
+
const u = p(r);
|
|
164
|
+
if (!u)
|
|
182
165
|
return;
|
|
183
|
-
const d = { ...
|
|
184
|
-
l.modifyHtml(
|
|
166
|
+
const d = { ...u.getNodeConfig() || {}, ...e }, l = i ?? t.getDocumentModifier();
|
|
167
|
+
l.modifyHtml(u).setNodeConfig(d), i || l.apply(new b("Update Items block configuration"));
|
|
185
168
|
}
|
|
186
169
|
export {
|
|
187
170
|
E as escapeReplacement,
|
|
188
171
|
_ as generateBlockInstanceId,
|
|
189
|
-
|
|
190
|
-
|
|
172
|
+
S as getDefaultItemsBlockConfig,
|
|
173
|
+
y as getItemsBlockConfig,
|
|
191
174
|
p as getItemsBlockContainer,
|
|
192
|
-
|
|
175
|
+
A as setItemsBlockConfig
|
|
193
176
|
};
|
|
@@ -93,8 +93,8 @@ function $(e, t = {}) {
|
|
|
93
93
|
productsPerRow: c.mobileCardsInRow,
|
|
94
94
|
composition: d,
|
|
95
95
|
filterList: l.filterList,
|
|
96
|
-
//
|
|
97
|
-
cellPadding:
|
|
96
|
+
// Match the initial render's gutter so a regeneration never changes block height (SD-143023).
|
|
97
|
+
cellPadding: U(c.mobileColumnSpacing),
|
|
98
98
|
rowSpacingPx: c.mobileRowSpacing,
|
|
99
99
|
...t
|
|
100
100
|
})}</table></td>`, E = n.querySelector(N);
|
|
@@ -120,8 +120,8 @@ function ee(e, t = {}) {
|
|
|
120
120
|
productsPerRow: a,
|
|
121
121
|
composition: d,
|
|
122
122
|
filterList: c.filterList,
|
|
123
|
-
//
|
|
124
|
-
cellPadding:
|
|
123
|
+
// Match the initial render's gutter so a regeneration never changes block height (SD-143023).
|
|
124
|
+
cellPadding: U(p.columnSpacing),
|
|
125
125
|
rowSpacingPx: p.rowSpacing,
|
|
126
126
|
...t
|
|
127
127
|
});
|
|
@@ -277,7 +277,7 @@ function re(e, t, n) {
|
|
|
277
277
|
});
|
|
278
278
|
}), s;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function h(e, t, n) {
|
|
281
281
|
if (!("querySelectorAll" in e))
|
|
282
282
|
return !1;
|
|
283
283
|
const o = e.querySelectorAll(
|
|
@@ -321,12 +321,12 @@ function ge(e) {
|
|
|
321
321
|
`[esd-extension-block-id="${m.IMAGE}"]`
|
|
322
322
|
).length !== o.length)
|
|
323
323
|
return !1;
|
|
324
|
-
let i =
|
|
324
|
+
let i = h(r, n, o);
|
|
325
325
|
const u = C(t), c = S.getConfig(t);
|
|
326
326
|
if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
|
|
327
327
|
const l = t.querySelector(O);
|
|
328
328
|
if (l) {
|
|
329
|
-
const a =
|
|
329
|
+
const a = h(
|
|
330
330
|
l,
|
|
331
331
|
n,
|
|
332
332
|
o
|
|
@@ -336,7 +336,7 @@ function ge(e) {
|
|
|
336
336
|
}
|
|
337
337
|
return i && n.apply(new g("Updated product content in-place")), !0;
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function I(e, t, n) {
|
|
340
340
|
if (!("querySelectorAll" in e))
|
|
341
341
|
return !1;
|
|
342
342
|
const o = e.querySelectorAll(
|
|
@@ -370,12 +370,12 @@ function Se(e) {
|
|
|
370
370
|
if (r.length === 0)
|
|
371
371
|
return !1;
|
|
372
372
|
const s = j(t);
|
|
373
|
-
let i =
|
|
373
|
+
let i = I(s, n, r);
|
|
374
374
|
const u = C(t), c = S.getConfig(t);
|
|
375
375
|
if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
|
|
376
376
|
const l = t.querySelector(O);
|
|
377
377
|
if (l) {
|
|
378
|
-
const a =
|
|
378
|
+
const a = I(l, n, r);
|
|
379
379
|
i = i || a;
|
|
380
380
|
}
|
|
381
381
|
}
|
|
@@ -24,13 +24,5 @@ export declare class ItemsBlock extends Block {
|
|
|
24
24
|
getSettingsPanelTitleHtml(): string;
|
|
25
25
|
getTemplate(): string;
|
|
26
26
|
allowInnerBlocksDND(): boolean;
|
|
27
|
-
canBeSavedAsModule(): boolean;
|
|
28
27
|
onCreated(node: ImmutableHtmlNode): void;
|
|
29
|
-
/**
|
|
30
|
-
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
31
|
-
* surfaces via document load. Stripo strips esd-ext-config and never restores it
|
|
32
|
-
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
33
|
-
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
34
|
-
*/
|
|
35
|
-
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
36
28
|
}
|
|
@@ -55,7 +55,7 @@ export declare function getItemsBlockContainer(currentNode: ImmutableHtmlNode |
|
|
|
55
55
|
/**
|
|
56
56
|
* Gets the node configuration from the Items block.
|
|
57
57
|
* Uses Stripo V2's getNodeConfig() API.
|
|
58
|
-
* Falls back to
|
|
58
|
+
* Falls back to migrating from legacy config block if nodeConfig is empty.
|
|
59
59
|
* @param currentNode - The current node from the control
|
|
60
60
|
* @returns The ItemsBlockConfig object or null if not found
|
|
61
61
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.8.1-beta.
|
|
3
|
+
"version": "3.8.1-beta.84abfcd",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|