import React, { useState } from 'react'; import { Space, Switch, Table, Tag, Transfer } from 'antd'; import type { GetProp, TableColumnsType, TableProps, TransferProps } from 'antd'; type TransferItem = GetProp[number]; type TableRowSelection = TableProps['rowSelection']; interface RecordType { key: string; title: string; description: string; tag: string; } interface DataType { key: string; title: string; description: string; tag: string; } interface TableTransferProps extends TransferProps { dataSource: DataType[]; leftColumns: TableColumnsType; rightColumns: TableColumnsType; } // Customize Table Transfer const TableTransfer = ({ leftColumns, rightColumns, ...restProps }: TableTransferProps) => ( {({ direction, filteredItems, onItemSelect, onItemSelectAll, selectedKeys: listSelectedKeys, disabled: listDisabled, }) => { const columns = direction === 'left' ? leftColumns : rightColumns; const rowSelection: TableRowSelection = { getCheckboxProps: () => ({ disabled: listDisabled }), onChange(selectedRowKeys) { onItemSelectAll(selectedRowKeys, 'replace'); }, selectedRowKeys: listSelectedKeys, selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT, Table.SELECTION_NONE], }; return ( ({ onClick: () => { if (itemDisabled || listDisabled) { return; } onItemSelect(key, !listSelectedKeys.includes(key)); }, })} /> ); }} ); const mockTags = ['cat', 'dog', 'bird']; const mockData: RecordType[] = Array.from({ length: 20 }).map((_, i) => ({ key: i.toString(), title: `content${i + 1}`, description: `description of content${i + 1}`, tag: mockTags[i % 3], })); const columns: TableColumnsType = [ { dataIndex: 'title', title: 'Name', }, { dataIndex: 'tag', title: 'Tag', render: (tag: string) => ( {tag.toUpperCase()} ), }, { dataIndex: 'description', title: 'Description', }, ]; const App: React.FC = () => { const [targetKeys, setTargetKeys] = useState([]); const [disabled, setDisabled] = useState(false); const onChange: TableTransferProps['onChange'] = (nextTargetKeys) => { setTargetKeys(nextTargetKeys); }; const toggleDisabled = (checked: boolean) => { setDisabled(checked); }; return ( <> item.title!.indexOf(inputValue) !== -1 || item.tag.indexOf(inputValue) !== -1 } leftColumns={columns} rightColumns={columns} /> ); }; export default App;