@nivaro/react 0.3.65 → 0.3.66

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.
Files changed (25) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +13 -4
  4. package/dist/shared/components/CollectionBrowserView.js +2509 -2668
  5. package/dist/shared/components/ItemEditForm.js +3910 -3771
  6. package/dist/shared/components/MyWorkView.js +124 -113
  7. package/dist/shared/components/ProfileView.js +483 -472
  8. package/dist/shared/components/ReportView.js +1100 -1094
  9. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  10. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  11. package/dist/shared/components/item-edit/CatalogPickerField.js +240 -238
  12. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  13. package/dist/shared/components/item-edit/M2MCombobox.js +414 -349
  14. package/dist/shared/components/item-edit/MidairCollisionDialog.js +211 -187
  15. package/dist/shared/components/item-edit/RelationCombobox.js +327 -311
  16. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  17. package/dist/shared/components/item-edit/UserChip.js +264 -229
  18. package/dist/shared/components/item-edit/cascade-clear-notice.js +23 -19
  19. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  20. package/dist/shared/components/item-edit/line-merge.js +73 -47
  21. package/dist/shared/components/item-edit/picker-search.js +25 -21
  22. package/dist/shared/components/queue/QueueWorklist.js +799 -772
  23. package/dist/shared/lib/obligation-reason-text.js +1 -1
  24. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  25. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { useRef as l, useEffect as f, useCallback as d, createContext as m, useContext as C } from "react";
2
- import { toast as h } from "sonner";
3
- const p = m(null), k = () => C(p);
1
+ import { useRef as s, useEffect as f, useCallback as d, createContext as m, useContext as h } from "react";
2
+ import { toast as C } from "sonner";
3
+ const p = m(null), E = () => h(p);
4
4
  function w(n) {
5
5
  const e = [...new Set(n.filter(Boolean))];
6
6
  return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
@@ -9,44 +9,48 @@ function T(n, e) {
9
9
  const r = w(n);
10
10
  return e ? `${r} cleared — not available for the ${e} you picked` : `${r} cleared — no longer available for what you picked`;
11
11
  }
12
- function S(n, e) {
13
- const r = new Set(n.map((t) => t.field)), c = [...new Set(n.flatMap((t) => t.parents))].filter((t) => !r.has(t));
14
- return c.length === 0 ? null : c.reduce((t, o) => e(o) > e(t) ? o : t, c[0]);
12
+ function x(n, e) {
13
+ const r = new Set(n.map((t) => t.field)), o = [...new Set(n.flatMap((t) => t.parents))].filter((t) => !r.has(t));
14
+ return o.length === 0 ? null : o.reduce((t, c) => e(c) > e(t) ? c : t, o[0]);
15
15
  }
16
- const g = 4e3, x = 500, R = "nvr-cascade-clear";
16
+ const S = 4e3, g = 500, R = "nvr-cascade-clear";
17
17
  function N(n) {
18
- const e = l(n);
18
+ const e = s(n);
19
19
  e.current = n;
20
- const r = l([]), c = l(0), t = l(null);
20
+ const r = s([]), o = s(0), t = s(null);
21
21
  return f(
22
22
  () => () => {
23
23
  t.current && clearTimeout(t.current);
24
24
  },
25
25
  []
26
- ), d((o) => {
27
- const s = Date.now();
28
- s - c.current > g && (r.current = []), c.current = s, r.current.some((a) => a.field === o.field) || r.current.push(o), t.current && clearTimeout(t.current), t.current = setTimeout(() => {
26
+ ), d((c) => {
27
+ const l = Date.now();
28
+ l - o.current > S && (r.current = []), o.current = l, r.current.some((a) => a.field === c.field) || r.current.push(c), t.current && clearTimeout(t.current), t.current = setTimeout(() => {
29
29
  const a = r.current;
30
30
  if (a.length === 0) return;
31
- const i = S(a, e.current.editSeq);
32
- h.info(
31
+ const u = x(a, e.current.editSeq);
32
+ C.info(
33
33
  T(
34
- a.map((u) => u.label),
35
- i ? e.current.labelOf(i) : null
34
+ a.map((i) => i.label),
35
+ u ? e.current.labelOf(u) : null
36
36
  ),
37
37
  {
38
38
  id: R,
39
39
  description: "Pick them again from the narrowed lists."
40
40
  }
41
41
  );
42
- }, x);
42
+ }, g);
43
43
  }, []);
44
44
  }
45
+ function P(n, e, r) {
46
+ return r.crossFill > 0 || r.notPerson > 0 ? !1 : (n.touched.add(e), n.seq.set(e, n.next()), !0);
47
+ }
45
48
  export {
46
49
  p as CascadeClearNoticeContext,
47
50
  T as cascadeClearText,
48
- S as cascadeRootParent,
51
+ x as cascadeRootParent,
49
52
  w as joinLabels,
53
+ P as notePersonLinkEdit,
50
54
  N as useCascadeClearNotices,
51
- k as useCascadeClearNotifier
55
+ E as useCascadeClearNotifier
52
56
  };
@@ -0,0 +1,52 @@
1
+ import { useQueries as p } from "@tanstack/react-query";
2
+ import { useMemo as m } from "react";
3
+ import { useNivaroClient as h } from "../../context.js";
4
+ import { get as w } from "../../lib/commands.js";
5
+ function v(n, f, c, a) {
6
+ const d = [];
7
+ for (const l of n) {
8
+ const r = l.split(".");
9
+ if (r.length !== 2 || !r[0] || !r[1]) continue;
10
+ const [t, o] = r, e = f[t], i = e != null && typeof e == "object" ? e.id : e;
11
+ if (i == null || i === "") continue;
12
+ const s = c[t], u = s != null && typeof s == "object" ? s.id : s;
13
+ !a && String(u ?? "") === String(i) || d.push({ path: l, hop: t, rest: o, id: String(i) });
14
+ }
15
+ return d;
16
+ }
17
+ function _(n) {
18
+ const f = h(), c = v(n.paths, n.draft, n.saved, n.isNew).map((t) => {
19
+ const o = n.relations.find(
20
+ (e) => e.many_collection === n.collection && e.many_field === t.hop && !e.junction_field
21
+ );
22
+ return o != null && o.one_collection ? { ...t, target: o.one_collection } : null;
23
+ }).filter((t) => !!t), a = /* @__PURE__ */ new Map();
24
+ for (const t of c) {
25
+ const o = `${t.target}:${t.id}`, e = a.get(o) ?? { target: t.target, id: t.id, fields: /* @__PURE__ */ new Set() };
26
+ e.fields.add(t.rest), a.set(o, e);
27
+ }
28
+ const d = [...a.values()], l = p({
29
+ queries: d.map((t) => ({
30
+ queryKey: ["header-path-preview", t.target, t.id, [...t.fields].sort().join(",")],
31
+ queryFn: () => f.request(
32
+ w(`/items/${t.target}/${encodeURIComponent(t.id)}`, {
33
+ fields: [...t.fields].join(",")
34
+ })
35
+ ).then((o) => o.data ?? null).catch(() => null),
36
+ staleTime: 3e4
37
+ }))
38
+ }), r = l.map((t) => t.dataUpdatedAt).join(",");
39
+ return m(() => {
40
+ var o;
41
+ const t = {};
42
+ for (const e of c) {
43
+ const i = d.findIndex((u) => u.target === e.target && u.id === e.id), s = (o = l[i]) == null ? void 0 : o.data;
44
+ s && (t[e.path] = s[e.rest] ?? null);
45
+ }
46
+ return t;
47
+ }, [r, c.map((t) => `${t.path}=${t.id}`).join("|")]);
48
+ }
49
+ export {
50
+ v as pathsToPreview,
51
+ _ as useHeaderPathPreview
52
+ };
@@ -1,58 +1,84 @@
1
- import { evaluateNumeric as s } from "../../lib/expression.js";
2
- import { sameStoredValue as d } from "../../lib/write-formula.js";
3
- import { lineConflictKey as u } from "./line-midair.js";
4
- function m(t) {
5
- const i = new Set((t.derived ?? []).map((e) => e.field));
6
- return t.conflicts.map((e) => {
7
- const r = t.mine[e.field], n = i.has(e.field) ? "derived" : d(e.current_value, r) ? "same" : "conflict";
1
+ import { evaluateNumeric as u } from "../../lib/expression.js";
2
+ import { sameStoredValue as a } from "../../lib/write-formula.js";
3
+ import { lineConflictKey as l } from "./line-midair.js";
4
+ function m(e, n) {
5
+ return e.key != null && e.rowId != null ? l({ key: e.key, rowId: e.rowId }, n) : n;
6
+ }
7
+ function k(e) {
8
+ const n = new Set((e.derived ?? []).map((t) => t.field));
9
+ return e.conflicts.map((t) => {
10
+ const i = e.mine[t.field], c = n.has(t.field) ? "derived" : a(t.current_value, i) ? "same" : "conflict";
8
11
  return {
9
- key: u(t, e.field),
10
- field: e.field,
11
- theirs: e.current_value,
12
- mine: r,
13
- kind: n
12
+ key: m(e, t.field),
13
+ field: t.field,
14
+ theirs: t.current_value,
15
+ mine: i,
16
+ kind: c
14
17
  };
15
18
  });
16
19
  }
17
- function p(t, i) {
18
- return t.every((e) => e.kind !== "conflict" || i.has(e.key));
20
+ function b(e, n) {
21
+ return e.every((t) => t.kind !== "conflict" || n.has(t.key));
19
22
  }
20
- function y(t, i) {
21
- const e = /* @__PURE__ */ new Set();
22
- for (const r of t) (r.kind !== "conflict" || i.get(r.key) !== "mine") && e.add(r.key);
23
- return e;
23
+ function g(e, n) {
24
+ const t = /* @__PURE__ */ new Set();
25
+ for (const i of e) (i.kind !== "conflict" || n.get(i.key) !== "mine") && t.add(i.key);
26
+ return t;
24
27
  }
25
- function l(t, i) {
26
- if (!(i != null && i.length)) return t;
27
- const e = { ...t };
28
- for (const r of i) {
29
- const n = s(r.formula, e);
30
- n !== null && Number.isFinite(n) && (e[r.field] = Math.round(n * 1e6) / 1e6);
28
+ function y(e, n) {
29
+ if (!(n != null && n.length)) return e;
30
+ const t = { ...e };
31
+ for (const i of n) {
32
+ const c = u(i.formula, t);
33
+ c !== null && Number.isFinite(c) && (t[i.field] = Math.round(c * 1e6) / 1e6);
31
34
  }
32
- return e;
33
- }
34
- function h(t, i) {
35
- const e = m(t), r = new Set(e.map((o) => o.field)), n = new Set((t.derived ?? []).map((o) => o.field)), f = { ...t.current ?? {} };
36
- for (const [o, c] of Object.entries(t.edit ?? t.mine))
37
- o.startsWith("_") || o === "id" || r.has(o) || n.has(o) || (f[o] = c);
38
- for (const o of e)
39
- o.kind !== "derived" && (f[o.field] = o.kind === "conflict" && i.get(o.key) === "mine" ? o.mine : o.theirs);
40
- return l(f, t.derived);
41
- }
42
- function g(t, i) {
43
- const e = [], r = (n) => {
44
- e.includes(n) || n === "id" || n.startsWith("_") || /_id$/.test(n) || i != null && i(n) || e.push(n);
35
+ return t;
36
+ }
37
+ function w(e, n) {
38
+ const t = k(e), i = new Set(t.map((r) => r.field)), c = new Set((e.derived ?? []).map((r) => r.field)), o = { ...e.current ?? {} };
39
+ for (const [r, d] of Object.entries(e.edit ?? e.mine))
40
+ r.startsWith("_") || r === "id" || i.has(r) || c.has(r) || (o[r] = d);
41
+ for (const r of t)
42
+ r.kind !== "derived" && (o[r.field] = r.kind === "conflict" && n.get(r.key) === "mine" ? r.mine : r.theirs);
43
+ return y(o, e.derived);
44
+ }
45
+ function S(e, n) {
46
+ const t = [], i = e.edit ?? e.mine, c = (o) => {
47
+ if (t.includes(o) || o === "id" || o.startsWith("_") || /_id$/.test(o)) return;
48
+ const r = i[o];
49
+ r !== null && typeof r == "object" || n != null && n(o) || t.push(o);
45
50
  };
46
- for (const n of Object.keys(t.edit ?? t.mine)) r(n);
47
- for (const n of t.conflicts) r(n.field);
48
- for (const n of t.derived ?? []) r(n.field);
49
- return e;
51
+ for (const o of Object.keys(e.edit ?? e.mine)) c(o);
52
+ for (const o of e.conflicts) c(o.field);
53
+ for (const o of e.derived ?? []) c(o.field);
54
+ return t;
55
+ }
56
+ function O(e) {
57
+ const n = {};
58
+ for (const [t, i] of Object.entries(e ?? {}))
59
+ t !== "id" && !t.startsWith("_") && (n[t] = i);
60
+ return n;
61
+ }
62
+ const v = /^(date_created|date_updated|created|changed|user_created|user_updated|creator|modified_by|modified_on)$/i;
63
+ function j(e, n, t) {
64
+ const i = t.filter((f) => Number(f.id) > n);
65
+ if (i.length === 0) return null;
66
+ const c = i.reduce((f, s) => Number(s.id) > Number(f.id) ? s : f), o = /* @__PURE__ */ new Set();
67
+ for (const f of i)
68
+ for (const s of Object.keys(f.delta ?? {})) v.test(s) || o.add(s);
69
+ const r = c.data ?? null, d = [];
70
+ for (const f of Object.keys(e))
71
+ f === "id" || f.startsWith("_") || !o.has(f) || d.push({ field: f, current_value: r ? r[f] : null });
72
+ return { conflicts: d, latest: Number(c.id), current: r };
50
73
  }
51
74
  export {
52
- m as classifyLineConflicts,
53
- p as mergeReady,
54
- y as mergeTheirsKeys,
55
- h as mergedLinePreview,
56
- g as previewFields,
57
- l as recomputeDerived
75
+ k as classifyLineConflicts,
76
+ O as mergeEditOf,
77
+ m as mergeKeyOf,
78
+ b as mergeReady,
79
+ g as mergeTheirsKeys,
80
+ w as mergedLinePreview,
81
+ S as previewFields,
82
+ y as recomputeDerived,
83
+ j as restoredLineConflicts
58
84
  };
@@ -1,35 +1,39 @@
1
- import { useState as i, useRef as s, useEffect as a } from "react";
1
+ import { useState as i, useRef as l, useEffect as s } from "react";
2
2
  import { matchesAllTokens as f } from "../../lib/utils.js";
3
- function p(t, n, e = 300) {
4
- const [r, c] = i(t), o = s(!1);
5
- return a(() => {
3
+ function g(t, e, n = 300) {
4
+ const [r, u] = i(t), c = l(!1);
5
+ return s(() => {
6
6
  if (t === r) {
7
- o.current = !1;
7
+ c.current = !1;
8
8
  return;
9
9
  }
10
10
  if (!t) {
11
- c("");
11
+ u("");
12
12
  return;
13
13
  }
14
- if (n) {
15
- o.current = !0;
14
+ if (e) {
15
+ c.current = !0;
16
16
  return;
17
17
  }
18
- const u = setTimeout(() => c(t), o.current ? 0 : e);
19
- return () => clearTimeout(u);
20
- }, [t, r, n, e]), r;
18
+ const o = setTimeout(() => u(t), c.current ? 0 : n);
19
+ return () => clearTimeout(o);
20
+ }, [t, r, e, n]), r;
21
21
  }
22
- function E(t, n, e, r) {
23
- return r || !e.trim() ? t : t.filter((c) => f(n(c), e));
22
+ function p(t, e, n, r) {
23
+ return r || !n.trim() ? t : t.filter((u) => f(e(u), n));
24
24
  }
25
- const l = 200;
26
- function S(t, n, e) {
27
- const r = e.replace(/[-_/]+/g, " ").trim();
28
- return !r || t.length >= l ? [] : t.filter((c) => f(n(c), r));
25
+ const a = 200;
26
+ function E(t, e, n) {
27
+ const r = n.replace(/[-_/]+/g, " ").trim();
28
+ return !r || t.length >= a ? [] : t.filter((u) => f(e(u), r));
29
+ }
30
+ function S(t) {
31
+ return !!t && t.length > 0 && t.every((e) => e.fuzzy === !0);
29
32
  }
30
33
  export {
31
- l as PICKER_PAGE,
32
- S as labelOnlyMatches,
33
- E as narrowLocally,
34
- p as useLatestSearch
34
+ a as PICKER_PAGE,
35
+ E as labelOnlyMatches,
36
+ p as narrowLocally,
37
+ S as onlyCloseMatches,
38
+ g as useLatestSearch
35
39
  };