import { dataTypes, Binding, Location } from '@adalo/constants' import { BlurhashMetadataRemote } from 'types' import { TableTheme } from './theme' export type CellProps = { cell: CellData theme: TableTheme } export type FileValue = { filename: string size: string url: string } export type ImageValue = { filename: string height: number metadata: BlurhashMetadataRemote size: number url: string width: number } export type FieldValue = | string | number | boolean | Location | FileValue | ImageValue export type DataTypeKeys = typeof dataTypes[keyof typeof dataTypes] export type CellStyle = { minWidth?: number width?: number flex: number alignItems: 'flex-start' | 'center' | 'flex-end' } export type CellData = { binding?: Binding type: DataTypeKeys label: string value: FieldValue fieldId: string style: CellStyle } export type Field = { fieldId: string label: string type: DataTypeKeys binding: Binding } export type BindingDataItem = { id: number } & { [key: string]: FieldValue } export type PaginationArrowProps = { direction: 'next' | 'previous' theme: CellProps['theme'] } export type SortArrowProps = { direction: 'asc' | 'desc' theme: CellProps['theme'] } export type TableSort = { direction: 'asc' | 'desc' fieldId: string type: typeof dataTypes[keyof typeof dataTypes] } | null export type TableColumn = { label: string style: CellStyle sort: 'asc' | 'desc' | null } export type TableState = { columns: TableColumn[] data: { id: number cells: CellData[] }[] }