@coldsmirk/ledger-mantine 0.10.0 → 0.10.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 +169 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +170 -48
- package/dist/index.js.map +1 -1
- package/dist/styles.css +23 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { ActionIcon, Box, Button, Center, Checkbox, CloseButton, EmptyState, Gro
|
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AutoScroller, Cursor, PointerActivationConstraints, PreventSelection } from "@dnd-kit/dom";
|
|
9
|
-
import { memo, startTransition, useCallback, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
9
|
+
import { createElement, memo, startTransition, useCallback, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
10
10
|
import { useDebouncedCallback, useUncontrolled } from "@mantine/hooks";
|
|
11
11
|
import { aggregationFn_count, aggregationFn_extent, aggregationFn_first, aggregationFn_last, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, cellSpanningFeature, columnFacetingFeature, columnFilteringFeature, columnGroupingFeature, columnOrderingFeature, columnPinningFeature, columnSizingFeature, columnVisibilityFeature, createColumnHelper as createColumnHelper$1, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_between, filterFn_betweenInclusive, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_notEmpty, filterFn_startsWith, filterFn_weakEquals, flexRender, flexRender as flexRender$1, functionalUpdate, globalFilteringFeature, rowAggregationFeature, rowExpandingFeature, rowPaginationFeature, rowPinningFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, tableFeatures, useTable } from "@tanstack/react-table";
|
|
12
12
|
import { measureElement, useVirtualizer } from "@tanstack/react-virtual";
|
|
@@ -428,8 +428,11 @@ function useRowReorder({ onRowReorder, labels, viewportRef, getCenterRows, nameR
|
|
|
428
428
|
body.append(rowClone);
|
|
429
429
|
ghostTable.append(colgroup, body);
|
|
430
430
|
element.replaceChildren(ghostTable);
|
|
431
|
-
const
|
|
432
|
-
|
|
431
|
+
const sourceStyle = getComputedStyle(source);
|
|
432
|
+
for (const variable of ["--ledger-body-bg", "--ledger-border-color"]) {
|
|
433
|
+
const value = sourceStyle.getPropertyValue(variable).trim();
|
|
434
|
+
if (value !== "") element.style.setProperty(variable, value);
|
|
435
|
+
}
|
|
433
436
|
const rowRect = source.getBoundingClientRect();
|
|
434
437
|
ghostOrigin.current = {
|
|
435
438
|
x: rowRect.left - ghostPosition.current.x,
|
|
@@ -2241,12 +2244,64 @@ function useColumnWindow({ enabled, overscan, viewport, centerColumnIds, widths,
|
|
|
2241
2244
|
]);
|
|
2242
2245
|
}
|
|
2243
2246
|
/**
|
|
2244
|
-
*
|
|
2245
|
-
*
|
|
2247
|
+
* What each rendered col holds, in colgroup order: a column, a spacer standing for the columns a
|
|
2248
|
+
* window left out, or the filler (docs/sizing.md#the-filler). Its length is what a full-width
|
|
2249
|
+
* cell (detail panel, loader row) spans; a row with no cells of its own (the skeleton) draws one
|
|
2250
|
+
* cell per entry.
|
|
2251
|
+
*/
|
|
2252
|
+
function renderedCols(view, leafColumnCount, pinnedEndCount, filler) {
|
|
2253
|
+
const columns = (count) => Array.from({ length: count }, () => "column");
|
|
2254
|
+
const fillerCol = filler ? ["filler"] : [];
|
|
2255
|
+
if (view === null) return [
|
|
2256
|
+
...columns(leafColumnCount - pinnedEndCount),
|
|
2257
|
+
...fillerCol,
|
|
2258
|
+
...columns(pinnedEndCount)
|
|
2259
|
+
];
|
|
2260
|
+
return [
|
|
2261
|
+
...columns(view.pinnedStartCount),
|
|
2262
|
+
...view.start > 0 ? ["spacer"] : [],
|
|
2263
|
+
...columns(view.end - view.start),
|
|
2264
|
+
...view.end < view.centerCount ? ["spacer"] : [],
|
|
2265
|
+
...fillerCol,
|
|
2266
|
+
...columns(view.pinnedEndCount)
|
|
2267
|
+
];
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Where the filler's cell stands in a row (docs/sizing.md#the-filler): before the first cell of
|
|
2271
|
+
* the end-pinned zone — so after the scrolling columns and a trailing spacer — or last where no
|
|
2272
|
+
* column is pinned to the end. The same index in every row, since every row tiles one colgroup.
|
|
2246
2273
|
*/
|
|
2247
|
-
function
|
|
2248
|
-
|
|
2249
|
-
return
|
|
2274
|
+
function fillerIndex(cells, inEndZone) {
|
|
2275
|
+
const index = cells.findIndex((cell) => inEndZone(cell));
|
|
2276
|
+
return index === -1 ? cells.length : index;
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* A row's rendered cells with the filler's cell put in its place (`fillerIndex`) — a `td`, or a
|
|
2280
|
+
* `th` in the header — or as they are where the row carries none. The cell is empty and, like a
|
|
2281
|
+
* spacer's, out of the accessibility tree: no cell of the ARIA table.
|
|
2282
|
+
*/
|
|
2283
|
+
function withFillerCell(cells, filler) {
|
|
2284
|
+
const nodes = cells.map((cell) => cell.node);
|
|
2285
|
+
if (filler === null) return nodes;
|
|
2286
|
+
const at = fillerIndex(cells, (cell) => cell.endZone);
|
|
2287
|
+
const fillerCell = createElement(filler, {
|
|
2288
|
+
key: "ledger:filler",
|
|
2289
|
+
"aria-hidden": true,
|
|
2290
|
+
"data-ledger-filler": true
|
|
2291
|
+
});
|
|
2292
|
+
return [
|
|
2293
|
+
...nodes.slice(0, at),
|
|
2294
|
+
fillerCell,
|
|
2295
|
+
...nodes.slice(at)
|
|
2296
|
+
];
|
|
2297
|
+
}
|
|
2298
|
+
/**
|
|
2299
|
+
* A header or footer cell's zone is its own leaves': v9 splits a group at every pinning
|
|
2300
|
+
* boundary, so each instance covers one zone — while the group column's `getIsPinned()` answers
|
|
2301
|
+
* for all its leaves at once, and would put a group's scrolling half in the end zone.
|
|
2302
|
+
*/
|
|
2303
|
+
function headerInEndZone(header) {
|
|
2304
|
+
return header.getLeafHeaders()[0]?.column.getIsPinned() === "end";
|
|
2250
2305
|
}
|
|
2251
2306
|
/**
|
|
2252
2307
|
* A leaf-level row's cells against the window. `cells` is the full display-ordered list, so a
|
|
@@ -2652,7 +2707,7 @@ function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan,
|
|
|
2652
2707
|
children: content
|
|
2653
2708
|
});
|
|
2654
2709
|
}
|
|
2655
|
-
function DataRowImpl({ row, dataIndex, last, rowsBelow, editingColumnId, editingRow, dragging, dropSide, selected, active, activatable, expanded, depth, spanning, columnWindow, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
|
|
2710
|
+
function DataRowImpl({ row, dataIndex, last, rowsBelow, editingColumnId, editingRow, dragging, dropSide, selected, active, activatable, expanded, depth, spanning, columnWindow, filler, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
|
|
2656
2711
|
const { getStyles, onRowClick, onRowActivate, onRowDoubleClick, onRowContextMenu, rowProps, activeRowEnabled, setActiveRow } = useDataTableContext();
|
|
2657
2712
|
const cells = row.getVisibleCells();
|
|
2658
2713
|
const firstDataCellIndex = cells.findIndex((cell) => !isInternalColumn(cell.column.id));
|
|
@@ -2707,26 +2762,40 @@ function DataRowImpl({ row, dataIndex, last, rowsBelow, editingColumnId, editing
|
|
|
2707
2762
|
rowSpan: spanning ? cell.getRowSpan() : 1
|
|
2708
2763
|
}, cell.id);
|
|
2709
2764
|
};
|
|
2710
|
-
|
|
2765
|
+
const placed = (cell, displayIndex) => {
|
|
2766
|
+
return {
|
|
2767
|
+
node: renderCell(cell, displayIndex),
|
|
2768
|
+
endZone: cell.column.getIsPinned() === "end"
|
|
2769
|
+
};
|
|
2770
|
+
};
|
|
2771
|
+
const fillerCell = filler ? "td" : null;
|
|
2772
|
+
if (columnWindow === null) return withFillerCell(cells.map((cell, index) => placed(cell, index)), fillerCell);
|
|
2711
2773
|
const segments = windowRowCells(cells, columnWindow);
|
|
2712
2774
|
const windowedStart = columnWindow.pinnedStartCount + columnWindow.start;
|
|
2713
2775
|
const trailingStart = cells.length - columnWindow.pinnedEndCount;
|
|
2714
|
-
return
|
|
2715
|
-
segments.leading.map((cell, index) =>
|
|
2716
|
-
columnWindow.start > 0
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
columnWindow.end < columnWindow.centerCount && /* @__PURE__ */ jsx("td", {
|
|
2722
|
-
"aria-hidden": true,
|
|
2723
|
-
"data-ledger-spacer": true
|
|
2724
|
-
}),
|
|
2725
|
-
segments.trailing.map((cell, index) => renderCell(cell, trailingStart + index))
|
|
2726
|
-
] });
|
|
2776
|
+
return withFillerCell([
|
|
2777
|
+
...segments.leading.map((cell, index) => placed(cell, index)),
|
|
2778
|
+
...columnWindow.start > 0 ? [spacerCell("leading")] : [],
|
|
2779
|
+
...segments.windowed.map((cell, index) => placed(cell, windowedStart + index)),
|
|
2780
|
+
...columnWindow.end < columnWindow.centerCount ? [spacerCell("trailing")] : [],
|
|
2781
|
+
...segments.trailing.map((cell, index) => placed(cell, trailingStart + index))
|
|
2782
|
+
], fillerCell);
|
|
2727
2783
|
}
|
|
2728
2784
|
}
|
|
2729
2785
|
const DataRow = memo(DataRowImpl);
|
|
2786
|
+
/**
|
|
2787
|
+
* A spacer's cell over a spacer col (docs/virtualization.md#column-virtualization), placed in its
|
|
2788
|
+
* row as the scrolling columns' — never the end zone's.
|
|
2789
|
+
*/
|
|
2790
|
+
function spacerCell(edge) {
|
|
2791
|
+
return {
|
|
2792
|
+
node: /* @__PURE__ */ jsx("td", {
|
|
2793
|
+
"aria-hidden": true,
|
|
2794
|
+
"data-ledger-spacer": true
|
|
2795
|
+
}, `ledger:spacer-${edge}`),
|
|
2796
|
+
endZone: false
|
|
2797
|
+
};
|
|
2798
|
+
}
|
|
2730
2799
|
function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, last, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
|
|
2731
2800
|
const { getStyles } = useDataTableContext();
|
|
2732
2801
|
const pinnedStyle = pinnedPosition === "top" ? { top: `${pinnedOffset ?? 0}px` } : pinnedPosition === "bottom" ? { bottom: `${pinnedOffset ?? 0}px` } : void 0;
|
|
@@ -2750,15 +2819,15 @@ function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, last,
|
|
|
2750
2819
|
})
|
|
2751
2820
|
});
|
|
2752
2821
|
}
|
|
2753
|
-
function SkeletonRows({ rowCount,
|
|
2822
|
+
function SkeletonRows({ rowCount, cols, ariaRowIndexStart }) {
|
|
2754
2823
|
const { getStyles } = useDataTableContext();
|
|
2755
2824
|
return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: rowCount }, (_, rowIndex) => /* @__PURE__ */ jsx(Table.Tr, {
|
|
2756
2825
|
"aria-rowindex": ariaRowIndexStart === void 0 ? void 0 : ariaRowIndexStart + rowIndex,
|
|
2757
2826
|
"data-last": rowIndex === rowCount - 1 || void 0,
|
|
2758
2827
|
role: "row",
|
|
2759
2828
|
...getStyles("row"),
|
|
2760
|
-
children:
|
|
2761
|
-
"data-leading":
|
|
2829
|
+
children: cols.map((col, colIndex) => col === "column" ? /* @__PURE__ */ jsx(Table.Td, {
|
|
2830
|
+
"data-leading": colIndex === 0 || void 0,
|
|
2762
2831
|
role: "cell",
|
|
2763
2832
|
...getStyles("cell"),
|
|
2764
2833
|
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
@@ -2766,7 +2835,13 @@ function SkeletonRows({ rowCount, columnCount, ariaRowIndexStart }) {
|
|
|
2766
2835
|
my: "calc((1lh - 10px) / 2)",
|
|
2767
2836
|
radius: "sm"
|
|
2768
2837
|
})
|
|
2769
|
-
},
|
|
2838
|
+
}, colIndex) : col === "spacer" ? /* @__PURE__ */ jsx("td", {
|
|
2839
|
+
"aria-hidden": true,
|
|
2840
|
+
"data-ledger-spacer": true
|
|
2841
|
+
}, colIndex) : /* @__PURE__ */ jsx("td", {
|
|
2842
|
+
"aria-hidden": true,
|
|
2843
|
+
"data-ledger-filler": true
|
|
2844
|
+
}, colIndex))
|
|
2770
2845
|
}, rowIndex)) });
|
|
2771
2846
|
}
|
|
2772
2847
|
function LoaderRow({ colSpan, ariaRowIndex }) {
|
|
@@ -2817,7 +2892,7 @@ function LoadMoreErrorRow({ colSpan, message, ariaRowIndex, onRetry }) {
|
|
|
2817
2892
|
})
|
|
2818
2893
|
});
|
|
2819
2894
|
}
|
|
2820
|
-
function TableBody({ table, virtualization, columnWindow, viewportRef, loading, loadingMore, loadMoreError, onLoadMoreRetry, reorderSourceId, reorderTarget, skeletonRowCount, onVirtualizerChange }) {
|
|
2895
|
+
function TableBody({ table, virtualization, columnWindow, filler, viewportRef, loading, loadingMore, loadMoreError, onLoadMoreRetry, reorderSourceId, reorderTarget, skeletonRowCount, onVirtualizerChange }) {
|
|
2821
2896
|
const { getStyles, withColumnHeaders } = useDataTableContext();
|
|
2822
2897
|
const ledger = table.options.meta?.ledger;
|
|
2823
2898
|
const withDetailPanels = Boolean(ledger?.renderDetailPanel);
|
|
@@ -2864,8 +2939,8 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
|
|
|
2864
2939
|
virtualizer,
|
|
2865
2940
|
onVirtualizerChange
|
|
2866
2941
|
]);
|
|
2867
|
-
const
|
|
2868
|
-
const fullWidthColSpan =
|
|
2942
|
+
const cols = renderedCols(columnWindow, table.getVisibleLeafColumns().length, table.getEndVisibleLeafColumns().length, filler);
|
|
2943
|
+
const fullWidthColSpan = cols.length;
|
|
2869
2944
|
const totalDisplayRowCount = topDisplayRows.length + centerDisplayRows.length + bottomDisplayRows.length;
|
|
2870
2945
|
const canCommitCell = Boolean(ledger?.onEditCommit);
|
|
2871
2946
|
const canCommitRow = Boolean(ledger?.onRowEditCommit);
|
|
@@ -2893,7 +2968,7 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
|
|
|
2893
2968
|
...getStyles("tbody"),
|
|
2894
2969
|
children: /* @__PURE__ */ jsx(SkeletonRows, {
|
|
2895
2970
|
ariaRowIndexStart: virtualEnabled ? headerRowCount + 1 : void 0,
|
|
2896
|
-
|
|
2971
|
+
cols,
|
|
2897
2972
|
rowCount: skeletonRowCount
|
|
2898
2973
|
})
|
|
2899
2974
|
});
|
|
@@ -2946,6 +3021,7 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
|
|
|
2946
3021
|
dropSide,
|
|
2947
3022
|
editingRow: editingRowId === row.id && (ledger?.editing.row.active(row.id) ?? false),
|
|
2948
3023
|
expanded: row.getIsExpanded(),
|
|
3024
|
+
filler,
|
|
2949
3025
|
last,
|
|
2950
3026
|
measureRef: options.measureRef,
|
|
2951
3027
|
pinKey,
|
|
@@ -3037,7 +3113,7 @@ function visibleFooterGroups(table) {
|
|
|
3037
3113
|
function tableHasFooter(table) {
|
|
3038
3114
|
return visibleFooterGroups(table).length > 0;
|
|
3039
3115
|
}
|
|
3040
|
-
function TableFooter({ table, ariaRowIndexStart, columnWindow }) {
|
|
3116
|
+
function TableFooter({ table, ariaRowIndexStart, columnWindow, filler }) {
|
|
3041
3117
|
const { getStyles, footerRowProps } = useDataTableContext();
|
|
3042
3118
|
const renderCell = (footer, colSpan, ariaColIndex) => /* @__PURE__ */ jsx(Table.Td, {
|
|
3043
3119
|
...mergeElementProps(resolveElementProps(footer.column.columnDef.meta?.footerCellProps, footer), {
|
|
@@ -3060,10 +3136,21 @@ function TableFooter({ table, ariaRowIndexStart, columnWindow }) {
|
|
|
3060
3136
|
role: "row",
|
|
3061
3137
|
...getStyles("footerRow")
|
|
3062
3138
|
}),
|
|
3063
|
-
children: columnWindow === null ? footerGroup.headers.map((footer) =>
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3139
|
+
children: withFillerCell(columnWindow === null ? footerGroup.headers.map((footer) => {
|
|
3140
|
+
return {
|
|
3141
|
+
node: renderCell(footer, void 0, void 0),
|
|
3142
|
+
endZone: headerInEndZone(footer)
|
|
3143
|
+
};
|
|
3144
|
+
}) : windowHeaderCells(footerGroup.headers, columnWindow).map((cell) => cell.kind === "spacer" ? {
|
|
3145
|
+
node: /* @__PURE__ */ jsx("td", {
|
|
3146
|
+
"aria-hidden": true,
|
|
3147
|
+
"data-ledger-spacer": true
|
|
3148
|
+
}, `ledger:spacer-${cell.edge}`),
|
|
3149
|
+
endZone: false
|
|
3150
|
+
} : {
|
|
3151
|
+
node: renderCell(cell.header, cell.colSpan, cell.ariaColIndex),
|
|
3152
|
+
endZone: headerInEndZone(cell.header)
|
|
3153
|
+
}), filler ? "td" : null)
|
|
3067
3154
|
}, footerGroup.id))
|
|
3068
3155
|
});
|
|
3069
3156
|
}
|
|
@@ -3669,7 +3756,7 @@ function useColumnResize(setColumnSizing) {
|
|
|
3669
3756
|
* which carries whatever render pass ran last — a discarded one included
|
|
3670
3757
|
* (docs/architecture.md).
|
|
3671
3758
|
*/
|
|
3672
|
-
function TableHeader({ table, columnWidths, columnSizing, columnWindow }) {
|
|
3759
|
+
function TableHeader({ table, columnWidths, columnSizing, columnWindow, filler }) {
|
|
3673
3760
|
const { getStyles, virtualizedRows, headerRowProps } = useDataTableContext();
|
|
3674
3761
|
const reorder = useColumnReorder(table);
|
|
3675
3762
|
const resize = useColumnResize(table.setColumnSizing);
|
|
@@ -3691,10 +3778,21 @@ function TableHeader({ table, columnWidths, columnSizing, columnWindow }) {
|
|
|
3691
3778
|
role: "row",
|
|
3692
3779
|
...getStyles("headerRow")
|
|
3693
3780
|
}),
|
|
3694
|
-
children: columnWindow === null ? headerGroup.headers.map((header) =>
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3781
|
+
children: withFillerCell(columnWindow === null ? headerGroup.headers.map((header) => {
|
|
3782
|
+
return {
|
|
3783
|
+
node: renderCell(header, void 0, void 0),
|
|
3784
|
+
endZone: headerInEndZone(header)
|
|
3785
|
+
};
|
|
3786
|
+
}) : windowHeaderCells(headerGroup.headers, columnWindow).map((cell) => cell.kind === "spacer" ? {
|
|
3787
|
+
node: /* @__PURE__ */ jsx("th", {
|
|
3788
|
+
"aria-hidden": true,
|
|
3789
|
+
"data-ledger-spacer": true
|
|
3790
|
+
}, `ledger:spacer-${cell.edge}`),
|
|
3791
|
+
endZone: false
|
|
3792
|
+
} : {
|
|
3793
|
+
node: renderCell(cell.header, cell.colSpan, cell.ariaColIndex),
|
|
3794
|
+
endZone: headerInEndZone(cell.header)
|
|
3795
|
+
}), filler ? "th" : null)
|
|
3698
3796
|
}, headerGroup.id))
|
|
3699
3797
|
});
|
|
3700
3798
|
}
|
|
@@ -3996,7 +4094,9 @@ function useAutosizeWidths({ columns, columnSizing, main, viewport, rows, appear
|
|
|
3996
4094
|
* by maxSize; when the container is too small every grow column falls back to its basis and the
|
|
3997
4095
|
* table overflows into horizontal scroll;
|
|
3998
4096
|
* - with no grow columns at all, surplus distributes proportionally over every column up to each
|
|
3999
|
-
* maxSize. Hard maximums win over filling the viewport
|
|
4097
|
+
* maxSize. Hard maximums win over filling the viewport: what no column may take is the filler,
|
|
4098
|
+
* an empty col between the scrolling columns and the end-pinned ones that every row carries a
|
|
4099
|
+
* cell of, so the table still spans the viewport (docs/sizing.md#the-filler).
|
|
4000
4100
|
*
|
|
4001
4101
|
* Author sizing comes from the raw-definition registry (`rawColumnSizing`), never from
|
|
4002
4102
|
* `column.columnDef` — TanStack merges `size: 150, minSize: 20` defaults into every resolved
|
|
@@ -4068,7 +4168,8 @@ function resolveColumnWidths(columns, columnSizing, availableWidth) {
|
|
|
4068
4168
|
} else byId[column.id] = clampWidth(sized, column.minSize, column.maxSize);
|
|
4069
4169
|
}
|
|
4070
4170
|
const baseTotal = columns.reduce((total, column) => total + (byId[column.id] ?? 0), 0);
|
|
4071
|
-
const
|
|
4171
|
+
const targetWidth = Number.isFinite(availableWidth) ? Math.max(0, Math.round(availableWidth)) : 0;
|
|
4172
|
+
const surplus = targetWidth - baseTotal;
|
|
4072
4173
|
if (surplus > 0) distributeSurplus(byId, growColumns.length > 0 ? growColumns : columns.map((column) => {
|
|
4073
4174
|
return {
|
|
4074
4175
|
id: column.id,
|
|
@@ -4076,9 +4177,11 @@ function resolveColumnWidths(columns, columnSizing, availableWidth) {
|
|
|
4076
4177
|
max: normalizedBound(column.maxSize)
|
|
4077
4178
|
};
|
|
4078
4179
|
}), surplus);
|
|
4180
|
+
const total = columns.reduce((sum, column) => sum + (byId[column.id] ?? 0), 0);
|
|
4079
4181
|
return {
|
|
4080
4182
|
byId,
|
|
4081
|
-
total
|
|
4183
|
+
total,
|
|
4184
|
+
filler: Math.max(0, targetWidth - total)
|
|
4082
4185
|
};
|
|
4083
4186
|
}
|
|
4084
4187
|
/**
|
|
@@ -4134,7 +4237,11 @@ function useColumnWidths(table, { columns, viewport, tableMinWidth, injectedWidt
|
|
|
4134
4237
|
injectedWidth,
|
|
4135
4238
|
autosizeWidths
|
|
4136
4239
|
]);
|
|
4137
|
-
const signature = JSON.stringify([
|
|
4240
|
+
const signature = JSON.stringify([
|
|
4241
|
+
resolved.total,
|
|
4242
|
+
resolved.filler,
|
|
4243
|
+
Object.entries(resolved.byId)
|
|
4244
|
+
]);
|
|
4138
4245
|
return useMemo(() => resolved, [signature]);
|
|
4139
4246
|
}
|
|
4140
4247
|
//#endregion
|
|
@@ -7158,7 +7265,17 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7158
7265
|
columnWidths,
|
|
7159
7266
|
tableState.columnPinning
|
|
7160
7267
|
]);
|
|
7161
|
-
const
|
|
7268
|
+
const filler = columnWidths.filler > 0;
|
|
7269
|
+
const fillerCol = filler && /* @__PURE__ */ jsx("col", {
|
|
7270
|
+
"data-ledger-filler": true,
|
|
7271
|
+
style: { width: columnWidths.filler }
|
|
7272
|
+
}, "ledger:filler");
|
|
7273
|
+
const endCols = pinnedEndCount === 0 ? [] : visibleLeafColumns.slice(-pinnedEndCount).map((column) => leafCol(column));
|
|
7274
|
+
const colElements = columnWindow === null ? [
|
|
7275
|
+
...visibleLeafColumns.slice(0, visibleLeafColumns.length - pinnedEndCount).map((column) => leafCol(column)),
|
|
7276
|
+
fillerCol,
|
|
7277
|
+
...endCols
|
|
7278
|
+
] : [
|
|
7162
7279
|
...visibleLeafColumns.slice(0, pinnedStartCount).map((column) => leafCol(column)),
|
|
7163
7280
|
columnWindow.start > 0 && /* @__PURE__ */ jsx("col", {
|
|
7164
7281
|
"data-ledger-spacer": true,
|
|
@@ -7169,7 +7286,8 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7169
7286
|
"data-ledger-spacer": true,
|
|
7170
7287
|
style: { width: columnWindow.trailingSpace }
|
|
7171
7288
|
}, "ledger:spacer-trailing"),
|
|
7172
|
-
|
|
7289
|
+
fillerCol,
|
|
7290
|
+
...endCols
|
|
7173
7291
|
];
|
|
7174
7292
|
const rowsLength = table.getRowModel().rows.length;
|
|
7175
7293
|
const errorActive = Boolean(error) && !loading;
|
|
@@ -7514,8 +7632,9 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7514
7632
|
tabularNums,
|
|
7515
7633
|
verticalSpacing: verticalSpacing ?? scale.verticalSpacing
|
|
7516
7634
|
};
|
|
7635
|
+
const tableWidth = columnWidths.total + columnWidths.filler;
|
|
7517
7636
|
const tableStyleProps = () => getStyles("table", { style: {
|
|
7518
|
-
width:
|
|
7637
|
+
width: tableWidth > 0 ? tableWidth : void 0,
|
|
7519
7638
|
minWidth: toPx(tableMinWidth),
|
|
7520
7639
|
borderCollapse: "separate",
|
|
7521
7640
|
borderSpacing: 0,
|
|
@@ -7639,6 +7758,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7639
7758
|
columnSizing: tableState.columnSizing,
|
|
7640
7759
|
columnWidths: columnWidths.byId,
|
|
7641
7760
|
columnWindow,
|
|
7761
|
+
filler,
|
|
7642
7762
|
table: erasedTable
|
|
7643
7763
|
})]
|
|
7644
7764
|
})
|
|
@@ -7670,6 +7790,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7670
7790
|
...tableStyleProps(),
|
|
7671
7791
|
children: [/* @__PURE__ */ jsx("colgroup", { children: colElements }), /* @__PURE__ */ jsx(TableBody, {
|
|
7672
7792
|
columnWindow,
|
|
7793
|
+
filler,
|
|
7673
7794
|
loading: loading === true,
|
|
7674
7795
|
loadingMore: loadingMore === true,
|
|
7675
7796
|
loadMoreError: loadMoreError ?? false,
|
|
@@ -7751,6 +7872,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
|
|
|
7751
7872
|
children: [/* @__PURE__ */ jsx("colgroup", { children: colElements }), /* @__PURE__ */ jsx(TableFooter, {
|
|
7752
7873
|
ariaRowIndexStart: virtualEnabled ? footerAriaRowIndexStart : void 0,
|
|
7753
7874
|
columnWindow,
|
|
7875
|
+
filler,
|
|
7754
7876
|
table: erasedTable
|
|
7755
7877
|
})]
|
|
7756
7878
|
})
|