From c4e848741d8a20cf0cc91635c958d94ddef2a8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Par=C3=A9?= Date: Tue, 17 Jan 2017 15:09:25 -0500 Subject: [PATCH] React input mask (#14068) * add react mask input * tsx do not work * regenerate with command line * tsx in tsconfig * maskChar accept null * lint --- react-input-mask/index.d.ts | 42 +++++++++++++++++++++ react-input-mask/react-input-mask-tests.tsx | 10 +++++ react-input-mask/tsconfig.json | 21 +++++++++++ react-input-mask/tslint.json | 1 + 4 files changed, 74 insertions(+) create mode 100644 react-input-mask/index.d.ts create mode 100644 react-input-mask/react-input-mask-tests.tsx create mode 100644 react-input-mask/tsconfig.json create mode 100644 react-input-mask/tslint.json diff --git a/react-input-mask/index.d.ts b/react-input-mask/index.d.ts new file mode 100644 index 0000000000..3764b61122 --- /dev/null +++ b/react-input-mask/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for react-input-mask 0.7 +// Project: https://github.com/sanniassin/react-input-mask +// Definitions by: Alexandre Paré +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from "react"; + +declare namespace reactInputMask { + export interface ReactInputMaskProps extends React.HTMLAttributes { + /** + * 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; + /** + * 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; + /** + * Defines format characters with characters as keys and corresponding RegExp string as values. Default ones: + * ``` + * { + * "9": "[0-9]", + * "a": "[A-Za-z]", + * "*": "[A-Za-z0-9]" + * }``` + */ + formatChars?: { [key: string]: string }; + /** + * Show mask even in empty input without focus. + */ + alwaysShowMask?: boolean; + } + export class ReactInputMask extends React.Component { + } +} +declare var ReactInputMask: typeof reactInputMask.ReactInputMask; +export = ReactInputMask; diff --git a/react-input-mask/react-input-mask-tests.tsx b/react-input-mask/react-input-mask-tests.tsx new file mode 100644 index 0000000000..955a6ce4b8 --- /dev/null +++ b/react-input-mask/react-input-mask-tests.tsx @@ -0,0 +1,10 @@ +import * as ReactInputMask from 'react-input-mask'; +import * as React from 'react'; + +
+ + + + + +
\ No newline at end of file diff --git a/react-input-mask/tsconfig.json b/react-input-mask/tsconfig.json new file mode 100644 index 0000000000..43fd3a083d --- /dev/null +++ b/react-input-mask/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-input-mask-tests.tsx" + ] +} diff --git a/react-input-mask/tslint.json b/react-input-mask/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-input-mask/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }