refactor(web): centralize multi-select release handling
This commit is contained in:
@@ -65,3 +65,24 @@ export function finalizeMultiSelectDraft<TState extends MultiSelectStateLike>(
|
||||
currentY,
|
||||
};
|
||||
}
|
||||
|
||||
export function completeMultiSelectDraft<TState extends MultiSelectStateLike>(
|
||||
state: TState,
|
||||
currentX: number,
|
||||
currentY: number,
|
||||
emptyState: TState,
|
||||
minDistancePx = 5,
|
||||
): { nextState: TState; shouldClear: boolean } {
|
||||
const finished = finalizeMultiSelectDraft(state, currentX, currentY, minDistancePx);
|
||||
if (!finished) {
|
||||
return {
|
||||
nextState: emptyState,
|
||||
shouldClear: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
nextState: finished,
|
||||
shouldClear: false,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user