@nivaro/react 0.3.64 → 0.3.66

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 (74) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +62 -8
  4. package/dist/shared/components/CollectionBrowserView.js +3127 -3204
  5. package/dist/shared/components/ConformanceView.js +235 -221
  6. package/dist/shared/components/DataTable.js +478 -459
  7. package/dist/shared/components/ItemEditForm.js +4842 -4500
  8. package/dist/shared/components/MyWorkView.js +124 -113
  9. package/dist/shared/components/PageRenderer.js +146 -138
  10. package/dist/shared/components/ProfileView.js +483 -472
  11. package/dist/shared/components/RecordDrilldownSheet.js +73 -65
  12. package/dist/shared/components/ReportView.js +1100 -1094
  13. package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
  14. package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
  15. package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
  16. package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
  17. package/dist/shared/components/bulk/MessageStakeholders.js +235 -0
  18. package/dist/shared/components/bulk/bulk-field-options.js +29 -23
  19. package/dist/shared/components/integrations/IntegrationObligationsView.js +191 -173
  20. package/dist/shared/components/integrations/IntegrationStatusLines.js +101 -85
  21. package/dist/shared/components/integrations/RecordIntegrationPreview.js +11 -9
  22. package/dist/shared/components/integrations/SendCurrentData.js +126 -0
  23. package/dist/shared/components/item-edit/CatalogPickerField.js +1535 -1440
  24. package/dist/shared/components/item-edit/FieldRenderer.js +49 -45
  25. package/dist/shared/components/item-edit/FieldRow.js +413 -403
  26. package/dist/shared/components/item-edit/GroupSection.js +555 -538
  27. package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
  28. package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
  29. package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
  30. package/dist/shared/components/item-edit/NestedRelationEditor.js +171 -163
  31. package/dist/shared/components/item-edit/PlanGrid.js +783 -724
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +291 -224
  33. package/dist/shared/components/item-edit/RecordInsights.js +113 -111
  34. package/dist/shared/components/item-edit/RecordLiveSync.js +4 -1
  35. package/dist/shared/components/item-edit/RelationCombobox.js +398 -364
  36. package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
  37. package/dist/shared/components/item-edit/UserChip.js +264 -229
  38. package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -0
  39. package/dist/shared/components/item-edit/collision-format.js +37 -0
  40. package/dist/shared/components/item-edit/field-a11y.js +25 -0
  41. package/dist/shared/components/item-edit/header-path-preview.js +52 -0
  42. package/dist/shared/components/item-edit/line-merge.js +84 -0
  43. package/dist/shared/components/item-edit/line-midair.js +94 -87
  44. package/dist/shared/components/item-edit/move-guard.js +17 -0
  45. package/dist/shared/components/item-edit/picker-search.js +27 -16
  46. package/dist/shared/components/item-edit/rail-width.js +8 -0
  47. package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
  48. package/dist/shared/components/panels/AccessDeniedPanel.js +96 -55
  49. package/dist/shared/components/panels/CommentPanel.js +142 -136
  50. package/dist/shared/components/panels/ItemLockBanner.js +246 -240
  51. package/dist/shared/components/panels/PipelinePanel.js +1366 -1194
  52. package/dist/shared/components/panels/RevisionsPanel.js +106 -102
  53. package/dist/shared/components/panels/SlaBreachBanner.js +16 -20
  54. package/dist/shared/components/panels/SlaClock.js +90 -68
  55. package/dist/shared/components/queue/QueueItemSheet.js +94 -87
  56. package/dist/shared/components/queue/QueueWorklist.js +1522 -1347
  57. package/dist/shared/components/queue/worklist-csv.js +75 -0
  58. package/dist/shared/components/queue/worklist-helpers.js +20 -0
  59. package/dist/shared/components/widgets/ReviewListWidget.js +226 -207
  60. package/dist/shared/lib/bulk-copy.js +17 -0
  61. package/dist/shared/lib/cbv-export.js +122 -0
  62. package/dist/shared/lib/delete-offer.js +13 -0
  63. package/dist/shared/lib/error-hints.js +1 -0
  64. package/dist/shared/lib/leave-guard.js +41 -26
  65. package/dist/shared/lib/list-link.js +72 -56
  66. package/dist/shared/lib/live-queries.js +32 -30
  67. package/dist/shared/lib/moved-notice.js +25 -0
  68. package/dist/shared/lib/notification-target.js +56 -54
  69. package/dist/shared/lib/obligation-banner.js +11 -8
  70. package/dist/shared/lib/obligation-reason-text.js +6 -6
  71. package/dist/shared/lib/quick-filter-cascade.js +29 -19
  72. package/dist/shared/lib/sort-cycle.js +6 -0
  73. package/dist/shared/lib/summary-mode.js +59 -41
  74. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
1
  import { jsxs as p, jsx as n } from "react/jsx-runtime";
2
- import { useQueryClient as ge, useQuery as k } from "@tanstack/react-query";
3
- import { Loader2 as Pe, Pencil as De, X as Ke } from "lucide-react";
4
- import { useMemo as L, useRef as $e, useEffect as je, useState as T, Fragment as ke } from "react";
5
- import { useNivaroClient as Le } from "../../context.js";
6
- import { get as K, post as Te, patch as Fe, del as Me } from "../../lib/commands.js";
7
- import { titleCase as R, formatNumber as Ae, cn as ue, toLocalDateString as Je } from "../../lib/utils.js";
8
- import { FieldRenderer as fe } from "./FieldRenderer.js";
9
- import { SENTINEL_FIELDS as Ye, EMPTY_NESTED_OPS as O, applyDisplayTemplate as Se } from "./helpers.js";
10
- const Ie = /* @__PURE__ */ new Set([
2
+ import { useQueryClient as Le, useQuery as j } from "@tanstack/react-query";
3
+ import { Loader2 as Ke, Pencil as $e, X as je } from "lucide-react";
4
+ import { useMemo as k, useRef as ke, useEffect as Fe, useState as F, Fragment as Te } from "react";
5
+ import { useNivaroClient as Se } from "../../context.js";
6
+ import { get as L, post as Me, patch as Ae, del as Je } from "../../lib/commands.js";
7
+ import { titleCase as O, cn as me, toLocalDateString as Ye } from "../../lib/utils.js";
8
+ import { FieldRenderer as pe } from "./FieldRenderer.js";
9
+ import { SENTINEL_FIELDS as Ie, EMPTY_NESTED_OPS as C, applyDisplayTemplate as Ue } from "./helpers.js";
10
+ const We = /* @__PURE__ */ new Set([
11
11
  "alias",
12
12
  "o2m",
13
13
  "m2m",
@@ -15,136 +15,137 @@ const Ie = /* @__PURE__ */ new Set([
15
15
  "presentation",
16
16
  "group",
17
17
  "divider"
18
- ]), We = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]);
19
- function ze(o, l) {
20
- return o === l || o == null && l == null ? !0 : o == null || l == null ? !1 : typeof o == "string" && typeof l == "number" || typeof o == "number" && typeof l == "string" ? String(o) === String(l) : JSON.stringify(o) === JSON.stringify(l);
18
+ ]), ze = /* @__PURE__ */ new Set(["__apply_values__", "__create_with_defaults__"]);
19
+ function Be(a, s) {
20
+ return a === s || a == null && s == null ? !0 : a == null || s == null ? !1 : typeof a == "string" && typeof s == "number" || typeof a == "number" && typeof s == "string" ? String(a) === String(s) : JSON.stringify(a) === JSON.stringify(s);
21
21
  }
22
- function me(o) {
22
+ function xe(a) {
23
23
  var x;
24
- const l = o == null ? void 0 : o.response;
25
- if ((x = l == null ? void 0 : l.violations) != null && x.length) {
26
- const q = l.violations.map((b) => b.explanation).filter(Boolean).join("; ");
27
- if (q) return q;
24
+ const s = a == null ? void 0 : a.response;
25
+ if ((x = s == null ? void 0 : s.violations) != null && x.length) {
26
+ const g = s.violations.map((b) => b.explanation).filter(Boolean).join("; ");
27
+ if (g) return g;
28
28
  }
29
- return l != null && l.message ? l.message : l != null && l.error ? l.error : o instanceof Error && o.message ? o.message : "Save failed";
29
+ return s != null && s.message ? s.message : s != null && s.error ? s.error : a instanceof Error && a.message ? a.message : "Save failed";
30
30
  }
31
- function Ue(o) {
32
- if (!Number.isFinite(o)) return o;
33
- const l = Math.round((o + Math.sign(o) * Number.EPSILON) * 100) / 100;
34
- return Object.is(l, -0) ? 0 : l;
31
+ function Ge(a) {
32
+ if (!Number.isFinite(a)) return a;
33
+ const s = Math.round((a + Math.sign(a) * Number.EPSILON) * 100) / 100;
34
+ return Object.is(s, -0) ? 0 : s;
35
35
  }
36
- function Ce({
37
- parentCollection: o,
38
- relationField: l,
36
+ function rt({
37
+ parentCollection: a,
38
+ relationField: s,
39
39
  parentRowId: x,
40
- stagedMembers: q,
40
+ stagedMembers: g,
41
41
  onStagedChange: b,
42
- parentDraft: pe,
43
- hint: g,
44
- readOnly: _ = !1,
45
- outerGridInvalidateKey: C,
46
- deferred: F = !1,
42
+ parentDraft: be,
43
+ hint: w,
44
+ readOnly: v = !1,
45
+ outerGridInvalidateKey: ee,
46
+ deferred: T = !1,
47
47
  onRowsChange: G,
48
- stagedOps: M,
48
+ stagedOps: S,
49
49
  onStagedOpsChange: f,
50
50
  matchCollection: m,
51
- matchQuery: A,
52
- matchSeed: J
51
+ matchQuery: M,
52
+ matchSeed: A
53
53
  }) {
54
- const y = Le(), ee = ge(), { data: Y, isLoading: xe } = k({
55
- queryKey: ["collection-meta", o],
56
- queryFn: () => y.request(K(`/collections/${o}`)).then((e) => {
54
+ var de, ue;
55
+ const y = Se(), te = Le(), { data: J, isLoading: ye } = j({
56
+ queryKey: ["collection-meta", a],
57
+ queryFn: () => y.request(L(`/collections/${a}`)).then((e) => {
57
58
  const t = e.data;
58
59
  return (t == null ? void 0 : t.relations) ?? [];
59
60
  }),
60
61
  staleTime: 10 * 6e4
61
- }), P = L(
62
- () => Y == null ? void 0 : Y.find(
63
- (e) => e.one_collection === o && e.one_field === l
62
+ }), P = k(
63
+ () => J == null ? void 0 : J.find(
64
+ (e) => e.one_collection === a && e.one_field === s
64
65
  ),
65
- [Y, o, l]
66
- ), d = m ?? (P == null ? void 0 : P.many_collection) ?? null, v = m ? null : (P == null ? void 0 : P.many_field) ?? null, { data: S = [] } = k({
66
+ [J, a, s]
67
+ ), d = m ?? (P == null ? void 0 : P.many_collection) ?? null, q = m ? null : (P == null ? void 0 : P.many_field) ?? null, { data: Y = [] } = j({
67
68
  queryKey: ["collection-meta", d],
68
- queryFn: () => y.request(K(`/collections/${d}`)).then((e) => {
69
+ queryFn: () => y.request(L(`/collections/${d}`)).then((e) => {
69
70
  const t = e.data;
70
71
  return (t == null ? void 0 : t.relations) ?? [];
71
72
  }),
72
73
  enabled: !!d,
73
74
  staleTime: 10 * 6e4
74
- }), { data: te = [] } = k({
75
+ }), { data: Q = [] } = j({
75
76
  queryKey: ["field-config", d, null],
76
- queryFn: () => y.request(K(`/field-config/${d}`)).then((e) => e.data ?? []),
77
+ queryFn: () => y.request(L(`/field-config/${d}`)).then((e) => e.data ?? []),
77
78
  enabled: !!d,
78
79
  staleTime: 6e4
79
- }), E = L(
80
- () => te.filter(
81
- (e) => !e.hidden && !Ie.has(e.type) && e.field !== v && !(J && e.field in J) && e.field !== "id" && !Ye.has(e.field) && !We.has(e.group_key ?? "")
80
+ }), E = k(
81
+ () => Q.filter(
82
+ (e) => !e.hidden && !We.has(e.type) && e.field !== q && !(A && e.field in A) && e.field !== "id" && !Ie.has(e.field) && !ze.has(e.group_key ?? "")
82
83
  ),
83
- [te, v]
84
- ), re = m ? ["nested-rows", d, JSON.stringify(A ?? null)] : ["nested-rows", d, v, x], { data: I = [], isLoading: Q } = k({
84
+ [Q, q]
85
+ ), re = m ? ["nested-rows", d, JSON.stringify(M ?? null)] : ["nested-rows", d, q, x], { data: I = [], isLoading: V } = j({
85
86
  queryKey: re,
86
87
  queryFn: () => y.request(
87
- K(`/items/${d}`, {
88
+ L(`/items/${d}`, {
88
89
  filter: JSON.stringify(
89
- m ? A : { [v]: { _eq: x } }
90
+ m ? M : { [q]: { _eq: x } }
90
91
  ),
91
92
  limit: 200
92
93
  })
93
94
  ).then((e) => e.data ?? []),
94
- enabled: m ? !!A : !!d && !!v && x != null,
95
+ enabled: m ? !!M : !!d && !!q && x != null,
95
96
  staleTime: 3e4
96
- }), N = L(() => {
97
+ }), N = k(() => {
97
98
  if (x != null) {
98
- if (F) {
99
- const e = M ?? O, t = new Set(e.deleted), r = new Map(e.updated.map((a) => [a.id, a.changes])), s = I.filter((a) => !t.has(String(a.id))).map((a) => {
100
- const u = r.get(String(a.id));
101
- return { key: String(a.id), data: u ? { ...a, ...u } : a };
102
- }), i = e.created.map((a, u) => ({ key: `created:${u}`, data: a }));
103
- return [...s, ...i];
99
+ if (T) {
100
+ const e = S ?? C, t = new Set(e.deleted), r = new Map(e.updated.map((o) => [o.id, o.changes])), l = I.filter((o) => !t.has(String(o.id))).map((o) => {
101
+ const u = r.get(String(o.id));
102
+ return { key: String(o.id), data: u ? { ...o, ...u } : o };
103
+ }), i = e.created.map((o, u) => ({ key: `created:${u}`, data: o }));
104
+ return [...l, ...i];
104
105
  }
105
106
  return I.map((e) => ({ key: String(e.id), data: e }));
106
107
  }
107
- return (q ?? []).map((e, t) => ({ key: `staged:${t}`, data: e }));
108
- }, [x, I, q, F, M]), ne = $e("");
109
- je(() => {
108
+ return (g ?? []).map((e, t) => ({ key: `staged:${t}`, data: e }));
109
+ }, [x, I, g, T, S]), ne = ke("");
110
+ Fe(() => {
110
111
  if (!G) return;
111
112
  const e = JSON.stringify(N.map((t) => t.data));
112
113
  e !== ne.current && (ne.current = e, G(N.map((t) => t.data)));
113
114
  }, [N, G]);
114
- const [c, V] = T(null), [h, W] = T({}), [be, X] = T(null), [z, ie] = T(!1), [U, w] = T(null);
115
+ const [c, X] = F(null), [h, U] = F({}), [Ne, H] = F(null), [W, ie] = F(!1), [z, _] = F(null);
115
116
  function se(e, t) {
116
- W((r) => ({ ...r, [e]: t })), w(null);
117
+ U((r) => ({ ...r, [e]: t })), _(null);
117
118
  }
118
- function ye() {
119
- _ || (V("new"), W({}), w(null));
119
+ function he() {
120
+ v || (X("new"), U({}), _(null));
120
121
  }
121
122
  function le(e, t) {
122
- _ || (V(e), W({ ...t }), w(null));
123
+ v || (X(e), U({ ...t }), _(null));
123
124
  }
124
125
  function D() {
125
- V(null), W({}), w(null);
126
+ X(null), U({}), _(null);
126
127
  }
127
128
  function ae() {
128
- ee.invalidateQueries({ queryKey: re }), C && ee.invalidateQueries({ queryKey: C });
129
+ te.invalidateQueries({ queryKey: re }), ee && te.invalidateQueries({ queryKey: ee });
129
130
  }
130
131
  async function oe() {
131
132
  if (!c) return;
132
- if (x != null && d && (v || m)) {
133
- const t = new Set(E.map((s) => s.field)), r = Object.fromEntries(
134
- Object.entries(h).filter(([s]) => t.has(s))
133
+ if (x != null && d && (q || m)) {
134
+ const t = new Set(E.map((l) => l.field)), r = Object.fromEntries(
135
+ Object.entries(h).filter(([l]) => t.has(l))
135
136
  );
136
- if (F) {
137
- const s = M ?? O, i = m ? { ...s, collection: m } : s, a = m ? { ...r, ...J ?? {} } : r;
137
+ if (T) {
138
+ const l = S ?? C, i = m ? { ...l, collection: m } : l, o = m ? { ...r, ...A ?? {} } : r;
138
139
  if (c === "new")
139
- f == null || f({ ...i, created: [...i.created, a] });
140
+ f == null || f({ ...i, created: [...i.created, o] });
140
141
  else if (c.startsWith("created:")) {
141
- const u = parseInt(c.slice(8), 10), $ = [...i.created];
142
- $[u] = a, f == null || f({ ...i, created: $ });
142
+ const u = parseInt(c.slice(8), 10), K = [...i.created];
143
+ K[u] = o, f == null || f({ ...i, created: K });
143
144
  } else {
144
- const u = I.find((j) => String(j.id) === c), $ = Object.fromEntries(
145
- Object.entries(r).filter(([j, Ee]) => !ze(Ee, u == null ? void 0 : u[j]))
146
- ), de = i.updated.filter((j) => j.id !== c);
147
- Object.keys($).length > 0 && de.push({ id: c, changes: $ }), f == null || f({ ...i, updated: de });
145
+ const u = I.find(($) => String($.id) === c), K = Object.fromEntries(
146
+ Object.entries(r).filter(([$, De]) => !Be(De, u == null ? void 0 : u[$]))
147
+ ), fe = i.updated.filter(($) => $.id !== c);
148
+ Object.keys(K).length > 0 && fe.push({ id: c, changes: K }), f == null || f({ ...i, updated: fe });
148
149
  }
149
150
  D();
150
151
  return;
@@ -152,19 +153,19 @@ function Ce({
152
153
  ie(!0);
153
154
  try {
154
155
  c === "new" ? await y.request(
155
- Te(`/items/${d}`, {
156
+ Me(`/items/${d}`, {
156
157
  ...r,
157
- ...m ? J ?? {} : { [v]: x }
158
+ ...m ? A ?? {} : { [q]: x }
158
159
  })
159
- ) : await y.request(Fe(`/items/${d}/${c}`, r)), ae(), D();
160
- } catch (s) {
161
- w(me(s));
160
+ ) : await y.request(Ae(`/items/${d}/${c}`, r)), ae(), D();
161
+ } catch (l) {
162
+ _(xe(l));
162
163
  } finally {
163
164
  ie(!1);
164
165
  }
165
166
  return;
166
167
  }
167
- const e = q ?? [];
168
+ const e = g ?? [];
168
169
  if (c === "new")
169
170
  b == null || b([...e, h]);
170
171
  else if (c.startsWith("staged:")) {
@@ -173,52 +174,52 @@ function Ce({
173
174
  }
174
175
  D();
175
176
  }
176
- async function Ne(e) {
177
+ async function _e(e) {
177
178
  if (x != null && d)
178
- if (F) {
179
- const t = M ?? O, r = m ? { ...t, collection: m } : t;
179
+ if (T) {
180
+ const t = S ?? C, r = m ? { ...t, collection: m } : t;
180
181
  if (e.startsWith("created:")) {
181
- const s = parseInt(e.slice(8), 10);
182
- f == null || f({ ...r, created: r.created.filter((i, a) => a !== s) });
182
+ const l = parseInt(e.slice(8), 10);
183
+ f == null || f({ ...r, created: r.created.filter((i, o) => o !== l) });
183
184
  } else
184
185
  f == null || f({
185
186
  ...r,
186
- updated: r.updated.filter((s) => s.id !== e),
187
+ updated: r.updated.filter((l) => l.id !== e),
187
188
  deleted: r.deleted.includes(e) ? r.deleted : [...r.deleted, e]
188
189
  });
189
190
  } else
190
191
  try {
191
- await y.request(Me(`/items/${d}/${e}`)), ae();
192
+ await y.request(Je(`/items/${d}/${e}`)), ae();
192
193
  } catch (t) {
193
- w(me(t));
194
+ _(xe(t));
194
195
  return;
195
196
  }
196
197
  else {
197
198
  const t = parseInt(e.slice(7), 10);
198
- b == null || b((q ?? []).filter((r, s) => s !== t));
199
+ b == null || b((g ?? []).filter((r, l) => l !== t));
199
200
  }
200
- X(null), w(null), c === e && D();
201
+ H(null), _(null), c === e && D();
201
202
  }
202
- const H = L(() => {
203
+ const R = k(() => {
203
204
  const e = /* @__PURE__ */ new Map();
204
205
  for (const t of E) {
205
- const r = S.find(
206
- (s) => s.many_collection === d && s.many_field === t.field && !s.junction_field
206
+ const r = Y.find(
207
+ (l) => l.many_collection === d && l.many_field === t.field && !l.junction_field
207
208
  );
208
209
  r != null && r.one_collection && e.set(t.field, r);
209
210
  }
210
211
  return e;
211
- }, [E, S, d]), Z = L(() => {
212
+ }, [E, Y, d]), Z = k(() => {
212
213
  const e = /* @__PURE__ */ new Map();
213
214
  for (const { key: t, data: r } of N) {
214
- const s = c === t ? h : r;
215
- for (const [i, a] of H) {
216
- const u = s[i];
217
- u == null || u === "" || !a.one_collection || (e.has(a.one_collection) || e.set(a.one_collection, /* @__PURE__ */ new Set()), e.get(a.one_collection).add(String(u)));
215
+ const l = c === t ? h : r;
216
+ for (const [i, o] of R) {
217
+ const u = l[i];
218
+ u == null || u === "" || !o.one_collection || (e.has(o.one_collection) || e.set(o.one_collection, /* @__PURE__ */ new Set()), e.get(o.one_collection).add(String(u)));
218
219
  }
219
220
  }
220
221
  return e;
221
- }, [N, c, h, H]), { data: he = {} } = k({
222
+ }, [N, c, h, R]), { data: we = {} } = j({
222
223
  queryKey: [
223
224
  "nested-m2o-display",
224
225
  d,
@@ -228,13 +229,13 @@ function Ce({
228
229
  const e = {};
229
230
  return await Promise.all(
230
231
  [...Z.entries()].map(async ([t, r]) => {
231
- var a;
232
- const [s, i] = await Promise.all([
232
+ var o;
233
+ const [l, i] = await Promise.all([
233
234
  y.request(
234
- K(`/collections/${t}`)
235
+ L(`/collections/${t}`)
235
236
  ),
236
237
  y.request(
237
- K(`/items/${t}`, {
238
+ L(`/items/${t}`, {
238
239
  filter: JSON.stringify({ id: { _in: [...r] } }),
239
240
  limit: r.size
240
241
  })
@@ -242,8 +243,8 @@ function Ce({
242
243
  ]);
243
244
  e[t] = {};
244
245
  for (const u of i.data ?? [])
245
- e[t][String(u.id)] = Se(
246
- (a = s.data) == null ? void 0 : a.display_template,
246
+ e[t][String(u.id)] = Ue(
247
+ (o = l.data) == null ? void 0 : o.display_template,
247
248
  u
248
249
  );
249
250
  })
@@ -252,52 +253,52 @@ function Ce({
252
253
  enabled: Z.size > 0,
253
254
  staleTime: 6e4
254
255
  });
255
- function we(e, t) {
256
- var s;
256
+ function ve(e, t) {
257
+ var l;
257
258
  if (t == null || t === "")
258
259
  return /* @__PURE__ */ n("span", { className: "text-slate-300", children: "—" });
259
- const r = H.get(e.field);
260
+ const r = R.get(e.field);
260
261
  if (r != null && r.one_collection) {
261
- const i = (s = he[r.one_collection]) == null ? void 0 : s[String(t)];
262
+ const i = (l = we[r.one_collection]) == null ? void 0 : l[String(t)];
262
263
  return /* @__PURE__ */ n("span", { className: "block truncate", children: i ?? String(t) });
263
264
  }
264
265
  if (e.type === "boolean")
265
266
  return /* @__PURE__ */ n("span", { className: t ? "text-emerald-600" : "text-slate-400", children: t ? "Yes" : "No" });
266
267
  if (e.type === "datetime" || e.type === "date")
267
268
  try {
268
- return /* @__PURE__ */ n("span", { className: "block truncate", children: Je(t) });
269
+ return /* @__PURE__ */ n("span", { className: "block truncate", children: Ye(t) });
269
270
  } catch {
270
271
  }
271
272
  return /* @__PURE__ */ n("span", { className: "block truncate", children: String(t) });
272
273
  }
273
- const _e = g && Number(pe[g.cap_field]) || 0, ve = g ? N.reduce(
274
+ const qe = w && Number(be[w.cap_field]) || 0, ge = w ? N.reduce(
274
275
  (e, t) => {
275
276
  const r = c === t.key ? h : t.data;
276
- return e + (Number(r[g.sum_field]) || 0);
277
+ return e + (Number(r[w.sum_field]) || 0);
277
278
  },
278
- c === "new" && Number(h[g.sum_field]) || 0
279
- ) : 0, ce = Ue(_e - ve);
280
- if (xe && !m || !d || !v && !m) return null;
281
- if (m && !A)
279
+ c === "new" && Number(h[w.sum_field]) || 0
280
+ ) : 0, ce = Ge(qe - ge), Ee = w ? ((ue = (de = Q.find((e) => e.field === w.sum_field)) == null ? void 0 : de.options) == null ? void 0 : ue.format) === "currency" : !1;
281
+ if (ye && !m || !d || !q && !m) return null;
282
+ if (m && !M)
282
283
  return /* @__PURE__ */ p("p", { className: "rounded-md border border-slate-200 bg-slate-50 px-2 py-1.5 text-[11px] text-slate-400", children: [
283
- R(l),
284
+ O(s),
284
285
  " — available after this row is saved."
285
286
  ] });
286
- const qe = _ ? 0 : 1, B = E.length + qe;
287
+ const Pe = v ? 0 : 1, B = E.length + Pe;
287
288
  return /* @__PURE__ */ p("div", { className: "overflow-hidden rounded-md border border-slate-200", children: [
288
289
  /* @__PURE__ */ p("div", { className: "flex items-center gap-2 px-2 py-1 bg-slate-50 border-b border-slate-200", children: [
289
- /* @__PURE__ */ n("span", { className: "text-[10px] font-medium text-slate-400 uppercase tracking-wide", children: R(l) }),
290
+ /* @__PURE__ */ n("span", { className: "text-[10px] font-medium text-slate-400 uppercase tracking-wide", children: O(s) }),
290
291
  /* @__PURE__ */ n("span", { className: "rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-500", children: N.length }),
291
- g && /* @__PURE__ */ p(
292
+ w && /* @__PURE__ */ p(
292
293
  "span",
293
294
  {
294
- className: ue(
295
+ className: me(
295
296
  "ml-auto text-[11px] font-medium",
296
297
  ce < 0 ? "text-red-600" : "text-slate-500"
297
298
  ),
298
299
  children: [
299
300
  "remaining: ",
300
- Ae(ce)
301
+ Qe(ce, Ee)
301
302
  ]
302
303
  }
303
304
  )
@@ -308,49 +309,49 @@ function Ce({
308
309
  "th",
309
310
  {
310
311
  className: "px-2 py-1.5 text-left font-medium text-slate-500 text-[11px]",
311
- children: e.label ?? R(e.field)
312
+ children: e.label ?? O(e.field)
312
313
  },
313
314
  e.field
314
315
  )),
315
- !_ && /* @__PURE__ */ n("th", { className: "w-16" })
316
+ !v && /* @__PURE__ */ n("th", { className: "w-16" })
316
317
  ] }) }),
317
318
  /* @__PURE__ */ p("tbody", { children: [
318
- Q && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: B, className: "px-2 py-3 text-center text-slate-400", children: /* @__PURE__ */ n(Pe, { className: "h-3.5 w-3.5 animate-spin inline" }) }) }),
319
- !Q && N.map(({ key: e, data: t }) => {
320
- const r = c === e, s = be === e;
321
- return /* @__PURE__ */ p(ke, { children: [
319
+ V && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: B, className: "px-2 py-3 text-center text-slate-400", children: /* @__PURE__ */ n(Ke, { className: "h-3.5 w-3.5 animate-spin inline" }) }) }),
320
+ !V && N.map(({ key: e, data: t }) => {
321
+ const r = c === e, l = Ne === e;
322
+ return /* @__PURE__ */ p(Te, { children: [
322
323
  /* @__PURE__ */ p(
323
324
  "tr",
324
325
  {
325
- onClick: () => !r && !_ && le(e, t),
326
- className: ue(
326
+ onClick: () => !r && !v && le(e, t),
327
+ className: me(
327
328
  "border-b border-slate-100 transition-colors",
328
329
  r ? "bg-[#f0fbff] dark:bg-nvr-cyan/5 cursor-default" : "bg-white hover:bg-slate-50/80",
329
- !r && !_ ? "cursor-pointer" : ""
330
+ !r && !v ? "cursor-pointer" : ""
330
331
  ),
331
332
  children: [
332
333
  E.map((i) => /* @__PURE__ */ n("td", { className: "px-2 py-1 align-top", children: r ? /* @__PURE__ */ n(
333
- fe,
334
+ pe,
334
335
  {
335
336
  field: i,
336
337
  value: h[i.field] ?? null,
337
- onChange: (a) => se(i.field, a),
338
- relations: S,
338
+ onChange: (o) => se(i.field, o),
339
+ relations: Y,
339
340
  collection: d,
340
341
  itemId: x != null ? e : "new"
341
342
  }
342
- ) : /* @__PURE__ */ n("div", { className: "py-0.5 overflow-hidden", children: we(i, t[i.field]) }) }, i.field)),
343
- !_ && /* @__PURE__ */ n("td", { className: "px-1 py-1 align-middle", children: r ? /* @__PURE__ */ p("div", { className: "flex items-stretch gap-1", children: [
343
+ ) : /* @__PURE__ */ n("div", { className: "py-0.5 overflow-hidden", children: ve(i, t[i.field]) }) }, i.field)),
344
+ !v && /* @__PURE__ */ n("td", { className: "px-1 py-1 align-middle", children: r ? /* @__PURE__ */ p("div", { className: "flex items-stretch gap-1", children: [
344
345
  /* @__PURE__ */ n(
345
346
  "button",
346
347
  {
347
348
  type: "button",
348
- disabled: z,
349
+ disabled: W,
349
350
  onClick: (i) => {
350
351
  i.stopPropagation(), oe();
351
352
  },
352
353
  className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
353
- children: z ? "…" : "Save"
354
+ children: W ? "…" : "Save"
354
355
  }
355
356
  ),
356
357
  /* @__PURE__ */ n(
@@ -364,14 +365,14 @@ function Ce({
364
365
  children: "✕"
365
366
  }
366
367
  )
367
- ] }) : s ? /* @__PURE__ */ p("div", { className: "flex items-center justify-end gap-1", children: [
368
+ ] }) : l ? /* @__PURE__ */ p("div", { className: "flex items-center justify-end gap-1", children: [
368
369
  /* @__PURE__ */ n("span", { className: "text-[10px] text-slate-400", children: "Delete?" }),
369
370
  /* @__PURE__ */ n(
370
371
  "button",
371
372
  {
372
373
  type: "button",
373
374
  onClick: (i) => {
374
- i.stopPropagation(), Ne(e);
375
+ i.stopPropagation(), _e(e);
375
376
  },
376
377
  className: "rounded px-1.5 py-0.5 text-[10px] text-red-500 hover:text-red-700 border border-red-200 hover:border-red-400",
377
378
  children: "Yes"
@@ -382,7 +383,7 @@ function Ce({
382
383
  {
383
384
  type: "button",
384
385
  onClick: (i) => {
385
- i.stopPropagation(), X(null), w(null);
386
+ i.stopPropagation(), H(null), _(null);
386
387
  },
387
388
  className: "rounded px-1.5 py-0.5 text-[10px] text-slate-400 hover:text-slate-700 border border-slate-200",
388
389
  children: "Cancel"
@@ -397,7 +398,7 @@ function Ce({
397
398
  i.stopPropagation(), le(e, t);
398
399
  },
399
400
  className: "rounded p-0.5 text-slate-300 hover:text-nvr-cyan",
400
- children: /* @__PURE__ */ n(De, { className: "h-3 w-3" })
401
+ children: /* @__PURE__ */ n($e, { className: "h-3 w-3" })
401
402
  }
402
403
  ),
403
404
  /* @__PURE__ */ n(
@@ -405,27 +406,27 @@ function Ce({
405
406
  {
406
407
  type: "button",
407
408
  onClick: (i) => {
408
- i.stopPropagation(), X(e), w(null);
409
+ i.stopPropagation(), H(e), _(null);
409
410
  },
410
411
  className: "rounded p-0.5 text-slate-300 hover:text-red-500",
411
- children: /* @__PURE__ */ n(Ke, { className: "h-3 w-3" })
412
+ children: /* @__PURE__ */ n(je, { className: "h-3 w-3" })
412
413
  }
413
414
  )
414
415
  ] }) })
415
416
  ]
416
417
  }
417
418
  ),
418
- (r || s) && U && /* @__PURE__ */ n("tr", { className: "border-b border-slate-100 bg-red-50/50", children: /* @__PURE__ */ n("td", { colSpan: B, className: "px-2 py-1 text-[11px] text-red-600", children: U }) })
419
+ (r || l) && z && /* @__PURE__ */ n("tr", { className: "border-b border-slate-100 bg-red-50/50", children: /* @__PURE__ */ n("td", { colSpan: B, className: "px-2 py-1 text-[11px] text-red-600", children: z }) })
419
420
  ] }, e);
420
421
  }),
421
422
  c === "new" && /* @__PURE__ */ p("tr", { className: "border-b border-slate-100 bg-[#f0fbff] dark:bg-nvr-cyan/5", children: [
422
423
  E.map((e) => /* @__PURE__ */ n("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ n(
423
- fe,
424
+ pe,
424
425
  {
425
426
  field: e,
426
427
  value: h[e.field] ?? null,
427
428
  onChange: (t) => se(e.field, t),
428
- relations: S,
429
+ relations: Y,
429
430
  collection: d,
430
431
  itemId: "new"
431
432
  }
@@ -435,10 +436,10 @@ function Ce({
435
436
  "button",
436
437
  {
437
438
  type: "button",
438
- disabled: z,
439
+ disabled: W,
439
440
  onClick: oe,
440
441
  className: "rounded px-2 h-7 bg-nvr-cyan text-white text-[10px] font-medium hover:brightness-110 disabled:opacity-50",
441
- children: z ? "…" : "Add"
442
+ children: W ? "…" : "Add"
442
443
  }
443
444
  ),
444
445
  /* @__PURE__ */ n(
@@ -452,8 +453,8 @@ function Ce({
452
453
  )
453
454
  ] }) })
454
455
  ] }),
455
- c === "new" && U && /* @__PURE__ */ n("tr", { className: "border-b border-slate-100 bg-red-50/50", children: /* @__PURE__ */ n("td", { colSpan: B, className: "px-2 py-1 text-[11px] text-red-600", children: U }) }),
456
- !Q && N.length === 0 && c !== "new" && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
456
+ c === "new" && z && /* @__PURE__ */ n("tr", { className: "border-b border-slate-100 bg-red-50/50", children: /* @__PURE__ */ n("td", { colSpan: B, className: "px-2 py-1 text-[11px] text-red-600", children: z }) }),
457
+ !V && N.length === 0 && c !== "new" && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
457
458
  "td",
458
459
  {
459
460
  colSpan: B,
@@ -463,18 +464,25 @@ function Ce({
463
464
  ) })
464
465
  ] })
465
466
  ] }),
466
- !_ && c !== "new" && /* @__PURE__ */ n("div", { className: "px-2 py-1 bg-slate-50/50 border-t border-slate-200", children: /* @__PURE__ */ n(
467
+ !v && c !== "new" && /* @__PURE__ */ n("div", { className: "px-2 py-1 bg-slate-50/50 border-t border-slate-200", children: /* @__PURE__ */ n(
467
468
  "button",
468
469
  {
469
470
  type: "button",
470
- onClick: ye,
471
+ onClick: he,
471
472
  className: "text-[11px] text-nvr-cyan font-medium hover:underline",
472
473
  children: "+ Add row"
473
474
  }
474
475
  ) })
475
476
  ] });
476
477
  }
478
+ function Qe(a, s) {
479
+ return s ? a.toLocaleString("en-US", { style: "currency", currency: "USD" }) : a.toLocaleString("en-US", {
480
+ minimumFractionDigits: Number.isInteger(a) ? 0 : 2,
481
+ maximumFractionDigits: 2
482
+ });
483
+ }
477
484
  export {
478
- Ce as NestedRelationEditor,
479
- Ue as roundCents
485
+ rt as NestedRelationEditor,
486
+ Qe as formatRemaining,
487
+ Ge as roundCents
480
488
  };