Skip to content

Commit

Permalink
Release 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yadav committed Dec 8, 2017
1 parent 07f1db3 commit b86ed66
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 43 deletions.
47 changes: 27 additions & 20 deletions dist/react-number-format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* react-number-format - 3.0.3
* react-number-format - 3.1.0
* Author : Sudhanshu Yadav
* Copyright (c) 2016,2017 to Sudhanshu Yadav - ignitersworld.com , released under the MIT license.
*/
Expand Down Expand Up @@ -113,7 +113,8 @@ return /******/ (function(modules) { // webpackBootstrap
onBlur: _propTypes2.default.func,
type: _propTypes2.default.oneOf(['text', 'tel']),
isAllowed: _propTypes2.default.func,
renderText: _propTypes2.default.func
renderText: _propTypes2.default.func,
getInputRef: _propTypes2.default.func
};

var defaultProps = {
Expand All @@ -131,7 +132,8 @@ return /******/ (function(modules) { // webpackBootstrap
onMouseUp: _utils.noop,
onFocus: _utils.noop,
onBlur: _utils.noop,
isAllowed: _utils.returnTrue
isAllowed: _utils.returnTrue,
getInputRef: _utils.noop
};

var NumberFormat = function (_React$Component) {
Expand Down Expand Up @@ -708,7 +710,9 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'correctInputValue',
value: function correctInputValue(caretPos, lastValue, value) {
var format = this.props.format;
var _props9 = this.props,
format = _props9.format,
decimalSeparator = _props9.decimalSeparator;

var lastNumStr = this.state.numAsString || '';

Expand Down Expand Up @@ -742,7 +746,8 @@ return /******/ (function(modules) { // webpackBootstrap
//clear only if something got deleted


if (numericString.length < lastNumStr.length && beforeDecimal === '' && !parseFloat(afterDecimal)) {
var isBeforeDecimalPoint = caretPos < value.indexOf(decimalSeparator) + 1;
if (numericString.length < lastNumStr.length && isBeforeDecimalPoint && beforeDecimal === '' && !parseFloat(afterDecimal)) {
return addNegation ? '-' : '';
}
}
Expand Down Expand Up @@ -840,13 +845,13 @@ return /******/ (function(modules) { // webpackBootstrap
var selectionStart = el.selectionStart;

var expectedCaretPosition = void 0;
var _props9 = this.props,
decimalScale = _props9.decimalScale,
fixedDecimalScale = _props9.fixedDecimalScale,
prefix = _props9.prefix,
suffix = _props9.suffix,
format = _props9.format,
onKeyDown = _props9.onKeyDown;
var _props10 = this.props,
decimalScale = _props10.decimalScale,
fixedDecimalScale = _props10.fixedDecimalScale,
prefix = _props10.prefix,
suffix = _props10.suffix,
format = _props10.format,
onKeyDown = _props10.onKeyDown;

var ignoreDecimalSeparator = decimalScale !== undefined && fixedDecimalScale;
var numRegex = this.getNumberRegex(false, ignoreDecimalSeparator);
Expand Down Expand Up @@ -941,16 +946,17 @@ return /******/ (function(modules) { // webpackBootstrap
}

_this2.props.onFocus(e);
});
}, 0);
}
}, {
key: 'render',
value: function render() {
var _props10 = this.props,
type = _props10.type,
displayType = _props10.displayType,
customInput = _props10.customInput,
renderText = _props10.renderText;
var _props11 = this.props,
type = _props11.type,
displayType = _props11.displayType,
customInput = _props11.customInput,
renderText = _props11.renderText,
getInputRef = _props11.getInputRef;
var value = this.state.value;


Expand All @@ -963,13 +969,14 @@ return /******/ (function(modules) { // webpackBootstrap
onKeyDown: this.onKeyDown,
onMouseUp: this.onMouseUp,
onFocus: this.onFocus,
onBlur: this.onBlur
onBlur: this.onBlur,
ref: getInputRef
});

if (displayType === 'text') {
return renderText ? renderText(value) || null : _react2.default.createElement(
'span',
otherProps,
_extends({}, otherProps, { ref: getInputRef }),
value
);
} else if (customInput) {
Expand Down
4 changes: 2 additions & 2 deletions dist/react-number-format.min.js

Large diffs are not rendered by default.

45 changes: 26 additions & 19 deletions lib/number_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ var propTypes = {
onBlur: _propTypes2.default.func,
type: _propTypes2.default.oneOf(['text', 'tel']),
isAllowed: _propTypes2.default.func,
renderText: _propTypes2.default.func
renderText: _propTypes2.default.func,
getInputRef: _propTypes2.default.func
};

var defaultProps = {
Expand All @@ -63,7 +64,8 @@ var defaultProps = {
onMouseUp: _utils.noop,
onFocus: _utils.noop,
onBlur: _utils.noop,
isAllowed: _utils.returnTrue
isAllowed: _utils.returnTrue,
getInputRef: _utils.noop
};

var NumberFormat = function (_React$Component) {
Expand Down Expand Up @@ -640,7 +642,9 @@ var NumberFormat = function (_React$Component) {
}, {
key: 'correctInputValue',
value: function correctInputValue(caretPos, lastValue, value) {
var format = this.props.format;
var _props9 = this.props,
format = _props9.format,
decimalSeparator = _props9.decimalSeparator;

var lastNumStr = this.state.numAsString || '';

Expand Down Expand Up @@ -674,7 +678,8 @@ var NumberFormat = function (_React$Component) {
//clear only if something got deleted


if (numericString.length < lastNumStr.length && beforeDecimal === '' && !parseFloat(afterDecimal)) {
var isBeforeDecimalPoint = caretPos < value.indexOf(decimalSeparator) + 1;
if (numericString.length < lastNumStr.length && isBeforeDecimalPoint && beforeDecimal === '' && !parseFloat(afterDecimal)) {
return addNegation ? '-' : '';
}
}
Expand Down Expand Up @@ -772,13 +777,13 @@ var NumberFormat = function (_React$Component) {
var selectionStart = el.selectionStart;

var expectedCaretPosition = void 0;
var _props9 = this.props,
decimalScale = _props9.decimalScale,
fixedDecimalScale = _props9.fixedDecimalScale,
prefix = _props9.prefix,
suffix = _props9.suffix,
format = _props9.format,
onKeyDown = _props9.onKeyDown;
var _props10 = this.props,
decimalScale = _props10.decimalScale,
fixedDecimalScale = _props10.fixedDecimalScale,
prefix = _props10.prefix,
suffix = _props10.suffix,
format = _props10.format,
onKeyDown = _props10.onKeyDown;

var ignoreDecimalSeparator = decimalScale !== undefined && fixedDecimalScale;
var numRegex = this.getNumberRegex(false, ignoreDecimalSeparator);
Expand Down Expand Up @@ -873,16 +878,17 @@ var NumberFormat = function (_React$Component) {
}

_this2.props.onFocus(e);
});
}, 0);
}
}, {
key: 'render',
value: function render() {
var _props10 = this.props,
type = _props10.type,
displayType = _props10.displayType,
customInput = _props10.customInput,
renderText = _props10.renderText;
var _props11 = this.props,
type = _props11.type,
displayType = _props11.displayType,
customInput = _props11.customInput,
renderText = _props11.renderText,
getInputRef = _props11.getInputRef;
var value = this.state.value;


Expand All @@ -895,13 +901,14 @@ var NumberFormat = function (_React$Component) {
onKeyDown: this.onKeyDown,
onMouseUp: this.onMouseUp,
onFocus: this.onFocus,
onBlur: this.onBlur
onBlur: this.onBlur,
ref: getInputRef
});

if (displayType === 'text') {
return renderText ? renderText(value) || null : _react2.default.createElement(
'span',
otherProps,
_extends({}, otherProps, { ref: getInputRef }),
value
);
} else if (customInput) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "react-number-format",
"description": "React component to format number in an input or as a text.",
"version": "3.0.3",
"version": "3.1.0",
"main": "lib/number_format.js",
"author": "Sudhanshu Yadav",
"license": "MIT",
Expand All @@ -24,7 +24,7 @@
],
"scripts": {
"start": "webpack-dev-server --content-base example/ --config webpack.dev.config.js --watch-poll --progress --inline --hot",
"bundle": "cross-env NODE_ENV=production npm run compile && cross-env NODE_ENV=production webpack --config webpack.bundle.config.js && cross-env NODE_ENV=production karma start",
"bundle": "cross-env NODE_ENV=production npm run compile && cross-env NODE_ENV=production webpack --config webpack.bundle.config.js && cross-env NODE_ENV=production TEST_BROWSER=ChromeHeadless karma start",
"compile": "cross-env NODE_ENV=production babel src --out-dir lib",
"test": "cross-env NODE_ENV=test karma start",
"lint": "cross-env eslint src/**"
Expand Down

0 comments on commit b86ed66

Please sign in to comment.