@nivaro/react 0.3.8 → 0.3.10

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 (60) hide show
  1. package/dist/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/replayUploadQueue.js +107 -93
  4. package/dist/hooks/useNivaroForm.js +129 -126
  5. package/dist/hooks/useSessionRecorder.js +103 -101
  6. package/dist/index.d.ts +115 -2
  7. package/dist/index.js +466 -447
  8. package/dist/shared/components/CollectionBrowserView.js +1058 -1059
  9. package/dist/shared/components/ConformanceView.js +36 -35
  10. package/dist/shared/components/DataTable.js +230 -223
  11. package/dist/shared/components/ForceReloadBanner.js +58 -34
  12. package/dist/shared/components/ItemEditForm.js +3687 -3580
  13. package/dist/shared/components/JsonMapEditor.js +18 -17
  14. package/dist/shared/components/MatrixEditor.js +8 -7
  15. package/dist/shared/components/MyWorkView.js +32 -31
  16. package/dist/shared/components/PageRenderer.js +146 -145
  17. package/dist/shared/components/QueryTable.js +49 -49
  18. package/dist/shared/components/RecordGridEditor.js +76 -75
  19. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  20. package/dist/shared/components/ai/AskPanel.js +55 -54
  21. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  22. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  23. package/dist/shared/components/chat/ChatPanel.js +288 -287
  24. package/dist/shared/components/chat/SlashCommands.js +30 -29
  25. package/dist/shared/components/chat/chat-outbox.js +76 -75
  26. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  27. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  28. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  29. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  30. package/dist/shared/components/item-edit/InlineTableField.js +301 -300
  31. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  33. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  34. package/dist/shared/components/item-edit/staged-links.js +86 -0
  35. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  36. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  37. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  38. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  39. package/dist/shared/components/panels/CommentPanel.js +237 -236
  40. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  41. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  42. package/dist/shared/components/profile/usePersonPresence.js +42 -37
  43. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  44. package/dist/shared/components/queue/QueueWorklist.js +597 -598
  45. package/dist/shared/lib/client-version.js +63 -0
  46. package/dist/shared/lib/force-reload.js +36 -0
  47. package/dist/shared/lib/load-error.js +11 -10
  48. package/dist/shared/lib/presence-live.js +73 -0
  49. package/dist/shared/lib/presence-state.js +39 -31
  50. package/dist/shared/lib/record-outbox.js +76 -75
  51. package/dist/shared/lib/request-gate.js +120 -102
  52. package/dist/shared/lib/rum.js +45 -36
  53. package/dist/shared/lib/safe-error.js +39 -0
  54. package/dist/shared/lib/server-clock.js +11 -7
  55. package/dist/shared/lib/signed-out.js +114 -0
  56. package/dist/shared/lib/socket-realtime.js +19 -17
  57. package/dist/shared/lib/unsaved-work.js +62 -0
  58. package/dist/shared/lib/use-online-users.js +11 -10
  59. package/dist/shared/lib/worker-socket.js +89 -79
  60. package/package.json +1 -1
@@ -1,21 +1,22 @@
1
1
  import { jsx as t, jsxs as p, Fragment as Q } from "react/jsx-runtime";
2
- import { useQuery as D, useQueryClient as We } from "@tanstack/react-query";
3
- import { useState as j, useEffect as Z, useRef as ee, useMemo as Oe, useCallback as Te } from "react";
4
- import { createPortal as Me } from "react-dom";
5
- import { useNivaroClient as z, useDrilldown as ye, useOverlayState as Ae, DrilldownContext as Pe, useItemNavigation as Fe } from "../context.js";
2
+ import { useQuery as D, useQueryClient as Oe } from "@tanstack/react-query";
3
+ import { useState as j, useEffect as Z, useRef as ee, useMemo as Te, useCallback as Me } from "react";
4
+ import { createPortal as Ae } from "react-dom";
5
+ import { useNivaroClient as z, useDrilldown as ye, useOverlayState as Pe, DrilldownContext as Fe, useItemNavigation as Be } from "../context.js";
6
6
  import { get as ve, post as V } from "../lib/commands.js";
7
7
  import { initialFilterSelection as Ee } from "../lib/query-filter-seed.js";
8
- import { resolveSheetDef as Be } from "../lib/sheet-def.js";
9
- import { useMyScopes as Le, matchScopeDimension as fe, effectiveScopeSeedIds as Ie, translateScopeValues as Qe } from "../lib/use-my-scopes.js";
10
- import { titleCase as E, formatRelative as De, formatNumber as ze } from "../lib/utils.js";
11
- import { CacheStamp as Ke } from "./CacheStamp.js";
12
- import { RelationCombobox as Ge } from "./item-edit/RelationCombobox.js";
8
+ import { userErrorMessage as ke } from "../lib/safe-error.js";
9
+ import { resolveSheetDef as Le } from "../lib/sheet-def.js";
10
+ import { useMyScopes as Ie, matchScopeDimension as fe, effectiveScopeSeedIds as Qe, translateScopeValues as De } from "../lib/use-my-scopes.js";
11
+ import { titleCase as B, formatRelative as ze, formatNumber as Ke } from "../lib/utils.js";
12
+ import { CacheStamp as Ge } from "./CacheStamp.js";
13
+ import { RelationCombobox as Ve } from "./item-edit/RelationCombobox.js";
13
14
  import { MatrixEditor as te } from "./MatrixEditor.js";
14
- import { QueryStatStrip as Ve } from "./QueryStatStrip.js";
15
- import { QueryTable as He } from "./QueryTable.js";
16
- import { RecordDrilldownSheet as Ue } from "./RecordDrilldownSheet.js";
15
+ import { QueryStatStrip as He } from "./QueryStatStrip.js";
16
+ import { QueryTable as Ue } from "./QueryTable.js";
17
+ import { RecordDrilldownSheet as Ye } from "./RecordDrilldownSheet.js";
17
18
  import { RecordGridEditor as be } from "./RecordGridEditor.js";
18
- import { SheetHeaderBody as Ye } from "./SheetHeaderBody.js";
19
+ import { SheetHeaderBody as Je } from "./SheetHeaderBody.js";
19
20
  const J = 76;
20
21
  function H() {
21
22
  return /* @__PURE__ */ t("div", { className: "space-y-1.5 p-3", children: [1, 2, 3].map((e) => /* @__PURE__ */ t(
@@ -27,10 +28,10 @@ function H() {
27
28
  )) });
28
29
  }
29
30
  function U({ error: e }) {
30
- const r = e instanceof Error ? e.message : "Failed to load widget data";
31
+ const r = ke(e, "Failed to load widget data");
31
32
  return /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center p-3 text-[12px] text-amber-600 dark:text-amber-500", children: r });
32
33
  }
33
- function Je(e) {
34
+ function Xe(e) {
34
35
  if (e == null) return "—";
35
36
  if (typeof e == "boolean") return e ? "true" : "false";
36
37
  const r = String(e);
@@ -64,7 +65,7 @@ function X(e, r) {
64
65
  }
65
66
  }), l;
66
67
  }
67
- function Xe({ content: e }) {
68
+ function Ze({ content: e }) {
68
69
  const r = [];
69
70
  let l = [], n = [], s = !1;
70
71
  const m = (a) => {
@@ -104,9 +105,9 @@ function re(e, r, l) {
104
105
  staleTime: 3e4
105
106
  });
106
107
  }
107
- function Ze({ slug: e, widget: r }) {
108
+ function et({ slug: e, widget: r }) {
108
109
  var u;
109
- const l = r.config ?? {}, { data: n, isLoading: s, error: m } = re(e, r, !!l.collection), i = Fe();
110
+ const l = r.config ?? {}, { data: n, isLoading: s, error: m } = re(e, r, !!l.collection), i = Be();
110
111
  if (!l.collection)
111
112
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
112
113
  if (s) return /* @__PURE__ */ t(H, {});
@@ -122,7 +123,7 @@ function Ze({ slug: e, widget: r }) {
122
123
  "th",
123
124
  {
124
125
  className: "whitespace-nowrap px-3 py-1.5 text-left font-medium text-slate-400",
125
- children: E(x)
126
+ children: B(x)
126
127
  },
127
128
  x
128
129
  )) }) }),
@@ -135,7 +136,7 @@ function Ze({ slug: e, widget: r }) {
135
136
  "td",
136
137
  {
137
138
  className: "whitespace-nowrap px-3 py-1.5 text-slate-700 dark:text-slate-300",
138
- children: Je(x[w])
139
+ children: Xe(x[w])
139
140
  },
140
141
  w
141
142
  ))
@@ -144,14 +145,14 @@ function Ze({ slug: e, widget: r }) {
144
145
  )) })
145
146
  ] }) });
146
147
  }
147
- function et({ slug: e, widget: r }) {
148
+ function tt({ slug: e, widget: r }) {
148
149
  const l = r.config ?? {}, { data: n, isLoading: s, error: m } = re(e, r, !!l.collection);
149
150
  return l.collection ? m ? /* @__PURE__ */ t(U, { error: m }) : /* @__PURE__ */ p("div", { className: "flex h-full flex-col items-start justify-center px-4", children: [
150
- s ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (n == null ? void 0 : n.value) != null ? ze(Number(n.value)) : "—" }),
151
+ s ? /* @__PURE__ */ t("div", { className: "h-9 w-24 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : /* @__PURE__ */ t("span", { className: "text-[32px] font-semibold leading-none tracking-tight text-slate-900 dark:text-slate-100", children: (n == null ? void 0 : n.value) != null ? Ke(Number(n.value)) : "—" }),
151
152
  /* @__PURE__ */ t("span", { className: "mt-1.5 text-[12px] text-slate-400", children: l.label || `${l.aggregate ?? "count"} of ${l.collection}` })
152
153
  ] }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Select a collection" });
153
154
  }
154
- function tt({ slug: e, widget: r }) {
155
+ function rt({ slug: e, widget: r }) {
155
156
  const { data: l, isLoading: n, error: s } = re(e, r, !0);
156
157
  if (n) return /* @__PURE__ */ t(H, {});
157
158
  if (s) return /* @__PURE__ */ t(U, { error: s });
@@ -166,13 +167,13 @@ function tt({ slug: e, widget: r }) {
166
167
  i.collection,
167
168
  i.item ? ` · ${i.item}` : ""
168
169
  ] }),
169
- /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: De(i.timestamp) })
170
+ /* @__PURE__ */ t("span", { className: "ml-auto shrink-0 text-[11px] text-slate-400", children: ze(i.timestamp) })
170
171
  ]
171
172
  },
172
173
  i.id
173
174
  )) }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "No activity" });
174
175
  }
175
- function rt({ widget: e }) {
176
+ function lt({ widget: e }) {
176
177
  var l;
177
178
  const r = String(((l = e.config) == null ? void 0 : l.url) ?? "");
178
179
  return r ? /^https?:\/\//i.test(r) ? /* @__PURE__ */ t(
@@ -185,7 +186,7 @@ function rt({ widget: e }) {
185
186
  }
186
187
  ) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-amber-600", children: "URL must start with http(s)://" }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set an iframe URL" });
187
188
  }
188
- function ke({
189
+ function Ne({
189
190
  config: e,
190
191
  initialScope: r,
191
192
  width: l,
@@ -217,7 +218,7 @@ function ke({
217
218
  }
218
219
  ) });
219
220
  }
220
- function lt({ widget: e }) {
221
+ function at({ widget: e }) {
221
222
  const r = e.config ?? {}, [l, n] = j(!1);
222
223
  return !r.target_collection || !r.option_collection || !r.key_field || !r.value_field ? /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Matrix editor not configured" }) : r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
223
224
  /* @__PURE__ */ t(
@@ -230,7 +231,7 @@ function lt({ widget: e }) {
230
231
  }
231
232
  ),
232
233
  l && /* @__PURE__ */ t(
233
- ke,
234
+ Ne,
234
235
  {
235
236
  config: r,
236
237
  width: r.sheet_width,
@@ -239,13 +240,13 @@ function lt({ widget: e }) {
239
240
  )
240
241
  ] }) : /* @__PURE__ */ t(te, { config: r });
241
242
  }
242
- function at(e) {
243
+ function nt(e) {
243
244
  return Ee(
244
245
  e,
245
246
  typeof window > "u" ? "" : window.location.search
246
247
  );
247
248
  }
248
- function Ne(e, r, l, n, s, m) {
249
+ function we(e, r, l, n, s, m) {
249
250
  if (typeof e != "string") return e;
250
251
  if (e.startsWith("$row.")) return r == null ? void 0 : r[e.slice(5)];
251
252
  if (e.startsWith("$rows.")) {
@@ -259,15 +260,15 @@ function Ne(e, r, l, n, s, m) {
259
260
  }
260
261
  return e;
261
262
  }
262
- function nt(e, r, l, n, s, m) {
263
+ function st(e, r, l, n, s, m) {
263
264
  const i = {};
264
265
  for (const [a, d] of Object.entries(e.params ?? {})) {
265
- const u = Ne(d, r, l, n, s, m);
266
+ const u = we(d, r, l, n, s, m);
266
267
  u !== void 0 && (i[a] = u);
267
268
  }
268
269
  return { ...e, params: i };
269
270
  }
270
- function st({
271
+ function it({
271
272
  config: e,
272
273
  stats: r,
273
274
  asOf: l
@@ -286,7 +287,7 @@ function st({
286
287
  className: "shrink-0 border-b border-slate-200 bg-white px-4 py-3 dark:border-border dark:bg-card",
287
288
  "data-sheet-header": !0,
288
289
  children: /* @__PURE__ */ t(
289
- Ye,
290
+ Je,
290
291
  {
291
292
  stats: r,
292
293
  rows: (m == null ? void 0 : m.data) ?? [],
@@ -299,7 +300,7 @@ function st({
299
300
  }
300
301
  );
301
302
  }
302
- function it({
303
+ function ot({
303
304
  def: e,
304
305
  row: r,
305
306
  onClose: l
@@ -339,7 +340,7 @@ function it({
339
340
  }
340
341
  )
341
342
  ] }),
342
- e.header && /* @__PURE__ */ t(st, { config: e.header.config, stats: e.header.stats, asOf: e.header.asOf }),
343
+ e.header && /* @__PURE__ */ t(it, { config: e.header.config, stats: e.header.stats, asOf: e.header.asOf }),
343
344
  /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: a != null && a.matrix ? /* @__PURE__ */ t(
344
345
  te,
345
346
  {
@@ -348,12 +349,12 @@ function it({
348
349
  lockScope: !0
349
350
  },
350
351
  n
351
- ) : a != null && a.config ? /* @__PURE__ */ t(we, { config: a.config }, n) : /* @__PURE__ */ t("p", { className: "p-4 text-[12px] text-slate-400", children: "Sheet not configured" }) })
352
+ ) : a != null && a.config ? /* @__PURE__ */ t($e, { config: a.config }, n) : /* @__PURE__ */ t("p", { className: "p-4 text-[12px] text-slate-400", children: "Sheet not configured" }) })
352
353
  ]
353
354
  }
354
355
  ) });
355
356
  }
356
- function ot(e, r, l, n) {
357
+ function dt(e, r, l, n) {
357
358
  if (!e) return;
358
359
  const s = (d) => {
359
360
  const u = /^\$filters\.(\w+)(?:\.(\w+))?$/.exec(d);
@@ -367,7 +368,7 @@ function ot(e, r, l, n) {
367
368
  ) : d, i = (d) => d === void 0 ? !0 : Array.isArray(d) ? d.some(i) : d && typeof d == "object" ? Object.values(d).some(i) : !1, a = m(e);
368
369
  return Array.isArray(a._and) && (a._and = a._and.filter((d) => !i(d))), i(a) ? void 0 : a;
369
370
  }
370
- function dt({
371
+ function ct({
371
372
  filter: e,
372
373
  selected: r,
373
374
  onChange: l,
@@ -392,7 +393,7 @@ function dt({
392
393
  };
393
394
  return window.addEventListener("mousedown", $), () => window.removeEventListener("mousedown", $);
394
395
  }, [i]);
395
- const _ = e.label ?? E(e.param), O = (n != null && n.length ? g.filter(($) => n.some((q) => String(q) === String($.id))) : g).filter(
396
+ const _ = e.label ?? B(e.param), O = (n != null && n.length ? g.filter(($) => n.some((q) => String(q) === String($.id))) : g).filter(
396
397
  ($) => d ? String($[w] ?? "").toLowerCase().includes(d.toLowerCase()) : !0
397
398
  ), S = n != null && n.length ? {
398
399
  label: "restricted",
@@ -468,10 +469,10 @@ function dt({
468
469
  ] })
469
470
  ] });
470
471
  }
471
- function ct({ widget: e }) {
472
- return /* @__PURE__ */ t(we, { config: e.config ?? {} });
473
- }
474
472
  function mt({ widget: e }) {
473
+ return /* @__PURE__ */ t($e, { config: e.config ?? {} });
474
+ }
475
+ function ut({ widget: e }) {
475
476
  const r = e.config ?? {}, [l, n] = j(!1);
476
477
  return r.collection ? r.display === "drawer" ? /* @__PURE__ */ p("div", { className: "flex h-full items-center", children: [
477
478
  /* @__PURE__ */ t(
@@ -518,7 +519,7 @@ function mt({ widget: e }) {
518
519
  )
519
520
  ] }) : /* @__PURE__ */ t(be, { config: r }) : /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Configure the record grid (collection)" });
520
521
  }
521
- function ut({
522
+ function pt({
522
523
  cfg: e
523
524
  }) {
524
525
  const [r, l] = j(!1), n = { ...e };
@@ -559,7 +560,7 @@ function ut({
559
560
  }
560
561
  )
561
562
  ] }),
562
- /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t($e, { config: n }) })
563
+ /* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ t(Se, { config: n }) })
563
564
  ]
564
565
  }
565
566
  )
@@ -567,14 +568,14 @@ function ut({
567
568
  )
568
569
  ] });
569
570
  }
570
- function we({ config: e }) {
571
- return e.display === "drawer" ? /* @__PURE__ */ t(ut, { cfg: e }) : /* @__PURE__ */ t($e, { config: e });
572
- }
573
571
  function $e({ config: e }) {
572
+ return e.display === "drawer" ? /* @__PURE__ */ t(pt, { cfg: e }) : /* @__PURE__ */ t(Se, { config: e });
573
+ }
574
+ function Se({ config: e }) {
574
575
  var de, ce, me, ue, pe, he, xe;
575
576
  const r = z(), l = ye(), [n, s] = j(null), [m, i] = j(null), [a, d] = j(null), [u, x] = j(
576
- () => at(e.filters)
577
- ), [f, w] = j(null), [g, _] = j(null), A = (g == null ? void 0 : g.phase) === "running", O = We();
577
+ () => nt(e.filters)
578
+ ), [f, w] = j(null), [g, _] = j(null), A = (g == null ? void 0 : g.phase) === "running", O = Oe();
578
579
  Z(() => {
579
580
  if ((g == null ? void 0 : g.phase) !== "running") return;
580
581
  const c = window.setInterval(() => {
@@ -584,7 +585,7 @@ function $e({ config: e }) {
584
585
  }, 250);
585
586
  return () => window.clearInterval(c);
586
587
  }, [g == null ? void 0 : g.phase]);
587
- const { scopes: S, ready: $ } = Le(), q = ee(!1), [M, o] = j(!1), [v, B] = j(/* @__PURE__ */ new Set());
588
+ const { scopes: S, ready: $ } = Ie(), q = ee(!1), [M, o] = j(!1), [y, E] = j(/* @__PURE__ */ new Set());
588
589
  Z(() => {
589
590
  if (q.current || !$) return;
590
591
  q.current = !0;
@@ -596,35 +597,35 @@ function $e({ config: e }) {
596
597
  (async () => {
597
598
  try {
598
599
  const h = {};
599
- for (const y of c) {
600
- const b = fe(S, { key: y.param, collection: y.collection });
600
+ for (const k of c) {
601
+ const b = fe(S, { key: k.param, collection: k.collection });
601
602
  if (!b) continue;
602
- const N = Ie(S, b.name);
603
+ const N = Qe(S, b.name);
603
604
  if (!N.length) continue;
604
- const C = y.value_field ?? "id", T = await Qe(
605
+ const C = k.value_field ?? "id", T = await De(
605
606
  r,
606
607
  b,
607
608
  N,
608
609
  C
609
610
  );
610
- T.length && (h[y.param] = T.map((F, I) => ({ [C]: F, id: N[I] })));
611
+ T.length && (h[k.param] = T.map((F, I) => ({ [C]: F, id: N[I] })));
611
612
  }
612
- Object.keys(h).length && (x((y) => {
613
- const b = { ...y };
613
+ Object.keys(h).length && (x((k) => {
614
+ const b = { ...k };
614
615
  for (const [N, C] of Object.entries(h))
615
616
  (b[N] ?? []).length || (b[N] = C);
616
617
  return b;
617
- }), B(new Set(Object.keys(h))));
618
+ }), E(new Set(Object.keys(h))));
618
619
  } finally {
619
620
  o(!0);
620
621
  }
621
622
  })();
622
623
  }, [$, S, e.filters, u, r]);
623
- const R = Oe(() => {
624
+ const R = Te(() => {
624
625
  const c = { ...e.params ?? {} };
625
626
  for (const h of e.filters ?? []) {
626
- const y = u[h.param] ?? [];
627
- y.length > 0 && (c[h.param] = y.map((b) => String(b[h.value_field ?? "id"] ?? "")).join(","));
627
+ const k = u[h.param] ?? [];
628
+ k.length > 0 && (c[h.param] = k.map((b) => String(b[h.value_field ?? "id"] ?? "")).join(","));
628
629
  }
629
630
  return c;
630
631
  }, [e.params, e.filters, u]), P = ee(!1), {
@@ -632,7 +633,7 @@ function $e({ config: e }) {
632
633
  isPending: L,
633
634
  error: le,
634
635
  refetch: ae,
635
- isFetching: Se
636
+ isFetching: Ce
636
637
  } = D({
637
638
  queryKey: ["page-renderer-query", e.query_slug, JSON.stringify(R)],
638
639
  queryFn: () => {
@@ -646,37 +647,37 @@ function $e({ config: e }) {
646
647
  },
647
648
  enabled: !!e.query_slug && M,
648
649
  staleTime: 6e4
649
- }), K = W == null ? void 0 : W.data, Ce = Te(() => {
650
+ }), K = W == null ? void 0 : W.data, _e = Me(() => {
650
651
  P.current = !0, ae();
651
652
  }, [ae]), ne = L;
652
653
  if (!e.query_slug) return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Set a query slug" });
653
- const _e = (c) => {
654
+ const qe = (c) => {
654
655
  var N;
655
656
  const h = {};
656
657
  for (const [C, T] of Object.entries(c.params ?? {})) {
657
- const F = Ne(T, null, K ?? [], R, u, e.filters);
658
+ const F = we(T, null, K ?? [], R, u, e.filters);
658
659
  if (F === void 0) {
659
660
  w(`Select a value for "${C}" first`);
660
661
  return;
661
662
  }
662
663
  h[C] = F;
663
664
  }
664
- const y = (N = c.confirm) == null ? void 0 : N.replace(/\{(\w+)\}/g, (C, T) => String(h[T] ?? "")), b = {
665
+ const k = (N = c.confirm) == null ? void 0 : N.replace(/\{(\w+)\}/g, (C, T) => String(h[T] ?? "")), b = {
665
666
  action: c,
666
667
  params: h,
667
- phase: y ? "confirm" : "running",
668
- confirmText: y ?? null,
668
+ phase: k ? "confirm" : "running",
669
+ confirmText: k ?? null,
669
670
  startedAt: Date.now(),
670
671
  elapsedMs: 0
671
672
  };
672
- _(b), y || se(b);
673
+ _(b), k || se(b);
673
674
  }, se = async (c) => {
674
675
  const h = Date.now();
675
676
  _({ ...c, phase: "running", startedAt: h, elapsedMs: 0 });
676
677
  try {
677
- const y = await r.request(
678
+ const k = await r.request(
678
679
  V(`/custom-queries/${c.action.query_slug}/execute`, { params: c.params })
679
- ), b = Array.isArray(y == null ? void 0 : y.data) ? y.data : [];
680
+ ), b = Array.isArray(k == null ? void 0 : k.data) ? k.data : [];
680
681
  _(
681
682
  (N) => N && N.action === c.action ? {
682
683
  ...N,
@@ -688,30 +689,30 @@ function $e({ config: e }) {
688
689
  ), w(
689
690
  `${c.action.success_message ?? `${c.action.label} completed`} · ${G(Date.now() - h)}`
690
691
  ), O.invalidateQueries({ queryKey: ["page-renderer-query", e.query_slug] });
691
- } catch (y) {
692
- const b = y instanceof Error ? y.message : "unknown error";
692
+ } catch (k) {
693
+ const b = ke(k, "unknown error");
693
694
  _(
694
695
  (N) => N && N.action === c.action ? { ...N, phase: "error", elapsedMs: Date.now() - h, error: b } : N
695
696
  ), w(`${c.action.label} failed: ${b}`);
696
697
  }
697
- }, qe = /* @__PURE__ */ t(
698
- Ke,
698
+ }, je = /* @__PURE__ */ t(
699
+ Ge,
699
700
  {
700
701
  envelope: W,
701
- onRefresh: Ce,
702
- refreshing: Se && !L,
702
+ onRefresh: _e,
703
+ refreshing: Ce && !L,
703
704
  className: "ml-auto"
704
705
  }
705
706
  ), Y = e.filters && e.filters.length > 0 || (de = e.actions) != null && de.length || W != null && W.cache_ttl ? /* @__PURE__ */ p("div", { className: "flex flex-wrap items-center gap-2 pb-2", children: [
706
707
  (e.filters ?? []).map((c) => {
707
- const h = fe(S, { key: c.param, collection: c.collection }), y = h ? (S == null ? void 0 : S.restricted[h.name]) ?? [] : [];
708
+ const h = fe(S, { key: c.param, collection: c.collection }), k = h ? (S == null ? void 0 : S.restricted[h.name]) ?? [] : [];
708
709
  return /* @__PURE__ */ t(
709
- dt,
710
+ ct,
710
711
  {
711
712
  filter: c,
712
713
  selected: u[c.param] ?? [],
713
- allowedIds: y.length > 0 ? y : void 0,
714
- scopeDefault: v.has(c.param),
714
+ allowedIds: k.length > 0 ? k : void 0,
715
+ scopeDefault: y.has(c.param),
715
716
  onChange: (b) => x((N) => ({ ...N, [c.param]: b }))
716
717
  },
717
718
  c.param
@@ -722,16 +723,16 @@ function $e({ config: e }) {
722
723
  {
723
724
  type: "button",
724
725
  disabled: A,
725
- onClick: () => void _e(c),
726
+ onClick: () => void qe(c),
726
727
  className: "ml-auto inline-flex h-8 items-center rounded-md bg-nvr-cyan px-3 text-[12px] font-semibold text-white hover:opacity-90 disabled:opacity-50",
727
728
  children: A ? "Running…" : c.label
728
729
  },
729
730
  c.label
730
731
  )),
731
732
  f && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-500", children: f }),
732
- qe
733
+ je
733
734
  ] }) : null, ie = (ce = e.stats) != null && ce.length ? /* @__PURE__ */ t(
734
- Ve,
735
+ He,
735
736
  {
736
737
  stats: e.stats,
737
738
  rows: K ?? [],
@@ -750,8 +751,8 @@ function $e({ config: e }) {
750
751
  Y,
751
752
  /* @__PURE__ */ t(U, { error: le })
752
753
  ] });
753
- const k = e.row_click, oe = (c, h) => {
754
- const b = Be(c, (C) => nt(
754
+ const v = e.row_click, oe = (c, h) => {
755
+ const b = Le(c, (C) => st(
755
756
  C,
756
757
  h,
757
758
  K ?? [],
@@ -783,14 +784,14 @@ function $e({ config: e }) {
783
784
  },
784
785
  row: h
785
786
  });
786
- }, je = k ? (c) => {
787
- k.picker ? s(c) : k.sheet ? oe(k.sheet, c) : k.matrix && c.id != null ? i(c.id) : k.drill && c.id != null && (l == null || l.open({
788
- collection: k.drill.collection ?? "",
787
+ }, Re = v ? (c) => {
788
+ v.picker ? s(c) : v.sheet ? oe(v.sheet, c) : v.matrix && c.id != null ? i(c.id) : v.drill && c.id != null && (l == null || l.open({
789
+ collection: v.drill.collection ?? "",
789
790
  itemId: String(c.id),
790
- layoutId: k.drill.layout_id,
791
- width: k.drill.width
791
+ layoutId: v.drill.layout_id,
792
+ width: v.drill.width
792
793
  }));
793
- } : void 0, Re = (me = e.row_actions) != null && me.length ? e.row_actions.map((c) => ({
794
+ } : void 0, We = (me = e.row_actions) != null && me.length ? e.row_actions.map((c) => ({
794
795
  label: c.label,
795
796
  onClick: (h) => oe(c.sheet, h)
796
797
  })) : void 0;
@@ -806,7 +807,7 @@ function $e({ config: e }) {
806
807
  Y,
807
808
  ie,
808
809
  /* @__PURE__ */ t(
809
- He,
810
+ Ue,
810
811
  {
811
812
  rows: K ?? [],
812
813
  config: (
@@ -816,13 +817,13 @@ function $e({ config: e }) {
816
817
  String(R[e.table.highlight_year_param] ?? "").split(",")[0]
817
818
  ) === (/* @__PURE__ */ new Date()).getFullYear() ? e.table : { ...e.table, highlight_group: void 0 } : e.table
818
819
  ),
819
- onRowClick: je,
820
- rowActions: Re,
820
+ onRowClick: Re,
821
+ rowActions: We,
821
822
  emptyText: e.empty_label,
822
823
  pivotYear: (xe = (he = e.table) == null ? void 0 : he.pivot) != null && xe.year_param && Number(String(R[e.table.pivot.year_param] ?? "").split(",")[0]) || void 0
823
824
  }
824
825
  ),
825
- (k == null ? void 0 : k.picker) && n && /* @__PURE__ */ t(
826
+ (v == null ? void 0 : v.picker) && n && /* @__PURE__ */ t(
826
827
  "div",
827
828
  {
828
829
  className: "fixed inset-0 z-50 flex items-start justify-center bg-black/30 pt-32",
@@ -833,28 +834,28 @@ function $e({ config: e }) {
833
834
  className: "w-[420px] rounded-lg border border-slate-200 bg-white p-4 shadow-xl dark:border-border dark:bg-background",
834
835
  onClick: (c) => c.stopPropagation(),
835
836
  children: [
836
- /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: k.picker.title ?? "Choose a record" }),
837
+ /* @__PURE__ */ t("p", { className: "mb-2 text-[13px] font-semibold text-slate-700 dark:text-slate-200", children: v.picker.title ?? "Choose a record" }),
837
838
  /* @__PURE__ */ t(
838
- Ge,
839
+ Ve,
839
840
  {
840
- collection: k.picker.collection,
841
+ collection: v.picker.collection,
841
842
  value: null,
842
843
  onChange: (c) => {
843
- var h, y, b, N;
844
+ var h, k, b, N;
844
845
  if (s(null), c != null) {
845
- if (k.matrix) {
846
+ if (v.matrix) {
846
847
  i(c);
847
848
  return;
848
849
  }
849
850
  l == null || l.open({
850
- collection: ((h = k.drill) == null ? void 0 : h.collection) ?? ((y = k.picker) == null ? void 0 : y.collection) ?? "",
851
+ collection: ((h = v.drill) == null ? void 0 : h.collection) ?? ((k = v.picker) == null ? void 0 : k.collection) ?? "",
851
852
  itemId: String(c),
852
- layoutId: (b = k.drill) == null ? void 0 : b.layout_id,
853
- width: (N = k.drill) == null ? void 0 : N.width
853
+ layoutId: (b = v.drill) == null ? void 0 : b.layout_id,
854
+ width: (N = v.drill) == null ? void 0 : N.width
854
855
  });
855
856
  }
856
857
  },
857
- extraFilter: ot(k.picker.filter, n, u, e.filters),
858
+ extraFilter: dt(v.picker.filter, n, u, e.filters),
858
859
  placeholder: "Search…"
859
860
  }
860
861
  ),
@@ -872,19 +873,19 @@ function $e({ config: e }) {
872
873
  )
873
874
  }
874
875
  ),
875
- (k == null ? void 0 : k.matrix) && m != null && /* @__PURE__ */ t(
876
- ke,
876
+ (v == null ? void 0 : v.matrix) && m != null && /* @__PURE__ */ t(
877
+ Ne,
877
878
  {
878
- config: k.matrix.config,
879
- initialScope: { [k.matrix.scope_field]: m },
880
- width: k.matrix.width,
881
- title: k.matrix.title,
879
+ config: v.matrix.config,
880
+ initialScope: { [v.matrix.scope_field]: m },
881
+ width: v.matrix.width,
882
+ title: v.matrix.title,
882
883
  onClose: () => i(null)
883
884
  }
884
885
  ),
885
- a && /* @__PURE__ */ t(it, { def: a.def, row: a.row, onClose: () => d(null) }),
886
+ a && /* @__PURE__ */ t(ot, { def: a.def, row: a.row, onClose: () => d(null) }),
886
887
  g && /* @__PURE__ */ t(
887
- pt,
888
+ ht,
888
889
  {
889
890
  run: g,
890
891
  onConfirm: () => void se(g),
@@ -898,13 +899,13 @@ function $e({ config: e }) {
898
899
  );
899
900
  }
900
901
  const G = (e) => e < 6e4 ? `${(e / 1e3).toFixed(e < 1e4 ? 1 : 0)}s` : `${Math.floor(e / 6e4)}m ${Math.round(e % 6e4 / 1e3)}s`;
901
- function pt({
902
+ function ht({
902
903
  run: e,
903
904
  onConfirm: r,
904
905
  onClose: l
905
906
  }) {
906
907
  const n = Object.entries(e.params);
907
- return Me(
908
+ return Ae(
908
909
  /* @__PURE__ */ p(Q, { children: [
909
910
  /* @__PURE__ */ t(
910
911
  "div",
@@ -924,7 +925,7 @@ function pt({
924
925
  children: [
925
926
  /* @__PURE__ */ t("p", { className: "text-[13.5px] font-semibold text-slate-900 dark:text-foreground", children: e.action.label }),
926
927
  n.length > 0 && /* @__PURE__ */ t("dl", { className: "mt-2 space-y-0.5 rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: n.map(([s, m]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
927
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: E(s) }),
928
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: B(s) }),
928
929
  /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(m) })
929
930
  ] }, s)) }),
930
931
  e.phase === "confirm" && /* @__PURE__ */ p(Q, { children: [
@@ -963,7 +964,7 @@ function pt({
963
964
  ] }),
964
965
  e.resultRows != null && e.resultRows > 0 && e.resultSample && /* @__PURE__ */ p("dl", { className: "mt-2 max-h-40 space-y-0.5 overflow-y-auto rounded-lg bg-slate-50 px-2.5 py-1.5 text-[11.5px] dark:bg-muted", children: [
965
966
  Object.entries(e.resultSample).slice(0, 8).map(([s, m]) => /* @__PURE__ */ p("div", { className: "flex gap-2", children: [
966
- /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: E(s) }),
967
+ /* @__PURE__ */ t("dt", { className: "text-slate-500 dark:text-slate-400", children: B(s) }),
967
968
  /* @__PURE__ */ t("dd", { className: "ml-auto font-medium tabular-nums text-slate-800 dark:text-slate-100", children: String(m ?? "—") })
968
969
  ] }, s)),
969
970
  e.resultRows > 1 && /* @__PURE__ */ p("p", { className: "pt-0.5 text-slate-400", children: [
@@ -1021,28 +1022,28 @@ function ge({ slug: e, widget: r }) {
1021
1022
  var l;
1022
1023
  switch (r.type) {
1023
1024
  case "table":
1024
- return /* @__PURE__ */ t(Ze, { slug: e, widget: r });
1025
- case "kpi":
1026
1025
  return /* @__PURE__ */ t(et, { slug: e, widget: r });
1026
+ case "kpi":
1027
+ return /* @__PURE__ */ t(tt, { slug: e, widget: r });
1027
1028
  case "markdown":
1028
- return /* @__PURE__ */ t(Xe, { content: String(((l = r.config) == null ? void 0 : l.content) ?? "") });
1029
+ return /* @__PURE__ */ t(Ze, { content: String(((l = r.config) == null ? void 0 : l.content) ?? "") });
1029
1030
  case "iframe":
1030
- return /* @__PURE__ */ t(rt, { widget: r });
1031
+ return /* @__PURE__ */ t(lt, { widget: r });
1031
1032
  case "query":
1032
- return /* @__PURE__ */ t(ct, { widget: r });
1033
+ return /* @__PURE__ */ t(mt, { widget: r });
1033
1034
  case "matrix":
1034
- return /* @__PURE__ */ t(lt, { widget: r });
1035
+ return /* @__PURE__ */ t(at, { widget: r });
1035
1036
  case "record-grid":
1036
- return /* @__PURE__ */ t(mt, { widget: r });
1037
+ return /* @__PURE__ */ t(ut, { widget: r });
1037
1038
  case "recent-activity":
1038
- return /* @__PURE__ */ t(tt, { slug: e, widget: r });
1039
+ return /* @__PURE__ */ t(rt, { slug: e, widget: r });
1039
1040
  default:
1040
1041
  return /* @__PURE__ */ t("div", { className: "p-3 text-[12px] text-slate-400", children: "Unknown widget" });
1041
1042
  }
1042
1043
  }
1043
- function Ot({ slug: e, hideHeader: r, className: l }) {
1044
+ function Mt({ slug: e, hideHeader: r, className: l }) {
1044
1045
  var q, M;
1045
- const n = z(), s = ye(), m = Ae("drill.page"), i = m.value, {
1046
+ const n = z(), s = ye(), m = Pe("drill.page"), i = m.value, {
1046
1047
  data: a,
1047
1048
  isLoading: d,
1048
1049
  error: u
@@ -1066,18 +1067,18 @@ function Ot({ slug: e, hideHeader: r, className: l }) {
1066
1067
  }
1067
1068
  );
1068
1069
  const x = ((q = a.layout) == null ? void 0 : q.columns) ?? 12, f = ((M = a.layout) == null ? void 0 : M.widgets) ?? [], w = (o) => {
1069
- var v;
1070
- return (o.type === "matrix" || o.type === "query" || o.type === "record-grid") && ((v = o.config) == null ? void 0 : v.display) === "drawer";
1071
- }, g = [...new Set(f.filter(w).map((o) => o.y))].filter((o) => f.every((v) => w(v) || o < v.y || o >= v.y + Math.max(v.h, 1))).sort((o, v) => o - v), _ = g.map((o) => ({
1070
+ var y;
1071
+ return (o.type === "matrix" || o.type === "query" || o.type === "record-grid") && ((y = o.config) == null ? void 0 : y.display) === "drawer";
1072
+ }, g = [...new Set(f.filter(w).map((o) => o.y))].filter((o) => f.every((y) => w(y) || o < y.y || o >= y.y + Math.max(y.h, 1))).sort((o, y) => o - y), _ = g.map((o) => ({
1072
1073
  y: o,
1073
- items: f.filter((v) => v.y === o && w(v)).sort((v, B) => v.x - B.x)
1074
- })), A = f.filter((o) => !(w(o) && g.includes(o.y))), O = (o) => o - g.filter((v) => v < o).length, S = A.find((o) => {
1075
- var v;
1076
- return (v = o.config) == null ? void 0 : v.full_height;
1074
+ items: f.filter((y) => y.y === o && w(y)).sort((y, E) => y.x - E.x)
1075
+ })), A = f.filter((o) => !(w(o) && g.includes(o.y))), O = (o) => o - g.filter((y) => y < o).length, S = A.find((o) => {
1076
+ var y;
1077
+ return (y = o.config) == null ? void 0 : y.full_height;
1077
1078
  }), $ = /* @__PURE__ */ p("div", { className: `flex h-full min-h-0 flex-col ${l ?? ""}`, children: [
1078
1079
  !r && /* @__PURE__ */ t("div", { className: "shrink-0 pb-4", children: /* @__PURE__ */ t("h1", { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: a.name }) }),
1079
1080
  /* @__PURE__ */ t("div", { className: `min-h-0 flex-1 overflow-y-auto ${S ? "flex flex-col" : ""}`, children: f.length === 0 ? /* @__PURE__ */ t("p", { className: "p-6 text-center text-[13px] text-slate-400", children: "This page has no widgets yet." }) : /* @__PURE__ */ p(Q, { children: [
1080
- _.map((o) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: o.items.map((v) => /* @__PURE__ */ t(ge, { slug: a.slug, widget: v }, v.id)) }, o.y)),
1081
+ _.map((o) => /* @__PURE__ */ t("div", { className: "mb-3 flex shrink-0 flex-wrap items-center gap-2", children: o.items.map((y) => /* @__PURE__ */ t(ge, { slug: a.slug, widget: y }, y.id)) }, o.y)),
1081
1082
  /* @__PURE__ */ t(
1082
1083
  "div",
1083
1084
  {
@@ -1094,17 +1095,17 @@ function Ot({ slug: e, hideHeader: r, className: l }) {
1094
1095
  },
1095
1096
  children: A.map((o) => {
1096
1097
  var R, P, W, L;
1097
- const v = (o.type === "matrix" || o.type === "query" || o.type === "record-grid") && ((R = o.config) == null ? void 0 : R.display) === "drawer", B = o === S;
1098
+ const y = (o.type === "matrix" || o.type === "query" || o.type === "record-grid") && ((R = o.config) == null ? void 0 : R.display) === "drawer", E = o === S;
1098
1099
  return /* @__PURE__ */ p(
1099
1100
  "div",
1100
1101
  {
1101
- className: v ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
1102
+ className: y ? "flex min-h-0 flex-col" : "flex min-h-0 flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm dark:border-border dark:bg-card",
1102
1103
  style: {
1103
1104
  gridColumn: `${Math.min(o.x, x - 1) + 1} / span ${Math.min(o.w, x)}`,
1104
- gridRow: B ? `${O(o.y) + 1} / -1` : `${O(o.y) + 1} / span ${Math.max(o.h, 1)}`
1105
+ gridRow: E ? `${O(o.y) + 1} / -1` : `${O(o.y) + 1} / span ${Math.max(o.h, 1)}`
1105
1106
  },
1106
1107
  children: [
1107
- !v && o.type !== "kpi" && o.type !== "markdown" && ((P = o.config) == null ? void 0 : P.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((W = o.config) == null ? void 0 : W.label) ?? "") || (typeof ((L = o.config) == null ? void 0 : L.collection) == "string" ? E(String(o.config.collection)) : E(o.type)) }),
1108
+ !y && o.type !== "kpi" && o.type !== "markdown" && ((P = o.config) == null ? void 0 : P.hide_label) !== !0 && /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-slate-100 px-3 py-1.5 text-[11px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: String(((W = o.config) == null ? void 0 : W.label) ?? "") || (typeof ((L = o.config) == null ? void 0 : L.collection) == "string" ? B(String(o.config.collection)) : B(o.type)) }),
1108
1109
  /* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ t(ge, { slug: a.slug, widget: o }) })
1109
1110
  ]
1110
1111
  },
@@ -1115,9 +1116,9 @@ function Ot({ slug: e, hideHeader: r, className: l }) {
1115
1116
  )
1116
1117
  ] }) })
1117
1118
  ] });
1118
- return s ? $ : /* @__PURE__ */ p(Pe.Provider, { value: { open: (o) => m.push([o]) }, children: [
1119
+ return s ? $ : /* @__PURE__ */ p(Fe.Provider, { value: { open: (o) => m.push([o]) }, children: [
1119
1120
  i != null && i.length ? /* @__PURE__ */ t(
1120
- Ue,
1121
+ Ye,
1121
1122
  {
1122
1123
  collection: i[0].collection,
1123
1124
  itemId: i[0].itemId,
@@ -1134,7 +1135,7 @@ function Ot({ slug: e, hideHeader: r, className: l }) {
1134
1135
  ] });
1135
1136
  }
1136
1137
  export {
1137
- Ot as PageRenderer,
1138
- we as QueryWidgetView,
1139
- mt as RecordGridWidgetBody
1138
+ Mt as PageRenderer,
1139
+ $e as QueryWidgetView,
1140
+ ut as RecordGridWidgetBody
1140
1141
  };