element-plus/packages/transfer/src/useCheckedChange.ts
jeremywu de0696b4f6
core/bumping-dependency-vue-version (#729)
* bumping version

* build(core): bumping vue version

- Bumping up vue version from ^3.0.0 to ^3.0.3 due to the change of `emitOptions`

* Remove transition mock/Add before-enter and before-leave hook emitter for popper
2020-12-01 10:28:42 +08:00

23 lines
730 B
TypeScript

export const LEFT_CHECK_CHANGE_EVENT = 'left-check-change'
export const RIGHT_CHECK_CHANGE_EVENT = 'right-check-change'
import type { TransferCheckedState, Key } from './transfer'
export const useCheckedChange = (checkedState: TransferCheckedState, emit) => {
const onSourceCheckedChange = (val: Key[], movedKeys: Key[]) => {
checkedState.leftChecked = val
if (movedKeys === undefined) return
emit(LEFT_CHECK_CHANGE_EVENT, val, movedKeys)
}
const onTargetCheckedChange = (val: Key[], movedKeys: Key[]) => {
checkedState.rightChecked = val
if (movedKeys === undefined) return
emit(RIGHT_CHECK_CHANGE_EVENT, val, movedKeys)
}
return {
onSourceCheckedChange,
onTargetCheckedChange,
}
}