@useinsider/guido 3.23.0-beta.9f6bfbf → 3.23.0-beta.a35efcf
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 +9 -1
- package/dist/@types/config/schemas.js +26 -26
- package/dist/components/Guido.vue.js +5 -5
- package/dist/components/Guido.vue2.js +88 -86
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
- package/dist/composables/useModuleRepair.js +30 -23
- package/dist/config/migrator/index.js +16 -16
- package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
- package/dist/enums/academy.js +2 -1
- package/dist/extensions/Blocks/Items/block.js +77 -115
- package/dist/extensions/Blocks/Items/constants/currency.js +14 -59
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +22 -33
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +51 -62
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +17 -18
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +31 -42
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +120 -141
- package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
- package/dist/extensions/Blocks/Items/extension.js +8 -9
- package/dist/extensions/Blocks/Items/items.css.js +0 -19
- package/dist/extensions/Blocks/Items/settingsPanel.js +25 -34
- package/dist/extensions/Blocks/Items/template.js +212 -250
- package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -1
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/src/@types/config/schemas.d.ts +4 -4
- package/dist/src/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +2 -2
- package/dist/src/composables/useModuleRepair.d.ts +2 -11
- package/dist/src/config/migrator/index.d.ts +1 -4
- package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +9 -6
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -32
- package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/template.d.ts +1 -4
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -12
- package/dist/src/stores/config.d.ts +20 -20
- package/dist/src/stores/editor.d.ts +25 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +1 -5
- package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
- package/dist/static/stripo-runtime-manifest.json.js +1 -1
- package/dist/stores/editor.js +15 -14
- package/dist/utils/itemsCurrencyRepair.js +24 -29
- package/dist/utils/legacyUnsubscribeConversion.js +49 -0
- package/dist/utils/pairProductVariables.js +99 -119
- package/package.json +2 -2
- package/dist/config/migrator/itemsPriceFormatMigrator.js +0 -20
- package/dist/extensions/Blocks/Items/controls/priceFormat.js +0 -145
- package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +0 -185
- package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +0 -1
- package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +0 -23
- package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +0 -61
|
@@ -1,128 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { productPairs as
|
|
3
|
-
import { escapeReplacement as
|
|
4
|
-
import { preserveTextStyles as
|
|
1
|
+
import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
|
+
import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
|
+
import { preserveTextStyles as L } from "./preserveTextStyles.js";
|
|
5
5
|
import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
|
|
6
6
|
const q = {
|
|
7
7
|
CART_ITEMS: "ins_apr",
|
|
8
8
|
BROWSED_ITEMS: "browsed_item",
|
|
9
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
-
}, W = (
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
for (;
|
|
14
|
-
|
|
15
|
-
return
|
|
10
|
+
}, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v($, C, A) {
|
|
12
|
+
let d = C;
|
|
13
|
+
for (; d > 0 && /\s/.test($[d - 1]); )
|
|
14
|
+
d -= 1;
|
|
15
|
+
return A.some((E) => $.endsWith(E, d));
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
19
|
-
var
|
|
20
|
-
const
|
|
21
|
-
for (let
|
|
22
|
-
(
|
|
17
|
+
const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
18
|
+
function Q($, C) {
|
|
19
|
+
var d;
|
|
20
|
+
const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
|
|
21
|
+
for (let E = A.nextNode(); E; E = A.nextNode())
|
|
22
|
+
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(j, (k, P) => `${P}href="${C}"`));
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
isFormatted: !1,
|
|
35
|
-
isSinglePrice: r.getAttribute(N.SINGLE_PRICE) === "true",
|
|
36
|
-
currencyPosition: Y(
|
|
37
|
-
r.getAttribute(N.ALIGNMENT) ?? void 0
|
|
38
|
-
),
|
|
39
|
-
configuredSymbol: (r.getAttribute(N.SYMBOL) || "").trim()
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function Z(r, h, p) {
|
|
43
|
-
const { isFormatted: u, isSinglePrice: A, currencyPosition: L, configuredSymbol: P } = p;
|
|
44
|
-
let y;
|
|
45
|
-
A ? y = u ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = u ? r.PRICE_FORMATTED : r.PRICE;
|
|
46
|
-
const E = r.CURRENCY;
|
|
47
|
-
let F = `{{${y}_${h}}}`, R = "";
|
|
48
|
-
return B(P) ? R = P : E && (R = `{{${E}_${h}}}`), R && (F = L === "after" ? `${F} ${R}` : `${R} ${F}`), F;
|
|
49
|
-
}
|
|
50
|
-
function ct(r) {
|
|
51
|
-
const h = W(r), p = new DOMParser().parseFromString(h, "text/html");
|
|
52
|
-
X(p);
|
|
53
|
-
const u = k.PAIRS_FOR_EXTENSION;
|
|
54
|
-
Object.entries(u).forEach(([o, T]) => {
|
|
55
|
-
p.querySelectorAll(".ins-product-td").forEach((n) => {
|
|
56
|
-
const S = n.getAttribute("data-number") || "1", I = n.getAttribute("data-type") || "CART_ITEMS";
|
|
57
|
-
n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
58
|
-
var b, M, D, x;
|
|
59
|
-
const m = t.getAttribute("data-type") || I, c = t.getAttribute("data-number") || S, f = T[m];
|
|
24
|
+
function et($) {
|
|
25
|
+
const C = W($), A = new DOMParser().parseFromString(C, "text/html");
|
|
26
|
+
X(A);
|
|
27
|
+
const d = M.PAIRS_FOR_EXTENSION;
|
|
28
|
+
Object.entries(d).forEach(([o, p]) => {
|
|
29
|
+
A.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
30
|
+
const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
|
|
31
|
+
r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
32
|
+
var S, I, O, x;
|
|
33
|
+
const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
|
|
60
34
|
if (f)
|
|
61
35
|
switch (o) {
|
|
62
36
|
case "imageSrc": {
|
|
63
|
-
let e = null,
|
|
64
|
-
if (t.tagName === "IMG" ? (e = t,
|
|
37
|
+
let e = null, s = null;
|
|
38
|
+
if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
|
|
65
39
|
break;
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
return
|
|
72
|
-
}) && (e.src = `{{${
|
|
40
|
+
const l = f.DEFAULT, c = f.ATTR;
|
|
41
|
+
if (l && e.src) {
|
|
42
|
+
const a = e.src;
|
|
43
|
+
l.some((g) => {
|
|
44
|
+
const u = g.split("/").pop() || "", H = a.split("/").pop() || "";
|
|
45
|
+
return a.includes(g) || a.includes(u) || H === u;
|
|
46
|
+
}) && (e.src = `{{${c}_${n}}}`);
|
|
73
47
|
}
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
79
|
-
(
|
|
48
|
+
const i = (I = (S = d.name) == null ? void 0 : S[m]) == null ? void 0 : I.ATTR;
|
|
49
|
+
if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
|
|
50
|
+
const a = (O = d.itemLink) == null ? void 0 : O[m];
|
|
51
|
+
if (a) {
|
|
52
|
+
const b = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
|
|
53
|
+
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${b}_${n}}}`);
|
|
80
54
|
}
|
|
81
55
|
}
|
|
82
56
|
break;
|
|
83
57
|
}
|
|
84
58
|
case "name": {
|
|
85
|
-
const e = f,
|
|
86
|
-
t.textContent && (t.innerHTML =
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
(
|
|
59
|
+
const e = f, s = e.ATTR, l = e.DEFAULT_HREF || "#!", c = e.HREF;
|
|
60
|
+
t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
61
|
+
const i = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
62
|
+
if (i && c) {
|
|
63
|
+
const a = i.href, b = `${window.location.href}${l}`;
|
|
64
|
+
(a === b || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
|
|
91
65
|
}
|
|
92
66
|
break;
|
|
93
67
|
}
|
|
94
68
|
case "price":
|
|
95
69
|
case "originalPrice": {
|
|
96
|
-
const e = f,
|
|
97
|
-
|
|
70
|
+
const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
|
|
71
|
+
let b;
|
|
72
|
+
i ? b = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : b = c ? e.PRICE_FORMATTED : e.PRICE;
|
|
73
|
+
const g = e.CURRENCY;
|
|
74
|
+
let u = `{{${b}_${n}}}`;
|
|
75
|
+
const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
|
|
76
|
+
let F = "";
|
|
77
|
+
G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
|
|
98
78
|
break;
|
|
99
79
|
}
|
|
100
80
|
case "quantity": {
|
|
101
|
-
const e = f,
|
|
102
|
-
|
|
81
|
+
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (x = t.textContent) == null ? void 0 : x.trim();
|
|
82
|
+
c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
103
83
|
break;
|
|
104
84
|
}
|
|
105
85
|
case "button": {
|
|
106
|
-
const e = f,
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
(
|
|
86
|
+
const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t.tagName === "A" ? t : t.querySelector("a");
|
|
87
|
+
if (c) {
|
|
88
|
+
const i = c.href || "", a = `${window.location.href}${l}`;
|
|
89
|
+
(i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
|
|
110
90
|
}
|
|
111
|
-
|
|
91
|
+
Q(t, `{{${s}_${n}}}`);
|
|
112
92
|
break;
|
|
113
93
|
}
|
|
114
94
|
case "itemLink": {
|
|
115
|
-
const e = f,
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
118
|
-
(
|
|
95
|
+
const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t;
|
|
96
|
+
if (c.href) {
|
|
97
|
+
const i = c.href, a = `${window.location.href}${l}`;
|
|
98
|
+
(i === a || i.endsWith(l)) && (c.href = `{{${s}_${n}}}`);
|
|
119
99
|
}
|
|
120
100
|
break;
|
|
121
101
|
}
|
|
122
102
|
default: {
|
|
123
103
|
if ("ATTR" in f) {
|
|
124
104
|
const e = f.ATTR;
|
|
125
|
-
t.textContent && (t.innerHTML =
|
|
105
|
+
t.textContent && (t.innerHTML = L(t, `{{${e}_${n}}}`));
|
|
126
106
|
}
|
|
127
107
|
break;
|
|
128
108
|
}
|
|
@@ -130,49 +110,49 @@ function ct(r) {
|
|
|
130
110
|
});
|
|
131
111
|
});
|
|
132
112
|
});
|
|
133
|
-
const
|
|
134
|
-
` : "", P =
|
|
113
|
+
const E = C.match(/<!DOCTYPE[^>]*>/i), k = E ? `${E[0]}
|
|
114
|
+
` : "", P = A.querySelectorAll(".ins-product-td"), N = [];
|
|
135
115
|
P.forEach((o) => {
|
|
136
|
-
const
|
|
137
|
-
|
|
116
|
+
const p = o.getAttribute("data-type") || "CART_ITEMS", T = o.getAttribute("data-number") || "1", r = o.outerHTML;
|
|
117
|
+
N.push({
|
|
138
118
|
element: o,
|
|
139
|
-
outerHtml:
|
|
140
|
-
type:
|
|
141
|
-
number:
|
|
119
|
+
outerHtml: r,
|
|
120
|
+
type: p,
|
|
121
|
+
number: T
|
|
142
122
|
});
|
|
143
123
|
});
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
const
|
|
149
|
-
|
|
124
|
+
let h = k + A.documentElement.outerHTML;
|
|
125
|
+
N.reverse().forEach(({ outerHtml: o, type: p, number: T }) => {
|
|
126
|
+
const r = q[p], _ = r ? `${r}_total_product_kind` : "";
|
|
127
|
+
if (_) {
|
|
128
|
+
const R = parseInt(T) - 1, n = `${`{% if ${_} > ${R} %}`}${o}{% endif %}`;
|
|
129
|
+
h = h.replace(o, B(n));
|
|
150
130
|
}
|
|
151
131
|
});
|
|
152
|
-
const
|
|
153
|
-
return
|
|
132
|
+
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set();
|
|
133
|
+
return V.forEach((o) => {
|
|
154
134
|
var t;
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
135
|
+
const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
|
|
136
|
+
if (!p || !q[T])
|
|
157
137
|
return;
|
|
158
|
-
const
|
|
159
|
-
if (!
|
|
138
|
+
const r = o.closest(".product-original-price-class");
|
|
139
|
+
if (!r || D.has(r))
|
|
160
140
|
return;
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
}),
|
|
165
|
-
if (
|
|
141
|
+
D.add(r);
|
|
142
|
+
const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
|
|
143
|
+
R.wrap.push(y !== "false"), w.set(_, R);
|
|
144
|
+
}), w.forEach(({ number: o, type: p, wrap: T }, r) => {
|
|
145
|
+
if (r.includes("{% if") || !T.some(Boolean))
|
|
166
146
|
return;
|
|
167
|
-
const
|
|
168
|
-
let m = "",
|
|
169
|
-
for (;
|
|
170
|
-
const
|
|
171
|
-
m +=
|
|
147
|
+
const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
|
|
148
|
+
let m = "", n = 0, f = 0, S = h.indexOf(r);
|
|
149
|
+
for (; S !== -1; ) {
|
|
150
|
+
const I = T[f] === !0 && !v(h, S, t);
|
|
151
|
+
m += h.slice(n, S) + (I ? `${R}${r}{% endif %}` : r), n = S + r.length, f += 1, S = h.indexOf(r, n);
|
|
172
152
|
}
|
|
173
|
-
|
|
174
|
-
}),
|
|
153
|
+
h = m + h.slice(n);
|
|
154
|
+
}), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
175
155
|
}
|
|
176
156
|
export {
|
|
177
|
-
|
|
157
|
+
et as pairProductVariables
|
|
178
158
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.23.0-beta.
|
|
3
|
+
"version": "3.23.0-beta.a35efcf",
|
|
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",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
},
|
|
129
129
|
"guido": {
|
|
130
130
|
"stripo": {
|
|
131
|
-
"version": "2.
|
|
131
|
+
"version": "2.83.1"
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ITEMS_PRICE_FORMAT_ATTR as e } from "../../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
-
import { applyPriceFormatOpsToElement as o, planPriceFormatOps as n, snapshotPriceFormatFromElement as c } from "../../extensions/Blocks/Items/utils/priceFormatOps.js";
|
|
3
|
-
import { protectLiquid as i, restoreLiquid as s } from "../../utils/liquidProtection.js";
|
|
4
|
-
const m = `td.ins-product-td.items-block-v2:not([${e.DECIMAL_COUNT}])`, a = (r) => o(
|
|
5
|
-
r,
|
|
6
|
-
n(c(r), { convertLegacy: !0 })
|
|
7
|
-
);
|
|
8
|
-
function T(r) {
|
|
9
|
-
if (typeof r != "string" || !r.includes("ins-product-td"))
|
|
10
|
-
return r;
|
|
11
|
-
try {
|
|
12
|
-
const t = new DOMParser().parseFromString(i(r), "text/html");
|
|
13
|
-
return Array.from(t.querySelectorAll(m)).map(a).includes(!0) ? s(t.documentElement.outerHTML) : r;
|
|
14
|
-
} catch (t) {
|
|
15
|
-
return console.error("ItemsPriceFormatMigrator failed:", t), r;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
T as migrateItemsPriceFormat
|
|
20
|
-
};
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
var f = Object.defineProperty;
|
|
2
|
-
var P = (o, i, t) => i in o ? f(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
|
|
3
|
-
var E = (o, i, t) => P(o, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
-
import { currencyOperators as m, currencyDecimalCounts as _ } from "../../../../enums/extensions/recommendationBlock.js";
|
|
5
|
-
import { UEAttr as d, ModificationDescription as L } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
-
import { CommonControl as N } from "../../common-control.js";
|
|
7
|
-
import { priceFormatFromConfig as T, normalizeDecimalCount as U, isNewPriceFormatRoot as M } from "../constants/currency.js";
|
|
8
|
-
import { ItemsBlockControlId as I, ItemsBlockId as R } from "../enums/controlEnums.js";
|
|
9
|
-
import { getItemsBlockConfig as h, getItemsBlockContainer as g, setItemsBlockConfig as F } from "../utils/nodeConfigUtils.js";
|
|
10
|
-
import { planPriceFormatOps as w, buildPriceFormatSnapshot as b, priceTextsFromConfig as x, samePriceText as y, replacePriceText as k } from "../utils/priceFormatOps.js";
|
|
11
|
-
const B = I.PRICE_FORMAT, a = {
|
|
12
|
-
THOUSAND_SEPARATOR: "priceThousandSeparator",
|
|
13
|
-
DECIMAL_SEPARATOR: "priceDecimalSeparator",
|
|
14
|
-
DECIMAL_COUNT: "priceDecimalCount"
|
|
15
|
-
}, H = [
|
|
16
|
-
["price", R.PRICE],
|
|
17
|
-
["originalPrice", R.ORIGINAL_PRICE]
|
|
18
|
-
];
|
|
19
|
-
function V(o) {
|
|
20
|
-
return H.flatMap(([i, t]) => o.querySelectorAll(
|
|
21
|
-
`[esd-extension-block-id="${t}"]`
|
|
22
|
-
).flatMap((r) => {
|
|
23
|
-
const c = r.querySelector("p");
|
|
24
|
-
return c ? [{ kind: i, paragraph: c }] : [];
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
function Q(o) {
|
|
28
|
-
return M(g(o));
|
|
29
|
-
}
|
|
30
|
-
function K(o, i, t, e) {
|
|
31
|
-
const r = g(o);
|
|
32
|
-
if (!r)
|
|
33
|
-
return;
|
|
34
|
-
const c = { ...h(o), ...t }, C = V(r), p = w(b({
|
|
35
|
-
rootAttr: (n) => r.getAttribute(n),
|
|
36
|
-
config: c,
|
|
37
|
-
paragraphs: C.map(({ kind: n, paragraph: s }) => ({
|
|
38
|
-
kind: n,
|
|
39
|
-
attr: (u) => s.getAttribute(u),
|
|
40
|
-
text: s.getInnerText()
|
|
41
|
-
}))
|
|
42
|
-
}), { convertLegacy: !0 }), S = p.texts ?? x(c), l = i.getDocumentModifier();
|
|
43
|
-
F(o, i, { ...t, ...p.configPatch }, l);
|
|
44
|
-
const D = l.modifyHtml(r);
|
|
45
|
-
Object.entries(p.rootSet).forEach(([n, s]) => {
|
|
46
|
-
D.setAttribute(n, s);
|
|
47
|
-
}), C.forEach(({ kind: n, paragraph: s }) => {
|
|
48
|
-
const u = l.modifyHtml(s), A = s.getInnerText().trim();
|
|
49
|
-
p.paragraphRemove.forEach((O) => {
|
|
50
|
-
u.removeAttribute(O);
|
|
51
|
-
}), y(A, S[n]) || u.setInnerHtml(k(s.getInnerHTML(), A, S[n]));
|
|
52
|
-
}), l.apply(new L(e));
|
|
53
|
-
}
|
|
54
|
-
class X extends N {
|
|
55
|
-
constructor() {
|
|
56
|
-
super(...arguments);
|
|
57
|
-
// The format of the last write, until Stripo hands back the updated node: guards the echo
|
|
58
|
-
// of the select this control itself repaints on an auto-swap.
|
|
59
|
-
E(this, "lastWritten", null);
|
|
60
|
-
}
|
|
61
|
-
getId() {
|
|
62
|
-
return B;
|
|
63
|
-
}
|
|
64
|
-
getTemplate() {
|
|
65
|
-
return `
|
|
66
|
-
<div class="${I.PRICE_FORMAT}">
|
|
67
|
-
${this._getSelectRow("Thousand Separator", a.THOUSAND_SEPARATOR, m)}
|
|
68
|
-
${this._getSelectRow("Decimal Separator", a.DECIMAL_SEPARATOR, m)}
|
|
69
|
-
${this._getSelectRow("Decimal Count", a.DECIMAL_COUNT, _)}
|
|
70
|
-
</div>
|
|
71
|
-
`;
|
|
72
|
-
}
|
|
73
|
-
onRender() {
|
|
74
|
-
this.forgetLastPanelNode(), this.api.setUIEAttribute(a.THOUSAND_SEPARATOR, d.SELECTPICKER.items, m), this.api.setUIEAttribute(a.DECIMAL_SEPARATOR, d.SELECTPICKER.items, m), this.api.setUIEAttribute(a.DECIMAL_COUNT, d.SELECTPICKER.items, _), this.api.onValueChanged(a.THOUSAND_SEPARATOR, (t) => {
|
|
75
|
-
this._onThousandSeparatorChange(t);
|
|
76
|
-
}), this.api.onValueChanged(a.DECIMAL_SEPARATOR, (t) => {
|
|
77
|
-
this._onDecimalSeparatorChange(t);
|
|
78
|
-
}), this.api.onValueChanged(a.DECIMAL_COUNT, (t) => {
|
|
79
|
-
this._onDecimalCountChange(t);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
onTemplateNodeUpdated(t) {
|
|
83
|
-
super.onTemplateNodeUpdated(t), this.lastWritten = null, this.handleBlockInstanceChange(() => {
|
|
84
|
-
this.api.updateValues(this._formValues(T(h(this.currentNode))));
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
onDestroy() {
|
|
88
|
-
super.onDestroy(), this.lastWritten = null;
|
|
89
|
-
}
|
|
90
|
-
_onThousandSeparatorChange(t) {
|
|
91
|
-
const e = this._currentFormat();
|
|
92
|
-
if (t === e.thousandSeparator)
|
|
93
|
-
return;
|
|
94
|
-
const r = t === e.decimalSeparator;
|
|
95
|
-
this._write({
|
|
96
|
-
...e,
|
|
97
|
-
thousandSeparator: t,
|
|
98
|
-
decimalSeparator: r ? e.thousandSeparator : e.decimalSeparator
|
|
99
|
-
}, "Updated price thousand separator"), r && this.api.updateValues({ [a.DECIMAL_SEPARATOR]: e.thousandSeparator });
|
|
100
|
-
}
|
|
101
|
-
_onDecimalSeparatorChange(t) {
|
|
102
|
-
const e = this._currentFormat();
|
|
103
|
-
if (t === e.decimalSeparator)
|
|
104
|
-
return;
|
|
105
|
-
const r = t === e.thousandSeparator;
|
|
106
|
-
this._write({
|
|
107
|
-
...e,
|
|
108
|
-
decimalSeparator: t,
|
|
109
|
-
thousandSeparator: r ? e.decimalSeparator : e.thousandSeparator
|
|
110
|
-
}, "Updated price decimal separator"), r && this.api.updateValues({ [a.THOUSAND_SEPARATOR]: e.decimalSeparator });
|
|
111
|
-
}
|
|
112
|
-
_onDecimalCountChange(t) {
|
|
113
|
-
const e = this._currentFormat(), r = U(t);
|
|
114
|
-
r !== e.decimalCount && this._write({ ...e, decimalCount: r }, "Updated price decimal count");
|
|
115
|
-
}
|
|
116
|
-
_currentFormat() {
|
|
117
|
-
return this.lastWritten ?? T(h(this.currentNode));
|
|
118
|
-
}
|
|
119
|
-
_write(t, e) {
|
|
120
|
-
this.lastWritten = t, K(this.currentNode, this.api, {
|
|
121
|
-
priceThousandSeparator: t.thousandSeparator,
|
|
122
|
-
priceDecimalSeparator: t.decimalSeparator,
|
|
123
|
-
priceDecimalCount: t.decimalCount
|
|
124
|
-
}, e);
|
|
125
|
-
}
|
|
126
|
-
_formValues(t) {
|
|
127
|
-
return {
|
|
128
|
-
[a.THOUSAND_SEPARATOR]: t.thousandSeparator,
|
|
129
|
-
[a.DECIMAL_SEPARATOR]: t.decimalSeparator,
|
|
130
|
-
[a.DECIMAL_COUNT]: String(t.decimalCount)
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
_getSelectRow(t, e, r) {
|
|
134
|
-
return this._GuTwoColumns([
|
|
135
|
-
this._GuLabel({ text: this.api.translate(t) }),
|
|
136
|
-
this._GuSelect({ name: e, placeholder: "", options: r })
|
|
137
|
-
], "no-separator");
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
export {
|
|
141
|
-
B as CONTROL_BLOCK_ID,
|
|
142
|
-
X as ItemsBlockPriceFormatControl,
|
|
143
|
-
K as applyPriceFormatChange,
|
|
144
|
-
Q as isNewPriceFormatBlock
|
|
145
|
-
};
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { formatNumber as w } from "../../Recommendation/utils/priceFormatter.js";
|
|
2
|
-
import { escapeHtml as q } from "../../../../utils/htmlEscape.js";
|
|
3
|
-
import { extractWrapperTags as B } from "../../../../utils/preserveTextStyles.js";
|
|
4
|
-
import { ITEMS_PRICE_FORMAT_ATTR as c, priceFormatFromConfig as _, normalizeDecimalCount as V, LEGACY_PRICE_PARAGRAPH_ATTRS as O, ITEMS_CURRENCY_ATTR as b } from "../constants/currency.js";
|
|
5
|
-
import { productPairs as W } from "../enums/productEnums.js";
|
|
6
|
-
import { DefaultConfigValues as I } from "../enums/settingsEnums.js";
|
|
7
|
-
import { escapeReplacement as z } from "./nodeConfigUtils.js";
|
|
8
|
-
const J = 'p[product-attr="price"], p[product-attr="originalPrice"]', K = [
|
|
9
|
-
...Object.values(c),
|
|
10
|
-
"data-type"
|
|
11
|
-
], L = "CART_ITEMS";
|
|
12
|
-
function X() {
|
|
13
|
-
return { rootSet: {}, paragraphRemove: [], configPatch: null, texts: null, changed: !1 };
|
|
14
|
-
}
|
|
15
|
-
function h(t) {
|
|
16
|
-
return t != null;
|
|
17
|
-
}
|
|
18
|
-
function Pt(t) {
|
|
19
|
-
return t === "price" || t === "originalPrice" ? t : null;
|
|
20
|
-
}
|
|
21
|
-
function N(t) {
|
|
22
|
-
const n = W.PAIRS_FOR_EXTENSION, r = t != null && t.type && t.type in n.price ? t.type : L, o = (t == null ? void 0 : t.priceSinglePrice) === !0, e = n.price[r], i = n.originalPrice[r];
|
|
23
|
-
return {
|
|
24
|
-
price: o ? e.DEFAULT_SINGLE_PRICE : e.DEFAULT_PRICE,
|
|
25
|
-
originalPrice: o ? i.DEFAULT_SINGLE_PRICE : i.DEFAULT_PRICE
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function P({ amount: t, format: n, symbol: r, alignment: o }) {
|
|
29
|
-
const e = w(Number(t), n), i = q((r ?? "").trim());
|
|
30
|
-
return i ? o === "1" ? `${e} ${i}` : `${i} ${e}` : e;
|
|
31
|
-
}
|
|
32
|
-
function Tt(t) {
|
|
33
|
-
const n = N(t), r = {
|
|
34
|
-
format: _(t),
|
|
35
|
-
symbol: (t == null ? void 0 : t.priceCurrencySymbol) ?? I.productPriceCurrencySymbolControlValue,
|
|
36
|
-
alignment: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0"
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
price: P({ amount: n.price, ...r }),
|
|
40
|
-
originalPrice: P({ amount: n.originalPrice, ...r })
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const x = / |\u00a0|\s+/g, Q = "(?: | |\\s)+", Z = /&(amp|lt|gt|quot|#x27|#39);/g, tt = { amp: "&", lt: "<", gt: ">", quot: '"', "#x27": "'", "#39": "'" }, rt = {
|
|
44
|
-
"&": "(?:&|&)",
|
|
45
|
-
"<": "(?:<|<)",
|
|
46
|
-
">": "(?:>|>)",
|
|
47
|
-
'"': '(?:"|")',
|
|
48
|
-
"'": "(?:'|'|')"
|
|
49
|
-
}, et = (t) => t.replace(Z, (n, r) => tt[r]), nt = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
50
|
-
function ot(t) {
|
|
51
|
-
return Array.from(t, (n) => rt[n] ?? nt(n)).join("");
|
|
52
|
-
}
|
|
53
|
-
function D(t, n) {
|
|
54
|
-
const r = (o) => o.replace(x, " ").trim();
|
|
55
|
-
return r(t ?? "") === r(et(n ?? ""));
|
|
56
|
-
}
|
|
57
|
-
function it(t, n, r) {
|
|
58
|
-
const o = t.trim(), e = n.trim().split(x).filter(Boolean), i = e.length ? new RegExp(e.map(ot).join(Q)) : null;
|
|
59
|
-
if (i != null && i.test(o))
|
|
60
|
-
return o.replace(i, z(r));
|
|
61
|
-
const { openTags: s, closeTags: u } = B(o);
|
|
62
|
-
return `${s}${r}${u}`;
|
|
63
|
-
}
|
|
64
|
-
function ct(t, n) {
|
|
65
|
-
if (!t)
|
|
66
|
-
return null;
|
|
67
|
-
const r = Object.fromEntries(
|
|
68
|
-
Object.entries(n).filter(([o, e]) => t[o] !== e)
|
|
69
|
-
);
|
|
70
|
-
return Object.keys(r).length > 0 ? r : null;
|
|
71
|
-
}
|
|
72
|
-
function Ct(t, { convertLegacy: n }) {
|
|
73
|
-
const { rootAttrs: r, paragraphs: o, config: e } = t, i = h(r[c.DECIMAL_COUNT]);
|
|
74
|
-
if (!i && !n)
|
|
75
|
-
return X();
|
|
76
|
-
const s = o.find((a) => a.kind === "price") ?? o[0], u = (a) => (s == null ? void 0 : s.attrs[a]) ?? null, l = i ? r[c.SINGLE_PRICE] : u("data-single_price"), m = typeof (e == null ? void 0 : e.priceSinglePrice) == "boolean" ? e.priceSinglePrice : l === "true", A = e == null ? void 0 : e.priceCurrencyLocation, j = u(b.POSITION) === "after" ? "1" : "0", H = i ? r[c.ALIGNMENT] : j, E = (typeof A == "string" && A.trim() !== "" ? A : H) === "1" ? "1" : "0", U = i ? r[c.SYMBOL] : u(b.SYMBOL), S = typeof (e == null ? void 0 : e.priceCurrencySymbol) == "string" ? e.priceCurrencySymbol : U ?? I.productPriceCurrencySymbolControlValue, p = _({
|
|
77
|
-
priceThousandSeparator: (e == null ? void 0 : e.priceThousandSeparator) ?? (i ? r[c.THOUSAND_SEPARATOR] ?? void 0 : void 0),
|
|
78
|
-
priceDecimalSeparator: (e == null ? void 0 : e.priceDecimalSeparator) ?? (i ? r[c.DECIMAL_SEPARATOR] ?? void 0 : void 0),
|
|
79
|
-
priceDecimalCount: (e == null ? void 0 : e.priceDecimalCount) ?? (i ? V(r[c.DECIMAL_COUNT]) : void 0)
|
|
80
|
-
}), G = {
|
|
81
|
-
[c.SYMBOL]: S.trim(),
|
|
82
|
-
[c.ALIGNMENT]: E,
|
|
83
|
-
[c.THOUSAND_SEPARATOR]: p.thousandSeparator,
|
|
84
|
-
[c.DECIMAL_SEPARATOR]: p.decimalSeparator,
|
|
85
|
-
[c.DECIMAL_COUNT]: String(p.decimalCount),
|
|
86
|
-
[c.SINGLE_PRICE]: m ? "true" : "false"
|
|
87
|
-
}, T = Object.fromEntries(
|
|
88
|
-
Object.entries(G).filter(([a, d]) => r[a] !== d)
|
|
89
|
-
), C = O.filter(
|
|
90
|
-
(a) => o.some((d) => h(d.attrs[a]))
|
|
91
|
-
), $ = {
|
|
92
|
-
priceThousandSeparator: p.thousandSeparator,
|
|
93
|
-
priceDecimalSeparator: p.decimalSeparator,
|
|
94
|
-
priceDecimalCount: p.decimalCount,
|
|
95
|
-
priceSinglePrice: m,
|
|
96
|
-
priceCurrencyLocation: E,
|
|
97
|
-
priceCurrencySymbol: S
|
|
98
|
-
}, f = ct(e, $), k = (e == null ? void 0 : e.type) ?? r["data-type"] ?? L, R = N({ type: k, priceSinglePrice: m }), y = (a) => P({ amount: a, format: p, symbol: S, alignment: E }), g = { price: y(R.price), originalPrice: y(R.originalPrice) }, Y = o.some((a) => !D(a.text, g[a.kind]));
|
|
99
|
-
return {
|
|
100
|
-
rootSet: T,
|
|
101
|
-
paragraphRemove: C,
|
|
102
|
-
configPatch: f,
|
|
103
|
-
texts: g,
|
|
104
|
-
changed: Object.keys(T).length > 0 || C.length > 0 || f !== null || Y
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function at(t) {
|
|
108
|
-
const n = {};
|
|
109
|
-
return K.forEach((r) => {
|
|
110
|
-
n[r] = t.rootAttr(r) ?? null;
|
|
111
|
-
}), {
|
|
112
|
-
rootAttrs: n,
|
|
113
|
-
config: t.config,
|
|
114
|
-
paragraphs: t.paragraphs.map((r) => {
|
|
115
|
-
const o = {};
|
|
116
|
-
return O.forEach((e) => {
|
|
117
|
-
o[e] = r.attr(e) ?? null;
|
|
118
|
-
}), { kind: r.kind, attrs: o, text: r.text.trim() };
|
|
119
|
-
})
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function M(t) {
|
|
123
|
-
const n = t.getAttribute("esd-ext-config");
|
|
124
|
-
if (!n)
|
|
125
|
-
return null;
|
|
126
|
-
try {
|
|
127
|
-
const r = JSON.parse(n);
|
|
128
|
-
return r && typeof r == "object" ? r : null;
|
|
129
|
-
} catch {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function F(t) {
|
|
134
|
-
return Array.from(t.querySelectorAll(J)).map((n) => ({
|
|
135
|
-
kind: n.getAttribute("product-attr"),
|
|
136
|
-
element: n
|
|
137
|
-
}));
|
|
138
|
-
}
|
|
139
|
-
function v(t) {
|
|
140
|
-
return t.textContent;
|
|
141
|
-
}
|
|
142
|
-
function ft(t) {
|
|
143
|
-
return at({
|
|
144
|
-
rootAttr: (n) => t.getAttribute(n),
|
|
145
|
-
config: M(t),
|
|
146
|
-
paragraphs: F(t).map(({ kind: n, element: r }) => ({
|
|
147
|
-
kind: n,
|
|
148
|
-
attr: (o) => r.getAttribute(o),
|
|
149
|
-
text: v(r)
|
|
150
|
-
}))
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function Rt(t, n) {
|
|
154
|
-
if (!n.changed)
|
|
155
|
-
return !1;
|
|
156
|
-
let r = !1;
|
|
157
|
-
if (Object.entries(n.rootSet).forEach(([o, e]) => {
|
|
158
|
-
t.getAttribute(o) !== e && (t.setAttribute(o, e), r = !0);
|
|
159
|
-
}), F(t).forEach(({ kind: o, element: e }) => {
|
|
160
|
-
var u;
|
|
161
|
-
n.paragraphRemove.forEach((l) => {
|
|
162
|
-
e.hasAttribute(l) && (e.removeAttribute(l), r = !0);
|
|
163
|
-
});
|
|
164
|
-
const i = (u = n.texts) == null ? void 0 : u[o], s = v(e).trim();
|
|
165
|
-
i !== void 0 && !D(s, i) && (e.innerHTML = it(e.innerHTML, s, i), r = !0);
|
|
166
|
-
}), n.configPatch) {
|
|
167
|
-
const o = M(t);
|
|
168
|
-
o && (t.setAttribute("esd-ext-config", JSON.stringify({ ...o, ...n.configPatch })), r = !0);
|
|
169
|
-
}
|
|
170
|
-
return r;
|
|
171
|
-
}
|
|
172
|
-
export {
|
|
173
|
-
J as PRICE_PARAGRAPH_SELECTOR,
|
|
174
|
-
Rt as applyPriceFormatOpsToElement,
|
|
175
|
-
at as buildPriceFormatSnapshot,
|
|
176
|
-
P as formatItemsDummyPrice,
|
|
177
|
-
Pt as paragraphKindOf,
|
|
178
|
-
Ct as planPriceFormatOps,
|
|
179
|
-
Tt as priceTextsFromConfig,
|
|
180
|
-
M as readPersistedConfigAttribute,
|
|
181
|
-
it as replacePriceText,
|
|
182
|
-
N as resolvePriceDummyAmounts,
|
|
183
|
-
D as samePriceText,
|
|
184
|
-
ft as snapshotPriceFormatFromElement
|
|
185
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function migrateItemsPriceFormat(html: string): string;
|