antd-mask-input
Version:
Ant Design Mask Input
36 lines (35 loc) • 1.43 kB
TypeScript
import * as React from 'react';
import { InputRef } from 'antd';
import { InputProps } from 'antd/lib/input';
import IMask from 'imask';
export interface MaskedInputProps extends Omit<InputProps, 'onChange' | 'value' | 'defaultValue'> {
mask: MaskType;
definitions?: InputMaskOptions['definitions'];
value?: string;
defaultValue?: string;
maskOptions?: InputMaskOptions;
onChange?: (event: OnChangeEvent) => any;
}
export { IMask };
export declare const MaskedInput: React.ForwardRefExoticComponent<MaskedInputProps & React.RefAttributes<InputRef>>;
export default MaskedInput;
export declare type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? {
[K in keyof R]: R[K];
} : never;
declare type OnChangeParam = Parameters<Exclude<InputProps['onChange'], undefined>>[0];
interface OnChangeEvent extends OnChangeParam {
maskedValue: string;
unmaskedValue: string;
}
interface IMaskOptionsBase extends UnionToIntersection<IMask.AnyMaskedOptions> {
}
export declare type InputMaskOptions = {
[K in keyof IMaskOptionsBase]?: IMaskOptionsBase[K];
};
declare type MaskFieldType = string | RegExp | Function | Date | InputMaskOptions;
interface IMaskOptions extends Omit<InputMaskOptions, 'mask'> {
mask: MaskFieldType;
}
interface MaskOptionsList extends Array<IMaskOptions> {
}
export declare type MaskType = MaskFieldType | MaskOptionsList;