@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
@@ -4,10 +4,10 @@ import { Loader2 as ie, X as W, ChevronRight as le } from "lucide-react";
4
4
  import { useState as k, useMemo as Z } from "react";
5
5
  import { useNivaroClient as de } from "../../context.js";
6
6
  import { get as V, patch as oe, del as ce, post as pe } from "../../lib/commands.js";
7
- import { titleCase as G, cn as ue } from "../../lib/utils.js";
8
- import { useAddendumO2M as me, useAddendumView as xe } from "./AddendumFieldContext.js";
9
- import { useO2MStaging as he } from "./O2MStagingContext.js";
10
- const be = /* @__PURE__ */ new Set([
7
+ import { titleCase as G, cn as ue, toLocalDateString as me } from "../../lib/utils.js";
8
+ import { useAddendumO2M as xe, useAddendumView as he } from "./AddendumFieldContext.js";
9
+ import { useO2MStaging as be } from "./O2MStagingContext.js";
10
+ const fe = /* @__PURE__ */ new Set([
11
11
  "alias",
12
12
  "o2m",
13
13
  "m2m",
@@ -16,7 +16,7 @@ const be = /* @__PURE__ */ new Set([
16
16
  "group",
17
17
  "divider"
18
18
  ]);
19
- function Ce({
19
+ function Ee({
20
20
  relatedCollection: l,
21
21
  manyField: c,
22
22
  parentId: m,
@@ -25,7 +25,7 @@ function Ce({
25
25
  emptyLabel: S
26
26
  }) {
27
27
  var L;
28
- const f = de(), Q = ae(), x = he(), d = m === "new", B = me()[F ?? ""] ?? [], [q, C] = k(null), [_, I] = k({}), [E, w] = k(!1), [R, g] = k({}), [y, $] = k(!1), N = xe(), { data: u } = Y({
28
+ const f = de(), _ = ae(), x = be(), d = m === "new", B = xe()[F ?? ""] ?? [], [q, C] = k(null), [D, I] = k({}), [E, v] = k(!1), [R, y] = k({}), [g, $] = k(!1), N = he(), { data: u } = Y({
29
29
  queryKey: ["active-layout", l, b ?? null],
30
30
  queryFn: () => f.request(
31
31
  V("/collection-layouts/active", {
@@ -45,7 +45,7 @@ function Ce({
45
45
  ).then((e) => e.data ?? []),
46
46
  staleTime: 6e4,
47
47
  enabled: !b || u !== void 0
48
- }), { data: v = [], isLoading: te } = Y({
48
+ }), { data: w = [], isLoading: te } = Y({
49
49
  queryKey: ["o2m-rows", l, c, m],
50
50
  queryFn: () => f.request(
51
51
  V(`/items/${l}`, {
@@ -56,7 +56,7 @@ function Ce({
56
56
  enabled: !d,
57
57
  staleTime: 3e4
58
58
  }), J = d && x ? x.getPendingRows(l, c) : [], o = ee.filter(
59
- (e) => !e.hidden && !be.has(e.type) && e.field !== c && e.field !== "id"
59
+ (e) => !e.hidden && !fe.has(e.type) && e.field !== c && e.field !== "id"
60
60
  ), A = Z(
61
61
  () => ((u == null ? void 0 : u.groups) ?? []).filter((e) => e.type === "section").sort((e, r) => e.sort - r.sort),
62
62
  [u]
@@ -72,7 +72,7 @@ function Ce({
72
72
  async function X(e) {
73
73
  $(!0);
74
74
  try {
75
- await f.request(oe(`/items/${l}/${e}`, _)), Q.invalidateQueries({ queryKey: ["o2m-rows", l, c, m] }), C(null);
75
+ await f.request(oe(`/items/${l}/${e}`, D)), _.invalidateQueries({ queryKey: ["o2m-rows", l, c, m] }), C(null);
76
76
  } catch {
77
77
  } finally {
78
78
  $(!1);
@@ -80,14 +80,14 @@ function Ce({
80
80
  }
81
81
  async function z() {
82
82
  if (d && x) {
83
- x.queueRow(l, c, { ...R }), w(!1), g({});
83
+ x.queueRow(l, c, { ...R }), v(!1), y({});
84
84
  return;
85
85
  }
86
86
  $(!0);
87
87
  try {
88
88
  await f.request(
89
89
  pe(`/items/${l}`, { ...R, [c]: m })
90
- ), Q.invalidateQueries({ queryKey: ["o2m-rows", l, c, m] }), w(!1), g({});
90
+ ), _.invalidateQueries({ queryKey: ["o2m-rows", l, c, m] }), v(!1), y({});
91
91
  } catch {
92
92
  } finally {
93
93
  $(!1);
@@ -95,7 +95,7 @@ function Ce({
95
95
  }
96
96
  async function re(e) {
97
97
  try {
98
- await f.request(ce(`/items/${l}/${e}`)), Q.invalidateQueries({ queryKey: ["o2m-rows", l, c, m] });
98
+ await f.request(ce(`/items/${l}/${e}`)), _.invalidateQueries({ queryKey: ["o2m-rows", l, c, m] });
99
99
  } catch {
100
100
  }
101
101
  }
@@ -105,7 +105,7 @@ function Ce({
105
105
  return /* @__PURE__ */ t("span", { className: r ? "text-emerald-600" : "text-slate-400", children: r ? "Yes" : "No" });
106
106
  if (e.type === "datetime" || e.type === "date")
107
107
  try {
108
- return /* @__PURE__ */ t("span", { children: new Date(String(r)).toLocaleDateString() });
108
+ return /* @__PURE__ */ t("span", { children: me(r) });
109
109
  } catch {
110
110
  }
111
111
  return /* @__PURE__ */ t("span", { className: "truncate", children: String(r) });
@@ -155,7 +155,7 @@ function Ce({
155
155
  );
156
156
  }
157
157
  function H(e, r, n, s, i) {
158
- const D = (h == null ? void 0 : h.get(null)) ?? [];
158
+ const M = (h == null ? void 0 : h.get(null)) ?? [];
159
159
  return /* @__PURE__ */ a("div", { className: "border border-slate-200 rounded-lg bg-white overflow-hidden", children: [
160
160
  /* @__PURE__ */ a("div", { className: "flex items-center justify-between border-b border-slate-100 px-3 py-2 bg-slate-50", children: [
161
161
  /* @__PURE__ */ t("span", { className: "text-[11px] font-semibold text-slate-600 uppercase tracking-wide", children: i }),
@@ -173,27 +173,27 @@ function Ce({
173
173
  "button",
174
174
  {
175
175
  type: "button",
176
- disabled: y,
176
+ disabled: g,
177
177
  onClick: n,
178
178
  className: "text-[11px] font-medium bg-nvr-cyan text-white px-2.5 py-0.5 rounded hover:brightness-110 disabled:opacity-50",
179
- children: y ? "…" : "Save"
179
+ children: g ? "…" : "Save"
180
180
  }
181
181
  )
182
182
  ] })
183
183
  ] }),
184
184
  /* @__PURE__ */ a("div", { className: "p-3 space-y-4", children: [
185
- D.length > 0 && /* @__PURE__ */ t("div", { className: "grid grid-cols-2 gap-x-4 gap-y-2", children: D.map((p) => /* @__PURE__ */ a("div", { children: [
185
+ M.length > 0 && /* @__PURE__ */ t("div", { className: "grid grid-cols-2 gap-x-4 gap-y-2", children: M.map((p) => /* @__PURE__ */ a("div", { children: [
186
186
  /* @__PURE__ */ t("label", { className: "block text-[11px] font-medium text-slate-500 mb-1", children: p.label ?? G(p.field) }),
187
187
  O(p, e, r)
188
188
  ] }, p.field)) }),
189
189
  A.map((p) => {
190
- const M = (h == null ? void 0 : h.get(p.key)) ?? [];
191
- return M.length ? /* @__PURE__ */ a("div", { children: [
190
+ const P = (h == null ? void 0 : h.get(p.key)) ?? [];
191
+ return P.length ? /* @__PURE__ */ a("div", { children: [
192
192
  /* @__PURE__ */ t("div", { className: "text-[10px] font-semibold uppercase tracking-wider text-slate-400 mb-2 pb-1 border-b border-slate-100", children: p.label }),
193
- /* @__PURE__ */ t("div", { className: "grid grid-cols-2 gap-x-4 gap-y-2", children: M.map((P) => /* @__PURE__ */ a("div", { children: [
194
- /* @__PURE__ */ t("label", { className: "block text-[11px] font-medium text-slate-500 mb-1", children: P.label ?? G(P.field) }),
195
- O(P, e, r)
196
- ] }, P.field)) })
193
+ /* @__PURE__ */ t("div", { className: "grid grid-cols-2 gap-x-4 gap-y-2", children: P.map((Q) => /* @__PURE__ */ a("div", { children: [
194
+ /* @__PURE__ */ t("label", { className: "block text-[11px] font-medium text-slate-500 mb-1", children: Q.label ?? G(Q.field) }),
195
+ O(Q, e, r)
196
+ ] }, Q.field)) })
197
197
  ] }, p.key) : null;
198
198
  })
199
199
  ] })
@@ -204,7 +204,7 @@ function Ce({
204
204
  }
205
205
  if (!d && te)
206
206
  return /* @__PURE__ */ t("div", { className: "py-3 text-center text-[12px] text-slate-400", children: /* @__PURE__ */ t(ie, { className: "h-4 w-4 animate-spin inline" }) });
207
- const se = d ? J : v, j = !!h && A.length > 0;
207
+ const se = d ? J : w, j = !!h && A.length > 0;
208
208
  return (
209
209
  // The flat grid shows every displayable child column (a wide legacy table
210
210
  // has dozens) — it scrolls inside its card rather than running off a
@@ -237,7 +237,7 @@ function Ce({
237
237
  }
238
238
  ) })
239
239
  ] }, r)),
240
- !d && N === "original" && v.map((e, r) => {
240
+ !d && N === "original" && w.map((e, r) => {
241
241
  const n = String(e.id), s = q === n && !j;
242
242
  return /* @__PURE__ */ a(
243
243
  "tr",
@@ -249,18 +249,18 @@ function Ce({
249
249
  children: [
250
250
  o.map((i) => /* @__PURE__ */ t("td", { className: "px-3 py-1.5", children: s ? O(
251
251
  i,
252
- _,
253
- (D, p) => I((M) => ({ ...M, [D]: p }))
252
+ D,
253
+ (M, p) => I((P) => ({ ...P, [M]: p }))
254
254
  ) : K(i, e[i.field]) }, i.field)),
255
255
  /* @__PURE__ */ t("td", { className: "px-2 py-1.5", children: /* @__PURE__ */ t("div", { className: "flex items-center gap-1 justify-end", children: s ? /* @__PURE__ */ a(U, { children: [
256
256
  /* @__PURE__ */ t(
257
257
  "button",
258
258
  {
259
259
  type: "button",
260
- disabled: y,
260
+ disabled: g,
261
261
  onClick: () => X(n),
262
262
  className: "rounded px-1.5 py-0.5 bg-nvr-cyan text-white text-[11px] font-medium hover:brightness-110 disabled:opacity-50",
263
- children: y ? "…" : "Save"
263
+ children: g ? "…" : "Save"
264
264
  }
265
265
  ),
266
266
  /* @__PURE__ */ t(
@@ -311,30 +311,30 @@ function Ce({
311
311
  ) }) : e.rows.map((r, n) => /* @__PURE__ */ a("tr", { className: "border-b border-amber-100 bg-amber-50/60", children: [
312
312
  o.map((s) => /* @__PURE__ */ t("td", { className: "px-3 py-1.5 text-[11px] text-amber-900", children: K(s, r[s.field]) }, s.field)),
313
313
  /* @__PURE__ */ t("td", { className: "px-2 py-1.5 text-right", children: /* @__PURE__ */ t("span", { className: "text-[10px] font-medium uppercase tracking-wide text-amber-400", children: "Proposed" }) })
314
- ] }, n)) : v.length === 0 ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t(
314
+ ] }, n)) : w.length === 0 ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t(
315
315
  "td",
316
316
  {
317
317
  colSpan: o.length + 1,
318
318
  className: "px-3 py-4 text-center text-[11px] text-slate-400",
319
319
  children: S ? `No ${S.toLowerCase()} yet` : "No rows"
320
320
  }
321
- ) }) : v.map((r, n) => /* @__PURE__ */ a("tr", { className: "border-b border-slate-100", children: [
321
+ ) }) : w.map((r, n) => /* @__PURE__ */ a("tr", { className: "border-b border-slate-100", children: [
322
322
  o.map((s) => /* @__PURE__ */ t("td", { className: "px-3 py-1.5 text-[11px] text-slate-700", children: K(s, r[s.field]) }, s.field)),
323
323
  /* @__PURE__ */ t("td", { className: "px-2 py-1.5" })
324
324
  ] }, n));
325
325
  })(),
326
326
  N === "original" && E && !j && /* @__PURE__ */ a("tr", { className: "border-b border-slate-100 bg-nvr-cyan/5", children: [
327
327
  d && /* @__PURE__ */ t("td", { className: "px-3 py-1.5" }),
328
- ne(R, (e, r) => g((n) => ({ ...n, [e]: r }))),
328
+ ne(R, (e, r) => y((n) => ({ ...n, [e]: r }))),
329
329
  /* @__PURE__ */ t("td", { className: "px-2 py-1.5", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-1 justify-end", children: [
330
330
  /* @__PURE__ */ t(
331
331
  "button",
332
332
  {
333
333
  type: "button",
334
- disabled: y,
334
+ disabled: g,
335
335
  onClick: z,
336
336
  className: "rounded px-1.5 py-0.5 bg-nvr-cyan text-white text-[11px] font-medium hover:brightness-110 disabled:opacity-50",
337
- children: y ? "…" : "Add"
337
+ children: g ? "…" : "Add"
338
338
  }
339
339
  ),
340
340
  /* @__PURE__ */ t(
@@ -342,7 +342,7 @@ function Ce({
342
342
  {
343
343
  type: "button",
344
344
  onClick: () => {
345
- w(!1), g({});
345
+ v(!1), y({});
346
346
  },
347
347
  className: "rounded px-1.5 py-0.5 text-slate-400 hover:text-slate-700 text-[11px]",
348
348
  children: "Cancel"
@@ -360,8 +360,8 @@ function Ce({
360
360
  ) })
361
361
  ] })
362
362
  ] }),
363
- q && j && (v.find((r) => String(r.id) === q) ? /* @__PURE__ */ t("div", { className: "border-t border-slate-200 p-3", children: H(
364
- _,
363
+ q && j && (w.find((r) => String(r.id) === q) ? /* @__PURE__ */ t("div", { className: "border-t border-slate-200 p-3", children: H(
364
+ D,
365
365
  (r, n) => I((s) => ({ ...s, [r]: n })),
366
366
  () => X(q),
367
367
  () => C(null),
@@ -369,10 +369,10 @@ function Ce({
369
369
  ) }) : null),
370
370
  E && j && /* @__PURE__ */ t("div", { className: "border-t border-slate-200 p-3", children: H(
371
371
  R,
372
- (e, r) => g((n) => ({ ...n, [e]: r })),
372
+ (e, r) => y((n) => ({ ...n, [e]: r })),
373
373
  z,
374
374
  () => {
375
- w(!1), g({});
375
+ v(!1), y({});
376
376
  },
377
377
  "New Row"
378
378
  ) }),
@@ -380,7 +380,7 @@ function Ce({
380
380
  "button",
381
381
  {
382
382
  type: "button",
383
- onClick: () => w(!0),
383
+ onClick: () => v(!0),
384
384
  className: "text-[11px] font-medium text-nvr-cyan hover:underline",
385
385
  children: "+ Add row"
386
386
  }
@@ -389,5 +389,5 @@ function Ce({
389
389
  );
390
390
  }
391
391
  export {
392
- Ce as InlineGridField
392
+ Ee as InlineGridField
393
393
  };