import React, { createContext, useMemo, useContext } from 'react'; import { tableStyle, tableHeaderStyle, tableBodyStyle, tableFooterStyle, tableHeadStyle, tableRowStyleStyle, tableDataStyle, tableCaptionStyle, } from './styles'; const TableHeaderContext = createContext<{ isHeaderRow: boolean; }>({ isHeaderRow: false, }); const TableFooterContext = createContext<{ isFooterRow: boolean; }>({ isFooterRow: false, }); const Table = React.forwardRef>( function Table({ className, ...props }, ref) { return ( ); } ); const TableHeader = React.forwardRef< HTMLTableSectionElement, React.ComponentProps<'thead'> >(function TableHeader({ className, ...props }, ref) { const contextValue = useMemo(() => { return { isHeaderRow: true, }; }, []); return ( ); }); const TableBody = React.forwardRef< HTMLTableSectionElement, React.ComponentProps<'tbody'> >(function TableBody({ className, ...props }, ref) { return ( ); }); const TableFooter = React.forwardRef< HTMLTableSectionElement, React.ComponentProps<'tfoot'> >(function TableFooter({ className, ...props }, ref) { const contextValue = useMemo(() => { return { isFooterRow: true, }; }, []); return ( ); }); const TableHead = React.forwardRef< HTMLTableCellElement, React.ComponentProps<'th'> >(function TableHead({ className, ...props }, ref) { return ( ); }); const TableData = React.forwardRef< HTMLTableCellElement, React.ComponentProps<'td'> >(function TableData({ className, ...props }, ref) { return (
); }); const TableRow = React.forwardRef< HTMLTableRowElement, React.ComponentProps<'tr'> >(function TableRow({ className, ...props }, ref) { const { isHeaderRow } = useContext(TableHeaderContext); const { isFooterRow } = useContext(TableFooterContext); return (
); }); const TableCaption = React.forwardRef< HTMLTableCaptionElement, React.ComponentProps<'caption'> >(function TableCaption({ className, ...props }, ref) { return (
); }); Table.displayName = 'Table'; TableHeader.displayName = 'TableHeader'; TableBody.displayName = 'TableBody'; TableFooter.displayName = 'TableFooter'; TableHead.displayName = 'TableHead'; TableRow.displayName = 'TableRow'; TableData.displayName = 'TableData'; TableCaption.displayName = 'TableCaption'; export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableData, TableCaption, };