import { Box, HStack, SpanBox, VStack } from './LayoutPrimitives' import { styled } from '../tokens/stitches.config' import { StyledText } from './StyledText' import { InfoLink } from './InfoLink' import { Button } from './Button' import { PencilSimple, Plus, Trash } from 'phosphor-react' import { isDarkTheme } from '../../lib/themeUpdater' interface TableProps { heading: string infoLink?: string onAdd?: () => void headers: string[] rows: Map> onDelete?: (id: string) => void onEdit?: (obj: any) => void } const HeaderWrapper = styled(Box, { width: '100%', '@md': { display: 'block', }, }) const TableCard = styled(Box, { backgroundColor: '$grayBg', display: 'flex', alignItems: 'center', padding: '10px 12px', border: '0.5px solid $grayBgActive', width: '100%', '&:hover': { border: '0.5px solid #FFD234', }, '@md': { paddingLeft: '0', }, }) const TableHeading = styled(Box, { backgroundColor: '$grayBgActive', border: '1px solid rgba(0, 0, 0, 0.06)', display: 'none', alignItems: 'center', padding: '14px 0 14px 40px', borderRadius: '5px 5px 0px 0px', width: '100%', '@md': { display: 'flex', }, }) const Input = styled('input', { backgroundColor: 'transparent', color: '$grayTextContrast', marginTop: '5px', '&[disabled]': { border: 'none', }, }) const IconButton = styled(Button, { variants: { style: { ctaWhite: { color: 'red', padding: '10px', display: 'flex', justifyContent: 'center', alignItems: 'center', border: '1px solid $grayBorder', boxSizing: 'border-box', borderRadius: 6, width: 40, height: 40, }, }, }, }) export function Table(props: TableProps): JSX.Element { const iconColor = isDarkTheme() ? '#D8D7D5' : '#5F5E58' return ( {props.heading} {props.infoLink && } {props.onAdd && ( )} {props.headers.map((header, index) => ( {header} ))} {Array.from(props.rows.keys()).map((key, index) => ( {Object.values(props.rows.get(key) || {}).map((cell, index) => ( ))} {props.onEdit && ( { props.onEdit && props.onEdit({ ...props.rows.get(key), id: key }) }} > )} {props.onDelete && ( { props.onDelete && props.onDelete(key) }} > )} ))} ) }