@react-aria/i18n 3.10.2 → 3.11.0

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 (68) hide show
  1. package/dist/context.main.js +48 -0
  2. package/dist/context.main.js.map +1 -0
  3. package/dist/context.mjs +38 -0
  4. package/dist/context.module.js +38 -0
  5. package/dist/context.module.js.map +1 -0
  6. package/dist/import.mjs +31 -6
  7. package/dist/main.js +45 -6
  8. package/dist/main.js.map +1 -0
  9. package/dist/module.js +31 -6
  10. package/dist/module.js.map +1 -0
  11. package/dist/types.d.ts +1 -0
  12. package/dist/types.d.ts.map +1 -1
  13. package/dist/useCollator.main.js +31 -0
  14. package/dist/useCollator.main.js.map +1 -0
  15. package/dist/useCollator.mjs +26 -0
  16. package/dist/useCollator.module.js +26 -0
  17. package/dist/useCollator.module.js.map +1 -0
  18. package/dist/useDateFormatter.main.js +47 -0
  19. package/dist/useDateFormatter.main.js.map +1 -0
  20. package/dist/useDateFormatter.mjs +42 -0
  21. package/dist/useDateFormatter.module.js +42 -0
  22. package/dist/useDateFormatter.module.js.map +1 -0
  23. package/dist/useDefaultLocale.main.js +68 -0
  24. package/dist/useDefaultLocale.main.js.map +1 -0
  25. package/dist/useDefaultLocale.mjs +63 -0
  26. package/dist/useDefaultLocale.module.js +63 -0
  27. package/dist/useDefaultLocale.module.js.map +1 -0
  28. package/dist/useFilter.main.js +72 -0
  29. package/dist/useFilter.main.js.map +1 -0
  30. package/dist/useFilter.mjs +67 -0
  31. package/dist/useFilter.module.js +67 -0
  32. package/dist/useFilter.module.js.map +1 -0
  33. package/dist/useListFormatter.main.js +31 -0
  34. package/dist/useListFormatter.main.js.map +1 -0
  35. package/dist/useListFormatter.mjs +26 -0
  36. package/dist/useListFormatter.module.js +26 -0
  37. package/dist/useListFormatter.module.js.map +1 -0
  38. package/dist/useLocalizedStringFormatter.main.js +47 -0
  39. package/dist/useLocalizedStringFormatter.main.js.map +1 -0
  40. package/dist/useLocalizedStringFormatter.mjs +41 -0
  41. package/dist/useLocalizedStringFormatter.module.js +41 -0
  42. package/dist/useLocalizedStringFormatter.module.js.map +1 -0
  43. package/dist/useMessageFormatter.main.js +48 -0
  44. package/dist/useMessageFormatter.main.js.map +1 -0
  45. package/dist/useMessageFormatter.mjs +43 -0
  46. package/dist/useMessageFormatter.module.js +28 -27
  47. package/dist/useMessageFormatter.module.js.map +1 -0
  48. package/dist/useNumberFormatter.main.js +33 -0
  49. package/dist/useNumberFormatter.main.js.map +1 -0
  50. package/dist/useNumberFormatter.mjs +28 -0
  51. package/dist/useNumberFormatter.module.js +28 -0
  52. package/dist/useNumberFormatter.module.js.map +1 -0
  53. package/dist/utils.main.js +71 -0
  54. package/dist/utils.main.js.map +1 -0
  55. package/dist/utils.mjs +66 -0
  56. package/dist/utils.module.js +66 -0
  57. package/dist/utils.module.js.map +1 -0
  58. package/package.json +11 -31
  59. package/src/index.ts +1 -0
  60. package/src/useMessageFormatter.ts +1 -1
  61. package/dist/real-main.js +0 -391
  62. package/dist/real-main.js.map +0 -1
  63. package/dist/real-module.js +0 -373
  64. package/dist/real-module.js.map +0 -1
  65. package/dist/real-module.mjs +0 -373
  66. package/dist/real-module.mjs.map +0 -1
  67. package/dist/useMessageFormatter.js +0 -52
  68. package/dist/useMessageFormatter.module.mjs +0 -42
@@ -1,373 +0,0 @@
1
- import $iFADg$react, {useContext as $iFADg$useContext, useState as $iFADg$useState, useEffect as $iFADg$useEffect, useMemo as $iFADg$useMemo, useCallback as $iFADg$useCallback} from "react";
2
- import {useIsSSR as $iFADg$useIsSSR} from "@react-aria/ssr";
3
- import {LocalizedStringDictionary as $iFADg$LocalizedStringDictionary, LocalizedStringFormatter as $iFADg$LocalizedStringFormatter} from "@internationalized/string";
4
- import {DateFormatter as $iFADg$DateFormatter} from "@internationalized/date";
5
- import {useDeepMemo as $iFADg$useDeepMemo} from "@react-aria/utils";
6
- import {NumberFormatter as $iFADg$NumberFormatter} from "@internationalized/number";
7
-
8
- /*
9
- * Copyright 2020 Adobe. All rights reserved.
10
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License. You may obtain a copy
12
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software distributed under
15
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
- * OF ANY KIND, either express or implied. See the License for the specific language
17
- * governing permissions and limitations under the License.
18
- */ /*
19
- * Copyright 2020 Adobe. All rights reserved.
20
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
21
- * you may not use this file except in compliance with the License. You may obtain a copy
22
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
23
- *
24
- * Unless required by applicable law or agreed to in writing, software distributed under
25
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
26
- * OF ANY KIND, either express or implied. See the License for the specific language
27
- * governing permissions and limitations under the License.
28
- */ /*
29
- * Copyright 2020 Adobe. All rights reserved.
30
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
31
- * you may not use this file except in compliance with the License. You may obtain a copy
32
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
33
- *
34
- * Unless required by applicable law or agreed to in writing, software distributed under
35
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
36
- * OF ANY KIND, either express or implied. See the License for the specific language
37
- * governing permissions and limitations under the License.
38
- */ // https://en.wikipedia.org/wiki/Right-to-left
39
- const $148a7a147e38ea7f$var$RTL_SCRIPTS = new Set([
40
- "Arab",
41
- "Syrc",
42
- "Samr",
43
- "Mand",
44
- "Thaa",
45
- "Mend",
46
- "Nkoo",
47
- "Adlm",
48
- "Rohg",
49
- "Hebr"
50
- ]);
51
- const $148a7a147e38ea7f$var$RTL_LANGS = new Set([
52
- "ae",
53
- "ar",
54
- "arc",
55
- "bcc",
56
- "bqi",
57
- "ckb",
58
- "dv",
59
- "fa",
60
- "glk",
61
- "he",
62
- "ku",
63
- "mzn",
64
- "nqo",
65
- "pnb",
66
- "ps",
67
- "sd",
68
- "ug",
69
- "ur",
70
- "yi"
71
- ]);
72
- function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
73
- // If the Intl.Locale API is available, use it to get the locale's text direction.
74
- // @ts-ignore
75
- if (Intl.Locale) {
76
- let locale = new Intl.Locale(localeString).maximize();
77
- // Use the text info object to get the direction if possible.
78
- // @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.
79
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
80
- let textInfo = typeof locale.getTextInfo === "function" ? locale.getTextInfo() : locale.textInfo;
81
- if (textInfo) return textInfo.direction === "rtl";
82
- // Fallback: guess using the script.
83
- // This is more accurate than guessing by language, since languages can be written in multiple scripts.
84
- if (locale.script) return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(locale.script);
85
- }
86
- // If not, just guess by the language (first part of the locale)
87
- let lang = localeString.split("-")[0];
88
- return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
89
- }
90
-
91
-
92
- /*
93
- * Copyright 2020 Adobe. All rights reserved.
94
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
95
- * you may not use this file except in compliance with the License. You may obtain a copy
96
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
97
- *
98
- * Unless required by applicable law or agreed to in writing, software distributed under
99
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
100
- * OF ANY KIND, either express or implied. See the License for the specific language
101
- * governing permissions and limitations under the License.
102
- */
103
-
104
-
105
- // Locale passed from server by PackageLocalizationProvider.
106
- const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for("react-aria.i18n.locale");
107
- function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
108
- let locale = typeof window !== "undefined" && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator !== "undefined" && (navigator.language || navigator.userLanguage) || "en-US";
109
- try {
110
- // @ts-ignore
111
- Intl.DateTimeFormat.supportedLocalesOf([
112
- locale
113
- ]);
114
- } catch (_err) {
115
- locale = "en-US";
116
- }
117
- return {
118
- locale: locale,
119
- direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? "rtl" : "ltr"
120
- };
121
- }
122
- let $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
123
- let $1e5a04cdaf7d1af8$var$listeners = new Set();
124
- function $1e5a04cdaf7d1af8$var$updateLocale() {
125
- $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
126
- for (let listener of $1e5a04cdaf7d1af8$var$listeners)listener($1e5a04cdaf7d1af8$var$currentLocale);
127
- }
128
- function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
129
- let isSSR = (0, $iFADg$useIsSSR)();
130
- let [defaultLocale, setDefaultLocale] = (0, $iFADg$useState)($1e5a04cdaf7d1af8$var$currentLocale);
131
- (0, $iFADg$useEffect)(()=>{
132
- if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
133
- $1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale);
134
- return ()=>{
135
- $1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale);
136
- if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
137
- };
138
- }, []);
139
- // We cannot determine the browser's language on the server, so default to
140
- // en-US. This will be updated after hydration on the client to the correct value.
141
- if (isSSR) return {
142
- locale: "en-US",
143
- direction: "ltr"
144
- };
145
- return defaultLocale;
146
- }
147
-
148
-
149
-
150
- const $18f2051aff69b9bf$var$I18nContext = /*#__PURE__*/ (0, $iFADg$react).createContext(null);
151
- function $18f2051aff69b9bf$export$a54013f0d02a8f82(props) {
152
- let { locale: locale, children: children } = props;
153
- let defaultLocale = (0, $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a)();
154
- let value = locale ? {
155
- locale: locale,
156
- direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? "rtl" : "ltr"
157
- } : defaultLocale;
158
- return /*#__PURE__*/ (0, $iFADg$react).createElement($18f2051aff69b9bf$var$I18nContext.Provider, {
159
- value: value
160
- }, children);
161
- }
162
- function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
163
- let defaultLocale = (0, $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a)();
164
- let context = (0, $iFADg$useContext)($18f2051aff69b9bf$var$I18nContext);
165
- return context || defaultLocale;
166
- }
167
-
168
-
169
- var $2aa2084a6c2b6b4f$exports = {};
170
- "use strict";
171
-
172
-
173
- /*
174
- * Copyright 2022 Adobe. All rights reserved.
175
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
176
- * you may not use this file except in compliance with the License. You may obtain a copy
177
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
178
- *
179
- * Unless required by applicable law or agreed to in writing, software distributed under
180
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
181
- * OF ANY KIND, either express or implied. See the License for the specific language
182
- * governing permissions and limitations under the License.
183
- */
184
-
185
-
186
- const $fca6afa0e843324b$var$cache = new WeakMap();
187
- function $fca6afa0e843324b$var$getCachedDictionary(strings) {
188
- let dictionary = $fca6afa0e843324b$var$cache.get(strings);
189
- if (!dictionary) {
190
- dictionary = new (0, $iFADg$LocalizedStringDictionary)(strings);
191
- $fca6afa0e843324b$var$cache.set(strings, dictionary);
192
- }
193
- return dictionary;
194
- }
195
- function $fca6afa0e843324b$export$87b761675e8eaa10(strings, packageName) {
196
- return packageName && (0, $iFADg$LocalizedStringDictionary).getGlobalDictionaryForPackage(packageName) || $fca6afa0e843324b$var$getCachedDictionary(strings);
197
- }
198
- function $fca6afa0e843324b$export$f12b703ca79dfbb1(strings, packageName) {
199
- let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
200
- let dictionary = $fca6afa0e843324b$export$87b761675e8eaa10(strings, packageName);
201
- return (0, $iFADg$useMemo)(()=>new (0, $iFADg$LocalizedStringFormatter)(locale, dictionary), [
202
- locale,
203
- dictionary
204
- ]);
205
- }
206
-
207
-
208
- /*
209
- * Copyright 2020 Adobe. All rights reserved.
210
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
211
- * you may not use this file except in compliance with the License. You may obtain a copy
212
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
213
- *
214
- * Unless required by applicable law or agreed to in writing, software distributed under
215
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
216
- * OF ANY KIND, either express or implied. See the License for the specific language
217
- * governing permissions and limitations under the License.
218
- */
219
-
220
- function $33bf17300c498528$export$a2f47a3d2973640(options = {}) {
221
- let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
222
- return (0, $iFADg$useMemo)(()=>new Intl.ListFormat(locale, options), [
223
- locale,
224
- options
225
- ]);
226
- }
227
-
228
-
229
- /*
230
- * Copyright 2020 Adobe. All rights reserved.
231
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
232
- * you may not use this file except in compliance with the License. You may obtain a copy
233
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
234
- *
235
- * Unless required by applicable law or agreed to in writing, software distributed under
236
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
237
- * OF ANY KIND, either express or implied. See the License for the specific language
238
- * governing permissions and limitations under the License.
239
- */
240
-
241
-
242
-
243
- function $896ba0a80a8f4d36$export$85fd5fdf27bacc79(options) {
244
- // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
245
- options = (0, $iFADg$useDeepMemo)(options !== null && options !== void 0 ? options : {}, $896ba0a80a8f4d36$var$isEqual);
246
- let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
247
- return (0, $iFADg$useMemo)(()=>new (0, $iFADg$DateFormatter)(locale, options), [
248
- locale,
249
- options
250
- ]);
251
- }
252
- function $896ba0a80a8f4d36$var$isEqual(a, b) {
253
- if (a === b) return true;
254
- let aKeys = Object.keys(a);
255
- let bKeys = Object.keys(b);
256
- if (aKeys.length !== bKeys.length) return false;
257
- for (let key of aKeys){
258
- if (b[key] !== a[key]) return false;
259
- }
260
- return true;
261
- }
262
-
263
-
264
- /*
265
- * Copyright 2020 Adobe. All rights reserved.
266
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
267
- * you may not use this file except in compliance with the License. You may obtain a copy
268
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
269
- *
270
- * Unless required by applicable law or agreed to in writing, software distributed under
271
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
272
- * OF ANY KIND, either express or implied. See the License for the specific language
273
- * governing permissions and limitations under the License.
274
- */
275
-
276
-
277
- function $a916eb452884faea$export$b7a616150fdb9f44(options = {}) {
278
- let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
279
- return (0, $iFADg$useMemo)(()=>new (0, $iFADg$NumberFormatter)(locale, options), [
280
- locale,
281
- options
282
- ]);
283
- }
284
-
285
-
286
- /*
287
- * Copyright 2020 Adobe. All rights reserved.
288
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
289
- * you may not use this file except in compliance with the License. You may obtain a copy
290
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
291
- *
292
- * Unless required by applicable law or agreed to in writing, software distributed under
293
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
294
- * OF ANY KIND, either express or implied. See the License for the specific language
295
- * governing permissions and limitations under the License.
296
- */
297
- let $325a3faab7a68acd$var$cache = new Map();
298
- function $325a3faab7a68acd$export$a16aca283550c30d(options) {
299
- let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
300
- let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
301
- if ($325a3faab7a68acd$var$cache.has(cacheKey)) return $325a3faab7a68acd$var$cache.get(cacheKey);
302
- let formatter = new Intl.Collator(locale, options);
303
- $325a3faab7a68acd$var$cache.set(cacheKey, formatter);
304
- return formatter;
305
- }
306
-
307
-
308
- /*
309
- * Copyright 2020 Adobe. All rights reserved.
310
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
311
- * you may not use this file except in compliance with the License. You may obtain a copy
312
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
313
- *
314
- * Unless required by applicable law or agreed to in writing, software distributed under
315
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
316
- * OF ANY KIND, either express or implied. See the License for the specific language
317
- * governing permissions and limitations under the License.
318
- */
319
-
320
- function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
321
- let collator = (0, $325a3faab7a68acd$export$a16aca283550c30d)({
322
- usage: "search",
323
- ...options
324
- });
325
- // TODO(later): these methods don't currently support the ignorePunctuation option.
326
- let startsWith = (0, $iFADg$useCallback)((string, substring)=>{
327
- if (substring.length === 0) return true;
328
- // Normalize both strings so we can slice safely
329
- // TODO: take into account the ignorePunctuation option as well...
330
- string = string.normalize("NFC");
331
- substring = substring.normalize("NFC");
332
- return collator.compare(string.slice(0, substring.length), substring) === 0;
333
- }, [
334
- collator
335
- ]);
336
- let endsWith = (0, $iFADg$useCallback)((string, substring)=>{
337
- if (substring.length === 0) return true;
338
- string = string.normalize("NFC");
339
- substring = substring.normalize("NFC");
340
- return collator.compare(string.slice(-substring.length), substring) === 0;
341
- }, [
342
- collator
343
- ]);
344
- let contains = (0, $iFADg$useCallback)((string, substring)=>{
345
- if (substring.length === 0) return true;
346
- string = string.normalize("NFC");
347
- substring = substring.normalize("NFC");
348
- let scan = 0;
349
- let sliceLen = substring.length;
350
- for(; scan + sliceLen <= string.length; scan++){
351
- let slice = string.slice(scan, scan + sliceLen);
352
- if (collator.compare(substring, slice) === 0) return true;
353
- }
354
- return false;
355
- }, [
356
- collator
357
- ]);
358
- return (0, $iFADg$useMemo)(()=>({
359
- startsWith: startsWith,
360
- endsWith: endsWith,
361
- contains: contains
362
- }), [
363
- startsWith,
364
- endsWith,
365
- contains
366
- ]);
367
- }
368
-
369
-
370
-
371
-
372
- export {$18f2051aff69b9bf$export$a54013f0d02a8f82 as I18nProvider, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 as useLocale, $fca6afa0e843324b$export$f12b703ca79dfbb1 as useLocalizedStringFormatter, $fca6afa0e843324b$export$87b761675e8eaa10 as useLocalizedStringDictionary, $33bf17300c498528$export$a2f47a3d2973640 as useListFormatter, $896ba0a80a8f4d36$export$85fd5fdf27bacc79 as useDateFormatter, $a916eb452884faea$export$b7a616150fdb9f44 as useNumberFormatter, $325a3faab7a68acd$export$a16aca283550c30d as useCollator, $bb77f239b46e8c72$export$3274cf84b703fff as useFilter};
373
- //# sourceMappingURL=real-module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,8CAA8C;AAC9C,MAAM,oCAAc,IAAI,IAAI;IAAC;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;CAAO;AAC5G,MAAM,kCAAY,IAAI,IAAI;IAAC;IAAM;IAAM;IAAO;IAAO;IAAO;IAAO;IAAM;IAAM;IAAO;IAAM;IAAM;IAAO;IAAO;IAAO;IAAM;IAAM;IAAM;IAAM;CAAK;AAK7I,SAAS,0CAAM,YAAoB;IACxC,kFAAkF;IAClF,aAAa;IACb,IAAI,KAAK,MAAM,EAAE;QACf,IAAI,SAAS,IAAI,KAAK,MAAM,CAAC,cAAc,QAAQ;QAEnD,6DAA6D;QAC7D,6GAA6G;QAC7G,2GAA2G;Q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AM,EAAE,OAAQ;YAC/C,IAAI,QAAQ,OAAO,KAAK,CAAC,MAAM,OAAO;YACtC,IAAI,SAAS,OAAO,CAAC,WAAW,WAAW,GACzC,OAAO;QAEX;QAEA,OAAO;IACT,GAAG;QAAC;KAAS;IAEb,OAAO,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;wBACpB;sBACA;sBACA;QACF,CAAA,GAAI;QAAC;QAAY;QAAU;KAAS;AACtC;","sources":["packages/@react-aria/i18n/src/index.ts","packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/useDefaultLocale.ts","node_modules/@parcel/node-resolver-core/lib/_empty.js","packages/@react-aria/i18n/src/useLocalizedStringFormatter.ts","packages/@react-aria/i18n/src/useListFormatter.tsx","packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react-aria/i18n/src/useCollator.ts","packages/@react-aria/i18n/src/useFilter.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 {I18nProvider, useLocale} from './context';\nexport {useMessageFormatter} from './useMessageFormatter';\nexport {useLocalizedStringFormatter, useLocalizedStringDictionary} from './useLocalizedStringFormatter';\nexport {useListFormatter} from './useListFormatter';\nexport {useDateFormatter} from './useDateFormatter';\nexport {useNumberFormatter} from './useNumberFormatter';\nexport {useCollator} from './useCollator';\nexport {useFilter} from './useFilter';\n\nexport type {FormatMessage} from './useMessageFormatter';\nexport type {I18nProviderProps} from './context';\nexport type {Locale} from './useDefaultLocale';\nexport type {LocalizedStrings} from '@internationalized/message';\nexport type {DateFormatterOptions} from './useDateFormatter';\nexport type {DateFormatter} from '@internationalized/date';\nexport type {Filter} from './useFilter';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\nexport interface I18nProviderProps {\n /** Contents that should have the locale applied. */\n children: ReactNode,\n /** The locale to apply to the children. */\n locale?: string\n}\n\nconst I18nContext = React.createContext<Locale | null>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps) {\n let {locale, children} = props;\n let defaultLocale = useDefaultLocale();\n\n let value: Locale = locale ? {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n } : defaultLocale;\n\n return (\n <I18nContext.Provider value={value}>\n {children}\n </I18nContext.Provider>\n );\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n let defaultLocale = useDefaultLocale();\n let context = useContext(I18nContext);\n return context || defaultLocale;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(localeString: string) {\n // If the Intl.Locale API is available, use it to get the locale's text direction.\n // @ts-ignore\n if (Intl.Locale) {\n let locale = new Intl.Locale(localeString).maximize();\n\n // Use the text info object to get the direction if possible.\n // @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo\n let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;\n if (textInfo) {\n return textInfo.direction === 'rtl';\n }\n\n // Fallback: guess using the script.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n if (locale.script) {\n return RTL_SCRIPTS.has(locale.script);\n }\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = localeString.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string,\n /** The writing direction for the locale. */\n direction: Direction\n}\n\n// Locale passed from server by PackageLocalizationProvider.\nconst localeSymbol = Symbol.for('react-aria.i18n.locale');\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n let locale = typeof window !== 'undefined' && window[localeSymbol]\n // @ts-ignore\n || (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage))\n || 'en-US';\n\n try {\n // @ts-ignore\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch (_err) {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr'\n };\n }\n\n return defaultLocale;\n}\n","\"use strict\";","/*\n * Copyright 2022 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\nimport {LocalizedString, LocalizedStringDictionary, LocalizedStringFormatter, LocalizedStrings} from '@internationalized/string';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\nconst cache = new WeakMap();\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(strings: LocalizedStrings<K, T>): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Returns a cached LocalizedStringDictionary for the given strings.\n */\nexport function useLocalizedStringDictionary<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringDictionary<K, T> {\n return (packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName)) || getCachedDictionary(strings);\n}\n\n/**\n * Provides localized string formatting for the current locale. Supports interpolating variables,\n * selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.\n * @param strings - A mapping of languages to localized strings by key.\n */\nexport function useLocalizedStringFormatter<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringFormatter<K, T> {\n let {locale} = useLocale();\n let dictionary = useLocalizedStringDictionary(strings, packageName);\n return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized list formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the list formatter for performance.\n * @param options - Formatting options.\n */\nexport function useListFormatter(options: Intl.ListFormatOptions = {}): Intl.ListFormat {\n let {locale} = useLocale();\n return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DateFormatter} from '@internationalized/date';\nimport {useDeepMemo} from '@react-aria/utils';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\nexport interface DateFormatterOptions extends Intl.DateTimeFormatOptions {\n calendar?: string\n}\n\n/**\n * Provides localized date formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the date formatter for performance.\n * @param options - Formatting options.\n */\nexport function useDateFormatter(options?: DateFormatterOptions): DateFormatter {\n // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.\n options = useDeepMemo(options ?? {}, isEqual);\n let {locale} = useLocale();\n return useMemo(() => new DateFormatter(locale, options), [locale, options]);\n}\n\nfunction isEqual(a: DateFormatterOptions, b: DateFormatterOptions) {\n if (a === b) {\n return true;\n }\n\n let aKeys = Object.keys(a);\n let bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let key of aKeys) {\n if (b[key] !== a[key]) {\n return false;\n }\n }\n\n return true;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {NumberFormatOptions, NumberFormatter} from '@internationalized/number';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {locale} = useLocale();\n return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\n\nlet cache = new Map<string, Intl.Collator>();\n\n/**\n * Provides localized string collation for the current locale. Automatically updates when the locale changes,\n * and handles caching of the collator for performance.\n * @param options - Collator options.\n */\nexport function useCollator(options?: Intl.CollatorOptions): Intl.Collator {\n let {locale} = useLocale();\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey)!;\n }\n\n let formatter = new Intl.Collator(locale, options);\n cache.set(cacheKey, formatter);\n return formatter;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCallback, useMemo} from 'react';\nimport {useCollator} from './useCollator';\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean,\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean,\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n let collator = useCollator({\n usage: 'search',\n ...options\n });\n\n // TODO(later): these methods don't currently support the ignorePunctuation option.\n let startsWith = useCallback((string, substring) => {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings so we can slice safely\n // TODO: take into account the ignorePunctuation option as well...\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(0, substring.length), substring) === 0;\n }, [collator]);\n\n let endsWith = useCallback((string, substring) => {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(-substring.length), substring) === 0;\n }, [collator]);\n\n let contains = useCallback((string, substring) => {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n\n let scan = 0;\n let sliceLen = substring.length;\n for (; scan + sliceLen <= string.length; scan++) {\n let slice = string.slice(scan, scan + sliceLen);\n if (collator.compare(substring, slice) === 0) {\n return true;\n }\n }\n\n return false;\n }, [collator]);\n\n return useMemo(() => ({\n startsWith,\n endsWith,\n contains\n }), [startsWith, endsWith, contains]);\n}\n"],"names":[],"version":3,"file":"real-module.js.map"}