-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from platformbuilders/feat/masked-text
Feat/masked text
- Loading branch information
Showing
31 changed files
with
1,201 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/** | ||
* 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 = | ||
| 'document' | ||
| 'credit-card' | ||
| 'cpf' | ||
| 'cnpj' | ||
| 'zip-code' | ||
| 'only-numbers' | ||
| 'money' | ||
| 'cel-phone' | ||
| 'datetime' | ||
| 'no-mask' | ||
| 'custom' | ||
| 'account-bank' | ||
| 'uppercase' | ||
|
||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import MaskService from './lib/mask-service'; | ||
import TextInputMask from './lib/text-input-mask'; | ||
import TextMask from './lib/text-mask'; | ||
|
||
module.exports.MaskService = MaskService; | ||
module.exports.TextInputMask = TextInputMask; | ||
module.exports.TextMask = TextMask; |
Oops, something went wrong.