@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
20 lines (19 loc) • 735 B
TypeScript
import type { 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: React.KeyboardEvent<HTMLInputElement>) => void;
onInput: (event: React.FormEvent<HTMLInputElement>) => void;
};
export default useHandleCursorPosition;