Skip to content

Commit

Permalink
feat(Table): apply vibe component props in TableVirtualizedBody (#2163)
Browse files Browse the repository at this point in the history
  • Loading branch information
YossiSaadi authored Jun 5, 2024
1 parent 39dd8fb commit 2a4238e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { VibeComponentProps } from "../../../types";
import VirtualizedList, { VirtualizedListItem } from "../../VirtualizedList/VirtualizedList";
import TableBody from "../TableBody/TableBody";
import styles from "./TableVirtualizedBody.module.scss";
import cx from "classnames";
import { getTestId } from "../../../tests/test-ids-utils";
import { ComponentDefaultTestId } from "../../../tests/constants";
import { ScrollDirection } from "react-window";
import { TableContext } from "../Table/Table";
import { RowHeights } from "../Table/TableConsts";
Expand All @@ -13,7 +16,14 @@ export interface ITableVirtualizedBodyProps extends VibeComponentProps {
onScroll?: (horizontalScrollDirection: ScrollDirection, scrollTop: number, scrollUpdateWasRequested: boolean) => void;
}

const TableVirtualizedBody: FC<ITableVirtualizedBodyProps> = ({ items, rowRenderer, onScroll }) => {
const TableVirtualizedBody: FC<ITableVirtualizedBodyProps> = ({
items,
rowRenderer,
onScroll,
id,
className,
"data-testid": dataTestId
}) => {
const itemRenderer: ComponentProps<typeof VirtualizedList>["itemRenderer"] = useCallback(
(value, index: number, style: CSSProperties) => {
const element = rowRenderer(value);
Expand All @@ -24,7 +34,11 @@ const TableVirtualizedBody: FC<ITableVirtualizedBodyProps> = ({ items, rowRender
const { size } = useContext(TableContext);

return (
<TableBody className={styles.tableBody}>
<TableBody
className={cx(styles.tableBody, className)}
id={id}
data-testid={dataTestId || getTestId(ComponentDefaultTestId.TABLE_VIRTUALIZED_BODY, id)}
>
{items?.length && (
<VirtualizedList
items={items}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export enum ComponentDefaultTestId {
DIALOG = "dialog",
TABLE = "table",
TABLE_BODY = "table-body",
TABLE_VIRTUALIZED_BODY = "table-virtualized-body",
TABLE_CELL = "table-cell",
TABLE_HEADER = "table-header",
TABLE_HEADER_CELL = "table-header-cell",
Expand Down

0 comments on commit 2a4238e

Please sign in to comment.