@useinsider/guido 3.17.0-beta.17c2940 → 3.17.0-beta.1f18d2d
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/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.js +6 -6
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +40 -35
- package/dist/composables/useModuleRepair.js +33 -0
- package/dist/composables/useStripo.js +1 -1
- package/dist/config/i18n/en/labels.json.js +1 -1
- package/dist/extensions/Blocks/Items/block.js +118 -49
- package/dist/extensions/Blocks/Items/constants/currency.js +25 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
- package/dist/extensions/Blocks/Items/template.js +153 -152
- package/dist/extensions/Blocks/Recommendation/block.js +12 -11
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +14 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +107 -106
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +9 -9
- package/dist/src/composables/useModuleRepair.d.ts +18 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +35 -0
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +43 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
- package/dist/src/utils/itemsCurrencyRepair.d.ts +17 -0
- package/dist/utils/itemsCurrencyRepair.js +39 -0
- package/dist/utils/pairProductVariables.js +58 -58
- package/package.json +1 -1
- package/dist/composables/useModuleDynamicContentRepair.js +0 -37
- package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -13
|
@@ -1,82 +1,82 @@
|
|
|
1
|
+
import { ITEMS_CURRENCY_ATTR as D, isCustomCurrencySymbol as G } from "../extensions/Blocks/Items/constants/currency.js";
|
|
1
2
|
import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
2
|
-
import {
|
|
3
|
-
import { escapeReplacement as G } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
3
|
+
import { escapeReplacement as X } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
4
|
import { preserveTextStyles as F } from "./preserveTextStyles.js";
|
|
5
|
-
import { unwrapProductNameLinks as
|
|
5
|
+
import { unwrapProductNameLinks as Y } from "./unwrapProductNameLink.js";
|
|
6
6
|
const x = {
|
|
7
7
|
CART_ITEMS: "ins_apr",
|
|
8
8
|
BROWSED_ITEMS: "browsed_item",
|
|
9
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
|
-
},
|
|
11
|
-
function v(S,
|
|
12
|
-
let
|
|
13
|
-
for (;
|
|
14
|
-
|
|
15
|
-
return
|
|
10
|
+
}, O = (S) => S.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v(S, y, b) {
|
|
12
|
+
let h = y;
|
|
13
|
+
for (; h > 0 && /\s/.test(S[h - 1]); )
|
|
14
|
+
h -= 1;
|
|
15
|
+
return b.some((I) => S.endsWith(I, h));
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
Object.entries(
|
|
22
|
-
|
|
17
|
+
function K(S) {
|
|
18
|
+
const y = O(S), b = new DOMParser().parseFromString(y, "text/html");
|
|
19
|
+
Y(b);
|
|
20
|
+
const h = L.PAIRS_FOR_EXTENSION;
|
|
21
|
+
Object.entries(h).forEach(([n, d]) => {
|
|
22
|
+
b.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
23
23
|
const E = r.getAttribute("data-number") || "1", m = r.getAttribute("data-type") || "CART_ITEMS";
|
|
24
24
|
r.querySelectorAll(`[product-attr="${n}"]`).forEach((t) => {
|
|
25
|
-
var
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
25
|
+
var $, H, N;
|
|
26
|
+
const g = t.getAttribute("data-type") || m, o = t.getAttribute("data-number") || E, u = d[g];
|
|
27
|
+
if (u)
|
|
28
28
|
switch (n) {
|
|
29
29
|
case "imageSrc": {
|
|
30
30
|
let e = null, s = null;
|
|
31
31
|
if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
|
|
32
32
|
break;
|
|
33
|
-
const a =
|
|
33
|
+
const a = u.DEFAULT, l = u.ATTR;
|
|
34
34
|
if (a && e.src) {
|
|
35
35
|
const i = e.src;
|
|
36
|
-
a.some((
|
|
37
|
-
const
|
|
38
|
-
return i.includes(
|
|
36
|
+
a.some((_) => {
|
|
37
|
+
const f = _.split("/").pop() || "", P = i.split("/").pop() || "";
|
|
38
|
+
return i.includes(_) || i.includes(f) || P === f;
|
|
39
39
|
}) && (e.src = `{{${l}_${o}}}`);
|
|
40
40
|
}
|
|
41
|
-
const c = (
|
|
41
|
+
const c = (H = ($ = h.name) == null ? void 0 : $[g]) == null ? void 0 : H.ATTR;
|
|
42
42
|
if (c && e.setAttribute("alt", `{{${c}_${o}}}`), s) {
|
|
43
|
-
const i = (
|
|
43
|
+
const i = (N = h.itemLink) == null ? void 0 : N[g];
|
|
44
44
|
if (i) {
|
|
45
|
-
const
|
|
46
|
-
(
|
|
45
|
+
const R = i.HREF, _ = i.DEFAULT_HREF || "#!", f = s.href;
|
|
46
|
+
(f === "#" || f === "" || f.endsWith("#!") || f.endsWith(_) || f === `${window.location.href}${_}` || !f || f === window.location.href) && (s.href = `{{${R}_${o}}}`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
51
|
case "name": {
|
|
52
|
-
const e =
|
|
52
|
+
const e = u, s = e.ATTR, a = e.DEFAULT_HREF || "#!", l = e.HREF;
|
|
53
53
|
t.textContent && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
54
54
|
const c = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
55
55
|
if (c && l) {
|
|
56
|
-
const i = c.href,
|
|
57
|
-
(i ===
|
|
56
|
+
const i = c.href, R = `${window.location.href}${a}`;
|
|
57
|
+
(i === R || i.endsWith(a)) && (c.href = `{{${l}_${o}}}`);
|
|
58
58
|
}
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
case "price":
|
|
62
62
|
case "originalPrice": {
|
|
63
|
-
const e =
|
|
64
|
-
let
|
|
65
|
-
c ?
|
|
66
|
-
const
|
|
67
|
-
let
|
|
68
|
-
const
|
|
63
|
+
const e = u, s = t.getAttribute("data-formated"), a = t.getAttribute("data-single_price"), l = s === "true", c = a === "true", i = t.getAttribute(D.POSITION) || "before";
|
|
64
|
+
let R;
|
|
65
|
+
c ? R = l ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : R = l ? e.PRICE_FORMATTED : e.PRICE;
|
|
66
|
+
const _ = e.CURRENCY;
|
|
67
|
+
let f = `{{${R}_${o}}}`;
|
|
68
|
+
const P = (t.getAttribute(D.SYMBOL) || "").trim(), V = G(P);
|
|
69
69
|
let C = "";
|
|
70
|
-
|
|
70
|
+
V ? C = P : _ && (C = `{{${_}_${o}}}`), C && (f = i === "after" ? `${f} ${C}` : `${C} ${f}`), t.innerHTML = F(t, f);
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
case "quantity": {
|
|
74
|
-
const e =
|
|
74
|
+
const e = u, s = e.ATTR, a = e.DEFAULT;
|
|
75
75
|
t.textContent && t.textContent.trim() === a && (t.innerHTML = F(t, `{{${s}_${o}}}`));
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
case "button": {
|
|
79
|
-
const e =
|
|
79
|
+
const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t.tagName === "A" ? t : t.querySelector("a");
|
|
80
80
|
if (l) {
|
|
81
81
|
const c = l.href || "", i = `${window.location.href}${a}`;
|
|
82
82
|
(c === "" || c === "#" || c === i || c.endsWith(a) || c.endsWith("#!") || c === window.location.href) && (l.href = `{{${s}_${o}}}`);
|
|
@@ -84,7 +84,7 @@ function J(S) {
|
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
86
|
case "itemLink": {
|
|
87
|
-
const e =
|
|
87
|
+
const e = u, s = e.HREF, a = e.DEFAULT_HREF || "#!", l = t;
|
|
88
88
|
if (l.href) {
|
|
89
89
|
const c = l.href, i = `${window.location.href}${a}`;
|
|
90
90
|
(c === i || c.endsWith(a)) && (l.href = `{{${s}_${o}}}`);
|
|
@@ -92,8 +92,8 @@ function J(S) {
|
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
94
|
default: {
|
|
95
|
-
if ("ATTR" in
|
|
96
|
-
const e =
|
|
95
|
+
if ("ATTR" in u) {
|
|
96
|
+
const e = u.ATTR;
|
|
97
97
|
t.textContent && (t.innerHTML = F(t, `{{${e}_${o}}}`));
|
|
98
98
|
}
|
|
99
99
|
break;
|
|
@@ -102,9 +102,9 @@ function J(S) {
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
-
const I =
|
|
106
|
-
` : "",
|
|
107
|
-
|
|
105
|
+
const I = y.match(/<!DOCTYPE[^>]*>/i), q = I ? `${I[0]}
|
|
106
|
+
` : "", U = b.querySelectorAll(".ins-product-td"), M = [];
|
|
107
|
+
U.forEach((n) => {
|
|
108
108
|
const d = n.getAttribute("data-type") || "CART_ITEMS", p = n.getAttribute("data-number") || "1", r = n.outerHTML;
|
|
109
109
|
M.push({
|
|
110
110
|
element: n,
|
|
@@ -113,16 +113,16 @@ function J(S) {
|
|
|
113
113
|
number: p
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
let A =
|
|
116
|
+
let A = q + b.documentElement.outerHTML;
|
|
117
117
|
M.reverse().forEach(({ outerHtml: n, type: d, number: p }) => {
|
|
118
118
|
const r = x[d], E = r ? `${r}_total_product_kind` : "";
|
|
119
119
|
if (E) {
|
|
120
|
-
const
|
|
121
|
-
A = A.replace(n,
|
|
120
|
+
const T = parseInt(p) - 1, o = `${`{% if ${E} > ${T} %}`}${n}{% endif %}`;
|
|
121
|
+
A = A.replace(n, X(o));
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
|
-
const
|
|
125
|
-
return
|
|
124
|
+
const W = b.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
|
|
125
|
+
return W.forEach((n) => {
|
|
126
126
|
var t;
|
|
127
127
|
const d = n.getAttribute("data-number"), p = n.getAttribute("data-type");
|
|
128
128
|
if (!d || !x[p])
|
|
@@ -131,20 +131,20 @@ function J(S) {
|
|
|
131
131
|
if (!r || k.has(r))
|
|
132
132
|
return;
|
|
133
133
|
k.add(r);
|
|
134
|
-
const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"),
|
|
135
|
-
|
|
134
|
+
const E = r.outerHTML, m = (t = n.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), T = w.get(E) ?? { number: d, type: p, wrap: [] };
|
|
135
|
+
T.wrap.push(m !== "false"), w.set(E, T);
|
|
136
136
|
}), w.forEach(({ number: n, type: d, wrap: p }, r) => {
|
|
137
137
|
if (r.includes("{% if") || !p.some(Boolean))
|
|
138
138
|
return;
|
|
139
|
-
const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE,
|
|
140
|
-
let
|
|
141
|
-
for (;
|
|
142
|
-
const
|
|
143
|
-
|
|
139
|
+
const E = L.PAIRS_FOR_EXTENSION.price[d].PRICE, m = L.PAIRS_FOR_EXTENSION.originalPrice[d].PRICE, T = `{% if ${E}_${n} != ${m}_${n} %}`, t = [T, O(T)];
|
|
140
|
+
let g = "", o = 0, u = 0, $ = A.indexOf(r);
|
|
141
|
+
for (; $ !== -1; ) {
|
|
142
|
+
const H = p[u] === !0 && !v(A, $, t);
|
|
143
|
+
g += A.slice(o, $) + (H ? `${T}${r}{% endif %}` : r), o = $ + r.length, u += 1, $ = A.indexOf(r, o);
|
|
144
144
|
}
|
|
145
|
-
A =
|
|
145
|
+
A = g + A.slice(o);
|
|
146
146
|
}), A.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
147
147
|
}
|
|
148
148
|
export {
|
|
149
|
-
|
|
149
|
+
K as pairProductVariables
|
|
150
150
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.17.0-beta.
|
|
3
|
+
"version": "3.17.0-beta.1f18d2d",
|
|
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",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useConfig as C } from "./useConfig.js";
|
|
2
|
-
import { useToaster as D } from "./useToaster.js";
|
|
3
|
-
import { useTranslations as T } from "./useTranslations.js";
|
|
4
|
-
import { ToasterTypeOptions as g } from "../enums/toaster.js";
|
|
5
|
-
import { buildDynamicContentLookup as h, convertModuleDynamicContent as O } from "../utils/dynamicContentConverter.js";
|
|
6
|
-
import { flattenDynamicContentList as f } from "../utils/genericUtil.js";
|
|
7
|
-
const M = "dynamic-content.unresolved-attributes-on-drop", b = () => {
|
|
8
|
-
const { template: i, isFeatureEnabled: p } = C(), { showToaster: m } = D(), a = T();
|
|
9
|
-
return { handleModuleAdd: (n, o) => {
|
|
10
|
-
var s, c, l;
|
|
11
|
-
try {
|
|
12
|
-
if ((n == null ? void 0 : n.action) !== "ADD" && (n == null ? void 0 : n.action) !== "COPY")
|
|
13
|
-
return;
|
|
14
|
-
const e = h(f((s = i.value) == null ? void 0 : s.dynamicContentList));
|
|
15
|
-
if (e.size === 0)
|
|
16
|
-
return;
|
|
17
|
-
const t = (c = o == null ? void 0 : o.getTargetNode) == null ? void 0 : c.call(o), r = (l = t == null ? void 0 : t.getOuterHTML) == null ? void 0 : l.call(t);
|
|
18
|
-
if (!t || typeof r != "string")
|
|
19
|
-
return;
|
|
20
|
-
const { html: u, unresolved: y } = O(
|
|
21
|
-
r,
|
|
22
|
-
e,
|
|
23
|
-
p("liquidSyntax")
|
|
24
|
-
);
|
|
25
|
-
u !== r && o.modifyHtml(t).replaceWith(u), y.length > 0 && m({
|
|
26
|
-
type: g.Warning,
|
|
27
|
-
message: a(M)
|
|
28
|
-
});
|
|
29
|
-
} catch (e) {
|
|
30
|
-
console.error("Failed to repair dynamic content on module add:", e);
|
|
31
|
-
}
|
|
32
|
-
} };
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
M as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
|
|
36
|
-
b as useModuleDynamicContentRepair
|
|
37
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ModuleAddData, ModuleModifier } from '@@/Types/stripo';
|
|
2
|
-
export declare const UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY = "dynamic-content.unresolved-attributes-on-drop";
|
|
3
|
-
/**
|
|
4
|
-
* Repairs label-form dynamic-content tokens in saved modules as they are dropped
|
|
5
|
-
* or copied into the editor. Saved modules serialize merge-tag chips by their
|
|
6
|
-
* display label (`{{ Phone Number }}`); this maps them back to their canonical
|
|
7
|
-
* token (`{{phone_number}}`) using the account's dynamic-content list.
|
|
8
|
-
*
|
|
9
|
-
* Wired into Stripo via the `onModuleAdd` init callback (see `useStripo`).
|
|
10
|
-
*/
|
|
11
|
-
export declare const useModuleDynamicContentRepair: () => {
|
|
12
|
-
handleModuleAdd: (data: ModuleAddData, modifier: ModuleModifier) => void;
|
|
13
|
-
};
|