@internationalized/number 3.0.5 → 3.0.6-nightly.3113

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 CHANGED
@@ -2,8 +2,8 @@ function $parcel$export(e, n, v, s) {
2
2
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3
3
  }
4
4
 
5
- $parcel$export(module.exports, "NumberFormatter", () => $b1fc4c479ca08b67$export$cc77c4ff7e8673c5);
6
- $parcel$export(module.exports, "NumberParser", () => $35c7ec3c204b4757$export$cd11ab140839f11d);
5
+ $parcel$export(module.exports, "NumberFormatter", () => $0c1d5654b62fc485$export$cc77c4ff7e8673c5);
6
+ $parcel$export(module.exports, "NumberParser", () => $d68f3f4c684426c6$export$cd11ab140839f11d);
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
9
9
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -14,20 +14,20 @@ $parcel$export(module.exports, "NumberParser", () => $35c7ec3c204b4757$export$cd
14
14
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
15
  * OF ANY KIND, either express or implied. See the License for the specific language
16
16
  * governing permissions and limitations under the License.
17
- */ let $b1fc4c479ca08b67$var$formatterCache = new Map();
18
- let $b1fc4c479ca08b67$var$supportsSignDisplay = false;
17
+ */ let $0c1d5654b62fc485$var$formatterCache = new Map();
18
+ let $0c1d5654b62fc485$var$supportsSignDisplay = false;
19
19
  try {
20
20
  // @ts-ignore
21
- $b1fc4c479ca08b67$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
21
+ $0c1d5654b62fc485$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
22
22
  signDisplay: 'exceptZero'
23
23
  }).resolvedOptions().signDisplay === 'exceptZero';
24
24
  // eslint-disable-next-line no-empty
25
25
  } catch (e) {
26
26
  }
27
- let $b1fc4c479ca08b67$var$supportsUnit = false;
27
+ let $0c1d5654b62fc485$var$supportsUnit = false;
28
28
  try {
29
29
  // @ts-ignore
30
- $b1fc4c479ca08b67$var$supportsUnit = new Intl.NumberFormat('de-DE', {
30
+ $0c1d5654b62fc485$var$supportsUnit = new Intl.NumberFormat('de-DE', {
31
31
  style: 'unit',
32
32
  unit: 'degree'
33
33
  }).resolvedOptions().style === 'unit';
@@ -37,7 +37,7 @@ try {
37
37
  // Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
38
38
  // Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
39
39
  // Values were determined by switching to each locale manually in Chrome.
40
- const $b1fc4c479ca08b67$var$UNITS = {
40
+ const $0c1d5654b62fc485$var$UNITS = {
41
41
  degree: {
42
42
  narrow: {
43
43
  default: '°',
@@ -47,15 +47,15 @@ const $b1fc4c479ca08b67$var$UNITS = {
47
47
  }
48
48
  }
49
49
  };
50
- class $b1fc4c479ca08b67$export$cc77c4ff7e8673c5 {
50
+ class $0c1d5654b62fc485$export$cc77c4ff7e8673c5 {
51
51
  format(value) {
52
52
  let res = '';
53
- if (!$b1fc4c479ca08b67$var$supportsSignDisplay && this.options.signDisplay != null) res = $b1fc4c479ca08b67$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
53
+ if (!$0c1d5654b62fc485$var$supportsSignDisplay && this.options.signDisplay != null) res = $0c1d5654b62fc485$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
54
54
  else res = this.numberFormatter.format(value);
55
- if (this.options.style === 'unit' && !$b1fc4c479ca08b67$var$supportsUnit) {
55
+ if (this.options.style === 'unit' && !$0c1d5654b62fc485$var$supportsUnit) {
56
56
  var ref;
57
57
  let { unit: unit , unitDisplay: unitDisplay = 'short' , locale: locale } = this.resolvedOptions();
58
- let values = (ref = $b1fc4c479ca08b67$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
58
+ let values = (ref = $0c1d5654b62fc485$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
59
59
  res += values[locale] || values.default;
60
60
  }
61
61
  return res;
@@ -67,11 +67,11 @@ class $b1fc4c479ca08b67$export$cc77c4ff7e8673c5 {
67
67
  }
68
68
  resolvedOptions() {
69
69
  let options = this.numberFormatter.resolvedOptions();
70
- if (!$b1fc4c479ca08b67$var$supportsSignDisplay && this.options.signDisplay != null) options = {
70
+ if (!$0c1d5654b62fc485$var$supportsSignDisplay && this.options.signDisplay != null) options = {
71
71
  ...options,
72
72
  signDisplay: this.options.signDisplay
73
73
  };
74
- if (!$b1fc4c479ca08b67$var$supportsUnit && this.options.style === 'unit') options = {
74
+ if (!$0c1d5654b62fc485$var$supportsUnit && this.options.style === 'unit') options = {
75
75
  ...options,
76
76
  style: 'unit',
77
77
  unit: this.options.unit,
@@ -81,19 +81,19 @@ class $b1fc4c479ca08b67$export$cc77c4ff7e8673c5 {
81
81
  }
82
82
  constructor(locale, options = {
83
83
  }){
84
- this.numberFormatter = $b1fc4c479ca08b67$var$getCachedNumberFormatter(locale, options);
84
+ this.numberFormatter = $0c1d5654b62fc485$var$getCachedNumberFormatter(locale, options);
85
85
  this.options = options;
86
86
  }
87
87
  }
88
- function $b1fc4c479ca08b67$var$getCachedNumberFormatter(locale, options = {
88
+ function $0c1d5654b62fc485$var$getCachedNumberFormatter(locale, options = {
89
89
  }) {
90
90
  let { numberingSystem: numberingSystem } = options;
91
91
  if (numberingSystem && locale.indexOf('-u-nu-') === -1) locale = `${locale}-u-nu-${numberingSystem}`;
92
- if (options.style === 'unit' && !$b1fc4c479ca08b67$var$supportsUnit) {
92
+ if (options.style === 'unit' && !$0c1d5654b62fc485$var$supportsUnit) {
93
93
  var ref;
94
94
  let { unit: unit , unitDisplay: unitDisplay = 'short' } = options;
95
95
  if (!unit) throw new Error('unit option must be provided with style: "unit"');
96
- if (!((ref = $b1fc4c479ca08b67$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
96
+ if (!((ref = $0c1d5654b62fc485$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
97
97
  options = {
98
98
  ...options,
99
99
  style: 'decimal'
@@ -101,12 +101,12 @@ function $b1fc4c479ca08b67$var$getCachedNumberFormatter(locale, options = {
101
101
  }
102
102
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
103
103
  ).join() : '');
104
- if ($b1fc4c479ca08b67$var$formatterCache.has(cacheKey)) return $b1fc4c479ca08b67$var$formatterCache.get(cacheKey);
104
+ if ($0c1d5654b62fc485$var$formatterCache.has(cacheKey)) return $0c1d5654b62fc485$var$formatterCache.get(cacheKey);
105
105
  let numberFormatter = new Intl.NumberFormat(locale, options);
106
- $b1fc4c479ca08b67$var$formatterCache.set(cacheKey, numberFormatter);
106
+ $0c1d5654b62fc485$var$formatterCache.set(cacheKey, numberFormatter);
107
107
  return numberFormatter;
108
108
  }
109
- function $b1fc4c479ca08b67$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
109
+ function $0c1d5654b62fc485$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
110
110
  if (signDisplay === 'auto') return numberFormat.format(num);
111
111
  else if (signDisplay === 'never') return numberFormat.format(Math.abs(num));
112
112
  else {
@@ -131,31 +131,31 @@ function $b1fc4c479ca08b67$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
131
131
  }
132
132
 
133
133
 
134
- const $35c7ec3c204b4757$var$CURRENCY_SIGN_REGEX = new RegExp('^.*\\(.*\\).*$');
135
- const $35c7ec3c204b4757$var$NUMBERING_SYSTEMS = [
134
+ const $d68f3f4c684426c6$var$CURRENCY_SIGN_REGEX = new RegExp('^.*\\(.*\\).*$');
135
+ const $d68f3f4c684426c6$var$NUMBERING_SYSTEMS = [
136
136
  'latn',
137
137
  'arab',
138
138
  'hanidec'
139
139
  ];
140
- class $35c7ec3c204b4757$export$cd11ab140839f11d {
140
+ class $d68f3f4c684426c6$export$cd11ab140839f11d {
141
141
  /**
142
142
  * Parses the given string to a number. Returns NaN if a valid number could not be parsed.
143
143
  */ parse(value) {
144
- return $35c7ec3c204b4757$var$getNumberParserImpl(this.locale, this.options, value).parse(value);
144
+ return $d68f3f4c684426c6$var$getNumberParserImpl(this.locale, this.options, value).parse(value);
145
145
  }
146
146
  /**
147
147
  * Returns whether the given string could potentially be a valid number. This should be used to
148
148
  * validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity
149
149
  * of the minus/plus sign characters can be checked.
150
150
  */ isValidPartialNumber(value, minValue, maxValue) {
151
- return $35c7ec3c204b4757$var$getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);
151
+ return $d68f3f4c684426c6$var$getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);
152
152
  }
153
153
  /**
154
154
  * Returns a numbering system for which the given string is valid in the current locale.
155
155
  * If no numbering system could be detected, the default numbering system for the current
156
156
  * locale is returned.
157
157
  */ getNumberingSystem(value) {
158
- return $35c7ec3c204b4757$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
158
+ return $d68f3f4c684426c6$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
159
159
  }
160
160
  constructor(locale, options = {
161
161
  }){
@@ -163,42 +163,42 @@ class $35c7ec3c204b4757$export$cd11ab140839f11d {
163
163
  this.options = options;
164
164
  }
165
165
  }
166
- const $35c7ec3c204b4757$var$numberParserCache = new Map();
167
- function $35c7ec3c204b4757$var$getNumberParserImpl(locale, options, value) {
166
+ const $d68f3f4c684426c6$var$numberParserCache = new Map();
167
+ function $d68f3f4c684426c6$var$getNumberParserImpl(locale, options, value) {
168
168
  // First try the default numbering system for the provided locale
169
- let defaultParser = $35c7ec3c204b4757$var$getCachedNumberParser(locale, options);
169
+ let defaultParser = $d68f3f4c684426c6$var$getCachedNumberParser(locale, options);
170
170
  // If that doesn't match, and the locale doesn't include a hard coded numbering system,
171
171
  // try each of the other supported numbering systems until we find one that matches.
172
172
  if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {
173
- for (let numberingSystem of $35c7ec3c204b4757$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
174
- let parser = $35c7ec3c204b4757$var$getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);
173
+ for (let numberingSystem of $d68f3f4c684426c6$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
174
+ let parser = $d68f3f4c684426c6$var$getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);
175
175
  if (parser.isValidPartialNumber(value)) return parser;
176
176
  }
177
177
  }
178
178
  return defaultParser;
179
179
  }
180
- function $35c7ec3c204b4757$var$getCachedNumberParser(locale, options) {
180
+ function $d68f3f4c684426c6$var$getCachedNumberParser(locale, options) {
181
181
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
182
182
  ).join() : '');
183
- let parser = $35c7ec3c204b4757$var$numberParserCache.get(cacheKey);
183
+ let parser = $d68f3f4c684426c6$var$numberParserCache.get(cacheKey);
184
184
  if (!parser) {
185
- parser = new $35c7ec3c204b4757$var$NumberParserImpl(locale, options);
186
- $35c7ec3c204b4757$var$numberParserCache.set(cacheKey, parser);
185
+ parser = new $d68f3f4c684426c6$var$NumberParserImpl(locale, options);
186
+ $d68f3f4c684426c6$var$numberParserCache.set(cacheKey, parser);
187
187
  }
188
188
  return parser;
189
189
  }
190
190
  // The actual number parser implementation. Instances of this class are cached
191
191
  // based on the locale, options, and detected numbering system.
192
- class $35c7ec3c204b4757$var$NumberParserImpl {
192
+ class $d68f3f4c684426c6$var$NumberParserImpl {
193
193
  parse(value) {
194
194
  // to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'
195
195
  let fullySanitizedValue = this.sanitize(value);
196
196
  // Remove group characters, and replace decimal points and numerals with ASCII values.
197
- fullySanitizedValue = $35c7ec3c204b4757$var$replaceAll(fullySanitizedValue, this.symbols.group, '').replace(this.symbols.decimal, '.').replace(this.symbols.minusSign, '-').replace(this.symbols.numeral, this.symbols.index);
197
+ fullySanitizedValue = $d68f3f4c684426c6$var$replaceAll(fullySanitizedValue, this.symbols.group, '').replace(this.symbols.decimal, '.').replace(this.symbols.minusSign, '-').replace(this.symbols.numeral, this.symbols.index);
198
198
  let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;
199
199
  if (isNaN(newValue)) return NaN;
200
200
  // accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again
201
- if (this.options.currencySign === 'accounting' && $35c7ec3c204b4757$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
201
+ if (this.options.currencySign === 'accounting' && $d68f3f4c684426c6$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
202
202
  // when reading the number, if it's a percent, then it should be interpreted as being divided by 100
203
203
  if (this.options.style === 'percent') {
204
204
  newValue /= 100;
@@ -219,11 +219,11 @@ class $35c7ec3c204b4757$var$NumberParserImpl {
219
219
  if (this.options.numberingSystem === 'arab') {
220
220
  value = value.replace(',', this.symbols.decimal);
221
221
  value = value.replace(String.fromCharCode(1548), this.symbols.decimal);
222
- value = $35c7ec3c204b4757$var$replaceAll(value, '.', this.symbols.group);
222
+ value = $d68f3f4c684426c6$var$replaceAll(value, '.', this.symbols.group);
223
223
  }
224
224
  // fr-FR group character is char code 8239, but that's not a key on the french keyboard,
225
225
  // so allow 'period' as a group char and replace it with a space
226
- if (this.options.locale === 'fr-FR') value = $35c7ec3c204b4757$var$replaceAll(value, '.', String.fromCharCode(8239));
226
+ if (this.options.locale === 'fr-FR') value = $d68f3f4c684426c6$var$replaceAll(value, '.', String.fromCharCode(8239));
227
227
  return value;
228
228
  }
229
229
  isValidPartialNumber(value, minValue = -Infinity, maxValue = Infinity) {
@@ -234,7 +234,7 @@ class $35c7ec3c204b4757$var$NumberParserImpl {
234
234
  // Numbers cannot start with a group separator
235
235
  if (value.startsWith(this.symbols.group)) return false;
236
236
  // Remove numerals, groups, and decimals
237
- value = $35c7ec3c204b4757$var$replaceAll(value, this.symbols.group, '').replace(this.symbols.numeral, '').replace(this.symbols.decimal, '');
237
+ value = $d68f3f4c684426c6$var$replaceAll(value, this.symbols.group, '').replace(this.symbols.numeral, '').replace(this.symbols.decimal, '');
238
238
  // The number is valid if there are no remaining characters
239
239
  return value.length === 0;
240
240
  }
@@ -242,10 +242,10 @@ class $35c7ec3c204b4757$var$NumberParserImpl {
242
242
  }){
243
243
  this.formatter = new Intl.NumberFormat(locale, options);
244
244
  this.options = this.formatter.resolvedOptions();
245
- this.symbols = $35c7ec3c204b4757$var$getSymbols(this.formatter, this.options, options);
245
+ this.symbols = $d68f3f4c684426c6$var$getSymbols(this.formatter, this.options, options);
246
246
  }
247
247
  }
248
- const $35c7ec3c204b4757$var$nonLiteralParts = new Set([
248
+ const $d68f3f4c684426c6$var$nonLiteralParts = new Set([
249
249
  'decimal',
250
250
  'fraction',
251
251
  'integer',
@@ -253,7 +253,7 @@ const $35c7ec3c204b4757$var$nonLiteralParts = new Set([
253
253
  'plusSign',
254
254
  'group'
255
255
  ]);
256
- function $35c7ec3c204b4757$var$getSymbols(formatter, intlOptions, originalOptions) {
256
+ function $d68f3f4c684426c6$var$getSymbols(formatter, intlOptions, originalOptions) {
257
257
  var ref, ref1, ref2, ref3;
258
258
  // Note: some locale's don't add a group symbol until there is a ten thousands place
259
259
  let allParts = formatter.formatToParts(-10000.111);
@@ -274,11 +274,11 @@ function $35c7ec3c204b4757$var$getSymbols(formatter, intlOptions, originalOption
274
274
  )) === null || ref3 === void 0 ? void 0 : ref3.value;
275
275
  // this set is also for a regex, it's all literals that might be in the string we want to eventually parse that
276
276
  // don't contribute to the numerical value
277
- let pluralLiterals = allParts.filter((p)=>!$35c7ec3c204b4757$var$nonLiteralParts.has(p.type)
278
- ).map((p)=>$35c7ec3c204b4757$var$escapeRegex(p.value)
277
+ let pluralLiterals = allParts.filter((p)=>!$d68f3f4c684426c6$var$nonLiteralParts.has(p.type)
278
+ ).map((p)=>$d68f3f4c684426c6$var$escapeRegex(p.value)
279
279
  );
280
- let singularLiterals = singularParts.filter((p)=>!$35c7ec3c204b4757$var$nonLiteralParts.has(p.type)
281
- ).map((p)=>$35c7ec3c204b4757$var$escapeRegex(p.value)
280
+ let singularLiterals = singularParts.filter((p)=>!$d68f3f4c684426c6$var$nonLiteralParts.has(p.type)
281
+ ).map((p)=>$d68f3f4c684426c6$var$escapeRegex(p.value)
282
282
  );
283
283
  let sortedLiterals = [
284
284
  ...new Set([
@@ -312,13 +312,13 @@ function $35c7ec3c204b4757$var$getSymbols(formatter, intlOptions, originalOption
312
312
  index: index
313
313
  };
314
314
  }
315
- function $35c7ec3c204b4757$var$replaceAll(str, find, replace) {
315
+ function $d68f3f4c684426c6$var$replaceAll(str, find, replace) {
316
316
  // @ts-ignore
317
317
  if (str.replaceAll) // @ts-ignore
318
318
  return str.replaceAll(find, replace);
319
319
  return str.split(find).join(replace);
320
320
  }
321
- function $35c7ec3c204b4757$var$escapeRegex(string) {
321
+ function $d68f3f4c684426c6$var$escapeRegex(string) {
322
322
  return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
323
323
  }
324
324
 
package/dist/module.js CHANGED
@@ -8,20 +8,20 @@
8
8
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
- */ let $81812865b3bb9d70$var$formatterCache = new Map();
12
- let $81812865b3bb9d70$var$supportsSignDisplay = false;
11
+ */ let $488c6ddbf4ef74c2$var$formatterCache = new Map();
12
+ let $488c6ddbf4ef74c2$var$supportsSignDisplay = false;
13
13
  try {
14
14
  // @ts-ignore
15
- $81812865b3bb9d70$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
15
+ $488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
16
16
  signDisplay: 'exceptZero'
17
17
  }).resolvedOptions().signDisplay === 'exceptZero';
18
18
  // eslint-disable-next-line no-empty
19
19
  } catch (e) {
20
20
  }
21
- let $81812865b3bb9d70$var$supportsUnit = false;
21
+ let $488c6ddbf4ef74c2$var$supportsUnit = false;
22
22
  try {
23
23
  // @ts-ignore
24
- $81812865b3bb9d70$var$supportsUnit = new Intl.NumberFormat('de-DE', {
24
+ $488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat('de-DE', {
25
25
  style: 'unit',
26
26
  unit: 'degree'
27
27
  }).resolvedOptions().style === 'unit';
@@ -31,7 +31,7 @@ try {
31
31
  // Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
32
32
  // Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
33
33
  // Values were determined by switching to each locale manually in Chrome.
34
- const $81812865b3bb9d70$var$UNITS = {
34
+ const $488c6ddbf4ef74c2$var$UNITS = {
35
35
  degree: {
36
36
  narrow: {
37
37
  default: '°',
@@ -41,15 +41,15 @@ const $81812865b3bb9d70$var$UNITS = {
41
41
  }
42
42
  }
43
43
  };
44
- class $81812865b3bb9d70$export$cc77c4ff7e8673c5 {
44
+ class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
45
45
  format(value) {
46
46
  let res = '';
47
- if (!$81812865b3bb9d70$var$supportsSignDisplay && this.options.signDisplay != null) res = $81812865b3bb9d70$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
47
+ if (!$488c6ddbf4ef74c2$var$supportsSignDisplay && this.options.signDisplay != null) res = $488c6ddbf4ef74c2$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
48
48
  else res = this.numberFormatter.format(value);
49
- if (this.options.style === 'unit' && !$81812865b3bb9d70$var$supportsUnit) {
49
+ if (this.options.style === 'unit' && !$488c6ddbf4ef74c2$var$supportsUnit) {
50
50
  var ref;
51
51
  let { unit: unit , unitDisplay: unitDisplay = 'short' , locale: locale } = this.resolvedOptions();
52
- let values = (ref = $81812865b3bb9d70$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
52
+ let values = (ref = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay];
53
53
  res += values[locale] || values.default;
54
54
  }
55
55
  return res;
@@ -61,11 +61,11 @@ class $81812865b3bb9d70$export$cc77c4ff7e8673c5 {
61
61
  }
62
62
  resolvedOptions() {
63
63
  let options = this.numberFormatter.resolvedOptions();
64
- if (!$81812865b3bb9d70$var$supportsSignDisplay && this.options.signDisplay != null) options = {
64
+ if (!$488c6ddbf4ef74c2$var$supportsSignDisplay && this.options.signDisplay != null) options = {
65
65
  ...options,
66
66
  signDisplay: this.options.signDisplay
67
67
  };
68
- if (!$81812865b3bb9d70$var$supportsUnit && this.options.style === 'unit') options = {
68
+ if (!$488c6ddbf4ef74c2$var$supportsUnit && this.options.style === 'unit') options = {
69
69
  ...options,
70
70
  style: 'unit',
71
71
  unit: this.options.unit,
@@ -75,19 +75,19 @@ class $81812865b3bb9d70$export$cc77c4ff7e8673c5 {
75
75
  }
76
76
  constructor(locale, options = {
77
77
  }){
78
- this.numberFormatter = $81812865b3bb9d70$var$getCachedNumberFormatter(locale, options);
78
+ this.numberFormatter = $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options);
79
79
  this.options = options;
80
80
  }
81
81
  }
82
- function $81812865b3bb9d70$var$getCachedNumberFormatter(locale, options = {
82
+ function $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options = {
83
83
  }) {
84
84
  let { numberingSystem: numberingSystem } = options;
85
85
  if (numberingSystem && locale.indexOf('-u-nu-') === -1) locale = `${locale}-u-nu-${numberingSystem}`;
86
- if (options.style === 'unit' && !$81812865b3bb9d70$var$supportsUnit) {
86
+ if (options.style === 'unit' && !$488c6ddbf4ef74c2$var$supportsUnit) {
87
87
  var ref;
88
88
  let { unit: unit , unitDisplay: unitDisplay = 'short' } = options;
89
89
  if (!unit) throw new Error('unit option must be provided with style: "unit"');
90
- if (!((ref = $81812865b3bb9d70$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
90
+ if (!((ref = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || ref === void 0 ? void 0 : ref[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
91
91
  options = {
92
92
  ...options,
93
93
  style: 'decimal'
@@ -95,12 +95,12 @@ function $81812865b3bb9d70$var$getCachedNumberFormatter(locale, options = {
95
95
  }
96
96
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
97
97
  ).join() : '');
98
- if ($81812865b3bb9d70$var$formatterCache.has(cacheKey)) return $81812865b3bb9d70$var$formatterCache.get(cacheKey);
98
+ if ($488c6ddbf4ef74c2$var$formatterCache.has(cacheKey)) return $488c6ddbf4ef74c2$var$formatterCache.get(cacheKey);
99
99
  let numberFormatter = new Intl.NumberFormat(locale, options);
100
- $81812865b3bb9d70$var$formatterCache.set(cacheKey, numberFormatter);
100
+ $488c6ddbf4ef74c2$var$formatterCache.set(cacheKey, numberFormatter);
101
101
  return numberFormatter;
102
102
  }
103
- function $81812865b3bb9d70$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
103
+ function $488c6ddbf4ef74c2$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
104
104
  if (signDisplay === 'auto') return numberFormat.format(num);
105
105
  else if (signDisplay === 'never') return numberFormat.format(Math.abs(num));
106
106
  else {
@@ -125,31 +125,31 @@ function $81812865b3bb9d70$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
125
125
  }
126
126
 
127
127
 
128
- const $ad41ad2a9f71fc3e$var$CURRENCY_SIGN_REGEX = new RegExp('^.*\\(.*\\).*$');
129
- const $ad41ad2a9f71fc3e$var$NUMBERING_SYSTEMS = [
128
+ const $6c7bd7858deea686$var$CURRENCY_SIGN_REGEX = new RegExp('^.*\\(.*\\).*$');
129
+ const $6c7bd7858deea686$var$NUMBERING_SYSTEMS = [
130
130
  'latn',
131
131
  'arab',
132
132
  'hanidec'
133
133
  ];
134
- class $ad41ad2a9f71fc3e$export$cd11ab140839f11d {
134
+ class $6c7bd7858deea686$export$cd11ab140839f11d {
135
135
  /**
136
136
  * Parses the given string to a number. Returns NaN if a valid number could not be parsed.
137
137
  */ parse(value) {
138
- return $ad41ad2a9f71fc3e$var$getNumberParserImpl(this.locale, this.options, value).parse(value);
138
+ return $6c7bd7858deea686$var$getNumberParserImpl(this.locale, this.options, value).parse(value);
139
139
  }
140
140
  /**
141
141
  * Returns whether the given string could potentially be a valid number. This should be used to
142
142
  * validate user input as the user types. If a `minValue` or `maxValue` is provided, the validity
143
143
  * of the minus/plus sign characters can be checked.
144
144
  */ isValidPartialNumber(value, minValue, maxValue) {
145
- return $ad41ad2a9f71fc3e$var$getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);
145
+ return $6c7bd7858deea686$var$getNumberParserImpl(this.locale, this.options, value).isValidPartialNumber(value, minValue, maxValue);
146
146
  }
147
147
  /**
148
148
  * Returns a numbering system for which the given string is valid in the current locale.
149
149
  * If no numbering system could be detected, the default numbering system for the current
150
150
  * locale is returned.
151
151
  */ getNumberingSystem(value) {
152
- return $ad41ad2a9f71fc3e$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
152
+ return $6c7bd7858deea686$var$getNumberParserImpl(this.locale, this.options, value).options.numberingSystem;
153
153
  }
154
154
  constructor(locale, options = {
155
155
  }){
@@ -157,42 +157,42 @@ class $ad41ad2a9f71fc3e$export$cd11ab140839f11d {
157
157
  this.options = options;
158
158
  }
159
159
  }
160
- const $ad41ad2a9f71fc3e$var$numberParserCache = new Map();
161
- function $ad41ad2a9f71fc3e$var$getNumberParserImpl(locale, options, value) {
160
+ const $6c7bd7858deea686$var$numberParserCache = new Map();
161
+ function $6c7bd7858deea686$var$getNumberParserImpl(locale, options, value) {
162
162
  // First try the default numbering system for the provided locale
163
- let defaultParser = $ad41ad2a9f71fc3e$var$getCachedNumberParser(locale, options);
163
+ let defaultParser = $6c7bd7858deea686$var$getCachedNumberParser(locale, options);
164
164
  // If that doesn't match, and the locale doesn't include a hard coded numbering system,
165
165
  // try each of the other supported numbering systems until we find one that matches.
166
166
  if (!locale.includes('-nu-') && !defaultParser.isValidPartialNumber(value)) {
167
- for (let numberingSystem of $ad41ad2a9f71fc3e$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
168
- let parser = $ad41ad2a9f71fc3e$var$getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);
167
+ for (let numberingSystem of $6c7bd7858deea686$var$NUMBERING_SYSTEMS)if (numberingSystem !== defaultParser.options.numberingSystem) {
168
+ let parser = $6c7bd7858deea686$var$getCachedNumberParser(locale + (locale.includes('-u-') ? '-nu-' : '-u-nu-') + numberingSystem, options);
169
169
  if (parser.isValidPartialNumber(value)) return parser;
170
170
  }
171
171
  }
172
172
  return defaultParser;
173
173
  }
174
- function $ad41ad2a9f71fc3e$var$getCachedNumberParser(locale, options) {
174
+ function $6c7bd7858deea686$var$getCachedNumberParser(locale, options) {
175
175
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
176
176
  ).join() : '');
177
- let parser = $ad41ad2a9f71fc3e$var$numberParserCache.get(cacheKey);
177
+ let parser = $6c7bd7858deea686$var$numberParserCache.get(cacheKey);
178
178
  if (!parser) {
179
- parser = new $ad41ad2a9f71fc3e$var$NumberParserImpl(locale, options);
180
- $ad41ad2a9f71fc3e$var$numberParserCache.set(cacheKey, parser);
179
+ parser = new $6c7bd7858deea686$var$NumberParserImpl(locale, options);
180
+ $6c7bd7858deea686$var$numberParserCache.set(cacheKey, parser);
181
181
  }
182
182
  return parser;
183
183
  }
184
184
  // The actual number parser implementation. Instances of this class are cached
185
185
  // based on the locale, options, and detected numbering system.
186
- class $ad41ad2a9f71fc3e$var$NumberParserImpl {
186
+ class $6c7bd7858deea686$var$NumberParserImpl {
187
187
  parse(value) {
188
188
  // to parse the number, we need to remove anything that isn't actually part of the number, for example we want '-10.40' not '-10.40 USD'
189
189
  let fullySanitizedValue = this.sanitize(value);
190
190
  // Remove group characters, and replace decimal points and numerals with ASCII values.
191
- fullySanitizedValue = $ad41ad2a9f71fc3e$var$replaceAll(fullySanitizedValue, this.symbols.group, '').replace(this.symbols.decimal, '.').replace(this.symbols.minusSign, '-').replace(this.symbols.numeral, this.symbols.index);
191
+ fullySanitizedValue = $6c7bd7858deea686$var$replaceAll(fullySanitizedValue, this.symbols.group, '').replace(this.symbols.decimal, '.').replace(this.symbols.minusSign, '-').replace(this.symbols.numeral, this.symbols.index);
192
192
  let newValue = fullySanitizedValue ? +fullySanitizedValue : NaN;
193
193
  if (isNaN(newValue)) return NaN;
194
194
  // accounting will always be stripped to a positive number, so if it's accounting and has a () around everything, then we need to make it negative again
195
- if (this.options.currencySign === 'accounting' && $ad41ad2a9f71fc3e$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
195
+ if (this.options.currencySign === 'accounting' && $6c7bd7858deea686$var$CURRENCY_SIGN_REGEX.test(value)) newValue = -1 * newValue;
196
196
  // when reading the number, if it's a percent, then it should be interpreted as being divided by 100
197
197
  if (this.options.style === 'percent') {
198
198
  newValue /= 100;
@@ -213,11 +213,11 @@ class $ad41ad2a9f71fc3e$var$NumberParserImpl {
213
213
  if (this.options.numberingSystem === 'arab') {
214
214
  value = value.replace(',', this.symbols.decimal);
215
215
  value = value.replace(String.fromCharCode(1548), this.symbols.decimal);
216
- value = $ad41ad2a9f71fc3e$var$replaceAll(value, '.', this.symbols.group);
216
+ value = $6c7bd7858deea686$var$replaceAll(value, '.', this.symbols.group);
217
217
  }
218
218
  // fr-FR group character is char code 8239, but that's not a key on the french keyboard,
219
219
  // so allow 'period' as a group char and replace it with a space
220
- if (this.options.locale === 'fr-FR') value = $ad41ad2a9f71fc3e$var$replaceAll(value, '.', String.fromCharCode(8239));
220
+ if (this.options.locale === 'fr-FR') value = $6c7bd7858deea686$var$replaceAll(value, '.', String.fromCharCode(8239));
221
221
  return value;
222
222
  }
223
223
  isValidPartialNumber(value, minValue = -Infinity, maxValue = Infinity) {
@@ -228,7 +228,7 @@ class $ad41ad2a9f71fc3e$var$NumberParserImpl {
228
228
  // Numbers cannot start with a group separator
229
229
  if (value.startsWith(this.symbols.group)) return false;
230
230
  // Remove numerals, groups, and decimals
231
- value = $ad41ad2a9f71fc3e$var$replaceAll(value, this.symbols.group, '').replace(this.symbols.numeral, '').replace(this.symbols.decimal, '');
231
+ value = $6c7bd7858deea686$var$replaceAll(value, this.symbols.group, '').replace(this.symbols.numeral, '').replace(this.symbols.decimal, '');
232
232
  // The number is valid if there are no remaining characters
233
233
  return value.length === 0;
234
234
  }
@@ -236,10 +236,10 @@ class $ad41ad2a9f71fc3e$var$NumberParserImpl {
236
236
  }){
237
237
  this.formatter = new Intl.NumberFormat(locale, options);
238
238
  this.options = this.formatter.resolvedOptions();
239
- this.symbols = $ad41ad2a9f71fc3e$var$getSymbols(this.formatter, this.options, options);
239
+ this.symbols = $6c7bd7858deea686$var$getSymbols(this.formatter, this.options, options);
240
240
  }
241
241
  }
242
- const $ad41ad2a9f71fc3e$var$nonLiteralParts = new Set([
242
+ const $6c7bd7858deea686$var$nonLiteralParts = new Set([
243
243
  'decimal',
244
244
  'fraction',
245
245
  'integer',
@@ -247,7 +247,7 @@ const $ad41ad2a9f71fc3e$var$nonLiteralParts = new Set([
247
247
  'plusSign',
248
248
  'group'
249
249
  ]);
250
- function $ad41ad2a9f71fc3e$var$getSymbols(formatter, intlOptions, originalOptions) {
250
+ function $6c7bd7858deea686$var$getSymbols(formatter, intlOptions, originalOptions) {
251
251
  var ref, ref1, ref2, ref3;
252
252
  // Note: some locale's don't add a group symbol until there is a ten thousands place
253
253
  let allParts = formatter.formatToParts(-10000.111);
@@ -268,11 +268,11 @@ function $ad41ad2a9f71fc3e$var$getSymbols(formatter, intlOptions, originalOption
268
268
  )) === null || ref3 === void 0 ? void 0 : ref3.value;
269
269
  // this set is also for a regex, it's all literals that might be in the string we want to eventually parse that
270
270
  // don't contribute to the numerical value
271
- let pluralLiterals = allParts.filter((p)=>!$ad41ad2a9f71fc3e$var$nonLiteralParts.has(p.type)
272
- ).map((p)=>$ad41ad2a9f71fc3e$var$escapeRegex(p.value)
271
+ let pluralLiterals = allParts.filter((p)=>!$6c7bd7858deea686$var$nonLiteralParts.has(p.type)
272
+ ).map((p)=>$6c7bd7858deea686$var$escapeRegex(p.value)
273
273
  );
274
- let singularLiterals = singularParts.filter((p)=>!$ad41ad2a9f71fc3e$var$nonLiteralParts.has(p.type)
275
- ).map((p)=>$ad41ad2a9f71fc3e$var$escapeRegex(p.value)
274
+ let singularLiterals = singularParts.filter((p)=>!$6c7bd7858deea686$var$nonLiteralParts.has(p.type)
275
+ ).map((p)=>$6c7bd7858deea686$var$escapeRegex(p.value)
276
276
  );
277
277
  let sortedLiterals = [
278
278
  ...new Set([
@@ -306,18 +306,18 @@ function $ad41ad2a9f71fc3e$var$getSymbols(formatter, intlOptions, originalOption
306
306
  index: index
307
307
  };
308
308
  }
309
- function $ad41ad2a9f71fc3e$var$replaceAll(str, find, replace) {
309
+ function $6c7bd7858deea686$var$replaceAll(str, find, replace) {
310
310
  // @ts-ignore
311
311
  if (str.replaceAll) // @ts-ignore
312
312
  return str.replaceAll(find, replace);
313
313
  return str.split(find).join(replace);
314
314
  }
315
- function $ad41ad2a9f71fc3e$var$escapeRegex(string) {
315
+ function $6c7bd7858deea686$var$escapeRegex(string) {
316
316
  return string.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
317
317
  }
318
318
 
319
319
 
320
320
 
321
321
 
322
- export {$81812865b3bb9d70$export$cc77c4ff7e8673c5 as NumberFormatter, $ad41ad2a9f71fc3e$export$cd11ab140839f11d as NumberParser};
322
+ export {$488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 as NumberFormatter, $6c7bd7858deea686$export$cd11ab140839f11d as NumberParser};
323
323
  //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internationalized/number",
3
- "version": "3.0.5",
3
+ "version": "3.0.6-nightly.3113+404d41859",
4
4
  "description": "Internationalized number formatting and parsing utilities",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",