├── .gitignore ├── .npmignore ├── screenshot.png ├── index.d.ts ├── package.json ├── README.md ├── example └── App.js └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .watchmanconfig 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .github 3 | example/ 4 | screenshot.png 5 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tschoffelen/react-native-keycode/HEAD/screenshot.png -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'react-native-keycode' { 2 | export interface KeycodeInputProps { 3 | length?: number 4 | tintColor?: string 5 | textColor?: string 6 | onChange?: (value: string) => void 7 | onComplete?: (value: string) => void 8 | autoFocus?: bool 9 | uppercase?: bool 10 | alphaNumeric?: bool 11 | numeric?: bool 12 | value?: string 13 | style?: any 14 | inputRef?: (ref: React.RefObject) => void 15 | } 16 | 17 | export const KeycodeInput: React.FC 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-keycode", 3 | "version": "1.1.2", 4 | "description": "Show the user a input form for a fixed-length code or password.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git+https://github.com/includable/react-native-keycode.git" 9 | }, 10 | "keywords": [ 11 | "react-native", 12 | "react-component", 13 | "code", 14 | "password", 15 | "input", 16 | "react", 17 | "ios", 18 | "android" 19 | ], 20 | "author": "Thomas Schoffelen (https://includable.com/)", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/includable/react-native-keycode/issues" 24 | }, 25 | "homepage": "https://github.com/includable/react-native-keycode#readme", 26 | "dependencies": { 27 | "prop-types": "^15.7.2" 28 | }, 29 | "peerDependencies": { 30 | "react": ">=16.8.0", 31 | "react-native": ">=0.59.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Native Keycode 2 | 3 | Show the user a input form for a fixed-length code or password. 4 | 5 |
6 | 7 |
8 | 9 | 10 | ## Installation 11 | 12 | ``` 13 | npm i -S react-native-keycode # or: yarn add react-native-keycode 14 | ``` 15 | 16 | 17 | ## Usage 18 | 19 | ``` 20 | // import statement: 21 | import { KeycodeInput } from 'react-native-keycode' 22 | 23 | // in your render function: 24 | { 26 | alert(value) 27 | }} 28 | /> 29 | ``` 30 | 31 | ### Complete example 32 | View a more complex example here: [example/App.js](example/App.js). 33 | 34 | ### Props 35 | * number `length`: number of characters in input (default: 4) 36 | * string `textColor`: color string for the color of the characters (default: black) 37 | * string `tintColor`: color string for the color of the active bottom bar (default: iOS blue) 38 | * string `defaultValue`: default '' 39 | * string `value`: default '' 40 | * boolean `uppercase`: default true 41 | * boolean `autoFocus`: default true 42 | * boolean `alphaNumeric`: default true, set to false to allow other characters than 0-9, A-Z 43 | * boolean `numberic`: default false 44 | * object `style` 45 | * function `onComplete` 46 | * function `onChange` 47 | * function `ref` 48 | 49 | 50 | ## Authors 51 | 52 | This library is developed by [Includable](https://includable.com/), a creative app and web platform 53 | development agency based in Amsterdam, The Netherlands. 54 | 55 | * Thomas Schoffelen, [@tschoffelen](https://twitter.com/tschoffelen) 56 | -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { Text, View, StyleSheet, Button } from 'react-native'; 3 | import { KeycodeInput } from './index'; 4 | 5 | const App = () => { 6 | const [value, setValue] = useState(''); 7 | const [numeric, setNumeric] = useState(false); 8 | return ( 9 | 10 | 11 | Enter your access code 12 | 13 | setValue(newValue)} 17 | onComplete={(completedValue) => { 18 | alert('Completed! Value: ' + completedValue); 19 | }}/> 20 | 21 | 22 |