import React, { ReactNode, CSSProperties } from 'react'; import { Surface } from './Surface'; export interface TableProps { children: ReactNode; className?: string; } export const Table = ({ children, className }: TableProps) => { return ( {children}
); }; export interface TableHeaderProps { children: ReactNode; className?: string; textAlign?: 'left' | 'center' | 'right'; w?: string; } export const TableHeader = ({ children, className, textAlign, w }: TableHeaderProps) => { return ( {React.Children.map(children, child => { if (React.isValidElement(child)) { return React.cloneElement(child as any, { textAlign: textAlign || (child.props as any).textAlign, w: w || (child.props as any).w }); } return child; })} ); }; export const TableHead = TableHeader; export const TableBody = ({ children, className }: { children: ReactNode, className?: string }) => { return ( {children} ); }; export const TableRow = ({ children, onClick, className, variant, clickable, bg, ...props }: { children: ReactNode, onClick?: () => void, className?: string, variant?: string, clickable?: boolean, bg?: string, [key: string]: any }) => { const isClickable = clickable || !!onClick; return ( {children} ); }; export interface TableHeaderCellProps { children: ReactNode; textAlign?: 'left' | 'center' | 'right'; w?: string; className?: string; } export const TableHeaderCell = ({ children, textAlign, w, className }: TableHeaderCellProps) => { const alignClass = textAlign === 'center' ? 'text-center' : (textAlign === 'right' ? 'text-right' : 'text-left'); return ( {children} ); }; export interface TableCellProps { children: ReactNode; textAlign?: 'left' | 'center' | 'right'; className?: string; py?: number; colSpan?: number; w?: string; position?: string; [key: string]: any; } export const TableCell = ({ children, textAlign, className, py, colSpan, w, position, ...props }: TableCellProps) => { const alignClass = textAlign === 'center' ? 'text-center' : (textAlign === 'right' ? 'text-right' : 'text-left'); return ( {children} ); };