hightable
Version:
A dynamic windowed scrolling table component for react
42 lines (41 loc) • 2.19 kB
TypeScript
import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
import type { ResolvedValue } from '../../helpers/dataframe/index.js';
export interface CellContentProps {
stringify: (value: unknown) => string | undefined;
cell?: ResolvedValue;
col: number;
row?: number;
}
interface Props {
/** aria column index */
ariaColIndex: number;
/** aria row index */
ariaRowIndex: number;
/** column index in the original dataframe, used for callbacks like onDoubleClickCell */
columnIndex: number;
/** index in the visible columns array (used for styling/widths) */
visibleColumnIndex: number;
/** function to stringify the cell value, used for default rendering and for copy to clipboard */
stringify: (value: unknown) => string | undefined;
/** cell value, undefined if the value has not been fetched yet, or if the value is actually undefined. Use hasResolved to distinguish these cases. */
cellValue?: unknown;
/** whether the cell value has been resolved */
hasResolved?: boolean;
/** class name */
className?: string;
/** double click callback */
onDoubleClickCell?: (event: MouseEvent, col: number, row: number) => void;
/** mouse down callback */
onMouseDownCell?: (event: MouseEvent, col: number, row: number) => void;
/** key down callback, for accessibility, it should be passed if onDoubleClickCell is passed. It can handle more than that action though. */
onKeyDownCell?: (event: KeyboardEvent, col: number, row: number) => void;
/** the row index in the original data, undefined if the value has not been fetched yet */
rowNumber?: number;
/** custom cell content component, if not provided, the default stringified value will be used */
renderCellContent?: (props: CellContentProps) => ReactNode;
}
/**
* Render a table cell <td> with title and optional custom rendering
*/
export default function Cell({ cellValue, hasResolved, onDoubleClickCell, onMouseDownCell, onKeyDownCell, stringify, columnIndex, visibleColumnIndex, className, ariaColIndex, ariaRowIndex, rowNumber, renderCellContent }: Props): import("react/jsx-runtime").JSX.Element;
export {};