@alexgorbatchev/shadcn 0.0.56 → 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 +2 -2
- package/dist/{chunk-74xynyzg.js → chunk-8m97h03v.js} +9 -3
- package/dist/components/data-grid/constrainDataGridColumnSizing.d.ts +2 -1
- package/dist/components/data-grid/getDataGridColumnFit.d.ts +1 -1
- package/dist/components/data-grid/getDataGridColumnFitMaximum.d.ts +1 -1
- package/dist/components/data-grid/index.js +1 -1
- package/dist/components/virtual-data-grid/VirtualDataGrid.d.ts +2 -1
- package/dist/components/virtual-data-grid/index.js +1 -1
- package/dist/prototype.js +1 -1
- package/llms/components/data-display/VirtualDataGrid.md +8 -0
- package/llms/setup.md +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -439,9 +439,9 @@ 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`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves
|
|
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
|
-
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. Container changes never overwrite user visibility, order, or width preferences. The `VirtualDataGridExample` fixture demonstrates this controlled integration.
|
|
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
|
|
|
446
446
|
`ActionsMenu` shares one `items` definition between a dropdown action and an optional context menu. Supply an accessible `label`; the default trigger is a ghost icon button. `size="sm"` displays the label, and `variant`, `disabled`, and `trigger` customize the action. Supplying `contextTarget` composes the native context trigger with that element and adds its popup. Compose items with `MenuItem`, `MenuLinkItem`, checkbox/radio parts, groups, labels, separators, shortcuts, and submenu parts; dropdown and context menus share these implementations. `MenuLinkItem` retains its native anchor and menu keyboard semantics.
|
|
447
447
|
|
|
@@ -62,7 +62,7 @@ function getDataGridColumnFit(table, width) {
|
|
|
62
62
|
let remaining = width;
|
|
63
63
|
for (const column of columns) {
|
|
64
64
|
if (column.columnDef.meta?.fill)
|
|
65
|
-
remaining -= column.
|
|
65
|
+
remaining -= column.getSize();
|
|
66
66
|
else if (!column.getCanHide())
|
|
67
67
|
remaining -= column.getSize();
|
|
68
68
|
}
|
|
@@ -82,10 +82,16 @@ function getDataGridColumnFit(table, width) {
|
|
|
82
82
|
function getDataGridColumnFitMaximum(table, columnId, width) {
|
|
83
83
|
const hidden = getDataGridColumnFit(table, width);
|
|
84
84
|
const column = table.getColumn(columnId);
|
|
85
|
+
const isRequired = column && !column.getCanHide();
|
|
85
86
|
const occupied = table.getVisibleLeafColumns().reduce((sum, other) => {
|
|
86
|
-
if (other.id === columnId
|
|
87
|
+
if (other.id === columnId)
|
|
88
|
+
return sum;
|
|
89
|
+
if (other.columnDef.meta?.fill) {
|
|
90
|
+
return sum + (isRequired ? other.columnDef.minSize ?? 20 : other.getSize());
|
|
91
|
+
}
|
|
92
|
+
if (isRequired && other.getCanHide() || hidden.includes(other.id))
|
|
87
93
|
return sum;
|
|
88
|
-
return sum +
|
|
94
|
+
return sum + other.getSize();
|
|
89
95
|
}, 0);
|
|
90
96
|
return Math.max(column?.columnDef.minSize ?? 20, Math.min(column?.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER, Math.floor(width - occupied)));
|
|
91
97
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ColumnSizingState, type RowData, type Table, type Updater } from "@tanstack/react-table";
|
|
2
2
|
import type { DataGridFeatures } from "./DataGrid.js";
|
|
3
3
|
/**
|
|
4
|
-
* Apply a user resize
|
|
4
|
+
* Apply a user resize while preserving fill space. Required columns may displace optional columns; optional
|
|
5
|
+
* columns preserve fitted neighbours and the fill preference. Use in the table's
|
|
5
6
|
* `onColumnSizingChange`, passing the width reported by `VirtualDataGrid.onFitWidthChange`, then store the result in
|
|
6
7
|
* preferred sizes. Then pass those preferences through `fitDataGridColumnSizing` into the table's sizing atom.
|
|
7
8
|
* Container changes never call this helper or rewrite preferred sizes.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RowData, Table } from "@tanstack/react-table";
|
|
2
2
|
import type { DataGridFeatures } from "./DataGrid.js";
|
|
3
|
-
/** Columns that do not fit after reserving each fill column's
|
|
3
|
+
/** Columns that do not fit after reserving each fill column's preferred size and every required fixed column. */
|
|
4
4
|
export declare function getDataGridColumnFit<T extends RowData>(table: Table<DataGridFeatures, T>, width: number): string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RowData, Table } from "@tanstack/react-table";
|
|
2
2
|
import type { DataGridFeatures } from "./DataGrid.js";
|
|
3
|
-
/**
|
|
3
|
+
/** Required columns reclaim optional space; optional columns keep fitted neighbours and the fill preference. */
|
|
4
4
|
export declare function getDataGridColumnFitMaximum<T extends RowData>(table: Table<DataGridFeatures, T>, columnId: string, width: number): number;
|
|
@@ -9,7 +9,8 @@ interface IVirtualDataGridProps<T extends RowData, TSelected> {
|
|
|
9
9
|
estimateRowHeight?: number;
|
|
10
10
|
overscan?: number;
|
|
11
11
|
/**
|
|
12
|
-
* Reserve one fill column's
|
|
12
|
+
* Reserve one fill column's native current size and hide optional columns that do not fit, in their chosen order.
|
|
13
|
+
* The fill column may shrink toward `minSize` when only required columns remain. Replaces
|
|
13
14
|
* `meta.visibleFrom` breakpoints; saved visibility and widths are unchanged. Use exactly one fill column, and
|
|
14
15
|
* ensure required columns' minima plus its minimum fit the smallest supported container. Only leaf headers resize.
|
|
15
16
|
* Pair with `fitDataGridColumnSizing` and `constrainDataGridColumnSizing` to preserve preferred widths separately
|
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.
|
|
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,9 +439,9 @@ 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`; required columns' minima plus that minimum must fit the smallest supported container. The grid reserves
|
|
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
|
-
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. Container changes never overwrite user visibility, order, or width preferences. The `VirtualDataGridExample` fixture demonstrates this controlled integration.
|
|
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
|
|
|
446
446
|
`ActionsMenu` shares one `items` definition between a dropdown action and an optional context menu. Supply an accessible `label`; the default trigger is a ghost icon button. `size="sm"` displays the label, and `variant`, `disabled`, and `trigger` customize the action. Supplying `contextTarget` composes the native context trigger with that element and adds its popup. Compose items with `MenuItem`, `MenuLinkItem`, checkbox/radio parts, groups, labels, separators, shortcuts, and submenu parts; dropdown and context menus share these implementations. `MenuLinkItem` retains its native anchor and menu keyboard semantics.
|
|
447
447
|
|