react-currency-input-field
Advanced tools
Comparing version 3.6.5 to 3.6.6
@@ -181,15 +181,10 @@ import React, { forwardRef, useMemo, useState, useRef, useEffect } from 'react'; | ||
: _value; | ||
var defaultNumberFormatOptions = { | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
}; | ||
var numberFormatter = intlConfig | ||
? new Intl.NumberFormat(intlConfig.locale, intlConfig.currency | ||
? { | ||
style: 'currency', | ||
currency: intlConfig.currency, | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
} | ||
: undefined) | ||
: new Intl.NumberFormat(undefined, { | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
}); | ||
? __assign(__assign({}, defaultNumberFormatOptions), { style: 'currency', currency: intlConfig.currency }) : defaultNumberFormatOptions) | ||
: new Intl.NumberFormat(undefined, defaultNumberFormatOptions); | ||
var parts = numberFormatter.formatToParts(Number(value)); | ||
@@ -196,0 +191,0 @@ var formatted = replaceParts(parts, options); |
@@ -189,15 +189,10 @@ (function (global, factory) { | ||
: _value; | ||
var defaultNumberFormatOptions = { | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
}; | ||
var numberFormatter = intlConfig | ||
? new Intl.NumberFormat(intlConfig.locale, intlConfig.currency | ||
? { | ||
style: 'currency', | ||
currency: intlConfig.currency, | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
} | ||
: undefined) | ||
: new Intl.NumberFormat(undefined, { | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
}); | ||
? __assign(__assign({}, defaultNumberFormatOptions), { style: 'currency', currency: intlConfig.currency }) : defaultNumberFormatOptions) | ||
: new Intl.NumberFormat(undefined, defaultNumberFormatOptions); | ||
var parts = numberFormatter.formatToParts(Number(value)); | ||
@@ -204,0 +199,0 @@ var formatted = replaceParts(parts, options); |
{ | ||
"name": "react-currency-input-field", | ||
"version": "3.6.5", | ||
"version": "3.6.6", | ||
"description": "React <input/> component for formatting currency and numbers.", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -519,3 +519,23 @@ import { formatValue } from '../formatValue'; | ||
}); | ||
it('should add decimals if intlConfig has no currency provided, decimalScale defined and the input value is X.00', () => { | ||
expect( | ||
formatValue({ | ||
value: '123.00', | ||
intlConfig: { locale: 'en-US' }, | ||
decimalScale: 2, | ||
}) | ||
).toEqual(`123.00`); | ||
}); | ||
it('should add decimals if intlConfig has no currency provided, decimalScale defined and the input value is X.00 (de-DE)', () => { | ||
expect( | ||
formatValue({ | ||
value: '123.00', | ||
intlConfig: { locale: 'de-DE' }, | ||
decimalScale: 2, | ||
}) | ||
).toEqual(`123,00`); | ||
}); | ||
}); | ||
}); |
@@ -87,2 +87,7 @@ import { IntlConfig } from '../CurrencyInputProps'; | ||
const defaultNumberFormatOptions = { | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
}; | ||
const numberFormatter = intlConfig | ||
@@ -93,13 +98,9 @@ ? new Intl.NumberFormat( | ||
? { | ||
...defaultNumberFormatOptions, | ||
style: 'currency', | ||
currency: intlConfig.currency, | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
} | ||
: undefined | ||
: defaultNumberFormatOptions | ||
) | ||
: new Intl.NumberFormat(undefined, { | ||
minimumFractionDigits: decimalScale || 0, | ||
maximumFractionDigits: 20, | ||
}); | ||
: new Intl.NumberFormat(undefined, defaultNumberFormatOptions); | ||
@@ -106,0 +107,0 @@ const parts = numberFormatter.formatToParts(Number(value)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
273349
5197