diff --git a/packages/react/src/table/table.tsx b/packages/react/src/table/table.tsx index d80bf13f5..bed9b96e8 100644 --- a/packages/react/src/table/table.tsx +++ b/packages/react/src/table/table.tsx @@ -31,16 +31,6 @@ import { useHorizontalScroll, } from '../utils'; -const tableVariants = cva({ - base: ['relative'], - variants: { - variant: { - default: '', - 'zebra-striped': '', - }, - }, -}); - const tableRowVariants = cva({ base: [ 'data-focus-visible:outline-focus-inset', @@ -79,20 +69,14 @@ type TableCellProps = RACCellProps & children: React.ReactNode; }; -// Used to deal with showing or hiding scroll indicators during column resizing -const TableScrollContainerContext = createContext<{ - isResizing: boolean; -}>({ - isResizing: false, -}); +type _TableScrollContainerProps = { + children: React.ReactNode; +}; -/** - * A container component for displaying tabular data with horizontal scrolling support. - */ -function Table(props: TableProps) { - const { className, children, variant = 'default', ...restProps } = props; +const _TableScrollContainer = ({ children }: _TableScrollContainerProps) => { + const containerContext = useContext(TableContainerContext); - const { isResizing } = useContext(TableScrollContainerContext); + const isResizing = containerContext?.isResizing ?? false; const { scrollContainerRef, @@ -101,6 +85,7 @@ function Table(props: TableProps) { hasScrollingOccurred, } = useHorizontalScroll([isResizing]); + // This has to be moved into a useEffect since we are stepping outside of React const handleScroll = useCallback( (direction: ScrollDirection) => { const container = scrollContainerRef.current; @@ -114,43 +99,60 @@ function Table(props: TableProps) { }, [scrollContainerRef], ); + return ( -