@useinsider/guido 3.17.0-beta.6b5cdfc → 3.17.0-beta.8dc8fbb
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.
|
@@ -2,6 +2,8 @@ import type { BaseDynamicContent } from '@@/Types/generic';
|
|
|
2
2
|
export type DynamicContentFormat = NonNullable<BaseDynamicContent['format']>;
|
|
3
3
|
/** Format key the dynamic-content picker sends for a custom date/time format. */
|
|
4
4
|
export declare const TIME_FORMAT_KEY = "time-format";
|
|
5
|
+
/** Wraps a Liquid filter argument in whichever quote style the value itself does not use. */
|
|
6
|
+
export declare const quoteArgument: (value: string) => string | null;
|
|
5
7
|
/**
|
|
6
8
|
* `{ key: 'time-format', value: '%Y-%m-%d' }` -> `date: "%Y-%m-%d"`.
|
|
7
9
|
*
|
|
@@ -1,68 +1,71 @@
|
|
|
1
|
-
import { formatToLiquidFilter as v,
|
|
2
|
-
const
|
|
3
|
-
if (!
|
|
1
|
+
import { formatToLiquidFilter as v, quoteArgument as b, liquidFilterToFormat as h } from "./liquidDynamicContent.js";
|
|
2
|
+
const k = (a) => {
|
|
3
|
+
if (!a.includes("="))
|
|
4
4
|
return null;
|
|
5
|
-
const [e,
|
|
6
|
-
return { key: e.trim(), value:
|
|
7
|
-
},
|
|
8
|
-
if (!
|
|
9
|
-
return
|
|
10
|
-
const e =
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
const
|
|
14
|
-
text:
|
|
15
|
-
value:
|
|
5
|
+
const [e, t] = a.split("=");
|
|
6
|
+
return { key: e.trim(), value: t.trim() };
|
|
7
|
+
}, c = "default:", f = (a) => {
|
|
8
|
+
if (!a.startsWith(c))
|
|
9
|
+
return a;
|
|
10
|
+
const e = a.slice(c.length).trim(), t = (r) => e.length >= 2 && e.startsWith(r) && e.endsWith(r);
|
|
11
|
+
return t('"') || t("'") ? e.slice(1, -1) : e;
|
|
12
|
+
}, d = (a) => {
|
|
13
|
+
const t = a.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((l) => l.trim()), [r] = t, s = {
|
|
14
|
+
text: a.label,
|
|
15
|
+
value: r || ""
|
|
16
16
|
};
|
|
17
|
-
if (
|
|
18
|
-
const [, l,
|
|
19
|
-
if (l.startsWith(
|
|
20
|
-
|
|
17
|
+
if (t.length >= 2) {
|
|
18
|
+
const [, l, n] = t;
|
|
19
|
+
if (l.startsWith(c))
|
|
20
|
+
s.fallback = f(l);
|
|
21
21
|
else {
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const u = h(l) ?? k(l);
|
|
23
|
+
u ? s.format = u : n || (s.fallback = l), n && (s.fallback = f(n));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
const
|
|
26
|
+
return s;
|
|
27
|
+
}, m = (a) => {
|
|
28
|
+
const t = !Number.isNaN(Number(a)) && a.trim() !== "" ? a : b(a);
|
|
29
|
+
return t === null ? null : `${c} ${t}`;
|
|
30
|
+
}, g = (a) => {
|
|
31
|
+
const e = a.format ? v(a.format) : null, t = a.fallback ? m(a.fallback) : null, r = [a.value, e, t].filter(Boolean);
|
|
29
32
|
return {
|
|
30
|
-
label: [
|
|
31
|
-
value: `{{ ${
|
|
33
|
+
label: [a.text, e, t && a.fallback].filter(Boolean).join(" | "),
|
|
34
|
+
value: `{{ ${r.join(" | ")} }}`
|
|
32
35
|
};
|
|
33
|
-
}, i = (
|
|
34
|
-
label: `${
|
|
35
|
-
value: `{{${
|
|
36
|
+
}, i = (a, e = !1) => a.map((t) => e ? g(t) : t.format ? {
|
|
37
|
+
label: `${t.text} | ${t.format.key}=${t.format.value}`,
|
|
38
|
+
value: `{{${t.value}|${t.format.key}=${t.format.value}}}`
|
|
36
39
|
} : {
|
|
37
|
-
label:
|
|
38
|
-
value:
|
|
39
|
-
}),
|
|
40
|
-
const e = [],
|
|
41
|
-
Array.isArray(l) && l.forEach((
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
|
|
40
|
+
label: t.fallback ? `${t.text} | ${t.fallback}` : t.text,
|
|
41
|
+
value: t.fallback ? `{{${t.value}|${t.fallback}}}` : `{{${t.value}}}`
|
|
42
|
+
}), y = (a) => {
|
|
43
|
+
const e = [], t = /* @__PURE__ */ new Set(), r = (l) => {
|
|
44
|
+
Array.isArray(l) && l.forEach((n) => {
|
|
45
|
+
const u = [...n.children ?? [], ...n.select_items ?? []];
|
|
46
|
+
if (u.length > 0) {
|
|
47
|
+
r(u);
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
|
-
const o =
|
|
48
|
-
o &&
|
|
50
|
+
const o = n.text || n.tag_text;
|
|
51
|
+
o && n.value && !t.has(n.value) && (t.add(n.value), e.push({ text: o, value: n.value }));
|
|
49
52
|
});
|
|
50
|
-
}, [
|
|
51
|
-
return s
|
|
52
|
-
},
|
|
53
|
-
const
|
|
53
|
+
}, [s] = Object.values(a ?? {});
|
|
54
|
+
return r(s), e;
|
|
55
|
+
}, p = (a, e, t = !1) => {
|
|
56
|
+
const r = new Set(a.map((l) => l.value)), s = e.filter((l) => r.has(l.value) ? !1 : (r.add(l.value), !0));
|
|
54
57
|
return [
|
|
55
|
-
...i(
|
|
56
|
-
...i(
|
|
58
|
+
...i(a, t),
|
|
59
|
+
...i(s, t)
|
|
57
60
|
];
|
|
58
|
-
},
|
|
59
|
-
var
|
|
60
|
-
return ((
|
|
61
|
+
}, F = () => {
|
|
62
|
+
var a;
|
|
63
|
+
return ((a = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : a.getAttribute("content")) ?? "";
|
|
61
64
|
};
|
|
62
65
|
export {
|
|
63
|
-
|
|
66
|
+
p as buildMergeTagEntries,
|
|
64
67
|
i as dynamicContentToMergeTags,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
y as flattenDynamicContentList,
|
|
69
|
+
F as getCsrfToken,
|
|
70
|
+
d as mergeTagToDynamicContent
|
|
68
71
|
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
const
|
|
2
|
-
if (t.key !==
|
|
1
|
+
const E = "time-format", r = "date", u = new RegExp(`^${r}\\s*:\\s*(?:"([^"]*)"|'([^']*)')$`), s = /%[-_0^#]?\d*[a-zA-Z%]/, c = new RegExp(s, "g"), l = /\b(?:Y{2,4}|M{2,4}|D{1,4}|d{3,4}|H{2}|h{2}|m{2}|s{2}|S{1,3}|A|a)\b/, T = (t) => t.includes('"') ? t.includes("'") ? null : `'${t}'` : `"${t}"`, i = (t) => s.test(t) && !l.test(t.replace(c, "")), R = (t) => {
|
|
2
|
+
if (t.key !== E || !i(t.value ?? ""))
|
|
3
3
|
return null;
|
|
4
|
-
const n =
|
|
4
|
+
const n = T(t.value);
|
|
5
5
|
return n === null ? null : `${r}: ${n}`;
|
|
6
|
-
},
|
|
7
|
-
const [, n, o] = t.match(
|
|
8
|
-
return e ? { key:
|
|
6
|
+
}, _ = (t) => {
|
|
7
|
+
const [, n, o] = t.match(u) ?? [], e = n ?? o;
|
|
8
|
+
return e ? { key: E, value: e } : null;
|
|
9
9
|
};
|
|
10
10
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
E as TIME_FORMAT_KEY,
|
|
12
|
+
R as formatToLiquidFilter,
|
|
13
|
+
_ as liquidFilterToFormat,
|
|
14
|
+
T as quoteArgument
|
|
14
15
|
};
|
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.8dc8fbb",
|
|
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",
|