mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-25 00:08:27 +08:00
c8635a7bc0
* feat: add Transfer's key type * docs: update prop * fix: key type * fix: cycle dependency
20 lines
509 B
TypeScript
20 lines
509 B
TypeScript
import type { TransferKey } from '../transfer/interface';
|
|
|
|
export const groupKeysMap = (keys: TransferKey[]) => {
|
|
const map = new Map<TransferKey, number>();
|
|
keys.forEach((key, index) => {
|
|
map.set(key, index);
|
|
});
|
|
return map;
|
|
};
|
|
|
|
export const groupDisabledKeysMap = <RecordType extends any[]>(dataSource: RecordType) => {
|
|
const map = new Map<TransferKey, number>();
|
|
dataSource.forEach(({ disabled, key }, index) => {
|
|
if (disabled) {
|
|
map.set(key, index);
|
|
}
|
|
});
|
|
return map;
|
|
};
|