Skip to content

Commit

Permalink
Merge pull request #11 from nosir/Issue-7
Browse files Browse the repository at this point in the history
[Issue-7] Remove numeral leading 0
  • Loading branch information
nosir authored Jul 9, 2016
2 parents fa4f008 + 37cc72a commit c7668a5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 9 deletions.
7 changes: 5 additions & 2 deletions dist/cleave-react.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/cleave-react.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion dist/cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,10 @@ NumeralFormatter.prototype = {
.replace(/[^\dM]/g, '')

// replace mark
.replace('M', owner.numeralDecimalMark);
.replace('M', owner.numeralDecimalMark)

// strip leading 0
.replace(/^(-)?0+(?=\d)/, '$1');

partInteger = value;

Expand Down
4 changes: 2 additions & 2 deletions dist/cleave.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"form",
"input"
],
"version": "0.3.1",
"version": "0.3.2",
"author": {
"name": "Max Huang",
"url": "http://github.com/nosir",
Expand Down
5 changes: 4 additions & 1 deletion src/shortcuts/NumeralFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ NumeralFormatter.prototype = {
.replace(/[^\dM]/g, '')

// replace mark
.replace('M', owner.numeralDecimalMark);
.replace('M', owner.numeralDecimalMark)

// strip leading 0
.replace(/^(-)?0+(?=\d)/, '$1');

partInteger = value;

Expand Down
27 changes: 27 additions & 0 deletions test/fixtures/numeral.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@
]
]
},
{
"thousandsGroupStyle": "thousand",
"numbers": [
[
"01234567",
"1,234,567"
]
]
},
{
"thousandsGroupStyle": "thousand",
"numbers": [
[
"0.1234",
"0.12"
]
]
},
{
"thousandsGroupStyle": "thousand",
"numbers": [
[
"00.1234",
"0.12"
]
]
},
{
"thousandsGroupStyle": "lakh",
"numbers": [
Expand Down

0 comments on commit c7668a5

Please sign in to comment.