@nivaro/react 0.3.13 → 0.3.14

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 (48) hide show
  1. package/dist/components/slots/pipeline/OwnersSection.js +79 -75
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +33 -2
  5. package/dist/index.js +520 -516
  6. package/dist/shared/components/CollectionBrowserView.js +2373 -2298
  7. package/dist/shared/components/DataTable.js +347 -335
  8. package/dist/shared/components/ItemEditForm.js +5278 -5149
  9. package/dist/shared/components/ListLoadError.js +33 -0
  10. package/dist/shared/components/PageRenderer.js +562 -529
  11. package/dist/shared/components/ProfileView.js +53 -51
  12. package/dist/shared/components/RecordReadView.js +119 -117
  13. package/dist/shared/components/ReportView.js +1268 -1241
  14. package/dist/shared/components/cbv/export-rows.js +69 -0
  15. package/dist/shared/components/cbv/saved-view-risk.js +35 -0
  16. package/dist/shared/components/cbv/unknown-fields.js +18 -0
  17. package/dist/shared/components/integrations/console/AlertsView.js +27 -25
  18. package/dist/shared/components/integrations/console/EventsView.js +244 -209
  19. package/dist/shared/components/item-edit/CatalogPickerField.js +946 -878
  20. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +84 -57
  21. package/dist/shared/components/item-edit/FieldAffordances.js +63 -61
  22. package/dist/shared/components/item-edit/FieldRow.js +195 -179
  23. package/dist/shared/components/item-edit/FilePickerField.js +257 -254
  24. package/dist/shared/components/item-edit/HeaderTools.js +139 -95
  25. package/dist/shared/components/item-edit/InlineTableField.js +2087 -2075
  26. package/dist/shared/components/item-edit/RowComments.js +1 -3
  27. package/dist/shared/components/item-edit/SummaryPanel.js +62 -62
  28. package/dist/shared/components/item-edit/UserChip.js +113 -113
  29. package/dist/shared/components/item-edit/file-download.js +18 -0
  30. package/dist/shared/components/item-edit/line-qty.js +67 -32
  31. package/dist/shared/components/item-edit/save-refusal.js +23 -0
  32. package/dist/shared/components/monitoring/TrafficMiniMap.js +9 -9
  33. package/dist/shared/components/panels/CommentPanel.js +30 -30
  34. package/dist/shared/components/panels/ItemLockBanner.js +207 -185
  35. package/dist/shared/components/panels/PipelinePanel.js +915 -786
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +45 -25
  37. package/dist/shared/components/profile/DelegationCard.js +1 -1
  38. package/dist/shared/components/profile/session-actions.js +24 -24
  39. package/dist/shared/components/queue/QueueItemSheet.js +18 -18
  40. package/dist/shared/components/queue/QueueWorklist.js +517 -504
  41. package/dist/shared/components/ui/dropdown-menu.js +8 -7
  42. package/dist/shared/lib/draft-store.js +60 -33
  43. package/dist/shared/lib/leave-guard.js +38 -0
  44. package/dist/shared/lib/load-error.js +38 -17
  45. package/dist/shared/lib/summary-mode.js +25 -25
  46. package/dist/shared/lib/table-pins.js +23 -0
  47. package/dist/shared/lib/validation-rules.js +55 -51
  48. package/package.json +1 -1
@@ -1,32 +1,32 @@
1
1
  import { jsx as t, jsxs as l } from "react/jsx-runtime";
2
- import { useQuery as j } from "@tanstack/react-query";
2
+ import { useQuery as P } from "@tanstack/react-query";
3
3
  import { UserCheck as S, Mail as U, Phone as q, Building2 as D, User as $, Clock as z, MessageCircle as F, ExternalLink as K, RefreshCw as W, LogOut as H } from "lucide-react";
4
- import R, { useState as P, useRef as N, useEffect as B } from "react";
5
- import { createPortal as Q } from "react-dom";
6
- import { useOptionalNivaroClient as T, useNavigation as Z, useItemEditAuth as J } from "../../context.js";
4
+ import R, { useState as O, useRef as C, useEffect as B } from "react";
5
+ import { createPortal as J } from "react-dom";
6
+ import { useOptionalNivaroClient as T, useNavigation as Q, useItemEditAuth as Z } from "../../context.js";
7
7
  import { get as L, post as V } from "../../lib/commands.js";
8
8
  import { userCardQuery as G } from "../../lib/user-cards.js";
9
- import { cn as _ } from "../../lib/utils.js";
9
+ import { cn as j } from "../../lib/utils.js";
10
10
  import { canOpenDm as X, openDmWith as Y } from "../chat/chat-core.js";
11
11
  import { HuddlePresenceLine as A } from "../chat/huddle/HuddleLiveBadge.js";
12
12
  import { useHuddleLive as I } from "../chat/huddle/huddle-live.js";
13
13
  import { MailSuppressedPill as ee } from "../profile/MailSuppressedPill.js";
14
14
  import { useReloadTheirTabs as te, useSignOutEverywhere as ae } from "../profile/session-actions.js";
15
15
  import { useCardPresence as ne } from "../profile/usePersonPresence.js";
16
- import { UserAvatar as C } from "../UserAvatar.js";
16
+ import { UserAvatar as _ } from "../UserAvatar.js";
17
17
  import { Popover as re, PopoverTrigger as le, PopoverContent as se } from "../ui/popover.js";
18
18
  function E(e, r, i) {
19
- const s = N(r);
19
+ const s = C(r);
20
20
  s.current = r;
21
- const d = N(i);
21
+ const d = C(i);
22
22
  d.current = i, B(() => {
23
23
  if (!e) return;
24
24
  const o = (n) => {
25
- const h = n.target;
26
- h && s.current(h) || d.current();
27
- }, c = () => d.current();
28
- return document.addEventListener("pointerdown", o, !0), window.addEventListener("blur", c), () => {
29
- document.removeEventListener("pointerdown", o, !0), window.removeEventListener("blur", c);
25
+ const f = n.target;
26
+ f && s.current(f) || d.current();
27
+ }, m = () => d.current();
28
+ return document.addEventListener("pointerdown", o, !0), window.addEventListener("blur", m), () => {
29
+ document.removeEventListener("pointerdown", o, !0), window.removeEventListener("blur", m);
30
30
  };
31
31
  }, [e]);
32
32
  }
@@ -34,61 +34,61 @@ function ie({
34
34
  users: e,
35
35
  showSingleName: r = !0
36
36
  }) {
37
- const i = N(null), s = N(null), d = N(null), [o, c] = P(null), [n, h] = P({ x: 0, y: 0 }), b = () => {
37
+ const i = C(null), s = C(null), d = C(null), [o, m] = O(null), [n, f] = O({ x: 0, y: 0 }), g = () => {
38
38
  d.current && clearTimeout(d.current), d.current = null;
39
- }, g = (a) => {
40
- var f;
41
- b();
42
- const p = (f = i.current) == null ? void 0 : f.getBoundingClientRect();
43
- p && h({ x: p.left, y: p.bottom + 6 }), c((x) => x === "pin" ? "pin" : a);
44
- }, k = () => {
45
- b(), d.current = setTimeout(() => c((a) => a === "pin" ? a : null), 160);
39
+ }, u = (a) => {
40
+ var h;
41
+ g();
42
+ const p = (h = i.current) == null ? void 0 : h.getBoundingClientRect();
43
+ p && f({ x: p.left, y: p.bottom + 6 }), m((x) => x === "pin" ? "pin" : a);
44
+ }, y = () => {
45
+ g(), d.current = setTimeout(() => m((a) => a === "pin" ? a : null), 160);
46
46
  };
47
47
  R.useLayoutEffect(() => {
48
- var w;
48
+ var b;
49
49
  if (!o) return;
50
50
  const a = s.current;
51
51
  if (!a) return;
52
52
  const p = a.getBoundingClientRect();
53
- let { x: f, y: x } = n;
54
- if (p.right > window.innerWidth - 8 && (f = Math.max(8, window.innerWidth - p.width - 8)), p.bottom > window.innerHeight - 8) {
55
- const O = (w = i.current) == null ? void 0 : w.getBoundingClientRect();
56
- x = Math.max(8, ((O == null ? void 0 : O.top) ?? x) - p.height - 6);
53
+ let { x: h, y: x } = n;
54
+ if (p.right > window.innerWidth - 8 && (h = Math.max(8, window.innerWidth - p.width - 8)), p.bottom > window.innerHeight - 8) {
55
+ const k = (b = i.current) == null ? void 0 : b.getBoundingClientRect();
56
+ x = Math.max(8, ((k == null ? void 0 : k.top) ?? x) - p.height - 6);
57
57
  }
58
- (f !== n.x || x !== n.y) && h({ x: f, y: x });
58
+ (h !== n.x || x !== n.y) && f({ x: h, y: x });
59
59
  }, [o, n]), E(
60
60
  !!o,
61
61
  (a) => {
62
- var p, f, x;
62
+ var p, h, x;
63
63
  return (
64
64
  // Clicks inside the user-card popover (portaled by Radix) keep the
65
65
  // roster mounted — closing would unmount the card mid-click.
66
- !!((p = a.closest) != null && p.call(a, "[data-radix-popper-content-wrapper]")) || !!((f = s.current) != null && f.contains(a)) || !!((x = i.current) != null && x.contains(a))
66
+ !!((p = a.closest) != null && p.call(a, "[data-radix-popper-content-wrapper]")) || !!((h = s.current) != null && h.contains(a)) || !!((x = i.current) != null && x.contains(a))
67
67
  );
68
68
  },
69
- () => c(null)
69
+ () => m(null)
70
70
  );
71
- const m = (a) => a.split(" ").map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
71
+ const c = (a) => a.split(" ").map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
72
72
  if (e.length === 0)
73
73
  return /* @__PURE__ */ t("span", { className: "text-[11px] text-slate-400", "data-roster-empty": !0, children: "—" });
74
- const u = e.slice(0, 4), v = e.length - u.length, y = "flex h-6 w-6 items-center justify-center rounded-full border-2 border-white bg-[#c7f0fb] text-[10px] font-bold leading-none text-[#04516b] dark:border-slate-900 dark:bg-[#0c3b4a] dark:text-[#7dd8f2]";
74
+ const w = e.slice(0, 4), v = e.length - w.length, N = "flex h-6 w-6 items-center justify-center rounded-full border-2 border-white bg-[#c7f0fb] text-[10px] font-bold leading-none text-[#04516b] dark:border-slate-900 dark:bg-[#0c3b4a] dark:text-[#7dd8f2]";
75
75
  return /* @__PURE__ */ l(
76
76
  "span",
77
77
  {
78
78
  ref: i,
79
- onMouseEnter: () => g("hover"),
80
- onMouseLeave: k,
79
+ onMouseEnter: () => u("hover"),
80
+ onMouseLeave: y,
81
81
  onClick: (a) => {
82
- a.stopPropagation(), g("pin");
82
+ a.stopPropagation(), u("pin");
83
83
  },
84
84
  className: "inline-flex cursor-pointer items-center",
85
85
  children: [
86
- /* @__PURE__ */ t("span", { className: "flex -space-x-2", children: u.map((a) => /* @__PURE__ */ t(
87
- C,
86
+ /* @__PURE__ */ t("span", { className: "flex -space-x-2", children: w.map((a) => /* @__PURE__ */ t(
87
+ _,
88
88
  {
89
89
  userId: a.id,
90
90
  className: "h-6 w-6 border-2 border-white dark:border-slate-900",
91
- fallback: /* @__PURE__ */ t("span", { "data-copy-skip": !0, "aria-hidden": "true", className: y, children: m(a.name) })
91
+ fallback: /* @__PURE__ */ t("span", { "data-copy-skip": !0, "aria-hidden": "true", className: N, children: c(a.name) })
92
92
  },
93
93
  a.id
94
94
  )) }),
@@ -97,16 +97,16 @@ function ie({
97
97
  v
98
98
  ] }),
99
99
  r && e.length === 1 && /* @__PURE__ */ t("span", { className: "ml-1.5 max-w-[130px] truncate text-[12px] font-medium text-slate-700 dark:text-slate-200", children: e[0].name }),
100
- o && Q(
100
+ o && J(
101
101
  /* @__PURE__ */ l(
102
102
  "div",
103
103
  {
104
104
  ref: s,
105
105
  style: oe(i.current, n),
106
- onMouseEnter: b,
107
- onMouseLeave: k,
106
+ onMouseEnter: g,
107
+ onMouseLeave: y,
108
108
  onMouseDown: (a) => {
109
- a.stopPropagation(), c("pin");
109
+ a.stopPropagation(), m("pin");
110
110
  },
111
111
  onClick: (a) => a.stopPropagation(),
112
112
  className: "w-max min-w-[190px] max-w-[300px] rounded-lg border border-slate-200 bg-white py-1.5 shadow-xl dark:border-slate-600 dark:bg-slate-800",
@@ -139,13 +139,13 @@ function Te({
139
139
  collection: e,
140
140
  itemId: r
141
141
  }) {
142
- const i = T(), { data: s = [], isLoading: d } = j({
142
+ const i = T(), { data: s = [], isLoading: d } = P({
143
143
  queryKey: ["pipeline-owners-resolved", e, r],
144
144
  queryFn: () => i.request(
145
145
  V(`/pipelines/instance/${e}/owners/batch`, { ids: [r] })
146
146
  ).then((o) => {
147
- var c;
148
- return ((c = o.data) == null ? void 0 : c[r]) ?? [];
147
+ var m;
148
+ return ((m = o.data) == null ? void 0 : m[r]) ?? [];
149
149
  }),
150
150
  enabled: !!i && !!e && !!r && r !== "new",
151
151
  staleTime: 3e4
@@ -157,12 +157,12 @@ function $e({
157
157
  itemId: r,
158
158
  label: i
159
159
  }) {
160
- const s = T(), { data: d = [] } = j({
160
+ const s = T(), { data: d = [] } = P({
161
161
  queryKey: ["pipeline-instance-owners", e, r],
162
162
  queryFn: () => s.request(L(`/pipelines/instance/${e}/${r}/owners`)).then((n) => n.data ?? []),
163
163
  enabled: !!s && !!e && !!r && r !== "new",
164
164
  staleTime: 3e4
165
- }), o = (n) => [n.first_name, n.last_name].filter(Boolean).join(" ") || n.email, c = (n) => o(n).split(" ").map((h) => h[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
165
+ }), o = (n) => [n.first_name, n.last_name].filter(Boolean).join(" ") || n.email, m = (n) => o(n).split(" ").map((f) => f[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
166
166
  return /* @__PURE__ */ l("div", { children: [
167
167
  /* @__PURE__ */ t("p", { className: "text-[11px] font-medium text-slate-400 mb-1.5", children: i }),
168
168
  d.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[13px] text-slate-400", children: "—" }) : /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: d.map((n) => /* @__PURE__ */ l(
@@ -171,11 +171,11 @@ function $e({
171
171
  className: "flex items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5",
172
172
  children: [
173
173
  /* @__PURE__ */ t(
174
- C,
174
+ _,
175
175
  {
176
176
  userId: n.id,
177
177
  className: "h-6 w-6",
178
- fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-nvr-cyan/15 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: c(n) })
178
+ fallback: /* @__PURE__ */ t("span", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-nvr-cyan/15 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: m(n) })
179
179
  }
180
180
  ),
181
181
  /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-700", children: o(n) })
@@ -192,41 +192,41 @@ function de({
192
192
  navigate: s,
193
193
  profileUrl: d,
194
194
  online: o,
195
- cardId: c,
195
+ cardId: m,
196
196
  onAction: n,
197
- open: h = !1
197
+ open: f = !1
198
198
  }) {
199
- var p;
200
- const { isAdmin: b, userId: g } = J(), k = !!g && g.toUpperCase() === r.toUpperCase(), m = ne(r, h), u = I().roomOf(r), v = ((p = e == null ? void 0 : e.manager_name) == null ? void 0 : p.trim()) || null, y = (() => {
201
- const f = e == null ? void 0 : e.timezone;
202
- if (!f) return null;
199
+ var h;
200
+ const { isAdmin: g, userId: u } = Z(), y = !!u && u.toUpperCase() === r.toUpperCase(), c = ne(r, f), w = I().roomOf(r), v = ((h = e == null ? void 0 : e.manager_name) == null ? void 0 : h.trim()) || null, N = (() => {
201
+ const x = e == null ? void 0 : e.timezone;
202
+ if (!x) return null;
203
203
  try {
204
- const x = Intl.DateTimeFormat().resolvedOptions().timeZone;
205
- return f === x ? null : new Intl.DateTimeFormat(void 0, {
204
+ const b = Intl.DateTimeFormat().resolvedOptions().timeZone;
205
+ return x === b ? null : new Intl.DateTimeFormat(void 0, {
206
206
  hour: "numeric",
207
207
  minute: "2-digit",
208
- timeZone: f
208
+ timeZone: x
209
209
  }).format(/* @__PURE__ */ new Date());
210
210
  } catch {
211
211
  return null;
212
212
  }
213
- })(), a = e != null && e.last_access ? (() => {
214
- const f = Date.now() - new Date(e.last_access).getTime(), x = Math.floor(f / 6e4);
215
- if (x < 2) return "Just now";
216
- if (x < 60) return `${x}m ago`;
217
- const w = Math.floor(x / 60);
218
- return w < 24 ? `${w}h ago` : `${Math.floor(w / 24)}d ago`;
213
+ })(), p = !!o || !!c.word ? c.word ? null : "Just now" : e != null && e.last_access ? (() => {
214
+ const x = Date.now() - new Date(e.last_access).getTime(), b = Math.floor(x / 6e4);
215
+ if (b < 2) return "Just now";
216
+ if (b < 60) return `${b}m ago`;
217
+ const k = Math.floor(b / 60);
218
+ return k < 24 ? `${k}h ago` : `${Math.floor(k / 24)}d ago`;
219
219
  })() : null;
220
220
  return /* @__PURE__ */ l(
221
221
  se,
222
222
  {
223
223
  align: "start",
224
224
  className: "w-72 p-0 overflow-hidden",
225
- "data-nvr-user-card": c ?? "",
225
+ "data-nvr-user-card": m ?? "",
226
226
  children: [
227
227
  /* @__PURE__ */ l("div", { className: "flex items-center gap-3 p-4 bg-gradient-to-br from-nvr-cyan/8 to-nvr-cyan/4 dark:from-nvr-cyan/10 dark:to-transparent border-b border-slate-100 dark:border-border", children: [
228
228
  /* @__PURE__ */ t(
229
- C,
229
+ _,
230
230
  {
231
231
  userId: r,
232
232
  className: "h-12 w-12 ring-2 ring-white shadow-sm dark:ring-card",
@@ -235,15 +235,15 @@ function de({
235
235
  ),
236
236
  /* @__PURE__ */ l("div", { className: "min-w-0 flex-1", children: [
237
237
  /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
238
- (o || m.word) && /* @__PURE__ */ t(
238
+ (o || c.word) && /* @__PURE__ */ t(
239
239
  "span",
240
240
  {
241
- "data-card-presence": m.word ?? "online",
242
- className: _(
241
+ "data-card-presence": c.word ?? "online",
242
+ className: j(
243
243
  "h-2 w-2 shrink-0 rounded-full ring-2 ring-white dark:ring-card",
244
- m.word === "away" ? "bg-white ring-amber-400 dark:bg-card" : m.word === "idle" ? "bg-amber-400" : "bg-emerald-400"
244
+ c.word === "away" ? "bg-white ring-amber-400 dark:bg-card" : c.word === "idle" ? "bg-amber-400" : "bg-emerald-400"
245
245
  ),
246
- title: m.word === "away" ? "Away" : m.word === "idle" ? "Idle" : "Online"
246
+ title: c.word === "away" ? "Away" : c.word === "idle" ? "Idle" : "Online"
247
247
  }
248
248
  ),
249
249
  /* @__PURE__ */ t("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100 truncate", children: e ? [e.first_name, e.last_name].filter(Boolean).join(" ") || e.email : r }),
@@ -256,21 +256,21 @@ function de({
256
256
  )
257
257
  ] }),
258
258
  ((e == null ? void 0 : e.title) || (e == null ? void 0 : e.department)) && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-500 dark:text-slate-400 truncate mt-0.5", children: [e.title, e.department].filter(Boolean).join(" · ") }),
259
- m.word && /* @__PURE__ */ l(
259
+ c.word && /* @__PURE__ */ l(
260
260
  "p",
261
261
  {
262
262
  className: "mt-0.5 truncate text-[11px] text-slate-500 dark:text-slate-400",
263
263
  "data-card-presence-line": !0,
264
264
  children: [
265
- m.word === "away" ? "Away" : m.word === "idle" ? `Idle${m.minutes ? ` · ${m.minutes}m` : ""}` : "Online now",
266
- m.page ? ` · on ${m.page}` : ""
265
+ c.word === "away" ? "Away" : c.word === "idle" ? `Idle${c.minutes ? ` · ${c.minutes}m` : ""}` : "Online now",
266
+ c.page ? ` · on ${c.page}` : ""
267
267
  ]
268
268
  }
269
269
  ),
270
- /* @__PURE__ */ t(A, { label: (u == null ? void 0 : u.label) ?? null, className: "mt-0.5" }),
271
- y && /* @__PURE__ */ l("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: [
270
+ /* @__PURE__ */ t(A, { label: (w == null ? void 0 : w.label) ?? null, className: "mt-0.5" }),
271
+ N && /* @__PURE__ */ l("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-slate-400", children: [
272
272
  "Local time: ",
273
- y
273
+ N
274
274
  ] }),
275
275
  (e == null ? void 0 : e.is_out_of_office) && /* @__PURE__ */ l("span", { className: "mt-1 inline-flex items-center gap-1 rounded-full bg-amber-100 dark:bg-amber-900/30 px-1.5 py-px text-[10px] font-medium text-amber-700 dark:text-amber-400", children: [
276
276
  /* @__PURE__ */ t(S, { className: "h-2.5 w-2.5" }),
@@ -280,8 +280,8 @@ function de({
280
280
  ee,
281
281
  {
282
282
  email: e == null ? void 0 : e.email,
283
- enabled: h,
284
- canClear: b,
283
+ enabled: f,
284
+ canClear: g,
285
285
  className: "mt-1"
286
286
  }
287
287
  )
@@ -311,7 +311,7 @@ function de({
311
311
  }
312
312
  )
313
313
  ] }),
314
- ((e == null ? void 0 : e.role_name) || v || a) && /* @__PURE__ */ l("div", { className: "px-4 py-3 space-y-1.5 border-b border-slate-100 dark:border-border", children: [
314
+ ((e == null ? void 0 : e.role_name) || v || p) && /* @__PURE__ */ l("div", { className: "px-4 py-3 space-y-1.5 border-b border-slate-100 dark:border-border", children: [
315
315
  (e == null ? void 0 : e.role_name) && /* @__PURE__ */ l("div", { className: "flex items-center gap-2 text-[11px] text-slate-500 dark:text-slate-400", children: [
316
316
  /* @__PURE__ */ t(D, { className: "h-3.5 w-3.5 shrink-0" }),
317
317
  /* @__PURE__ */ t("span", { children: e.role_name })
@@ -324,11 +324,11 @@ function de({
324
324
  /* @__PURE__ */ t("span", { className: "font-medium text-slate-600 dark:text-slate-300", children: v })
325
325
  ] })
326
326
  ] }),
327
- a && /* @__PURE__ */ l("div", { className: "flex items-center gap-2 text-[11px] text-slate-400", children: [
327
+ p && /* @__PURE__ */ l("div", { className: "flex items-center gap-2 text-[11px] text-slate-400", children: [
328
328
  /* @__PURE__ */ t(z, { className: "h-3.5 w-3.5 shrink-0" }),
329
329
  /* @__PURE__ */ l("span", { children: [
330
330
  "Last seen ",
331
- a
331
+ p
332
332
  ] })
333
333
  ] })
334
334
  ] }),
@@ -379,7 +379,7 @@ function de({
379
379
  }
380
380
  )
381
381
  ] }),
382
- b && !k && /* @__PURE__ */ t(
382
+ g && !y && /* @__PURE__ */ t(
383
383
  ce,
384
384
  {
385
385
  userId: r,
@@ -396,13 +396,13 @@ function ce({
396
396
  name: r,
397
397
  onDone: i
398
398
  }) {
399
- const [s, d] = P(!1);
399
+ const [s, d] = O(!1);
400
400
  B(() => {
401
401
  if (!s) return;
402
- const h = setTimeout(() => d(!1), 4e3);
403
- return () => clearTimeout(h);
402
+ const f = setTimeout(() => d(!1), 4e3);
403
+ return () => clearTimeout(f);
404
404
  }, [s]);
405
- const o = te(e, { onDone: i }), c = ae(e, r, { onDone: i }), n = "flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-medium transition-colors disabled:opacity-50";
405
+ const o = te(e, { onDone: i }), m = ae(e, r, { onDone: i }), n = "flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-medium transition-colors disabled:opacity-50";
406
406
  return /* @__PURE__ */ l(
407
407
  "div",
408
408
  {
@@ -416,13 +416,13 @@ function ce({
416
416
  disabled: o.isPending,
417
417
  onClick: () => o.mutate({}),
418
418
  "data-tip": "Every tab they have open shows a 15-second countdown, then reloads",
419
- className: _(
419
+ className: j(
420
420
  n,
421
421
  "text-amber-800 hover:bg-amber-50 dark:text-amber-300 dark:hover:bg-amber-500/10"
422
422
  ),
423
423
  "data-user-card-reload": !0,
424
424
  children: [
425
- /* @__PURE__ */ t(W, { className: _("h-3.5 w-3.5", o.isPending && "animate-spin") }),
425
+ /* @__PURE__ */ t(W, { className: j("h-3.5 w-3.5", o.isPending && "animate-spin") }),
426
426
  o.isPending ? "Sending…" : "Reload tabs"
427
427
  ]
428
428
  }
@@ -431,17 +431,17 @@ function ce({
431
431
  "button",
432
432
  {
433
433
  type: "button",
434
- disabled: c.isPending,
435
- onClick: () => s ? c.mutate() : d(!0),
434
+ disabled: m.isPending,
435
+ onClick: () => s ? m.mutate() : d(!0),
436
436
  "data-tip": s ? "Click again to sign them out of every session" : "Ends every session they have, on every app — they can sign in again",
437
- className: _(
437
+ className: j(
438
438
  n,
439
439
  s ? "bg-red-600 text-white hover:bg-red-700" : "text-amber-800 hover:bg-amber-50 dark:text-amber-300 dark:hover:bg-amber-500/10"
440
440
  ),
441
441
  "data-user-card-sign-out": s ? "armed" : "",
442
442
  children: [
443
443
  /* @__PURE__ */ t(H, { className: "h-3.5 w-3.5" }),
444
- c.isPending ? "Signing out…" : s ? "Confirm sign out" : "Sign out"
444
+ m.isPending ? "Signing out…" : s ? "Confirm sign out" : "Sign out"
445
445
  ]
446
446
  }
447
447
  )
@@ -454,34 +454,34 @@ function me({
454
454
  size: r = "default",
455
455
  children: i
456
456
  }) {
457
- const s = T(), { navigate: d, userUrl: o } = Z(), c = o ? o(e) : `/users/${e}`, [n, h] = P(!1), b = R.useId();
457
+ const s = T(), { navigate: d, userUrl: o } = Q(), m = o ? o(e) : `/users/${e}`, [n, f] = O(!1), g = R.useId();
458
458
  E(
459
459
  n,
460
460
  (a) => {
461
- var p, f, x, w;
462
- return !!((p = a.closest) != null && p.call(a, `[data-nvr-user-card="${CSS.escape(b)}"]`)) || !!((f = a.closest) != null && f.call(a, `[data-nvr-user-chip="${CSS.escape(b)}"]`)) || // Anything else floating above the card (a tooltip, a nested menu).
463
- !!((x = a.closest) != null && x.call(a, "[data-radix-popper-content-wrapper]")) && !((w = a.closest) != null && w.call(a, "[data-nvr-user-card]"));
461
+ var p, h, x, b;
462
+ return !!((p = a.closest) != null && p.call(a, `[data-nvr-user-card="${CSS.escape(g)}"]`)) || !!((h = a.closest) != null && h.call(a, `[data-nvr-user-chip="${CSS.escape(g)}"]`)) || // Anything else floating above the card (a tooltip, a nested menu).
463
+ !!((x = a.closest) != null && x.call(a, "[data-radix-popper-content-wrapper]")) && !((b = a.closest) != null && b.call(a, "[data-nvr-user-card]"));
464
464
  },
465
- () => h(!1)
465
+ () => f(!1)
466
466
  );
467
- const { data: g, isLoading: k } = j({
467
+ const { data: u, isLoading: y } = P({
468
468
  ...G(s, e),
469
469
  enabled: !!s && !!e,
470
470
  staleTime: 12e4
471
- }), { data: m } = j({
471
+ }), { data: c } = P({
472
472
  queryKey: ["user-presence", e],
473
473
  queryFn: () => s.request(L(`/presence/users/${e}`)).then((a) => a),
474
474
  enabled: !!s && !!e && n,
475
475
  staleTime: 15e3,
476
476
  refetchInterval: n ? 2e4 : !1
477
- }), u = g ? [g.first_name, g.last_name].filter(Boolean).join(" ") || g.email : e, v = u.split(" ").map((a) => a[0]).filter(Boolean).slice(0, 2).join("").toUpperCase(), y = (m == null ? void 0 : m.online) ?? !1;
478
- return k && !i ? r === "compact" ? /* @__PURE__ */ t("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5", children: [
477
+ }), w = u ? [u.first_name, u.last_name].filter(Boolean).join(" ") || u.email : e, v = w.split(" ").map((a) => a[0]).filter(Boolean).slice(0, 2).join("").toUpperCase(), N = (c == null ? void 0 : c.online) ?? !1;
478
+ return y && !i ? r === "compact" ? /* @__PURE__ */ t("span", { className: "animate-pulse inline-block h-3.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5", children: [
479
479
  /* @__PURE__ */ t("span", { className: "flex h-6 w-6 shrink-0 rounded-full animate-pulse bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))]" }),
480
480
  /* @__PURE__ */ t("span", { className: "animate-pulse h-2.5 w-16 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] inline-block" })
481
- ] }) : /* @__PURE__ */ l(re, { open: n, onOpenChange: h, children: [
482
- /* @__PURE__ */ t(le, { asChild: !0, "data-nvr-user-chip": b, children: i || (r === "compact" ? /* @__PURE__ */ l("span", { className: "inline-flex cursor-pointer items-center gap-1 rounded-full bg-slate-100 dark:bg-slate-800 py-px pl-px pr-1.5 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors", children: [
481
+ ] }) : /* @__PURE__ */ l(re, { open: n, onOpenChange: f, children: [
482
+ /* @__PURE__ */ t(le, { asChild: !0, "data-nvr-user-chip": g, children: i || (r === "compact" ? /* @__PURE__ */ l("span", { className: "inline-flex cursor-pointer items-center gap-1 rounded-full bg-slate-100 dark:bg-slate-800 py-px pl-px pr-1.5 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors", children: [
483
483
  /* @__PURE__ */ t(
484
- C,
484
+ _,
485
485
  {
486
486
  userId: e,
487
487
  className: "h-4 w-4",
@@ -496,10 +496,10 @@ function me({
496
496
  )
497
497
  }
498
498
  ),
499
- /* @__PURE__ */ t("span", { className: "text-[11px] font-medium text-slate-600 dark:text-slate-300", children: u })
499
+ /* @__PURE__ */ t("span", { className: "text-[11px] font-medium text-slate-600 dark:text-slate-300", children: w })
500
500
  ] }) : /* @__PURE__ */ l("div", { className: "inline-flex cursor-pointer items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 py-0.5 pl-0.5 pr-2.5 hover:bg-slate-100 dark:border-border dark:bg-card dark:hover:bg-accent transition-colors", children: [
501
501
  /* @__PURE__ */ t(
502
- C,
502
+ _,
503
503
  {
504
504
  userId: e,
505
505
  className: "h-6 w-6",
@@ -514,19 +514,19 @@ function me({
514
514
  )
515
515
  }
516
516
  ),
517
- /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-700 dark:text-slate-300", children: u })
517
+ /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-700 dark:text-slate-300", children: w })
518
518
  ] })) }),
519
519
  /* @__PURE__ */ t(
520
520
  de,
521
521
  {
522
- user: g,
522
+ user: u,
523
523
  userId: e,
524
524
  initials: v,
525
525
  navigate: d,
526
- profileUrl: c,
527
- online: y,
528
- cardId: b,
529
- onAction: () => h(!1),
526
+ profileUrl: m,
527
+ online: N,
528
+ cardId: g,
529
+ onAction: () => f(!1),
530
530
  open: n
531
531
  }
532
532
  )
@@ -0,0 +1,18 @@
1
+ import { toast as d } from "sonner";
2
+ import { useApiFetchConfig as u } from "../../context.js";
3
+ function f() {
4
+ const o = u(), a = o.authHeaders.Authorization;
5
+ return (c, i) => {
6
+ if (a)
7
+ return (e) => {
8
+ e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || (e.preventDefault(), fetch(c, { headers: o.authHeaders, credentials: o.credentials }).then(async (r) => {
9
+ if (!r.ok) throw new Error(String(r.status));
10
+ const n = URL.createObjectURL(await r.blob()), t = document.createElement("a");
11
+ t.href = n, t.download = i || "download", document.body.appendChild(t), t.click(), t.remove(), setTimeout(() => URL.revokeObjectURL(n), 3e4);
12
+ }).catch(() => d.error("The file could not be downloaded")));
13
+ };
14
+ };
15
+ }
16
+ export {
17
+ f as useFileDownload
18
+ };
@@ -1,13 +1,14 @@
1
- import { evaluateNumeric as c } from "../../lib/expression.js";
2
- const o = {
1
+ import { evaluateNumeric as a } from "../../lib/expression.js";
2
+ import { applyValidationRule as m } from "../../lib/validation-rules.js";
3
+ const f = {
3
4
  tinyint: 255,
4
5
  smallint: 32767,
5
6
  integer: 2147483647,
6
7
  int: 2147483647,
7
8
  bigInteger: Number.MAX_SAFE_INTEGER,
8
9
  bigint: Number.MAX_SAFE_INTEGER
9
- }, f = /* @__PURE__ */ new Set([
10
- ...Object.keys(o),
10
+ }, b = /* @__PURE__ */ new Set([
11
+ ...Object.keys(f),
11
12
  "decimal",
12
13
  "float",
13
14
  "double",
@@ -17,41 +18,75 @@ const o = {
17
18
  "smallmoney",
18
19
  "number"
19
20
  ]);
20
- function m(e) {
21
- return e != null && Object.hasOwn(o, e);
21
+ function c(n) {
22
+ return n != null && Object.hasOwn(f, n);
22
23
  }
23
- function b(e, n = {}) {
24
- const r = n.label ?? "Value";
25
- if (e == null || typeof e == "string" && e.trim() === "")
24
+ function E(n, e = {}) {
25
+ const i = e.label ?? "Value";
26
+ if (n == null || typeof n == "string" && n.trim() === "")
26
27
  return { ok: !0, value: null };
27
- const i = typeof e == "number" ? e : Number(e);
28
- if (Number.isNaN(i)) return { ok: !1, message: `${r} must be a number` };
29
- const t = m(n.type) ? o[n.type] : Number.MAX_SAFE_INTEGER;
30
- return !Number.isFinite(i) || Math.abs(i) > t ? { ok: !1, message: `${r} can't be more than ${t.toLocaleString("en-US")}` } : m(n.type) && !Number.isInteger(i) ? { ok: !1, message: `${r} must be a whole number` } : n.min !== void 0 && i < n.min ? {
28
+ const r = typeof n == "number" ? n : Number(n);
29
+ if (Number.isNaN(r)) return { ok: !1, message: `${i} must be a number` };
30
+ const t = c(e.type) ? f[e.type] : Number.MAX_SAFE_INTEGER;
31
+ return !Number.isFinite(r) || Math.abs(r) > t ? { ok: !1, message: `${i} can't be more than ${t.toLocaleString("en-US")}` } : c(e.type) && !Number.isInteger(r) ? { ok: !1, message: `${i} must be a whole number` } : e.min !== void 0 && r < e.min ? {
31
32
  ok: !1,
32
- message: n.min === 0 ? `${r} can't be negative` : `${r} can't be below ${n.min}`
33
- } : { ok: !0, value: i };
33
+ message: e.min === 0 ? `${i} can't be negative` : `${i} can't be below ${e.min}`
34
+ } : { ok: !0, value: r };
34
35
  }
35
- function g(e, n, r, i = {}) {
36
- const t = { ...e, ...n };
37
- for (const u of r)
38
- e[u] != null && e[u] !== "" && (t[u] = e[u]);
39
- for (const [u, s] of Object.entries(i)) {
40
- const l = c(s, t);
41
- l !== null && (t[u] = l);
36
+ function _(n, e, i, r = {}) {
37
+ const t = { ...n, ...e };
38
+ for (const u of i)
39
+ n[u] != null && n[u] !== "" && (t[u] = n[u]);
40
+ for (const [u, l] of Object.entries(r)) {
41
+ const o = a(l, t);
42
+ o !== null && (t[u] = o);
42
43
  }
43
44
  return t;
44
45
  }
45
- function N(e, n, r) {
46
- const i = {};
47
- for (const [t, u] of Object.entries(e))
48
- r.has(t) && (n && t !== "_change_reason" && String(u ?? "") === String(n[t] ?? "") || (i[t] = u));
49
- return i;
46
+ function p(n, e, i) {
47
+ const r = {};
48
+ for (const [t, u] of Object.entries(n))
49
+ i.has(t) && (e && t !== "_change_reason" && String(u ?? "") === String(e[t] ?? "") || (r[t] = u));
50
+ return r;
51
+ }
52
+ function g(n) {
53
+ let e = n;
54
+ if (typeof e == "string")
55
+ try {
56
+ e = JSON.parse(e);
57
+ } catch {
58
+ return [];
59
+ }
60
+ return Array.isArray(e) ? e.filter((i) => i && typeof i.type == "string") : [];
61
+ }
62
+ function h(n, e, i) {
63
+ const r = [];
64
+ for (const t of n)
65
+ for (const u of g(t.validation_rules)) {
66
+ if (u.soft) continue;
67
+ const l = u.type === "gte_field" || u.type === "lte_field";
68
+ if (!(t.field in e) && !(l && u.field && u.field in e)) continue;
69
+ const o = y(t.type, i[t.field]), s = m(u, o, t.label || t.field, i);
70
+ if (s) {
71
+ r.push({ field: t.field, message: s });
72
+ break;
73
+ }
74
+ }
75
+ return r;
76
+ }
77
+ function y(n, e) {
78
+ if (typeof e != "string" || !b.has(n ?? "")) return e;
79
+ const i = e.trim();
80
+ if (i === "") return e;
81
+ const r = Number(i);
82
+ return Number.isNaN(r) ? e : r;
50
83
  }
51
84
  export {
52
- f as NUMBER_FIELD_TYPES,
53
- N as changedRowFields,
54
- b as checkNumberEntry,
55
- m as isIntegerFieldType,
56
- g as mergePendingQtyRow
85
+ b as NUMBER_FIELD_TYPES,
86
+ p as changedRowFields,
87
+ E as checkNumberEntry,
88
+ c as isIntegerFieldType,
89
+ h as lineRuleErrors,
90
+ _ as mergePendingQtyRow,
91
+ y as ruleValueFor
57
92
  };