@internationalized/number 3.6.5 → 3.6.7

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.
Files changed (30) hide show
  1. package/dist/{main.js → index.cjs} +5 -5
  2. package/dist/{main.js.map → index.cjs.map} +1 -1
  3. package/dist/{import.mjs → index.js} +4 -4
  4. package/dist/{module.js.map → index.js.map} +1 -1
  5. package/dist/{module.js → index.mjs} +4 -4
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/{NumberFormatter.main.js → private/NumberFormatter.cjs} +28 -27
  8. package/dist/private/NumberFormatter.cjs.map +1 -0
  9. package/dist/{NumberFormatter.mjs → private/NumberFormatter.js} +25 -22
  10. package/dist/private/NumberFormatter.js.map +1 -0
  11. package/dist/{NumberFormatter.module.js → private/NumberFormatter.mjs} +28 -27
  12. package/dist/private/NumberFormatter.mjs.map +1 -0
  13. package/dist/{NumberParser.main.js → private/NumberParser.cjs} +94 -79
  14. package/dist/private/NumberParser.cjs.map +1 -0
  15. package/dist/{NumberParser.mjs → private/NumberParser.js} +67 -48
  16. package/dist/private/NumberParser.js.map +1 -0
  17. package/dist/{NumberParser.module.js → private/NumberParser.mjs} +94 -79
  18. package/dist/private/NumberParser.mjs.map +1 -0
  19. package/dist/types/src/NumberFormatter.d.ts +32 -0
  20. package/dist/types/src/NumberParser.d.ts +27 -0
  21. package/dist/types/src/index.d.ts +3 -0
  22. package/package.json +33 -18
  23. package/src/NumberFormatter.ts +39 -13
  24. package/src/NumberParser.ts +139 -52
  25. package/dist/NumberFormatter.main.js.map +0 -1
  26. package/dist/NumberFormatter.module.js.map +0 -1
  27. package/dist/NumberParser.main.js.map +0 -1
  28. package/dist/NumberParser.module.js.map +0 -1
  29. package/dist/types.d.ts +0 -50
  30. package/dist/types.d.ts.map +0 -1
@@ -1,13 +1,13 @@
1
- var $0c1d5654b62fc485$exports = require("./NumberFormatter.main.js");
2
- var $d68f3f4c684426c6$exports = require("./NumberParser.main.js");
1
+ var $7fe67f77592add0a$exports = require("./private/NumberFormatter.cjs");
2
+ var $52ebab2a875d5a2c$exports = require("./private/NumberParser.cjs");
3
3
 
4
4
 
5
5
  function $parcel$export(e, n, v, s) {
6
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
7
  }
8
8
 
9
- $parcel$export(module.exports, "NumberFormatter", () => $0c1d5654b62fc485$exports.NumberFormatter);
10
- $parcel$export(module.exports, "NumberParser", () => $d68f3f4c684426c6$exports.NumberParser);
9
+ $parcel$export(module.exports, "NumberFormatter", function () { return $7fe67f77592add0a$exports.NumberFormatter; });
10
+ $parcel$export(module.exports, "NumberParser", function () { return $52ebab2a875d5a2c$exports.NumberParser; });
11
11
  /*
12
12
  * Copyright 2020 Adobe. All rights reserved.
13
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -22,4 +22,4 @@ $parcel$export(module.exports, "NumberParser", () => $d68f3f4c684426c6$exports.N
22
22
 
23
23
 
24
24
 
25
- //# sourceMappingURL=main.js.map
25
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/number/src/index.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"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/number/src/index.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"],"names":[],"version":3,"file":"index.cjs.map"}
@@ -1,5 +1,5 @@
1
- import {NumberFormatter as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5} from "./NumberFormatter.mjs";
2
- import {NumberParser as $6c7bd7858deea686$export$cd11ab140839f11d} from "./NumberParser.mjs";
1
+ import {NumberFormatter as $6c0bb0183c96ba81$export$cc77c4ff7e8673c5} from "./private/NumberFormatter.js";
2
+ import {NumberParser as $8f9e7ac92b21e8dd$export$cd11ab140839f11d} from "./private/NumberParser.js";
3
3
 
4
4
  /*
5
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,5 +15,5 @@ import {NumberParser as $6c7bd7858deea686$export$cd11ab140839f11d} from "./Numbe
15
15
 
16
16
 
17
17
 
18
- export {$488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 as NumberFormatter, $6c7bd7858deea686$export$cd11ab140839f11d as NumberParser};
19
- //# sourceMappingURL=module.js.map
18
+ export {$6c0bb0183c96ba81$export$cc77c4ff7e8673c5 as NumberFormatter, $8f9e7ac92b21e8dd$export$cd11ab140839f11d as NumberParser};
19
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/number/src/index.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"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/number/src/index.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"],"names":[],"version":3,"file":"index.js.map"}
@@ -1,5 +1,5 @@
1
- import {NumberFormatter as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5} from "./NumberFormatter.module.js";
2
- import {NumberParser as $6c7bd7858deea686$export$cd11ab140839f11d} from "./NumberParser.module.js";
1
+ import {NumberFormatter as $1dfb119a85e764e5$export$cc77c4ff7e8673c5} from "./private/NumberFormatter.mjs";
2
+ import {NumberParser as $eb76cf4feb040f77$export$cd11ab140839f11d} from "./private/NumberParser.mjs";
3
3
 
4
4
  /*
5
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,5 +15,5 @@ import {NumberParser as $6c7bd7858deea686$export$cd11ab140839f11d} from "./Numbe
15
15
 
16
16
 
17
17
 
18
- export {$488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 as NumberFormatter, $6c7bd7858deea686$export$cd11ab140839f11d as NumberParser};
19
- //# sourceMappingURL=module.js.map
18
+ export {$1dfb119a85e764e5$export$cc77c4ff7e8673c5 as NumberFormatter, $eb76cf4feb040f77$export$cd11ab140839f11d as NumberParser};
19
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/number/src/index.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"],"names":[],"version":3,"file":"index.mjs.map"}
@@ -3,7 +3,7 @@ function $parcel$export(e, n, v, s) {
3
3
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
4
  }
5
5
 
6
- $parcel$export(module.exports, "NumberFormatter", () => $0c1d5654b62fc485$export$cc77c4ff7e8673c5);
6
+ $parcel$export(module.exports, "NumberFormatter", function () { return $7fe67f77592add0a$export$cc77c4ff7e8673c5; });
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,17 +14,17 @@ $parcel$export(module.exports, "NumberFormatter", () => $0c1d5654b62fc485$export
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 $0c1d5654b62fc485$var$formatterCache = new Map();
18
- let $0c1d5654b62fc485$var$supportsSignDisplay = false;
17
+ */ let $7fe67f77592add0a$var$formatterCache = new Map();
18
+ let $7fe67f77592add0a$var$supportsSignDisplay = false;
19
19
  try {
20
- $0c1d5654b62fc485$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
20
+ $7fe67f77592add0a$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
21
21
  signDisplay: 'exceptZero'
22
22
  }).resolvedOptions().signDisplay === 'exceptZero';
23
23
  // eslint-disable-next-line no-empty
24
24
  } catch {}
25
- let $0c1d5654b62fc485$var$supportsUnit = false;
25
+ let $7fe67f77592add0a$var$supportsUnit = false;
26
26
  try {
27
- $0c1d5654b62fc485$var$supportsUnit = new Intl.NumberFormat('de-DE', {
27
+ $7fe67f77592add0a$var$supportsUnit = new Intl.NumberFormat('de-DE', {
28
28
  style: 'unit',
29
29
  unit: 'degree'
30
30
  }).resolvedOptions().style === 'unit';
@@ -33,7 +33,7 @@ try {
33
33
  // Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
34
34
  // Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
35
35
  // Values were determined by switching to each locale manually in Chrome.
36
- const $0c1d5654b62fc485$var$UNITS = {
36
+ const $7fe67f77592add0a$var$UNITS = {
37
37
  degree: {
38
38
  narrow: {
39
39
  default: "\xb0",
@@ -43,16 +43,22 @@ const $0c1d5654b62fc485$var$UNITS = {
43
43
  }
44
44
  }
45
45
  };
46
- class $0c1d5654b62fc485$export$cc77c4ff7e8673c5 {
47
- /** Formats a number value as a string, according to the locale and options provided to the constructor. */ format(value) {
46
+ class $7fe67f77592add0a$export$cc77c4ff7e8673c5 {
47
+ constructor(locale, options = {}){
48
+ this.numberFormatter = $7fe67f77592add0a$var$getCachedNumberFormatter(locale, options);
49
+ this.options = options;
50
+ }
51
+ /**
52
+ * Formats a number value as a string, according to the locale and options provided to the
53
+ * constructor.
54
+ */ format(value) {
48
55
  let res = '';
49
- if (!$0c1d5654b62fc485$var$supportsSignDisplay && this.options.signDisplay != null) res = $0c1d5654b62fc485$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
56
+ if (!$7fe67f77592add0a$var$supportsSignDisplay && this.options.signDisplay != null) res = $7fe67f77592add0a$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
50
57
  else res = this.numberFormatter.format(value);
51
- if (this.options.style === 'unit' && !$0c1d5654b62fc485$var$supportsUnit) {
52
- var _UNITS_unit;
58
+ if (this.options.style === 'unit' && !$7fe67f77592add0a$var$supportsUnit) {
53
59
  let { unit: unit, unitDisplay: unitDisplay = 'short', locale: locale } = this.resolvedOptions();
54
60
  if (!unit) return res;
55
- let values = (_UNITS_unit = $0c1d5654b62fc485$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay];
61
+ let values = $7fe67f77592add0a$var$UNITS[unit]?.[unitDisplay];
56
62
  res += values[locale] || values.default;
57
63
  }
58
64
  return res;
@@ -90,11 +96,11 @@ class $0c1d5654b62fc485$export$cc77c4ff7e8673c5 {
90
96
  }
91
97
  /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
92
98
  let options = this.numberFormatter.resolvedOptions();
93
- if (!$0c1d5654b62fc485$var$supportsSignDisplay && this.options.signDisplay != null) options = {
99
+ if (!$7fe67f77592add0a$var$supportsSignDisplay && this.options.signDisplay != null) options = {
94
100
  ...options,
95
101
  signDisplay: this.options.signDisplay
96
102
  };
97
- if (!$0c1d5654b62fc485$var$supportsUnit && this.options.style === 'unit') options = {
103
+ if (!$7fe67f77592add0a$var$supportsUnit && this.options.style === 'unit') options = {
98
104
  ...options,
99
105
  style: 'unit',
100
106
  unit: this.options.unit,
@@ -102,34 +108,29 @@ class $0c1d5654b62fc485$export$cc77c4ff7e8673c5 {
102
108
  };
103
109
  return options;
104
110
  }
105
- constructor(locale, options = {}){
106
- this.numberFormatter = $0c1d5654b62fc485$var$getCachedNumberFormatter(locale, options);
107
- this.options = options;
108
- }
109
111
  }
110
- function $0c1d5654b62fc485$var$getCachedNumberFormatter(locale, options = {}) {
112
+ function $7fe67f77592add0a$var$getCachedNumberFormatter(locale, options = {}) {
111
113
  let { numberingSystem: numberingSystem } = options;
112
114
  if (numberingSystem && locale.includes('-nu-')) {
113
115
  if (!locale.includes('-u-')) locale += '-u-';
114
116
  locale += `-nu-${numberingSystem}`;
115
117
  }
116
- if (options.style === 'unit' && !$0c1d5654b62fc485$var$supportsUnit) {
117
- var _UNITS_unit;
118
+ if (options.style === 'unit' && !$7fe67f77592add0a$var$supportsUnit) {
118
119
  let { unit: unit, unitDisplay: unitDisplay = 'short' } = options;
119
120
  if (!unit) throw new Error('unit option must be provided with style: "unit"');
120
- if (!((_UNITS_unit = $0c1d5654b62fc485$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
121
+ if (!$7fe67f77592add0a$var$UNITS[unit]?.[unitDisplay]) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
121
122
  options = {
122
123
  ...options,
123
124
  style: 'decimal'
124
125
  };
125
126
  }
126
127
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
127
- if ($0c1d5654b62fc485$var$formatterCache.has(cacheKey)) return $0c1d5654b62fc485$var$formatterCache.get(cacheKey);
128
+ if ($7fe67f77592add0a$var$formatterCache.has(cacheKey)) return $7fe67f77592add0a$var$formatterCache.get(cacheKey);
128
129
  let numberFormatter = new Intl.NumberFormat(locale, options);
129
- $0c1d5654b62fc485$var$formatterCache.set(cacheKey, numberFormatter);
130
+ $7fe67f77592add0a$var$formatterCache.set(cacheKey, numberFormatter);
130
131
  return numberFormatter;
131
132
  }
132
- function $0c1d5654b62fc485$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
133
+ function $7fe67f77592add0a$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
133
134
  if (signDisplay === 'auto') return numberFormat.format(num);
134
135
  else if (signDisplay === 'never') return numberFormat.format(Math.abs(num));
135
136
  else {
@@ -154,4 +155,4 @@ function $0c1d5654b62fc485$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
154
155
  }
155
156
 
156
157
 
157
- //# sourceMappingURL=NumberFormatter.main.js.map
158
+ //# sourceMappingURL=NumberFormatter.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAEzB,IAAI,4CAAsB;AAC1B,IAAI;IACF,4CACE,IAAI,KAAK,YAAY,CAAC,SAAS;QAAC,aAAa;IAAY,GAAG,eAAe,GAAG,WAAW,KACzF;AACF,oCAAoC;AACtC,EAAE,OAAM,CAAC;AAET,IAAI,qCAAe;AACnB,IAAI;IACF,qCACE,IAAI,KAAK,YAAY,CAAC,SAAS;QAAC,OAAO;QAAQ,MAAM;IAAQ,GAAG,eAAe,GAAG,KAAK,KACvF;AACF,oCAAoC;AACtC,EAAE,OAAM,CAAC;AAET,gHAAgH;AAChH,wGAAwG;AACxG,yEAAyE;AACzE,MAAM,8BAAQ;IACZ,QAAQ;QACN,QAAQ;YACN,SAAS;YACT,SAAS;YACT,SAAS;YACT,SAAS;QAGX;IACF;AACF;AAeO,MAAM;IAIX,YAAY,MAAc,EAAE,UAA+B,CAAC,CAAC,CAAE;QAC7D,IAAI,CAAC,eAAe,GAAG,+CAAyB,QAAQ;QACxD,IAAI,CAAC,OAAO,GAAG;IACjB;IAEA;;;GAGC,GACD,OAAO,KAAa,EAAU;QAC5B,IAAI,MAAM;QACV,IAAI,CAAC,6CAAuB,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,MACtD,MAAM,0CAAgC,IAAI,CAAC,eAAe,EAAE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AAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,GACnC,IAAI,KACP,EAAC;IACP,IAAI,qCAAe,GAAG,CAAC,WACrB,OAAO,qCAAe,GAAG,CAAC;IAG5B,IAAI,kBAAkB,IAAI,KAAK,YAAY,CAAC,QAAQ;IACpD,qCAAe,GAAG,CAAC,UAAU;IAC7B,OAAO;AACT;AAGO,SAAS,0CACd,YAA+B,EAC/B,WAAmB,EACnB,GAAW;IAEX,IAAI,gBAAgB,QAClB,OAAO,aAAa,MAAM,CAAC;SACtB,IAAI,gBAAgB,SACzB,OAAO,aAAa,MAAM,CAAC,KAAK,GAAG,CAAC;SAC/B;QACL,IAAI,oBAAoB;QACxB,IAAI,gBAAgB,UAClB,oBAAoB,MAAM,KAAK,OAAO,EAAE,CAAC,KAAK;aACzC,IAAI,gBAAgB;YACzB,IAAI,OAAO,EAAE,CAAC,KAAK,OAAO,OAAO,EAAE,CAAC,KAAK,IACvC,MAAM,KAAK,GAAG,CAAC;iBAEf,oBAAoB,MAAM;;QAI9B,IAAI,mBAAmB;YACrB,IAAI,WAAW,aAAa,MAAM,CAAC,CAAC;YACpC,IAAI,SAAS,aAAa,MAAM,CAAC;YACjC,kCAAkC;YAClC,IAAI,QAAQ,SAAS,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,iBAAiB;YAClE,IAAI;mBAAI;aAAM,CAAC,MAAM,KAAK,GACxB,QAAQ,IAAI,CAAC;YAEf,IAAI,WAAW,SAAS,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;YAClF,OAAO;QACT,OACE,OAAO,aAAa,MAAM,CAAC;IAE/B;AACF","sources":["packages/@internationalized/number/src/NumberFormatter.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\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n supportsSignDisplay =\n new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'}).resolvedOptions().signDisplay ===\n 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch {}\n\nlet supportsUnit = false;\ntry {\n supportsUnit =\n new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'}).resolvedOptions().style ===\n 'unit';\n // eslint-disable-next-line no-empty\n} catch {}\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\n * 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 /**\n * Formats a number value as a string, according to the locale and options provided to the\n * constructor.\n */\n format(value: number): string {\n let res = '';\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n res = numberFormatSignDisplayPolyfill(this.numberFormatter, this.options.signDisplay, value);\n } else {\n res = this.numberFormatter.format(value);\n }\n\n if (this.options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short', locale} = this.resolvedOptions();\n if (!unit) {\n return res;\n }\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 return this.numberFormatter.formatToParts(value);\n }\n\n /** Formats a number range as a string. */\n formatRange(start: number, end: number): string {\n if (typeof this.numberFormatter.formatRange === 'function') {\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 if (typeof this.numberFormatter.formatRangeToParts === 'function') {\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 = {\n ...options,\n style: 'unit',\n unit: this.options.unit,\n unitDisplay: this.options.unitDisplay\n };\n }\n\n return options;\n }\n}\n\nfunction getCachedNumberFormatter(\n locale: string,\n options: NumberFormatOptions = {}\n): Intl.NumberFormat {\n let {numberingSystem} = options;\n if (numberingSystem && locale.includes('-nu-')) {\n if (!locale.includes('-u-')) {\n locale += '-u-';\n }\n locale += `-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 =\n locale +\n (options\n ? Object.entries(options)\n .sort((a, b) => (a[0] < b[0] ? -1 : 1))\n .join()\n : '');\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(\n numberFormat: Intl.NumberFormat,\n signDisplay: string,\n num: number\n): string {\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"],"names":[],"version":3,"file":"NumberFormatter.cjs.map"}
@@ -8,17 +8,17 @@
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 $488c6ddbf4ef74c2$var$formatterCache = new Map();
12
- let $488c6ddbf4ef74c2$var$supportsSignDisplay = false;
11
+ */ let $6c0bb0183c96ba81$var$formatterCache = new Map();
12
+ let $6c0bb0183c96ba81$var$supportsSignDisplay = false;
13
13
  try {
14
- $488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
14
+ $6c0bb0183c96ba81$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
15
15
  signDisplay: 'exceptZero'
16
16
  }).resolvedOptions().signDisplay === 'exceptZero';
17
17
  // eslint-disable-next-line no-empty
18
18
  } catch {}
19
- let $488c6ddbf4ef74c2$var$supportsUnit = false;
19
+ let $6c0bb0183c96ba81$var$supportsUnit = false;
20
20
  try {
21
- $488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat('de-DE', {
21
+ $6c0bb0183c96ba81$var$supportsUnit = new Intl.NumberFormat('de-DE', {
22
22
  style: 'unit',
23
23
  unit: 'degree'
24
24
  }).resolvedOptions().style === 'unit';
@@ -27,7 +27,7 @@ try {
27
27
  // Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
28
28
  // Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
29
29
  // Values were determined by switching to each locale manually in Chrome.
30
- const $488c6ddbf4ef74c2$var$UNITS = {
30
+ const $6c0bb0183c96ba81$var$UNITS = {
31
31
  degree: {
32
32
  narrow: {
33
33
  default: "\xb0",
@@ -37,16 +37,19 @@ const $488c6ddbf4ef74c2$var$UNITS = {
37
37
  }
38
38
  }
39
39
  };
40
- class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
41
- /** Formats a number value as a string, according to the locale and options provided to the constructor. */ format(value) {
40
+ class $6c0bb0183c96ba81$export$cc77c4ff7e8673c5 {
41
+ /**
42
+ * Formats a number value as a string, according to the locale and options provided to the
43
+ * constructor.
44
+ */ format(value) {
42
45
  let res = '';
43
- if (!$488c6ddbf4ef74c2$var$supportsSignDisplay && this.options.signDisplay != null) res = $488c6ddbf4ef74c2$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
46
+ if (!$6c0bb0183c96ba81$var$supportsSignDisplay && this.options.signDisplay != null) res = $6c0bb0183c96ba81$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
44
47
  else res = this.numberFormatter.format(value);
45
- if (this.options.style === 'unit' && !$488c6ddbf4ef74c2$var$supportsUnit) {
48
+ if (this.options.style === 'unit' && !$6c0bb0183c96ba81$var$supportsUnit) {
46
49
  var _UNITS_unit;
47
50
  let { unit: unit, unitDisplay: unitDisplay = 'short', locale: locale } = this.resolvedOptions();
48
51
  if (!unit) return res;
49
- let values = (_UNITS_unit = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay];
52
+ let values = (_UNITS_unit = $6c0bb0183c96ba81$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay];
50
53
  res += values[locale] || values.default;
51
54
  }
52
55
  return res;
@@ -84,11 +87,11 @@ class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
84
87
  }
85
88
  /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
86
89
  let options = this.numberFormatter.resolvedOptions();
87
- if (!$488c6ddbf4ef74c2$var$supportsSignDisplay && this.options.signDisplay != null) options = {
90
+ if (!$6c0bb0183c96ba81$var$supportsSignDisplay && this.options.signDisplay != null) options = {
88
91
  ...options,
89
92
  signDisplay: this.options.signDisplay
90
93
  };
91
- if (!$488c6ddbf4ef74c2$var$supportsUnit && this.options.style === 'unit') options = {
94
+ if (!$6c0bb0183c96ba81$var$supportsUnit && this.options.style === 'unit') options = {
92
95
  ...options,
93
96
  style: 'unit',
94
97
  unit: this.options.unit,
@@ -97,33 +100,33 @@ class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
97
100
  return options;
98
101
  }
99
102
  constructor(locale, options = {}){
100
- this.numberFormatter = $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options);
103
+ this.numberFormatter = $6c0bb0183c96ba81$var$getCachedNumberFormatter(locale, options);
101
104
  this.options = options;
102
105
  }
103
106
  }
104
- function $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options = {}) {
107
+ function $6c0bb0183c96ba81$var$getCachedNumberFormatter(locale, options = {}) {
105
108
  let { numberingSystem: numberingSystem } = options;
106
109
  if (numberingSystem && locale.includes('-nu-')) {
107
110
  if (!locale.includes('-u-')) locale += '-u-';
108
111
  locale += `-nu-${numberingSystem}`;
109
112
  }
110
- if (options.style === 'unit' && !$488c6ddbf4ef74c2$var$supportsUnit) {
113
+ if (options.style === 'unit' && !$6c0bb0183c96ba81$var$supportsUnit) {
111
114
  var _UNITS_unit;
112
115
  let { unit: unit, unitDisplay: unitDisplay = 'short' } = options;
113
116
  if (!unit) throw new Error('unit option must be provided with style: "unit"');
114
- if (!((_UNITS_unit = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
117
+ if (!((_UNITS_unit = $6c0bb0183c96ba81$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
115
118
  options = {
116
119
  ...options,
117
120
  style: 'decimal'
118
121
  };
119
122
  }
120
123
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
121
- if ($488c6ddbf4ef74c2$var$formatterCache.has(cacheKey)) return $488c6ddbf4ef74c2$var$formatterCache.get(cacheKey);
124
+ if ($6c0bb0183c96ba81$var$formatterCache.has(cacheKey)) return $6c0bb0183c96ba81$var$formatterCache.get(cacheKey);
122
125
  let numberFormatter = new Intl.NumberFormat(locale, options);
123
- $488c6ddbf4ef74c2$var$formatterCache.set(cacheKey, numberFormatter);
126
+ $6c0bb0183c96ba81$var$formatterCache.set(cacheKey, numberFormatter);
124
127
  return numberFormatter;
125
128
  }
126
- function $488c6ddbf4ef74c2$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
129
+ function $6c0bb0183c96ba81$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
127
130
  if (signDisplay === 'auto') return numberFormat.format(num);
128
131
  else if (signDisplay === 'never') return numberFormat.format(Math.abs(num));
129
132
  else {
@@ -148,5 +151,5 @@ function $488c6ddbf4ef74c2$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
148
151
  }
149
152
 
150
153
 
151
- export {$488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 as NumberFormatter, $488c6ddbf4ef74c2$export$711b50b3c525e0f2 as numberFormatSignDisplayPolyfill};
152
- //# sourceMappingURL=NumberFormatter.module.js.map
154
+ export {$6c0bb0183c96ba81$export$cc77c4ff7e8673c5 as NumberFormatter, $6c0bb0183c96ba81$export$711b50b3c525e0f2 as numberFormatSignDisplayPolyfill};
155
+ //# sourceMappingURL=NumberFormatter.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAED,IAAI,uCAAiB,IAAI;AAEzB,IAAI,4CAAsB;AAC1B,IAAI;IACF,4CACE,IAAI,KAAK,YAAY,CAAC,SAAS;QAAC,aAAa;IAAY,GAAG,eAAe,GAAG,WAAW,KACzF;AACF,oCAAoC;AACtC,EAAE,OAAM,CAAC;AAET,IAAI,qCAAe;AACnB,IAAI;IACF,qCACE,IAAI,KAAK,YAAY,CAAC,SAAS;QAAC,OAAO;QAAQ,MAAM;IAAQ,GAAG,eAAe,GAAG,KA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I,WAAW,aAAa,MAAM,CAAC,CAAC;YACpC,IAAI,SAAS,aAAa,MAAM,CAAC;YACjC,kCAAkC;YAClC,IAAI,QAAQ,SAAS,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,iBAAiB;YAClE,IAAI;mBAAI;aAAM,CAAC,MAAM,KAAK,GACxB,QAAQ,IAAI,CAAC;YAEf,IAAI,WAAW,SAAS,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;YAClF,OAAO;QACT,OACE,OAAO,aAAa,MAAM,CAAC;IAE/B;AACF","sources":["packages/@internationalized/number/src/NumberFormatter.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\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n supportsSignDisplay =\n new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'}).resolvedOptions().signDisplay ===\n 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch {}\n\nlet supportsUnit = false;\ntry {\n supportsUnit =\n new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'}).resolvedOptions().style ===\n 'unit';\n // eslint-disable-next-line no-empty\n} catch {}\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\n * 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 /**\n * Formats a number value as a string, according to the locale and options provided to the\n * constructor.\n */\n format(value: number): string {\n let res = '';\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n res = numberFormatSignDisplayPolyfill(this.numberFormatter, this.options.signDisplay, value);\n } else {\n res = this.numberFormatter.format(value);\n }\n\n if (this.options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short', locale} = this.resolvedOptions();\n if (!unit) {\n return res;\n }\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 return this.numberFormatter.formatToParts(value);\n }\n\n /** Formats a number range as a string. */\n formatRange(start: number, end: number): string {\n if (typeof this.numberFormatter.formatRange === 'function') {\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 if (typeof this.numberFormatter.formatRangeToParts === 'function') {\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 = {\n ...options,\n style: 'unit',\n unit: this.options.unit,\n unitDisplay: this.options.unitDisplay\n };\n }\n\n return options;\n }\n}\n\nfunction getCachedNumberFormatter(\n locale: string,\n options: NumberFormatOptions = {}\n): Intl.NumberFormat {\n let {numberingSystem} = options;\n if (numberingSystem && locale.includes('-nu-')) {\n if (!locale.includes('-u-')) {\n locale += '-u-';\n }\n locale += `-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 =\n locale +\n (options\n ? Object.entries(options)\n .sort((a, b) => (a[0] < b[0] ? -1 : 1))\n .join()\n : '');\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(\n numberFormat: Intl.NumberFormat,\n signDisplay: string,\n num: number\n): string {\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"],"names":[],"version":3,"file":"NumberFormatter.js.map"}
@@ -8,17 +8,17 @@
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 $488c6ddbf4ef74c2$var$formatterCache = new Map();
12
- let $488c6ddbf4ef74c2$var$supportsSignDisplay = false;
11
+ */ let $1dfb119a85e764e5$var$formatterCache = new Map();
12
+ let $1dfb119a85e764e5$var$supportsSignDisplay = false;
13
13
  try {
14
- $488c6ddbf4ef74c2$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
14
+ $1dfb119a85e764e5$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
15
15
  signDisplay: 'exceptZero'
16
16
  }).resolvedOptions().signDisplay === 'exceptZero';
17
17
  // eslint-disable-next-line no-empty
18
18
  } catch {}
19
- let $488c6ddbf4ef74c2$var$supportsUnit = false;
19
+ let $1dfb119a85e764e5$var$supportsUnit = false;
20
20
  try {
21
- $488c6ddbf4ef74c2$var$supportsUnit = new Intl.NumberFormat('de-DE', {
21
+ $1dfb119a85e764e5$var$supportsUnit = new Intl.NumberFormat('de-DE', {
22
22
  style: 'unit',
23
23
  unit: 'degree'
24
24
  }).resolvedOptions().style === 'unit';
@@ -27,7 +27,7 @@ try {
27
27
  // Polyfill for units since Safari doesn't support them yet. See https://bugs.webkit.org/show_bug.cgi?id=215438.
28
28
  // Currently only polyfilling the unit degree in narrow format for ColorSlider in our supported locales.
29
29
  // Values were determined by switching to each locale manually in Chrome.
30
- const $488c6ddbf4ef74c2$var$UNITS = {
30
+ const $1dfb119a85e764e5$var$UNITS = {
31
31
  degree: {
32
32
  narrow: {
33
33
  default: "\xb0",
@@ -37,16 +37,22 @@ const $488c6ddbf4ef74c2$var$UNITS = {
37
37
  }
38
38
  }
39
39
  };
40
- class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
41
- /** Formats a number value as a string, according to the locale and options provided to the constructor. */ format(value) {
40
+ class $1dfb119a85e764e5$export$cc77c4ff7e8673c5 {
41
+ constructor(locale, options = {}){
42
+ this.numberFormatter = $1dfb119a85e764e5$var$getCachedNumberFormatter(locale, options);
43
+ this.options = options;
44
+ }
45
+ /**
46
+ * Formats a number value as a string, according to the locale and options provided to the
47
+ * constructor.
48
+ */ format(value) {
42
49
  let res = '';
43
- if (!$488c6ddbf4ef74c2$var$supportsSignDisplay && this.options.signDisplay != null) res = $488c6ddbf4ef74c2$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
50
+ if (!$1dfb119a85e764e5$var$supportsSignDisplay && this.options.signDisplay != null) res = $1dfb119a85e764e5$export$711b50b3c525e0f2(this.numberFormatter, this.options.signDisplay, value);
44
51
  else res = this.numberFormatter.format(value);
45
- if (this.options.style === 'unit' && !$488c6ddbf4ef74c2$var$supportsUnit) {
46
- var _UNITS_unit;
52
+ if (this.options.style === 'unit' && !$1dfb119a85e764e5$var$supportsUnit) {
47
53
  let { unit: unit, unitDisplay: unitDisplay = 'short', locale: locale } = this.resolvedOptions();
48
54
  if (!unit) return res;
49
- let values = (_UNITS_unit = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay];
55
+ let values = $1dfb119a85e764e5$var$UNITS[unit]?.[unitDisplay];
50
56
  res += values[locale] || values.default;
51
57
  }
52
58
  return res;
@@ -84,11 +90,11 @@ class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
84
90
  }
85
91
  /** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
86
92
  let options = this.numberFormatter.resolvedOptions();
87
- if (!$488c6ddbf4ef74c2$var$supportsSignDisplay && this.options.signDisplay != null) options = {
93
+ if (!$1dfb119a85e764e5$var$supportsSignDisplay && this.options.signDisplay != null) options = {
88
94
  ...options,
89
95
  signDisplay: this.options.signDisplay
90
96
  };
91
- if (!$488c6ddbf4ef74c2$var$supportsUnit && this.options.style === 'unit') options = {
97
+ if (!$1dfb119a85e764e5$var$supportsUnit && this.options.style === 'unit') options = {
92
98
  ...options,
93
99
  style: 'unit',
94
100
  unit: this.options.unit,
@@ -96,34 +102,29 @@ class $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 {
96
102
  };
97
103
  return options;
98
104
  }
99
- constructor(locale, options = {}){
100
- this.numberFormatter = $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options);
101
- this.options = options;
102
- }
103
105
  }
104
- function $488c6ddbf4ef74c2$var$getCachedNumberFormatter(locale, options = {}) {
106
+ function $1dfb119a85e764e5$var$getCachedNumberFormatter(locale, options = {}) {
105
107
  let { numberingSystem: numberingSystem } = options;
106
108
  if (numberingSystem && locale.includes('-nu-')) {
107
109
  if (!locale.includes('-u-')) locale += '-u-';
108
110
  locale += `-nu-${numberingSystem}`;
109
111
  }
110
- if (options.style === 'unit' && !$488c6ddbf4ef74c2$var$supportsUnit) {
111
- var _UNITS_unit;
112
+ if (options.style === 'unit' && !$1dfb119a85e764e5$var$supportsUnit) {
112
113
  let { unit: unit, unitDisplay: unitDisplay = 'short' } = options;
113
114
  if (!unit) throw new Error('unit option must be provided with style: "unit"');
114
- if (!((_UNITS_unit = $488c6ddbf4ef74c2$var$UNITS[unit]) === null || _UNITS_unit === void 0 ? void 0 : _UNITS_unit[unitDisplay])) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
115
+ if (!$1dfb119a85e764e5$var$UNITS[unit]?.[unitDisplay]) throw new Error(`Unsupported unit ${unit} with unitDisplay = ${unitDisplay}`);
115
116
  options = {
116
117
  ...options,
117
118
  style: 'decimal'
118
119
  };
119
120
  }
120
121
  let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
121
- if ($488c6ddbf4ef74c2$var$formatterCache.has(cacheKey)) return $488c6ddbf4ef74c2$var$formatterCache.get(cacheKey);
122
+ if ($1dfb119a85e764e5$var$formatterCache.has(cacheKey)) return $1dfb119a85e764e5$var$formatterCache.get(cacheKey);
122
123
  let numberFormatter = new Intl.NumberFormat(locale, options);
123
- $488c6ddbf4ef74c2$var$formatterCache.set(cacheKey, numberFormatter);
124
+ $1dfb119a85e764e5$var$formatterCache.set(cacheKey, numberFormatter);
124
125
  return numberFormatter;
125
126
  }
126
- function $488c6ddbf4ef74c2$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
127
+ function $1dfb119a85e764e5$export$711b50b3c525e0f2(numberFormat, signDisplay, num) {
127
128
  if (signDisplay === 'auto') return numberFormat.format(num);
128
129
  else if (signDisplay === 'never') return numberFormat.format(Math.abs(num));
129
130
  else {
@@ -148,5 +149,5 @@ function $488c6ddbf4ef74c2$export$711b50b3c525e0f2(numberFormat, signDisplay, nu
148
149
  }
149
150
 
150
151
 
151
- export {$488c6ddbf4ef74c2$export$cc77c4ff7e8673c5 as NumberFormatter, $488c6ddbf4ef74c2$export$711b50b3c525e0f2 as numberFormatSignDisplayPolyfill};
152
- //# sourceMappingURL=NumberFormatter.module.js.map
152
+ export {$1dfb119a85e764e5$export$cc77c4ff7e8673c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AC/B,WAAmB,EACnB,GAAW;IAEX,IAAI,gBAAgB,QAClB,OAAO,aAAa,MAAM,CAAC;SACtB,IAAI,gBAAgB,SACzB,OAAO,aAAa,MAAM,CAAC,KAAK,GAAG,CAAC;SAC/B;QACL,IAAI,oBAAoB;QACxB,IAAI,gBAAgB,UAClB,oBAAoB,MAAM,KAAK,OAAO,EAAE,CAAC,KAAK;aACzC,IAAI,gBAAgB;YACzB,IAAI,OAAO,EAAE,CAAC,KAAK,OAAO,OAAO,EAAE,CAAC,KAAK,IACvC,MAAM,KAAK,GAAG,CAAC;iBAEf,oBAAoB,MAAM;;QAI9B,IAAI,mBAAmB;YACrB,IAAI,WAAW,aAAa,MAAM,CAAC,CAAC;YACpC,IAAI,SAAS,aAAa,MAAM,CAAC;YACjC,kCAAkC;YAClC,IAAI,QAAQ,SAAS,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,iBAAiB;YAClE,IAAI;mBAAI;aAAM,CAAC,MAAM,KAAK,GACxB,QAAQ,IAAI,CAAC;YAEf,IAAI,WAAW,SAAS,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;YAClF,OAAO;QACT,OACE,OAAO,aAAa,MAAM,CAAC;IAE/B;AACF","sources":["packages/@internationalized/number/src/NumberFormatter.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\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n supportsSignDisplay =\n new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'}).resolvedOptions().signDisplay ===\n 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch {}\n\nlet supportsUnit = false;\ntry {\n supportsUnit =\n new Intl.NumberFormat('de-DE', {style: 'unit', unit: 'degree'}).resolvedOptions().style ===\n 'unit';\n // eslint-disable-next-line no-empty\n} catch {}\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\n * 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 /**\n * Formats a number value as a string, according to the locale and options provided to the\n * constructor.\n */\n format(value: number): string {\n let res = '';\n if (!supportsSignDisplay && this.options.signDisplay != null) {\n res = numberFormatSignDisplayPolyfill(this.numberFormatter, this.options.signDisplay, value);\n } else {\n res = this.numberFormatter.format(value);\n }\n\n if (this.options.style === 'unit' && !supportsUnit) {\n let {unit, unitDisplay = 'short', locale} = this.resolvedOptions();\n if (!unit) {\n return res;\n }\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 return this.numberFormatter.formatToParts(value);\n }\n\n /** Formats a number range as a string. */\n formatRange(start: number, end: number): string {\n if (typeof this.numberFormatter.formatRange === 'function') {\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 if (typeof this.numberFormatter.formatRangeToParts === 'function') {\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 = {\n ...options,\n style: 'unit',\n unit: this.options.unit,\n unitDisplay: this.options.unitDisplay\n };\n }\n\n return options;\n }\n}\n\nfunction getCachedNumberFormatter(\n locale: string,\n options: NumberFormatOptions = {}\n): Intl.NumberFormat {\n let {numberingSystem} = options;\n if (numberingSystem && locale.includes('-nu-')) {\n if (!locale.includes('-u-')) {\n locale += '-u-';\n }\n locale += `-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 =\n locale +\n (options\n ? Object.entries(options)\n .sort((a, b) => (a[0] < b[0] ? -1 : 1))\n .join()\n : '');\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(\n numberFormat: Intl.NumberFormat,\n signDisplay: string,\n num: number\n): string {\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"],"names":[],"version":3,"file":"NumberFormatter.mjs.map"}