Skip to content
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 #2489

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
083a1b3
feat: virtulization on table poc
saurabhdaware Jan 8, 2025
7d2dd2b
chore: virtulized selectable demo
tewarig Jan 12, 2025
0aa7112
chore: minor changes
tewarig Jan 14, 2025
8f9cb0d
chore: update table styling and virtulization poc
tewarig Jan 14, 2025
fc37ce6
chore: add toolbar
tewarig Jan 15, 2025
1aaf188
chore: styling fix
tewarig Jan 15, 2025
2b4aa42
fix: height of table
tewarig Jan 20, 2025
dc52d5c
chore: remove hasPadding from tableBody
tewarig Jan 20, 2025
cec32e2
chore: scroll styling in case of not proper space is their , in virtu…
tewarig Jan 20, 2025
e21ee7f
chore: added isVirtualized prop
tewarig Jan 20, 2025
46dee3a
chore: added dynamic width and height
tewarig Jan 20, 2025
b7105ab
chore: table hover actions fixes
tewarig Jan 21, 2025
cdbe7e3
fix: row bottom not visible with rowHeight
tewarig Jan 21, 2025
e236d3e
fix: distance between header height and table height
tewarig Jan 21, 2025
bf39ca1
fix: gap between table cells
tewarig Jan 21, 2025
96cbd91
chore: added isSelectable todo
tewarig Jan 21, 2025
463c2b9
chore: add isVirtualized prop
tewarig Jan 21, 2025
449feb6
chore: remove unused classes
tewarig Jan 21, 2025
6b20fcb
chore: remove comments
tewarig Jan 21, 2025
39dc02a
chore: code clean up
tewarig Jan 21, 2025
e8b7f4d
fix: old table styling
tewarig Jan 21, 2025
d3d27d9
chore: table height fix
tewarig Jan 22, 2025
628ec0f
fix: table bg on hover , (but hover actions are not working now ;_;)
tewarig Jan 22, 2025
dc41225
fix: table hover actions :tick
tewarig Jan 22, 2025
bba72bf
fix: inconsistent size of checkbox header
tewarig Jan 22, 2025
5bec187
chore: added examples
tewarig Jan 22, 2025
ed69707
chore: update story
tewarig Jan 22, 2025
6c0be96
chore: pagination check and prop fix
tewarig Jan 22, 2025
41fb380
chore: throw error
tewarig Jan 22, 2025
9976ef5
chore: added error
tewarig Jan 22, 2025
0522eb1
fix: make table response
tewarig Jan 22, 2025
0209b1f
chore: update docs & components and types
tewarig Jan 22, 2025
9112ea0
chore: fixed ts and lint errors in code
tewarig Jan 22, 2025
14c19db
fix: more ts error and ignore few files now
tewarig Jan 22, 2025
48c5af6
chore: ignore table test
tewarig Jan 23, 2025
0d68ee5
chore: update test
tewarig Jan 23, 2025
30f7122
fix: ts error
tewarig Jan 23, 2025
e74cc16
fix: more ts error
tewarig Jan 23, 2025
494db30
chore: update virtuazlied table api
tewarig Jan 23, 2025
8be1b12
chore: added table body styles
tewarig Jan 23, 2025
7cb1f2e
refactor: styles for table and table body
tewarig Jan 23, 2025
fae4a09
chore: code clean up
tewarig Jan 23, 2025
9cafe8a
chore: added test & updated ref type
tewarig Jan 23, 2025
c1fc368
chore: added changeset
tewarig Jan 23, 2025
44c03ec
fix: lint error
tewarig Jan 24, 2025
0e3a352
chore: cleanup
tewarig Jan 24, 2025
51cf688
chore: update snap
tewarig Jan 24, 2025
213540c
chore: fix snap
tewarig Jan 24, 2025
43a0f2d
chore: removed ununsed code
tewarig Jan 24, 2025
2656536
chore: unused code
tewarig Jan 24, 2025
1e51e8e
chore: move updates
tewarig Jan 24, 2025
8d6df4c
chore: update snap
tewarig Jan 24, 2025
4375895
chore: update table
tewarig Jan 24, 2025
a013e48
chore: self review changes
tewarig Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-students-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@razorpay/blade': minor
---

feat(blade): add support for table virtualization
86 changes: 86 additions & 0 deletions packages/blade/codemods/aicodemod/knowledge/Table.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,89 @@ const TableComponent: StoryFn<typeof Table> = ({ ...args }) => {
);
};
```

# Virtualized Table

Virtaulized table is a table component that renders only the visible rows and columns. This is useful when you have a large dataset and you want to render only the visible rows and columns to improve the performance of the table.

Out implementation of virtualized table is an wrapper on top of react-table-library 's implementation. It provides a simple API to create a virtualized table.

## Props

most of props are same as Table component. we have added following table component.

```ts

isVirtualized = false, // default value is false , it is used to enable virtualization in table

ref = React.Ref<HTMLDivElement> | undefined, // ref to the table container , since in virtualized table we need to calculate the height and width of the table to render only the visible rows and columns
```
but their is a change in children prop of Table component. In virtualized table we need to pass a component named TableVirtulized that takes TableHeader, TableBody components.
VirtualizedTable is a wrapper on top of react-table-library's [Virtualized](https://github.com/table-library/react-table-library/blob/master/src/virtualized/Virtualized.tsx) component. It provides a simple API to create a virtualized table.


```ts
type VirtualizedWrapperProps<Item> = {
/**
* * @example
* <TableVirtulized
* tableData={tableData}
* rowHeight={(item, index) => {
* // header height and row height
* return index === 0 ? 50 : 57.5;
* }}
* header={() => (
* <TableHeader>
* <TableHeaderRow>
* <TableHeaderCell>ID</TableHeaderCell>
* <TableHeaderCell>Amount</TableHeaderCell>
* <TableHeaderCell>Account</TableHeaderCell>
* <TableHeaderCell>Date</TableHeaderCell>
* <TableHeaderCell>Method</TableHeaderCell>
* <TableHeaderCell>Status</TableHeaderCell>
* </TableHeaderRow>
* </TableHeader>
* )}
* body={(tableItem, index) => (
* <TableRow key={index} item={tableItem}>
* <TableCell>
* <Code size="medium">{tableItem.paymentId}</Code>
* </TableCell>
* <TableCell>
* <Amount value={tableItem.amount} />
* </TableCell>
* <TableCell>{tableItem.account}</TableCell>
* <TableCell>
* <Text>{tableItem.date}</Text>
* </TableCell>
* <TableCell>{tableItem.method}</TableCell>
* <TableCell>{tableItem.status}</TableCell>
* </TableRow>
* )}
* />
*
**/
/**
*
* should be a function that returns TableHeader,
*
**/
header: () => React.ReactElement;
/**
*
* should be a function that returns TableBody
*
* */
body: (tableItem: TableNode<Item>, index: number) => React.ReactElement;
/**
*
*/
tableData: TableNode<Item>[];
/**
* should be a function that returns the height of the row
* index 0 is the header height
**/
rowHeight: RowHeight;
};

```
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//ignore file for ts check
import React from 'react';
import { BasicExample } from './examples';
import StoryPageWrapper from '~utils/storybook/StoryPageWrapper';
Expand Down
Loading
Loading