import React, { createContext, useMemo, useContext } from 'react'; import { Table as ExpoTable, THead as ExpoTHead, TBody as ExpoTBody, TFoot as ExpoTFoot, TR as ExpoTR, Caption as ExpoTCaption, } from '@expo/html-elements'; import { tableStyle, tableHeaderStyle, tableBodyStyle, tableFooterStyle, tableHeadStyle, tableRowStyleStyle, tableDataStyle, tableCaptionStyle, } from './styles'; import { Text, View } from 'react-native'; const TableHeaderContext = createContext<{ isHeaderRow: boolean; }>({ isHeaderRow: false, }); const TableFooterContext = createContext<{ isFooterRow: boolean; }>({ isFooterRow: false, }); type ITableProps = React.ComponentProps; type ITableHeaderProps = React.ComponentProps; type ITableBodyProps = React.ComponentProps; type ITableFooterProps = React.ComponentProps; type ITableHeadProps = React.ComponentProps & { useRNView?: boolean; }; type ITableRowProps = React.ComponentProps; type ITableDataProps = React.ComponentProps & { useRNView?: boolean; }; type ITableCaptionProps = React.ComponentProps; const Table = React.forwardRef< React.ComponentRef, ITableProps >(({ className, ...props }, ref) => { return ( ); }); const TableHeader = React.forwardRef< React.ComponentRef, ITableHeaderProps >(function TableHeader({ className, ...props }, ref) { const contextValue = useMemo(() => { return { isHeaderRow: true, }; }, []); return ( ); }); const TableBody = React.forwardRef< React.ComponentRef, ITableBodyProps >(function TableBody({ className, ...props }, ref) { return ( ); }); const TableFooter = React.forwardRef< React.ComponentRef, ITableFooterProps >(function TableFooter({ className, ...props }, ref) { const contextValue = useMemo(() => { return { isFooterRow: true, }; }, []); return ( ); }); const TableHead = React.forwardRef< React.ComponentRef, ITableHeadProps >(function TableHead({ useRNView = false, className, ...props }, ref) { if (useRNView) { return ( ); } else { return ( ); } }); const TableRow = React.forwardRef< React.ComponentRef, ITableRowProps >(function TableRow({ className, ...props }, ref) { const { isHeaderRow } = useContext(TableHeaderContext); const { isFooterRow } = useContext(TableFooterContext); return ( ); }); const TableData = React.forwardRef< React.ComponentRef, ITableDataProps >(function TableData({ useRNView = false, className, ...props }, ref) { if (useRNView) { return ( ); } else { return ( ); } }); const TableCaption = React.forwardRef< React.ComponentRef, ITableCaptionProps >(({ 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, };