@nivaro/react 0.3.121 → 0.3.123

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,60 +1,68 @@
1
- import { useRef as l, useEffect as f, useCallback as d, createContext as h, useContext as m } from "react";
2
- import { toast as C } from "sonner";
3
- const p = h(null), v = () => m(p);
4
- function S(t) {
5
- const e = [...new Set(t.filter(Boolean))];
6
- return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
7
- }
8
- function T(t, e) {
9
- const r = S(t);
10
- return e ? `${r} cleared — not available for the ${e} you picked` : `${r} cleared — no longer available for what you picked`;
11
- }
12
- function w(t, e) {
13
- const r = new Set(t.map((n) => n.field)), o = [...new Set(t.flatMap((n) => n.parents))].filter((n) => !r.has(n));
14
- return o.length === 0 ? null : o.reduce((n, c) => e(c) > e(n) ? c : n, o[0]);
15
- }
16
- const g = 4e3, x = 500, k = "nvr-cascade-clear";
17
- function A(t) {
18
- const e = l(t);
19
- e.current = t;
20
- const r = l([]), o = l(0), n = l(null);
1
+ import { useRef as s, useEffect as f, useCallback as d, createContext as h, useContext as C } from "react";
2
+ import { toast as m } from "sonner";
3
+ const p = h(null), $ = () => C(p);
4
+ function k(e) {
5
+ const t = [...new Set(e.filter(Boolean))];
6
+ return t.length <= 1 ? t[0] ?? "" : `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}`;
7
+ }
8
+ function g(e, t) {
9
+ const r = k(e);
10
+ return t ? `${r} cleared — not available for the ${t} you picked` : `${r} cleared — no longer available for what you picked`;
11
+ }
12
+ function S(e, t) {
13
+ const r = new Set(e.map((n) => n.field)), c = [...new Set(e.flatMap((n) => n.parents))].filter((n) => !r.has(n));
14
+ return c.length === 0 ? null : c.reduce((n, o) => t(o) > t(n) ? o : n, c[0]);
15
+ }
16
+ const T = 4e3, w = 500, P = "nvr-cascade-clear";
17
+ function M(e) {
18
+ const t = s(e);
19
+ t.current = e;
20
+ const r = s([]), c = s(0), n = s(null);
21
21
  return f(
22
22
  () => () => {
23
23
  n.current && clearTimeout(n.current);
24
24
  },
25
25
  []
26
- ), d((c) => {
27
- const u = Date.now();
28
- u - o.current > g && (r.current = []), o.current = u, r.current.some((a) => a.field === c.field) || r.current.push(c), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
26
+ ), d((o) => {
27
+ const i = Date.now();
28
+ i - c.current > T && (r.current = []), c.current = i, r.current.some((a) => a.field === o.field) || r.current.push(o), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
29
29
  const a = r.current;
30
30
  if (a.length === 0) return;
31
- const s = w(a, e.current.editSeq);
32
- C.info(
33
- T(
34
- a.map((i) => i.label),
35
- s ? e.current.labelOf(s) : null
31
+ const u = S(a, t.current.editSeq);
32
+ m.info(
33
+ g(
34
+ a.map((l) => l.label),
35
+ u ? t.current.labelOf(u) : null
36
36
  ),
37
37
  {
38
- id: k,
38
+ id: P,
39
39
  description: "Pick them again from the narrowed lists."
40
40
  }
41
41
  );
42
- }, x);
42
+ }, w);
43
43
  }, []);
44
44
  }
45
- function E(t, e, r) {
46
- return r.crossFill > 0 || r.notPerson > 0 ? !1 : (t.touched.add(e), t.seq.set(e, t.next()), !0);
45
+ function v(e, t, r) {
46
+ return r.crossFill > 0 || r.notPerson > 0 ? !1 : (e.touched.add(t), e.seq.set(t, e.next()), !0);
47
+ }
48
+ function A(e, t) {
49
+ t.leftWorkStaged || e.clear();
50
+ }
51
+ function E(e) {
52
+ return `Pick a ${e}`;
47
53
  }
48
- function N(t, e) {
49
- e.leftWorkStaged || t.clear();
54
+ function N(e) {
55
+ return typeof e == "string" && e.startsWith("Pick a ");
50
56
  }
51
57
  export {
52
58
  p as CascadeClearNoticeContext,
53
- T as cascadeClearText,
54
- w as cascadeRootParent,
55
- S as joinLabels,
56
- E as notePersonLinkEdit,
57
- N as settleTouchedAfterSave,
58
- A as useCascadeClearNotices,
59
- v as useCascadeClearNotifier
59
+ g as cascadeClearText,
60
+ E as cascadePickMessage,
61
+ S as cascadeRootParent,
62
+ N as isCascadePickMessage,
63
+ k as joinLabels,
64
+ v as notePersonLinkEdit,
65
+ A as settleTouchedAfterSave,
66
+ M as useCascadeClearNotices,
67
+ $ as useCascadeClearNotifier
60
68
  };
@@ -1,5 +1,5 @@
1
- import { m2aWriteMeta as x, parseM2aToken as E } from "./M2MCombobox.js";
2
- function L(n, r, a) {
1
+ import { m2aWriteMeta as E, parseM2aToken as L } from "./M2MCombobox.js";
2
+ function O(n, r, a) {
3
3
  var _;
4
4
  let e = r.find((t) => t.one_collection === n && t.one_field === a);
5
5
  if (!e && a.includes(".")) {
@@ -13,7 +13,7 @@ function L(n, r, a) {
13
13
  if (!s) return null;
14
14
  const u = r.find(
15
15
  (t) => t.many_collection === e.many_collection && t.many_field === s && t.id !== e.id
16
- ), d = x(u);
16
+ ), d = E(u);
17
17
  return {
18
18
  field: e.one_field,
19
19
  junctionField: s,
@@ -21,64 +21,65 @@ function L(n, r, a) {
21
21
  m2aField: (d == null ? void 0 : d.field) ?? null
22
22
  };
23
23
  }
24
- function O(n) {
24
+ function z(n) {
25
25
  return n == null || n === "" ? [] : Array.isArray(n) ? n : typeof n == "object" ? [] : [n];
26
26
  }
27
- const F = (n) => n && typeof n == "object" ? `${String(n.collection ?? "").toLowerCase()}:${String(n.id ?? "").toLowerCase()}` : `:${String(n).toLowerCase()}`;
28
- function M(n) {
27
+ const S = (n) => n && typeof n == "object" ? `${String(n.collection ?? "").toLowerCase()}:${String(n.id ?? "").toLowerCase()}` : `:${String(n).toLowerCase()}`;
28
+ function W(n) {
29
29
  var i;
30
30
  const { collection: r, relations: a, links: e, unlinks: s, payload: u, isNew: d } = n, _ = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set([...e.keys(), ...s.keys()]);
31
31
  for (const m of t) {
32
- const g = e.get(m) ?? [], y = s.get(m) ?? /* @__PURE__ */ new Set();
33
- if (g.length === 0 && y.size === 0) continue;
34
- const f = L(r, a, m);
32
+ const g = e.get(m) ?? [], w = s.get(m) ?? /* @__PURE__ */ new Set();
33
+ if (g.length === 0 && w.size === 0) continue;
34
+ const f = O(r, a, m);
35
35
  if (!f) continue;
36
- const k = (o) => {
36
+ const p = (o) => {
37
37
  if (!f.m2aCollection) return o;
38
- const l = E(o);
38
+ const l = L(o);
39
39
  return l ? { collection: l.collection, id: l.id } : { collection: f.m2aCollection, id: o };
40
- }, C = (o) => {
40
+ }, j = (o) => {
41
41
  const l = o[f.junctionField];
42
42
  if (l == null) return null;
43
43
  if (!f.m2aCollection) return l;
44
- const c = f.m2aField ? o[f.m2aField] : null;
45
- return typeof c == "string" && c ? { collection: c, id: l } : null;
44
+ const y = f.m2aField ? o[f.m2aField] : null;
45
+ return typeof y == "string" && y ? { collection: y, id: l } : null;
46
46
  };
47
47
  if (d) {
48
- if (y.size > 0) continue;
48
+ if (w.size > 0) continue;
49
49
  const o = [], l = /* @__PURE__ */ new Set();
50
- for (const c of [...O(u[f.field]), ...g.map(k)]) {
51
- const w = F(c);
52
- l.has(w) || (l.add(w), o.push(c));
50
+ for (const y of [...z(u[f.field]), ...g.map(p)]) {
51
+ const c = S(y);
52
+ l.has(c) || (l.add(c), o.push(y));
53
53
  }
54
54
  u[f.field] = o, _.add(m);
55
55
  continue;
56
56
  }
57
- const S = (i = n.committed) == null ? void 0 : i.call(n, m);
58
- let p = [];
59
- if (y.size > 0) {
60
- if (!S) continue;
61
- const o = new Map(S.map((c) => [String(c.id), c])), l = [...y].map((c) => {
62
- const w = o.get(String(c));
63
- return w ? C(w) : null;
57
+ const h = (i = n.committed) == null ? void 0 : i.call(n, m);
58
+ let k = [];
59
+ if (w.size > 0) {
60
+ if (!h) continue;
61
+ const o = new Map(h.map((c) => [String(c.id), c])), l = [...w].map((c) => {
62
+ const b = o.get(String(c));
63
+ return b ? j(b) : null;
64
64
  });
65
65
  if (l.some((c) => c == null)) continue;
66
- p = l;
66
+ const y = new Set(g.map((c) => S(p(c))));
67
+ k = l.filter((c) => !y.has(S(c)));
67
68
  }
68
- const b = (S ?? []).filter((o) => !y.has(o.id) && !y.has(String(o.id))).map(C).filter((o) => o != null), h = [], j = /* @__PURE__ */ new Set();
69
- for (const o of [...b, ...g.map(k)]) {
70
- const l = F(o);
71
- j.has(l) || (j.add(l), h.push(o));
69
+ const x = (h ?? []).filter((o) => !w.has(o.id) && !w.has(String(o.id))).map(j).filter((o) => o != null), C = [], F = /* @__PURE__ */ new Set();
70
+ for (const o of [...x, ...g.map(p)]) {
71
+ const l = S(o);
72
+ F.has(l) || (F.add(l), C.push(o));
72
73
  }
73
74
  u[f.field] = {
74
- ...h.length ? { create: h } : {},
75
- ...p.length ? { delete: p } : {}
75
+ ...C.length ? { create: C } : {},
76
+ ...k.length ? { delete: k } : {}
76
77
  }, _.add(m);
77
78
  }
78
79
  return _;
79
80
  }
80
- const z = 500;
81
- function W(n) {
81
+ const A = 500;
82
+ function $(n) {
82
83
  var a;
83
84
  const r = /* @__PURE__ */ new Set();
84
85
  for (const [e, s] of n.rows) {
@@ -88,7 +89,7 @@ function W(n) {
88
89
  const d = e.slice(0, u), _ = e.slice(u + 1), t = n.relations.find(
89
90
  (i) => i.one_collection === n.collection && i.many_collection === d && i.many_field === _ && !!i.one_field && i.junction_field == null
90
91
  );
91
- t != null && t.one_field && (s.length > z || s.some((i) => Object.keys(i).some((m) => m.startsWith("__o2m_"))) || (n.payload[t.one_field] = s.map((i) => {
92
+ t != null && t.one_field && (s.length > A || s.some((i) => Object.keys(i).some((m) => m.startsWith("__o2m_"))) || (n.payload[t.one_field] = s.map((i) => {
92
93
  const { id: m, ...g } = i;
93
94
  return g;
94
95
  }), r.add(e)));
@@ -96,6 +97,6 @@ function W(n) {
96
97
  return r;
97
98
  }
98
99
  export {
99
- M as foldStagedLinks,
100
- W as foldStagedRows
100
+ W as foldStagedLinks,
101
+ $ as foldStagedRows
101
102
  };
@@ -26,7 +26,7 @@ const h = {
26
26
  SYSTEM_COLLECTION: "System tables change only through their own admin pages.",
27
27
  CLOUD_EXTENSIONS_LOCKED: "Extensions are managed by your hosting plan.",
28
28
  // ── Records and forms ──────────────────────────────────────────────────────
29
- OUT_OF_SCOPE: "Pick a value inside your own scope, or ask someone who covers that one to create the record.",
29
+ OUT_OF_SCOPE: "Pick a value inside your own scope, or ask someone who covers that one to make the change.",
30
30
  EDIT_LOCKED: "This record is locked at its current stage. Ask its owner or an administrator to change it.",
31
31
  RECORD_LOCKED: "Someone else is editing this record. Wait until they finish, then reload.",
32
32
  ITEM_LOCKED: "Someone else is editing this record. Wait until they finish, then reload.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.121",
3
+ "version": "0.3.123",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -104,7 +104,7 @@
104
104
  "typescript": "^5.0.0",
105
105
  "vite": "^6.0.0",
106
106
  "vite-plugin-dts": "^5.0.2",
107
- "vitest": "^2.1.0"
107
+ "vitest": "^4.1.12"
108
108
  },
109
109
  "peerDependenciesMeta": {
110
110
  "rrweb": {