Skip to content

Commit a14f758

Browse files
feat(Table): add fixed-height row virtualization and shared plugin protocol
Add `useTableRowsVirtualization({rowHeight, viewportHeight})` and the `Table.virtualization` prop for fixed-height flat-row windowing, rebuilt on main after the plugin row/render context landed. Row status keeps full rendering (not an admitted windowing composition), and the row-index plugin builds its column once so a parent re-render no longer re-renders every row. Adds the Chromium accessibility spec and the 1k/10k/100k release measurement harness. This diff was generated with AI assistance (Navi). Tags: ai-generated
1 parent 9db6e34 commit a14f758

57 files changed

Lines changed: 5413 additions & 200 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@astryxdesign/core': patch
3+
'@astryxdesign/cli': patch
4+
---
5+
6+
[feature] Add fixed-height flat-data Table virtualization through `useTableRowsVirtualization({rowHeight, viewportHeight})` and `Table.virtualization`. Keep complete data and canonical identity in Table, preserve logical row positions, retain focused rows, and fall back to full rendering for unsupported content or geometry. Existing tables do not opt in automatically.
7+
8+
@humbertovirtudes

‎apps/sandbox/scripts/next-export-routes.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@
501501
"/templates/RadioListWithValidation/",
502502
"/templates/ResizableShowcase/",
503503
"/templates/ResizableSidebar/",
504+
"/templates/RowsVirtualizationHookUsage/",
504505
"/templates/ScrollableAreaInlineRail/",
505506
"/templates/ScrollableAreaOverscrollChaining/",
506507
"/templates/ScrollableAreaShowcase/",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
import type {Meta, StoryObj} from '@storybook/react-vite';
3+
import {Table, useTableRowsVirtualization} from '@astryxdesign/core';
4+
const rows = Array.from({length: 2000}, (_, index) => ({
5+
id: String(index),
6+
name: `Product ${index + 1}`,
7+
status: 'Available',
8+
}));
9+
const meta: Meta = {
10+
title: 'Core/Table virtualization',
11+
component: Table,
12+
};
13+
export default meta;
14+
function Example() {
15+
const virtualization = useTableRowsVirtualization({
16+
rowHeight: 56,
17+
viewportHeight: 320,
18+
});
19+
return (
20+
<Table
21+
data={rows}
22+
columns={[
23+
{key: 'name', header: 'Product'},
24+
{key: 'status', header: 'Status'},
25+
]}
26+
idKey="id"
27+
virtualization={virtualization}
28+
dividers="grid"
29+
isStriped
30+
/>
31+
);
32+
}
33+
export const FixedHeightWindowing: StoryObj = {
34+
render: () => <Example />,
35+
};

‎internal/shadcn-registry/routes.lock.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,6 +3926,11 @@
39263926
"path": "examples/use-table-row-status/semantic-and-custom-markers",
39273927
"aliases": []
39283928
},
3929+
{
3930+
"name": "example-use-table-rows-virtualization-fixed-height-rows",
3931+
"path": "examples/use-table-rows-virtualization/fixed-height-rows",
3932+
"aliases": []
3933+
},
39293934
{
39303935
"name": "example-use-table-selection-state-table-selection-in-the-leading-mark",
39313936
"path": "examples/use-table-selection-state/table-selection-in-the-leading-mark",
@@ -4316,6 +4321,11 @@
43164321
"path": "hooks/use-table-row-status",
43174322
"aliases": []
43184323
},
4324+
{
4325+
"name": "hook-use-table-rows-virtualization",
4326+
"path": "hooks/use-table-rows-virtualization",
4327+
"aliases": []
4328+
},
43194329
{
43204330
"name": "hook-use-table-selection",
43214331
"path": "hooks/use-table-selection",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4+
export const doc = {
5+
type: 'block',
6+
exampleFor: 'useTableRowsVirtualization',
7+
name: 'useTableRowsVirtualization - Fixed Height Rows',
8+
displayName: 'useTableRowsVirtualization - Fixed Height Rows',
9+
description:
10+
'A Table with 1,000 product rows in a fixed-height viewport. Scroll vertically to mount the visible rows. The caller keeps all data and columns; this hook does not virtualize columns.',
11+
isReady: true,
12+
aspectRatio: 16 / 9,
13+
componentsUsed: ['Table'],
14+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
3+
'use client';
4+
5+
import {
6+
Table,
7+
useTableRowsVirtualization,
8+
type TableColumn,
9+
} from '@astryxdesign/core/Table';
10+
11+
interface Product extends Record<string, unknown> {
12+
id: string;
13+
name: string;
14+
}
15+
16+
const products: Product[] = Array.from({length: 1000}, (_, index) => ({
17+
id: `product-${index}`,
18+
name: `Product ${index + 1}`,
19+
}));
20+
const columns: TableColumn<Product>[] = [{key: 'name', header: 'Product'}];
21+
22+
export default function RowsVirtualizationHookUsage() {
23+
const virtualization = useTableRowsVirtualization({
24+
rowHeight: 56,
25+
viewportHeight: 320,
26+
});
27+
return (
28+
<Table
29+
data={products}
30+
columns={columns}
31+
idKey="id"
32+
virtualization={virtualization}
33+
/>
34+
);
35+
}

‎packages/core/api-report.md‎

Lines changed: 29 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)