@nivaro/react 0.3.55 → 0.3.57

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,6 +1,10 @@
1
- function r(t, e) {
2
- return t || e ? { refresh: !0, pill: 0, stats: !0 } : { refresh: !1, pill: 1, stats: !0 };
1
+ function r(e, t) {
2
+ return e || t ? { refresh: !0, pill: 0, stats: !0 } : { refresh: !1, pill: 1, stats: !0 };
3
+ }
4
+ function l(e) {
5
+ return !e.table || e.busy || typeof e.liveTotal != "number" || typeof e.rowsTotal != "number" ? !1 : e.liveTotal !== e.rowsTotal;
3
6
  }
4
7
  export {
5
- r as stateAspectEffect
8
+ r as stateAspectEffect,
9
+ l as statsOutrunRows
6
10
  };
@@ -0,0 +1,14 @@
1
+ const s = /* @__PURE__ */ new Set(["id", "name", "title", "label", "type", "code", "display_name"]);
2
+ function n(t) {
3
+ return t.replace(/_/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase()).replace(/\bId\b/g, "ID");
4
+ }
5
+ function i(t) {
6
+ const e = t.split(".").filter(Boolean);
7
+ if (e.length === 0) return t;
8
+ if (e.length === 1) return n(e[0]);
9
+ const r = e[e.length - 1], o = e[e.length - 2], a = e.slice(0, -1);
10
+ return s.has(r.toLowerCase()) ? a.map(n).join(" → ") : r.toLowerCase().startsWith(`${o.toLowerCase()}_`) ? [...e.slice(0, -2), r].map(n).join(" → ") : e.map(n).join(" → ");
11
+ }
12
+ export {
13
+ i as pathHeader
14
+ };
@@ -0,0 +1,36 @@
1
+ const a = (e) => e.startsWith("directus_") || e.startsWith("nivaro_");
2
+ function d(e) {
3
+ var f;
4
+ const { qc: r, collection: l, rows: c } = e;
5
+ if (c.length !== 0) {
6
+ if (e.resolveList.length > 0) {
7
+ const i = c.map((n) => String(n.id)).join(",");
8
+ r.prefetchQuery({
9
+ queryKey: ["cbv-resolved", l, i, e.resolveList.join(",")],
10
+ queryFn: () => e.fetchResolved(i),
11
+ staleTime: 3e4
12
+ });
13
+ }
14
+ for (const i of e.columns) {
15
+ if (e.isResolvedCol(i)) continue;
16
+ const n = (f = e.relations.find(
17
+ (o) => o.many_collection === l && o.many_field === i && o.one_collection
18
+ )) == null ? void 0 : f.one_collection;
19
+ if (!n) continue;
20
+ const u = /* @__PURE__ */ new Set();
21
+ for (const o of c) {
22
+ const s = o[i];
23
+ if (s == null || s === "") continue;
24
+ const t = String(s);
25
+ u.has(t) || (u.add(t), n === "nivaro_users" ? r.prefetchQuery({ ...e.userCardQuery(t), staleTime: 12e4 }) : a(n) || r.prefetchQuery({
26
+ queryKey: ["cbv-relation-item", n, t],
27
+ queryFn: () => e.fetchRelation(n, t),
28
+ staleTime: 30 * 6e4
29
+ }));
30
+ }
31
+ }
32
+ }
33
+ }
34
+ export {
35
+ d as warmPageLookups
36
+ };
@@ -1,81 +1,106 @@
1
- import { get as c } from "./commands.js";
2
- const o = /^[A-Za-z_][A-Za-z0-9_]*$/;
3
- function a(n) {
4
- const t = n == null ? void 0 : n.friendly_id_field;
5
- return typeof t == "string" && t !== "id" && o.test(t) ? t : null;
1
+ import { get as y } from "./commands.js";
2
+ const s = /^[A-Za-z_][A-Za-z0-9_]*$/;
3
+ function d(e) {
4
+ const n = e == null ? void 0 : e.friendly_id_field;
5
+ return typeof n == "string" && n !== "id" && s.test(n) ? n : null;
6
6
  }
7
- function s(n) {
8
- if (n == null || typeof n == "object") return null;
9
- const t = String(n).trim();
10
- return t === "" ? null : t;
7
+ function f(e) {
8
+ if (e == null || typeof e == "object") return null;
9
+ const n = String(e).trim();
10
+ return n === "" ? null : n;
11
11
  }
12
- function d(n, t) {
13
- const r = a(n);
14
- return r && t ? s(t[r]) : null;
12
+ function a(e, n) {
13
+ const t = d(e);
14
+ return t && n ? f(n[t]) : null;
15
15
  }
16
- function y(n) {
17
- const t = n == null ? void 0 : n.url_alias_fields;
18
- let r = t;
19
- if (typeof t == "string")
16
+ const g = ["title", "name", "label", "subject", "description"];
17
+ function p(e) {
18
+ const n = String(e || "record").replace(/^nivaro_/, "").replace(/_/g, " ").trim().toLowerCase();
19
+ return /ies$/.test(n) ? `${n.slice(0, -3)}y` : /[^s]s$/.test(n) ? n.slice(0, -1) : n || "record";
20
+ }
21
+ function b(e, n, t, r) {
22
+ var c;
23
+ const i = a(e, n);
24
+ if (i) return i;
25
+ if ((t == null || t === "") && !n) return "";
26
+ const l = `No ${p(r)} number`, u = n ? (c = g.map((o) => f(n[o])).find((o) => o != null)) == null ? void 0 : c.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim() : void 0;
27
+ return u ? `${l} · ${u.length > 60 ? `${u.slice(0, 59)}…` : u}` : l;
28
+ }
29
+ function m(e) {
30
+ const n = e == null ? void 0 : e.url_alias_fields;
31
+ let t = n;
32
+ if (typeof n == "string")
20
33
  try {
21
- r = JSON.parse(t);
34
+ t = JSON.parse(n);
22
35
  } catch {
23
- r = [];
36
+ t = [];
24
37
  }
25
- return Array.isArray(r) ? r.filter((e) => typeof e == "string" && o.test(e)) : [];
38
+ return Array.isArray(t) ? t.filter((r) => typeof r == "string" && s.test(r)) : [];
26
39
  }
27
- function g(n, t) {
28
- if (!t) return null;
29
- const r = y(n);
30
- let e;
31
- if (r.length > 0) {
32
- const i = r.map((l) => s(t[l]));
40
+ function S(e, n) {
41
+ if (!n) return null;
42
+ const t = m(e);
43
+ let r;
44
+ if (t.length > 0) {
45
+ const i = t.map((l) => f(n[l]));
33
46
  if (i.some((l) => l == null)) return null;
34
- e = i.join("-");
47
+ r = i.join("-");
35
48
  } else
36
- e = d(n, t);
37
- return !e || /^\d+$/.test(e) || /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(e) || e === "new" || e.includes("/") ? null : e;
49
+ r = a(e, n);
50
+ return !r || /^\d+$/.test(r) || /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(r) || r === "new" || r.includes("/") ? null : r;
38
51
  }
39
- async function S(n, t, r, e, i) {
40
- var f;
41
- const l = g(r, e);
52
+ async function I(e, n, t, r, i) {
53
+ var u;
54
+ const l = S(t, r);
42
55
  if (!l) return String(i);
43
56
  try {
44
- const u = await n.request(
45
- c(`/items/${t}/by-slug/${encodeURIComponent(l)}`, { fields: "id" })
57
+ const c = await e.request(
58
+ y(`/items/${n}/by-slug/${encodeURIComponent(l)}`, { fields: "id" })
46
59
  );
47
- return String(((f = u == null ? void 0 : u.data) == null ? void 0 : f.id) ?? "") === String(i) ? l : String(i);
60
+ return String(((u = c == null ? void 0 : c.data) == null ? void 0 : u.id) ?? "") === String(i) ? l : String(i);
48
61
  } catch {
49
62
  return String(i);
50
63
  }
51
64
  }
52
- async function w(n) {
53
- const t = typeof navigator < "u" ? navigator.clipboard : void 0;
54
- if (!t) return;
55
- const r = globalThis.ClipboardItem;
56
- if (r && typeof t.write == "function")
65
+ async function _(e) {
66
+ const n = typeof navigator < "u" ? navigator.clipboard : void 0;
67
+ if (!n) return;
68
+ const t = globalThis.ClipboardItem;
69
+ if (t && typeof n.write == "function")
57
70
  try {
58
- await t.write([
59
- new r({ "text/plain": n.then((e) => new Blob([e], { type: "text/plain" })) })
71
+ await n.write([
72
+ new t({ "text/plain": e.then((r) => new Blob([r], { type: "text/plain" })) })
60
73
  ]);
61
74
  return;
62
75
  } catch {
63
76
  }
64
- await t.writeText(await n);
77
+ await n.writeText(await e);
78
+ }
79
+ function $(e) {
80
+ return /^No [\w ]+ number( · |$)/.test(String(e ?? ""));
65
81
  }
66
- function p(n) {
67
- return /^No [\w ]+ number( · |$)/.test(String(n ?? ""));
82
+ function h(e) {
83
+ const n = String(e.label ?? "").trim();
84
+ return !n || $(n) ? null : n;
68
85
  }
69
- function h(n) {
70
- const t = String(n.label ?? "").trim();
71
- return !t || p(t) ? null : t;
86
+ function N(e) {
87
+ const n = String(e.label ?? "").trim();
88
+ if (n) return { copy: h({ label: n }), name: n };
89
+ const t = a(e.meta, e.row);
90
+ return t ? { copy: t, name: t } : e.meta ? d(e.meta) ? {
91
+ copy: null,
92
+ name: b(e.meta, e.row, e.id, e.collection)
93
+ } : { copy: String(e.id), name: String(e.id) } : { copy: null, name: "this record" };
72
94
  }
73
95
  export {
74
- g as aliasSegmentOf,
96
+ S as aliasSegmentOf,
75
97
  h as copyIdText,
76
- w as copyWhenReady,
77
- a as friendlyIdFieldOf,
78
- d as friendlyIdOf,
79
- p as isNoNumberLabel,
80
- S as shareableRecordId
98
+ _ as copyWhenReady,
99
+ d as friendlyIdFieldOf,
100
+ a as friendlyIdOf,
101
+ $ as isNoNumberLabel,
102
+ p as recordNoun,
103
+ b as recordRefLabel,
104
+ N as rowMenuRef,
105
+ I as shareableRecordId
81
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.55",
3
+ "version": "0.3.57",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",