@lumerahq/ui 0.12.0-dev.0 → 0.12.0-dev.2

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import React__default, { useContext, createContext, forwardRef, createElement, memo, useId as useId$1, useTransition, useMemo, useRef, useEffect, useState, cloneElement, isValidElement, useCallback, Suspense, lazy, Fragment as Fragment$1, useLayoutEffect } from "react";
4
- import { u as useAgentChat, a as useAgentChatSessions, g as getRecordAuditLogSnapshot, d as auditLogDetailValue, e as auditLogActorLabel, n as normalizeRecordAuditCollections, A as AUDIT_LOG_MAX_COLLECTIONS, b as useAuditLog, f as fetchRecordAuditLogCsv, h as AUDIT_LOG_EXPORT_LIMIT, c as useAutomationRun } from "./use-automation-run-BrghacFY.js";
4
+ import { u as useAgentChat, a as useAgentChatSessions, g as getRecordAuditLogSnapshot, d as auditLogSummaryWithCollectionLabel, e as auditLogDetailValue, f as auditLogActorLabel, n as normalizeRecordAuditCollections, h as normalizeAuditLogFilterState, A as AUDIT_LOG_MAX_COLLECTIONS, b as useAuditLog, i as fetchRecordAuditLogCsv, j as normalizeAuditLogExportLimit, c as useAutomationRun } from "./use-automation-run-DmMpzFCS.js";
5
5
  import { t as twMerge, p as clsx, o as cn$2, a as formatCellValue$2 } from "./formatters-D4T821Dv.js";
6
6
  import { f as getDownloadUrl, t as pbSql, p as parentApiRequest, d as parentApiStream, B as BridgeError, z as automationStatuses, L as getAutomationRunFileDownloadUrl, R as listAutomationRunFiles } from "./automations-EgDXJ43_.js";
7
7
  import * as ReactDOM from "react-dom";
@@ -86,24 +86,24 @@ const createLucideIcon = (iconName, iconNode) => {
86
86
  Component.displayName = toPascalCase(iconName);
87
87
  return Component;
88
88
  };
89
- const __iconNode$J = [
89
+ const __iconNode$K = [
90
90
  ["path", { d: "M12 5v14", key: "s699le" }],
91
91
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
92
92
  ];
93
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$J);
94
- const __iconNode$I = [
93
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$K);
94
+ const __iconNode$J = [
95
95
  ["path", { d: "m21 16-4 4-4-4", key: "f6ql7i" }],
96
96
  ["path", { d: "M17 20V4", key: "1ejh1v" }],
97
97
  ["path", { d: "m3 8 4-4 4 4", key: "11wl7u" }],
98
98
  ["path", { d: "M7 4v16", key: "1glfcx" }]
99
99
  ];
100
- const ArrowUpDown = createLucideIcon("arrow-up-down", __iconNode$I);
101
- const __iconNode$H = [
100
+ const ArrowUpDown = createLucideIcon("arrow-up-down", __iconNode$J);
101
+ const __iconNode$I = [
102
102
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
103
103
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
104
104
  ];
105
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$H);
106
- const __iconNode$G = [
105
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$I);
106
+ const __iconNode$H = [
107
107
  ["path", { d: "M12 8V4H8", key: "hb8ula" }],
108
108
  ["rect", { width: "16", height: "12", x: "4", y: "8", rx: "2", key: "enze0r" }],
109
109
  ["path", { d: "M2 14h2", key: "vft8re" }],
@@ -111,8 +111,8 @@ const __iconNode$G = [
111
111
  ["path", { d: "M15 13v2", key: "1xurst" }],
112
112
  ["path", { d: "M9 13v2", key: "rq6x2g" }]
113
113
  ];
114
- const Bot = createLucideIcon("bot", __iconNode$G);
115
- const __iconNode$F = [
114
+ const Bot = createLucideIcon("bot", __iconNode$H);
115
+ const __iconNode$G = [
116
116
  ["path", { d: "M12 18V5", key: "adv99a" }],
117
117
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
118
118
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -122,27 +122,33 @@ const __iconNode$F = [
122
122
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
123
123
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
124
124
  ];
125
- const Brain = createLucideIcon("brain", __iconNode$F);
126
- const __iconNode$E = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
127
- const Check = createLucideIcon("check", __iconNode$E);
128
- const __iconNode$D = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
129
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$D);
130
- const __iconNode$C = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
131
- const ChevronLeft = createLucideIcon("chevron-left", __iconNode$C);
132
- const __iconNode$B = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
133
- const ChevronRight = createLucideIcon("chevron-right", __iconNode$B);
134
- const __iconNode$A = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
135
- const ChevronUp = createLucideIcon("chevron-up", __iconNode$A);
136
- const __iconNode$z = [
125
+ const Brain = createLucideIcon("brain", __iconNode$G);
126
+ const __iconNode$F = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
127
+ const Check = createLucideIcon("check", __iconNode$F);
128
+ const __iconNode$E = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
129
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$E);
130
+ const __iconNode$D = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
131
+ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$D);
132
+ const __iconNode$C = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
133
+ const ChevronRight = createLucideIcon("chevron-right", __iconNode$C);
134
+ const __iconNode$B = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
135
+ const ChevronUp = createLucideIcon("chevron-up", __iconNode$B);
136
+ const __iconNode$A = [
137
137
  ["path", { d: "m11 17-5-5 5-5", key: "13zhaf" }],
138
138
  ["path", { d: "m18 17-5-5 5-5", key: "h8a8et" }]
139
139
  ];
140
- const ChevronsLeft = createLucideIcon("chevrons-left", __iconNode$z);
141
- const __iconNode$y = [
140
+ const ChevronsLeft = createLucideIcon("chevrons-left", __iconNode$A);
141
+ const __iconNode$z = [
142
142
  ["path", { d: "m6 17 5-5-5-5", key: "xnjwq" }],
143
143
  ["path", { d: "m13 17 5-5-5-5", key: "17xmmf" }]
144
144
  ];
145
- const ChevronsRight = createLucideIcon("chevrons-right", __iconNode$y);
145
+ const ChevronsRight = createLucideIcon("chevrons-right", __iconNode$z);
146
+ const __iconNode$y = [
147
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
148
+ ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
149
+ ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
150
+ ];
151
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$y);
146
152
  const __iconNode$x = [
147
153
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
148
154
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
@@ -24035,7 +24041,7 @@ var lr = (e) => {
24035
24041
  for (; t > 0 && e[t - 1] === `
24036
24042
  `; ) t--;
24037
24043
  return e.slice(0, t);
24038
- }, cr = lazy(() => import("./highlighted-body-OFNGDK62-DD5EYZQR.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), st = ({ code: e, language: t, className: o, children: n, isIncomplete: r = false, startLine: s2, lineNumbers: a, ...l }) => {
24044
+ }, cr = lazy(() => import("./highlighted-body-OFNGDK62-DzatZiEq.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), st = ({ code: e, language: t, className: o, children: n, isIncomplete: r = false, startLine: s2, lineNumbers: a, ...l }) => {
24039
24045
  let i = y2(), d2 = useMemo(() => lr(e), [e]), c2 = useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: d2.split(`
24040
24046
  `).map((p2) => [{ content: p2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [d2]);
24041
24047
  return jsx(nt.Provider, { value: { code: e }, children: jsxs(ot, { isIncomplete: r, language: t, children: [jsx(rt, { language: t }), n ? jsx("div", { className: i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"), children: jsx("div", { className: i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"), "data-streamdown": "code-block-actions", children: n }) }) : null, jsx(Suspense, { fallback: jsx(At, { className: o, language: t, lineNumbers: a, result: c2, startLine: s2, ...l }), children: jsx(cr, { className: o, code: d2, language: t, lineNumbers: a, raw: c2, startLine: s2, ...l }) })] }) });
@@ -24397,7 +24403,7 @@ var vo = ({ children: e, className: t, showControls: o, showCopy: n = true, show
24397
24403
  let l = y2(), i = o && n, d2 = o && r, c2 = o && s2, p2 = i || d2 || c2;
24398
24404
  return jsxs("div", { className: l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"), "data-streamdown": "table-wrapper", children: [p2 ? jsxs("div", { className: l("flex items-center justify-end gap-1"), children: [i ? jsx(Te, {}) : null, d2 ? jsx(Pe, {}) : null, c2 ? jsx(Co, { showCopy: i, showDownload: d2, children: e }) : null] }) : null, jsx("div", { className: l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"), children: jsx("table", { className: l("w-full divide-y divide-border", t), "data-streamdown": "table", ...a, children: e }) })] });
24399
24405
  };
24400
- var es = /startLine=(\d+)/, ts = /\bnoLineNumbers\b/, os = lazy(() => import("./mermaid-GHXKKRXX-BdrbO7XD.js").then((e) => ({ default: e.Mermaid }))), ns = /language-([^\s]+)/;
24406
+ var es = /startLine=(\d+)/, ts = /\bnoLineNumbers\b/, os = lazy(() => import("./mermaid-GHXKKRXX-BPtfcw6Y.js").then((e) => ({ default: e.Mermaid }))), ns = /language-([^\s]+)/;
24401
24407
  function qe(e, t) {
24402
24408
  if (!(e != null && e.position || t != null && t.position)) return true;
24403
24409
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -29533,6 +29539,26 @@ const markerStyles = {
29533
29539
  updated: "bg-sky-500",
29534
29540
  deleted: "bg-rose-500"
29535
29541
  };
29542
+ const systemFieldKeys = /* @__PURE__ */ new Set([
29543
+ "id",
29544
+ "created",
29545
+ "updated",
29546
+ "created_by",
29547
+ "updated_by",
29548
+ "created_by_actor_type",
29549
+ "updated_by_actor_type",
29550
+ "external_id",
29551
+ "lm_provenance"
29552
+ ]);
29553
+ const identityFieldKeys = /* @__PURE__ */ new Set(["collection", "collection_id", "record_id"]);
29554
+ const fieldKey = (field) => field.key?.trim().toLowerCase() || field.label.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
29555
+ const displayFields = (fields, fieldLabels, showSystemFields) => {
29556
+ if (!fields) return null;
29557
+ return fields.filter((field) => showSystemFields || !systemFieldKeys.has(fieldKey(field))).map((field) => {
29558
+ const label = field.key && fieldLabels?.[field.key] || fieldLabels?.[field.label] || fieldLabels?.[fieldKey(field)];
29559
+ return label?.trim() ? { ...field, label: label.trim() } : field;
29560
+ });
29561
+ };
29536
29562
  function FieldValue({ field }) {
29537
29563
  if (field.json !== void 0) {
29538
29564
  return /* @__PURE__ */ jsx("pre", { className: "max-h-48 overflow-auto rounded-lg bg-background p-3 text-xs", children: JSON.stringify(field.json, null, 2) });
@@ -29543,10 +29569,36 @@ function FieldValue({ field }) {
29543
29569
  ] });
29544
29570
  }
29545
29571
  function FieldList({ fields }) {
29546
- return /* @__PURE__ */ jsx("dl", { className: "divide-y divide-border/70", children: fields.map((field, index2) => /* @__PURE__ */ jsxs("div", { className: "grid gap-1 py-2.5 sm:grid-cols-[9rem_1fr] sm:gap-4", children: [
29547
- /* @__PURE__ */ jsx("dt", { className: "text-xs font-medium text-muted-foreground", children: field.label }),
29548
- /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(FieldValue, { field }) })
29549
- ] }, `${field.label}-${index2}`)) });
29572
+ return /* @__PURE__ */ jsx("dl", { className: "divide-y divide-border/70", children: fields.map((field, index2) => /* @__PURE__ */ jsxs(
29573
+ "div",
29574
+ {
29575
+ className: "grid gap-1 py-2.5 sm:grid-cols-[9rem_1fr] sm:gap-4",
29576
+ children: [
29577
+ /* @__PURE__ */ jsx("dt", { className: "text-xs font-medium text-muted-foreground", children: field.label }),
29578
+ /* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(FieldValue, { field }) })
29579
+ ]
29580
+ },
29581
+ `${field.key || field.label}-${index2}`
29582
+ )) });
29583
+ }
29584
+ function FieldGroups({ fields }) {
29585
+ const groups = [
29586
+ { title: "Changed fields", fields: [] },
29587
+ { title: "Record identity", fields: [] },
29588
+ { title: "System/debug fields", fields: [] },
29589
+ { title: "Other details", fields: [] }
29590
+ ];
29591
+ for (const field of fields) {
29592
+ const key = fieldKey(field);
29593
+ if (field.changed || field.value.includes("→")) groups[0].fields.push(field);
29594
+ else if (identityFieldKeys.has(key)) groups[1].fields.push(field);
29595
+ else if (systemFieldKeys.has(key)) groups[2].fields.push(field);
29596
+ else groups[3].fields.push(field);
29597
+ }
29598
+ return /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: groups.filter((group) => group.fields.length > 0).map((group) => /* @__PURE__ */ jsxs("section", { className: "min-w-0", children: [
29599
+ /* @__PURE__ */ jsx("p", { className: "mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: group.title }),
29600
+ /* @__PURE__ */ jsx(FieldList, { fields: group.fields })
29601
+ ] }, group.title)) });
29550
29602
  }
29551
29603
  function SnapshotSide({ label, fields }) {
29552
29604
  return /* @__PURE__ */ jsxs("div", { className: "min-w-0 rounded-xl border bg-background p-3", children: [
@@ -29554,7 +29606,19 @@ function SnapshotSide({ label, fields }) {
29554
29606
  fields?.length ? /* @__PURE__ */ jsx(FieldList, { fields }) : /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-muted-foreground", children: "No values" })
29555
29607
  ] });
29556
29608
  }
29557
- function AuditLogEntry({ entry }) {
29609
+ function AuditLogEntry({
29610
+ entry,
29611
+ collectionLabel,
29612
+ activityCollectionLabel,
29613
+ density,
29614
+ showCollectionColumn,
29615
+ showActorColumn,
29616
+ showSystemFields,
29617
+ fieldLabels,
29618
+ columnCount,
29619
+ getRecordHref,
29620
+ onRecordClick
29621
+ }) {
29558
29622
  const detailsID = `${useId$1()}-details`;
29559
29623
  const [expanded, setExpanded] = useState(false);
29560
29624
  const snapshotQuery = useQuery({
@@ -29564,45 +29628,95 @@ function AuditLogEntry({ entry }) {
29564
29628
  staleTime: Number.POSITIVE_INFINITY,
29565
29629
  retry: false
29566
29630
  });
29631
+ const detailFields = displayFields(entry.details, fieldLabels, showSystemFields) ?? [];
29632
+ const recordHref = getRecordHref?.(entry)?.trim();
29633
+ const rowPadding = density === "comfortable" ? "py-4" : void 0;
29634
+ const summary = activityCollectionLabel ? auditLogSummaryWithCollectionLabel(entry, activityCollectionLabel) : entry.summary;
29635
+ const recordAction = recordHref ? /* @__PURE__ */ jsxs(
29636
+ "a",
29637
+ {
29638
+ href: recordHref,
29639
+ className: buttonVariants({ variant: "ghost", size: "xs", className: "text-xs" }),
29640
+ title: "Open record",
29641
+ onClick: () => onRecordClick?.(entry),
29642
+ children: [
29643
+ /* @__PURE__ */ jsx(ExternalLink, { "aria-hidden": true }),
29644
+ /* @__PURE__ */ jsx("span", { children: "Open record" })
29645
+ ]
29646
+ }
29647
+ ) : onRecordClick ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "ghost", size: "xs", title: "Open record", onClick: () => onRecordClick(entry), children: [
29648
+ /* @__PURE__ */ jsx(ExternalLink, {}),
29649
+ "Open record"
29650
+ ] }) : null;
29567
29651
  return /* @__PURE__ */ jsxs(Fragment, { children: [
29568
29652
  /* @__PURE__ */ jsxs(TableRow, { "aria-expanded": expanded, children: [
29569
- /* @__PURE__ */ jsx(TableCell, { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ jsx("time", { dateTime: entry.occurred_at, title: new Date(entry.occurred_at).toLocaleString(), children: relativeTime(entry.occurred_at) }) }),
29570
- /* @__PURE__ */ jsx(TableCell, { className: "max-w-48 truncate font-mono text-xs", title: auditLogDetailValue(entry, "Collection"), children: auditLogDetailValue(entry, "Collection") || "—" }),
29571
- /* @__PURE__ */ jsx(TableCell, { className: "min-w-64 whitespace-normal", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2.5", children: [
29653
+ /* @__PURE__ */ jsx(TableCell, { className: cn$2("text-xs text-muted-foreground", rowPadding), children: /* @__PURE__ */ jsx("time", { dateTime: entry.occurred_at, title: new Date(entry.occurred_at).toLocaleString(), children: relativeTime(entry.occurred_at) }) }),
29654
+ showCollectionColumn ? /* @__PURE__ */ jsx(
29655
+ TableCell,
29656
+ {
29657
+ className: cn$2("max-w-48 truncate text-xs", rowPadding),
29658
+ title: auditLogDetailValue(entry, "Collection"),
29659
+ children: collectionLabel || "—"
29660
+ }
29661
+ ) : null,
29662
+ /* @__PURE__ */ jsx(TableCell, { className: cn$2("min-w-64 whitespace-normal", rowPadding), children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2.5", children: [
29572
29663
  /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cn$2("mt-1.5 size-2 shrink-0 rounded-full", markerStyles[entry.event]) }),
29573
- /* @__PURE__ */ jsx("span", { children: entry.summary.map((segment, index2) => /* @__PURE__ */ jsxs("span", { children: [
29664
+ /* @__PURE__ */ jsx("span", { children: summary.map((segment, index2) => /* @__PURE__ */ jsxs("span", { children: [
29574
29665
  index2 > 0 ? " " : "",
29575
29666
  /* @__PURE__ */ jsx("span", { className: segment.emphasis === "strong" ? "font-semibold" : void 0, children: segment.text })
29576
29667
  ] }, `${segment.text}-${index2}`)) })
29577
29668
  ] }) }),
29578
- /* @__PURE__ */ jsx(TableCell, { className: "max-w-48 truncate text-xs", title: auditLogActorLabel(entry.actor), children: auditLogActorLabel(entry.actor) }),
29579
- /* @__PURE__ */ jsx(TableCell, { className: "w-12 text-right", children: /* @__PURE__ */ jsx(
29580
- Button2,
29581
- {
29582
- type: "button",
29583
- variant: "ghost",
29584
- size: "icon-sm",
29585
- "aria-label": expanded ? "Hide audit details" : "Show audit details",
29586
- "aria-expanded": expanded,
29587
- "aria-controls": detailsID,
29588
- onClick: () => setExpanded((value) => !value),
29589
- children: /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn$2("transition-transform", expanded && "rotate-180") })
29590
- }
29591
- ) })
29669
+ showActorColumn ? /* @__PURE__ */ jsx(TableCell, { className: cn$2("max-w-48 truncate text-xs", rowPadding), title: auditLogActorLabel(entry.actor), children: auditLogActorLabel(entry.actor) }) : null,
29670
+ /* @__PURE__ */ jsx(TableCell, { className: cn$2("text-right", rowPadding), children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-0.5", children: [
29671
+ recordAction,
29672
+ /* @__PURE__ */ jsx(
29673
+ Button2,
29674
+ {
29675
+ type: "button",
29676
+ variant: "ghost",
29677
+ size: "icon-sm",
29678
+ "aria-label": expanded ? "Hide audit details" : "Show audit details",
29679
+ "aria-expanded": expanded,
29680
+ "aria-controls": detailsID,
29681
+ onClick: () => setExpanded((value) => !value),
29682
+ children: /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn$2("transition-transform", expanded && "rotate-180") })
29683
+ }
29684
+ )
29685
+ ] }) })
29592
29686
  ] }),
29593
- expanded ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsxs(TableCell, { id: detailsID, colSpan: 5, className: "bg-muted/20 p-4 whitespace-normal", children: [
29594
- entry.details.length > 0 ? /* @__PURE__ */ jsx(FieldList, { fields: entry.details }) : null,
29595
- entry.has_snapshot ? /* @__PURE__ */ jsxs("div", { className: cn$2(entry.details.length > 0 && "mt-4 border-t pt-4"), children: [
29596
- /* @__PURE__ */ jsx("p", { className: "mb-3 text-sm font-medium", children: "Before and after" }),
29597
- snapshotQuery.isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 py-4 text-sm text-muted-foreground", children: [
29598
- /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }),
29599
- " Loading values…"
29600
- ] }) : snapshotQuery.isError ? /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-destructive", children: "Could not load the before and after values." }) : snapshotQuery.data?.snapshot ? /* @__PURE__ */ jsxs("div", { className: "grid gap-3 lg:grid-cols-2", children: [
29601
- /* @__PURE__ */ jsx(SnapshotSide, { label: "Before", fields: snapshotQuery.data.snapshot.before }),
29602
- /* @__PURE__ */ jsx(SnapshotSide, { label: "After", fields: snapshotQuery.data.snapshot.after })
29603
- ] }) : /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-muted-foreground", children: "No before and after values are available." })
29604
- ] }) : null
29605
- ] }) }) : null
29687
+ expanded ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsxs(
29688
+ TableCell,
29689
+ {
29690
+ id: detailsID,
29691
+ colSpan: columnCount,
29692
+ className: cn$2("bg-muted/20 whitespace-normal", density === "comfortable" ? "p-5" : "p-4"),
29693
+ children: [
29694
+ detailFields.length > 0 ? /* @__PURE__ */ jsx(FieldGroups, { fields: detailFields }) : null,
29695
+ entry.has_snapshot ? /* @__PURE__ */ jsxs("div", { className: cn$2(detailFields.length > 0 && "mt-4 border-t pt-4"), children: [
29696
+ /* @__PURE__ */ jsx("p", { className: "mb-3 text-sm font-medium", children: "Before and after" }),
29697
+ snapshotQuery.isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 py-4 text-sm text-muted-foreground", children: [
29698
+ /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }),
29699
+ " Loading values…"
29700
+ ] }) : snapshotQuery.isError ? /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-destructive", children: "Could not load the before and after values." }) : snapshotQuery.data?.snapshot ? /* @__PURE__ */ jsxs("div", { className: "grid gap-3 lg:grid-cols-2", children: [
29701
+ /* @__PURE__ */ jsx(
29702
+ SnapshotSide,
29703
+ {
29704
+ label: "Before",
29705
+ fields: displayFields(snapshotQuery.data.snapshot.before, fieldLabels, showSystemFields)
29706
+ }
29707
+ ),
29708
+ /* @__PURE__ */ jsx(
29709
+ SnapshotSide,
29710
+ {
29711
+ label: "After",
29712
+ fields: displayFields(snapshotQuery.data.snapshot.after, fieldLabels, showSystemFields)
29713
+ }
29714
+ )
29715
+ ] }) : /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-muted-foreground", children: "No before and after values are available." })
29716
+ ] }) : null
29717
+ ]
29718
+ }
29719
+ ) }) : null
29606
29720
  ] });
29607
29721
  }
29608
29722
  const MenuPositionerContext = /* @__PURE__ */ React.createContext(void 0);
@@ -30418,6 +30532,51 @@ const MenuGroupLabel = /* @__PURE__ */ React.forwardRef(function MenuGroupLabelC
30418
30532
  });
30419
30533
  });
30420
30534
  if (process.env.NODE_ENV !== "production") MenuGroupLabel.displayName = "MenuGroupLabel";
30535
+ const MenuItem = /* @__PURE__ */ React.forwardRef(function MenuItem2(componentProps, forwardedRef) {
30536
+ const {
30537
+ render,
30538
+ className,
30539
+ id: idProp,
30540
+ label,
30541
+ nativeButton = false,
30542
+ disabled = false,
30543
+ closeOnClick = true,
30544
+ ...elementProps
30545
+ } = componentProps;
30546
+ const listItem2 = useCompositeListItem({
30547
+ label
30548
+ });
30549
+ const menuPositionerContext = useMenuPositionerContext(true);
30550
+ const id = useBaseUiId(idProp);
30551
+ const {
30552
+ store
30553
+ } = useMenuRootContext();
30554
+ const highlighted = store.useState("isActive", listItem2.index);
30555
+ const itemProps = store.useState("itemProps");
30556
+ const {
30557
+ getItemProps,
30558
+ itemRef
30559
+ } = useMenuItem({
30560
+ closeOnClick,
30561
+ disabled,
30562
+ highlighted,
30563
+ id,
30564
+ store,
30565
+ nativeButton,
30566
+ nodeId: menuPositionerContext?.nodeId,
30567
+ itemMetadata: REGULAR_ITEM
30568
+ });
30569
+ const state = React.useMemo(() => ({
30570
+ disabled,
30571
+ highlighted
30572
+ }), [disabled, highlighted]);
30573
+ return useRenderElement("div", componentProps, {
30574
+ state,
30575
+ props: [itemProps, elementProps, getItemProps],
30576
+ ref: [itemRef, forwardedRef, listItem2.ref]
30577
+ });
30578
+ });
30579
+ if (process.env.NODE_ENV !== "production") MenuItem.displayName = "MenuItem";
30421
30580
  const EMPTY = 0;
30422
30581
  class Timeout {
30423
30582
  static create() {
@@ -39581,6 +39740,26 @@ function DropdownMenuLabel({
39581
39740
  }
39582
39741
  );
39583
39742
  }
39743
+ function DropdownMenuItem({
39744
+ className,
39745
+ inset,
39746
+ variant = "default",
39747
+ ...props
39748
+ }) {
39749
+ return /* @__PURE__ */ jsx(
39750
+ MenuItem,
39751
+ {
39752
+ "data-slot": "dropdown-menu-item",
39753
+ "data-inset": inset,
39754
+ "data-variant": variant,
39755
+ className: cn$2(
39756
+ "group/dropdown-menu-item relative flex cursor-default items-center gap-2.5 rounded-2xl px-3 py-2 text-sm font-medium outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-9.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
39757
+ className
39758
+ ),
39759
+ ...props
39760
+ }
39761
+ );
39762
+ }
39584
39763
  function DropdownMenuCheckboxItem({
39585
39764
  className,
39586
39765
  children: children2,
@@ -39613,6 +39792,16 @@ function DropdownMenuCheckboxItem({
39613
39792
  }
39614
39793
  );
39615
39794
  }
39795
+ function DropdownMenuSeparator({ className, ...props }) {
39796
+ return /* @__PURE__ */ jsx(
39797
+ Separator$1,
39798
+ {
39799
+ "data-slot": "dropdown-menu-separator",
39800
+ className: cn$2("-mx-1.5 my-1.5 h-px bg-border/50", className),
39801
+ ...props
39802
+ }
39803
+ );
39804
+ }
39616
39805
  let FieldControlDataAttributes = /* @__PURE__ */ (function(FieldControlDataAttributes2) {
39617
39806
  FieldControlDataAttributes2["disabled"] = "data-disabled";
39618
39807
  FieldControlDataAttributes2["valid"] = "data-valid";
@@ -41961,6 +42150,25 @@ const dateTimeBoundary = (value) => {
41961
42150
  const parsed = new Date(value);
41962
42151
  return Number.isNaN(parsed.getTime()) ? void 0 : parsed.toISOString();
41963
42152
  };
42153
+ const dateTimeInputValue = (value) => {
42154
+ if (!value) return "";
42155
+ const parsed = new Date(value);
42156
+ if (Number.isNaN(parsed.getTime())) return "";
42157
+ const local = new Date(parsed.getTime() - parsed.getTimezoneOffset() * 6e4);
42158
+ return local.toISOString().slice(0, 16);
42159
+ };
42160
+ const formatDateTime = (value) => {
42161
+ if (!value) return "";
42162
+ const parsed = new Date(value);
42163
+ if (Number.isNaN(parsed.getTime())) return value;
42164
+ return new Intl.DateTimeFormat(void 0, {
42165
+ month: "short",
42166
+ day: "numeric",
42167
+ year: "numeric",
42168
+ hour: "numeric",
42169
+ minute: "2-digit"
42170
+ }).format(parsed);
42171
+ };
41964
42172
  const filenameFor = (collections) => {
41965
42173
  const prefix = collections.length === 1 ? collections[0] : "record";
41966
42174
  const safePrefix = prefix.trim().replace(/[^a-zA-Z0-9_-]+/g, "-") || "record";
@@ -41976,41 +42184,104 @@ const downloadCsv = (filename, csv) => {
41976
42184
  link2.remove();
41977
42185
  setTimeout(() => URL.revokeObjectURL(url), 0);
41978
42186
  };
41979
- const selectionLabel = (selected, total) => {
41980
- if (selected === total) return "All collections";
41981
- if (selected === 1) return "1 collection";
41982
- return `${selected} collections`;
42187
+ const defaultState = (icon, title, description, action) => /* @__PURE__ */ jsxs("div", { children: [
42188
+ icon,
42189
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: title }),
42190
+ /* @__PURE__ */ jsx("p", { className: "mx-auto mt-1 max-w-sm text-xs text-muted-foreground", children: description }),
42191
+ action ? /* @__PURE__ */ jsx("div", { className: "mt-3 flex justify-center gap-2", children: action }) : null
42192
+ ] });
42193
+ const errorCopyFor = (status) => {
42194
+ if (status === 400) {
42195
+ return {
42196
+ title: "Current filters could not be applied",
42197
+ description: "The audit API rejected the current filter values. Reset filters or adjust the date range."
42198
+ };
42199
+ }
42200
+ if (status === 401) {
42201
+ return {
42202
+ title: "Session is not authorized",
42203
+ description: "Refresh the app and sign in again before loading audit activity."
42204
+ };
42205
+ }
42206
+ if (status === 403) {
42207
+ return {
42208
+ title: "Activity is not available",
42209
+ description: "You need read access to every selected collection."
42210
+ };
42211
+ }
42212
+ if (status === 404) {
42213
+ return {
42214
+ title: "Selected collection was not found",
42215
+ description: "Check the selected collection names or reset filters."
42216
+ };
42217
+ }
42218
+ if (status && status >= 500) {
42219
+ return {
42220
+ title: "Audit endpoint is unavailable",
42221
+ description: "Refresh activity. If it still fails, the audit service may be down."
42222
+ };
42223
+ }
42224
+ return {
42225
+ title: "Could not reach audit activity",
42226
+ description: "Refresh activity or reset filters and try again."
42227
+ };
41983
42228
  };
41984
- function AuditLog({ collections, pageSize = 50, title = "Activity", className }) {
42229
+ function AuditLog({
42230
+ collections,
42231
+ collectionLabels,
42232
+ filters: controlledFilters,
42233
+ defaultFilters,
42234
+ onFiltersChange,
42235
+ pageSize = 50,
42236
+ exportMaxRows,
42237
+ exportFilename,
42238
+ title = "Activity",
42239
+ density = "compact",
42240
+ showCollectionColumn = true,
42241
+ showActorColumn = true,
42242
+ showSystemFields = true,
42243
+ fieldLabels,
42244
+ getRecordHref,
42245
+ onRecordClick,
42246
+ loadingState,
42247
+ emptyState,
42248
+ errorState,
42249
+ className
42250
+ }) {
41985
42251
  const id = useId$1();
41986
42252
  const fromID = `${id}-from`;
41987
- const toID = `${id}-to`;
42253
+ const untilID = `${id}-until`;
41988
42254
  const eventID = `${id}-event`;
41989
42255
  const actorID = `${id}-actor`;
41990
42256
  const availableCollections = normalizeRecordAuditCollections(collections);
41991
42257
  const availableKey = availableCollections.join("\0");
41992
- const [collectionFilter, setCollectionFilter] = useState({ key: availableKey, values: availableCollections });
41993
- const selectedCollections = collectionFilter.key === availableKey ? availableCollections.filter((collection) => collectionFilter.values.includes(collection)) : availableCollections;
42258
+ const [localFilters, setLocalFilters] = useState(() => ({
42259
+ key: availableKey,
42260
+ value: normalizeAuditLogFilterState(availableCollections, defaultFilters)
42261
+ }));
42262
+ const filterState = controlledFilters !== void 0 ? normalizeAuditLogFilterState(availableCollections, controlledFilters) : localFilters.key === availableKey ? normalizeAuditLogFilterState(availableCollections, localFilters.value) : normalizeAuditLogFilterState(availableCollections);
42263
+ const selectedCollections = filterState.collections;
41994
42264
  const selectedKey = selectedCollections.join("\0");
41995
- const [event, setEvent] = useState("all");
41996
- const [actorFilter, setActorFilter] = useState({ key: selectedKey, value: "all" });
41997
- const [fromDateTime, setFromDateTime] = useState("");
41998
- const [toDateTime, setToDateTime] = useState("");
42265
+ const event = filterState.event ?? "all";
42266
+ const actor = filterState.actor ?? "all";
42267
+ const fromDateTime = dateTimeInputValue(filterState.since);
42268
+ const untilDateTime = dateTimeInputValue(filterState.until);
41999
42269
  const [isExporting, setIsExporting] = useState(false);
42000
42270
  const [exportStatus, setExportStatus] = useState({ key: "", message: "" });
42001
- const actor = actorFilter.key === selectedKey ? actorFilter.value : "all";
42002
- const filters = useMemo(
42271
+ const requestFilters = useMemo(
42003
42272
  () => ({
42004
- event: event === "all" ? void 0 : event,
42005
- actor: actor === "all" ? void 0 : actor,
42006
- since: dateTimeBoundary(fromDateTime),
42007
- until: dateTimeBoundary(toDateTime)
42273
+ event: filterState.event,
42274
+ actor: filterState.actor,
42275
+ since: filterState.since,
42276
+ until: filterState.until
42008
42277
  }),
42009
- [actor, event, fromDateTime, toDateTime]
42278
+ [filterState.actor, filterState.event, filterState.since, filterState.until]
42010
42279
  );
42011
- const filterKey = [selectedKey, event, actor, fromDateTime, toDateTime].join("");
42280
+ const filterKey = [selectedKey, event, actor, filterState.since, filterState.until].join("");
42012
42281
  const configurationError = availableCollections.length === 0 ? "Add at least one collection to the component." : availableCollections.length > AUDIT_LOG_MAX_COLLECTIONS ? `Choose no more than ${AUDIT_LOG_MAX_COLLECTIONS} collections.` : "";
42013
- const auditLog = useAuditLog(selectedCollections, filters, { pageSize, enabled: !configurationError });
42282
+ const auditLog = useAuditLog(selectedCollections, requestFilters, { pageSize, enabled: !configurationError });
42283
+ const columnCount = 3 + Number(showCollectionColumn) + Number(showActorColumn);
42284
+ const labelForCollection = (collection) => collectionLabels?.[collection]?.trim() || collection;
42014
42285
  const actorOptions = useMemo(() => {
42015
42286
  const actors = /* @__PURE__ */ new Map();
42016
42287
  for (const entry of auditLog.entries) {
@@ -42021,38 +42292,84 @@ function AuditLog({ collections, pageSize = 50, title = "Activity", className })
42021
42292
  ([, left], [, right]) => auditLogActorLabel(left).localeCompare(auditLogActorLabel(right))
42022
42293
  );
42023
42294
  }, [auditLog.entries]);
42024
- const hasFilters = selectedCollections.length !== availableCollections.length || event !== "all" || actor !== "all" || Boolean(fromDateTime) || Boolean(toDateTime);
42295
+ const hasFilters = selectedCollections.length !== availableCollections.length || Boolean(filterState.event || filterState.actor || filterState.since || filterState.until);
42296
+ const hasDateFilter = Boolean(filterState.since || filterState.until);
42025
42297
  const status = auditLog.error?.status;
42298
+ const errorCopy = errorCopyFor(status);
42026
42299
  const exportMessage = exportStatus.key === filterKey ? exportStatus.message : "";
42027
42300
  const selectedActor = actorOptions.find(([actorID2]) => actorID2 === actor)?.[1];
42028
42301
  const selectedActorLabel = actor === "all" ? "All actors" : selectedActor ? auditLogActorLabel(selectedActor) : "Selected actor";
42302
+ const disabledCollections = auditLog.collectionStatus.filter((collection) => !collection.audit_enabled).map((collection) => labelForCollection(collection.name));
42303
+ const collectionSelectionLabel = selectedCollections.length === availableCollections.length ? "All collections" : selectedCollections.length === 1 ? labelForCollection(selectedCollections[0]) : `${selectedCollections.length} collections`;
42304
+ const setFilters = (next2) => {
42305
+ const normalized = normalizeAuditLogFilterState(availableCollections, next2);
42306
+ if (controlledFilters === void 0) setLocalFilters({ key: availableKey, value: normalized });
42307
+ onFiltersChange?.(normalized);
42308
+ };
42029
42309
  const toggleCollection = (collection, checked) => {
42030
42310
  const next2 = new Set(selectedCollections);
42031
42311
  if (checked) next2.add(collection);
42032
42312
  else if (next2.size > 1) next2.delete(collection);
42033
- const values = availableCollections.filter((value) => next2.has(value));
42034
- setCollectionFilter({
42035
- key: availableKey,
42036
- values
42313
+ setFilters({
42314
+ ...filterState,
42315
+ collections: availableCollections.filter((value) => next2.has(value)),
42316
+ actor: void 0
42037
42317
  });
42038
- setActorFilter({ key: values.join("\0"), value: "all" });
42039
- };
42040
- const clearFilters = () => {
42041
- setCollectionFilter({ key: availableKey, values: availableCollections });
42042
- setEvent("all");
42043
- setActorFilter({ key: availableKey, value: "all" });
42044
- setFromDateTime("");
42045
- setToDateTime("");
42046
42318
  };
42319
+ const resetFilters = () => setFilters(normalizeAuditLogFilterState(availableCollections));
42320
+ const resetFiltersFromPointer = () => resetFilters();
42321
+ const filterChips = [];
42322
+ if (selectedCollections.length !== availableCollections.length) {
42323
+ const labels = selectedCollections.map(labelForCollection);
42324
+ filterChips.push({
42325
+ key: "collections",
42326
+ label: `Collections: ${labels.length <= 2 ? labels.join(", ") : `${labels.length} collections`}`,
42327
+ onClear: () => setFilters({ ...filterState, collections: availableCollections, actor: void 0 })
42328
+ });
42329
+ }
42330
+ if (filterState.since) {
42331
+ filterChips.push({
42332
+ key: "since",
42333
+ label: `From ${formatDateTime(filterState.since)}`,
42334
+ onClear: () => setFilters({ ...filterState, since: void 0 })
42335
+ });
42336
+ }
42337
+ if (filterState.until) {
42338
+ filterChips.push({
42339
+ key: "until",
42340
+ label: `Until ${formatDateTime(filterState.until)}`,
42341
+ onClear: () => setFilters({ ...filterState, until: void 0 })
42342
+ });
42343
+ }
42344
+ if (filterState.event) {
42345
+ filterChips.push({
42346
+ key: "event",
42347
+ label: `Event: ${filterState.event[0].toUpperCase()}${filterState.event.slice(1)}`,
42348
+ onClear: () => setFilters({ ...filterState, event: void 0 })
42349
+ });
42350
+ }
42351
+ if (filterState.actor) {
42352
+ filterChips.push({
42353
+ key: "actor",
42354
+ label: `Actor: ${selectedActorLabel}`,
42355
+ onClear: () => setFilters({ ...filterState, actor: void 0 })
42356
+ });
42357
+ }
42358
+ const filterSummary = filterChips.map((chip) => chip.label).join("; ") || "No filters applied";
42047
42359
  const handleExport = async () => {
42360
+ const limit = normalizeAuditLogExportLimit(exportMaxRows);
42048
42361
  setIsExporting(true);
42049
42362
  setExportStatus({ key: filterKey, message: "" });
42050
42363
  try {
42051
- const result = await fetchRecordAuditLogCsv({ collections: selectedCollections, ...filters });
42052
- downloadCsv(filenameFor(selectedCollections), result.csv);
42364
+ const result = await fetchRecordAuditLogCsv({ collections: selectedCollections, ...requestFilters }, limit, {
42365
+ collectionLabels
42366
+ });
42367
+ const filename = exportFilename?.trim() || filenameFor(selectedCollections);
42368
+ downloadCsv(filename, result.csv);
42369
+ const rowText = `${result.count.toLocaleString()} ${result.count === 1 ? "row" : "rows"}`;
42053
42370
  setExportStatus({
42054
42371
  key: filterKey,
42055
- message: result.truncated ? `Exported the first ${AUDIT_LOG_EXPORT_LIMIT.toLocaleString()} entries.` : `Exported ${result.count.toLocaleString()} ${result.count === 1 ? "entry" : "entries"}.`
42372
+ message: `${filename}: exported ${rowText}; ${result.truncated ? `truncated to first ${limit.toLocaleString()} rows` : "not truncated"}; ${hasFilters ? `filters: ${filterSummary}` : "no filters applied"}.`
42056
42373
  });
42057
42374
  } catch {
42058
42375
  setExportStatus({ key: filterKey, message: "Could not export the activity. Try again." });
@@ -42103,29 +42420,38 @@ function AuditLog({ collections, pageSize = 50, title = "Activity", className })
42103
42420
  /* @__PURE__ */ jsxs(
42104
42421
  DropdownMenuTrigger,
42105
42422
  {
42106
- render: /* @__PURE__ */ jsx(Button2, { type: "button", variant: "outline", size: "sm", className: "w-[10.5rem] justify-start" }),
42423
+ render: /* @__PURE__ */ jsx(Button2, { type: "button", variant: "outline", size: "sm", className: "w-[11rem] justify-start" }),
42107
42424
  children: [
42108
42425
  /* @__PURE__ */ jsx(ListFilter, {}),
42109
- /* @__PURE__ */ jsx("span", { className: "truncate", children: selectionLabel(selectedCollections.length, availableCollections.length) })
42426
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: collectionSelectionLabel })
42110
42427
  ]
42111
42428
  }
42112
42429
  ),
42113
- /* @__PURE__ */ jsx(DropdownMenuContent, { align: "start", className: "w-64", children: /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
42114
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Select collections" }),
42115
- availableCollections.map((collection) => {
42116
- const checked = selectedCollections.includes(collection);
42117
- return /* @__PURE__ */ jsx(
42118
- DropdownMenuCheckboxItem,
42119
- {
42120
- checked,
42121
- disabled: checked && selectedCollections.length === 1,
42122
- onCheckedChange: (value) => toggleCollection(collection, value === true),
42123
- children: /* @__PURE__ */ jsx("span", { className: "truncate font-mono text-xs", title: collection, children: collection })
42124
- },
42125
- collection
42126
- );
42127
- })
42128
- ] }) })
42430
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", className: "w-64", children: [
42431
+ /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
42432
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: "Select collections" }),
42433
+ availableCollections.map((collection) => {
42434
+ const checked = selectedCollections.includes(collection);
42435
+ return /* @__PURE__ */ jsx(
42436
+ DropdownMenuCheckboxItem,
42437
+ {
42438
+ checked,
42439
+ disabled: checked && selectedCollections.length === 1,
42440
+ onCheckedChange: (value) => toggleCollection(collection, value === true),
42441
+ children: /* @__PURE__ */ jsx("span", { className: "truncate", title: collection, children: labelForCollection(collection) })
42442
+ },
42443
+ collection
42444
+ );
42445
+ })
42446
+ ] }),
42447
+ hasFilters ? /* @__PURE__ */ jsxs(Fragment, { children: [
42448
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
42449
+ /* @__PURE__ */ jsxs(DropdownMenuItem, { onClick: resetFilters, children: [
42450
+ /* @__PURE__ */ jsx(FunnelX, {}),
42451
+ "Reset filters"
42452
+ ] })
42453
+ ] }) : null
42454
+ ] })
42129
42455
  ] })
42130
42456
  ] }) : null,
42131
42457
  /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
@@ -42134,80 +42460,169 @@ function AuditLog({ collections, pageSize = 50, title = "Activity", className })
42134
42460
  Input2,
42135
42461
  {
42136
42462
  id: fromID,
42463
+ "aria-label": "From date and time in your local timezone",
42137
42464
  type: "datetime-local",
42138
42465
  step: "60",
42139
42466
  value: fromDateTime,
42140
- max: toDateTime || void 0,
42467
+ max: untilDateTime || void 0,
42141
42468
  className: "h-8 w-[12rem] text-xs",
42142
- onChange: (inputEvent) => setFromDateTime(inputEvent.target.value)
42469
+ onChange: (inputEvent) => setFilters({ ...filterState, since: dateTimeBoundary(inputEvent.target.value) })
42143
42470
  }
42144
42471
  )
42145
42472
  ] }),
42146
42473
  /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42147
- /* @__PURE__ */ jsx(Label, { htmlFor: toID, className: "text-xs text-muted-foreground", children: "To" }),
42474
+ /* @__PURE__ */ jsx(Label, { htmlFor: untilID, className: "text-xs text-muted-foreground", children: "Until" }),
42148
42475
  /* @__PURE__ */ jsx(
42149
42476
  Input2,
42150
42477
  {
42151
- id: toID,
42478
+ id: untilID,
42479
+ "aria-label": "Until date and time in your local timezone",
42152
42480
  type: "datetime-local",
42153
42481
  step: "60",
42154
- value: toDateTime,
42482
+ value: untilDateTime,
42155
42483
  min: fromDateTime || void 0,
42156
42484
  className: "h-8 w-[12rem] text-xs",
42157
- onChange: (inputEvent) => setToDateTime(inputEvent.target.value)
42485
+ onChange: (inputEvent) => setFilters({ ...filterState, until: dateTimeBoundary(inputEvent.target.value) })
42158
42486
  }
42159
42487
  )
42160
42488
  ] }),
42161
42489
  /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42162
42490
  /* @__PURE__ */ jsx(Label, { htmlFor: eventID, className: "text-xs text-muted-foreground", children: "Event" }),
42163
- /* @__PURE__ */ jsxs(Select, { value: event, onValueChange: (value) => value && setEvent(value), children: [
42164
- /* @__PURE__ */ jsx(SelectTrigger2, { id: eventID, size: "sm", className: "w-[8.5rem] rounded-lg border-border bg-background", children: /* @__PURE__ */ jsx(SelectValue2, { children: event === "all" ? "All events" : `${event[0].toUpperCase()}${event.slice(1)}` }) }),
42165
- /* @__PURE__ */ jsxs(SelectContent, { children: [
42166
- /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All events" }),
42167
- /* @__PURE__ */ jsx(SelectItem2, { value: "created", children: "Created" }),
42168
- /* @__PURE__ */ jsx(SelectItem2, { value: "updated", children: "Updated" }),
42169
- /* @__PURE__ */ jsx(SelectItem2, { value: "deleted", children: "Deleted" })
42170
- ] })
42171
- ] })
42491
+ /* @__PURE__ */ jsxs(
42492
+ Select,
42493
+ {
42494
+ value: event,
42495
+ onValueChange: (value) => value && setFilters({ ...filterState, event: value === "all" ? void 0 : value }),
42496
+ children: [
42497
+ /* @__PURE__ */ jsx(SelectTrigger2, { id: eventID, size: "sm", className: "w-[8.5rem] rounded-lg border-border bg-background", children: /* @__PURE__ */ jsx(SelectValue2, { children: event === "all" ? "All events" : `${event[0].toUpperCase()}${event.slice(1)}` }) }),
42498
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
42499
+ /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All events" }),
42500
+ /* @__PURE__ */ jsx(SelectItem2, { value: "created", children: "Created" }),
42501
+ /* @__PURE__ */ jsx(SelectItem2, { value: "updated", children: "Updated" }),
42502
+ /* @__PURE__ */ jsx(SelectItem2, { value: "deleted", children: "Deleted" })
42503
+ ] })
42504
+ ]
42505
+ }
42506
+ )
42172
42507
  ] }),
42173
42508
  /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
42174
42509
  /* @__PURE__ */ jsx(Label, { htmlFor: actorID, className: "text-xs text-muted-foreground", children: "Actor" }),
42175
- /* @__PURE__ */ jsxs(Select, { value: actor, onValueChange: (value) => value && setActorFilter({ key: selectedKey, value }), children: [
42176
- /* @__PURE__ */ jsx(SelectTrigger2, { id: actorID, size: "sm", className: "w-[11rem] rounded-lg border-border bg-background", children: /* @__PURE__ */ jsx(SelectValue2, { children: selectedActorLabel }) }),
42177
- /* @__PURE__ */ jsxs(SelectContent, { children: [
42178
- /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All actors" }),
42179
- actorOptions.map(([actorID2, option]) => /* @__PURE__ */ jsx(SelectItem2, { value: actorID2, children: auditLogActorLabel(option) }, actorID2))
42180
- ] })
42181
- ] })
42510
+ /* @__PURE__ */ jsxs(
42511
+ Select,
42512
+ {
42513
+ value: actor,
42514
+ onValueChange: (value) => value && setFilters({ ...filterState, actor: value === "all" ? void 0 : value }),
42515
+ children: [
42516
+ /* @__PURE__ */ jsx(SelectTrigger2, { id: actorID, size: "sm", className: "w-[11rem] rounded-lg border-border bg-background", children: /* @__PURE__ */ jsx(SelectValue2, { children: selectedActorLabel }) }),
42517
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
42518
+ /* @__PURE__ */ jsx(SelectItem2, { value: "all", children: "All actors" }),
42519
+ actorOptions.map(([actorID2, option]) => /* @__PURE__ */ jsx(SelectItem2, { value: actorID2, children: auditLogActorLabel(option) }, actorID2))
42520
+ ] })
42521
+ ]
42522
+ }
42523
+ )
42182
42524
  ] }),
42183
- hasFilters ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "ghost", size: "sm", className: "mb-px", onClick: clearFilters, children: [
42184
- /* @__PURE__ */ jsx(FunnelX, {}),
42185
- " Clear"
42186
- ] }) : null
42525
+ /* @__PURE__ */ jsx("span", { className: "mb-2 text-[11px] text-muted-foreground", children: "Dates use local time" }),
42526
+ hasFilters ? /* @__PURE__ */ jsxs(
42527
+ Button2,
42528
+ {
42529
+ type: "button",
42530
+ variant: "ghost",
42531
+ size: "sm",
42532
+ className: "mb-px",
42533
+ onPointerDown: resetFiltersFromPointer,
42534
+ onClick: resetFilters,
42535
+ children: [
42536
+ /* @__PURE__ */ jsx(FunnelX, {}),
42537
+ " Reset filters"
42538
+ ]
42539
+ }
42540
+ ) : null
42187
42541
  ] }),
42542
+ filterChips.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 border-b bg-muted/10 px-5 py-2 text-xs", children: [
42543
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: "Active filters" }),
42544
+ filterChips.map((chip) => /* @__PURE__ */ jsxs(
42545
+ "span",
42546
+ {
42547
+ className: "inline-flex h-6 max-w-full items-center gap-1 rounded-full border bg-background px-2 text-foreground",
42548
+ children: [
42549
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: chip.label }),
42550
+ /* @__PURE__ */ jsx(
42551
+ "button",
42552
+ {
42553
+ type: "button",
42554
+ className: "rounded-full text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:outline-none",
42555
+ "aria-label": `Clear ${chip.label}`,
42556
+ onClick: chip.onClear,
42557
+ children: /* @__PURE__ */ jsx(X$2, { className: "size-3" })
42558
+ }
42559
+ )
42560
+ ]
42561
+ },
42562
+ chip.key
42563
+ ))
42564
+ ] }) : null,
42565
+ disabledCollections.length > 0 && !auditLog.error ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2 border-b bg-amber-50 px-5 py-2.5 text-xs text-amber-950", role: "status", children: [
42566
+ /* @__PURE__ */ jsx(CircleAlert, { className: "mt-0.5 size-4 shrink-0" }),
42567
+ /* @__PURE__ */ jsxs("p", { children: [
42568
+ "Auditing is off for ",
42569
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: disabledCollections.join(", ") }),
42570
+ ". Existing history is still visible, but new changes will not be recorded."
42571
+ ] })
42572
+ ] }) : null,
42188
42573
  /* @__PURE__ */ jsxs(Table, { children: [
42189
42574
  /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-transparent", children: [
42190
42575
  /* @__PURE__ */ jsx(TableHead, { className: "w-32 text-xs text-muted-foreground", children: "Time" }),
42191
- /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Collection" }),
42576
+ showCollectionColumn ? /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Collection" }) : null,
42192
42577
  /* @__PURE__ */ jsx(TableHead, { className: "text-xs text-muted-foreground", children: "Activity" }),
42193
- /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Actor" }),
42194
- /* @__PURE__ */ jsx(TableHead, { className: "w-12", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Details" }) })
42578
+ showActorColumn ? /* @__PURE__ */ jsx(TableHead, { className: "w-48 text-xs text-muted-foreground", children: "Actor" }) : null,
42579
+ /* @__PURE__ */ jsx(TableHead, { className: getRecordHref || onRecordClick ? "w-36" : "w-12", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Actions" }) })
42195
42580
  ] }) }),
42196
- /* @__PURE__ */ jsx(TableBody, { children: auditLog.isLoading ? [0, 1, 2].map((item) => /* @__PURE__ */ jsxs(TableRow, { children: [
42581
+ /* @__PURE__ */ jsx(TableBody, { children: auditLog.isLoading ? loadingState !== void 0 ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: loadingState }) }) : [0, 1, 2].map((item) => /* @__PURE__ */ jsxs(TableRow, { children: [
42197
42582
  /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20" }) }),
42198
- /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-28" }) }),
42583
+ showCollectionColumn ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-28" }) }) : null,
42199
42584
  /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-2/3" }) }),
42200
- /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }) }),
42585
+ showActorColumn ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }) }) : null,
42201
42586
  /* @__PURE__ */ jsx(TableCell, {})
42202
- ] }, item)) : configurationError || auditLog.error ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsxs(TableCell, { colSpan: 5, className: "h-48 whitespace-normal text-center", children: [
42587
+ ] }, item)) : configurationError || auditLog.error ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: auditLog.error && errorState ? errorState(auditLog.error) : defaultState(
42203
42588
  /* @__PURE__ */ jsx(History, { className: "mx-auto mb-3 size-8 text-muted-foreground/60" }),
42204
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: configurationError ? "Audit log is not configured" : status === 403 ? "Activity is not available" : "Could not load activity" }),
42205
- /* @__PURE__ */ jsx("p", { className: "mx-auto mt-1 max-w-sm text-xs text-muted-foreground", children: configurationError || (status === 403 ? "You need read access to every selected collection." : "Refresh the activity to try again.") })
42206
- ] }) }) : auditLog.entries.length === 0 ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsxs(TableCell, { colSpan: 5, className: "h-48 whitespace-normal text-center", children: [
42589
+ configurationError ? "Audit log is not configured" : errorCopy.title,
42590
+ configurationError || `${errorCopy.description} Filters: ${filterSummary}.`,
42591
+ configurationError ? void 0 : /* @__PURE__ */ jsxs(Fragment, { children: [
42592
+ hasFilters ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "outline", size: "sm", onClick: resetFilters, children: [
42593
+ /* @__PURE__ */ jsx(FunnelX, {}),
42594
+ " Reset filters"
42595
+ ] }) : null,
42596
+ /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "ghost", size: "sm", onClick: () => void auditLog.refresh(), children: [
42597
+ /* @__PURE__ */ jsx(RefreshCw, {}),
42598
+ " Refresh"
42599
+ ] })
42600
+ ] })
42601
+ ) }) }) : auditLog.entries.length === 0 ? /* @__PURE__ */ jsx(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, className: "h-48 whitespace-normal text-center", children: emptyState ?? defaultState(
42207
42602
  /* @__PURE__ */ jsx(History, { className: "mx-auto mb-3 size-8 text-muted-foreground/60" }),
42208
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "No activity to show" }),
42209
- /* @__PURE__ */ jsx("p", { className: "mx-auto mt-1 max-w-sm text-xs text-muted-foreground", children: "Auditing may be off, or no changes match the current filters." })
42210
- ] }) }) : auditLog.entries.map((entry) => /* @__PURE__ */ jsx(AuditLogEntry, { entry }, entry.id)) })
42603
+ hasDateFilter ? "No activity in this date range" : hasFilters ? "No activity matches these filters" : "No activity to show",
42604
+ hasDateFilter ? "Try expanding the date range or reset filters." : disabledCollections.length > 0 ? "Auditing is off, and no existing changes match the current filters." : hasFilters ? "Try removing a filter or reset filters." : "No record changes have been logged yet.",
42605
+ hasFilters ? /* @__PURE__ */ jsxs(Button2, { type: "button", variant: "outline", size: "sm", onClick: resetFilters, children: [
42606
+ /* @__PURE__ */ jsx(FunnelX, {}),
42607
+ " Reset filters"
42608
+ ] }) : void 0
42609
+ ) }) }) : auditLog.entries.map((entry) => /* @__PURE__ */ jsx(
42610
+ AuditLogEntry,
42611
+ {
42612
+ entry,
42613
+ collectionLabel: labelForCollection(auditLogDetailValue(entry, "Collection")),
42614
+ activityCollectionLabel: collectionLabels?.[auditLogDetailValue(entry, "Collection")]?.trim(),
42615
+ density,
42616
+ showCollectionColumn,
42617
+ showActorColumn,
42618
+ showSystemFields,
42619
+ fieldLabels,
42620
+ columnCount,
42621
+ getRecordHref,
42622
+ onRecordClick
42623
+ },
42624
+ entry.id
42625
+ )) })
42211
42626
  ] }),
42212
42627
  auditLog.hasMore ? /* @__PURE__ */ jsx("div", { className: "flex justify-center border-t p-4", children: /* @__PURE__ */ jsxs(
42213
42628
  Button2,
@@ -43473,13 +43888,13 @@ function RecordSheet({
43473
43888
  actions,
43474
43889
  width = "max-w-lg"
43475
43890
  }) {
43476
- const displayFields = fields ?? (record ? Object.keys(record).map((key) => ({ key, label: key })) : []);
43891
+ const displayFields2 = fields ?? (record ? Object.keys(record).map((key) => ({ key, label: key })) : []);
43477
43892
  return /* @__PURE__ */ jsx(Sheet, { open: open2, onOpenChange, children: /* @__PURE__ */ jsxs(SheetContent, { side: "right", className: `w-full ${width} overflow-y-auto`, children: [
43478
43893
  /* @__PURE__ */ jsxs(SheetHeader, { children: [
43479
43894
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsx(SheetTitle, { children: title }) }),
43480
43895
  description && /* @__PURE__ */ jsx(SheetDescription, { children: description })
43481
43896
  ] }),
43482
- /* @__PURE__ */ jsx("div", { className: "mt-6 space-y-4 px-4", children: isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : !record ? /* @__PURE__ */ jsx("p", { className: "py-12 text-center text-muted-foreground", children: "No record selected" }) : displayFields.map((field) => {
43897
+ /* @__PURE__ */ jsx("div", { className: "mt-6 space-y-4 px-4", children: isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }) : !record ? /* @__PURE__ */ jsx("p", { className: "py-12 text-center text-muted-foreground", children: "No record selected" }) : displayFields2.map((field) => {
43483
43898
  const value = record[field.key];
43484
43899
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
43485
43900
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-muted-foreground", children: field.label }),