es-grid-template
Version:
es-grid-template
108 lines (107 loc) • 4.61 kB
TypeScript
import type { Dispatch, SetStateAction } from 'react';
import type { ColumnTable, ExpandableConfig, IFormat, IWrapSettings, Locale, PaginationConfig, RangeState, RecordDoubleClickEventArgs, RowClassName, SelectionSettings, SourceFilter } from "./../grid-component/type";
import type { SubmitHandler } from "react-hook-form";
import type { ExpandedState, Row, Table } from '@tanstack/react-table';
export type IPositionCell = {
rowId: string;
colId: string;
} | undefined;
export interface IContext<T> {
t?: any;
prefix: string;
id: string;
rowKey: string;
originData: any[];
dataSource: any[];
format?: IFormat;
expandable?: ExpandableConfig<T>;
wrapSettings?: IWrapSettings;
setExpanded: Dispatch<SetStateAction<ExpandedState>>;
expanded: ExpandedState;
recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
recordClick?: (args: RecordDoubleClickEventArgs<T>) => void;
selectionSettings?: SelectionSettings;
isSelectionChange?: {
isChange: boolean;
type: string;
rowData: T;
rowsData: T[];
};
setIsSelectionChange: Dispatch<SetStateAction<{
isChange: boolean;
type: string;
rowData: T;
rowsData: T[];
}>>;
setSorterChange: Dispatch<SetStateAction<boolean>>;
setFilterChange: Dispatch<SetStateAction<boolean>>;
onContextMenu?: (data: T) => (event: any) => void;
locale?: Locale;
lang?: string;
windowSize: {
innerHeight: number;
innerWidth: number;
};
control?: any;
errors?: any;
handleSubmit?: any;
onSubmit?: SubmitHandler<any>;
getValues?: any;
reset?: any;
setValue?: any;
handleCellChange?: (args: ContextCellChange) => void;
handleCellChangeAndAddRow?: (args: ContextCellChange) => void;
editingKey?: string;
setEditingKey?: Dispatch<SetStateAction<string>>;
rangeState?: RangeState;
setRangeState?: Dispatch<SetStateAction<RangeState | undefined>>;
rangePasteState?: RangeState;
setRangePasteState?: Dispatch<SetStateAction<RangeState | undefined>>;
startCell?: IPositionCell;
setStartCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
endCell?: IPositionCell;
setEndCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
startPasteCell?: IPositionCell;
setStartPasteCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
endPasteCell?: IPositionCell;
setEndPasteCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
isSelecting?: boolean;
setIsSelecting?: Dispatch<SetStateAction<boolean>>;
isPasting?: boolean;
setIsPasting?: Dispatch<SetStateAction<boolean>>;
focusedCell?: IPositionCell;
setFocusedCell?: Dispatch<SetStateAction<IPositionCell | undefined>>;
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[], copyRows: T[]) => void;
handleDeleteContent?: () => void;
handleAddMulti?: (item: any, n: number, id?: string) => void;
dataErrors?: any[];
isDataTree: boolean;
handleCellClick?: (rowNumber: number, record: T, column: ColumnTable, rowId: string, cellValue: any) => void;
pagination?: false | PaginationConfig;
rowClassName?: string | RowClassName<T>;
table?: Table<T>;
rowEditable?: (rowData: T) => boolean;
onRowStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | ((data: T, row: Row<T>) => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
onRowHeaderStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
onRowFooterStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
dataSourceFilter?: SourceFilter[];
onExpandClick?: (args: {
expandedKeys: string[];
key: string;
rowData: any;
}) => void;
setIsExpandClick: Dispatch<SetStateAction<boolean>>;
}
export declare const TableContext: import("react").Context<IContext<any>>;
export type ContextCellChange = {
key: string;
record: any;
field: string;
option: any;
indexRow: number;
indexCol: number;
newState?: any;
prevState?: any;
type: 'enter' | 'blur' | 'outClick';
addNewRow?: boolean;
};