@internationalized/number 3.1.2-nightly.3599 → 3.1.2-nightly.3603
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 +101 -102
- package/dist/main.js.map +1 -1
- package/dist/module.mjs +101 -102
- package/dist/module.mjs.map +1 -1
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -5,6 +5,16 @@ function $parcel$export(e, n, v, s) {
|
|
|
5
5
|
$parcel$export(module.exports, "NumberFormatter", () => $0c1d5654b62fc485$export$cc77c4ff7e8673c5);
|
|
6
6
|
$parcel$export(module.exports, "NumberParser", () => $d68f3f4c684426c6$export$cd11ab140839f11d);
|
|
7
7
|
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/ /*
|
|
8
18
|
* Copyright 2020 Adobe. All rights reserved.
|
|
9
19
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
20
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -18,43 +28,41 @@ $parcel$export(module.exports, "NumberParser", () => $d68f3f4c684426c6$export$cd
|
|
|
18
28
|
let $0c1d5654b62fc485$var$supportsSignDisplay = false;
|
|
19
29
|
try {
|
|
20
30
|
// @ts-ignore
|
|
21
|
-
$0c1d5654b62fc485$var$supportsSignDisplay = new Intl.NumberFormat(
|
|
22
|
-
signDisplay:
|
|
23
|
-
}).resolvedOptions().signDisplay ===
|
|
31
|
+
$0c1d5654b62fc485$var$supportsSignDisplay = new Intl.NumberFormat("de-DE", {
|
|
32
|
+
signDisplay: "exceptZero"
|
|
33
|
+
}).resolvedOptions().signDisplay === "exceptZero";
|
|
24
34
|
// eslint-disable-next-line no-empty
|
|
25
|
-
} catch (e) {
|
|
26
|
-
}
|
|
35
|
+
} catch (e) {}
|
|
27
36
|
let $0c1d5654b62fc485$var$supportsUnit = false;
|
|
28
37
|
try {
|
|
29
38
|
// @ts-ignore
|
|
30
|
-
$0c1d5654b62fc485$var$supportsUnit = new Intl.NumberFormat(
|
|
31
|
-
style:
|
|
32
|
-
unit:
|
|
33
|
-
}).resolvedOptions().style ===
|
|
39
|
+
$0c1d5654b62fc485$var$supportsUnit = new Intl.NumberFormat("de-DE", {
|
|
40
|
+
style: "unit",
|
|
41
|
+
unit: "degree"
|
|
42
|
+
}).resolvedOptions().style === "unit";
|
|
34
43
|
// eslint-disable-next-line no-empty
|
|
35
|
-
} catch (e1) {
|
|
36
|
-
}
|
|
44
|
+
} catch (e1) {}
|
|
37
45
|
// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
|
|
38
46
|
// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
|
|
39
47
|
// Values were determined by switching to each locale manually in Chrome.
|
|
40
48
|
const $0c1d5654b62fc485$var$UNITS = {
|
|
41
49
|
degree: {
|
|
42
50
|
narrow: {
|
|
43
|
-
default:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
default: "\xb0",
|
|
52
|
+
"ja-JP": " 度",
|
|
53
|
+
"zh-TW": "度",
|
|
54
|
+
"sl-SI": " \xb0"
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
};
|
|
50
58
|
class $0c1d5654b62fc485$export$cc77c4ff7e8673c5 {
|
|
51
59
|
/** Formats a number value as a string, according to the locale and options provided to the constructor. */ format(value) {
|
|
52
|
-
let res =
|
|
60
|
+
let res = "";
|
|
53
61
|
if (!$0c1d5654b62fc485$var$supportsSignDisplay && this.options.signDisplay != null) res = $0c1d5654b62fc485$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
|
|
54
62
|
else res = this.numberFormatter.format(value);
|
|
55
|
-
if (this.options.style ===
|
|
63
|
+
if (this.options.style === "unit" && !$0c1d5654b62fc485$var$supportsUnit) {
|
|
56
64
|
var ref;
|
|
57
|
-
let { unit: unit , unitDisplay: unitDisplay =
|
|
65
|
+
let { unit: unit , unitDisplay: unitDisplay = "short" , locale: locale } = this.resolvedOptions();
|
|
58
66
|
let values = (ref = $0c1d5654b62fc485$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
|
|
59
67
|
res += values[locale] || values.default;
|
|
60
68
|
}
|
|
@@ -67,35 +75,33 @@ class $0c1d5654b62fc485$export$cc77c4ff7e8673c5 {
|
|
|
67
75
|
}
|
|
68
76
|
/** Formats a number range as a string. */ formatRange(start, end) {
|
|
69
77
|
// @ts-ignore
|
|
70
|
-
if (typeof this.numberFormatter.formatRange ===
|
|
78
|
+
if (typeof this.numberFormatter.formatRange === "function") // @ts-ignore
|
|
71
79
|
return this.numberFormatter.formatRange(start, end);
|
|
72
|
-
if (end < start) throw new RangeError(
|
|
80
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
73
81
|
// Very basic fallback for old browsers.
|
|
74
82
|
return `${this.format(start)} – ${this.format(end)}`;
|
|
75
83
|
}
|
|
76
84
|
/** Formats a number range as an array of parts. */ formatRangeToParts(start, end) {
|
|
77
85
|
// @ts-ignore
|
|
78
|
-
if (typeof this.numberFormatter.formatRangeToParts ===
|
|
86
|
+
if (typeof this.numberFormatter.formatRangeToParts === "function") // @ts-ignore
|
|
79
87
|
return this.numberFormatter.formatRangeToParts(start, end);
|
|
80
|
-
if (end < start) throw new RangeError(
|
|
88
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
81
89
|
let startParts = this.numberFormatter.formatToParts(start);
|
|
82
90
|
let endParts = this.numberFormatter.formatToParts(end);
|
|
83
91
|
return [
|
|
84
92
|
...startParts.map((p)=>({
|
|
85
93
|
...p,
|
|
86
|
-
source:
|
|
87
|
-
})
|
|
88
|
-
),
|
|
94
|
+
source: "startRange"
|
|
95
|
+
})),
|
|
89
96
|
{
|
|
90
|
-
type:
|
|
91
|
-
value:
|
|
92
|
-
source:
|
|
97
|
+
type: "literal",
|
|
98
|
+
value: " – ",
|
|
99
|
+
source: "shared"
|
|
93
100
|
},
|
|
94
101
|
...endParts.map((p)=>({
|
|
95
102
|
...p,
|
|
96
|
-
source:
|
|
97
|
-
})
|
|
98
|
-
)
|
|
103
|
+
source: "endRange"
|
|
104
|
+
}))
|
|
99
105
|
];
|
|
100
106
|
}
|
|
101
107
|
/** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
|
|
@@ -104,48 +110,45 @@ class $0c1d5654b62fc485$export$cc77c4ff7e8673c5 {
|
|
|
104
110
|
...options,
|
|
105
111
|
signDisplay: this.options.signDisplay
|
|
106
112
|
};
|
|
107
|
-
if (!$0c1d5654b62fc485$var$supportsUnit && this.options.style ===
|
|
113
|
+
if (!$0c1d5654b62fc485$var$supportsUnit && this.options.style === "unit") options = {
|
|
108
114
|
...options,
|
|
109
|
-
style:
|
|
115
|
+
style: "unit",
|
|
110
116
|
unit: this.options.unit,
|
|
111
117
|
unitDisplay: this.options.unitDisplay
|
|
112
118
|
};
|
|
113
119
|
return options;
|
|
114
120
|
}
|
|
115
|
-
constructor(locale, options = {
|
|
116
|
-
}){
|
|
121
|
+
constructor(locale, options = {}){
|
|
117
122
|
this.numberFormatter = $0c1d5654b62fc485$var$getCachedNumberFormatter(locale, options);
|
|
118
123
|
this.options = options;
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
|
-
function $0c1d5654b62fc485$var$getCachedNumberFormatter(locale, options = {
|
|
122
|
-
}) {
|
|
126
|
+
function $0c1d5654b62fc485$var$getCachedNumberFormatter(locale, options = {}) {
|
|
123
127
|
let { numberingSystem: numberingSystem } = options;
|
|
124
|
-
if (numberingSystem && locale.indexOf(
|
|
125
|
-
if (options.style ===
|
|
128
|
+
if (numberingSystem && locale.indexOf("-u-nu-") === -1) locale = `${locale}-u-nu-${numberingSystem}`;
|
|
129
|
+
if (options.style === "unit" && !$0c1d5654b62fc485$var$supportsUnit) {
|
|
126
130
|
var ref;
|
|
127
|
-
let { unit: unit , unitDisplay: unitDisplay =
|
|
131
|
+
let { unit: unit , unitDisplay: unitDisplay = "short" } = options;
|
|
128
132
|
if (!unit) throw new Error('unit option must be provided with style: "unit"');
|
|
129
133
|
if (!((ref = $0c1d5654b62fc485$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
|
|
130
134
|
options = {
|
|
131
135
|
...options,
|
|
132
|
-
style:
|
|
136
|
+
style: "decimal"
|
|
133
137
|
};
|
|
134
138
|
}
|
|
135
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
136
|
-
).join() : '');
|
|
139
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
|
|
137
140
|
if ($0c1d5654b62fc485$var$formatterCache.has(cacheKey)) return $0c1d5654b62fc485$var$formatterCache.get(cacheKey);
|
|
138
141
|
let numberFormatter = new Intl.NumberFormat(locale, options);
|
|
139
142
|
$0c1d5654b62fc485$var$formatterCache.set(cacheKey, numberFormatter);
|
|
140
143
|
return numberFormatter;
|
|
141
144
|
}
|
|
142
145
|
function $0c1d5654b62fc485$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
|
|
143
|
-
if (signDisplay ===
|
|
144
|
-
else if (signDisplay ===
|
|
146
|
+
if (signDisplay === "auto") return numberFormat.format(num);
|
|
147
|
+
else if (signDisplay === "never") return numberFormat.format(Math.abs(num));
|
|
145
148
|
else {
|
|
146
149
|
let needsPositiveSign = false;
|
|
147
|
-
if (signDisplay ===
|
|
148
|
-
else if (signDisplay ===
|
|
150
|
+
if (signDisplay === "always") needsPositiveSign = num > 0 || Object.is(num, 0);
|
|
151
|
+
else if (signDisplay === "exceptZero") {
|
|
149
152
|
if (Object.is(num, -0) || Object.is(num, 0)) num = Math.abs(num);
|
|
150
153
|
else needsPositiveSign = num > 0;
|
|
151
154
|
}
|
|
@@ -153,22 +156,32 @@ function $0c1d5654b62fc485$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
|
|
|
153
156
|
let negative = numberFormat.format(-num);
|
|
154
157
|
let noSign = numberFormat.format(num);
|
|
155
158
|
// ignore RTL/LTR marker character
|
|
156
|
-
let minus = negative.replace(noSign,
|
|
159
|
+
let minus = negative.replace(noSign, "").replace(/\u200e|\u061C/, "");
|
|
157
160
|
if ([
|
|
158
161
|
...minus
|
|
159
|
-
].length !== 1) console.warn(
|
|
160
|
-
let positive = negative.replace(noSign,
|
|
162
|
+
].length !== 1) console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case");
|
|
163
|
+
let positive = negative.replace(noSign, "!!!").replace(minus, "+").replace("!!!", noSign);
|
|
161
164
|
return positive;
|
|
162
165
|
} else return numberFormat.format(num);
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
|
|
167
|
-
|
|
170
|
+
/*
|
|
171
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
172
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
173
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
174
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
175
|
+
*
|
|
176
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
177
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
178
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
179
|
+
* governing permissions and limitations under the License.
|
|
180
|
+
*/ const $d68f3f4c684426c6$var$CURRENCY_SIGN_REGEX = new RegExp("^.*\\(.*\\).*$");
|
|
168
181
|
const $d68f3f4c684426c6$var$NUMBERING_SYSTEMS = [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
182
|
+
"latn",
|
|
183
|
+
"arab",
|
|
184
|
+
"hanidec"
|
|
172
185
|
];
|
|
173
186
|
class $d68f3f4c684426c6$export$cd11ab140839f11d {
|
|
174
187
|
/**
|
|
@@ -190,8 +203,7 @@ class $d68f3f4c684426c6$export$cd11ab140839f11d {
|
|
|
190
203
|
*/ getNumberingSystem(value) {
|
|
191
204
|
return $d68f3f4c684426c6$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
|
|
192
205
|
}
|
|
193
|
-
constructor(locale, options = {
|
|
194
|
-
}){
|
|
206
|
+
constructor(locale, options = {}){
|
|
195
207
|
this.locale = locale;
|
|
196
208
|
this.options = options;
|
|
197
209
|
}
|
|
@@ -202,17 +214,16 @@ function $d68f3f4c684426c6$var$getNumberParserImpl(locale, options, value) {
|
|
|
202
214
|
let defaultParser = $d68f3f4c684426c6$var$getCachedNumberParser(locale, options);
|
|
203
215
|
// If that doesn't match, and the locale doesn't include a hard coded numbering system,
|
|
204
216
|
// try each of the other supported numbering systems until we find one that matches.
|
|
205
|
-
if (!locale.includes(
|
|
217
|
+
if (!locale.includes("-nu-") && !defaultParser.isValidPartialNumber(value)) {
|
|
206
218
|
for (let numberingSystem of $d68f3f4c684426c6$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
|
|
207
|
-
let parser = $d68f3f4c684426c6$var$getCachedNumberParser(locale + (locale.includes(
|
|
219
|
+
let parser = $d68f3f4c684426c6$var$getCachedNumberParser(locale + (locale.includes("-u-") ? "-nu-" : "-u-nu-") + numberingSystem, options);
|
|
208
220
|
if (parser.isValidPartialNumber(value)) return parser;
|
|
209
221
|
}
|
|
210
222
|
}
|
|
211
223
|
return defaultParser;
|
|
212
224
|
}
|
|
213
225
|
function $d68f3f4c684426c6$var$getCachedNumberParser(locale, options) {
|
|
214
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
215
|
-
).join() : '');
|
|
226
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
|
|
216
227
|
let parser = $d68f3f4c684426c6$var$numberParserCache.get(cacheKey);
|
|
217
228
|
if (!parser) {
|
|
218
229
|
parser = new $d68f3f4c684426c6$var$NumberParserImpl(locale, options);
|
|
@@ -227,13 +238,13 @@ class $d68f3f4c684426c6$var$NumberParserImpl {
|
|
|
227
238
|
// 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'
|
|
228
239
|
let fullySanitizedValue = this.sanitize(value);
|
|
229
240
|
// Remove group characters, and replace decimal points and numerals with ASCII values.
|
|
230
|
-
fullySanitizedValue = $d68f3f4c684426c6$var$replaceAll(fullySanitizedValue, this.symbols.group,
|
|
241
|
+
fullySanitizedValue = $d68f3f4c684426c6$var$replaceAll(fullySanitizedValue, this.symbols.group, "").replace(this.symbols.decimal, ".").replace(this.symbols.minusSign, "-").replace(this.symbols.numeral, this.symbols.index);
|
|
231
242
|
let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;
|
|
232
243
|
if (isNaN(newValue)) return NaN;
|
|
233
244
|
// 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
|
|
234
|
-
if (this.options.currencySign ===
|
|
245
|
+
if (this.options.currencySign === "accounting" && $d68f3f4c684426c6$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
|
|
235
246
|
// when reading the number, if it's a percent, then it should be interpreted as being divided by 100
|
|
236
|
-
if (this.options.style ===
|
|
247
|
+
if (this.options.style === "percent") {
|
|
237
248
|
newValue /= 100;
|
|
238
249
|
var _maximumFractionDigits;
|
|
239
250
|
// after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits
|
|
@@ -243,20 +254,20 @@ class $d68f3f4c684426c6$var$NumberParserImpl {
|
|
|
243
254
|
}
|
|
244
255
|
sanitize(value) {
|
|
245
256
|
// Remove literals and whitespace, which are allowed anywhere in the string
|
|
246
|
-
value = value.replace(this.symbols.literals,
|
|
257
|
+
value = value.replace(this.symbols.literals, "");
|
|
247
258
|
// Replace the ASCII minus sign with the minus sign used in the current locale
|
|
248
259
|
// so that both are allowed in case the user's keyboard doesn't have the locale's minus sign.
|
|
249
|
-
value = value.replace(
|
|
260
|
+
value = value.replace("-", this.symbols.minusSign);
|
|
250
261
|
// In arab numeral system, their decimal character is 1643, but most keyboards don't type that
|
|
251
262
|
// instead they use the , (44) character or apparently the (1548) character.
|
|
252
|
-
if (this.options.numberingSystem ===
|
|
253
|
-
value = value.replace(
|
|
263
|
+
if (this.options.numberingSystem === "arab") {
|
|
264
|
+
value = value.replace(",", this.symbols.decimal);
|
|
254
265
|
value = value.replace(String.fromCharCode(1548), this.symbols.decimal);
|
|
255
|
-
value = $d68f3f4c684426c6$var$replaceAll(value,
|
|
266
|
+
value = $d68f3f4c684426c6$var$replaceAll(value, ".", this.symbols.group);
|
|
256
267
|
}
|
|
257
268
|
// fr-FR group character is char code 8239, but that's not a key on the french keyboard,
|
|
258
269
|
// so allow 'period' as a group char and replace it with a space
|
|
259
|
-
if (this.options.locale ===
|
|
270
|
+
if (this.options.locale === "fr-FR") value = $d68f3f4c684426c6$var$replaceAll(value, ".", String.fromCharCode(8239));
|
|
260
271
|
return value;
|
|
261
272
|
}
|
|
262
273
|
isValidPartialNumber(value, minValue = -Infinity, maxValue = Infinity) {
|
|
@@ -267,24 +278,23 @@ class $d68f3f4c684426c6$var$NumberParserImpl {
|
|
|
267
278
|
// Numbers cannot start with a group separator
|
|
268
279
|
if (value.startsWith(this.symbols.group)) return false;
|
|
269
280
|
// Remove numerals, groups, and decimals
|
|
270
|
-
value = $d68f3f4c684426c6$var$replaceAll(value, this.symbols.group,
|
|
281
|
+
value = $d68f3f4c684426c6$var$replaceAll(value, this.symbols.group, "").replace(this.symbols.numeral, "").replace(this.symbols.decimal, "");
|
|
271
282
|
// The number is valid if there are no remaining characters
|
|
272
283
|
return value.length === 0;
|
|
273
284
|
}
|
|
274
|
-
constructor(locale, options = {
|
|
275
|
-
}){
|
|
285
|
+
constructor(locale, options = {}){
|
|
276
286
|
this.formatter = new Intl.NumberFormat(locale, options);
|
|
277
287
|
this.options = this.formatter.resolvedOptions();
|
|
278
288
|
this.symbols = $d68f3f4c684426c6$var$getSymbols(this.formatter, this.options, options);
|
|
279
289
|
}
|
|
280
290
|
}
|
|
281
291
|
const $d68f3f4c684426c6$var$nonLiteralParts = new Set([
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
"decimal",
|
|
293
|
+
"fraction",
|
|
294
|
+
"integer",
|
|
295
|
+
"minusSign",
|
|
296
|
+
"plusSign",
|
|
297
|
+
"group"
|
|
288
298
|
]);
|
|
289
299
|
function $d68f3f4c684426c6$var$getSymbols(formatter, intlOptions, originalOptions) {
|
|
290
300
|
var ref, ref1, ref2, ref3;
|
|
@@ -293,34 +303,25 @@ function $d68f3f4c684426c6$var$getSymbols(formatter, intlOptions, originalOption
|
|
|
293
303
|
let posAllParts = formatter.formatToParts(10000.111);
|
|
294
304
|
let singularParts = formatter.formatToParts(1);
|
|
295
305
|
var ref4;
|
|
296
|
-
let minusSign = (ref4 = (ref = allParts.find((p)=>p.type ===
|
|
297
|
-
)) === null ||
|
|
298
|
-
let plusSign = (ref1 = posAllParts.find((p)=>p.type === 'plusSign'
|
|
299
|
-
)) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
306
|
+
let minusSign = (ref4 = (ref = allParts.find((p)=>p.type === "minusSign")) === null || ref === void 0 ? void 0 : ref.value) !== null && ref4 !== void 0 ? ref4 : "-";
|
|
307
|
+
let plusSign = (ref1 = posAllParts.find((p)=>p.type === "plusSign")) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
300
308
|
// Safari does not support the signDisplay option, but our number parser polyfills it.
|
|
301
309
|
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.
|
|
302
310
|
// @ts-ignore
|
|
303
|
-
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) ===
|
|
304
|
-
let decimal = (ref2 = allParts.find((p)=>p.type ===
|
|
305
|
-
)) === null ||
|
|
306
|
-
let group = (ref3 = allParts.find((p)=>p.type === 'group'
|
|
307
|
-
)) === null || ref3 === void 0 ? void 0 : ref3.value;
|
|
311
|
+
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === "exceptZero" || (originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === "always")) plusSign = "+";
|
|
312
|
+
let decimal = (ref2 = allParts.find((p)=>p.type === "decimal")) === null || ref2 === void 0 ? void 0 : ref2.value;
|
|
313
|
+
let group = (ref3 = allParts.find((p)=>p.type === "group")) === null || ref3 === void 0 ? void 0 : ref3.value;
|
|
308
314
|
// this set is also for a regex, it's all literals that might be in the string we want to eventually parse that
|
|
309
315
|
// don't contribute to the numerical value
|
|
310
|
-
let pluralLiterals = allParts.filter((p)=>!$d68f3f4c684426c6$var$nonLiteralParts.has(p.type)
|
|
311
|
-
).map((p)=>$d68f3f4c684426c6$var$escapeRegex(p.value)
|
|
312
|
-
);
|
|
313
|
-
let singularLiterals = singularParts.filter((p)=>!$d68f3f4c684426c6$var$nonLiteralParts.has(p.type)
|
|
314
|
-
).map((p)=>$d68f3f4c684426c6$var$escapeRegex(p.value)
|
|
315
|
-
);
|
|
316
|
+
let pluralLiterals = allParts.filter((p)=>!$d68f3f4c684426c6$var$nonLiteralParts.has(p.type)).map((p)=>$d68f3f4c684426c6$var$escapeRegex(p.value));
|
|
317
|
+
let singularLiterals = singularParts.filter((p)=>!$d68f3f4c684426c6$var$nonLiteralParts.has(p.type)).map((p)=>$d68f3f4c684426c6$var$escapeRegex(p.value));
|
|
316
318
|
let sortedLiterals = [
|
|
317
319
|
...new Set([
|
|
318
320
|
...singularLiterals,
|
|
319
321
|
...pluralLiterals
|
|
320
322
|
])
|
|
321
|
-
].sort((a, b)=>b.length - a.length
|
|
322
|
-
);
|
|
323
|
-
let literals = sortedLiterals.length === 0 ? new RegExp('[\\p{White_Space}]', 'gu') : new RegExp(`${sortedLiterals.join('|')}|[\\p{White_Space}]`, 'gu');
|
|
323
|
+
].sort((a, b)=>b.length - a.length);
|
|
324
|
+
let literals = sortedLiterals.length === 0 ? new RegExp("[\\p{White_Space}]", "gu") : new RegExp(`${sortedLiterals.join("|")}|[\\p{White_Space}]`, "gu");
|
|
324
325
|
// These are for replacing non-latn characters with the latn equivalent
|
|
325
326
|
let numerals = [
|
|
326
327
|
...new Intl.NumberFormat(intlOptions.locale, {
|
|
@@ -330,11 +331,9 @@ function $d68f3f4c684426c6$var$getSymbols(formatter, intlOptions, originalOption
|
|
|
330
331
|
let indexes = new Map(numerals.map((d, i)=>[
|
|
331
332
|
d,
|
|
332
333
|
i
|
|
333
|
-
]
|
|
334
|
-
));
|
|
335
|
-
let
|
|
336
|
-
let index = (d)=>String(indexes.get(d))
|
|
337
|
-
;
|
|
334
|
+
]));
|
|
335
|
+
let numeral = new RegExp(`[${numerals.join("")}]`, "g");
|
|
336
|
+
let index = (d)=>String(indexes.get(d));
|
|
338
337
|
return {
|
|
339
338
|
minusSign: minusSign,
|
|
340
339
|
plusSign: plusSign,
|
|
@@ -352,7 +351,7 @@ function $d68f3f4c684426c6$var$replaceAll(str, find, replace) {
|
|
|
352
351
|
return str.split(find).join(replace);
|
|
353
352
|
}
|
|
354
353
|
function $d68f3f4c684426c6$var$escapeRegex(string) {
|
|
355
|
-
return string.replace(/[-/\\^$*+?.()|[\]{}]/g,
|
|
354
|
+
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
356
355
|
}
|
|
357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AK;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\ninterface NumberRangeFormatPart extends Intl.NumberFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\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 /** Formats a number value as a string, according to the locale and options provided to the constructor. */\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 /** Formats a number to an array of parts such as separators, digits, punctuation, and more. */\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n /** Formats a number range as a string. */\n formatRange(start: number, end: number): string {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRange === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.format(start)} – ${this.format(end)}`;\n }\n\n /** Formats a number range as an array of parts. */\n formatRangeToParts(start: number, end: number): NumberRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.numberFormatter.formatToParts(start);\n let endParts = this.numberFormatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as NumberRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as NumberRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\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 to perform locale-aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. It 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 private locale: string;\n private 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 = sortedLiterals.length === 0 ? \n new RegExp('[\\\\p{White_Space}]', 'gu') :\n 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":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAEzB,IAAI,4CAAsB,KAAK;AAC/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ources":["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\ninterface NumberRangeFormatPart extends Intl.NumberFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\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 /** Formats a number value as a string, according to the locale and options provided to the constructor. */\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 /** Formats a number to an array of parts such as separators, digits, punctuation, and more. */\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n /** Formats a number range as a string. */\n formatRange(start: number, end: number): string {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRange === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.format(start)} – ${this.format(end)}`;\n }\n\n /** Formats a number range as an array of parts. */\n formatRangeToParts(start: number, end: number): NumberRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.numberFormatter.formatToParts(start);\n let endParts = this.numberFormatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as NumberRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as NumberRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\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 to perform locale-aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. It 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 private locale: string;\n private 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 = sortedLiterals.length === 0 ? \n new RegExp('[\\\\p{White_Space}]', 'gu') :\n 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.mjs
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/ /*
|
|
2
12
|
* Copyright 2020 Adobe. All rights reserved.
|
|
3
13
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
14
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -12,43 +22,41 @@
|
|
|
12
22
|
let $488c6ddbf4ef74c2$var$supportsSignDisplay = false;
|
|
13
23
|
try {
|
|
14
24
|
// @ts-ignore
|
|
15
|
-
$488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat(
|
|
16
|
-
signDisplay:
|
|
17
|
-
}).resolvedOptions().signDisplay ===
|
|
25
|
+
$488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat("de-DE", {
|
|
26
|
+
signDisplay: "exceptZero"
|
|
27
|
+
}).resolvedOptions().signDisplay === "exceptZero";
|
|
18
28
|
// eslint-disable-next-line no-empty
|
|
19
|
-
} catch (e) {
|
|
20
|
-
}
|
|
29
|
+
} catch (e) {}
|
|
21
30
|
let $488c6ddbf4ef74c2$var$supportsUnit = false;
|
|
22
31
|
try {
|
|
23
32
|
// @ts-ignore
|
|
24
|
-
$488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat(
|
|
25
|
-
style:
|
|
26
|
-
unit:
|
|
27
|
-
}).resolvedOptions().style ===
|
|
33
|
+
$488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat("de-DE", {
|
|
34
|
+
style: "unit",
|
|
35
|
+
unit: "degree"
|
|
36
|
+
}).resolvedOptions().style === "unit";
|
|
28
37
|
// eslint-disable-next-line no-empty
|
|
29
|
-
} catch (e1) {
|
|
30
|
-
}
|
|
38
|
+
} catch (e1) {}
|
|
31
39
|
// Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
|
|
32
40
|
// Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
|
|
33
41
|
// Values were determined by switching to each locale manually in Chrome.
|
|
34
42
|
const $488c6ddbf4ef74c2$var$UNITS = {
|
|
35
43
|
degree: {
|
|
36
44
|
narrow: {
|
|
37
|
-
default:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
default: "\xb0",
|
|
46
|
+
"ja-JP": " 度",
|
|
47
|
+
"zh-TW": "度",
|
|
48
|
+
"sl-SI": " \xb0"
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
};
|
|
44
52
|
class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
|
|
45
53
|
/** Formats a number value as a string, according to the locale and options provided to the constructor. */ format(value) {
|
|
46
|
-
let res =
|
|
54
|
+
let res = "";
|
|
47
55
|
if (!$488c6ddbf4ef74c2$var$supportsSignDisplay && this.options.signDisplay != null) res = $488c6ddbf4ef74c2$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
|
|
48
56
|
else res = this.numberFormatter.format(value);
|
|
49
|
-
if (this.options.style ===
|
|
57
|
+
if (this.options.style === "unit" && !$488c6ddbf4ef74c2$var$supportsUnit) {
|
|
50
58
|
var ref;
|
|
51
|
-
let { unit: unit , unitDisplay: unitDisplay =
|
|
59
|
+
let { unit: unit , unitDisplay: unitDisplay = "short" , locale: locale } = this.resolvedOptions();
|
|
52
60
|
let values = (ref = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
|
|
53
61
|
res += values[locale] || values.default;
|
|
54
62
|
}
|
|
@@ -61,35 +69,33 @@ class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
|
|
|
61
69
|
}
|
|
62
70
|
/** Formats a number range as a string. */ formatRange(start, end) {
|
|
63
71
|
// @ts-ignore
|
|
64
|
-
if (typeof this.numberFormatter.formatRange ===
|
|
72
|
+
if (typeof this.numberFormatter.formatRange === "function") // @ts-ignore
|
|
65
73
|
return this.numberFormatter.formatRange(start, end);
|
|
66
|
-
if (end < start) throw new RangeError(
|
|
74
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
67
75
|
// Very basic fallback for old browsers.
|
|
68
76
|
return `${this.format(start)} – ${this.format(end)}`;
|
|
69
77
|
}
|
|
70
78
|
/** Formats a number range as an array of parts. */ formatRangeToParts(start, end) {
|
|
71
79
|
// @ts-ignore
|
|
72
|
-
if (typeof this.numberFormatter.formatRangeToParts ===
|
|
80
|
+
if (typeof this.numberFormatter.formatRangeToParts === "function") // @ts-ignore
|
|
73
81
|
return this.numberFormatter.formatRangeToParts(start, end);
|
|
74
|
-
if (end < start) throw new RangeError(
|
|
82
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
75
83
|
let startParts = this.numberFormatter.formatToParts(start);
|
|
76
84
|
let endParts = this.numberFormatter.formatToParts(end);
|
|
77
85
|
return [
|
|
78
86
|
...startParts.map((p)=>({
|
|
79
87
|
...p,
|
|
80
|
-
source:
|
|
81
|
-
})
|
|
82
|
-
),
|
|
88
|
+
source: "startRange"
|
|
89
|
+
})),
|
|
83
90
|
{
|
|
84
|
-
type:
|
|
85
|
-
value:
|
|
86
|
-
source:
|
|
91
|
+
type: "literal",
|
|
92
|
+
value: " – ",
|
|
93
|
+
source: "shared"
|
|
87
94
|
},
|
|
88
95
|
...endParts.map((p)=>({
|
|
89
96
|
...p,
|
|
90
|
-
source:
|
|
91
|
-
})
|
|
92
|
-
)
|
|
97
|
+
source: "endRange"
|
|
98
|
+
}))
|
|
93
99
|
];
|
|
94
100
|
}
|
|
95
101
|
/** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
|
|
@@ -98,48 +104,45 @@ class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
|
|
|
98
104
|
...options,
|
|
99
105
|
signDisplay: this.options.signDisplay
|
|
100
106
|
};
|
|
101
|
-
if (!$488c6ddbf4ef74c2$var$supportsUnit && this.options.style ===
|
|
107
|
+
if (!$488c6ddbf4ef74c2$var$supportsUnit && this.options.style === "unit") options = {
|
|
102
108
|
...options,
|
|
103
|
-
style:
|
|
109
|
+
style: "unit",
|
|
104
110
|
unit: this.options.unit,
|
|
105
111
|
unitDisplay: this.options.unitDisplay
|
|
106
112
|
};
|
|
107
113
|
return options;
|
|
108
114
|
}
|
|
109
|
-
constructor(locale, options = {
|
|
110
|
-
}){
|
|
115
|
+
constructor(locale, options = {}){
|
|
111
116
|
this.numberFormatter = $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options);
|
|
112
117
|
this.options = options;
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
function $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options = {
|
|
116
|
-
}) {
|
|
120
|
+
function $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options = {}) {
|
|
117
121
|
let { numberingSystem: numberingSystem } = options;
|
|
118
|
-
if (numberingSystem && locale.indexOf(
|
|
119
|
-
if (options.style ===
|
|
122
|
+
if (numberingSystem && locale.indexOf("-u-nu-") === -1) locale = `${locale}-u-nu-${numberingSystem}`;
|
|
123
|
+
if (options.style === "unit" && !$488c6ddbf4ef74c2$var$supportsUnit) {
|
|
120
124
|
var ref;
|
|
121
|
-
let { unit: unit , unitDisplay: unitDisplay =
|
|
125
|
+
let { unit: unit , unitDisplay: unitDisplay = "short" } = options;
|
|
122
126
|
if (!unit) throw new Error('unit option must be provided with style: "unit"');
|
|
123
127
|
if (!((ref = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
|
|
124
128
|
options = {
|
|
125
129
|
...options,
|
|
126
|
-
style:
|
|
130
|
+
style: "decimal"
|
|
127
131
|
};
|
|
128
132
|
}
|
|
129
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
130
|
-
).join() : '');
|
|
133
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
|
|
131
134
|
if ($488c6ddbf4ef74c2$var$formatterCache.has(cacheKey)) return $488c6ddbf4ef74c2$var$formatterCache.get(cacheKey);
|
|
132
135
|
let numberFormatter = new Intl.NumberFormat(locale, options);
|
|
133
136
|
$488c6ddbf4ef74c2$var$formatterCache.set(cacheKey, numberFormatter);
|
|
134
137
|
return numberFormatter;
|
|
135
138
|
}
|
|
136
139
|
function $488c6ddbf4ef74c2$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
|
|
137
|
-
if (signDisplay ===
|
|
138
|
-
else if (signDisplay ===
|
|
140
|
+
if (signDisplay === "auto") return numberFormat.format(num);
|
|
141
|
+
else if (signDisplay === "never") return numberFormat.format(Math.abs(num));
|
|
139
142
|
else {
|
|
140
143
|
let needsPositiveSign = false;
|
|
141
|
-
if (signDisplay ===
|
|
142
|
-
else if (signDisplay ===
|
|
144
|
+
if (signDisplay === "always") needsPositiveSign = num > 0 || Object.is(num, 0);
|
|
145
|
+
else if (signDisplay === "exceptZero") {
|
|
143
146
|
if (Object.is(num, -0) || Object.is(num, 0)) num = Math.abs(num);
|
|
144
147
|
else needsPositiveSign = num > 0;
|
|
145
148
|
}
|
|
@@ -147,22 +150,32 @@ function $488c6ddbf4ef74c2$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
|
|
|
147
150
|
let negative = numberFormat.format(-num);
|
|
148
151
|
let noSign = numberFormat.format(num);
|
|
149
152
|
// ignore RTL/LTR marker character
|
|
150
|
-
let minus = negative.replace(noSign,
|
|
153
|
+
let minus = negative.replace(noSign, "").replace(/\u200e|\u061C/, "");
|
|
151
154
|
if ([
|
|
152
155
|
...minus
|
|
153
|
-
].length !== 1) console.warn(
|
|
154
|
-
let positive = negative.replace(noSign,
|
|
156
|
+
].length !== 1) console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case");
|
|
157
|
+
let positive = negative.replace(noSign, "!!!").replace(minus, "+").replace("!!!", noSign);
|
|
155
158
|
return positive;
|
|
156
159
|
} else return numberFormat.format(num);
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
|
|
161
|
-
|
|
164
|
+
/*
|
|
165
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
166
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
167
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
168
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
169
|
+
*
|
|
170
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
171
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
172
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
173
|
+
* governing permissions and limitations under the License.
|
|
174
|
+
*/ const $6c7bd7858deea686$var$CURRENCY_SIGN_REGEX = new RegExp("^.*\\(.*\\).*$");
|
|
162
175
|
const $6c7bd7858deea686$var$NUMBERING_SYSTEMS = [
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
176
|
+
"latn",
|
|
177
|
+
"arab",
|
|
178
|
+
"hanidec"
|
|
166
179
|
];
|
|
167
180
|
class $6c7bd7858deea686$export$cd11ab140839f11d {
|
|
168
181
|
/**
|
|
@@ -184,8 +197,7 @@ class $6c7bd7858deea686$export$cd11ab140839f11d {
|
|
|
184
197
|
*/ getNumberingSystem(value) {
|
|
185
198
|
return $6c7bd7858deea686$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
|
|
186
199
|
}
|
|
187
|
-
constructor(locale, options = {
|
|
188
|
-
}){
|
|
200
|
+
constructor(locale, options = {}){
|
|
189
201
|
this.locale = locale;
|
|
190
202
|
this.options = options;
|
|
191
203
|
}
|
|
@@ -196,17 +208,16 @@ function $6c7bd7858deea686$var$getNumberParserImpl(locale, options, value) {
|
|
|
196
208
|
let defaultParser = $6c7bd7858deea686$var$getCachedNumberParser(locale, options);
|
|
197
209
|
// If that doesn't match, and the locale doesn't include a hard coded numbering system,
|
|
198
210
|
// try each of the other supported numbering systems until we find one that matches.
|
|
199
|
-
if (!locale.includes(
|
|
211
|
+
if (!locale.includes("-nu-") && !defaultParser.isValidPartialNumber(value)) {
|
|
200
212
|
for (let numberingSystem of $6c7bd7858deea686$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
|
|
201
|
-
let parser = $6c7bd7858deea686$var$getCachedNumberParser(locale + (locale.includes(
|
|
213
|
+
let parser = $6c7bd7858deea686$var$getCachedNumberParser(locale + (locale.includes("-u-") ? "-nu-" : "-u-nu-") + numberingSystem, options);
|
|
202
214
|
if (parser.isValidPartialNumber(value)) return parser;
|
|
203
215
|
}
|
|
204
216
|
}
|
|
205
217
|
return defaultParser;
|
|
206
218
|
}
|
|
207
219
|
function $6c7bd7858deea686$var$getCachedNumberParser(locale, options) {
|
|
208
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
209
|
-
).join() : '');
|
|
220
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
|
|
210
221
|
let parser = $6c7bd7858deea686$var$numberParserCache.get(cacheKey);
|
|
211
222
|
if (!parser) {
|
|
212
223
|
parser = new $6c7bd7858deea686$var$NumberParserImpl(locale, options);
|
|
@@ -221,13 +232,13 @@ class $6c7bd7858deea686$var$NumberParserImpl {
|
|
|
221
232
|
// 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'
|
|
222
233
|
let fullySanitizedValue = this.sanitize(value);
|
|
223
234
|
// Remove group characters, and replace decimal points and numerals with ASCII values.
|
|
224
|
-
fullySanitizedValue = $6c7bd7858deea686$var$replaceAll(fullySanitizedValue, this.symbols.group,
|
|
235
|
+
fullySanitizedValue = $6c7bd7858deea686$var$replaceAll(fullySanitizedValue, this.symbols.group, "").replace(this.symbols.decimal, ".").replace(this.symbols.minusSign, "-").replace(this.symbols.numeral, this.symbols.index);
|
|
225
236
|
let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;
|
|
226
237
|
if (isNaN(newValue)) return NaN;
|
|
227
238
|
// 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
|
|
228
|
-
if (this.options.currencySign ===
|
|
239
|
+
if (this.options.currencySign === "accounting" && $6c7bd7858deea686$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
|
|
229
240
|
// when reading the number, if it's a percent, then it should be interpreted as being divided by 100
|
|
230
|
-
if (this.options.style ===
|
|
241
|
+
if (this.options.style === "percent") {
|
|
231
242
|
newValue /= 100;
|
|
232
243
|
var _maximumFractionDigits;
|
|
233
244
|
// after dividing to get the percent value, javascript may get .0210999999 instead of .0211, so fix the number of fraction digits
|
|
@@ -237,20 +248,20 @@ class $6c7bd7858deea686$var$NumberParserImpl {
|
|
|
237
248
|
}
|
|
238
249
|
sanitize(value) {
|
|
239
250
|
// Remove literals and whitespace, which are allowed anywhere in the string
|
|
240
|
-
value = value.replace(this.symbols.literals,
|
|
251
|
+
value = value.replace(this.symbols.literals, "");
|
|
241
252
|
// Replace the ASCII minus sign with the minus sign used in the current locale
|
|
242
253
|
// so that both are allowed in case the user's keyboard doesn't have the locale's minus sign.
|
|
243
|
-
value = value.replace(
|
|
254
|
+
value = value.replace("-", this.symbols.minusSign);
|
|
244
255
|
// In arab numeral system, their decimal character is 1643, but most keyboards don't type that
|
|
245
256
|
// instead they use the , (44) character or apparently the (1548) character.
|
|
246
|
-
if (this.options.numberingSystem ===
|
|
247
|
-
value = value.replace(
|
|
257
|
+
if (this.options.numberingSystem === "arab") {
|
|
258
|
+
value = value.replace(",", this.symbols.decimal);
|
|
248
259
|
value = value.replace(String.fromCharCode(1548), this.symbols.decimal);
|
|
249
|
-
value = $6c7bd7858deea686$var$replaceAll(value,
|
|
260
|
+
value = $6c7bd7858deea686$var$replaceAll(value, ".", this.symbols.group);
|
|
250
261
|
}
|
|
251
262
|
// fr-FR group character is char code 8239, but that's not a key on the french keyboard,
|
|
252
263
|
// so allow 'period' as a group char and replace it with a space
|
|
253
|
-
if (this.options.locale ===
|
|
264
|
+
if (this.options.locale === "fr-FR") value = $6c7bd7858deea686$var$replaceAll(value, ".", String.fromCharCode(8239));
|
|
254
265
|
return value;
|
|
255
266
|
}
|
|
256
267
|
isValidPartialNumber(value, minValue = -Infinity, maxValue = Infinity) {
|
|
@@ -261,24 +272,23 @@ class $6c7bd7858deea686$var$NumberParserImpl {
|
|
|
261
272
|
// Numbers cannot start with a group separator
|
|
262
273
|
if (value.startsWith(this.symbols.group)) return false;
|
|
263
274
|
// Remove numerals, groups, and decimals
|
|
264
|
-
value = $6c7bd7858deea686$var$replaceAll(value, this.symbols.group,
|
|
275
|
+
value = $6c7bd7858deea686$var$replaceAll(value, this.symbols.group, "").replace(this.symbols.numeral, "").replace(this.symbols.decimal, "");
|
|
265
276
|
// The number is valid if there are no remaining characters
|
|
266
277
|
return value.length === 0;
|
|
267
278
|
}
|
|
268
|
-
constructor(locale, options = {
|
|
269
|
-
}){
|
|
279
|
+
constructor(locale, options = {}){
|
|
270
280
|
this.formatter = new Intl.NumberFormat(locale, options);
|
|
271
281
|
this.options = this.formatter.resolvedOptions();
|
|
272
282
|
this.symbols = $6c7bd7858deea686$var$getSymbols(this.formatter, this.options, options);
|
|
273
283
|
}
|
|
274
284
|
}
|
|
275
285
|
const $6c7bd7858deea686$var$nonLiteralParts = new Set([
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
286
|
+
"decimal",
|
|
287
|
+
"fraction",
|
|
288
|
+
"integer",
|
|
289
|
+
"minusSign",
|
|
290
|
+
"plusSign",
|
|
291
|
+
"group"
|
|
282
292
|
]);
|
|
283
293
|
function $6c7bd7858deea686$var$getSymbols(formatter, intlOptions, originalOptions) {
|
|
284
294
|
var ref, ref1, ref2, ref3;
|
|
@@ -287,34 +297,25 @@ function $6c7bd7858deea686$var$getSymbols(formatter, intlOptions, originalOption
|
|
|
287
297
|
let posAllParts = formatter.formatToParts(10000.111);
|
|
288
298
|
let singularParts = formatter.formatToParts(1);
|
|
289
299
|
var ref4;
|
|
290
|
-
let minusSign = (ref4 = (ref = allParts.find((p)=>p.type ===
|
|
291
|
-
)) === null ||
|
|
292
|
-
let plusSign = (ref1 = posAllParts.find((p)=>p.type === 'plusSign'
|
|
293
|
-
)) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
300
|
+
let minusSign = (ref4 = (ref = allParts.find((p)=>p.type === "minusSign")) === null || ref === void 0 ? void 0 : ref.value) !== null && ref4 !== void 0 ? ref4 : "-";
|
|
301
|
+
let plusSign = (ref1 = posAllParts.find((p)=>p.type === "plusSign")) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
294
302
|
// Safari does not support the signDisplay option, but our number parser polyfills it.
|
|
295
303
|
// If no plus sign was returned, but the original options contained signDisplay, default to the '+' character.
|
|
296
304
|
// @ts-ignore
|
|
297
|
-
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) ===
|
|
298
|
-
let decimal = (ref2 = allParts.find((p)=>p.type ===
|
|
299
|
-
)) === null ||
|
|
300
|
-
let group = (ref3 = allParts.find((p)=>p.type === 'group'
|
|
301
|
-
)) === null || ref3 === void 0 ? void 0 : ref3.value;
|
|
305
|
+
if (!plusSign && ((originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === "exceptZero" || (originalOptions === null || originalOptions === void 0 ? void 0 : originalOptions.signDisplay) === "always")) plusSign = "+";
|
|
306
|
+
let decimal = (ref2 = allParts.find((p)=>p.type === "decimal")) === null || ref2 === void 0 ? void 0 : ref2.value;
|
|
307
|
+
let group = (ref3 = allParts.find((p)=>p.type === "group")) === null || ref3 === void 0 ? void 0 : ref3.value;
|
|
302
308
|
// this set is also for a regex, it's all literals that might be in the string we want to eventually parse that
|
|
303
309
|
// don't contribute to the numerical value
|
|
304
|
-
let pluralLiterals = allParts.filter((p)=>!$6c7bd7858deea686$var$nonLiteralParts.has(p.type)
|
|
305
|
-
).map((p)=>$6c7bd7858deea686$var$escapeRegex(p.value)
|
|
306
|
-
);
|
|
307
|
-
let singularLiterals = singularParts.filter((p)=>!$6c7bd7858deea686$var$nonLiteralParts.has(p.type)
|
|
308
|
-
).map((p)=>$6c7bd7858deea686$var$escapeRegex(p.value)
|
|
309
|
-
);
|
|
310
|
+
let pluralLiterals = allParts.filter((p)=>!$6c7bd7858deea686$var$nonLiteralParts.has(p.type)).map((p)=>$6c7bd7858deea686$var$escapeRegex(p.value));
|
|
311
|
+
let singularLiterals = singularParts.filter((p)=>!$6c7bd7858deea686$var$nonLiteralParts.has(p.type)).map((p)=>$6c7bd7858deea686$var$escapeRegex(p.value));
|
|
310
312
|
let sortedLiterals = [
|
|
311
313
|
...new Set([
|
|
312
314
|
...singularLiterals,
|
|
313
315
|
...pluralLiterals
|
|
314
316
|
])
|
|
315
|
-
].sort((a, b)=>b.length - a.length
|
|
316
|
-
);
|
|
317
|
-
let literals = sortedLiterals.length === 0 ? new RegExp('[\\p{White_Space}]', 'gu') : new RegExp(`${sortedLiterals.join('|')}|[\\p{White_Space}]`, 'gu');
|
|
317
|
+
].sort((a, b)=>b.length - a.length);
|
|
318
|
+
let literals = sortedLiterals.length === 0 ? new RegExp("[\\p{White_Space}]", "gu") : new RegExp(`${sortedLiterals.join("|")}|[\\p{White_Space}]`, "gu");
|
|
318
319
|
// These are for replacing non-latn characters with the latn equivalent
|
|
319
320
|
let numerals = [
|
|
320
321
|
...new Intl.NumberFormat(intlOptions.locale, {
|
|
@@ -324,11 +325,9 @@ function $6c7bd7858deea686$var$getSymbols(formatter, intlOptions, originalOption
|
|
|
324
325
|
let indexes = new Map(numerals.map((d, i)=>[
|
|
325
326
|
d,
|
|
326
327
|
i
|
|
327
|
-
]
|
|
328
|
-
));
|
|
329
|
-
let
|
|
330
|
-
let index = (d)=>String(indexes.get(d))
|
|
331
|
-
;
|
|
328
|
+
]));
|
|
329
|
+
let numeral = new RegExp(`[${numerals.join("")}]`, "g");
|
|
330
|
+
let index = (d)=>String(indexes.get(d));
|
|
332
331
|
return {
|
|
333
332
|
minusSign: minusSign,
|
|
334
333
|
plusSign: plusSign,
|
|
@@ -346,7 +345,7 @@ function $6c7bd7858deea686$var$replaceAll(str, find, replace) {
|
|
|
346
345
|
return str.split(find).join(replace);
|
|
347
346
|
}
|
|
348
347
|
function $6c7bd7858deea686$var$escapeRegex(string) {
|
|
349
|
-
return string.replace(/[-/\\^$*+?.()|[\]{}]/g,
|
|
348
|
+
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
350
349
|
}
|
|
351
350
|
|
|
352
351
|
|
package/dist/module.mjs.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,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,CAA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AAC,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\ninterface NumberRangeFormatPart extends Intl.NumberFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\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 /** Formats a number value as a string, according to the locale and options provided to the constructor. */\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 /** Formats a number to an array of parts such as separators, digits, punctuation, and more. */\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n /** Formats a number range as a string. */\n formatRange(start: number, end: number): string {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRange === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.format(start)} – ${this.format(end)}`;\n }\n\n /** Formats a number range as an array of parts. */\n formatRangeToParts(start: number, end: number): NumberRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.numberFormatter.formatToParts(start);\n let endParts = this.numberFormatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as NumberRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as NumberRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\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 to perform locale-aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. It 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 private locale: string;\n private 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 = sortedLiterals.length === 0 ? \n new RegExp('[\\\\p{White_Space}]', 'gu') :\n 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.mjs.map"}
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAEzB,IAAI,4CAAsB,KAAK;AAC/B,IAAI;IACF,aAAa;IACb,4CAAsB,AAAC,IAAI,KAAK,YAAY,CAAC,SAAS;QAAC,aAAa;IAAY,GAAI,eAAe,GAAG,WAAW,KAAK;AACtH,oCAAoC;AACtC,EAAE,OAAO,GAAG,CAAC;AAEb,IAAI,qCAAe,KAAK;AACxB,IAAI;IACF,aAAa;IACb,qCAAe,AAAC,IAAI,KAAK,YAAY,CAAC,SAAS;QAAC,OAAO;QAAQ,MAAM;IAAQ,GAAI,eAAe,GAAG,KAAK,KAAK;AAC7G,oCAAoC;AACtC,EAAE,OAAO,IAAG,CAAC;AAEb,gHAAgH;AAChH,wGAAwG;AACxG,yEAAyE;AACzE,MAAM,8BAAQ;IACZ,QAAQ;QACN,QAAQ;YACN,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;QAGX;IACF;AACF;AAcO,MAAM;IASX,yGAAyG,GACzG,OAAO,KAAa,EAAU;QAC5B,IAAI,MAAM;QACV,IAAI,CAAC,6CAAuB,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,IAAI,EAC1D,MAAM,0CAAgC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;aAEtF,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;QAGpC,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,UAAU,CAAC,oCAAc;gBAErC;YADb,IAAI,QAAC,KAAI,eAAE,cAAc,kBAAS,OAAM,EAAC,GAAG,IAAI,CAAC,eAAe;YAChE,IAAI,SAAS,CAAA,MAAA,2BAAK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iCAAW,GAAW,EAAE,IAAY,EAAE,OAAe,EAAE;IAC9D,aAAa;IACb,IAAI,IAAI,UAAU,EAChB,aAAa;IACb,OAAO,IAAI,UAAU,CAAC,MAAM;IAG9B,OAAO,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC;AAC9B;AAEA,SAAS,kCAAY,MAAc,EAAE;IACnC,OAAO,OAAO,OAAO,CAAC,yBAAyB;AACjD;","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\ninterface NumberRangeFormatPart extends Intl.NumberFormatPart {\n source: 'startRange' | 'endRange' | 'shared'\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 /** Formats a number value as a string, according to the locale and options provided to the constructor. */\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 /** Formats a number to an array of parts such as separators, digits, punctuation, and more. */\n formatToParts(value: number): Intl.NumberFormatPart[] {\n // TODO: implement signDisplay for formatToParts\n // @ts-ignore\n return this.numberFormatter.formatToParts(value);\n }\n\n /** Formats a number range as a string. */\n formatRange(start: number, end: number): string {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRange === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRange(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n // Very basic fallback for old browsers.\n return `${this.format(start)} – ${this.format(end)}`;\n }\n\n /** Formats a number range as an array of parts. */\n formatRangeToParts(start: number, end: number): NumberRangeFormatPart[] {\n // @ts-ignore\n if (typeof this.numberFormatter.formatRangeToParts === 'function') {\n // @ts-ignore\n return this.numberFormatter.formatRangeToParts(start, end);\n }\n\n if (end < start) {\n throw new RangeError('End date must be >= start date');\n }\n\n let startParts = this.numberFormatter.formatToParts(start);\n let endParts = this.numberFormatter.formatToParts(end);\n return [\n ...startParts.map(p => ({...p, source: 'startRange'} as NumberRangeFormatPart)),\n {type: 'literal', value: ' – ', source: 'shared'},\n ...endParts.map(p => ({...p, source: 'endRange'} as NumberRangeFormatPart))\n ];\n }\n\n /** Returns the resolved formatting options based on the values passed to the constructor. */\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 to perform locale-aware parsing of numbers from Unicode strings,\n * as well as validation of partial user input. It 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 private locale: string;\n private 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 = sortedLiterals.length === 0 ? \n new RegExp('[\\\\p{White_Space}]', 'gu') :\n 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.mjs.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internationalized/number",
|
|
3
|
-
"version": "3.1.2-nightly.
|
|
3
|
+
"version": "3.1.2-nightly.3603+22cb32d32",
|
|
4
4
|
"description": "Internationalized number formatting and parsing utilities",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
25
|
+
"@swc/helpers": "^0.4.14"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "22cb32d329e66c60f55d4fc4025d1d44bb015d71"
|
|
31
31
|
}
|