@useinsider/guido 3.19.0-beta.3303d1f → 3.19.0-beta.3abc7c5
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 +1 -0
- package/dist/@types/config/schemas.js +33 -31
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +50 -48
- package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
- package/dist/components/organisms/header/EditorActions.vue.js +5 -5
- package/dist/components/organisms/header/EditorActions.vue2.js +85 -55
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +48 -0
- package/dist/components/wrappers/WpDrawer.vue.js +9 -7
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/composables/useHtmlCompiler.js +37 -26
- package/dist/composables/useHtmlValidator.js +2 -0
- package/dist/composables/useSave.js +90 -45
- package/dist/composables/useSaveValidation.js +279 -0
- package/dist/composables/useSaveValidationRollout.js +9 -0
- package/dist/composables/validators/useCouponBlockValidator.js +24 -21
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
- package/dist/config/migrator/itemsBlockMigrator.js +248 -236
- package/dist/enums/save-validation.js +4 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +105 -114
- package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
- package/dist/extensions/Blocks/Items/template.js +204 -219
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +54 -47
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/save-validation.d.ts +19 -0
- package/dist/src/components/Guido.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useHtmlValidator.d.ts +21 -0
- package/dist/src/composables/useSave.d.ts +6 -1
- package/dist/src/composables/useSaveValidation.d.ts +6 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
- package/dist/src/enums/save-validation.d.ts +27 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
- package/dist/src/extensions/Blocks/Items/template.d.ts +0 -19
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
- package/dist/src/stores/config.d.ts +32 -0
- package/dist/src/stores/save-validation.d.ts +22 -0
- package/dist/src/utils/templatePreparation.d.ts +30 -0
- package/dist/stores/config.js +84 -67
- package/dist/stores/save-validation.js +30 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/templatePreparation.js +39 -36
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
|
@@ -1,84 +1,154 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var U = (o, t, r) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
|
|
3
|
+
var M = (o, t, r) => U(o, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { BLOCK_ID as w } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { productPairs as K } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { ItemInCartOptions as I, DefaultConfigValues as g, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as q } from "../../stores/template.js";
|
|
9
|
+
const x = {
|
|
10
|
+
img: {
|
|
11
|
+
pairsKey: "imageSrc",
|
|
12
|
+
defaultKey: "DEFAULT",
|
|
13
|
+
isArray: !0
|
|
14
|
+
},
|
|
15
|
+
name: {
|
|
16
|
+
pairsKey: "name",
|
|
17
|
+
defaultKey: "DEFAULT",
|
|
18
|
+
isArray: !0
|
|
19
|
+
},
|
|
20
|
+
url: {
|
|
21
|
+
pairsKey: "button",
|
|
22
|
+
defaultKey: "DEFAULT_HREF",
|
|
23
|
+
isArray: !1
|
|
24
|
+
},
|
|
25
|
+
formattedprice: {
|
|
26
|
+
pairsKey: "price",
|
|
27
|
+
defaultKey: "DEFAULT_PRICE_FORMATTED",
|
|
28
|
+
isArray: !1
|
|
29
|
+
},
|
|
30
|
+
productcurrency: {
|
|
31
|
+
pairsKey: "price",
|
|
32
|
+
defaultKey: "DEFAULT_CURRENCY",
|
|
33
|
+
isArray: !1
|
|
34
|
+
},
|
|
35
|
+
quantity: {
|
|
36
|
+
pairsKey: "quantity",
|
|
37
|
+
defaultKey: "DEFAULT",
|
|
38
|
+
isArray: !1
|
|
39
|
+
},
|
|
40
|
+
price: {
|
|
41
|
+
pairsKey: "price",
|
|
42
|
+
defaultKey: "DEFAULT_PRICE",
|
|
43
|
+
isArray: !1
|
|
44
|
+
},
|
|
45
|
+
originalprice: {
|
|
46
|
+
pairsKey: "originalPrice",
|
|
47
|
+
defaultKey: "DEFAULT_PRICE",
|
|
48
|
+
isArray: !1
|
|
49
|
+
},
|
|
50
|
+
originalformattedprice: {
|
|
51
|
+
pairsKey: "originalPrice",
|
|
52
|
+
defaultKey: "DEFAULT_PRICE_FORMATTED",
|
|
53
|
+
isArray: !1
|
|
54
|
+
},
|
|
55
|
+
single_price: {
|
|
56
|
+
pairsKey: "price",
|
|
57
|
+
defaultKey: "DEFAULT_SINGLE_PRICE",
|
|
58
|
+
isArray: !1
|
|
59
|
+
},
|
|
60
|
+
single_formattedprice: {
|
|
61
|
+
pairsKey: "price",
|
|
62
|
+
defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
|
|
63
|
+
isArray: !1
|
|
64
|
+
},
|
|
65
|
+
single_originalprice: {
|
|
66
|
+
pairsKey: "originalPrice",
|
|
67
|
+
defaultKey: "DEFAULT_SINGLE_PRICE",
|
|
68
|
+
isArray: !1
|
|
69
|
+
},
|
|
70
|
+
single_originalformattedprice: {
|
|
71
|
+
pairsKey: "originalPrice",
|
|
72
|
+
defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
|
|
73
|
+
isArray: !1
|
|
74
|
+
}
|
|
75
|
+
};
|
|
8
76
|
function O() {
|
|
9
77
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
10
78
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
13
|
-
CartItems:
|
|
14
|
-
BrowsedItems:
|
|
15
|
-
PurchasedItems:
|
|
16
|
-
CART_ITEMS:
|
|
17
|
-
BROWSED_ITEMS:
|
|
18
|
-
PURCHASED_ITEMS:
|
|
19
|
-
}[
|
|
79
|
+
function k(o) {
|
|
80
|
+
return o ? {
|
|
81
|
+
CartItems: p.ITEMS_TYPE.CART_ITEMS,
|
|
82
|
+
BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
83
|
+
PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
84
|
+
CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
|
|
85
|
+
BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
86
|
+
PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
|
|
87
|
+
}[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
|
|
20
88
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var o;
|
|
26
|
-
const t = (i, u) => i == null ? u : i === "1" || i === "true", e = (i, u) => i || u, a = c["data-type"] || c["data-source"], r = P(a), d = h[r];
|
|
27
|
-
let n = c["data-cart_items_select_control_value"] || ((o = d == null ? void 0 : d[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
|
|
89
|
+
function h(o) {
|
|
90
|
+
var e;
|
|
91
|
+
const t = (l, u) => l == null ? u : l === "1" || l === "true", r = (l, u) => l || u, c = o["data-type"] || o["data-source"], a = k(c), i = I[a];
|
|
92
|
+
let n = o["data-cart_items_select_control_value"] || ((e = i == null ? void 0 : i[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
|
|
28
93
|
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
29
|
-
const
|
|
30
|
-
u && u[
|
|
94
|
+
const l = parseInt(n) - 1, u = I[a];
|
|
95
|
+
u && u[l] && (n = u[l].value);
|
|
31
96
|
}
|
|
32
97
|
return {
|
|
33
98
|
initialized: !0,
|
|
34
|
-
blockInstanceId:
|
|
35
|
-
source:
|
|
36
|
-
type:
|
|
99
|
+
blockInstanceId: r(o["data-block-instance-id"], O()),
|
|
100
|
+
source: a,
|
|
101
|
+
type: a,
|
|
37
102
|
itemsSelectValue: n,
|
|
38
|
-
orientation:
|
|
39
|
-
nameTrimming: t(
|
|
40
|
-
priceHideDiscount: t(
|
|
41
|
-
priceFormatted: t(
|
|
42
|
-
priceSinglePrice: t(
|
|
43
|
-
priceCurrencySymbol:
|
|
44
|
-
|
|
45
|
-
|
|
103
|
+
orientation: o["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
|
|
104
|
+
nameTrimming: t(o["data-product_name_control_trim"], !0),
|
|
105
|
+
priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
|
|
106
|
+
priceFormatted: t(o["data-product_price_control_formated"], !0),
|
|
107
|
+
priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
|
|
108
|
+
priceCurrencySymbol: r(
|
|
109
|
+
o["data-product_price_control_currency_symbol"],
|
|
110
|
+
g.productPriceCurrencySymbolControlValue
|
|
46
111
|
),
|
|
47
|
-
priceCurrencyLocation:
|
|
48
|
-
|
|
49
|
-
|
|
112
|
+
priceCurrencyLocation: r(
|
|
113
|
+
o["data-product_price_currency_location"],
|
|
114
|
+
g.productPriceCurrencyLocationControlValue
|
|
50
115
|
),
|
|
51
|
-
priceOrientation:
|
|
52
|
-
quantityControlEnabled: t(
|
|
53
|
-
buttonLink:
|
|
54
|
-
imageLink:
|
|
55
|
-
buttonLabel:
|
|
56
|
-
buttonFullWidth: t(
|
|
57
|
-
imageVisible: t(
|
|
58
|
-
nameVisible: t(
|
|
59
|
-
quantityVisible: t(
|
|
60
|
-
priceVisible: t(
|
|
61
|
-
originalPriceVisible: t(
|
|
62
|
-
buttonVisible: t(
|
|
116
|
+
priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
|
|
117
|
+
quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
|
|
118
|
+
buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
|
|
119
|
+
imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
|
|
120
|
+
buttonLabel: r(o["data-product_button_control_label"], "Buy"),
|
|
121
|
+
buttonFullWidth: t(o["data-product_button_control_atw"], !0),
|
|
122
|
+
imageVisible: t(o["data-product_image_control_enabled"], !0),
|
|
123
|
+
nameVisible: t(o["data-product_name_control_enabled"], !0),
|
|
124
|
+
quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
|
|
125
|
+
priceVisible: t(o["data-product_price_control_enabled"], !0),
|
|
126
|
+
originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
|
|
127
|
+
buttonVisible: t(o["data-product_button_control_enabled"], !0)
|
|
63
128
|
};
|
|
64
129
|
}
|
|
65
|
-
|
|
66
|
-
|
|
130
|
+
const V = {
|
|
131
|
+
ins_apr: "CART_ITEMS",
|
|
132
|
+
browsed_item: "BROWSED_ITEMS",
|
|
133
|
+
purchased_item: "PURCHASED_ITEMS"
|
|
134
|
+
};
|
|
135
|
+
function $(o, t) {
|
|
136
|
+
const r = {
|
|
67
137
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
68
138
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
69
139
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
70
140
|
};
|
|
71
|
-
return
|
|
141
|
+
return r[o] || r.CART_ITEMS;
|
|
72
142
|
}
|
|
73
|
-
function
|
|
74
|
-
const
|
|
143
|
+
function N(o, t) {
|
|
144
|
+
const r = {
|
|
75
145
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
76
146
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
77
147
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
78
148
|
};
|
|
79
|
-
return
|
|
149
|
+
return r[o] || r.CART_ITEMS;
|
|
80
150
|
}
|
|
81
|
-
class
|
|
151
|
+
class H {
|
|
82
152
|
constructor() {
|
|
83
153
|
M(this, "parser");
|
|
84
154
|
this.parser = new DOMParser();
|
|
@@ -87,40 +157,42 @@ class F {
|
|
|
87
157
|
try {
|
|
88
158
|
if (!this.containsItemsBlock(t))
|
|
89
159
|
return this.backfillV2ProductTdAttributes(t);
|
|
90
|
-
|
|
160
|
+
let r = this.removeJinjaConditionals(t);
|
|
161
|
+
r = this.replaceTemplateVariables(r);
|
|
162
|
+
const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
|
|
91
163
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
92
164
|
);
|
|
93
|
-
return
|
|
94
|
-
n.migrations = { ...n.migrations, [
|
|
95
|
-
}),
|
|
96
|
-
const
|
|
97
|
-
orientation:
|
|
98
|
-
itemsType:
|
|
99
|
-
itemId:
|
|
100
|
-
currencySymbol:
|
|
101
|
-
currencyLocation:
|
|
102
|
-
formattedPrice:
|
|
103
|
-
configBlockAttributes:
|
|
165
|
+
return q().$patch((n) => {
|
|
166
|
+
n.migrations = { ...n.migrations, [w]: a.length };
|
|
167
|
+
}), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
|
|
168
|
+
const e = this.extractConfiguration(n), l = F({
|
|
169
|
+
orientation: e.orientation,
|
|
170
|
+
itemsType: e.itemsType,
|
|
171
|
+
itemId: e.itemId,
|
|
172
|
+
currencySymbol: e.currencySymbol,
|
|
173
|
+
currencyLocation: e.currencyLocation,
|
|
174
|
+
formattedPrice: e.formattedPrice,
|
|
175
|
+
configBlockAttributes: e.configBlockAttributes,
|
|
104
176
|
migrate: !0,
|
|
105
|
-
nameStyles:
|
|
106
|
-
buttonStyles:
|
|
107
|
-
priceStyles:
|
|
108
|
-
originalPriceStyles:
|
|
109
|
-
quantityStyles:
|
|
110
|
-
nodeConfig:
|
|
111
|
-
}),
|
|
112
|
-
`<table><tbody><tr>${
|
|
177
|
+
nameStyles: e.nameStyles,
|
|
178
|
+
buttonStyles: e.buttonStyles,
|
|
179
|
+
priceStyles: e.priceStyles,
|
|
180
|
+
originalPriceStyles: e.originalPriceStyles,
|
|
181
|
+
quantityStyles: e.quantityStyles,
|
|
182
|
+
nodeConfig: h(e.configBlockAttributes)
|
|
183
|
+
}), s = this.parser.parseFromString(
|
|
184
|
+
`<table><tbody><tr>${l}</tr></tbody></table>`,
|
|
113
185
|
"text/html"
|
|
114
186
|
).querySelector("td");
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
187
|
+
if (s && n.parentNode) {
|
|
188
|
+
const _ = h(e.configBlockAttributes);
|
|
189
|
+
s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
|
|
190
|
+
const d = s.querySelector("esd-config-block");
|
|
191
|
+
d && d.remove(), n.parentNode.replaceChild(s, n);
|
|
120
192
|
}
|
|
121
|
-
}),
|
|
122
|
-
} catch (
|
|
123
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
193
|
+
}), c.documentElement.outerHTML);
|
|
194
|
+
} catch (r) {
|
|
195
|
+
return console.error("ItemsBlockMigrator failed:", r), t;
|
|
124
196
|
}
|
|
125
197
|
}
|
|
126
198
|
/**
|
|
@@ -130,118 +202,28 @@ class F {
|
|
|
130
202
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
131
203
|
*/
|
|
132
204
|
extractConfiguration(t) {
|
|
133
|
-
var C;
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
),
|
|
137
|
-
|
|
138
|
-
|
|
205
|
+
var C, D, P;
|
|
206
|
+
const r = k(
|
|
207
|
+
((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
|
|
208
|
+
), c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(c) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), l = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, c), b = d["data-card_orientation_control_value"];
|
|
209
|
+
let S;
|
|
210
|
+
b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
211
|
+
const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
|
|
139
212
|
return {
|
|
140
213
|
orientation: S,
|
|
141
|
-
itemsType:
|
|
214
|
+
itemsType: r,
|
|
142
215
|
itemId: n,
|
|
143
|
-
currencySymbol:
|
|
144
|
-
currencyLocation:
|
|
145
|
-
formattedPrice:
|
|
146
|
-
configBlockAttributes:
|
|
147
|
-
nameStyles:
|
|
148
|
-
buttonStyles:
|
|
149
|
-
priceStyles:
|
|
150
|
-
originalPriceStyles:
|
|
216
|
+
currencySymbol: l,
|
|
217
|
+
currencyLocation: s,
|
|
218
|
+
formattedPrice: _,
|
|
219
|
+
configBlockAttributes: d,
|
|
220
|
+
nameStyles: A,
|
|
221
|
+
buttonStyles: m,
|
|
222
|
+
priceStyles: R,
|
|
223
|
+
originalPriceStyles: L,
|
|
151
224
|
quantityStyles: B
|
|
152
225
|
};
|
|
153
226
|
}
|
|
154
|
-
/**
|
|
155
|
-
* DOM fallback for hand-edited templates. The esd-config-block is authoritative only for
|
|
156
|
-
* the keys it ACTUALLY carries — every other key follows the live markup, whether the block
|
|
157
|
-
* was deleted outright or (far more common) survives carrying only a couple of `_opened`
|
|
158
|
-
* attributes. Without the per-key split, one such stub block shadows the whole DOM and the
|
|
159
|
-
* card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
|
|
160
|
-
*/
|
|
161
|
-
applyDomFallbacks(t, e) {
|
|
162
|
-
var S, y;
|
|
163
|
-
const a = t.querySelector("esd-config-block"), r = (...f) => !a || f.every((g) => !(a.getAttribute(g) ?? "").trim());
|
|
164
|
-
Object.entries({
|
|
165
|
-
image: '[product-attr="imageSrc"]',
|
|
166
|
-
name: '[product-attr="name"]',
|
|
167
|
-
price: '[product-attr="price"]',
|
|
168
|
-
original_price: '[product-attr="originalPrice"], p.original-price',
|
|
169
|
-
quantity: '[product-attr="quantity"]',
|
|
170
|
-
button: '[product-attr="button"]'
|
|
171
|
-
}).forEach(([f, g]) => {
|
|
172
|
-
const I = `data-product_${f}_control_enabled`;
|
|
173
|
-
r(I) && (e[I] = t.querySelector(g) ? "true" : "false");
|
|
174
|
-
}), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
|
|
175
|
-
const n = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (S = n == null ? void 0 : n.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
|
|
176
|
-
o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o);
|
|
177
|
-
const i = (n == null ? void 0 : n.getAttribute("style")) || "";
|
|
178
|
-
r("data-product_button_control_atw") && /display:\s*inline/.test(i) && !/(?:^|;)\s*width\s*:\s*100%/.test(i) && (e["data-product_button_control_atw"] = "false");
|
|
179
|
-
const u = t.querySelector('[product-attr="imageSrc"]'), l = u ? this.readImageSize(u) : null, s = (l == null ? void 0 : l.height) ?? (l == null ? void 0 : l.width), p = (l == null ? void 0 : l.width) ?? (l == null ? void 0 : l.height);
|
|
180
|
-
s && r("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = s), p && r("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = p), this.applyPriceDomFallbacks(t, e, r);
|
|
181
|
-
const T = ((y = t.querySelector('[product-attr="name"]')) == null ? void 0 : y.getAttribute("style")) || "";
|
|
182
|
-
r("data-product_name_control_trim") && /white-space:\s*normal/.test(T) && (e["data-product_name_control_trim"] = "0");
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Carries the price cell's own currency/format attributes into the config attributes when
|
|
186
|
-
* the config block omits them. extractConfiguration used to read the cell separately for the
|
|
187
|
-
* rendered markup while nodeConfig kept the defaults — so a ₺/after card migrated rendering
|
|
188
|
-
* ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
|
|
189
|
-
* the default back over the real value.
|
|
190
|
-
*/
|
|
191
|
-
applyPriceDomFallbacks(t, e, a) {
|
|
192
|
-
var u;
|
|
193
|
-
const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
|
|
194
|
-
if (!r)
|
|
195
|
-
return;
|
|
196
|
-
const d = (u = r.getAttribute("data-currency_symbol")) == null ? void 0 : u.trim();
|
|
197
|
-
d && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = d);
|
|
198
|
-
const n = r.getAttribute("data-curency");
|
|
199
|
-
if (n && a("data-product_price_currency_location", "data-product_price_control_curency")) {
|
|
200
|
-
const l = n === "after" ? "1" : "0";
|
|
201
|
-
e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
|
|
202
|
-
}
|
|
203
|
-
const o = r.getAttribute("data-formated");
|
|
204
|
-
o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
|
|
205
|
-
const i = r.getAttribute("data-single_price");
|
|
206
|
-
i && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
210
|
-
* Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
|
|
211
|
-
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
212
|
-
*/
|
|
213
|
-
readSelfOrDescendantAttribute(t, e) {
|
|
214
|
-
var a;
|
|
215
|
-
return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Reads the product image's pixel size — `width`/`height` attributes first, then px values
|
|
219
|
-
* in the inline style. An explicit `width`/`height` wins over `max-*`, which is only an
|
|
220
|
-
* upper bound; `max-*` still covers the common `width: 100%` case, where no pixel size can
|
|
221
|
-
* be read from the property itself. Each side is null when it carries no pixel size.
|
|
222
|
-
*/
|
|
223
|
-
readImageSize(t) {
|
|
224
|
-
return {
|
|
225
|
-
width: this.readImageDimension(t, "width"),
|
|
226
|
-
height: this.readImageDimension(t, "height")
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* One side of readImageSize. `width="0"` is not a size — authors who override the real
|
|
231
|
-
* dimensions in CSS zero out the attributes, and taking the 0 collapses the migrated image
|
|
232
|
-
* to nothing, so only a positive integer counts as an answer.
|
|
233
|
-
*/
|
|
234
|
-
readImageDimension(t, e) {
|
|
235
|
-
var u;
|
|
236
|
-
const a = (l) => {
|
|
237
|
-
const s = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = s ? Math.floor(parseFloat(s[1])) : 0;
|
|
238
|
-
return p > 0 ? String(p) : null;
|
|
239
|
-
}, r = a((u = t.getAttribute(e)) == null ? void 0 : u.trim());
|
|
240
|
-
if (r)
|
|
241
|
-
return r;
|
|
242
|
-
const d = t.getAttribute("style") || "", n = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), o = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = d.match(n) || d.match(o);
|
|
243
|
-
return a(i == null ? void 0 : i[1]);
|
|
244
|
-
}
|
|
245
227
|
/**
|
|
246
228
|
* Extracts all data-* attributes from the esd-config-block element
|
|
247
229
|
* Returns a key-value mapping of all configuration attributes
|
|
@@ -249,27 +231,27 @@ class F {
|
|
|
249
231
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
250
232
|
* @param itemNumber - The item number (1-based index)
|
|
251
233
|
*/
|
|
252
|
-
extractConfigBlockAttributes(t,
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
if (d["data-product_price_control_curency"]) {
|
|
265
|
-
const o = d["data-product_price_control_curency"];
|
|
266
|
-
let i = o;
|
|
267
|
-
o === "before" ? i = "0" : o === "after" && (i = "1"), d["data-product_price_control_curency"] = i, d["data-product_price_currency_location"] = i;
|
|
234
|
+
extractConfigBlockAttributes(t, r, c) {
|
|
235
|
+
const a = t.querySelector("esd-config-block"), i = {};
|
|
236
|
+
if (!a)
|
|
237
|
+
return this.getDefaultConfigBlockAttributes();
|
|
238
|
+
if (Array.from(a.attributes).forEach((e) => {
|
|
239
|
+
e.name.startsWith("data-") && (i[e.name] = e.value);
|
|
240
|
+
}), i["data-cart_items_select_control_value"]) {
|
|
241
|
+
const e = i["data-cart_items_select_control_value"];
|
|
242
|
+
if (/^\d+$/.test(e)) {
|
|
243
|
+
const l = parseInt(e) - 1, u = I[r];
|
|
244
|
+
u && u[l] && (i["data-cart_items_select_control_value"] = u[l].value);
|
|
268
245
|
}
|
|
269
|
-
(!d["data-product_price_control_currency_symbol"] || d["data-product_price_control_currency_symbol"].trim() === "") && (d["data-product_price_control_currency_symbol"] = "USD");
|
|
270
246
|
}
|
|
271
|
-
|
|
272
|
-
|
|
247
|
+
if (i["data-product_price_control_curency"]) {
|
|
248
|
+
const e = i["data-product_price_control_curency"];
|
|
249
|
+
let l = e;
|
|
250
|
+
e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
|
|
251
|
+
}
|
|
252
|
+
(!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
|
|
253
|
+
const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
254
|
+
return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, c), n["data-product_button_link"] = N(r, c), n;
|
|
273
255
|
}
|
|
274
256
|
/**
|
|
275
257
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -343,27 +325,25 @@ class F {
|
|
|
343
325
|
backfillV2ProductTdAttributes(t) {
|
|
344
326
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
345
327
|
return t;
|
|
346
|
-
const
|
|
347
|
-
let
|
|
348
|
-
return
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
const n = r.getAttribute("esd-ext-config");
|
|
353
|
-
let o = null;
|
|
328
|
+
const r = this.parser.parseFromString(t, "text/html");
|
|
329
|
+
let c = !1;
|
|
330
|
+
return r.querySelectorAll(".ins-product-td").forEach((a) => {
|
|
331
|
+
a.hasAttribute("width") && (a.removeAttribute("width"), c = !0);
|
|
332
|
+
const i = a.getAttribute("esd-ext-config");
|
|
333
|
+
let n = null;
|
|
354
334
|
try {
|
|
355
|
-
|
|
335
|
+
n = i ? JSON.parse(i) : null;
|
|
356
336
|
} catch {
|
|
357
337
|
}
|
|
358
|
-
if (!
|
|
338
|
+
if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
|
|
359
339
|
return;
|
|
360
|
-
const
|
|
361
|
-
if (!
|
|
340
|
+
const e = n.type || n.source;
|
|
341
|
+
if (!e)
|
|
362
342
|
return;
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
}),
|
|
343
|
+
a.setAttribute("data-type", e), c = !0;
|
|
344
|
+
const l = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
345
|
+
l && a.getAttribute("data-number") !== l[1] && a.setAttribute("data-number", l[1]);
|
|
346
|
+
}), c ? r.documentElement.outerHTML : t;
|
|
367
347
|
}
|
|
368
348
|
/**
|
|
369
349
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -384,22 +364,54 @@ class F {
|
|
|
384
364
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
385
365
|
*/
|
|
386
366
|
removeJinjaConditionals(t) {
|
|
387
|
-
const
|
|
388
|
-
let
|
|
389
|
-
return
|
|
367
|
+
const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
368
|
+
let a = c ? t.replace(c[0], r) : t;
|
|
369
|
+
return a = a.replace(
|
|
390
370
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
391
371
|
""
|
|
392
|
-
),
|
|
372
|
+
), a = a.replace(
|
|
393
373
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
394
374
|
""
|
|
395
|
-
),
|
|
375
|
+
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
|
|
396
376
|
|
|
397
|
-
`),
|
|
377
|
+
`), a;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Replaces template variables with default values from productPairs
|
|
381
|
+
* Supports all block types by detecting prefix and using appropriate type:
|
|
382
|
+
*
|
|
383
|
+
* Examples:
|
|
384
|
+
* - {{ins_apr_img_1}} → https://web-image.useinsider.com/.../img_1.jpeg (CART_ITEMS)
|
|
385
|
+
* - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
|
|
386
|
+
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
387
|
+
*/
|
|
388
|
+
replaceTemplateVariables(t) {
|
|
389
|
+
const { PAIRS_FOR_EXTENSION: r } = K;
|
|
390
|
+
return t.replace(/{{([^}]+)}}/g, (c, a) => {
|
|
391
|
+
const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
392
|
+
if (!i)
|
|
393
|
+
return c;
|
|
394
|
+
const [, n, e, l] = i, u = V[n];
|
|
395
|
+
if (!u)
|
|
396
|
+
return console.warn(`Unknown variable prefix: ${n}`), c;
|
|
397
|
+
const s = x[e];
|
|
398
|
+
if (!s)
|
|
399
|
+
return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
|
|
400
|
+
const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
|
|
401
|
+
if (!y)
|
|
402
|
+
return console.warn(`No data found for: ${_}.${u}`), c;
|
|
403
|
+
if (b) {
|
|
404
|
+
const f = parseInt(l) - 1, m = y[d];
|
|
405
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
|
|
406
|
+
}
|
|
407
|
+
const A = y[d];
|
|
408
|
+
return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
|
|
409
|
+
});
|
|
398
410
|
}
|
|
399
411
|
}
|
|
400
|
-
function
|
|
401
|
-
return new
|
|
412
|
+
function Q(o) {
|
|
413
|
+
return new H().migrate(o);
|
|
402
414
|
}
|
|
403
415
|
export {
|
|
404
|
-
|
|
416
|
+
Q as migrateItemsBlock
|
|
405
417
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s))(n || {});
|
|
2
|
+
export {
|
|
3
|
+
n as SaveValidationRule
|
|
4
|
+
};
|