@useinsider/guido 2.1.0-beta.7ae6573 → 2.1.0-beta.7bbedc6
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 +36 -0
- package/dist/@types/config/schemas.js +70 -65
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +69 -58
- package/dist/components/organisms/base/Toaster.vue.js +4 -4
- package/dist/components/organisms/base/Toaster.vue2.js +12 -9
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -17
- package/dist/config/migrator/itemsBlockMigrator.js +101 -97
- package/dist/enums/defaults.js +8 -4
- package/dist/extensions/Blocks/Recommendation/block.js +24 -23
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +27 -26
- package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +11 -10
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +87 -37
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
- package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +25 -30
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -30
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +31 -15
- package/dist/extensions/ModulesTabIcons/extension.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
- package/dist/services/stripoApi.js +20 -17
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
- package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +11 -2
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/static/styles/customEditorStyle.css.js +10 -9
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import r from "../extensions/ModulesTabIcons/extension.js";
|
|
1
2
|
import { useConfigStore as l } from "../stores/config.js";
|
|
2
|
-
const
|
|
3
|
+
const a = {
|
|
3
4
|
"amp-accordion": "ampAccordionEnabled",
|
|
4
5
|
"amp-carousel": "ampCarouselEnabled",
|
|
5
6
|
"amp-form-controls": "ampFormControlsEnabled",
|
|
@@ -13,7 +14,7 @@ const r = {
|
|
|
13
14
|
"text-block": "textEnabled",
|
|
14
15
|
"timer-block": "timerEnabled",
|
|
15
16
|
"video-block": "videoEnabled"
|
|
16
|
-
},
|
|
17
|
+
}, s = {
|
|
17
18
|
"dynamic-content": () => import("../extensions/DynamicContent/extension.js"),
|
|
18
19
|
"checkbox-block": () => import("../extensions/Blocks/Checkbox/extension.js"),
|
|
19
20
|
"radio-button-block": () => import("../extensions/Blocks/RadioButton/extension.js"),
|
|
@@ -21,31 +22,40 @@ const r = {
|
|
|
21
22
|
"unsubscribe-block": () => import("../extensions/Blocks/Unsubscribe/extension.js"),
|
|
22
23
|
"coupon-block": () => import("../extensions/Blocks/CouponBlock/extension.js"),
|
|
23
24
|
"items-block": () => import("../extensions/Blocks/Items/extension.js")
|
|
24
|
-
},
|
|
25
|
+
}, i = (n) => {
|
|
25
26
|
if (!n || !n.length)
|
|
26
27
|
return {};
|
|
27
|
-
const
|
|
28
|
+
const t = {};
|
|
28
29
|
return n.forEach((o) => {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return t
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const e = a[o];
|
|
31
|
+
e && (t[e] = !1);
|
|
32
|
+
}), t;
|
|
33
|
+
}, b = () => [r], m = async (n) => {
|
|
34
|
+
const t = b();
|
|
35
|
+
if (!n || !n.length)
|
|
36
|
+
return t;
|
|
37
|
+
const o = await Promise.all(
|
|
38
|
+
n.map(async (e) => {
|
|
39
|
+
const c = s[e];
|
|
40
|
+
return c ? (await c()).default : null;
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
return [
|
|
44
|
+
...t,
|
|
45
|
+
...o.filter((e) => e !== null)
|
|
46
|
+
];
|
|
47
|
+
}, E = () => {
|
|
38
48
|
const n = l();
|
|
39
49
|
return {
|
|
40
50
|
getStripoBlocksConfig: async () => {
|
|
41
51
|
const o = n.blocks;
|
|
42
52
|
return {
|
|
43
|
-
baseBlocks:
|
|
44
|
-
extensions: await
|
|
53
|
+
baseBlocks: i(o == null ? void 0 : o.excludeDefaults),
|
|
54
|
+
extensions: await m(o == null ? void 0 : o.includeCustoms)
|
|
45
55
|
};
|
|
46
56
|
}
|
|
47
57
|
};
|
|
48
58
|
};
|
|
49
59
|
export {
|
|
50
|
-
|
|
60
|
+
E as useBlocksConfig
|
|
51
61
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
2
2
|
function b(e, u, r, o) {
|
|
3
|
-
const
|
|
4
|
-
return o === "before" ? `${t} ${
|
|
3
|
+
const n = `{{${e}_${u}_${r}}}`, t = `{{${e}_${u}_currency}}`;
|
|
4
|
+
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
5
5
|
}
|
|
6
|
-
function p(e, u, r, o,
|
|
6
|
+
function p(e, u, r, o, n) {
|
|
7
7
|
switch (u) {
|
|
8
8
|
case "productImage": {
|
|
9
9
|
const t = e.querySelector("img");
|
|
@@ -24,7 +24,7 @@ function p(e, u, r, o, s) {
|
|
|
24
24
|
const t = e.querySelector("p");
|
|
25
25
|
if (t) {
|
|
26
26
|
const c = t.querySelector("strong") || t;
|
|
27
|
-
c.textContent = b(r, o, "price",
|
|
27
|
+
c.textContent = b(r, o, "price", n);
|
|
28
28
|
}
|
|
29
29
|
break;
|
|
30
30
|
}
|
|
@@ -36,7 +36,7 @@ function p(e, u, r, o, s) {
|
|
|
36
36
|
r,
|
|
37
37
|
o,
|
|
38
38
|
"original_price",
|
|
39
|
-
|
|
39
|
+
n
|
|
40
40
|
), t.setAttribute("product-attr", "discount");
|
|
41
41
|
}
|
|
42
42
|
break;
|
|
@@ -67,12 +67,12 @@ function p(e, u, r, o, s) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
function $(e, u, r) {
|
|
70
|
-
e.querySelectorAll(".recommendation-product-row").forEach((
|
|
71
|
-
|
|
72
|
-
const i =
|
|
70
|
+
e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
71
|
+
n.querySelectorAll("[data-attribute-type]").forEach((s) => {
|
|
72
|
+
const i = s.getAttribute("data-attribute-type") || "", a = s.querySelectorAll(".attribute-cell");
|
|
73
73
|
a.length > 0 ? a.forEach((l) => {
|
|
74
74
|
p(l, i, u, t, r);
|
|
75
|
-
}) : p(
|
|
75
|
+
}) : p(s, i, u, t, r);
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
}
|
|
@@ -80,9 +80,9 @@ function S(e, u, r) {
|
|
|
80
80
|
const o = e.querySelectorAll(".recommendation-product-row");
|
|
81
81
|
if (!o.length)
|
|
82
82
|
return;
|
|
83
|
-
const [
|
|
84
|
-
o.forEach((
|
|
85
|
-
|
|
83
|
+
const [n] = o, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
84
|
+
o.forEach((s, i) => {
|
|
85
|
+
s.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
86
86
|
const f = l.getAttribute("data-attribute-type") || "";
|
|
87
87
|
l.querySelectorAll(".attribute-cell").forEach((y, m) => {
|
|
88
88
|
const A = i * c + m;
|
|
@@ -91,9 +91,14 @@ function S(e, u, r) {
|
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
function q(e, u) {
|
|
94
|
+
function q(e, u, r) {
|
|
95
|
+
e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
96
|
+
S(n, u, r);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function d(e, u) {
|
|
95
100
|
const r = e.getAttribute("data-layout") || "grid", o = e.getAttribute("currency-alignment") || "after";
|
|
96
|
-
r === "list" ? $(e, u, o) :
|
|
101
|
+
r === "list" ? $(e, u, o) : q(e, u, o);
|
|
97
102
|
}
|
|
98
103
|
function h(e, u) {
|
|
99
104
|
const r = e.match(/<!DOCTYPE[^>]*>/i);
|
|
@@ -104,10 +109,10 @@ function w(e) {
|
|
|
104
109
|
const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".ins-recommendation-v3-block-v2");
|
|
105
110
|
if (!o.length)
|
|
106
111
|
return e;
|
|
107
|
-
const { buildCampaignUrl:
|
|
112
|
+
const { buildCampaignUrl: n } = _();
|
|
108
113
|
return o.forEach((c) => {
|
|
109
|
-
const
|
|
110
|
-
|
|
114
|
+
const s = c.getAttribute("recommendation-id");
|
|
115
|
+
s && (n(s), d(c, s));
|
|
111
116
|
}), h(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
112
117
|
}
|
|
113
118
|
export {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var B = Object.defineProperty;
|
|
2
|
-
var U = (
|
|
3
|
-
var M = (
|
|
2
|
+
var U = (e, t, r) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var M = (e, t, r) => U(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
import { productPairs as v } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
5
|
-
import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as
|
|
5
|
+
import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as u } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
6
6
|
import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
|
|
7
7
|
const w = {
|
|
8
8
|
img: {
|
|
@@ -74,76 +74,76 @@ const w = {
|
|
|
74
74
|
function F() {
|
|
75
75
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
76
76
|
}
|
|
77
|
-
function q(
|
|
78
|
-
return
|
|
79
|
-
CartItems:
|
|
80
|
-
BrowsedItems:
|
|
81
|
-
PurchasedItems:
|
|
82
|
-
CART_ITEMS:
|
|
83
|
-
BROWSED_ITEMS:
|
|
84
|
-
PURCHASED_ITEMS:
|
|
85
|
-
}[
|
|
77
|
+
function q(e) {
|
|
78
|
+
return e ? {
|
|
79
|
+
CartItems: u.ITEMS_TYPE.CART_ITEMS,
|
|
80
|
+
BrowsedItems: u.ITEMS_TYPE.BROWSED_ITEMS,
|
|
81
|
+
PurchasedItems: u.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
82
|
+
CART_ITEMS: u.ITEMS_TYPE.CART_ITEMS,
|
|
83
|
+
BROWSED_ITEMS: u.ITEMS_TYPE.BROWSED_ITEMS,
|
|
84
|
+
PURCHASED_ITEMS: u.ITEMS_TYPE.PURCHASED_ITEMS
|
|
85
|
+
}[e] || u.ITEMS_TYPE.CART_ITEMS : u.ITEMS_TYPE.CART_ITEMS;
|
|
86
86
|
}
|
|
87
|
-
function R(
|
|
88
|
-
const t = (a, o) => a == null ? o : a === "1" || a === "true",
|
|
89
|
-
let n =
|
|
87
|
+
function R(e) {
|
|
88
|
+
const t = (a, o) => a == null ? o : a === "1" || a === "true", r = (a, o) => a || o, c = e["data-type"] || e["data-source"], i = q(c);
|
|
89
|
+
let n = e["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
|
|
90
90
|
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
91
|
-
const a = parseInt(n) - 1, o = E[
|
|
91
|
+
const a = parseInt(n) - 1, o = E[i];
|
|
92
92
|
o && o[a] && (n = o[a].value);
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
95
|
initialized: !0,
|
|
96
|
-
blockInstanceId: e
|
|
97
|
-
source:
|
|
98
|
-
type:
|
|
96
|
+
blockInstanceId: r(e["data-block-instance-id"], F()),
|
|
97
|
+
source: i,
|
|
98
|
+
type: i,
|
|
99
99
|
itemsSelectValue: n,
|
|
100
|
-
orientation:
|
|
101
|
-
nameTrimming: t(
|
|
102
|
-
priceHideDiscount: t(
|
|
103
|
-
priceFormatted: t(
|
|
104
|
-
priceSinglePrice: t(
|
|
105
|
-
priceCurrencySymbol:
|
|
106
|
-
|
|
100
|
+
orientation: e["data-card_orientation_control_value"] || u.ORIENTATION.VERTICAL,
|
|
101
|
+
nameTrimming: t(e["data-product_name_control_trim"], !0),
|
|
102
|
+
priceHideDiscount: t(e["data-product_price_control_nodup"], !0),
|
|
103
|
+
priceFormatted: t(e["data-product_price_control_formated"], !0),
|
|
104
|
+
priceSinglePrice: t(e["data-product_price_control_single_price"], !1),
|
|
105
|
+
priceCurrencySymbol: r(
|
|
106
|
+
e["data-product_price_control_currency_symbol"],
|
|
107
107
|
g.productPriceCurrencySymbolControlValue
|
|
108
108
|
),
|
|
109
|
-
priceCurrencyLocation:
|
|
110
|
-
|
|
109
|
+
priceCurrencyLocation: r(
|
|
110
|
+
e["data-product_price_currency_location"],
|
|
111
111
|
g.productPriceCurrencyLocationControlValue
|
|
112
112
|
),
|
|
113
|
-
priceOrientation:
|
|
114
|
-
quantityControlEnabled: t(
|
|
115
|
-
buttonLink: e
|
|
116
|
-
imageLink: e
|
|
117
|
-
buttonLabel: e
|
|
118
|
-
buttonFullWidth: t(
|
|
119
|
-
imageVisible: t(
|
|
120
|
-
nameVisible: t(
|
|
121
|
-
quantityVisible: t(
|
|
122
|
-
priceVisible: t(
|
|
123
|
-
originalPriceVisible: t(
|
|
124
|
-
buttonVisible: t(
|
|
113
|
+
priceOrientation: e["data-product_original_price_control_orientation"] || "horizontal",
|
|
114
|
+
quantityControlEnabled: t(e["data-product_quantity_control_enabled"], !0),
|
|
115
|
+
buttonLink: r(e["data-product_button_link"], g.productButtonLinkControlValue),
|
|
116
|
+
imageLink: r(e["data-product_image_link"], g.productImageLinkControlValue),
|
|
117
|
+
buttonLabel: r(e["data-product_button_control_label"], "Buy"),
|
|
118
|
+
buttonFullWidth: t(e["data-product_button_control_atw"], !0),
|
|
119
|
+
imageVisible: t(e["data-product_image_control_enabled"], !0),
|
|
120
|
+
nameVisible: t(e["data-product_name_control_enabled"], !0),
|
|
121
|
+
quantityVisible: t(e["data-product_quantity_control_enabled"], !0),
|
|
122
|
+
priceVisible: t(e["data-product_price_control_enabled"], !0),
|
|
123
|
+
originalPriceVisible: t(e["data-product_original_price_control_enabled"], !0),
|
|
124
|
+
buttonVisible: t(e["data-product_button_control_enabled"], !0)
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const O = {
|
|
128
128
|
ins_apr: "CART_ITEMS",
|
|
129
129
|
browsed_item: "BROWSED_ITEMS",
|
|
130
130
|
purchased_item: "PURCHASED_ITEMS"
|
|
131
131
|
};
|
|
132
|
-
function
|
|
133
|
-
const
|
|
132
|
+
function $(e, t) {
|
|
133
|
+
const r = {
|
|
134
134
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
135
135
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
136
136
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
137
137
|
};
|
|
138
|
-
return e
|
|
138
|
+
return r[e] || r.CART_ITEMS;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
const
|
|
140
|
+
function x(e, t) {
|
|
141
|
+
const r = {
|
|
142
142
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
143
143
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
144
144
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
145
145
|
};
|
|
146
|
-
return e
|
|
146
|
+
return r[e] || r.CART_ITEMS;
|
|
147
147
|
}
|
|
148
148
|
class V {
|
|
149
149
|
constructor() {
|
|
@@ -152,12 +152,12 @@ class V {
|
|
|
152
152
|
}
|
|
153
153
|
migrate(t) {
|
|
154
154
|
try {
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
const
|
|
155
|
+
let r = this.removeJinjaConditionals(t);
|
|
156
|
+
r = this.replaceTemplateVariables(r);
|
|
157
|
+
const c = this.parser.parseFromString(r, "text/html"), i = c.querySelectorAll(
|
|
158
158
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
159
159
|
);
|
|
160
|
-
return
|
|
160
|
+
return i.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (i.forEach((n) => {
|
|
161
161
|
const a = this.extractConfiguration(n), o = K({
|
|
162
162
|
orientation: a.orientation,
|
|
163
163
|
itemsType: a.itemsType,
|
|
@@ -173,19 +173,19 @@ class V {
|
|
|
173
173
|
originalPriceStyles: a.originalPriceStyles,
|
|
174
174
|
quantityStyles: a.quantityStyles,
|
|
175
175
|
nodeConfig: R(a.configBlockAttributes)
|
|
176
|
-
}),
|
|
176
|
+
}), l = this.parser.parseFromString(
|
|
177
177
|
`<table><tbody><tr>${o}</tr></tbody></table>`,
|
|
178
178
|
"text/html"
|
|
179
179
|
).querySelector("td");
|
|
180
|
-
if (
|
|
180
|
+
if (l && n.parentNode) {
|
|
181
181
|
const f = R(a.configBlockAttributes);
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
182
|
+
l.setAttribute("esd-ext-config", JSON.stringify(f));
|
|
183
|
+
const d = l.querySelector("esd-config-block");
|
|
184
|
+
d && d.remove(), n.parentNode.replaceChild(l, n);
|
|
185
185
|
}
|
|
186
|
-
}),
|
|
187
|
-
} catch (
|
|
188
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
186
|
+
}), c.documentElement.outerHTML);
|
|
187
|
+
} catch (r) {
|
|
188
|
+
return console.error("ItemsBlockMigrator failed:", r), t;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -196,22 +196,22 @@ class V {
|
|
|
196
196
|
*/
|
|
197
197
|
extractConfiguration(t) {
|
|
198
198
|
var C, D, P;
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
const p = t.querySelector('a[product-attr="name"]'),
|
|
199
|
+
const r = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", i = parseInt(c) - 1, n = E[r], a = ((P = n == null ? void 0 : n[i]) == null ? void 0 : P.value) || n[0].value, o = t.querySelector('[product-attr="price"]'), _ = (o == null ? void 0 : o.getAttribute("data-currency_symbol")) || "USD", f = ((o == null ? void 0 : o.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", d = (o == null ? void 0 : o.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, r, c), S = s["data-card_orientation_control_value"];
|
|
200
|
+
let b;
|
|
201
|
+
S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
202
|
+
const p = t.querySelector('a[product-attr="name"]'), I = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, h = (o == null ? void 0 : o.getAttribute("style")) || void 0, T = t.querySelector("p.original-price"), k = (T == null ? void 0 : T.getAttribute("style")) || void 0, A = t.querySelector('[product-attr="quantity"]'), L = (A == null ? void 0 : A.getAttribute("style")) || void 0;
|
|
203
203
|
return {
|
|
204
|
-
orientation:
|
|
205
|
-
itemsType:
|
|
204
|
+
orientation: b,
|
|
205
|
+
itemsType: r,
|
|
206
206
|
itemId: a,
|
|
207
207
|
currencySymbol: _,
|
|
208
208
|
currencyLocation: f,
|
|
209
|
-
formattedPrice:
|
|
209
|
+
formattedPrice: d,
|
|
210
210
|
configBlockAttributes: s,
|
|
211
|
-
nameStyles:
|
|
211
|
+
nameStyles: I,
|
|
212
212
|
buttonStyles: m,
|
|
213
|
-
priceStyles:
|
|
214
|
-
originalPriceStyles:
|
|
213
|
+
priceStyles: h,
|
|
214
|
+
originalPriceStyles: k,
|
|
215
215
|
quantityStyles: L
|
|
216
216
|
};
|
|
217
217
|
}
|
|
@@ -222,17 +222,17 @@ class V {
|
|
|
222
222
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
223
223
|
* @param itemNumber - The item number (1-based index)
|
|
224
224
|
*/
|
|
225
|
-
extractConfigBlockAttributes(t,
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
225
|
+
extractConfigBlockAttributes(t, r, c) {
|
|
226
|
+
const i = t.querySelector("esd-config-block"), n = {};
|
|
227
|
+
if (!i)
|
|
228
228
|
return this.getDefaultConfigBlockAttributes();
|
|
229
|
-
if (Array.from(
|
|
229
|
+
if (Array.from(i.attributes).forEach((o) => {
|
|
230
230
|
o.name.startsWith("data-") && (n[o.name] = o.value);
|
|
231
231
|
}), n["data-cart_items_select_control_value"]) {
|
|
232
232
|
const o = n["data-cart_items_select_control_value"];
|
|
233
233
|
if (/^\d+$/.test(o)) {
|
|
234
|
-
const _ = parseInt(o) - 1,
|
|
235
|
-
|
|
234
|
+
const _ = parseInt(o) - 1, l = E[r];
|
|
235
|
+
l && l[_] && (n["data-cart_items_select_control_value"] = l[_].value);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
if (n["data-product_price_control_curency"]) {
|
|
@@ -242,7 +242,7 @@ class V {
|
|
|
242
242
|
}
|
|
243
243
|
(!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
|
|
244
244
|
const a = { ...this.getDefaultConfigBlockAttributes(), ...n };
|
|
245
|
-
return a["data-type"] =
|
|
245
|
+
return a["data-type"] = r, a["data-source"] = r, a["data-product_image_link"] = $(r, c), a["data-product_button_link"] = x(r, c), a;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
248
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -297,18 +297,22 @@ class V {
|
|
|
297
297
|
* - Cart Items: ins_apr_total_product_kind, ins_apr_price_N, ins_apr_originalprice_N
|
|
298
298
|
* - Browsed Items: browsed_item_total_product_kind, browsed_item_price_N, browsed_item_originalprice_N
|
|
299
299
|
* - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
|
|
300
|
+
*
|
|
301
|
+
* IMPORTANT: Preserves the esd-custom-display-conditions attribute on <body> which
|
|
302
|
+
* contains display condition Jinja scripts that should NOT be removed.
|
|
300
303
|
*/
|
|
301
304
|
removeJinjaConditionals(t) {
|
|
302
|
-
|
|
305
|
+
const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
306
|
+
let i = c ? t.replace(c[0], r) : t;
|
|
307
|
+
return i = i.replace(
|
|
303
308
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
304
309
|
""
|
|
305
|
-
)
|
|
306
|
-
return e = e.replace(
|
|
310
|
+
), i = i.replace(
|
|
307
311
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
308
312
|
""
|
|
309
|
-
),
|
|
313
|
+
), i = i.replace(/\{%\s*endif\s*%\}/g, ""), c && (i = i.replace(r, c[0])), i = i.replace(/\n\s*\n\s*\n/g, `
|
|
310
314
|
|
|
311
|
-
`),
|
|
315
|
+
`), i;
|
|
312
316
|
}
|
|
313
317
|
/**
|
|
314
318
|
* Replaces template variables with default values from productPairs
|
|
@@ -320,31 +324,31 @@ class V {
|
|
|
320
324
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
321
325
|
*/
|
|
322
326
|
replaceTemplateVariables(t) {
|
|
323
|
-
const { PAIRS_FOR_EXTENSION:
|
|
324
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
325
|
-
const n =
|
|
327
|
+
const { PAIRS_FOR_EXTENSION: r } = v;
|
|
328
|
+
return t.replace(/{{([^}]+)}}/g, (c, i) => {
|
|
329
|
+
const n = i.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
326
330
|
if (!n)
|
|
327
|
-
return
|
|
328
|
-
const [, a, o, _] = n,
|
|
329
|
-
if (!
|
|
330
|
-
return console.warn(`Unknown variable prefix: ${a}`),
|
|
331
|
+
return c;
|
|
332
|
+
const [, a, o, _] = n, l = O[a];
|
|
333
|
+
if (!l)
|
|
334
|
+
return console.warn(`Unknown variable prefix: ${a}`), c;
|
|
331
335
|
const f = w[o];
|
|
332
336
|
if (!f)
|
|
333
|
-
return console.warn(`Unknown variable suffix mapping for: ${o}`),
|
|
334
|
-
const { pairsKey:
|
|
337
|
+
return console.warn(`Unknown variable suffix mapping for: ${o}`), c;
|
|
338
|
+
const { pairsKey: d, defaultKey: s, isArray: S } = f, p = r[d][l];
|
|
335
339
|
if (!p)
|
|
336
|
-
return console.warn(`No data found for: ${
|
|
337
|
-
if (
|
|
340
|
+
return console.warn(`No data found for: ${d}.${l}`), c;
|
|
341
|
+
if (S) {
|
|
338
342
|
const y = parseInt(_) - 1, m = p[s];
|
|
339
|
-
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${
|
|
343
|
+
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${d}.${l}.${s}[${y}]`), c);
|
|
340
344
|
}
|
|
341
|
-
const
|
|
342
|
-
return
|
|
345
|
+
const I = p[s];
|
|
346
|
+
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${d}.${l}.${s}`), c);
|
|
343
347
|
});
|
|
344
348
|
}
|
|
345
349
|
}
|
|
346
|
-
function G(
|
|
347
|
-
return new V().migrate(
|
|
350
|
+
function G(e) {
|
|
351
|
+
return new V().migrate(e);
|
|
348
352
|
}
|
|
349
353
|
export {
|
|
350
354
|
G as migrateItemsBlock
|
package/dist/enums/defaults.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e = {
|
|
2
2
|
transactional: 2
|
|
3
|
-
}, o = 2,
|
|
3
|
+
}, o = 2, t = 13, s = {
|
|
4
|
+
SAVED_MODULES: "savedModules",
|
|
5
|
+
DEFAULT_MODULES: "defaultModules"
|
|
6
|
+
};
|
|
4
7
|
export {
|
|
5
8
|
o as EditorType,
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
t as MAX_DEFAULT_TEMPLATE_ID,
|
|
10
|
+
s as ModuleFolderDefaults,
|
|
11
|
+
e as TemplateTypes
|
|
8
12
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var g = (r, o, t) =>
|
|
4
|
-
import { Block as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var f = (r, o, t) => o in r ? p(r, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[o] = t;
|
|
3
|
+
var g = (r, o, t) => f(r, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { Block as h, BlockCompositionType as I, ModificationDescription as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { ensureMobileCssRulesExist as d } from "./controls/mobileLayout/cssRules.js";
|
|
6
|
+
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
7
|
+
import { useRecommendationExtensionStore as u } from "./store/recommendation.js";
|
|
8
|
+
import { getDefaultTemplate as k } from "./templates/grid/template.js";
|
|
9
|
+
const B = "recommendation-block", c = "ins-recommendation-v3-block-v2", a = "recommendation-id";
|
|
10
|
+
class y extends h {
|
|
10
11
|
constructor() {
|
|
11
12
|
super();
|
|
12
13
|
/**
|
|
@@ -16,7 +17,7 @@ class b extends f {
|
|
|
16
17
|
g(this, "_pendingBlockId", null);
|
|
17
18
|
}
|
|
18
19
|
getId() {
|
|
19
|
-
return
|
|
20
|
+
return B;
|
|
20
21
|
}
|
|
21
22
|
getIcon() {
|
|
22
23
|
return "recommendation-icon";
|
|
@@ -39,7 +40,7 @@ class b extends f {
|
|
|
39
40
|
*/
|
|
40
41
|
getTemplate() {
|
|
41
42
|
const t = this._generateNextId();
|
|
42
|
-
return this._pendingBlockId = t,
|
|
43
|
+
return this._pendingBlockId = t, k(t);
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* Called when a new block is dropped into the template
|
|
@@ -51,8 +52,8 @@ class b extends f {
|
|
|
51
52
|
onCreated(t) {
|
|
52
53
|
const e = this._pendingBlockId ?? this._generateNextId();
|
|
53
54
|
this._pendingBlockId = null, this._assignRecommendationId(t, e);
|
|
54
|
-
const n =
|
|
55
|
-
i.setCurrentBlock(e), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
|
|
55
|
+
const n = s.initializeConfig(this.api, t, { recommendationId: e }), i = u();
|
|
56
|
+
i.setCurrentBlock(e), d(this.api), i.patchCurrentBlockConfig({ language: n.language }, { triggerRefetch: !1 });
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* Called when the document changes or template is loaded
|
|
@@ -65,14 +66,14 @@ class b extends f {
|
|
|
65
66
|
if (!(!t || !("getNodeConfig" in t))) {
|
|
66
67
|
if (!this._getRecommendationId(t)) {
|
|
67
68
|
const e = this._generateNextId();
|
|
68
|
-
this._assignRecommendationId(t, e),
|
|
69
|
+
this._assignRecommendationId(t, e), s.hasConfig(t) && s.updateConfig(
|
|
69
70
|
this.api,
|
|
70
71
|
t,
|
|
71
72
|
{ recommendationId: e },
|
|
72
73
|
"Assign recommendation ID to legacy block"
|
|
73
74
|
);
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
s.needsMigration(t) && this._migrateFromLegacy(t), d(this.api);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
/**
|
|
@@ -83,7 +84,7 @@ class b extends f {
|
|
|
83
84
|
*/
|
|
84
85
|
onDelete(t) {
|
|
85
86
|
const e = this._getRecommendationId(t);
|
|
86
|
-
e &&
|
|
87
|
+
e && u().removeBlockState(e);
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
89
90
|
* Generates the next unique recommendation ID by scanning all existing blocks
|
|
@@ -93,7 +94,7 @@ class b extends f {
|
|
|
93
94
|
let t = 0;
|
|
94
95
|
try {
|
|
95
96
|
const e = this.api.getDocumentRoot();
|
|
96
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
97
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${c}`).forEach((i) => {
|
|
97
98
|
if ("getAttribute" in i) {
|
|
98
99
|
const m = i.getAttribute(a), l = m ? parseInt(m) : 0;
|
|
99
100
|
l > t && (t = l);
|
|
@@ -114,7 +115,7 @@ class b extends f {
|
|
|
114
115
|
if (!n)
|
|
115
116
|
return;
|
|
116
117
|
const i = this.api.getDocumentModifier();
|
|
117
|
-
i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new
|
|
118
|
+
i.modifyHtml(n).setAttribute(a, e.toString()), i.apply(new _(`Assign recommendation ID ${e}`));
|
|
118
119
|
}
|
|
119
120
|
/**
|
|
120
121
|
* Gets the recommendation-id from a block node
|
|
@@ -135,19 +136,19 @@ class b extends f {
|
|
|
135
136
|
_getBlockElement(t) {
|
|
136
137
|
if ("getAttribute" in t) {
|
|
137
138
|
const e = t.getAttribute("class");
|
|
138
|
-
if (e && e.includes(
|
|
139
|
+
if (e && e.includes(c))
|
|
139
140
|
return t;
|
|
140
141
|
}
|
|
141
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
142
|
+
return "querySelector" in t ? t.querySelector(`.${c}`) : null;
|
|
142
143
|
}
|
|
143
144
|
/**
|
|
144
145
|
* Migrate configuration from legacy format
|
|
145
146
|
*/
|
|
146
147
|
_migrateFromLegacy(t) {
|
|
147
|
-
|
|
148
|
+
s.migrateFromDataAttributes(this.api, t);
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
export {
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
B as BLOCK_ID,
|
|
153
|
+
y as RecommendationBlock
|
|
153
154
|
};
|