@nivaro/react 0.3.49 → 0.3.50

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 (32) hide show
  1. package/dist/components/InlineGridField.js +166 -105
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +25 -1
  5. package/dist/shared/components/ItemEditForm.js +4676 -4579
  6. package/dist/shared/components/QueryTable.js +461 -332
  7. package/dist/shared/components/item-edit/CatalogPickerField.js +1144 -1127
  8. package/dist/shared/components/item-edit/CloneDialog.js +192 -142
  9. package/dist/shared/components/item-edit/FieldRenderer.js +127 -126
  10. package/dist/shared/components/item-edit/FieldRow.js +236 -226
  11. package/dist/shared/components/item-edit/InlineGridField.js +92 -90
  12. package/dist/shared/components/item-edit/InlineTableField.js +3088 -2945
  13. package/dist/shared/components/item-edit/MidairCollisionDialog.js +175 -0
  14. package/dist/shared/components/item-edit/PlanGrid.js +162 -162
  15. package/dist/shared/components/item-edit/PolishFields.js +169 -162
  16. package/dist/shared/components/item-edit/RelationCombobox.js +186 -181
  17. package/dist/shared/components/item-edit/SummaryPanel.js +148 -135
  18. package/dist/shared/components/item-edit/ValidationSummary.js +64 -47
  19. package/dist/shared/components/item-edit/helpers.js +181 -155
  20. package/dist/shared/components/item-edit/line-midair.js +201 -0
  21. package/dist/shared/components/item-edit/soft-rules.js +27 -0
  22. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  23. package/dist/shared/components/panels/ItemLockBanner.js +414 -358
  24. package/dist/shared/components/panels/PipelinePanel.js +1157 -963
  25. package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
  26. package/dist/shared/components/queue/QueueWorklist.js +870 -827
  27. package/dist/shared/components/queue/column-chooser.js +21 -0
  28. package/dist/shared/components/queue/live-state-aspect.js +6 -0
  29. package/dist/shared/components/ui/number-draft-input.js +93 -0
  30. package/dist/shared/components/widgets/ReviewListWidget.js +191 -166
  31. package/dist/shared/lib/error-hints.js +1 -0
  32. package/package.json +1 -1
@@ -1,27 +1,27 @@
1
- import { jsx as s, jsxs as b } from "react/jsx-runtime";
2
- import { useQuery as Z } from "@tanstack/react-query";
3
- import { ChevronRight as ee, AlertCircle as te } from "lucide-react";
4
- import { useState as S, useMemo as L } from "react";
5
- import { useNivaroClient as re, useItemEditAuth as le } from "../../context.js";
6
- import { post as R, patch as se } from "../../lib/commands.js";
7
- import { formatDateTime as H, cn as ne, formatDate as ae } from "../../lib/utils.js";
8
- import { TooltipProvider as oe, Tooltip as de, TooltipTrigger as ie, TooltipContent as ue } from "../ui/tooltip.js";
9
- function W(t) {
1
+ import { jsx as a, jsxs as m } from "react/jsx-runtime";
2
+ import { useQuery as ee } from "@tanstack/react-query";
3
+ import { ChevronRight as te, AlertCircle as re } from "lucide-react";
4
+ import { useState as T, useMemo as V } from "react";
5
+ import { useNivaroClient as le, useItemEditAuth as ae } from "../../context.js";
6
+ import { post as z, patch as ne } from "../../lib/commands.js";
7
+ import { formatDateTime as B, cn as K, formatDate as se } from "../../lib/utils.js";
8
+ import { TooltipProvider as oe, Tooltip as ie, TooltipTrigger as de, TooltipContent as ue } from "../ui/tooltip.js";
9
+ function L(t) {
10
10
  return t === !0 || t === 1 || t === "1" || t === "true";
11
11
  }
12
- function O(t, r) {
12
+ function D(t, r) {
13
13
  if (t == null || t === "") return "—";
14
14
  if (r === "currency" || r === "number") {
15
- const d = Number(t);
16
- return Number.isNaN(d) ? String(t) : r === "currency" ? new Intl.NumberFormat(void 0, { style: "currency", currency: "USD" }).format(d) : new Intl.NumberFormat().format(d);
15
+ const i = Number(t);
16
+ return Number.isNaN(i) ? String(t) : r === "currency" ? new Intl.NumberFormat(void 0, { style: "currency", currency: "USD" }).format(i) : new Intl.NumberFormat().format(i);
17
17
  }
18
18
  if (r === "date" || r === "datetime") {
19
- const d = new Date(t);
20
- return Number.isNaN(d.getTime()) ? String(t) : r === "date" ? ae(d) : H(d);
19
+ const i = new Date(t);
20
+ return Number.isNaN(i.getTime()) ? String(t) : r === "date" ? se(i) : B(i);
21
21
  }
22
22
  return String(t);
23
23
  }
24
- const G = {
24
+ const P = {
25
25
  green: "#16a34a",
26
26
  red: "#dc2626",
27
27
  amber: "#d97706",
@@ -37,12 +37,12 @@ function ce(t) {
37
37
  };
38
38
  }
39
39
  function E({ label: t, color: r }) {
40
- const d = r ? G[r] ?? null : null;
41
- return /* @__PURE__ */ s(
40
+ const i = r ? P[r] ?? null : null;
41
+ return /* @__PURE__ */ a(
42
42
  "span",
43
43
  {
44
44
  className: "inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11px] font-medium",
45
- style: ce(d),
45
+ style: ce(i),
46
46
  children: t
47
47
  }
48
48
  );
@@ -50,202 +50,198 @@ function E({ label: t, color: r }) {
50
50
  function me(t, r) {
51
51
  if (t == null || t === "")
52
52
  return r.empty_label ? { label: r.empty_label, color: r.empty_color ?? "blue" } : { label: "—", color: null };
53
- const d = r.options.find((p) => p.value === String(t));
54
- return d ? { label: d.label, color: d.color } : { label: String(t), color: null };
53
+ const i = r.options.find((f) => f.value === String(t));
54
+ return i ? { label: i.label, color: i.color } : { label: String(t), color: null };
55
55
  }
56
- function be(t, r) {
57
- const d = /* @__PURE__ */ new Map();
58
- for (const f of t.rows) {
59
- const o = String(f.group ?? ""), y = d.get(o);
60
- y ? y.push(f) : d.set(o, [f]);
56
+ function pe(t, r) {
57
+ const i = /* @__PURE__ */ new Map();
58
+ for (const x of t.rows) {
59
+ const s = String(x.group ?? ""), g = i.get(s);
60
+ g ? g.push(x) : i.set(s, [x]);
61
61
  }
62
- const p = Array.from(d.entries()).map(([f, o]) => {
63
- const x = new Set(o.map((T) => String(T.status ?? ""))).size > 1, C = x ? null : o[0].status;
64
- let g = null;
65
- return r && o.every((w) => r in w.values) && (g = o.reduce((w, $) => w + (Number($.values[r]) || 0), 0)), { key: f, rows: o, count: o.length, sum: g, uniformStatus: C, mixedStatus: x };
62
+ const f = Array.from(i.entries()).map(([x, s]) => {
63
+ const h = new Set(s.map((q) => String(q.status ?? ""))).size > 1, $ = h ? null : s[0].status;
64
+ let N = null;
65
+ return r && s.every((v) => r in v.values) && (N = s.reduce((v, A) => v + (Number(A.values[r]) || 0), 0)), { key: x, rows: s, count: s.length, sum: N, uniformStatus: $, mixedStatus: h };
66
66
  });
67
- return p.sort((f, o) => f.key.localeCompare(o.key, void 0, { numeric: !0 })), p;
67
+ return f.sort((x, s) => x.key.localeCompare(s.key, void 0, { numeric: !0 })), f;
68
68
  }
69
- function B(t, r, d) {
70
- let p = null;
71
- for (const f of t) {
72
- const o = f.values[r];
73
- if (o == null || o === "") continue;
74
- const y = typeof o == "number" ? o : Date.parse(String(o)), x = Number.isNaN(y) ? Number(o) : y;
75
- Number.isFinite(x) && (p == null || (d ? x > p : x < p)) && (p = x);
69
+ function W(t, r, i) {
70
+ let f = null;
71
+ for (const x of t) {
72
+ const s = x.values[r];
73
+ if (s == null || s === "") continue;
74
+ const g = typeof s == "number" ? s : Date.parse(String(s)), h = Number.isNaN(g) ? Number(s) : g;
75
+ Number.isFinite(h) && (f == null || (i ? h > f : h < f)) && (f = h);
76
76
  }
77
- return p;
77
+ return f;
78
78
  }
79
- function we({
79
+ function Ne({
80
80
  data: t,
81
81
  config: r,
82
- loading: d,
83
- error: p,
84
- onRefetch: f,
85
- hostRecordId: o,
86
- emptyLabel: y
82
+ loading: i,
83
+ error: f,
84
+ onRefetch: x,
85
+ hostRecordId: s,
86
+ emptyLabel: g
87
87
  }) {
88
- const x = re(), { userId: C } = le(), [g, T] = S(() => /* @__PURE__ */ new Set()), [w, $] = S(null), [M, K] = S({}), [A, D] = S(null), [F, P] = S(""), I = L(() => {
89
- const e = t ? be(t, r.aggregate_sum) : [], a = r.group_sort;
90
- if (!(a != null && a.field)) return e;
91
- const m = a.direction === "desc";
92
- return [...e].sort((k, i) => {
93
- const c = B(k.rows, a.field, m), h = B(i.rows, a.field, m);
94
- return c == null && h == null ? 0 : c == null ? 1 : h == null ? -1 : m ? h - c : c - h;
88
+ const h = le(), { userId: $ } = ae(), [N, q] = T(() => /* @__PURE__ */ new Set()), [v, A] = T(null), [G, H] = T({}), [b, _] = T(null), [F, M] = T(""), I = V(() => {
89
+ const e = t ? pe(t, r.aggregate_sum) : [], o = r.group_sort;
90
+ if (!(o != null && o.field)) return e;
91
+ const p = o.direction === "desc";
92
+ return [...e].sort((k, d) => {
93
+ const c = W(k.rows, o.field, p), y = W(d.rows, o.field, p);
94
+ return c == null && y == null ? 0 : c == null ? 1 : y == null ? -1 : p ? y - c : c - y;
95
95
  });
96
- }, [t, r.aggregate_sum, r.group_sort]), j = L(() => ((t == null ? void 0 : t.rows) ?? []).map((e) => String(e.id)), [t]), { data: v } = Z({
96
+ }, [t, r.aggregate_sum, r.group_sort]), j = V(() => ((t == null ? void 0 : t.rows) ?? []).map((e) => String(e.id)), [t]), { data: S } = ee({
97
97
  queryKey: ["review-list-enrich", r.enrich_endpoint ?? "", j.join(",")],
98
- queryFn: () => x.request(
99
- R(r.enrich_endpoint, { ids: j })
98
+ queryFn: () => h.request(
99
+ z(r.enrich_endpoint, { ids: j })
100
100
  ).then((e) => {
101
- var a;
102
- return ((a = e == null ? void 0 : e.data) == null ? void 0 : a.rows) ?? {};
101
+ var o;
102
+ return ((o = e == null ? void 0 : e.data) == null ? void 0 : o.rows) ?? {};
103
103
  }).catch(() => ({})),
104
104
  enabled: !!r.enrich_endpoint && j.length > 0,
105
105
  staleTime: 3e4
106
- }), q = (e) => v == null ? void 0 : v[String(e)], U = !!v && Object.values(v).some((e) => {
107
- var a;
108
- return (((a = e.chips) == null ? void 0 : a.length) ?? 0) > 0;
106
+ }), O = (e) => S == null ? void 0 : S[String(e)], R = !!S && Object.values(S).some((e) => {
107
+ var o;
108
+ return (((o = e.chips) == null ? void 0 : o.length) ?? 0) > 0;
109
109
  }), Q = I.length === 1;
110
- if (d)
111
- return /* @__PURE__ */ s("div", { className: "space-y-2", children: [0, 1].map((e) => /* @__PURE__ */ s(
110
+ if (i)
111
+ return /* @__PURE__ */ a("div", { className: "space-y-2", children: [0, 1].map((e) => /* @__PURE__ */ a(
112
112
  "div",
113
113
  {
114
114
  className: "animate-pulse h-12 rounded-md bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]"
115
115
  },
116
116
  e
117
117
  )) });
118
- if (p)
119
- return /* @__PURE__ */ s("p", { className: "text-[12px] text-red-500", children: p });
118
+ if (f)
119
+ return /* @__PURE__ */ a("p", { className: "text-[12px] text-red-500", children: f });
120
120
  if (!t || t.rows.length === 0)
121
- return /* @__PURE__ */ s("p", { className: "text-[12px] italic text-slate-400", children: y ? `No ${y.toLowerCase()} yet` : "Nothing here yet" });
121
+ return /* @__PURE__ */ a("p", { className: "text-[12px] italic text-slate-400", children: g ? `No ${g.toLowerCase()} yet` : "Nothing here yet" });
122
122
  const X = (e) => {
123
- T((a) => {
124
- const m = new Set(a);
125
- return m.has(e) ? m.delete(e) : m.add(e), m;
123
+ q((o) => {
124
+ const p = new Set(o);
125
+ return p.has(e) ? p.delete(e) : p.add(e), p;
126
126
  });
127
- }, J = (e, a) => {
128
- if (a.require_note) {
129
- P(""), D({ group: e, option: a });
130
- return;
131
- }
132
- V(e, a, null);
133
- }, V = async (e, a, m) => {
134
- $(e.key);
127
+ }, J = (e, o) => {
128
+ M(""), _({ group: e, option: o });
129
+ }, Y = async (e, o, p) => {
130
+ A(e.key);
135
131
  let k = null;
136
132
  if (r.status.action_endpoint)
137
133
  try {
138
- await x.request(
139
- R(r.status.action_endpoint, {
140
- ids: e.rows.map((i) => i.id),
141
- status: a.value,
134
+ await h.request(
135
+ z(r.status.action_endpoint, {
136
+ ids: e.rows.map((d) => d.id),
137
+ status: o.value,
142
138
  // The status each row showed: the endpoint may refuse (409) rows
143
139
  // someone changed since this list loaded instead of overwriting
144
140
  // them. The refetch below shows what they are now.
145
141
  expected: Object.fromEntries(
146
- e.rows.map((i) => [String(i.id), i.status == null ? null : String(i.status)])
142
+ e.rows.map((d) => [String(d.id), d.status == null ? null : String(d.status)])
147
143
  ),
148
- ...m ? { note: m } : {},
149
- ...o != null && o !== "" ? { workflow_id: Number(o) } : {}
144
+ ...p ? { note: p } : {},
145
+ ...s != null && s !== "" ? { workflow_id: Number(s) } : {}
150
146
  })
151
147
  );
152
- } catch (i) {
153
- const c = i == null ? void 0 : i.response;
148
+ } catch (d) {
149
+ const c = d == null ? void 0 : d.response;
154
150
  k = (c == null ? void 0 : c.error) ?? "Failed to update";
155
151
  }
156
152
  else {
157
- const i = r.status.stamp_date_field ? (/* @__PURE__ */ new Date()).toISOString() : void 0, h = (await Promise.all(
158
- e.rows.map(async (N) => {
159
- const l = { [r.status.field]: a.value };
160
- r.status.stamp_user_field && C && (l[r.status.stamp_user_field] = C), r.status.stamp_date_field && (l[r.status.stamp_date_field] = i), m && (l._change_reason = m);
153
+ const d = r.status.stamp_date_field ? (/* @__PURE__ */ new Date()).toISOString() : void 0, y = (await Promise.all(
154
+ e.rows.map(async (w) => {
155
+ const l = { [r.status.field]: o.value };
156
+ r.status.stamp_user_field && $ && (l[r.status.stamp_user_field] = $), r.status.stamp_date_field && (l[r.status.stamp_date_field] = d), p && (l._change_reason = p);
161
157
  try {
162
- return await x.request(se(`/items/${r.collection}/${N.id}`, l)), { ok: !0 };
158
+ return await h.request(ne(`/items/${r.collection}/${w.id}`, l)), { ok: !0 };
163
159
  } catch (u) {
164
160
  const n = u == null ? void 0 : u.response;
165
161
  return { ok: !1, error: (n == null ? void 0 : n.error) ?? "Failed to update" };
166
162
  }
167
163
  })
168
- )).filter((N) => !N.ok);
169
- h.length > 0 && (k = `${h.length} of ${e.rows.length} row(s) failed to update`);
164
+ )).filter((w) => !w.ok);
165
+ y.length > 0 && (k = `${y.length} of ${e.rows.length} row(s) failed to update`);
170
166
  }
171
- $(null), K((i) => {
172
- const c = { ...i };
167
+ A(null), H((d) => {
168
+ const c = { ...d };
173
169
  return k ? c[e.key] = k : delete c[e.key], c;
174
- }), f();
175
- }, z = t.columns.line_columns, Y = t.columns.group_meta;
176
- return /* @__PURE__ */ s(oe, { delayDuration: 200, children: /* @__PURE__ */ b("div", { className: "space-y-2", children: [
177
- t.truncated && /* @__PURE__ */ s("p", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Showing first 2000 rows — some rows may be missing." }),
170
+ }), x();
171
+ }, U = t.columns.line_columns, Z = t.columns.group_meta;
172
+ return /* @__PURE__ */ a(oe, { delayDuration: 200, children: /* @__PURE__ */ m("div", { className: "space-y-2", children: [
173
+ t.truncated && /* @__PURE__ */ a("p", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Showing first 2000 rows — some rows may be missing." }),
178
174
  I.map((e) => {
179
- const a = Q ? !g.has(e.key) : g.has(e.key), m = e.rows.every((l) => {
175
+ const o = Q ? !N.has(e.key) : N.has(e.key), p = e.rows.every((l) => {
180
176
  var u;
181
- return ((u = q(l.id)) == null ? void 0 : u.can_act) !== !1;
182
- }), k = e.mixedStatus ? { label: "Mixed", color: null } : me(e.uniformStatus, r.status), i = e.rows[0], c = i.stamp_user, h = i.stamp_date, N = e.rows.reduce((l, u) => {
177
+ return ((u = O(l.id)) == null ? void 0 : u.can_act) !== !1;
178
+ }), k = e.mixedStatus ? { label: "Mixed", color: null } : me(e.uniformStatus, r.status), d = e.rows[0], c = d.stamp_user, y = d.stamp_date, w = e.rows.reduce((l, u) => {
183
179
  var n;
184
- for (const _ of ((n = q(u.id)) == null ? void 0 : n.chips) ?? []) {
185
- if (_.tone === "danger") return "danger";
186
- _.tone === "warn" && l == null && (l = "warn");
180
+ for (const C of ((n = O(u.id)) == null ? void 0 : n.chips) ?? []) {
181
+ if (C.tone === "danger") return "danger";
182
+ C.tone === "warn" && l == null && (l = "warn");
187
183
  }
188
184
  return l;
189
185
  }, null);
190
- return /* @__PURE__ */ b(
186
+ return /* @__PURE__ */ m(
191
187
  "div",
192
188
  {
193
189
  "data-review-group": e.key,
194
- "data-review-tone": N ?? void 0,
195
- className: ne(
190
+ "data-review-tone": w ?? void 0,
191
+ className: K(
196
192
  "rounded-md border",
197
- N === "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" : N === "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"
193
+ w === "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" : w === "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"
198
194
  ),
199
195
  children: [
200
- /* @__PURE__ */ b("div", { className: "flex w-full flex-wrap items-center gap-2 px-3 py-2", children: [
201
- /* @__PURE__ */ b(
196
+ /* @__PURE__ */ m("div", { className: "flex w-full flex-wrap items-center gap-2 px-3 py-2", children: [
197
+ /* @__PURE__ */ m(
202
198
  "button",
203
199
  {
204
200
  type: "button",
205
201
  onClick: () => X(e.key),
206
202
  className: "flex min-w-0 flex-1 flex-wrap items-center gap-2 text-left",
207
203
  children: [
208
- /* @__PURE__ */ s(
209
- ee,
204
+ /* @__PURE__ */ a(
205
+ te,
210
206
  {
211
- className: `h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform ${a ? "rotate-90" : ""}`
207
+ className: `h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform ${o ? "rotate-90" : ""}`
212
208
  }
213
209
  ),
214
- /* @__PURE__ */ s("span", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: e.key || "—" }),
215
- /* @__PURE__ */ b("span", { className: "text-[11px] text-slate-400", children: [
210
+ /* @__PURE__ */ a("span", { className: "text-[12px] font-medium text-slate-700 dark:text-slate-200", children: e.key || "—" }),
211
+ /* @__PURE__ */ m("span", { className: "text-[11px] text-slate-400", children: [
216
212
  e.count,
217
213
  " row",
218
214
  e.count === 1 ? "" : "s",
219
- e.sum != null ? ` · ${O(e.sum, r.aggregate_sum_format ?? "number")}` : ""
215
+ e.sum != null ? ` · ${D(e.sum, r.aggregate_sum_format ?? "number")}` : ""
220
216
  ] }),
221
- Y.map((l) => {
222
- const u = i.values[l.field];
223
- return l.format === "flag" ? W(u) ? /* @__PURE__ */ s(E, { label: l.label, color: l.color ?? "amber" }, l.field) : null : u == null || u === "" ? null : /* @__PURE__ */ b(
217
+ Z.map((l) => {
218
+ const u = d.values[l.field];
219
+ return l.format === "flag" ? L(u) ? /* @__PURE__ */ a(E, { label: l.label, color: l.color ?? "amber" }, l.field) : null : u == null || u === "" ? null : /* @__PURE__ */ m(
224
220
  "span",
225
221
  {
226
222
  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",
227
223
  children: [
228
224
  l.label,
229
225
  ": ",
230
- O(u, l.format)
226
+ D(u, l.format)
231
227
  ]
232
228
  },
233
229
  l.field
234
230
  );
235
231
  }),
236
- /* @__PURE__ */ s(E, { label: k.label, color: k.color }),
237
- c && /* @__PURE__ */ b(de, { children: [
238
- /* @__PURE__ */ s(ie, { asChild: !0, children: /* @__PURE__ */ s("span", { className: "cursor-default text-[11px] text-slate-400 underline decoration-dotted", children: c.label }) }),
239
- /* @__PURE__ */ b(ue, { side: "top", className: "text-[12px]", children: [
240
- /* @__PURE__ */ s("p", { className: "font-medium", children: c.label }),
241
- h && /* @__PURE__ */ s("p", { className: "text-muted-foreground", children: H(h) })
232
+ /* @__PURE__ */ a(E, { label: k.label, color: k.color }),
233
+ c && /* @__PURE__ */ m(ie, { children: [
234
+ /* @__PURE__ */ a(de, { asChild: !0, children: /* @__PURE__ */ a("span", { className: "cursor-default text-[11px] text-slate-400 underline decoration-dotted", children: c.label }) }),
235
+ /* @__PURE__ */ m(ue, { side: "top", className: "text-[12px]", children: [
236
+ /* @__PURE__ */ a("p", { className: "font-medium", children: c.label }),
237
+ y && /* @__PURE__ */ a("p", { className: "text-muted-foreground", children: B(y) })
242
238
  ] })
243
239
  ] })
244
240
  ]
245
241
  }
246
242
  ),
247
- /* @__PURE__ */ b("span", { className: "flex flex-wrap items-center gap-1.5", children: [
248
- !m && /* @__PURE__ */ s(
243
+ /* @__PURE__ */ m("span", { className: "flex flex-wrap items-center gap-1.5", children: [
244
+ !p && /* @__PURE__ */ a(
249
245
  "span",
250
246
  {
251
247
  className: "text-[11px] text-slate-400",
@@ -253,13 +249,13 @@ function we({
253
249
  children: "View only"
254
250
  }
255
251
  ),
256
- m && r.status.options.map((l) => {
257
- const u = !e.mixedStatus && String(e.uniformStatus) === l.value, n = G[l.color] ?? G.slate, _ = w === e.key;
258
- return /* @__PURE__ */ s(
252
+ p && r.status.options.map((l) => {
253
+ const u = !e.mixedStatus && String(e.uniformStatus) === l.value, n = P[l.color] ?? P.slate, C = v === e.key;
254
+ return /* @__PURE__ */ a(
259
255
  "button",
260
256
  {
261
257
  type: "button",
262
- disabled: _ || u,
258
+ disabled: C || u,
263
259
  onClick: () => J(e, l),
264
260
  className: "rounded-md border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",
265
261
  style: {
@@ -267,38 +263,38 @@ function we({
267
263
  borderColor: `${n}55`,
268
264
  color: n
269
265
  },
270
- children: _ ? "…" : l.label
266
+ children: C ? "…" : l.label
271
267
  },
272
268
  l.value
273
269
  );
274
270
  })
275
271
  ] })
276
272
  ] }),
277
- M[e.key] && /* @__PURE__ */ b("p", { className: "flex items-center gap-1 px-3 pb-2 text-[11px] text-red-600", children: [
278
- /* @__PURE__ */ s(te, { className: "h-3 w-3 shrink-0" }),
279
- M[e.key]
273
+ G[e.key] && /* @__PURE__ */ m("p", { className: "flex items-center gap-1 px-3 pb-2 text-[11px] text-red-600", children: [
274
+ /* @__PURE__ */ a(re, { className: "h-3 w-3 shrink-0" }),
275
+ G[e.key]
280
276
  ] }),
281
- a && /* @__PURE__ */ s("div", { className: "overflow-x-auto border-t border-slate-100 dark:border-border/50", children: /* @__PURE__ */ b("table", { className: "w-full border-collapse text-[12px]", children: [
282
- /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ b("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: [
283
- z.map((l) => /* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: l.label }, l.field)),
284
- U && /* @__PURE__ */ s("th", { className: "px-2.5 py-1.5 font-medium", children: "Match" })
277
+ o && /* @__PURE__ */ a("div", { className: "overflow-x-auto border-t border-slate-100 dark:border-border/50", children: /* @__PURE__ */ m("table", { className: "w-full border-collapse text-[12px]", children: [
278
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ m("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: [
279
+ U.map((l) => /* @__PURE__ */ a("th", { className: "px-2.5 py-1.5 font-medium", children: l.label }, l.field)),
280
+ R && /* @__PURE__ */ a("th", { className: "px-2.5 py-1.5 font-medium", children: "Match" })
285
281
  ] }) }),
286
- /* @__PURE__ */ s("tbody", { children: e.rows.map((l) => {
282
+ /* @__PURE__ */ a("tbody", { children: e.rows.map((l) => {
287
283
  var u;
288
- return /* @__PURE__ */ b(
284
+ return /* @__PURE__ */ m(
289
285
  "tr",
290
286
  {
291
287
  className: "border-b border-slate-100 last:border-b-0 dark:border-border/50",
292
288
  children: [
293
- z.map((n) => /* @__PURE__ */ s(
289
+ U.map((n) => /* @__PURE__ */ a(
294
290
  "td",
295
291
  {
296
292
  className: "px-2.5 py-1.5 text-slate-600 dark:text-slate-300",
297
- children: n.format === "flag" ? W(l.values[n.field]) ? /* @__PURE__ */ s(E, { label: n.label, color: n.color ?? "amber" }) : "—" : O(l.values[n.field], n.format)
293
+ children: n.format === "flag" ? L(l.values[n.field]) ? /* @__PURE__ */ a(E, { label: n.label, color: n.color ?? "amber" }) : "—" : D(l.values[n.field], n.format)
298
294
  },
299
295
  n.field
300
296
  )),
301
- U && /* @__PURE__ */ s("td", { className: "px-2.5 py-1.5", children: /* @__PURE__ */ s("span", { className: "flex flex-wrap gap-1", children: (((u = q(l.id)) == null ? void 0 : u.chips) ?? []).map((n) => /* @__PURE__ */ s(
297
+ R && /* @__PURE__ */ a("td", { className: "px-2.5 py-1.5", children: /* @__PURE__ */ a("span", { className: "flex flex-wrap gap-1", children: (((u = O(l.id)) == null ? void 0 : u.chips) ?? []).map((n) => /* @__PURE__ */ a(
302
298
  "span",
303
299
  {
304
300
  title: n.title,
@@ -318,54 +314,83 @@ function we({
318
314
  e.key
319
315
  );
320
316
  }),
321
- A && /* @__PURE__ */ s(
317
+ b && /* @__PURE__ */ a(
322
318
  "div",
323
319
  {
324
320
  className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4",
325
- onClick: () => D(null),
326
- children: /* @__PURE__ */ b(
321
+ onClick: () => _(null),
322
+ onKeyDown: (e) => {
323
+ e.key === "Escape" && (e.stopPropagation(), _(null));
324
+ },
325
+ children: /* @__PURE__ */ m(
327
326
  "div",
328
327
  {
328
+ role: "dialog",
329
+ "aria-modal": "true",
330
+ "aria-labelledby": "review-confirm-title",
331
+ "data-review-confirm": b.option.value,
329
332
  className: "w-full max-w-md rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-card",
330
333
  onClick: (e) => e.stopPropagation(),
331
334
  children: [
332
- /* @__PURE__ */ b("p", { className: "text-[13px] font-medium text-slate-700 dark:text-slate-200", children: [
333
- A.option.label,
334
- " — add a note"
335
+ /* @__PURE__ */ m(
336
+ "p",
337
+ {
338
+ id: "review-confirm-title",
339
+ className: "text-[13px] font-medium text-slate-700 dark:text-slate-200",
340
+ children: [
341
+ b.option.label,
342
+ " ",
343
+ b.group.key || "these rows",
344
+ "?"
345
+ ]
346
+ }
347
+ ),
348
+ /* @__PURE__ */ m("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: [
349
+ b.group.count,
350
+ " row",
351
+ b.group.count === 1 ? "" : "s",
352
+ b.group.sum != null ? ` · ${D(b.group.sum, r.aggregate_sum_format ?? "number")}` : ""
335
353
  ] }),
336
- /* @__PURE__ */ s("p", { className: "mt-0.5 text-[11px] text-slate-500", children: "A reason is required for this decision. It is recorded with the record." }),
337
- /* @__PURE__ */ s(
354
+ /* @__PURE__ */ a("p", { className: "mt-1.5 text-[11px] text-slate-500 dark:text-slate-400", children: b.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." }),
355
+ /* @__PURE__ */ a(
338
356
  "textarea",
339
357
  {
340
358
  value: F,
341
- onChange: (e) => P(e.target.value),
359
+ onChange: (e) => M(e.target.value),
342
360
  rows: 3,
343
361
  autoFocus: !0,
362
+ "aria-label": b.option.require_note ? "Reason" : "Note (optional)",
363
+ "data-review-confirm-note": !0,
344
364
  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",
345
- placeholder: "Why is this being rejected?"
365
+ placeholder: b.option.require_note ? "Why is this being rejected?" : "Note (optional)"
346
366
  }
347
367
  ),
348
- /* @__PURE__ */ b("div", { className: "mt-3 flex items-center justify-end gap-1.5", children: [
349
- /* @__PURE__ */ s(
368
+ /* @__PURE__ */ m("div", { className: "mt-3 flex items-center justify-end gap-1.5", children: [
369
+ /* @__PURE__ */ a(
350
370
  "button",
351
371
  {
352
372
  type: "button",
353
- onClick: () => D(null),
373
+ "data-review-confirm-cancel": !0,
374
+ onClick: () => _(null),
354
375
  className: "rounded px-2.5 py-1 text-[11px] text-slate-500 hover:bg-slate-100 dark:hover:bg-muted",
355
376
  children: "Cancel"
356
377
  }
357
378
  ),
358
- /* @__PURE__ */ s(
379
+ /* @__PURE__ */ a(
359
380
  "button",
360
381
  {
361
382
  type: "button",
362
- disabled: !F.trim(),
383
+ "data-review-confirm-submit": !0,
384
+ disabled: !!b.option.require_note && !F.trim(),
363
385
  onClick: () => {
364
- const e = A;
365
- D(null), V(e.group, e.option, F.trim());
386
+ const e = b;
387
+ _(null), Y(e.group, e.option, F.trim() || null);
366
388
  },
367
- className: "rounded bg-red-600 px-3 py-1 text-[11px] font-medium text-white hover:brightness-110 disabled:opacity-50",
368
- children: A.option.label
389
+ className: K(
390
+ "rounded px-3 py-1 text-[11px] font-medium hover:brightness-110 disabled:opacity-50",
391
+ b.option.require_note ? "bg-red-600 text-white" : "bg-nvr-cyan text-white"
392
+ ),
393
+ children: b.option.label
369
394
  }
370
395
  )
371
396
  ] })
@@ -377,7 +402,7 @@ function we({
377
402
  ] }) });
378
403
  }
379
404
  export {
380
- we as ReviewListWidget,
381
- G as STATUS_COLOR_HEX,
382
- O as formatValue
405
+ Ne as ReviewListWidget,
406
+ P as STATUS_COLOR_HEX,
407
+ D as formatValue
383
408
  };
@@ -45,6 +45,7 @@ const h = {
45
45
  VALUE_OUT_OF_RANGE: "Use a smaller number, then save again.",
46
46
  DELETE_GUARDED: "This record is protected from deletion. Sort out what the message names first.",
47
47
  TRANSITION_DUPLICATE: "This move was already made. Reload the record to see where it is now.",
48
+ PRIORITY_REQUIRED: "Flag the workflow as Priority, then approve.",
48
49
  NESTED_ROW_REFUSED: "Fix the line the message names, then save again.",
49
50
  NESTED_ROW_NOT_OWNED: "That line belongs to another record. Reload, then try again.",
50
51
  NESTED_ROWS_LIMIT: "Save fewer lines at once, then add the rest in another save.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.49",
3
+ "version": "0.3.50",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",