|
|
@ -156,8 +156,8 @@ class Transfer<RecordType extends TransferItem = TransferItem> extends React.Com |
|
|
|
|
|
|
|
const { selectedKeys = [], targetKeys = [] } = props; |
|
|
|
this.state = { |
|
|
|
sourceSelectedKeys: selectedKeys.filter(key => targetKeys.indexOf(key) === -1), |
|
|
|
targetSelectedKeys: selectedKeys.filter(key => targetKeys.indexOf(key) > -1), |
|
|
|
sourceSelectedKeys: selectedKeys.filter(key => !targetKeys.includes(key)), |
|
|
|
targetSelectedKeys: selectedKeys.filter(key => targetKeys.includes(key)), |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
@ -198,7 +198,7 @@ class Transfer<RecordType extends TransferItem = TransferItem> extends React.Com |
|
|
|
const newTargetKeys = |
|
|
|
direction === 'right' |
|
|
|
? newMoveKeys.concat(targetKeys) |
|
|
|
: targetKeys.filter(targetKey => newMoveKeys.indexOf(targetKey) === -1); |
|
|
|
: targetKeys.filter(targetKey => !newMoveKeys.includes(targetKey)); |
|
|
|
|
|
|
|
// empty checked keys
|
|
|
|
const oppositeDirection = direction === 'right' ? 'left' : 'right'; |
|
|
@ -214,13 +214,13 @@ class Transfer<RecordType extends TransferItem = TransferItem> extends React.Com |
|
|
|
|
|
|
|
onItemSelectAll = (direction: TransferDirection, selectedKeys: string[], checkAll: boolean) => { |
|
|
|
this.setStateKeys(direction, prevKeys => { |
|
|
|
let mergedCheckedKeys = []; |
|
|
|
let mergedCheckedKeys: string[] = []; |
|
|
|
if (checkAll) { |
|
|
|
// Merge current keys with origin key
|
|
|
|
mergedCheckedKeys = Array.from(new Set([...prevKeys, ...selectedKeys])); |
|
|
|
mergedCheckedKeys = Array.from(new Set<string>([...prevKeys, ...selectedKeys])); |
|
|
|
} else { |
|
|
|
// Remove current keys from origin keys
|
|
|
|
mergedCheckedKeys = prevKeys.filter((key: string) => selectedKeys.indexOf(key) === -1); |
|
|
|
mergedCheckedKeys = prevKeys.filter(key => !selectedKeys.includes(key)); |
|
|
|
} |
|
|
|
|
|
|
|
this.handleSelectChange(direction, mergedCheckedKeys); |
|
|
|