@internationalized/number
Advanced tools
Comparing version 3.0.0-nightly-533a02fe1-241009 to 3.0.0-nightly-56e575731-241121
@@ -20,3 +20,2 @@ | ||
try { | ||
// @ts-ignore | ||
$0c1d5654b62fc485$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', { | ||
@@ -26,6 +25,5 @@ signDisplay: 'exceptZero' | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} catch {} | ||
let $0c1d5654b62fc485$var$supportsUnit = false; | ||
try { | ||
// @ts-ignore | ||
$0c1d5654b62fc485$var$supportsUnit = new Intl.NumberFormat('de-DE', { | ||
@@ -36,3 +34,3 @@ style: 'unit', | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} catch {} | ||
// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438. | ||
@@ -67,9 +65,6 @@ // Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales. | ||
// TODO: implement signDisplay for formatToParts | ||
// @ts-ignore | ||
return this.numberFormatter.formatToParts(value); | ||
} | ||
/** Formats a number range as a string. */ formatRange(start, end) { | ||
// @ts-ignore | ||
if (typeof this.numberFormatter.formatRange === 'function') // @ts-ignore | ||
return this.numberFormatter.formatRange(start, end); | ||
if (typeof this.numberFormatter.formatRange === 'function') return this.numberFormatter.formatRange(start, end); | ||
if (end < start) throw new RangeError('End date must be >= start date'); | ||
@@ -80,5 +75,3 @@ // Very basic fallback for old browsers. | ||
/** Formats a number range as an array of parts. */ formatRangeToParts(start, end) { | ||
// @ts-ignore | ||
if (typeof this.numberFormatter.formatRangeToParts === 'function') // @ts-ignore | ||
return this.numberFormatter.formatRangeToParts(start, end); | ||
if (typeof this.numberFormatter.formatRangeToParts === 'function') return this.numberFormatter.formatRangeToParts(start, end); | ||
if (end < start) throw new RangeError('End date must be >= start date'); | ||
@@ -85,0 +78,0 @@ let startParts = this.numberFormatter.formatToParts(start); |
@@ -14,3 +14,2 @@ /* | ||
try { | ||
// @ts-ignore | ||
$488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', { | ||
@@ -20,6 +19,5 @@ signDisplay: 'exceptZero' | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} catch {} | ||
let $488c6ddbf4ef74c2$var$supportsUnit = false; | ||
try { | ||
// @ts-ignore | ||
$488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat('de-DE', { | ||
@@ -30,3 +28,3 @@ style: 'unit', | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} catch {} | ||
// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438. | ||
@@ -61,9 +59,6 @@ // Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales. | ||
// TODO: implement signDisplay for formatToParts | ||
// @ts-ignore | ||
return this.numberFormatter.formatToParts(value); | ||
} | ||
/** Formats a number range as a string. */ formatRange(start, end) { | ||
// @ts-ignore | ||
if (typeof this.numberFormatter.formatRange === 'function') // @ts-ignore | ||
return this.numberFormatter.formatRange(start, end); | ||
if (typeof this.numberFormatter.formatRange === 'function') return this.numberFormatter.formatRange(start, end); | ||
if (end < start) throw new RangeError('End date must be >= start date'); | ||
@@ -74,5 +69,3 @@ // Very basic fallback for old browsers. | ||
/** Formats a number range as an array of parts. */ formatRangeToParts(start, end) { | ||
// @ts-ignore | ||
if (typeof this.numberFormatter.formatRangeToParts === 'function') // @ts-ignore | ||
return this.numberFormatter.formatRangeToParts(start, end); | ||
if (typeof this.numberFormatter.formatRangeToParts === 'function') return this.numberFormatter.formatRangeToParts(start, end); | ||
if (end < start) throw new RangeError('End date must be >= start date'); | ||
@@ -79,0 +72,0 @@ let startParts = this.numberFormatter.formatToParts(start); |
@@ -24,3 +24,5 @@ var $0c1d5654b62fc485$exports = require("./NumberFormatter.main.js"); | ||
'arab', | ||
'hanidec' | ||
'hanidec', | ||
'deva', | ||
'beng' | ||
]; | ||
@@ -191,4 +193,8 @@ class $d68f3f4c684426c6$export$cd11ab140839f11d { | ||
...intlOptions, | ||
// Resets so we get the full range of symbols | ||
minimumSignificantDigits: 1, | ||
maximumSignificantDigits: 21 | ||
maximumSignificantDigits: 21, | ||
roundingIncrement: 1, | ||
roundingPriority: 'auto', | ||
roundingMode: 'halfExpand' | ||
}); | ||
@@ -204,3 +210,2 @@ // Note: some locale's don't add a group symbol until there is a ten thousands place | ||
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character. | ||
// @ts-ignore | ||
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'exceptZero' || (originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'always')) plusSign = '+'; | ||
@@ -250,5 +255,3 @@ // If maximumSignificantDigits is 1 (the minimum) then we won't get decimal characters out of the above formatters | ||
function $d68f3f4c684426c6$var$replaceAll(str, find, replace) { | ||
// @ts-ignore | ||
if (str.replaceAll) // @ts-ignore | ||
return str.replaceAll(find, replace); | ||
if (str.replaceAll) return str.replaceAll(find, replace); | ||
return str.split(find).join(replace); | ||
@@ -255,0 +258,0 @@ } |
@@ -18,3 +18,5 @@ import {NumberFormatter as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5} from "./NumberFormatter.module.js"; | ||
'arab', | ||
'hanidec' | ||
'hanidec', | ||
'deva', | ||
'beng' | ||
]; | ||
@@ -185,4 +187,8 @@ class $6c7bd7858deea686$export$cd11ab140839f11d { | ||
...intlOptions, | ||
// Resets so we get the full range of symbols | ||
minimumSignificantDigits: 1, | ||
maximumSignificantDigits: 21 | ||
maximumSignificantDigits: 21, | ||
roundingIncrement: 1, | ||
roundingPriority: 'auto', | ||
roundingMode: 'halfExpand' | ||
}); | ||
@@ -198,3 +204,2 @@ // Note: some locale's don't add a group symbol until there is a ten thousands place | ||
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character. | ||
// @ts-ignore | ||
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'exceptZero' || (originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'always')) plusSign = '+'; | ||
@@ -244,5 +249,3 @@ // If maximumSignificantDigits is 1 (the minimum) then we won't get decimal characters out of the above formatters | ||
function $6c7bd7858deea686$var$replaceAll(str, find, replace) { | ||
// @ts-ignore | ||
if (str.replaceAll) // @ts-ignore | ||
return str.replaceAll(find, replace); | ||
if (str.replaceAll) return str.replaceAll(find, replace); | ||
return str.split(find).join(replace); | ||
@@ -249,0 +252,0 @@ } |
{ | ||
"name": "@internationalized/number", | ||
"version": "3.0.0-nightly-533a02fe1-241009", | ||
"version": "3.0.0-nightly-56e575731-241121", | ||
"description": "Internationalized number formatting and parsing utilities", | ||
@@ -30,3 +30,3 @@ "license": "Apache-2.0", | ||
}, | ||
"stableVersion": "3.5.4" | ||
"stableVersion": "3.6.0" | ||
} |
@@ -17,13 +17,11 @@ /* | ||
try { | ||
// @ts-ignore | ||
supportsSignDisplay = (new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'})).resolvedOptions().signDisplay === 'exceptZero'; | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} catch {} | ||
let supportsUnit = false; | ||
try { | ||
// @ts-ignore | ||
supportsUnit = (new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'})).resolvedOptions().style === 'unit'; | ||
// eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} catch {} | ||
@@ -91,3 +89,2 @@ // Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438. | ||
// TODO: implement signDisplay for formatToParts | ||
// @ts-ignore | ||
return this.numberFormatter.formatToParts(value); | ||
@@ -98,5 +95,3 @@ } | ||
formatRange(start: number, end: number): string { | ||
// @ts-ignore | ||
if (typeof this.numberFormatter.formatRange === 'function') { | ||
// @ts-ignore | ||
return this.numberFormatter.formatRange(start, end); | ||
@@ -115,5 +110,3 @@ } | ||
formatRangeToParts(start: number, end: number): NumberRangeFormatPart[] { | ||
// @ts-ignore | ||
if (typeof this.numberFormatter.formatRangeToParts === 'function') { | ||
// @ts-ignore | ||
return this.numberFormatter.formatRangeToParts(start, end); | ||
@@ -120,0 +113,0 @@ } |
@@ -26,3 +26,3 @@ /* | ||
const CURRENCY_SIGN_REGEX = new RegExp('^.*\\(.*\\).*$'); | ||
const NUMBERING_SYSTEMS = ['latn', 'arab', 'hanidec']; | ||
const NUMBERING_SYSTEMS = ['latn', 'arab', 'hanidec', 'deva', 'beng']; | ||
@@ -259,3 +259,10 @@ /** | ||
// formatter needs access to all decimal places in order to generate the correct literal strings for the plural set | ||
let symbolFormatter = new Intl.NumberFormat(locale, {...intlOptions, minimumSignificantDigits: 1, maximumSignificantDigits: 21}); | ||
let symbolFormatter = new Intl.NumberFormat(locale, {...intlOptions, | ||
// Resets so we get the full range of symbols | ||
minimumSignificantDigits: 1, | ||
maximumSignificantDigits: 21, | ||
roundingIncrement: 1, | ||
roundingPriority: 'auto', | ||
roundingMode: 'halfExpand' | ||
}); | ||
// Note: some locale's don't add a group symbol until there is a ten thousands place | ||
@@ -271,3 +278,2 @@ let allParts = symbolFormatter.formatToParts(-10000.111); | ||
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character. | ||
// @ts-ignore | ||
if (!plusSign && (originalOptions?.signDisplay === 'exceptZero' || originalOptions?.signDisplay === 'always')) { | ||
@@ -304,5 +310,3 @@ plusSign = '+'; | ||
function replaceAll(str: string, find: string, replace: string) { | ||
// @ts-ignore | ||
if (str.replaceAll) { | ||
// @ts-ignore | ||
return str.replaceAll(find, replace); | ||
@@ -309,0 +313,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
169926
1770