From f3fb98ea1904885bef643c3046b64ca2aa4a4f9f Mon Sep 17 00:00:00 2001 From: Dean Shub Date: Sat, 20 Oct 2018 13:16:15 +0300 Subject: [PATCH] fixing the float dot zero issue --- dist/react-numeric-input.js | 4 ++-- dist/react-numeric-input.min.js | 2 +- docs/react-numeric-input.js | 4 ++-- index.js | 4 ++-- src/NumericInput.jsx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/react-numeric-input.js b/dist/react-numeric-input.js index 52df137..fc13538 100644 --- a/dist/react-numeric-input.js +++ b/dist/react-numeric-input.js @@ -82,7 +82,7 @@ return /******/ (function(modules) { // webpackBootstrap var KEYCODE_DOWN = 40; var IS_BROWSER = typeof document != 'undefined'; var RE_NUMBER = /^[+-]?((\.\d+)|(\d+(\.\d+)?))$/; - var RE_INCOMPLETE_NUMBER = /^([+-]|\.0*|[+-]\.0*|[+-]?\d+\.)?$/; + var RE_INCOMPLETE_NUMBER = /^([+-]|[0-9]*\.0*|[+-]\.0*|[+-]?\d+\.)?$/; /** * Just a simple helper to provide support for older IEs. This is not exactly a @@ -1082,7 +1082,7 @@ return /******/ (function(modules) { // webpackBootstrap value: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), defaultValue: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]), strict: _propTypes2.default.bool, - componentClass: _propTypes2.default.string, + componentClass: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]), mobile: function mobile(props, propName) { var prop = props[propName]; if (prop !== true && prop !== false && prop !== 'auto' && typeof prop != 'function') { diff --git a/dist/react-numeric-input.min.js b/dist/react-numeric-input.min.js index f46ffd1..3c55857 100644 --- a/dist/react-numeric-input.min.js +++ b/dist/react-numeric-input.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("PropTypes")):"function"==typeof define&&define.amd?define(["React","PropTypes"],e):"object"==typeof exports?exports.NumericInput=e(require("React"),require("PropTypes")):t.NumericInput=e(t.React,t.PropTypes)}(this,function(t,e){return function(t){function e(o){if(n[o])return n[o].exports;var a=n[o]={exports:{},id:o,loaded:!1};return t[o].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function a(t,e){var n={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t,e){return t.classList?t.classList.add(e):void(t.className.search(new RegExp("\\b"+e+"\\b"))||(t.className=" "+e))}function l(t,e){if(t.className){if(t.classList)return t.classList.remove(e);t.className=t.className.replace(new RegExp("\\b"+e+"\\b","g"),"")}}function p(t,e,n){var o=t[e];if("function"==typeof o){for(var a=arguments.length,i=Array(a>3?a-3:0),s=3;sthis.props.maxLength&&(e="This value is too long")),e=e||(t?"":this.refsInput.validationMessage||"Unknown Error");var a=this._valid!==e;this._valid=e,e?(u(this.refsWrapper,"has-error"),a&&this._invokeEventCallback("onInvalid",e,this.state.value,this.refsInput.value)):(l(this.refsWrapper,"has-error"),a&&this._invokeEventCallback("onValid",this.state.value,this.refsInput.value))}},{key:"_toNumber",value:function(t){var n=parseFloat(t);if(!isNaN(n)&&isFinite(n)||(n=0),this._isStrict){var o=p(this.props,"precision",null,this),a=Math.pow(10,null===o?10:o),i=+p(this.props,"min",e.defaultProps.min,this),s=+p(this.props,"max",e.defaultProps.max,this);n=Math.min(Math.max(n,i),s),n=Math.round(n*a)/a}return n}},{key:"_parse",value:function(t){return t=String(t),"function"==typeof this.props.parse?parseFloat(this.props.parse(t)):parseFloat(t)}},{key:"_format",value:function(t){var e=this._toNumber(t),n=p(this.props,"precision",null,this);return null!==n&&(e=t.toFixed(n)),e+="",this.props.format?this.props.format(e):e}},{key:"_step",value:function t(n,o){var a=this._isStrict;this._isStrict=!0;var t=+p(this.props,"step",e.defaultProps.step,this,n>0?e.DIRECTION_UP:e.DIRECTION_DOWN),i=this._toNumber((this.state.value||0)+t*n);return this.props.snap&&(i=Math.round(i/t)*t),this._isStrict=a,i!==this.state.value&&(this.setState({value:i,stringValue:i+""},o),!0)}},{key:"_onKeyDown",value:function(){for(var t=arguments.length,e=Array(t),n=0;n0&&a.length&&"."===a.charAt(this.refsInput.selectionEnd-1)&&(o.preventDefault(),this.refsInput.selectionStart=this.refsInput.selectionEnd=this.refsInput.selectionEnd-1):46===o.keyCode&&this.refsInput.selectionStart==this.refsInput.selectionEnd&&this.refsInput.selectionEnd0&&void 0!==arguments[0]&&arguments[0],o=arguments[1];this.stop(),this._step(1,o);var a=+p(this.props,"max",e.defaultProps.max,this);(isNaN(this.state.value)||+this.state.value0&&void 0!==arguments[0]&&arguments[0],o=arguments[1];this.stop(),this._step(-1,o);var a=+p(this.props,"min",e.defaultProps.min,this);(isNaN(this.state.value)||+this.state.value>a)&&(this._timer=setTimeout(function(){t.decrease(!0)},n?e.SPEED:e.DELAY))}},{key:"onMouseDown",value:function(t,e){"down"==t?this.decrease(!1,e):"up"==t&&this.increase(!1,e)}},{key:"onTouchStart",value:function(t,e){e.preventDefault(),"down"==t?this.decrease():"up"==t&&this.increase()}},{key:"onTouchEnd",value:function(t){t.preventDefault(),this.stop()}},{key:"_invokeEventCallback",value:function(t){if("function"==typeof this.props[t]){for(var e,n=arguments.length,o=Array(n>1?n-1:0),a=1;a=0||Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t,e){return t.classList?t.classList.add(e):void(t.className.search(new RegExp("\\b"+e+"\\b"))||(t.className=" "+e))}function l(t,e){if(t.className){if(t.classList)return t.classList.remove(e);t.className=t.className.replace(new RegExp("\\b"+e+"\\b","g"),"")}}function p(t,e,n){var o=t[e];if("function"==typeof o){for(var a=arguments.length,i=Array(a>3?a-3:0),s=3;sthis.props.maxLength&&(e="This value is too long")),e=e||(t?"":this.refsInput.validationMessage||"Unknown Error");var a=this._valid!==e;this._valid=e,e?(u(this.refsWrapper,"has-error"),a&&this._invokeEventCallback("onInvalid",e,this.state.value,this.refsInput.value)):(l(this.refsWrapper,"has-error"),a&&this._invokeEventCallback("onValid",this.state.value,this.refsInput.value))}},{key:"_toNumber",value:function(t){var n=parseFloat(t);if(!isNaN(n)&&isFinite(n)||(n=0),this._isStrict){var o=p(this.props,"precision",null,this),a=Math.pow(10,null===o?10:o),i=+p(this.props,"min",e.defaultProps.min,this),s=+p(this.props,"max",e.defaultProps.max,this);n=Math.min(Math.max(n,i),s),n=Math.round(n*a)/a}return n}},{key:"_parse",value:function(t){return t=String(t),"function"==typeof this.props.parse?parseFloat(this.props.parse(t)):parseFloat(t)}},{key:"_format",value:function(t){var e=this._toNumber(t),n=p(this.props,"precision",null,this);return null!==n&&(e=t.toFixed(n)),e+="",this.props.format?this.props.format(e):e}},{key:"_step",value:function t(n,o){var a=this._isStrict;this._isStrict=!0;var t=+p(this.props,"step",e.defaultProps.step,this,n>0?e.DIRECTION_UP:e.DIRECTION_DOWN),i=this._toNumber((this.state.value||0)+t*n);return this.props.snap&&(i=Math.round(i/t)*t),this._isStrict=a,i!==this.state.value&&(this.setState({value:i,stringValue:i+""},o),!0)}},{key:"_onKeyDown",value:function(){for(var t=arguments.length,e=Array(t),n=0;n0&&a.length&&"."===a.charAt(this.refsInput.selectionEnd-1)&&(o.preventDefault(),this.refsInput.selectionStart=this.refsInput.selectionEnd=this.refsInput.selectionEnd-1):46===o.keyCode&&this.refsInput.selectionStart==this.refsInput.selectionEnd&&this.refsInput.selectionEnd0&&void 0!==arguments[0]&&arguments[0],o=arguments[1];this.stop(),this._step(1,o);var a=+p(this.props,"max",e.defaultProps.max,this);(isNaN(this.state.value)||+this.state.value0&&void 0!==arguments[0]&&arguments[0],o=arguments[1];this.stop(),this._step(-1,o);var a=+p(this.props,"min",e.defaultProps.min,this);(isNaN(this.state.value)||+this.state.value>a)&&(this._timer=setTimeout(function(){t.decrease(!0)},n?e.SPEED:e.DELAY))}},{key:"onMouseDown",value:function(t,e){"down"==t?this.decrease(!1,e):"up"==t&&this.increase(!1,e)}},{key:"onTouchStart",value:function(t,e){e.preventDefault(),"down"==t?this.decrease():"up"==t&&this.increase()}},{key:"onTouchEnd",value:function(t){t.preventDefault(),this.stop()}},{key:"_invokeEventCallback",value:function(t){if("function"==typeof this.props[t]){for(var e,n=arguments.length,o=Array(n>1?n-1:0),a=1;a