-
Notifications
You must be signed in to change notification settings - Fork 151
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): add virtualization #2489
base: master
Are you sure you want to change the base?
Conversation
const isVirtualized = (React.isValidElement<{ | ||
header?: () => React.ReactElement; | ||
children?: React.ReactNode; | ||
}>(tableRootComponent) && | ||
Array.isArray(tableRootComponent.props?.children) && | ||
tableRootComponent.props.children?.length && | ||
React.isValidElement<{ children?: React.ReactNode }>(tableRootComponent.props?.children[1]) && | ||
typeof tableRootComponent.props?.children[1]?.props.children === 'function') as boolean; |
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.
This looks a little complex 🙈 Can you add comment on how this checks if table is virualized?
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.
refactored this. no jsx walking
paddingX="0" | ||
paddingY="0" |
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.
This is allowed in TS 🙈 ?
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.
Why are these different story files? we can have one TableVirtualized.stories.tsx and add virtualized tables there right?
if (isVirtualized) { | ||
if ( | ||
React.isValidElement<{ header?: () => React.ReactElement }>(tableRootComponent) && | ||
tableRootComponent?.props.header | ||
) { | ||
if (React.isValidElement(tableRootComponent?.props.header())) { | ||
const tableHeaderRow = tableRootComponent.props.header().props.children; | ||
if ( | ||
React.isValidElement<{ children?: React.ReactNode }>(tableHeaderRow) && | ||
tableHeaderRow.props.children | ||
) { | ||
const tableHeaderCells = React.Children.toArray(tableHeaderRow.props.children); | ||
return tableHeaderCells.length; | ||
} | ||
} | ||
} | ||
} | ||
|
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.
This won't be needed as we discussed
@@ -156,8 +199,17 @@ const _Table = <Item,>({ | |||
undefined, | |||
); | |||
const [hasHoverActions, setHasHoverActions] = React.useState(false); | |||
const tableRootComponent = children([]); | |||
const isVirtualized = (React.isValidElement<{ |
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.
@@ -12,6 +12,7 @@ const ComponentIds = { | |||
TableFooter: 'TableFooter', | |||
TableFooterRow: 'TableFooterRow', | |||
TableFooterCell: 'TableFooterCell', | |||
VirtualizedTable: 'VirtualizedTable', |
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.
This doesn't exist right?
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.
it is being used in TableVirtualizedWrapper
<TableBody<Item>> | ||
{(tableItem, index) => ( |
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.
<TableBody<Item>> | |
{(tableItem, index) => ( | |
<TableBody> | |
{(tableItem: Item, index) => ( |
{(tableData) => ( | ||
<> | ||
{() => ( | ||
<TableVirtualizedWrapper rowHeight={() => 57}> |
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.
we can remove virtualization from Basic story I guess
tableRootComponent.props.children?.length && | ||
React.isValidElement<{ children?: React.ReactNode }>(tableRootComponent.props?.children[1]) && | ||
typeof tableRootComponent.props?.children[1]?.props.children === 'function') as boolean; | ||
const isVirtualized = getComponentId(tableRootComponent) === ComponentIds.VirtualizedTable; |
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.
nice 👯
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.
Looks good to me
Description
Changes
Additional Information
dev checklist -
[ x ] vtable height be changed
[ x ] check why check box look weird ?
[ x ] need to make row similar to normal table
[ x ] should check the space of table.
[ x ] vtable should be aligned as normal table.
[ x ] hover actions
[ x ] sticky column
[ x ] table header
[ x ] fix ts error
[ x ] unified styles for virtualized table
[ x ] add tests
Component Checklist