import { ComponentPropsWithRef, ForwardedRef, PropsWithoutRef, ReactElement, RefAttributes, WeakValidationMap, } from 'react'; import { LeafyGreenTableCell, LGRowData } from '../useLeafyGreenTable'; export type Align = Extract< ComponentPropsWithRef<'td'>['align'], 'left' | 'right' | 'center' >; interface BaseCellProps extends ComponentPropsWithRef<'td'> { /** * Alignment of the cell's contents * * Overrides ``'s deprecated `align` prop */ align?: Align; /** * A `className` applied to the inner `div` of the Cell */ contentClassName?: string; } export interface CellProps extends BaseCellProps { /** * The cell object that is returned when mapping through a row passed from the `useLeafyGreenTable` or `useLeafyGreenVirtualTable` hook. */ cell?: LeafyGreenTableCell; } export type InternalCellWithRTRequiredProps = Omit< CellProps, 'cell' > & Required, 'cell'>>; export interface InternalCellProps extends BaseCellProps {} export interface InternalCellWithRTProps extends InternalCellWithRTRequiredProps {} // https://stackoverflow.com/a/58473012 // React.forwardRef can only work with plain function types. /** * Type definition for `Cell` that works with generics. * cell is optional */ export interface CellComponentType { ( props: CellProps, ref: ForwardedRef, ): ReactElement | null; displayName?: string; propTypes?: | WeakValidationMap< PropsWithoutRef & RefAttributes> > | undefined; } /** * Type definition for `InternalCellWithRT` that works with generics. * cell is required */ export interface InternalCellWithRTComponentType { ( props: InternalCellWithRTProps, ref: ForwardedRef, ): ReactElement | null; displayName?: string; propTypes?: | WeakValidationMap< PropsWithoutRef & RefAttributes> > | undefined; }