-
Notifications
You must be signed in to change notification settings - Fork 249
/
index.d.ts
106 lines (91 loc) · 2.58 KB
/
index.d.ts
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* Type Definition.
*
* Using with Typescript development.
*
* Definitions by: Italo Izaac <https://github.com/iiandrade>
*/
import * as React from 'react'
import { TextInput, TextInputProps } from 'react-native'
// Type prop of TextInputMask.
export type TextInputMaskTypeProp =
| 'credit-card'
| 'cpf'
| 'cnpj'
| 'zip-code'
| 'only-numbers'
| 'money'
| 'cel-phone'
| 'datetime'
| 'custom'
// Option prop of TextInputMask.
export interface TextInputMaskOptionProp {
// Money type.
precision?: number
separator?: string
delimiter?: string
unit?: string
suffixUnit?: string
zeroCents?: boolean
// Phone type.
withDDD?: boolean
dddMask?: string
maskType?: 'BRL' | 'INTERNATIONAL'
// Datetime type.
format?: string
// Credit card type.
obfuscated?: boolean
issuer?: 'visa-or-mastercard' | 'diners' | 'amex'
// Custom type.
mask?: string
validator?: (value: string, settings: TextInputMaskOptionProp) => boolean
getRawValue?: (value: string, settings: TextInputMaskOptionProp) => any
translation?: { [s: string]: (val: string) => string | null | undefined }
}
// TextInputMask Props
export interface TextInputMaskProps extends Pick<TextInputProps, Exclude<keyof TextInputProps, 'onChangeText'>> {
type: TextInputMaskTypeProp
options?: TextInputMaskOptionProp
checkText?: (previous: string, next: string) => boolean
onChangeText?: (text: string, rawText?: string) => void
refInput?: (ref: any) => void
customTextInput?: any
customTextInputProps?: Object
includeRawValueInChangeText?: boolean
}
// TextInputMask Component
export class TextInputMask extends React.Component<TextInputMaskProps> {}
// TextMask
export class TextMask extends React.Component<TextInputMaskProps> {}
// MaskService
export namespace MaskService {
function toMask(
type: string,
value: string,
options?: TextInputMaskOptionProp
): string
function toRawValue(
type: string,
maskedValue: string,
options?: TextInputMaskOptionProp
): string
function isValid(
type: string,
value: string,
options?: TextInputMaskOptionProp
): boolean
}
// TextInputMaskMethods
export class TextInputMaskMethods {
getElement(): TextInput
getRawValue(): string
isValid(): boolean
}
// TextInputMasked
export type TextInputMasked = TextInputMaskMethods | null
// TextMaskMethods
export class TextMaskMethods {
getElement(): TextInput
}
// TextMaskInstance
export type TextMaskInstance = TextMaskMethods | null