es-grid-template
Version:
es-grid-template
102 lines (101 loc) • 3.69 kB
TypeScript
import type { ReactElement, ReactNode } from 'react';
import type React from 'react';
import type { ColumnTemplate, CommandItem, FilterOperator, IColumnType, IFormat, ITextAlign, TypeFilter } from '../grid-component/type';
export type CellProps = React.TdHTMLAttributes<HTMLTableCellElement>;
export type FilterState = {
field: any;
key: any;
column: ArtColumn;
filteredKeys: any[];
operator: string | undefined;
};
export interface ArtColumnStaticPart {
/** Column name */
headerText?: string;
/** Field in the data */
field: string;
/** Display title of the column; when rendering on the page, this field overrides the `name` field */
title?: ReactNode;
headerTemplate?: ReactNode | ((col: any) => ReactNode);
/** Column width; required if the column is locked */
width?: number;
fixed?: 'left' | 'right';
/** @deprecated Whether the column is hidden */
hidden?: boolean;
/** Whether the column is locked (fixed) */
lock?: boolean;
/** Props for the header cell */
headerCellProps?: CellProps;
/** Feature toggles */
features?: Record<string, any>;
/** Whether filtering is allowed */
allowFiltering?: boolean;
/**
* @deprecated Please use `allowSortering` instead.
* @since 1.7.25
*/
sorter?: boolean;
isSummary?: boolean;
/** Whether sorting is allowed */
allowSortering?: boolean;
/** Filter operator */
operator?: FilterOperator;
/** Whether to hide the operator selector */
hideOperator?: boolean;
/** Filter type */
typeFilter?: TypeFilter;
/** Custom filter icon */
filterIcon?: any;
/** Column type */
type?: IColumnType;
/** Data source dropdown options for the column */
source?: any[];
/** Format configuration or formatter function */
format?: IFormat | ((rowData: any) => IFormat);
/** Alignment of the text or content inside the cell */
textAlign?: ITextAlign;
headerTextAlign?: ITextAlign;
onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, column: any) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
commandItems?: CommandItem[];
tooltipDescription?: string | ((rowData: any) => string | ReactNode);
headerTooltip?: boolean | string | (() => ReactNode | ReactElement);
}
export interface ArtColumnDynamicPart<RecordType = any> {
/** Custom data retrieval method */
getValue?: (row: any, rowIndex: number) => any;
/** Custom render method */
template?: (args: ColumnTemplate<RecordType>) => ReactNode;
/** Custom method to get cell props */
getCellProps?: (value: any, row: any, rowIndex: number) => CellProps;
/** Custom method to get cell SpanRect */
getSpanRect?: (value: any, row: any, rowIndex: number) => SpanRect;
}
export interface ArtColumn extends ArtColumnStaticPart, ArtColumnDynamicPart {
children?: ArtColumn[];
}
/** SpanRect is used to describe the boundaries of merged cells
* Note that top/left is inclusive, while bottom/right is exclusive */
export interface SpanRect {
top: number;
bottom: number;
left: number;
right: number;
}
export interface AbstractTreeNode {
children?: AbstractTreeNode[];
}
export type SortOrder = 'descend' | 'ascend' | 'none';
export type SortItem = {
columnKey: string;
field: string;
order: SortOrder;
};
export type Transform<T> = (input: T) => T;
export type TableTransform = Transform<{
columns: ArtColumn[];
dataSource: any[];
}>;
export interface HoverRange {
start: number;
end: number;
}