@ai-matrx/design-system 0.49.12 → 0.49.19

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 (39) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/data-table/copy-helpers.d.cts +1 -1
  3. package/dist/data-table/copy-helpers.d.ts +1 -1
  4. package/dist/data-table/facets.cjs +2 -0
  5. package/dist/data-table/facets.cjs.map +1 -1
  6. package/dist/data-table/facets.d.cts +3 -1
  7. package/dist/data-table/facets.d.ts +3 -1
  8. package/dist/data-table/facets.js +2 -0
  9. package/dist/data-table/facets.js.map +1 -1
  10. package/dist/data-table/filter-engine.d.cts +1 -1
  11. package/dist/data-table/filter-engine.d.ts +1 -1
  12. package/dist/data-table/host.d.cts +1 -1
  13. package/dist/data-table/host.d.ts +1 -1
  14. package/dist/data-table/index.cjs +521 -330
  15. package/dist/data-table/index.cjs.map +1 -1
  16. package/dist/data-table/index.d.cts +7 -3
  17. package/dist/data-table/index.d.ts +7 -3
  18. package/dist/data-table/index.js +452 -261
  19. package/dist/data-table/index.js.map +1 -1
  20. package/dist/data-table/infer-filter.d.cts +1 -1
  21. package/dist/data-table/infer-filter.d.ts +1 -1
  22. package/dist/data-table/layered-filters.d.cts +1 -1
  23. package/dist/data-table/layered-filters.d.ts +1 -1
  24. package/dist/data-table/menu-targets.cjs.map +1 -1
  25. package/dist/data-table/menu-targets.d.cts +5 -0
  26. package/dist/data-table/menu-targets.d.ts +5 -0
  27. package/dist/data-table/menu-targets.js.map +1 -1
  28. package/dist/data-table/query-control.d.cts +1 -1
  29. package/dist/data-table/query-control.d.ts +1 -1
  30. package/dist/data-table/types.cjs.map +1 -1
  31. package/dist/data-table/types.d.cts +1 -1
  32. package/dist/data-table/types.d.ts +1 -1
  33. package/dist/data-table/url-state.d.cts +1 -1
  34. package/dist/data-table/url-state.d.ts +1 -1
  35. package/dist/data-table/xlsx.d.cts +1 -1
  36. package/dist/data-table/xlsx.d.ts +1 -1
  37. package/dist/{layered-filters-B-znwvFV.d.cts → layered-filters-BltsILT3.d.cts} +7 -1
  38. package/dist/{layered-filters-Dhfam7uI.d.ts → layered-filters-DrGJ_nuG.d.ts} +7 -1
  39. package/package.json +1 -1
@@ -34157,7 +34157,7 @@ __export(data_table_exports, {
34157
34157
  module.exports = __toCommonJS(data_table_exports);
34158
34158
 
34159
34159
  // src/data-table/MatrxDataTable.tsx
34160
- var import_react21 = require("react");
34160
+ var import_react22 = require("react");
34161
34161
  var import_react_dom3 = require("react-dom");
34162
34162
  var import_core3 = require("@dnd-kit/core");
34163
34163
 
@@ -35238,7 +35238,11 @@ function TableTitleRow({
35238
35238
  "data-matrx-table-toolbar": true,
35239
35239
  className: cn(
35240
35240
  "relative flex min-w-0 shrink-0 items-center gap-2",
35241
- singleRow ? "flex-nowrap overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden" : "flex-wrap",
35241
+ // `max-w-full`: drawn into a page's row slot (`portalInto`), the row is held to the slot's
35242
+ // width, so IT is the scroller its pinned controls stick to — never a row as wide as its
35243
+ // content inside a narrower slot, where "sticky" had nothing to stick to and "New record"
35244
+ // sat past the slot's edge, cut to "N" (merged-grid leftovers, 2026-09-28).
35245
+ singleRow ? "max-w-full flex-nowrap overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden" : "flex-wrap",
35242
35246
  // ONE CONTROL HEIGHT ON A TOOLBAR ROW (lane C, review 2026-09-26: 28/32/44 mixed): a host's
35243
35247
  // tap-target toolbar actions draw at 32px like every other control; a finger (coarse
35244
35248
  // pointer) keeps the 44px floor.
@@ -36731,7 +36735,7 @@ function GenericTablePagination({
36731
36735
  // src/data-table/TableViewTabs.tsx
36732
36736
  var import_react7 = require("react");
36733
36737
  var import_jsx_runtime24 = require("react/jsx-runtime");
36734
- function TableViewTabs({ tabs, activeId, onSelect, onAdd, onClose, onRename, related, editingId, onEditCancel, onEditDone }) {
36738
+ function TableViewTabs({ tabs, activeId, onSelect, onAdd, onClose, onRename, related, editingId, onEditCancel, onEditDone, closable = true, addHint = "New view from the current one \xB7 double-click a tab to rename", renameable = true }) {
36735
36739
  const [renaming, setRenaming] = (0, import_react7.useState)(null);
36736
36740
  const [draft, setDraft] = (0, import_react7.useState)("");
36737
36741
  const opened = (0, import_react7.useRef)(null);
@@ -36754,9 +36758,11 @@ function TableViewTabs({ tabs, activeId, onSelect, onAdd, onClose, onRename, rel
36754
36758
  if (id) onEditCancel?.(id);
36755
36759
  onEditDone?.();
36756
36760
  };
36761
+ const canClose = (id) => closable && tabs.length > 1 && id !== "default";
36762
+ const canRename = (id) => renameable && id !== "default";
36757
36763
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex min-w-0 shrink-0 items-center border-b", "data-matrx-table-tabs": true, children: [
36758
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { role: "tablist", "aria-label": "Table views", className: "flex min-w-0 flex-1 items-center overflow-x-auto", children: [
36759
- tabs.map((tab, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "group flex shrink-0 items-center border-r", children: [
36764
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex min-w-0 flex-1 items-center overflow-x-auto", children: [
36765
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { role: "tablist", "aria-label": "Table views", className: "flex shrink-0 items-center", children: tabs.map((tab, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { role: "presentation", className: "group flex shrink-0 items-center border-r", children: [
36760
36766
  renaming === tab.id ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
36761
36767
  "input",
36762
36768
  {
@@ -36780,12 +36786,26 @@ function TableViewTabs({ tabs, activeId, onSelect, onAdd, onClose, onRename, rel
36780
36786
  role: "tab",
36781
36787
  "aria-selected": tab.id === activeId,
36782
36788
  tabIndex: tab.id === activeId ? 0 : -1,
36789
+ "aria-keyshortcuts": [canClose(tab.id) ? "Delete" : "", canRename(tab.id) ? "F2" : ""].filter(Boolean).join(" ") || void 0,
36783
36790
  onClick: () => onSelect(tab.id),
36784
36791
  onDoubleClick: () => {
36785
- setDraft(tab.label);
36786
- setRenaming(tab.id);
36792
+ if (canRename(tab.id)) {
36793
+ setDraft(tab.label);
36794
+ setRenaming(tab.id);
36795
+ }
36787
36796
  },
36788
36797
  onKeyDown: (e) => {
36798
+ if (e.key === "Delete" && canClose(tab.id)) {
36799
+ e.preventDefault();
36800
+ onClose(tab.id);
36801
+ return;
36802
+ }
36803
+ if (e.key === "F2" && canRename(tab.id)) {
36804
+ e.preventDefault();
36805
+ setDraft(tab.label);
36806
+ setRenaming(tab.id);
36807
+ return;
36808
+ }
36789
36809
  const next = e.key === "ArrowRight" ? (index + 1) % tabs.length : e.key === "ArrowLeft" ? (index + tabs.length - 1) % tabs.length : e.key === "Home" ? 0 : e.key === "End" ? tabs.length - 1 : -1;
36790
36810
  if (next >= 0) {
36791
36811
  e.preventDefault();
@@ -36801,17 +36821,18 @@ function TableViewTabs({ tabs, activeId, onSelect, onAdd, onClose, onRename, rel
36801
36821
  ]
36802
36822
  }
36803
36823
  ),
36804
- tabs.length > 1 && tab.id !== "default" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Tooltip, { children: [
36805
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", "aria-label": `Close ${tab.label}`, onClick: () => onClose(tab.id), className: "flex size-7 items-center justify-center rounded hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(X, { className: "size-4" }) }) }),
36824
+ canClose(tab.id) && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Tooltip, { children: [
36825
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", "aria-hidden": "true", tabIndex: -1, "data-close-tab": tab.id, onClick: () => onClose(tab.id), className: "flex size-7 items-center justify-center rounded hover:bg-muted", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(X, { className: "size-4" }) }) }),
36806
36826
  /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(TooltipContent, { children: [
36807
36827
  "Close ",
36808
- tab.label
36828
+ tab.label,
36829
+ " (Delete)"
36809
36830
  ] })
36810
36831
  ] })
36811
- ] }, tab.id)),
36832
+ ] }, tab.id)) }),
36812
36833
  /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Tooltip, { children: [
36813
36834
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", "aria-label": "New table tab", onClick: onAdd, className: "flex size-8 shrink-0 items-center justify-center rounded hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Plus, { className: "size-4" }) }) }),
36814
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TooltipContent, { children: "New view from the current one \xB7 double-click a tab to rename" })
36835
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(TooltipContent, { children: addHint })
36815
36836
  ] })
36816
36837
  ] }),
36817
36838
  related && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex shrink-0 items-center gap-1 border-l px-2", children: related })
@@ -42172,6 +42193,7 @@ CommandShortcut.displayName = "CommandShortcut";
42172
42193
  var MAX_LISTABLE_FACET_LENGTH = 300;
42173
42194
  var DEFAULT_FACET_LIMIT = 200;
42174
42195
  var MAX_FACET_LIMIT = 500;
42196
+ var CORE_SUGGESTION_DISTINCT_EXCLUSIVE_LIMIT = 15;
42175
42197
  function facetText(raw) {
42176
42198
  if (raw === null || raw === void 0) return "";
42177
42199
  if (typeof raw === "object") {
@@ -42298,6 +42320,7 @@ function HeaderMenuItems({
42298
42320
  const disabled = Boolean(item.disabledReason);
42299
42321
  const hasSubmenu = Boolean(item.submenu && item.submenu.length > 0);
42300
42322
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col", children: [
42323
+ item.separatorBefore ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { role: "separator", className: "-mx-1 my-1 h-px bg-border" }) : null,
42301
42324
  /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
42302
42325
  Button,
42303
42326
  {
@@ -42367,7 +42390,7 @@ function ColumnHeaderCell({
42367
42390
  compact = false,
42368
42391
  marker,
42369
42392
  filterApplyLabel,
42370
- filterShowCancel = false,
42393
+ filterShowCancel,
42371
42394
  filterFooterHint,
42372
42395
  allowNegation = false,
42373
42396
  allowNullModes = false,
@@ -42405,7 +42428,8 @@ function ColumnHeaderCell({
42405
42428
  } : void 0;
42406
42429
  const reorderClass = reorderEnabled ? "touch-none cursor-grab active:cursor-grabbing" : void 0;
42407
42430
  const filterActive = isColumnFilterActive(filterValue);
42408
- const deferredFilter = filterApplyLabel !== void 0 || filterShowCancel || filterFooterHint !== void 0;
42431
+ const deferredFilter = filterKind === "text" || filterApplyLabel !== void 0 || Boolean(filterShowCancel) || filterFooterHint !== void 0;
42432
+ const showFilterCancel = filterShowCancel ?? filterKind === "text";
42409
42433
  const [filterOpen, setFilterOpen] = (0, import_react13.useState)(false);
42410
42434
  const [pendingNegation, setPendingNegation] = (0, import_react13.useState)(false);
42411
42435
  const [draftFilter, setDraftFilter] = (0, import_react13.useState)(filterValue);
@@ -42566,7 +42590,7 @@ function ColumnHeaderCell({
42566
42590
  filterKind && deferredFilter ? /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "mt-2 border-t border-border pt-2", children: [
42567
42591
  filterFooterHint ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "mb-2 text-xs text-muted-foreground", children: filterFooterHint }) : null,
42568
42592
  /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex justify-end gap-2", children: [
42569
- filterShowCancel ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Button, { type: "button", variant: "ghost", size: "sm", onClick: cancelFilter, children: "Cancel" }) : null,
42593
+ showFilterCancel ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Button, { type: "button", variant: "ghost", size: "sm", onClick: cancelFilter, children: "Cancel" }) : null,
42570
42594
  /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Button, { type: "button", size: "sm", onClick: applyFilter, children: filterApplyLabel ?? "Apply" })
42571
42595
  ] })
42572
42596
  ] }) : null,
@@ -42913,7 +42937,7 @@ function FacetChecklist({
42913
42937
  onChange
42914
42938
  }) {
42915
42939
  const [query, setQuery] = (0, import_react13.useState)("");
42916
- const selected = value?.kind === "select" ? value.values ?? (value.value && value.value !== "__all__" ? [value.value] : []) : [];
42940
+ const selected = value?.kind === "select" ? (value.values ?? (value.value && value.value !== "__all__" ? [value.value] : [])).map((candidate) => candidate === SELECT_EMPTY_VALUE ? "" : candidate) : [];
42917
42941
  const selectedSet = new Set(selected);
42918
42942
  const rows = (0, import_react13.useMemo)(() => {
42919
42943
  if (!facets) return [];
@@ -42931,7 +42955,7 @@ function FacetChecklist({
42931
42955
  const next = new Set(selectedSet);
42932
42956
  if (next.has(candidate)) next.delete(candidate);
42933
42957
  else next.add(candidate);
42934
- const values = [...next];
42958
+ const values = [...next].map((value2) => value2 === "" ? SELECT_EMPTY_VALUE : value2);
42935
42959
  onChange(
42936
42960
  values.length === 0 ? void 0 : { kind: "select", value: values[0] ?? "", values }
42937
42961
  );
@@ -45492,6 +45516,62 @@ function ToolbarListedLabel({ label, children }) {
45492
45516
  ] });
45493
45517
  }
45494
45518
 
45519
+ // src/data-table/pinned-fold.ts
45520
+ var import_react17 = require("react");
45521
+ function pinnedMustFold(room, full) {
45522
+ if (room <= 0 || full === null) return false;
45523
+ return full > room + 0.5;
45524
+ }
45525
+ function usePinnedFold(el, active) {
45526
+ const [folded, setFolded] = (0, import_react17.useState)(false);
45527
+ const full = (0, import_react17.useRef)(null);
45528
+ const current = (0, import_react17.useRef)(false);
45529
+ (0, import_react17.useEffect)(() => {
45530
+ if (!active || !el) {
45531
+ if (current.current) {
45532
+ current.current = false;
45533
+ setFolded(false);
45534
+ }
45535
+ return;
45536
+ }
45537
+ const row = el.closest("[data-matrx-table-toolbar]") ?? el.parentElement;
45538
+ if (!row) return;
45539
+ let pending = 0;
45540
+ let stopped = false;
45541
+ const measure = () => {
45542
+ pending = 0;
45543
+ if (stopped) return;
45544
+ if (!current.current) {
45545
+ const width = Math.max(el.getBoundingClientRect().width || 0, el.scrollWidth || 0);
45546
+ if (width > 0) full.current = width;
45547
+ }
45548
+ const next = pinnedMustFold(row.clientWidth, full.current);
45549
+ if (next !== current.current) {
45550
+ current.current = next;
45551
+ setFolded(next);
45552
+ }
45553
+ };
45554
+ const schedule = () => {
45555
+ if (pending) return;
45556
+ pending = typeof requestAnimationFrame === "function" && typeof document !== "undefined" && document.visibilityState !== "hidden" ? requestAnimationFrame(measure) : setTimeout(measure, 0);
45557
+ };
45558
+ const sizes = typeof ResizeObserver === "function" ? new ResizeObserver(schedule) : null;
45559
+ sizes?.observe(row);
45560
+ sizes?.observe(el);
45561
+ const content = typeof MutationObserver === "function" ? new MutationObserver(schedule) : null;
45562
+ content?.observe(el, { childList: true, subtree: true, characterData: true });
45563
+ if (typeof window !== "undefined") window.addEventListener("resize", schedule);
45564
+ measure();
45565
+ return () => {
45566
+ stopped = true;
45567
+ sizes?.disconnect();
45568
+ content?.disconnect();
45569
+ if (typeof window !== "undefined") window.removeEventListener("resize", schedule);
45570
+ };
45571
+ }, [el, active]);
45572
+ return folded;
45573
+ }
45574
+
45495
45575
  // src/data-table/coverage.ts
45496
45576
  var PARTIAL_BADGE = "Partial";
45497
45577
  var UNKNOWN_TOTAL_BADGE = "Unknown total";
@@ -45640,7 +45720,7 @@ function rankTableSearchRows(rows, columns, query, options = {}, extraText) {
45640
45720
  }
45641
45721
 
45642
45722
  // src/data-table/ColumnManager.tsx
45643
- var import_react17 = require("react");
45723
+ var import_react18 = require("react");
45644
45724
  var import_core2 = require("@dnd-kit/core");
45645
45725
  var import_jsx_runtime43 = require("react/jsx-runtime");
45646
45726
  function ColumnManager({
@@ -45651,15 +45731,15 @@ function ColumnManager({
45651
45731
  hidden,
45652
45732
  onApply
45653
45733
  }) {
45654
- const byId = (0, import_react17.useMemo)(
45734
+ const byId = (0, import_react18.useMemo)(
45655
45735
  () => new Map(columns.map((column) => [columnId(column), column])),
45656
45736
  [columns]
45657
45737
  );
45658
- const [draftOrder, setDraftOrder] = (0, import_react17.useState)(order);
45659
- const [draftHidden, setDraftHidden] = (0, import_react17.useState)(() => new Set(hidden));
45660
- const [draggedColumnId, setDraggedColumnId] = (0, import_react17.useState)(null);
45661
- const [dropTarget, setDropTarget] = (0, import_react17.useState)(null);
45662
- (0, import_react17.useEffect)(() => {
45738
+ const [draftOrder, setDraftOrder] = (0, import_react18.useState)(order);
45739
+ const [draftHidden, setDraftHidden] = (0, import_react18.useState)(() => new Set(hidden));
45740
+ const [draggedColumnId, setDraggedColumnId] = (0, import_react18.useState)(null);
45741
+ const [dropTarget, setDropTarget] = (0, import_react18.useState)(null);
45742
+ (0, import_react18.useEffect)(() => {
45663
45743
  if (!open) return;
45664
45744
  setDraftOrder(order);
45665
45745
  setDraftHidden(new Set(hidden));
@@ -46146,7 +46226,7 @@ var layeredRuleSchema = import_zod2.z.object({ id: import_zod2.z.string().min(1)
46146
46226
  var snapshotSchema = import_zod2.z.object({
46147
46227
  __kind: import_zod2.z.literal("matrx-table-view"),
46148
46228
  version: import_zod2.z.literal(1),
46149
- query: import_zod2.z.object({ pageSize: import_zod2.z.number().int().positive(), search: import_zod2.z.string(), searchMatchMode: import_zod2.z.enum(["contains", "whole_words"]).optional(), searchScope: import_zod2.z.string().min(1).optional(), anyOf: import_zod2.z.string(), layeredFilters: import_zod2.z.array(layeredRuleSchema).optional(), columnFilters: import_zod2.z.record(import_zod2.z.string(), filterSchema.optional()), sort: import_zod2.z.object({ id: import_zod2.z.string().min(1), direction: import_zod2.z.enum(["asc", "desc"]) }).nullable() }),
46229
+ query: import_zod2.z.object({ pageSize: import_zod2.z.number().int().nonnegative(), search: import_zod2.z.string(), searchMatchMode: import_zod2.z.enum(["contains", "whole_words"]).optional(), searchScope: import_zod2.z.string().min(1).optional(), anyOf: import_zod2.z.string(), layeredFilters: import_zod2.z.array(layeredRuleSchema).optional(), columnFilters: import_zod2.z.record(import_zod2.z.string(), filterSchema.optional()), sort: import_zod2.z.object({ id: import_zod2.z.string().min(1), direction: import_zod2.z.enum(["asc", "desc"]) }).nullable() }),
46150
46230
  columns: import_zod2.z.object({
46151
46231
  order: import_zod2.z.array(import_zod2.z.string().min(1)).refine((order) => new Set(order).size === order.length, {
46152
46232
  message: "Column order must not contain duplicate IDs"
@@ -46201,7 +46281,7 @@ function parseTableViewSnapshot(raw) {
46201
46281
  }
46202
46282
 
46203
46283
  // src/data-table/MatrxUuidCell.tsx
46204
- var import_react18 = require("react");
46284
+ var import_react19 = require("react");
46205
46285
  var import_jsx_runtime44 = require("react/jsx-runtime");
46206
46286
  var SHORT_LEN = 8;
46207
46287
  function shortUuid(id, len = SHORT_LEN) {
@@ -46241,11 +46321,11 @@ function MatrxUuidCell({
46241
46321
  }) {
46242
46322
  const { resolveEntityDoors, ResourcePeek } = useMatrxDataTableHost();
46243
46323
  const { notify, notice } = useTableNotice();
46244
- const [copied, setCopied] = (0, import_react18.useState)(false);
46245
- const [opening, setOpening] = (0, import_react18.useState)(false);
46246
- const [peekOpen, setPeekOpen] = (0, import_react18.useState)(false);
46247
- const timer = (0, import_react18.useRef)(null);
46248
- (0, import_react18.useEffect)(
46324
+ const [copied, setCopied] = (0, import_react19.useState)(false);
46325
+ const [opening, setOpening] = (0, import_react19.useState)(false);
46326
+ const [peekOpen, setPeekOpen] = (0, import_react19.useState)(false);
46327
+ const timer = (0, import_react19.useRef)(null);
46328
+ (0, import_react19.useEffect)(
46249
46329
  () => () => {
46250
46330
  if (timer.current) clearTimeout(timer.current);
46251
46331
  },
@@ -46540,7 +46620,7 @@ function DataRowInspector({
46540
46620
  }
46541
46621
 
46542
46622
  // src/data-table/DataRowWindow.tsx
46543
- var import_react19 = require("react");
46623
+ var import_react20 = require("react");
46544
46624
  var import_jsx_runtime46 = require("react/jsx-runtime");
46545
46625
  function DataRowWindow({
46546
46626
  isOpen,
@@ -46561,8 +46641,8 @@ function DataRowWindow({
46561
46641
  const hasEdit = editContent != null;
46562
46642
  const hasTabs = hasEdit && children == null;
46563
46643
  const initialTab = defaultTab ?? (hasEdit ? "edit" : "view");
46564
- const [tab, setTab] = (0, import_react19.useState)(initialTab);
46565
- (0, import_react19.useEffect)(() => {
46644
+ const [tab, setTab] = (0, import_react20.useState)(initialTab);
46645
+ (0, import_react20.useEffect)(() => {
46566
46646
  if (!isOpen) return;
46567
46647
  setTab(defaultTab ?? (hasEdit ? "edit" : "view"));
46568
46648
  }, [isOpen, windowId, hasEdit, defaultTab]);
@@ -47803,7 +47883,7 @@ function DirtySavePill({
47803
47883
  }
47804
47884
 
47805
47885
  // src/data-table/EditableTableCell.tsx
47806
- var import_react20 = require("react");
47886
+ var import_react21 = require("react");
47807
47887
  var import_jsx_runtime49 = require("react/jsx-runtime");
47808
47888
  function CellRefusal({ reason }) {
47809
47889
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
@@ -47865,12 +47945,12 @@ function EditableTableCell({
47865
47945
  editRequest,
47866
47946
  editSeed
47867
47947
  }) {
47868
- const [open, setOpen] = (0, import_react20.useState)(false);
47869
- const [refusal, setRefusal] = (0, import_react20.useState)(null);
47870
- (0, import_react20.useEffect)(() => {
47948
+ const [open, setOpen] = (0, import_react21.useState)(false);
47949
+ const [refusal, setRefusal] = (0, import_react21.useState)(null);
47950
+ (0, import_react21.useEffect)(() => {
47871
47951
  if (editRequest !== void 0) setOpen(true);
47872
47952
  }, [editRequest]);
47873
- (0, import_react20.useEffect)(() => {
47953
+ (0, import_react21.useEffect)(() => {
47874
47954
  if (!open) setRefusal(null);
47875
47955
  }, [open]);
47876
47956
  const usePencil = Boolean(href) || editTrigger === "pencil";
@@ -47974,13 +48054,13 @@ function InlineStringEditor({
47974
48054
  editRequest,
47975
48055
  editSeed
47976
48056
  }) {
47977
- const [editing, setEditing] = (0, import_react20.useState)(false);
47978
- const [draft, setDraft] = (0, import_react20.useState)(value);
47979
- const [refusal, setRefusal] = (0, import_react20.useState)(null);
47980
- const handledEditRequest = (0, import_react20.useRef)(void 0);
47981
- const seedRef = (0, import_react20.useRef)(editSeed);
48057
+ const [editing, setEditing] = (0, import_react21.useState)(false);
48058
+ const [draft, setDraft] = (0, import_react21.useState)(value);
48059
+ const [refusal, setRefusal] = (0, import_react21.useState)(null);
48060
+ const handledEditRequest = (0, import_react21.useRef)(void 0);
48061
+ const seedRef = (0, import_react21.useRef)(editSeed);
47982
48062
  seedRef.current = editSeed;
47983
- (0, import_react20.useEffect)(() => {
48063
+ (0, import_react21.useEffect)(() => {
47984
48064
  if (editRequest === void 0 || handledEditRequest.current === editRequest) return;
47985
48065
  handledEditRequest.current = editRequest;
47986
48066
  setDraft(seedRef.current ?? value);
@@ -48140,8 +48220,8 @@ function DateEditor({
48140
48220
  onCommit,
48141
48221
  onCancel
48142
48222
  }) {
48143
- const [draft, setDraft] = (0, import_react20.useState)(value);
48144
- const done = (0, import_react20.useRef)(false);
48223
+ const [draft, setDraft] = (0, import_react21.useState)(value);
48224
+ const done = (0, import_react21.useRef)(false);
48145
48225
  const finish = () => {
48146
48226
  if (done.current) return;
48147
48227
  done.current = true;
@@ -48176,8 +48256,8 @@ function TagsEditor({
48176
48256
  onCommit,
48177
48257
  onCancel
48178
48258
  }) {
48179
- const [tags, setTags] = (0, import_react20.useState)(value);
48180
- const [draft, setDraft] = (0, import_react20.useState)("");
48259
+ const [tags, setTags] = (0, import_react21.useState)(value);
48260
+ const [draft, setDraft] = (0, import_react21.useState)("");
48181
48261
  const add = (raw) => {
48182
48262
  const next = raw.trim();
48183
48263
  if (!next || tags.includes(next)) return;
@@ -48274,7 +48354,7 @@ function NumberEditor({
48274
48354
  onCommit,
48275
48355
  onCancel
48276
48356
  }) {
48277
- const [draft, setDraft] = (0, import_react20.useState)(String(value));
48357
+ const [draft, setDraft] = (0, import_react21.useState)(String(value));
48278
48358
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "flex flex-col gap-2", children: [
48279
48359
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
48280
48360
  Input,
@@ -48678,6 +48758,7 @@ function safeQueryPage(requestedPage, totalItems, pageSize) {
48678
48758
 
48679
48759
  // src/data-table/MatrxDataTable.tsx
48680
48760
  var import_jsx_runtime51 = require("react/jsx-runtime");
48761
+ var EMPTY_TABLE_ROWS = [];
48681
48762
  function TableToolbarAction({
48682
48763
  HostAction,
48683
48764
  ariaLabel,
@@ -48702,7 +48783,7 @@ function TableToolbarAction({
48702
48783
  disabled,
48703
48784
  onClick,
48704
48785
  children: [
48705
- (0, import_react21.isValidElement)(children) ? (0, import_react21.cloneElement)(children, { className: cn("h-4 w-4", children.props.className) }) : children,
48786
+ (0, import_react22.isValidElement)(children) ? (0, import_react22.cloneElement)(children, { className: cn("h-4 w-4", children.props.className) }) : children,
48706
48787
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { children: ariaLabel })
48707
48788
  ]
48708
48789
  }
@@ -48724,7 +48805,7 @@ function TableToolbarAction({
48724
48805
  "aria-busy": busy || void 0,
48725
48806
  disabled,
48726
48807
  onClick,
48727
- children: (0, import_react21.isValidElement)(children) ? (0, import_react21.cloneElement)(children, { className: cn("h-5 w-5", children.props.className) }) : children
48808
+ children: (0, import_react22.isValidElement)(children) ? (0, import_react22.cloneElement)(children, { className: cn("h-5 w-5", children.props.className) }) : children
48728
48809
  }
48729
48810
  ) }) }),
48730
48811
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TooltipContent, { children: tooltip ?? ariaLabel })
@@ -48787,7 +48868,7 @@ function MatrxDataTableWithUrlState({
48787
48868
  ...urlState.history === void 0 ? {} : { history: urlState.history },
48788
48869
  ...urlState.textHistory === void 0 ? {} : { textHistory: urlState.textHistory }
48789
48870
  });
48790
- (0, import_react21.useEffect)(() => {
48871
+ (0, import_react22.useEffect)(() => {
48791
48872
  if (activeUrlTableIds.has(urlState.id)) {
48792
48873
  throw new Error(
48793
48874
  `Duplicate MatrxDataTable urlState.id "${urlState.id}" on one page. Give every table a unique stable id.`
@@ -48896,7 +48977,7 @@ var DND_MEASURING = { droppable: { strategy: import_core3.MeasuringStrategy.Alwa
48896
48977
  var NO_LAYERED_FILTERS = [];
48897
48978
  var NO_GROUPING_VALUE = "__matrx_no_grouping__";
48898
48979
  function useRenderEpoch(values) {
48899
- const held = (0, import_react21.useRef)(null);
48980
+ const held = (0, import_react22.useRef)(null);
48900
48981
  const previous = held.current;
48901
48982
  if (previous !== null && previous.values.length === values.length && previous.values.every((value, i) => Object.is(value, values[i]))) {
48902
48983
  return previous.epoch;
@@ -48938,10 +49019,10 @@ function versionFacts(version2) {
48938
49019
  function sameBodyRow(a, b) {
48939
49020
  return a.row === b.row && a.index === b.index && a.epoch === b.epoch && a.rowId === b.rowId && a.facts.length === b.facts.length && a.facts.every((fact, i) => Object.is(fact, b.facts[i]));
48940
49021
  }
48941
- var MatrxTableBodyRow = (0, import_react21.memo)(function MatrxTableBodyRow2({ row, index, render }) {
49022
+ var MatrxTableBodyRow = (0, import_react22.memo)(function MatrxTableBodyRow2({ row, index, render }) {
48942
49023
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx_runtime51.Fragment, { children: render(row, index) });
48943
49024
  }, sameBodyRow);
48944
- var MatrxTableChrome = (0, import_react21.memo)(function MatrxTableChrome2({ render }) {
49025
+ var MatrxTableChrome = (0, import_react22.memo)(function MatrxTableChrome2({ render }) {
48945
49026
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx_runtime51.Fragment, { children: render() });
48946
49027
  }, (a, b) => a.part === b.part && a.epoch === b.epoch);
48947
49028
  function columnsSignature(columns) {
@@ -49040,9 +49121,9 @@ function MatrxDataTableCore(coreProps) {
49040
49121
  } = coreProps;
49041
49122
  const appendQuery = query?.mode === "controlled-append" ? query : null;
49042
49123
  const appendQueryKey = appendQuery?.pagination.queryKey ?? null;
49043
- const committedAppendQueryKey = (0, import_react21.useRef)(appendQueryKey);
49124
+ const committedAppendQueryKey = (0, import_react22.useRef)(appendQueryKey);
49044
49125
  const appendSourceChanged = appendQuery !== null && committedAppendQueryKey.current !== appendQueryKey;
49045
- const data = (appendQuery ? appendQuery.pagination.rows : suppliedData) ?? [];
49126
+ const data = (appendQuery ? appendQuery.pagination.rows : suppliedData) ?? EMPTY_TABLE_ROWS;
49046
49127
  const readView = tableReadView(read, data.length, appendQuery ? appendQuery.pagination.loading : suppliedLoading);
49047
49128
  const isLoading = readView.loading;
49048
49129
  const isFetching = appendQuery ? appendQuery.pagination.isFetchingNextPage : suppliedFetching;
@@ -49053,19 +49134,21 @@ function MatrxDataTableCore(coreProps) {
49053
49134
  const ContextMenuBoundary = host.ContextMenuBoundary ?? TableContextPassthrough;
49054
49135
  const resolvedDensity = density ?? host.defaultDensity ?? "normal";
49055
49136
  const SavedViews = host.SavedViews;
49137
+ const savedViewsId = tableId ?? urlState?.id;
49138
+ const showViewTabs = viewTabs && Boolean(viewTabsStore || savedViewsId && SavedViews);
49056
49139
  const Link = host.Link ?? DefaultTableLink;
49057
49140
  const SidePanelSurface = host.SidePanelSurface ?? DefaultTableSidePanel;
49058
49141
  const { notify: toast, notice } = useTableNotice();
49059
- const [savedViewError, setSavedViewError] = (0, import_react21.useState)(null);
49060
- const [toolbarActionError, setToolbarActionError] = (0, import_react21.useState)(null);
49061
- const [toolbarActionPending, setToolbarActionPending] = (0, import_react21.useState)({ refresh: false, add: false });
49062
- const toolbarActionPendingRef = (0, import_react21.useRef)({ refresh: false, add: false });
49142
+ const [savedViewError, setSavedViewError] = (0, import_react22.useState)(null);
49143
+ const [toolbarActionError, setToolbarActionError] = (0, import_react22.useState)(null);
49144
+ const [toolbarActionPending, setToolbarActionPending] = (0, import_react22.useState)({ refresh: false, add: false });
49145
+ const toolbarActionPendingRef = (0, import_react22.useRef)({ refresh: false, add: false });
49063
49146
  const CHECKBOX_TAP_AREA = "h-4 w-4 touch-manipulation";
49064
49147
  const mobileCardsClass = mobileCardsBreakpoint === "lg" ? "lg:hidden" : "sm:hidden";
49065
49148
  const tableWithCardsClass = mobileCardsBreakpoint === "lg" ? "max-lg:hidden" : "max-sm:hidden";
49066
49149
  const cardsQuery = mobileCardsBreakpoint === "lg" ? "(max-width: 1023px)" : "(max-width: 639px)";
49067
- const [cardsActive, setCardsActive] = (0, import_react21.useState)(null);
49068
- (0, import_react21.useEffect)(() => {
49150
+ const [cardsActive, setCardsActive] = (0, import_react22.useState)(null);
49151
+ (0, import_react22.useEffect)(() => {
49069
49152
  if (!mobileCards || typeof window === "undefined" || !window.matchMedia) return;
49070
49153
  const mql = window.matchMedia(cardsQuery);
49071
49154
  const read2 = () => setCardsActive(mql.matches);
@@ -49081,12 +49164,12 @@ function MatrxDataTableCore(coreProps) {
49081
49164
  const appendDefaultsToSourceProcessing = appendQuery !== null && sourceProcessing === void 0;
49082
49165
  const sourceColumnFilterOwnership = sourceProcessing?.columnFilters;
49083
49166
  const sourceOwnsColumnFilters = appendDefaultsToSourceProcessing ? true : sourceColumnFilterOwnership === "source" || typeof sourceColumnFilterOwnership === "object" && sourceColumnFilterOwnership.source.length > 0;
49084
- const remoteQueryUsesLocalColumnFilters = remoteQuery !== null && sourceColumnFilterOwnership === "local";
49167
+ const remoteQueryUsesLocalProcessing = remoteQuery !== null && (sourceColumnFilterOwnership === "local" || remoteQuery.mode === "controlled" && (sourceProcessing?.search === "local" || sourceProcessing?.sort === "local"));
49085
49168
  const sourceOwnsSort = appendQuery !== null && sourceProcessing === void 0 ? true : sourceProcessing?.sort === "source";
49086
49169
  const sourceOwnsIntelligentSearch = sourceProcessing?.intelligentSearch === "source";
49087
- const sourceOwnsSearch = remoteQuery?.mode === "controlled" || appendQuery !== null && sourceProcessing === void 0 || sourceProcessing?.search === "source" || sourceOwnsIntelligentSearch;
49170
+ const sourceOwnsSearch = remoteQuery?.mode === "controlled" && sourceProcessing?.search !== "local" || appendQuery !== null && sourceProcessing === void 0 || sourceProcessing?.search === "source" || sourceOwnsIntelligentSearch;
49088
49171
  const intelligentSearchEnabled = toolbar?.intelligentSearch !== void 0 && (sourceOwnsIntelligentSearch || remoteQuery === null && !sourceOwnsSearch);
49089
- const emitControlledQueryChange = (0, import_react21.useCallback)(
49172
+ const emitControlledQueryChange = (0, import_react22.useCallback)(
49090
49173
  (patch, options) => {
49091
49174
  if (!controlledQuery) return;
49092
49175
  controlledQuery.onStateChange(
@@ -49095,8 +49178,8 @@ function MatrxDataTableCore(coreProps) {
49095
49178
  },
49096
49179
  [controlledQuery]
49097
49180
  );
49098
- const [internalSearch, setInternalSearch] = (0, import_react21.useState)("");
49099
- const [draggedRowId, setDraggedRowId] = (0, import_react21.useState)(null);
49181
+ const [internalSearch, setInternalSearch] = (0, import_react22.useState)("");
49182
+ const [draggedRowId, setDraggedRowId] = (0, import_react22.useState)(null);
49100
49183
  const hierarchySensors = (0, import_core3.useSensors)((0, import_core3.useSensor)(import_core3.PointerSensor, POINTER_SENSOR_OPTIONS));
49101
49184
  const toolbarSearchControlled = toolbar?.searchValue !== void 0;
49102
49185
  const searchValue = controlledQuery ? controlledQuery.state.search : toolbarSearchControlled ? toolbar?.searchValue ?? "" : internalSearch;
@@ -49108,7 +49191,7 @@ function MatrxDataTableCore(coreProps) {
49108
49191
  }
49109
49192
  toolbar?.onSearchChange?.(v);
49110
49193
  };
49111
- const [internalSearchMatchMode, setInternalSearchMatchMode] = (0, import_react21.useState)(
49194
+ const [internalSearchMatchMode, setInternalSearchMatchMode] = (0, import_react22.useState)(
49112
49195
  toolbar?.searchMatch?.defaultMode ?? "contains"
49113
49196
  );
49114
49197
  const searchMatchMode = controlledQuery ? controlledQuery.state.searchMatchMode ?? toolbar?.searchMatch?.defaultMode ?? "contains" : internalSearchMatchMode;
@@ -49119,7 +49202,7 @@ function MatrxDataTableCore(coreProps) {
49119
49202
  }
49120
49203
  setInternalSearchMatchMode(mode);
49121
49204
  };
49122
- const [internalSearchScope, setInternalSearchScope] = (0, import_react21.useState)("all");
49205
+ const [internalSearchScope, setInternalSearchScope] = (0, import_react22.useState)("all");
49123
49206
  const searchScope = controlledQuery ? controlledQuery.state.searchScope ?? "all" : internalSearchScope;
49124
49207
  const setSearchScope = (scope) => {
49125
49208
  if (controlledQuery) {
@@ -49128,7 +49211,7 @@ function MatrxDataTableCore(coreProps) {
49128
49211
  }
49129
49212
  setInternalSearchScope(scope);
49130
49213
  };
49131
- const [internalAnyOf, setInternalAnyOf] = (0, import_react21.useState)("");
49214
+ const [internalAnyOf, setInternalAnyOf] = (0, import_react22.useState)("");
49132
49215
  const toolbarAnyOfControlled = toolbar?.anyOf?.value !== void 0;
49133
49216
  const anyOfValue = controlledQuery ? controlledQuery.state.anyOf : toolbarAnyOfControlled ? toolbar?.anyOf?.value ?? "" : internalAnyOf;
49134
49217
  const setAnyOfValue = (v) => {
@@ -49139,7 +49222,7 @@ function MatrxDataTableCore(coreProps) {
49139
49222
  }
49140
49223
  toolbar?.anyOf?.onChange?.(v);
49141
49224
  };
49142
- const [internalLayeredFilters, setInternalLayeredFilters] = (0, import_react21.useState)([]);
49225
+ const [internalLayeredFilters, setInternalLayeredFilters] = (0, import_react22.useState)([]);
49143
49226
  const layeredFilters = controlledQuery ? controlledQuery.state.layeredFilters ?? NO_LAYERED_FILTERS : internalLayeredFilters;
49144
49227
  const setLayeredFilters = (next) => {
49145
49228
  if (controlledQuery) {
@@ -49148,9 +49231,9 @@ function MatrxDataTableCore(coreProps) {
49148
49231
  }
49149
49232
  setInternalLayeredFilters(next);
49150
49233
  };
49151
- const [internalColumnFilters, setInternalColumnFilters] = (0, import_react21.useState)({});
49234
+ const [internalColumnFilters, setInternalColumnFilters] = (0, import_react22.useState)({});
49152
49235
  const columnFilters = controlledQuery ? controlledQuery.state.columnFilters : internalColumnFilters;
49153
- const localColumnFilters = (0, import_react21.useMemo)(() => {
49236
+ const localColumnFilters = (0, import_react22.useMemo)(() => {
49154
49237
  if (appendDefaultsToSourceProcessing) return {};
49155
49238
  if (sourceColumnFilterOwnership === "source") return {};
49156
49239
  if (sourceColumnFilterOwnership === void 0 || sourceColumnFilterOwnership === "local") {
@@ -49172,7 +49255,7 @@ function MatrxDataTableCore(coreProps) {
49172
49255
  }
49173
49256
  setInternalColumnFilters(nextFilters);
49174
49257
  };
49175
- const [internalSort, setInternalSort] = (0, import_react21.useState)(defaultSort);
49258
+ const [internalSort, setInternalSort] = (0, import_react22.useState)(defaultSort);
49176
49259
  const sort = controlledQuery ? controlledQuery.state.sort : internalSort;
49177
49260
  const setSort = (next) => {
49178
49261
  if (controlledQuery) {
@@ -49181,7 +49264,7 @@ function MatrxDataTableCore(coreProps) {
49181
49264
  }
49182
49265
  setInternalSort(next);
49183
49266
  };
49184
- const [internalPage, setInternalPage] = (0, import_react21.useState)(1);
49267
+ const [internalPage, setInternalPage] = (0, import_react22.useState)(1);
49185
49268
  const page = controlledQuery ? controlledQuery.state.page : internalPage;
49186
49269
  const setPage = (next) => {
49187
49270
  if (controlledQuery) {
@@ -49190,7 +49273,7 @@ function MatrxDataTableCore(coreProps) {
49190
49273
  }
49191
49274
  setInternalPage(next);
49192
49275
  };
49193
- const [internalPageSize, setInternalPageSize] = (0, import_react21.useState)(
49276
+ const [internalPageSize, setInternalPageSize] = (0, import_react22.useState)(
49194
49277
  defaultPageSize
49195
49278
  );
49196
49279
  const pageSize = controlledQuery ? controlledQuery.state.pageSize : internalPageSize;
@@ -49201,28 +49284,28 @@ function MatrxDataTableCore(coreProps) {
49201
49284
  }
49202
49285
  setInternalPageSize(next);
49203
49286
  };
49204
- const [uncontrolledSelectedId, setUncontrolledSelectedId] = (0, import_react21.useState)(null);
49287
+ const [uncontrolledSelectedId, setUncontrolledSelectedId] = (0, import_react22.useState)(null);
49205
49288
  const rawSelectedId = controlledSelectedId !== void 0 ? controlledSelectedId : uncontrolledSelectedId;
49206
49289
  const selectedId = appendSourceChanged ? null : rawSelectedId;
49207
49290
  const setSelectedId = (id) => {
49208
49291
  if (controlledSelectedId === void 0) setUncontrolledSelectedId(id);
49209
49292
  onSelectedIdChange?.(id);
49210
49293
  };
49211
- const [uncontrolledWindowRowId, setUncontrolledWindowRowId] = (0, import_react21.useState)(null);
49294
+ const [uncontrolledWindowRowId, setUncontrolledWindowRowId] = (0, import_react22.useState)(null);
49212
49295
  const rawWindowRowId = controlledWindowRowId !== void 0 ? controlledWindowRowId : uncontrolledWindowRowId;
49213
49296
  const windowRowId = appendSourceChanged ? null : rawWindowRowId;
49214
49297
  const setWindowRowId = (id) => {
49215
49298
  if (controlledWindowRowId === void 0) setUncontrolledWindowRowId(id);
49216
49299
  onWindowRowIdChange?.(id);
49217
49300
  };
49218
- const [windowRowSnapshot, setWindowRowSnapshot] = (0, import_react21.useState)(null);
49301
+ const [windowRowSnapshot, setWindowRowSnapshot] = (0, import_react22.useState)(null);
49219
49302
  const editScopeKey = appendQueryKey === null ? "\0local" : `append:${appendQueryKey}`;
49220
- const [editsByScope, setEditsByScope] = (0, import_react21.useState)({});
49221
- const editRevisionRef = (0, import_react21.useRef)({});
49222
- const [savingByScope, setSavingByScope] = (0, import_react21.useState)({});
49223
- const savingScopesRef = (0, import_react21.useRef)(/* @__PURE__ */ new Set());
49224
- const [editRequest, setEditRequest] = (0, import_react21.useState)(null);
49225
- const [confirmForeignDraftDiscard, setConfirmForeignDraftDiscard] = (0, import_react21.useState)(false);
49303
+ const [editsByScope, setEditsByScope] = (0, import_react22.useState)({});
49304
+ const editRevisionRef = (0, import_react22.useRef)({});
49305
+ const [savingByScope, setSavingByScope] = (0, import_react22.useState)({});
49306
+ const savingScopesRef = (0, import_react22.useRef)(/* @__PURE__ */ new Set());
49307
+ const [editRequest, setEditRequest] = (0, import_react22.useState)(null);
49308
+ const [confirmForeignDraftDiscard, setConfirmForeignDraftDiscard] = (0, import_react22.useState)(false);
49226
49309
  const edits = editsByScope[editScopeKey]?.values ?? {};
49227
49310
  const saving = (savingByScope[editScopeKey] ?? 0) > 0;
49228
49311
  const setEdits = (next) => {
@@ -49289,7 +49372,7 @@ function MatrxDataTableCore(coreProps) {
49289
49372
  rows: Object.entries(draft.values).map(([rowId, columns2]) => ({ rowId, columns: columns2 }))
49290
49373
  }));
49291
49374
  const selection = appendSourceChanged && selectionConfig ? { ...selectionConfig, selectedIds: [] } : selectionConfig;
49292
- (0, import_react21.useEffect)(() => {
49375
+ (0, import_react22.useEffect)(() => {
49293
49376
  const previous = committedAppendQueryKey.current;
49294
49377
  committedAppendQueryKey.current = appendQueryKey;
49295
49378
  if (previous === null || appendQueryKey === null || previous === appendQueryKey) {
@@ -49307,14 +49390,14 @@ function MatrxDataTableCore(coreProps) {
49307
49390
  onWindowRowIdChange,
49308
49391
  selectionConfig
49309
49392
  ]);
49310
- const scrollRef = (0, import_react21.useRef)(null);
49311
- const tableRef = (0, import_react21.useRef)(null);
49312
- const tableHeaderRef = (0, import_react21.useRef)(null);
49313
- const cardsScrollRef = (0, import_react21.useRef)(null);
49314
- const [documentStickyHeader, setDocumentStickyHeader] = (0, import_react21.useState)(false);
49315
- const documentStickyHeaderRef = (0, import_react21.useRef)(false);
49316
- const previousAppendKeyForScrollReset = (0, import_react21.useRef)(appendQueryKey);
49317
- (0, import_react21.useLayoutEffect)(() => {
49393
+ const scrollRef = (0, import_react22.useRef)(null);
49394
+ const tableRef = (0, import_react22.useRef)(null);
49395
+ const tableHeaderRef = (0, import_react22.useRef)(null);
49396
+ const cardsScrollRef = (0, import_react22.useRef)(null);
49397
+ const [documentStickyHeader, setDocumentStickyHeader] = (0, import_react22.useState)(false);
49398
+ const documentStickyHeaderRef = (0, import_react22.useRef)(false);
49399
+ const previousAppendKeyForScrollReset = (0, import_react22.useRef)(appendQueryKey);
49400
+ (0, import_react22.useLayoutEffect)(() => {
49318
49401
  const previous = previousAppendKeyForScrollReset.current;
49319
49402
  previousAppendKeyForScrollReset.current = appendQueryKey;
49320
49403
  if (previous === null || appendQueryKey === null || previous === appendQueryKey) {
@@ -49339,14 +49422,14 @@ function MatrxDataTableCore(coreProps) {
49339
49422
  ...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.thresholdPx !== void 0 ? { thresholdPx: appendScrollPolicy.thresholdPx } : {},
49340
49423
  ...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.intentTimeoutMs !== void 0 ? { intentTimeoutMs: appendScrollPolicy.intentTimeoutMs } : {}
49341
49424
  });
49342
- const rootRef = (0, import_react21.useRef)(null);
49425
+ const rootRef = (0, import_react22.useRef)(null);
49343
49426
  useClippedContentGuard(rootRef, {
49344
49427
  label: typeof copy === "object" && copy.listLabel ? `Table: ${copy.listLabel}` : "MatrxDataTable"
49345
49428
  });
49346
- const [scrollHintRight, setScrollHintRight] = (0, import_react21.useState)(false);
49347
- const [scrollHintLeft, setScrollHintLeft] = (0, import_react21.useState)(false);
49348
- const [scrollHintRightInset, setScrollHintRightInset] = (0, import_react21.useState)(6);
49349
- const updateScrollHint = (0, import_react21.useCallback)(() => {
49429
+ const [scrollHintRight, setScrollHintRight] = (0, import_react22.useState)(false);
49430
+ const [scrollHintLeft, setScrollHintLeft] = (0, import_react22.useState)(false);
49431
+ const [scrollHintRightInset, setScrollHintRightInset] = (0, import_react22.useState)(6);
49432
+ const updateScrollHint = (0, import_react22.useCallback)(() => {
49350
49433
  const el = scrollRef.current;
49351
49434
  if (!el) return;
49352
49435
  const hasRows = Boolean(el.querySelector("tbody tr[data-row-id]"));
@@ -49363,7 +49446,7 @@ function MatrxDataTableCore(coreProps) {
49363
49446
  behavior: "smooth"
49364
49447
  });
49365
49448
  };
49366
- (0, import_react21.useEffect)(() => {
49449
+ (0, import_react22.useEffect)(() => {
49367
49450
  updateScrollHint();
49368
49451
  window.addEventListener("resize", updateScrollHint);
49369
49452
  const el = scrollRef.current;
@@ -49378,7 +49461,7 @@ function MatrxDataTableCore(coreProps) {
49378
49461
  observer?.disconnect();
49379
49462
  };
49380
49463
  }, [updateScrollHint, data, columns]);
49381
- (0, import_react21.useLayoutEffect)(() => {
49464
+ (0, import_react22.useLayoutEffect)(() => {
49382
49465
  const scroll = scrollRef.current;
49383
49466
  const table = tableRef.current;
49384
49467
  const header = tableHeaderRef.current;
@@ -49437,30 +49520,30 @@ function MatrxDataTableCore(coreProps) {
49437
49520
  window.removeEventListener("resize", requestUpdate);
49438
49521
  };
49439
49522
  }, [stickyHeader, data, columns]);
49440
- const [columnOrder, setColumnOrder] = (0, import_react21.useState)(() => columnState?.order ?? columns.map(columnId));
49441
- const [hiddenColumnIds, setHiddenColumnIds] = (0, import_react21.useState)(
49523
+ const [columnOrder, setColumnOrder] = (0, import_react22.useState)(() => columnState?.order ?? columns.map(columnId));
49524
+ const [hiddenColumnIds, setHiddenColumnIds] = (0, import_react22.useState)(
49442
49525
  () => new Set(columnState?.hidden ?? columns.filter((column) => column.hidden).map(columnId))
49443
49526
  );
49444
- const [columnWidths, setColumnWidths] = (0, import_react21.useState)(
49527
+ const [columnWidths, setColumnWidths] = (0, import_react22.useState)(
49445
49528
  () => normalizeColumnWidthsForColumns(columnState?.widths, columns)
49446
49529
  );
49447
- const [fixedTableGeometry, setFixedTableGeometry] = (0, import_react21.useState)(null);
49448
- const knownColumnIds = (0, import_react21.useRef)(new Set(columns.map(columnId)));
49449
- const draggedColumnId = (0, import_react21.useRef)(null);
49450
- const columnDragActive = (0, import_react21.useRef)(false);
49451
- const columnDragRaf = (0, import_react21.useRef)(null);
49452
- const columnDragScrollDirection = (0, import_react21.useRef)(0);
49453
- const [columnDragPreview, setColumnDragPreview] = (0, import_react21.useState)(null);
49454
- const stopColumnDragScroll = (0, import_react21.useCallback)(() => {
49530
+ const [fixedTableGeometry, setFixedTableGeometry] = (0, import_react22.useState)(null);
49531
+ const knownColumnIds = (0, import_react22.useRef)(new Set(columns.map(columnId)));
49532
+ const draggedColumnId = (0, import_react22.useRef)(null);
49533
+ const columnDragActive = (0, import_react22.useRef)(false);
49534
+ const columnDragRaf = (0, import_react22.useRef)(null);
49535
+ const columnDragScrollDirection = (0, import_react22.useRef)(0);
49536
+ const [columnDragPreview, setColumnDragPreview] = (0, import_react22.useState)(null);
49537
+ const stopColumnDragScroll = (0, import_react22.useCallback)(() => {
49455
49538
  if (columnDragRaf.current !== null) cancelAnimationFrame(columnDragRaf.current);
49456
49539
  columnDragRaf.current = null;
49457
49540
  columnDragScrollDirection.current = 0;
49458
49541
  }, []);
49459
- (0, import_react21.useEffect)(() => () => {
49542
+ (0, import_react22.useEffect)(() => () => {
49460
49543
  columnDragActive.current = false;
49461
49544
  stopColumnDragScroll();
49462
49545
  }, [stopColumnDragScroll]);
49463
- const startColumnDragScroll = (0, import_react21.useCallback)(() => {
49546
+ const startColumnDragScroll = (0, import_react22.useCallback)(() => {
49464
49547
  if (!columnDragActive.current || columnDragRaf.current !== null) return;
49465
49548
  const scrollStep = () => {
49466
49549
  const scroll = scrollRef.current;
@@ -49487,25 +49570,25 @@ function MatrxDataTableCore(coreProps) {
49487
49570
  };
49488
49571
  columnDragRaf.current = requestAnimationFrame(scrollStep);
49489
49572
  }, []);
49490
- const commitColumnState = (0, import_react21.useCallback)((order, hidden) => {
49573
+ const commitColumnState = (0, import_react22.useCallback)((order, hidden) => {
49491
49574
  if (columnState) columnState.onChange({ order, hidden: [...hidden] });
49492
49575
  else {
49493
49576
  setColumnOrder(order);
49494
49577
  setHiddenColumnIds(hidden);
49495
49578
  }
49496
49579
  }, [columnState]);
49497
- const [internalColumnManagerOpen, setInternalColumnManagerOpen] = (0, import_react21.useState)(false);
49580
+ const [internalColumnManagerOpen, setInternalColumnManagerOpen] = (0, import_react22.useState)(false);
49498
49581
  const columnManagerOpen = controlledColumnManager?.open ?? internalColumnManagerOpen;
49499
49582
  const setColumnManagerOpen = controlledColumnManager?.onOpenChange ?? setInternalColumnManagerOpen;
49500
- const columnIds = (0, import_react21.useMemo)(() => columns.map(columnId), [columns]);
49501
- const effectiveColumnOrder = (0, import_react21.useMemo)(() => columnState ? [...columnState.order.filter((id, index, values) => columnIds.includes(id) && values.indexOf(id) === index), ...columnIds.filter((id) => !columnState.order.includes(id))] : columnOrder, [columnIds, columnOrder, columnState]);
49502
- const effectiveHiddenColumnIds = (0, import_react21.useMemo)(() => columnState ? new Set(columnState.hidden.filter((id) => columnIds.includes(id))) : hiddenColumnIds, [columnIds, columnState, hiddenColumnIds]);
49503
- const effectiveColumnWidths = (0, import_react21.useMemo)(
49583
+ const columnIds = (0, import_react22.useMemo)(() => columns.map(columnId), [columns]);
49584
+ const effectiveColumnOrder = (0, import_react22.useMemo)(() => columnState ? [...columnState.order.filter((id, index, values) => columnIds.includes(id) && values.indexOf(id) === index), ...columnIds.filter((id) => !columnState.order.includes(id))] : columnOrder, [columnIds, columnOrder, columnState]);
49585
+ const effectiveHiddenColumnIds = (0, import_react22.useMemo)(() => columnState ? new Set(columnState.hidden.filter((id) => columnIds.includes(id))) : hiddenColumnIds, [columnIds, columnState, hiddenColumnIds]);
49586
+ const effectiveColumnWidths = (0, import_react22.useMemo)(
49504
49587
  () => normalizeColumnWidthsForColumns(columnState?.widths ?? columnWidths, columns),
49505
49588
  [columns, columnState?.widths, columnWidths]
49506
49589
  );
49507
- const resizeGestureSnapshotRef = (0, import_react21.useRef)(null);
49508
- const measureVisibleColumnWidths = (0, import_react21.useCallback)(() => {
49590
+ const resizeGestureSnapshotRef = (0, import_react22.useRef)(null);
49591
+ const measureVisibleColumnWidths = (0, import_react22.useCallback)(() => {
49509
49592
  const measured = {};
49510
49593
  const headers = tableRef.current ? Array.from(tableRef.current.querySelectorAll(
49511
49594
  "thead th[data-matrx-table-column-id]"
@@ -49519,7 +49602,7 @@ function MatrxDataTableCore(coreProps) {
49519
49602
  }
49520
49603
  return normalizeColumnWidthsForColumns(measured, columns);
49521
49604
  }, [columns]);
49522
- const measureFixedTableGeometry = (0, import_react21.useCallback)(() => {
49605
+ const measureFixedTableGeometry = (0, import_react22.useCallback)(() => {
49523
49606
  const table = tableRef.current;
49524
49607
  const headers = table ? Array.from(table.querySelectorAll("thead th")) : [];
49525
49608
  const widthFor = (selector) => {
@@ -49554,16 +49637,16 @@ function MatrxDataTableCore(coreProps) {
49554
49637
  ...actionsWidth === void 0 ? {} : { actionsWidth }
49555
49638
  };
49556
49639
  }, [resolvedDensity]);
49557
- const captureResizeGestureSnapshot = (0, import_react21.useCallback)(() => {
49640
+ const captureResizeGestureSnapshot = (0, import_react22.useCallback)(() => {
49558
49641
  resizeGestureSnapshotRef.current = {
49559
49642
  widths: measureVisibleColumnWidths(),
49560
49643
  geometry: measureFixedTableGeometry()
49561
49644
  };
49562
49645
  }, [measureFixedTableGeometry, measureVisibleColumnWidths]);
49563
- const clearResizeGestureSnapshot = (0, import_react21.useCallback)(() => {
49646
+ const clearResizeGestureSnapshot = (0, import_react22.useCallback)(() => {
49564
49647
  resizeGestureSnapshotRef.current = null;
49565
49648
  }, []);
49566
- const commitColumnWidths = (0, import_react21.useCallback)((next, captureInitialWidths = false) => {
49649
+ const commitColumnWidths = (0, import_react22.useCallback)((next, captureInitialWidths = false) => {
49567
49650
  const gestureSnapshot = captureInitialWidths ? resizeGestureSnapshotRef.current : null;
49568
49651
  resizeGestureSnapshotRef.current = null;
49569
49652
  const normalized = normalizeColumnWidthsForColumns(
@@ -49582,7 +49665,7 @@ function MatrxDataTableCore(coreProps) {
49582
49665
  }
49583
49666
  setColumnWidths(normalized);
49584
49667
  }, [columnIds, columnState, columns, measureFixedTableGeometry, measureVisibleColumnWidths]);
49585
- (0, import_react21.useEffect)(() => {
49668
+ (0, import_react22.useEffect)(() => {
49586
49669
  const ids = columns.map(columnId);
49587
49670
  if (columnState) return;
49588
49671
  const previousIds = knownColumnIds.current;
@@ -49601,31 +49684,31 @@ function MatrxDataTableCore(coreProps) {
49601
49684
  setColumnWidths((current) => normalizeColumnWidthsForColumns(current, columns));
49602
49685
  knownColumnIds.current = new Set(ids);
49603
49686
  }, [columns, columnState]);
49604
- (0, import_react21.useLayoutEffect)(() => {
49687
+ (0, import_react22.useLayoutEffect)(() => {
49605
49688
  for (const id of columnIds) {
49606
49689
  tableRef.current?.style.removeProperty(columnResizeCssVar(id));
49607
49690
  }
49608
49691
  });
49609
- const previewColumnOrder = (0, import_react21.useMemo)(
49692
+ const previewColumnOrder = (0, import_react22.useMemo)(
49610
49693
  () => projectColumnDragOrder(effectiveColumnOrder, columnDragPreview),
49611
49694
  [columnDragPreview, effectiveColumnOrder]
49612
49695
  );
49613
49696
  useColumnReorderAnimation(tableRef, previewColumnOrder.join("\0"), columnDragPreview !== null);
49614
- const visibleColumns = (0, import_react21.useMemo)(() => {
49697
+ const visibleColumns = (0, import_react22.useMemo)(() => {
49615
49698
  const byId = new Map(columns.map((column) => [columnId(column), column]));
49616
49699
  return previewColumnOrder.map((id) => byId.get(id)).filter(
49617
49700
  (column) => column !== void 0 && !effectiveHiddenColumnIds.has(columnId(column))
49618
49701
  );
49619
49702
  }, [columns, effectiveHiddenColumnIds, previewColumnOrder]);
49620
49703
  const usesMeasuredFixedLayout = visibleColumns.length > 0 && visibleColumns.every((column) => effectiveColumnWidths[columnId(column)] !== void 0);
49621
- (0, import_react21.useLayoutEffect)(() => {
49704
+ (0, import_react22.useLayoutEffect)(() => {
49622
49705
  if (!usesMeasuredFixedLayout) {
49623
49706
  if (fixedTableGeometry !== null) setFixedTableGeometry(null);
49624
49707
  return;
49625
49708
  }
49626
49709
  if (fixedTableGeometry === null) setFixedTableGeometry(measureFixedTableGeometry());
49627
49710
  }, [fixedTableGeometry, measureFixedTableGeometry, usesMeasuredFixedLayout]);
49628
- (0, import_react21.useLayoutEffect)(() => {
49711
+ (0, import_react22.useLayoutEffect)(() => {
49629
49712
  if (!usesMeasuredFixedLayout) return;
49630
49713
  const table = tableRef.current;
49631
49714
  if (!table) return;
@@ -49649,8 +49732,8 @@ function MatrxDataTableCore(coreProps) {
49649
49732
  const fixedLayoutActive = usesMeasuredFixedLayout && fixedTableGeometry !== null;
49650
49733
  const freezeWanted = visibleColumns.some((column) => column.frozen);
49651
49734
  const selectionColumnWidth = fixedTableGeometry?.selectionWidth ?? (selection && (freezeWanted || fitToWidth) ? SELECTION_COLUMN_PX : void 0);
49652
- const [fitSpace, setFitSpace] = (0, import_react21.useState)(null);
49653
- (0, import_react21.useLayoutEffect)(() => {
49735
+ const [fitSpace, setFitSpace] = (0, import_react22.useState)(null);
49736
+ (0, import_react22.useLayoutEffect)(() => {
49654
49737
  if (!fitToWidth) {
49655
49738
  setFitSpace(null);
49656
49739
  return;
@@ -49665,19 +49748,28 @@ function MatrxDataTableCore(coreProps) {
49665
49748
  ...strips.map((strip) => Math.ceil(strip.scrollWidth) + 16),
49666
49749
  actionsHeader ? Math.ceil(actionsHeader.scrollWidth) : 0
49667
49750
  );
49668
- const next = { width: el.clientWidth, actions };
49669
- setFitSpace((now) => now && now.width === next.width && now.actions === next.actions ? now : next);
49751
+ const table2 = el.querySelector(":scope > table");
49752
+ const spill = table2 && table2.hasAttribute("data-matrx-table-fit") ? Math.max(0, el.scrollWidth - el.clientWidth) : 0;
49753
+ setFitSpace((now) => {
49754
+ const sameWidth = now !== null && now.width === el.clientWidth;
49755
+ const slack = sameWidth ? now.slack + spill : spill;
49756
+ const next = { width: el.clientWidth, actions, slack };
49757
+ return now && now.width === next.width && now.actions === next.actions && now.slack === next.slack ? now : next;
49758
+ });
49670
49759
  };
49671
49760
  read2();
49672
49761
  if (typeof ResizeObserver === "undefined") return;
49673
49762
  const observer = new ResizeObserver(read2);
49674
49763
  observer.observe(el);
49764
+ const table = el.querySelector(":scope > table");
49765
+ if (table) observer.observe(table);
49675
49766
  return () => observer.disconnect();
49676
49767
  }, [fitToWidth, data.length]);
49677
- const fittedWidths = (0, import_react21.useMemo)(() => {
49768
+ const fittedWidths = (0, import_react22.useMemo)(() => {
49678
49769
  if (!fitToWidth || !fitSpace) return null;
49679
- const scaling = visibleColumns.filter((col) => resolveColumnMarker(col) === void 0);
49680
- const fixed = visibleColumns.filter((col) => resolveColumnMarker(col) !== void 0).reduce((sum, col) => sum + (pixelWidth(col.width) ?? 40), 0);
49770
+ const keepsItsWidth = (col) => resolveColumnMarker(col) !== void 0 || col.resizable === false && pixelWidth(col.width) !== void 0;
49771
+ const scaling = visibleColumns.filter((col) => !keepsItsWidth(col));
49772
+ const fixed = visibleColumns.filter(keepsItsWidth).reduce((sum, col) => sum + (pixelWidth(col.width) ?? 40), 0);
49681
49773
  const utilities = (selection ? selectionColumnWidth ?? SELECTION_COLUMN_PX : 0) + fitSpace.actions;
49682
49774
  return fitColumnWidths(
49683
49775
  scaling.map(columnId),
@@ -49685,12 +49777,12 @@ function MatrxDataTableCore(coreProps) {
49685
49777
  const col = scaling.find((c) => columnId(c) === id);
49686
49778
  return effectiveColumnWidths[id] ?? pixelWidth(col?.width) ?? FIT_DEFAULT_COLUMN_PX;
49687
49779
  },
49688
- fitSpace.width - utilities - fixed
49780
+ fitSpace.width - utilities - fixed - fitSpace.slack
49689
49781
  );
49690
49782
  }, [fitToWidth, fitSpace, visibleColumns, selection, selectionColumnWidth, effectiveColumnWidths]);
49691
49783
  const fitActive = fittedWidths !== null;
49692
49784
  const actionsColumnWidth = fitActive && fitSpace ? fitSpace.actions : fixedTableGeometry?.actionsWidth;
49693
- const frozenColumns = (0, import_react21.useMemo)(() => {
49785
+ const frozenColumns = (0, import_react22.useMemo)(() => {
49694
49786
  if (!freezeWanted) return NO_FROZEN_COLUMNS;
49695
49787
  const ids = visibleColumns.map(columnId);
49696
49788
  const byId = new Map(visibleColumns.map((column) => [columnId(column), column]));
@@ -49738,15 +49830,15 @@ function MatrxDataTableCore(coreProps) {
49738
49830
  const color = cellTintColor(row, id, colId);
49739
49831
  return color ? CELL_TINT_CLASS[color] : void 0;
49740
49832
  };
49741
- const declaredVisibleCopyColumns = (0, import_react21.useMemo)(
49833
+ const declaredVisibleCopyColumns = (0, import_react22.useMemo)(
49742
49834
  () => visibleColumns.filter((column) => column.accessorFn !== void 0 || column.accessorKey !== void 0),
49743
49835
  [visibleColumns]
49744
49836
  );
49745
- const tableCopySourceNamespace = (0, import_react21.useId)();
49746
- const tableContextMenuInstanceId = (0, import_react21.useId)();
49747
- const tableDndContextId = (0, import_react21.useId)();
49837
+ const tableCopySourceNamespace = (0, import_react22.useId)();
49838
+ const tableContextMenuInstanceId = (0, import_react22.useId)();
49839
+ const tableDndContextId = (0, import_react22.useId)();
49748
49840
  const defaultCopyTitle = toolbar?.title || "Table";
49749
- const defaultCopy = (0, import_react21.useMemo)(() => ({
49841
+ const defaultCopy = (0, import_react22.useMemo)(() => ({
49750
49842
  label: defaultCopyTitle,
49751
49843
  listLabel: defaultCopyTitle,
49752
49844
  location: defaultCopyTitle,
@@ -49763,14 +49855,14 @@ function MatrxDataTableCore(coreProps) {
49763
49855
  const effectiveCopy = copy === false ? void 0 : copy ?? defaultCopy;
49764
49856
  const effectiveCopyColumns = copy === void 0 ? declaredVisibleCopyColumns : visibleColumns;
49765
49857
  const copySubsetVariant2 = useCopySubsetVariant();
49766
- const chromeLatest = (0, import_react21.useRef)({
49858
+ const chromeLatest = (0, import_react22.useRef)({
49767
49859
  processed: [],
49768
49860
  data: [],
49769
49861
  toggleAllOnPage: () => void 0,
49770
49862
  showMore: async () => void 0,
49771
49863
  applySavedView: () => void 0
49772
49864
  });
49773
- const applyLatestSavedView = (0, import_react21.useCallback)((snapshot) => chromeLatest.current.applySavedView(snapshot), []);
49865
+ const applyLatestSavedView = (0, import_react22.useCallback)((snapshot) => chromeLatest.current.applySavedView(snapshot), []);
49774
49866
  const copySubsetColumns = () => effectiveCopyColumns.filter((c) => c.filter !== false || c.accessorKey || c.accessorFn).map((c) => ({
49775
49867
  id: columnId(c),
49776
49868
  header: typeof c.header === "string" ? c.header : columnId(c),
@@ -49791,7 +49883,7 @@ function MatrxDataTableCore(coreProps) {
49791
49883
  serializer: (shaped) => buildViewAgentInput(effectiveCopy, shaped, chromeLatest.current.data, { scope: "custom" })
49792
49884
  }), copySubsetSize(rows().length, copySubsetColumns().length))
49793
49885
  ] : [];
49794
- const filterMeta = (0, import_react21.useMemo)(() => {
49886
+ const filterMeta = (0, import_react22.useMemo)(() => {
49795
49887
  const meta = /* @__PURE__ */ new Map();
49796
49888
  for (const col of visibleColumns) {
49797
49889
  const id = columnId(col);
@@ -49799,15 +49891,15 @@ function MatrxDataTableCore(coreProps) {
49799
49891
  }
49800
49892
  return meta;
49801
49893
  }, [visibleColumns, data, remoteQuery]);
49802
- const intelligentSearchScopes = (0, import_react21.useMemo)(
49894
+ const intelligentSearchScopes = (0, import_react22.useMemo)(
49803
49895
  () => resolveTableSearchScopes(data, columns, {
49804
49896
  ...toolbar?.intelligentSearch?.roles === void 0 ? {} : { roles: toolbar.intelligentSearch.roles },
49805
49897
  ...toolbar?.intelligentSearch?.scopes === void 0 ? {} : { scopes: toolbar.intelligentSearch.scopes }
49806
49898
  }),
49807
49899
  [columns, data, toolbar?.intelligentSearch?.roles, toolbar?.intelligentSearch?.scopes]
49808
49900
  );
49809
- const processed = (0, import_react21.useMemo)(() => {
49810
- if (remoteQuery && !appendUsesLocalProcessing && !remoteQueryUsesLocalColumnFilters) return data;
49901
+ const processed = (0, import_react22.useMemo)(() => {
49902
+ if (remoteQuery && !appendUsesLocalProcessing && !remoteQueryUsesLocalProcessing) return data;
49811
49903
  if (processLocalRows) {
49812
49904
  return processLocalRows(data, {
49813
49905
  page,
@@ -49863,15 +49955,15 @@ function MatrxDataTableCore(coreProps) {
49863
49955
  pageSize,
49864
49956
  remoteQuery,
49865
49957
  appendUsesLocalProcessing,
49866
- remoteQueryUsesLocalColumnFilters,
49958
+ remoteQueryUsesLocalProcessing,
49867
49959
  sourceOwnsColumnFilters,
49868
49960
  sourceOwnsSort,
49869
49961
  sourceOwnsSearch,
49870
49962
  intelligentSearchEnabled,
49871
49963
  searchScope
49872
49964
  ]);
49873
- const lastNotifiedViewRows = (0, import_react21.useRef)(null);
49874
- (0, import_react21.useEffect)(() => {
49965
+ const lastNotifiedViewRows = (0, import_react22.useRef)(null);
49966
+ (0, import_react22.useEffect)(() => {
49875
49967
  if (!onViewChange) {
49876
49968
  lastNotifiedViewRows.current = null;
49877
49969
  return;
@@ -49880,7 +49972,7 @@ function MatrxDataTableCore(coreProps) {
49880
49972
  lastNotifiedViewRows.current = processed;
49881
49973
  if (changed) onViewChange(processed);
49882
49974
  }, [processed, onViewChange]);
49883
- (0, import_react21.useEffect)(() => {
49975
+ (0, import_react22.useEffect)(() => {
49884
49976
  if (controlledQuery) return;
49885
49977
  setInternalPage(1);
49886
49978
  }, [
@@ -49924,7 +50016,7 @@ function MatrxDataTableCore(coreProps) {
49924
50016
  numberedPageHasMore: !hidePagination && !isLoading && !isFetching && processed.length > 0 && safePage < pageCount && (remoteQuery?.mode === "controlled" || !remoteQuery),
49925
50017
  onPageAdvance: setPage
49926
50018
  });
49927
- const paginated = (0, import_react21.useMemo)(() => {
50019
+ const paginated = (0, import_react22.useMemo)(() => {
49928
50020
  if (remoteQuery) return processed;
49929
50021
  if (hidePagination) return processed;
49930
50022
  if (localProgressiveEnabled) return [...progressiveRows.rows];
@@ -49933,16 +50025,16 @@ function MatrxDataTableCore(coreProps) {
49933
50025
  return processed.slice(start, start + effectivePageSize);
49934
50026
  }, [processed, safePage, effectivePageSize, pageSize, remoteQuery, hidePagination, localProgressiveEnabled, progressiveRows.rows]);
49935
50027
  const groupingColumnId = grouping?.columnId ?? null;
49936
- const [uncontrolledCollapsed, setUncontrolledCollapsed] = (0, import_react21.useState)([]);
50028
+ const [uncontrolledCollapsed, setUncontrolledCollapsed] = (0, import_react22.useState)([]);
49937
50029
  const collapsedGroups = grouping?.collapsed ?? uncontrolledCollapsed;
49938
- const setCollapsedGroups = (0, import_react21.useCallback)(
50030
+ const setCollapsedGroups = (0, import_react22.useCallback)(
49939
50031
  (next) => {
49940
50032
  if (grouping?.onCollapsedChange) grouping.onCollapsedChange(next);
49941
50033
  else setUncontrolledCollapsed(next);
49942
50034
  },
49943
50035
  [grouping]
49944
50036
  );
49945
- const groups = (0, import_react21.useMemo)(() => {
50037
+ const groups = (0, import_react22.useMemo)(() => {
49946
50038
  if (!grouping || !groupingColumnId) return null;
49947
50039
  const groupColumn = columns.find((col) => columnId(col) === groupingColumnId);
49948
50040
  if (!groupColumn) return null;
@@ -49961,7 +50053,7 @@ function MatrxDataTableCore(coreProps) {
49961
50053
  ...grouping.emptyLabel ? { emptyLabel: grouping.emptyLabel } : {}
49962
50054
  });
49963
50055
  }, [grouping, groupingColumnId, columns, paginated]);
49964
- const groupableColumns = (0, import_react21.useMemo)(() => {
50056
+ const groupableColumns = (0, import_react22.useMemo)(() => {
49965
50057
  const allowed = grouping?.groupableColumnIds;
49966
50058
  return visibleColumns.filter((col) => {
49967
50059
  const id = columnId(col);
@@ -49969,7 +50061,7 @@ function MatrxDataTableCore(coreProps) {
49969
50061
  return col.accessorKey !== void 0 || col.accessorFn !== void 0;
49970
50062
  });
49971
50063
  }, [visibleColumns, grouping?.groupableColumnIds]);
49972
- const groupedRenderRows = (0, import_react21.useMemo)(
50064
+ const groupedRenderRows = (0, import_react22.useMemo)(
49973
50065
  () => groups ? flattenGroups(groups, collapsedGroups) : null,
49974
50066
  [groups, collapsedGroups]
49975
50067
  );
@@ -49981,7 +50073,7 @@ function MatrxDataTableCore(coreProps) {
49981
50073
  const bodyEntryCount = groupedRenderRows ? groupedRenderRows.length : paginated.length;
49982
50074
  const virtualizeActive = virtualizeConfig !== null && virtualizeConfig.enabled !== false && bodyEntryCount > virtualThreshold && !hierarchy && expandedDetail === void 0;
49983
50075
  const columnWindowWidth = virtualizeConfig?.columnWidth ?? 160;
49984
- const frozenRunLength = (0, import_react21.useMemo)(() => {
50076
+ const frozenRunLength = (0, import_react22.useMemo)(() => {
49985
50077
  let run = 0;
49986
50078
  for (const col of visibleColumns) {
49987
50079
  if (frozenColumns.offsets[columnId(col)] === void 0) break;
@@ -49990,9 +50082,9 @@ function MatrxDataTableCore(coreProps) {
49990
50082
  return run;
49991
50083
  }, [visibleColumns, frozenColumns]);
49992
50084
  const columnVirtualizeActive = virtualizeConfig !== null && virtualizeConfig.enabled !== false && virtualizeConfig.columns === true && visibleColumns.length - frozenRunLength > 30 && !hierarchy && mobileCards === void 0;
49993
- const [rowWindow, setRowWindow] = (0, import_react21.useState)(null);
49994
- const [columnWindow, setColumnWindow] = (0, import_react21.useState)(null);
49995
- const windowInputs = (0, import_react21.useRef)({
50085
+ const [rowWindow, setRowWindow] = (0, import_react22.useState)(null);
50086
+ const [columnWindow, setColumnWindow] = (0, import_react22.useState)(null);
50087
+ const windowInputs = (0, import_react22.useRef)({
49996
50088
  virtualizeActive: false,
49997
50089
  bodyEntryCount: 0,
49998
50090
  virtualRowHeight: 40,
@@ -50012,7 +50104,7 @@ function MatrxDataTableCore(coreProps) {
50012
50104
  columnWindowWidth,
50013
50105
  frozenRunLength
50014
50106
  };
50015
- const recomputeWindows = (0, import_react21.useCallback)(() => {
50107
+ const recomputeWindows = (0, import_react22.useCallback)(() => {
50016
50108
  const el = scrollRef.current;
50017
50109
  const input = windowInputs.current;
50018
50110
  const nextRow = input.virtualizeActive ? computeWindow({
@@ -50033,7 +50125,7 @@ function MatrxDataTableCore(coreProps) {
50033
50125
  setRowWindow((prev) => sameWindow(prev, nextRow) ? prev : nextRow);
50034
50126
  setColumnWindow((prev) => sameWindow(prev, nextColumn) ? prev : nextColumn);
50035
50127
  }, []);
50036
- const effectiveRowWindow = (0, import_react21.useMemo)(() => {
50128
+ const effectiveRowWindow = (0, import_react22.useMemo)(() => {
50037
50129
  if (!virtualizeActive) return null;
50038
50130
  if (rowWindow && rowWindow.end <= bodyEntryCount) return rowWindow;
50039
50131
  return computeWindow({
@@ -50044,7 +50136,7 @@ function MatrxDataTableCore(coreProps) {
50044
50136
  overscan: virtualizeConfig?.overscan ?? 8
50045
50137
  });
50046
50138
  }, [virtualizeActive, rowWindow, bodyEntryCount, virtualRowHeight, virtualizeConfig?.overscan]);
50047
- const effectiveColumnWindow = (0, import_react21.useMemo)(() => {
50139
+ const effectiveColumnWindow = (0, import_react22.useMemo)(() => {
50048
50140
  if (!columnVirtualizeActive) return null;
50049
50141
  if (columnWindow && columnWindow.end <= visibleColumns.length) return columnWindow;
50050
50142
  return computeWindow({
@@ -50064,7 +50156,7 @@ function MatrxDataTableCore(coreProps) {
50064
50156
  frozenRunLength
50065
50157
  ]);
50066
50158
  const metricsWanted = virtualizeActive || columnVirtualizeActive;
50067
- (0, import_react21.useEffect)(() => {
50159
+ (0, import_react22.useEffect)(() => {
50068
50160
  recomputeWindows();
50069
50161
  }, [
50070
50162
  recomputeWindows,
@@ -50076,7 +50168,7 @@ function MatrxDataTableCore(coreProps) {
50076
50168
  columnWindowWidth,
50077
50169
  frozenRunLength
50078
50170
  ]);
50079
- (0, import_react21.useEffect)(() => {
50171
+ (0, import_react22.useEffect)(() => {
50080
50172
  if (!metricsWanted) return;
50081
50173
  const el = scrollRef.current;
50082
50174
  if (!el) return;
@@ -50097,7 +50189,7 @@ function MatrxDataTableCore(coreProps) {
50097
50189
  observer?.disconnect();
50098
50190
  };
50099
50191
  }, [metricsWanted, recomputeWindows]);
50100
- const renderedColumns = (0, import_react21.useMemo)(
50192
+ const renderedColumns = (0, import_react22.useMemo)(
50101
50193
  () => effectiveColumnWindow ? [
50102
50194
  ...visibleColumns.slice(0, frozenRunLength),
50103
50195
  ...visibleColumns.slice(effectiveColumnWindow.start, effectiveColumnWindow.end)
@@ -50105,7 +50197,7 @@ function MatrxDataTableCore(coreProps) {
50105
50197
  [effectiveColumnWindow, visibleColumns, frozenRunLength]
50106
50198
  );
50107
50199
  const columnSpacers = effectiveColumnWindow ? { start: effectiveColumnWindow.padStart, end: effectiveColumnWindow.padEnd } : null;
50108
- const windowedWidthFor = (0, import_react21.useCallback)(
50200
+ const windowedWidthFor = (0, import_react22.useCallback)(
50109
50201
  (id, declared) => {
50110
50202
  const fitted = fittedWidths?.[id];
50111
50203
  if (fitted !== void 0) return fitted;
@@ -50117,7 +50209,7 @@ function MatrxDataTableCore(coreProps) {
50117
50209
  [effectiveColumnWindow, effectiveColumnWidths, frozenColumns, columnWindowWidth, fittedWidths]
50118
50210
  );
50119
50211
  const coverageUnanswered = readView.failure || read?.status === "loading" && data.length === 0;
50120
- const coverageResult = (0, import_react21.useMemo)(() => {
50212
+ const coverageResult = (0, import_react22.useMemo)(() => {
50121
50213
  if (!coverage || coverageUnanswered) return null;
50122
50214
  return describeCoverage({
50123
50215
  loaded: coverage.loaded ?? data.length,
@@ -50128,7 +50220,7 @@ function MatrxDataTableCore(coreProps) {
50128
50220
  ...coverage.noun === void 0 ? {} : { noun: coverage.noun }
50129
50221
  });
50130
50222
  }, [coverage, coverageUnanswered, data.length]);
50131
- const bodyEntries = (0, import_react21.useMemo)(() => {
50223
+ const bodyEntries = (0, import_react22.useMemo)(() => {
50132
50224
  const from = effectiveRowWindow ? effectiveRowWindow.start : 0;
50133
50225
  const to = effectiveRowWindow ? effectiveRowWindow.end : void 0;
50134
50226
  const windowed = groupedRenderRows ? groupedRenderRows.slice(from, to).map(
@@ -50145,28 +50237,28 @@ function MatrxDataTableCore(coreProps) {
50145
50237
  windowed.push({ kind: "spacer", height: effectiveRowWindow.padEnd, place: "end" });
50146
50238
  return windowed;
50147
50239
  }, [groupedRenderRows, collapsedGroups, paginated, effectiveRowWindow]);
50148
- const getRowIdRef = (0, import_react21.useRef)(getRowId);
50240
+ const getRowIdRef = (0, import_react22.useRef)(getRowId);
50149
50241
  getRowIdRef.current = getRowId;
50150
- const spreadsheetRowIds = (0, import_react21.useMemo)(
50242
+ const spreadsheetRowIds = (0, import_react22.useMemo)(
50151
50243
  () => paginated.map((row) => getRowIdRef.current(row)),
50152
50244
  [paginated]
50153
50245
  );
50154
- const spreadsheetColumnIds = (0, import_react21.useMemo)(
50246
+ const spreadsheetColumnIds = (0, import_react22.useMemo)(
50155
50247
  () => visibleColumns.map((col) => columnId(col)),
50156
50248
  [visibleColumns]
50157
50249
  );
50158
- const spreadsheetRowById = (0, import_react21.useMemo)(() => {
50250
+ const spreadsheetRowById = (0, import_react22.useMemo)(() => {
50159
50251
  const map = /* @__PURE__ */ new Map();
50160
50252
  for (const row of paginated) map.set(getRowIdRef.current(row), row);
50161
50253
  return map;
50162
50254
  }, [paginated]);
50163
- const spreadsheetColumnById = (0, import_react21.useMemo)(() => {
50255
+ const spreadsheetColumnById = (0, import_react22.useMemo)(() => {
50164
50256
  const map = /* @__PURE__ */ new Map();
50165
50257
  for (const col of visibleColumns) map.set(columnId(col), col);
50166
50258
  return map;
50167
50259
  }, [visibleColumns]);
50168
50260
  const spreadsheetEnabled = Boolean(spreadsheet && spreadsheet.enabled !== false);
50169
- const openRowRef = (0, import_react21.useRef)(() => void 0);
50261
+ const openRowRef = (0, import_react22.useRef)(() => void 0);
50170
50262
  const sheet = useSpreadsheetGrid(
50171
50263
  spreadsheetEnabled && spreadsheet ? {
50172
50264
  rowIds: spreadsheetRowIds,
@@ -50208,12 +50300,12 @@ function MatrxDataTableCore(coreProps) {
50208
50300
  } : null
50209
50301
  );
50210
50302
  if (spreadsheet?.controllerRef) spreadsheet.controllerRef.current = spreadsheetEnabled ? sheet.controller : null;
50211
- const sheetRef = (0, import_react21.useRef)(sheet);
50303
+ const sheetRef = (0, import_react22.useRef)(sheet);
50212
50304
  sheetRef.current = sheet;
50213
- const onSheetSelectionRef = (0, import_react21.useRef)(spreadsheet?.onSelectionChange);
50305
+ const onSheetSelectionRef = (0, import_react22.useRef)(spreadsheet?.onSelectionChange);
50214
50306
  onSheetSelectionRef.current = spreadsheet?.onSelectionChange;
50215
50307
  const sheetSelectionKey = sheet.range ? `${sheet.range.anchor.rowId}\0${sheet.range.anchor.fieldName}\0${sheet.range.focus.rowId}\0${sheet.range.focus.fieldName}\0${sheet.bounds ? `${sheet.bounds.r0}:${sheet.bounds.r1}:${sheet.bounds.c0}:${sheet.bounds.c1}` : ""}` : "";
50216
- (0, import_react21.useEffect)(() => {
50308
+ (0, import_react22.useEffect)(() => {
50217
50309
  const tell = onSheetSelectionRef.current;
50218
50310
  if (!tell) return;
50219
50311
  const current = sheetRef.current;
@@ -50230,11 +50322,12 @@ function MatrxDataTableCore(coreProps) {
50230
50322
  tsv: current.selectionTsv()
50231
50323
  });
50232
50324
  }, [sheetSelectionKey]);
50233
- const searchValueRef = (0, import_react21.useRef)(searchValue);
50325
+ const searchValueRef = (0, import_react22.useRef)(searchValue);
50234
50326
  searchValueRef.current = searchValue;
50235
50327
  const facetsEnabled = Boolean(facets && facets.enabled !== false);
50236
- const [facetState, setFacetState] = (0, import_react21.useState)({});
50237
- const facetReadCell = (0, import_react21.useCallback)(
50328
+ const coreSuggestionsEnabled = facets?.enabled !== false;
50329
+ const [facetState, setFacetState] = (0, import_react22.useState)({});
50330
+ const facetReadCell = (0, import_react22.useCallback)(
50238
50331
  (row, colId) => {
50239
50332
  if (facets?.readCell) return facets.readCell(row, colId);
50240
50333
  const col = visibleColumns.find((candidate) => columnId(candidate) === colId);
@@ -50242,12 +50335,37 @@ function MatrxDataTableCore(coreProps) {
50242
50335
  },
50243
50336
  [facets, visibleColumns]
50244
50337
  );
50245
- const facetInputsRef = (0, import_react21.useRef)({ data, facets, facetReadCell });
50246
- facetInputsRef.current = { data, facets, facetReadCell };
50247
- const facetRequestRef = (0, import_react21.useRef)(/* @__PURE__ */ new Map());
50248
- const requestFacets = (0, import_react21.useCallback)((colId) => {
50249
- const { data: rows, facets: config, facetReadCell: readCell } = facetInputsRef.current;
50250
- if (!config || config.enabled === false) return;
50338
+ const coreFacetTotal = remoteQuery?.mode === "controlled" ? remoteQuery.totalItems : appendQuery?.pagination.sourceRecords?.total ?? coverage?.matched ?? coverage?.total;
50339
+ const coreFacetLoaded = appendQuery?.pagination.sourceRecords?.loaded;
50340
+ const facetInputsRef = (0, import_react22.useRef)({ data, facets, facetReadCell, coreFacetTotal, coreFacetLoaded });
50341
+ facetInputsRef.current = { data, facets, facetReadCell, coreFacetTotal, coreFacetLoaded };
50342
+ const facetRequestRef = (0, import_react22.useRef)(/* @__PURE__ */ new Map());
50343
+ const requestFacets = (0, import_react22.useCallback)((colId) => {
50344
+ const { data: rows, facets: config, facetReadCell: readCell, coreFacetTotal: total, coreFacetLoaded: loaded } = facetInputsRef.current;
50345
+ if (!config || config.enabled === false) {
50346
+ const complete2 = localFacetsAreComplete(loaded ?? rows.length, total ?? rows.length);
50347
+ const hasArrayValue = rows.some((row) => {
50348
+ try {
50349
+ return Array.isArray(readCell(row, colId));
50350
+ } catch {
50351
+ return false;
50352
+ }
50353
+ });
50354
+ const suggestions = computeColumnFacets({
50355
+ columnId: colId,
50356
+ rows,
50357
+ readValue: readCell,
50358
+ complete: complete2
50359
+ });
50360
+ setFacetState((current) => ({
50361
+ ...current,
50362
+ [colId]: {
50363
+ loading: false,
50364
+ data: !hasArrayValue && suggestions.distinctCount + (suggestions.blank > 0 ? 1 : 0) < CORE_SUGGESTION_DISTINCT_EXCLUSIVE_LIMIT ? suggestions : null
50365
+ }
50366
+ }));
50367
+ return;
50368
+ }
50251
50369
  const complete = localFacetsAreComplete(rows.length, config.totalRows);
50252
50370
  const limit = config.limit;
50253
50371
  if (complete || !config.source) {
@@ -50304,21 +50422,20 @@ function MatrxDataTableCore(coreProps) {
50304
50422
  }));
50305
50423
  });
50306
50424
  }, []);
50307
- (0, import_react21.useEffect)(() => {
50308
- if (!facetsEnabled) return;
50425
+ (0, import_react22.useEffect)(() => {
50309
50426
  setFacetState({});
50310
50427
  facetRequestRef.current = /* @__PURE__ */ new Map();
50311
- }, [facetsEnabled, data, searchValue]);
50428
+ }, [facetsEnabled, data, searchValue, coreFacetTotal, coreFacetLoaded]);
50312
50429
  const totalIsKnown = !isLoading && !readView.failure;
50313
- (0, import_react21.useEffect)(() => {
50430
+ (0, import_react22.useEffect)(() => {
50314
50431
  if (!controlledQuery || !totalIsKnown || controlledQuery.state.page === safePage) return;
50315
50432
  emitControlledQueryChange({ page: safePage });
50316
50433
  }, [controlledQuery, emitControlledQueryChange, safePage, totalIsKnown]);
50317
- const selectedRow = (0, import_react21.useMemo)(() => {
50434
+ const selectedRow = (0, import_react22.useMemo)(() => {
50318
50435
  if (!selectedId) return null;
50319
50436
  return data.find((r) => getRowId(r) === selectedId) ?? null;
50320
50437
  }, [data, selectedId, getRowId]);
50321
- const windowRow = (0, import_react21.useMemo)(() => {
50438
+ const windowRow = (0, import_react22.useMemo)(() => {
50322
50439
  if (!windowRowId) return null;
50323
50440
  return data.find((r) => getRowId(r) === windowRowId) ?? (windowRowSnapshot && windowRowSnapshot.queryKey === appendQueryKey && getRowId(windowRowSnapshot.row) === windowRowId ? windowRowSnapshot.row : null);
50324
50441
  }, [data, windowRowId, windowRowSnapshot, getRowId, appendQueryKey]);
@@ -50337,39 +50454,60 @@ function MatrxDataTableCore(coreProps) {
50337
50454
  const target = toolbar.portalInto;
50338
50455
  return target ? (0, import_react_dom3.createPortal)(node, target) : null;
50339
50456
  };
50457
+ const [pinnedEl, setPinnedEl] = (0, import_react22.useState)(null);
50458
+ const pinnedRowActive = Boolean(
50459
+ toolbar?.singleRow && toolbar.overflow && toolbar.overflow.mode !== "sheet" && (toolbar.overflow.pinned || toolbar.overflow.mode === "menu")
50460
+ );
50461
+ const pinnedFolded = usePinnedFold(pinnedEl, pinnedRowActive);
50462
+ const toolbarEnd = { node: null };
50340
50463
  const renderToolbarControls = (controls) => {
50464
+ toolbarEnd.node = null;
50341
50465
  const overflow = toolbar?.overflow;
50342
50466
  const mode = overflow?.mode ?? "inline";
50343
- const stick = (node) => toolbar?.singleRow ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
50344
- "span",
50345
- {
50346
- "data-matrx-table-toolbar-pinned": "",
50347
- className: "sticky right-0 z-[1] flex shrink-0 items-center gap-1 bg-background pl-1 before:pointer-events-none before:absolute before:inset-y-0 before:-left-6 before:w-6 before:bg-gradient-to-l before:from-background before:to-transparent",
50348
- children: node
50349
- }
50350
- ) : node;
50351
- if (mode === "menu") {
50352
- return stick(
50353
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
50467
+ if (mode === "sheet") {
50468
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(ToolbarOverflowSheet, { ...overflow?.label ? { label: overflow.label } : {}, top: overflow?.sheetTop, children: [
50469
+ controls,
50470
+ overflow?.pinned,
50471
+ overflow?.sheetExtras
50472
+ ] });
50473
+ }
50474
+ if (!pinnedRowActive) {
50475
+ if (mode === "menu") {
50476
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
50354
50477
  overflow?.pinned,
50355
50478
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(ToolbarOverflowMenu, { children: [
50356
50479
  controls,
50357
50480
  overflow?.sheetExtras
50358
50481
  ] })
50359
- ] })
50360
- );
50361
- }
50362
- if (mode === "sheet") {
50363
- return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(ToolbarOverflowSheet, { ...overflow?.label ? { label: overflow.label } : {}, top: overflow?.sheetTop, children: [
50482
+ ] });
50483
+ }
50484
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
50364
50485
  controls,
50365
- overflow?.pinned,
50366
- overflow?.sheetExtras
50486
+ overflow?.pinned
50367
50487
  ] });
50368
50488
  }
50369
- return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
50370
- controls,
50371
- overflow?.pinned ? stick(overflow.pinned) : null
50372
- ] });
50489
+ const folded = pinnedFolded;
50490
+ toolbarEnd.node = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
50491
+ "span",
50492
+ {
50493
+ ref: setPinnedEl,
50494
+ "data-matrx-table-toolbar-pinned": "",
50495
+ ...folded ? { "data-matrx-table-toolbar-pinned-folded": "" } : {},
50496
+ className: "sticky right-0 z-[1] -ml-1 flex shrink-0 items-center gap-1 bg-background pl-1 before:pointer-events-none before:absolute before:inset-y-0 before:-left-6 before:w-6 before:bg-gradient-to-l before:from-background before:to-transparent",
50497
+ children: folded ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(ToolbarOverflowMenu, { children: [
50498
+ controls,
50499
+ overflow?.pinned,
50500
+ overflow?.sheetExtras
50501
+ ] }) : mode === "menu" ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
50502
+ overflow?.pinned,
50503
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(ToolbarOverflowMenu, { children: [
50504
+ controls,
50505
+ overflow?.sheetExtras
50506
+ ] })
50507
+ ] }) : overflow?.pinned
50508
+ }
50509
+ );
50510
+ return folded || mode === "menu" ? null : controls;
50373
50511
  };
50374
50512
  const renderRowActions = (row, controls) => {
50375
50513
  const actions = rowActions?.(row, controls);
@@ -50434,7 +50572,7 @@ function MatrxDataTableCore(coreProps) {
50434
50572
  ...resolveSummaryValue(summary?.source?.totals?.[id], value)
50435
50573
  }));
50436
50574
  const hasSummaryTotals = summaryTotals.length > 0;
50437
- const changeCount = (0, import_react21.useMemo)(() => {
50575
+ const changeCount = (0, import_react22.useMemo)(() => {
50438
50576
  let n2 = 0;
50439
50577
  for (const fields of Object.values(edits)) {
50440
50578
  n2 += Object.keys(fields).length;
@@ -50525,7 +50663,7 @@ function MatrxDataTableCore(coreProps) {
50525
50663
  }
50526
50664
  resetToolbarFacets(toolbar?.facets);
50527
50665
  };
50528
- const renderedEmptyState = (remoteQuery === null || remoteQueryUsesLocalColumnFilters) && data.length > 0 && hasActiveFilters ? {
50666
+ const renderedEmptyState = (remoteQuery === null || remoteQueryUsesLocalProcessing) && data.length > 0 && hasActiveFilters ? {
50529
50667
  title: "No matching rows",
50530
50668
  description: "No rows match the current search or filters.",
50531
50669
  action: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Button, { type: "button", variant: "outline", size: "sm", onClick: clearAllFilters, children: "Clear filters" }),
@@ -50618,7 +50756,7 @@ function MatrxDataTableCore(coreProps) {
50618
50756
  }));
50619
50757
  return true;
50620
50758
  };
50621
- const requestCellEditRef = (0, import_react21.useRef)(requestCellEdit);
50759
+ const requestCellEditRef = (0, import_react22.useRef)(requestCellEdit);
50622
50760
  requestCellEditRef.current = requestCellEdit;
50623
50761
  const buildRecordControls = (row) => {
50624
50762
  const rowId = getRowId(row);
@@ -50645,7 +50783,7 @@ function MatrxDataTableCore(coreProps) {
50645
50783
  };
50646
50784
  const hierarchyRows = hierarchy?.rows ?? data;
50647
50785
  const hierarchyGetParentId = hierarchy?.getParentId;
50648
- const hierarchyIndex = (0, import_react21.useMemo)(() => {
50786
+ const hierarchyIndex = (0, import_react22.useMemo)(() => {
50649
50787
  if (!hierarchyGetParentId) return null;
50650
50788
  const byId = /* @__PURE__ */ new Map();
50651
50789
  const parentById = /* @__PURE__ */ new Map();
@@ -50677,7 +50815,7 @@ function MatrxDataTableCore(coreProps) {
50677
50815
  return { byId, parentById, depthById };
50678
50816
  }, [hierarchyGetParentId, hierarchyRows, getRowId]);
50679
50817
  const draggedRow = draggedRowId && hierarchyIndex ? hierarchyIndex.byId.get(draggedRowId) : void 0;
50680
- const hierarchyBlockedIds = (0, import_react21.useMemo)(() => {
50818
+ const hierarchyBlockedIds = (0, import_react22.useMemo)(() => {
50681
50819
  if (!draggedRowId || !hierarchyIndex) return null;
50682
50820
  const childrenById = /* @__PURE__ */ new Map();
50683
50821
  for (const [id, parentId] of hierarchyIndex.parentById) {
@@ -50964,16 +51102,16 @@ function MatrxDataTableCore(coreProps) {
50964
51102
  return [];
50965
51103
  }
50966
51104
  };
50967
- const menuSectionsForRef = (0, import_react21.useRef)(menuSectionsFor);
51105
+ const menuSectionsForRef = (0, import_react22.useRef)(menuSectionsFor);
50968
51106
  menuSectionsForRef.current = menuSectionsFor;
50969
51107
  const hasMenuSections = Boolean(contextMenu?.sections);
50970
- const boundarySections = (0, import_react21.useCallback)(
51108
+ const boundarySections = (0, import_react22.useCallback)(
50971
51109
  (target) => menuSectionsForRef.current(target),
50972
51110
  []
50973
51111
  );
50974
- const resolveMenuLevelRef = (0, import_react21.useRef)(resolveMenuLevel);
51112
+ const resolveMenuLevelRef = (0, import_react22.useRef)(resolveMenuLevel);
50975
51113
  resolveMenuLevelRef.current = resolveMenuLevel;
50976
- (0, import_react21.useEffect)(() => {
51114
+ (0, import_react22.useEffect)(() => {
50977
51115
  if (!host.rowContextRegistry) return;
50978
51116
  return host.rowContextRegistry.register(
50979
51117
  tableContextMenuInstanceId,
@@ -50982,7 +51120,7 @@ function MatrxDataTableCore(coreProps) {
50982
51120
  }, [host.rowContextRegistry, tableContextMenuInstanceId]);
50983
51121
  const showActionsCol = windowEnabled || Boolean(rowActions) || showInlineRowCopy;
50984
51122
  const getSelectionId = selection?.getSelectionId ?? getRowId;
50985
- const selectedIdSet = (0, import_react21.useMemo)(
51123
+ const selectedIdSet = (0, import_react22.useMemo)(
50986
51124
  () => new Set(selection?.selectedIds ?? []),
50987
51125
  [selection?.selectedIds]
50988
51126
  );
@@ -50994,7 +51132,7 @@ function MatrxDataTableCore(coreProps) {
50994
51132
  );
50995
51133
  const allOnPageSelected = selectableRows.length > 0 && selectedOnPage.length === selectableRows.length;
50996
51134
  const someOnPageSelected = selectedOnPage.length > 0 && !allOnPageSelected;
50997
- const selectedRows = (0, import_react21.useMemo)(() => {
51135
+ const selectedRows = (0, import_react22.useMemo)(() => {
50998
51136
  const resolved = /* @__PURE__ */ new Set();
50999
51137
  return data.filter((row) => {
51000
51138
  const id = getSelectionId(row);
@@ -51003,7 +51141,7 @@ function MatrxDataTableCore(coreProps) {
51003
51141
  return true;
51004
51142
  });
51005
51143
  }, [data, getSelectionId, selectedIdSet]);
51006
- const lastToggledIndex = (0, import_react21.useRef)(null);
51144
+ const lastToggledIndex = (0, import_react22.useRef)(null);
51007
51145
  const setSelectedIds = (next) => selection?.onSelectedIdsChange([...next]);
51008
51146
  const toggleRowSelected = (index, shiftKey) => {
51009
51147
  if (!selection) return;
@@ -51044,7 +51182,7 @@ function MatrxDataTableCore(coreProps) {
51044
51182
  }
51045
51183
  } : facet
51046
51184
  ) : toolbar?.facets;
51047
- const rowLatest = (0, import_react21.useRef)(null);
51185
+ const rowLatest = (0, import_react22.useRef)(null);
51048
51186
  const renderRecordCell = (row, col, index) => {
51049
51187
  const id = getRowId(row);
51050
51188
  const field = col.accessorKey ? String(col.accessorKey) : columnId(col);
@@ -51080,7 +51218,7 @@ function MatrxDataTableCore(coreProps) {
51080
51218
  }
51081
51219
  return href ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Link, { href, onClick: (event) => event.stopPropagation(), className: "block w-full min-w-0 rounded outline-none focus-visible:ring-2 focus-visible:ring-ring", children: display }) : display;
51082
51220
  };
51083
- const currentViewSnapshot = (0, import_react21.useMemo)(
51221
+ const currentViewSnapshot = (0, import_react22.useMemo)(
51084
51222
  () => ({
51085
51223
  __kind: "matrx-table-view",
51086
51224
  version: 1,
@@ -51115,7 +51253,7 @@ function MatrxDataTableCore(coreProps) {
51115
51253
  sort
51116
51254
  ]
51117
51255
  );
51118
- const declaredDefaultViewSnapshot = (0, import_react21.useMemo)(
51256
+ const declaredDefaultViewSnapshot = (0, import_react22.useMemo)(
51119
51257
  () => defaultViewSnapshot ?? {
51120
51258
  __kind: "matrx-table-view",
51121
51259
  version: 1,
@@ -51123,7 +51261,6 @@ function MatrxDataTableCore(coreProps) {
51123
51261
  pageSize: defaultPageSize,
51124
51262
  search: "",
51125
51263
  anyOf: "",
51126
- layeredFilters: [],
51127
51264
  columnFilters: {},
51128
51265
  sort: defaultSort
51129
51266
  },
@@ -51134,7 +51271,7 @@ function MatrxDataTableCore(coreProps) {
51134
51271
  },
51135
51272
  [columns, defaultPageSize, defaultSort, defaultViewSnapshot]
51136
51273
  );
51137
- const applySavedView = (0, import_react21.useCallback)(
51274
+ const applySavedView = (0, import_react22.useCallback)(
51138
51275
  (rawSnapshot) => {
51139
51276
  const snapshot = parseTableViewSnapshot(rawSnapshot);
51140
51277
  if (!snapshot) {
@@ -51359,6 +51496,7 @@ function MatrxDataTableCore(coreProps) {
51359
51496
  allRowsAreLoaded,
51360
51497
  effectivePageSize,
51361
51498
  safePage,
51499
+ isFetching,
51362
51500
  controlledQuery,
51363
51501
  emitControlledQueryChange,
51364
51502
  ...pageSizeOptions
@@ -51366,6 +51504,8 @@ function MatrxDataTableCore(coreProps) {
51366
51504
  const toolbarReadsRows = showToolbarCopy && copyDrawsFromRows(effectiveCopy);
51367
51505
  const toolbarEpoch = useRenderEpoch([
51368
51506
  hideToolbar,
51507
+ pinnedFolded,
51508
+ pinnedRowActive,
51369
51509
  viewTabs,
51370
51510
  toolbar,
51371
51511
  showSearch,
@@ -51758,7 +51898,7 @@ function MatrxDataTableCore(coreProps) {
51758
51898
  },
51759
51899
  `${id}:expanded-detail`
51760
51900
  ) : null;
51761
- return hierarchy ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_react21.Fragment, { children: [
51901
+ return hierarchy ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_react22.Fragment, { children: [
51762
51902
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
51763
51903
  HierarchyDroppableRow,
51764
51904
  {
@@ -51768,7 +51908,7 @@ function MatrxDataTableCore(coreProps) {
51768
51908
  }
51769
51909
  ),
51770
51910
  inlineDetail
51771
- ] }, id) : /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_react21.Fragment, { children: [
51911
+ ] }, id) : /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_react22.Fragment, { children: [
51772
51912
  wrappedRow,
51773
51913
  inlineDetail
51774
51914
  ] }, id);
@@ -51877,43 +52017,40 @@ function MatrxDataTableCore(coreProps) {
51877
52017
  "data-matrx-table-density": resolvedDensity,
51878
52018
  "data-url-state-table": urlState?.id,
51879
52019
  className: cn(
51880
- "flex h-full min-h-0 flex-col gap-2 px-0 py-2",
52020
+ "flex h-full min-h-0 flex-col gap-2 px-0 pt-2 pb-0",
51881
52021
  className
51882
52022
  ),
51883
52023
  children: [
51884
52024
  notice,
51885
52025
  savedViewError ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ErrorBox, { className: "shrink-0 text-xs text-destructive", message: savedViewError, operation: "Save or apply a saved view", origin: "design-system/MatrxDataTable" }) : null,
51886
52026
  toolbarActionError ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ErrorBox, { className: "shrink-0 text-xs text-destructive", message: toolbarActionError, operation: "Run a table toolbar action", origin: "design-system/MatrxDataTable" }) : null,
51887
- summaryMetrics.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
52027
+ summaryMetrics.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
51888
52028
  "section",
51889
52029
  {
51890
52030
  "data-matrx-table-summary": true,
51891
52031
  "data-matrx-table-summary-scope": summaryUsesSource ? "source" : summaryCoverage,
51892
52032
  "aria-label": `Table summary: ${summaryCaption}`,
51893
- className: "flex shrink-0 flex-wrap items-stretch gap-2",
51894
- children: [
51895
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "flex items-center px-1 text-xs font-medium text-muted-foreground", children: summaryCaption }),
51896
- summaryMetrics.map((metric) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "min-w-24 rounded-md border border-border bg-card px-3 py-2 shadow-xs", children: [
51897
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "text-xs text-muted-foreground", children: metric.label }),
51898
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "mt-0.5 text-sm font-semibold tabular-nums text-foreground", children: [
51899
- metric.value,
51900
- metric.unavailable ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ErrorBox, { as: "span", className: "sr-only", message: `${metric.label} is unavailable`, operation: "Summarize this table", origin: "design-system/MatrxDataTable" }) : null
51901
- ] })
51902
- ] }, metric.id))
51903
- ]
52033
+ className: "flex w-full min-w-0 shrink-0 flex-nowrap items-stretch gap-2 overflow-x-auto overscroll-x-contain",
52034
+ children: summaryMetrics.map((metric) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "min-w-24 shrink-0 whitespace-nowrap rounded-md border border-border bg-card px-3 py-2 shadow-xs", children: [
52035
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "text-xs text-muted-foreground", children: metric.label }),
52036
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "mt-0.5 text-sm font-semibold tabular-nums text-foreground", children: [
52037
+ metric.value,
52038
+ metric.unavailable ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ErrorBox, { as: "span", className: "sr-only", message: `${metric.label} is unavailable`, operation: "Summarize this table", origin: "design-system/MatrxDataTable" }) : null
52039
+ ] })
52040
+ ] }, metric.id))
51904
52041
  }
51905
52042
  ) : null,
51906
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(MatrxTableChrome, { part: "toolbar", epoch: toolbarEpoch, render: () => placeToolbar(!hideToolbar && (viewTabs || toolbar?.title || toolbar?.titleCount || showSearch || toolbar?.customSearch || toolbar?.anyOf || toolbar?.layeredFilters || toolbar?.facets && toolbar.facets.length > 0 || toolbar?.leading || toolbar?.actions || toolbar?.refresh || toolbar?.add || tableId && SavedViews || hasActiveFilters || showToolbarCopy || columns.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
52043
+ /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(MatrxTableChrome, { part: "toolbar", epoch: toolbarEpoch, render: () => placeToolbar(!hideToolbar && (showViewTabs || toolbar?.title || toolbar?.titleCount || showSearch || toolbar?.customSearch || toolbar?.anyOf || toolbar?.layeredFilters || toolbar?.facets && toolbar.facets.length > 0 || toolbar?.leading || toolbar?.actions || toolbar?.refresh || toolbar?.add || savedViewsId && SavedViews || hasActiveFilters || showToolbarCopy || columns.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
51907
52044
  TableTitleRow,
51908
52045
  {
51909
52046
  ...toolbar?.singleRow ? { singleRow: true } : {},
51910
- tabs: viewTabs ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableViewWorkspace, { snapshot: currentViewSnapshot, onApply: applyLatestSavedView, related: relatedTableActions, ...viewTabsStore ? { store: viewTabsStore } : {} }, tableId ?? "table") : void 0,
52047
+ tabs: viewTabs && viewTabsStore ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableViewWorkspace, { snapshot: currentViewSnapshot, onApply: applyLatestSavedView, related: relatedTableActions, ...viewTabsStore ? { store: viewTabsStore } : {} }, savedViewsId ?? "table") : viewTabs && savedViewsId && SavedViews ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(SavedViews, { tableId: savedViewsId, snapshot: currentViewSnapshot, defaultSnapshot: declaredDefaultViewSnapshot, onApply: applyLatestSavedView, presentation: "tabs", related: relatedTableActions }) : void 0,
51911
52048
  ...toolbar?.title === void 0 ? {} : { title: toolbar.title },
51912
52049
  ...toolbar?.titleCount === void 0 ? {} : { count: toolbar.titleCount },
51913
- context: tableId && SavedViews ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "data-matrx-table-view-control": true, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
52050
+ context: savedViewsId && SavedViews && !viewTabs ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "data-matrx-table-view-control": true, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
51914
52051
  SavedViews,
51915
52052
  {
51916
- tableId,
52053
+ tableId: savedViewsId,
51917
52054
  snapshot: currentViewSnapshot,
51918
52055
  defaultSnapshot: declaredDefaultViewSnapshot,
51919
52056
  onApply: applyLatestSavedView
@@ -52215,7 +52352,8 @@ function MatrxDataTableCore(coreProps) {
52215
52352
  ] }))
52216
52353
  ]
52217
52354
  }
52218
- )
52355
+ ),
52356
+ toolbarEnd.node
52219
52357
  ]
52220
52358
  }
52221
52359
  )) }),
@@ -52529,7 +52667,7 @@ function MatrxDataTableCore(coreProps) {
52529
52667
  {
52530
52668
  label: col.header,
52531
52669
  labelText: headerLabel,
52532
- ...facetsEnabled ? {
52670
+ ...facetsEnabled || meta?.kind !== void 0 && meta.kind !== null && coreSuggestionsEnabled ? {
52533
52671
  facets: facetState[id]?.data ?? null,
52534
52672
  facetsLoading: facetState[id]?.loading ?? false,
52535
52673
  ...facetState[id]?.error === void 0 ? {} : { facetsError: facetState[id]?.error },
@@ -52654,12 +52792,12 @@ function MatrxDataTableCore(coreProps) {
52654
52792
  },
52655
52793
  "matrx-column-spacer-end"
52656
52794
  ) : null
52657
- ] }, `sk-${i}`)) : readFailure ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", { colSpan: renderedColSpan, "data-matrx-table-message-cell": true, className: "px-0 py-12 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "sticky left-0 flex flex-col items-center gap-2 whitespace-normal px-4", style: { width: "100cqw", maxWidth: "100%" }, children: readFailure }) }) }) : paginated.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
52795
+ ] }, `sk-${i}`)) : readFailure ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", { colSpan: renderedColSpan, "data-matrx-table-message-cell": true, className: "overflow-visible! px-0 py-12 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "sticky left-0 flex flex-col items-center gap-2 whitespace-normal px-4", style: { width: "100cqw", maxWidth: "100%" }, children: readFailure }) }) }) : paginated.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
52658
52796
  "td",
52659
52797
  {
52660
52798
  colSpan: renderedColSpan,
52661
52799
  "data-matrx-table-message-cell": true,
52662
- className: "px-0 py-12 text-center",
52800
+ className: "overflow-visible! px-0 py-12 text-center",
52663
52801
  children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { "data-matrx-table-empty-state": true, className: "sticky left-0 flex flex-col items-center gap-2 whitespace-normal px-4", style: { width: "100cqw", maxWidth: "100%" }, children: [
52664
52802
  renderedEmptyState?.icon,
52665
52803
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "text-sm font-medium text-foreground", children: renderedEmptyState?.title ?? "No rows" }),
@@ -52749,62 +52887,61 @@ function MatrxDataTableCore(coreProps) {
52749
52887
  "border-t-2 border-border bg-muted/50 font-semibold",
52750
52888
  hasSummaryTotals && "sticky bottom-0 z-10 bg-muted/95 backdrop-blur-sm"
52751
52889
  ), children: [
52752
- hasSummaryTotals ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, { children: [
52753
- /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("tr", { "data-matrx-table-summary-total-caption": true, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("td", { colSpan: renderedColSpan, className: "px-2 pt-2 text-xs font-medium text-muted-foreground", children: [
52754
- summaryCaption,
52755
- readView.stale ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "ml-1 text-amber-700 dark:text-amber-300", children: "Retained rows may be out of date." }) : null
52756
- ] }) }),
52757
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("tr", { "data-matrx-table-summary-totals": true, children: [
52758
- selection ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", { className: "px-2 py-2" }) : null,
52759
- columnSpacers && columnSpacers.start > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
52760
- "td",
52761
- {
52762
- "aria-hidden": "true",
52763
- "data-matrx-table-column-spacer": "start",
52764
- className: "border-0 p-0",
52765
- style: { width: `${columnSpacers.start}px`, minWidth: `${columnSpacers.start}px` }
52766
- },
52767
- "matrx-summary-column-spacer-start"
52768
- ) : null,
52769
- renderedColumns.map((column) => {
52770
- const total = summaryTotals.find((candidate) => candidate.id === columnId(column));
52771
- return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
52772
- "td",
52773
- {
52774
- className: cn(
52775
- "px-2 py-2 align-middle",
52776
- (column.compact || resolveColumnMarker(column) !== void 0) && "px-1",
52777
- column.className,
52778
- column.align === "center" && "text-center",
52779
- column.align === "right" && "text-right"
52780
- ),
52781
- style: columnWidthVar(
52782
- resolveColumnMarker(column) && column.width === void 0 ? 40 : column.width,
52783
- windowedWidthFor(columnId(column), column.width),
52784
- columnId(column),
52785
- resizableColumns && column.resizable !== false
52786
- ),
52787
- children: [
52788
- total?.value,
52789
- total?.unavailable ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ErrorBox, { as: "span", className: "sr-only", message: `${columnId(column)} total is unavailable`, operation: "Total this column", origin: "design-system/MatrxDataTable" }) : null
52790
- ]
52791
- },
52792
- columnId(column)
52793
- );
52794
- }),
52795
- columnSpacers && columnSpacers.end > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
52890
+ hasSummaryTotals ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx_runtime51.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("tr", { "data-matrx-table-summary-totals": true, children: [
52891
+ selection ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", { className: "px-2 py-2" }) : null,
52892
+ columnSpacers && columnSpacers.start > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
52893
+ "td",
52894
+ {
52895
+ "aria-hidden": "true",
52896
+ "data-matrx-table-column-spacer": "start",
52897
+ className: "border-0 p-0",
52898
+ style: { width: `${columnSpacers.start}px`, minWidth: `${columnSpacers.start}px` }
52899
+ },
52900
+ "matrx-summary-column-spacer-start"
52901
+ ) : null,
52902
+ renderedColumns.map((column, columnIndex) => {
52903
+ const total = summaryTotals.find((candidate) => candidate.id === columnId(column));
52904
+ return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
52796
52905
  "td",
52797
52906
  {
52798
- "aria-hidden": "true",
52799
- "data-matrx-table-column-spacer": "end",
52800
- className: "border-0 p-0",
52801
- style: { width: `${columnSpacers.end}px`, minWidth: `${columnSpacers.end}px` }
52907
+ className: cn(
52908
+ "px-2 py-2 align-middle font-semibold",
52909
+ (column.compact || resolveColumnMarker(column) !== void 0) && "px-1",
52910
+ column.className,
52911
+ column.align === "center" && "text-center",
52912
+ column.align === "right" && "text-right"
52913
+ ),
52914
+ style: columnWidthVar(
52915
+ resolveColumnMarker(column) && column.width === void 0 ? 40 : column.width,
52916
+ windowedWidthFor(columnId(column), column.width),
52917
+ columnId(column),
52918
+ resizableColumns && column.resizable !== false
52919
+ ),
52920
+ children: [
52921
+ columnIndex === 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("span", { "data-matrx-table-summary-total-label": true, className: "text-sm font-semibold text-foreground", children: [
52922
+ summaryCaption,
52923
+ readView.stale ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "ml-1 text-xs text-amber-700 dark:text-amber-300", children: "Retained rows may be out of date." }) : null
52924
+ ] }) : null,
52925
+ columnIndex === 0 && total?.value != null ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "ml-2", children: total.value }) : null,
52926
+ columnIndex !== 0 ? total?.value : null,
52927
+ total?.unavailable ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ErrorBox, { as: "span", className: "sr-only", message: `${columnId(column)} total is unavailable`, operation: "Total this column", origin: "design-system/MatrxDataTable" }) : null
52928
+ ]
52802
52929
  },
52803
- "matrx-summary-column-spacer-end"
52804
- ) : null,
52805
- showActionsCol ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", {}) : null
52806
- ] })
52807
- ] }) : null,
52930
+ columnId(column)
52931
+ );
52932
+ }),
52933
+ columnSpacers && columnSpacers.end > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
52934
+ "td",
52935
+ {
52936
+ "aria-hidden": "true",
52937
+ "data-matrx-table-column-spacer": "end",
52938
+ className: "border-0 p-0",
52939
+ style: { width: `${columnSpacers.end}px`, minWidth: `${columnSpacers.end}px` }
52940
+ },
52941
+ "matrx-summary-column-spacer-end"
52942
+ ) : null,
52943
+ showActionsCol ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", {}) : null
52944
+ ] }) }) : null,
52808
52945
  footerRows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("tr", { children: [
52809
52946
  selection ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("td", { className: "px-2 py-2" }) : null,
52810
52947
  columnSpacers && columnSpacers.start > 0 ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
@@ -53034,6 +53171,7 @@ function MatrxDataTableCore(coreProps) {
53034
53171
  showAllOption: allRowsAreLoaded,
53035
53172
  allValue: 0,
53036
53173
  allOptionLabel: "All loaded",
53174
+ isFetching,
53037
53175
  compact: true,
53038
53176
  hideEntriesInfo: false
53039
53177
  }
@@ -53388,7 +53526,7 @@ function HierarchyDragIndicatorLayer({
53388
53526
  scrollRef,
53389
53527
  resolve: resolve2
53390
53528
  }) {
53391
- const [indicator, setIndicator] = (0, import_react21.useState)(
53529
+ const [indicator, setIndicator] = (0, import_react22.useState)(
53392
53530
  null
53393
53531
  );
53394
53532
  (0, import_core3.useDndMonitor)({
@@ -53492,9 +53630,9 @@ function HierarchyDroppableRow({
53492
53630
  children
53493
53631
  }) {
53494
53632
  const { setNodeRef } = (0, import_core3.useDroppable)({ id, disabled });
53495
- if (!(0, import_react21.isValidElement)(children) || children.type !== "tr") return children;
53633
+ if (!(0, import_react22.isValidElement)(children) || children.type !== "tr") return children;
53496
53634
  const row = children;
53497
- return (0, import_react21.cloneElement)(row, {
53635
+ return (0, import_react22.cloneElement)(row, {
53498
53636
  ref: setNodeRef,
53499
53637
  className: row.props.className
53500
53638
  });
@@ -53604,7 +53742,7 @@ function columnWidthVar(width, resizedWidth, id, resizable) {
53604
53742
  };
53605
53743
  }
53606
53744
  function DefaultJsonCell({ value }) {
53607
- const [open, setOpen] = (0, import_react21.useState)(false);
53745
+ const [open, setOpen] = (0, import_react22.useState)(false);
53608
53746
  const host = useMatrxDataTableHost();
53609
53747
  const Viewer = host.JsonViewer;
53610
53748
  const text = JSON.stringify(value, null, 2);
@@ -53687,7 +53825,7 @@ function resolveStringTitle(title, fallback) {
53687
53825
  }
53688
53826
 
53689
53827
  // src/data-table/SavedViewsControl.tsx
53690
- var import_react22 = require("react");
53828
+ var import_react23 = require("react");
53691
53829
 
53692
53830
  // src/dropdown-menu.tsx
53693
53831
  var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"), 1);
@@ -53834,14 +53972,26 @@ function SavedViewsControl({
53834
53972
  onSelect,
53835
53973
  onSaveNew,
53836
53974
  onUpdate,
53837
- onReload
53975
+ onReload,
53976
+ presentation = "menu",
53977
+ onRename,
53978
+ related
53838
53979
  }) {
53839
- const unsavedChangesId = (0, import_react22.useId)();
53840
- const [saveOpen, setSaveOpen] = (0, import_react22.useState)(false);
53841
- const [name, setName] = (0, import_react22.useState)("");
53842
- const [saving, setSaving] = (0, import_react22.useState)(false);
53843
- const [actionError, setActionError] = (0, import_react22.useState)(null);
53980
+ const unsavedChangesId = (0, import_react23.useId)();
53981
+ const [saveOpen, setSaveOpen] = (0, import_react23.useState)(false);
53982
+ const [name, setName] = (0, import_react23.useState)("");
53983
+ const [saving, setSaving] = (0, import_react23.useState)(false);
53984
+ const [actionError, setActionError] = (0, import_react23.useState)(null);
53985
+ const [pendingSelect, setPendingSelect] = (0, import_react23.useState)(void 0);
53844
53986
  const visibleError = actionError ?? error;
53987
+ const select = (id) => {
53988
+ if (id === activeId) return;
53989
+ if (dirty) {
53990
+ setPendingSelect(id);
53991
+ return;
53992
+ }
53993
+ onSelect(id);
53994
+ };
53845
53995
  const save = async () => {
53846
53996
  const next = name.trim();
53847
53997
  if (!next) return;
@@ -53883,7 +54033,31 @@ function SavedViewsControl({
53883
54033
  };
53884
54034
  const activeName = activeId ? views.find((view) => view.id === activeId)?.name : void 0;
53885
54035
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex min-w-0 flex-wrap items-center gap-1", "data-matrx-table-saved-views": true, children: [
53886
- /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenu, { children: [
54036
+ presentation === "tabs" ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
54037
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
54038
+ TableViewTabs,
54039
+ {
54040
+ tabs: [{ id: "default", label: "Default view" }, ...views.map((view) => ({ id: view.id, label: view.name }))],
54041
+ activeId: activeId ?? "default",
54042
+ onSelect: (id) => select(id === "default" ? null : id),
54043
+ onAdd: () => {
54044
+ setActionError(null);
54045
+ setSaveOpen(true);
54046
+ },
54047
+ onClose: () => {
54048
+ },
54049
+ onRename: (id, label) => {
54050
+ if (onRename) void Promise.resolve(onRename(id, label)).catch((cause) => setActionError(cause instanceof Error ? cause.message : String(cause)));
54051
+ },
54052
+ closable: false,
54053
+ renameable: Boolean(onRename),
54054
+ addHint: "Save a named view to your account",
54055
+ related
54056
+ }
54057
+ ),
54058
+ dirty ? onUpdate ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Button, { type: "button", variant: "ghost", size: "sm", disabled: saving, onClick: () => void update(), className: "h-8 shrink-0 text-xs", children: "Save changes" }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Button, { type: "button", variant: "ghost", size: "sm", disabled: saving, onClick: () => setSaveOpen(true), className: "h-8 shrink-0 text-xs", children: "Save as view" }) : null,
54059
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { role: "status", className: "text-xs text-muted-foreground", children: "Loading views\u2026" }) : null
54060
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenu, { children: [
53887
54061
  /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Tooltip, { children: [
53888
54062
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
53889
54063
  Button,
@@ -53906,7 +54080,7 @@ function SavedViewsControl({
53906
54080
  ] }),
53907
54081
  /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenuContent, { align: "end", children: [
53908
54082
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuLabel, { children: "Views" }),
53909
- /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenuRadioGroup, { value: activeId ?? "__default__", onValueChange: (value) => onSelect(value === "__default__" ? null : value), children: [
54083
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DropdownMenuRadioGroup, { value: activeId ?? "__default__", onValueChange: (value) => select(value === "__default__" ? null : value), children: [
53910
54084
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuRadioItem, { value: "__default__", children: "Default view" }),
53911
54085
  views.map((view) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuRadioItem, { value: view.id, children: view.name }, view.id))
53912
54086
  ] }),
@@ -53919,7 +54093,10 @@ function SavedViewsControl({
53919
54093
  onReload ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DropdownMenuItem, { disabled: saving || loading, onSelect: () => void reload(), children: "Reload views" }) : null
53920
54094
  ] })
53921
54095
  ] }),
53922
- dirty ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { id: unsavedChangesId, className: "sr-only", children: "This table view has unsaved changes. Open the view menu to save or update it." }) : null,
54096
+ dirty ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { id: presentation === "menu" ? unsavedChangesId : void 0, role: presentation === "tabs" ? "status" : void 0, className: "sr-only", children: [
54097
+ "This table view has unsaved changes. ",
54098
+ presentation === "tabs" ? onUpdate ? "Use Save changes to update it." : "Use Save as view to keep it." : "Open the view menu to save or update it."
54099
+ ] }) : null,
53923
54100
  visibleError && !saveOpen ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ErrorBox, { className: "basis-full break-words text-xs text-destructive", message: visibleError, operation: "Load or save a saved view", origin: "design-system/SavedViewsControl" }) : null,
53924
54101
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Dialog, { open: saveOpen, onOpenChange: setSaveOpen, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DialogContent, { children: [
53925
54102
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DialogTitle, { children: "Save current view" }) }),
@@ -53929,6 +54106,20 @@ function SavedViewsControl({
53929
54106
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Button, { type: "button", variant: "outline", onClick: () => setSaveOpen(false), children: "Cancel" }),
53930
54107
  /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Button, { type: "button", disabled: !name.trim() || saving, onClick: () => void save(), children: saving ? "Saving\u2026" : "Save view" })
53931
54108
  ] })
54109
+ ] }) }),
54110
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Dialog, { open: pendingSelect !== void 0, onOpenChange: (open) => {
54111
+ if (!open) setPendingSelect(void 0);
54112
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DialogContent, { children: [
54113
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DialogTitle, { children: "Unsaved view changes" }) }),
54114
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("p", { className: "text-sm text-muted-foreground", children: "Switching views will discard the changes you have not saved." }),
54115
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(DialogFooter, { children: [
54116
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Button, { type: "button", variant: "outline", onClick: () => setPendingSelect(void 0), children: "Stay on this view" }),
54117
+ /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Button, { type: "button", onClick: () => {
54118
+ const next = pendingSelect;
54119
+ setPendingSelect(void 0);
54120
+ if (next !== void 0) onSelect(next);
54121
+ }, children: "Discard changes and switch" })
54122
+ ] })
53932
54123
  ] }) })
53933
54124
  ] });
53934
54125
  }