import React, { forwardRef, useCallback, useRef } from "react"; import { VibeComponent, VibeComponentProps } from "../../../types"; import { ITableCellProps } from "../TableCell/TableCell"; import useMergeRef from "../../../hooks/useMergeRef"; import { getTestId } from "../../../tests/test-ids-utils"; import { ComponentDefaultTestId } from "../../../tests/constants"; import cx from "classnames"; import styles from "./TableRow.module.scss"; import { useTableRowMenu } from "../context/TableRowMenuContext/TableRowMenuContext"; export interface ITableRowProps extends VibeComponentProps { /** * Does the row have a highlighted style */ highlighted?: boolean; children?: React.ReactElement | React.ReactElement[]; style?: React.CSSProperties; } const TableRow: VibeComponent = forwardRef( ({ highlighted, children, style, id, className, "data-testid": dataTestId }, ref) => { const componentRef = useRef(null); const mergedRef = useMergeRef(componentRef, ref); const { onMouseOverRow, onMouseLeaveRow } = useTableRowMenu(); const onMouseEnter = useCallback(() => { onMouseOverRow(componentRef); }, [onMouseOverRow]); return (
{children}
); } ); export default TableRow;