@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, liquidFilterToFormat as b } from "./liquidDynamicContent.js";
2
- const h = (t) => {
3
- if (!t.includes("="))
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, a] = t.split("=");
6
- return { key: e.trim(), value: a.trim() };
7
- }, u = "default:", f = (t) => {
8
- if (!t.startsWith(u))
9
- return t;
10
- const e = t.slice(u.length).trim();
11
- return e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e;
12
- }, g = (t) => {
13
- const a = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((l) => l.trim()), [s] = a, n = {
14
- text: t.label,
15
- value: s || ""
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 (a.length >= 2) {
18
- const [, l, r] = a;
19
- if (l.startsWith(u))
20
- n.fallback = f(l);
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 c = b(l) ?? h(l);
23
- c ? n.format = c : r || (n.fallback = l), r && (n.fallback = f(r));
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 n;
27
- }, k = (t) => !Number.isNaN(Number(t)) && t.trim() !== "" ? t : `"${t}"`, m = (t) => {
28
- const e = t.format ? v(t.format) : null, a = t.fallback ? `${u} ${k(t.fallback)}` : null, s = [t.value, e, a].filter(Boolean);
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: [t.text, e, t.fallback || null].filter(Boolean).join(" | "),
31
- value: `{{ ${s.join(" | ")} }}`
33
+ label: [a.text, e, t && a.fallback].filter(Boolean).join(" | "),
34
+ value: `{{ ${r.join(" | ")} }}`
32
35
  };
33
- }, i = (t, e = !1) => t.map((a) => e ? m(a) : a.format ? {
34
- label: `${a.text} | ${a.format.key}=${a.format.value}`,
35
- value: `{{${a.value}|${a.format.key}=${a.format.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: a.fallback ? `${a.text} | ${a.fallback}` : a.text,
38
- value: a.fallback ? `{{${a.value}|${a.fallback}}}` : `{{${a.value}}}`
39
- }), d = (t) => {
40
- const e = [], a = /* @__PURE__ */ new Set(), s = (l) => {
41
- Array.isArray(l) && l.forEach((r) => {
42
- const c = [...r.children ?? [], ...r.select_items ?? []];
43
- if (c.length > 0) {
44
- s(c);
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 = r.text || r.tag_text;
48
- o && r.value && !a.has(r.value) && (a.add(r.value), e.push({ text: o, value: r.value }));
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
- }, [n] = Object.values(t ?? {});
51
- return s(n), e;
52
- }, y = (t, e, a = !1) => {
53
- const s = new Set(t.map((l) => l.value)), n = e.filter((l) => s.has(l.value) ? !1 : (s.add(l.value), !0));
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(t, a),
56
- ...i(n, a)
58
+ ...i(a, t),
59
+ ...i(s, t)
57
60
  ];
58
- }, p = () => {
59
- var t;
60
- return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
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
- y as buildMergeTagEntries,
66
+ p as buildMergeTagEntries,
64
67
  i as dynamicContentToMergeTags,
65
- d as flattenDynamicContentList,
66
- p as getCsrfToken,
67
- g as mergeTagToDynamicContent
68
+ y as flattenDynamicContentList,
69
+ F as getCsrfToken,
70
+ d as mergeTagToDynamicContent
68
71
  };
@@ -1,14 +1,15 @@
1
- const u = "time-format", r = "date", l = new RegExp(`^${r}\\s*:\\s*(?:"([^"]*)"|'([^']*)')$`), s = /%[-_0^#]?\d*[a-zA-Z%]/, E = (t) => t.includes('"') ? t.includes("'") ? null : `'${t}'` : `"${t}"`, c = (t) => {
2
- if (t.key !== u || !s.test(t.value ?? ""))
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 = E(t.value);
4
+ const n = T(t.value);
5
5
  return n === null ? null : `${r}: ${n}`;
6
- }, i = (t) => {
7
- const [, n, o] = t.match(l) ?? [], e = n ?? o;
8
- return e ? { key: u, value: e } : null;
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
- u as TIME_FORMAT_KEY,
12
- c as formatToLiquidFilter,
13
- i as liquidFilterToFormat
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.6b5cdfc",
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",