@nivaro/react 0.3.10 → 0.3.11

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 (43) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useNivaroForm.js +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +34 -3
  5. package/dist/shared/components/CollectionBrowserView.js +1546 -1477
  6. package/dist/shared/components/ItemEditForm.js +4332 -4195
  7. package/dist/shared/components/PageRenderer.js +512 -465
  8. package/dist/shared/components/QueryStatStrip.js +74 -70
  9. package/dist/shared/components/ReportView.js +818 -827
  10. package/dist/shared/components/SheetHeaderBody.js +16 -14
  11. package/dist/shared/components/item-edit/CatalogPickerField.js +1029 -933
  12. package/dist/shared/components/item-edit/FieldRenderer.js +161 -156
  13. package/dist/shared/components/item-edit/FieldRow.js +20 -19
  14. package/dist/shared/components/item-edit/FilePickerField.js +52 -40
  15. package/dist/shared/components/item-edit/GroupSection.js +221 -221
  16. package/dist/shared/components/item-edit/InlineGridField.js +41 -41
  17. package/dist/shared/components/item-edit/InlineTableField.js +2249 -2238
  18. package/dist/shared/components/item-edit/M2MCombobox.js +46 -44
  19. package/dist/shared/components/item-edit/NestedRelationEditor.js +11 -11
  20. package/dist/shared/components/item-edit/QuickPicker.js +263 -216
  21. package/dist/shared/components/item-edit/RelationCombobox.js +285 -245
  22. package/dist/shared/components/item-edit/RichTextEditorImpl.js +42 -32
  23. package/dist/shared/components/item-edit/RowHistorySheet.js +130 -134
  24. package/dist/shared/components/item-edit/SummaryPanel.js +305 -279
  25. package/dist/shared/components/item-edit/helpers.js +133 -134
  26. package/dist/shared/components/item-edit/line-qty.js +57 -0
  27. package/dist/shared/components/item-edit/option-disambiguate.js +53 -0
  28. package/dist/shared/components/panels/AddendumLinesDiff.js +87 -90
  29. package/dist/shared/components/panels/CommentPanel.js +350 -315
  30. package/dist/shared/components/panels/ItemLockBanner.js +297 -230
  31. package/dist/shared/components/panels/PipelinePanel.js +719 -701
  32. package/dist/shared/components/queue/QueueQuickFilters.js +43 -41
  33. package/dist/shared/components/queue/QueueWorklist.js +1005 -935
  34. package/dist/shared/components/widgets/ReviewListWidget.js +99 -93
  35. package/dist/shared/lib/obligation-banner.js +14 -13
  36. package/dist/shared/lib/obligation-reason-text.js +13 -0
  37. package/dist/shared/lib/query-filter-seed.js +34 -11
  38. package/dist/shared/lib/sanitize-html.js +24 -15
  39. package/dist/shared/lib/sheet-def.js +38 -22
  40. package/dist/shared/lib/unique-options.js +10 -0
  41. package/dist/shared/lib/utils.js +57 -43
  42. package/dist/shared/lib/validation-rules.js +58 -34
  43. package/package.json +1 -1
@@ -1,49 +1,53 @@
1
1
  import { jsx as l, jsxs as y } from "react/jsx-runtime";
2
- import { useQuery as W } from "@tanstack/react-query";
3
- import { useRef as q, useState as R, useLayoutEffect as I, useId as K } from "react";
4
- import { useNivaroClient as Q } from "../context.js";
5
- import { post as G } from "../lib/commands.js";
6
- import { matchRows as J, statCoverage as V, statValue as H, sumField as X, fmtStat as T, compactStat as Y } from "../lib/query-stats.js";
7
- import { colorPair as z } from "./QueryTable.js";
8
- const Z = /* @__PURE__ */ new Set(["ink", "muted"]), ee = 150, F = 8;
9
- function te(e, d) {
10
- const f = q(null), b = q(null);
11
- return I(() => {
12
- const u = f.current, o = b.current;
13
- if (!u || !o) {
14
- d(!0);
2
+ import { useQuery as Q } from "@tanstack/react-query";
3
+ import { useRef as S, useState as C, useLayoutEffect as A, useId as G } from "react";
4
+ import { useNivaroClient as J } from "../context.js";
5
+ import { post as V } from "../lib/commands.js";
6
+ import { matchRows as H, statCoverage as X, statValue as Y, sumField as Z, fmtStat as z, compactStat as ee } from "../lib/query-stats.js";
7
+ import { colorPair as I } from "./QueryTable.js";
8
+ const te = /* @__PURE__ */ new Set(["ink", "muted"]), re = 150, P = 8;
9
+ function ne(e, c) {
10
+ const b = S(null), f = S(null);
11
+ return A(() => {
12
+ const d = b.current, o = f.current;
13
+ if (!d || !o) {
14
+ c(!0);
15
15
  return;
16
16
  }
17
- const x = () => d(o.offsetWidth <= u.clientWidth);
17
+ const x = () => c(o.offsetWidth <= d.clientWidth);
18
18
  if (x(), typeof ResizeObserver > "u") return;
19
19
  const m = new ResizeObserver(x);
20
- return m.observe(u), () => m.disconnect();
21
- }, [e]), { box: f, probe: b };
20
+ return m.observe(d), () => m.disconnect();
21
+ }, [e]), { box: b, probe: f };
22
22
  }
23
- function re({
23
+ function ae({
24
24
  stat: e,
25
- rows: d,
26
- effectiveParams: f,
27
- loading: b,
28
- compact: u,
25
+ rows: c,
26
+ effectiveParams: b,
27
+ loading: f,
28
+ compact: d,
29
29
  onFit: o
30
30
  }) {
31
- const x = Q(), [m, p] = R(!1), k = K(), t = e.query, g = t ? {
32
- ...t.params ?? {},
31
+ const x = J(), [m, p] = C(!1), k = G(), r = e.query, g = r ? {
32
+ ...r.params ?? {},
33
33
  ...Object.fromEntries(
34
- Object.entries(t.param_from ?? {}).map(([r, U]) => [r, f[U]])
34
+ Object.entries(r.param_from ?? {}).map(([t, K]) => [t, b[K]])
35
35
  )
36
- } : null, { data: N, isLoading: n } = W({
37
- queryKey: ["query-stat", t == null ? void 0 : t.slug, JSON.stringify(g)],
36
+ } : null, { data: N, isLoading: n } = Q({
37
+ queryKey: ["query-stat", r == null ? void 0 : r.slug, JSON.stringify(g)],
38
38
  queryFn: () => x.request(
39
- G(`/custom-queries/${t.slug}/execute`, { params: g })
40
- ).then((r) => r.data ?? []),
41
- enabled: !!t,
39
+ V(`/custom-queries/${r.slug}/execute`, { params: g })
40
+ ).then((t) => t.data ?? []),
41
+ enabled: !!r,
42
42
  staleTime: 6e4
43
- }), c = J(d, e.row_match), s = t ? n : b, a = e.coverage && !s ? V(e, d) : null, _ = !!a && a.reporting === 0, i = s || _ ? null : H(e, d, N ?? null), C = !s && (i == null || i === ""), L = e.format === "date" || e.format === "text", O = t ? t.label_field ? (N ?? []).map((r) => ({
44
- label: String(r[t.label_field] ?? "—"),
45
- value: Number(r[t.value_field]) || 0
46
- })) : [] : (e.details ?? []).map((r) => ({ label: r.label, value: X(c, r.field) })), M = typeof i == "number" && i < 0 && (e.field_subtract || e.accent_negative), w = M ? e.accent_negative ?? "negative" : e.accent, v = L || C || !w ? null : M ? z(w) : z(w, e.accent_dark), P = v && !Z.has(String(w).trim().toLowerCase()), E = typeof i == "number" && e.field_subtract && i > 0 ? "+" : "", h = `${E}${T(i, e.format, e.empty_label)}`, $ = typeof i == "number" && (e.format === void 0 || e.format === "currency" || e.format === "number"), { box: A, probe: B } = te($ ? h : "", o), j = u && $ ? `${E}${Y(i, e.format)}` : h, D = a && a.reporting > 0 && a.reporting < a.total, S = O.length > 0;
43
+ }), u = H(c, e.row_match), s = r ? n : f, a = e.coverage && !s ? X(e, c) : null, _ = !!a && a.reporting === 0, R = e.requires_field, L = !!R && !f && !c.some((t) => t[R] != null && t[R] !== ""), i = s || _ || L ? null : Y(e, c, N ?? null), O = !s && (i == null || i === ""), M = e.format === "date" || e.format === "text", E = r ? r.label_field ? (N ?? []).map((t) => ({
44
+ label: String(t[r.label_field] ?? "—"),
45
+ value: Number(t[r.value_field]) || 0
46
+ })) : [] : (e.details ?? []).map((t) => ({ label: t.label, value: Z(u, t.field) })), $ = typeof i == "number" && i < 0 && (e.field_subtract || e.accent_negative), w = $ ? e.accent_negative ?? "negative" : e.accent, v = M || O || !w ? null : $ ? I(w) : I(w, e.accent_dark), B = v && !te.has(String(w).trim().toLowerCase()), j = typeof i == "number" && e.field_subtract && i > 0 ? "+" : "", h = `${j}${z(
47
+ i,
48
+ e.format,
49
+ L ? e.requires_label ?? e.empty_label : e.empty_label
50
+ )}`, F = typeof i == "number" && (e.format === void 0 || e.format === "currency" || e.format === "number"), { box: D, probe: U } = ne(F ? h : "", o), T = d && F ? `${j}${ee(i, e.format)}` : h, W = a && a.reporting > 0 && a.reporting < a.total, q = E.length > 0;
47
51
  return (
48
52
  // Hover is a mouse convenience; the label button below is the keyboard path.
49
53
  // biome-ignore lint/a11y/noStaticElementInteractions: see above
@@ -52,11 +56,11 @@ function re({
52
56
  {
53
57
  className: "relative min-w-0 rounded-lg border border-slate-200 bg-white px-3 py-2 dark:border-border dark:bg-card",
54
58
  style: v ? { "--qsa": v[0], "--qsad": v[1] } : void 0,
55
- onMouseEnter: S ? () => p(!0) : void 0,
56
- onMouseLeave: S ? () => p(!1) : void 0,
59
+ onMouseEnter: q ? () => p(!0) : void 0,
60
+ onMouseLeave: q ? () => p(!1) : void 0,
57
61
  "data-stat-tile": e.label,
58
62
  children: [
59
- P && /* @__PURE__ */ l(
63
+ B && /* @__PURE__ */ l(
60
64
  "span",
61
65
  {
62
66
  "aria-hidden": "true",
@@ -72,7 +76,7 @@ function re({
72
76
  style: { backgroundColor: e.bg, filter: "saturate(2.2)" }
73
77
  }
74
78
  ),
75
- S ? (
79
+ q ? (
76
80
  // The breakdown is a disclosure: a real button so keyboard users reach it.
77
81
  /* @__PURE__ */ l(
78
82
  "button",
@@ -84,8 +88,8 @@ function re({
84
88
  onFocus: () => p(!0),
85
89
  onBlur: () => p(!1),
86
90
  onClick: () => p(!0),
87
- onKeyDown: (r) => {
88
- r.key === "Escape" && p(!1);
91
+ onKeyDown: (t) => {
92
+ t.key === "Escape" && p(!1);
89
93
  },
90
94
  title: e.label,
91
95
  children: e.label
@@ -96,16 +100,16 @@ function re({
96
100
  s ? /* @__PURE__ */ l("div", { className: "mt-1 h-5 w-24 animate-pulse rounded bg-slate-200/60 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ y(
97
101
  "p",
98
102
  {
99
- ref: A,
100
- className: `relative mt-0.5 truncate leading-[22px] tabular-nums ${C ? "text-[13px] font-normal text-slate-500 dark:text-slate-400" : L ? "text-[13px] font-medium text-slate-600 dark:text-slate-300" : v ? "text-[15px] font-semibold text-[color:var(--qsa)] dark:text-[color:var(--qsad)]" : "text-[15px] font-semibold text-slate-800 dark:text-slate-100"}`,
101
- title: j !== h ? h : void 0,
103
+ ref: D,
104
+ className: `relative mt-0.5 truncate leading-[22px] tabular-nums ${O ? "text-[13px] font-normal text-slate-500 dark:text-slate-400" : M ? "text-[13px] font-medium text-slate-600 dark:text-slate-300" : v ? "text-[15px] font-semibold text-[color:var(--qsa)] dark:text-[color:var(--qsad)]" : "text-[15px] font-semibold text-slate-800 dark:text-slate-100"}`,
105
+ title: T !== h ? h : void 0,
102
106
  "data-stat-value": !0,
103
107
  children: [
104
- j,
108
+ T,
105
109
  /* @__PURE__ */ l(
106
110
  "span",
107
111
  {
108
- ref: B,
112
+ ref: U,
109
113
  "aria-hidden": "true",
110
114
  className: "pointer-events-none invisible absolute left-0 top-0 whitespace-nowrap",
111
115
  children: h
@@ -114,7 +118,7 @@ function re({
114
118
  ]
115
119
  }
116
120
  ),
117
- D && /* @__PURE__ */ y(
121
+ W && /* @__PURE__ */ y(
118
122
  "p",
119
123
  {
120
124
  className: "truncate text-[11px] tabular-nums text-slate-500 dark:text-slate-400",
@@ -128,15 +132,15 @@ function re({
128
132
  ]
129
133
  }
130
134
  ),
131
- m && S && /* @__PURE__ */ l(
135
+ m && q && /* @__PURE__ */ l(
132
136
  "div",
133
137
  {
134
138
  id: k,
135
139
  className: "absolute left-0 top-full z-40 mt-1 min-w-[220px] rounded-md border border-slate-200 bg-white p-2 shadow-lg dark:border-border dark:bg-popover",
136
- children: O.map((r) => /* @__PURE__ */ y("div", { className: "flex justify-between gap-4 py-0.5 text-[12px]", children: [
137
- /* @__PURE__ */ l("span", { className: "text-slate-500 dark:text-slate-400", children: r.label }),
138
- /* @__PURE__ */ l("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: T(r.value, e.format) })
139
- ] }, r.label))
140
+ children: E.map((t) => /* @__PURE__ */ y("div", { className: "flex justify-between gap-4 py-0.5 text-[12px]", children: [
141
+ /* @__PURE__ */ l("span", { className: "text-slate-500 dark:text-slate-400", children: t.label }),
142
+ /* @__PURE__ */ l("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: z(t.value, e.format) })
143
+ ] }, t.label))
140
144
  }
141
145
  )
142
146
  ]
@@ -144,40 +148,40 @@ function re({
144
148
  )
145
149
  );
146
150
  }
147
- function de({
151
+ function me({
148
152
  stats: e,
149
- rows: d,
150
- effectiveParams: f,
151
- loading: b
153
+ rows: c,
154
+ effectiveParams: b,
155
+ loading: f
152
156
  }) {
153
- const u = q(null), o = e.length, [x, m] = R(o), [p, k] = R({}), t = Object.values(p).some(Boolean), g = q(/* @__PURE__ */ new Map()), N = (n) => {
154
- let c = g.current.get(n);
155
- return c || (c = (s) => k((a) => a[n] === !s ? a : { ...a, [n]: !s }), g.current.set(n, c)), c;
157
+ const d = S(null), o = e.length, [x, m] = C(o), [p, k] = C({}), r = Object.values(p).some(Boolean), g = S(/* @__PURE__ */ new Map()), N = (n) => {
158
+ let u = g.current.get(n);
159
+ return u || (u = (s) => k((a) => a[n] === !s ? a : { ...a, [n]: !s }), g.current.set(n, u)), u;
156
160
  };
157
- return I(() => {
158
- const n = u.current;
161
+ return A(() => {
162
+ const n = d.current;
159
163
  if (!n || !o) return;
160
- const c = () => {
161
- const a = Math.max(1, Math.floor((n.clientWidth + F) / (ee + F))), _ = Math.ceil(o / a);
164
+ const u = () => {
165
+ const a = Math.max(1, Math.floor((n.clientWidth + P) / (re + P))), _ = Math.ceil(o / a);
162
166
  m(Math.ceil(o / _));
163
167
  };
164
- if (c(), typeof ResizeObserver > "u") return;
165
- const s = new ResizeObserver(c);
168
+ if (u(), typeof ResizeObserver > "u") return;
169
+ const s = new ResizeObserver(u);
166
170
  return s.observe(n), () => s.disconnect();
167
171
  }, [o]), o ? /* @__PURE__ */ l(
168
172
  "div",
169
173
  {
170
- ref: u,
174
+ ref: d,
171
175
  className: "grid gap-2 pb-3",
172
176
  style: { gridTemplateColumns: `repeat(${x}, minmax(0, 1fr))` },
173
177
  children: e.map((n) => /* @__PURE__ */ l(
174
- re,
178
+ ae,
175
179
  {
176
180
  stat: n,
177
- rows: d,
178
- effectiveParams: f,
179
- loading: b,
180
- compact: t,
181
+ rows: c,
182
+ effectiveParams: b,
183
+ loading: f,
184
+ compact: r,
181
185
  onFit: N(n.label)
182
186
  },
183
187
  n.label
@@ -186,5 +190,5 @@ function de({
186
190
  ) : null;
187
191
  }
188
192
  export {
189
- de as QueryStatStrip
193
+ me as QueryStatStrip
190
194
  };