react-native-web-mask
Version:
A cross-platform input mask hook for React and React Native, with TypeScript and helper utilities
17 lines (16 loc) • 614 B
TypeScript
import { ChangeEvent } from "react";
export type MaskType = "phone" | "money" | "card" | "zip" | "date" | "monthDay" | "custom";
export interface UseInputMaskProps {
maskType?: MaskType;
initialValue?: string;
customMask?: (value: string) => string;
onChange?: (event: ChangeEvent<HTMLInputElement> | string) => void;
}
export interface UseInputMaskReturn {
maskedValue: string;
rawValue: string;
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
onChangeText: (text: string) => void;
setValue: (value: string) => void;
}
export type MaskFn = (value: string) => string;