Skip to content

Commit

Permalink
Release for #331
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yadav committed Aug 7, 2019
1 parent 9e7f07a commit 8effbb4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
13 changes: 10 additions & 3 deletions dist/react-number-format.es.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* react-number-format - 4.1.1
* react-number-format - 4.2.0
* Author : Sudhanshu Yadav
* Copyright (c) 2016, 2019 to Sudhanshu Yadav, released under the MIT license.
* https://github.com/s-yadav/react-number-format
Expand Down Expand Up @@ -203,6 +203,7 @@ function getThousandsGroupRegex(thousandsGroupStyle) {
function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
var index = str.search(/[1-9]/);
index = index === -1 ? str.length : index;
return str.substring(0, index) + str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator);
} //spilt a float number into different parts beforeDecimal, afterDecimal, and negation

Expand Down Expand Up @@ -364,6 +365,7 @@ var propTypes$1 = {
customInput: propTypes.elementType,
allowNegative: propTypes.bool,
allowEmptyFormatting: propTypes.bool,
allowLeadingZeros: propTypes.bool,
onValueChange: propTypes.func,
onKeyDown: propTypes.func,
onMouseUp: propTypes.func,
Expand All @@ -384,6 +386,7 @@ var defaultProps = {
suffix: '',
allowNegative: true,
allowEmptyFormatting: false,
allowLeadingZeros: false,
isNumericString: false,
type: 'text',
onValueChange: noop,
Expand Down Expand Up @@ -1103,13 +1106,17 @@ function (_React$Component) {
var props = this.props,
state = this.state;
var format = props.format,
onBlur = props.onBlur;
onBlur = props.onBlur,
allowLeadingZeros = props.allowLeadingZeros;
var numAsString = state.numAsString;
var lastValue = state.value;
this.focusedElm = null;

if (!format) {
numAsString = fixLeadingZero(numAsString);
if (!allowLeadingZeros) {
numAsString = fixLeadingZero(numAsString);
}

var formattedValue = this.formatNumString(numAsString); //change the state

if (formattedValue !== lastValue) {
Expand Down
13 changes: 10 additions & 3 deletions dist/react-number-format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* react-number-format - 4.1.1
* react-number-format - 4.2.0
* Author : Sudhanshu Yadav
* Copyright (c) 2016, 2019 to Sudhanshu Yadav, released under the MIT license.
* https://github.com/s-yadav/react-number-format
Expand Down Expand Up @@ -209,6 +209,7 @@
function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
var index = str.search(/[1-9]/);
index = index === -1 ? str.length : index;
return str.substring(0, index) + str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator);
} //spilt a float number into different parts beforeDecimal, afterDecimal, and negation

Expand Down Expand Up @@ -370,6 +371,7 @@
customInput: propTypes.elementType,
allowNegative: propTypes.bool,
allowEmptyFormatting: propTypes.bool,
allowLeadingZeros: propTypes.bool,
onValueChange: propTypes.func,
onKeyDown: propTypes.func,
onMouseUp: propTypes.func,
Expand All @@ -390,6 +392,7 @@
suffix: '',
allowNegative: true,
allowEmptyFormatting: false,
allowLeadingZeros: false,
isNumericString: false,
type: 'text',
onValueChange: noop,
Expand Down Expand Up @@ -1109,13 +1112,17 @@
var props = this.props,
state = this.state;
var format = props.format,
onBlur = props.onBlur;
onBlur = props.onBlur,
allowLeadingZeros = props.allowLeadingZeros;
var numAsString = state.numAsString;
var lastValue = state.value;
this.focusedElm = null;

if (!format) {
numAsString = fixLeadingZero(numAsString);
if (!allowLeadingZeros) {
numAsString = fixLeadingZero(numAsString);
}

var formattedValue = this.formatNumString(numAsString); //change the state

if (formattedValue !== lastValue) {
Expand Down
2 changes: 1 addition & 1 deletion dist/react-number-format.min.js

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions lib/number_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var propTypes = {
customInput: _propTypes.default.elementType,
allowNegative: _propTypes.default.bool,
allowEmptyFormatting: _propTypes.default.bool,
allowLeadingZeros: _propTypes.default.bool,
onValueChange: _propTypes.default.func,
onKeyDown: _propTypes.default.func,
onMouseUp: _propTypes.default.func,
Expand All @@ -71,6 +72,7 @@ var defaultProps = {
suffix: '',
allowNegative: true,
allowEmptyFormatting: false,
allowLeadingZeros: false,
isNumericString: false,
type: 'text',
onValueChange: _utils.noop,
Expand Down Expand Up @@ -790,13 +792,17 @@ function (_React$Component) {
var props = this.props,
state = this.state;
var format = props.format,
onBlur = props.onBlur;
onBlur = props.onBlur,
allowLeadingZeros = props.allowLeadingZeros;
var numAsString = state.numAsString;
var lastValue = state.value;
this.focusedElm = null;

if (!format) {
numAsString = (0, _utils.fixLeadingZero)(numAsString);
if (!allowLeadingZeros) {
numAsString = (0, _utils.fixLeadingZero)(numAsString);
}

var formattedValue = this.formatNumString(numAsString); //change the state

if (formattedValue !== lastValue) {
Expand Down
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function getThousandsGroupRegex(thousandsGroupStyle) {
function applyThousandSeparator(str, thousandSeparator, thousandsGroupStyle) {
var thousandsGroupRegex = getThousandsGroupRegex(thousandsGroupStyle);
var index = str.search(/[1-9]/);
index = index === -1 ? str.length : index;
return str.substring(0, index) + str.substring(index, str.length).replace(thousandsGroupRegex, '$1' + thousandSeparator);
} //spilt a float number into different parts beforeDecimal, afterDecimal, and negation

Expand Down
2 changes: 1 addition & 1 deletion 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": "4.1.1",
"version": "4.2.0",
"main": "lib/number_format.js",
"module": "dist/react-number-format.es.js",
"author": "Sudhanshu Yadav",
Expand Down

0 comments on commit 8effbb4

Please sign in to comment.