-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(table): virtualization #4285
Open
vinroger
wants to merge
27
commits into
canary
Choose a base branch
from
feat/eng-1633-virtualization-for-table
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
bff9f02
feat: baseline virtualization for table
vinroger aaf9afb
merge branch canary
vinroger 038613a
fix: table layout
vinroger 72b4f88
fix: calc header height w layouteffect to offset padding
vinroger 432e2e8
Merge branch 'canary' into feat/eng-1633-virtualization-for-table
vinroger ed0a7d8
Merge branch 'canary' into feat/eng-1633-virtualization-for-table
vinroger fc78b55
chore: remove unused files and comments
vinroger 783e260
chore: add missing package
vinroger dfc56c1
feat: add shouldVirtualize conditional to render virtualized-table
vinroger edd6f91
feat: update docs for table
vinroger 3308771
feat: use wrapper to support theme styles
vinroger 455149b
chore: add changeset
vinroger f70264b
chore(changeset): update package name
wingkwong 9a39d23
Merge branch 'canary' into feat/eng-1633-virtualization-for-table
wingkwong d2ebb53
chore(deps): pnpm-lock.yaml
wingkwong a86c898
Merge branch 'canary' into feat/eng-1633-virtualization-for-table
wingkwong 022ed88
fix(table): outdated package name
wingkwong bc5e2f7
chore(changeset): add issue number
wingkwong f842772
fix(deps): keep the version consistent with other components
wingkwong 013b9c7
fix(table): incorrect displayName
wingkwong 3cc6473
Merge branch 'feat/eng-1633-virtualization-for-table' of https://gith…
wingkwong 9f051e6
refactor(table): use VirtualizedTemplate
wingkwong 6f3a15b
Merge branch 'canary' into feat/eng-1633-virtualization-for-table
wingkwong 8f8cd39
chore(deps): bump `@tanstack/react-virtua`
wingkwong 5c7ab0f
Merge branch 'canary' into feat/eng-1633-virtualization-for-table
wingkwong d5ee046
chore(deps): typecheck issue
wingkwong f73a7a5
fix(table): do not use any type
wingkwong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@heroui/table": patch | ||
--- | ||
|
||
Virtualization support added to Table component (#3697) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/docs/content/components/table/virtualization-custom-max-table-height.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Table, TableBody, TableCell, TableColumn, TableHeader, TableRow} from "@nextui-org/react"; | ||
|
||
function generateRows(count) { | ||
return Array.from({length: count}, (_, index) => ({ | ||
key: index.toString(), | ||
name: `Item ${index + 1}`, | ||
value: `Value ${index + 1}`, | ||
})); | ||
} | ||
|
||
export default function App() { | ||
const rows = generateRows(500); | ||
const columns = [ | ||
{key: "name", label: "Name"}, | ||
{key: "value", label: "Value"}, | ||
]; | ||
|
||
return ( | ||
<Table | ||
isVirtualized | ||
aria-label="Example of virtualized table with a large dataset" | ||
maxTableHeight={300} | ||
rowHeight={40} | ||
> | ||
<TableHeader columns={columns}> | ||
{(column) => <TableColumn key={column.key}>{column.label}</TableColumn>} | ||
</TableHeader> | ||
<TableBody items={rows}> | ||
{(item) => ( | ||
<TableRow key={item.key}> | ||
{(columnKey) => <TableCell>{item[columnKey]}</TableCell>} | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
apps/docs/content/components/table/virtualization-custom-max-table-height.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import App from "./virtualization-custom-max-table-height.raw.jsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
37 changes: 37 additions & 0 deletions
37
apps/docs/content/components/table/virtualization-custom-row-height.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Table, TableBody, TableCell, TableColumn, TableHeader, TableRow} from "@nextui-org/react"; | ||
|
||
function generateRows(count) { | ||
return Array.from({length: count}, (_, index) => ({ | ||
key: index.toString(), | ||
name: `Item ${index + 1}`, | ||
value: `Value ${index + 1}`, | ||
})); | ||
} | ||
|
||
export default function App() { | ||
const rows = generateRows(500); | ||
const columns = [ | ||
{key: "name", label: "Name"}, | ||
{key: "value", label: "Value"}, | ||
]; | ||
|
||
return ( | ||
<Table | ||
isVirtualized | ||
aria-label="Example of virtualized table with a large dataset" | ||
maxTableHeight={500} | ||
rowHeight={70} | ||
> | ||
<TableHeader columns={columns}> | ||
{(column) => <TableColumn key={column.key}>{column.label}</TableColumn>} | ||
</TableHeader> | ||
<TableBody items={rows}> | ||
{(item) => ( | ||
<TableRow key={item.key}> | ||
{(columnKey) => <TableCell>{item[columnKey]}</TableCell>} | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
apps/docs/content/components/table/virtualization-custom-row-height.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import App from "./virtualization-custom-row-height.raw.jsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
37 changes: 37 additions & 0 deletions
37
apps/docs/content/components/table/virtualization-ten-thousand.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Table, TableBody, TableCell, TableColumn, TableHeader, TableRow} from "@nextui-org/react"; | ||
|
||
function generateRows(count) { | ||
return Array.from({length: count}, (_, index) => ({ | ||
key: index.toString(), | ||
name: `Item ${index + 1}`, | ||
value: `Value ${index + 1}`, | ||
})); | ||
} | ||
wingkwong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default function App() { | ||
const rows = generateRows(10000); | ||
const columns = [ | ||
{key: "name", label: "Name"}, | ||
{key: "value", label: "Value"}, | ||
]; | ||
|
||
return ( | ||
<Table | ||
isVirtualized | ||
aria-label="Example of virtualized table with a large dataset" | ||
maxTableHeight={500} | ||
rowHeight={40} | ||
> | ||
<TableHeader columns={columns}> | ||
{(column) => <TableColumn key={column.key}>{column.label}</TableColumn>} | ||
</TableHeader> | ||
<TableBody items={rows}> | ||
{(item) => ( | ||
<TableRow key={item.key}> | ||
{(columnKey) => <TableCell>{item[columnKey]}</TableCell>} | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
apps/docs/content/components/table/virtualization-ten-thousand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import App from "./virtualization-ten-thousand.raw.jsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Table, TableBody, TableCell, TableColumn, TableHeader, TableRow} from "@nextui-org/react"; | ||
|
||
function generateRows(count) { | ||
return Array.from({length: count}, (_, index) => ({ | ||
key: index.toString(), | ||
name: `Item ${index + 1}`, | ||
value: `Value ${index + 1}`, | ||
})); | ||
} | ||
|
||
export default function App() { | ||
const rows = generateRows(500); | ||
const columns = [ | ||
{key: "name", label: "Name"}, | ||
{key: "value", label: "Value"}, | ||
]; | ||
|
||
return ( | ||
<Table | ||
isVirtualized | ||
aria-label="Example of virtualized table with a large dataset" | ||
maxTableHeight={500} | ||
rowHeight={40} | ||
> | ||
Comment on lines
+19
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance error handling and loading states The table implementation could benefit from additional error handling and loading states to improve user experience. <Table
isVirtualized
aria-label="Example of virtualized table with a large dataset"
maxTableHeight={500}
rowHeight={40}
+ loadingState={isLoading ? "loading" : "idle"}
+ loadingContent={<Spinner label="Loading..." />}
+ emptyContent={<div>No rows to display</div>}
>
|
||
<TableHeader columns={columns}> | ||
{(column) => <TableColumn key={column.key}>{column.label}</TableColumn>} | ||
</TableHeader> | ||
<TableBody items={rows}> | ||
{(item) => ( | ||
<TableRow key={item.key}> | ||
{(columnKey) => <TableCell>{item[columnKey]}</TableCell>} | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
wingkwong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</Table> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import App from "./virtualization.raw.jsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Extract generateRows to a shared utility file
This helper function is duplicated across multiple example files. Consider moving it to a shared utility file to improve maintainability.
Create a new file
apps/docs/content/components/table/utils.js
:Then import it in each example file: