forked from sanniassin/react-input-mask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
67 lines (59 loc) · 2.18 KB
/
index.d.ts
File metadata and controls
67 lines (59 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as React from "react";
export interface Selection {
start: number;
end: number;
}
export interface InputState {
value: string;
selection: Selection | null;
}
export interface BeforeMaskedStateChangeStates {
previousState: InputState;
currentState: InputState;
nextState: InputState;
}
export type Props = Omit<React.InputHTMLAttributes<HTMLInputElement>, "children"> & {
/**
* Mask string. Format characters are:
* * `9`: `0-9`
* * `a`: `A-Z, a-z`
* * `\*`: `A-Z, a-z, 0-9`
*
* Any character can be escaped with backslash, which usually will appear as double backslash in JS strings.
* For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}`
*/
mask: string | Array<(string | RegExp)>;
/**
* Character to cover unfilled editable parts of mask. Default character is "_". If set to null, unfilled parts will be empty, like in ordinary input.
*/
maskChar?: string | null | undefined;
maskPlaceholder?: string | null | undefined;
/**
* Show mask even in empty input without focus.
*/
alwaysShowMask?: boolean | undefined;
/**
* Reference to the input element which is being masked. This element should be always passed as children of ReactInputMask.
* @example
* ```tsx
* const inputRef = React.createRef<HTMLInputElement>();
*
* <ReactInputMask mask="99/99/9999" inputRef={inputRef}>
* <input type="text" ref={inputRef}/>
* </ReactInputMask>
* ```
*/
inputRef: React.Ref<HTMLInputElement>;
/**
* In case you need to implement more complex masking behavior, you can provide
* beforeMaskedStateChange function to change masked value and cursor position
* before it will be applied to the input.
*
* * previousState: Input state before change. Only defined on change event.
* * currentState: Current raw input state. Not defined during component render.
* * nextState: Input state with applied mask. Contains value and selection fields.
*/
beforeMaskedStateChange?(states: BeforeMaskedStateChangeStates): InputState;
children: React.ReactNode;
};
export default class ReactInputMask extends React.Component<Props> {}