@useinsider/guido 2.1.0-beta.bc18abc → 2.1.0-beta.da327fa
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/useActionsApi.js +15 -13
- package/dist/config/migrator/itemsBlockMigrator.js +140 -123
- package/dist/extensions/Blocks/Items/block.js +19 -28
- package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
- package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
- package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
- package/dist/extensions/Blocks/Items/extension.js +8 -9
- package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
- package/dist/extensions/Blocks/Items/template.js +181 -175
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +3 -3
- package/dist/extensions/Blocks/common-control.js +91 -92
- package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
- package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
- package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
- package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useToaster as w } from "./useToaster.js";
|
|
2
2
|
const v = () => {
|
|
3
|
-
const { handleError:
|
|
3
|
+
const { handleError: n } = w(), m = (t = {}) => new Promise((e, a) => {
|
|
4
4
|
const o = { ...{
|
|
5
5
|
minimize: !0,
|
|
6
6
|
utmEntity: {
|
|
@@ -21,9 +21,9 @@ const v = () => {
|
|
|
21
21
|
resetDataSavedFlag: !1,
|
|
22
22
|
disableLineHeightsReplace: !0
|
|
23
23
|
}, ...t }, s = {
|
|
24
|
-
callback: (
|
|
25
|
-
|
|
26
|
-
html:
|
|
24
|
+
callback: (l, r, d, c, u) => {
|
|
25
|
+
l ? a(l) : e({
|
|
26
|
+
html: r,
|
|
27
27
|
ampHtml: d,
|
|
28
28
|
ampErrors: c,
|
|
29
29
|
displayConditions: u
|
|
@@ -34,15 +34,15 @@ const v = () => {
|
|
|
34
34
|
window.StripoEditorApi.actionsApi.compileEmail(s);
|
|
35
35
|
});
|
|
36
36
|
return {
|
|
37
|
-
getCompiledEmail:
|
|
37
|
+
getCompiledEmail: m,
|
|
38
38
|
getTemplateData: () => new Promise((t) => {
|
|
39
|
-
const e = ({ html: a, css: i, width: o, height:
|
|
39
|
+
const e = ({ html: a, css: i, width: o, height: p, utmParams: s, syncModulesIds: l }) => t({
|
|
40
40
|
html: a,
|
|
41
41
|
css: i,
|
|
42
42
|
width: o,
|
|
43
|
-
height:
|
|
43
|
+
height: p,
|
|
44
44
|
utmParams: s,
|
|
45
|
-
syncModulesIds:
|
|
45
|
+
syncModulesIds: l
|
|
46
46
|
});
|
|
47
47
|
window.StripoEditorApi.actionsApi.getTemplateData(e);
|
|
48
48
|
}),
|
|
@@ -56,7 +56,7 @@ const v = () => {
|
|
|
56
56
|
displayConditions: a,
|
|
57
57
|
ampHtml: i = "",
|
|
58
58
|
ampErrors: o = []
|
|
59
|
-
} = await
|
|
59
|
+
} = await m({ minimize: !1, resetDataSavedFlag: !1, ...t });
|
|
60
60
|
return {
|
|
61
61
|
html: e,
|
|
62
62
|
ampHtml: i,
|
|
@@ -64,7 +64,7 @@ const v = () => {
|
|
|
64
64
|
displayConditions: a
|
|
65
65
|
};
|
|
66
66
|
} catch (e) {
|
|
67
|
-
return
|
|
67
|
+
return n(e, "Error loading preview"), {
|
|
68
68
|
html: "",
|
|
69
69
|
ampHtml: "",
|
|
70
70
|
ampErrors: [],
|
|
@@ -80,17 +80,19 @@ const v = () => {
|
|
|
80
80
|
}
|
|
81
81
|
try {
|
|
82
82
|
window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
|
|
83
|
-
i ? (
|
|
83
|
+
i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
|
|
84
84
|
});
|
|
85
85
|
} catch (i) {
|
|
86
|
-
|
|
86
|
+
n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
|
|
87
87
|
}
|
|
88
88
|
}),
|
|
89
89
|
updateHtmlAndCss: (t, e) => {
|
|
90
90
|
window.StripoEditorApi.actionsApi.updateHtmlAndCss(t, e);
|
|
91
91
|
},
|
|
92
92
|
editorSave: () => {
|
|
93
|
-
window.StripoEditorApi.actionsApi.save()
|
|
93
|
+
window.StripoEditorApi.actionsApi.save((t) => {
|
|
94
|
+
t && n(t, "Failed to save template");
|
|
95
|
+
});
|
|
94
96
|
}
|
|
95
97
|
};
|
|
96
98
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { productPairs as
|
|
5
|
-
import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var U = (r, t, e) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var M = (r, t, e) => U(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { productPairs as v } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
5
|
+
import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as d } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
|
|
7
7
|
const w = {
|
|
8
8
|
img: {
|
|
9
9
|
pairsKey: "imageSrc",
|
|
@@ -74,102 +74,118 @@ 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(r) {
|
|
78
|
+
return r ? {
|
|
79
|
+
CartItems: d.ITEMS_TYPE.CART_ITEMS,
|
|
80
|
+
BrowsedItems: d.ITEMS_TYPE.BROWSED_ITEMS,
|
|
81
|
+
PurchasedItems: d.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
82
|
+
CART_ITEMS: d.ITEMS_TYPE.CART_ITEMS,
|
|
83
|
+
BROWSED_ITEMS: d.ITEMS_TYPE.BROWSED_ITEMS,
|
|
84
|
+
PURCHASED_ITEMS: d.ITEMS_TYPE.PURCHASED_ITEMS
|
|
85
|
+
}[r] || d.ITEMS_TYPE.CART_ITEMS : d.ITEMS_TYPE.CART_ITEMS;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
const t = (
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
|
|
87
|
+
function R(r) {
|
|
88
|
+
const t = (a, o) => a == null ? o : a === "1" || a === "true", e = (a, o) => a || o, i = r["data-type"] || r["data-source"], l = q(i);
|
|
89
|
+
let n = r["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
|
|
90
|
+
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
91
|
+
const a = parseInt(n) - 1, o = E[l];
|
|
92
|
+
o && o[a] && (n = o[a].value);
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
95
|
initialized: !0,
|
|
96
|
-
blockInstanceId: r
|
|
97
|
-
source:
|
|
98
|
-
type:
|
|
99
|
-
itemsSelectValue:
|
|
100
|
-
orientation:
|
|
101
|
-
nameTrimming: t(
|
|
102
|
-
priceHideDiscount: t(
|
|
103
|
-
priceFormatted: t(
|
|
104
|
-
priceSinglePrice: t(
|
|
105
|
-
priceCurrencySymbol:
|
|
106
|
-
|
|
96
|
+
blockInstanceId: e(r["data-block-instance-id"], F()),
|
|
97
|
+
source: l,
|
|
98
|
+
type: l,
|
|
99
|
+
itemsSelectValue: n,
|
|
100
|
+
orientation: r["data-card_orientation_control_value"] || d.ORIENTATION.VERTICAL,
|
|
101
|
+
nameTrimming: t(r["data-product_name_control_trim"], !0),
|
|
102
|
+
priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
|
|
103
|
+
priceFormatted: t(r["data-product_price_control_formated"], !0),
|
|
104
|
+
priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
|
|
105
|
+
priceCurrencySymbol: e(
|
|
106
|
+
r["data-product_price_control_currency_symbol"],
|
|
107
107
|
g.productPriceCurrencySymbolControlValue
|
|
108
108
|
),
|
|
109
|
-
priceCurrencyLocation:
|
|
110
|
-
|
|
109
|
+
priceCurrencyLocation: e(
|
|
110
|
+
r["data-product_price_currency_location"],
|
|
111
111
|
g.productPriceCurrencyLocationControlValue
|
|
112
112
|
),
|
|
113
|
-
priceOrientation:
|
|
114
|
-
quantityControlEnabled: t(
|
|
115
|
-
buttonLink: r
|
|
116
|
-
imageLink: r
|
|
117
|
-
buttonLabel: r
|
|
118
|
-
buttonFullWidth: t(
|
|
119
|
-
imageVisible: t(
|
|
120
|
-
nameVisible: t(
|
|
121
|
-
quantityVisible: t(
|
|
122
|
-
priceVisible: t(
|
|
123
|
-
originalPriceVisible: t(
|
|
124
|
-
buttonVisible: t(
|
|
113
|
+
priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
|
|
114
|
+
quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
|
|
115
|
+
buttonLink: e(r["data-product_button_link"], g.productButtonLinkControlValue),
|
|
116
|
+
imageLink: e(r["data-product_image_link"], g.productImageLinkControlValue),
|
|
117
|
+
buttonLabel: e(r["data-product_button_control_label"], "Buy"),
|
|
118
|
+
buttonFullWidth: t(r["data-product_button_control_atw"], !0),
|
|
119
|
+
imageVisible: t(r["data-product_image_control_enabled"], !0),
|
|
120
|
+
nameVisible: t(r["data-product_name_control_enabled"], !0),
|
|
121
|
+
quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
|
|
122
|
+
priceVisible: t(r["data-product_price_control_enabled"], !0),
|
|
123
|
+
originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
|
|
124
|
+
buttonVisible: t(r["data-product_button_control_enabled"], !0)
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const $ = {
|
|
128
128
|
ins_apr: "CART_ITEMS",
|
|
129
129
|
browsed_item: "BROWSED_ITEMS",
|
|
130
130
|
purchased_item: "PURCHASED_ITEMS"
|
|
131
131
|
};
|
|
132
|
-
|
|
132
|
+
function x(r, t) {
|
|
133
|
+
const e = {
|
|
134
|
+
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
135
|
+
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
136
|
+
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
137
|
+
};
|
|
138
|
+
return e[r] || e.CART_ITEMS;
|
|
139
|
+
}
|
|
140
|
+
function O(r, t) {
|
|
141
|
+
const e = {
|
|
142
|
+
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
143
|
+
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
144
|
+
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
145
|
+
};
|
|
146
|
+
return e[r] || e.CART_ITEMS;
|
|
147
|
+
}
|
|
148
|
+
class V {
|
|
133
149
|
constructor() {
|
|
134
|
-
|
|
150
|
+
M(this, "parser");
|
|
135
151
|
this.parser = new DOMParser();
|
|
136
152
|
}
|
|
137
153
|
migrate(t) {
|
|
138
154
|
try {
|
|
139
|
-
let
|
|
140
|
-
|
|
141
|
-
const
|
|
155
|
+
let e = this.removeJinjaConditionals(t);
|
|
156
|
+
e = this.replaceTemplateVariables(e);
|
|
157
|
+
const i = this.parser.parseFromString(e, "text/html"), l = i.querySelectorAll(
|
|
142
158
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
143
159
|
);
|
|
144
|
-
return
|
|
145
|
-
const
|
|
146
|
-
orientation:
|
|
147
|
-
itemsType:
|
|
148
|
-
itemId:
|
|
149
|
-
currencySymbol:
|
|
150
|
-
currencyLocation:
|
|
151
|
-
formattedPrice:
|
|
152
|
-
configBlockAttributes:
|
|
160
|
+
return l.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (l.forEach((n) => {
|
|
161
|
+
const a = this.extractConfiguration(n), o = K({
|
|
162
|
+
orientation: a.orientation,
|
|
163
|
+
itemsType: a.itemsType,
|
|
164
|
+
itemId: a.itemId,
|
|
165
|
+
currencySymbol: a.currencySymbol,
|
|
166
|
+
currencyLocation: a.currencyLocation,
|
|
167
|
+
formattedPrice: a.formattedPrice,
|
|
168
|
+
configBlockAttributes: a.configBlockAttributes,
|
|
153
169
|
migrate: !0,
|
|
154
|
-
nameStyles:
|
|
155
|
-
buttonStyles:
|
|
156
|
-
priceStyles:
|
|
157
|
-
originalPriceStyles:
|
|
158
|
-
quantityStyles:
|
|
159
|
-
nodeConfig:
|
|
160
|
-
}),
|
|
161
|
-
`<table><tbody><tr>${
|
|
170
|
+
nameStyles: a.nameStyles,
|
|
171
|
+
buttonStyles: a.buttonStyles,
|
|
172
|
+
priceStyles: a.priceStyles,
|
|
173
|
+
originalPriceStyles: a.originalPriceStyles,
|
|
174
|
+
quantityStyles: a.quantityStyles,
|
|
175
|
+
nodeConfig: R(a.configBlockAttributes)
|
|
176
|
+
}), c = this.parser.parseFromString(
|
|
177
|
+
`<table><tbody><tr>${o}</tr></tbody></table>`,
|
|
162
178
|
"text/html"
|
|
163
179
|
).querySelector("td");
|
|
164
|
-
if (
|
|
165
|
-
const f =
|
|
166
|
-
|
|
167
|
-
const u =
|
|
168
|
-
u && u.remove(),
|
|
180
|
+
if (c && n.parentNode) {
|
|
181
|
+
const f = R(a.configBlockAttributes);
|
|
182
|
+
c.setAttribute("esd-ext-config", JSON.stringify(f));
|
|
183
|
+
const u = c.querySelector("esd-config-block");
|
|
184
|
+
u && u.remove(), n.parentNode.replaceChild(c, n);
|
|
169
185
|
}
|
|
170
|
-
}),
|
|
171
|
-
} catch (
|
|
172
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
186
|
+
}), i.documentElement.outerHTML);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
173
189
|
}
|
|
174
190
|
}
|
|
175
191
|
/**
|
|
@@ -180,23 +196,23 @@ class N {
|
|
|
180
196
|
*/
|
|
181
197
|
extractConfiguration(t) {
|
|
182
198
|
var C, D, P;
|
|
183
|
-
const
|
|
199
|
+
const e = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", i = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", l = parseInt(i) - 1, n = E[e], a = ((P = n == null ? void 0 : n[l]) == 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", u = (o == null ? void 0 : o.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, e, i), b = s["data-card_orientation_control_value"];
|
|
184
200
|
let S;
|
|
185
201
|
b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
186
|
-
const p = t.querySelector('a[product-attr="name"]'), T = (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,
|
|
202
|
+
const p = t.querySelector('a[product-attr="name"]'), T = (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, k = (o == null ? void 0 : o.getAttribute("style")) || void 0, I = t.querySelector("p.original-price"), h = (I == null ? void 0 : I.getAttribute("style")) || void 0, A = t.querySelector('[product-attr="quantity"]'), L = (A == null ? void 0 : A.getAttribute("style")) || void 0;
|
|
187
203
|
return {
|
|
188
204
|
orientation: S,
|
|
189
|
-
itemsType:
|
|
190
|
-
itemId:
|
|
191
|
-
currencySymbol:
|
|
205
|
+
itemsType: e,
|
|
206
|
+
itemId: a,
|
|
207
|
+
currencySymbol: _,
|
|
192
208
|
currencyLocation: f,
|
|
193
209
|
formattedPrice: u,
|
|
194
210
|
configBlockAttributes: s,
|
|
195
211
|
nameStyles: T,
|
|
196
212
|
buttonStyles: m,
|
|
197
|
-
priceStyles:
|
|
198
|
-
originalPriceStyles:
|
|
199
|
-
quantityStyles:
|
|
213
|
+
priceStyles: k,
|
|
214
|
+
originalPriceStyles: h,
|
|
215
|
+
quantityStyles: L
|
|
200
216
|
};
|
|
201
217
|
}
|
|
202
218
|
/**
|
|
@@ -204,28 +220,29 @@ class N {
|
|
|
204
220
|
* Returns a key-value mapping of all configuration attributes
|
|
205
221
|
* @param block - The block element containing the esd-config-block
|
|
206
222
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
223
|
+
* @param itemNumber - The item number (1-based index)
|
|
207
224
|
*/
|
|
208
|
-
extractConfigBlockAttributes(t,
|
|
209
|
-
const
|
|
210
|
-
if (!
|
|
225
|
+
extractConfigBlockAttributes(t, e, i) {
|
|
226
|
+
const l = t.querySelector("esd-config-block"), n = {};
|
|
227
|
+
if (!l)
|
|
211
228
|
return this.getDefaultConfigBlockAttributes();
|
|
212
|
-
if (Array.from(
|
|
213
|
-
|
|
229
|
+
if (Array.from(l.attributes).forEach((o) => {
|
|
230
|
+
o.name.startsWith("data-") && (n[o.name] = o.value);
|
|
214
231
|
}), n["data-cart_items_select_control_value"]) {
|
|
215
|
-
const
|
|
216
|
-
if (/^\d+$/.test(
|
|
217
|
-
const
|
|
218
|
-
|
|
232
|
+
const o = n["data-cart_items_select_control_value"];
|
|
233
|
+
if (/^\d+$/.test(o)) {
|
|
234
|
+
const _ = parseInt(o) - 1, c = E[e];
|
|
235
|
+
c && c[_] && (n["data-cart_items_select_control_value"] = c[_].value);
|
|
219
236
|
}
|
|
220
237
|
}
|
|
221
238
|
if (n["data-product_price_control_curency"]) {
|
|
222
|
-
const
|
|
223
|
-
let
|
|
224
|
-
|
|
239
|
+
const o = n["data-product_price_control_curency"];
|
|
240
|
+
let _ = o;
|
|
241
|
+
o === "before" ? _ = "0" : o === "after" && (_ = "1"), n["data-product_price_control_curency"] = _, n["data-product_price_currency_location"] = _;
|
|
225
242
|
}
|
|
226
|
-
(!n["data-
|
|
227
|
-
const
|
|
228
|
-
return
|
|
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
|
+
const a = { ...this.getDefaultConfigBlockAttributes(), ...n };
|
|
245
|
+
return a["data-type"] = e, a["data-source"] = e, a["data-product_image_link"] = x(e, i), a["data-product_button_link"] = O(e, i), a;
|
|
229
246
|
}
|
|
230
247
|
/**
|
|
231
248
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -254,7 +271,7 @@ class N {
|
|
|
254
271
|
"data-product_price_control_color": "#060606",
|
|
255
272
|
"data-product_price_control_curency": "0",
|
|
256
273
|
"data-product_price_currency_location": "0",
|
|
257
|
-
"data-
|
|
274
|
+
"data-product_price_control_currency_symbol": "USD",
|
|
258
275
|
"data-product_price_control_formated": "1",
|
|
259
276
|
"data-product_price_control_nodup": "1",
|
|
260
277
|
"data-product_price_control_single_price": "false",
|
|
@@ -282,16 +299,16 @@ class N {
|
|
|
282
299
|
* - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
|
|
283
300
|
*/
|
|
284
301
|
removeJinjaConditionals(t) {
|
|
285
|
-
let
|
|
302
|
+
let e = t.replace(
|
|
286
303
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
287
304
|
""
|
|
288
305
|
);
|
|
289
|
-
return
|
|
306
|
+
return e = e.replace(
|
|
290
307
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
291
308
|
""
|
|
292
|
-
),
|
|
309
|
+
), e = e.replace(/\{%\s*endif\s*%\}/g, ""), e = e.replace(/\n\s*\n\s*\n/g, `
|
|
293
310
|
|
|
294
|
-
`),
|
|
311
|
+
`), e;
|
|
295
312
|
}
|
|
296
313
|
/**
|
|
297
314
|
* Replaces template variables with default values from productPairs
|
|
@@ -303,32 +320,32 @@ class N {
|
|
|
303
320
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
304
321
|
*/
|
|
305
322
|
replaceTemplateVariables(t) {
|
|
306
|
-
const { PAIRS_FOR_EXTENSION:
|
|
307
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
308
|
-
const
|
|
309
|
-
if (!
|
|
310
|
-
return
|
|
311
|
-
const [,
|
|
312
|
-
if (!
|
|
313
|
-
return console.warn(`Unknown variable prefix: ${
|
|
314
|
-
const f = w[
|
|
323
|
+
const { PAIRS_FOR_EXTENSION: e } = v;
|
|
324
|
+
return t.replace(/{{([^}]+)}}/g, (i, l) => {
|
|
325
|
+
const n = l.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
326
|
+
if (!n)
|
|
327
|
+
return i;
|
|
328
|
+
const [, a, o, _] = n, c = $[a];
|
|
329
|
+
if (!c)
|
|
330
|
+
return console.warn(`Unknown variable prefix: ${a}`), i;
|
|
331
|
+
const f = w[o];
|
|
315
332
|
if (!f)
|
|
316
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
317
|
-
const { pairsKey: u, defaultKey: s, isArray: b } = f, p =
|
|
333
|
+
return console.warn(`Unknown variable suffix mapping for: ${o}`), i;
|
|
334
|
+
const { pairsKey: u, defaultKey: s, isArray: b } = f, p = e[u][c];
|
|
318
335
|
if (!p)
|
|
319
|
-
return console.warn(`No data found for: ${u}.${
|
|
336
|
+
return console.warn(`No data found for: ${u}.${c}`), i;
|
|
320
337
|
if (b) {
|
|
321
|
-
const y = parseInt(
|
|
322
|
-
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${
|
|
338
|
+
const y = parseInt(_) - 1, m = p[s];
|
|
339
|
+
return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${c}.${s}[${y}]`), i);
|
|
323
340
|
}
|
|
324
341
|
const T = p[s];
|
|
325
|
-
return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${
|
|
342
|
+
return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${c}.${s}`), i);
|
|
326
343
|
});
|
|
327
344
|
}
|
|
328
345
|
}
|
|
329
|
-
function
|
|
330
|
-
return new
|
|
346
|
+
function G(r) {
|
|
347
|
+
return new V().migrate(r);
|
|
331
348
|
}
|
|
332
349
|
export {
|
|
333
|
-
|
|
350
|
+
G as migrateItemsBlock
|
|
334
351
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { useOnboardingStore as
|
|
2
|
-
import { Block as
|
|
3
|
-
import { SETTINGS_ENUMS as c, DefaultConfigValues as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { getItemsBlockContainer as g, getItemsBlockConfig as a, getDefaultItemsBlockConfig as C } from "./utils/nodeConfigUtils.js";
|
|
1
|
+
import { useOnboardingStore as d } from "../../../stores/onboarding.js";
|
|
2
|
+
import { Block as g, BlockCompositionType as f, ModificationDescription as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
3
|
+
import { SETTINGS_ENUMS as c, DefaultConfigValues as i } from "./enums/settingsEnums.js";
|
|
4
|
+
import { getDefaultTemplate as p } from "./template.js";
|
|
5
|
+
import { getItemsBlockContainer as u, getItemsBlockConfig as C, getDefaultItemsBlockConfig as I } from "./utils/nodeConfigUtils.js";
|
|
7
6
|
const y = "items-block";
|
|
8
|
-
class B extends
|
|
7
|
+
class B extends g {
|
|
9
8
|
getId() {
|
|
10
9
|
return y;
|
|
11
10
|
}
|
|
@@ -13,7 +12,7 @@ class B extends u {
|
|
|
13
12
|
return "items-icon";
|
|
14
13
|
}
|
|
15
14
|
getBlockCompositionType() {
|
|
16
|
-
return
|
|
15
|
+
return f.CONTAINER;
|
|
17
16
|
}
|
|
18
17
|
getName() {
|
|
19
18
|
return this.api.translate("Items");
|
|
@@ -22,40 +21,32 @@ class B extends u {
|
|
|
22
21
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
23
22
|
}
|
|
24
23
|
getTemplate() {
|
|
25
|
-
return
|
|
24
|
+
return p({
|
|
26
25
|
orientation: c.ORIENTATION.VERTICAL,
|
|
27
26
|
itemsType: c.ITEMS_TYPE.CART_ITEMS,
|
|
28
27
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
29
|
-
currencySymbol:
|
|
30
|
-
currencyLocation:
|
|
31
|
-
formattedPrice:
|
|
28
|
+
currencySymbol: i.productPriceCurrencySymbolControlValue,
|
|
29
|
+
currencyLocation: i.productPriceCurrencyLocationControlValue,
|
|
30
|
+
formattedPrice: i.productPriceFormattedControlValue === "1"
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
allowInnerBlocksDND() {
|
|
35
34
|
return !1;
|
|
36
35
|
}
|
|
37
36
|
onCreated(n) {
|
|
38
|
-
const
|
|
37
|
+
const s = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
|
|
38
|
+
r.querySelector('[product-attr="imageSrc"] img') || s.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
39
|
+
const e = u(n);
|
|
39
40
|
if (!e)
|
|
40
41
|
return;
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
l ?
|
|
42
|
+
const a = e.getNodeConfig(), l = a && Object.keys(a).length > 0, t = C(n);
|
|
43
|
+
if (t != null && t.initialized)
|
|
44
|
+
l ? 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"));
|
|
44
45
|
else {
|
|
45
|
-
const
|
|
46
|
-
this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(
|
|
46
|
+
const m = I();
|
|
47
|
+
this.api.getDocumentModifier().modifyHtml(e).setNodeConfig(m).apply(new o("Initialize Items block with default configuration")), d().startOnboarding("itemsOnboarding");
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
onSelect(n) {
|
|
50
|
-
const e = p(), t = a(n);
|
|
51
|
-
t && (e.setItemsType(t.type || o.itemsType), e.setItemIds(t.itemsSelectValue || o.cartItemsSelectControlValue), e.setOrientation(t.orientation || o.cardOrientationControlValue), e.setCurrencySymbol(
|
|
52
|
-
t.priceCurrencySymbol || o.productPriceCurrencySymbolControlValue
|
|
53
|
-
), e.setCurrencyLocation(
|
|
54
|
-
t.priceCurrencyLocation || o.productPriceCurrencyLocationControlValue
|
|
55
|
-
), e.setFormattedPrice(
|
|
56
|
-
t.priceFormatted ?? o.productPriceFormattedControlValue === "1"
|
|
57
|
-
));
|
|
58
|
-
}
|
|
59
50
|
}
|
|
60
51
|
export {
|
|
61
52
|
y as BLOCK_ID,
|
|
@@ -1,52 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { ItemsBlockControlId as d } from "../../enums/controlEnums.js";
|
|
6
|
-
import { useItemsBlockStore as m } from "../../store/items-block.js";
|
|
7
|
-
import { getItemsBlockConfig as L } from "../../utils/nodeConfigUtils.js";
|
|
8
|
-
const r = d.BUTTON_LINK, s = {
|
|
1
|
+
import { CommonControl as r } from "../../../common-control.js";
|
|
2
|
+
import { ItemsBlockControlId as i } from "../../enums/controlEnums.js";
|
|
3
|
+
import { getItemsBlockConfig as o } from "../../utils/nodeConfigUtils.js";
|
|
4
|
+
const s = i.BUTTON_LINK, n = {
|
|
9
5
|
LINK: "link"
|
|
10
6
|
};
|
|
11
|
-
class
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments);
|
|
14
|
-
i(this, "store", m());
|
|
15
|
-
}
|
|
7
|
+
class m extends r {
|
|
16
8
|
getId() {
|
|
17
|
-
return
|
|
9
|
+
return s;
|
|
18
10
|
}
|
|
19
11
|
getTemplate() {
|
|
20
12
|
return `
|
|
21
|
-
<div class="container ${
|
|
13
|
+
<div class="container ${s}">
|
|
22
14
|
${this._getLink()}
|
|
23
15
|
</div>
|
|
24
16
|
`;
|
|
25
17
|
}
|
|
26
18
|
onRender() {
|
|
19
|
+
const t = o(this.currentNode);
|
|
27
20
|
this.api.updateValues({
|
|
28
|
-
[
|
|
21
|
+
[n.LINK]: (t == null ? void 0 : t.buttonLink) ?? ""
|
|
29
22
|
});
|
|
30
23
|
}
|
|
31
|
-
onTemplateNodeUpdated(
|
|
32
|
-
super.onTemplateNodeUpdated(
|
|
33
|
-
()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
this.api.updateValues({
|
|
39
|
-
[s.LINK]: this.store.buttonLink
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
);
|
|
24
|
+
onTemplateNodeUpdated(t) {
|
|
25
|
+
super.onTemplateNodeUpdated(t), this.handleBlockInstanceChange(() => {
|
|
26
|
+
const e = o(this.currentNode);
|
|
27
|
+
this.api.updateValues({
|
|
28
|
+
[n.LINK]: (e == null ? void 0 : e.buttonLink) ?? ""
|
|
29
|
+
});
|
|
30
|
+
});
|
|
43
31
|
}
|
|
44
32
|
_getLink() {
|
|
45
33
|
return `
|
|
46
34
|
${this._GuOneColumn([
|
|
47
35
|
this._GuLabel({ text: "Link" }),
|
|
48
36
|
this._GuTextInput({
|
|
49
|
-
name:
|
|
37
|
+
name: n.LINK,
|
|
50
38
|
placeholder: "Enter Link",
|
|
51
39
|
className: "es-100",
|
|
52
40
|
disabled: !0
|
|
@@ -56,6 +44,6 @@ class N extends u {
|
|
|
56
44
|
}
|
|
57
45
|
}
|
|
58
46
|
export {
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
m as ButtonLinkControl,
|
|
48
|
+
s as CONTROL_BLOCK_ID
|
|
61
49
|
};
|