@coldsmirk/ledger-mantine 0.9.2 → 0.10.1

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.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";
@@ -1096,6 +1096,7 @@ const defaultLabels = {
1096
1096
  ungroupColumn: "Ungroup",
1097
1097
  columnWidth: "Width",
1098
1098
  columnWidthAuto: "Auto",
1099
+ columnWidthFit: "Fit",
1099
1100
  resizeColumn: "Drag to resize; double-click to fit content",
1100
1101
  reorderColumn: "Drag to reorder column",
1101
1102
  filterColumn: (column) => `Filter ${column}`,
@@ -1332,6 +1333,7 @@ function ColumnsPanelItem({ column, table, labels, icons, index, zone, orderable
1332
1333
  const canGroup = table.options.enableGrouping === true && column.getCanGroup();
1333
1334
  const width = table.atoms.columnSizing.get()[column.id];
1334
1335
  const declaredWidth = rawColumnSizing(column.columnDef)?.size ?? table.options.defaultColumn?.size;
1336
+ const widthPlaceholder = column.columnDef.meta?.autosize === true ? labels.columnWidthFit : declaredWidth === void 0 ? labels.columnWidthAuto : String(declaredWidth);
1335
1337
  const handleWidthChange = (value) => {
1336
1338
  table.setColumnSizing((previous) => {
1337
1339
  if (value === "") {
@@ -1393,7 +1395,7 @@ function ColumnsPanelItem({ column, table, labels, icons, index, zone, orderable
1393
1395
  classNames: { input: "ledger-columns-panel-width-input" },
1394
1396
  max: column.columnDef.maxSize,
1395
1397
  min: column.columnDef.minSize,
1396
- placeholder: declaredWidth === void 0 ? labels.columnWidthAuto : String(declaredWidth),
1398
+ placeholder: widthPlaceholder,
1397
1399
  size: "xs",
1398
1400
  startValue: declaredWidth,
1399
1401
  step: 10,
@@ -2239,12 +2241,64 @@ function useColumnWindow({ enabled, overscan, viewport, centerColumnIds, widths,
2239
2241
  ]);
2240
2242
  }
2241
2243
  /**
2242
- * Rendered column count including the spacer cols — what a full-width cell (detail panel,
2243
- * loader row) spans.
2244
+ * What each rendered col holds, in colgroup order: a column, a spacer standing for the columns a
2245
+ * window left out, or the filler (docs/sizing.md#the-filler). Its length is what a full-width
2246
+ * cell (detail panel, loader row) spans; a row with no cells of its own (the skeleton) draws one
2247
+ * cell per entry.
2244
2248
  */
2245
- function renderedColCount(view, leafColumnCount) {
2246
- if (view === null) return leafColumnCount;
2247
- return view.pinnedStartCount + (view.end - view.start) + view.pinnedEndCount + (view.start > 0 ? 1 : 0) + (view.end < view.centerCount ? 1 : 0);
2249
+ function renderedCols(view, leafColumnCount, pinnedEndCount, filler) {
2250
+ const columns = (count) => Array.from({ length: count }, () => "column");
2251
+ const fillerCol = filler ? ["filler"] : [];
2252
+ if (view === null) return [
2253
+ ...columns(leafColumnCount - pinnedEndCount),
2254
+ ...fillerCol,
2255
+ ...columns(pinnedEndCount)
2256
+ ];
2257
+ return [
2258
+ ...columns(view.pinnedStartCount),
2259
+ ...view.start > 0 ? ["spacer"] : [],
2260
+ ...columns(view.end - view.start),
2261
+ ...view.end < view.centerCount ? ["spacer"] : [],
2262
+ ...fillerCol,
2263
+ ...columns(view.pinnedEndCount)
2264
+ ];
2265
+ }
2266
+ /**
2267
+ * Where the filler's cell stands in a row (docs/sizing.md#the-filler): before the first cell of
2268
+ * the end-pinned zone — so after the scrolling columns and a trailing spacer — or last where no
2269
+ * column is pinned to the end. The same index in every row, since every row tiles one colgroup.
2270
+ */
2271
+ function fillerIndex(cells, inEndZone) {
2272
+ const index = cells.findIndex((cell) => inEndZone(cell));
2273
+ return index === -1 ? cells.length : index;
2274
+ }
2275
+ /**
2276
+ * A row's rendered cells with the filler's cell put in its place (`fillerIndex`) — a `td`, or a
2277
+ * `th` in the header — or as they are where the row carries none. The cell is empty and, like a
2278
+ * spacer's, out of the accessibility tree: no cell of the ARIA table.
2279
+ */
2280
+ function withFillerCell(cells, filler) {
2281
+ const nodes = cells.map((cell) => cell.node);
2282
+ if (filler === null) return nodes;
2283
+ const at = fillerIndex(cells, (cell) => cell.endZone);
2284
+ const fillerCell = createElement(filler, {
2285
+ key: "ledger:filler",
2286
+ "aria-hidden": true,
2287
+ "data-ledger-filler": true
2288
+ });
2289
+ return [
2290
+ ...nodes.slice(0, at),
2291
+ fillerCell,
2292
+ ...nodes.slice(at)
2293
+ ];
2294
+ }
2295
+ /**
2296
+ * A header or footer cell's zone is its own leaves': v9 splits a group at every pinning
2297
+ * boundary, so each instance covers one zone — while the group column's `getIsPinned()` answers
2298
+ * for all its leaves at once, and would put a group's scrolling half in the end zone.
2299
+ */
2300
+ function headerInEndZone(header) {
2301
+ return header.getLeafHeaders()[0]?.column.getIsPinned() === "end";
2248
2302
  }
2249
2303
  /**
2250
2304
  * A leaf-level row's cells against the window. `cells` is the full display-ordered list, so a
@@ -2650,7 +2704,7 @@ function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan,
2650
2704
  children: content
2651
2705
  });
2652
2706
  }
2653
- function DataRowImpl({ row, dataIndex, last, rowsBelow, editingColumnId, editingRow, dragging, dropSide, selected, active, activatable, expanded, depth, spanning, columnWindow, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
2707
+ function DataRowImpl({ row, dataIndex, last, rowsBelow, editingColumnId, editingRow, dragging, dropSide, selected, active, activatable, expanded, depth, spanning, columnWindow, filler, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
2654
2708
  const { getStyles, onRowClick, onRowActivate, onRowDoubleClick, onRowContextMenu, rowProps, activeRowEnabled, setActiveRow } = useDataTableContext();
2655
2709
  const cells = row.getVisibleCells();
2656
2710
  const firstDataCellIndex = cells.findIndex((cell) => !isInternalColumn(cell.column.id));
@@ -2705,26 +2759,40 @@ function DataRowImpl({ row, dataIndex, last, rowsBelow, editingColumnId, editing
2705
2759
  rowSpan: spanning ? cell.getRowSpan() : 1
2706
2760
  }, cell.id);
2707
2761
  };
2708
- if (columnWindow === null) return cells.map((cell, index) => renderCell(cell, index));
2762
+ const placed = (cell, displayIndex) => {
2763
+ return {
2764
+ node: renderCell(cell, displayIndex),
2765
+ endZone: cell.column.getIsPinned() === "end"
2766
+ };
2767
+ };
2768
+ const fillerCell = filler ? "td" : null;
2769
+ if (columnWindow === null) return withFillerCell(cells.map((cell, index) => placed(cell, index)), fillerCell);
2709
2770
  const segments = windowRowCells(cells, columnWindow);
2710
2771
  const windowedStart = columnWindow.pinnedStartCount + columnWindow.start;
2711
2772
  const trailingStart = cells.length - columnWindow.pinnedEndCount;
2712
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2713
- segments.leading.map((cell, index) => renderCell(cell, index)),
2714
- columnWindow.start > 0 && /* @__PURE__ */ jsx("td", {
2715
- "aria-hidden": true,
2716
- "data-ledger-spacer": true
2717
- }),
2718
- segments.windowed.map((cell, index) => renderCell(cell, windowedStart + index)),
2719
- columnWindow.end < columnWindow.centerCount && /* @__PURE__ */ jsx("td", {
2720
- "aria-hidden": true,
2721
- "data-ledger-spacer": true
2722
- }),
2723
- segments.trailing.map((cell, index) => renderCell(cell, trailingStart + index))
2724
- ] });
2773
+ return withFillerCell([
2774
+ ...segments.leading.map((cell, index) => placed(cell, index)),
2775
+ ...columnWindow.start > 0 ? [spacerCell("leading")] : [],
2776
+ ...segments.windowed.map((cell, index) => placed(cell, windowedStart + index)),
2777
+ ...columnWindow.end < columnWindow.centerCount ? [spacerCell("trailing")] : [],
2778
+ ...segments.trailing.map((cell, index) => placed(cell, trailingStart + index))
2779
+ ], fillerCell);
2725
2780
  }
2726
2781
  }
2727
2782
  const DataRow = memo(DataRowImpl);
2783
+ /**
2784
+ * A spacer's cell over a spacer col (docs/virtualization.md#column-virtualization), placed in its
2785
+ * row as the scrolling columns' — never the end zone's.
2786
+ */
2787
+ function spacerCell(edge) {
2788
+ return {
2789
+ node: /* @__PURE__ */ jsx("td", {
2790
+ "aria-hidden": true,
2791
+ "data-ledger-spacer": true
2792
+ }, `ledger:spacer-${edge}`),
2793
+ endZone: false
2794
+ };
2795
+ }
2728
2796
  function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, last, pinnedPosition, pinnedOffset, virtualIndex, measureRef, ariaRowIndex }) {
2729
2797
  const { getStyles } = useDataTableContext();
2730
2798
  const pinnedStyle = pinnedPosition === "top" ? { top: `${pinnedOffset ?? 0}px` } : pinnedPosition === "bottom" ? { bottom: `${pinnedOffset ?? 0}px` } : void 0;
@@ -2748,15 +2816,15 @@ function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, last,
2748
2816
  })
2749
2817
  });
2750
2818
  }
2751
- function SkeletonRows({ rowCount, columnCount, ariaRowIndexStart }) {
2819
+ function SkeletonRows({ rowCount, cols, ariaRowIndexStart }) {
2752
2820
  const { getStyles } = useDataTableContext();
2753
2821
  return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: rowCount }, (_, rowIndex) => /* @__PURE__ */ jsx(Table.Tr, {
2754
2822
  "aria-rowindex": ariaRowIndexStart === void 0 ? void 0 : ariaRowIndexStart + rowIndex,
2755
2823
  "data-last": rowIndex === rowCount - 1 || void 0,
2756
2824
  role: "row",
2757
2825
  ...getStyles("row"),
2758
- children: Array.from({ length: columnCount }, (_, columnIndex) => /* @__PURE__ */ jsx(Table.Td, {
2759
- "data-leading": columnIndex === 0 || void 0,
2826
+ children: cols.map((col, colIndex) => col === "column" ? /* @__PURE__ */ jsx(Table.Td, {
2827
+ "data-leading": colIndex === 0 || void 0,
2760
2828
  role: "cell",
2761
2829
  ...getStyles("cell"),
2762
2830
  children: /* @__PURE__ */ jsx(Skeleton, {
@@ -2764,7 +2832,13 @@ function SkeletonRows({ rowCount, columnCount, ariaRowIndexStart }) {
2764
2832
  my: "calc((1lh - 10px) / 2)",
2765
2833
  radius: "sm"
2766
2834
  })
2767
- }, columnIndex))
2835
+ }, colIndex) : col === "spacer" ? /* @__PURE__ */ jsx("td", {
2836
+ "aria-hidden": true,
2837
+ "data-ledger-spacer": true
2838
+ }, colIndex) : /* @__PURE__ */ jsx("td", {
2839
+ "aria-hidden": true,
2840
+ "data-ledger-filler": true
2841
+ }, colIndex))
2768
2842
  }, rowIndex)) });
2769
2843
  }
2770
2844
  function LoaderRow({ colSpan, ariaRowIndex }) {
@@ -2815,7 +2889,7 @@ function LoadMoreErrorRow({ colSpan, message, ariaRowIndex, onRetry }) {
2815
2889
  })
2816
2890
  });
2817
2891
  }
2818
- function TableBody({ table, virtualization, columnWindow, viewportRef, loading, loadingMore, loadMoreError, onLoadMoreRetry, reorderSourceId, reorderTarget, skeletonRowCount, onVirtualizerChange }) {
2892
+ function TableBody({ table, virtualization, columnWindow, filler, viewportRef, loading, loadingMore, loadMoreError, onLoadMoreRetry, reorderSourceId, reorderTarget, skeletonRowCount, onVirtualizerChange }) {
2819
2893
  const { getStyles, withColumnHeaders } = useDataTableContext();
2820
2894
  const ledger = table.options.meta?.ledger;
2821
2895
  const withDetailPanels = Boolean(ledger?.renderDetailPanel);
@@ -2862,8 +2936,8 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
2862
2936
  virtualizer,
2863
2937
  onVirtualizerChange
2864
2938
  ]);
2865
- const leafColumnCount = table.getVisibleLeafColumns().length;
2866
- const fullWidthColSpan = renderedColCount(columnWindow, leafColumnCount);
2939
+ const cols = renderedCols(columnWindow, table.getVisibleLeafColumns().length, table.getEndVisibleLeafColumns().length, filler);
2940
+ const fullWidthColSpan = cols.length;
2867
2941
  const totalDisplayRowCount = topDisplayRows.length + centerDisplayRows.length + bottomDisplayRows.length;
2868
2942
  const canCommitCell = Boolean(ledger?.onEditCommit);
2869
2943
  const canCommitRow = Boolean(ledger?.onRowEditCommit);
@@ -2891,7 +2965,7 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
2891
2965
  ...getStyles("tbody"),
2892
2966
  children: /* @__PURE__ */ jsx(SkeletonRows, {
2893
2967
  ariaRowIndexStart: virtualEnabled ? headerRowCount + 1 : void 0,
2894
- columnCount: fullWidthColSpan,
2968
+ cols,
2895
2969
  rowCount: skeletonRowCount
2896
2970
  })
2897
2971
  });
@@ -2944,6 +3018,7 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
2944
3018
  dropSide,
2945
3019
  editingRow: editingRowId === row.id && (ledger?.editing.row.active(row.id) ?? false),
2946
3020
  expanded: row.getIsExpanded(),
3021
+ filler,
2947
3022
  last,
2948
3023
  measureRef: options.measureRef,
2949
3024
  pinKey,
@@ -3035,7 +3110,7 @@ function visibleFooterGroups(table) {
3035
3110
  function tableHasFooter(table) {
3036
3111
  return visibleFooterGroups(table).length > 0;
3037
3112
  }
3038
- function TableFooter({ table, ariaRowIndexStart, columnWindow }) {
3113
+ function TableFooter({ table, ariaRowIndexStart, columnWindow, filler }) {
3039
3114
  const { getStyles, footerRowProps } = useDataTableContext();
3040
3115
  const renderCell = (footer, colSpan, ariaColIndex) => /* @__PURE__ */ jsx(Table.Td, {
3041
3116
  ...mergeElementProps(resolveElementProps(footer.column.columnDef.meta?.footerCellProps, footer), {
@@ -3058,42 +3133,85 @@ function TableFooter({ table, ariaRowIndexStart, columnWindow }) {
3058
3133
  role: "row",
3059
3134
  ...getStyles("footerRow")
3060
3135
  }),
3061
- children: columnWindow === null ? footerGroup.headers.map((footer) => renderCell(footer, void 0, void 0)) : windowHeaderCells(footerGroup.headers, columnWindow).map((cell) => cell.kind === "spacer" ? /* @__PURE__ */ jsx("td", {
3062
- "aria-hidden": true,
3063
- "data-ledger-spacer": true
3064
- }, `ledger:spacer-${cell.edge}`) : renderCell(cell.header, cell.colSpan, cell.ariaColIndex))
3136
+ children: withFillerCell(columnWindow === null ? footerGroup.headers.map((footer) => {
3137
+ return {
3138
+ node: renderCell(footer, void 0, void 0),
3139
+ endZone: headerInEndZone(footer)
3140
+ };
3141
+ }) : windowHeaderCells(footerGroup.headers, columnWindow).map((cell) => cell.kind === "spacer" ? {
3142
+ node: /* @__PURE__ */ jsx("td", {
3143
+ "aria-hidden": true,
3144
+ "data-ledger-spacer": true
3145
+ }, `ledger:spacer-${cell.edge}`),
3146
+ endZone: false
3147
+ } : {
3148
+ node: renderCell(cell.header, cell.colSpan, cell.ariaColIndex),
3149
+ endZone: headerInEndZone(cell.header)
3150
+ }), filler ? "td" : null)
3065
3151
  }, footerGroup.id))
3066
3152
  });
3067
3153
  }
3068
3154
  //#endregion
3069
- //#region src/autosize-column.ts
3155
+ //#region src/column-autosize.ts
3070
3156
  /**
3071
- * Fit a column to its rendered content (the resizer's double-click). Measures the header cell,
3072
- * every RENDERED body cell of the column — under virtualization that is the current window, which
3073
- * is the industry contract for autosize (unrendered rows have no boxes to measure) — and the
3074
- * footer cell, which is rendered content the column has to hold like any other. Writes the result
3075
- * through `columnSizing`, clamped like an interactive resize.
3157
+ * Fitting columns to their rendered content (docs/sizing.md#autosize) — one measurement behind
3158
+ * both of its uses: the resizer's double-click, which writes the fit as a `columnSizing` entry,
3159
+ * and `meta.autosize`, which keeps a column fitted as its content changes (`use-autosize-widths.ts`).
3076
3160
  *
3077
- * The column, its constraints and whether it carries a filter all arrive from the render that put
3078
- * the handle on screen, for the reason `use-column-resize.ts` gives.
3161
+ * What is measured is what the column has to hold: the header cell, every RENDERED body cell —
3162
+ * under virtualization that is the current window, the industry contract for autosize (unrendered
3163
+ * rows have no boxes to measure) — and the footer cell, which is rendered content like any other.
3164
+ * A cell that spans columns (a merged body cell, a footer total, a detail panel) says nothing about
3165
+ * the width of any one of them, and a cell holding an editor is as wide as the editor makes
3166
+ * itself, not as its value; neither is measured.
3079
3167
  *
3080
3168
  * A content cell is measured out of the table's layout: for the pass it is a block as wide as its
3081
3169
  * content (`display: block; width: max-content`, no wrapping), so its width is the content's, in
3082
3170
  * whichever direction that lies. Read in place, a cell is never narrower than its column — a fixed
3083
3171
  * table lays every cell at the column's width, and a truncating span clips at it — so a fit could
3084
- * only ever widen a column. Every cell is switched first and read afterwards, so the whole pass
3085
- * costs one reflow, and each gets its own inline styles back before anything paints.
3172
+ * only ever widen a column. Every cell of every column is switched first and read afterwards, so a
3173
+ * pass costs one reflow however many columns it fits, and each cell gets its own inline styles back
3174
+ * before anything paints.
3086
3175
  */
3087
3176
  /**
3088
3177
  * Breathing room over the tightest fit — content flush against the column edge reads clipped.
3089
3178
  */
3090
3179
  const AUTOSIZE_SLACK_PX = 8;
3091
3180
  /**
3092
- * Reserved for the hover-revealed header actions overlay (the filter button) so autosize does
3093
- * not park the drag line underneath it.
3181
+ * Reserved for the hover-revealed header actions overlay (the filter button) so a fit does not
3182
+ * park the drag line underneath it.
3094
3183
  */
3095
3184
  const HEADER_ACTIONS_ALLOWANCE_PX = 28;
3096
3185
  /**
3186
+ * Tukey's fence: a value past the third quartile by more than this many interquartile ranges is an
3187
+ * outlier. 1.5 is Tukey's own constant and MUI X's `outliersFactor` default.
3188
+ */
3189
+ const OUTLIER_FACTOR = 1.5;
3190
+ /**
3191
+ * Linear interpolation between closest ranks (Hyndman–Fan type 7, the spreadsheet and NumPy
3192
+ * default) over ascending `sorted`.
3193
+ */
3194
+ function quantile(sorted, p) {
3195
+ const rank = (sorted.length - 1) * p;
3196
+ const lower = Math.floor(rank);
3197
+ const below = sorted[lower];
3198
+ const above = sorted[Math.min(lower + 1, sorted.length - 1)];
3199
+ return below + (rank - lower) * (above - below);
3200
+ }
3201
+ /**
3202
+ * The widest of `values` within Tukey's upper fence (Q3 + 1.5 × IQR) — the width that holds every
3203
+ * value but the outliers. A set too uniform to have any (IQR 0) fences at its common value, so a
3204
+ * single long value among identical ones is still the outlier it reads as.
3205
+ */
3206
+ function fencedMax(values) {
3207
+ if (values.length === 0) return 0;
3208
+ const sorted = values.toSorted((a, b) => a - b);
3209
+ const q1 = quantile(sorted, .25);
3210
+ const q3 = quantile(sorted, .75);
3211
+ const fence = q3 + OUTLIER_FACTOR * (q3 - q1);
3212
+ return sorted.findLast((value) => value <= fence) ?? sorted[0];
3213
+ }
3214
+ /**
3097
3215
  * Computed lengths always resolve to `Npx`; strip the unit before coercing.
3098
3216
  */
3099
3217
  function asPx(value) {
@@ -3110,12 +3228,27 @@ function headerCellWidth(th, hasFilter) {
3110
3228
  const indicatorWidth = indicator ? indicator.offsetWidth + 6 : 0;
3111
3229
  return labelText.scrollWidth + indicatorWidth + horizontalPadding(th) + (hasFilter ? HEADER_ACTIONS_ALLOWANCE_PX : 0);
3112
3230
  }
3113
- function autosizeColumn(setColumnSizing, { columnId, minSize, maxSize, hasFilter }, main) {
3114
- const selector = `[data-ledger-column-id="${CSS.escape(columnId)}"]`;
3115
- const headerCell = main.querySelector(`:scope .ledger-header ${selector}`);
3116
- const contentCells = [...main.querySelectorAll(`:scope :is(.ledger-tbody, .ledger-footer) ${selector}`)].filter((cell) => cell.colSpan <= 1);
3117
- const cells = headerCell ? [headerCell, ...contentCells] : contentCells;
3118
- if (cells.length === 0) return;
3231
+ function contentCells(main, region, selector) {
3232
+ return [...main.querySelectorAll(`:scope ${region} ${selector}`)].filter((cell) => cell.colSpan <= 1 && !Object.hasOwn(cell.dataset, "editing"));
3233
+ }
3234
+ /**
3235
+ * The width each target's rendered content needs, slack included, in integer pixels — before the
3236
+ * column's own `minSize`/`maxSize`, which are the caller's to apply. A column with nothing rendered
3237
+ * (one a column window left out) has no entry.
3238
+ */
3239
+ function measureColumnWidths(main, targets) {
3240
+ const columns = targets.map((target) => {
3241
+ const selector = `[data-ledger-column-id="${CSS.escape(target.columnId)}"]`;
3242
+ return {
3243
+ target,
3244
+ header: main.querySelector(`:scope .ledger-header ${selector}`),
3245
+ body: contentCells(main, ".ledger-tbody", selector),
3246
+ footer: contentCells(main, ".ledger-footer", selector)
3247
+ };
3248
+ });
3249
+ const headers = columns.map((column) => column.header).filter((header) => header !== null);
3250
+ const contents = columns.flatMap((column) => [...column.body, ...column.footer]);
3251
+ const cells = [...headers, ...contents];
3119
3252
  const previous = cells.map((cell) => {
3120
3253
  return {
3121
3254
  display: cell.style.display,
@@ -3124,22 +3257,37 @@ function autosizeColumn(setColumnSizing, { columnId, minSize, maxSize, hasFilter
3124
3257
  };
3125
3258
  });
3126
3259
  for (const cell of cells) cell.style.whiteSpace = "nowrap";
3127
- for (const cell of contentCells) {
3260
+ for (const cell of contents) {
3128
3261
  cell.style.display = "block";
3129
3262
  cell.style.width = "max-content";
3130
3263
  }
3131
- let content = headerCell ? headerCellWidth(headerCell, hasFilter) : 0;
3132
- for (const cell of contentCells) content = Math.max(content, cell.scrollWidth);
3264
+ const widths = /* @__PURE__ */ new Map();
3265
+ for (const { target, header, body, footer } of columns) {
3266
+ if (!header && body.length === 0 && footer.length === 0) continue;
3267
+ const bodyWidths = body.map((cell) => cell.scrollWidth);
3268
+ const content = Math.max(header ? headerCellWidth(header, target.hasFilter) : 0, ...footer.map((cell) => cell.scrollWidth), target.truncate ? fencedMax(bodyWidths) : Math.max(0, ...bodyWidths));
3269
+ widths.set(target.columnId, Math.round(content) + AUTOSIZE_SLACK_PX);
3270
+ }
3133
3271
  for (const [index, cell] of cells.entries()) {
3134
3272
  const styles = previous[index];
3135
3273
  cell.style.display = styles?.display ?? "";
3136
3274
  cell.style.whiteSpace = styles?.whiteSpace ?? "";
3137
3275
  cell.style.width = styles?.width ?? "";
3138
3276
  }
3139
- const next = Math.min(Math.max(Math.round(content + AUTOSIZE_SLACK_PX), minSize), maxSize);
3140
- setColumnSizing((previous) => previous[columnId] === next ? previous : {
3277
+ return widths;
3278
+ }
3279
+ /**
3280
+ * The resizer's double-click: fit the column once and write the fit through `columnSizing`, clamped
3281
+ * like an interactive resize. The column, its constraints and whether it carries a filter all
3282
+ * arrive from the render that put the handle on screen, for the reason `use-column-resize.ts` gives.
3283
+ */
3284
+ function autosizeColumn(setColumnSizing, { minSize, maxSize, ...target }, main) {
3285
+ const fitted = measureColumnWidths(main, [target]).get(target.columnId);
3286
+ if (fitted === void 0) return;
3287
+ const next = Math.min(Math.max(fitted, minSize), maxSize);
3288
+ setColumnSizing((previous) => previous[target.columnId] === next ? previous : {
3141
3289
  ...previous,
3142
- [columnId]: next
3290
+ [target.columnId]: next
3143
3291
  });
3144
3292
  }
3145
3293
  //#endregion
@@ -3605,7 +3753,7 @@ function useColumnResize(setColumnSizing) {
3605
3753
  * which carries whatever render pass ran last — a discarded one included
3606
3754
  * (docs/architecture.md).
3607
3755
  */
3608
- function TableHeader({ table, columnWidths, columnSizing, columnWindow }) {
3756
+ function TableHeader({ table, columnWidths, columnSizing, columnWindow, filler }) {
3609
3757
  const { getStyles, virtualizedRows, headerRowProps } = useDataTableContext();
3610
3758
  const reorder = useColumnReorder(table);
3611
3759
  const resize = useColumnResize(table.setColumnSizing);
@@ -3627,10 +3775,21 @@ function TableHeader({ table, columnWidths, columnSizing, columnWindow }) {
3627
3775
  role: "row",
3628
3776
  ...getStyles("headerRow")
3629
3777
  }),
3630
- children: columnWindow === null ? headerGroup.headers.map((header) => renderCell(header, void 0, void 0)) : windowHeaderCells(headerGroup.headers, columnWindow).map((cell) => cell.kind === "spacer" ? /* @__PURE__ */ jsx("th", {
3631
- "aria-hidden": true,
3632
- "data-ledger-spacer": true
3633
- }, `ledger:spacer-${cell.edge}`) : renderCell(cell.header, cell.colSpan, cell.ariaColIndex))
3778
+ children: withFillerCell(columnWindow === null ? headerGroup.headers.map((header) => {
3779
+ return {
3780
+ node: renderCell(header, void 0, void 0),
3781
+ endZone: headerInEndZone(header)
3782
+ };
3783
+ }) : windowHeaderCells(headerGroup.headers, columnWindow).map((cell) => cell.kind === "spacer" ? {
3784
+ node: /* @__PURE__ */ jsx("th", {
3785
+ "aria-hidden": true,
3786
+ "data-ledger-spacer": true
3787
+ }, `ledger:spacer-${cell.edge}`),
3788
+ endZone: false
3789
+ } : {
3790
+ node: renderCell(cell.header, cell.colSpan, cell.ariaColIndex),
3791
+ endZone: headerInEndZone(cell.header)
3792
+ }), filler ? "th" : null)
3634
3793
  }, headerGroup.id))
3635
3794
  });
3636
3795
  }
@@ -3751,7 +3910,8 @@ function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing
3751
3910
  const main = event.currentTarget.closest(".ledger-main");
3752
3911
  if (main) autosizeColumn(table.setColumnSizing, {
3753
3912
  ...resizerSpec,
3754
- hasFilter: meta?.filter !== void 0
3913
+ hasFilter: meta?.filter !== void 0,
3914
+ truncate: meta?.truncate === true
3755
3915
  }, main);
3756
3916
  },
3757
3917
  ...resize.getResizerProps(resizerSpec),
@@ -3762,6 +3922,160 @@ function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing
3762
3922
  });
3763
3923
  }
3764
3924
  //#endregion
3925
+ //#region src/use-autosize-widths.ts
3926
+ /**
3927
+ * `meta.autosize` (docs/sizing.md#autosize): keeps each such column fitted to its rendered content
3928
+ * and hands the width engine the fits, which rank between a user's resize and the author's `size`.
3929
+ *
3930
+ * When a fit is taken, and what it may do:
3931
+ * - **A new view refits.** Different rows (a new page, a filter, a sort — anything that changes the
3932
+ * row ids or their order), new column definitions (a renderer, a translated header) or another
3933
+ * set of visible columns, another density, or a web font that finished loading: the content is
3934
+ * new, so the widths follow it in both directions.
3935
+ * - **The same rows again only widen.** A refetch that hands back the same rows (a poll, an
3936
+ * edit) may make a cell wider, never a column narrower — otherwise a value that alternates
3937
+ * between short and long would shake the columns on every refresh.
3938
+ * - **Content that arrives with a window only widens, once the scrolling settles.** Under
3939
+ * virtualization the rows and columns scrolled into view were never measured; fitting them on
3940
+ * every window shift would reflow the table each step of a scroll, and narrowing would move the
3941
+ * columns under the reader.
3942
+ * - **A table with no layout waits for one.** In a hidden tab or a collapsed panel every cell
3943
+ * measures zero; the fit is taken when the table is first laid out instead.
3944
+ *
3945
+ * A fit is taken in a layout effect, before the browser paints, so a refit never shows the old
3946
+ * widths for a frame; a column a user resized is left to the user's width and not measured.
3947
+ */
3948
+ /**
3949
+ * How long a scroll has to rest before the content it brought into view is fitted.
3950
+ */
3951
+ const SCROLL_SETTLE_MS = 150;
3952
+ const NO_WIDTHS = {};
3953
+ function autosizeTargets(columns, columnSizing) {
3954
+ return columns.flatMap((column) => {
3955
+ const { meta } = column.columnDef;
3956
+ return meta?.autosize === true && !isInternalColumn(column.id) && columnSizing[column.id] === void 0 ? [{
3957
+ columnId: column.id,
3958
+ hasFilter: meta.filter !== void 0,
3959
+ truncate: meta.truncate === true
3960
+ }] : [];
3961
+ });
3962
+ }
3963
+ function sameIds(previous, next) {
3964
+ return previous.length === next.length && previous.every((id, index) => id === next[index]);
3965
+ }
3966
+ /**
3967
+ * The fits after a pass: a column measured takes its new width (in `widen` mode, only if wider), a
3968
+ * column with nothing rendered keeps the width it had, a column no longer fitted drops out.
3969
+ */
3970
+ function mergeWidths(previous, measured, targets, mode) {
3971
+ const next = {};
3972
+ for (const { columnId } of targets) {
3973
+ const fresh = measured.get(columnId);
3974
+ const held = previous[columnId];
3975
+ const width = fresh === void 0 || held === void 0 ? fresh ?? held : mode === "widen" ? Math.max(held, fresh) : fresh;
3976
+ if (width !== void 0) next[columnId] = width;
3977
+ }
3978
+ const keys = Object.keys(next);
3979
+ return keys.length === Object.keys(previous).length && keys.every((key) => previous[key] === next[key]) ? previous : next;
3980
+ }
3981
+ /**
3982
+ * Bumps whenever web fonts finish loading: text measured in a fallback face is the wrong width.
3983
+ */
3984
+ function useFontsVersion(enabled) {
3985
+ const [version, setVersion] = useState(0);
3986
+ useEffect(() => {
3987
+ if (!enabled || !("fonts" in document)) return;
3988
+ const bump = () => setVersion((previous) => previous + 1);
3989
+ document.fonts.addEventListener("loadingdone", bump);
3990
+ return () => document.fonts.removeEventListener("loadingdone", bump);
3991
+ }, [enabled]);
3992
+ return version;
3993
+ }
3994
+ function useAutosizeWidths({ columns, columnSizing, main, viewport, rows, appearance, virtualized }) {
3995
+ const targets = autosizeTargets(columns, columnSizing);
3996
+ const enabled = targets.length > 0;
3997
+ const fontsVersion = useFontsVersion(enabled);
3998
+ const signature = JSON.stringify([
3999
+ targets,
4000
+ appearance,
4001
+ fontsVersion
4002
+ ]);
4003
+ const [widths, setWidths] = useState(NO_WIDTHS);
4004
+ const view = useRef(null);
4005
+ /**
4006
+ * A fit was due while the table had no layout.
4007
+ */
4008
+ const awaitingLayout = useRef(false);
4009
+ const settleTimer = useRef(void 0);
4010
+ const fit = useEventCallback((mode) => {
4011
+ if (!main) return;
4012
+ if (main.getClientRects().length === 0) {
4013
+ awaitingLayout.current = true;
4014
+ return;
4015
+ }
4016
+ awaitingLayout.current = false;
4017
+ const measured = measureColumnWidths(main, targets);
4018
+ setWidths((previous) => mergeWidths(previous, measured, targets, mode));
4019
+ });
4020
+ const fitWhenSettled = useCallback(() => {
4021
+ clearTimeout(settleTimer.current);
4022
+ settleTimer.current = setTimeout(() => fit("widen"), SCROLL_SETTLE_MS);
4023
+ }, [fit]);
4024
+ useEffect(() => () => clearTimeout(settleTimer.current), []);
4025
+ useLayoutEffect(() => {
4026
+ if (!enabled) {
4027
+ view.current = null;
4028
+ setWidths(NO_WIDTHS);
4029
+ return;
4030
+ }
4031
+ const rowIds = rows.map((row) => row.id);
4032
+ const sameView = view.current !== null && view.current.columns === columns && view.current.signature === signature && sameIds(view.current.rowIds, rowIds);
4033
+ view.current = {
4034
+ columns,
4035
+ signature,
4036
+ rowIds
4037
+ };
4038
+ fit(sameView ? "widen" : "refit");
4039
+ }, [
4040
+ enabled,
4041
+ main,
4042
+ columns,
4043
+ rows,
4044
+ signature,
4045
+ fit
4046
+ ]);
4047
+ useEffect(() => {
4048
+ if (enabled && virtualized && widths !== NO_WIDTHS) fitWhenSettled();
4049
+ }, [
4050
+ enabled,
4051
+ virtualized,
4052
+ widths,
4053
+ fitWhenSettled
4054
+ ]);
4055
+ useEffect(() => {
4056
+ if (!enabled || !main) return;
4057
+ const observer = new ResizeObserver(() => {
4058
+ if (awaitingLayout.current) fit("refit");
4059
+ else if (virtualized) fitWhenSettled();
4060
+ });
4061
+ observer.observe(main);
4062
+ if (!virtualized || !viewport) return () => observer.disconnect();
4063
+ viewport.addEventListener("scroll", fitWhenSettled, { passive: true });
4064
+ return () => {
4065
+ observer.disconnect();
4066
+ viewport.removeEventListener("scroll", fitWhenSettled);
4067
+ };
4068
+ }, [
4069
+ enabled,
4070
+ main,
4071
+ viewport,
4072
+ virtualized,
4073
+ fit,
4074
+ fitWhenSettled
4075
+ ]);
4076
+ return widths;
4077
+ }
4078
+ //#endregion
3765
4079
  //#region src/use-column-widths.ts
3766
4080
  /**
3767
4081
  * The width engine (docs/sizing.md): every visible leaf column resolves to an exact integer
@@ -3769,14 +4083,17 @@ function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing
3769
4083
  * number system — the browser never redistributes anything.
3770
4084
  *
3771
4085
  * Rules, in order:
3772
- * - a column with an explicit width (user-resized `columnSizing` entry, else the author's
3773
- * `size`, else `defaultColumn.size`) is fixed at that width, clamped to its declared min/max;
4086
+ * - a column with an explicit width (user-resized `columnSizing` entry, else its fitted content
4087
+ * width under `meta.autosize`, else the author's `size`, else `defaultColumn.size`) is fixed at
4088
+ * that width, clamped to its declared min/max;
3774
4089
  * - a column without one is a grow column with basis `minSize ?? 80`; container surplus is
3775
4090
  * distributed proportionally to the bases (integer floor, remainder in display order), capped
3776
4091
  * by maxSize; when the container is too small every grow column falls back to its basis and the
3777
4092
  * table overflows into horizontal scroll;
3778
4093
  * - with no grow columns at all, surplus distributes proportionally over every column up to each
3779
- * maxSize. Hard maximums win over filling the viewport.
4094
+ * maxSize. Hard maximums win over filling the viewport: what no column may take is the filler,
4095
+ * an empty col between the scrolling columns and the end-pinned ones that every row carries a
4096
+ * cell of, so the table still spans the viewport (docs/sizing.md#the-filler).
3780
4097
  *
3781
4098
  * Author sizing comes from the raw-definition registry (`rawColumnSizing`), never from
3782
4099
  * `column.columnDef` — TanStack merges `size: 150, minSize: 20` defaults into every resolved
@@ -3836,7 +4153,7 @@ function resolveColumnWidths(columns, columnSizing, availableWidth) {
3836
4153
  const byId = {};
3837
4154
  const growColumns = [];
3838
4155
  for (const column of columns) {
3839
- const sized = finiteNumber(columnSizing[column.id]) ?? finiteNumber(column.size);
4156
+ const sized = finiteNumber(columnSizing[column.id]) ?? finiteNumber(column.fit) ?? finiteNumber(column.size);
3840
4157
  if (sized === void 0) {
3841
4158
  const basis = clampWidth(column.minSize ?? DEFAULT_FLEX_BASIS, column.minSize, column.maxSize);
3842
4159
  byId[column.id] = basis;
@@ -3848,7 +4165,8 @@ function resolveColumnWidths(columns, columnSizing, availableWidth) {
3848
4165
  } else byId[column.id] = clampWidth(sized, column.minSize, column.maxSize);
3849
4166
  }
3850
4167
  const baseTotal = columns.reduce((total, column) => total + (byId[column.id] ?? 0), 0);
3851
- const surplus = (Number.isFinite(availableWidth) ? Math.max(0, Math.round(availableWidth)) : 0) - baseTotal;
4168
+ const targetWidth = Number.isFinite(availableWidth) ? Math.max(0, Math.round(availableWidth)) : 0;
4169
+ const surplus = targetWidth - baseTotal;
3852
4170
  if (surplus > 0) distributeSurplus(byId, growColumns.length > 0 ? growColumns : columns.map((column) => {
3853
4171
  return {
3854
4172
  id: column.id,
@@ -3856,9 +4174,11 @@ function resolveColumnWidths(columns, columnSizing, availableWidth) {
3856
4174
  max: normalizedBound(column.maxSize)
3857
4175
  };
3858
4176
  }), surplus);
4177
+ const total = columns.reduce((sum, column) => sum + (byId[column.id] ?? 0), 0);
3859
4178
  return {
3860
4179
  byId,
3861
- total: columns.reduce((sum, column) => sum + (byId[column.id] ?? 0), 0)
4180
+ total,
4181
+ filler: Math.max(0, targetWidth - total)
3862
4182
  };
3863
4183
  }
3864
4184
  /**
@@ -3872,7 +4192,7 @@ function minWidthPx(tableMinWidth, viewport) {
3872
4192
  if (!tableElement) return Number.parseFloat(tableMinWidth) || 0;
3873
4193
  return Number.parseFloat(getComputedStyle(tableElement).minWidth) || 0;
3874
4194
  }
3875
- function useColumnWidths(table, columns, viewport, tableMinWidth, injectedWidth) {
4195
+ function useColumnWidths(table, { columns, viewport, tableMinWidth, injectedWidth, autosizeWidths }) {
3876
4196
  const [availableWidth, setAvailableWidth] = useState(0);
3877
4197
  const measure = useCallback(() => {
3878
4198
  if (!viewport) return;
@@ -3893,12 +4213,14 @@ function useColumnWidths(table, columns, viewport, tableMinWidth, injectedWidth)
3893
4213
  const raw = rawColumnSizing(column.columnDef);
3894
4214
  if (isInternalColumn(column.id)) return {
3895
4215
  id: column.id,
4216
+ fit: void 0,
3896
4217
  size: raw?.size ?? injectedWidth,
3897
4218
  minSize: raw?.minSize ?? injectedWidth,
3898
4219
  maxSize: raw?.maxSize ?? injectedWidth
3899
4220
  };
3900
4221
  return {
3901
4222
  id: column.id,
4223
+ fit: autosizeWidths[column.id],
3902
4224
  size: raw ? raw.size ?? defaultColumn?.size : column.columnDef.size,
3903
4225
  minSize: raw ? raw.minSize ?? defaultColumn?.minSize : column.columnDef.minSize,
3904
4226
  maxSize: raw ? raw.maxSize ?? defaultColumn?.maxSize : column.columnDef.maxSize
@@ -3909,9 +4231,14 @@ function useColumnWidths(table, columns, viewport, tableMinWidth, injectedWidth)
3909
4231
  columnSizing,
3910
4232
  availableWidth,
3911
4233
  defaultColumn,
3912
- injectedWidth
4234
+ injectedWidth,
4235
+ autosizeWidths
4236
+ ]);
4237
+ const signature = JSON.stringify([
4238
+ resolved.total,
4239
+ resolved.filler,
4240
+ Object.entries(resolved.byId)
3913
4241
  ]);
3914
- const signature = JSON.stringify([resolved.total, Object.entries(resolved.byId)]);
3915
4242
  return useMemo(() => resolved, [signature]);
3916
4243
  }
3917
4244
  //#endregion
@@ -6817,6 +7144,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
6817
7144
  setViewport(element);
6818
7145
  }, []);
6819
7146
  const viewportFit = useViewportFit(viewport);
7147
+ const [main, setMain] = useState(null);
6820
7148
  const startLeafColumns = table.getStartVisibleLeafColumns();
6821
7149
  const endLeafColumns = table.getEndVisibleLeafColumns();
6822
7150
  const displayColumns = [
@@ -6831,7 +7159,21 @@ function DataTableCore({ presentation, stylesProps, table }) {
6831
7159
  const visibleLeafColumns = useMemo(() => displayColumns, [displayOrderSignature, ledgerColumns]);
6832
7160
  const size = sizeProp ?? "sm";
6833
7161
  const scale = SIZES[size];
6834
- const columnWidths = useColumnWidths(table, visibleLeafColumns, viewport, tableMinWidth, scale.injectedWidth);
7162
+ const columnWidths = useColumnWidths(table, {
7163
+ autosizeWidths: useAutosizeWidths({
7164
+ appearance: size,
7165
+ columnSizing: table.state.columnSizing,
7166
+ columns: visibleLeafColumns,
7167
+ main,
7168
+ rows: table.getRowModel().rows,
7169
+ viewport,
7170
+ virtualized: Boolean(virtualizedRows) || Boolean(virtualizedColumns)
7171
+ }),
7172
+ columns: visibleLeafColumns,
7173
+ injectedWidth: scale.injectedWidth,
7174
+ tableMinWidth,
7175
+ viewport
7176
+ });
6835
7177
  const virtualization = virtualizedRows ? {
6836
7178
  estimateHeight: typeof virtualizedRows === "object" && virtualizedRows.estimateHeight !== void 0 ? virtualizedRows.estimateHeight : scale.rowHeight,
6837
7179
  overscan: typeof virtualizedRows === "object" && virtualizedRows.overscan !== void 0 ? virtualizedRows.overscan : 8
@@ -6920,7 +7262,17 @@ function DataTableCore({ presentation, stylesProps, table }) {
6920
7262
  columnWidths,
6921
7263
  tableState.columnPinning
6922
7264
  ]);
6923
- const colElements = columnWindow === null ? visibleLeafColumns.map((column) => leafCol(column)) : [
7265
+ const filler = columnWidths.filler > 0;
7266
+ const fillerCol = filler && /* @__PURE__ */ jsx("col", {
7267
+ "data-ledger-filler": true,
7268
+ style: { width: columnWidths.filler }
7269
+ }, "ledger:filler");
7270
+ const endCols = pinnedEndCount === 0 ? [] : visibleLeafColumns.slice(-pinnedEndCount).map((column) => leafCol(column));
7271
+ const colElements = columnWindow === null ? [
7272
+ ...visibleLeafColumns.slice(0, visibleLeafColumns.length - pinnedEndCount).map((column) => leafCol(column)),
7273
+ fillerCol,
7274
+ ...endCols
7275
+ ] : [
6924
7276
  ...visibleLeafColumns.slice(0, pinnedStartCount).map((column) => leafCol(column)),
6925
7277
  columnWindow.start > 0 && /* @__PURE__ */ jsx("col", {
6926
7278
  "data-ledger-spacer": true,
@@ -6931,7 +7283,8 @@ function DataTableCore({ presentation, stylesProps, table }) {
6931
7283
  "data-ledger-spacer": true,
6932
7284
  style: { width: columnWindow.trailingSpace }
6933
7285
  }, "ledger:spacer-trailing"),
6934
- ...pinnedEndCount === 0 ? [] : visibleLeafColumns.slice(-pinnedEndCount).map((column) => leafCol(column))
7286
+ fillerCol,
7287
+ ...endCols
6935
7288
  ];
6936
7289
  const rowsLength = table.getRowModel().rows.length;
6937
7290
  const errorActive = Boolean(error) && !loading;
@@ -7276,8 +7629,9 @@ function DataTableCore({ presentation, stylesProps, table }) {
7276
7629
  tabularNums,
7277
7630
  verticalSpacing: verticalSpacing ?? scale.verticalSpacing
7278
7631
  };
7632
+ const tableWidth = columnWidths.total + columnWidths.filler;
7279
7633
  const tableStyleProps = () => getStyles("table", { style: {
7280
- width: columnWidths.total > 0 ? columnWidths.total : void 0,
7634
+ width: tableWidth > 0 ? tableWidth : void 0,
7281
7635
  minWidth: toPx(tableMinWidth),
7282
7636
  borderCollapse: "separate",
7283
7637
  borderSpacing: 0,
@@ -7381,6 +7735,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
7381
7735
  children: labels.rowNavigation
7382
7736
  })] }),
7383
7737
  /* @__PURE__ */ jsxs("div", {
7738
+ ref: setMain,
7384
7739
  "aria-busy": loading || void 0,
7385
7740
  "aria-colcount": columnWindow === null ? void 0 : columnWindow.totalLeafCount,
7386
7741
  "aria-describedby": ariaDescribedBy,
@@ -7400,6 +7755,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
7400
7755
  columnSizing: tableState.columnSizing,
7401
7756
  columnWidths: columnWidths.byId,
7402
7757
  columnWindow,
7758
+ filler,
7403
7759
  table: erasedTable
7404
7760
  })]
7405
7761
  })
@@ -7431,6 +7787,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
7431
7787
  ...tableStyleProps(),
7432
7788
  children: [/* @__PURE__ */ jsx("colgroup", { children: colElements }), /* @__PURE__ */ jsx(TableBody, {
7433
7789
  columnWindow,
7790
+ filler,
7434
7791
  loading: loading === true,
7435
7792
  loadingMore: loadingMore === true,
7436
7793
  loadMoreError: loadMoreError ?? false,
@@ -7512,6 +7869,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
7512
7869
  children: [/* @__PURE__ */ jsx("colgroup", { children: colElements }), /* @__PURE__ */ jsx(TableFooter, {
7513
7870
  ariaRowIndexStart: virtualEnabled ? footerAriaRowIndexStart : void 0,
7514
7871
  columnWindow,
7872
+ filler,
7515
7873
  table: erasedTable
7516
7874
  })]
7517
7875
  })