From 8346e265f9519a0e6ddef621d395d76b23841531 Mon Sep 17 00:00:00 2001 From: Italo Izaac Date: Fri, 1 Jun 2018 23:05:07 -0300 Subject: [PATCH] Typescript type definition for using with Typescript development. --- index.d.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 20 +++++++++++++++++++- package.json | 13 ++++++++++--- 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..877e59d5 --- /dev/null +++ b/index.d.ts @@ -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 {} + +// MaskService +export declare class MaskService { + static toMask(type: string, value: any, options: TextInputMaskOptionProp): string; + static isValid(type: string, value: any, options: TextInputMaskOptionProp): boolean; +} diff --git a/package-lock.json b/package-lock.json index e28cb996..deaee4c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,22 @@ { "name": "react-native-masked-text", - "version": "1.6.4", + "version": "1.6.5", "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/react": { + "version": "16.3.16", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.3.16.tgz", + "integrity": "sha512-fM7YX3Q9a915DXi8T06F8906bWv19sbkVO+k5PUYRIWXU2PINLEHbMMGgySem2phwF6En0+HGI6MOrobp+Ya1g==", + "requires": { + "csstype": "2.5.3" + } + }, + "@types/react-native": { + "version": "0.55.16", + "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.55.16.tgz", + "integrity": "sha512-PK70anyuFvK8bnGWfPAnwi/J2Ak254z3/cCScgqtmI8ZGYv0SlKU+9hRnFGC+ZpxnYUUMEgoNEwharSTzuaZUg==" + }, "abab": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", @@ -1098,6 +1111,11 @@ "cssom": "0.3.2" } }, + "csstype": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.5.3.tgz", + "integrity": "sha512-G5HnoK8nOiAq3DXIEoY2n/8Vb7Lgrms+jGJl8E4EJpQEeVONEnPFJSl8IK505wPBoxxtrtHhrRm4WX2GgdqarA==" + }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", diff --git a/package.json b/package.json index f39b1237..0268be3a 100644 --- a/package.json +++ b/package.json @@ -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": [ { @@ -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": { @@ -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",