@wwdrew/react-native-numeric-textinput
Advanced tools
Comparing version 1.0.2 to 1.0.3
import React from 'react'; | ||
import { TextInput } from 'react-native'; | ||
import { code } from 'currency-codes'; | ||
import { Platform, TextInput } from 'react-native'; | ||
import { code } from 'currency-codes'; // Polyfill for Intl until properly supported in Android | ||
import 'intl'; | ||
import 'intl/locale-data/jsonp/en'; | ||
const createFormatConfig = (style, options) => { | ||
@@ -63,3 +66,3 @@ let formatOptions = { | ||
const updateValue = (key, onUpdate) => { | ||
const updateValue = (key, updateCallback) => { | ||
let newValue = ''; | ||
@@ -76,8 +79,8 @@ | ||
onUpdate(parseStringValue(newValue, formatConfig.minimumFractionDigits)); | ||
updateCallback(parseStringValue(newValue, formatConfig.minimumFractionDigits)); | ||
} | ||
}; | ||
const formatValue = value => { | ||
return new Intl.NumberFormat(locale, formatConfig).format(value); | ||
const formatValue = numberValue => { | ||
return new Intl.NumberFormat(locale, formatConfig).format(numberValue); | ||
}; | ||
@@ -92,3 +95,4 @@ | ||
value: formatValue(value), | ||
keyboardType: "number-pad" | ||
keyboardType: Platform.OS === 'ios' ? 'number-pad' : 'default' // Another temporary fix for Android as the numeric keyboards don't fire keyPress events | ||
})); | ||
@@ -95,0 +99,0 @@ }; |
{ | ||
"name": "@wwdrew/react-native-numeric-textinput", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A React Native TextInput that formats and displays only numeric inputs, including i18n currency formatting.", | ||
@@ -34,3 +34,4 @@ "main": "lib/NumericTextInput.js", | ||
"dependencies": { | ||
"currency-codes": "^1.5.0" | ||
"currency-codes": "^1.5.0", | ||
"intl": "^1.2.5" | ||
}, | ||
@@ -41,6 +42,7 @@ "devDependencies": { | ||
"@babel/plugin-transform-flow-strip-types": "^7.4.0", | ||
"@babel/preset-env": "^7.4.3", | ||
"@babel/preset-react": "^7.0.0", | ||
"@react-native-community/eslint-config": "0.0.4", | ||
"eslint": "^5.16.0", | ||
"flow-copy-source": "^2.0.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
10198
81
2
7
+ Addedintl@^1.2.5
+ Addedintl@1.2.5(transitive)