@react-aria/i18n 3.2.0 → 3.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +64 -186
- package/dist/main.js.map +1 -1
- package/dist/module.js +54 -184
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +9 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -5
- package/src/index.ts +2 -1
- package/src/useDateFormatter.ts +32 -8
- package/src/useMessageFormatter.ts +17 -75
- package/src/useNumberFormatter.ts +4 -30
- package/src/utils.ts +0 -33
- package/src/useNumberParser.ts +0 -48
package/dist/main.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var {
|
|
4
|
+
NumberFormatter
|
|
5
|
+
} = require("@internationalized/number");
|
|
6
|
+
|
|
7
|
+
var {
|
|
8
|
+
DateFormatter
|
|
9
|
+
} = require("@internationalized/date");
|
|
10
|
+
|
|
11
|
+
var {
|
|
12
|
+
MessageDictionary,
|
|
13
|
+
MessageFormatter
|
|
14
|
+
} = require("@internationalized/message");
|
|
4
15
|
|
|
5
16
|
var {
|
|
6
17
|
useIsSSR
|
|
@@ -15,6 +26,7 @@ var {
|
|
|
15
26
|
useState,
|
|
16
27
|
useContext,
|
|
17
28
|
useCallback,
|
|
29
|
+
useMemo,
|
|
18
30
|
useRef
|
|
19
31
|
} = _react2;
|
|
20
32
|
|
|
@@ -55,42 +67,6 @@ function $dbb62b32f79d03a795a46f9fbec514c$export$isRTL(locale) {
|
|
|
55
67
|
return $dbb62b32f79d03a795a46f9fbec514c$var$RTL_LANGS.has(lang);
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
function $dbb62b32f79d03a795a46f9fbec514c$export$numberFormatSignDisplayPolyfill(numberFormat, signDisplay, num) {
|
|
59
|
-
if (signDisplay === 'auto') {
|
|
60
|
-
return numberFormat.format(num);
|
|
61
|
-
} else if (signDisplay === 'never') {
|
|
62
|
-
return numberFormat.format(Math.abs(num));
|
|
63
|
-
} else {
|
|
64
|
-
let needsPositiveSign = false;
|
|
65
|
-
|
|
66
|
-
if (signDisplay === 'always') {
|
|
67
|
-
needsPositiveSign = num > 0 || Object.is(num, 0);
|
|
68
|
-
} else if (signDisplay === 'exceptZero') {
|
|
69
|
-
if (Object.is(num, -0) || Object.is(num, 0)) {
|
|
70
|
-
num = Math.abs(num);
|
|
71
|
-
} else {
|
|
72
|
-
needsPositiveSign = num > 0;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (needsPositiveSign) {
|
|
77
|
-
let negative = numberFormat.format(-num);
|
|
78
|
-
let noSign = numberFormat.format(num); // ignore RTL/LTR marker character
|
|
79
|
-
|
|
80
|
-
let minus = negative.replace(noSign, '').replace(/\u200e|\u061C/, '');
|
|
81
|
-
|
|
82
|
-
if ([...minus].length !== 1) {
|
|
83
|
-
console.warn('@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let positive = negative.replace(noSign, '!!!').replace(minus, '+').replace('!!!', noSign);
|
|
87
|
-
return positive;
|
|
88
|
-
} else {
|
|
89
|
-
return numberFormat.format(num);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
70
|
/**
|
|
95
71
|
* Gets the locale setting of the browser.
|
|
96
72
|
*/
|
|
@@ -147,7 +123,7 @@ function $c53c7d716f930bd5da78e9efb99e3e$export$useDefaultLocale() {
|
|
|
147
123
|
return defaultLocale;
|
|
148
124
|
}
|
|
149
125
|
|
|
150
|
-
const $aa95c2b730b505b265f124d9aec67193$var$I18nContext = _react.createContext(null);
|
|
126
|
+
const $aa95c2b730b505b265f124d9aec67193$var$I18nContext = /*#__PURE__*/_react.createContext(null);
|
|
151
127
|
|
|
152
128
|
function I18nProvider(props) {
|
|
153
129
|
let {
|
|
@@ -177,191 +153,93 @@ function useLocale() {
|
|
|
177
153
|
}
|
|
178
154
|
|
|
179
155
|
exports.useLocale = useLocale;
|
|
180
|
-
const $a5aefbc9b72193c190dce301e0eb39$var$
|
|
156
|
+
const $a5aefbc9b72193c190dce301e0eb39$var$cache = new WeakMap();
|
|
157
|
+
|
|
158
|
+
function $a5aefbc9b72193c190dce301e0eb39$var$getCachedDictionary(strings) {
|
|
159
|
+
let dictionary = $a5aefbc9b72193c190dce301e0eb39$var$cache.get(strings);
|
|
160
|
+
|
|
161
|
+
if (!dictionary) {
|
|
162
|
+
dictionary = new MessageDictionary(strings);
|
|
163
|
+
$a5aefbc9b72193c190dce301e0eb39$var$cache.set(strings, dictionary);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return dictionary;
|
|
167
|
+
}
|
|
181
168
|
/**
|
|
182
169
|
* Handles formatting ICU Message strings to create localized strings for the current locale.
|
|
183
170
|
* Automatically updates when the locale changes, and handles caching of messages for performance.
|
|
184
171
|
* @param strings - A mapping of languages to strings by key.
|
|
185
172
|
*/
|
|
186
173
|
|
|
174
|
+
|
|
187
175
|
function useMessageFormatter(strings) {
|
|
188
176
|
let {
|
|
189
|
-
locale
|
|
190
|
-
} = useLocale();
|
|
191
|
-
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
if (localeCache && localeCache.has(currentLocale)) {
|
|
195
|
-
return localeCache.get(currentLocale);
|
|
196
|
-
} // Add to the formatter cache if needed
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (!localeCache) {
|
|
200
|
-
localeCache = new Map();
|
|
201
|
-
$a5aefbc9b72193c190dce301e0eb39$var$formatterCache.set(strings, localeCache);
|
|
202
|
-
} // Get the strings for the current locale
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
let localeStrings = $a5aefbc9b72193c190dce301e0eb39$var$selectLocale(strings, currentLocale); // Create a new message formatter
|
|
206
|
-
|
|
207
|
-
let cache = {};
|
|
208
|
-
|
|
209
|
-
let formatMessage = (key, variables) => {
|
|
210
|
-
let message = cache[key + '.' + currentLocale];
|
|
211
|
-
|
|
212
|
-
if (!message) {
|
|
213
|
-
let msg = localeStrings[key];
|
|
214
|
-
|
|
215
|
-
if (!msg) {
|
|
216
|
-
throw new Error("Could not find intl message " + key + " in " + currentLocale + " locale");
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
message = new _intlMessageformat(msg, currentLocale);
|
|
220
|
-
cache[key] = message;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return message.format(variables);
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
localeCache.set(currentLocale, formatMessage);
|
|
227
|
-
return formatMessage;
|
|
177
|
+
locale
|
|
178
|
+
} = useLocale();
|
|
179
|
+
let dictionary = useMemo(() => $a5aefbc9b72193c190dce301e0eb39$var$getCachedDictionary(strings), [strings]);
|
|
180
|
+
let formatter = useMemo(() => new MessageFormatter(locale, dictionary), [locale, dictionary]);
|
|
181
|
+
return useCallback((key, variables) => formatter.format(key, variables), [formatter]);
|
|
228
182
|
}
|
|
229
183
|
|
|
230
184
|
exports.useMessageFormatter = useMessageFormatter;
|
|
231
185
|
|
|
232
|
-
function $a5aefbc9b72193c190dce301e0eb39$var$selectLocale(strings, locale) {
|
|
233
|
-
// If there is an exact match, use it.
|
|
234
|
-
if (strings[locale]) {
|
|
235
|
-
return strings[locale];
|
|
236
|
-
} // Attempt to find the closest match by language.
|
|
237
|
-
// For example, if the locale is fr-CA (French Canadian), but there is only
|
|
238
|
-
// an fr-FR (France) set of strings, use that.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
let language = $a5aefbc9b72193c190dce301e0eb39$var$getLanguage(locale);
|
|
242
|
-
|
|
243
|
-
for (let key in strings) {
|
|
244
|
-
if (key.startsWith(language + '-')) {
|
|
245
|
-
return strings[key];
|
|
246
|
-
}
|
|
247
|
-
} // Nothing close, use english.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return strings['en-US'];
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function $a5aefbc9b72193c190dce301e0eb39$var$getLanguage(locale) {
|
|
254
|
-
// @ts-ignore
|
|
255
|
-
if (Intl.Locale) {
|
|
256
|
-
// @ts-ignore
|
|
257
|
-
return new Intl.Locale(locale).language;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return locale.split('-')[0];
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
let $bdeee39f835a1e28966186127db96579$var$formatterCache = new Map();
|
|
264
186
|
/**
|
|
265
187
|
* Provides localized date formatting for the current locale. Automatically updates when the locale changes,
|
|
266
188
|
* and handles caching of the date formatter for performance.
|
|
267
189
|
* @param options - Formatting options.
|
|
268
190
|
*/
|
|
269
|
-
|
|
270
191
|
function useDateFormatter(options) {
|
|
192
|
+
// Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
|
|
193
|
+
let lastOptions = useRef(null);
|
|
194
|
+
|
|
195
|
+
if (options && lastOptions.current && $bdeee39f835a1e28966186127db96579$var$isEqual(options, lastOptions.current)) {
|
|
196
|
+
options = lastOptions.current;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
lastOptions.current = options;
|
|
271
200
|
let {
|
|
272
201
|
locale
|
|
273
202
|
} = useLocale();
|
|
274
|
-
|
|
203
|
+
return useMemo(() => new DateFormatter(locale, options), [locale, options]);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
exports.useDateFormatter = useDateFormatter;
|
|
275
207
|
|
|
276
|
-
|
|
277
|
-
|
|
208
|
+
function $bdeee39f835a1e28966186127db96579$var$isEqual(a, b) {
|
|
209
|
+
if (a === b) {
|
|
210
|
+
return true;
|
|
278
211
|
}
|
|
279
212
|
|
|
280
|
-
let
|
|
281
|
-
|
|
282
|
-
return formatter;
|
|
283
|
-
}
|
|
213
|
+
let aKeys = Object.keys(a);
|
|
214
|
+
let bKeys = Object.keys(b);
|
|
284
215
|
|
|
285
|
-
|
|
216
|
+
if (aKeys.length !== bKeys.length) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
286
219
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
let {
|
|
293
|
-
locale
|
|
294
|
-
} = useLocale();
|
|
295
|
-
const numberData = useRef({
|
|
296
|
-
group: null,
|
|
297
|
-
decimal: null,
|
|
298
|
-
numeral: null,
|
|
299
|
-
index: null
|
|
300
|
-
});
|
|
301
|
-
useEffect(() => {
|
|
302
|
-
const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
|
|
303
|
-
const numerals = [...new Intl.NumberFormat(locale, {
|
|
304
|
-
useGrouping: false
|
|
305
|
-
}).format(9876543210)].reverse();
|
|
306
|
-
const index = new Map(numerals.map((d, i) => [d, i]));
|
|
307
|
-
numberData.current.group = new RegExp("[" + parts.find(d => d.type === 'group').value + "]", 'g');
|
|
308
|
-
numberData.current.decimal = new RegExp("[" + parts.find(d => d.type === 'decimal').value + "]");
|
|
309
|
-
numberData.current.numeral = new RegExp("[" + numerals.join('') + "]", 'g');
|
|
310
|
-
|
|
311
|
-
numberData.current.index = d => index.get(d);
|
|
312
|
-
}, [locale]);
|
|
313
|
-
const parse = useCallback(value => {
|
|
314
|
-
value = value.trim().replace(numberData.current.group, '').replace(numberData.current.decimal, '.').replace(numberData.current.numeral, numberData.current.index);
|
|
315
|
-
return value ? +value : NaN;
|
|
316
|
-
}, []);
|
|
317
|
-
return {
|
|
318
|
-
parse
|
|
319
|
-
};
|
|
320
|
-
}
|
|
220
|
+
for (let key of aKeys) {
|
|
221
|
+
if (b[key] !== a[key]) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
321
225
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
let $fa77db1482937b6cdb6683d9d7eb896$var$supportsSignDisplay = false;
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
325
228
|
|
|
326
|
-
try {
|
|
327
|
-
// @ts-ignore
|
|
328
|
-
$fa77db1482937b6cdb6683d9d7eb896$var$supportsSignDisplay = new Intl.NumberFormat('de-DE', {
|
|
329
|
-
signDisplay: 'exceptZero'
|
|
330
|
-
}).resolvedOptions().signDisplay === 'exceptZero'; // eslint-disable-next-line no-empty
|
|
331
|
-
} catch (e) {}
|
|
332
229
|
/**
|
|
333
230
|
* Provides localized number formatting for the current locale. Automatically updates when the locale changes,
|
|
334
231
|
* and handles caching of the number formatter for performance.
|
|
335
232
|
* @param options - Formatting options.
|
|
336
233
|
*/
|
|
337
|
-
|
|
338
|
-
|
|
339
234
|
function useNumberFormatter(options) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
} = useLocale();
|
|
343
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');
|
|
344
|
-
|
|
345
|
-
if ($fa77db1482937b6cdb6683d9d7eb896$var$formatterCache.has(cacheKey)) {
|
|
346
|
-
return $fa77db1482937b6cdb6683d9d7eb896$var$formatterCache.get(cacheKey);
|
|
235
|
+
if (options === void 0) {
|
|
236
|
+
options = {};
|
|
347
237
|
}
|
|
348
238
|
|
|
349
|
-
let numberFormatter = new Intl.NumberFormat(locale, options); // @ts-ignore
|
|
350
|
-
|
|
351
239
|
let {
|
|
352
|
-
|
|
353
|
-
} =
|
|
354
|
-
|
|
355
|
-
get(target, property) {
|
|
356
|
-
if (property === 'format') {
|
|
357
|
-
return v => $dbb62b32f79d03a795a46f9fbec514c$export$numberFormatSignDisplayPolyfill(numberFormatter, signDisplay, v);
|
|
358
|
-
} else {
|
|
359
|
-
return target[property];
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
}) : numberFormatter);
|
|
364
|
-
return numberFormatter;
|
|
240
|
+
locale
|
|
241
|
+
} = useLocale();
|
|
242
|
+
return useMemo(() => new NumberFormatter(locale, options), [locale, options]);
|
|
365
243
|
}
|
|
366
244
|
|
|
367
245
|
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ACA,aAAOJ,QAAQ,CAACK,OAAT,CAAiBH,MAAM,CAACI,KAAP,CAAa,CAACH,SAAS,CAACvG,MAAxB,CAAjB,EAAkDuG,SAAlD,MAAiE,CAAxE;AACD,KApBI;;AAqBLK,IAAAA,QAAQ,CAACN,MAAD,EAASC,SAAT,EAAoB;AAC1B,UAAIA,SAAS,CAACvG,MAAV,KAAqB,CAAzB,EAA4B;AAC1B,eAAO,IAAP;AACD;;AAEDsG,MAAAA,MAAM,GAAGA,MAAM,CAACE,SAAP,CAAiB,KAAjB,CAAT;AACAD,MAAAA,SAAS,GAAGA,SAAS,CAACC,SAAV,CAAoB,KAApB,CAAZ;AAEA,UAAIK,IAAI,GAAG,CAAX;AACA,UAAIC,QAAQ,GAAGP,SAAS,CAACvG,MAAzB;;AACA,aAAO6G,IAAI,GAAGC,QAAP,IAAmBR,MAAM,CAACtG,MAAjC,EAAyC6G,IAAI,EAA7C,EAAiD;AAC/C,YAAIH,KAAK,GAAGJ,MAAM,CAACI,KAAP,CAAaG,IAAb,EAAmBA,IAAI,GAAGC,QAA1B,CAAZ;;AACA,YAAIV,QAAQ,CAACK,OAAT,CAAiBF,SAAjB,EAA4BG,KAA5B,MAAuC,CAA3C,EAA8C;AAC5C,iBAAO,IAAP;AACD;AACF;;AAED,aAAO,KAAP;AACD;;AAvCI,GAAP;AAyCD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/i18n/src/utils.ts","./packages/@react-aria/i18n/src/useDefaultLocale.ts","./packages/@react-aria/i18n/src/context.tsx","./packages/@react-aria/i18n/src/useMessageFormatter.ts","./packages/@react-aria/i18n/src/useDateFormatter.ts","./packages/@react-aria/i18n/src/useNumberParser.ts","./packages/@react-aria/i18n/src/useNumberFormatter.ts","./packages/@react-aria/i18n/src/useCollator.ts","./packages/@react-aria/i18n/src/useFilter.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\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(locale: string) {\n // If the Intl.Locale API is available, use it to get the script for the locale.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n // @ts-ignore\n if (Intl.Locale) {\n // @ts-ignore\n let script = new Intl.Locale(locale).maximize().script;\n return RTL_SCRIPTS.has(script);\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = locale.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n\nexport function numberFormatSignDisplayPolyfill(numberFormat: Intl.NumberFormat, signDisplay: 'always' | 'exceptZero' | 'auto' | 'never', num: number) {\n if (signDisplay === 'auto') {\n return numberFormat.format(num);\n } else if (signDisplay === 'never') {\n return numberFormat.format(Math.abs(num));\n } else {\n let needsPositiveSign = false;\n if (signDisplay === 'always') {\n needsPositiveSign = num > 0 || Object.is(num, 0);\n } else if (signDisplay === 'exceptZero') {\n if (Object.is(num, -0) || Object.is(num, 0)) {\n num = Math.abs(num);\n } else {\n needsPositiveSign = num > 0;\n }\n }\n\n if (needsPositiveSign) {\n let negative = numberFormat.format(-num);\n let noSign = numberFormat.format(num);\n // ignore RTL/LTR marker character\n let minus = negative.replace(noSign, '').replace(/\\u200e|\\u061C/, '');\n if ([...minus].length !== 1) {\n console.warn('@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case');\n }\n let positive = negative.replace(noSign, '!!!').replace(minus, '+').replace('!!!', noSign);\n return positive;\n } else {\n return numberFormat.format(num);\n }\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\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/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n // @ts-ignore\n let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\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","/*\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\ninterface ProviderProps {\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);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: ProviderProps) {\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\nimport IntlMessageFormat from 'intl-messageformat';\nimport {useLocale} from './context';\n\ntype MessageFormatterStrings = {\n [lang: string]: {\n [key: string]: string\n }\n};\n\ntype FormatMessage = (key: string, variables?: {[key: string]: any}) => string;\n\nconst formatterCache = new Map();\n\n/**\n * Handles formatting ICU Message strings to create localized strings for the current locale.\n * Automatically updates when the locale changes, and handles caching of messages for performance.\n * @param strings - A mapping of languages to strings by key.\n */\nexport function useMessageFormatter(strings: MessageFormatterStrings): FormatMessage {\n let {locale: currentLocale} = useLocale();\n\n // Check the cache\n let localeCache = formatterCache.get(strings);\n if (localeCache && localeCache.has(currentLocale)) {\n return localeCache.get(currentLocale);\n }\n\n // Add to the formatter cache if needed\n if (!localeCache) {\n localeCache = new Map();\n formatterCache.set(strings, localeCache);\n }\n\n // Get the strings for the current locale\n let localeStrings = selectLocale(strings, currentLocale);\n\n // Create a new message formatter\n let cache = {};\n let formatMessage = (key, variables) => {\n let message = cache[key + '.' + currentLocale];\n if (!message) {\n let msg = localeStrings[key];\n if (!msg) {\n throw new Error(`Could not find intl message ${key} in ${currentLocale} locale`);\n }\n\n message = new IntlMessageFormat(msg, currentLocale);\n cache[key] = message;\n }\n\n return message.format(variables);\n };\n\n localeCache.set(currentLocale, formatMessage);\n return formatMessage;\n}\n\nfunction selectLocale(strings, locale) {\n // If there is an exact match, use it.\n if (strings[locale]) {\n return strings[locale];\n }\n\n // Attempt to find the closest match by language.\n // For example, if the locale is fr-CA (French Canadian), but there is only\n // an fr-FR (France) set of strings, use that.\n let language = getLanguage(locale);\n for (let key in strings) {\n if (key.startsWith(language + '-')) {\n return strings[key];\n }\n }\n\n // Nothing close, use english.\n return strings['en-US'];\n}\n\nfunction getLanguage(locale) {\n // @ts-ignore\n if (Intl.Locale) {\n // @ts-ignore\n return new Intl.Locale(locale).language;\n }\n\n return locale.split('-')[0];\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 formatterCache = new Map<string, Intl.DateTimeFormat>();\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?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\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 (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey);\n }\n\n let formatter = new Intl.DateTimeFormat(locale, options);\n formatterCache.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, useEffect, useRef} from 'react';\nimport {useLocale} from './context';\n\ntype NumberParser = {\n parse: (value:string) => number\n}\n\n/**\n * Provides localized number parsing for the current locale.\n * Idea from https://observablehq.com/@mbostock/localized-number-parsing.\n */\nexport function useNumberParser(): NumberParser {\n let {locale} = useLocale();\n const numberData = useRef({group: null, decimal: null, numeral: null, index: null});\n\n useEffect(() => {\n const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);\n const numerals = [...new Intl.NumberFormat(locale, {useGrouping: false}).format(9876543210)].reverse();\n const index = new Map(numerals.map((d, i) => [d, i]));\n \n numberData.current.group = new RegExp(`[${parts.find(d => d.type === 'group').value}]`, 'g');\n numberData.current.decimal = new RegExp(`[${parts.find(d => d.type === 'decimal').value}]`);\n numberData.current.numeral = new RegExp(`[${numerals.join('')}]`, 'g');\n numberData.current.index = d => index.get(d);\n }, [locale]);\n\n const parse = useCallback((value:string) => {\n value = value.trim()\n .replace(numberData.current.group, '')\n .replace(numberData.current.decimal, '.')\n .replace(numberData.current.numeral, numberData.current.index);\n return value ? +value : NaN;\n }, []);\n\n return {parse};\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 {numberFormatSignDisplayPolyfill} from './utils';\nimport {useLocale} from './context';\n\nlet formatterCache = new Map<string, Intl.NumberFormat>();\n\nlet supportsSignDisplay = false;\ntry {\n // @ts-ignore\n supportsSignDisplay = (new Intl.NumberFormat('de-DE', {signDisplay: 'exceptZero'})).resolvedOptions().signDisplay === 'exceptZero';\n // eslint-disable-next-line no-empty\n} catch (e) {}\n\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?: Intl.NumberFormatOptions): Intl.NumberFormat {\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 (formatterCache.has(cacheKey)) {\n return formatterCache.get(cacheKey);\n }\n\n let numberFormatter = new Intl.NumberFormat(locale, options);\n // @ts-ignore\n let {signDisplay} = options || {};\n formatterCache.set(cacheKey, (!supportsSignDisplay && signDisplay != null) ? new Proxy(numberFormatter, {\n get(target, property) {\n if (property === 'format') {\n return (v) => numberFormatSignDisplayPolyfill(numberFormatter, signDisplay, v);\n } else {\n return target[property];\n }\n }\n }) : numberFormatter);\n return numberFormatter;\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 {useCollator} from './useCollator';\n\ninterface 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\n return {\n startsWith(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 },\n endsWith(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 },\n contains(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 }\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","RTL_SCRIPTS","Set","RTL_LANGS","isRTL","locale","Intl","Locale","script","maximize","has","lang","split","numberFormatSignDisplayPolyfill","numberFormat","signDisplay","num","format","Math","abs","needsPositiveSign","Object","is","negative","noSign","minus","replace","length","console","warn","positive","getDefaultLocale","navigator","language","userLanguage","direction","currentLocale","listeners","updateLocale","listener","useDefaultLocale","isSSR","useIsSSR","defaultLocale","setDefaultLocale","useState","useEffect","size","window","addEventListener","add","delete","removeEventListener","I18nContext","React","createContext","I18nProvider","props","children","value","useLocale","context","useContext","formatterCache","Map","useMessageFormatter","strings","localeCache","get","set","localeStrings","selectLocale","cache","formatMessage","key","variables","message","msg","Error","IntlMessageFormat","getLanguage","startsWith","useDateFormatter","options","cacheKey","entries","sort","b","join","formatter","DateTimeFormat","useNumberParser","numberData","useRef","group","decimal","numeral","index","parts","NumberFormat","formatToParts","numerals","useGrouping","reverse","map","d","i","current","RegExp","find","type","parse","useCallback","trim","NaN","supportsSignDisplay","resolvedOptions","e","useNumberFormatter","numberFormatter","Proxy","target","property","v","useCollator","Collator","useFilter","collator","usage","string","substring","normalize","compare","slice","endsWith","contains","scan","sliceLen"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACFD;;;;;;;;;;;AAYA;AACA,MAAMG,gDAAW,GAAG,IAAIC,GAAJ,CAAQ,CAAC,MAAD,EAAS,MAAT,EAAiB,MAAjB,EAAyB,MAAzB,EAAiC,MAAjC,EAAyC,MAAzC,EAAiD,MAAjD,EAAyD,MAAzD,EAAiE,MAAjE,EAAyE,MAA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ApD,MAAmE,CAA1E;AACD,KAXI;;AAYLI,IAAAA,QAAQ,CAACL,MAAD,EAASC,SAAT,EAAoB;AAC1B,UAAIA,SAAS,CAACf,MAAV,KAAqB,CAAzB,EAA4B;AAC1B,eAAO,IAAP;AACD;;AAEDc,MAAAA,MAAM,GAAGA,MAAM,CAACE,SAAP,CAAiB,KAAjB,CAAT;AACAD,MAAAA,SAAS,GAAGA,SAAS,CAACC,SAAV,CAAoB,KAApB,CAAZ;AACA,aAAOL,QAAQ,CAACM,OAAT,CAAiBH,MAAM,CAACI,KAAP,CAAa,CAACH,SAAS,CAACf,MAAxB,CAAjB,EAAkDe,SAAlD,MAAiE,CAAxE;AACD,KApBI;;AAqBLK,IAAAA,QAAQ,CAACN,MAAD,EAASC,SAAT,EAAoB;AAC1B,UAAIA,SAAS,CAACf,MAAV,KAAqB,CAAzB,EAA4B;AAC1B,eAAO,IAAP;AACD;;AAEDc,MAAAA,MAAM,GAAGA,MAAM,CAACE,SAAP,CAAiB,KAAjB,CAAT;AACAD,MAAAA,SAAS,GAAGA,SAAS,CAACC,SAAV,CAAoB,KAApB,CAAZ;AAEA,UAAIK,IAAI,GAAG,CAAX;AACA,UAAIC,QAAQ,GAAGP,SAAS,CAACf,MAAzB;;AACA,aAAOqB,IAAI,GAAGC,QAAP,IAAmBR,MAAM,CAACd,MAAjC,EAAyCqB,IAAI,EAA7C,EAAiD;AAC/C,YAAIH,KAAK,GAAGJ,MAAM,CAACI,KAAP,CAAaG,IAAb,EAAmBA,IAAI,GAAGC,QAA1B,CAAZ;;AACA,YAAIX,QAAQ,CAACM,OAAT,CAAiBF,SAAjB,EAA4BG,KAA5B,MAAuC,CAA3C,EAA8C;AAC5C,iBAAO,IAAP;AACD;AACF;;AAED,aAAO,KAAP;AACD;;AAvCI,GAAP;AAyCD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/i18n/src/utils.ts","./packages/@react-aria/i18n/src/useDefaultLocale.ts","./packages/@react-aria/i18n/src/context.tsx","./packages/@react-aria/i18n/src/useMessageFormatter.ts","./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":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\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(locale: string) {\n // If the Intl.Locale API is available, use it to get the script for the locale.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n // @ts-ignore\n if (Intl.Locale) {\n // @ts-ignore\n let script = new Intl.Locale(locale).maximize().script;\n return RTL_SCRIPTS.has(script);\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = locale.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/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n // @ts-ignore\n let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\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","/*\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\ninterface ProviderProps {\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);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: ProviderProps) {\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\nimport {LocalizedStrings, MessageDictionary, MessageFormatter} from '@internationalized/message';\nimport {useCallback, useMemo} from 'react';\nimport {useLocale} from './context';\n\ntype FormatMessage = (key: string, variables?: {[key: string]: any}) => string;\n\nconst cache = new WeakMap();\nfunction getCachedDictionary(strings: LocalizedStrings) {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new MessageDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Handles formatting ICU Message strings to create localized strings for the current locale.\n * Automatically updates when the locale changes, and handles caching of messages for performance.\n * @param strings - A mapping of languages to strings by key.\n */\nexport function useMessageFormatter(strings: LocalizedStrings): FormatMessage {\n let {locale} = useLocale();\n let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n let formatter = useMemo(() => new MessageFormatter(locale, dictionary), [locale, dictionary]);\n return useCallback((key, variables) => formatter.format(key, variables), [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 {DateFormatter} from '@internationalized/date';\nimport {useLocale} from './context';\nimport {useMemo, useRef} from 'react';\n\ninterface 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 let lastOptions = useRef(null);\n if (options && lastOptions.current && isEqual(options, lastOptions.current)) {\n options = lastOptions.current;\n }\n\n lastOptions.current = options;\n\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 {useCollator} from './useCollator';\n\ninterface 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\n return {\n startsWith(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 },\n endsWith(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 },\n contains(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 }\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","RTL_SCRIPTS","Set","RTL_LANGS","isRTL","locale","Intl","Locale","script","maximize","has","lang","split","getDefaultLocale","navigator","language","userLanguage","direction","currentLocale","listeners","updateLocale","listener","useDefaultLocale","isSSR","useIsSSR","defaultLocale","setDefaultLocale","useState","useEffect","size","window","addEventListener","add","delete","removeEventListener","I18nContext","React","createContext","I18nProvider","props","children","value","useLocale","context","useContext","cache","WeakMap","getCachedDictionary","strings","dictionary","get","MessageDictionary","set","useMessageFormatter","useMemo","formatter","MessageFormatter","useCallback","key","variables","format","useDateFormatter","options","lastOptions","useRef","current","isEqual","DateFormatter","b","aKeys","Object","keys","bKeys","length","useNumberFormatter","NumberFormatter","Map","useCollator","cacheKey","entries","sort","join","Collator","useFilter","collator","usage","startsWith","string","substring","normalize","compare","slice","endsWith","contains","scan","sliceLen"],"version":3,"file":"main.js.map"}
|