@nivaro/react 0.3.36 → 0.3.37

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 (102) hide show
  1. package/dist/components/slots/CommentsSlot.js +44 -36
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +9 -1
  5. package/dist/shared/components/AgentBadge.js +26 -0
  6. package/dist/shared/components/AgentQuestionsCard.js +198 -0
  7. package/dist/shared/components/ItemEditForm.js +3329 -3263
  8. package/dist/shared/components/McpConnectionScope.js +480 -0
  9. package/dist/shared/components/MyWorkView.js +223 -208
  10. package/dist/shared/components/RecordReadView.js +620 -575
  11. package/dist/shared/components/chat/ChatPanel.js +683 -671
  12. package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
  13. package/dist/shared/components/imports/ImportConsole.js +106 -104
  14. package/dist/shared/components/imports/RunDetailSheet.js +11 -10
  15. package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
  16. package/dist/shared/components/item-edit/FormTour.js +279 -0
  17. package/dist/shared/components/item-edit/GroupSection.js +377 -360
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +28 -28
  19. package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
  20. package/dist/shared/components/item-edit/form-density.js +36 -0
  21. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
  22. package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
  23. package/dist/shared/components/layout-editor/AddPanel.js +349 -192
  24. package/dist/shared/components/layout-editor/DesignNode.js +126 -112
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +123 -103
  26. package/dist/shared/components/layout-editor/LayoutEditor.js +829 -751
  27. package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
  28. package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
  29. package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
  30. package/dist/shared/components/layout-editor/add-target.js +54 -43
  31. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
  32. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
  33. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +347 -189
  35. package/dist/shared/components/layout-editor/dnd/TrashZone.js +60 -32
  36. package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
  37. package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
  38. package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
  39. package/dist/shared/components/layout-editor/dnd/node.js +115 -105
  40. package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
  41. package/dist/shared/components/layout-editor/dnd/trash-drop.js +34 -28
  42. package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
  43. package/dist/shared/components/layout-editor/even-row.js +86 -0
  44. package/dist/shared/components/layout-editor/field-list.js +99 -0
  45. package/dist/shared/components/layout-editor/format-painter.js +102 -0
  46. package/dist/shared/components/layout-editor/grid-guides.js +15 -13
  47. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
  48. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
  49. package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
  50. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
  51. package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
  52. package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
  53. package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
  54. package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
  55. package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
  56. package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
  57. package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
  58. package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
  59. package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
  60. package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
  61. package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
  62. package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
  63. package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
  64. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
  65. package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
  66. package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
  67. package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
  68. package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
  69. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  70. package/dist/shared/components/layout-editor/pin.js +37 -19
  71. package/dist/shared/components/layout-editor/place-clip.js +257 -0
  72. package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
  73. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +148 -117
  74. package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
  75. package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
  76. package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
  77. package/dist/shared/components/layout-editor/removed-log.js +151 -0
  78. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
  79. package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
  80. package/dist/shared/components/layout-editor/revert-element.js +140 -0
  81. package/dist/shared/components/layout-editor/section-structure.js +193 -170
  82. package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
  83. package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
  84. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
  85. package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
  86. package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
  87. package/dist/shared/components/layout-editor/shortcuts.js +21 -16
  88. package/dist/shared/components/layout-editor/structure-ops.js +221 -195
  89. package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
  90. package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
  91. package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
  92. package/dist/shared/components/panels/CommentPanel.js +47 -45
  93. package/dist/shared/components/panels/RevisionsPanel.js +66 -64
  94. package/dist/shared/components/panels/TaskPanel.js +395 -332
  95. package/dist/shared/components/profile/AgentsPanel.js +196 -147
  96. package/dist/shared/components/profile/ConnectionRollback.js +329 -0
  97. package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
  98. package/dist/shared/lib/entry-config.js +22 -22
  99. package/dist/shared/lib/form-usage-beacon.js +91 -55
  100. package/dist/shared/lib/layout-lint.js +530 -284
  101. package/dist/shared/lib/layout-resolve.js +58 -44
  102. package/package.json +1 -1
@@ -0,0 +1,69 @@
1
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
+ import { Download as p, Loader2 as N, Check as C } from "lucide-react";
3
+ import { useState as d, useEffect as k } from "react";
4
+ import { toast as g } from "sonner";
5
+ import { Button as y } from "../ui/button.js";
6
+ import { Command as b, CommandInput as v, CommandList as D, CommandEmpty as $, CommandGroup as S, CommandItem as O } from "../ui/command.js";
7
+ import { Popover as P, PopoverTrigger as T, PopoverContent as j } from "../ui/popover.js";
8
+ import { useDownload as B } from "./RunDetailSheet.js";
9
+ import { definitionTitle as r } from "./types.js";
10
+ function _({ definitions: n }) {
11
+ const [c, h] = d(!1), [x, m] = d(null), { download: u, busy: l, error: s } = B();
12
+ k(() => {
13
+ s && g.error(`Could not download the sample: ${s}`);
14
+ }, [s]);
15
+ const w = [...n].sort(
16
+ (e, o) => r(e).localeCompare(r(o))
17
+ );
18
+ return /* @__PURE__ */ a(P, { open: c, onOpenChange: h, children: [
19
+ /* @__PURE__ */ t(T, { asChild: !0, children: /* @__PURE__ */ a(
20
+ y,
21
+ {
22
+ size: "sm",
23
+ variant: "outline",
24
+ className: "h-7",
25
+ "data-import-sample-open": !0,
26
+ disabled: n.length === 0,
27
+ "data-tip": "A CSV with the columns an import reads and example rows",
28
+ children: [
29
+ /* @__PURE__ */ t(p, { className: "h-3.5 w-3.5" }),
30
+ /* @__PURE__ */ t("span", { className: "max-sm:sr-only", children: "Download sample" })
31
+ ]
32
+ }
33
+ ) }),
34
+ /* @__PURE__ */ a(j, { align: "end", className: "w-[300px] p-0", children: [
35
+ /* @__PURE__ */ a(b, { children: [
36
+ /* @__PURE__ */ t(v, { placeholder: "Which import?", className: "h-9 text-[12.5px]" }),
37
+ /* @__PURE__ */ a(D, { className: "max-h-[320px]", children: [
38
+ /* @__PURE__ */ t($, { className: "py-4 text-center text-[12px] text-slate-500 dark:text-slate-400", children: "No import matches." }),
39
+ /* @__PURE__ */ t(S, { children: w.map((e) => {
40
+ const o = `/staged-imports/definitions/${e.id}/sample`, f = l === o;
41
+ return /* @__PURE__ */ a(
42
+ O,
43
+ {
44
+ value: `${r(e)} ${e.key}`,
45
+ "data-import-sample": e.key,
46
+ disabled: !!l,
47
+ onSelect: () => {
48
+ u(o, `${e.key}_sample.csv`).then(() => {
49
+ m(e.id), window.setTimeout(() => m((i) => i === e.id ? null : i), 2e3);
50
+ });
51
+ },
52
+ className: "flex items-center gap-2 text-[12.5px]",
53
+ children: [
54
+ /* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate", children: r(e) }),
55
+ f ? /* @__PURE__ */ t(N, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 motion-safe:animate-spin" }) : x === e.id ? /* @__PURE__ */ t(C, { className: "h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }) : /* @__PURE__ */ t(p, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
56
+ ]
57
+ },
58
+ e.id
59
+ );
60
+ }) })
61
+ ] })
62
+ ] }),
63
+ /* @__PURE__ */ t("p", { className: "border-t border-slate-100 px-3 py-2 text-[11px] leading-snug text-slate-500 dark:border-border dark:text-slate-400", children: "Headers the import reads, with example rows. Open it, replace the rows with yours, and upload it with New import." })
64
+ ] })
65
+ ] });
66
+ }
67
+ export {
68
+ _ as DownloadSampleButton
69
+ };
@@ -1,128 +1,129 @@
1
1
  import { jsxs as a, jsx as t, Fragment as Ke } from "react/jsx-runtime";
2
2
  import { useQueryClient as Pe, useQuery as L, useMutation as ue } from "@tanstack/react-query";
3
- import { RefreshCw as Qe, Plus as me, AlertTriangle as Te, Upload as Fe, Ban as ve, MoreHorizontal as ze, ScrollText as Be, RotateCcw as Oe } from "lucide-react";
3
+ import { RefreshCw as Qe, Plus as me, AlertTriangle as Te, Upload as Fe, Ban as ye, MoreHorizontal as Be, ScrollText as ze, RotateCcw as Oe } from "lucide-react";
4
4
  import { useState as c, useEffect as pe, useMemo as he, useRef as Ue } from "react";
5
5
  import { useNivaroClient as $e, useItemEditAuth as je, useNavigation as He, useItemNavigation as Ve } from "../../context.js";
6
6
  import { useDebounced as We } from "../../hooks/useDebounced.js";
7
7
  import { get as M, post as xe } from "../../lib/commands.js";
8
8
  import { useLiveEvent as Ge } from "../../lib/live.js";
9
- import { formatNumber as v, cn as I, formatRelative as Ye, formatDateTime as Ze } from "../../lib/utils.js";
9
+ import { formatNumber as k, cn as D, formatRelative as Ye, formatDateTime as Ze } from "../../lib/utils.js";
10
10
  import { DataTable as Xe } from "../DataTable.js";
11
11
  import { Button as y } from "../ui/button.js";
12
12
  import { DropdownMenu as Je, DropdownMenuTrigger as et, DropdownMenuContent as tt, DropdownMenuItem as O } from "../ui/dropdown-menu.js";
13
13
  import { CollectionImportPanel as rt } from "./CollectionImportPanel.js";
14
14
  import { DefinitionHealthPanel as at } from "./DefinitionHealthPanel.js";
15
15
  import { DefinitionsPanel as nt } from "./DefinitionsPanel.js";
16
- import { NewImportDialog as ot } from "./NewImportDialog.js";
17
- import { RunDetailSheet as st } from "./RunDetailSheet.js";
18
- import { LIVE_POLL_MS as ge, queueStanding as fe, STATUS_STYLE as ke, useElapsed as it, StatusPill as Ne } from "./run-parts.js";
19
- import { RUN_STATUSES as lt, formatDuration as $, definitionTitle as dt, runnerName as ct } from "./types.js";
20
- const be = 25, ut = 3e4, mt = [
16
+ import { DownloadSampleButton as ot } from "./DownloadSampleButton.js";
17
+ import { NewImportDialog as st } from "./NewImportDialog.js";
18
+ import { RunDetailSheet as it } from "./RunDetailSheet.js";
19
+ import { LIVE_POLL_MS as ge, queueStanding as fe, STATUS_STYLE as ke, useElapsed as lt, StatusPill as Ne } from "./run-parts.js";
20
+ import { RUN_STATUSES as dt, formatDuration as $, definitionTitle as ct, runnerName as ut } from "./types.js";
21
+ const be = 25, mt = 3e4, pt = [
21
22
  { value: "7", label: "7d" },
22
23
  { value: "30", label: "30d" },
23
24
  { value: "90", label: "90d" },
24
25
  { value: "0", label: "All" }
25
- ], pt = {
26
+ ], ht = {
26
27
  runs: "Staged imports",
27
28
  collection: "Collection imports",
28
29
  definitions: "Definitions"
29
30
  };
30
31
  function U({
31
32
  label: o,
32
- value: s,
33
- sub: i
33
+ value: i,
34
+ sub: l
34
35
  }) {
35
36
  return /* @__PURE__ */ a("div", { className: "px-3.5 py-2", children: [
36
37
  /* @__PURE__ */ t("p", { className: "text-[10.5px] font-medium text-slate-400 dark:text-muted-foreground", children: o }),
37
- /* @__PURE__ */ t("p", { className: "mt-0.5 text-[15px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: s }),
38
- i && /* @__PURE__ */ t("p", { className: "mt-1 text-[10.5px] leading-none text-slate-400", children: i })
38
+ /* @__PURE__ */ t("p", { className: "mt-0.5 text-[15px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: i }),
39
+ l && /* @__PURE__ */ t("p", { className: "mt-1 text-[10.5px] leading-none text-slate-400", children: l })
39
40
  ] });
40
41
  }
41
- function ye({
42
+ function ve({
42
43
  label: o,
43
- count: s,
44
- status: i,
44
+ count: i,
45
+ status: l,
45
46
  active: m,
46
- onClick: k
47
+ onClick: N
47
48
  }) {
48
49
  return /* @__PURE__ */ a(
49
50
  "button",
50
51
  {
51
52
  type: "button",
52
- onClick: k,
53
+ onClick: N,
53
54
  "aria-pressed": m,
54
- className: I(
55
+ className: D(
55
56
  "flex items-center gap-1.5 px-3 py-2 text-left transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
56
57
  m && "bg-nvr-cyan/10 ring-1 ring-inset ring-nvr-cyan dark:bg-nvr-cyan/15",
57
- !m && s === 0 && "opacity-45"
58
+ !m && i === 0 && "opacity-45"
58
59
  ),
59
60
  children: [
60
- i && /* @__PURE__ */ t("span", { className: I("h-1.5 w-1.5 shrink-0 rounded-full", ke[i].dot) }),
61
- /* @__PURE__ */ t("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: s == null ? "—" : v(s) }),
61
+ l && /* @__PURE__ */ t("span", { className: D("h-1.5 w-1.5 shrink-0 rounded-full", ke[l].dot) }),
62
+ /* @__PURE__ */ t("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: i == null ? "—" : k(i) }),
62
63
  /* @__PURE__ */ t("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children: o })
63
64
  ]
64
65
  }
65
66
  );
66
67
  }
67
- function ht({
68
+ function xt({
68
69
  run: o,
69
- queuedCount: s,
70
- stage: i,
70
+ queuedCount: i,
71
+ stage: l,
71
72
  standing: m,
72
- canManage: k,
73
- onOpen: N,
74
- onCancel: D
73
+ canManage: N,
74
+ onOpen: w,
75
+ onCancel: I
75
76
  }) {
76
- const l = o.status === "running", p = it(o.started_at ?? o.created_at, l);
77
+ const d = o.status === "running", p = lt(o.started_at ?? o.created_at, d);
77
78
  return /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1.5 rounded-lg border border-[#7ad9f2] bg-nvr-cyan/10 px-3.5 py-2.5 dark:border-[#0e5c72] dark:bg-nvr-cyan/10", children: [
78
- /* @__PURE__ */ t(Ne, { status: l ? "running" : "queued" }),
79
+ /* @__PURE__ */ t(Ne, { status: d ? "running" : "queued" }),
79
80
  /* @__PURE__ */ t(
80
81
  "button",
81
82
  {
82
83
  type: "button",
83
- onClick: N,
84
+ onClick: w,
84
85
  className: "font-mono text-[12px] font-medium text-slate-900 underline-offset-2 hover:underline dark:text-foreground",
85
86
  children: o.import_key
86
87
  }
87
88
  ),
88
- l && p != null && /* @__PURE__ */ a("span", { className: "font-mono text-[12px] tabular-nums text-slate-600 dark:text-muted-foreground", children: [
89
+ d && p != null && /* @__PURE__ */ a("span", { className: "font-mono text-[12px] tabular-nums text-slate-600 dark:text-muted-foreground", children: [
89
90
  $(p),
90
91
  " elapsed"
91
92
  ] }),
92
- i && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: i }),
93
- !l && m && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: m }),
93
+ l && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: l }),
94
+ !d && m && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: m }),
94
95
  o.row_count != null && /* @__PURE__ */ a("span", { className: "text-[12px] tabular-nums text-slate-500 dark:text-muted-foreground", children: [
95
- v(o.row_count),
96
+ k(o.row_count),
96
97
  " rows"
97
98
  ] }),
98
- s > 0 && /* @__PURE__ */ a("span", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
99
+ i > 0 && /* @__PURE__ */ a("span", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
99
100
  "· ",
100
- s,
101
+ i,
101
102
  " more queued"
102
103
  ] }),
103
- k && /* @__PURE__ */ a(y, { variant: "ghost", size: "sm", className: "ml-auto h-7 px-2", onClick: D, children: [
104
- /* @__PURE__ */ t(ve, { className: "h-3.5 w-3.5" }),
104
+ N && /* @__PURE__ */ a(y, { variant: "ghost", size: "sm", className: "ml-auto h-7 px-2", onClick: I, children: [
105
+ /* @__PURE__ */ t(ye, { className: "h-3.5 w-3.5" }),
105
106
  "Stop"
106
107
  ] })
107
108
  ] });
108
109
  }
109
- function Kt({
110
+ function Qt({
110
111
  realtime: o,
111
- defaultTab: s = "runs",
112
- initialJobId: i,
112
+ defaultTab: i = "runs",
113
+ initialJobId: l,
113
114
  onJobOpen: m,
114
- initialRunId: k = null,
115
- onRunOpen: N,
116
- initialDefinitionKey: D = null
115
+ initialRunId: N = null,
116
+ onRunOpen: w,
117
+ initialDefinitionKey: I = null
117
118
  }) {
118
119
  var ie, le, de, ce;
119
- const l = $e(), p = Pe(), { isAdmin: d } = je(), j = He(), { open: we } = Ve(), _e = !!j.itemUrl || !!j.openItem, [w, H] = c(() => i ? "collection" : D && d ? "definitions" : s !== "runs" && !d ? "runs" : s), [h, R] = c("all"), [x, K] = c(""), [V, W] = c(""), [P, G] = c(1), [g, Y] = c("30"), [_, Ce] = c(k), C = (e) => {
120
- Ce(e), N == null || N(e);
120
+ const d = $e(), p = Pe(), { isAdmin: s } = je(), j = He(), { open: we } = Ve(), _e = !!j.itemUrl || !!j.openItem, [b, H] = c(() => l ? "collection" : I && s ? "definitions" : i !== "runs" && !s ? "runs" : i), [h, R] = c("all"), [x, K] = c(""), [V, W] = c(""), [P, G] = c(1), [g, Y] = c("30"), [_, Ce] = c(N), C = (e) => {
121
+ Ce(e), w == null || w(e);
121
122
  }, [Se, Q] = c(!1), [Z, A] = c(null), [X, qe] = c({}), S = We(V, 300);
122
123
  pe(() => G(1), [h, x, S, g]);
123
124
  const T = L({
124
125
  queryKey: ["staged-import-definitions"],
125
- queryFn: () => l.request(
126
+ queryFn: () => d.request(
126
127
  M("/staged-imports/definitions", { all: !0 })
127
128
  )
128
129
  }), f = he(
@@ -133,10 +134,10 @@ function Kt({
133
134
  [(ie = T.data) == null ? void 0 : ie.data]
134
135
  ), J = L({
135
136
  queryKey: ["staged-import-stats", g],
136
- queryFn: () => l.request(M("/staged-imports/stats", { days: g }))
137
- }), r = (le = J.data) == null ? void 0 : le.data, Ie = ((r == null ? void 0 : r.active.length) ?? 0) > 0 ? ge : ut, q = L({
137
+ queryFn: () => d.request(M("/staged-imports/stats", { days: g }))
138
+ }), r = (le = J.data) == null ? void 0 : le.data, De = ((r == null ? void 0 : r.active.length) ?? 0) > 0 ? ge : mt, q = L({
138
139
  queryKey: ["staged-import-runs", h, x, S, P, g],
139
- queryFn: () => l.request(
140
+ queryFn: () => d.request(
140
141
  M("/staged-imports", {
141
142
  page: P,
142
143
  limit: be,
@@ -146,26 +147,26 @@ function Kt({
146
147
  ...S.trim() ? { search: S.trim() } : {}
147
148
  })
148
149
  ),
149
- refetchInterval: Ie,
150
+ refetchInterval: De,
150
151
  // Refetching must not blank the table out from under someone reading it.
151
152
  placeholderData: (e) => e
152
153
  }), ee = ((de = q.data) == null ? void 0 : de.data) ?? [];
153
- function b() {
154
+ function v() {
154
155
  p.invalidateQueries({ queryKey: ["staged-import-runs"] }), p.invalidateQueries({ queryKey: ["staged-import-stats"] }), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
155
156
  }
156
- const te = Ue(b);
157
- te.current = b, pe(() => {
157
+ const te = Ue(v);
158
+ te.current = v, pe(() => {
158
159
  if (o)
159
160
  return o.subscribe((e) => {
160
161
  qe((n) => ({
161
162
  ...n,
162
- [e.id]: e.stage === "row_count" ? `${v(e.row_count ?? 0)} rows read` : e.stage === "preparing" ? "Preparing the staging table" : e.stage === "importing" ? "Importing the rows" : e.stage === "completed" ? "Completed" : typeof e.error == "string" && e.error ? e.error : "Failed"
163
+ [e.id]: e.stage === "row_count" ? `${k(e.row_count ?? 0)} rows read` : e.stage === "preparing" ? "Preparing the staging table" : e.stage === "importing" ? "Importing the rows" : e.stage === "completed" ? "Completed" : typeof e.error == "string" && e.error ? e.error : "Failed"
163
164
  })), te.current();
164
165
  });
165
166
  }, [o]);
166
- const De = (r == null ? void 0 : r.by_status) ?? {}, E = (r == null ? void 0 : r.active) ?? [], u = E.find((e) => e.status === "running") ?? E[0], Ae = E.filter((e) => e.id !== (u == null ? void 0 : u.id)).length, re = (r == null ? void 0 : r.by_key) ?? {}, ae = E.some((e) => e.status === "queued"), ne = L({
167
+ const Ie = (r == null ? void 0 : r.by_status) ?? {}, E = (r == null ? void 0 : r.active) ?? [], u = E.find((e) => e.status === "running") ?? E[0], Ae = E.filter((e) => e.id !== (u == null ? void 0 : u.id)).length, re = (r == null ? void 0 : r.by_key) ?? {}, ae = E.some((e) => e.status === "queued"), ne = L({
167
168
  queryKey: ["staged-import-queue"],
168
- queryFn: () => l.request(M("/staged-imports/queue")).then((e) => e.data ?? []),
169
+ queryFn: () => d.request(M("/staged-imports/queue")).then((e) => e.data ?? []),
169
170
  enabled: ae,
170
171
  refetchInterval: ae ? ge * 2 : !1,
171
172
  placeholderData: (e) => e
@@ -181,15 +182,15 @@ function Kt({
181
182
  { match: (e) => (e == null ? void 0 : e.kind) === "import", debounceMs: 400, includeOwn: !0 }
182
183
  );
183
184
  const oe = ue({
184
- mutationFn: (e) => l.request(xe(`/staged-imports/${e}/requeue`)),
185
+ mutationFn: (e) => d.request(xe(`/staged-imports/${e}/requeue`)),
185
186
  onSuccess: () => {
186
- A(null), b();
187
+ A(null), v();
187
188
  },
188
189
  onError: (e) => A(e.message)
189
- }), z = ue({
190
- mutationFn: (e) => l.request(xe(`/staged-imports/${e}/cancel`)),
190
+ }), B = ue({
191
+ mutationFn: (e) => d.request(xe(`/staged-imports/${e}/cancel`)),
191
192
  onSuccess: () => {
192
- A(null), b();
193
+ A(null), v();
193
194
  },
194
195
  onError: (e) => A(e.message)
195
196
  }), Ee = [
@@ -231,7 +232,7 @@ function Kt({
231
232
  header: "Rows",
232
233
  className: "w-[90px] text-right",
233
234
  headerClassName: "text-right",
234
- render: (e) => /* @__PURE__ */ t("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-700 dark:text-foreground", children: e.row_count == null ? "—" : v(e.row_count) })
235
+ render: (e) => /* @__PURE__ */ t("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-700 dark:text-foreground", children: e.row_count == null ? "—" : k(e.row_count) })
235
236
  },
236
237
  {
237
238
  key: "duration",
@@ -245,7 +246,7 @@ function Kt({
245
246
  header: "Queued by",
246
247
  className: "w-[150px]",
247
248
  render: (e) => {
248
- const n = ct(e);
249
+ const n = ut(e);
249
250
  return n ? e.created_by && _e ? /* @__PURE__ */ t(
250
251
  "button",
251
252
  {
@@ -283,15 +284,15 @@ function Kt({
283
284
  type: "button",
284
285
  className: "rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
285
286
  "aria-label": `Actions for run ${e.id}`,
286
- children: /* @__PURE__ */ t(ze, { className: "h-4 w-4" })
287
+ children: /* @__PURE__ */ t(Be, { className: "h-4 w-4" })
287
288
  }
288
289
  ) }),
289
290
  /* @__PURE__ */ a(tt, { align: "end", className: "text-[12.5px]", children: [
290
291
  /* @__PURE__ */ a(O, { onSelect: () => C(e.id), children: [
291
- /* @__PURE__ */ t(Be, { className: "h-3.5 w-3.5" }),
292
+ /* @__PURE__ */ t(ze, { className: "h-3.5 w-3.5" }),
292
293
  " View details"
293
294
  ] }),
294
- d && /* @__PURE__ */ a(
295
+ s && /* @__PURE__ */ a(
295
296
  O,
296
297
  {
297
298
  disabled: e.status === "running" || !e.file,
@@ -302,13 +303,13 @@ function Kt({
302
303
  ]
303
304
  }
304
305
  ),
305
- d && /* @__PURE__ */ a(
306
+ s && /* @__PURE__ */ a(
306
307
  O,
307
308
  {
308
309
  disabled: e.status === "completed",
309
- onSelect: () => z.mutate(e.id),
310
+ onSelect: () => B.mutate(e.id),
310
311
  children: [
311
- /* @__PURE__ */ t(ve, { className: "h-3.5 w-3.5" }),
312
+ /* @__PURE__ */ t(ye, { className: "h-3.5 w-3.5" }),
312
313
  " Cancel"
313
314
  ]
314
315
  }
@@ -316,19 +317,19 @@ function Kt({
316
317
  ] })
317
318
  ] }) })
318
319
  }
319
- ], B = h !== "all" || !!x || !!S.trim(), se = ((r == null ? void 0 : r.all_time_total) ?? 0) === 0 && !J.isLoading, Le = !B && !se && ((r == null ? void 0 : r.total) ?? 0) === 0 && g !== "0", Me = _ != null ? ee.find((e) => e.id === _) : void 0;
320
+ ], z = h !== "all" || !!x || !!S.trim(), se = ((r == null ? void 0 : r.all_time_total) ?? 0) === 0 && !J.isLoading, Le = !z && !se && ((r == null ? void 0 : r.total) ?? 0) === 0 && g !== "0", Me = _ != null ? ee.find((e) => e.id === _) : void 0;
320
321
  return /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
321
322
  /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2", children: [
322
- /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: ["runs", "collection", "definitions"].filter((e) => e === "runs" || d).map((e) => /* @__PURE__ */ t(
323
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: ["runs", "collection", "definitions"].filter((e) => e === "runs" || s).map((e) => /* @__PURE__ */ t(
323
324
  "button",
324
325
  {
325
326
  type: "button",
326
327
  onClick: () => H(e),
327
- className: I(
328
+ className: D(
328
329
  "rounded-md px-2.5 py-1 text-[12.5px] font-medium transition-colors",
329
- w === e ? "bg-nvr-cyan/15 text-nvr-navy dark:bg-nvr-cyan/20 dark:text-nvr-cyan" : "text-slate-500 hover:bg-slate-100 hover:text-slate-800 dark:text-muted-foreground dark:hover:bg-muted"
330
+ b === e ? "bg-nvr-cyan/15 text-nvr-navy dark:bg-nvr-cyan/20 dark:text-nvr-cyan" : "text-slate-500 hover:bg-slate-100 hover:text-slate-800 dark:text-muted-foreground dark:hover:bg-muted"
330
331
  ),
331
- children: pt[e]
332
+ children: ht[e]
332
333
  },
333
334
  e
334
335
  )) }),
@@ -339,20 +340,21 @@ function Kt({
339
340
  variant: "ghost",
340
341
  size: "sm",
341
342
  className: "h-7 px-2",
342
- onClick: b,
343
+ onClick: v,
343
344
  "aria-label": "Refresh",
344
345
  children: /* @__PURE__ */ t(
345
346
  Qe,
346
347
  {
347
- className: I(
348
+ className: D(
348
349
  "h-3.5 w-3.5",
349
- w === "runs" && q.isFetching && "motion-safe:animate-spin"
350
+ b === "runs" && q.isFetching && "motion-safe:animate-spin"
350
351
  )
351
352
  }
352
353
  )
353
354
  }
354
355
  ),
355
- d && w === "runs" && /* @__PURE__ */ a(y, { size: "sm", className: "h-7", onClick: () => Q(!0), children: [
356
+ s && b === "runs" && /* @__PURE__ */ t(ot, { definitions: f.filter((e) => e.is_active) }),
357
+ s && b === "runs" && /* @__PURE__ */ a(y, { size: "sm", className: "h-7", onClick: () => Q(!0), children: [
356
358
  /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
357
359
  "New import"
358
360
  ] })
@@ -362,28 +364,28 @@ function Kt({
362
364
  /* @__PURE__ */ t(Te, { className: "h-3.5 w-3.5 shrink-0" }),
363
365
  Z
364
366
  ] }),
365
- w === "collection" ? /* @__PURE__ */ t(rt, { initialJobId: i, onJobOpen: m }) : w === "definitions" ? /* @__PURE__ */ t(
367
+ b === "collection" ? /* @__PURE__ */ t(rt, { initialJobId: l, onJobOpen: m }) : b === "definitions" ? /* @__PURE__ */ t(
366
368
  nt,
367
369
  {
368
370
  definitions: f,
369
371
  runCounts: re,
370
372
  isLoading: T.isLoading,
371
- initialKey: D
373
+ initialKey: I
372
374
  }
373
375
  ) : /* @__PURE__ */ a(Ke, { children: [
374
376
  u && /* @__PURE__ */ t(
375
- ht,
377
+ xt,
376
378
  {
377
379
  run: u,
378
380
  queuedCount: Ae,
379
381
  stage: X[u.id] ?? null,
380
382
  standing: fe(F.get(u.id)),
381
- canManage: d,
383
+ canManage: s,
382
384
  onOpen: () => C(u.id),
383
- onCancel: () => z.mutate(u.id)
385
+ onCancel: () => B.mutate(u.id)
384
386
  }
385
387
  ),
386
- d && f.length > 0 && /* @__PURE__ */ t(
388
+ s && f.length > 0 && /* @__PURE__ */ t(
387
389
  at,
388
390
  {
389
391
  definitions: f,
@@ -393,7 +395,7 @@ function Kt({
393
395
  ),
394
396
  /* @__PURE__ */ a("div", { className: "flex flex-wrap items-stretch divide-x divide-slate-200 overflow-hidden rounded-lg border border-slate-200 bg-white dark:divide-border dark:border-border dark:bg-card", children: [
395
397
  /* @__PURE__ */ t(
396
- ye,
398
+ ve,
397
399
  {
398
400
  label: "All",
399
401
  count: (r == null ? void 0 : r.total) ?? null,
@@ -401,12 +403,12 @@ function Kt({
401
403
  onClick: () => R("all")
402
404
  }
403
405
  ),
404
- lt.map((e) => /* @__PURE__ */ t(
405
- ye,
406
+ dt.map((e) => /* @__PURE__ */ t(
407
+ ve,
406
408
  {
407
409
  label: ke[e].label,
408
410
  status: e,
409
- count: De[e] ?? 0,
411
+ count: Ie[e] ?? 0,
410
412
  active: h === e,
411
413
  onClick: () => R(h === e ? "all" : e)
412
414
  },
@@ -425,7 +427,7 @@ function Kt({
425
427
  U,
426
428
  {
427
429
  label: "Rows imported",
428
- value: r ? v(r.rows_imported) : "—"
430
+ value: r ? k(r.rows_imported) : "—"
429
431
  }
430
432
  ),
431
433
  /* @__PURE__ */ t(
@@ -436,12 +438,12 @@ function Kt({
436
438
  sub: "completed runs"
437
439
  }
438
440
  ),
439
- /* @__PURE__ */ t("div", { className: "flex items-center gap-0.5 px-2.5 py-2", children: mt.map((e) => /* @__PURE__ */ t(
441
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-0.5 px-2.5 py-2", children: pt.map((e) => /* @__PURE__ */ t(
440
442
  "button",
441
443
  {
442
444
  type: "button",
443
445
  onClick: () => Y(e.value),
444
- className: I(
446
+ className: D(
445
447
  "rounded px-1.5 py-1 text-[11px] font-medium transition-colors",
446
448
  g === e.value ? "bg-nvr-cyan/15 text-nvr-navy dark:bg-nvr-cyan/20 dark:text-nvr-cyan" : "text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted"
447
449
  ),
@@ -455,7 +457,7 @@ function Kt({
455
457
  /* @__PURE__ */ t(Fe, { className: "h-5 w-5 text-slate-300" }),
456
458
  /* @__PURE__ */ t("h3", { className: "mt-3 text-[15px] font-semibold text-slate-900 dark:text-foreground", children: "No imports have run yet" }),
457
459
  /* @__PURE__ */ t("p", { className: "mt-1.5 text-[12.5px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: "An import reads a file and brings its rows into the records it is defined for. Runs are queued here and picked up by the worker within a few seconds. Runs that share a staging table go one at a time; others run side by side." }),
458
- d && /* @__PURE__ */ a("div", { className: "mt-4 flex items-center gap-2", children: [
460
+ s && /* @__PURE__ */ a("div", { className: "mt-4 flex items-center gap-2", children: [
459
461
  /* @__PURE__ */ a(y, { size: "sm", onClick: () => Q(!0), children: [
460
462
  /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
461
463
  " Queue an import"
@@ -465,7 +467,7 @@ function Kt({
465
467
  ] }) }) : /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
466
468
  Le && /* @__PURE__ */ a("p", { className: "flex flex-wrap items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-2 text-[12px] text-slate-600 dark:border-border dark:bg-card dark:text-muted-foreground", children: [
467
469
  "Nothing ran in this window. All ",
468
- v((r == null ? void 0 : r.all_time_total) ?? 0),
470
+ k((r == null ? void 0 : r.all_time_total) ?? 0),
469
471
  " runs on record are older than it.",
470
472
  /* @__PURE__ */ t(
471
473
  "button",
@@ -500,7 +502,7 @@ function Kt({
500
502
  // placeholder as its own clear-selection item, and a second
501
503
  // option with an empty value is what Radix rejects.
502
504
  placeholder: "All imports",
503
- options: f.map((e) => ({ label: dt(e), value: e.key }))
505
+ options: f.map((e) => ({ label: ct(e), value: e.key }))
504
506
  }
505
507
  ],
506
508
  filterValues: { key: x },
@@ -508,9 +510,9 @@ function Kt({
508
510
  onRowClick: (e) => C(e.id),
509
511
  nowrapCells: !0,
510
512
  minBodyHeight: 280,
511
- emptyMessage: B ? "No runs match these filters." : "No runs in this window — widen it above.",
513
+ emptyMessage: z ? "No runs match these filters." : "No runs in this window — widen it above.",
512
514
  rowClassName: (e) => e.status === "running" ? "bg-nvr-cyan/5 dark:bg-nvr-cyan/10" : void 0,
513
- toolbarRight: B ? /* @__PURE__ */ t(
515
+ toolbarRight: z ? /* @__PURE__ */ t(
514
516
  y,
515
517
  {
516
518
  variant: "ghost",
@@ -527,31 +529,31 @@ function Kt({
527
529
  ] })
528
530
  ] }),
529
531
  /* @__PURE__ */ t(
530
- st,
532
+ it,
531
533
  {
532
534
  run: Me,
533
535
  runId: _,
534
536
  stage: _ != null ? X[_] ?? null : null,
535
- isAdmin: d,
537
+ isAdmin: s,
536
538
  onClose: () => C(null),
537
539
  onRequeue: (e) => oe.mutate(e),
538
- onCancel: (e) => z.mutate(e)
540
+ onCancel: (e) => B.mutate(e)
539
541
  }
540
542
  ),
541
- d && /* @__PURE__ */ t(
542
- ot,
543
+ s && /* @__PURE__ */ t(
544
+ st,
543
545
  {
544
546
  open: Se,
545
547
  onOpenChange: Q,
546
548
  definitions: f.filter((e) => e.is_active),
547
549
  runCounts: re,
548
550
  onQueued: (e) => {
549
- b(), C(e);
551
+ v(), C(e);
550
552
  }
551
553
  }
552
554
  )
553
555
  ] });
554
556
  }
555
557
  export {
556
- Kt as ImportConsole
558
+ Qt as ImportConsole
557
559
  };
@@ -3,11 +3,11 @@ import { useQueryClient as oe, useQuery as X, useMutation as Y } from "@tanstack
3
3
  import { FileSpreadsheet as Ne, Download as Z, RotateCcw as ve, Undo2 as ee, Ban as we, ArrowRight as ye, AlertTriangle as Ce, Loader2 as H, Search as _e, ChevronDown as ie, ChevronRight as ce, Check as ue, Copy as me, ExternalLink as $e } from "lucide-react";
4
4
  import { useState as N, useEffect as he, useMemo as pe } from "react";
5
5
  import { useNivaroClient as te, useApiFetchConfig as Re, useItemNavigation as Se } from "../../context.js";
6
- import { ExplainButton as Te } from "../ai/ExplainButton.js";
7
- import { useDebounced as Le } from "../../hooks/useDebounced.js";
6
+ import { useDebounced as Te } from "../../hooks/useDebounced.js";
8
7
  import { get as xe, post as J } from "../../lib/commands.js";
9
- import { parseImportLog as qe } from "../../lib/import-log.js";
10
- import { formatDateTime as se, formatNumber as h, cn as b, formatFileSize as Ee, titleCase as Fe } from "../../lib/utils.js";
8
+ import { parseImportLog as Le } from "../../lib/import-log.js";
9
+ import { formatDateTime as se, formatNumber as h, cn as b, formatFileSize as qe, titleCase as Ee } from "../../lib/utils.js";
10
+ import { ExplainButton as Fe } from "../ai/ExplainButton.js";
11
11
  import { Button as S } from "../ui/button.js";
12
12
  import { Input as Ke } from "../ui/input.js";
13
13
  import { Sheet as Pe, SheetContent as De, SheetTitle as je, SheetDescription as Me } from "../ui/sheet.js";
@@ -57,7 +57,7 @@ const B = 50, K = {
57
57
  bar: "bg-[#ef4444]",
58
58
  dot: "bg-[#ef4444]"
59
59
  }
60
- }, v = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0ea5e9]/60 focus-visible:ring-offset-0", ge = (t) => Fe(
60
+ }, v = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0ea5e9]/60 focus-visible:ring-offset-0", ge = (t) => Ee(
61
61
  String(t ?? "").replace(/_junction$/i, " links").replace(/_/g, " ")
62
62
  );
63
63
  function le(t) {
@@ -497,7 +497,7 @@ function Ie({
497
497
  live: c
498
498
  }) {
499
499
  var O, U, z;
500
- const p = te(), u = oe(), { download: s, busy: g, error: r } = ke(), [f, x] = N(""), [m, Q] = N(null), [w, L] = N(1), [q, D] = N(null), C = Le(f, 300);
500
+ const p = te(), u = oe(), { download: s, busy: g, error: r } = ke(), [f, x] = N(""), [m, Q] = N(null), [w, L] = N(1), [q, D] = N(null), C = Te(f, 300);
501
501
  he(() => L(1), [o, m, C, t]);
502
502
  const _ = { kind: o ?? "", collection: m ?? "", search: C, page: w, limit: B }, y = X({
503
503
  queryKey: ["staged-import-run-items", t, _],
@@ -1014,7 +1014,7 @@ function Nt({
1014
1014
  /* @__PURE__ */ e(Ne, { className: "h-4 w-4 shrink-0 text-slate-400" }),
1015
1015
  /* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
1016
1016
  /* @__PURE__ */ e("p", { className: "truncate font-mono text-[11.5px] text-slate-800 dark:text-foreground", children: r.file_name ?? r.file }),
1017
- r.file_size != null && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: Ee(Number(r.file_size)) })
1017
+ r.file_size != null && /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-500 dark:text-muted-foreground", children: qe(Number(r.file_size)) })
1018
1018
  ] }),
1019
1019
  m && /* @__PURE__ */ e(
1020
1020
  "a",
@@ -1033,7 +1033,7 @@ function Nt({
1033
1033
  ] }) : /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: "No file is attached, so this run cannot be queued again." })
1034
1034
  ] }),
1035
1035
  l && r.status !== "running" && (r.status === "error" || (r.duration ?? 0) >= Ye) && /* @__PURE__ */ e("section", { "data-run-explain": !0, children: /* @__PURE__ */ e(
1036
- Te,
1036
+ Fe,
1037
1037
  {
1038
1038
  kind: "import-run",
1039
1039
  params: { id: r.id },
@@ -1263,7 +1263,7 @@ function rt({ error: t }) {
1263
1263
  }
1264
1264
  function de({ run: t }) {
1265
1265
  const [n, o] = N(!1), l = pe(
1266
- () => qe(t.logs, t.status === "error"),
1266
+ () => Le(t.logs, t.status === "error"),
1267
1267
  [t.logs, t.status]
1268
1268
  );
1269
1269
  if (!t.logs)
@@ -1329,5 +1329,6 @@ function de({ run: t }) {
1329
1329
  ] });
1330
1330
  }
1331
1331
  export {
1332
- Nt as RunDetailSheet
1332
+ Nt as RunDetailSheet,
1333
+ ke as useDownload
1333
1334
  };