import { CSSProperties, DragEvent, ReactNode } from 'react'; import { PaginationProps } from '../pagination'; import { InputProps } from '../input'; import { AvailableVirtualListProps } from '../_class/virtual-list'; export declare type TransferItem = { key: string; value: string; disabled?: boolean; }; export declare type TransferListType = 'source' | 'target' | string; declare type TransferListTitle = string | ((params: { countTotal: number; countSelected: number; clear: () => void; checkbox: ReactNode; searchInput: ReactNode; }) => ReactNode); interface TransferPropsWithArrayType { /** * 搜索框默认提示文字,通过数组为左右列表传入不同属性 */ searchPlaceholder?: string | string[]; /** * 左右两栏是否显示搜索框,通过数组为左右列表传入不同属性 */ showSearch?: boolean | InputProps | Array; /** * 左右两栏是否显示底部重置按钮,通过数组为左右列表传入不同属性 */ showFooter?: boolean | ReactNode | Array; /** * 是否使用翻页,也可传入 `Pagination` 的配置,通过数组为左右列表传入不同属性 */ pagination?: boolean | PaginationProps | Array; /** * 左右两栏框的样式,通过数组为左右列表传入不同属性 */ listStyle?: CSSProperties | CSSProperties[]; } /** * @title Transfer */ export interface TransferProps extends TransferPropsWithArrayType { prefixCls?: string; style?: CSSProperties; className?: string | string[]; /** * 自定义列表渲染函数 */ children?: (props: TransferCustomListProps) => ReactNode; /** * 穿梭框数据源,其中一部分会被渲染到左边一栏,targetKeys 中指定的除外 */ dataSource?: TransferItem[]; /** * 默认的 `targetKeys` * @defaultValue [] */ defaultTargetKeys?: string[]; /** * 默认的 `selectKeys` * @defaultValue [] */ defaultSelectedKeys?: string[]; /** * 渲染到右边一栏数据的 key 集合 */ targetKeys?: string[]; /** * 当前应该有哪些项被选中 */ selectedKeys?: string[]; /** * 穿梭框左右栏标题数组 * @defaultValue ['Source', 'Target'] */ titleRender?: Array; /** * 穿梭按钮的文案数组,顺序从上至下 */ operationTexts?: string[] | ReactNode[]; /** * 禁用穿梭框 */ disabled?: boolean; /** * 单向 */ oneWay?: boolean; /** * 简单模式 */ simple?: boolean | { retainSelectedItems?: boolean; }; /** * 列表内条目是否可拖拽 */ draggable?: boolean; /** * 穿梭中间操作部分的样式 */ operationStyle?: CSSProperties; /** * 传递虚拟滚动属性。 */ virtualListProps?: AvailableVirtualListProps; /** * 每行数据渲染函数 */ render?: (item: TransferItem) => any; /** * 搜索框筛选算法 * @defaultValue (inputValue, item) => item.value.indexOf(inputValue) !== -1 */ filterOption?: (inputValue: string, item: TransferItem) => boolean; /** * 选中项在两栏之间转移时的回调 */ onChange?: (newTargetKeys: string[], direction: 'source' | 'target' | string, moveKeys: string[]) => void; /** * 数据项选中状态发生改变的回调 */ onSelectChange?: (leftSelectedKeys: string[], rightSelectedKeys: string[]) => void; /** * 搜索框输入进行搜索时回调函数 */ onSearch?: (value: string, type?: 'source' | 'target' | string) => void; /** * 点击重置按钮后的回调 */ onResetData?: () => void; /** * 节点开始拖拽的回调 */ onDragStart?: (e: DragEvent, item: TransferItem) => void; /** * 节点结束拖拽的回调 */ onDragEnd?: (e: DragEvent, item: TransferItem) => void; /** * 节点离开可释放目标上时的回调 */ onDragLeave?: (e: DragEvent, item: TransferItem) => void; /** * 节点被拖拽至可释放目标上时的回调 */ onDragOver?: (e: DragEvent, item: TransferItem) => void; /** * 节点在可释放目标上释放时的回调 */ onDrop?: (info: { e: DragEvent; dragItem: TransferItem; dropItem: TransferItem; dropPosition: number; }) => void; } export interface TransferListProps extends Pick { searchPlaceholder?: string; showSearch?: boolean | InputProps; showFooter?: boolean | ReactNode; pagination?: boolean | PaginationProps; title: TransferListTitle; allowClear: boolean; selectedKeys: string[]; validKeys: string[]; selectedDisabledKeys: string[]; listType: TransferListType; handleSelect: (newSelectKeys: string[]) => void; handleRemove: (removeKeys: string[]) => void; renderList: (props: TransferCustomListProps) => ReactNode; renderHeaderUnit: (countSelected: any, countAll: any) => ReactNode; } export interface TransferCustomListProps extends Pick { filteredItems: TransferItem[]; onItemSelect: (key: string, selected: boolean) => void; onItemRemove: (key: string) => void; onItemSelectAll: (keys: string[], selected: boolean) => void; } export interface TransferItemProps extends Pick { item: TransferItem; droppable: boolean; onItemSelect: (key: string, selected: boolean) => void; onItemRemove: (key: string) => void; onDrop?: (e: DragEvent, item: TransferItem, dropPosition: number) => void; } export {};