ant-design/components/_util/transKeys.ts
章鱼怪 c8635a7bc0
feat: improve Transfer key type (#47879)
* feat: add Transfer's key type

* docs: update prop

* fix: key type

* fix: cycle dependency
2024-03-14 21:14:21 +08:00

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;
};