@nivaro/react 0.3.15 → 0.3.16

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 (34) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +127 -6
  4. package/dist/index.js +736 -734
  5. package/dist/shared/components/CollectionBrowserView.js +2344 -2309
  6. package/dist/shared/components/ItemEditForm.js +3773 -3604
  7. package/dist/shared/components/RecordGridEditor.js +319 -282
  8. package/dist/shared/components/RecordReadView.js +202 -200
  9. package/dist/shared/components/cbv/unknown-fields.js +18 -8
  10. package/dist/shared/components/import/DocumentAutofillButton.js +148 -142
  11. package/dist/shared/components/item-edit/CatalogPickerField.js +264 -276
  12. package/dist/shared/components/item-edit/FieldRenderer.js +136 -133
  13. package/dist/shared/components/item-edit/FieldRow.js +198 -184
  14. package/dist/shared/components/item-edit/HeaderTools.js +107 -99
  15. package/dist/shared/components/item-edit/InlineTableField.js +138 -136
  16. package/dist/shared/components/item-edit/RecordLiveSync.js +1 -0
  17. package/dist/shared/components/item-edit/RelationCombobox.js +30 -23
  18. package/dist/shared/components/item-edit/SummaryPanel.js +334 -294
  19. package/dist/shared/components/item-edit/column-length.js +12 -0
  20. package/dist/shared/components/panels/AccessDeniedPanel.js +47 -37
  21. package/dist/shared/components/panels/ItemLockBanner.js +307 -285
  22. package/dist/shared/components/panels/PipelinePanel.js +486 -465
  23. package/dist/shared/components/panels/RevisionsPanel.js +210 -204
  24. package/dist/shared/components/profile/DelegationCard.js +178 -121
  25. package/dist/shared/components/profile/PersonActivity.js +152 -139
  26. package/dist/shared/components/queue/QueueWorklist.js +668 -659
  27. package/dist/shared/components/queue/transition-note.js +90 -0
  28. package/dist/shared/components/support/SupportRequestDialog.js +100 -89
  29. package/dist/shared/components/support/TicketDetailSheet.js +104 -91
  30. package/dist/shared/lib/autofill-runs.js +33 -26
  31. package/dist/shared/lib/draft-store.js +40 -24
  32. package/dist/shared/lib/live-queries.js +10 -9
  33. package/dist/shared/lib/restore-skipped.js +10 -0
  34. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ import { jsx as n, jsxs as s } from "react/jsx-runtime";
2
+ import { useState as b, useRef as p, useCallback as x } from "react";
3
+ import { Dialog as k, DialogContent as v, DialogHeader as N, DialogTitle as y, DialogDescription as w, DialogFooter as D } from "../ui/dialog.js";
4
+ function P(t) {
5
+ return (t == null ? void 0 : t.comment_mode) === "required";
6
+ }
7
+ function R() {
8
+ const [t, d] = b(null), [o, u] = b(""), i = p(null), m = p(Promise.resolve()), l = x((e) => {
9
+ const r = m.current.then(
10
+ () => new Promise((a) => {
11
+ u(""), d({ label: e, resolve: a });
12
+ })
13
+ );
14
+ return m.current = r.catch(() => null), r;
15
+ }, []), f = x(
16
+ (e) => {
17
+ const r = i.current;
18
+ if (!r) return l(e);
19
+ const a = r.get(e);
20
+ if (a) return a;
21
+ const h = l(e);
22
+ return r.set(e, h), h;
23
+ },
24
+ [l]
25
+ ), c = (e) => {
26
+ t == null || t.resolve(e), d(null);
27
+ }, g = /* @__PURE__ */ n(k, { open: !!t, onOpenChange: (e) => !e && c(null), children: /* @__PURE__ */ s(v, { className: "max-w-md dark:bg-card", "data-transition-note": !0, children: [
28
+ /* @__PURE__ */ s(N, { className: "px-6 pt-5", children: [
29
+ /* @__PURE__ */ n(y, { className: "text-[15px] font-semibold", children: (t == null ? void 0 : t.label) ?? "Move" }),
30
+ /* @__PURE__ */ n(w, { className: "text-[12.5px]", children: "This move needs a note — it is kept on the record’s history." })
31
+ ] }),
32
+ /* @__PURE__ */ s(
33
+ "form",
34
+ {
35
+ className: "space-y-3 px-6 pb-5",
36
+ onSubmit: (e) => {
37
+ e.preventDefault(), o.trim() && c(o.trim());
38
+ },
39
+ children: [
40
+ /* @__PURE__ */ n(
41
+ "textarea",
42
+ {
43
+ autoFocus: !0,
44
+ rows: 3,
45
+ value: o,
46
+ onChange: (e) => u(e.target.value),
47
+ placeholder: "Why is it moving?",
48
+ "aria-label": "Note",
49
+ className: "w-full resize-none rounded-md border border-slate-200 bg-white px-2.5 py-2 text-[13px] outline-none focus:border-nvr-cyan/60 dark:border-border dark:bg-background dark:text-slate-100"
50
+ }
51
+ ),
52
+ /* @__PURE__ */ s(D, { className: "gap-2", children: [
53
+ /* @__PURE__ */ n(
54
+ "button",
55
+ {
56
+ type: "button",
57
+ onClick: () => c(null),
58
+ className: "h-8 rounded-md border border-slate-200 px-3 text-[12.5px] text-slate-600 hover:bg-muted dark:border-border dark:text-slate-300",
59
+ children: "Cancel"
60
+ }
61
+ ),
62
+ /* @__PURE__ */ n(
63
+ "button",
64
+ {
65
+ type: "submit",
66
+ disabled: !o.trim(),
67
+ className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-semibold text-white disabled:opacity-50",
68
+ children: "Move"
69
+ }
70
+ )
71
+ ] })
72
+ ]
73
+ }
74
+ )
75
+ ] }) });
76
+ return {
77
+ ask: f,
78
+ beginBatch: () => {
79
+ i.current = /* @__PURE__ */ new Map();
80
+ },
81
+ endBatch: () => {
82
+ i.current = null;
83
+ },
84
+ dialog: g
85
+ };
86
+ }
87
+ export {
88
+ P as needsTransitionNote,
89
+ R as useTransitionNote
90
+ };
@@ -1,125 +1,136 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
- import { useQueryClient as $, useQuery as Y, useMutation as z } from "@tanstack/react-query";
3
- import { Loader2 as W, Paperclip as G, X as H } from "lucide-react";
4
- import { useState as l, useRef as L, useEffect as j } from "react";
5
- import { useNivaroClient as U } from "../../context.js";
6
- import { get as X, post as _ } from "../../lib/commands.js";
7
- import { invalidateRecordTasks as B } from "../../lib/record-tasks.js";
8
- import { prepareReplayClip as J } from "../../lib/replay-capture.js";
9
- import { installReplayTail as V } from "../../lib/replay-tail.js";
10
- import { Dialog as Z, DialogContent as O, DialogHeader as ee, DialogTitle as te, DialogDescription as ae } from "../ui/dialog.js";
11
- import { collectSupportContext as re } from "./support-context.js";
12
- function he({
13
- open: d,
14
- onOpenChange: m,
15
- collection: s,
16
- item: i,
17
- recordLabel: N,
18
- onCreated: x
2
+ import { useQueryClient as L, useQuery as Y, useMutation as _ } from "@tanstack/react-query";
3
+ import { Loader2 as M, Paperclip as z, X as G } from "lucide-react";
4
+ import { useState as l, useRef as P, useEffect as W } from "react";
5
+ import { useNivaroClient as H } from "../../context.js";
6
+ import { get as X, post as B } from "../../lib/commands.js";
7
+ import { invalidateRecordTasks as J } from "../../lib/record-tasks.js";
8
+ import { prepareReplayClip as V } from "../../lib/replay-capture.js";
9
+ import { installReplayTail as Z } from "../../lib/replay-tail.js";
10
+ import { Dialog as O, DialogContent as ee, DialogHeader as te, DialogTitle as re, DialogDescription as ae } from "../ui/dialog.js";
11
+ import { collectSupportContext as ne } from "./support-context.js";
12
+ function fe({
13
+ open: u,
14
+ onOpenChange: c,
15
+ collection: o,
16
+ item: p,
17
+ recordLabel: C,
18
+ onCreated: f
19
19
  }) {
20
- const u = U(), h = $(), r = !!s && i != null && i !== "", [o, q] = l(null), [f, C] = l(""), [D, S] = l(""), [g, b] = l([]), [I, R] = l(!1), [A, c] = l(null), [T, F] = l(!0), y = L(null);
21
- j(() => {
22
- V();
23
- }, []), j(() => {
24
- if (!d) {
25
- y.current = null;
20
+ const m = H(), i = L(), n = !!o && p != null && p !== "", [d, S] = l(null), [g, D] = l(""), [R, I] = l(""), [y, b] = l([]), [T, A] = l(!1), [Q, x] = l(null), [E, K] = l(!0), v = P(null), k = P(!1);
21
+ W(() => {
22
+ Z();
23
+ }, []), W(() => {
24
+ if (!u) {
25
+ v.current = null;
26
26
  return;
27
27
  }
28
- y.current = {
29
- clip: J("support"),
28
+ v.current = {
29
+ clip: V("support"),
30
30
  route: typeof window < "u" ? window.location.pathname : ""
31
31
  };
32
- }, [d]);
33
- const { data: k = [] } = Y({
34
- queryKey: ["support-categories", r ? s : null],
35
- queryFn: () => u.request(
36
- X("/support/categories", r ? { collection: s } : void 0)
32
+ }, [u]);
33
+ const { data: w = [] } = Y({
34
+ queryKey: ["support-categories", n ? o : null],
35
+ queryFn: () => m.request(
36
+ X("/support/categories", n ? { collection: o } : void 0)
37
37
  ).then((e) => e.data ?? []),
38
- enabled: d
39
- }), M = () => {
40
- q(null), C(""), S(""), b([]), c(null), F(!0);
38
+ enabled: u
39
+ }), N = () => {
40
+ S(null), D(""), I(""), b([]), x(null), K(!0);
41
41
  };
42
- async function E() {
43
- if (!T) return { fileId: null, replay: null };
44
- const e = y.current;
45
- return re({
42
+ async function j() {
43
+ if (!E) return { fileId: null, replay: null };
44
+ const e = v.current;
45
+ return ne({
46
46
  clip: (e == null ? void 0 : e.clip) ?? null,
47
47
  route: (e == null ? void 0 : e.route) ?? (typeof window < "u" ? window.location.pathname : ""),
48
- upload: (n) => u.upload(n, { title: "What they saw" }),
48
+ upload: (r) => m.upload(r, { title: "What they saw" }),
49
49
  userAgent: typeof navigator < "u" ? navigator.userAgent : null
50
50
  });
51
51
  }
52
- const v = z({
52
+ const q = _({
53
53
  mutationFn: async () => {
54
- const e = await E();
55
- return u.request(
56
- _("/support/tickets", {
57
- title: f.trim(),
58
- description: D.trim() || null,
59
- category_id: o,
60
- collection: r ? s : null,
61
- item: r ? String(i) : null,
62
- attachments: [...g.map((n) => n.id), ...e.fileId ? [e.fileId] : []],
54
+ const e = await j();
55
+ return m.request(
56
+ B("/support/tickets", {
57
+ title: g.trim(),
58
+ description: R.trim() || null,
59
+ category_id: d,
60
+ collection: n ? o : null,
61
+ item: n ? String(p) : null,
62
+ attachments: [...y.map((r) => r.id), ...e.fileId ? [e.fileId] : []],
63
63
  ...e.replay ? { replay: e.replay } : {}
64
64
  })
65
65
  );
66
66
  },
67
67
  onSuccess: (e) => {
68
- h.invalidateQueries({ queryKey: ["support-tickets"] }), h.invalidateQueries({ queryKey: ["support-summary"] }), r && B(h, s, i), x == null || x(e.data), M(), m(!1);
68
+ i.invalidateQueries({ queryKey: ["support-tickets"] }), i.invalidateQueries({ queryKey: ["support-summary"] }), n && J(i, o, p), f == null || f(e.data), N(), c(!1);
69
69
  },
70
- onError: (e) => c(e.message || "Could not send the request")
70
+ onError: (e) => {
71
+ var s;
72
+ const r = e.response;
73
+ if ((((s = r == null ? void 0 : r.data) == null ? void 0 : s.code) ?? (r == null ? void 0 : r.code)) === "DUPLICATE_REQUEST") {
74
+ i.invalidateQueries({ queryKey: ["support-tickets"] }), i.invalidateQueries({ queryKey: ["support-summary"] }), N(), c(!1);
75
+ return;
76
+ }
77
+ x(e.message || "Could not send the request");
78
+ },
79
+ onSettled: () => {
80
+ k.current = !1;
81
+ }
71
82
  });
72
- async function K(e) {
83
+ async function U(e) {
73
84
  if (e != null && e.length) {
74
- R(!0), c(null);
85
+ A(!0), x(null);
75
86
  try {
76
- for (const n of Array.from(e).slice(0, 10)) {
77
- const w = await u.upload(n);
78
- b((P) => [...P, { id: String(w.id), name: n.name }]);
87
+ for (const r of Array.from(e).slice(0, 10)) {
88
+ const s = await m.upload(r);
89
+ b(($) => [...$, { id: String(s.id), name: r.name }]);
79
90
  }
80
91
  } catch {
81
- c("A file could not be uploaded");
92
+ x("A file could not be uploaded");
82
93
  } finally {
83
- R(!1);
94
+ A(!1);
84
95
  }
85
96
  }
86
97
  }
87
- const p = k.find((e) => e.id === o) ?? null, Q = f.trim().length > 0 && !v.isPending && !I;
98
+ const h = w.find((e) => e.id === d) ?? null, F = g.trim().length > 0 && !q.isPending && !T;
88
99
  return /* @__PURE__ */ t(
89
- Z,
100
+ O,
90
101
  {
91
- open: d,
102
+ open: u,
92
103
  onOpenChange: (e) => {
93
- e || M(), m(e);
104
+ e || N(), c(e);
94
105
  },
95
- children: /* @__PURE__ */ a(O, { className: "max-w-xl dark:bg-card", "data-support-request": !0, children: [
96
- /* @__PURE__ */ a(ee, { className: "px-6 pt-5", children: [
97
- /* @__PURE__ */ t(te, { className: "text-[15px] font-semibold text-slate-900 dark:text-slate-100", children: r ? `Request a change${N ? ` · ${N}` : ""}` : "Get help" }),
98
- /* @__PURE__ */ t(ae, { className: "text-[12.5px] text-slate-500 dark:text-muted-foreground", children: r ? "Tell the administrators what needs to change on this record. You can follow the request under My requests." : "Ask the administrators for help. You can follow the request under My requests." })
106
+ children: /* @__PURE__ */ a(ee, { className: "max-w-xl dark:bg-card", "data-support-request": !0, children: [
107
+ /* @__PURE__ */ a(te, { className: "px-6 pt-5", children: [
108
+ /* @__PURE__ */ t(re, { className: "text-[15px] font-semibold text-slate-900 dark:text-slate-100", children: n ? `Request a change${C ? ` · ${C}` : ""}` : "Get help" }),
109
+ /* @__PURE__ */ t(ae, { className: "text-[12.5px] text-slate-500 dark:text-muted-foreground", children: n ? "Tell the administrators what needs to change on this record. You can follow the request under My requests." : "Ask the administrators for help. You can follow the request under My requests." })
99
110
  ] }),
100
111
  /* @__PURE__ */ a(
101
112
  "form",
102
113
  {
103
114
  className: "space-y-4 px-6 pb-5 pt-3",
104
115
  onSubmit: (e) => {
105
- e.preventDefault(), Q && v.mutate();
116
+ e.preventDefault(), !(!F || k.current) && (k.current = !0, q.mutate());
106
117
  },
107
118
  children: [
108
- k.length > 0 && /* @__PURE__ */ a("fieldset", { children: [
119
+ w.length > 0 && /* @__PURE__ */ a("fieldset", { children: [
109
120
  /* @__PURE__ */ t("legend", { className: "mb-1.5 text-[12px] font-medium text-slate-700 dark:text-slate-200", children: "What kind of request?" }),
110
- /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1.5", "data-support-types": !0, children: k.map((e) => /* @__PURE__ */ t(
121
+ /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1.5", "data-support-types": !0, children: w.map((e) => /* @__PURE__ */ t(
111
122
  "button",
112
123
  {
113
124
  type: "button",
114
125
  "data-support-type": e.id,
115
- "aria-pressed": o === e.id,
116
- onClick: () => q(o === e.id ? null : e.id),
117
- className: o === e.id ? "rounded-full border border-nvr-cyan/60 bg-nvr-cyan/10 px-2.5 py-1 text-[12px] font-medium text-nvr-navy dark:text-nvr-cyan" : "rounded-full border border-slate-200 px-2.5 py-1 text-[12px] text-slate-600 hover:border-slate-300 dark:border-border dark:text-slate-300",
126
+ "aria-pressed": d === e.id,
127
+ onClick: () => S(d === e.id ? null : e.id),
128
+ className: d === e.id ? "rounded-full border border-nvr-cyan/60 bg-nvr-cyan/10 px-2.5 py-1 text-[12px] font-medium text-nvr-navy dark:text-nvr-cyan" : "rounded-full border border-slate-200 px-2.5 py-1 text-[12px] text-slate-600 hover:border-slate-300 dark:border-border dark:text-slate-300",
118
129
  children: e.name
119
130
  },
120
131
  e.id
121
132
  )) }),
122
- (p == null ? void 0 : p.description) && /* @__PURE__ */ t("p", { className: "mt-1.5 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: p.description })
133
+ (h == null ? void 0 : h.description) && /* @__PURE__ */ t("p", { className: "mt-1.5 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: h.description })
123
134
  ] }),
124
135
  /* @__PURE__ */ a("label", { className: "block", children: [
125
136
  /* @__PURE__ */ t("span", { className: "mb-1 block text-[12px] font-medium text-slate-700 dark:text-slate-200", children: "Summary" }),
@@ -127,10 +138,10 @@ function he({
127
138
  "input",
128
139
  {
129
140
  "data-support-title": !0,
130
- value: f,
131
- onChange: (e) => C(e.target.value),
141
+ value: g,
142
+ onChange: (e) => D(e.target.value),
132
143
  maxLength: 200,
133
- placeholder: r ? "e.g. Move to funding year 2027" : "e.g. I need access to the National zone",
144
+ placeholder: n ? "e.g. Move to funding year 2027" : "e.g. I need access to the National zone",
134
145
  className: "h-9 w-full rounded-md border border-slate-200 bg-white px-3 text-[13px] text-slate-900 outline-none focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-slate-100"
135
146
  }
136
147
  )
@@ -141,8 +152,8 @@ function he({
141
152
  "textarea",
142
153
  {
143
154
  "data-support-description": !0,
144
- value: D,
145
- onChange: (e) => S(e.target.value),
155
+ value: R,
156
+ onChange: (e) => I(e.target.value),
146
157
  rows: 5,
147
158
  placeholder: "What should change, and why",
148
159
  className: "w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-[13px] text-slate-900 outline-none focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-slate-100"
@@ -151,7 +162,7 @@ function he({
151
162
  ] }),
152
163
  /* @__PURE__ */ a("div", { children: [
153
164
  /* @__PURE__ */ a("label", { className: "inline-flex cursor-pointer items-center gap-1.5 text-[12px] font-medium text-slate-600 hover:text-slate-900 dark:text-slate-300 dark:hover:text-slate-100", children: [
154
- I ? /* @__PURE__ */ t(W, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(G, { className: "h-3.5 w-3.5" }),
165
+ T ? /* @__PURE__ */ t(M, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(z, { className: "h-3.5 w-3.5" }),
155
166
  "Attach files",
156
167
  /* @__PURE__ */ t(
157
168
  "input",
@@ -161,12 +172,12 @@ function he({
161
172
  className: "hidden",
162
173
  "data-support-files": !0,
163
174
  onChange: (e) => {
164
- K(e.target.files), e.target.value = "";
175
+ U(e.target.files), e.target.value = "";
165
176
  }
166
177
  }
167
178
  )
168
179
  ] }),
169
- g.length > 0 && /* @__PURE__ */ t("ul", { className: "mt-1.5 flex flex-wrap gap-1.5", children: g.map((e) => /* @__PURE__ */ a(
180
+ y.length > 0 && /* @__PURE__ */ t("ul", { className: "mt-1.5 flex flex-wrap gap-1.5", children: y.map((e) => /* @__PURE__ */ a(
170
181
  "li",
171
182
  {
172
183
  className: "inline-flex items-center gap-1 rounded bg-slate-100 px-2 py-0.5 text-[11.5px] text-slate-700 dark:bg-white/10 dark:text-slate-200",
@@ -177,9 +188,9 @@ function he({
177
188
  {
178
189
  type: "button",
179
190
  "aria-label": `Remove ${e.name}`,
180
- onClick: () => b((n) => n.filter((w) => w.id !== e.id)),
191
+ onClick: () => b((r) => r.filter((s) => s.id !== e.id)),
181
192
  className: "text-slate-400 hover:text-slate-700 dark:hover:text-slate-100",
182
- children: /* @__PURE__ */ t(H, { className: "h-3 w-3" })
193
+ children: /* @__PURE__ */ t(G, { className: "h-3 w-3" })
183
194
  }
184
195
  )
185
196
  ]
@@ -197,8 +208,8 @@ function he({
197
208
  "input",
198
209
  {
199
210
  type: "checkbox",
200
- checked: T,
201
- onChange: (e) => F(e.target.checked),
211
+ checked: E,
212
+ onChange: (e) => K(e.target.checked),
202
213
  className: "mt-0.5 accent-[#00ceff]"
203
214
  }
204
215
  ),
@@ -209,13 +220,13 @@ function he({
209
220
  ]
210
221
  }
211
222
  ),
212
- A && /* @__PURE__ */ t("p", { className: "text-[12px] text-red-600 dark:text-red-400", role: "alert", children: A }),
223
+ Q && /* @__PURE__ */ t("p", { className: "text-[12px] text-red-600 dark:text-red-400", role: "alert", children: Q }),
213
224
  /* @__PURE__ */ a("div", { className: "flex justify-end gap-2 pt-1", children: [
214
225
  /* @__PURE__ */ t(
215
226
  "button",
216
227
  {
217
228
  type: "button",
218
- onClick: () => m(!1),
229
+ onClick: () => c(!1),
219
230
  className: "h-8 rounded-md border border-slate-200 px-3 text-[12.5px] text-slate-700 hover:bg-slate-50 dark:border-border dark:text-slate-200 dark:hover:bg-white/5",
220
231
  children: "Cancel"
221
232
  }
@@ -225,10 +236,10 @@ function he({
225
236
  {
226
237
  type: "submit",
227
238
  "data-support-send": !0,
228
- disabled: !Q,
239
+ disabled: !F,
229
240
  className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-nvr-cyan/60 bg-nvr-cyan/10 px-3 text-[12.5px] font-medium text-nvr-navy hover:bg-nvr-cyan/15 disabled:opacity-50 dark:text-nvr-cyan",
230
241
  children: [
231
- v.isPending && /* @__PURE__ */ t(W, { className: "h-3.5 w-3.5 animate-spin" }),
242
+ q.isPending && /* @__PURE__ */ t(M, { className: "h-3.5 w-3.5 animate-spin" }),
232
243
  "Send request"
233
244
  ]
234
245
  }
@@ -242,5 +253,5 @@ function he({
242
253
  );
243
254
  }
244
255
  export {
245
- he as SupportRequestDialog
256
+ fe as SupportRequestDialog
246
257
  };