@react-aria/i18n 3.3.4 → 3.3.5

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.map CHANGED
@@ -1 +1 @@
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,MAAzE,CAAR,CAApB;AACA,MAAMC,8CAAS,GAAG,IAAID,GAAJ,CAAQ,CAAC,IAAD,EAAO,IAAP,EAAa,KAAb,EAAoB,KAApB,EAA2B,KAA3B,EAAkC,KAAlC,EAAyC,IAAzC,EAA+C,IAA/C,EAAqD,KAArD,EAA4D,IAA5D,EAAkE,IAAlE,EAAwE,KAAxE,EAA+E,KAA/E,EAAsF,KAAtF,EAA6F,IAA7F,EAAmG,IAAnG,EAAyG,IAAzG,EAA+G,IAA/G,EAAqH,IAArH,CAAR,CAAlB;AAEA;;;;AAGO,SAASE,6CAAT,CAAeC,MAAf,EAA+B;AACpC;AACA;AACA;AACA,MAAIC,IAAI,CAACC,MAAT,EAAiB;AACf;AACA,QAAIC,MAAM,GAAG,IAAIF,IAAI,CAACC,MAAT,CAAgBF,MAAhB,EAAwBI,QAAxB,GAAmCD,MAAhD;AACA,WAAOP,gDAAW,CAACS,GAAZ,CAAgBF,MAAhB,CAAP;AACD,GARmC,CAUpC;;;AACA,MAAIG,IAAI,GAAGN,MAAM,CAACO,KAAP,CAAa,GAAb,EAAkB,CAAlB,CAAX;AAC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;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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEAA,EAUG,AAVH;;;;;;;;;;CAUG,AAVH,EAUG,CAEH,EAA8C,AAA9C,4CAA8C;AAC9C,KAAK,CAAC,iCAAW,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAAA,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;AAAA,CAAC;AAC5G,KAAK,CAAC,+BAAS,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAAA,CAAI;IAAE,CAAI;IAAE,CAAK;IAAE,CAAK;IAAE,CAAK;IAAE,CAAK;IAAE,CAAI;IAAE,CAAI;IAAE,CAAK;IAAE,CAAI;IAAE,CAAI;IAAE,CAAK;IAAE,CAAK;IAAE,CAAK;IAAE,CAAI;IAAE,CAAI;IAAE,CAAI;IAAE,CAAI;IAAE,CAAI;AAAA,CAAC;SAKpI,yCAAK,CAAC,MAAc,EAAE,CAAC;IACrC,EAAgF,AAAhF,8EAAgF;IAChF,EAAuG,AAAvG,qGAAuG;IACvG,EAAa,AAAb,WAAa;IACb,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,EAAa,AAAb,WAAa;QACb,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM;QACtD,MAAM,CAAC,iCAAW,CAAC,GAAG,CAAC,MAAM;IAC/B,CAAC;IAED,EAAgE,AAAhE,8DAAgE;IAChE,GAAG,CAAC,IA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IAAI,GAAG,QAAQ;gBAC9C,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,MAAM,CAAC,EAC1C,MAAM,CAAC,IAAI;YAEf,CAAC;YAED,MAAM,CAAC,KAAK;QACd,CAAC;IACH,CAAC;AACH,CAAC;;","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","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":["/*\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/// <reference types=\"intl-types-extension\" />\n\nexport * from './context';\nexport * from './useMessageFormatter';\nexport * from './useDateFormatter';\nexport * from './useNumberFormatter';\nexport * from './useCollator';\nexport * 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\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\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 {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":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,10 +1,16 @@
1
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
2
- import { NumberFormatter } from "@internationalized/number";
3
- import { DateFormatter } from "@internationalized/date";
4
- import { MessageDictionary, MessageFormatter } from "@internationalized/message";
5
- import { useIsSSR } from "@react-aria/ssr";
6
- import _react, { useEffect, useState, useContext, useCallback, useMemo, useRef } from "react";
1
+ import $4oXB5$react, {useContext as $4oXB5$useContext, useState as $4oXB5$useState, useEffect as $4oXB5$useEffect, useMemo as $4oXB5$useMemo, useCallback as $4oXB5$useCallback, useRef as $4oXB5$useRef} from "react";
2
+ import {useIsSSR as $4oXB5$useIsSSR} from "@react-aria/ssr";
3
+ import {MessageDictionary as $4oXB5$MessageDictionary, MessageFormatter as $4oXB5$MessageFormatter} from "@internationalized/message";
4
+ import {DateFormatter as $4oXB5$DateFormatter} from "@internationalized/date";
5
+ import {NumberFormatter as $4oXB5$NumberFormatter} from "@internationalized/number";
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+ var $1bbc62ad423ac4ed$exports = {};
7
11
 
12
+ $parcel$export($1bbc62ad423ac4ed$exports, "I18nProvider", () => $1bbc62ad423ac4ed$export$a54013f0d02a8f82);
13
+ $parcel$export($1bbc62ad423ac4ed$exports, "useLocale", () => $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7);
8
14
  /*
9
15
  * Copyright 2020 Adobe. All rights reserved.
10
16
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -15,269 +21,251 @@ import _react, { useEffect, useState, useContext, useCallback, useMemo, useRef }
15
21
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
22
  * OF ANY KIND, either express or implied. See the License for the specific language
17
23
  * governing permissions and limitations under the License.
18
- */
19
- // https://en.wikipedia.org/wiki/Right-to-left
20
- const $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);
21
- const $d26e725ad56fbcb2c25f52b7de27$var$RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);
22
- /**
23
- * 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}.
24
- */
25
-
26
- function $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) {
27
- // If the Intl.Locale API is available, use it to get the script for the locale.
28
- // This is more accurate than guessing by language, since languages can be written in multiple scripts.
29
- // @ts-ignore
30
- if (Intl.Locale) {
24
+ */ // https://en.wikipedia.org/wiki/Right-to-left
25
+ const $1ad791d3e8a33aa4$var$RTL_SCRIPTS = new Set([
26
+ 'Arab',
27
+ 'Syrc',
28
+ 'Samr',
29
+ 'Mand',
30
+ 'Thaa',
31
+ 'Mend',
32
+ 'Nkoo',
33
+ 'Adlm',
34
+ 'Rohg',
35
+ 'Hebr'
36
+ ]);
37
+ const $1ad791d3e8a33aa4$var$RTL_LANGS = new Set([
38
+ 'ae',
39
+ 'ar',
40
+ 'arc',
41
+ 'bcc',
42
+ 'bqi',
43
+ 'ckb',
44
+ 'dv',
45
+ 'fa',
46
+ 'glk',
47
+ 'he',
48
+ 'ku',
49
+ 'mzn',
50
+ 'nqo',
51
+ 'pnb',
52
+ 'ps',
53
+ 'sd',
54
+ 'ug',
55
+ 'ur',
56
+ 'yi'
57
+ ]);
58
+ function $1ad791d3e8a33aa4$export$702d680b21cbd764(locale) {
59
+ // If the Intl.Locale API is available, use it to get the script for the locale.
60
+ // This is more accurate than guessing by language, since languages can be written in multiple scripts.
31
61
  // @ts-ignore
32
- let script = new Intl.Locale(locale).maximize().script;
33
- return $d26e725ad56fbcb2c25f52b7de27$var$RTL_SCRIPTS.has(script);
34
- } // If not, just guess by the language (first part of the locale)
62
+ if (Intl.Locale) {
63
+ // @ts-ignore
64
+ let script = new Intl.Locale(locale).maximize().script;
65
+ return $1ad791d3e8a33aa4$var$RTL_SCRIPTS.has(script);
66
+ }
67
+ // If not, just guess by the language (first part of the locale)
68
+ let lang = locale.split('-')[0];
69
+ return $1ad791d3e8a33aa4$var$RTL_LANGS.has(lang);
70
+ }
71
+
72
+
35
73
 
36
74
 
37
- let lang = locale.split('-')[0];
38
- return $d26e725ad56fbcb2c25f52b7de27$var$RTL_LANGS.has(lang);
39
- }
40
75
 
41
- /**
42
- * Gets the locale setting of the browser.
43
- */
44
- function $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale() {
45
- // @ts-ignore
46
- let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
47
- return {
48
- locale,
49
- direction: $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) ? 'rtl' : 'ltr'
50
- };
76
+ function $9a70206312150f3d$export$f09106e7c6677ec5() {
77
+ // @ts-ignore
78
+ let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
79
+ return {
80
+ locale: locale,
81
+ direction: $1ad791d3e8a33aa4$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'
82
+ };
83
+ }
84
+ let $9a70206312150f3d$var$currentLocale = $9a70206312150f3d$export$f09106e7c6677ec5();
85
+ let $9a70206312150f3d$var$listeners = new Set();
86
+ function $9a70206312150f3d$var$updateLocale() {
87
+ $9a70206312150f3d$var$currentLocale = $9a70206312150f3d$export$f09106e7c6677ec5();
88
+ for (let listener of $9a70206312150f3d$var$listeners)listener($9a70206312150f3d$var$currentLocale);
89
+ }
90
+ function $9a70206312150f3d$export$188ec29ebc2bdc3a() {
91
+ let isSSR = $4oXB5$useIsSSR();
92
+ let [defaultLocale, setDefaultLocale] = $4oXB5$useState($9a70206312150f3d$var$currentLocale);
93
+ $4oXB5$useEffect(()=>{
94
+ if ($9a70206312150f3d$var$listeners.size === 0) window.addEventListener('languagechange', $9a70206312150f3d$var$updateLocale);
95
+ $9a70206312150f3d$var$listeners.add(setDefaultLocale);
96
+ return ()=>{
97
+ $9a70206312150f3d$var$listeners.delete(setDefaultLocale);
98
+ if ($9a70206312150f3d$var$listeners.size === 0) window.removeEventListener('languagechange', $9a70206312150f3d$var$updateLocale);
99
+ };
100
+ }, []);
101
+ // We cannot determine the browser's language on the server, so default to
102
+ // en-US. This will be updated after hydration on the client to the correct value.
103
+ if (isSSR) return {
104
+ locale: 'en-US',
105
+ direction: 'ltr'
106
+ };
107
+ return defaultLocale;
51
108
  }
52
109
 
53
- let $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();
54
- let $e851d0b81d46abd5f971c8e95c27f1$var$listeners = new Set();
55
110
 
56
- function $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale() {
57
- $e851d0b81d46abd5f971c8e95c27f1$var$currentLocale = $e851d0b81d46abd5f971c8e95c27f1$export$getDefaultLocale();
58
111
 
59
- for (let listener of $e851d0b81d46abd5f971c8e95c27f1$var$listeners) {
60
- listener($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale);
61
- }
112
+ const $1bbc62ad423ac4ed$var$I18nContext = /*#__PURE__*/ $4oXB5$react.createContext(null);
113
+ function $1bbc62ad423ac4ed$export$a54013f0d02a8f82(props) {
114
+ let { locale: locale , children: children } = props;
115
+ let defaultLocale = $9a70206312150f3d$export$188ec29ebc2bdc3a();
116
+ let value = locale ? {
117
+ locale: locale,
118
+ direction: $1ad791d3e8a33aa4$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'
119
+ } : defaultLocale;
120
+ return(/*#__PURE__*/ $4oXB5$react.createElement($1bbc62ad423ac4ed$var$I18nContext.Provider, {
121
+ value: value
122
+ }, children));
123
+ }
124
+ function $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7() {
125
+ let defaultLocale = $9a70206312150f3d$export$188ec29ebc2bdc3a();
126
+ let context = $4oXB5$useContext($1bbc62ad423ac4ed$var$I18nContext);
127
+ return context || defaultLocale;
62
128
  }
63
- /**
64
- * Returns the current browser/system language, and updates when it changes.
65
- */
66
129
 
67
130
 
68
- function $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale() {
69
- let isSSR = useIsSSR();
70
- let [defaultLocale, setDefaultLocale] = useState($e851d0b81d46abd5f971c8e95c27f1$var$currentLocale);
71
- useEffect(() => {
72
- if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {
73
- window.addEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);
74
- }
131
+ var $9aec7593eb71f732$exports = {};
75
132
 
76
- $e851d0b81d46abd5f971c8e95c27f1$var$listeners.add(setDefaultLocale);
77
- return () => {
78
- $e851d0b81d46abd5f971c8e95c27f1$var$listeners.delete(setDefaultLocale);
79
-
80
- if ($e851d0b81d46abd5f971c8e95c27f1$var$listeners.size === 0) {
81
- window.removeEventListener('languagechange', $e851d0b81d46abd5f971c8e95c27f1$var$updateLocale);
82
- }
83
- };
84
- }, []); // We cannot determine the browser's language on the server, so default to
85
- // en-US. This will be updated after hydration on the client to the correct value.
133
+ $parcel$export($9aec7593eb71f732$exports, "useMessageFormatter", () => $9aec7593eb71f732$export$ec23bf898b1eed85);
86
134
 
87
- if (isSSR) {
88
- return {
89
- locale: 'en-US',
90
- direction: 'ltr'
91
- };
92
- }
93
135
 
94
- return defaultLocale;
95
- }
96
136
 
97
- const $cff8541df3b5c83067b2ab3ee0d20$var$I18nContext = /*#__PURE__*/_react.createContext(null);
98
-
99
- export function I18nProvider(props) {
100
- let {
101
- locale,
102
- children
103
- } = props;
104
- let defaultLocale = $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale();
105
- let value = locale ? {
106
- locale,
107
- direction: $d26e725ad56fbcb2c25f52b7de27$export$isRTL(locale) ? 'rtl' : 'ltr'
108
- } : defaultLocale;
109
- return /*#__PURE__*/_react.createElement($cff8541df3b5c83067b2ab3ee0d20$var$I18nContext.Provider, {
110
- value: value
111
- }, children);
137
+ const $9aec7593eb71f732$var$cache = new WeakMap();
138
+ function $9aec7593eb71f732$var$getCachedDictionary(strings) {
139
+ let dictionary = $9aec7593eb71f732$var$cache.get(strings);
140
+ if (!dictionary) {
141
+ dictionary = new $4oXB5$MessageDictionary(strings);
142
+ $9aec7593eb71f732$var$cache.set(strings, dictionary);
143
+ }
144
+ return dictionary;
112
145
  }
113
- /**
114
- * Returns the current locale and layout direction.
115
- */
116
-
117
- export function useLocale() {
118
- let defaultLocale = $e851d0b81d46abd5f971c8e95c27f1$export$useDefaultLocale();
119
- let context = useContext($cff8541df3b5c83067b2ab3ee0d20$var$I18nContext);
120
- return context || defaultLocale;
146
+ function $9aec7593eb71f732$export$ec23bf898b1eed85(strings) {
147
+ let { locale: locale } = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7();
148
+ let dictionary = $4oXB5$useMemo(()=>$9aec7593eb71f732$var$getCachedDictionary(strings)
149
+ , [
150
+ strings
151
+ ]);
152
+ let formatter = $4oXB5$useMemo(()=>new $4oXB5$MessageFormatter(locale, dictionary)
153
+ , [
154
+ locale,
155
+ dictionary
156
+ ]);
157
+ return $4oXB5$useCallback((key, variables)=>formatter.format(key, variables)
158
+ , [
159
+ formatter
160
+ ]);
121
161
  }
122
- const $f58d206cee90f9c2bf3c03e4522c35$var$cache = new WeakMap();
123
162
 
124
- function $f58d206cee90f9c2bf3c03e4522c35$var$getCachedDictionary(strings) {
125
- let dictionary = $f58d206cee90f9c2bf3c03e4522c35$var$cache.get(strings);
126
163
 
127
- if (!dictionary) {
128
- dictionary = new MessageDictionary(strings);
129
- $f58d206cee90f9c2bf3c03e4522c35$var$cache.set(strings, dictionary);
130
- }
164
+ var $6489b9f106b69c05$exports = {};
165
+
166
+ $parcel$export($6489b9f106b69c05$exports, "useDateFormatter", () => $6489b9f106b69c05$export$85fd5fdf27bacc79);
131
167
 
132
- return dictionary;
168
+
169
+
170
+ function $6489b9f106b69c05$export$85fd5fdf27bacc79(options) {
171
+ // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
172
+ let lastOptions = $4oXB5$useRef(null);
173
+ if (options && lastOptions.current && $6489b9f106b69c05$var$isEqual(options, lastOptions.current)) options = lastOptions.current;
174
+ lastOptions.current = options;
175
+ let { locale: locale } = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7();
176
+ return $4oXB5$useMemo(()=>new $4oXB5$DateFormatter(locale, options)
177
+ , [
178
+ locale,
179
+ options
180
+ ]);
133
181
  }
134
- /**
135
- * Handles formatting ICU Message strings to create localized strings for the current locale.
136
- * Automatically updates when the locale changes, and handles caching of messages for performance.
137
- * @param strings - A mapping of languages to strings by key.
138
- */
139
-
140
-
141
- export function useMessageFormatter(strings) {
142
- let {
143
- locale
144
- } = useLocale();
145
- let dictionary = useMemo(() => $f58d206cee90f9c2bf3c03e4522c35$var$getCachedDictionary(strings), [strings]);
146
- let formatter = useMemo(() => new MessageFormatter(locale, dictionary), [locale, dictionary]);
147
- return useCallback((key, variables) => formatter.format(key, variables), [formatter]);
182
+ function $6489b9f106b69c05$var$isEqual(a, b) {
183
+ if (a === b) return true;
184
+ let aKeys = Object.keys(a);
185
+ let bKeys = Object.keys(b);
186
+ if (aKeys.length !== bKeys.length) return false;
187
+ for (let key of aKeys){
188
+ if (b[key] !== a[key]) return false;
189
+ }
190
+ return true;
148
191
  }
149
192
 
150
- /**
151
- * Provides localized date formatting for the current locale. Automatically updates when the locale changes,
152
- * and handles caching of the date formatter for performance.
153
- * @param options - Formatting options.
154
- */
155
- export function useDateFormatter(options) {
156
- // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
157
- let lastOptions = useRef(null);
158
-
159
- if (options && lastOptions.current && $b0007c63a64054c318efb8b6cd0053f$var$isEqual(options, lastOptions.current)) {
160
- options = lastOptions.current;
161
- }
162
-
163
- lastOptions.current = options;
164
- let {
165
- locale
166
- } = useLocale();
167
- return useMemo(() => new DateFormatter(locale, options), [locale, options]);
168
- }
169
193
 
170
- function $b0007c63a64054c318efb8b6cd0053f$var$isEqual(a, b) {
171
- if (a === b) {
172
- return true;
173
- }
194
+ var $259f0789267e35cd$exports = {};
174
195
 
175
- let aKeys = Object.keys(a);
176
- let bKeys = Object.keys(b);
196
+ $parcel$export($259f0789267e35cd$exports, "useNumberFormatter", () => $259f0789267e35cd$export$b7a616150fdb9f44);
177
197
 
178
- if (aKeys.length !== bKeys.length) {
179
- return false;
180
- }
181
198
 
182
- for (let key of aKeys) {
183
- if (b[key] !== a[key]) {
184
- return false;
185
- }
186
- }
187
199
 
188
- return true;
200
+ function $259f0789267e35cd$export$b7a616150fdb9f44(options = {
201
+ }) {
202
+ let { locale: locale } = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7();
203
+ return $4oXB5$useMemo(()=>new $4oXB5$NumberFormatter(locale, options)
204
+ , [
205
+ locale,
206
+ options
207
+ ]);
189
208
  }
190
209
 
191
- /**
192
- * Provides localized number formatting for the current locale. Automatically updates when the locale changes,
193
- * and handles caching of the number formatter for performance.
194
- * @param options - Formatting options.
195
- */
196
- export function useNumberFormatter(options) {
197
- if (options === void 0) {
198
- options = {};
199
- }
200
-
201
- let {
202
- locale
203
- } = useLocale();
204
- return useMemo(() => new NumberFormatter(locale, options), [locale, options]);
205
- }
206
- let $a4045a18d7252bf6de9312e613c4e$var$cache = new Map();
207
- /**
208
- * Provides localized string collation for the current locale. Automatically updates when the locale changes,
209
- * and handles caching of the collator for performance.
210
- * @param options - Collator options.
211
- */
212
-
213
- export function useCollator(options) {
214
- let {
215
- locale
216
- } = useLocale();
217
- let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');
218
-
219
- if ($a4045a18d7252bf6de9312e613c4e$var$cache.has(cacheKey)) {
220
- return $a4045a18d7252bf6de9312e613c4e$var$cache.get(cacheKey);
221
- }
222
-
223
- let formatter = new Intl.Collator(locale, options);
224
- $a4045a18d7252bf6de9312e613c4e$var$cache.set(cacheKey, formatter);
225
- return formatter;
210
+
211
+ var $2032e35a005f8123$exports = {};
212
+
213
+ $parcel$export($2032e35a005f8123$exports, "useCollator", () => $2032e35a005f8123$export$a16aca283550c30d);
214
+
215
+ let $2032e35a005f8123$var$cache = new Map();
216
+ function $2032e35a005f8123$export$a16aca283550c30d(options) {
217
+ let { locale: locale } = $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7();
218
+ let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
219
+ ).join() : '');
220
+ if ($2032e35a005f8123$var$cache.has(cacheKey)) return $2032e35a005f8123$var$cache.get(cacheKey);
221
+ let formatter = new Intl.Collator(locale, options);
222
+ $2032e35a005f8123$var$cache.set(cacheKey, formatter);
223
+ return formatter;
226
224
  }
227
225
 
228
- /**
229
- * Provides localized string search functionality that is useful for filtering or matching items
230
- * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.
231
- */
232
- export function useFilter(options) {
233
- let collator = useCollator(_babelRuntimeHelpersEsmExtends({
234
- usage: 'search'
235
- }, options)); // TODO(later): these methods don't currently support the ignorePunctuation option.
236
-
237
- return {
238
- startsWith(string, substring) {
239
- if (substring.length === 0) {
240
- return true;
241
- } // Normalize both strings so we can slice safely
242
- // TODO: take into account the ignorePunctuation option as well...
243
-
244
-
245
- string = string.normalize('NFC');
246
- substring = substring.normalize('NFC');
247
- return collator.compare(string.slice(0, substring.length), substring) === 0;
248
- },
249
-
250
- endsWith(string, substring) {
251
- if (substring.length === 0) {
252
- return true;
253
- }
254
-
255
- string = string.normalize('NFC');
256
- substring = substring.normalize('NFC');
257
- return collator.compare(string.slice(-substring.length), substring) === 0;
258
- },
259
-
260
- contains(string, substring) {
261
- if (substring.length === 0) {
262
- return true;
263
- }
264
-
265
- string = string.normalize('NFC');
266
- substring = substring.normalize('NFC');
267
- let scan = 0;
268
- let sliceLen = substring.length;
269
-
270
- for (; scan + sliceLen <= string.length; scan++) {
271
- let slice = string.slice(scan, scan + sliceLen);
272
-
273
- if (collator.compare(substring, slice) === 0) {
274
- return true;
275
- }
276
- }
277
226
 
278
- return false;
279
- }
227
+ var $eb14a2d22a778b07$exports = {};
228
+
229
+ $parcel$export($eb14a2d22a778b07$exports, "useFilter", () => $eb14a2d22a778b07$export$3274cf84b703fff);
280
230
 
281
- };
231
+ function $eb14a2d22a778b07$export$3274cf84b703fff(options) {
232
+ let collator = $2032e35a005f8123$export$a16aca283550c30d({
233
+ usage: 'search',
234
+ ...options
235
+ });
236
+ // TODO(later): these methods don't currently support the ignorePunctuation option.
237
+ return {
238
+ startsWith (string, substring) {
239
+ if (substring.length === 0) return true;
240
+ // Normalize both strings so we can slice safely
241
+ // TODO: take into account the ignorePunctuation option as well...
242
+ string = string.normalize('NFC');
243
+ substring = substring.normalize('NFC');
244
+ return collator.compare(string.slice(0, substring.length), substring) === 0;
245
+ },
246
+ endsWith (string, substring) {
247
+ if (substring.length === 0) return true;
248
+ string = string.normalize('NFC');
249
+ substring = substring.normalize('NFC');
250
+ return collator.compare(string.slice(-substring.length), substring) === 0;
251
+ },
252
+ contains (string, substring) {
253
+ if (substring.length === 0) return true;
254
+ string = string.normalize('NFC');
255
+ substring = substring.normalize('NFC');
256
+ let scan = 0;
257
+ let sliceLen = substring.length;
258
+ for(; scan + sliceLen <= string.length; scan++){
259
+ let slice = string.slice(scan, scan + sliceLen);
260
+ if (collator.compare(substring, slice) === 0) return true;
261
+ }
262
+ return false;
263
+ }
264
+ };
282
265
  }
266
+
267
+
268
+
269
+
270
+ export {$1bbc62ad423ac4ed$export$a54013f0d02a8f82 as I18nProvider, $1bbc62ad423ac4ed$export$43bb16f9c6d9e3f7 as useLocale, $9aec7593eb71f732$export$ec23bf898b1eed85 as useMessageFormatter, $6489b9f106b69c05$export$85fd5fdf27bacc79 as useDateFormatter, $259f0789267e35cd$export$b7a616150fdb9f44 as useNumberFormatter, $2032e35a005f8123$export$a16aca283550c30d as useCollator, $eb14a2d22a778b07$export$3274cf84b703fff as useFilter};
283
271
  //# sourceMappingURL=module.js.map