@internationalized/number 3.0.5-nightly.3111 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +80 -75
- package/dist/main.js.map +1 -1
- package/dist/module.js +79 -74
- package/dist/module.js.map +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -2,8 +2,8 @@ function $parcel$export(e, n, v, s) {
|
|
|
2
2
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
$parcel$export(module.exports, "NumberFormatter", () => $
|
|
6
|
-
$parcel$export(module.exports, "NumberParser", () => $
|
|
5
|
+
$parcel$export(module.exports, "NumberFormatter", () => $b1fc4c479ca08b67$export$cc77c4ff7e8673c5);
|
|
6
|
+
$parcel$export(module.exports, "NumberParser", () => $35c7ec3c204b4757$export$cd11ab140839f11d);
|
|
7
7
|
/*
|
|
8
8
|
* Copyright 2020 Adobe. All rights reserved.
|
|
9
9
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -14,20 +14,20 @@ $parcel$export(module.exports, "NumberParser", () => $243eedc23c13e9f6$export$cd
|
|
|
14
14
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
15
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
16
|
* governing permissions and limitations under the License.
|
|
17
|
-
*/ let $
|
|
18
|
-
let $
|
|
17
|
+
*/ let $b1fc4c479ca08b67$var$formatterCache = new Map();
|
|
18
|
+
let $b1fc4c479ca08b67$var$supportsSignDisplay = false;
|
|
19
19
|
try {
|
|
20
20
|
// @ts-ignore
|
|
21
|
-
$
|
|
21
|
+
$b1fc4c479ca08b67$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
|
|
22
22
|
signDisplay: 'exceptZero'
|
|
23
23
|
}).resolvedOptions().signDisplay === 'exceptZero';
|
|
24
24
|
// eslint-disable-next-line no-empty
|
|
25
25
|
} catch (e) {
|
|
26
26
|
}
|
|
27
|
-
let $
|
|
27
|
+
let $b1fc4c479ca08b67$var$supportsUnit = false;
|
|
28
28
|
try {
|
|
29
29
|
// @ts-ignore
|
|
30
|
-
$
|
|
30
|
+
$b1fc4c479ca08b67$var$supportsUnit = new Intl.NumberFormat('de-DE', {
|
|
31
31
|
style: 'unit',
|
|
32
32
|
unit: 'degree'
|
|
33
33
|
}).resolvedOptions().style === 'unit';
|
|
@@ -37,7 +37,7 @@ try {
|
|
|
37
37
|
// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
|
|
38
38
|
// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
|
|
39
39
|
// Values were determined by switching to each locale manually in Chrome.
|
|
40
|
-
const $
|
|
40
|
+
const $b1fc4c479ca08b67$var$UNITS = {
|
|
41
41
|
degree: {
|
|
42
42
|
narrow: {
|
|
43
43
|
default: '°',
|
|
@@ -47,19 +47,15 @@ const $3f189ec7e11e3b00$var$UNITS = {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
class $
|
|
51
|
-
constructor(locale, options = {
|
|
52
|
-
}){
|
|
53
|
-
this.numberFormatter = $3f189ec7e11e3b00$var$getCachedNumberFormatter(locale, options);
|
|
54
|
-
this.options = options;
|
|
55
|
-
}
|
|
50
|
+
class $b1fc4c479ca08b67$export$cc77c4ff7e8673c5 {
|
|
56
51
|
format(value) {
|
|
57
52
|
let res = '';
|
|
58
|
-
if (!$
|
|
53
|
+
if (!$b1fc4c479ca08b67$var$supportsSignDisplay && this.options.signDisplay != null) res = $b1fc4c479ca08b67$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
|
|
59
54
|
else res = this.numberFormatter.format(value);
|
|
60
|
-
if (this.options.style === 'unit' && !$
|
|
55
|
+
if (this.options.style === 'unit' && !$b1fc4c479ca08b67$var$supportsUnit) {
|
|
56
|
+
var ref;
|
|
61
57
|
let { unit: unit , unitDisplay: unitDisplay = 'short' , locale: locale } = this.resolvedOptions();
|
|
62
|
-
let values = $
|
|
58
|
+
let values = (ref = $b1fc4c479ca08b67$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
|
|
63
59
|
res += values[locale] || values.default;
|
|
64
60
|
}
|
|
65
61
|
return res;
|
|
@@ -71,11 +67,11 @@ class $3f189ec7e11e3b00$export$cc77c4ff7e8673c5 {
|
|
|
71
67
|
}
|
|
72
68
|
resolvedOptions() {
|
|
73
69
|
let options = this.numberFormatter.resolvedOptions();
|
|
74
|
-
if (!$
|
|
70
|
+
if (!$b1fc4c479ca08b67$var$supportsSignDisplay && this.options.signDisplay != null) options = {
|
|
75
71
|
...options,
|
|
76
72
|
signDisplay: this.options.signDisplay
|
|
77
73
|
};
|
|
78
|
-
if (!$
|
|
74
|
+
if (!$b1fc4c479ca08b67$var$supportsUnit && this.options.style === 'unit') options = {
|
|
79
75
|
...options,
|
|
80
76
|
style: 'unit',
|
|
81
77
|
unit: this.options.unit,
|
|
@@ -83,15 +79,21 @@ class $3f189ec7e11e3b00$export$cc77c4ff7e8673c5 {
|
|
|
83
79
|
};
|
|
84
80
|
return options;
|
|
85
81
|
}
|
|
82
|
+
constructor(locale, options = {
|
|
83
|
+
}){
|
|
84
|
+
this.numberFormatter = $b1fc4c479ca08b67$var$getCachedNumberFormatter(locale, options);
|
|
85
|
+
this.options = options;
|
|
86
|
+
}
|
|
86
87
|
}
|
|
87
|
-
function $
|
|
88
|
+
function $b1fc4c479ca08b67$var$getCachedNumberFormatter(locale, options = {
|
|
88
89
|
}) {
|
|
89
90
|
let { numberingSystem: numberingSystem } = options;
|
|
90
91
|
if (numberingSystem && locale.indexOf('-u-nu-') === -1) locale = `${locale}-u-nu-${numberingSystem}`;
|
|
91
|
-
if (options.style === 'unit' && !$
|
|
92
|
+
if (options.style === 'unit' && !$b1fc4c479ca08b67$var$supportsUnit) {
|
|
93
|
+
var ref;
|
|
92
94
|
let { unit: unit , unitDisplay: unitDisplay = 'short' } = options;
|
|
93
95
|
if (!unit) throw new Error('unit option must be provided with style: "unit"');
|
|
94
|
-
if (
|
|
96
|
+
if (!((ref = $b1fc4c479ca08b67$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
|
|
95
97
|
options = {
|
|
96
98
|
...options,
|
|
97
99
|
style: 'decimal'
|
|
@@ -99,12 +101,12 @@ function $3f189ec7e11e3b00$var$getCachedNumberFormatter(locale, options = {
|
|
|
99
101
|
}
|
|
100
102
|
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
101
103
|
).join() : '');
|
|
102
|
-
if ($
|
|
104
|
+
if ($b1fc4c479ca08b67$var$formatterCache.has(cacheKey)) return $b1fc4c479ca08b67$var$formatterCache.get(cacheKey);
|
|
103
105
|
let numberFormatter = new Intl.NumberFormat(locale, options);
|
|
104
|
-
$
|
|
106
|
+
$b1fc4c479ca08b67$var$formatterCache.set(cacheKey, numberFormatter);
|
|
105
107
|
return numberFormatter;
|
|
106
108
|
}
|
|
107
|
-
function $
|
|
109
|
+
function $b1fc4c479ca08b67$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
|
|
108
110
|
if (signDisplay === 'auto') return numberFormat.format(num);
|
|
109
111
|
else if (signDisplay === 'never') return numberFormat.format(Math.abs(num));
|
|
110
112
|
else {
|
|
@@ -129,85 +131,80 @@ function $3f189ec7e11e3b00$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
|
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
|
|
132
|
-
const $
|
|
133
|
-
const $
|
|
134
|
+
const $35c7ec3c204b4757$var$CURRENCY_SIGN_REGEX = new RegExp('^.*\\(.*\\).*$');
|
|
135
|
+
const $35c7ec3c204b4757$var$NUMBERING_SYSTEMS = [
|
|
134
136
|
'latn',
|
|
135
137
|
'arab',
|
|
136
138
|
'hanidec'
|
|
137
139
|
];
|
|
138
|
-
class $
|
|
139
|
-
constructor(locale, options = {
|
|
140
|
-
}){
|
|
141
|
-
this.locale = locale;
|
|
142
|
-
this.options = options;
|
|
143
|
-
}
|
|
140
|
+
class $35c7ec3c204b4757$export$cd11ab140839f11d {
|
|
144
141
|
/**
|
|
145
142
|
* Parses the given string to a number. Returns NaN if a valid number could not be parsed.
|
|
146
143
|
*/ parse(value) {
|
|
147
|
-
return $
|
|
144
|
+
return $35c7ec3c204b4757$var$getNumberParserImpl(this.locale, this.options, value).parse(value);
|
|
148
145
|
}
|
|
149
146
|
/**
|
|
150
147
|
* Returns whether the given string could potentially be a valid number. This should be used to
|
|
151
148
|
* validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity
|
|
152
149
|
* of the minus/plus sign characters can be checked.
|
|
153
150
|
*/ isValidPartialNumber(value, minValue, maxValue) {
|
|
154
|
-
return $
|
|
151
|
+
return $35c7ec3c204b4757$var$getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);
|
|
155
152
|
}
|
|
156
153
|
/**
|
|
157
154
|
* Returns a numbering system for which the given string is valid in the current locale.
|
|
158
155
|
* If no numbering system could be detected, the default numbering system for the current
|
|
159
156
|
* locale is returned.
|
|
160
157
|
*/ getNumberingSystem(value) {
|
|
161
|
-
return $
|
|
158
|
+
return $35c7ec3c204b4757$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
|
|
159
|
+
}
|
|
160
|
+
constructor(locale, options = {
|
|
161
|
+
}){
|
|
162
|
+
this.locale = locale;
|
|
163
|
+
this.options = options;
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
|
-
const $
|
|
165
|
-
function $
|
|
166
|
+
const $35c7ec3c204b4757$var$numberParserCache = new Map();
|
|
167
|
+
function $35c7ec3c204b4757$var$getNumberParserImpl(locale, options, value) {
|
|
166
168
|
// First try the default numbering system for the provided locale
|
|
167
|
-
let defaultParser = $
|
|
169
|
+
let defaultParser = $35c7ec3c204b4757$var$getCachedNumberParser(locale, options);
|
|
168
170
|
// If that doesn't match, and the locale doesn't include a hard coded numbering system,
|
|
169
171
|
// try each of the other supported numbering systems until we find one that matches.
|
|
170
172
|
if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {
|
|
171
|
-
for (let numberingSystem of $
|
|
172
|
-
let parser = $
|
|
173
|
+
for (let numberingSystem of $35c7ec3c204b4757$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
|
|
174
|
+
let parser = $35c7ec3c204b4757$var$getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);
|
|
173
175
|
if (parser.isValidPartialNumber(value)) return parser;
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
178
|
return defaultParser;
|
|
177
179
|
}
|
|
178
|
-
function $
|
|
180
|
+
function $35c7ec3c204b4757$var$getCachedNumberParser(locale, options) {
|
|
179
181
|
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
180
182
|
).join() : '');
|
|
181
|
-
let parser = $
|
|
183
|
+
let parser = $35c7ec3c204b4757$var$numberParserCache.get(cacheKey);
|
|
182
184
|
if (!parser) {
|
|
183
|
-
parser = new $
|
|
184
|
-
$
|
|
185
|
+
parser = new $35c7ec3c204b4757$var$NumberParserImpl(locale, options);
|
|
186
|
+
$35c7ec3c204b4757$var$numberParserCache.set(cacheKey, parser);
|
|
185
187
|
}
|
|
186
188
|
return parser;
|
|
187
189
|
}
|
|
188
190
|
// The actual number parser implementation. Instances of this class are cached
|
|
189
191
|
// based on the locale, options, and detected numbering system.
|
|
190
|
-
class $
|
|
191
|
-
constructor(locale, options = {
|
|
192
|
-
}){
|
|
193
|
-
this.formatter = new Intl.NumberFormat(locale, options);
|
|
194
|
-
this.options = this.formatter.resolvedOptions();
|
|
195
|
-
this.symbols = $243eedc23c13e9f6$var$getSymbols(this.formatter, this.options, options);
|
|
196
|
-
}
|
|
192
|
+
class $35c7ec3c204b4757$var$NumberParserImpl {
|
|
197
193
|
parse(value) {
|
|
198
194
|
// to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'
|
|
199
195
|
let fullySanitizedValue = this.sanitize(value);
|
|
200
196
|
// Remove group characters, and replace decimal points and numerals with ASCII values.
|
|
201
|
-
fullySanitizedValue = $
|
|
197
|
+
fullySanitizedValue = $35c7ec3c204b4757$var$replaceAll(fullySanitizedValue, this.symbols.group, '').replace(this.symbols.decimal, '.').replace(this.symbols.minusSign, '-').replace(this.symbols.numeral, this.symbols.index);
|
|
202
198
|
let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;
|
|
203
199
|
if (isNaN(newValue)) return NaN;
|
|
204
200
|
// accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again
|
|
205
|
-
if (this.options.currencySign === 'accounting' && $
|
|
201
|
+
if (this.options.currencySign === 'accounting' && $35c7ec3c204b4757$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
|
|
206
202
|
// when reading the number, if it's a percent, then it should be interpreted as being divided by 100
|
|
207
203
|
if (this.options.style === 'percent') {
|
|
208
204
|
newValue /= 100;
|
|
205
|
+
var _maximumFractionDigits;
|
|
209
206
|
// after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits
|
|
210
|
-
newValue = +newValue.toFixed((this.options.maximumFractionDigits
|
|
207
|
+
newValue = +newValue.toFixed(((_maximumFractionDigits = this.options.maximumFractionDigits) !== null && _maximumFractionDigits !== void 0 ? _maximumFractionDigits : 0) + 2);
|
|
211
208
|
}
|
|
212
209
|
return newValue;
|
|
213
210
|
}
|
|
@@ -222,11 +219,11 @@ class $243eedc23c13e9f6$var$NumberParserImpl {
|
|
|
222
219
|
if (this.options.numberingSystem === 'arab') {
|
|
223
220
|
value = value.replace(',', this.symbols.decimal);
|
|
224
221
|
value = value.replace(String.fromCharCode(1548), this.symbols.decimal);
|
|
225
|
-
value = $
|
|
222
|
+
value = $35c7ec3c204b4757$var$replaceAll(value, '.', this.symbols.group);
|
|
226
223
|
}
|
|
227
224
|
// fr-FR group character is char code 8239, but that's not a key on the french keyboard,
|
|
228
225
|
// so allow 'period' as a group char and replace it with a space
|
|
229
|
-
if (this.options.locale === 'fr-FR') value = $
|
|
226
|
+
if (this.options.locale === 'fr-FR') value = $35c7ec3c204b4757$var$replaceAll(value, '.', String.fromCharCode(8239));
|
|
230
227
|
return value;
|
|
231
228
|
}
|
|
232
229
|
isValidPartialNumber(value, minValue = -Infinity, maxValue = Infinity) {
|
|
@@ -237,12 +234,18 @@ class $243eedc23c13e9f6$var$NumberParserImpl {
|
|
|
237
234
|
// Numbers cannot start with a group separator
|
|
238
235
|
if (value.startsWith(this.symbols.group)) return false;
|
|
239
236
|
// Remove numerals, groups, and decimals
|
|
240
|
-
value = $
|
|
237
|
+
value = $35c7ec3c204b4757$var$replaceAll(value, this.symbols.group, '').replace(this.symbols.numeral, '').replace(this.symbols.decimal, '');
|
|
241
238
|
// The number is valid if there are no remaining characters
|
|
242
239
|
return value.length === 0;
|
|
243
240
|
}
|
|
241
|
+
constructor(locale, options = {
|
|
242
|
+
}){
|
|
243
|
+
this.formatter = new Intl.NumberFormat(locale, options);
|
|
244
|
+
this.options = this.formatter.resolvedOptions();
|
|
245
|
+
this.symbols = $35c7ec3c204b4757$var$getSymbols(this.formatter, this.options, options);
|
|
246
|
+
}
|
|
244
247
|
}
|
|
245
|
-
const $
|
|
248
|
+
const $35c7ec3c204b4757$var$nonLiteralParts = new Set([
|
|
246
249
|
'decimal',
|
|
247
250
|
'fraction',
|
|
248
251
|
'integer',
|
|
@@ -250,30 +253,32 @@ const $243eedc23c13e9f6$var$nonLiteralParts = new Set([
|
|
|
250
253
|
'plusSign',
|
|
251
254
|
'group'
|
|
252
255
|
]);
|
|
253
|
-
function $
|
|
256
|
+
function $35c7ec3c204b4757$var$getSymbols(formatter, intlOptions, originalOptions) {
|
|
257
|
+
var ref, ref1, ref2, ref3;
|
|
254
258
|
// Note: some locale's don't add a group symbol until there is a ten thousands place
|
|
255
259
|
let allParts = formatter.formatToParts(-10000.111);
|
|
256
260
|
let posAllParts = formatter.formatToParts(10000.111);
|
|
257
261
|
let singularParts = formatter.formatToParts(1);
|
|
258
|
-
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
)
|
|
262
|
+
var ref4;
|
|
263
|
+
let minusSign = (ref4 = (ref = allParts.find((p)=>p.type === 'minusSign'
|
|
264
|
+
)) === null || ref === void 0 ? void 0 : ref.value) !== null && ref4 !== void 0 ? ref4 : '-';
|
|
265
|
+
let plusSign = (ref1 = posAllParts.find((p)=>p.type === 'plusSign'
|
|
266
|
+
)) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
262
267
|
// Safari does not support the signDisplay option, but our number parser polyfills it.
|
|
263
268
|
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.
|
|
264
269
|
// @ts-ignore
|
|
265
|
-
if (!plusSign && (originalOptions
|
|
266
|
-
let decimal = allParts.find((p)=>p.type === 'decimal'
|
|
267
|
-
)
|
|
268
|
-
let group = allParts.find((p)=>p.type === 'group'
|
|
269
|
-
)
|
|
270
|
+
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'exceptZero' || (originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'always')) plusSign = '+';
|
|
271
|
+
let decimal = (ref2 = allParts.find((p)=>p.type === 'decimal'
|
|
272
|
+
)) === null || ref2 === void 0 ? void 0 : ref2.value;
|
|
273
|
+
let group = (ref3 = allParts.find((p)=>p.type === 'group'
|
|
274
|
+
)) === null || ref3 === void 0 ? void 0 : ref3.value;
|
|
270
275
|
// this set is also for a regex, it's all literals that might be in the string we want to eventually parse that
|
|
271
276
|
// don't contribute to the numerical value
|
|
272
|
-
let pluralLiterals = allParts.filter((p)=>!$
|
|
273
|
-
).map((p)=>$
|
|
277
|
+
let pluralLiterals = allParts.filter((p)=>!$35c7ec3c204b4757$var$nonLiteralParts.has(p.type)
|
|
278
|
+
).map((p)=>$35c7ec3c204b4757$var$escapeRegex(p.value)
|
|
274
279
|
);
|
|
275
|
-
let singularLiterals = singularParts.filter((p)=>!$
|
|
276
|
-
).map((p)=>$
|
|
280
|
+
let singularLiterals = singularParts.filter((p)=>!$35c7ec3c204b4757$var$nonLiteralParts.has(p.type)
|
|
281
|
+
).map((p)=>$35c7ec3c204b4757$var$escapeRegex(p.value)
|
|
277
282
|
);
|
|
278
283
|
let sortedLiterals = [
|
|
279
284
|
...new Set([
|
|
@@ -307,13 +312,13 @@ function $243eedc23c13e9f6$var$getSymbols(formatter, intlOptions, originalOption
|
|
|
307
312
|
index: index
|
|
308
313
|
};
|
|
309
314
|
}
|
|
310
|
-
function $
|
|
315
|
+
function $35c7ec3c204b4757$var$replaceAll(str, find, replace) {
|
|
311
316
|
// @ts-ignore
|
|
312
317
|
if (str.replaceAll) // @ts-ignore
|
|
313
318
|
return str.replaceAll(find, replace);
|
|
314
319
|
return str.split(find).join(replace);
|
|
315
320
|
}
|
|
316
|
-
function $
|
|
321
|
+
function $35c7ec3c204b4757$var$escapeRegex(string) {
|
|
317
322
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
318
323
|
}
|
|
319
324
|
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;ACAA,EAUG,AAVH;;;;;;;;;;CAUG,AAVH,EAUG,CAEH,GAAG,CAAC,oCAAc,GAAG,GAAG,CAAC,GAAG;AAE5B,GAAG,CAAC,yCAAmB,GAAG,KAAK;AAC/B,GAAG,CAAC,CAAC;IACH,EAAa,AAAb,WAAa;IACb,yCAAmB,GAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAO,QAAE,CAAC;QAAA,WAAW,EAAE,CAAY;IAAA,CAAC,EAAG,eAAe,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AC,IAAI,CAAC,CAAG,IAAE,mBAAmB,GAAG,CAAI;IAEhF,EAAuE,AAAvE,qEAAuE;IACvE,GAAG,CAAC,QAAQ,GAAG,CAAC;WAAG,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAAA,WAAW,EAAE,KAAK;QAAA,CAAC,EAAE,MAAM,CAAC,UAAU;IAAC,CAAC,CAAC,OAAO;IAC9G,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAK,CAAC;YAAA,CAAC;YAAE,CAAC;QAAA,CAAC;;IACnD,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAE,GAAE,CAAC,GAAG,CAAG;IACtD,GAAG,CAAC,KAAK,IAAG,CAAC,GAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;IAErC,MAAM,CAAC,CAAC;mBAAA,SAAS;kBAAE,QAAQ;iBAAE,OAAO;eAAE,KAAK;kBAAE,QAAQ;iBAAE,OAAO;eAAE,KAAK;IAAA,CAAC;AACxE,CAAC;SAEQ,gCAAU,CAAC,GAAW,EAAE,IAAY,EAAE,OAAe,EAAE,CAAC;IAC/D,EAAa,AAAb,WAAa;IACb,EAAE,EAAE,GAAG,CAAC,UAAU,EAChB,EAAa,AAAb,WAAa;IACb,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO;IAGrC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO;AACrC,CAAC;SAEQ,iCAAW,CAAC,MAAc,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAM;AACvD,CAAC;;","sources":["packages/@internationalized/number/src/index.ts","packages/@internationalized/number/src/NumberFormatter.ts","packages/@internationalized/number/src/NumberParser.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {NumberFormatOptions} from './NumberFormatter';\n\nexport {NumberFormatter} from './NumberFormatter';\nexport {NumberParser} from './NumberParser';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n // @ts-ignore\n supportsSignDisplay = (new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'})).resolvedOptions().signDisplay === 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\nlet supportsUnit = false;\ntry {\n // @ts-ignore\n supportsUnit = (new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'})).resolvedOptions().style === 'unit';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\n// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.\n// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.\n// Values were determined by switching to each locale manually in Chrome.\nconst UNITS = {\n degree: {\n narrow: {\n default: '°',\n 'ja-JP': ' 度',\n 'zh-TW': '度',\n 'sl-SI': ' °'\n // Arabic?? But Safari already doesn't use Arabic digits so might be ok...\n // https://bugs.webkit.org/show_bug.cgi?id=218139\n }\n }\n};\n\nexport interface NumberFormatOptions extends Intl.NumberFormatOptions {\n /** Overrides default numbering system for the current locale. */\n numberingSystem?: string\n}\n\n/**\n * A wrapper around Intl.NumberFormat providing additional options, polyfills, and caching for performance.\n */\nexport class NumberFormatter implements Intl.NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n private options: NumberFormatOptions;\n\n constructor(locale: string, options: NumberFormatOptions = {}) {\n this.numberFormatter = getCachedNumberFormatter(locale, options);\n this.options = options;\n }\n\n format(value: number): string {\n let res = '';\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n res = numberFormatSignDisplayPolyfill(this.numberFormatter, this.options.signDisplay, value);\n } else {\n res = this.numberFormatter.format(value);\n }\n\n if (this.options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short', locale} = this.resolvedOptions();\n let values = UNITS[unit]?.[unitDisplay];\n res += values[locale] || values.default;\n }\n\n return res;\n }\n\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n let options = this.numberFormatter.resolvedOptions();\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n options = {...options, signDisplay: this.options.signDisplay};\n }\n\n if (!supportsUnit && this.options.style === 'unit') {\n options = {...options, style: 'unit', unit: this.options.unit, unitDisplay: this.options.unitDisplay};\n }\n\n return options;\n }\n}\n\nfunction getCachedNumberFormatter(locale: string, options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {numberingSystem} = options;\n if (numberingSystem && locale.indexOf('-u-nu-') === -1) {\n locale = `${locale}-u-nu-${numberingSystem}`;\n }\n\n if (options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short'} = options;\n if (!unit) {\n throw new Error('unit option must be provided with style: \"unit\"');\n }\n if (!UNITS[unit]?.[unitDisplay]) {\n throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);\n }\n options = {...options, style: 'decimal'};\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey);\n }\n\n let numberFormatter = new Intl.NumberFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\n/** @private - exported for tests */\nexport function numberFormatSignDisplayPolyfill(numberFormat: Intl.NumberFormat, signDisplay: string, num: number) {\n if (signDisplay === 'auto') {\n return numberFormat.format(num);\n } else if (signDisplay === 'never') {\n return numberFormat.format(Math.abs(num));\n } else {\n let needsPositiveSign = false;\n if (signDisplay === 'always') {\n needsPositiveSign = num > 0 || Object.is(num, 0);\n } else if (signDisplay === 'exceptZero') {\n if (Object.is(num, -0) || Object.is(num, 0)) {\n num = Math.abs(num);\n } else {\n needsPositiveSign = num > 0;\n }\n }\n\n if (needsPositiveSign) {\n let negative = numberFormat.format(-num);\n let noSign = numberFormat.format(num);\n // ignore RTL/LTR marker character\n let minus = negative.replace(noSign, '').replace(/\\u200e|\\u061C/, '');\n if ([...minus].length !== 1) {\n console.warn('@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case');\n }\n let positive = negative.replace(noSign, '!!!').replace(minus, '+').replace('!!!', noSign);\n return positive;\n } else {\n return numberFormat.format(num);\n }\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\ninterface Symbols {\n minusSign: string,\n plusSign: string,\n decimal: string,\n group: string,\n literals: RegExp,\n numeral: RegExp,\n index: (v: string) => string\n}\n\nconst CURRENCY_SIGN_REGEX = new RegExp('^.*\\\\(.*\\\\).*$');\nconst NUMBERING_SYSTEMS = ['latn', 'arab', 'hanidec'];\n\n/**\n * A NumberParser can be used perform locale aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. Automatically detects the numbering system\n * used in the input, and supports parsing decimals, percentages, currency values, and units\n * according to the locale.\n */\nexport class NumberParser {\n locale: string;\n options: Intl.NumberFormatOptions;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.locale = locale;\n this.options = options;\n }\n\n /**\n * Parses the given string to a number. Returns NaN if a valid number could not be parsed.\n */\n parse(value: string): number {\n return getNumberParserImpl(this.locale, this.options, value).parse(value);\n }\n\n /**\n * Returns whether the given string could potentially be a valid number. This should be used to\n * validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity\n * of the minus/plus sign characters can be checked.\n */\n isValidPartialNumber(value: string, minValue?: number, maxValue?: number): boolean {\n return getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);\n }\n\n /**\n * Returns a numbering system for which the given string is valid in the current locale.\n * If no numbering system could be detected, the default numbering system for the current\n * locale is returned.\n */\n getNumberingSystem(value: string): string {\n return getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;\n }\n}\n\nconst numberParserCache = new Map<string, NumberParserImpl>();\nfunction getNumberParserImpl(locale: string, options: Intl.NumberFormatOptions, value: string) {\n // First try the default numbering system for the provided locale\n let defaultParser = getCachedNumberParser(locale, options);\n\n // If that doesn't match, and the locale doesn't include a hard coded numbering system,\n // try each of the other supported numbering systems until we find one that matches.\n if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {\n for (let numberingSystem of NUMBERING_SYSTEMS) {\n if (numberingSystem !== defaultParser.options.numberingSystem) {\n let parser = getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);\n if (parser.isValidPartialNumber(value)) {\n return parser;\n }\n }\n }\n }\n\n return defaultParser;\n}\n\nfunction getCachedNumberParser(locale: string, options: Intl.NumberFormatOptions) {\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n let parser = numberParserCache.get(cacheKey);\n if (!parser) {\n parser = new NumberParserImpl(locale, options);\n numberParserCache.set(cacheKey, parser);\n }\n\n return parser;\n}\n\n// The actual number parser implementation. Instances of this class are cached\n// based on the locale, options, and detected numbering system.\nclass NumberParserImpl {\n formatter: Intl.NumberFormat;\n options: Intl.ResolvedNumberFormatOptions;\n symbols: Symbols;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.formatter = new Intl.NumberFormat(locale, options);\n this.options = this.formatter.resolvedOptions();\n this.symbols = getSymbols(this.formatter, this.options, options);\n }\n\n parse(value: string) {\n // to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'\n let fullySanitizedValue = this.sanitize(value);\n\n // Remove group characters, and replace decimal points and numerals with ASCII values.\n fullySanitizedValue = replaceAll(fullySanitizedValue, this.symbols.group, '')\n .replace(this.symbols.decimal, '.')\n .replace(this.symbols.minusSign, '-')\n .replace(this.symbols.numeral, this.symbols.index);\n\n let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;\n if (isNaN(newValue)) {\n return NaN;\n }\n\n // accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again\n if (this.options.currencySign === 'accounting' && CURRENCY_SIGN_REGEX.test(value)) {\n newValue = -1 * newValue;\n }\n\n // when reading the number, if it's a percent, then it should be interpreted as being divided by 100\n if (this.options.style === 'percent') {\n newValue /= 100;\n // after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits\n newValue = +newValue.toFixed((this.options.maximumFractionDigits ?? 0) + 2);\n }\n\n return newValue;\n }\n\n sanitize(value: string) {\n // Remove literals and whitespace, which are allowed anywhere in the string\n value = value.replace(this.symbols.literals, '');\n\n // Replace the ASCII minus sign with the minus sign used in the current locale\n // so that both are allowed in case the user's keyboard doesn't have the locale's minus sign.\n value = value.replace('-', this.symbols.minusSign);\n\n // In arab numeral system, their decimal character is 1643, but most keyboards don't type that\n // instead they use the , (44) character or apparently the (1548) character.\n if (this.options.numberingSystem === 'arab') {\n value = value.replace(',', this.symbols.decimal);\n value = value.replace(String.fromCharCode(1548), this.symbols.decimal);\n value = replaceAll(value, '.', this.symbols.group);\n }\n\n // fr-FR group character is char code 8239, but that's not a key on the french keyboard,\n // so allow 'period' as a group char and replace it with a space\n if (this.options.locale === 'fr-FR') {\n value = replaceAll(value, '.', String.fromCharCode(8239));\n }\n\n return value;\n }\n\n isValidPartialNumber(value: string, minValue: number = -Infinity, maxValue: number = Infinity): boolean {\n value = this.sanitize(value);\n\n // Remove minus or plus sign, which must be at the start of the string.\n if (value.startsWith(this.symbols.minusSign) && minValue < 0) {\n value = value.slice(this.symbols.minusSign.length);\n } else if (this.symbols.plusSign && value.startsWith(this.symbols.plusSign) && maxValue > 0) {\n value = value.slice(this.symbols.plusSign.length);\n }\n\n // Numbers cannot start with a group separator\n if (value.startsWith(this.symbols.group)) {\n return false;\n }\n\n // Remove numerals, groups, and decimals\n value = replaceAll(value, this.symbols.group, '')\n .replace(this.symbols.numeral, '')\n .replace(this.symbols.decimal, '');\n\n // The number is valid if there are no remaining characters\n return value.length === 0;\n }\n}\n\nconst nonLiteralParts = new Set(['decimal', 'fraction', 'integer', 'minusSign', 'plusSign', 'group']);\n\nfunction getSymbols(formatter: Intl.NumberFormat, intlOptions: Intl.ResolvedNumberFormatOptions, originalOptions: Intl.NumberFormatOptions): Symbols {\n // Note: some locale's don't add a group symbol until there is a ten thousands place\n let allParts = formatter.formatToParts(-10000.111);\n let posAllParts = formatter.formatToParts(10000.111);\n let singularParts = formatter.formatToParts(1);\n\n let minusSign = allParts.find(p => p.type === 'minusSign')?.value ?? '-';\n let plusSign = posAllParts.find(p => p.type === 'plusSign')?.value;\n\n // Safari does not support the signDisplay option, but our number parser polyfills it.\n // If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.\n // @ts-ignore\n if (!plusSign && (originalOptions?.signDisplay === 'exceptZero' || originalOptions?.signDisplay === 'always')) {\n plusSign = '+';\n }\n\n let decimal = allParts.find(p => p.type === 'decimal')?.value;\n let group = allParts.find(p => p.type === 'group')?.value;\n\n // this set is also for a regex, it's all literals that might be in the string we want to eventually parse that\n // don't contribute to the numerical value\n let pluralLiterals = allParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let singularLiterals = singularParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let sortedLiterals = [...new Set([...singularLiterals, ...pluralLiterals])].sort((a, b) => b.length - a.length);\n let literals = new RegExp(`${sortedLiterals.join('|')}|[\\\\p{White_Space}]`, 'gu');\n\n // These are for replacing non-latn characters with the latn equivalent\n let numerals = [...new Intl.NumberFormat(intlOptions.locale, {useGrouping: false}).format(9876543210)].reverse();\n let indexes = new Map(numerals.map((d, i) => [d, i]));\n let numeral = new RegExp(`[${numerals.join('')}]`, 'g');\n let index = d => String(indexes.get(d));\n\n return {minusSign, plusSign, decimal, group, literals, numeral, index};\n}\n\nfunction replaceAll(str: string, find: string, replace: string) {\n // @ts-ignore\n if (str.replaceAll) {\n // @ts-ignore\n return str.replaceAll(find, replace);\n }\n\n return str.split(find).join(replace);\n}\n\nfunction escapeRegex(string: string) {\n return string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;ACAA,EAUG,AAVH;;;;;;;;;;CAUG,AAVH,EAUG,CAEH,GAAG,CAAC,oCAAc,GAAG,GAAG,CAAC,GAAG;AAE5B,GAAG,CAAC,yCAAmB,GAAG,KAAK;AAC/B,GAAG,CAAC,CAAC;IACH,EAAa,AAAb,WAAa;IACb,yCAAmB,GAAI,GAAG,C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M,EAAE,CAAC;YAAA,WAAW,EAAE,KAAK;QAAA,CAAC,EAAE,MAAM,CAAC,UAAU;IAAC,CAAC,CAAC,OAAO;IAC9G,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAK,CAAC;YAAA,CAAC;YAAE,CAAC;QAAA,CAAC;;IACnD,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAE,GAAE,CAAC,GAAG,CAAG;IACtD,GAAG,CAAC,KAAK,IAAG,CAAC,GAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;IAErC,MAAM,CAAC,CAAC;mBAAA,SAAS;kBAAE,QAAQ;iBAAE,OAAO;eAAE,KAAK;kBAAE,QAAQ;iBAAE,OAAO;eAAE,KAAK;IAAA,CAAC;AACxE,CAAC;SAEQ,gCAAU,CAAC,GAAW,EAAE,IAAY,EAAE,OAAe,EAAE,CAAC;IAC/D,EAAa,AAAb,WAAa;IACb,EAAE,EAAE,GAAG,CAAC,UAAU,EAChB,EAAa,AAAb,WAAa;IACb,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO;IAGrC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO;AACrC,CAAC;SAEQ,iCAAW,CAAC,MAAc,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAM;AACvD,CAAC;;","sources":["packages/@internationalized/number/src/index.ts","packages/@internationalized/number/src/NumberFormatter.ts","packages/@internationalized/number/src/NumberParser.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {NumberFormatOptions} from './NumberFormatter';\n\nexport {NumberFormatter} from './NumberFormatter';\nexport {NumberParser} from './NumberParser';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n // @ts-ignore\n supportsSignDisplay = (new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'})).resolvedOptions().signDisplay === 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\nlet supportsUnit = false;\ntry {\n // @ts-ignore\n supportsUnit = (new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'})).resolvedOptions().style === 'unit';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\n// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.\n// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.\n// Values were determined by switching to each locale manually in Chrome.\nconst UNITS = {\n degree: {\n narrow: {\n default: '°',\n 'ja-JP': ' 度',\n 'zh-TW': '度',\n 'sl-SI': ' °'\n // Arabic?? But Safari already doesn't use Arabic digits so might be ok...\n // https://bugs.webkit.org/show_bug.cgi?id=218139\n }\n }\n};\n\nexport interface NumberFormatOptions extends Intl.NumberFormatOptions {\n /** Overrides default numbering system for the current locale. */\n numberingSystem?: string\n}\n\n/**\n * A wrapper around Intl.NumberFormat providing additional options, polyfills, and caching for performance.\n */\nexport class NumberFormatter implements Intl.NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n private options: NumberFormatOptions;\n\n constructor(locale: string, options: NumberFormatOptions = {}) {\n this.numberFormatter = getCachedNumberFormatter(locale, options);\n this.options = options;\n }\n\n format(value: number): string {\n let res = '';\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n res = numberFormatSignDisplayPolyfill(this.numberFormatter, this.options.signDisplay, value);\n } else {\n res = this.numberFormatter.format(value);\n }\n\n if (this.options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short', locale} = this.resolvedOptions();\n let values = UNITS[unit]?.[unitDisplay];\n res += values[locale] || values.default;\n }\n\n return res;\n }\n\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n let options = this.numberFormatter.resolvedOptions();\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n options = {...options, signDisplay: this.options.signDisplay};\n }\n\n if (!supportsUnit && this.options.style === 'unit') {\n options = {...options, style: 'unit', unit: this.options.unit, unitDisplay: this.options.unitDisplay};\n }\n\n return options;\n }\n}\n\nfunction getCachedNumberFormatter(locale: string, options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {numberingSystem} = options;\n if (numberingSystem && locale.indexOf('-u-nu-') === -1) {\n locale = `${locale}-u-nu-${numberingSystem}`;\n }\n\n if (options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short'} = options;\n if (!unit) {\n throw new Error('unit option must be provided with style: \"unit\"');\n }\n if (!UNITS[unit]?.[unitDisplay]) {\n throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);\n }\n options = {...options, style: 'decimal'};\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey);\n }\n\n let numberFormatter = new Intl.NumberFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\n/** @private - exported for tests */\nexport function numberFormatSignDisplayPolyfill(numberFormat: Intl.NumberFormat, signDisplay: string, num: number) {\n if (signDisplay === 'auto') {\n return numberFormat.format(num);\n } else if (signDisplay === 'never') {\n return numberFormat.format(Math.abs(num));\n } else {\n let needsPositiveSign = false;\n if (signDisplay === 'always') {\n needsPositiveSign = num > 0 || Object.is(num, 0);\n } else if (signDisplay === 'exceptZero') {\n if (Object.is(num, -0) || Object.is(num, 0)) {\n num = Math.abs(num);\n } else {\n needsPositiveSign = num > 0;\n }\n }\n\n if (needsPositiveSign) {\n let negative = numberFormat.format(-num);\n let noSign = numberFormat.format(num);\n // ignore RTL/LTR marker character\n let minus = negative.replace(noSign, '').replace(/\\u200e|\\u061C/, '');\n if ([...minus].length !== 1) {\n console.warn('@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case');\n }\n let positive = negative.replace(noSign, '!!!').replace(minus, '+').replace('!!!', noSign);\n return positive;\n } else {\n return numberFormat.format(num);\n }\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\ninterface Symbols {\n minusSign: string,\n plusSign: string,\n decimal: string,\n group: string,\n literals: RegExp,\n numeral: RegExp,\n index: (v: string) => string\n}\n\nconst CURRENCY_SIGN_REGEX = new RegExp('^.*\\\\(.*\\\\).*$');\nconst NUMBERING_SYSTEMS = ['latn', 'arab', 'hanidec'];\n\n/**\n * A NumberParser can be used perform locale aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. Automatically detects the numbering system\n * used in the input, and supports parsing decimals, percentages, currency values, and units\n * according to the locale.\n */\nexport class NumberParser {\n locale: string;\n options: Intl.NumberFormatOptions;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.locale = locale;\n this.options = options;\n }\n\n /**\n * Parses the given string to a number. Returns NaN if a valid number could not be parsed.\n */\n parse(value: string): number {\n return getNumberParserImpl(this.locale, this.options, value).parse(value);\n }\n\n /**\n * Returns whether the given string could potentially be a valid number. This should be used to\n * validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity\n * of the minus/plus sign characters can be checked.\n */\n isValidPartialNumber(value: string, minValue?: number, maxValue?: number): boolean {\n return getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);\n }\n\n /**\n * Returns a numbering system for which the given string is valid in the current locale.\n * If no numbering system could be detected, the default numbering system for the current\n * locale is returned.\n */\n getNumberingSystem(value: string): string {\n return getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;\n }\n}\n\nconst numberParserCache = new Map<string, NumberParserImpl>();\nfunction getNumberParserImpl(locale: string, options: Intl.NumberFormatOptions, value: string) {\n // First try the default numbering system for the provided locale\n let defaultParser = getCachedNumberParser(locale, options);\n\n // If that doesn't match, and the locale doesn't include a hard coded numbering system,\n // try each of the other supported numbering systems until we find one that matches.\n if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {\n for (let numberingSystem of NUMBERING_SYSTEMS) {\n if (numberingSystem !== defaultParser.options.numberingSystem) {\n let parser = getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);\n if (parser.isValidPartialNumber(value)) {\n return parser;\n }\n }\n }\n }\n\n return defaultParser;\n}\n\nfunction getCachedNumberParser(locale: string, options: Intl.NumberFormatOptions) {\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n let parser = numberParserCache.get(cacheKey);\n if (!parser) {\n parser = new NumberParserImpl(locale, options);\n numberParserCache.set(cacheKey, parser);\n }\n\n return parser;\n}\n\n// The actual number parser implementation. Instances of this class are cached\n// based on the locale, options, and detected numbering system.\nclass NumberParserImpl {\n formatter: Intl.NumberFormat;\n options: Intl.ResolvedNumberFormatOptions;\n symbols: Symbols;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.formatter = new Intl.NumberFormat(locale, options);\n this.options = this.formatter.resolvedOptions();\n this.symbols = getSymbols(this.formatter, this.options, options);\n }\n\n parse(value: string) {\n // to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'\n let fullySanitizedValue = this.sanitize(value);\n\n // Remove group characters, and replace decimal points and numerals with ASCII values.\n fullySanitizedValue = replaceAll(fullySanitizedValue, this.symbols.group, '')\n .replace(this.symbols.decimal, '.')\n .replace(this.symbols.minusSign, '-')\n .replace(this.symbols.numeral, this.symbols.index);\n\n let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;\n if (isNaN(newValue)) {\n return NaN;\n }\n\n // accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again\n if (this.options.currencySign === 'accounting' && CURRENCY_SIGN_REGEX.test(value)) {\n newValue = -1 * newValue;\n }\n\n // when reading the number, if it's a percent, then it should be interpreted as being divided by 100\n if (this.options.style === 'percent') {\n newValue /= 100;\n // after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits\n newValue = +newValue.toFixed((this.options.maximumFractionDigits ?? 0) + 2);\n }\n\n return newValue;\n }\n\n sanitize(value: string) {\n // Remove literals and whitespace, which are allowed anywhere in the string\n value = value.replace(this.symbols.literals, '');\n\n // Replace the ASCII minus sign with the minus sign used in the current locale\n // so that both are allowed in case the user's keyboard doesn't have the locale's minus sign.\n value = value.replace('-', this.symbols.minusSign);\n\n // In arab numeral system, their decimal character is 1643, but most keyboards don't type that\n // instead they use the , (44) character or apparently the (1548) character.\n if (this.options.numberingSystem === 'arab') {\n value = value.replace(',', this.symbols.decimal);\n value = value.replace(String.fromCharCode(1548), this.symbols.decimal);\n value = replaceAll(value, '.', this.symbols.group);\n }\n\n // fr-FR group character is char code 8239, but that's not a key on the french keyboard,\n // so allow 'period' as a group char and replace it with a space\n if (this.options.locale === 'fr-FR') {\n value = replaceAll(value, '.', String.fromCharCode(8239));\n }\n\n return value;\n }\n\n isValidPartialNumber(value: string, minValue: number = -Infinity, maxValue: number = Infinity): boolean {\n value = this.sanitize(value);\n\n // Remove minus or plus sign, which must be at the start of the string.\n if (value.startsWith(this.symbols.minusSign) && minValue < 0) {\n value = value.slice(this.symbols.minusSign.length);\n } else if (this.symbols.plusSign && value.startsWith(this.symbols.plusSign) && maxValue > 0) {\n value = value.slice(this.symbols.plusSign.length);\n }\n\n // Numbers cannot start with a group separator\n if (value.startsWith(this.symbols.group)) {\n return false;\n }\n\n // Remove numerals, groups, and decimals\n value = replaceAll(value, this.symbols.group, '')\n .replace(this.symbols.numeral, '')\n .replace(this.symbols.decimal, '');\n\n // The number is valid if there are no remaining characters\n return value.length === 0;\n }\n}\n\nconst nonLiteralParts = new Set(['decimal', 'fraction', 'integer', 'minusSign', 'plusSign', 'group']);\n\nfunction getSymbols(formatter: Intl.NumberFormat, intlOptions: Intl.ResolvedNumberFormatOptions, originalOptions: Intl.NumberFormatOptions): Symbols {\n // Note: some locale's don't add a group symbol until there is a ten thousands place\n let allParts = formatter.formatToParts(-10000.111);\n let posAllParts = formatter.formatToParts(10000.111);\n let singularParts = formatter.formatToParts(1);\n\n let minusSign = allParts.find(p => p.type === 'minusSign')?.value ?? '-';\n let plusSign = posAllParts.find(p => p.type === 'plusSign')?.value;\n\n // Safari does not support the signDisplay option, but our number parser polyfills it.\n // If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.\n // @ts-ignore\n if (!plusSign && (originalOptions?.signDisplay === 'exceptZero' || originalOptions?.signDisplay === 'always')) {\n plusSign = '+';\n }\n\n let decimal = allParts.find(p => p.type === 'decimal')?.value;\n let group = allParts.find(p => p.type === 'group')?.value;\n\n // this set is also for a regex, it's all literals that might be in the string we want to eventually parse that\n // don't contribute to the numerical value\n let pluralLiterals = allParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let singularLiterals = singularParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let sortedLiterals = [...new Set([...singularLiterals, ...pluralLiterals])].sort((a, b) => b.length - a.length);\n let literals = new RegExp(`${sortedLiterals.join('|')}|[\\\\p{White_Space}]`, 'gu');\n\n // These are for replacing non-latn characters with the latn equivalent\n let numerals = [...new Intl.NumberFormat(intlOptions.locale, {useGrouping: false}).format(9876543210)].reverse();\n let indexes = new Map(numerals.map((d, i) => [d, i]));\n let numeral = new RegExp(`[${numerals.join('')}]`, 'g');\n let index = d => String(indexes.get(d));\n\n return {minusSign, plusSign, decimal, group, literals, numeral, index};\n}\n\nfunction replaceAll(str: string, find: string, replace: string) {\n // @ts-ignore\n if (str.replaceAll) {\n // @ts-ignore\n return str.replaceAll(find, replace);\n }\n\n return str.split(find).join(replace);\n}\n\nfunction escapeRegex(string: string) {\n return string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
|
-
*/ let $
|
|
12
|
-
let $
|
|
11
|
+
*/ let $81812865b3bb9d70$var$formatterCache = new Map();
|
|
12
|
+
let $81812865b3bb9d70$var$supportsSignDisplay = false;
|
|
13
13
|
try {
|
|
14
14
|
// @ts-ignore
|
|
15
|
-
$
|
|
15
|
+
$81812865b3bb9d70$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
|
|
16
16
|
signDisplay: 'exceptZero'
|
|
17
17
|
}).resolvedOptions().signDisplay === 'exceptZero';
|
|
18
18
|
// eslint-disable-next-line no-empty
|
|
19
19
|
} catch (e) {
|
|
20
20
|
}
|
|
21
|
-
let $
|
|
21
|
+
let $81812865b3bb9d70$var$supportsUnit = false;
|
|
22
22
|
try {
|
|
23
23
|
// @ts-ignore
|
|
24
|
-
$
|
|
24
|
+
$81812865b3bb9d70$var$supportsUnit = new Intl.NumberFormat('de-DE', {
|
|
25
25
|
style: 'unit',
|
|
26
26
|
unit: 'degree'
|
|
27
27
|
}).resolvedOptions().style === 'unit';
|
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
|
|
32
32
|
// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
|
|
33
33
|
// Values were determined by switching to each locale manually in Chrome.
|
|
34
|
-
const $
|
|
34
|
+
const $81812865b3bb9d70$var$UNITS = {
|
|
35
35
|
degree: {
|
|
36
36
|
narrow: {
|
|
37
37
|
default: '°',
|
|
@@ -41,19 +41,15 @@ const $9b4a6da87944ea89$var$UNITS = {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
class $
|
|
45
|
-
constructor(locale, options = {
|
|
46
|
-
}){
|
|
47
|
-
this.numberFormatter = $9b4a6da87944ea89$var$getCachedNumberFormatter(locale, options);
|
|
48
|
-
this.options = options;
|
|
49
|
-
}
|
|
44
|
+
class $81812865b3bb9d70$export$cc77c4ff7e8673c5 {
|
|
50
45
|
format(value) {
|
|
51
46
|
let res = '';
|
|
52
|
-
if (!$
|
|
47
|
+
if (!$81812865b3bb9d70$var$supportsSignDisplay && this.options.signDisplay != null) res = $81812865b3bb9d70$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
|
|
53
48
|
else res = this.numberFormatter.format(value);
|
|
54
|
-
if (this.options.style === 'unit' && !$
|
|
49
|
+
if (this.options.style === 'unit' && !$81812865b3bb9d70$var$supportsUnit) {
|
|
50
|
+
var ref;
|
|
55
51
|
let { unit: unit , unitDisplay: unitDisplay = 'short' , locale: locale } = this.resolvedOptions();
|
|
56
|
-
let values = $
|
|
52
|
+
let values = (ref = $81812865b3bb9d70$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
|
|
57
53
|
res += values[locale] || values.default;
|
|
58
54
|
}
|
|
59
55
|
return res;
|
|
@@ -65,11 +61,11 @@ class $9b4a6da87944ea89$export$cc77c4ff7e8673c5 {
|
|
|
65
61
|
}
|
|
66
62
|
resolvedOptions() {
|
|
67
63
|
let options = this.numberFormatter.resolvedOptions();
|
|
68
|
-
if (!$
|
|
64
|
+
if (!$81812865b3bb9d70$var$supportsSignDisplay && this.options.signDisplay != null) options = {
|
|
69
65
|
...options,
|
|
70
66
|
signDisplay: this.options.signDisplay
|
|
71
67
|
};
|
|
72
|
-
if (!$
|
|
68
|
+
if (!$81812865b3bb9d70$var$supportsUnit && this.options.style === 'unit') options = {
|
|
73
69
|
...options,
|
|
74
70
|
style: 'unit',
|
|
75
71
|
unit: this.options.unit,
|
|
@@ -77,15 +73,21 @@ class $9b4a6da87944ea89$export$cc77c4ff7e8673c5 {
|
|
|
77
73
|
};
|
|
78
74
|
return options;
|
|
79
75
|
}
|
|
76
|
+
constructor(locale, options = {
|
|
77
|
+
}){
|
|
78
|
+
this.numberFormatter = $81812865b3bb9d70$var$getCachedNumberFormatter(locale, options);
|
|
79
|
+
this.options = options;
|
|
80
|
+
}
|
|
80
81
|
}
|
|
81
|
-
function $
|
|
82
|
+
function $81812865b3bb9d70$var$getCachedNumberFormatter(locale, options = {
|
|
82
83
|
}) {
|
|
83
84
|
let { numberingSystem: numberingSystem } = options;
|
|
84
85
|
if (numberingSystem && locale.indexOf('-u-nu-') === -1) locale = `${locale}-u-nu-${numberingSystem}`;
|
|
85
|
-
if (options.style === 'unit' && !$
|
|
86
|
+
if (options.style === 'unit' && !$81812865b3bb9d70$var$supportsUnit) {
|
|
87
|
+
var ref;
|
|
86
88
|
let { unit: unit , unitDisplay: unitDisplay = 'short' } = options;
|
|
87
89
|
if (!unit) throw new Error('unit option must be provided with style: "unit"');
|
|
88
|
-
if (
|
|
90
|
+
if (!((ref = $81812865b3bb9d70$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
|
|
89
91
|
options = {
|
|
90
92
|
...options,
|
|
91
93
|
style: 'decimal'
|
|
@@ -93,12 +95,12 @@ function $9b4a6da87944ea89$var$getCachedNumberFormatter(locale, options = {
|
|
|
93
95
|
}
|
|
94
96
|
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
95
97
|
).join() : '');
|
|
96
|
-
if ($
|
|
98
|
+
if ($81812865b3bb9d70$var$formatterCache.has(cacheKey)) return $81812865b3bb9d70$var$formatterCache.get(cacheKey);
|
|
97
99
|
let numberFormatter = new Intl.NumberFormat(locale, options);
|
|
98
|
-
$
|
|
100
|
+
$81812865b3bb9d70$var$formatterCache.set(cacheKey, numberFormatter);
|
|
99
101
|
return numberFormatter;
|
|
100
102
|
}
|
|
101
|
-
function $
|
|
103
|
+
function $81812865b3bb9d70$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
|
|
102
104
|
if (signDisplay === 'auto') return numberFormat.format(num);
|
|
103
105
|
else if (signDisplay === 'never') return numberFormat.format(Math.abs(num));
|
|
104
106
|
else {
|
|
@@ -123,85 +125,80 @@ function $9b4a6da87944ea89$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
|
|
126
|
-
const $
|
|
127
|
-
const $
|
|
128
|
+
const $ad41ad2a9f71fc3e$var$CURRENCY_SIGN_REGEX = new RegExp('^.*\\(.*\\).*$');
|
|
129
|
+
const $ad41ad2a9f71fc3e$var$NUMBERING_SYSTEMS = [
|
|
128
130
|
'latn',
|
|
129
131
|
'arab',
|
|
130
132
|
'hanidec'
|
|
131
133
|
];
|
|
132
|
-
class $
|
|
133
|
-
constructor(locale, options = {
|
|
134
|
-
}){
|
|
135
|
-
this.locale = locale;
|
|
136
|
-
this.options = options;
|
|
137
|
-
}
|
|
134
|
+
class $ad41ad2a9f71fc3e$export$cd11ab140839f11d {
|
|
138
135
|
/**
|
|
139
136
|
* Parses the given string to a number. Returns NaN if a valid number could not be parsed.
|
|
140
137
|
*/ parse(value) {
|
|
141
|
-
return $
|
|
138
|
+
return $ad41ad2a9f71fc3e$var$getNumberParserImpl(this.locale, this.options, value).parse(value);
|
|
142
139
|
}
|
|
143
140
|
/**
|
|
144
141
|
* Returns whether the given string could potentially be a valid number. This should be used to
|
|
145
142
|
* validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity
|
|
146
143
|
* of the minus/plus sign characters can be checked.
|
|
147
144
|
*/ isValidPartialNumber(value, minValue, maxValue) {
|
|
148
|
-
return $
|
|
145
|
+
return $ad41ad2a9f71fc3e$var$getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);
|
|
149
146
|
}
|
|
150
147
|
/**
|
|
151
148
|
* Returns a numbering system for which the given string is valid in the current locale.
|
|
152
149
|
* If no numbering system could be detected, the default numbering system for the current
|
|
153
150
|
* locale is returned.
|
|
154
151
|
*/ getNumberingSystem(value) {
|
|
155
|
-
return $
|
|
152
|
+
return $ad41ad2a9f71fc3e$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
|
|
153
|
+
}
|
|
154
|
+
constructor(locale, options = {
|
|
155
|
+
}){
|
|
156
|
+
this.locale = locale;
|
|
157
|
+
this.options = options;
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
|
-
const $
|
|
159
|
-
function $
|
|
160
|
+
const $ad41ad2a9f71fc3e$var$numberParserCache = new Map();
|
|
161
|
+
function $ad41ad2a9f71fc3e$var$getNumberParserImpl(locale, options, value) {
|
|
160
162
|
// First try the default numbering system for the provided locale
|
|
161
|
-
let defaultParser = $
|
|
163
|
+
let defaultParser = $ad41ad2a9f71fc3e$var$getCachedNumberParser(locale, options);
|
|
162
164
|
// If that doesn't match, and the locale doesn't include a hard coded numbering system,
|
|
163
165
|
// try each of the other supported numbering systems until we find one that matches.
|
|
164
166
|
if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {
|
|
165
|
-
for (let numberingSystem of $
|
|
166
|
-
let parser = $
|
|
167
|
+
for (let numberingSystem of $ad41ad2a9f71fc3e$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
|
|
168
|
+
let parser = $ad41ad2a9f71fc3e$var$getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);
|
|
167
169
|
if (parser.isValidPartialNumber(value)) return parser;
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
return defaultParser;
|
|
171
173
|
}
|
|
172
|
-
function $
|
|
174
|
+
function $ad41ad2a9f71fc3e$var$getCachedNumberParser(locale, options) {
|
|
173
175
|
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
174
176
|
).join() : '');
|
|
175
|
-
let parser = $
|
|
177
|
+
let parser = $ad41ad2a9f71fc3e$var$numberParserCache.get(cacheKey);
|
|
176
178
|
if (!parser) {
|
|
177
|
-
parser = new $
|
|
178
|
-
$
|
|
179
|
+
parser = new $ad41ad2a9f71fc3e$var$NumberParserImpl(locale, options);
|
|
180
|
+
$ad41ad2a9f71fc3e$var$numberParserCache.set(cacheKey, parser);
|
|
179
181
|
}
|
|
180
182
|
return parser;
|
|
181
183
|
}
|
|
182
184
|
// The actual number parser implementation. Instances of this class are cached
|
|
183
185
|
// based on the locale, options, and detected numbering system.
|
|
184
|
-
class $
|
|
185
|
-
constructor(locale, options = {
|
|
186
|
-
}){
|
|
187
|
-
this.formatter = new Intl.NumberFormat(locale, options);
|
|
188
|
-
this.options = this.formatter.resolvedOptions();
|
|
189
|
-
this.symbols = $ccdc4c7bf6c16c67$var$getSymbols(this.formatter, this.options, options);
|
|
190
|
-
}
|
|
186
|
+
class $ad41ad2a9f71fc3e$var$NumberParserImpl {
|
|
191
187
|
parse(value) {
|
|
192
188
|
// to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'
|
|
193
189
|
let fullySanitizedValue = this.sanitize(value);
|
|
194
190
|
// Remove group characters, and replace decimal points and numerals with ASCII values.
|
|
195
|
-
fullySanitizedValue = $
|
|
191
|
+
fullySanitizedValue = $ad41ad2a9f71fc3e$var$replaceAll(fullySanitizedValue, this.symbols.group, '').replace(this.symbols.decimal, '.').replace(this.symbols.minusSign, '-').replace(this.symbols.numeral, this.symbols.index);
|
|
196
192
|
let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;
|
|
197
193
|
if (isNaN(newValue)) return NaN;
|
|
198
194
|
// accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again
|
|
199
|
-
if (this.options.currencySign === 'accounting' && $
|
|
195
|
+
if (this.options.currencySign === 'accounting' && $ad41ad2a9f71fc3e$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
|
|
200
196
|
// when reading the number, if it's a percent, then it should be interpreted as being divided by 100
|
|
201
197
|
if (this.options.style === 'percent') {
|
|
202
198
|
newValue /= 100;
|
|
199
|
+
var _maximumFractionDigits;
|
|
203
200
|
// after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits
|
|
204
|
-
newValue = +newValue.toFixed((this.options.maximumFractionDigits
|
|
201
|
+
newValue = +newValue.toFixed(((_maximumFractionDigits = this.options.maximumFractionDigits) !== null && _maximumFractionDigits !== void 0 ? _maximumFractionDigits : 0) + 2);
|
|
205
202
|
}
|
|
206
203
|
return newValue;
|
|
207
204
|
}
|
|
@@ -216,11 +213,11 @@ class $ccdc4c7bf6c16c67$var$NumberParserImpl {
|
|
|
216
213
|
if (this.options.numberingSystem === 'arab') {
|
|
217
214
|
value = value.replace(',', this.symbols.decimal);
|
|
218
215
|
value = value.replace(String.fromCharCode(1548), this.symbols.decimal);
|
|
219
|
-
value = $
|
|
216
|
+
value = $ad41ad2a9f71fc3e$var$replaceAll(value, '.', this.symbols.group);
|
|
220
217
|
}
|
|
221
218
|
// fr-FR group character is char code 8239, but that's not a key on the french keyboard,
|
|
222
219
|
// so allow 'period' as a group char and replace it with a space
|
|
223
|
-
if (this.options.locale === 'fr-FR') value = $
|
|
220
|
+
if (this.options.locale === 'fr-FR') value = $ad41ad2a9f71fc3e$var$replaceAll(value, '.', String.fromCharCode(8239));
|
|
224
221
|
return value;
|
|
225
222
|
}
|
|
226
223
|
isValidPartialNumber(value, minValue = -Infinity, maxValue = Infinity) {
|
|
@@ -231,12 +228,18 @@ class $ccdc4c7bf6c16c67$var$NumberParserImpl {
|
|
|
231
228
|
// Numbers cannot start with a group separator
|
|
232
229
|
if (value.startsWith(this.symbols.group)) return false;
|
|
233
230
|
// Remove numerals, groups, and decimals
|
|
234
|
-
value = $
|
|
231
|
+
value = $ad41ad2a9f71fc3e$var$replaceAll(value, this.symbols.group, '').replace(this.symbols.numeral, '').replace(this.symbols.decimal, '');
|
|
235
232
|
// The number is valid if there are no remaining characters
|
|
236
233
|
return value.length === 0;
|
|
237
234
|
}
|
|
235
|
+
constructor(locale, options = {
|
|
236
|
+
}){
|
|
237
|
+
this.formatter = new Intl.NumberFormat(locale, options);
|
|
238
|
+
this.options = this.formatter.resolvedOptions();
|
|
239
|
+
this.symbols = $ad41ad2a9f71fc3e$var$getSymbols(this.formatter, this.options, options);
|
|
240
|
+
}
|
|
238
241
|
}
|
|
239
|
-
const $
|
|
242
|
+
const $ad41ad2a9f71fc3e$var$nonLiteralParts = new Set([
|
|
240
243
|
'decimal',
|
|
241
244
|
'fraction',
|
|
242
245
|
'integer',
|
|
@@ -244,30 +247,32 @@ const $ccdc4c7bf6c16c67$var$nonLiteralParts = new Set([
|
|
|
244
247
|
'plusSign',
|
|
245
248
|
'group'
|
|
246
249
|
]);
|
|
247
|
-
function $
|
|
250
|
+
function $ad41ad2a9f71fc3e$var$getSymbols(formatter, intlOptions, originalOptions) {
|
|
251
|
+
var ref, ref1, ref2, ref3;
|
|
248
252
|
// Note: some locale's don't add a group symbol until there is a ten thousands place
|
|
249
253
|
let allParts = formatter.formatToParts(-10000.111);
|
|
250
254
|
let posAllParts = formatter.formatToParts(10000.111);
|
|
251
255
|
let singularParts = formatter.formatToParts(1);
|
|
252
|
-
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
)
|
|
256
|
+
var ref4;
|
|
257
|
+
let minusSign = (ref4 = (ref = allParts.find((p)=>p.type === 'minusSign'
|
|
258
|
+
)) === null || ref === void 0 ? void 0 : ref.value) !== null && ref4 !== void 0 ? ref4 : '-';
|
|
259
|
+
let plusSign = (ref1 = posAllParts.find((p)=>p.type === 'plusSign'
|
|
260
|
+
)) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
256
261
|
// Safari does not support the signDisplay option, but our number parser polyfills it.
|
|
257
262
|
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.
|
|
258
263
|
// @ts-ignore
|
|
259
|
-
if (!plusSign && (originalOptions
|
|
260
|
-
let decimal = allParts.find((p)=>p.type === 'decimal'
|
|
261
|
-
)
|
|
262
|
-
let group = allParts.find((p)=>p.type === 'group'
|
|
263
|
-
)
|
|
264
|
+
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'exceptZero' || (originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === 'always')) plusSign = '+';
|
|
265
|
+
let decimal = (ref2 = allParts.find((p)=>p.type === 'decimal'
|
|
266
|
+
)) === null || ref2 === void 0 ? void 0 : ref2.value;
|
|
267
|
+
let group = (ref3 = allParts.find((p)=>p.type === 'group'
|
|
268
|
+
)) === null || ref3 === void 0 ? void 0 : ref3.value;
|
|
264
269
|
// this set is also for a regex, it's all literals that might be in the string we want to eventually parse that
|
|
265
270
|
// don't contribute to the numerical value
|
|
266
|
-
let pluralLiterals = allParts.filter((p)=>!$
|
|
267
|
-
).map((p)=>$
|
|
271
|
+
let pluralLiterals = allParts.filter((p)=>!$ad41ad2a9f71fc3e$var$nonLiteralParts.has(p.type)
|
|
272
|
+
).map((p)=>$ad41ad2a9f71fc3e$var$escapeRegex(p.value)
|
|
268
273
|
);
|
|
269
|
-
let singularLiterals = singularParts.filter((p)=>!$
|
|
270
|
-
).map((p)=>$
|
|
274
|
+
let singularLiterals = singularParts.filter((p)=>!$ad41ad2a9f71fc3e$var$nonLiteralParts.has(p.type)
|
|
275
|
+
).map((p)=>$ad41ad2a9f71fc3e$var$escapeRegex(p.value)
|
|
271
276
|
);
|
|
272
277
|
let sortedLiterals = [
|
|
273
278
|
...new Set([
|
|
@@ -301,18 +306,18 @@ function $ccdc4c7bf6c16c67$var$getSymbols(formatter, intlOptions, originalOption
|
|
|
301
306
|
index: index
|
|
302
307
|
};
|
|
303
308
|
}
|
|
304
|
-
function $
|
|
309
|
+
function $ad41ad2a9f71fc3e$var$replaceAll(str, find, replace) {
|
|
305
310
|
// @ts-ignore
|
|
306
311
|
if (str.replaceAll) // @ts-ignore
|
|
307
312
|
return str.replaceAll(find, replace);
|
|
308
313
|
return str.split(find).join(replace);
|
|
309
314
|
}
|
|
310
|
-
function $
|
|
315
|
+
function $ad41ad2a9f71fc3e$var$escapeRegex(string) {
|
|
311
316
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
312
317
|
}
|
|
313
318
|
|
|
314
319
|
|
|
315
320
|
|
|
316
321
|
|
|
317
|
-
export {$
|
|
322
|
+
export {$81812865b3bb9d70$export$cc77c4ff7e8673c5 as NumberFormatter, $ad41ad2a9f71fc3e$export$cd11ab140839f11d as NumberParser};
|
|
318
323
|
//# sourceMappingURL=module.js.map
|
package/dist/module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AAG,CAAC,UAAU,EAChB,EAAa,AAAb,WAAa;IACb,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO;IAGrC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO;AACrC,CAAC;SAEQ,iCAAW,CAAC,MAAc,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAM;AACvD,CAAC;;","sources":["packages/@internationalized/number/src/index.ts","packages/@internationalized/number/src/NumberFormatter.ts","packages/@internationalized/number/src/NumberParser.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {NumberFormatOptions} from './NumberFormatter';\n\nexport {NumberFormatter} from './NumberFormatter';\nexport {NumberParser} from './NumberParser';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n // @ts-ignore\n supportsSignDisplay = (new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'})).resolvedOptions().signDisplay === 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\nlet supportsUnit = false;\ntry {\n // @ts-ignore\n supportsUnit = (new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'})).resolvedOptions().style === 'unit';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\n// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.\n// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.\n// Values were determined by switching to each locale manually in Chrome.\nconst UNITS = {\n degree: {\n narrow: {\n default: '°',\n 'ja-JP': ' 度',\n 'zh-TW': '度',\n 'sl-SI': ' °'\n // Arabic?? But Safari already doesn't use Arabic digits so might be ok...\n // https://bugs.webkit.org/show_bug.cgi?id=218139\n }\n }\n};\n\nexport interface NumberFormatOptions extends Intl.NumberFormatOptions {\n /** Overrides default numbering system for the current locale. */\n numberingSystem?: string\n}\n\n/**\n * A wrapper around Intl.NumberFormat providing additional options, polyfills, and caching for performance.\n */\nexport class NumberFormatter implements Intl.NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n private options: NumberFormatOptions;\n\n constructor(locale: string, options: NumberFormatOptions = {}) {\n this.numberFormatter = getCachedNumberFormatter(locale, options);\n this.options = options;\n }\n\n format(value: number): string {\n let res = '';\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n res = numberFormatSignDisplayPolyfill(this.numberFormatter, this.options.signDisplay, value);\n } else {\n res = this.numberFormatter.format(value);\n }\n\n if (this.options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short', locale} = this.resolvedOptions();\n let values = UNITS[unit]?.[unitDisplay];\n res += values[locale] || values.default;\n }\n\n return res;\n }\n\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n let options = this.numberFormatter.resolvedOptions();\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n options = {...options, signDisplay: this.options.signDisplay};\n }\n\n if (!supportsUnit && this.options.style === 'unit') {\n options = {...options, style: 'unit', unit: this.options.unit, unitDisplay: this.options.unitDisplay};\n }\n\n return options;\n }\n}\n\nfunction getCachedNumberFormatter(locale: string, options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {numberingSystem} = options;\n if (numberingSystem && locale.indexOf('-u-nu-') === -1) {\n locale = `${locale}-u-nu-${numberingSystem}`;\n }\n\n if (options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short'} = options;\n if (!unit) {\n throw new Error('unit option must be provided with style: \"unit\"');\n }\n if (!UNITS[unit]?.[unitDisplay]) {\n throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);\n }\n options = {...options, style: 'decimal'};\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey);\n }\n\n let numberFormatter = new Intl.NumberFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\n/** @private - exported for tests */\nexport function numberFormatSignDisplayPolyfill(numberFormat: Intl.NumberFormat, signDisplay: string, num: number) {\n if (signDisplay === 'auto') {\n return numberFormat.format(num);\n } else if (signDisplay === 'never') {\n return numberFormat.format(Math.abs(num));\n } else {\n let needsPositiveSign = false;\n if (signDisplay === 'always') {\n needsPositiveSign = num > 0 || Object.is(num, 0);\n } else if (signDisplay === 'exceptZero') {\n if (Object.is(num, -0) || Object.is(num, 0)) {\n num = Math.abs(num);\n } else {\n needsPositiveSign = num > 0;\n }\n }\n\n if (needsPositiveSign) {\n let negative = numberFormat.format(-num);\n let noSign = numberFormat.format(num);\n // ignore RTL/LTR marker character\n let minus = negative.replace(noSign, '').replace(/\\u200e|\\u061C/, '');\n if ([...minus].length !== 1) {\n console.warn('@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case');\n }\n let positive = negative.replace(noSign, '!!!').replace(minus, '+').replace('!!!', noSign);\n return positive;\n } else {\n return numberFormat.format(num);\n }\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\ninterface Symbols {\n minusSign: string,\n plusSign: string,\n decimal: string,\n group: string,\n literals: RegExp,\n numeral: RegExp,\n index: (v: string) => string\n}\n\nconst CURRENCY_SIGN_REGEX = new RegExp('^.*\\\\(.*\\\\).*$');\nconst NUMBERING_SYSTEMS = ['latn', 'arab', 'hanidec'];\n\n/**\n * A NumberParser can be used perform locale aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. Automatically detects the numbering system\n * used in the input, and supports parsing decimals, percentages, currency values, and units\n * according to the locale.\n */\nexport class NumberParser {\n locale: string;\n options: Intl.NumberFormatOptions;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.locale = locale;\n this.options = options;\n }\n\n /**\n * Parses the given string to a number. Returns NaN if a valid number could not be parsed.\n */\n parse(value: string): number {\n return getNumberParserImpl(this.locale, this.options, value).parse(value);\n }\n\n /**\n * Returns whether the given string could potentially be a valid number. This should be used to\n * validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity\n * of the minus/plus sign characters can be checked.\n */\n isValidPartialNumber(value: string, minValue?: number, maxValue?: number): boolean {\n return getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);\n }\n\n /**\n * Returns a numbering system for which the given string is valid in the current locale.\n * If no numbering system could be detected, the default numbering system for the current\n * locale is returned.\n */\n getNumberingSystem(value: string): string {\n return getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;\n }\n}\n\nconst numberParserCache = new Map<string, NumberParserImpl>();\nfunction getNumberParserImpl(locale: string, options: Intl.NumberFormatOptions, value: string) {\n // First try the default numbering system for the provided locale\n let defaultParser = getCachedNumberParser(locale, options);\n\n // If that doesn't match, and the locale doesn't include a hard coded numbering system,\n // try each of the other supported numbering systems until we find one that matches.\n if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {\n for (let numberingSystem of NUMBERING_SYSTEMS) {\n if (numberingSystem !== defaultParser.options.numberingSystem) {\n let parser = getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);\n if (parser.isValidPartialNumber(value)) {\n return parser;\n }\n }\n }\n }\n\n return defaultParser;\n}\n\nfunction getCachedNumberParser(locale: string, options: Intl.NumberFormatOptions) {\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n let parser = numberParserCache.get(cacheKey);\n if (!parser) {\n parser = new NumberParserImpl(locale, options);\n numberParserCache.set(cacheKey, parser);\n }\n\n return parser;\n}\n\n// The actual number parser implementation. Instances of this class are cached\n// based on the locale, options, and detected numbering system.\nclass NumberParserImpl {\n formatter: Intl.NumberFormat;\n options: Intl.ResolvedNumberFormatOptions;\n symbols: Symbols;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.formatter = new Intl.NumberFormat(locale, options);\n this.options = this.formatter.resolvedOptions();\n this.symbols = getSymbols(this.formatter, this.options, options);\n }\n\n parse(value: string) {\n // to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'\n let fullySanitizedValue = this.sanitize(value);\n\n // Remove group characters, and replace decimal points and numerals with ASCII values.\n fullySanitizedValue = replaceAll(fullySanitizedValue, this.symbols.group, '')\n .replace(this.symbols.decimal, '.')\n .replace(this.symbols.minusSign, '-')\n .replace(this.symbols.numeral, this.symbols.index);\n\n let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;\n if (isNaN(newValue)) {\n return NaN;\n }\n\n // accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again\n if (this.options.currencySign === 'accounting' && CURRENCY_SIGN_REGEX.test(value)) {\n newValue = -1 * newValue;\n }\n\n // when reading the number, if it's a percent, then it should be interpreted as being divided by 100\n if (this.options.style === 'percent') {\n newValue /= 100;\n // after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits\n newValue = +newValue.toFixed((this.options.maximumFractionDigits ?? 0) + 2);\n }\n\n return newValue;\n }\n\n sanitize(value: string) {\n // Remove literals and whitespace, which are allowed anywhere in the string\n value = value.replace(this.symbols.literals, '');\n\n // Replace the ASCII minus sign with the minus sign used in the current locale\n // so that both are allowed in case the user's keyboard doesn't have the locale's minus sign.\n value = value.replace('-', this.symbols.minusSign);\n\n // In arab numeral system, their decimal character is 1643, but most keyboards don't type that\n // instead they use the , (44) character or apparently the (1548) character.\n if (this.options.numberingSystem === 'arab') {\n value = value.replace(',', this.symbols.decimal);\n value = value.replace(String.fromCharCode(1548), this.symbols.decimal);\n value = replaceAll(value, '.', this.symbols.group);\n }\n\n // fr-FR group character is char code 8239, but that's not a key on the french keyboard,\n // so allow 'period' as a group char and replace it with a space\n if (this.options.locale === 'fr-FR') {\n value = replaceAll(value, '.', String.fromCharCode(8239));\n }\n\n return value;\n }\n\n isValidPartialNumber(value: string, minValue: number = -Infinity, maxValue: number = Infinity): boolean {\n value = this.sanitize(value);\n\n // Remove minus or plus sign, which must be at the start of the string.\n if (value.startsWith(this.symbols.minusSign) && minValue < 0) {\n value = value.slice(this.symbols.minusSign.length);\n } else if (this.symbols.plusSign && value.startsWith(this.symbols.plusSign) && maxValue > 0) {\n value = value.slice(this.symbols.plusSign.length);\n }\n\n // Numbers cannot start with a group separator\n if (value.startsWith(this.symbols.group)) {\n return false;\n }\n\n // Remove numerals, groups, and decimals\n value = replaceAll(value, this.symbols.group, '')\n .replace(this.symbols.numeral, '')\n .replace(this.symbols.decimal, '');\n\n // The number is valid if there are no remaining characters\n return value.length === 0;\n }\n}\n\nconst nonLiteralParts = new Set(['decimal', 'fraction', 'integer', 'minusSign', 'plusSign', 'group']);\n\nfunction getSymbols(formatter: Intl.NumberFormat, intlOptions: Intl.ResolvedNumberFormatOptions, originalOptions: Intl.NumberFormatOptions): Symbols {\n // Note: some locale's don't add a group symbol until there is a ten thousands place\n let allParts = formatter.formatToParts(-10000.111);\n let posAllParts = formatter.formatToParts(10000.111);\n let singularParts = formatter.formatToParts(1);\n\n let minusSign = allParts.find(p => p.type === 'minusSign')?.value ?? '-';\n let plusSign = posAllParts.find(p => p.type === 'plusSign')?.value;\n\n // Safari does not support the signDisplay option, but our number parser polyfills it.\n // If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.\n // @ts-ignore\n if (!plusSign && (originalOptions?.signDisplay === 'exceptZero' || originalOptions?.signDisplay === 'always')) {\n plusSign = '+';\n }\n\n let decimal = allParts.find(p => p.type === 'decimal')?.value;\n let group = allParts.find(p => p.type === 'group')?.value;\n\n // this set is also for a regex, it's all literals that might be in the string we want to eventually parse that\n // don't contribute to the numerical value\n let pluralLiterals = allParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let singularLiterals = singularParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let sortedLiterals = [...new Set([...singularLiterals, ...pluralLiterals])].sort((a, b) => b.length - a.length);\n let literals = new RegExp(`${sortedLiterals.join('|')}|[\\\\p{White_Space}]`, 'gu');\n\n // These are for replacing non-latn characters with the latn equivalent\n let numerals = [...new Intl.NumberFormat(intlOptions.locale, {useGrouping: false}).format(9876543210)].reverse();\n let indexes = new Map(numerals.map((d, i) => [d, i]));\n let numeral = new RegExp(`[${numerals.join('')}]`, 'g');\n let index = d => String(indexes.get(d));\n\n return {minusSign, plusSign, decimal, group, literals, numeral, index};\n}\n\nfunction replaceAll(str: string, find: string, replace: string) {\n // @ts-ignore\n if (str.replaceAll) {\n // @ts-ignore\n return str.replaceAll(find, replace);\n }\n\n return str.split(find).join(replace);\n}\n\nfunction escapeRegex(string: string) {\n return string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":"ACAA,EAUG,AAVH;;;;;;;;;;CAUG,AAVH,EAUG,CAEH,GAAG,CAAC,oCAAc,GAAG,GAAG,CAAC,GAAG;AAE5B,GAAG,CAAC,yCAAmB,GAAG,KAAK;AAC/B,GAAG,CAAC,CAAC;IACH,EAAa,AAAb,WAAa;IACb,yCAAmB,GAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAO,QAAE,CAAC;QAAA,WAAW,EAAE,CAAY;IAAA,CAAC,EAAG,eAAe,GAAG,WAAW,KAAK,CAAY;AAClI,EAAoC,AAApC,kCAAoC;AACtC,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;AAAA,CAAC;AAEd,GAAG,CAAC,kCAAY,GAAG,KAAK;AACxB,GAAG,CAAC,CAAC;IACH,EAAa,AAAb,WAAa;IACb,kCAAY,GAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAO,QAAE,CAAC;QAAA,KAAK,EAAE,CAAM;QAAE,IAAI,EAAE,CAAQ;IAAA,CAAC,EAAG,eAAe,GAAG,KAAK,KAAK,CAAM;AACnH,EAAoC,AAApC,kCAAoC;AACtC,CAAC,CAAC,KAAK,EAAE,EAAC,EAAE,CAAC;AAAA,CAAC;AAEd,EAAgH,AAAhH,8GAAgH;AAChH,EAAwG,AAAxG,sGAAwG;AACxG,EAAyE,AAAzE,uEAAyE;AACzE,KAAK,CAAC,2BAAK,GAAG,CAAC;IACb,MAAM,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;YACP,OAAO,EAAE,CAAG;YACX,CAAM,QAAE,CAAI;YACX,CAAK,QAAE,CAAG;YACV,CAAK,QAAE,CAAI;QAGf,CAAC;IACH,CAAC;AACH,CAAC;MAUY,yCAAe;IAS1B,MAAM,CAAC,KAA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CAAC;SAEQ,iCAAW,CAAC,MAAc,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAM;AACvD,CAAC;;","sources":["packages/@internationalized/number/src/index.ts","packages/@internationalized/number/src/NumberFormatter.ts","packages/@internationalized/number/src/NumberParser.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {NumberFormatOptions} from './NumberFormatter';\n\nexport {NumberFormatter} from './NumberFormatter';\nexport {NumberParser} from './NumberParser';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n // @ts-ignore\n supportsSignDisplay = (new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'})).resolvedOptions().signDisplay === 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\nlet supportsUnit = false;\ntry {\n // @ts-ignore\n supportsUnit = (new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'})).resolvedOptions().style === 'unit';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\n// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.\n// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.\n// Values were determined by switching to each locale manually in Chrome.\nconst UNITS = {\n degree: {\n narrow: {\n default: '°',\n 'ja-JP': ' 度',\n 'zh-TW': '度',\n 'sl-SI': ' °'\n // Arabic?? But Safari already doesn't use Arabic digits so might be ok...\n // https://bugs.webkit.org/show_bug.cgi?id=218139\n }\n }\n};\n\nexport interface NumberFormatOptions extends Intl.NumberFormatOptions {\n /** Overrides default numbering system for the current locale. */\n numberingSystem?: string\n}\n\n/**\n * A wrapper around Intl.NumberFormat providing additional options, polyfills, and caching for performance.\n */\nexport class NumberFormatter implements Intl.NumberFormat {\n private numberFormatter: Intl.NumberFormat;\n private options: NumberFormatOptions;\n\n constructor(locale: string, options: NumberFormatOptions = {}) {\n this.numberFormatter = getCachedNumberFormatter(locale, options);\n this.options = options;\n }\n\n format(value: number): string {\n let res = '';\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n res = numberFormatSignDisplayPolyfill(this.numberFormatter, this.options.signDisplay, value);\n } else {\n res = this.numberFormatter.format(value);\n }\n\n if (this.options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short', locale} = this.resolvedOptions();\n let values = UNITS[unit]?.[unitDisplay];\n res += values[locale] || values.default;\n }\n\n return res;\n }\n\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n resolvedOptions(): Intl.ResolvedNumberFormatOptions {\n let options = this.numberFormatter.resolvedOptions();\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n options = {...options, signDisplay: this.options.signDisplay};\n }\n\n if (!supportsUnit && this.options.style === 'unit') {\n options = {...options, style: 'unit', unit: this.options.unit, unitDisplay: this.options.unitDisplay};\n }\n\n return options;\n }\n}\n\nfunction getCachedNumberFormatter(locale: string, options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {numberingSystem} = options;\n if (numberingSystem && locale.indexOf('-u-nu-') === -1) {\n locale = `${locale}-u-nu-${numberingSystem}`;\n }\n\n if (options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short'} = options;\n if (!unit) {\n throw new Error('unit option must be provided with style: \"unit\"');\n }\n if (!UNITS[unit]?.[unitDisplay]) {\n throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);\n }\n options = {...options, style: 'decimal'};\n }\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey);\n }\n\n let numberFormatter = new Intl.NumberFormat(locale, options);\n formatterCache.set(cacheKey, numberFormatter);\n return numberFormatter;\n}\n\n/** @private - exported for tests */\nexport function numberFormatSignDisplayPolyfill(numberFormat: Intl.NumberFormat, signDisplay: string, num: number) {\n if (signDisplay === 'auto') {\n return numberFormat.format(num);\n } else if (signDisplay === 'never') {\n return numberFormat.format(Math.abs(num));\n } else {\n let needsPositiveSign = false;\n if (signDisplay === 'always') {\n needsPositiveSign = num > 0 || Object.is(num, 0);\n } else if (signDisplay === 'exceptZero') {\n if (Object.is(num, -0) || Object.is(num, 0)) {\n num = Math.abs(num);\n } else {\n needsPositiveSign = num > 0;\n }\n }\n\n if (needsPositiveSign) {\n let negative = numberFormat.format(-num);\n let noSign = numberFormat.format(num);\n // ignore RTL/LTR marker character\n let minus = negative.replace(noSign, '').replace(/\\u200e|\\u061C/, '');\n if ([...minus].length !== 1) {\n console.warn('@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case');\n }\n let positive = negative.replace(noSign, '!!!').replace(minus, '+').replace('!!!', noSign);\n return positive;\n } else {\n return numberFormat.format(num);\n }\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\ninterface Symbols {\n minusSign: string,\n plusSign: string,\n decimal: string,\n group: string,\n literals: RegExp,\n numeral: RegExp,\n index: (v: string) => string\n}\n\nconst CURRENCY_SIGN_REGEX = new RegExp('^.*\\\\(.*\\\\).*$');\nconst NUMBERING_SYSTEMS = ['latn', 'arab', 'hanidec'];\n\n/**\n * A NumberParser can be used perform locale aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. Automatically detects the numbering system\n * used in the input, and supports parsing decimals, percentages, currency values, and units\n * according to the locale.\n */\nexport class NumberParser {\n locale: string;\n options: Intl.NumberFormatOptions;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.locale = locale;\n this.options = options;\n }\n\n /**\n * Parses the given string to a number. Returns NaN if a valid number could not be parsed.\n */\n parse(value: string): number {\n return getNumberParserImpl(this.locale, this.options, value).parse(value);\n }\n\n /**\n * Returns whether the given string could potentially be a valid number. This should be used to\n * validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity\n * of the minus/plus sign characters can be checked.\n */\n isValidPartialNumber(value: string, minValue?: number, maxValue?: number): boolean {\n return getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);\n }\n\n /**\n * Returns a numbering system for which the given string is valid in the current locale.\n * If no numbering system could be detected, the default numbering system for the current\n * locale is returned.\n */\n getNumberingSystem(value: string): string {\n return getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;\n }\n}\n\nconst numberParserCache = new Map<string, NumberParserImpl>();\nfunction getNumberParserImpl(locale: string, options: Intl.NumberFormatOptions, value: string) {\n // First try the default numbering system for the provided locale\n let defaultParser = getCachedNumberParser(locale, options);\n\n // If that doesn't match, and the locale doesn't include a hard coded numbering system,\n // try each of the other supported numbering systems until we find one that matches.\n if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {\n for (let numberingSystem of NUMBERING_SYSTEMS) {\n if (numberingSystem !== defaultParser.options.numberingSystem) {\n let parser = getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);\n if (parser.isValidPartialNumber(value)) {\n return parser;\n }\n }\n }\n }\n\n return defaultParser;\n}\n\nfunction getCachedNumberParser(locale: string, options: Intl.NumberFormatOptions) {\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n let parser = numberParserCache.get(cacheKey);\n if (!parser) {\n parser = new NumberParserImpl(locale, options);\n numberParserCache.set(cacheKey, parser);\n }\n\n return parser;\n}\n\n// The actual number parser implementation. Instances of this class are cached\n// based on the locale, options, and detected numbering system.\nclass NumberParserImpl {\n formatter: Intl.NumberFormat;\n options: Intl.ResolvedNumberFormatOptions;\n symbols: Symbols;\n\n constructor(locale: string, options: Intl.NumberFormatOptions = {}) {\n this.formatter = new Intl.NumberFormat(locale, options);\n this.options = this.formatter.resolvedOptions();\n this.symbols = getSymbols(this.formatter, this.options, options);\n }\n\n parse(value: string) {\n // to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'\n let fullySanitizedValue = this.sanitize(value);\n\n // Remove group characters, and replace decimal points and numerals with ASCII values.\n fullySanitizedValue = replaceAll(fullySanitizedValue, this.symbols.group, '')\n .replace(this.symbols.decimal, '.')\n .replace(this.symbols.minusSign, '-')\n .replace(this.symbols.numeral, this.symbols.index);\n\n let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;\n if (isNaN(newValue)) {\n return NaN;\n }\n\n // accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again\n if (this.options.currencySign === 'accounting' && CURRENCY_SIGN_REGEX.test(value)) {\n newValue = -1 * newValue;\n }\n\n // when reading the number, if it's a percent, then it should be interpreted as being divided by 100\n if (this.options.style === 'percent') {\n newValue /= 100;\n // after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits\n newValue = +newValue.toFixed((this.options.maximumFractionDigits ?? 0) + 2);\n }\n\n return newValue;\n }\n\n sanitize(value: string) {\n // Remove literals and whitespace, which are allowed anywhere in the string\n value = value.replace(this.symbols.literals, '');\n\n // Replace the ASCII minus sign with the minus sign used in the current locale\n // so that both are allowed in case the user's keyboard doesn't have the locale's minus sign.\n value = value.replace('-', this.symbols.minusSign);\n\n // In arab numeral system, their decimal character is 1643, but most keyboards don't type that\n // instead they use the , (44) character or apparently the (1548) character.\n if (this.options.numberingSystem === 'arab') {\n value = value.replace(',', this.symbols.decimal);\n value = value.replace(String.fromCharCode(1548), this.symbols.decimal);\n value = replaceAll(value, '.', this.symbols.group);\n }\n\n // fr-FR group character is char code 8239, but that's not a key on the french keyboard,\n // so allow 'period' as a group char and replace it with a space\n if (this.options.locale === 'fr-FR') {\n value = replaceAll(value, '.', String.fromCharCode(8239));\n }\n\n return value;\n }\n\n isValidPartialNumber(value: string, minValue: number = -Infinity, maxValue: number = Infinity): boolean {\n value = this.sanitize(value);\n\n // Remove minus or plus sign, which must be at the start of the string.\n if (value.startsWith(this.symbols.minusSign) && minValue < 0) {\n value = value.slice(this.symbols.minusSign.length);\n } else if (this.symbols.plusSign && value.startsWith(this.symbols.plusSign) && maxValue > 0) {\n value = value.slice(this.symbols.plusSign.length);\n }\n\n // Numbers cannot start with a group separator\n if (value.startsWith(this.symbols.group)) {\n return false;\n }\n\n // Remove numerals, groups, and decimals\n value = replaceAll(value, this.symbols.group, '')\n .replace(this.symbols.numeral, '')\n .replace(this.symbols.decimal, '');\n\n // The number is valid if there are no remaining characters\n return value.length === 0;\n }\n}\n\nconst nonLiteralParts = new Set(['decimal', 'fraction', 'integer', 'minusSign', 'plusSign', 'group']);\n\nfunction getSymbols(formatter: Intl.NumberFormat, intlOptions: Intl.ResolvedNumberFormatOptions, originalOptions: Intl.NumberFormatOptions): Symbols {\n // Note: some locale's don't add a group symbol until there is a ten thousands place\n let allParts = formatter.formatToParts(-10000.111);\n let posAllParts = formatter.formatToParts(10000.111);\n let singularParts = formatter.formatToParts(1);\n\n let minusSign = allParts.find(p => p.type === 'minusSign')?.value ?? '-';\n let plusSign = posAllParts.find(p => p.type === 'plusSign')?.value;\n\n // Safari does not support the signDisplay option, but our number parser polyfills it.\n // If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.\n // @ts-ignore\n if (!plusSign && (originalOptions?.signDisplay === 'exceptZero' || originalOptions?.signDisplay === 'always')) {\n plusSign = '+';\n }\n\n let decimal = allParts.find(p => p.type === 'decimal')?.value;\n let group = allParts.find(p => p.type === 'group')?.value;\n\n // this set is also for a regex, it's all literals that might be in the string we want to eventually parse that\n // don't contribute to the numerical value\n let pluralLiterals = allParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let singularLiterals = singularParts.filter(p => !nonLiteralParts.has(p.type)).map(p => escapeRegex(p.value));\n let sortedLiterals = [...new Set([...singularLiterals, ...pluralLiterals])].sort((a, b) => b.length - a.length);\n let literals = new RegExp(`${sortedLiterals.join('|')}|[\\\\p{White_Space}]`, 'gu');\n\n // These are for replacing non-latn characters with the latn equivalent\n let numerals = [...new Intl.NumberFormat(intlOptions.locale, {useGrouping: false}).format(9876543210)].reverse();\n let indexes = new Map(numerals.map((d, i) => [d, i]));\n let numeral = new RegExp(`[${numerals.join('')}]`, 'g');\n let index = d => String(indexes.get(d));\n\n return {minusSign, plusSign, decimal, group, literals, numeral, index};\n}\n\nfunction replaceAll(str: string, find: string, replace: string) {\n // @ts-ignore\n if (str.replaceAll) {\n // @ts-ignore\n return str.replaceAll(find, replace);\n }\n\n return str.split(find).join(replace);\n}\n\nfunction escapeRegex(string: string) {\n return string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&');\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internationalized/number",
|
|
3
|
-
"version": "3.0.5
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"description": "Internationalized number formatting and parsing utilities",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
|
|
26
26
|
}
|