UNPKG

1.38 kBTypeScriptView Raw
1// Type definitions for react-text-mask 5.4
2// Project: https://github.com/text-mask/text-mask/tree/master/react
3// Definitions by: Guilherme Hübner <https://github.com/guilhermehubner>
4// Deividi Cavarzan <https://github.com/cavarzan>
5// Artem Lyubchuk <https://github.com/needpower>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7// TypeScript Version: 2.8
8
9import * as React from "react";
10
11export type maskArray = Array<string | RegExp> | boolean;
12
13export interface MaskedInputProps
14 extends React.InputHTMLAttributes<HTMLInputElement> {
15 mask?: maskArray | ((value: string) => maskArray);
16
17 guide?: boolean;
18
19 placeholderChar?: string;
20
21 keepCharPositions?: boolean;
22
23 pipe?: (
24 conformedValue: string,
25 config: any
26 ) => false | string | { value: string; indexesOfPipedChars: number[] };
27
28 showMask?: boolean;
29
30 render?: (ref: (inputElement: HTMLElement) => void, props: any) => any;
31}
32
33export interface conformToMaskResult {
34 conformedValue: string;
35 meta: {
36 someCharsRejected: boolean;
37 };
38}
39
40export default class MaskedInput extends React.Component<
41 MaskedInputProps,
42 any
43> {
44 inputElement: HTMLElement;
45}
46
47export function conformToMask(
48 text: string,
49 mask: maskArray | ((value: string) => maskArray),
50 config?: any
51): conformToMaskResult;