@are-visual/virtual-table
Version:
### VirtualTable
50 lines (46 loc) • 2.22 kB
TypeScript
import * as _are_visual_virtual_table from '@are-visual/virtual-table';
import { ColumnExtra } from '@are-visual/virtual-table';
import { ComponentType, Key, ReactNode, HTMLAttributes, TdHTMLAttributes } from 'react';
type RowSelectMethod = 'all' | 'none' | 'invert' | 'single' | 'multiple';
type SelectionSelectFn<T = any> = (record: T, selected: boolean, selectedRows: T[], nativeEvent: Event) => void;
type GetComponentProps<DataType> = (data: DataType, index?: number) => HTMLAttributes<any> & TdHTMLAttributes<any>;
type SelectionColumnTitleProps = SelectionProps & {
allKeys: Key[];
onClear: () => void;
onSelectAll: () => void;
onSelectInvert: () => void;
};
interface TableRowSelection<T = any> {
component?: ComponentType<SelectionProps>;
/** Keep the selection keys in list even the key not exist in `dataSource` anymore */
preserveSelectedRowKeys?: boolean;
multiple?: boolean;
selectedRowKeys?: Key[];
defaultSelectedRowKeys?: Key[];
onChange?: (selectedRowKeys: Key[], selectedRows: T[], info: {
type: RowSelectMethod;
}) => void;
getSelectionProps?: (record: T) => SelectionProps & Record<string, unknown>;
onSelect?: SelectionSelectFn<T>;
hideSelectAll?: boolean;
fixed?: boolean;
columnWidth?: number;
columnTitle?: ReactNode | ((checkboxNode: ReactNode, props: SelectionColumnTitleProps) => ReactNode);
renderCell?: (value: boolean, record: T, index: number, originNode: ReactNode) => ReactNode;
onCell?: GetComponentProps<T>;
extraColumnProps?: ColumnExtra;
}
interface SelectionProps {
multiple?: boolean;
value?: boolean;
onChange?: (nextValue: boolean, e: Event) => void;
indeterminate?: boolean;
disabled?: boolean;
}
declare const SELECTION_COLUMN_KEY = "VirtualTable.SELECTION_COLUMN";
/**
* 为 Table 实现多选、单选功能,不传入 options 则是禁用插件
*/
declare const tableSelection: <T = any>(options?: TableRowSelection<T> | undefined) => _are_visual_virtual_table.Middleware<T>;
export { SELECTION_COLUMN_KEY, tableSelection };
export type { GetComponentProps, RowSelectMethod, SelectionColumnTitleProps, SelectionProps, SelectionSelectFn, TableRowSelection };