@optilogic/core 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +91 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +91 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/data-grid/DataGrid.tsx +81 -25
- package/src/components/data-grid/components/HeaderCell.tsx +5 -1
- package/src/components/data-grid/hooks/useColumnResize.ts +30 -1
- package/src/components/data-grid/types.ts +5 -0
package/dist/index.d.cts
CHANGED
|
@@ -1628,6 +1628,10 @@ interface DataGridProps<T = Record<string, CellValue>> {
|
|
|
1628
1628
|
tooltipMinLength?: number;
|
|
1629
1629
|
/** Show column dividing borders between cells (default: true) */
|
|
1630
1630
|
showColumnBorders?: boolean;
|
|
1631
|
+
/** When true, columns scale proportionally to fill the container width.
|
|
1632
|
+
* Columns shrink/grow to keep total width = container width.
|
|
1633
|
+
* Horizontal scroll only kicks in if columns hit their minWidth constraints. */
|
|
1634
|
+
fillWidth?: boolean;
|
|
1631
1635
|
/** Enable internal sorting when in uncontrolled mode (default: true) */
|
|
1632
1636
|
enableInternalSorting?: boolean;
|
|
1633
1637
|
/** Enable internal filtering when in uncontrolled mode (default: true) */
|
|
@@ -1741,6 +1745,7 @@ interface HeaderCellProps$1<T = Record<string, CellValue>> {
|
|
|
1741
1745
|
sorting?: SortConfig;
|
|
1742
1746
|
filter?: FilterConfig;
|
|
1743
1747
|
isResizable: boolean;
|
|
1748
|
+
fillWidth?: boolean;
|
|
1744
1749
|
onSort?: () => void;
|
|
1745
1750
|
onFilterChange?: (filter: FilterConfig | null) => void;
|
|
1746
1751
|
onResize?: (width: number) => void;
|
|
@@ -1786,7 +1791,7 @@ interface GridCellProps<T = Record<string, CellValue>> {
|
|
|
1786
1791
|
/**
|
|
1787
1792
|
* DataGrid Component
|
|
1788
1793
|
*/
|
|
1789
|
-
declare function DataGrid<T = Record<string, CellValue>>({ data, columns, getRowKey, resizableColumns, virtualized, stickyHeader, showTooltips, tooltipMinLength, enableKeyboardNavigation, showColumnBorders, enableInternalSorting, enableInternalFiltering, sorting: controlledSorting, onSortChange, filters: controlledFilters, onFilterChange, columnWidths: controlledColumnWidths, onColumnResize, onColumnResizeStart, onColumnResizeEnd, defaultSorting, defaultFilters, defaultColumnWidths, onStateChange, onRowClick, onRowDoubleClick, selectedRows, onSelectedRowsChange, rowClassName, onCellEdit, onCellEditStart, onCellEditCancel, focusedCell: controlledFocusedCell, onFocusedCellChange, pagination, search, loading, loadingComponent, emptyMessage, emptyComponent, className, tableClassName, infiniteScroll, onLoadMore, hasMore, loadingMore, }: DataGridProps<T>): react_jsx_runtime.JSX.Element;
|
|
1794
|
+
declare function DataGrid<T = Record<string, CellValue>>({ data, columns, getRowKey, resizableColumns, virtualized, stickyHeader, showTooltips, tooltipMinLength, enableKeyboardNavigation, showColumnBorders, fillWidth, enableInternalSorting, enableInternalFiltering, sorting: controlledSorting, onSortChange, filters: controlledFilters, onFilterChange, columnWidths: controlledColumnWidths, onColumnResize, onColumnResizeStart, onColumnResizeEnd, defaultSorting, defaultFilters, defaultColumnWidths, onStateChange, onRowClick, onRowDoubleClick, selectedRows, onSelectedRowsChange, rowClassName, onCellEdit, onCellEditStart, onCellEditCancel, focusedCell: controlledFocusedCell, onFocusedCellChange, pagination, search, loading, loadingComponent, emptyMessage, emptyComponent, className, tableClassName, infiniteScroll, onLoadMore, hasMore, loadingMore, }: DataGridProps<T>): react_jsx_runtime.JSX.Element;
|
|
1790
1795
|
|
|
1791
1796
|
interface HeaderCellProps<T = any> {
|
|
1792
1797
|
/** Column definition */
|
|
@@ -1801,6 +1806,8 @@ interface HeaderCellProps<T = any> {
|
|
|
1801
1806
|
filter?: FilterConfig;
|
|
1802
1807
|
/** Whether this column is resizable */
|
|
1803
1808
|
isResizable: boolean;
|
|
1809
|
+
/** Whether fillWidth mode is active */
|
|
1810
|
+
fillWidth?: boolean;
|
|
1804
1811
|
/** Callback when sort is toggled */
|
|
1805
1812
|
onSort?: () => void;
|
|
1806
1813
|
/** Callback when filter changes */
|
|
@@ -1815,7 +1822,7 @@ interface HeaderCellProps<T = any> {
|
|
|
1815
1822
|
/**
|
|
1816
1823
|
* HeaderCell Component
|
|
1817
1824
|
*/
|
|
1818
|
-
declare function HeaderCell<T = any>({ column, columnIndex, width, sorting, filter, isResizable, onSort, onFilterChange, onResizeMouseDown, onResizeDoubleClick, isResizing, }: HeaderCellProps<T>): react_jsx_runtime.JSX.Element;
|
|
1825
|
+
declare function HeaderCell<T = any>({ column, columnIndex, width, sorting, filter, isResizable, fillWidth, onSort, onFilterChange, onResizeMouseDown, onResizeDoubleClick, isResizing, }: HeaderCellProps<T>): react_jsx_runtime.JSX.Element;
|
|
1819
1826
|
|
|
1820
1827
|
interface FilterPopoverProps<T = Record<string, CellValue>> {
|
|
1821
1828
|
/** Column definition */
|
|
@@ -2019,6 +2026,12 @@ interface UseColumnResizeManagerOptions<T = any> {
|
|
|
2019
2026
|
onColumnResizeStart?: (columnKey: string) => void;
|
|
2020
2027
|
/** Callback when resize ends */
|
|
2021
2028
|
onColumnResizeEnd?: (columnKey: string, width: number) => void;
|
|
2029
|
+
/** Whether fillWidth mode is active */
|
|
2030
|
+
fillWidth?: boolean;
|
|
2031
|
+
/** Measured container width for fillWidth redistribution */
|
|
2032
|
+
containerWidth?: number;
|
|
2033
|
+
/** Effective column widths (after fillWidth scaling) */
|
|
2034
|
+
effectiveColumnWidths?: Record<string, number>;
|
|
2022
2035
|
}
|
|
2023
2036
|
interface UseColumnResizeManagerReturn {
|
|
2024
2037
|
/** Currently resizing column key */
|
package/dist/index.d.ts
CHANGED
|
@@ -1628,6 +1628,10 @@ interface DataGridProps<T = Record<string, CellValue>> {
|
|
|
1628
1628
|
tooltipMinLength?: number;
|
|
1629
1629
|
/** Show column dividing borders between cells (default: true) */
|
|
1630
1630
|
showColumnBorders?: boolean;
|
|
1631
|
+
/** When true, columns scale proportionally to fill the container width.
|
|
1632
|
+
* Columns shrink/grow to keep total width = container width.
|
|
1633
|
+
* Horizontal scroll only kicks in if columns hit their minWidth constraints. */
|
|
1634
|
+
fillWidth?: boolean;
|
|
1631
1635
|
/** Enable internal sorting when in uncontrolled mode (default: true) */
|
|
1632
1636
|
enableInternalSorting?: boolean;
|
|
1633
1637
|
/** Enable internal filtering when in uncontrolled mode (default: true) */
|
|
@@ -1741,6 +1745,7 @@ interface HeaderCellProps$1<T = Record<string, CellValue>> {
|
|
|
1741
1745
|
sorting?: SortConfig;
|
|
1742
1746
|
filter?: FilterConfig;
|
|
1743
1747
|
isResizable: boolean;
|
|
1748
|
+
fillWidth?: boolean;
|
|
1744
1749
|
onSort?: () => void;
|
|
1745
1750
|
onFilterChange?: (filter: FilterConfig | null) => void;
|
|
1746
1751
|
onResize?: (width: number) => void;
|
|
@@ -1786,7 +1791,7 @@ interface GridCellProps<T = Record<string, CellValue>> {
|
|
|
1786
1791
|
/**
|
|
1787
1792
|
* DataGrid Component
|
|
1788
1793
|
*/
|
|
1789
|
-
declare function DataGrid<T = Record<string, CellValue>>({ data, columns, getRowKey, resizableColumns, virtualized, stickyHeader, showTooltips, tooltipMinLength, enableKeyboardNavigation, showColumnBorders, enableInternalSorting, enableInternalFiltering, sorting: controlledSorting, onSortChange, filters: controlledFilters, onFilterChange, columnWidths: controlledColumnWidths, onColumnResize, onColumnResizeStart, onColumnResizeEnd, defaultSorting, defaultFilters, defaultColumnWidths, onStateChange, onRowClick, onRowDoubleClick, selectedRows, onSelectedRowsChange, rowClassName, onCellEdit, onCellEditStart, onCellEditCancel, focusedCell: controlledFocusedCell, onFocusedCellChange, pagination, search, loading, loadingComponent, emptyMessage, emptyComponent, className, tableClassName, infiniteScroll, onLoadMore, hasMore, loadingMore, }: DataGridProps<T>): react_jsx_runtime.JSX.Element;
|
|
1794
|
+
declare function DataGrid<T = Record<string, CellValue>>({ data, columns, getRowKey, resizableColumns, virtualized, stickyHeader, showTooltips, tooltipMinLength, enableKeyboardNavigation, showColumnBorders, fillWidth, enableInternalSorting, enableInternalFiltering, sorting: controlledSorting, onSortChange, filters: controlledFilters, onFilterChange, columnWidths: controlledColumnWidths, onColumnResize, onColumnResizeStart, onColumnResizeEnd, defaultSorting, defaultFilters, defaultColumnWidths, onStateChange, onRowClick, onRowDoubleClick, selectedRows, onSelectedRowsChange, rowClassName, onCellEdit, onCellEditStart, onCellEditCancel, focusedCell: controlledFocusedCell, onFocusedCellChange, pagination, search, loading, loadingComponent, emptyMessage, emptyComponent, className, tableClassName, infiniteScroll, onLoadMore, hasMore, loadingMore, }: DataGridProps<T>): react_jsx_runtime.JSX.Element;
|
|
1790
1795
|
|
|
1791
1796
|
interface HeaderCellProps<T = any> {
|
|
1792
1797
|
/** Column definition */
|
|
@@ -1801,6 +1806,8 @@ interface HeaderCellProps<T = any> {
|
|
|
1801
1806
|
filter?: FilterConfig;
|
|
1802
1807
|
/** Whether this column is resizable */
|
|
1803
1808
|
isResizable: boolean;
|
|
1809
|
+
/** Whether fillWidth mode is active */
|
|
1810
|
+
fillWidth?: boolean;
|
|
1804
1811
|
/** Callback when sort is toggled */
|
|
1805
1812
|
onSort?: () => void;
|
|
1806
1813
|
/** Callback when filter changes */
|
|
@@ -1815,7 +1822,7 @@ interface HeaderCellProps<T = any> {
|
|
|
1815
1822
|
/**
|
|
1816
1823
|
* HeaderCell Component
|
|
1817
1824
|
*/
|
|
1818
|
-
declare function HeaderCell<T = any>({ column, columnIndex, width, sorting, filter, isResizable, onSort, onFilterChange, onResizeMouseDown, onResizeDoubleClick, isResizing, }: HeaderCellProps<T>): react_jsx_runtime.JSX.Element;
|
|
1825
|
+
declare function HeaderCell<T = any>({ column, columnIndex, width, sorting, filter, isResizable, fillWidth, onSort, onFilterChange, onResizeMouseDown, onResizeDoubleClick, isResizing, }: HeaderCellProps<T>): react_jsx_runtime.JSX.Element;
|
|
1819
1826
|
|
|
1820
1827
|
interface FilterPopoverProps<T = Record<string, CellValue>> {
|
|
1821
1828
|
/** Column definition */
|
|
@@ -2019,6 +2026,12 @@ interface UseColumnResizeManagerOptions<T = any> {
|
|
|
2019
2026
|
onColumnResizeStart?: (columnKey: string) => void;
|
|
2020
2027
|
/** Callback when resize ends */
|
|
2021
2028
|
onColumnResizeEnd?: (columnKey: string, width: number) => void;
|
|
2029
|
+
/** Whether fillWidth mode is active */
|
|
2030
|
+
fillWidth?: boolean;
|
|
2031
|
+
/** Measured container width for fillWidth redistribution */
|
|
2032
|
+
containerWidth?: number;
|
|
2033
|
+
/** Effective column widths (after fillWidth scaling) */
|
|
2034
|
+
effectiveColumnWidths?: Record<string, number>;
|
|
2022
2035
|
}
|
|
2023
2036
|
interface UseColumnResizeManagerReturn {
|
|
2024
2037
|
/** Currently resizing column key */
|
package/dist/index.js
CHANGED
|
@@ -3434,6 +3434,7 @@ function HeaderCell({
|
|
|
3434
3434
|
sorting,
|
|
3435
3435
|
filter,
|
|
3436
3436
|
isResizable,
|
|
3437
|
+
fillWidth,
|
|
3437
3438
|
onSort,
|
|
3438
3439
|
onFilterChange,
|
|
3439
3440
|
onResizeMouseDown,
|
|
@@ -3477,7 +3478,8 @@ function HeaderCell({
|
|
|
3477
3478
|
"div",
|
|
3478
3479
|
{
|
|
3479
3480
|
className: cn(
|
|
3480
|
-
"relative
|
|
3481
|
+
"relative border-r border-border last:border-r-0",
|
|
3482
|
+
!fillWidth && "flex-shrink-0",
|
|
3481
3483
|
"bg-muted select-none",
|
|
3482
3484
|
isResizing && "bg-accent/20"
|
|
3483
3485
|
),
|
|
@@ -4417,11 +4419,15 @@ function useColumnResizeManager(options) {
|
|
|
4417
4419
|
resizableColumns,
|
|
4418
4420
|
onColumnResize,
|
|
4419
4421
|
onColumnResizeStart,
|
|
4420
|
-
onColumnResizeEnd
|
|
4422
|
+
onColumnResizeEnd,
|
|
4423
|
+
fillWidth,
|
|
4424
|
+
containerWidth,
|
|
4425
|
+
effectiveColumnWidths
|
|
4421
4426
|
} = options;
|
|
4422
4427
|
const [resizingColumn, setResizingColumn] = useState(null);
|
|
4423
4428
|
const startXRef = useRef(0);
|
|
4424
4429
|
const startWidthRef = useRef(0);
|
|
4430
|
+
const startEffectiveWidthsRef = useRef({});
|
|
4425
4431
|
const getColumn = useCallback(
|
|
4426
4432
|
(columnKey) => {
|
|
4427
4433
|
return columns.find((c) => c.key === columnKey);
|
|
@@ -4445,9 +4451,20 @@ function useColumnResizeManager(options) {
|
|
|
4445
4451
|
resizingColumn,
|
|
4446
4452
|
startWidthRef.current + deltaX
|
|
4447
4453
|
);
|
|
4454
|
+
if (fillWidth && containerWidth) {
|
|
4455
|
+
const otherCols = columns.filter((c) => c.key !== resizingColumn);
|
|
4456
|
+
const startEffective = startEffectiveWidthsRef.current;
|
|
4457
|
+
const otherTotal = otherCols.reduce((s, c) => s + (startEffective[c.key] || 0), 0);
|
|
4458
|
+
const remaining = containerWidth - newWidth;
|
|
4459
|
+
for (const col of otherCols) {
|
|
4460
|
+
const proportion = (startEffective[col.key] || 0) / otherTotal;
|
|
4461
|
+
const adjusted = clampWidth(col.key, Math.floor(remaining * proportion));
|
|
4462
|
+
onColumnResize(col.key, adjusted);
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4448
4465
|
onColumnResize(resizingColumn, newWidth);
|
|
4449
4466
|
},
|
|
4450
|
-
[resizingColumn, clampWidth, onColumnResize]
|
|
4467
|
+
[resizingColumn, clampWidth, onColumnResize, fillWidth, containerWidth, columns]
|
|
4451
4468
|
);
|
|
4452
4469
|
const handleMouseUp = useCallback(() => {
|
|
4453
4470
|
if (!resizingColumn) return;
|
|
@@ -4481,6 +4498,9 @@ function useColumnResizeManager(options) {
|
|
|
4481
4498
|
document.body.style.userSelect = "none";
|
|
4482
4499
|
document.body.style.cursor = "col-resize";
|
|
4483
4500
|
onColumnResizeStart?.(columnKey);
|
|
4501
|
+
if (fillWidth && effectiveColumnWidths) {
|
|
4502
|
+
startEffectiveWidthsRef.current = { ...effectiveColumnWidths };
|
|
4503
|
+
}
|
|
4484
4504
|
};
|
|
4485
4505
|
const handleDoubleClick = (event) => {
|
|
4486
4506
|
if (!isResizable) return;
|
|
@@ -4506,7 +4526,9 @@ function useColumnResizeManager(options) {
|
|
|
4506
4526
|
resizingColumn,
|
|
4507
4527
|
onColumnResize,
|
|
4508
4528
|
onColumnResizeStart,
|
|
4509
|
-
onColumnResizeEnd
|
|
4529
|
+
onColumnResizeEnd,
|
|
4530
|
+
fillWidth,
|
|
4531
|
+
effectiveColumnWidths
|
|
4510
4532
|
]
|
|
4511
4533
|
);
|
|
4512
4534
|
return {
|
|
@@ -4731,6 +4753,7 @@ function DataGrid({
|
|
|
4731
4753
|
tooltipMinLength = 30,
|
|
4732
4754
|
enableKeyboardNavigation = true,
|
|
4733
4755
|
showColumnBorders = true,
|
|
4756
|
+
fillWidth,
|
|
4734
4757
|
enableInternalSorting = true,
|
|
4735
4758
|
enableInternalFiltering = true,
|
|
4736
4759
|
// Controlled sorting
|
|
@@ -4785,6 +4808,26 @@ function DataGrid({
|
|
|
4785
4808
|
const headerRef = React20.useRef(null);
|
|
4786
4809
|
const [headerHeight, setHeaderHeight] = React20.useState(40);
|
|
4787
4810
|
const [hoveredCell, setHoveredCell] = React20.useState(null);
|
|
4811
|
+
const [containerWidth, setContainerWidth] = React20.useState(0);
|
|
4812
|
+
const fillWidthObserverRef = React20.useRef(null);
|
|
4813
|
+
const parentCallbackRef = React20.useCallback(
|
|
4814
|
+
(node) => {
|
|
4815
|
+
fillWidthObserverRef.current?.disconnect();
|
|
4816
|
+
fillWidthObserverRef.current = null;
|
|
4817
|
+
parentRef.current = node;
|
|
4818
|
+
if (!fillWidth || !node) return;
|
|
4819
|
+
const observer = new ResizeObserver((entries) => {
|
|
4820
|
+
const w = entries[0]?.contentRect.width;
|
|
4821
|
+
if (w && w > 0) setContainerWidth(w);
|
|
4822
|
+
});
|
|
4823
|
+
observer.observe(node);
|
|
4824
|
+
fillWidthObserverRef.current = observer;
|
|
4825
|
+
},
|
|
4826
|
+
[fillWidth]
|
|
4827
|
+
);
|
|
4828
|
+
React20.useEffect(() => {
|
|
4829
|
+
return () => fillWidthObserverRef.current?.disconnect();
|
|
4830
|
+
}, []);
|
|
4788
4831
|
const visibleColumns = React20.useMemo(
|
|
4789
4832
|
() => columns.filter((col) => !col.hidden),
|
|
4790
4833
|
[columns]
|
|
@@ -4838,14 +4881,6 @@ function DataGrid({
|
|
|
4838
4881
|
visibleColumns
|
|
4839
4882
|
]);
|
|
4840
4883
|
processedDataRef.current = processedData;
|
|
4841
|
-
const { resizingColumn, getResizeProps } = useColumnResizeManager({
|
|
4842
|
-
columns: visibleColumns,
|
|
4843
|
-
columnWidths: state.columnWidths,
|
|
4844
|
-
resizableColumns,
|
|
4845
|
-
onColumnResize: actions.setColumnWidth,
|
|
4846
|
-
onColumnResizeStart,
|
|
4847
|
-
onColumnResizeEnd
|
|
4848
|
-
});
|
|
4849
4884
|
const shouldVirtualize = virtualized ?? processedData.length > 100;
|
|
4850
4885
|
React20.useLayoutEffect(() => {
|
|
4851
4886
|
if (headerRef.current && shouldVirtualize) {
|
|
@@ -4859,12 +4894,38 @@ function DataGrid({
|
|
|
4859
4894
|
overscan: DEFAULT_OVERSCAN,
|
|
4860
4895
|
enabled: shouldVirtualize
|
|
4861
4896
|
});
|
|
4862
|
-
const tableWidth = React20.useMemo(() => {
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4897
|
+
const { tableWidth, effectiveColumnWidths } = React20.useMemo(() => {
|
|
4898
|
+
const rawWidths = {};
|
|
4899
|
+
let rawTotal = 0;
|
|
4900
|
+
for (const col of visibleColumns) {
|
|
4901
|
+
const w = state.columnWidths[col.key] || col.width || estimateColumnWidth(col);
|
|
4902
|
+
rawWidths[col.key] = w;
|
|
4903
|
+
rawTotal += w;
|
|
4904
|
+
}
|
|
4905
|
+
if (!fillWidth || !containerWidth || rawTotal >= containerWidth) {
|
|
4906
|
+
return { tableWidth: rawTotal, effectiveColumnWidths: rawWidths };
|
|
4907
|
+
}
|
|
4908
|
+
const scale = containerWidth / rawTotal;
|
|
4909
|
+
const scaled = {};
|
|
4910
|
+
for (const col of visibleColumns) {
|
|
4911
|
+
let w = Math.floor(rawWidths[col.key] * scale);
|
|
4912
|
+
if (col.minWidth) w = Math.max(w, col.minWidth);
|
|
4913
|
+
if (col.maxWidth) w = Math.min(w, col.maxWidth);
|
|
4914
|
+
scaled[col.key] = w;
|
|
4915
|
+
}
|
|
4916
|
+
return { tableWidth: containerWidth, effectiveColumnWidths: scaled };
|
|
4917
|
+
}, [visibleColumns, state.columnWidths, fillWidth, containerWidth]);
|
|
4918
|
+
const { resizingColumn, getResizeProps } = useColumnResizeManager({
|
|
4919
|
+
columns: visibleColumns,
|
|
4920
|
+
columnWidths: state.columnWidths,
|
|
4921
|
+
resizableColumns,
|
|
4922
|
+
onColumnResize: actions.setColumnWidth,
|
|
4923
|
+
onColumnResizeStart,
|
|
4924
|
+
onColumnResizeEnd,
|
|
4925
|
+
fillWidth,
|
|
4926
|
+
containerWidth,
|
|
4927
|
+
effectiveColumnWidths
|
|
4928
|
+
});
|
|
4868
4929
|
const visibleRowCount = React20.useMemo(() => {
|
|
4869
4930
|
if (!parentRef.current) return 10;
|
|
4870
4931
|
return Math.floor(parentRef.current.clientHeight / DEFAULT_ROW_HEIGHT);
|
|
@@ -5069,7 +5130,7 @@ function DataGrid({
|
|
|
5069
5130
|
/* @__PURE__ */ jsx(
|
|
5070
5131
|
"div",
|
|
5071
5132
|
{
|
|
5072
|
-
ref:
|
|
5133
|
+
ref: parentCallbackRef,
|
|
5073
5134
|
className: "flex-1 overflow-auto bg-background relative w-full min-h-0 max-h-full",
|
|
5074
5135
|
style: { contain: "strict" },
|
|
5075
5136
|
children: /* @__PURE__ */ jsxs(
|
|
@@ -5096,7 +5157,7 @@ function DataGrid({
|
|
|
5096
5157
|
},
|
|
5097
5158
|
role: "row",
|
|
5098
5159
|
children: visibleColumns.map((column, colIndex) => {
|
|
5099
|
-
const width =
|
|
5160
|
+
const width = effectiveColumnWidths[column.key];
|
|
5100
5161
|
const resizeProps = getResizeProps(column.key);
|
|
5101
5162
|
return /* @__PURE__ */ jsx(
|
|
5102
5163
|
HeaderCell,
|
|
@@ -5107,6 +5168,7 @@ function DataGrid({
|
|
|
5107
5168
|
sorting: getColumnSort(column.key),
|
|
5108
5169
|
filter: getColumnFilter(column.key),
|
|
5109
5170
|
isResizable: resizableColumns && column.resizable !== false,
|
|
5171
|
+
fillWidth,
|
|
5110
5172
|
onSort: () => handleSort(column.key),
|
|
5111
5173
|
onFilterChange: (filter) => handleFilterChange(column.key, filter),
|
|
5112
5174
|
onResizeMouseDown: resizeProps.handleMouseDown,
|
|
@@ -5155,7 +5217,7 @@ function DataGrid({
|
|
|
5155
5217
|
"aria-rowindex": virtualRow.index + 1,
|
|
5156
5218
|
"aria-selected": isSelected,
|
|
5157
5219
|
children: visibleColumns.map((column, colIndex) => {
|
|
5158
|
-
const width =
|
|
5220
|
+
const width = effectiveColumnWidths[column.key];
|
|
5159
5221
|
const isEditingThisCell = state.editingCell?.rowIndex === virtualRow.index && state.editingCell?.columnKey === column.key;
|
|
5160
5222
|
const isFocused = state.focusedCell?.rowIndex === virtualRow.index && state.focusedCell?.columnKey === column.key;
|
|
5161
5223
|
const cellContent = renderCell(
|
|
@@ -5170,7 +5232,8 @@ function DataGrid({
|
|
|
5170
5232
|
"div",
|
|
5171
5233
|
{
|
|
5172
5234
|
className: cn(
|
|
5173
|
-
"
|
|
5235
|
+
"px-3 py-2 text-sm overflow-hidden",
|
|
5236
|
+
!fillWidth && "flex-shrink-0",
|
|
5174
5237
|
showColumnBorders && "border-r border-border last:border-r-0",
|
|
5175
5238
|
isFocused && !isEditingThisCell && "ring-2 ring-inset ring-primary",
|
|
5176
5239
|
isEditingThisCell && "ring-2 ring-inset ring-primary bg-background",
|
|
@@ -5282,7 +5345,7 @@ function DataGrid({
|
|
|
5282
5345
|
}
|
|
5283
5346
|
)
|
|
5284
5347
|
] }) }),
|
|
5285
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-auto min-h-0", children: [
|
|
5348
|
+
/* @__PURE__ */ jsxs("div", { ref: parentCallbackRef, className: "flex-1 overflow-auto min-h-0", children: [
|
|
5286
5349
|
/* @__PURE__ */ jsx(
|
|
5287
5350
|
"div",
|
|
5288
5351
|
{
|
|
@@ -5293,7 +5356,7 @@ function DataGrid({
|
|
|
5293
5356
|
style: { width: tableWidth ? `${tableWidth}px` : "100%" },
|
|
5294
5357
|
role: "row",
|
|
5295
5358
|
children: visibleColumns.map((column, colIndex) => {
|
|
5296
|
-
const width =
|
|
5359
|
+
const width = effectiveColumnWidths[column.key];
|
|
5297
5360
|
const resizeProps = getResizeProps(column.key);
|
|
5298
5361
|
return /* @__PURE__ */ jsx(
|
|
5299
5362
|
HeaderCell,
|
|
@@ -5304,6 +5367,7 @@ function DataGrid({
|
|
|
5304
5367
|
sorting: getColumnSort(column.key),
|
|
5305
5368
|
filter: getColumnFilter(column.key),
|
|
5306
5369
|
isResizable: resizableColumns && column.resizable !== false,
|
|
5370
|
+
fillWidth,
|
|
5307
5371
|
onSort: () => handleSort(column.key),
|
|
5308
5372
|
onFilterChange: (filter) => handleFilterChange(column.key, filter),
|
|
5309
5373
|
onResizeMouseDown: resizeProps.handleMouseDown,
|
|
@@ -5333,14 +5397,15 @@ function DataGrid({
|
|
|
5333
5397
|
onDoubleClick: () => onRowDoubleClick?.(row, rowIndex),
|
|
5334
5398
|
role: "row",
|
|
5335
5399
|
children: visibleColumns.map((column) => {
|
|
5336
|
-
const width =
|
|
5400
|
+
const width = effectiveColumnWidths[column.key];
|
|
5337
5401
|
const isEditingThisCell = state.editingCell?.rowIndex === rowIndex && state.editingCell?.columnKey === column.key;
|
|
5338
5402
|
const isFocused = state.focusedCell?.rowIndex === rowIndex && state.focusedCell?.columnKey === column.key;
|
|
5339
5403
|
return /* @__PURE__ */ jsx(
|
|
5340
5404
|
"div",
|
|
5341
5405
|
{
|
|
5342
5406
|
className: cn(
|
|
5343
|
-
"
|
|
5407
|
+
"px-3 py-2 text-sm overflow-hidden",
|
|
5408
|
+
!fillWidth && "flex-shrink-0",
|
|
5344
5409
|
showColumnBorders && "border-r border-border last:border-r-0",
|
|
5345
5410
|
isFocused && !isEditingThisCell && "ring-2 ring-inset ring-primary",
|
|
5346
5411
|
isEditingThisCell && "ring-2 ring-inset ring-primary bg-background",
|