@nivaro/react 0.3.111 → 0.3.112

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 (75) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +170 -2
  4. package/dist/index.js +745 -728
  5. package/dist/shared/components/CollectionBrowserView.js +3097 -2972
  6. package/dist/shared/components/CollectionImportBanner.js +135 -0
  7. package/dist/shared/components/ItemEditForm.js +2235 -2218
  8. package/dist/shared/components/JobsTray.js +54 -47
  9. package/dist/shared/components/ViewAsPersonButton.js +109 -0
  10. package/dist/shared/components/bulk/BulkFieldUpdate.js +228 -150
  11. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +35 -41
  12. package/dist/shared/components/bulk/BulkLinksValue.js +91 -0
  13. package/dist/shared/components/bulk/bulk-field-options.js +20 -19
  14. package/dist/shared/components/bulk/bulk-update-preview.js +39 -0
  15. package/dist/shared/components/cbv/ColumnHeaderMenu.js +113 -0
  16. package/dist/shared/components/cbv/column-totals.js +66 -0
  17. package/dist/shared/components/collections-directory/CollectionHoverCard.js +108 -81
  18. package/dist/shared/components/collections-directory/CollectionRow.js +164 -148
  19. package/dist/shared/components/collections-directory/CollectionsDirectory.js +167 -166
  20. package/dist/shared/components/collections-directory/directory-data.js +70 -58
  21. package/dist/shared/components/imports/CollectionImportPanel.js +120 -118
  22. package/dist/shared/components/imports/DefinitionsPanel.js +24 -24
  23. package/dist/shared/components/imports/ImportDuplicatesNotice.js +65 -0
  24. package/dist/shared/components/item-edit/CatalogPickerField.js +631 -639
  25. package/dist/shared/components/item-edit/DuplicateNotice.js +168 -0
  26. package/dist/shared/components/item-edit/FieldRow.js +248 -246
  27. package/dist/shared/components/item-edit/InlineGridField.js +34 -33
  28. package/dist/shared/components/item-edit/InlineTableField.js +3064 -2882
  29. package/dist/shared/components/item-edit/MembershipSetField.js +165 -169
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +184 -189
  31. package/dist/shared/components/item-edit/PlanGrid.js +2 -1
  32. package/dist/shared/components/item-edit/QuickPickerDialog.js +35 -34
  33. package/dist/shared/components/item-edit/RecordLiveSync.js +32 -30
  34. package/dist/shared/components/item-edit/RelationCombobox.js +101 -100
  35. package/dist/shared/components/item-edit/RowHistorySheet.js +28 -27
  36. package/dist/shared/components/item-edit/SummaryPanel.js +133 -135
  37. package/dist/shared/components/item-edit/ViewAsRole.js +129 -52
  38. package/dist/shared/components/item-edit/grid-search.js +345 -0
  39. package/dist/shared/components/item-edit/render-stability.js +61 -54
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +25 -20
  41. package/dist/shared/components/ops-report/DigestSections.js +163 -144
  42. package/dist/shared/components/ops-report/drill.js +97 -97
  43. package/dist/shared/components/panels/AddendumLinesDiff.js +52 -51
  44. package/dist/shared/components/panels/AddendumPanel.js +92 -91
  45. package/dist/shared/components/panels/AsyncUserPicker.js +108 -0
  46. package/dist/shared/components/panels/CommentPanel.js +265 -252
  47. package/dist/shared/components/panels/OwnersSlot.js +47 -35
  48. package/dist/shared/components/panels/PipelineInsight.js +186 -0
  49. package/dist/shared/components/panels/PipelinePanel.js +1529 -1492
  50. package/dist/shared/components/panels/RecordIntegrityBanner.js +39 -38
  51. package/dist/shared/components/panels/RevisionsPanel.js +261 -260
  52. package/dist/shared/components/pipeline/FieldPicker.js +41 -40
  53. package/dist/shared/components/pipeline/OwnerMatrix.js +829 -700
  54. package/dist/shared/components/pipeline/OwnerRecordTrial.js +362 -0
  55. package/dist/shared/components/pipeline/PipelineEditorView.js +483 -467
  56. package/dist/shared/components/pipeline/PipelineStateOwners.js +65 -64
  57. package/dist/shared/components/pipeline/owner-matrix-draft.js +178 -0
  58. package/dist/shared/components/profile/MyDefaultsCard.js +36 -35
  59. package/dist/shared/components/profile/PersonHeader.js +29 -29
  60. package/dist/shared/components/profile/PersonProfile.js +30 -28
  61. package/dist/shared/components/profile/SlowScreensCard.js +286 -0
  62. package/dist/shared/components/queue/QueueWorklist.js +1090 -1071
  63. package/dist/shared/components/quick-filters/useQuickFilterEditing.js +45 -44
  64. package/dist/shared/components/support/TicketDetailSheet.js +25 -16
  65. package/dist/shared/components/support/TicketSlowScreens.js +32 -0
  66. package/dist/shared/lib/activity-sentence.js +224 -178
  67. package/dist/shared/lib/collection-import-banner.js +27 -0
  68. package/dist/shared/lib/crash-report.js +112 -0
  69. package/dist/shared/lib/export-runs.js +99 -0
  70. package/dist/shared/lib/jobs-tray.js +89 -67
  71. package/dist/shared/lib/list-link.js +76 -69
  72. package/dist/shared/lib/nav-trail.js +180 -76
  73. package/dist/shared/lib/query-keys.js +26 -0
  74. package/dist/shared/lib/view-as.js +16 -11
  75. package/package.json +1 -1
@@ -5,25 +5,26 @@ import { useState as O, useRef as Pe, useEffect as Je, useMemo as oe, Fragment a
5
5
  import { toast as E } from "sonner";
6
6
  import { useNivaroClient as xe, useItemEditAuth as st } from "../../context.js";
7
7
  import { get as L, post as ve, del as it } from "../../lib/commands.js";
8
- import { sanitizeHtml as ot } from "../../lib/sanitize-html.js";
9
- import { useStartsOpen as dt } from "../../lib/use-starts-open.js";
8
+ import { queryKeys as ot } from "../../lib/query-keys.js";
9
+ import { sanitizeHtml as dt } from "../../lib/sanitize-html.js";
10
+ import { useStartsOpen as ct } from "../../lib/use-starts-open.js";
10
11
  import { titleCase as fe } from "../../lib/utils.js";
11
- import { DocumentAutofillButton as ct } from "../import/DocumentAutofillButton.js";
12
- import { FieldRenderer as mt } from "../item-edit/FieldRenderer.js";
13
- import { useFileDownload as ut } from "../item-edit/file-download.js";
14
- import { evalClientFormula as pt } from "../item-edit/InlineTableField.js";
15
- import { parseRollupParentFilter as ze, matchesRollupFilter as ft, computeLiveRollup as We, parseRollupSources as He } from "../item-edit/live-rollups.js";
16
- import { useLocalLiveRows as ht, LiveRowsContext as xt, O2MStagingContext as bt, useLiveRows as gt } from "../item-edit/O2MStagingContext.js";
12
+ import { DocumentAutofillButton as mt } from "../import/DocumentAutofillButton.js";
13
+ import { FieldRenderer as ut } from "../item-edit/FieldRenderer.js";
14
+ import { useFileDownload as pt } from "../item-edit/file-download.js";
15
+ import { evalClientFormula as ft } from "../item-edit/InlineTableField.js";
16
+ import { parseRollupParentFilter as ze, matchesRollupFilter as ht, computeLiveRollup as We, parseRollupSources as He } from "../item-edit/live-rollups.js";
17
+ import { useLocalLiveRows as xt, LiveRowsContext as bt, O2MStagingContext as gt, useLiveRows as vt } from "../item-edit/O2MStagingContext.js";
17
18
  import { Button as Q } from "../ui/button.js";
18
19
  import { Input as je } from "../ui/input.js";
19
20
  import { Label as he } from "../ui/label.js";
20
- import { Sheet as vt, SheetContent as yt, SheetHeader as Nt, SheetTitle as kt } from "../ui/sheet.js";
21
+ import { Sheet as yt, SheetContent as Nt, SheetHeader as kt, SheetTitle as _t } from "../ui/sheet.js";
21
22
  import { Skeleton as re } from "../ui/skeleton.js";
22
- import { Textarea as _t } from "../ui/textarea.js";
23
- import { AddendumCompare as wt } from "./AddendumCompare.js";
23
+ import { Textarea as wt } from "../ui/textarea.js";
24
+ import { AddendumCompare as Ct } from "./AddendumCompare.js";
24
25
  import { AddendumLinesDiff as Ue } from "./AddendumLinesDiff.js";
25
- import { resolveAddendumAmounts as Ct } from "./addendum-summary.js";
26
- const ye = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }), St = (t) => t.replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
26
+ import { resolveAddendumAmounts as St } from "./addendum-summary.js";
27
+ const ye = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }), qt = (t) => t.replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
27
28
  function Qe(t) {
28
29
  const m = Number(t);
29
30
  return !t || Number.isNaN(m) || m === 0 ? null : /* @__PURE__ */ i(
@@ -88,11 +89,11 @@ const Me = {
88
89
  badge: "bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-400",
89
90
  dot: "bg-amber-500"
90
91
  }
91
- }, qt = (t, m) => Math.round(Number(t) * 100) === Math.round(Number(m) * 100);
92
- function Ft(t, m, y) {
92
+ }, Ft = (t, m) => Math.round(Number(t) * 100) === Math.round(Number(m) * 100);
93
+ function At(t, m, y) {
93
94
  if (!y || t.computed_type !== "rollup" || !t.computed_formula) return t;
94
95
  const x = We(He(t.computed_formula), y.rows);
95
- return x === null || m != null && qt(m, x) ? t : {
96
+ return x === null || m != null && Ft(m, x) ? t : {
96
97
  ...t,
97
98
  options: {
98
99
  ...t.options ?? {},
@@ -100,7 +101,7 @@ function Ft(t, m, y) {
100
101
  }
101
102
  };
102
103
  }
103
- function At({
104
+ function Mt({
104
105
  current: t,
105
106
  value: m,
106
107
  onChange: y,
@@ -153,7 +154,7 @@ function At({
153
154
  ] })
154
155
  ] });
155
156
  }
156
- const Mt = lt(function({
157
+ const Pt = lt(function({
157
158
  configuredFields: m,
158
159
  fieldMap: y,
159
160
  formData: x,
@@ -163,7 +164,7 @@ const Mt = lt(function({
163
164
  prefillParentId: _,
164
165
  parentData: f
165
166
  }) {
166
- const C = gt();
167
+ const C = vt();
167
168
  return m.length === 0 ? /* @__PURE__ */ r("div", { className: "rounded-lg border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-center dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No fields configured for addendum. Set up the field list in Data Model → Layouts → Addendum Form." }) }) : /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border pt-3", children: [
168
169
  /* @__PURE__ */ r("p", { className: "mb-3 text-[11px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Proposed changes" }),
169
170
  /* @__PURE__ */ r("div", { className: "space-y-3", children: m.map((u) => {
@@ -192,7 +193,7 @@ const Mt = lt(function({
192
193
  return /* @__PURE__ */ i("div", { children: [
193
194
  /* @__PURE__ */ r(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: S }),
194
195
  /* @__PURE__ */ r(
195
- At,
196
+ Mt,
196
197
  {
197
198
  current: Number.isFinite(I) ? I : 0,
198
199
  value: x[u.field],
@@ -206,9 +207,9 @@ const Mt = lt(function({
206
207
  return /* @__PURE__ */ i("div", { children: [
207
208
  /* @__PURE__ */ r(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: S }),
208
209
  /* @__PURE__ */ r(
209
- mt,
210
+ ut,
210
211
  {
211
- field: Ft(v, x[u.field], C),
212
+ field: At(v, x[u.field], C),
212
213
  value: x[u.field],
213
214
  onChange: (I) => k(u.field, I),
214
215
  relations: p,
@@ -221,7 +222,7 @@ const Mt = lt(function({
221
222
  }) })
222
223
  ] });
223
224
  });
224
- function Pt({ addendumId: t }) {
225
+ function jt({ addendumId: t }) {
225
226
  const m = xe(), { data: y, isLoading: x } = W({
226
227
  queryKey: ["pipeline-instance", "nivaro_addendums", t],
227
228
  queryFn: () => m.request(L(`/pipelines/instance/nivaro_addendums/${t}`)).then((b) => b.data),
@@ -250,7 +251,7 @@ function Pt({ addendumId: t }) {
250
251
  k.completed_at && /* @__PURE__ */ r("p", { className: "text-[11px] text-slate-400 italic", children: "Workflow complete." })
251
252
  ] });
252
253
  }
253
- function jt({
254
+ function Rt({
254
255
  collection: t,
255
256
  itemId: m,
256
257
  assignments: y,
@@ -322,7 +323,7 @@ function jt({
322
323
  Je(() => {
323
324
  se.current = M;
324
325
  }, [M]);
325
- const te = ht(), me = oe(
326
+ const te = xt(), me = oe(
326
327
  () => ({
327
328
  getPendingRows: (l, n) => M.get(`${l}.${n}`) ?? [],
328
329
  queueRow: (l, n, o) => H((d) => {
@@ -361,7 +362,7 @@ function jt({
361
362
  })
362
363
  }),
363
364
  [M, X, Z]
364
- ), $ = pe({
365
+ ), q = pe({
365
366
  mutationFn: () => {
366
367
  const l = {};
367
368
  for (const [n, o] of Object.entries(K)) {
@@ -397,9 +398,9 @@ function jt({
397
398
  },
398
399
  onError: () => E.error("Failed to create addendum")
399
400
  });
400
- return /* @__PURE__ */ r(xt.Provider, { value: te, children: /* @__PURE__ */ r(bt.Provider, { value: me, children: /* @__PURE__ */ i("div", { className: "flex h-full flex-col", children: [
401
- /* @__PURE__ */ i(Nt, { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
402
- /* @__PURE__ */ r(kt, { className: "text-[14px] font-semibold text-slate-900 dark:text-slate-100", children: "New Addendum" }),
401
+ return /* @__PURE__ */ r(bt.Provider, { value: te, children: /* @__PURE__ */ r(gt.Provider, { value: me, children: /* @__PURE__ */ i("div", { className: "flex h-full flex-col", children: [
402
+ /* @__PURE__ */ i(kt, { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
403
+ /* @__PURE__ */ r(_t, { className: "text-[14px] font-semibold text-slate-900 dark:text-slate-100", children: "New Addendum" }),
403
404
  /* @__PURE__ */ r("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400", children: "Propose changes to this record. Fields are pre-filled with current values — edit what's changing." })
404
405
  ] }),
405
406
  /* @__PURE__ */ i("div", { className: "flex-1 overflow-y-auto px-5 py-4 space-y-4", children: [
@@ -423,7 +424,7 @@ function jt({
423
424
  /* @__PURE__ */ i("div", { children: [
424
425
  /* @__PURE__ */ r(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: "Notes" }),
425
426
  /* @__PURE__ */ r(
426
- _t,
427
+ wt,
427
428
  {
428
429
  value: N,
429
430
  onChange: (l) => I(l.target.value),
@@ -485,7 +486,7 @@ function jt({
485
486
  }
486
487
  ),
487
488
  /* @__PURE__ */ r(
488
- ct,
489
+ mt,
489
490
  {
490
491
  collection: t,
491
492
  layoutId: k,
@@ -498,7 +499,7 @@ function jt({
498
499
  ] })
499
500
  ] }),
500
501
  /* @__PURE__ */ r(
501
- Mt,
502
+ Pt,
502
503
  {
503
504
  parentData: _,
504
505
  configuredFields: v,
@@ -518,15 +519,15 @@ function jt({
518
519
  {
519
520
  size: "sm",
520
521
  className: "h-8 bg-nvr-cyan text-[12px] font-medium text-white hover:bg-nvr-cyan/90",
521
- disabled: !S.trim() || $.isPending,
522
- onClick: () => $.mutate(),
523
- children: $.isPending ? "Creating…" : "Create Addendum"
522
+ disabled: !S.trim() || q.isPending,
523
+ onClick: () => q.mutate(),
524
+ children: q.isPending ? "Creating…" : "Create Addendum"
524
525
  }
525
526
  )
526
527
  ] })
527
528
  ] }) }) });
528
529
  }
529
- function Rt({ addendum: t }) {
530
+ function Ot({ addendum: t }) {
530
531
  var C;
531
532
  const m = xe(), y = [t.created_by, t.approved_by].filter(Boolean), { data: x = {} } = W({
532
533
  queryKey: ["addendum-users", ...y.sort()],
@@ -567,15 +568,15 @@ function Rt({ addendum: t }) {
567
568
  "div",
568
569
  {
569
570
  className: "nvr-addendum-reason max-w-[75ch] leading-relaxed [&_a]:text-nvr-cyan [&_a]:underline [&_li]:ml-4 [&_ol]:list-decimal [&_p]:mb-1 [&_ul]:list-disc",
570
- dangerouslySetInnerHTML: { __html: ot(t.description) }
571
+ dangerouslySetInnerHTML: { __html: dt(t.description) }
571
572
  }
572
573
  ) : /* @__PURE__ */ r("p", { className: "max-w-[75ch] whitespace-pre-wrap leading-relaxed", children: t.description }) })
573
574
  ] }),
574
- /* @__PURE__ */ r(Ot, { ids: t.attachments })
575
+ /* @__PURE__ */ r(Dt, { ids: t.attachments })
575
576
  ] });
576
577
  }
577
- function Ot({ ids: t }) {
578
- const m = xe(), y = ut(), x = Array.isArray(t) ? t.filter(Boolean) : [], { data: k = [] } = W({
578
+ function Dt({ ids: t }) {
579
+ const m = xe(), y = pt(), x = Array.isArray(t) ? t.filter(Boolean) : [], { data: k = [] } = W({
579
580
  queryKey: ["addendum-files", ...x],
580
581
  queryFn: () => Promise.all(
581
582
  x.map(
@@ -632,7 +633,7 @@ function Ot({ ids: t }) {
632
633
  ] })
633
634
  ] });
634
635
  }
635
- function Dt({
636
+ function Tt({
636
637
  addendum: t,
637
638
  configuredFields: m,
638
639
  onRefresh: y,
@@ -722,7 +723,7 @@ function Dt({
722
723
  (s) => s.one_collection === p && s.many_collection === e.related_collection && s.many_field === e.fk_field && !s.junction_field
723
724
  );
724
725
  return a ? a.one_field ?? a.many_collection : null;
725
- }, $ = oe(
726
+ }, q = oe(
726
727
  () => Object.values(_).filter((e) => {
727
728
  const a = te(e);
728
729
  return a.length > 0 && !a.some((s) => s.recursive) && a.every((s) => {
@@ -735,13 +736,13 @@ function Dt({
735
736
  ), l = oe(
736
737
  () => [
737
738
  ...new Set(
738
- $.flatMap((e) => te(e).map((a) => a.related_collection))
739
+ q.flatMap((e) => te(e).map((a) => a.related_collection))
739
740
  )
740
741
  ],
741
- [$]
742
+ [q]
742
743
  ), n = Le({
743
744
  queries: l.map((e) => ({
744
- queryKey: ["field-config", e, null],
745
+ queryKey: ot.fieldConfig(e, null),
745
746
  queryFn: () => f.request(L(`/field-config/${e}`)).then((a) => a.data ?? []),
746
747
  staleTime: 6e4
747
748
  }))
@@ -756,7 +757,7 @@ function Dt({
756
757
  p,
757
758
  b,
758
759
  d.map((e) => e.field).join(","),
759
- $.map((e) => e.field).join(",")
760
+ q.map((e) => e.field).join(",")
760
761
  ],
761
762
  queryFn: () => f.request(
762
763
  L(`/items/${p}/${b}`, {
@@ -766,7 +767,7 @@ function Dt({
766
767
  ...d.map((e) => e.field),
767
768
  // The rollups themselves (current figure) plus any parent_filter
768
769
  // columns that decide whether the rollup applies to this record.
769
- ...$.flatMap((e) => [
770
+ ...q.flatMap((e) => [
770
771
  e.field,
771
772
  ...Object.keys(ze(e.computed_formula) ?? {})
772
773
  ])
@@ -774,22 +775,22 @@ function Dt({
774
775
  ].join(",")
775
776
  })
776
777
  ).then((e) => e.data ?? null).catch(() => null),
777
- enabled: !!p && !!b && (d.length > 0 || $.length > 0),
778
+ enabled: !!p && !!b && (d.length > 0 || q.length > 0),
778
779
  staleTime: 15e3
779
780
  }), h = oe(() => {
780
781
  const e = /* @__PURE__ */ new Map(), a = new Map(
781
782
  l.map((s, g) => {
782
- var q;
783
+ var $;
783
784
  return [
784
785
  s,
785
- (q = n[g]) == null ? void 0 : q.data
786
+ ($ = n[g]) == null ? void 0 : $.data
786
787
  ];
787
788
  })
788
789
  );
789
- for (const s of $) {
790
+ for (const s of q) {
790
791
  const g = ze(s.computed_formula);
791
- if (g && c && !ft(c, g)) continue;
792
- const q = /* @__PURE__ */ new Map();
792
+ if (g && c && !ht(c, g)) continue;
793
+ const $ = /* @__PURE__ */ new Map();
793
794
  let J = !0;
794
795
  for (const U of te(s)) {
795
796
  const ge = me(U), ue = a.get(U.related_collection);
@@ -800,22 +801,22 @@ function Dt({
800
801
  const Ze = ue.filter((Ce) => Ce.computed_type === "write" && !!Ce.computed_formula), et = N[ge].map((Ce) => {
801
802
  const Ae = { ...Ce };
802
803
  for (const Te of Ze) {
803
- const Ee = pt(String(Te.computed_formula), Ae);
804
+ const Ee = ft(String(Te.computed_formula), Ae);
804
805
  Ee !== null && (Ae[Te.field] = Ee);
805
806
  }
806
807
  return Ae;
807
808
  });
808
- q.set(`${U.related_collection}.${U.fk_field}`, et);
809
+ $.set(`${U.related_collection}.${U.fk_field}`, et);
809
810
  }
810
811
  if (!J) continue;
811
- const T = We(te(s), q);
812
+ const T = We(te(s), $);
812
813
  T !== null && e.set(s.field, Math.round(T * 100) / 100);
813
814
  }
814
815
  return e;
815
- }, [$, l, o, N, c]), w = (e, a) => a ? e.filter((s) => {
816
- const g = a.find((q) => String(q.id) === String(s.id));
816
+ }, [q, l, o, N, c]), w = (e, a) => a ? e.filter((s) => {
817
+ const g = a.find(($) => String($.id) === String(s.id));
817
818
  return g ? Object.keys(s).some(
818
- (q) => q !== "id" && String(s[q] ?? "") !== String(g[q] ?? "")
819
+ ($) => $ !== "id" && String(s[$] ?? "") !== String(g[$] ?? "")
819
820
  ) : !0;
820
821
  }).length : e.length, ie = [
821
822
  ...se.filter((e) => {
@@ -830,7 +831,7 @@ function Dt({
830
831
  label_override: e.label_override ?? null,
831
832
  value: N[e.field]
832
833
  })),
833
- ...$.flatMap(
834
+ ...q.flatMap(
834
835
  (e) => h.has(e.field) && !(c && c[e.field] != null && Number(c[e.field]) === h.get(e.field)) ? [
835
836
  {
836
837
  field: e.field,
@@ -843,14 +844,14 @@ function Dt({
843
844
  var g;
844
845
  const s = (g = _[e]) == null ? void 0 : g.type;
845
846
  return s && ["integer", "bigInteger", "decimal", "float", "number"].includes(s) ? !0 : a != null && a !== "" && !Array.isArray(a) && !Number.isNaN(Number(a));
846
- }, $e = (e) => {
847
+ }, qe = (e) => {
847
848
  var s;
848
849
  const a = (s = _[e]) == null ? void 0 : s.options;
849
850
  return a && typeof a == "object" && a.format === "currency" ? !0 : /amount|cost|price|total|budget|spend/i.test(e);
850
- }, qe = (e, a) => $e(e) ? ye.format(Number(a)) : new Intl.NumberFormat("en-US").format(Number(a)), Ge = oe(() => {
851
+ }, $e = (e, a) => qe(e) ? ye.format(Number(a)) : new Intl.NumberFormat("en-US").format(Number(a)), Ge = oe(() => {
851
852
  if (t.cost_impact != null && Number(t.cost_impact) !== 0 || !c) return null;
852
853
  for (const e of d) {
853
- if (!$e(e.field)) continue;
854
+ if (!qe(e.field)) continue;
854
855
  const a = Number(N[e.field]), s = Number(c[e.field]);
855
856
  if (!Number.isNaN(a) && !Number.isNaN(s) && a !== s) return a - s;
856
857
  }
@@ -862,10 +863,10 @@ function Dt({
862
863
  ...h.entries()
863
864
  ].flatMap(([a, s]) => {
864
865
  const g = c[a];
865
- return !$e(a) || g == null || g === "" ? [] : Number.isNaN(Number(g)) || Number.isNaN(s) ? [] : [{ field: a, previous: Number(g), next: s }];
866
+ return !qe(a) || g == null || g === "" ? [] : Number.isNaN(Number(g)) || Number.isNaN(s) ? [] : [{ field: a, previous: Number(g), next: s }];
866
867
  });
867
868
  return e.find((a) => a.previous !== a.next) ?? e[0] ?? null;
868
- }, [c, d, N, h]), we = Ct(t, _e), Fe = we.previous != null || we.next != null || we.change != null, be = Fe ? (_e == null ? void 0 : _e.field) ?? null : null, Xe = be ? ((Oe = ie.find((e) => e.field === be)) == null ? void 0 : Oe.label_override) ?? ((De = _[be]) == null ? void 0 : De.label) ?? fe(be) : "Amount";
869
+ }, [c, d, N, h]), we = St(t, _e), Fe = we.previous != null || we.next != null || we.change != null, be = Fe ? (_e == null ? void 0 : _e.field) ?? null : null, Xe = be ? ((Oe = ie.find((e) => e.field === be)) == null ? void 0 : Oe.label_override) ?? ((De = _[be]) == null ? void 0 : De.label) ?? fe(be) : "Amount";
869
870
  return /* @__PURE__ */ i(
870
871
  "div",
871
872
  {
@@ -903,7 +904,7 @@ function Dt({
903
904
  ] }),
904
905
  Qe(t.cost_impact) ?? Qe(Ge)
905
906
  ] }),
906
- t.description && !C && /* @__PURE__ */ r("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400 line-clamp-1", children: St(t.description) })
907
+ t.description && !C && /* @__PURE__ */ r("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400 line-clamp-1", children: qt(t.description) })
907
908
  ] }),
908
909
  /* @__PURE__ */ r(
909
910
  "span",
@@ -919,7 +920,7 @@ function Dt({
919
920
  }
920
921
  ),
921
922
  C && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border", children: [
922
- /* @__PURE__ */ r(Rt, { addendum: t }),
923
+ /* @__PURE__ */ r(Ot, { addendum: t }),
923
924
  (ke > 0 || Fe) && /* @__PURE__ */ i("section", { className: "border-t border-slate-100 px-4 py-3.5 dark:border-border", children: [
924
925
  /* @__PURE__ */ r("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: F ? "Changes" : "Proposed changes" }),
925
926
  /* @__PURE__ */ i("dl", { className: Ve, children: [
@@ -939,12 +940,12 @@ function Dt({
939
940
  else if (typeof a == "object")
940
941
  s = JSON.stringify(a).slice(0, 60);
941
942
  else if (Ye(e.field, a)) {
942
- const q = Number(a), J = c == null ? void 0 : c[e.field], T = J != null && J !== "" && !Number.isNaN(Number(J)) ? Number(J) : null, U = T != null ? q - T : 0;
943
+ const $ = Number(a), J = c == null ? void 0 : c[e.field], T = J != null && J !== "" && !Number.isNaN(Number(J)) ? Number(J) : null, U = T != null ? $ - T : 0;
943
944
  s = /* @__PURE__ */ i("span", { className: "inline-flex flex-wrap items-baseline gap-x-1.5 tabular-nums", children: [
944
- T != null && T !== q && /* @__PURE__ */ r("span", { className: "text-slate-400 line-through decoration-slate-300 dark:text-slate-500 dark:decoration-slate-600", children: qe(e.field, T) }),
945
+ T != null && T !== $ && /* @__PURE__ */ r("span", { className: "text-slate-400 line-through decoration-slate-300 dark:text-slate-500 dark:decoration-slate-600", children: $e(e.field, T) }),
945
946
  /* @__PURE__ */ i("span", { className: "font-medium text-foreground", children: [
946
- T != null && T !== q && /* @__PURE__ */ r("span", { className: "mr-1 font-normal text-slate-400", "aria-hidden": "true", children: "→" }),
947
- qe(e.field, q)
947
+ T != null && T !== $ && /* @__PURE__ */ r("span", { className: "mr-1 font-normal text-slate-400", "aria-hidden": "true", children: "→" }),
948
+ $e(e.field, $)
948
949
  ] }),
949
950
  U !== 0 && /* @__PURE__ */ i(
950
951
  "span",
@@ -955,7 +956,7 @@ function Dt({
955
956
  ),
956
957
  children: [
957
958
  U > 0 ? "+" : "−",
958
- qe(e.field, Math.abs(U))
959
+ $e(e.field, Math.abs(U))
959
960
  ]
960
961
  }
961
962
  )
@@ -987,8 +988,8 @@ function Dt({
987
988
  }),
988
989
  j.map(({ field: e, rel: a }) => {
989
990
  var U, ge;
990
- const s = N[e], g = j.findIndex((ue) => ue.field === e), q = V[e] ?? ((U = G[g]) != null && U.isLoading ? null : []);
991
- if (F || !Array.isArray(s) || !q || !(a != null && a.many_collection) || !a.many_field)
991
+ const s = N[e], g = j.findIndex((ue) => ue.field === e), $ = V[e] ?? ((U = G[g]) != null && U.isLoading ? null : []);
992
+ if (F || !Array.isArray(s) || !$ || !(a != null && a.many_collection) || !a.many_field)
992
993
  return null;
993
994
  const J = m.find((ue) => ue.field === e), T = (J == null ? void 0 : J.label_override) ?? ((ge = _[e]) == null ? void 0 : ge.label) ?? fe(e);
994
995
  return /* @__PURE__ */ i(Se, { children: [
@@ -1000,7 +1001,7 @@ function Dt({
1000
1001
  childCollection: a.many_collection,
1001
1002
  fkField: a.many_field,
1002
1003
  proposed: s,
1003
- original: q,
1004
+ original: $,
1004
1005
  label: T
1005
1006
  }
1006
1007
  ) })
@@ -1010,7 +1011,7 @@ function Dt({
1010
1011
  ] }),
1011
1012
  t.workflow_template_id && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border px-4 py-3.5", children: [
1012
1013
  /* @__PURE__ */ r("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: "Workflow" }),
1013
- /* @__PURE__ */ r(Pt, { addendumId: t.id }),
1014
+ /* @__PURE__ */ r(jt, { addendumId: t.id }),
1014
1015
  Y && /* @__PURE__ */ r("div", { className: "mt-2 flex items-center justify-end gap-2", children: t.status === "approved" ? t.legacy_id != null ? null : R ? /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5", children: [
1015
1016
  /* @__PURE__ */ r("span", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Roll every applied change back?" }),
1016
1017
  /* @__PURE__ */ r(
@@ -1156,7 +1157,7 @@ function Dt({
1156
1157
  }
1157
1158
  );
1158
1159
  }
1159
- function or({
1160
+ function cr({
1160
1161
  collection: t,
1161
1162
  item: m,
1162
1163
  addendumLayoutId: y,
@@ -1166,7 +1167,7 @@ function or({
1166
1167
  onCreated: b,
1167
1168
  defaultExpanded: _ = !0
1168
1169
  }) {
1169
- const f = xe(), C = Be(), [u, v] = O(!1), [S, B] = dt(_, !0), N = !S, I = (n) => B((o) => !(typeof n == "function" ? n(!o) : n)), [j, G] = O(!1), {
1170
+ const f = xe(), C = Be(), [u, v] = O(!1), [S, B] = ct(_, !0), N = !S, I = (n) => B((o) => !(typeof n == "function" ? n(!o) : n)), [j, G] = O(!1), {
1170
1171
  data: F = [],
1171
1172
  isLoading: ne,
1172
1173
  refetch: V
@@ -1225,19 +1226,19 @@ function or({
1225
1226
  b == null || b({ id: n, pdfSlot: d });
1226
1227
  }, me = ae.filter(
1227
1228
  (n) => !String(n.field).startsWith("__") && (n.is_visible || n.is_visible === 1)
1228
- ), $ = F.filter(
1229
+ ), q = F.filter(
1229
1230
  (n) => !["approved", "rejected", "reverted"].includes(n.status)
1230
1231
  ).length, l = Pe(k);
1231
1232
  return l.current = k, Je(() => {
1232
1233
  var n;
1233
- (n = l.current) == null || n.call(l, $);
1234
- }, [$]), !x && (ne || F.length === 0) ? null : /* @__PURE__ */ i(Ne, { children: [
1234
+ (n = l.current) == null || n.call(l, q);
1235
+ }, [q]), !x && (ne || F.length === 0) ? null : /* @__PURE__ */ i(Ne, { children: [
1235
1236
  /* @__PURE__ */ i(
1236
1237
  "div",
1237
1238
  {
1238
1239
  className: D(
1239
1240
  "overflow-hidden rounded-xl border bg-white dark:bg-card",
1240
- $ > 0 ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
1241
+ q > 0 ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
1241
1242
  ),
1242
1243
  children: [
1243
1244
  /* @__PURE__ */ i(
@@ -1245,16 +1246,16 @@ function or({
1245
1246
  {
1246
1247
  className: D(
1247
1248
  "flex items-center justify-between px-4 py-3 cursor-pointer select-none",
1248
- !N && ($ > 0 ? "border-b border-amber-200 dark:border-amber-500/30" : "border-b border-slate-200 dark:border-border")
1249
+ !N && (q > 0 ? "border-b border-amber-200 dark:border-amber-500/30" : "border-b border-slate-200 dark:border-border")
1249
1250
  ),
1250
1251
  onClick: () => I((n) => !n),
1251
1252
  children: [
1252
1253
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1253
1254
  /* @__PURE__ */ r(tt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500" }),
1254
1255
  /* @__PURE__ */ r("h3", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: "Addendums" }),
1255
- $ > 0 && /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1256
+ q > 0 && /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
1256
1257
  /* @__PURE__ */ r("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse" }),
1257
- $,
1258
+ q,
1258
1259
  " in review"
1259
1260
  ] }),
1260
1261
  F.length >= 2 && !N && /* @__PURE__ */ r(
@@ -1275,7 +1276,7 @@ function or({
1275
1276
  )
1276
1277
  ] }),
1277
1278
  /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1278
- x && (!(A != null && A.single_active_addendum) || $ === 0) && /* @__PURE__ */ r(
1279
+ x && (!(A != null && A.single_active_addendum) || q === 0) && /* @__PURE__ */ r(
1279
1280
  Q,
1280
1281
  {
1281
1282
  size: "sm",
@@ -1311,7 +1312,7 @@ function or({
1311
1312
  /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No addendum attached to this record" }),
1312
1313
  /* @__PURE__ */ r("p", { className: "mt-0.5 text-[11px] text-slate-300 dark:text-slate-600", children: "Addendums propose changes that go through a review process before being applied." })
1313
1314
  ] }) : j && F.length >= 2 ? /* @__PURE__ */ r("div", { className: "p-3", children: /* @__PURE__ */ r(
1314
- wt,
1315
+ Ct,
1315
1316
  {
1316
1317
  client: f,
1317
1318
  addendums: F,
@@ -1321,7 +1322,7 @@ function or({
1321
1322
  fieldMap: Object.fromEntries(M.map((n) => [n.field, n]))
1322
1323
  }
1323
1324
  ) }) : /* @__PURE__ */ r("div", { className: "p-3 space-y-2", children: F.map((n) => /* @__PURE__ */ r(
1324
- Dt,
1325
+ Tt,
1325
1326
  {
1326
1327
  addendum: n,
1327
1328
  configuredFields: me,
@@ -1337,14 +1338,14 @@ function or({
1337
1338
  ]
1338
1339
  }
1339
1340
  ),
1340
- /* @__PURE__ */ r(vt, { open: u, onOpenChange: v, children: /* @__PURE__ */ r(yt, { side: "right", className: "w-[80vw] sm:max-w-[80vw] p-0 flex flex-col", children: u && (ee || X) ? /* @__PURE__ */ i("div", { className: "flex flex-col gap-3 p-6", children: [
1341
+ /* @__PURE__ */ r(yt, { open: u, onOpenChange: v, children: /* @__PURE__ */ r(Nt, { side: "right", className: "w-[80vw] sm:max-w-[80vw] p-0 flex flex-col", children: u && (ee || X) ? /* @__PURE__ */ i("div", { className: "flex flex-col gap-3 p-6", children: [
1341
1342
  /* @__PURE__ */ r(re, { className: "h-6 w-48" }),
1342
1343
  /* @__PURE__ */ r(re, { className: "h-9 w-full" }),
1343
1344
  /* @__PURE__ */ r(re, { className: "h-9 w-full" }),
1344
1345
  /* @__PURE__ */ r(re, { className: "h-9 w-full" }),
1345
1346
  /* @__PURE__ */ r(re, { className: "h-9 w-3/4" })
1346
1347
  ] }) : u && Z ? /* @__PURE__ */ r(
1347
- jt,
1348
+ Rt,
1348
1349
  {
1349
1350
  collection: t,
1350
1351
  itemId: m,
@@ -1361,5 +1362,5 @@ function or({
1361
1362
  ] });
1362
1363
  }
1363
1364
  export {
1364
- or as AddendumPanel
1365
+ cr as AddendumPanel
1365
1366
  };
@@ -0,0 +1,108 @@
1
+ import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
+ import { useQuery as g } from "@tanstack/react-query";
3
+ import { ChevronDown as Q, X as S, Search as _, Loader2 as $, Check as q } from "lucide-react";
4
+ import { useState as m, useRef as v, useEffect as N } from "react";
5
+ import { useNivaroClient as L } from "../../context.js";
6
+ import { get as O } from "../../lib/commands.js";
7
+ import { userCardQuery as R } from "../../lib/user-cards.js";
8
+ import { Popover as B, PopoverTrigger as D, PopoverContent as U } from "../ui/popover.js";
9
+ function I({
10
+ value: s,
11
+ onChange: d
12
+ }) {
13
+ const u = L(), [l, p] = m(!1), [o, f] = m(""), [i, w] = m(""), h = v(null), a = v(null);
14
+ N(() => {
15
+ l ? setTimeout(() => {
16
+ var e;
17
+ return (e = h.current) == null ? void 0 : e.focus();
18
+ }, 50) : f("");
19
+ }, [l]), N(() => (a.current && clearTimeout(a.current), a.current = setTimeout(() => w(o), 250), () => {
20
+ a.current && clearTimeout(a.current);
21
+ }), [o]);
22
+ const { data: k, isLoading: C } = g({
23
+ queryKey: ["users", "async-search", i],
24
+ queryFn: () => u.request(
25
+ O("/users", {
26
+ limit: 50,
27
+ sort: "first_name",
28
+ ...i ? { search: i } : {}
29
+ })
30
+ ).then((e) => e.data),
31
+ enabled: l,
32
+ staleTime: 3e4
33
+ }), { data: T } = g({
34
+ ...R(u, s),
35
+ enabled: !!s,
36
+ staleTime: 5 * 6e4
37
+ }), c = k ?? [], n = T ?? c.find((e) => e.id === s) ?? null, x = n ? [n.first_name, n.last_name].filter(Boolean).join(" ").trim() || n.email : s ? "Selected person" : null, j = (e) => [e.first_name, e.last_name].filter(Boolean).join(" ").trim();
38
+ return /* @__PURE__ */ r(B, { open: l, onOpenChange: p, children: [
39
+ /* @__PURE__ */ r("div", { className: "relative flex h-8 w-full", children: [
40
+ /* @__PURE__ */ t(D, { asChild: !0, children: /* @__PURE__ */ r(
41
+ "button",
42
+ {
43
+ type: "button",
44
+ className: "flex h-full w-full items-center justify-between gap-1.5 rounded-md border border-slate-200 bg-white px-2.5 text-left text-[13px] text-slate-700 hover:border-slate-300",
45
+ children: [
46
+ /* @__PURE__ */ t("span", { className: `flex-1 truncate ${x ? "" : "text-slate-400"}`, children: x ?? "Select a user…" }),
47
+ /* @__PURE__ */ t(Q, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
48
+ ]
49
+ }
50
+ ) }),
51
+ s && /* @__PURE__ */ t(
52
+ "button",
53
+ {
54
+ type: "button",
55
+ onClick: (e) => {
56
+ e.stopPropagation(), d("");
57
+ },
58
+ className: "absolute right-6 top-1/2 -translate-y-1/2 flex h-5 w-5 items-center justify-center rounded text-slate-400 hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-muted dark:hover:text-slate-300",
59
+ children: /* @__PURE__ */ t(S, { className: "h-3 w-3" })
60
+ }
61
+ )
62
+ ] }),
63
+ /* @__PURE__ */ r(U, { align: "start", className: "w-72 p-0", sideOffset: 4, children: [
64
+ /* @__PURE__ */ t("div", { className: "border-b border-slate-100 px-2 py-1.5", children: /* @__PURE__ */ r("div", { className: "relative", children: [
65
+ /* @__PURE__ */ t(_, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400" }),
66
+ /* @__PURE__ */ t(
67
+ "input",
68
+ {
69
+ ref: h,
70
+ value: o,
71
+ onChange: (e) => f(e.target.value),
72
+ placeholder: "Search users…",
73
+ className: "h-7 w-full rounded-md bg-slate-50 pl-7 pr-2 text-[12px] placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-nvr-cyan/40"
74
+ }
75
+ )
76
+ ] }) }),
77
+ /* @__PURE__ */ t("div", { className: "max-h-56 overflow-y-auto py-1", children: C ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 px-3 py-2 text-[12px] text-slate-400", children: [
78
+ /* @__PURE__ */ t($, { className: "h-3.5 w-3.5 animate-spin" }),
79
+ "Loading…"
80
+ ] }) : c.length === 0 ? /* @__PURE__ */ t("div", { className: "px-3 py-2 text-[12px] text-slate-400", children: "No results" }) : c.map((e) => {
81
+ const b = j(e), P = b ? `${b} (${e.email})` : e.email, y = e.id === s;
82
+ return /* @__PURE__ */ r(
83
+ "button",
84
+ {
85
+ type: "button",
86
+ onClick: () => {
87
+ d(e.id), p(!1);
88
+ },
89
+ className: `flex w-full items-center gap-2 px-3 py-1.5 text-left text-[12px] hover:bg-slate-50 ${y ? "font-medium text-slate-800" : "text-slate-600"}`,
90
+ children: [
91
+ /* @__PURE__ */ t(
92
+ q,
93
+ {
94
+ className: `h-3.5 w-3.5 shrink-0 ${y ? "text-nvr-cyan" : "opacity-0"}`
95
+ }
96
+ ),
97
+ P
98
+ ]
99
+ },
100
+ e.id
101
+ );
102
+ }) })
103
+ ] })
104
+ ] });
105
+ }
106
+ export {
107
+ I as AsyncUserPicker
108
+ };