11/*!
2- * react-number-format - 3.0.3
2+ * react-number-format - 3.1.0
33 * Author : Sudhanshu Yadav
44 * Copyright (c) 2016,2017 to Sudhanshu Yadav - ignitersworld.com , released under the MIT license.
55 */
@@ -113,7 +113,8 @@ return /******/ (function(modules) { // webpackBootstrap
113113 onBlur : _propTypes2 . default . func ,
114114 type : _propTypes2 . default . oneOf ( [ 'text' , 'tel' ] ) ,
115115 isAllowed : _propTypes2 . default . func ,
116- renderText : _propTypes2 . default . func
116+ renderText : _propTypes2 . default . func ,
117+ getInputRef : _propTypes2 . default . func
117118 } ;
118119
119120 var defaultProps = {
@@ -131,7 +132,8 @@ return /******/ (function(modules) { // webpackBootstrap
131132 onMouseUp : _utils . noop ,
132133 onFocus : _utils . noop ,
133134 onBlur : _utils . noop ,
134- isAllowed : _utils . returnTrue
135+ isAllowed : _utils . returnTrue ,
136+ getInputRef : _utils . noop
135137 } ;
136138
137139 var NumberFormat = function ( _React$Component ) {
@@ -708,7 +710,9 @@ return /******/ (function(modules) { // webpackBootstrap
708710 } , {
709711 key : 'correctInputValue' ,
710712 value : function correctInputValue ( caretPos , lastValue , value ) {
711- var format = this . props . format ;
713+ var _props9 = this . props ,
714+ format = _props9 . format ,
715+ decimalSeparator = _props9 . decimalSeparator ;
712716
713717 var lastNumStr = this . state . numAsString || '' ;
714718
@@ -742,7 +746,8 @@ return /******/ (function(modules) { // webpackBootstrap
742746 //clear only if something got deleted
743747
744748
745- if ( numericString . length < lastNumStr . length && beforeDecimal === '' && ! parseFloat ( afterDecimal ) ) {
749+ var isBeforeDecimalPoint = caretPos < value . indexOf ( decimalSeparator ) + 1 ;
750+ if ( numericString . length < lastNumStr . length && isBeforeDecimalPoint && beforeDecimal === '' && ! parseFloat ( afterDecimal ) ) {
746751 return addNegation ? '-' : '' ;
747752 }
748753 }
@@ -840,13 +845,13 @@ return /******/ (function(modules) { // webpackBootstrap
840845 var selectionStart = el . selectionStart ;
841846
842847 var expectedCaretPosition = void 0 ;
843- var _props9 = this . props ,
844- decimalScale = _props9 . decimalScale ,
845- fixedDecimalScale = _props9 . fixedDecimalScale ,
846- prefix = _props9 . prefix ,
847- suffix = _props9 . suffix ,
848- format = _props9 . format ,
849- onKeyDown = _props9 . onKeyDown ;
848+ var _props10 = this . props ,
849+ decimalScale = _props10 . decimalScale ,
850+ fixedDecimalScale = _props10 . fixedDecimalScale ,
851+ prefix = _props10 . prefix ,
852+ suffix = _props10 . suffix ,
853+ format = _props10 . format ,
854+ onKeyDown = _props10 . onKeyDown ;
850855
851856 var ignoreDecimalSeparator = decimalScale !== undefined && fixedDecimalScale ;
852857 var numRegex = this . getNumberRegex ( false , ignoreDecimalSeparator ) ;
@@ -941,16 +946,17 @@ return /******/ (function(modules) { // webpackBootstrap
941946 }
942947
943948 _this2 . props . onFocus ( e ) ;
944- } ) ;
949+ } , 0 ) ;
945950 }
946951 } , {
947952 key : 'render' ,
948953 value : function render ( ) {
949- var _props10 = this . props ,
950- type = _props10 . type ,
951- displayType = _props10 . displayType ,
952- customInput = _props10 . customInput ,
953- renderText = _props10 . renderText ;
954+ var _props11 = this . props ,
955+ type = _props11 . type ,
956+ displayType = _props11 . displayType ,
957+ customInput = _props11 . customInput ,
958+ renderText = _props11 . renderText ,
959+ getInputRef = _props11 . getInputRef ;
954960 var value = this . state . value ;
955961
956962
@@ -963,13 +969,14 @@ return /******/ (function(modules) { // webpackBootstrap
963969 onKeyDown : this . onKeyDown ,
964970 onMouseUp : this . onMouseUp ,
965971 onFocus : this . onFocus ,
966- onBlur : this . onBlur
972+ onBlur : this . onBlur ,
973+ ref : getInputRef
967974 } ) ;
968975
969976 if ( displayType === 'text' ) {
970977 return renderText ? renderText ( value ) || null : _react2 . default . createElement (
971978 'span' ,
972- otherProps ,
979+ _extends ( { } , otherProps , { ref : getInputRef } ) ,
973980 value
974981 ) ;
975982 } else if ( customInput ) {
0 commit comments