@nivaro/react 0.3.57 → 0.3.59

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 (69) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +37 -2
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2693 -2619
  8. package/dist/shared/components/DataTable.js +538 -495
  9. package/dist/shared/components/ItemEditForm.js +4559 -4386
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/ProfileView.js +716 -715
  12. package/dist/shared/components/QueryTable.js +74 -74
  13. package/dist/shared/components/RecordReadView.js +367 -364
  14. package/dist/shared/components/ReportView.js +64 -39
  15. package/dist/shared/components/WidgetSlot.js +543 -520
  16. package/dist/shared/components/alerts/AlertManagerView.js +324 -317
  17. package/dist/shared/components/alerts/types.js +37 -14
  18. package/dist/shared/components/cbv/row-focus.js +19 -0
  19. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  20. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  21. package/dist/shared/components/integrations/console/tone.js +52 -30
  22. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  23. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  24. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  25. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  26. package/dist/shared/components/item-edit/InlineTableField.js +2487 -2442
  27. package/dist/shared/components/item-edit/M2MCombobox.js +321 -295
  28. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  29. package/dist/shared/components/item-edit/PlanGrid.js +973 -894
  30. package/dist/shared/components/item-edit/QuickCreateButton.js +335 -106
  31. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  32. package/dist/shared/components/item-edit/RelationCombobox.js +452 -335
  33. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +262 -141
  34. package/dist/shared/components/item-edit/SummaryPanel.js +385 -358
  35. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  36. package/dist/shared/components/item-edit/line-midair.js +82 -75
  37. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  38. package/dist/shared/components/item-edit/related-missing.js +45 -0
  39. package/dist/shared/components/item-edit/save-outcome.js +9 -7
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  41. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  42. package/dist/shared/components/panels/ItemLockBanner.js +213 -211
  43. package/dist/shared/components/panels/PipelinePanel.js +1140 -1053
  44. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  45. package/dist/shared/components/panels/RevisionsPanel.js +316 -299
  46. package/dist/shared/components/panels/TaskPanel.js +265 -249
  47. package/dist/shared/components/panels/landing-state.js +27 -0
  48. package/dist/shared/components/pipeline/PipelineEditorView.js +110 -92
  49. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  50. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  51. package/dist/shared/components/queue/QueueQuickFilters.js +52 -52
  52. package/dist/shared/components/queue/QueueWorklist.js +1050 -1026
  53. package/dist/shared/components/queue/group-sums.js +27 -0
  54. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  55. package/dist/shared/components/widgets/ReviewListWidget.js +175 -154
  56. package/dist/shared/lib/back-closes.js +25 -0
  57. package/dist/shared/lib/display-prefs.js +60 -52
  58. package/dist/shared/lib/draft-store.js +71 -48
  59. package/dist/shared/lib/expression.js +53 -53
  60. package/dist/shared/lib/form-usage-beacon.js +7 -7
  61. package/dist/shared/lib/list-page-memory.js +63 -0
  62. package/dist/shared/lib/live.js +44 -44
  63. package/dist/shared/lib/money-input.js +45 -0
  64. package/dist/shared/lib/own-writes.js +76 -28
  65. package/dist/shared/lib/request-gate.js +110 -109
  66. package/dist/shared/lib/sanitize-html.js +10 -6
  67. package/dist/shared/lib/staged-row-labels.js +18 -0
  68. package/dist/shared/lib/validation-rules.js +34 -19
  69. package/package.json +1 -1
@@ -1,15 +1,16 @@
1
1
  import { jsx as n, jsxs as f } from "react/jsx-runtime";
2
- import { useQuery as ne } from "@tanstack/react-query";
3
- import { ChevronRight as ae, AlertCircle as se } from "lucide-react";
4
- import { useState as T, useMemo as K } from "react";
5
- import { useNivaroClient as oe, useItemEditAuth as ie } from "../../context.js";
6
- import { post as W, patch as de } from "../../lib/commands.js";
7
- import { formatDateTime as Y, cn as B, formatDate as ue } from "../../lib/utils.js";
8
- import { TooltipProvider as ce, Tooltip as me, TooltipTrigger as pe, TooltipContent as be } from "../ui/tooltip.js";
9
- function H(r) {
2
+ import { useQuery as se } from "@tanstack/react-query";
3
+ import { ChevronRight as oe, AlertCircle as ie } from "lucide-react";
4
+ import { useState as D, useMemo as W } from "react";
5
+ import { useNivaroClient as de, useItemEditAuth as ue } from "../../context.js";
6
+ import { useBackCloses as ce } from "../../lib/back-closes.js";
7
+ import { post as H, patch as me } from "../../lib/commands.js";
8
+ import { formatDateTime as ee, cn as Q, formatDate as pe } from "../../lib/utils.js";
9
+ import { TooltipProvider as be, Tooltip as fe, TooltipTrigger as xe, TooltipContent as he } from "../ui/tooltip.js";
10
+ function X(r) {
10
11
  return r === !0 || r === 1 || r === "1" || r === "true";
11
12
  }
12
- function A(r, t) {
13
+ function F(r, t) {
13
14
  if (r == null || r === "") return "—";
14
15
  if (t === "currency" || t === "number") {
15
16
  const a = Number(r);
@@ -17,11 +18,11 @@ function A(r, t) {
17
18
  }
18
19
  if (t === "date" || t === "datetime") {
19
20
  const a = new Date(r);
20
- return Number.isNaN(a.getTime()) ? String(r) : t === "date" ? ue(typeof r == "string" ? r : a) : Y(a);
21
+ return Number.isNaN(a.getTime()) ? String(r) : t === "date" ? pe(typeof r == "string" ? r : a) : ee(a);
21
22
  }
22
23
  return String(r);
23
24
  }
24
- const I = {
25
+ const R = {
25
26
  green: "#16a34a",
26
27
  red: "#dc2626",
27
28
  amber: "#d97706",
@@ -29,101 +30,103 @@ const I = {
29
30
  purple: "#9333ea",
30
31
  slate: "#64748b"
31
32
  };
32
- function fe(r) {
33
+ function we(r) {
33
34
  return {
34
35
  backgroundColor: r ? `${r}22` : "#f1f5f9",
35
36
  color: r ?? "#475569",
36
37
  border: `1px solid ${r ? `${r}44` : "#e2e8f0"}`
37
38
  };
38
39
  }
39
- function M({ label: r, color: t }) {
40
- const a = t ? I[t] ?? null : null;
40
+ function I({ label: r, color: t }) {
41
+ const a = t ? R[t] ?? null : null;
41
42
  return /* @__PURE__ */ n(
42
43
  "span",
43
44
  {
44
45
  className: "inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11px] font-medium",
45
- style: fe(a),
46
+ style: we(a),
46
47
  children: r
47
48
  }
48
49
  );
49
50
  }
50
- function xe(r, t) {
51
+ function ye(r, t) {
51
52
  if (r == null || r === "")
52
53
  return t.empty_label ? { label: t.empty_label, color: t.empty_color ?? "blue" } : { label: "—", color: null };
53
- const a = t.options.find((u) => u.value === String(r));
54
+ const a = t.options.find((b) => b.value === String(r));
54
55
  return a ? { label: a.status_label || a.label, color: a.color } : { label: String(r), color: null };
55
56
  }
56
- function he(r, t) {
57
+ function ke(r, t) {
57
58
  const a = /* @__PURE__ */ new Map();
58
59
  for (const x of r.rows) {
59
60
  const s = String(x.group ?? ""), h = a.get(s);
60
61
  h ? h.push(x) : a.set(s, [x]);
61
62
  }
62
- const u = Array.from(a.entries()).map(([x, s]) => {
63
- const y = new Set(s.map((F) => String(F.status ?? ""))).size > 1, D = y ? null : s[0].status;
64
- let _ = null;
65
- return t && s.every((S) => t in S.values) && (_ = s.reduce((S, O) => S + (Number(O.values[t]) || 0), 0)), { key: x, rows: s, count: s.length, sum: _, uniformStatus: D, mixedStatus: y };
63
+ const b = Array.from(a.entries()).map(([x, s]) => {
64
+ const w = new Set(s.map((j) => String(j.status ?? ""))).size > 1, O = w ? null : s[0].status;
65
+ let C = null;
66
+ return t && s.every((q) => t in q.values) && (C = s.reduce((q, E) => q + (Number(E.values[t]) || 0), 0)), { key: x, rows: s, count: s.length, sum: C, uniformStatus: O, mixedStatus: w };
66
67
  });
67
- return u.sort((x, s) => x.key.localeCompare(s.key, void 0, { numeric: !0 })), u;
68
+ return b.sort((x, s) => x.key.localeCompare(s.key, void 0, { numeric: !0 })), b;
68
69
  }
69
- function Q(r, t, a) {
70
- let u = null;
70
+ function J(r, t, a) {
71
+ let b = null;
71
72
  for (const x of r) {
72
73
  const s = x.values[t];
73
74
  if (s == null || s === "") continue;
74
- const h = typeof s == "number" ? s : Date.parse(String(s)), y = Number.isNaN(h) ? Number(s) : h;
75
- Number.isFinite(y) && (u == null || (a ? y > u : y < u)) && (u = y);
75
+ const h = typeof s == "number" ? s : Date.parse(String(s)), w = Number.isNaN(h) ? Number(s) : h;
76
+ Number.isFinite(w) && (b == null || (a ? w > b : w < b)) && (b = w);
76
77
  }
77
- return u;
78
+ return b;
78
79
  }
79
- function X(r, t) {
80
- const a = r.rows[0], u = (x) => {
81
- const s = t.find((y) => y.role === x);
80
+ function Y(r, t) {
81
+ const a = r.rows[0], b = (x) => {
82
+ const s = t.find((w) => w.role === x);
82
83
  if (!s || !a) return null;
83
84
  const h = a.values[s.field];
84
- return h == null || h === "" ? null : `${s.prefix ?? ""}${A(h, s.format)}`;
85
+ return h == null || h === "" ? null : `${s.prefix ?? ""}${F(h, s.format)}`;
85
86
  };
86
- return { title: u("title") ?? (r.key || "—"), subtitle: u("subtitle") };
87
+ return { title: b("title") ?? (r.key || "—"), subtitle: b("subtitle") };
87
88
  }
88
- function J(r, t) {
89
+ function Z(r, t) {
89
90
  const a = (t == null ? void 0 : t.trim()) || "row";
90
91
  return `${r} ${a}${r === 1 ? "" : "s"}`;
91
92
  }
92
- function ye(r, t, a) {
93
- const u = a != null && a.trim() ? `${a.trim()} ` : "";
94
- return `${r.label} ${u}${t.title}${t.subtitle ? ` · ${t.subtitle}` : ""}?`;
93
+ function ge(r, t, a) {
94
+ const b = a != null && a.trim() ? `${a.trim()} ` : "";
95
+ return `${r.label} ${b}${t.title}${t.subtitle ? ` · ${t.subtitle}` : ""}?`;
95
96
  }
96
- function Ce({
97
+ function De({
97
98
  data: r,
98
99
  config: t,
99
100
  loading: a,
100
- error: u,
101
+ error: b,
101
102
  onRefetch: x,
102
103
  hostRecordId: s,
103
104
  emptyLabel: h
104
105
  }) {
105
- const y = oe(), { userId: D } = ie(), [_, F] = T(() => /* @__PURE__ */ new Set()), [S, O] = T(null), [R, Z] = T({}), [m, $] = T(null), [E, L] = T(""), U = K(() => {
106
- const e = r ? he(r, t.aggregate_sum) : [], o = t.group_sort;
106
+ const w = de(), { userId: O } = ue(), [C, j] = D(() => /* @__PURE__ */ new Set()), [q, E] = D(null), [L, te] = D({}), [c, _] = D(null), [P, U] = D("");
107
+ ce(() => _(null), c != null);
108
+ const V = W(() => {
109
+ const e = r ? ke(r, t.aggregate_sum) : [], o = t.group_sort;
107
110
  if (!(o != null && o.field)) return e;
108
- const p = o.direction === "desc";
109
- return [...e].sort((k, d) => {
110
- const b = Q(k.rows, o.field, p), w = Q(d.rows, o.field, p);
111
- return b == null && w == null ? 0 : b == null ? 1 : w == null ? -1 : p ? w - b : b - w;
111
+ const m = o.direction === "desc";
112
+ return [...e].sort((y, d) => {
113
+ const p = J(y.rows, o.field, m), k = J(d.rows, o.field, m);
114
+ return p == null && k == null ? 0 : p == null ? 1 : k == null ? -1 : m ? k - p : p - k;
112
115
  });
113
- }, [r, t.aggregate_sum, t.group_sort]), P = K(() => ((r == null ? void 0 : r.rows) ?? []).map((e) => String(e.id)), [r]), { data: C } = ne({
114
- queryKey: ["review-list-enrich", t.enrich_endpoint ?? "", P.join(",")],
115
- queryFn: () => y.request(
116
- W(t.enrich_endpoint, { ids: P })
116
+ }, [r, t.aggregate_sum, t.group_sort]), G = W(() => ((r == null ? void 0 : r.rows) ?? []).map((e) => String(e.id)), [r]), { data: T } = se({
117
+ queryKey: ["review-list-enrich", t.enrich_endpoint ?? "", G.join(",")],
118
+ queryFn: () => w.request(
119
+ H(t.enrich_endpoint, { ids: G })
117
120
  ).then((e) => {
118
121
  var o;
119
122
  return ((o = e == null ? void 0 : e.data) == null ? void 0 : o.rows) ?? {};
120
123
  }).catch(() => ({})),
121
- enabled: !!t.enrich_endpoint && P.length > 0,
124
+ enabled: !!t.enrich_endpoint && G.length > 0,
122
125
  staleTime: 3e4
123
- }), j = (e) => C == null ? void 0 : C[String(e)], V = !!C && Object.values(C).some((e) => {
126
+ }), S = (e) => T == null ? void 0 : T[String(e)], z = !!T && Object.values(T).some((e) => {
124
127
  var o;
125
128
  return (((o = e.chips) == null ? void 0 : o.length) ?? 0) > 0;
126
- }), ee = U.length === 1;
129
+ }), re = V.length === 1;
127
130
  if (a)
128
131
  return /* @__PURE__ */ n("div", { className: "space-y-2", children: [0, 1].map((e) => /* @__PURE__ */ n(
129
132
  "div",
@@ -132,24 +135,27 @@ function Ce({
132
135
  },
133
136
  e
134
137
  )) });
135
- if (u)
136
- return /* @__PURE__ */ n("p", { className: "text-[12px] text-red-500", children: u });
138
+ if (b)
139
+ return /* @__PURE__ */ n("p", { className: "text-[12px] text-red-500", children: b });
137
140
  if (!r || r.rows.length === 0)
138
141
  return /* @__PURE__ */ n("p", { className: "text-[12px] italic text-slate-400", children: h ? `No ${h.toLowerCase()} yet` : "Nothing here yet" });
139
- const te = (e) => {
140
- F((o) => {
141
- const p = new Set(o);
142
- return p.has(e) ? p.delete(e) : p.add(e), p;
142
+ const le = (e) => {
143
+ j((o) => {
144
+ const m = new Set(o);
145
+ return m.has(e) ? m.delete(e) : m.add(e), m;
143
146
  });
144
- }, re = (e, o) => {
145
- L(""), $({ group: e, option: o });
146
- }, le = async (e, o, p) => {
147
- O(e.key);
148
- let k = null;
147
+ }, B = (e, o) => e.rows.map((m) => {
148
+ var y, d, p;
149
+ return (p = (d = (y = S(m.id)) == null ? void 0 : y.confirm_notices) == null ? void 0 : d[o.value]) == null ? void 0 : p.trim();
150
+ }).find((m) => !!m) ?? o.confirm_notice ?? null, ne = (e, o) => {
151
+ U(""), _({ group: e, option: o });
152
+ }, ae = async (e, o, m) => {
153
+ E(e.key);
154
+ let y = null;
149
155
  if (t.status.action_endpoint)
150
156
  try {
151
- await y.request(
152
- W(t.status.action_endpoint, {
157
+ await w.request(
158
+ H(t.status.action_endpoint, {
153
159
  ids: e.rows.map((d) => d.id),
154
160
  status: o.value,
155
161
  // The status each row showed: the endpoint may refuse (409) rows
@@ -158,48 +164,51 @@ function Ce({
158
164
  expected: Object.fromEntries(
159
165
  e.rows.map((d) => [String(d.id), d.status == null ? null : String(d.status)])
160
166
  ),
161
- ...p ? { note: p } : {},
167
+ ...m ? { note: m } : {},
162
168
  ...s != null && s !== "" ? { workflow_id: Number(s) } : {}
163
169
  })
164
170
  );
165
171
  } catch (d) {
166
- const b = d == null ? void 0 : d.response;
167
- k = (b == null ? void 0 : b.error) ?? "Failed to update";
172
+ const p = d == null ? void 0 : d.response;
173
+ y = (p == null ? void 0 : p.error) ?? "Failed to update";
168
174
  }
169
175
  else {
170
- const d = t.status.stamp_date_field ? (/* @__PURE__ */ new Date()).toISOString() : void 0, w = (await Promise.all(
171
- e.rows.map(async (g) => {
172
- const N = { [t.status.field]: o.value };
173
- t.status.stamp_user_field && D && (N[t.status.stamp_user_field] = D), t.status.stamp_date_field && (N[t.status.stamp_date_field] = d), p && (N._change_reason = p);
176
+ const d = t.status.stamp_date_field ? (/* @__PURE__ */ new Date()).toISOString() : void 0, k = (await Promise.all(
177
+ e.rows.map(async (N) => {
178
+ const g = { [t.status.field]: o.value };
179
+ t.status.stamp_user_field && O && (g[t.status.stamp_user_field] = O), t.status.stamp_date_field && (g[t.status.stamp_date_field] = d), m && (g._change_reason = m);
174
180
  try {
175
- return await y.request(de(`/items/${t.collection}/${g.id}`, N)), { ok: !0 };
176
- } catch (v) {
177
- const l = v == null ? void 0 : v.response;
178
- return { ok: !1, error: (l == null ? void 0 : l.error) ?? "Failed to update" };
181
+ return await w.request(me(`/items/${t.collection}/${N.id}`, g)), { ok: !0 };
182
+ } catch ($) {
183
+ const v = $ == null ? void 0 : $.response;
184
+ return { ok: !1, error: (v == null ? void 0 : v.error) ?? "Failed to update" };
179
185
  }
180
186
  })
181
- )).filter((g) => !g.ok);
182
- w.length > 0 && (k = `${w.length} of ${e.rows.length} row(s) failed to update`);
187
+ )).filter((N) => !N.ok);
188
+ k.length > 0 && (y = `${k.length} of ${e.rows.length} row(s) failed to update`);
183
189
  }
184
- O(null), Z((d) => {
185
- const b = { ...d };
186
- return k ? b[e.key] = k : delete b[e.key], b;
190
+ E(null), te((d) => {
191
+ const p = { ...d };
192
+ return y ? p[e.key] = y : delete p[e.key], p;
187
193
  }), x();
188
- }, z = r.columns.line_columns, G = r.columns.group_meta;
189
- return /* @__PURE__ */ n(ce, { delayDuration: 200, children: /* @__PURE__ */ f("div", { className: "space-y-2", children: [
194
+ }, K = r.columns.line_columns, M = r.columns.group_meta;
195
+ return /* @__PURE__ */ n(be, { delayDuration: 200, children: /* @__PURE__ */ f("div", { className: "space-y-2", children: [
190
196
  r.truncated && /* @__PURE__ */ n("p", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Showing first 2000 rows — some rows may be missing." }),
191
- U.map((e) => {
192
- const o = ee ? !_.has(e.key) : _.has(e.key), p = e.rows.every((l) => {
193
- var c;
194
- return ((c = j(l.id)) == null ? void 0 : c.can_act) !== !1;
195
- }), k = e.rows.map((l) => {
196
- var c;
197
- return (c = j(l.id)) == null ? void 0 : c.reason;
198
- }).find((l) => !!l) ?? "Only the workflow contact chain (or the PO requestor for invalid holds) can decide this", d = X(e, G), b = e.mixedStatus ? { label: "Mixed", color: null } : xe(e.uniformStatus, t.status), w = e.rows[0], g = w.stamp_user, N = w.stamp_date, v = e.rows.reduce((l, c) => {
197
+ V.map((e) => {
198
+ const o = re ? !C.has(e.key) : C.has(e.key), m = e.rows.every((l) => {
199
+ var u;
200
+ return ((u = S(l.id)) == null ? void 0 : u.can_act) !== !1;
201
+ }), y = e.rows.map((l) => {
202
+ var u;
203
+ return (u = S(l.id)) == null ? void 0 : u.reason;
204
+ }).find((l) => !!l) ?? "Only the workflow contact chain (or the PO requestor for invalid holds) can decide this", d = e.rows.map((l) => {
205
+ var u, i;
206
+ return (i = (u = S(l.id)) == null ? void 0 : u.note) == null ? void 0 : i.trim();
207
+ }).find((l) => !!l) ?? null, p = Y(e, M), k = e.mixedStatus ? { label: "Mixed", color: null } : ye(e.uniformStatus, t.status), N = e.rows[0], g = N.stamp_user, $ = N.stamp_date, v = e.rows.reduce((l, u) => {
199
208
  var i;
200
- for (const q of ((i = j(c.id)) == null ? void 0 : i.chips) ?? []) {
201
- if (q.tone === "danger") return "danger";
202
- q.tone === "warn" && l == null && (l = "warn");
209
+ for (const A of ((i = S(u.id)) == null ? void 0 : i.chips) ?? []) {
210
+ if (A.tone === "danger") return "danger";
211
+ A.tone === "warn" && l == null && (l = "warn");
203
212
  }
204
213
  return l;
205
214
  }, null);
@@ -208,7 +217,7 @@ function Ce({
208
217
  {
209
218
  "data-review-group": e.key,
210
219
  "data-review-tone": v ?? void 0,
211
- className: B(
220
+ className: Q(
212
221
  "rounded-md border",
213
222
  v === "danger" ? "border-l-2 border-l-red-500 border-red-200 bg-red-50/40 dark:border-red-500/40 dark:bg-red-500/5" : v === "warn" ? "border-l-2 border-l-amber-500 border-amber-200 bg-amber-50/40 dark:border-amber-500/40 dark:bg-amber-500/5" : "border-slate-200 dark:border-border"
214
223
  ),
@@ -218,11 +227,11 @@ function Ce({
218
227
  "button",
219
228
  {
220
229
  type: "button",
221
- onClick: () => te(e.key),
230
+ onClick: () => le(e.key),
222
231
  className: "flex min-w-0 flex-1 flex-wrap items-center gap-2 text-left",
223
232
  children: [
224
233
  /* @__PURE__ */ n(
225
- ae,
234
+ oe,
226
235
  {
227
236
  className: `h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform ${o ? "rotate-90" : ""}`
228
237
  }
@@ -232,97 +241,109 @@ function Ce({
232
241
  {
233
242
  className: "text-[12px] font-medium text-slate-700 dark:text-slate-200",
234
243
  "data-review-group-title": !0,
235
- children: d.title
244
+ children: p.title
236
245
  }
237
246
  ),
238
- d.subtitle && /* @__PURE__ */ n("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: d.subtitle }),
247
+ p.subtitle && /* @__PURE__ */ n("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: p.subtitle }),
239
248
  /* @__PURE__ */ f("span", { className: "text-[11px] text-slate-400", children: [
240
- J(e.count, t.row_noun),
241
- e.sum != null ? ` · ${A(e.sum, t.aggregate_sum_format ?? "number")}` : ""
249
+ Z(e.count, t.row_noun),
250
+ e.sum != null ? ` · ${F(e.sum, t.aggregate_sum_format ?? "number")}` : ""
242
251
  ] }),
243
- G.map((l) => {
252
+ M.map((l) => {
244
253
  if (l.role) return null;
245
- const c = w.values[l.field];
246
- return l.format === "flag" ? H(c) ? /* @__PURE__ */ n(M, { label: l.label, color: l.color ?? "amber" }, l.field) : null : c == null || c === "" ? null : /* @__PURE__ */ f(
254
+ const u = N.values[l.field];
255
+ return l.format === "flag" ? X(u) ? /* @__PURE__ */ n(I, { label: l.label, color: l.color ?? "amber" }, l.field) : null : u == null || u === "" ? null : /* @__PURE__ */ f(
247
256
  "span",
248
257
  {
249
258
  className: "rounded-full bg-slate-100 px-2 py-0.5 text-[10px] font-medium text-slate-500 dark:bg-slate-800 dark:text-slate-400",
250
259
  children: [
251
260
  l.label,
252
261
  ": ",
253
- A(c, l.format)
262
+ F(u, l.format)
254
263
  ]
255
264
  },
256
265
  l.field
257
266
  );
258
267
  }),
259
- /* @__PURE__ */ n(M, { label: b.label, color: b.color }),
260
- g && /* @__PURE__ */ f(me, { children: [
261
- /* @__PURE__ */ n(pe, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "cursor-default text-[11px] text-slate-400 underline decoration-dotted", children: g.label }) }),
262
- /* @__PURE__ */ f(be, { side: "top", className: "text-[12px]", children: [
268
+ /* @__PURE__ */ n(I, { label: k.label, color: k.color }),
269
+ g && /* @__PURE__ */ f(fe, { children: [
270
+ /* @__PURE__ */ n(xe, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "cursor-default text-[11px] text-slate-400 underline decoration-dotted", children: g.label }) }),
271
+ /* @__PURE__ */ f(he, { side: "top", className: "text-[12px]", children: [
263
272
  /* @__PURE__ */ n("p", { className: "font-medium", children: g.label }),
264
- N && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: Y(N) })
273
+ $ && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: ee($) })
265
274
  ] })
266
275
  ] })
267
276
  ]
268
277
  }
269
278
  ),
270
279
  /* @__PURE__ */ f("span", { className: "flex flex-wrap items-center gap-1.5", children: [
271
- !p && /* @__PURE__ */ n(
280
+ !m && /* @__PURE__ */ n(
272
281
  "span",
273
282
  {
274
283
  className: "text-[11px] text-slate-400",
275
- title: k,
284
+ title: y,
276
285
  "data-review-view-only": !0,
277
286
  children: "View only"
278
287
  }
279
288
  ),
280
- p && t.status.options.map((l) => {
281
- const c = !e.mixedStatus && String(e.uniformStatus) === l.value, i = I[l.color] ?? I.slate, q = S === e.key;
289
+ m && t.status.options.map((l) => {
290
+ const u = !e.mixedStatus && String(e.uniformStatus) === l.value, i = R[l.color] ?? R.slate, A = q === e.key;
282
291
  return /* @__PURE__ */ n(
283
292
  "button",
284
293
  {
285
294
  type: "button",
286
- disabled: q || c,
287
- onClick: () => re(e, l),
295
+ disabled: A || u,
296
+ onClick: () => ne(e, l),
288
297
  className: "rounded-md border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
289
298
  style: {
290
- backgroundColor: c ? `${i}22` : "transparent",
299
+ backgroundColor: u ? `${i}22` : "transparent",
291
300
  borderColor: `${i}55`,
292
301
  color: i
293
302
  },
294
- children: q ? "…" : l.label
303
+ children: A ? "…" : l.label
295
304
  },
296
305
  l.value
297
306
  );
298
307
  })
299
308
  ] })
300
309
  ] }),
301
- R[e.key] && /* @__PURE__ */ f("p", { className: "flex items-center gap-1 px-3 pb-2 text-[11px] text-red-600", children: [
302
- /* @__PURE__ */ n(se, { className: "h-3 w-3 shrink-0" }),
303
- R[e.key]
310
+ d && /* @__PURE__ */ f(
311
+ "p",
312
+ {
313
+ "data-review-decision-note": !0,
314
+ className: "border-t border-slate-100 px-3 py-1.5 text-[11.5px] text-red-700 dark:border-border dark:text-red-300",
315
+ children: [
316
+ /* @__PURE__ */ n("span", { className: "font-medium", children: "Reason:" }),
317
+ " ",
318
+ /* @__PURE__ */ n("span", { className: "whitespace-pre-line", children: d })
319
+ ]
320
+ }
321
+ ),
322
+ L[e.key] && /* @__PURE__ */ f("p", { className: "flex items-center gap-1 px-3 pb-2 text-[11px] text-red-600", children: [
323
+ /* @__PURE__ */ n(ie, { className: "h-3 w-3 shrink-0" }),
324
+ L[e.key]
304
325
  ] }),
305
326
  o && /* @__PURE__ */ n("div", { className: "overflow-x-auto border-t border-slate-100 dark:border-border/50", children: /* @__PURE__ */ f("table", { className: "w-full border-collapse text-[12px]", children: [
306
327
  /* @__PURE__ */ n("thead", { children: /* @__PURE__ */ f("tr", { className: "border-b border-slate-200 bg-slate-50/60 text-left text-[11px] font-medium text-slate-400 dark:border-border dark:bg-white/[0.02]", children: [
307
- z.map((l) => /* @__PURE__ */ n("th", { className: "px-2.5 py-1.5 font-medium", children: l.label }, l.field)),
308
- V && /* @__PURE__ */ n("th", { className: "px-2.5 py-1.5 font-medium", children: "Match" })
328
+ K.map((l) => /* @__PURE__ */ n("th", { className: "px-2.5 py-1.5 font-medium", children: l.label }, l.field)),
329
+ z && /* @__PURE__ */ n("th", { className: "px-2.5 py-1.5 font-medium", children: "Match" })
309
330
  ] }) }),
310
331
  /* @__PURE__ */ n("tbody", { children: e.rows.map((l) => {
311
- var c;
332
+ var u;
312
333
  return /* @__PURE__ */ f(
313
334
  "tr",
314
335
  {
315
336
  className: "border-b border-slate-100 last:border-b-0 dark:border-border/50",
316
337
  children: [
317
- z.map((i) => /* @__PURE__ */ n(
338
+ K.map((i) => /* @__PURE__ */ n(
318
339
  "td",
319
340
  {
320
341
  className: "px-2.5 py-1.5 text-slate-600 dark:text-slate-300",
321
- children: i.format === "flag" ? H(l.values[i.field]) ? /* @__PURE__ */ n(M, { label: i.label, color: i.color ?? "amber" }) : "—" : A(l.values[i.field], i.format)
342
+ children: i.format === "flag" ? X(l.values[i.field]) ? /* @__PURE__ */ n(I, { label: i.label, color: i.color ?? "amber" }) : "—" : F(l.values[i.field], i.format)
322
343
  },
323
344
  i.field
324
345
  )),
325
- V && /* @__PURE__ */ n("td", { className: "px-2.5 py-1.5", children: /* @__PURE__ */ n("span", { className: "flex flex-wrap gap-1", children: (((c = j(l.id)) == null ? void 0 : c.chips) ?? []).map((i) => /* @__PURE__ */ n(
346
+ z && /* @__PURE__ */ n("td", { className: "px-2.5 py-1.5", children: /* @__PURE__ */ n("span", { className: "flex flex-wrap gap-1", children: (((u = S(l.id)) == null ? void 0 : u.chips) ?? []).map((i) => /* @__PURE__ */ n(
326
347
  "span",
327
348
  {
328
349
  title: i.title,
@@ -342,13 +363,13 @@ function Ce({
342
363
  e.key
343
364
  );
344
365
  }),
345
- m && /* @__PURE__ */ n(
366
+ c && /* @__PURE__ */ n(
346
367
  "div",
347
368
  {
348
369
  className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4",
349
- onClick: () => $(null),
370
+ onClick: () => _(null),
350
371
  onKeyDown: (e) => {
351
- e.key === "Escape" && (e.stopPropagation(), $(null));
372
+ e.key === "Escape" && (e.stopPropagation(), _(null));
352
373
  },
353
374
  children: /* @__PURE__ */ f(
354
375
  "div",
@@ -356,7 +377,7 @@ function Ce({
356
377
  role: "dialog",
357
378
  "aria-modal": "true",
358
379
  "aria-labelledby": "review-confirm-title",
359
- "data-review-confirm": m.option.value,
380
+ "data-review-confirm": c.option.value,
360
381
  className: "w-full max-w-md rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-card",
361
382
  onClick: (e) => e.stopPropagation(),
362
383
  children: [
@@ -365,36 +386,36 @@ function Ce({
365
386
  {
366
387
  id: "review-confirm-title",
367
388
  className: "text-[13px] font-medium text-slate-700 dark:text-slate-200",
368
- children: ye(
369
- m.option,
370
- X(m.group, G),
389
+ children: ge(
390
+ c.option,
391
+ Y(c.group, M),
371
392
  t.group_noun
372
393
  )
373
394
  }
374
395
  ),
375
396
  /* @__PURE__ */ f("p", { className: "mt-1 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 text-[12px] tabular-nums text-slate-600 dark:border-border dark:bg-white/[0.03] dark:text-slate-300", children: [
376
- J(m.group.count, t.row_noun),
377
- m.group.sum != null ? ` · ${A(m.group.sum, t.aggregate_sum_format ?? "number")}` : ""
397
+ Z(c.group.count, t.row_noun),
398
+ c.group.sum != null ? ` · ${F(c.group.sum, t.aggregate_sum_format ?? "number")}` : ""
378
399
  ] }),
379
400
  /* @__PURE__ */ n(
380
401
  "p",
381
402
  {
382
403
  className: "mt-1.5 text-[11px] text-slate-500 dark:text-slate-400",
383
404
  "data-review-confirm-notice": !0,
384
- children: m.option.confirm_notice ? `${m.option.confirm_notice}${m.option.require_note ? " A reason is required." : ""}` : m.option.require_note ? "A reason is required for this decision. It is recorded with the record." : "Nothing changes until you confirm. A note is optional and is recorded with the decision."
405
+ children: B(c.group, c.option) ? `${B(c.group, c.option)}${c.option.require_note ? " A reason is required." : ""}` : c.option.require_note ? "A reason is required for this decision. It is recorded with the record." : "Nothing changes until you confirm. A note is optional and is recorded with the decision."
385
406
  }
386
407
  ),
387
408
  /* @__PURE__ */ n(
388
409
  "textarea",
389
410
  {
390
- value: E,
391
- onChange: (e) => L(e.target.value),
411
+ value: P,
412
+ onChange: (e) => U(e.target.value),
392
413
  rows: 3,
393
414
  autoFocus: !0,
394
- "aria-label": m.option.require_note ? "Reason" : "Note (optional)",
415
+ "aria-label": c.option.require_note ? "Reason" : "Note (optional)",
395
416
  "data-review-confirm-note": !0,
396
417
  className: "mt-2 w-full rounded-md border border-slate-200 bg-white px-2.5 py-1.5 text-[12px] text-slate-700 outline-none focus:border-nvr-cyan dark:border-border dark:bg-background dark:text-slate-200",
397
- placeholder: m.option.require_note ? "Why is this being rejected?" : "Note (optional)"
418
+ placeholder: c.option.require_note ? "Why is this being rejected?" : "Note (optional)"
398
419
  }
399
420
  ),
400
421
  /* @__PURE__ */ f("div", { className: "mt-3 flex items-center justify-end gap-1.5", children: [
@@ -403,7 +424,7 @@ function Ce({
403
424
  {
404
425
  type: "button",
405
426
  "data-review-confirm-cancel": !0,
406
- onClick: () => $(null),
427
+ onClick: () => _(null),
407
428
  className: "rounded px-2.5 py-1 text-[11px] text-slate-500 hover:bg-slate-100 dark:hover:bg-muted",
408
429
  children: "Cancel"
409
430
  }
@@ -413,16 +434,16 @@ function Ce({
413
434
  {
414
435
  type: "button",
415
436
  "data-review-confirm-submit": !0,
416
- disabled: !!m.option.require_note && !E.trim(),
437
+ disabled: !!c.option.require_note && !P.trim(),
417
438
  onClick: () => {
418
- const e = m;
419
- $(null), le(e.group, e.option, E.trim() || null);
439
+ const e = c;
440
+ _(null), ae(e.group, e.option, P.trim() || null);
420
441
  },
421
- className: B(
442
+ className: Q(
422
443
  "rounded px-3 py-1 text-[11px] font-medium hover:brightness-110 disabled:opacity-50",
423
- m.option.require_note ? "bg-red-600 text-white" : "bg-nvr-cyan text-white"
444
+ c.option.require_note ? "bg-red-600 text-white" : "bg-nvr-cyan text-white"
424
445
  ),
425
- children: m.option.label
446
+ children: c.option.label
426
447
  }
427
448
  )
428
449
  ] })
@@ -434,10 +455,10 @@ function Ce({
434
455
  ] }) });
435
456
  }
436
457
  export {
437
- Ce as ReviewListWidget,
438
- I as STATUS_COLOR_HEX,
439
- ye as confirmTitle,
440
- J as countLabel,
441
- A as formatValue,
442
- X as groupName
458
+ De as ReviewListWidget,
459
+ R as STATUS_COLOR_HEX,
460
+ ge as confirmTitle,
461
+ Z as countLabel,
462
+ F as formatValue,
463
+ Y as groupName
443
464
  };
@@ -0,0 +1,25 @@
1
+ import { useRef as a, useEffect as w } from "react";
2
+ let d = 0;
3
+ function f(e, t = !0) {
4
+ const o = a(e);
5
+ o.current = e, w(() => {
6
+ if (!t || typeof window > "u") return;
7
+ const r = `nvr-dialog-${++d}`, n = () => {
8
+ var u;
9
+ return ((u = window.history.state) == null ? void 0 : u.nvrDialog) === r;
10
+ };
11
+ window.history.pushState({ ...window.history.state ?? {}, nvrDialog: r }, "");
12
+ let s = !1;
13
+ const i = () => {
14
+ n() || (s = !0, o.current());
15
+ };
16
+ return window.addEventListener("popstate", i), () => {
17
+ window.removeEventListener("popstate", i), s || setTimeout(() => {
18
+ n() && window.history.back();
19
+ }, 0);
20
+ };
21
+ }, [t]);
22
+ }
23
+ export {
24
+ f as useBackCloses
25
+ };