@@ -7829,8 +7829,6 @@ return /******/ (function(modules) { // webpackBootstrap
78297829 decimal = _localizers . number . decimalChar ( null , props . culture ) ,
78307830 format = getFormat ( props ) ;
78317831
7832- this . _beginningWithSign = false ;
7833-
78347832 if ( value == null || isNaN ( props . value ) ) value = '' ; else value = props . editing ? ( '' + value ) . replace ( '.' , decimal ) : _localizers . number . format ( value , format , props . culture ) ;
78357833
78367834 return {
@@ -7851,48 +7849,43 @@ return /******/ (function(modules) { // webpackBootstrap
78517849 className : 'rw-input' ,
78527850 onChange : this . _change ,
78537851 onBlur : this . _finish ,
7854- onKeyPress : this . _typing ,
78557852 'aria-disabled' : this . props . disabled ,
78567853 'aria-readonly' : this . props . readOnly ,
78577854 disabled : this . props . disabled ,
78587855 readOnly : this . props . readOnly ,
78597856 placeholder : this . props . placeholder ,
7860- value : value } ) ) ;
7861- } ,
7862- _typing : function _typing ( e ) {
7863- var current = e . target . value ,
7864- newVal = e . key ;
7865-
7866- this . _beginningWithSign = current . trim ( ) === '' && this . isSign ( newVal ) ;
7867-
7868- this . props . onKeyPress && this . props . onKeyPress ( e ) ;
7857+ value : value
7858+ } ) ) ;
78697859 } ,
78707860 _change : function _change ( e ) {
78717861 var val = e . target . value ,
7872- number = this . _parse ( e . target . value ) ,
7873- atSign = this . isSign ( val . trim ( ) ) ,
7874- startingWithSign = this . _beginningWithSign ;
7862+ number = this . _parse ( e . target . value ) ;
78757863
7876- this . _beginningWithSign = false ;
7864+ var isIntermediate = this . isIntermediateValue ( number , val ) ;
78777865
7878- if ( val == null || val . trim ( ) === '' || atSign && ! startingWithSign ) {
7866+ if ( val == null || val . trim ( ) === '' ) {
78797867 this . current ( '' ) ;
78807868 return this . props . onChange ( null ) ;
78817869 }
78827870
7883- if ( this . isFlushable ( number , val ) ) {
7884- if ( number !== this . props . value ) return this . props . onChange ( number ) ; else this . setState ( this . getDefaultState ( ) ) ; // 5. -> 5
7871+ if ( ! isIntermediate ) {
7872+ if ( number !== this . props . value ) {
7873+ return this . props . onChange ( number ) ;
7874+ }
7875+ } else {
7876+ this . current ( e . target . value ) ;
78857877 }
7886-
7887- if ( number < this . props . min || atSign && startingWithSign || this . isAtDelimiter ( number , val ) ) this . current ( e . target . value ) ;
78887878 } ,
78897879 _finish : function _finish ( ) {
78907880 var str = this . state . stringValue ,
78917881 number = this . _parse ( str ) ;
78927882
78937883 // if number is below the min
78947884 // we need to flush low values and decimal stops, onBlur means i'm done inputing
7895- if ( ! isNaN ( number ) && ( number < this . props . min || this . isAtDelimiter ( number , str ) ) ) {
7885+ if ( this . isIntermediateValue ( number , str ) ) {
7886+ if ( isNaN ( number ) ) {
7887+ number = null ;
7888+ }
78967889 this . props . onChange ( number ) ;
78977890 }
78987891 } ,
@@ -7908,24 +7901,35 @@ return /******/ (function(modules) { // webpackBootstrap
79087901
79097902 return strVal ;
79107903 } ,
7911- isFlushable : function isFlushable ( num , str ) {
7912- return this . isValid ( num ) && ! this . isAtDelimiter ( num , str ) && ! this . isSign ( str ) ;
7904+ isIntermediateValue : function isIntermediateValue ( num , str ) {
7905+ return ! ! ( num < this . props . min || this . isSign ( str ) || this . isAtDelimiter ( num , str ) || this . isPaddedZeros ( str ) ) ;
79137906 } ,
79147907 isSign : function isSign ( val ) {
79157908 return ( val || '' ) . trim ( ) === '-' ;
79167909 } ,
7910+ isPaddedZeros : function isPaddedZeros ( str ) {
7911+ var localeChar = _localizers . number . decimalChar ( null , this . props . culture ) ;
7912+
7913+ var _str$split = str . split ( localeChar ) ;
7914+
7915+ var _ = _str$split [ 0 ] ;
7916+ var decimals = _str$split [ 1 ] ;
7917+
7918+
7919+ return ! ! ( decimals && decimals . match ( / 0 + $ / ) ) ;
7920+ } ,
79177921 isAtDelimiter : function isAtDelimiter ( num , str ) {
79187922 var props = arguments . length <= 2 || arguments [ 2 ] === undefined ? this . props : arguments [ 2 ] ;
79197923
79207924 var localeChar = _localizers . number . decimalChar ( null , props . culture ) ,
79217925 lastIndex = str . length - 1 ,
79227926 char ;
79237927
7924- if ( str . length <= 1 ) return false ;
7928+ if ( str . length < 1 ) return false ;
79257929
79267930 char = str [ lastIndex ] ;
79277931
7928- return char === localeChar && str . indexOf ( char ) === lastIndex ;
7932+ return ! ! ( char === localeChar && str . indexOf ( char ) === lastIndex ) ;
79297933 } ,
79307934 isValid : function isValid ( num ) {
79317935 if ( typeof num !== 'number' || isNaN ( num ) ) return false ;
@@ -7934,8 +7938,8 @@ return /******/ (function(modules) { // webpackBootstrap
79347938
79357939
79367940 //this intermediate state is for when one runs into the decimal or are typing the number
7937- current : function current ( val ) {
7938- this . setState ( { stringValue : val } ) ;
7941+ current : function current ( stringValue ) {
7942+ this . setState ( { stringValue : stringValue } ) ;
79397943 }
79407944 } ) ;
79417945 module . exports = exports [ 'default' ] ;
0 commit comments