Skip to content

Commit

Permalink
Merge branch 'iiandrade-master'
Browse files Browse the repository at this point in the history
* iiandrade-master:
  Typescript type definition for using with Typescript development.
  • Loading branch information
Ben-hur Santos Ott committed Jun 3, 2018
2 parents 766c719 + 8346e26 commit 8d492d0
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
43 changes: 43 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as React from "react";
import {TextInput, TextInputProps} from "react-native";

// Type prop of TextInputMask.
type TextInputMaskTypeProp = "credit-card" | "cpf" | "cnpj" | "zip-code" | "only-numbers" | "money" | "cel-phone" | "datetime" | "custom";

// Option prop of TextInputMask.
type TextInputMaskOptionProp = {
// Money type.
precision?: number;
separator?: string;
delimiter?: string;
unit?: string;
suffixUnit?: string;
zeroCents?: boolean;

// Phone type.
withDDD?: boolean;
dddMask?: string;

// Datetime type.
format?: string;

// Credit card type.
obfuscated?: boolean;
};

// TextInputMask Props
interface TextInputMaskProps extends TextInputProps {
type: TextInputMaskTypeProp;
options?: TextInputMaskOptionProp;
checkText?: (previous: string, next: string) => boolean;
onChangeText?: (text: string) => void;
}

// TextInputMask Component
export declare class TextInputMask extends React.Component<TextInputMaskProps> {}

// MaskService
export declare class MaskService {
static toMask(type: string, value: any, options: TextInputMaskOptionProp): string;
static isValid(type: string, value: any, options: TextInputMaskOptionProp): boolean;
}
20 changes: 19 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-masked-text",
"version": "1.6.5",
"version": "1.7.0",
"description": "Text and TextInput with mask for React Native applications",
"licenses": [
{
Expand All @@ -19,7 +19,12 @@
"type": "git",
"url": "git+https://github.com/benhurott/react-native-masked-text.git"
},
"keywords": ["mask", "text", "textinput", "react-native"],
"keywords": [
"mask",
"text",
"textinput",
"react-native"
],
"author": "Ben-hur Santos Ott",
"license": "ISC",
"bugs": {
Expand All @@ -28,7 +33,9 @@
"homepage": "https://github.com/benhurott/react-native-masked-text#readme",
"dependencies": {
"moment": "^2.19.1",
"tinymask": "^1.0.2"
"tinymask": "^1.0.2",
"@types/react-native": "*",
"@types/react": "*"
},
"devDependencies": {
"babel-cli": "^6.26.0",
Expand Down

0 comments on commit 8d492d0

Please sign in to comment.