@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
20 lines (19 loc) • 749 B
TypeScript
import type { FormEvent, KeyboardEvent, RefObject } from 'react';
type TransferToNextParams = {
key: string;
currentInput: HTMLInputElement;
nextInput: HTMLInputElement;
};
type UseHandleCursorPositionOptions = {
onTransferToNext?: (params: TransferToNextParams) => void;
};
/**
* A hook to handle cursor position and navigation between multiple masked input fields.
*/
declare function useHandleCursorPosition(keysToHandle?: RegExp | {
[inputId: string]: RegExp[];
}, scopeRootRef?: RefObject<HTMLElement | null>, options?: UseHandleCursorPositionOptions): {
onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
onInput: (event: FormEvent<HTMLInputElement>) => void;
};
export default useHandleCursorPosition;