import { Checkbox, Transfer } from 'antd'; import { SortableContainer, SortableElement, SortableHandle, arrayMove, } from 'react-sortable-hoc'; import style from './style.module.scss' import type { Tagging } from 'api'; import type { TransferItem, TransferProps } from 'antd/es/transfer'; import type { ReactElement } from 'react'; const Layout = ({children}: {children: any}) => ; type ItemProps = { value: Tagging, checked: boolean, onChange: (checked: boolean) => void, append?: ReactElement, showIndex: number } const Item = ({ value, append, checked, onChange, showIndex }: ItemProps) => { return (
  • { showIndex + 1 }. onChange(e.target.checked)}> {value.tagTitle} { append && }
  • ) } const SortLayout = SortableContainer(Layout) const SortDrag = SortableHandle(() => ); const SortItem = SortableElement((props: Omit) => } />) interface DataType { key: string; data: Tagging } interface TableTransferProps extends TransferProps { dataSource: DataType[]; onChangeSort?: (data: DataType[]) => void } // Customize Table Transfer export const SortTransfer = ({ onChangeSort, ...restProps }: TableTransferProps) => ( {({ direction, filteredItems, onItemSelect, selectedKeys: listSelectedKeys, }) => { const SLayout = direction === 'left' ? Layout : SortLayout const SItem = direction === 'left' ? Item : SortItem return ( onChangeSort && onChangeSort(arrayMove(filteredItems, data.oldIndex, data.newIndex))} useDragHandle children={ filteredItems.map((item, index) => ( key === item.key)} onChange={(check) => onItemSelect(item.key, check)} /> )) } /> ) }} );