@ai-matrx/design-system 0.37.1 → 0.38.0
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.
- package/CHANGELOG.md +15 -0
- package/dist/content-transfer.cjs +81 -17
- package/dist/content-transfer.cjs.map +1 -1
- package/dist/content-transfer.js +81 -17
- package/dist/content-transfer.js.map +1 -1
- package/dist/data-table/data-row-inspector.cjs +81 -17
- package/dist/data-table/data-row-inspector.cjs.map +1 -1
- package/dist/data-table/data-row-inspector.js +83 -19
- package/dist/data-table/data-row-inspector.js.map +1 -1
- package/dist/data-table/data-row-window.cjs +81 -17
- package/dist/data-table/data-row-window.cjs.map +1 -1
- package/dist/data-table/data-row-window.js +83 -19
- package/dist/data-table/data-row-window.js.map +1 -1
- package/dist/data-table/index.cjs +82 -18
- package/dist/data-table/index.cjs.map +1 -1
- package/dist/data-table/index.js +178 -114
- package/dist/data-table/index.js.map +1 -1
- package/dist/index.cjs +81 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +91 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/data-table/index.js
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
useEffect as useEffect16,
|
|
10
10
|
useId as useId2,
|
|
11
11
|
useLayoutEffect as useLayoutEffect2,
|
|
12
|
-
useMemo as
|
|
13
|
-
useRef as
|
|
12
|
+
useMemo as useMemo9,
|
|
13
|
+
useRef as useRef16,
|
|
14
14
|
useState as useState22
|
|
15
15
|
} from "react";
|
|
16
16
|
import {
|
|
@@ -1490,7 +1490,8 @@ var Dialog = ({
|
|
|
1490
1490
|
children,
|
|
1491
1491
|
...props
|
|
1492
1492
|
}) => {
|
|
1493
|
-
const
|
|
1493
|
+
const isMobile = useIsMobile();
|
|
1494
|
+
const modal = props.modal ?? isMobile;
|
|
1494
1495
|
return /* @__PURE__ */ jsx15(RadixDialogModalProvider, { modal, children: /* @__PURE__ */ jsx15(DialogPrimitive.Root, { ...props, modal, children }) });
|
|
1495
1496
|
};
|
|
1496
1497
|
Dialog.displayName = "Dialog";
|
|
@@ -1536,6 +1537,11 @@ DialogContentPrimitive.displayName = "DialogContentPrimitive";
|
|
|
1536
1537
|
var DIALOG_DESKTOP_CLASSES = "matrx-dialog-card fixed inset-0 z-[10000] m-auto grid h-fit min-w-0 w-full max-w-lg gap-4 max-h-[85dvh] overflow-y-auto overscroll-contain [--dialog-pad:1.5rem] overflow-x-clip border bg-background p-6 shadow-lg [overflow-wrap:anywhere] [&>*]:min-w-0 [&>*]:max-w-full sm:rounded-lg";
|
|
1537
1538
|
var DIALOG_MOBILE_SHEET_CLASSES = "matrx-mobile-sheet matrx-dialog-card fixed inset-x-0 bottom-0 left-0 right-0 top-auto z-[10000] flex min-w-0 flex-col w-full max-w-full max-h-[90dvh] gap-4 [--dialog-pad:1rem] overflow-x-clip border-t bg-background p-4 pb-safe shadow-lg [overflow-wrap:anywhere] [&>*]:min-w-0 [&>*]:max-w-full rounded-t-2xl rounded-b-none overflow-y-auto overscroll-contain";
|
|
1538
1539
|
var DIALOG_MOBILE_SHEET_OVERRIDE = "inset-x-0 bottom-0 left-0 right-0 top-auto translate-none w-full max-w-full max-h-[90dvh] rounded-b-none rounded-t-2xl overflow-y-auto";
|
|
1540
|
+
var DialogWindowHandleContext = React10.createContext(null);
|
|
1541
|
+
var WINDOW_KEEP_VISIBLE = 80;
|
|
1542
|
+
function isInteractiveTarget(target) {
|
|
1543
|
+
return target instanceof Element && Boolean(target.closest("button, a, input, textarea, select, [role='button'], [contenteditable='true']"));
|
|
1544
|
+
}
|
|
1539
1545
|
var DialogContent = React10.forwardRef(
|
|
1540
1546
|
({
|
|
1541
1547
|
className,
|
|
@@ -1544,15 +1550,50 @@ var DialogContent = React10.forwardRef(
|
|
|
1544
1550
|
animated = true,
|
|
1545
1551
|
showCloseButton = true,
|
|
1546
1552
|
container,
|
|
1553
|
+
dismissOnOutsideClick = false,
|
|
1554
|
+
onInteractOutside,
|
|
1555
|
+
onEscapeKeyDown,
|
|
1556
|
+
style,
|
|
1547
1557
|
...props
|
|
1548
1558
|
}, ref) => {
|
|
1549
1559
|
const isMobile = useIsMobile();
|
|
1550
1560
|
const isModal = useRadixDialogModal();
|
|
1551
1561
|
const injectedContainer = usePortalContainer(container);
|
|
1552
1562
|
const asSheet = mobileSheet && isMobile;
|
|
1563
|
+
const windowed = !isModal && !asSheet;
|
|
1553
1564
|
const [containerEl, setContainerEl] = React10.useState(
|
|
1554
1565
|
null
|
|
1555
1566
|
);
|
|
1567
|
+
const [offset, setOffset] = React10.useState({ x: 0, y: 0 });
|
|
1568
|
+
const dragRef = React10.useRef(null);
|
|
1569
|
+
const handle = React10.useMemo(() => {
|
|
1570
|
+
if (!windowed) return null;
|
|
1571
|
+
const clamp = (value, limit) => Math.max(-limit, Math.min(limit, value));
|
|
1572
|
+
return {
|
|
1573
|
+
onPointerDown: (event) => {
|
|
1574
|
+
if (event.button !== 0 || isInteractiveTarget(event.target)) return;
|
|
1575
|
+
dragRef.current = { x: event.clientX, y: event.clientY, baseX: offset.x, baseY: offset.y };
|
|
1576
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
1577
|
+
},
|
|
1578
|
+
onPointerMove: (event) => {
|
|
1579
|
+
const start = dragRef.current;
|
|
1580
|
+
if (!start) return;
|
|
1581
|
+
setOffset({
|
|
1582
|
+
x: clamp(start.baseX + event.clientX - start.x, window.innerWidth / 2 - WINDOW_KEEP_VISIBLE / 2),
|
|
1583
|
+
y: clamp(start.baseY + event.clientY - start.y, window.innerHeight / 2 - WINDOW_KEEP_VISIBLE / 2)
|
|
1584
|
+
});
|
|
1585
|
+
},
|
|
1586
|
+
onPointerUp: (event) => {
|
|
1587
|
+
if (!dragRef.current) return;
|
|
1588
|
+
dragRef.current = null;
|
|
1589
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
1590
|
+
},
|
|
1591
|
+
onPointerCancel: () => {
|
|
1592
|
+
dragRef.current = null;
|
|
1593
|
+
},
|
|
1594
|
+
onDoubleClick: () => setOffset({ x: 0, y: 0 })
|
|
1595
|
+
};
|
|
1596
|
+
}, [windowed, offset.x, offset.y]);
|
|
1556
1597
|
const mergedRef = React10.useCallback(
|
|
1557
1598
|
(node) => {
|
|
1558
1599
|
setContainerEl(node);
|
|
@@ -1580,19 +1621,33 @@ var DialogContent = React10.forwardRef(
|
|
|
1580
1621
|
// can sit beside a host's floating window manager (which starts at
|
|
1581
1622
|
// z=1000); staying below that boundary makes a newly focused window
|
|
1582
1623
|
// usable without coupling the two systems.
|
|
1583
|
-
!isModal && "z-[900]"
|
|
1624
|
+
!isModal && "z-[900]",
|
|
1625
|
+
// Without an overlay the card needs its own separation from the page.
|
|
1626
|
+
windowed && "shadow-2xl ring-1 ring-border/60"
|
|
1584
1627
|
),
|
|
1628
|
+
style: windowed && (offset.x !== 0 || offset.y !== 0) ? { ...style, translate: `${offset.x}px ${offset.y}px` } : style,
|
|
1629
|
+
onInteractOutside: (event) => {
|
|
1630
|
+
onInteractOutside?.(event);
|
|
1631
|
+
if (windowed && !dismissOnOutsideClick) event.preventDefault();
|
|
1632
|
+
},
|
|
1633
|
+
onEscapeKeyDown: (event) => {
|
|
1634
|
+
onEscapeKeyDown?.(event);
|
|
1635
|
+
const pressedIn = event.target instanceof Node && event.target !== document.body ? event.target : document.activeElement;
|
|
1636
|
+
if (windowed && containerEl && !(pressedIn && containerEl.contains(pressedIn))) {
|
|
1637
|
+
event.preventDefault();
|
|
1638
|
+
}
|
|
1639
|
+
},
|
|
1585
1640
|
...hasDescription ? {} : { "aria-describedby": void 0 },
|
|
1586
1641
|
...props,
|
|
1587
1642
|
children: [
|
|
1588
1643
|
hasTitle ? null : /* @__PURE__ */ jsx15(VisuallyHidden.Root, { children: /* @__PURE__ */ jsx15(DialogPrimitive.Title, { children: "Dialog" }) }),
|
|
1589
|
-
/* @__PURE__ */ jsx15(DialogContainerContext.Provider, { value: containerEl, children: /* @__PURE__ */ jsx15(
|
|
1644
|
+
/* @__PURE__ */ jsx15(DialogContainerContext.Provider, { value: containerEl, children: /* @__PURE__ */ jsx15(DialogWindowHandleContext.Provider, { value: handle, children: /* @__PURE__ */ jsx15(
|
|
1590
1645
|
PortalContainerProvider,
|
|
1591
1646
|
{
|
|
1592
1647
|
container: containerEl ?? injectedContainer ?? null,
|
|
1593
1648
|
children
|
|
1594
1649
|
}
|
|
1595
|
-
) }),
|
|
1650
|
+
) }) }),
|
|
1596
1651
|
showCloseButton ? /* @__PURE__ */ jsxs9(
|
|
1597
1652
|
DialogPrimitive.Close,
|
|
1598
1653
|
{
|
|
@@ -1615,19 +1670,28 @@ DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
|
1615
1670
|
var DialogHeader = ({
|
|
1616
1671
|
className,
|
|
1617
1672
|
...props
|
|
1618
|
-
}) =>
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
"
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1673
|
+
}) => {
|
|
1674
|
+
const handle = React10.useContext(DialogWindowHandleContext);
|
|
1675
|
+
return /* @__PURE__ */ jsx15(
|
|
1676
|
+
"div",
|
|
1677
|
+
{
|
|
1678
|
+
"data-slot": "dialog-header",
|
|
1679
|
+
...handle ? {
|
|
1680
|
+
...handle,
|
|
1681
|
+
"data-window-handle": "",
|
|
1682
|
+
title: "Drag to move \xB7 double-click to recenter"
|
|
1683
|
+
} : {},
|
|
1684
|
+
className: cn(
|
|
1685
|
+
// DialogContent owns an absolute close control. Reserve its hit area in
|
|
1686
|
+
// every header so trailing actions never render underneath it.
|
|
1687
|
+
"flex flex-col space-y-1.5 pr-12 text-center sm:text-left",
|
|
1688
|
+
handle && "cursor-grab select-none active:cursor-grabbing",
|
|
1689
|
+
className
|
|
1690
|
+
),
|
|
1691
|
+
...props
|
|
1692
|
+
}
|
|
1693
|
+
);
|
|
1694
|
+
};
|
|
1631
1695
|
DialogHeader.displayName = "DialogHeader";
|
|
1632
1696
|
var DialogFooter = ({
|
|
1633
1697
|
className,
|
|
@@ -5614,7 +5678,7 @@ function useClippedContentGuard(ref, options) {
|
|
|
5614
5678
|
}
|
|
5615
5679
|
|
|
5616
5680
|
// src/data-table/url-state.ts
|
|
5617
|
-
import { useCallback as useCallback4, useEffect as useEffect7, useMemo as
|
|
5681
|
+
import { useCallback as useCallback4, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef9, useState as useState12 } from "react";
|
|
5618
5682
|
import {
|
|
5619
5683
|
commitUrlParams,
|
|
5620
5684
|
useUrlSearchParams
|
|
@@ -5694,7 +5758,7 @@ function useTableUrlState(options) {
|
|
|
5694
5758
|
[defaultPageSize, defaultSortDirection, defaultSortId, key]
|
|
5695
5759
|
);
|
|
5696
5760
|
const state = readState(searchParams);
|
|
5697
|
-
const lastTextWriteAt =
|
|
5761
|
+
const lastTextWriteAt = useRef9(0);
|
|
5698
5762
|
const [debouncedSearch, setDebouncedSearch] = useState12(state.search);
|
|
5699
5763
|
useEffect7(() => {
|
|
5700
5764
|
if (state.search === debouncedSearch) return;
|
|
@@ -5789,7 +5853,7 @@ function useTableUrlState(options) {
|
|
|
5789
5853
|
writeState(next);
|
|
5790
5854
|
setDebouncedSearch("");
|
|
5791
5855
|
}, [defaultPageSize, defaultSortDirection, defaultSortId, writeState]);
|
|
5792
|
-
const queryState =
|
|
5856
|
+
const queryState = useMemo5(
|
|
5793
5857
|
() => state.search === debouncedSearch ? state : { ...state, search: debouncedSearch, page: 1 },
|
|
5794
5858
|
[state, debouncedSearch]
|
|
5795
5859
|
);
|
|
@@ -5804,10 +5868,10 @@ import {
|
|
|
5804
5868
|
} from "@ai-matrx/kit/url-state";
|
|
5805
5869
|
|
|
5806
5870
|
// src/data-table/RowAlchemyLauncher.tsx
|
|
5807
|
-
import { useCallback as useCallback5, useEffect as useEffect8, useRef as
|
|
5871
|
+
import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef10, useState as useState13 } from "react";
|
|
5808
5872
|
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5809
5873
|
function MatrxTableRowAlchemyProvider({ copy, placement, controls, children }) {
|
|
5810
|
-
const controller =
|
|
5874
|
+
const controller = useRef10(null);
|
|
5811
5875
|
const { CopyControls } = useMatrxDataTableHost();
|
|
5812
5876
|
const [active, setActive] = useState13(false);
|
|
5813
5877
|
const [fallback, setFallback] = useState13(false);
|
|
@@ -5849,8 +5913,8 @@ function MatrxTableRowAlchemyProvider({ copy, placement, controls, children }) {
|
|
|
5849
5913
|
import {
|
|
5850
5914
|
forwardRef as forwardRef12,
|
|
5851
5915
|
useEffect as useEffect9,
|
|
5852
|
-
useMemo as
|
|
5853
|
-
useRef as
|
|
5916
|
+
useMemo as useMemo6,
|
|
5917
|
+
useRef as useRef11,
|
|
5854
5918
|
useState as useState14
|
|
5855
5919
|
} from "react";
|
|
5856
5920
|
import { useDraggable } from "@dnd-kit/core";
|
|
@@ -6192,7 +6256,7 @@ function ColumnHeaderCell({
|
|
|
6192
6256
|
setPendingNegation(filterValue?.negated ?? false);
|
|
6193
6257
|
}
|
|
6194
6258
|
}, [filterOpen, filterValue]);
|
|
6195
|
-
const notifyOpen =
|
|
6259
|
+
const notifyOpen = useRef11(onFilterOpen);
|
|
6196
6260
|
notifyOpen.current = onFilterOpen;
|
|
6197
6261
|
useEffect9(() => {
|
|
6198
6262
|
if (filterOpen) notifyOpen.current?.();
|
|
@@ -6679,7 +6743,7 @@ function FacetChecklist({
|
|
|
6679
6743
|
const [query, setQuery] = useState14("");
|
|
6680
6744
|
const selected = value?.kind === "select" ? value.values ?? (value.value && value.value !== "__all__" ? [value.value] : []) : [];
|
|
6681
6745
|
const selectedSet = new Set(selected);
|
|
6682
|
-
const rows =
|
|
6746
|
+
const rows = useMemo6(() => {
|
|
6683
6747
|
if (!facets) return [];
|
|
6684
6748
|
const listed = facets.values.map((entry) => ({
|
|
6685
6749
|
value: entry.value,
|
|
@@ -6849,7 +6913,7 @@ function SearchableSelectFilter({
|
|
|
6849
6913
|
allowCustom = false
|
|
6850
6914
|
}) {
|
|
6851
6915
|
const [query, setQuery] = useState14("");
|
|
6852
|
-
const filtered =
|
|
6916
|
+
const filtered = useMemo6(() => {
|
|
6853
6917
|
const q = query.trim().toLowerCase();
|
|
6854
6918
|
if (!q) return options;
|
|
6855
6919
|
return options.filter(
|
|
@@ -7035,7 +7099,7 @@ function parseOptionalNumber(raw) {
|
|
|
7035
7099
|
import {
|
|
7036
7100
|
useCallback as useCallback6,
|
|
7037
7101
|
useEffect as useEffect10,
|
|
7038
|
-
useRef as
|
|
7102
|
+
useRef as useRef12,
|
|
7039
7103
|
useState as useState15
|
|
7040
7104
|
} from "react";
|
|
7041
7105
|
|
|
@@ -7079,11 +7143,11 @@ function ColumnResizeHandle({
|
|
|
7079
7143
|
onResizeCancel,
|
|
7080
7144
|
onResizeCommit
|
|
7081
7145
|
}) {
|
|
7082
|
-
const handleRef =
|
|
7083
|
-
const activeResizeRef =
|
|
7084
|
-
const previewRafRef =
|
|
7085
|
-
const queuedWidthRef =
|
|
7086
|
-
const keyboardWidthRef =
|
|
7146
|
+
const handleRef = useRef12(null);
|
|
7147
|
+
const activeResizeRef = useRef12(null);
|
|
7148
|
+
const previewRafRef = useRef12(null);
|
|
7149
|
+
const queuedWidthRef = useRef12(null);
|
|
7150
|
+
const keyboardWidthRef = useRef12(null);
|
|
7087
7151
|
const [announcedWidth, setAnnouncedWidth] = useState15(null);
|
|
7088
7152
|
const bounds = resolveColumnResizeBounds(minWidth, maxWidth);
|
|
7089
7153
|
const cssVar = columnResizeCssVar(columnId2);
|
|
@@ -7672,7 +7736,7 @@ function scrollOffsetForIndex(input) {
|
|
|
7672
7736
|
}
|
|
7673
7737
|
|
|
7674
7738
|
// src/data-table/useSpreadsheetGrid.ts
|
|
7675
|
-
import { useCallback as useCallback7, useEffect as useEffect11, useMemo as
|
|
7739
|
+
import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo7, useRef as useRef13, useState as useState16 } from "react";
|
|
7676
7740
|
|
|
7677
7741
|
// src/data-table/grid-selection.ts
|
|
7678
7742
|
function rangeBounds(range, rowIds, fieldNames) {
|
|
@@ -8383,11 +8447,11 @@ function useSpreadsheetGrid(options) {
|
|
|
8383
8447
|
const [range, setRange] = useState16(null);
|
|
8384
8448
|
const [fillTarget, setFillTarget] = useState16(null);
|
|
8385
8449
|
const [stack, setStack] = useState16(() => createUndoStack(options?.undoDepth ?? 100));
|
|
8386
|
-
const draggingRef =
|
|
8387
|
-
const optionsRef =
|
|
8450
|
+
const draggingRef = useRef13(null);
|
|
8451
|
+
const optionsRef = useRef13(options);
|
|
8388
8452
|
optionsRef.current = options;
|
|
8389
8453
|
const rowIds = options?.rowIds ?? [];
|
|
8390
|
-
const columnIds =
|
|
8454
|
+
const columnIds = useMemo7(
|
|
8391
8455
|
() => options ? options.columnIds.filter((id) => id !== "") : [],
|
|
8392
8456
|
[options]
|
|
8393
8457
|
);
|
|
@@ -8398,16 +8462,16 @@ function useSpreadsheetGrid(options) {
|
|
|
8398
8462
|
const alive = rowSet.has(range.anchor.rowId) && rowSet.has(range.focus.rowId) && colSet.has(range.anchor.fieldName) && colSet.has(range.focus.fieldName);
|
|
8399
8463
|
if (!alive) setRange(null);
|
|
8400
8464
|
}, [range, rowIds, columnIds]);
|
|
8401
|
-
const bounds =
|
|
8465
|
+
const bounds = useMemo7(
|
|
8402
8466
|
() => range ? rangeBounds(range, rowIds, columnIds) : null,
|
|
8403
8467
|
[range, rowIds, columnIds]
|
|
8404
8468
|
);
|
|
8405
|
-
const rowIndexById =
|
|
8469
|
+
const rowIndexById = useMemo7(() => {
|
|
8406
8470
|
const map = /* @__PURE__ */ new Map();
|
|
8407
8471
|
for (let i = 0; i < rowIds.length; i += 1) map.set(rowIds[i], i);
|
|
8408
8472
|
return map;
|
|
8409
8473
|
}, [rowIds]);
|
|
8410
|
-
const columnIndexById =
|
|
8474
|
+
const columnIndexById = useMemo7(() => {
|
|
8411
8475
|
const map = /* @__PURE__ */ new Map();
|
|
8412
8476
|
for (let i = 0; i < columnIds.length; i += 1) map.set(columnIds[i], i);
|
|
8413
8477
|
return map;
|
|
@@ -8791,9 +8855,9 @@ function useSpreadsheetGrid(options) {
|
|
|
8791
8855
|
},
|
|
8792
8856
|
[]
|
|
8793
8857
|
);
|
|
8794
|
-
const fillTargetRef =
|
|
8858
|
+
const fillTargetRef = useRef13(null);
|
|
8795
8859
|
fillTargetRef.current = fillTarget;
|
|
8796
|
-
const boundsRef =
|
|
8860
|
+
const boundsRef = useRef13(null);
|
|
8797
8861
|
boundsRef.current = bounds;
|
|
8798
8862
|
useEffect11(() => {
|
|
8799
8863
|
if (!options) return;
|
|
@@ -8988,7 +9052,7 @@ function rankTableSearchRows(rows, columns, query, options = {}, extraText) {
|
|
|
8988
9052
|
}
|
|
8989
9053
|
|
|
8990
9054
|
// src/data-table/ColumnManager.tsx
|
|
8991
|
-
import { useEffect as useEffect12, useMemo as
|
|
9055
|
+
import { useEffect as useEffect12, useMemo as useMemo8, useState as useState17 } from "react";
|
|
8992
9056
|
import { useDndMonitor, useDraggable as useDraggable2, useDroppable } from "@dnd-kit/core";
|
|
8993
9057
|
import { jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
8994
9058
|
function ColumnManager({
|
|
@@ -8999,7 +9063,7 @@ function ColumnManager({
|
|
|
8999
9063
|
hidden,
|
|
9000
9064
|
onApply
|
|
9001
9065
|
}) {
|
|
9002
|
-
const byId =
|
|
9066
|
+
const byId = useMemo8(
|
|
9003
9067
|
() => new Map(columns.map((column) => [columnId(column), column])),
|
|
9004
9068
|
[columns]
|
|
9005
9069
|
);
|
|
@@ -9541,7 +9605,7 @@ function parseTableViewSnapshot(raw) {
|
|
|
9541
9605
|
// src/data-table/MatrxUuidCell.tsx
|
|
9542
9606
|
import {
|
|
9543
9607
|
useEffect as useEffect13,
|
|
9544
|
-
useRef as
|
|
9608
|
+
useRef as useRef14,
|
|
9545
9609
|
useState as useState18
|
|
9546
9610
|
} from "react";
|
|
9547
9611
|
import { jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
@@ -9586,7 +9650,7 @@ function MatrxUuidCell({
|
|
|
9586
9650
|
const [copied, setCopied] = useState18(false);
|
|
9587
9651
|
const [opening, setOpening] = useState18(false);
|
|
9588
9652
|
const [peekOpen, setPeekOpen] = useState18(false);
|
|
9589
|
-
const timer =
|
|
9653
|
+
const timer = useRef14(null);
|
|
9590
9654
|
useEffect13(
|
|
9591
9655
|
() => () => {
|
|
9592
9656
|
if (timer.current) clearTimeout(timer.current);
|
|
@@ -10820,7 +10884,7 @@ function DirtySavePill({
|
|
|
10820
10884
|
}
|
|
10821
10885
|
|
|
10822
10886
|
// src/data-table/EditableTableCell.tsx
|
|
10823
|
-
import { useEffect as useEffect15, useRef as
|
|
10887
|
+
import { useEffect as useEffect15, useRef as useRef15, useState as useState20 } from "react";
|
|
10824
10888
|
import { jsx as jsx39, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
10825
10889
|
function CellRefusal({ reason }) {
|
|
10826
10890
|
return /* @__PURE__ */ jsx39(
|
|
@@ -10994,8 +11058,8 @@ function InlineStringEditor({
|
|
|
10994
11058
|
const [editing, setEditing] = useState20(false);
|
|
10995
11059
|
const [draft, setDraft] = useState20(value);
|
|
10996
11060
|
const [refusal, setRefusal] = useState20(null);
|
|
10997
|
-
const handledEditRequest =
|
|
10998
|
-
const seedRef =
|
|
11061
|
+
const handledEditRequest = useRef15(void 0);
|
|
11062
|
+
const seedRef = useRef15(editSeed);
|
|
10999
11063
|
seedRef.current = editSeed;
|
|
11000
11064
|
useEffect15(() => {
|
|
11001
11065
|
if (editRequest === void 0 || handledEditRequest.current === editRequest) return;
|
|
@@ -12124,7 +12188,7 @@ function MatrxDataTableCore({
|
|
|
12124
12188
|
}) {
|
|
12125
12189
|
const appendQuery = query?.mode === "controlled-append" ? query : null;
|
|
12126
12190
|
const appendQueryKey = appendQuery?.pagination.queryKey ?? null;
|
|
12127
|
-
const committedAppendQueryKey =
|
|
12191
|
+
const committedAppendQueryKey = useRef16(appendQueryKey);
|
|
12128
12192
|
const appendSourceChanged = appendQuery !== null && committedAppendQueryKey.current !== appendQueryKey;
|
|
12129
12193
|
const data = (appendQuery ? appendQuery.pagination.rows : suppliedData) ?? [];
|
|
12130
12194
|
const isLoading = appendQuery ? appendQuery.pagination.loading : suppliedLoading;
|
|
@@ -12139,7 +12203,7 @@ function MatrxDataTableCore({
|
|
|
12139
12203
|
const [savedViewError, setSavedViewError] = useState22(null);
|
|
12140
12204
|
const [toolbarActionError, setToolbarActionError] = useState22(null);
|
|
12141
12205
|
const [toolbarActionPending, setToolbarActionPending] = useState22({ refresh: false, add: false });
|
|
12142
|
-
const toolbarActionPendingRef =
|
|
12206
|
+
const toolbarActionPendingRef = useRef16({ refresh: false, add: false });
|
|
12143
12207
|
const CHECKBOX_TAP_AREA = "h-4 w-4 touch-manipulation";
|
|
12144
12208
|
const mobileCardsClass = mobileCardsBreakpoint === "lg" ? "lg:hidden" : "sm:hidden";
|
|
12145
12209
|
const tableWithCardsClass = mobileCardsBreakpoint === "lg" ? "max-lg:hidden" : "max-sm:hidden";
|
|
@@ -12277,9 +12341,9 @@ function MatrxDataTableCore({
|
|
|
12277
12341
|
const [windowRowSnapshot, setWindowRowSnapshot] = useState22(null);
|
|
12278
12342
|
const editScopeKey = appendQueryKey === null ? "\0local" : `append:${appendQueryKey}`;
|
|
12279
12343
|
const [editsByScope, setEditsByScope] = useState22({});
|
|
12280
|
-
const editRevisionRef =
|
|
12344
|
+
const editRevisionRef = useRef16({});
|
|
12281
12345
|
const [savingByScope, setSavingByScope] = useState22({});
|
|
12282
|
-
const savingScopesRef =
|
|
12346
|
+
const savingScopesRef = useRef16(/* @__PURE__ */ new Set());
|
|
12283
12347
|
const [editRequest, setEditRequest] = useState22(null);
|
|
12284
12348
|
const [confirmForeignDraftDiscard, setConfirmForeignDraftDiscard] = useState22(false);
|
|
12285
12349
|
const edits = editsByScope[editScopeKey]?.values ?? {};
|
|
@@ -12366,13 +12430,13 @@ function MatrxDataTableCore({
|
|
|
12366
12430
|
onWindowRowIdChange,
|
|
12367
12431
|
selectionConfig
|
|
12368
12432
|
]);
|
|
12369
|
-
const scrollRef =
|
|
12370
|
-
const tableRef =
|
|
12371
|
-
const tableHeaderRef =
|
|
12372
|
-
const cardsScrollRef =
|
|
12433
|
+
const scrollRef = useRef16(null);
|
|
12434
|
+
const tableRef = useRef16(null);
|
|
12435
|
+
const tableHeaderRef = useRef16(null);
|
|
12436
|
+
const cardsScrollRef = useRef16(null);
|
|
12373
12437
|
const [documentStickyHeader, setDocumentStickyHeader] = useState22(false);
|
|
12374
|
-
const documentStickyHeaderRef =
|
|
12375
|
-
const previousAppendKeyForScrollReset =
|
|
12438
|
+
const documentStickyHeaderRef = useRef16(false);
|
|
12439
|
+
const previousAppendKeyForScrollReset = useRef16(appendQueryKey);
|
|
12376
12440
|
useLayoutEffect2(() => {
|
|
12377
12441
|
const previous = previousAppendKeyForScrollReset.current;
|
|
12378
12442
|
previousAppendKeyForScrollReset.current = appendQueryKey;
|
|
@@ -12398,7 +12462,7 @@ function MatrxDataTableCore({
|
|
|
12398
12462
|
...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.thresholdPx !== void 0 ? { thresholdPx: appendScrollPolicy.thresholdPx } : {},
|
|
12399
12463
|
...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.intentTimeoutMs !== void 0 ? { intentTimeoutMs: appendScrollPolicy.intentTimeoutMs } : {}
|
|
12400
12464
|
});
|
|
12401
|
-
const rootRef =
|
|
12465
|
+
const rootRef = useRef16(null);
|
|
12402
12466
|
useClippedContentGuard(rootRef, {
|
|
12403
12467
|
label: typeof copy === "object" && copy.listLabel ? `Table: ${copy.listLabel}` : "MatrxDataTable"
|
|
12404
12468
|
});
|
|
@@ -12500,11 +12564,11 @@ function MatrxDataTableCore({
|
|
|
12500
12564
|
() => normalizeColumnWidthsForColumns(columnState?.widths, columns)
|
|
12501
12565
|
);
|
|
12502
12566
|
const [fixedTableGeometry, setFixedTableGeometry] = useState22(null);
|
|
12503
|
-
const knownColumnIds =
|
|
12504
|
-
const draggedColumnId =
|
|
12505
|
-
const columnDragActive =
|
|
12506
|
-
const columnDragRaf =
|
|
12507
|
-
const columnDragScrollDirection =
|
|
12567
|
+
const knownColumnIds = useRef16(new Set(columns.map(columnId)));
|
|
12568
|
+
const draggedColumnId = useRef16(null);
|
|
12569
|
+
const columnDragActive = useRef16(false);
|
|
12570
|
+
const columnDragRaf = useRef16(null);
|
|
12571
|
+
const columnDragScrollDirection = useRef16(0);
|
|
12508
12572
|
const [columnDragPreview, setColumnDragPreview] = useState22(null);
|
|
12509
12573
|
const stopColumnDragScroll = useCallback8(() => {
|
|
12510
12574
|
if (columnDragRaf.current !== null) cancelAnimationFrame(columnDragRaf.current);
|
|
@@ -12552,14 +12616,14 @@ function MatrxDataTableCore({
|
|
|
12552
12616
|
const [internalColumnManagerOpen, setInternalColumnManagerOpen] = useState22(false);
|
|
12553
12617
|
const columnManagerOpen = controlledColumnManager?.open ?? internalColumnManagerOpen;
|
|
12554
12618
|
const setColumnManagerOpen = controlledColumnManager?.onOpenChange ?? setInternalColumnManagerOpen;
|
|
12555
|
-
const columnIds =
|
|
12556
|
-
const effectiveColumnOrder =
|
|
12557
|
-
const effectiveHiddenColumnIds =
|
|
12558
|
-
const effectiveColumnWidths =
|
|
12619
|
+
const columnIds = useMemo9(() => columns.map(columnId), [columns]);
|
|
12620
|
+
const effectiveColumnOrder = useMemo9(() => 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]);
|
|
12621
|
+
const effectiveHiddenColumnIds = useMemo9(() => columnState ? new Set(columnState.hidden.filter((id) => columnIds.includes(id))) : hiddenColumnIds, [columnIds, columnState, hiddenColumnIds]);
|
|
12622
|
+
const effectiveColumnWidths = useMemo9(
|
|
12559
12623
|
() => normalizeColumnWidthsForColumns(columnState?.widths ?? columnWidths, columns),
|
|
12560
12624
|
[columns, columnState?.widths, columnWidths]
|
|
12561
12625
|
);
|
|
12562
|
-
const resizeGestureSnapshotRef =
|
|
12626
|
+
const resizeGestureSnapshotRef = useRef16(null);
|
|
12563
12627
|
const measureVisibleColumnWidths = useCallback8(() => {
|
|
12564
12628
|
const measured = {};
|
|
12565
12629
|
const headers = tableRef.current ? Array.from(tableRef.current.querySelectorAll(
|
|
@@ -12661,12 +12725,12 @@ function MatrxDataTableCore({
|
|
|
12661
12725
|
tableRef.current?.style.removeProperty(columnResizeCssVar(id));
|
|
12662
12726
|
}
|
|
12663
12727
|
});
|
|
12664
|
-
const previewColumnOrder =
|
|
12728
|
+
const previewColumnOrder = useMemo9(
|
|
12665
12729
|
() => projectColumnDragOrder(effectiveColumnOrder, columnDragPreview),
|
|
12666
12730
|
[columnDragPreview, effectiveColumnOrder]
|
|
12667
12731
|
);
|
|
12668
12732
|
useColumnReorderAnimation(tableRef, previewColumnOrder.join("\0"), columnDragPreview !== null);
|
|
12669
|
-
const visibleColumns =
|
|
12733
|
+
const visibleColumns = useMemo9(() => {
|
|
12670
12734
|
const byId = new Map(columns.map((column) => [columnId(column), column]));
|
|
12671
12735
|
return previewColumnOrder.map((id) => byId.get(id)).filter(
|
|
12672
12736
|
(column) => column !== void 0 && !effectiveHiddenColumnIds.has(columnId(column))
|
|
@@ -12702,7 +12766,7 @@ function MatrxDataTableCore({
|
|
|
12702
12766
|
setFixedTableGeometry(geometry);
|
|
12703
12767
|
}, [resolvedDensity, measureFixedTableGeometry, usesMeasuredFixedLayout]);
|
|
12704
12768
|
const fixedLayoutActive = usesMeasuredFixedLayout && fixedTableGeometry !== null;
|
|
12705
|
-
const frozenColumns =
|
|
12769
|
+
const frozenColumns = useMemo9(() => {
|
|
12706
12770
|
if (!visibleColumns.some((column) => column.frozen)) return NO_FROZEN_COLUMNS;
|
|
12707
12771
|
const ids = visibleColumns.map(columnId);
|
|
12708
12772
|
const byId = new Map(visibleColumns.map((column) => [columnId(column), column]));
|
|
@@ -12750,7 +12814,7 @@ function MatrxDataTableCore({
|
|
|
12750
12814
|
const color = cellTintColor(row, id, colId);
|
|
12751
12815
|
return color ? CELL_TINT_CLASS[color] : void 0;
|
|
12752
12816
|
};
|
|
12753
|
-
const declaredVisibleCopyColumns =
|
|
12817
|
+
const declaredVisibleCopyColumns = useMemo9(
|
|
12754
12818
|
() => visibleColumns.filter((column) => column.accessorFn !== void 0 || column.accessorKey !== void 0),
|
|
12755
12819
|
[visibleColumns]
|
|
12756
12820
|
);
|
|
@@ -12758,7 +12822,7 @@ function MatrxDataTableCore({
|
|
|
12758
12822
|
const tableContextMenuInstanceId = useId2();
|
|
12759
12823
|
const tableDndContextId = useId2();
|
|
12760
12824
|
const defaultCopyTitle = toolbar?.title || "Table";
|
|
12761
|
-
const defaultCopy =
|
|
12825
|
+
const defaultCopy = useMemo9(() => ({
|
|
12762
12826
|
label: defaultCopyTitle,
|
|
12763
12827
|
listLabel: defaultCopyTitle,
|
|
12764
12828
|
location: defaultCopyTitle,
|
|
@@ -12793,7 +12857,7 @@ function MatrxDataTableCore({
|
|
|
12793
12857
|
serializer: (shaped) => buildViewAgentInput(effectiveCopy, shaped, data, { scope: "custom" })
|
|
12794
12858
|
}))
|
|
12795
12859
|
] : [];
|
|
12796
|
-
const filterMeta =
|
|
12860
|
+
const filterMeta = useMemo9(() => {
|
|
12797
12861
|
const meta = /* @__PURE__ */ new Map();
|
|
12798
12862
|
for (const col of visibleColumns) {
|
|
12799
12863
|
const id = columnId(col);
|
|
@@ -12801,14 +12865,14 @@ function MatrxDataTableCore({
|
|
|
12801
12865
|
}
|
|
12802
12866
|
return meta;
|
|
12803
12867
|
}, [visibleColumns, data, remoteQuery]);
|
|
12804
|
-
const intelligentSearchScopes =
|
|
12868
|
+
const intelligentSearchScopes = useMemo9(
|
|
12805
12869
|
() => resolveTableSearchScopes(data, columns, {
|
|
12806
12870
|
...toolbar?.intelligentSearch?.roles === void 0 ? {} : { roles: toolbar.intelligentSearch.roles },
|
|
12807
12871
|
...toolbar?.intelligentSearch?.scopes === void 0 ? {} : { scopes: toolbar.intelligentSearch.scopes }
|
|
12808
12872
|
}),
|
|
12809
12873
|
[columns, data, toolbar?.intelligentSearch?.roles, toolbar?.intelligentSearch?.scopes]
|
|
12810
12874
|
);
|
|
12811
|
-
const processed =
|
|
12875
|
+
const processed = useMemo9(() => {
|
|
12812
12876
|
if (remoteQuery && !appendUsesLocalProcessing) return data;
|
|
12813
12877
|
if (processLocalRows) {
|
|
12814
12878
|
return processLocalRows(data, {
|
|
@@ -12871,7 +12935,7 @@ function MatrxDataTableCore({
|
|
|
12871
12935
|
intelligentSearchEnabled,
|
|
12872
12936
|
searchScope
|
|
12873
12937
|
]);
|
|
12874
|
-
const lastNotifiedViewRows =
|
|
12938
|
+
const lastNotifiedViewRows = useRef16(null);
|
|
12875
12939
|
useEffect16(() => {
|
|
12876
12940
|
if (!onViewChange) {
|
|
12877
12941
|
lastNotifiedViewRows.current = null;
|
|
@@ -12925,7 +12989,7 @@ function MatrxDataTableCore({
|
|
|
12925
12989
|
numberedPageHasMore: !hidePagination && !isLoading && !isFetching && processed.length > 0 && safePage < pageCount && (remoteQuery?.mode === "controlled" || !remoteQuery && localPagination?.mode === "numbered"),
|
|
12926
12990
|
onPageAdvance: setPage
|
|
12927
12991
|
});
|
|
12928
|
-
const paginated =
|
|
12992
|
+
const paginated = useMemo9(() => {
|
|
12929
12993
|
if (remoteQuery) return processed;
|
|
12930
12994
|
if (hidePagination) return processed;
|
|
12931
12995
|
if (localProgressiveEnabled) return [...progressiveRows.rows];
|
|
@@ -12943,7 +13007,7 @@ function MatrxDataTableCore({
|
|
|
12943
13007
|
},
|
|
12944
13008
|
[grouping]
|
|
12945
13009
|
);
|
|
12946
|
-
const groups =
|
|
13010
|
+
const groups = useMemo9(() => {
|
|
12947
13011
|
if (!grouping || !groupingColumnId) return null;
|
|
12948
13012
|
const groupColumn = columns.find((col) => columnId(col) === groupingColumnId);
|
|
12949
13013
|
if (!groupColumn) return null;
|
|
@@ -12962,7 +13026,7 @@ function MatrxDataTableCore({
|
|
|
12962
13026
|
...grouping.emptyLabel ? { emptyLabel: grouping.emptyLabel } : {}
|
|
12963
13027
|
});
|
|
12964
13028
|
}, [grouping, groupingColumnId, columns, paginated]);
|
|
12965
|
-
const groupableColumns =
|
|
13029
|
+
const groupableColumns = useMemo9(() => {
|
|
12966
13030
|
const allowed = grouping?.groupableColumnIds;
|
|
12967
13031
|
return visibleColumns.filter((col) => {
|
|
12968
13032
|
const id = columnId(col);
|
|
@@ -12970,7 +13034,7 @@ function MatrxDataTableCore({
|
|
|
12970
13034
|
return col.accessorKey !== void 0 || col.accessorFn !== void 0;
|
|
12971
13035
|
});
|
|
12972
13036
|
}, [visibleColumns, grouping?.groupableColumnIds]);
|
|
12973
|
-
const groupedRenderRows =
|
|
13037
|
+
const groupedRenderRows = useMemo9(
|
|
12974
13038
|
() => groups ? flattenGroups(groups, collapsedGroups) : null,
|
|
12975
13039
|
[groups, collapsedGroups]
|
|
12976
13040
|
);
|
|
@@ -12980,7 +13044,7 @@ function MatrxDataTableCore({
|
|
|
12980
13044
|
const bodyEntryCount = groupedRenderRows ? groupedRenderRows.length : paginated.length;
|
|
12981
13045
|
const virtualizeActive = virtualizeConfig !== null && virtualizeConfig.enabled !== false && bodyEntryCount > virtualThreshold && !hierarchy && expandedDetail === void 0;
|
|
12982
13046
|
const columnWindowWidth = virtualizeConfig?.columnWidth ?? 160;
|
|
12983
|
-
const frozenRunLength =
|
|
13047
|
+
const frozenRunLength = useMemo9(() => {
|
|
12984
13048
|
let run = 0;
|
|
12985
13049
|
for (const col of visibleColumns) {
|
|
12986
13050
|
if (frozenColumns.offsets[columnId(col)] === void 0) break;
|
|
@@ -12991,7 +13055,7 @@ function MatrxDataTableCore({
|
|
|
12991
13055
|
const columnVirtualizeActive = virtualizeConfig !== null && virtualizeConfig.enabled !== false && virtualizeConfig.columns === true && visibleColumns.length - frozenRunLength > 30 && !hierarchy && mobileCards === void 0;
|
|
12992
13056
|
const [rowWindow, setRowWindow] = useState22(null);
|
|
12993
13057
|
const [columnWindow, setColumnWindow] = useState22(null);
|
|
12994
|
-
const windowInputs =
|
|
13058
|
+
const windowInputs = useRef16({
|
|
12995
13059
|
virtualizeActive: false,
|
|
12996
13060
|
bodyEntryCount: 0,
|
|
12997
13061
|
virtualRowHeight: 40,
|
|
@@ -13032,7 +13096,7 @@ function MatrxDataTableCore({
|
|
|
13032
13096
|
setRowWindow((prev) => sameWindow(prev, nextRow) ? prev : nextRow);
|
|
13033
13097
|
setColumnWindow((prev) => sameWindow(prev, nextColumn) ? prev : nextColumn);
|
|
13034
13098
|
}, []);
|
|
13035
|
-
const effectiveRowWindow =
|
|
13099
|
+
const effectiveRowWindow = useMemo9(() => {
|
|
13036
13100
|
if (!virtualizeActive) return null;
|
|
13037
13101
|
if (rowWindow && rowWindow.end <= bodyEntryCount) return rowWindow;
|
|
13038
13102
|
return computeWindow({
|
|
@@ -13043,7 +13107,7 @@ function MatrxDataTableCore({
|
|
|
13043
13107
|
overscan: virtualizeConfig?.overscan ?? 8
|
|
13044
13108
|
});
|
|
13045
13109
|
}, [virtualizeActive, rowWindow, bodyEntryCount, virtualRowHeight, virtualizeConfig?.overscan]);
|
|
13046
|
-
const effectiveColumnWindow =
|
|
13110
|
+
const effectiveColumnWindow = useMemo9(() => {
|
|
13047
13111
|
if (!columnVirtualizeActive) return null;
|
|
13048
13112
|
if (columnWindow && columnWindow.end <= visibleColumns.length) return columnWindow;
|
|
13049
13113
|
return computeWindow({
|
|
@@ -13096,7 +13160,7 @@ function MatrxDataTableCore({
|
|
|
13096
13160
|
observer?.disconnect();
|
|
13097
13161
|
};
|
|
13098
13162
|
}, [metricsWanted, recomputeWindows]);
|
|
13099
|
-
const renderedColumns =
|
|
13163
|
+
const renderedColumns = useMemo9(
|
|
13100
13164
|
() => effectiveColumnWindow ? [
|
|
13101
13165
|
...visibleColumns.slice(0, frozenRunLength),
|
|
13102
13166
|
...visibleColumns.slice(effectiveColumnWindow.start, effectiveColumnWindow.end)
|
|
@@ -13113,7 +13177,7 @@ function MatrxDataTableCore({
|
|
|
13113
13177
|
},
|
|
13114
13178
|
[effectiveColumnWindow, effectiveColumnWidths, frozenColumns, columnWindowWidth]
|
|
13115
13179
|
);
|
|
13116
|
-
const coverageResult =
|
|
13180
|
+
const coverageResult = useMemo9(() => {
|
|
13117
13181
|
if (!coverage) return null;
|
|
13118
13182
|
return describeCoverage({
|
|
13119
13183
|
loaded: coverage.loaded ?? data.length,
|
|
@@ -13124,7 +13188,7 @@ function MatrxDataTableCore({
|
|
|
13124
13188
|
...coverage.noun === void 0 ? {} : { noun: coverage.noun }
|
|
13125
13189
|
});
|
|
13126
13190
|
}, [coverage, data.length]);
|
|
13127
|
-
const bodyEntries =
|
|
13191
|
+
const bodyEntries = useMemo9(() => {
|
|
13128
13192
|
const from = effectiveRowWindow ? effectiveRowWindow.start : 0;
|
|
13129
13193
|
const to = effectiveRowWindow ? effectiveRowWindow.end : void 0;
|
|
13130
13194
|
const windowed = groupedRenderRows ? groupedRenderRows.slice(from, to).map(
|
|
@@ -13141,22 +13205,22 @@ function MatrxDataTableCore({
|
|
|
13141
13205
|
windowed.push({ kind: "spacer", height: effectiveRowWindow.padEnd, place: "end" });
|
|
13142
13206
|
return windowed;
|
|
13143
13207
|
}, [groupedRenderRows, collapsedGroups, paginated, effectiveRowWindow]);
|
|
13144
|
-
const getRowIdRef =
|
|
13208
|
+
const getRowIdRef = useRef16(getRowId);
|
|
13145
13209
|
getRowIdRef.current = getRowId;
|
|
13146
|
-
const spreadsheetRowIds =
|
|
13210
|
+
const spreadsheetRowIds = useMemo9(
|
|
13147
13211
|
() => paginated.map((row) => getRowIdRef.current(row)),
|
|
13148
13212
|
[paginated]
|
|
13149
13213
|
);
|
|
13150
|
-
const spreadsheetColumnIds =
|
|
13214
|
+
const spreadsheetColumnIds = useMemo9(
|
|
13151
13215
|
() => visibleColumns.map((col) => columnId(col)),
|
|
13152
13216
|
[visibleColumns]
|
|
13153
13217
|
);
|
|
13154
|
-
const spreadsheetRowById =
|
|
13218
|
+
const spreadsheetRowById = useMemo9(() => {
|
|
13155
13219
|
const map = /* @__PURE__ */ new Map();
|
|
13156
13220
|
for (const row of paginated) map.set(getRowIdRef.current(row), row);
|
|
13157
13221
|
return map;
|
|
13158
13222
|
}, [paginated]);
|
|
13159
|
-
const spreadsheetColumnById =
|
|
13223
|
+
const spreadsheetColumnById = useMemo9(() => {
|
|
13160
13224
|
const map = /* @__PURE__ */ new Map();
|
|
13161
13225
|
for (const col of visibleColumns) map.set(columnId(col), col);
|
|
13162
13226
|
return map;
|
|
@@ -13189,9 +13253,9 @@ function MatrxDataTableCore({
|
|
|
13189
13253
|
...spreadsheet.onPastePlan ? { onPastePlan: spreadsheet.onPastePlan } : {}
|
|
13190
13254
|
} : null
|
|
13191
13255
|
);
|
|
13192
|
-
const sheetRef =
|
|
13256
|
+
const sheetRef = useRef16(sheet);
|
|
13193
13257
|
sheetRef.current = sheet;
|
|
13194
|
-
const searchValueRef =
|
|
13258
|
+
const searchValueRef = useRef16(searchValue);
|
|
13195
13259
|
searchValueRef.current = searchValue;
|
|
13196
13260
|
const facetsEnabled = Boolean(facets && facets.enabled !== false);
|
|
13197
13261
|
const [facetState, setFacetState] = useState22({});
|
|
@@ -13203,9 +13267,9 @@ function MatrxDataTableCore({
|
|
|
13203
13267
|
},
|
|
13204
13268
|
[facets, visibleColumns]
|
|
13205
13269
|
);
|
|
13206
|
-
const facetInputsRef =
|
|
13270
|
+
const facetInputsRef = useRef16({ data, facets, facetReadCell });
|
|
13207
13271
|
facetInputsRef.current = { data, facets, facetReadCell };
|
|
13208
|
-
const facetRequestRef =
|
|
13272
|
+
const facetRequestRef = useRef16(/* @__PURE__ */ new Map());
|
|
13209
13273
|
const requestFacets = useCallback8((colId) => {
|
|
13210
13274
|
const { data: rows, facets: config, facetReadCell: readCell } = facetInputsRef.current;
|
|
13211
13275
|
if (!config || config.enabled === false) return;
|
|
@@ -13274,11 +13338,11 @@ function MatrxDataTableCore({
|
|
|
13274
13338
|
if (!controlledQuery || controlledQuery.state.page === safePage) return;
|
|
13275
13339
|
emitControlledQueryChange({ page: safePage });
|
|
13276
13340
|
}, [controlledQuery, emitControlledQueryChange, safePage]);
|
|
13277
|
-
const selectedRow =
|
|
13341
|
+
const selectedRow = useMemo9(() => {
|
|
13278
13342
|
if (!selectedId) return null;
|
|
13279
13343
|
return data.find((r) => getRowId(r) === selectedId) ?? null;
|
|
13280
13344
|
}, [data, selectedId, getRowId]);
|
|
13281
|
-
const windowRow =
|
|
13345
|
+
const windowRow = useMemo9(() => {
|
|
13282
13346
|
if (!windowRowId) return null;
|
|
13283
13347
|
return data.find((r) => getRowId(r) === windowRowId) ?? (windowRowSnapshot && windowRowSnapshot.queryKey === appendQueryKey && getRowId(windowRowSnapshot.row) === windowRowId ? windowRowSnapshot.row : null);
|
|
13284
13348
|
}, [data, windowRowId, windowRowSnapshot, getRowId, appendQueryKey]);
|
|
@@ -13313,7 +13377,7 @@ function MatrxDataTableCore({
|
|
|
13313
13377
|
return def !== void 0 && f.value !== def;
|
|
13314
13378
|
});
|
|
13315
13379
|
const hasActiveFilters = activeFilterCount > 0 || Boolean(searchValue.trim()) || intelligentSearchEnabled && searchScope !== "all" || Boolean(anyOfValue.trim()) || completeLayeredFilterRules(layeredFilters).length > 0 || facetActive;
|
|
13316
|
-
const changeCount =
|
|
13380
|
+
const changeCount = useMemo9(() => {
|
|
13317
13381
|
let n2 = 0;
|
|
13318
13382
|
for (const fields of Object.values(edits)) {
|
|
13319
13383
|
n2 += Object.keys(fields).length;
|
|
@@ -13492,7 +13556,7 @@ function MatrxDataTableCore({
|
|
|
13492
13556
|
}));
|
|
13493
13557
|
return true;
|
|
13494
13558
|
};
|
|
13495
|
-
const requestCellEditRef =
|
|
13559
|
+
const requestCellEditRef = useRef16(requestCellEdit);
|
|
13496
13560
|
requestCellEditRef.current = requestCellEdit;
|
|
13497
13561
|
const buildRecordControls = (row) => {
|
|
13498
13562
|
const rowId = getRowId(row);
|
|
@@ -13519,7 +13583,7 @@ function MatrxDataTableCore({
|
|
|
13519
13583
|
};
|
|
13520
13584
|
const hierarchyRows = hierarchy?.rows ?? data;
|
|
13521
13585
|
const hierarchyGetParentId = hierarchy?.getParentId;
|
|
13522
|
-
const hierarchyIndex =
|
|
13586
|
+
const hierarchyIndex = useMemo9(() => {
|
|
13523
13587
|
if (!hierarchyGetParentId) return null;
|
|
13524
13588
|
const byId = /* @__PURE__ */ new Map();
|
|
13525
13589
|
const parentById = /* @__PURE__ */ new Map();
|
|
@@ -13551,7 +13615,7 @@ function MatrxDataTableCore({
|
|
|
13551
13615
|
return { byId, parentById, depthById };
|
|
13552
13616
|
}, [hierarchyGetParentId, hierarchyRows, getRowId]);
|
|
13553
13617
|
const draggedRow = draggedRowId && hierarchyIndex ? hierarchyIndex.byId.get(draggedRowId) : void 0;
|
|
13554
|
-
const hierarchyBlockedIds =
|
|
13618
|
+
const hierarchyBlockedIds = useMemo9(() => {
|
|
13555
13619
|
if (!draggedRowId || !hierarchyIndex) return null;
|
|
13556
13620
|
const childrenById = /* @__PURE__ */ new Map();
|
|
13557
13621
|
for (const [id, parentId] of hierarchyIndex.parentById) {
|
|
@@ -13797,7 +13861,7 @@ function MatrxDataTableCore({
|
|
|
13797
13861
|
}
|
|
13798
13862
|
}
|
|
13799
13863
|
};
|
|
13800
|
-
const resolveMenuLevelRef =
|
|
13864
|
+
const resolveMenuLevelRef = useRef16(resolveMenuLevel);
|
|
13801
13865
|
resolveMenuLevelRef.current = resolveMenuLevel;
|
|
13802
13866
|
useEffect16(() => {
|
|
13803
13867
|
if (!host.rowContextRegistry) return;
|
|
@@ -13807,7 +13871,7 @@ function MatrxDataTableCore({
|
|
|
13807
13871
|
);
|
|
13808
13872
|
}, [host.rowContextRegistry, tableContextMenuInstanceId]);
|
|
13809
13873
|
const showActionsCol = windowEnabled || Boolean(rowActions) || showInlineRowCopy;
|
|
13810
|
-
const selectedIdSet =
|
|
13874
|
+
const selectedIdSet = useMemo9(
|
|
13811
13875
|
() => new Set(selection?.selectedIds ?? []),
|
|
13812
13876
|
[selection?.selectedIds]
|
|
13813
13877
|
);
|
|
@@ -13819,11 +13883,11 @@ function MatrxDataTableCore({
|
|
|
13819
13883
|
);
|
|
13820
13884
|
const allOnPageSelected = selectableRows.length > 0 && selectedOnPage.length === selectableRows.length;
|
|
13821
13885
|
const someOnPageSelected = selectedOnPage.length > 0 && !allOnPageSelected;
|
|
13822
|
-
const selectedRows =
|
|
13886
|
+
const selectedRows = useMemo9(
|
|
13823
13887
|
() => data.filter((row) => selectedIdSet.has(getRowId(row))),
|
|
13824
13888
|
[data, selectedIdSet, getRowId]
|
|
13825
13889
|
);
|
|
13826
|
-
const lastToggledIndex =
|
|
13890
|
+
const lastToggledIndex = useRef16(null);
|
|
13827
13891
|
const setSelectedIds = (next) => selection?.onSelectedIdsChange([...next]);
|
|
13828
13892
|
const toggleRowSelected = (index, shiftKey) => {
|
|
13829
13893
|
if (!selection) return;
|
|
@@ -13905,7 +13969,7 @@ function MatrxDataTableCore({
|
|
|
13905
13969
|
}
|
|
13906
13970
|
return href ? /* @__PURE__ */ jsx42(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;
|
|
13907
13971
|
};
|
|
13908
|
-
const currentViewSnapshot =
|
|
13972
|
+
const currentViewSnapshot = useMemo9(
|
|
13909
13973
|
() => ({
|
|
13910
13974
|
__kind: "matrx-table-view",
|
|
13911
13975
|
version: 1,
|
|
@@ -13940,7 +14004,7 @@ function MatrxDataTableCore({
|
|
|
13940
14004
|
sort
|
|
13941
14005
|
]
|
|
13942
14006
|
);
|
|
13943
|
-
const declaredDefaultViewSnapshot =
|
|
14007
|
+
const declaredDefaultViewSnapshot = useMemo9(
|
|
13944
14008
|
() => defaultViewSnapshot ?? {
|
|
13945
14009
|
__kind: "matrx-table-view",
|
|
13946
14010
|
version: 1,
|
|
@@ -16315,7 +16379,7 @@ function SavedViewsControl({
|
|
|
16315
16379
|
] })
|
|
16316
16380
|
] }),
|
|
16317
16381
|
dirty ? /* @__PURE__ */ jsx44("span", { id: unsavedChangesId, className: "sr-only", children: "This table view has unsaved changes. Open the view menu to save or update it." }) : null,
|
|
16318
|
-
visibleError ? /* @__PURE__ */ jsx44("p", { role: "alert", className: "basis-full break-words text-xs text-destructive", children: visibleError }) : null,
|
|
16382
|
+
visibleError && !saveOpen ? /* @__PURE__ */ jsx44("p", { role: "alert", className: "basis-full break-words text-xs text-destructive", children: visibleError }) : null,
|
|
16319
16383
|
/* @__PURE__ */ jsx44(Dialog, { open: saveOpen, onOpenChange: setSaveOpen, children: /* @__PURE__ */ jsxs34(DialogContent, { children: [
|
|
16320
16384
|
/* @__PURE__ */ jsx44(DialogHeader, { children: /* @__PURE__ */ jsx44(DialogTitle, { children: "Save current view" }) }),
|
|
16321
16385
|
visibleError ? /* @__PURE__ */ jsx44("p", { role: "alert", className: "text-sm text-destructive", children: visibleError }) : null,
|