@useinsider/guido 3.30.0-beta.232ea3c → 3.30.0-beta.25ed52c
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 +52 -0
- package/dist/@types/config/schemas.js +40 -33
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +128 -113
- package/dist/components/organisms/dynamic-content/DynamicContentAooRuleConfig.vue.js +34 -0
- package/dist/components/organisms/dynamic-content/DynamicContentAooRuleConfig.vue2.js +76 -0
- package/dist/components/organisms/dynamic-content/DynamicContentCustomFormat.vue.js +21 -0
- package/dist/components/organisms/dynamic-content/DynamicContentCustomFormat.vue2.js +33 -0
- package/dist/components/organisms/dynamic-content/DynamicContentPicker.vue.js +42 -0
- package/dist/components/organisms/dynamic-content/DynamicContentPicker.vue2.js +216 -0
- package/dist/composables/useDynamicContentFormat.js +10 -0
- package/dist/composables/useDynamicContentPicker.js +36 -0
- package/dist/composables/useHtmlCompiler.js +15 -13
- package/dist/composables/useInfoBoxPosition.js +16 -0
- package/dist/composables/useStripo.js +59 -57
- package/dist/config/compiler/liquidCompilerRules.js +13 -5
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/enums/dynamic-content.js +180 -2
- package/dist/extensions/DynamicContent/dynamic-content.js +56 -33
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/@types/generic.d.ts +11 -0
- package/dist/src/components/organisms/dynamic-content/DynamicContentAooRuleConfig.vue.d.ts +48 -0
- package/dist/src/components/organisms/dynamic-content/DynamicContentCustomFormat.vue.d.ts +44 -0
- package/dist/src/components/organisms/dynamic-content/DynamicContentPicker.vue.d.ts +67 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +6 -0
- package/dist/src/composables/useDynamicContentFormat.d.ts +5 -0
- package/dist/src/composables/useDynamicContentPicker.d.ts +35 -0
- package/dist/src/composables/useInfoBoxPosition.d.ts +24 -0
- package/dist/src/enums/dynamic-content.d.ts +21 -0
- package/dist/src/extensions/DynamicContent/dynamic-content.d.ts +11 -0
- package/dist/src/stores/config.d.ts +63 -0
- package/dist/src/utils/clipboardText.d.ts +1 -0
- package/dist/src/utils/dynamicContentPicker.d.ts +43 -0
- package/dist/src/utils/genericUtil.d.ts +7 -2
- package/dist/src/utils/linkTokenPaste.d.ts +3 -0
- package/dist/src/utils/liquidLinkQuotes.d.ts +4 -0
- package/dist/utils/clipboardText.js +31 -0
- package/dist/utils/dynamicContentPicker.js +88 -0
- package/dist/utils/genericUtil.js +53 -43
- package/dist/utils/linkTokenPaste.js +28 -0
- package/dist/utils/liquidLinkQuotes.js +10 -0
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ARRAY_OF_OBJECTS_TYPE as _, ARRAY_OF_OBJECTS_CATEGORY_VALUE as E } from "../enums/dynamic-content.js";
|
|
2
|
+
const d = /^([^.]+\.[^_]+(?:_[^_]+)*?)(?:_\d|$)/, O = /^[^.]+\.[^_]+(?:_[^_]+)*?_\d/, A = /\{\{(.*?)\}\}/gm, v = (r) => r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = (r) => r.slice(r.indexOf(".") + 1), u = (r) => {
|
|
3
|
+
var e;
|
|
4
|
+
return r ? ((e = r.match(d)) == null ? void 0 : e[1]) ?? null : null;
|
|
5
|
+
}, a = (r) => O.test(r || ""), g = (r, e) => {
|
|
6
|
+
if (!Array.isArray(e) || !e.length || !a(r))
|
|
7
|
+
return !1;
|
|
8
|
+
const n = u(r);
|
|
9
|
+
return !!n && e.includes(h(n));
|
|
10
|
+
}, x = (r) => {
|
|
11
|
+
if (typeof r != "string" || r === "")
|
|
12
|
+
return [];
|
|
13
|
+
const e = [];
|
|
14
|
+
let n;
|
|
15
|
+
for (A.lastIndex = 0; (n = A.exec(r)) !== null; ) {
|
|
16
|
+
const [l = ""] = (n[1] || "").split("|");
|
|
17
|
+
l.trim() && e.push(l.trim());
|
|
18
|
+
}
|
|
19
|
+
return e;
|
|
20
|
+
}, C = (r) => {
|
|
21
|
+
const e = [];
|
|
22
|
+
return x(r).forEach((n) => {
|
|
23
|
+
const l = a(n) ? u(n) : null;
|
|
24
|
+
l && !e.includes(l) && e.push(l);
|
|
25
|
+
}), e;
|
|
26
|
+
}, L = (r, e) => !r || !e ? r || "" : r.replace(new RegExp(`\\{\\{\\s*${v(e)}\\s*(\\|[^}]*)?\\}\\}`), ""), m = (r) => Array.isArray(r) ? r.reduce((e, n) => e || (n.value && a(n.value) ? n.value : m(n.children)), null) : null, S = (r, e, n) => !Array.isArray(r) || !(e != null && e.length) ? r || [] : r.map((l) => {
|
|
27
|
+
const c = l.value, s = e.filter((t) => h(t) === c);
|
|
28
|
+
return s.length ? {
|
|
29
|
+
...l,
|
|
30
|
+
children: (l.children || []).map((t) => {
|
|
31
|
+
const i = u(m(t.select_items));
|
|
32
|
+
return !i || s.includes(i) ? t : {
|
|
33
|
+
...t,
|
|
34
|
+
disable: !0,
|
|
35
|
+
infoBoxProps: {
|
|
36
|
+
id: `disabled-rule-${c}-${t.value}`,
|
|
37
|
+
theme: "light",
|
|
38
|
+
variant: "information",
|
|
39
|
+
descriptionText: n
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
})
|
|
43
|
+
} : l;
|
|
44
|
+
}), o = (r) => {
|
|
45
|
+
var e;
|
|
46
|
+
return Array.isArray(r == null ? void 0 : r.columns) && (((e = r == null ? void 0 : r.columns) == null ? void 0 : e.length) ?? 0) > 0;
|
|
47
|
+
}, b = (r) => !r || !o(r) ? [] : r.columns.map((e) => ({ ...e, description: `{{${e.value}}}` })), $ = (r, e) => {
|
|
48
|
+
if (!Array.isArray(e) || !e.length || !(r != null && r.value))
|
|
49
|
+
return null;
|
|
50
|
+
const n = e.flatMap((s) => Array.isArray(s.children) ? s.children : []), l = n.reduce((s, t) => {
|
|
51
|
+
if (s)
|
|
52
|
+
return s;
|
|
53
|
+
if (o(t)) {
|
|
54
|
+
const i = t.columns.find((y) => y.value === r.value);
|
|
55
|
+
return i ? { binding: t, column: i } : null;
|
|
56
|
+
}
|
|
57
|
+
return t.value === r.value ? { binding: t, column: null } : null;
|
|
58
|
+
}, null);
|
|
59
|
+
if (l)
|
|
60
|
+
return l;
|
|
61
|
+
const c = r.text ? n.find((s) => !o(s) && s.text === r.text) : void 0;
|
|
62
|
+
return c ? { binding: c, column: null } : null;
|
|
63
|
+
}, f = (r) => r.type === _ || r.value === E, k = (r) => {
|
|
64
|
+
const [e] = Object.values(r ?? {}), n = Array.isArray(e) ? e : [], l = n.find(f), c = n.filter((t) => !f(t)).map((t) => ({
|
|
65
|
+
...t,
|
|
66
|
+
children: Array.isArray(t.children) ? t.children.map((i) => ({
|
|
67
|
+
...i,
|
|
68
|
+
description: o(i) ? "" : `{{${i.value}}}`
|
|
69
|
+
})) : t.children
|
|
70
|
+
})), s = (Array.isArray(l == null ? void 0 : l.children) ? l.children : []).filter((t) => Array.isArray(t.children) && t.children.length > 0);
|
|
71
|
+
return { options: c, aooOptions: s };
|
|
72
|
+
}, w = (r) => r.filter(Boolean).join(`
|
|
73
|
+
`), R = ["a", "e", "i", "o", "u"], T = ["html", "hour"], B = (r) => r && (R.includes(r[0].toLowerCase()) || T.some((n) => r.toLowerCase().startsWith(n))) ? "an" : "a";
|
|
74
|
+
export {
|
|
75
|
+
S as applyAooDisabledState,
|
|
76
|
+
w as buildAooScanContent,
|
|
77
|
+
b as buildLookupColumnOptions,
|
|
78
|
+
k as buildPickerOptions,
|
|
79
|
+
u as extractAooRulePattern,
|
|
80
|
+
C as extractUsedAooPatterns,
|
|
81
|
+
$ as findDynamicContentSelection,
|
|
82
|
+
m as getFirstRuleTokenFromSelectItems,
|
|
83
|
+
B as getIndefiniteArticle,
|
|
84
|
+
a as isAooToken,
|
|
85
|
+
g as isAooTokenForArrays,
|
|
86
|
+
o as isLookupBinding,
|
|
87
|
+
L as removeAooTokenOnce
|
|
88
|
+
};
|
|
@@ -1,78 +1,88 @@
|
|
|
1
|
-
import { formatToLiquidFilter as
|
|
2
|
-
const
|
|
1
|
+
import { formatToLiquidFilter as g, liquidFilterToFormat as p, quoteArgument as y } from "./liquidDynamicContent.js";
|
|
2
|
+
const m = (t) => {
|
|
3
3
|
if (!t.includes("="))
|
|
4
4
|
return null;
|
|
5
|
-
const [
|
|
6
|
-
return { key:
|
|
7
|
-
}, u = "default:",
|
|
5
|
+
const [a, e] = t.split("=");
|
|
6
|
+
return { key: a.trim(), value: e.trim() };
|
|
7
|
+
}, u = "default:", b = (t) => {
|
|
8
8
|
if (!t.startsWith(u))
|
|
9
9
|
return t;
|
|
10
|
-
const
|
|
11
|
-
return e('"') || e("'") ?
|
|
12
|
-
},
|
|
13
|
-
const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((
|
|
10
|
+
const a = t.slice(u.length).trim(), e = (r) => a.length >= 2 && a.startsWith(r) && a.endsWith(r);
|
|
11
|
+
return e('"') || e("'") ? a.slice(1, -1) : a;
|
|
12
|
+
}, A = (t) => {
|
|
13
|
+
const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((n) => n.trim()), [r] = e, s = {
|
|
14
14
|
text: t.label,
|
|
15
|
-
value:
|
|
15
|
+
value: r || ""
|
|
16
16
|
};
|
|
17
17
|
if (e.length >= 2) {
|
|
18
|
-
const [,
|
|
19
|
-
if (
|
|
20
|
-
s.fallback =
|
|
18
|
+
const [, n, c] = e;
|
|
19
|
+
if (n.startsWith(u))
|
|
20
|
+
s.fallback = b(n);
|
|
21
21
|
else {
|
|
22
|
-
const l =
|
|
23
|
-
l ? s.format = l :
|
|
22
|
+
const l = p(n) ?? m(n);
|
|
23
|
+
l ? s.format = l : c || (s.fallback = n), c && (s.fallback = b(c));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return s;
|
|
27
|
-
},
|
|
28
|
-
const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t :
|
|
27
|
+
}, v = (t) => {
|
|
28
|
+
const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : y(t);
|
|
29
29
|
return e === null ? null : `${u} ${e}`;
|
|
30
|
-
},
|
|
31
|
-
const
|
|
30
|
+
}, T = (t) => {
|
|
31
|
+
const a = t.format ? g(t.format) : null, e = t.fallback ? v(t.fallback) : null, r = [t.value, a, e].filter(Boolean);
|
|
32
32
|
return {
|
|
33
|
-
label: [t.text,
|
|
34
|
-
value: `{{ ${
|
|
33
|
+
label: [t.text, a, e && t.fallback].filter(Boolean).join(" | "),
|
|
34
|
+
value: `{{ ${r.join(" | ")} }}`
|
|
35
35
|
};
|
|
36
|
-
},
|
|
36
|
+
}, i = (t, a = !1) => t.map((e) => a ? T(e) : e.format ? {
|
|
37
37
|
label: `${e.text} | ${e.format.key}=${e.format.value}`,
|
|
38
38
|
value: `{{${e.value}|${e.format.key}=${e.format.value}}}`
|
|
39
39
|
} : {
|
|
40
40
|
label: e.fallback ? `${e.text} | ${e.fallback}` : e.text,
|
|
41
41
|
value: e.fallback ? `{{${e.value}|${e.fallback}}}` : `{{${e.value}}}`
|
|
42
|
-
}),
|
|
43
|
-
const
|
|
44
|
-
Array.isArray(
|
|
45
|
-
const f = [...l.children ?? [], ...l.select_items ?? []],
|
|
42
|
+
}), d = (t) => {
|
|
43
|
+
const a = [], e = /* @__PURE__ */ new Set(), r = (n, c) => {
|
|
44
|
+
Array.isArray(n) && n.forEach((l) => {
|
|
45
|
+
const f = [...l.children ?? [], ...l.select_items ?? [], ...l.columns ?? []], o = l.text || l.tag_text;
|
|
46
46
|
if (f.length > 0) {
|
|
47
|
-
|
|
47
|
+
r(f, o ? [...c, o] : c);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
o && l.value && !e.has(l.value) && (e.add(l.value), a.push({ value: l.value, text: o, tagText: l.tag_text || o, path: c }));
|
|
51
51
|
});
|
|
52
52
|
}, [s] = Object.values(t ?? {});
|
|
53
|
-
return
|
|
54
|
-
},
|
|
55
|
-
const
|
|
53
|
+
return r(s, []), a;
|
|
54
|
+
}, h = (t) => d(t).map(({ text: a, value: e }) => ({ text: a, value: e })), L = (t, a, e = !1) => {
|
|
55
|
+
const r = new Set(t.map((n) => n.value)), s = a.filter((n) => r.has(n.value) ? !1 : (r.add(n.value), !0));
|
|
56
56
|
return [
|
|
57
|
-
...
|
|
58
|
-
...
|
|
57
|
+
...i(t, e),
|
|
58
|
+
...i(s, e)
|
|
59
59
|
];
|
|
60
|
+
}, k = /url(_\d+)?$/i, _ = /^call_an_api_response_/, $ = (t) => k.test(t) || _.test(t), P = (t, a = !1) => {
|
|
61
|
+
const [e] = Object.values(t ?? {});
|
|
62
|
+
return (e ?? []).map((r) => {
|
|
63
|
+
const s = h({ node: [r] }).filter((n) => $(n.value));
|
|
64
|
+
return {
|
|
65
|
+
category: r.text || r.tag_text || "",
|
|
66
|
+
entries: i(s, a).map(({ label: n, value: c }) => ({ label: n, value: c }))
|
|
67
|
+
};
|
|
68
|
+
}).filter((r) => r.category && r.entries.length > 0);
|
|
60
69
|
}, F = () => {
|
|
61
70
|
var t;
|
|
62
71
|
return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
|
|
63
|
-
},
|
|
72
|
+
}, N = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", C = (t) => {
|
|
64
73
|
if (t === null || typeof t != "object" || Array.isArray(t))
|
|
65
74
|
return !1;
|
|
66
|
-
const
|
|
67
|
-
return
|
|
75
|
+
const a = Object.getPrototypeOf(t);
|
|
76
|
+
return a === Object.prototype || a === null;
|
|
68
77
|
};
|
|
69
78
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
N as asText,
|
|
80
|
+
L as buildMergeTagEntries,
|
|
81
|
+
P as buildSpecialLinkGroups,
|
|
82
|
+
i as dynamicContentToMergeTags,
|
|
83
|
+
d as flattenDynamicContentCandidates,
|
|
84
|
+
h as flattenDynamicContentList,
|
|
75
85
|
F as getCsrfToken,
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
C as isPlainObject,
|
|
87
|
+
A as mergeTagToDynamicContent
|
|
78
88
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { findEditorShadowRoot as a } from "./editorShadowRoot.js";
|
|
2
|
+
const l = ".e2e-link-input .contenteditable-input", c = "https://", p = /^\{\{[^{}]+\}\}$/;
|
|
3
|
+
let e = null;
|
|
4
|
+
const d = (t) => p.test(t), u = (t) => {
|
|
5
|
+
var i;
|
|
6
|
+
const n = t instanceof Element ? t.closest(l) : null;
|
|
7
|
+
return ((i = n == null ? void 0 : n.textContent) == null ? void 0 : i.trim()) === c ? n : null;
|
|
8
|
+
}, r = (t) => {
|
|
9
|
+
var o, s;
|
|
10
|
+
const n = ((o = t.clipboardData) == null ? void 0 : o.getData("text/plain").trim()) ?? "", i = d(n) ? u(t.target) : null;
|
|
11
|
+
if (!i)
|
|
12
|
+
return;
|
|
13
|
+
(s = window.getSelection()) == null || s.selectAllChildren(i), !i.dispatchEvent(new InputEvent("beforeinput", {
|
|
14
|
+
inputType: "insertFromPaste",
|
|
15
|
+
data: n,
|
|
16
|
+
bubbles: !0,
|
|
17
|
+
cancelable: !0
|
|
18
|
+
})) && (t.preventDefault(), t.stopImmediatePropagation());
|
|
19
|
+
}, E = () => {
|
|
20
|
+
e == null || e.removeEventListener("paste", r, !0), e = null;
|
|
21
|
+
}, m = () => {
|
|
22
|
+
E(), e = a(), e == null || e.addEventListener("paste", r, !0);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
E as disposeLinkTokenPaste,
|
|
26
|
+
d as isBareToken,
|
|
27
|
+
m as listenForLinkTokenPaste
|
|
28
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const o = /\s([\w:-]+)\s*=\s*(?:"[^"]*"|'[^']*')/g, E = /^(?:href|src)$/i, e = /\{\{[^{}]*\}\}/g, c = /'[^']*'|'.*?'|"(.*?)"/gs, i = /'|'|'|'|"|"/i, T = (t) => t.replace(
|
|
2
|
+
c,
|
|
3
|
+
(n, s) => s === void 0 || i.test(s) || s.startsWith("//") ? n : `'${s}'`
|
|
4
|
+
);
|
|
5
|
+
function r(t) {
|
|
6
|
+
return t.includes(""") ? t.replace(o, (n, s) => E.test(s) && n.endsWith('"') ? n.replace(e, T) : n) : t;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
r as singleQuoteLiquidLinks
|
|
10
|
+
};
|
|
@@ -1,129 +1,128 @@
|
|
|
1
|
-
import { isNewPriceFormatRoot as
|
|
2
|
-
import { productPairs as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const q = {
|
|
1
|
+
import { isNewPriceFormatRoot as W, ITEMS_PRICE_FORMAT_ATTR as w, currencyPositionFromLocation as V, ITEMS_CURRENCY_ATTR as x, isCustomCurrencySymbol as G } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { productPairs as N } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
|
+
import { preserveTextStyles as H } from "./preserveTextStyles.js";
|
|
4
|
+
import { protectTableText as Y, restoreTableText as B } from "./protectTableText.js";
|
|
5
|
+
import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
|
|
6
|
+
const D = {
|
|
8
7
|
CART_ITEMS: "ins_apr",
|
|
9
8
|
BROWSED_ITEMS: "browsed_item",
|
|
10
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
11
|
-
},
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
for (;
|
|
15
|
-
|
|
16
|
-
return
|
|
10
|
+
}, U = (r) => r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v(r, _, u) {
|
|
12
|
+
let l = _;
|
|
13
|
+
for (; l > 0 && /\s/.test(r[l - 1]); )
|
|
14
|
+
l -= 1;
|
|
15
|
+
return u.some((p) => r.endsWith(p, l));
|
|
17
16
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
var
|
|
21
|
-
const
|
|
22
|
-
for (let
|
|
23
|
-
(
|
|
17
|
+
const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
18
|
+
function Q(r, _) {
|
|
19
|
+
var l;
|
|
20
|
+
const u = r.ownerDocument.createTreeWalker(r, NodeFilter.SHOW_COMMENT);
|
|
21
|
+
for (let p = u.nextNode(); p; p = u.nextNode())
|
|
22
|
+
(l = p.nodeValue) != null && l.includes("[if mso]") && (p.nodeValue = p.nodeValue.replace(j, (I, E) => `${E}href="${_}"`));
|
|
24
23
|
}
|
|
25
|
-
function
|
|
24
|
+
function z(r) {
|
|
26
25
|
return {
|
|
27
26
|
isFormatted: r.getAttribute("data-formated") === "true",
|
|
28
27
|
isSinglePrice: r.getAttribute("data-single_price") === "true",
|
|
29
|
-
currencyPosition: r.getAttribute(
|
|
30
|
-
configuredSymbol: (r.getAttribute(
|
|
28
|
+
currencyPosition: r.getAttribute(x.POSITION) || "before",
|
|
29
|
+
configuredSymbol: (r.getAttribute(x.SYMBOL) || "").trim()
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
|
-
function
|
|
32
|
+
function J(r) {
|
|
34
33
|
return {
|
|
35
34
|
isFormatted: !1,
|
|
36
|
-
isSinglePrice: r.getAttribute(
|
|
37
|
-
currencyPosition:
|
|
38
|
-
r.getAttribute(
|
|
35
|
+
isSinglePrice: r.getAttribute(w.SINGLE_PRICE) === "true",
|
|
36
|
+
currencyPosition: V(
|
|
37
|
+
r.getAttribute(w.ALIGNMENT) ?? void 0
|
|
39
38
|
),
|
|
40
|
-
configuredSymbol: (r.getAttribute(
|
|
39
|
+
configuredSymbol: (r.getAttribute(w.SYMBOL) || "").trim()
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
|
-
function
|
|
44
|
-
const { isFormatted:
|
|
42
|
+
function K(r, _, u) {
|
|
43
|
+
const { isFormatted: l, isSinglePrice: p, currencyPosition: I, configuredSymbol: E } = u;
|
|
45
44
|
let y;
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
return
|
|
45
|
+
p ? y = l ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = l ? r.PRICE_FORMATTED : r.PRICE;
|
|
46
|
+
const b = r.CURRENCY;
|
|
47
|
+
let S = `{{${y}_${_}}}`, o = "";
|
|
48
|
+
return G(E) ? o = E : b && (o = `{{${b}_${_}}}`), o && (S = I === "after" ? `${S} ${o}` : `${o} ${S}`), S;
|
|
50
49
|
}
|
|
51
|
-
function
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
Object.entries(
|
|
56
|
-
|
|
57
|
-
const
|
|
50
|
+
function nt(r) {
|
|
51
|
+
const _ = U(Y(r)), u = new DOMParser().parseFromString(_, "text/html");
|
|
52
|
+
X(u);
|
|
53
|
+
const l = N.PAIRS_FOR_EXTENSION;
|
|
54
|
+
Object.entries(l).forEach(([o, R]) => {
|
|
55
|
+
u.querySelectorAll(".ins-product-td").forEach((n) => {
|
|
56
|
+
const m = n.getAttribute("data-number") || "1", C = n.getAttribute("data-type") || "CART_ITEMS";
|
|
58
57
|
n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
59
|
-
var
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
58
|
+
var h, L, k, O;
|
|
59
|
+
const P = t.getAttribute("data-type") || C, c = t.getAttribute("data-number") || m, d = R[P];
|
|
60
|
+
if (d)
|
|
62
61
|
switch (o) {
|
|
63
62
|
case "imageSrc": {
|
|
64
63
|
let e = null, i = null;
|
|
65
64
|
if (t.tagName === "IMG" ? (e = t, i = e.closest("a")) : (e = t.querySelector("img"), i = t.querySelector("a") || t.closest("a")), !e)
|
|
66
65
|
break;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
return
|
|
66
|
+
const A = d.DEFAULT, a = d.ATTR;
|
|
67
|
+
if (A && e.src) {
|
|
68
|
+
const f = e.src;
|
|
69
|
+
A.some((F) => {
|
|
70
|
+
const T = F.split("/").pop() || "", q = f.split("/").pop() || "";
|
|
71
|
+
return f.includes(F) || f.includes(T) || q === T;
|
|
73
72
|
}) && (e.src = `{{${a}_${c}}}`);
|
|
74
73
|
}
|
|
75
|
-
const s = (
|
|
74
|
+
const s = (L = (h = l.name) == null ? void 0 : h[P]) == null ? void 0 : L.ATTR;
|
|
76
75
|
if (s && e.setAttribute("alt", `{{${s}_${c}}}`), i) {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
(
|
|
76
|
+
const f = (k = l.itemLink) == null ? void 0 : k[P];
|
|
77
|
+
if (f) {
|
|
78
|
+
const M = f.HREF, F = f.DEFAULT_HREF || "#!", T = i.href;
|
|
79
|
+
(T === "#" || T === "" || T.endsWith("#!") || T.endsWith(F) || T === `${window.location.href}${F}` || !T || T === window.location.href) && (i.href = `{{${M}_${c}}}`);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
break;
|
|
84
83
|
}
|
|
85
84
|
case "name": {
|
|
86
|
-
const e =
|
|
87
|
-
t.textContent && (t.innerHTML =
|
|
85
|
+
const e = d, i = e.ATTR, A = e.DEFAULT_HREF || "#!", a = e.HREF;
|
|
86
|
+
t.textContent && (t.innerHTML = H(t, `{{${i}_${c}}}`));
|
|
88
87
|
const s = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
89
88
|
if (s && a) {
|
|
90
|
-
const
|
|
91
|
-
(
|
|
89
|
+
const f = s.href, M = `${window.location.href}${A}`;
|
|
90
|
+
(f === M || f.endsWith(A)) && (s.href = `{{${a}_${c}}}`);
|
|
92
91
|
}
|
|
93
92
|
break;
|
|
94
93
|
}
|
|
95
94
|
case "price":
|
|
96
95
|
case "originalPrice": {
|
|
97
|
-
const e =
|
|
98
|
-
t.innerHTML =
|
|
96
|
+
const e = d, i = W(n) ? J(n) : z(t);
|
|
97
|
+
t.innerHTML = H(t, K(e, c, i));
|
|
99
98
|
break;
|
|
100
99
|
}
|
|
101
100
|
case "quantity": {
|
|
102
|
-
const e =
|
|
103
|
-
a &&
|
|
101
|
+
const e = d, i = e.ATTR, A = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (O = t.textContent) == null ? void 0 : O.trim();
|
|
102
|
+
a && A.includes(a) && (t.innerHTML = H(t, `{{${i}_${c}}}`));
|
|
104
103
|
break;
|
|
105
104
|
}
|
|
106
105
|
case "button": {
|
|
107
|
-
const e =
|
|
106
|
+
const e = d, i = e.HREF, A = e.DEFAULT_HREF || "#!", a = t.tagName === "A" ? t : t.querySelector("a");
|
|
108
107
|
if (a) {
|
|
109
|
-
const s = a.href || "",
|
|
110
|
-
(s === "" || s === "#" || s ===
|
|
108
|
+
const s = a.href || "", f = `${window.location.href}${A}`;
|
|
109
|
+
(s === "" || s === "#" || s === f || s.endsWith(A) || s.endsWith("#!") || s === window.location.href) && (a.href = `{{${i}_${c}}}`);
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
Q(t, `{{${i}_${c}}}`);
|
|
113
112
|
break;
|
|
114
113
|
}
|
|
115
114
|
case "itemLink": {
|
|
116
|
-
const e =
|
|
115
|
+
const e = d, i = e.HREF, A = e.DEFAULT_HREF || "#!", a = t;
|
|
117
116
|
if (a.href) {
|
|
118
|
-
const s = a.href,
|
|
119
|
-
(s ===
|
|
117
|
+
const s = a.href, f = `${window.location.href}${A}`;
|
|
118
|
+
(s === f || s.endsWith(A)) && (a.href = `{{${i}_${c}}}`);
|
|
120
119
|
}
|
|
121
120
|
break;
|
|
122
121
|
}
|
|
123
122
|
default: {
|
|
124
|
-
if ("ATTR" in
|
|
125
|
-
const e =
|
|
126
|
-
t.textContent && (t.innerHTML =
|
|
123
|
+
if ("ATTR" in d) {
|
|
124
|
+
const e = d.ATTR;
|
|
125
|
+
t.textContent && (t.innerHTML = H(t, `{{${e}_${c}}}`));
|
|
127
126
|
}
|
|
128
127
|
break;
|
|
129
128
|
}
|
|
@@ -131,49 +130,40 @@ function at(r) {
|
|
|
131
130
|
});
|
|
132
131
|
});
|
|
133
132
|
});
|
|
134
|
-
const
|
|
135
|
-
` : ""
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
number: _
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
let E = L + p.documentElement.outerHTML;
|
|
146
|
-
y.reverse().forEach(({ outerHtml: o, type: T, number: _ }) => {
|
|
147
|
-
const n = q[T], S = n ? `${n}_total_product_kind` : "";
|
|
148
|
-
if (S) {
|
|
149
|
-
const b = parseInt(_) - 1, c = `${`{% if ${S} > ${b} %}`}${o}{% endif %}`;
|
|
150
|
-
E = E.replace(o, v(c));
|
|
151
|
-
}
|
|
133
|
+
const p = _.match(/<!DOCTYPE[^>]*>/i), I = p ? `${p[0]}
|
|
134
|
+
` : "";
|
|
135
|
+
u.querySelectorAll(".ins-product-td").forEach((o) => {
|
|
136
|
+
const R = o.getAttribute("data-type") || "CART_ITEMS", $ = D[R];
|
|
137
|
+
if (!$)
|
|
138
|
+
return;
|
|
139
|
+
const n = parseInt(o.getAttribute("data-number") || "1") - 1;
|
|
140
|
+
o.before(u.createComment(`{% if ${$}_total_product_kind > ${n} %}`)), o.after(u.createComment("{% endif %}"));
|
|
152
141
|
});
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
let E = I + u.documentElement.outerHTML;
|
|
143
|
+
const y = u.querySelectorAll('[product-attr="originalPrice"][data-type]'), b = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set();
|
|
144
|
+
return y.forEach((o) => {
|
|
155
145
|
var t;
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
146
|
+
const R = o.getAttribute("data-number"), $ = o.getAttribute("data-type");
|
|
147
|
+
if (!R || !D[$])
|
|
158
148
|
return;
|
|
159
149
|
const n = o.closest(".product-original-price-class");
|
|
160
|
-
if (!n ||
|
|
150
|
+
if (!n || S.has(n))
|
|
161
151
|
return;
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
}),
|
|
166
|
-
if (n.includes("{% if") ||
|
|
152
|
+
S.add(n);
|
|
153
|
+
const m = n.outerHTML, C = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), g = b.get(m) ?? { number: R, type: $, wrap: [] };
|
|
154
|
+
g.wrap.push(C !== "false"), b.set(m, g);
|
|
155
|
+
}), b.forEach(({ number: o, type: R, wrap: $ }, n) => {
|
|
156
|
+
if (n.includes("{% if") || !$.some(Boolean))
|
|
167
157
|
return;
|
|
168
|
-
const
|
|
169
|
-
let
|
|
170
|
-
for (;
|
|
171
|
-
const
|
|
172
|
-
|
|
158
|
+
const m = N.PAIRS_FOR_EXTENSION.price[R].PRICE, C = N.PAIRS_FOR_EXTENSION.originalPrice[R].PRICE, g = `{% if ${m}_${o} != ${C}_${o} %}`, t = [g, U(g)];
|
|
159
|
+
let P = "", c = 0, d = 0, h = E.indexOf(n);
|
|
160
|
+
for (; h !== -1; ) {
|
|
161
|
+
const L = $[d] === !0 && !v(E, h, t);
|
|
162
|
+
P += E.slice(c, h) + (L ? `${g}${n}{% endif %}` : n), c = h + n.length, d += 1, h = E.indexOf(n, c);
|
|
173
163
|
}
|
|
174
|
-
E =
|
|
175
|
-
}),
|
|
164
|
+
E = P + E.slice(c);
|
|
165
|
+
}), B(E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
176
166
|
}
|
|
177
167
|
export {
|
|
178
|
-
|
|
168
|
+
nt as pairProductVariables
|
|
179
169
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.30.0-beta.
|
|
3
|
+
"version": "3.30.0-beta.25ed52c",
|
|
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",
|