@@ -2,6 +2,7 @@ import React, {Component} from "react";
22import { Text , TextInput , TouchableHighlight , View } from "react-native" ;
33import PropTypes from "prop-types" ;
44import { Style } from "./style" ;
5+ import { isEmpty , isStringEmpty , debounce } from "./utils" ;
56
67/**
78 * Default Color
@@ -95,7 +96,7 @@ class InputSpinner extends Component {
9596 onChange ( num ) {
9697 if ( this . props . disabled ) return ;
9798 const current_value = this . state . value ;
98- const separator = ! this . isStringEmpty ( this . props . decimalSeparator )
99+ const separator = ! isEmpty ( this . props . decimalSeparator )
99100 ? this . props . decimalSeparator
100101 : "." ;
101102 if (
@@ -159,7 +160,6 @@ class InputSpinner extends Component {
159160 return num ;
160161 }
161162
162-
163163 /**
164164 * Limit value to be within max and min range
165165 * @param value
@@ -190,7 +190,7 @@ class InputSpinner extends Component {
190190 */
191191 parseNum ( num ) {
192192 num = String ( num ) . replace (
193- ! this . isStringEmpty ( this . props . decimalSeparator )
193+ ! isEmpty ( this . props . decimalSeparator )
194194 ? this . props . decimalSeparator
195195 : "." ,
196196 "."
@@ -225,13 +225,15 @@ class InputSpinner extends Component {
225225 } else {
226226 value = String ( this . parseNum ( value ) ) ;
227227 }
228- let hasPlaceholder = value === "0" && ! this . isStringEmpty ( this . props . placeholder ) ;
229- return hasPlaceholder ? "" : value . replace (
230- "." ,
231- ! this . isStringEmpty ( this . props . decimalSeparator )
232- ? this . props . decimalSeparator
233- : "."
234- ) ;
228+ let hasPlaceholder = value === "0" && ! isEmpty ( this . props . placeholder ) ;
229+ return hasPlaceholder
230+ ? ""
231+ : value . replace (
232+ "." ,
233+ ! isEmpty ( this . props . decimalSeparator )
234+ ? this . props . decimalSeparator
235+ : "."
236+ ) ;
235237 }
236238
237239 /**
@@ -391,24 +393,6 @@ class InputSpinner extends Component {
391393 this . textInput . clear ( ) ;
392394 }
393395
394- /**
395- * Is object empty
396- * @param obj
397- * @returns {boolean }
398- */
399- isObjectEmpty ( obj ) {
400- return Object . entries ( obj ) . length === 0 && obj . constructor === Object ;
401- }
402-
403- /**
404- * Is string empty
405- * @param str
406- * @returns {boolean|boolean }
407- */
408- isStringEmpty ( str ) {
409- return ! str || String ( str ) === "" ;
410- }
411-
412396 /**
413397 * Is text input editable
414398 * @returns {boolean|Boolean }
@@ -625,7 +609,7 @@ class InputSpinner extends Component {
625609 * @private
626610 */
627611 _getStyleButtonPress ( ) {
628- return this . isObjectEmpty ( this . props . buttonPressStyle )
612+ return isEmpty ( this . props . buttonPressStyle )
629613 ? this . props . buttonStyle
630614 : this . props . buttonPressStyle ;
631615 }
@@ -803,7 +787,9 @@ class InputSpinner extends Component {
803787 */
804788 render ( ) {
805789 return (
806- < View style = { this . _getContainerStyle ( ) } { ...this . props . containerProps } >
790+ < View
791+ style = { this . _getContainerStyle ( ) }
792+ { ...this . props . containerProps } >
807793 { this . _renderLeftButton ( ) }
808794
809795 { this . props . prepend }
0 commit comments