@alexgorbatchev/shadcn 0.0.57 → 0.0.58

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/README.md CHANGED
@@ -439,7 +439,7 @@ Column `meta.filter` offers a column in `DataGridFilters`, hidden columns includ
439
439
 
440
440
  Import `DataGridSelectHeader` and `DataGridSelectCell` from `@alexgorbatchev/shadcn/data-grid`. Pass the current `useTable` result as `table` to both controls, and pass `row` and an accessible `label` to each cell. The header selects selectable filtered rows across all pages and preserves selections hidden by filters. It shows a mixed state when some of those rows are selected and disables itself when none are selectable. Its default label is "Select all filtered rows"; provide `label` to name the scope in your application. Cells follow native row selection rules, including disabled rows and partially selected parents. The controls observe selection changes without requiring the parent table selector to include selection state.
441
441
 
442
- For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's preferred size, bounded by its native sizing limits, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
442
+ For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's native current size, including controlled sizing state and its min/max bounds, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
443
443
 
444
444
  Keep preferred widths separate from the table's rendered sizing atom. In `onFitWidthChange`, store the reported width in a ref and write `fitDataGridColumnSizing(table, preferredWidths, width)` into the sizing atom. The helper temporarily shrinks required resizable columns toward their minima when needed and restores their preferred widths when space returns. In `onColumnSizingChange`, obtain new preferences with `constrainDataGridColumnSizing(table, updater, widthRef.current, preferredWidths)`, then derive the sizing atom with `fitDataGridColumnSizing`. Persist only the preferred widths, after the resize settles. Native pointer and keyboard resizing starts at the displayed width, stays within the available space, and leaves other columns' preferences unchanged. Widening a required column can hide optional columns again; widening an optional column preserves its fitted neighbours and the fill column's preferred space. Container changes never overwrite user visibility, order, or width preferences. The `VirtualDataGridExample` fixture demonstrates this controlled integration.
445
445
 
@@ -56,18 +56,13 @@ var DataGridColumnFitContext = createContext(undefined);
56
56
  import { Subscribe } from "@tanstack/react-table";
57
57
  import { useContext } from "react";
58
58
 
59
- // src/components/data-grid/getDataGridFillPreferredSize.ts
60
- function getDataGridFillPreferredSize(column) {
61
- return Math.min(column.maxSize ?? Number.MAX_SAFE_INTEGER, Math.max(column.minSize ?? 20, column.size ?? 150));
62
- }
63
-
64
59
  // src/components/data-grid/getDataGridColumnFit.ts
65
60
  function getDataGridColumnFit(table, width) {
66
61
  const columns = table.getVisibleLeafColumns();
67
62
  let remaining = width;
68
63
  for (const column of columns) {
69
64
  if (column.columnDef.meta?.fill)
70
- remaining -= getDataGridFillPreferredSize(column.columnDef);
65
+ remaining -= column.getSize();
71
66
  else if (!column.getCanHide())
72
67
  remaining -= column.getSize();
73
68
  }
@@ -92,7 +87,7 @@ function getDataGridColumnFitMaximum(table, columnId, width) {
92
87
  if (other.id === columnId)
93
88
  return sum;
94
89
  if (other.columnDef.meta?.fill) {
95
- return sum + (isRequired ? other.columnDef.minSize ?? 20 : getDataGridFillPreferredSize(other.columnDef));
90
+ return sum + (isRequired ? other.columnDef.minSize ?? 20 : other.getSize());
96
91
  }
97
92
  if (isRequired && other.getCanHide() || hidden.includes(other.id))
98
93
  return sum;
@@ -7,7 +7,7 @@ import {
7
7
  DataGridColumnHeader2,
8
8
  DataGridFilter2,
9
9
  DataGridPagination2
10
- } from "../../chunk-kyctwprg.js";
10
+ } from "../../chunk-8m97h03v.js";
11
11
  import"../../chunk-7ny0vyek.js";
12
12
  import"../../chunk-8ssktt4b.js";
13
13
  import"../../chunk-en44w1pn.js";
@@ -9,7 +9,7 @@ interface IVirtualDataGridProps<T extends RowData, TSelected> {
9
9
  estimateRowHeight?: number;
10
10
  overscan?: number;
11
11
  /**
12
- * Reserve one fill column's preferred `size` and hide optional columns that do not fit, in their chosen order.
12
+ * Reserve one fill column's native current size and hide optional columns that do not fit, in their chosen order.
13
13
  * The fill column may shrink toward `minSize` when only required columns remain. Replaces
14
14
  * `meta.visibleFrom` breakpoints; saved visibility and widths are unchanged. Use exactly one fill column, and
15
15
  * ensure required columns' minima plus its minimum fit the smallest supported container. Only leaf headers resize.
@@ -10,7 +10,7 @@ import {
10
10
  DataGridHeaderRows,
11
11
  DataGridCells2,
12
12
  DataGridColumns
13
- } from "../../chunk-kyctwprg.js";
13
+ } from "../../chunk-8m97h03v.js";
14
14
  import"../../chunk-7ny0vyek.js";
15
15
  import"../../chunk-8ssktt4b.js";
16
16
  import"../../chunk-e6hk39ev.js";
package/dist/prototype.js CHANGED
@@ -2051,7 +2051,7 @@ var program = new Command;
2051
2051
  // package.json
2052
2052
  var package_default = {
2053
2053
  name: "@alexgorbatchev/shadcn",
2054
- version: "0.0.57",
2054
+ version: "0.0.58",
2055
2055
  description: "Sharp, monospace React components with compact and comfortable densities.",
2056
2056
  license: "MIT",
2057
2057
  repository: {
@@ -84,6 +84,14 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
84
84
  }
85
85
  ```
86
86
 
87
+ ### PreferredFillWidth
88
+
89
+ ```tsx
90
+ {
91
+ render: () => <VirtualDataGridExample files={fixture_gridFiles} width={420} fitColumns preferredFillSize={240}/>
92
+ }
93
+ ```
94
+
87
95
  ### FittedColumnGroups
88
96
 
89
97
  ```tsx
package/llms/setup.md CHANGED
@@ -439,7 +439,7 @@ Column `meta.filter` offers a column in `DataGridFilters`, hidden columns includ
439
439
 
440
440
  Import `DataGridSelectHeader` and `DataGridSelectCell` from `@alexgorbatchev/shadcn/data-grid`. Pass the current `useTable` result as `table` to both controls, and pass `row` and an accessible `label` to each cell. The header selects selectable filtered rows across all pages and preserves selections hidden by filters. It shows a mixed state when some of those rows are selected and disables itself when none are selectable. Its default label is "Select all filtered rows"; provide `label` to name the scope in your application. Cells follow native row selection rules, including disabled rows and partially selected parents. The controls observe selection changes without requiring the parent table selector to include selection state.
441
441
 
442
- For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's preferred size, bounded by its native sizing limits, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
442
+ For grids that must fit their container, set `VirtualDataGrid fitColumns`. Use exactly one `meta.fill` column with an explicit `minSize` and a preferred `size`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves the fill column's native current size, including controlled sizing state and its min/max bounds, and temporarily hides optional columns that do not fit, prioritizing their chosen order. When only required columns remain, the fill column can shrink toward its minimum. The grid lists hidden columns and explains how to reveal them. This mode replaces `meta.visibleFrom` breakpoints and offers resize handles on leaf headers only.
443
443
 
444
444
  Keep preferred widths separate from the table's rendered sizing atom. In `onFitWidthChange`, store the reported width in a ref and write `fitDataGridColumnSizing(table, preferredWidths, width)` into the sizing atom. The helper temporarily shrinks required resizable columns toward their minima when needed and restores their preferred widths when space returns. In `onColumnSizingChange`, obtain new preferences with `constrainDataGridColumnSizing(table, updater, widthRef.current, preferredWidths)`, then derive the sizing atom with `fitDataGridColumnSizing`. Persist only the preferred widths, after the resize settles. Native pointer and keyboard resizing starts at the displayed width, stays within the available space, and leaves other columns' preferences unchanged. Widening a required column can hide optional columns again; widening an optional column preserves its fitted neighbours and the fill column's preferred space. Container changes never overwrite user visibility, order, or width preferences. The `VirtualDataGridExample` fixture demonstrates this controlled integration.
445
445
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgorbatchev/shadcn",
3
- "version": "0.0.57",
3
+ "version": "0.0.58",
4
4
  "description": "Sharp, monospace React components with compact and comfortable densities.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,3 +0,0 @@
1
- import type { ColumnDef_ColumnSizing } from "@tanstack/react-table";
2
- /** The fill reservation before optional columns are admitted, bounded by the column's native sizing limits. */
3
- export declare function getDataGridFillPreferredSize(column: ColumnDef_ColumnSizing): number;