@useinsider/guido 3.27.0-beta.cf35c0c → 3.27.0-beta.ee85b86

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,31 +1,45 @@
1
- import { DATA_ATTRIBUTE_REGEX as A, DYNAMIC_CONTENT_TAG_REGEX as m, ALLOWED_DYNAMIC_SYSTEM_TOKENS as D } from "../enums/html-validator.js";
2
- import { dynamicContentToMergeTags as T } from "./genericUtil.js";
3
- const p = "guidoDataMask", M = "EndDataMask", f = /guidoDataMask(\d+)EndDataMask/g, h = /^\d+_\d+_.+$/, E = (o) => o.trim().toLowerCase(), I = (...o) => {
4
- const r = /* @__PURE__ */ new Map();
5
- return o.forEach((i) => {
6
- i.forEach((s) => {
7
- const a = E(s.text);
8
- a && r.set(a, s);
1
+ import { DATA_ATTRIBUTE_REGEX as g, DYNAMIC_CONTENT_TAG_REGEX as A, ALLOWED_DYNAMIC_SYSTEM_TOKENS as T } from "../enums/html-validator.js";
2
+ import { dynamicContentToMergeTags as D } from "./genericUtil.js";
3
+ const f = "guidoDataMask", h = "EndDataMask", v = /guidoDataMask(\d+)EndDataMask/g, M = /^\d+_\d+_.+$/, d = (e) => e.trim().toLowerCase(), E = (e, n) => {
4
+ const t = [];
5
+ return e.replace(g, (o) => (t.push(o), `${f}${t.length - 1}${h}`)).replace(A, (o) => {
6
+ const i = o.slice(2, -2), c = i.indexOf("|"), l = c === -1 ? i : i.slice(0, c);
7
+ return n({ tag: o, inner: i, pipeIndex: c, namePart: l, name: l.trim() });
8
+ }).replace(v, (o, i) => t[Number(i)]);
9
+ }, _ = (e, n) => e.pipeIndex !== -1 ? `{{${e.namePart.replace(e.name, () => n)}${e.inner.slice(e.pipeIndex)}}}` : D([{ text: e.name, value: n }])[0].value, w = (e) => {
10
+ const n = /* @__PURE__ */ new Map();
11
+ return e.forEach((t) => {
12
+ new Set([t.text, t.tagText].map(d)).forEach((s) => {
13
+ if (!s)
14
+ return;
15
+ let a = n.get(s);
16
+ a || (a = [], n.set(s, a)), a.some((o) => o.value === t.value) || a.push(t);
9
17
  });
10
- }), r;
11
- }, w = (o, r, i) => {
12
- const s = /* @__PURE__ */ new Set(), a = new Set([...r.values()].map((e) => e.value)), u = [];
13
- return { html: o.replace(A, (e) => (u.push(e), `${p}${u.length - 1}${M}`)).replace(m, (e) => {
14
- const n = e.slice(2, -2), c = n.indexOf("|"), l = c === -1 ? n : n.slice(0, c), t = l.trim();
15
- if (t === "" || D.includes(t) || t.includes(".") || h.test(t) || a.has(t))
16
- return e;
17
- const d = r.get(E(t));
18
- if (d) {
19
- if (c !== -1) {
20
- const _ = n.slice(c);
21
- return `{{${l.replace(t, () => d.value)}${_}}}`;
22
- }
23
- return T([d], i)[0].value;
18
+ }), n;
19
+ }, x = (e, n, t = []) => {
20
+ const s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
21
+ ...[...n.values()].flat().map((c) => c.value),
22
+ ...t
23
+ ]);
24
+ return { html: E(e, (c) => {
25
+ const { tag: l, name: r } = c;
26
+ if (r === "" || T.includes(r) || r.includes(".") || M.test(r) || o.has(r))
27
+ return l;
28
+ const m = d(r), u = n.get(m) ?? [];
29
+ if (u.length === 1)
30
+ return _(c, u[0].value);
31
+ if (u.length > 1) {
32
+ const p = a.get(m) ?? { label: r, spellings: [], candidates: u };
33
+ return p.spellings.includes(r) || p.spellings.push(r), a.set(m, p), l;
24
34
  }
25
- return s.add(t), e;
26
- }).replace(f, (e, n) => u[Number(n)]), unresolved: [...s] };
27
- };
35
+ return s.add(r), l;
36
+ }), unresolved: [...s], ambiguous: [...a.values()] };
37
+ }, I = (e, n) => E(e, (t) => {
38
+ const s = n.get(t.name);
39
+ return s ? _(t, s) : t.tag;
40
+ });
28
41
  export {
29
- I as buildDynamicContentLookup,
30
- w as convertModuleDynamicContent
42
+ I as applyDynamicContentChoices,
43
+ w as buildDynamicContentLookup,
44
+ x as convertModuleDynamicContent
31
45
  };
@@ -0,0 +1,6 @@
1
+ import { ModuleDynamicContentAttribute as n } from "../enums/dynamic-content.js";
2
+ const t = `\\s+${n.Pending}="[^"]*"`, o = (e) => e.replace(new RegExp(t, "g"), "");
3
+ export {
4
+ t as PENDING_MARKER_PATTERN,
5
+ o as stripPendingMarker
6
+ };
@@ -1,78 +1,78 @@
1
- import { formatToLiquidFilter as b, quoteArgument as y, liquidFilterToFormat as h } from "./liquidDynamicContent.js";
2
- const g = (t) => {
1
+ import { formatToLiquidFilter as y, liquidFilterToFormat as g, quoteArgument as m } from "./liquidDynamicContent.js";
2
+ const v = (t) => {
3
3
  if (!t.includes("="))
4
4
  return null;
5
5
  const [r, e] = t.split("=");
6
6
  return { key: r.trim(), value: e.trim() };
7
- }, c = "default:", f = (t) => {
8
- if (!t.startsWith(c))
7
+ }, u = "default:", i = (t) => {
8
+ if (!t.startsWith(u))
9
9
  return t;
10
- const r = t.slice(c.length).trim(), e = (l) => r.length >= 2 && r.startsWith(l) && r.endsWith(l);
10
+ const r = t.slice(u.length).trim(), e = (n) => r.length >= 2 && r.startsWith(n) && r.endsWith(n);
11
11
  return e('"') || e("'") ? r.slice(1, -1) : r;
12
- }, k = (t) => {
13
- const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((a) => a.trim()), [l] = e, s = {
12
+ }, $ = (t) => {
13
+ const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((a) => a.trim()), [n] = e, s = {
14
14
  text: t.label,
15
- value: l || ""
15
+ value: n || ""
16
16
  };
17
17
  if (e.length >= 2) {
18
- const [, a, n] = e;
19
- if (a.startsWith(c))
20
- s.fallback = f(a);
18
+ const [, a, o] = e;
19
+ if (a.startsWith(u))
20
+ s.fallback = i(a);
21
21
  else {
22
- const o = h(a) ?? g(a);
23
- o ? s.format = o : n || (s.fallback = a), n && (s.fallback = f(n));
22
+ const l = g(a) ?? v(a);
23
+ l ? s.format = l : o || (s.fallback = a), o && (s.fallback = i(o));
24
24
  }
25
25
  }
26
26
  return s;
27
+ }, h = (t) => {
28
+ const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : m(t);
29
+ return e === null ? null : `${u} ${e}`;
27
30
  }, p = (t) => {
28
- const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : y(t);
29
- return e === null ? null : `${c} ${e}`;
30
- }, v = (t) => {
31
- const r = t.format ? b(t.format) : null, e = t.fallback ? p(t.fallback) : null, l = [t.value, r, e].filter(Boolean);
31
+ const r = t.format ? y(t.format) : null, e = t.fallback ? h(t.fallback) : null, n = [t.value, r, e].filter(Boolean);
32
32
  return {
33
33
  label: [t.text, r, e && t.fallback].filter(Boolean).join(" | "),
34
- value: `{{ ${l.join(" | ")} }}`
34
+ value: `{{ ${n.join(" | ")} }}`
35
35
  };
36
- }, i = (t, r = !1) => t.map((e) => r ? v(e) : e.format ? {
36
+ }, b = (t, r = !1) => t.map((e) => r ? p(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
- }), $ = (t) => {
43
- const r = [], e = /* @__PURE__ */ new Set(), l = (a) => {
44
- Array.isArray(a) && a.forEach((n) => {
45
- const o = [...n.children ?? [], ...n.select_items ?? []];
46
- if (o.length > 0) {
47
- l(o);
42
+ }), k = (t) => {
43
+ const r = [], e = /* @__PURE__ */ new Set(), n = (a, o) => {
44
+ Array.isArray(a) && a.forEach((l) => {
45
+ const f = [...l.children ?? [], ...l.select_items ?? []], c = l.text || l.tag_text;
46
+ if (f.length > 0) {
47
+ n(f, c ? [...o, c] : o);
48
48
  return;
49
49
  }
50
- const u = n.text || n.tag_text;
51
- u && n.value && !e.has(n.value) && (e.add(n.value), r.push({ text: u, value: n.value }));
50
+ c && l.value && !e.has(l.value) && (e.add(l.value), r.push({ value: l.value, text: c, tagText: l.tag_text || c, path: o }));
52
51
  });
53
52
  }, [s] = Object.values(t ?? {});
54
- return l(s), r;
55
- }, d = (t, r, e = !1) => {
56
- const l = new Set(t.map((a) => a.value)), s = r.filter((a) => l.has(a.value) ? !1 : (l.add(a.value), !0));
53
+ return n(s, []), r;
54
+ }, x = (t) => k(t).map(({ text: r, value: e }) => ({ text: r, value: e })), T = (t, r, e = !1) => {
55
+ const n = new Set(t.map((a) => a.value)), s = r.filter((a) => n.has(a.value) ? !1 : (n.add(a.value), !0));
57
56
  return [
58
- ...i(t, e),
59
- ...i(s, e)
57
+ ...b(t, e),
58
+ ...b(s, e)
60
59
  ];
61
60
  }, F = () => {
62
61
  var t;
63
62
  return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
64
- }, T = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", x = (t) => {
63
+ }, P = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", j = (t) => {
65
64
  if (t === null || typeof t != "object" || Array.isArray(t))
66
65
  return !1;
67
66
  const r = Object.getPrototypeOf(t);
68
67
  return r === Object.prototype || r === null;
69
68
  };
70
69
  export {
71
- T as asText,
72
- d as buildMergeTagEntries,
73
- i as dynamicContentToMergeTags,
74
- $ as flattenDynamicContentList,
70
+ P as asText,
71
+ T as buildMergeTagEntries,
72
+ b as dynamicContentToMergeTags,
73
+ k as flattenDynamicContentCandidates,
74
+ x as flattenDynamicContentList,
75
75
  F as getCsrfToken,
76
- x as isPlainObject,
77
- k as mergeTagToDynamicContent
76
+ j as isPlainObject,
77
+ $ as mergeTagToDynamicContent
78
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.27.0-beta.cf35c0c",
3
+ "version": "3.27.0-beta.ee85b86",
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",