From 80a3fe0e2f1724ba841d2716d4dfd6b51dbe9f17 Mon Sep 17 00:00:00 2001 From: rares-nandra Date: Mon, 4 Dec 2023 11:40:50 +0200 Subject: [PATCH 1/3] Fix issue-94: isMax is inverted when keyboard input is provided for the on limit reached callback --- NumericInput/NumericInput.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NumericInput/NumericInput.js b/NumericInput/NumericInput.js index 29255483..483b3f6d 100644 --- a/NumericInput/NumericInput.js +++ b/NumericInput/NumericInput.js @@ -127,10 +127,10 @@ export default class NumericInput extends Component { let legal = match && match[0] === match.input && ((this.props.maxValue === null || (parseFloat(this.state.stringValue) <= this.props.maxValue)) && (this.props.minValue === null || (parseFloat(this.state.stringValue) >= this.props.minValue))) if (!legal) { if (this.props.minValue !== null && (parseFloat(this.state.stringValue) <= this.props.minValue)) { - this.props.onLimitReached(true, 'Reached Minimum Value!') + this.props.onLimitReached(false, 'Reached Minimum Value!') } if (this.props.maxValue !== null && (parseFloat(this.state.stringValue) >= this.props.maxValue)) { - this.props.onLimitReached(false, 'Reached Maximum Value!') + this.props.onLimitReached(true, 'Reached Maximum Value!') } if (this.ref) { this.ref.blur() From 4ad1e4cc5657d1904c7054317074cce29b357b79 Mon Sep 17 00:00:00 2001 From: rares-nandra Date: Mon, 4 Dec 2023 21:15:28 +0200 Subject: [PATCH 2/3] changed the keyboard type for iOS to numbers-and-punctuation and added support for the , symbol to act as the . symbol --- NumericInput/NumericInput.js | 1 + 1 file changed, 1 insertion(+) diff --git a/NumericInput/NumericInput.js b/NumericInput/NumericInput.js index 483b3f6d..143cf6a7 100644 --- a/NumericInput/NumericInput.js +++ b/NumericInput/NumericInput.js @@ -71,6 +71,7 @@ export default class NumericInput extends Component { intMatch = (value) => value && value.match(/-?\d+/) && value.match(/-?\d+/)[0] === value.match(/-?\d+/).input onChange = (value) => { + value = value.replace(",", "."); let currValue = typeof this.props.value === 'number' ? this.props.value : this.state.value if ((value.length === 1 && value === '-') || (value.length === 2 && value === '0-')) { this.setState({ stringValue: '-' }) From e2c73d9ba64588e97d9d6da8af2b11545fe79a11 Mon Sep 17 00:00:00 2001 From: rares-nandra Date: Mon, 4 Dec 2023 21:21:50 +0200 Subject: [PATCH 3/3] added the keyboard type change --- NumericInput/NumericInput.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NumericInput/NumericInput.js b/NumericInput/NumericInput.js index 143cf6a7..fe3a4bf8 100644 --- a/NumericInput/NumericInput.js +++ b/NumericInput/NumericInput.js @@ -1,5 +1,5 @@ import React, { Component } from 'react' -import { View, TextInput, StyleSheet, Text } from 'react-native' +import { View, TextInput, StyleSheet, Text, Platform } from 'react-native' import Icon from 'react-native-vector-icons/Ionicons' import Button from '../Button' import PropTypes from 'prop-types' @@ -219,7 +219,7 @@ export default class NumericInput extends Component { if (this.props.type === 'up-down') return ( - this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} /> + this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} /> - this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} /> + this.ref = ref} onBlur={this.onBlur} onFocus={this.onFocus} />