import React from 'react'; import {Flex} from '@gravity-ui/uikit'; import {cn} from '../../utils/cn'; import {TableKeyboardNavigationScope} from '../TableKeyboardNavigation/TableKeyboardNavigation'; import {TableSkeleton} from '../TableSkeleton/TableSkeleton'; import {useTableScroll} from './useTableScroll'; import './TableWithControlsLayout.scss'; const b = cn('ydb-table-with-controls-layout'); interface TableWithControlsLayoutItemProps { children: React.ReactNode; renderExtraControls?: () => React.ReactNode; className?: string; fullHeight?: boolean; keyboardNavigation?: boolean; inheritKeyboardNavigation?: boolean; keyboardNavigationResetKey?: string; } export interface TableWrapperProps extends Omit { loading?: boolean; scrollContainerRef?: React.RefObject; scrollDependencies?: any[]; children: React.ReactNode; } export const TableWithControlsLayout = ({ children, className, fullHeight, keyboardNavigation = true, inheritKeyboardNavigation = false, keyboardNavigationResetKey, }: TableWithControlsLayoutItemProps) => { const containerRef = React.useRef(null); return (
{children}
); }; TableWithControlsLayout.Controls = function TableControls({ children, renderExtraControls, className, }: TableWithControlsLayoutItemProps) { return (
{children}
{renderExtraControls?.()}
); }; TableWithControlsLayout.Table = function Table({ children, loading, className, scrollContainerRef, scrollDependencies = [], }: TableWrapperProps) { // Create an internal ref for the table container const tableContainerRef = React.useRef(null); // Use the internal ref for scrolling useTableScroll({ tableContainerRef, scrollContainerRef, dependencies: scrollDependencies, }); if (loading) { return ; } return (
{children}
); }; TableWithControlsLayout.Footer = function TableFooter({ children, className, }: { children: React.ReactNode; className?: string; }) { return (
{children}
); };