@useinsider/guido 3.17.0-beta.77567eb → 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.
@@ -1,4 +1,4 @@
1
- const o = { stripo: { version: "2.73.0" } }, s = {
1
+ const o = { stripo: { version: "2.72.1" } }, s = {
2
2
  guido: o
3
3
  };
4
4
  export {
@@ -0,0 +1,20 @@
1
+ import type { BaseDynamicContent } from '@@/Types/generic';
2
+ export type DynamicContentFormat = NonNullable<BaseDynamicContent['format']>;
3
+ /** Format key the dynamic-content picker sends for a custom date/time format. */
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;
7
+ /**
8
+ * `{ key: 'time-format', value: '%Y-%m-%d' }` -> `date: "%Y-%m-%d"`.
9
+ *
10
+ * Only a custom date/time strftime pattern has a Liquid equivalent. Anything else returns null so
11
+ * the caller emits a plain tag rather than one that silently lost — or literally printed — its
12
+ * format.
13
+ * @example formatToLiquidFilter({ key: 'time-format', value: '%b %-d, %Y' }) -> date: "%b %-d, %Y"
14
+ */
15
+ export declare const formatToLiquidFilter: (format: DynamicContentFormat) => string | null;
16
+ /**
17
+ * Inverse of `formatToLiquidFilter` — reads the picker format back out of one filter segment, so a
18
+ * reopened tag restores its selection in the host's format dropdown.
19
+ */
20
+ export declare const liquidFilterToFormat: (segment: string) => DynamicContentFormat | null;
@@ -1,68 +1,71 @@
1
- const o = (l) => {
2
- const a = l.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((t) => t.trim()), [c] = a, r = {
3
- text: l.label,
4
- value: c || ""
1
+ import { formatToLiquidFilter as v, quoteArgument as b, liquidFilterToFormat as h } from "./liquidDynamicContent.js";
2
+ const k = (a) => {
3
+ if (!a.includes("="))
4
+ return null;
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 || ""
5
16
  };
6
- if (a.length >= 2) {
7
- const [, t, e] = a;
8
- if (t.startsWith("default:")) {
9
- let n = t.slice(8).trim();
10
- n.startsWith('"') && n.endsWith('"') && (n = n.slice(1, -1)), r.fallback = n;
11
- } else {
12
- const n = t.includes("=") ? { key: t.split("=")[0].trim(), value: t.split("=")[1].trim() } : null;
13
- n ? r.format = n : e || (r.fallback = t), e && (r.fallback = e);
17
+ if (t.length >= 2) {
18
+ const [, l, n] = t;
19
+ if (l.startsWith(c))
20
+ s.fallback = f(l);
21
+ else {
22
+ const u = h(l) ?? k(l);
23
+ u ? s.format = u : n || (s.fallback = l), n && (s.fallback = f(n));
14
24
  }
15
25
  }
16
- return r;
17
- }, f = (l, s = !1) => l.map((a) => {
18
- if (a.format)
19
- return {
20
- label: `${a.text} | ${a.format.key}=${a.format.value}`,
21
- value: `{{${a.value}|${a.format.key}=${a.format.value}}}`
22
- };
23
- if (s) {
24
- if (!a.fallback)
25
- return {
26
- label: a.text,
27
- value: `{{ ${a.value} }}`
28
- };
29
- const r = !Number.isNaN(Number(a.fallback)) && a.fallback.trim() !== "" ? a.fallback : `"${a.fallback}"`;
30
- return {
31
- label: `${a.text} | ${a.fallback}`,
32
- value: `{{ ${a.value} | default: ${r} }}`
33
- };
34
- }
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);
35
32
  return {
36
- label: a.fallback ? `${a.text} | ${a.fallback}` : a.text,
37
- value: a.fallback ? `{{${a.value}|${a.fallback}}}` : `{{${a.value}}}`
33
+ label: [a.text, e, t && a.fallback].filter(Boolean).join(" | "),
34
+ value: `{{ ${r.join(" | ")} }}`
38
35
  };
39
- }), b = (l) => {
40
- const s = [], a = /* @__PURE__ */ new Set(), c = (t) => {
41
- Array.isArray(t) && t.forEach((e) => {
42
- const n = [...e.children ?? [], ...e.select_items ?? []];
43
- if (n.length > 0) {
44
- c(n);
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}}}`
39
+ } : {
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 u = e.text || e.tag_text;
48
- u && e.value && !a.has(e.value) && (a.add(e.value), s.push({ text: u, value: e.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
- }, [r] = Object.values(l ?? {});
51
- return c(r), s;
52
- }, v = (l, s, a = !1) => {
53
- const c = new Set(l.map((t) => t.value)), r = s.filter((t) => c.has(t.value) ? !1 : (c.add(t.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
- ...f(l, a),
56
- ...f(r, a)
58
+ ...i(a, t),
59
+ ...i(s, t)
57
60
  ];
58
- }, i = () => {
59
- var l;
60
- return ((l = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : l.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
- v as buildMergeTagEntries,
64
- f as dynamicContentToMergeTags,
65
- b as flattenDynamicContentList,
66
- i as getCsrfToken,
67
- o as mergeTagToDynamicContent
66
+ p as buildMergeTagEntries,
67
+ i as dynamicContentToMergeTags,
68
+ y as flattenDynamicContentList,
69
+ F as getCsrfToken,
70
+ d as mergeTagToDynamicContent
68
71
  };
@@ -0,0 +1,15 @@
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
+ return null;
4
+ const n = T(t.value);
5
+ return n === null ? null : `${r}: ${n}`;
6
+ }, _ = (t) => {
7
+ const [, n, o] = t.match(u) ?? [], e = n ?? o;
8
+ return e ? { key: E, value: e } : null;
9
+ };
10
+ export {
11
+ E as TIME_FORMAT_KEY,
12
+ R as formatToLiquidFilter,
13
+ _ as liquidFilterToFormat,
14
+ T as quoteArgument
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.17.0-beta.77567eb",
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",
@@ -117,7 +117,7 @@
117
117
  },
118
118
  "guido": {
119
119
  "stripo": {
120
- "version": "2.73.0"
120
+ "version": "2.72.1"
121
121
  }
122
122
  }
123
123
  }