@coldsmirk/ledger-mantine 0.8.1 → 0.9.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.d.cts CHANGED
@@ -881,7 +881,7 @@ declare module "@tanstack/react-table" {
881
881
  /**
882
882
  * DOM props for this column's footer cell — static, or per footer.
883
883
  */
884
- footerCellProps?: DataTableElementProps<Omit<TableThProps, "ref">, Header<TData, TValue>>;
884
+ footerCellProps?: DataTableElementProps<Omit<TableTdProps, "ref">, Header<TData, TValue>>;
885
885
  /**
886
886
  * `toCsv` column control: `false` excludes the column; an object overrides the exported
887
887
  * header text or derives the exported value.
@@ -1009,9 +1009,10 @@ interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesAp
1009
1009
  withColumnBorders?: boolean;
1010
1010
  withRowBorders?: boolean;
1011
1011
  /**
1012
- * The closing line under the last row — and under a footer — for a table that stands alone
1013
- * without a frame. Mantine's `Table` leaves the last row open, so this is off by default; the
1014
- * `withTableBorder` frame closes the table itself and ignores it (docs/styling.md#borders).
1012
+ * The closing line on the body's bottom edge — and under a footer — for a table that stands
1013
+ * alone without a frame. Mantine's `Table` leaves a last row on that edge open, so this is off
1014
+ * by default; the `withTableBorder` frame closes the table itself and ignores it
1015
+ * (docs/styling.md#borders).
1015
1016
  */
1016
1017
  withBottomBorder?: boolean;
1017
1018
  borderColor?: MantineColor;
package/dist/index.d.ts CHANGED
@@ -881,7 +881,7 @@ declare module "@tanstack/react-table" {
881
881
  /**
882
882
  * DOM props for this column's footer cell — static, or per footer.
883
883
  */
884
- footerCellProps?: DataTableElementProps<Omit<TableThProps, "ref">, Header<TData, TValue>>;
884
+ footerCellProps?: DataTableElementProps<Omit<TableTdProps, "ref">, Header<TData, TValue>>;
885
885
  /**
886
886
  * `toCsv` column control: `false` excludes the column; an object overrides the exported
887
887
  * header text or derives the exported value.
@@ -1009,9 +1009,10 @@ interface DataTableBaseProps<TData extends RowData$1> extends BoxProps, StylesAp
1009
1009
  withColumnBorders?: boolean;
1010
1010
  withRowBorders?: boolean;
1011
1011
  /**
1012
- * The closing line under the last row — and under a footer — for a table that stands alone
1013
- * without a frame. Mantine's `Table` leaves the last row open, so this is off by default; the
1014
- * `withTableBorder` frame closes the table itself and ignores it (docs/styling.md#borders).
1012
+ * The closing line on the body's bottom edge — and under a footer — for a table that stands
1013
+ * alone without a frame. Mantine's `Table` leaves a last row on that edge open, so this is off
1014
+ * by default; the `withTableBorder` frame closes the table itself and ignores it
1015
+ * (docs/styling.md#borders).
1015
1016
  */
1016
1017
  withBottomBorder?: boolean;
1017
1018
  borderColor?: MantineColor;
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { AutoScroller, Cursor, PointerActivationConstraints, PreventSelection }
9
9
  import { 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
- import { useVirtualizer } from "@tanstack/react-virtual";
12
+ import { measureElement, useVirtualizer } from "@tanstack/react-virtual";
13
13
  import { DatePicker } from "@mantine/dates";
14
14
  //#region src/context.ts
15
15
  /**
@@ -597,6 +597,7 @@ function RowDragCell({ row, table }) {
597
597
  "aria-pressed": lifted || void 0,
598
598
  color: "gray",
599
599
  size: SIZES[size].control,
600
+ style: { cursor: orderable ? "grab" : "default" },
600
601
  variant: "subtle",
601
602
  onBlur: () => {
602
603
  if (lifted) rowReorderKeyboard?.cancel();
@@ -617,6 +618,7 @@ function RowDragCell({ row, table }) {
617
618
  * display order from the shared core when the click arrives, which is whatever render pass ran
618
619
  * last. The controller answers from the commit instead (`use-row-commands.ts`).
619
620
  */
621
+ const CONTROL_CLASS_NAMES = { body: "ledger-selection-control" };
620
622
  function noop() {}
621
623
  function SelectionHeaderCell({ table }) {
622
624
  const { labels, selection, size } = useDataTableContext();
@@ -627,6 +629,7 @@ function SelectionHeaderCell({ table }) {
627
629
  return /* @__PURE__ */ jsx(Checkbox, {
628
630
  "aria-label": labels.selectAllRows,
629
631
  checked: allSelected,
632
+ classNames: CONTROL_CLASS_NAMES,
630
633
  indeterminate: !allSelected && someSelected,
631
634
  size: SIZES[size].control,
632
635
  onChange: noop,
@@ -646,6 +649,7 @@ function SelectionCell({ row }) {
646
649
  if (row.getCanMultiSelect() === false) return /* @__PURE__ */ jsx(Radio, {
647
650
  "aria-label": labels.selectRow,
648
651
  checked: selected,
652
+ classNames: CONTROL_CLASS_NAMES,
649
653
  disabled: !row.getCanSelect(),
650
654
  name: `${instanceId}-selection`,
651
655
  size: SIZES[size].control,
@@ -655,6 +659,7 @@ function SelectionCell({ row }) {
655
659
  return /* @__PURE__ */ jsx(Checkbox, {
656
660
  "aria-label": labels.selectRow,
657
661
  checked: selected,
662
+ classNames: CONTROL_CLASS_NAMES,
658
663
  disabled: !row.getCanSelect(),
659
664
  indeterminate: !selected && row.getIsSomeSelected(),
660
665
  size: SIZES[size].control,
@@ -1356,6 +1361,7 @@ function ColumnsPanelItem({ column, table, labels, icons, index, zone, orderable
1356
1361
  className: "ledger-columns-panel-handle",
1357
1362
  color: "gray",
1358
1363
  size: "sm",
1364
+ style: { cursor: isDragging ? "grabbing" : "grab" },
1359
1365
  variant: "subtle",
1360
1366
  children: /* @__PURE__ */ jsx(icons.reorderColumn, {})
1361
1367
  })
@@ -1675,7 +1681,8 @@ function PaginationBarCore({ table, labels, pageSizeOptions, size, className, st
1675
1681
  children: labels.paginationSummary(from, to, total)
1676
1682
  }), /* @__PURE__ */ jsxs(Group, {
1677
1683
  gap: "md",
1678
- wrap: "nowrap",
1684
+ justify: "flex-end",
1685
+ wrap: "wrap",
1679
1686
  children: [/* @__PURE__ */ jsxs(Group, {
1680
1687
  gap: "xs",
1681
1688
  wrap: "nowrap",
@@ -1683,6 +1690,7 @@ function PaginationBarCore({ table, labels, pageSizeOptions, size, className, st
1683
1690
  c: "var(--ledger-color-dimmed)",
1684
1691
  id: pageSizeLabelId,
1685
1692
  size,
1693
+ style: { whiteSpace: "nowrap" },
1686
1694
  children: labels.rowsPerPage
1687
1695
  }, "label"), /* @__PURE__ */ jsx(Select, {
1688
1696
  allowDeselect: false,
@@ -1861,7 +1869,7 @@ function cellValue(cell) {
1861
1869
  */
1862
1870
  function canEditWith(row, edit, gate) {
1863
1871
  if (!gate.enableEditing || !gate.hasCommitHandler) return false;
1864
- if (!edit) return false;
1872
+ if (!edit || row.getIsGrouped()) return false;
1865
1873
  return !(typeof edit === "object" && edit.enabled && !edit.enabled(row));
1866
1874
  }
1867
1875
  /**
@@ -2428,6 +2436,15 @@ const TREE_INDENT_PX = 20;
2428
2436
  const DEFAULT_ESTIMATED_ROW_HEIGHT = SIZES.sm.rowHeight;
2429
2437
  const DEFAULT_OVERSCAN = 8;
2430
2438
  /**
2439
+ * A row's height as layout has it, fractions included. TanStack Virtual rounds every measurement
2440
+ * to the pixel, and a row is seldom a whole number of pixels tall (Mantine's line height is 1.55):
2441
+ * each measured row then counted up to half a pixel wrong, the virtualizer's idea of where a row
2442
+ * starts drifted from the DOM by that much per row, and `scrollToRow` landed its row a few pixels
2443
+ * under the header. The resize entry's border box is exact. Without an entry (a row mounting) the
2444
+ * default answers from its cache or the element, and the entry that follows corrects it.
2445
+ */
2446
+ const measureRow = (element, entry, instance) => entry?.borderBoxSize[0]?.blockSize ?? measureElement(element, entry, instance);
2447
+ /**
2431
2448
  * Whether any leaf definition declares a merge — the gate that keeps span-index reads (and the
2432
2449
  * per-row span signature) entirely out of tables that never span.
2433
2450
  */
@@ -2569,9 +2586,10 @@ function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan,
2569
2586
  const editMode = ledger?.editing.mode ?? "cell";
2570
2587
  const { meta } = column.columnDef;
2571
2588
  const grouped = cell.getIsGrouped();
2572
- const aggregated = cell.getIsAggregated() && row.getIsGrouped();
2573
- const placeholder = cell.getIsPlaceholder();
2574
- const gateOpen = !grouped && !aggregated && !placeholder && canEditCell(cell, row);
2589
+ const groupRow = row.getIsGrouped();
2590
+ const aggregated = cell.getIsAggregated() && groupRow;
2591
+ const empty = cell.getIsPlaceholder() || groupRow && !grouped && !aggregated && !isInternalColumn(column.id);
2592
+ const gateOpen = !empty && canEditCell(cell, row);
2575
2593
  const editable = !editing && gateOpen;
2576
2594
  const cellEditorActive = editing && gateOpen;
2577
2595
  const rowEditorActive = rowEditing && gateOpen;
@@ -2579,8 +2597,8 @@ function DataCell({ cell, editing, rowEditing, isFirstDataCell, depth, rowSpan,
2579
2597
  const instantEdit = normalizedEdit?.kind === "instant" ? normalizedEdit : null;
2580
2598
  let content;
2581
2599
  if (grouped) content = /* @__PURE__ */ jsx(GroupCell, { cell });
2582
- else if (aggregated) content = flexRender$1(column.columnDef.aggregatedCell ?? column.columnDef.cell, cell.getContext());
2583
- else if (placeholder) content = null;
2600
+ else if (aggregated) content = flexRender$1(column.columnDef.aggregatedCell, cell.getContext());
2601
+ else if (empty) content = null;
2584
2602
  else if (cellEditorActive) content = /* @__PURE__ */ jsx(CellEditor, { cell });
2585
2603
  else if (rowEditorActive) content = /* @__PURE__ */ jsx(RowCellEditor, { cell });
2586
2604
  else if (editable && instantEdit && editMode === "cell") content = /* @__PURE__ */ jsx(InstantCell, {
@@ -2722,6 +2740,7 @@ function DetailRow({ row, renderDetailPanel, colSpan, dragging, dropSide, last,
2722
2740
  role: "row",
2723
2741
  ...getStyles("row", { style: pinnedStyle }),
2724
2742
  children: /* @__PURE__ */ jsx(Table.Td, {
2743
+ "data-leading": true,
2725
2744
  colSpan,
2726
2745
  role: "cell",
2727
2746
  ...getStyles("detailPanel"),
@@ -2737,10 +2756,12 @@ function SkeletonRows({ rowCount, columnCount, ariaRowIndexStart }) {
2737
2756
  role: "row",
2738
2757
  ...getStyles("row"),
2739
2758
  children: Array.from({ length: columnCount }, (_, columnIndex) => /* @__PURE__ */ jsx(Table.Td, {
2759
+ "data-leading": columnIndex === 0 || void 0,
2740
2760
  role: "cell",
2741
2761
  ...getStyles("cell"),
2742
2762
  children: /* @__PURE__ */ jsx(Skeleton, {
2743
2763
  height: 10,
2764
+ my: "calc((1lh - 10px) / 2)",
2744
2765
  radius: "sm"
2745
2766
  })
2746
2767
  }, columnIndex))
@@ -2753,6 +2774,7 @@ function LoaderRow({ colSpan, ariaRowIndex }) {
2753
2774
  role: "row",
2754
2775
  ...getStyles("loaderRow"),
2755
2776
  children: /* @__PURE__ */ jsx(Table.Td, {
2777
+ "data-leading": true,
2756
2778
  colSpan,
2757
2779
  role: "cell",
2758
2780
  children: /* @__PURE__ */ jsxs("div", {
@@ -2773,6 +2795,7 @@ function LoadMoreErrorRow({ colSpan, message, ariaRowIndex, onRetry }) {
2773
2795
  role: "row",
2774
2796
  ...getStyles("loaderRow"),
2775
2797
  children: /* @__PURE__ */ jsx(Table.Td, {
2798
+ "data-leading": true,
2776
2799
  colSpan,
2777
2800
  role: "cell",
2778
2801
  children: /* @__PURE__ */ jsxs("div", {
@@ -2826,6 +2849,7 @@ function TableBody({ table, virtualization, columnWindow, viewportRef, loading,
2826
2849
  estimateSize,
2827
2850
  getItemKey,
2828
2851
  getScrollElement: () => viewportRef.current,
2852
+ measureElement: measureRow,
2829
2853
  overscan: virtualization?.overscan ?? DEFAULT_OVERSCAN,
2830
2854
  useFlushSync: false
2831
2855
  });
@@ -3013,7 +3037,7 @@ function tableHasFooter(table) {
3013
3037
  }
3014
3038
  function TableFooter({ table, ariaRowIndexStart, columnWindow }) {
3015
3039
  const { getStyles, footerRowProps } = useDataTableContext();
3016
- const renderCell = (footer, colSpan, ariaColIndex) => /* @__PURE__ */ jsx(Table.Th, {
3040
+ const renderCell = (footer, colSpan, ariaColIndex) => /* @__PURE__ */ jsx(Table.Td, {
3017
3041
  ...mergeElementProps(resolveElementProps(footer.column.columnDef.meta?.footerCellProps, footer), {
3018
3042
  "aria-colindex": ariaColIndex,
3019
3043
  colSpan: colSpan ?? footer.colSpan,
@@ -3034,7 +3058,7 @@ function TableFooter({ table, ariaRowIndexStart, columnWindow }) {
3034
3058
  role: "row",
3035
3059
  ...getStyles("footerRow")
3036
3060
  }),
3037
- children: columnWindow === null ? footerGroup.headers.map((footer) => renderCell(footer, void 0, void 0)) : windowHeaderCells(footerGroup.headers, columnWindow).map((cell) => cell.kind === "spacer" ? /* @__PURE__ */ jsx("th", {
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", {
3038
3062
  "aria-hidden": true,
3039
3063
  "data-ledger-spacer": true
3040
3064
  }, `ledger:spacer-${cell.edge}`) : renderCell(cell.header, cell.colSpan, cell.ariaColIndex))
@@ -3053,9 +3077,12 @@ function TableFooter({ table, ariaRowIndexStart, columnWindow }) {
3053
3077
  * The column, its constraints and whether it carries a filter all arrive from the render that put
3054
3078
  * the handle on screen, for the reason `use-column-resize.ts` gives.
3055
3079
  *
3056
- * Measurement forces `white-space: nowrap` on every cell first and reads afterwards, so the
3057
- * whole pass costs one reflow. Truncating cells clip their own overflow (the td never grows),
3058
- * so the content width is read from the `[data-truncate]` span instead of the cell box.
3080
+ * A content cell is measured out of the table's layout: for the pass it is a block as wide as its
3081
+ * content (`display: block; width: max-content`, no wrapping), so its width is the content's, in
3082
+ * whichever direction that lies. Read in place, a cell is never narrower than its column — a fixed
3083
+ * 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.
3059
3086
  */
3060
3087
  /**
3061
3088
  * Breathing room over the tightest fit — content flush against the column edge reads clipped.
@@ -3076,10 +3103,6 @@ function horizontalPadding(element) {
3076
3103
  const style = getComputedStyle(element);
3077
3104
  return asPx(style.paddingInlineStart) + asPx(style.paddingInlineEnd);
3078
3105
  }
3079
- function bodyCellWidth(cell) {
3080
- const truncated = cell.querySelector(":scope [data-truncate]");
3081
- return truncated ? truncated.scrollWidth + horizontalPadding(cell) : cell.scrollWidth;
3082
- }
3083
3106
  function headerCellWidth(th, hasFilter) {
3084
3107
  const labelText = th.querySelector(":scope .ledger-header-label [data-truncate]");
3085
3108
  if (!labelText) return th.scrollWidth;
@@ -3090,16 +3113,29 @@ function headerCellWidth(th, hasFilter) {
3090
3113
  function autosizeColumn(setColumnSizing, { columnId, minSize, maxSize, hasFilter }, main) {
3091
3114
  const selector = `[data-ledger-column-id="${CSS.escape(columnId)}"]`;
3092
3115
  const headerCell = main.querySelector(`:scope .ledger-header ${selector}`);
3093
- const bodyCells = [...main.querySelectorAll(`:scope .ledger-tbody ${selector}`)];
3094
- const footerCells = [...main.querySelectorAll(`:scope .ledger-footer ${selector}`)].filter((cell) => cell.colSpan <= 1);
3095
- const contentCells = [...bodyCells, ...footerCells];
3116
+ const contentCells = [...main.querySelectorAll(`:scope :is(.ledger-tbody, .ledger-footer) ${selector}`)].filter((cell) => cell.colSpan <= 1);
3096
3117
  const cells = headerCell ? [headerCell, ...contentCells] : contentCells;
3097
3118
  if (cells.length === 0) return;
3098
- const previousWhitespace = cells.map((cell) => cell.style.whiteSpace);
3119
+ const previous = cells.map((cell) => {
3120
+ return {
3121
+ display: cell.style.display,
3122
+ whiteSpace: cell.style.whiteSpace,
3123
+ width: cell.style.width
3124
+ };
3125
+ });
3099
3126
  for (const cell of cells) cell.style.whiteSpace = "nowrap";
3127
+ for (const cell of contentCells) {
3128
+ cell.style.display = "block";
3129
+ cell.style.width = "max-content";
3130
+ }
3100
3131
  let content = headerCell ? headerCellWidth(headerCell, hasFilter) : 0;
3101
- for (const cell of contentCells) content = Math.max(content, bodyCellWidth(cell));
3102
- for (const [index, cell] of cells.entries()) cell.style.whiteSpace = previousWhitespace[index] ?? "";
3132
+ for (const cell of contentCells) content = Math.max(content, cell.scrollWidth);
3133
+ for (const [index, cell] of cells.entries()) {
3134
+ const styles = previous[index];
3135
+ cell.style.display = styles?.display ?? "";
3136
+ cell.style.whiteSpace = styles?.whiteSpace ?? "";
3137
+ cell.style.width = styles?.width ?? "";
3138
+ }
3103
3139
  const next = Math.min(Math.max(Math.round(content + AUTOSIZE_SLACK_PX), minSize), maxSize);
3104
3140
  setColumnSizing((previous) => previous[columnId] === next ? previous : {
3105
3141
  ...previous,
@@ -3299,6 +3335,7 @@ function RangeFilter({ column, name }) {
3299
3335
  wrap: "nowrap",
3300
3336
  children: [
3301
3337
  /* @__PURE__ */ jsx(NumberInput, {
3338
+ hideControls: true,
3302
3339
  "aria-label": labels.filterRangeMin,
3303
3340
  flex: 1,
3304
3341
  placeholder: facetMin === void 0 ? labels.filterRangeMin : String(facetMin),
@@ -3306,6 +3343,7 @@ function RangeFilter({ column, name }) {
3306
3343
  onChange: setBound(0)
3307
3344
  }),
3308
3345
  /* @__PURE__ */ jsx(NumberInput, {
3346
+ hideControls: true,
3309
3347
  "aria-label": labels.filterRangeMax,
3310
3348
  flex: 1,
3311
3349
  placeholder: facetMax === void 0 ? labels.filterRangeMax : String(facetMax),
@@ -3661,7 +3699,11 @@ function HeaderCell({ header, table, reorder, resize, columnWidths, columnSizing
3661
3699
  ...getStyles("headerCell", { style: pinnedCellStyle(column) }),
3662
3700
  ...reorder.getHeaderProps(column.id)
3663
3701
  }),
3664
- children: header.isPlaceholder ? null : internal ? label : /* @__PURE__ */ jsxs(Fragment, { children: [
3702
+ children: header.isPlaceholder ? null : internal ? /* @__PURE__ */ jsx("div", {
3703
+ ...getStyles("headerLabel"),
3704
+ "data-align": "center",
3705
+ children: label
3706
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [
3665
3707
  canSort ? /* @__PURE__ */ jsxs("button", {
3666
3708
  type: "button",
3667
3709
  onClick: handleSortClick,
@@ -6490,31 +6532,36 @@ function useStylesRevision(getStyles, selectors) {
6490
6532
  return revision;
6491
6533
  }
6492
6534
  //#endregion
6493
- //#region src/use-viewport-overflow.ts
6535
+ //#region src/use-viewport-fit.ts
6536
+ const UNMEASURED = {
6537
+ overflowing: false,
6538
+ underfilled: false
6539
+ };
6494
6540
  /**
6495
- * Whether the body viewport scrolls on either axis. A scroll container has to be reachable by
6496
- * keyboard to be scrolled by it (WCAG 2.1.1), while a focus stop over content that fits is a
6497
- * Tab press spent on nothing — so the viewport's focus stop follows this.
6498
- *
6499
- * Measured whenever the viewport or its content resizes: rows arriving, columns widening, or
6500
- * the host resizing the table each change the answer without a scroll event. A 1px tolerance
6501
- * absorbs fractional layout rounding, which would otherwise flicker the stop on and off.
6541
+ * Layout sizes only, never rects: a transform (a modal scaling in) would shrink a rect but not
6542
+ * the viewport's client box, and nothing re-measures when the transform ends. A 1px tolerance
6543
+ * absorbs fractional layout rounding, which would otherwise flicker either answer.
6502
6544
  */
6503
- function useViewportOverflow(viewport) {
6504
- const [overflowing, setOverflowing] = useState(false);
6545
+ function useViewportFit(viewport) {
6546
+ const [fit, setFit] = useState(UNMEASURED);
6505
6547
  useLayoutEffect(() => {
6506
6548
  if (!viewport) return;
6549
+ const content = viewport.firstElementChild;
6507
6550
  const measure = () => {
6508
- const next = viewport.scrollHeight - viewport.clientHeight > 1 || viewport.scrollWidth - viewport.clientWidth > 1;
6509
- setOverflowing(next);
6551
+ const overflowing = viewport.scrollHeight - viewport.clientHeight > 1 || viewport.scrollWidth - viewport.clientWidth > 1;
6552
+ const underfilled = content instanceof HTMLElement && viewport.clientHeight - content.offsetHeight >= 1;
6553
+ setFit((previous) => previous.overflowing === overflowing && previous.underfilled === underfilled ? previous : {
6554
+ overflowing,
6555
+ underfilled
6556
+ });
6510
6557
  };
6511
6558
  measure();
6512
6559
  const observer = new ResizeObserver(measure);
6513
6560
  observer.observe(viewport);
6514
- if (viewport.firstElementChild) observer.observe(viewport.firstElementChild);
6561
+ if (content) observer.observe(content);
6515
6562
  return () => observer.disconnect();
6516
6563
  }, [viewport]);
6517
- return overflowing;
6564
+ return fit;
6518
6565
  }
6519
6566
  //#endregion
6520
6567
  //#region src/data-table.tsx
@@ -6766,7 +6813,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
6766
6813
  viewportRef.current = element;
6767
6814
  setViewport(element);
6768
6815
  }, []);
6769
- const viewportOverflows = useViewportOverflow(viewport);
6816
+ const viewportFit = useViewportFit(viewport);
6770
6817
  const startLeafColumns = table.getStartVisibleLeafColumns();
6771
6818
  const endLeafColumns = table.getEndVisibleLeafColumns();
6772
6819
  const displayColumns = [
@@ -6855,6 +6902,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
6855
6902
  leftOffset += width;
6856
6903
  }
6857
6904
  }
6905
+ varsMap["--ledger-pinned-start-width"] = `${leftOffset}px`;
6858
6906
  let rightOffset = 0;
6859
6907
  for (let index = visibleLeafColumns.length - 1; index >= 0; index -= 1) {
6860
6908
  const column = visibleLeafColumns[index];
@@ -7119,7 +7167,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
7119
7167
  ]);
7120
7168
  const activeRowAnnouncer = useRef(null);
7121
7169
  const rowNavigationHintId = `${instanceId}-row-navigation`;
7122
- const viewportFocusStop = activeRowEnabled || viewportOverflows;
7170
+ const viewportFocusStop = activeRowEnabled || viewportFit.overflowing;
7123
7171
  const viewportDescribedBy = activeRowEnabled ? [viewportProps?.["aria-describedby"], rowNavigationHintId].filter(Boolean).join(" ") : viewportProps?.["aria-describedby"];
7124
7172
  const announceActiveRow = useEventCallback(() => {
7125
7173
  const target = activeRowAnnouncer.current;
@@ -7229,7 +7277,8 @@ function DataTableCore({ presentation, stylesProps, table }) {
7229
7277
  width: columnWidths.total > 0 ? columnWidths.total : void 0,
7230
7278
  minWidth: toPx(tableMinWidth),
7231
7279
  borderCollapse: "separate",
7232
- borderSpacing: 0
7280
+ borderSpacing: 0,
7281
+ fontSize: "inherit"
7233
7282
  } });
7234
7283
  const rowOrderingEnabled = ledger?.rowOrdering.enabled === true;
7235
7284
  const nameReorderRow = useEventCallback((row) => {
@@ -7309,6 +7358,7 @@ function DataTableCore({ presentation, stylesProps, table }) {
7309
7358
  "data-scrolled-start": scrollEdges.start || void 0,
7310
7359
  "data-size": size,
7311
7360
  "data-striped": stripedMode,
7361
+ "data-underfilled": viewportFit.underfilled || void 0,
7312
7362
  "data-virtualized-columns": columnWindow !== null || void 0,
7313
7363
  "data-virtualized-rows": virtualEnabled || void 0,
7314
7364
  "data-with-bottom-border": withBottomBorder || void 0,
@@ -7489,13 +7539,15 @@ DataTable.SelectionBar = DataTableSelectionBar;
7489
7539
  * renderer over the public editing contexts (docs/editing.md#editors), which is the proof the
7490
7540
  * contexts suffice: anything these do, an application's own renderer can do the same way.
7491
7541
  * All are default-variant Mantine inputs at the context's `size` — the border marks the cell as an
7492
- * open editor, and the size keeps it inside the row.
7542
+ * open editor, and the size keeps it inside the row. The fields fill the cell (`flex={1}` in the
7543
+ * host's flex line); the checkbox keeps its own size, placed by the column's alignment.
7493
7544
  */
7494
7545
  const renderTextEditor = ({ value, setValue, error, pending, autoFocus, label, size }) => /* @__PURE__ */ jsx(TextInput, {
7495
7546
  "aria-label": label,
7496
7547
  autoFocus,
7497
7548
  disabled: pending,
7498
7549
  error,
7550
+ flex: 1,
7499
7551
  size,
7500
7552
  value: value === null || value === void 0 ? "" : String(value),
7501
7553
  onChange: (event) => setValue(event.currentTarget.value)
@@ -7512,6 +7564,7 @@ const renderNumberEditor = ({ value, setValue, error, pending, autoFocus, label,
7512
7564
  autoFocus,
7513
7565
  disabled: pending,
7514
7566
  error,
7567
+ flex: 1,
7515
7568
  size,
7516
7569
  value: typeof value === "number" || typeof value === "string" ? value : "",
7517
7570
  onChange: (next) => setValue(next === "" ? null : next)
@@ -7536,6 +7589,7 @@ function selectEditor(options) {
7536
7589
  defaultDropdownOpened: mode === "cell",
7537
7590
  disabled: pending,
7538
7591
  error,
7592
+ flex: 1,
7539
7593
  size,
7540
7594
  value: value === null || value === void 0 ? null : String(value),
7541
7595
  onChange: (next) => {