Skip to content

Commit

Permalink
Migration to Numbro v2 (#5127)
Browse files Browse the repository at this point in the history
* Changed: new version of Numbro library. #5081

* Updated Numbro version in yarn.lock and bower.json. #5081
  • Loading branch information
swistach committed Jun 4, 2018
1 parent 6583927 commit 5d70d80
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .config/production.js
Expand Up @@ -66,7 +66,7 @@ module.exports.create = function create(envArgs) {
from: {glob: 'node_modules/numbro/@(LICENSE-Numeraljs|LICENSE)'}, to: 'numbro', flatten: true
},
{
from: {glob: 'node_modules/numbro/dist/@(numbro.js|languages.js)'}, to: 'numbro', flatten: true
from: {glob: 'node_modules/numbro/dist/@(numbro.js|languages.min.js)'}, to: 'numbro', flatten: true
},
{
from: {glob: 'node_modules/numbro/dist/languages/*.js'}, to: 'numbro/languages', flatten: true
Expand Down
4 changes: 2 additions & 2 deletions .config/test-e2e.js
Expand Up @@ -50,8 +50,8 @@ module.exports.create = function create(envArgs) {
'lib/jquery.simulate.js',
'lib/lodash.underscore.js',
'lib/backbone.js',
'../dist/numbro/numbro.js',
'../dist/numbro/languages.js',
'../node_modules/numbro/dist/numbro.js',
'../node_modules/numbro/dist/languages.min.js',
'../dist/moment/moment.js',
'../dist/pikaday/pikaday.js',
'../dist/handsontable.js',
Expand Down
4 changes: 2 additions & 2 deletions .config/test-mobile.js
Expand Up @@ -34,8 +34,8 @@ module.exports.create = function create(envArgs) {
'lib/jquery.simulate.js',
'lib/lodash.underscore.js',
'lib/backbone.js',
'../dist/numbro/numbro.js',
'../dist/numbro/languages.js',
'../node_modules/numbro/dist/numbro.js',
'../node_modules/numbro/dist/languages.min.js',
'../dist/moment/moment.js',
'../dist/pikaday/pikaday.js',
'../dist/handsontable.js',
Expand Down
2 changes: 1 addition & 1 deletion .config/test-production.js
Expand Up @@ -36,7 +36,7 @@ module.exports.create = function create(envArgs) {
'lib/lodash.underscore.js',
'lib/backbone.js',
'../dist/handsontable.full.min.js',
'../dist/numbro/languages.js',
'../node_modules/numbro/dist/languages.min.js',
'../dist/languages/all.min.js',
],
})
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Expand Up @@ -35,7 +35,7 @@
],
"dependencies": {
"moment": "^2.13.0",
"numbro": "^1.8.0",
"numbro": "^2.0.6",
"pikaday": "^1.4.0"
},
"devDependencies": {
Expand Down
38 changes: 29 additions & 9 deletions package-lock.json

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
Expand Up @@ -60,7 +60,7 @@
],
"dependencies": {
"moment": "2.20.1",
"numbro": "1.11.0",
"numbro": "^2.0.6",
"pikaday": "1.5.1"
},
"devDependencies": {
Expand Down
13 changes: 10 additions & 3 deletions src/renderers/numericRenderer.js
Expand Up @@ -19,15 +19,22 @@ import {isNumeric} from './../helpers/number';
function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
if (isNumeric(value)) {
const numericFormat = cellProperties.numericFormat;
const cellCulture = numericFormat && numericFormat.culture;
const cellCulture = numericFormat && numericFormat.culture || '-';
const cellFormatPattern = numericFormat && numericFormat.pattern;
const className = cellProperties.className || '';
let classArr = className.length ? className.split(' ') : [];

if (typeof cellCulture !== 'undefined') {
numbro.culture(cellCulture);
if (typeof cellCulture !== 'undefined' && !numbro.languages()[cellCulture]) {
const shortTag = cellCulture.replace('-', '');
const langData = numbro.allLanguages ? numbro.allLanguages[cellCulture] : numbro[shortTag];

if (langData) {
numbro.registerLanguage(langData);
}
}

numbro.setLanguage(cellCulture);

value = numbro(value).format(cellFormatPattern || '0');

if (classArr.indexOf('htLeft') < 0 && classArr.indexOf('htCenter') < 0 &&
Expand Down
12 changes: 9 additions & 3 deletions yarn.lock
Expand Up @@ -874,6 +874,10 @@ big.js@^3.1.3:
version "3.2.0"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"

bignumber.js@^4.0.4:
version "4.1.0"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1"

binary-extensions@^1.0.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205"
Expand Down Expand Up @@ -4126,9 +4130,11 @@ number-is-nan@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"

numbro@1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/numbro/-/numbro-1.11.0.tgz#39aa17b358b4682aec8ca0d5755f35c5d9ce8f9e"
numbro@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/numbro/-/numbro-2.0.6.tgz#d46acaa11aa879d522e93651de3926646d6db100"
dependencies:
bignumber.js "^4.0.4"

"nwmatcher@>= 1.3.9 < 2.0.0":
version "1.4.4"
Expand Down

0 comments on commit 5d70d80

Please sign in to comment.