@react-aria/i18n 3.11.0 → 3.11.1
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/context.main.js +10 -4
- package/dist/context.main.js.map +1 -1
- package/dist/context.mjs +11 -5
- package/dist/context.module.js +10 -4
- package/dist/context.module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useCollator.main.js +1 -1
- package/dist/useCollator.mjs +2 -2
- package/dist/useCollator.module.js +1 -1
- package/dist/useDateFormatter.mjs +1 -1
- package/dist/useDefaultLocale.main.js +8 -8
- package/dist/useDefaultLocale.mjs +9 -9
- package/dist/useDefaultLocale.module.js +8 -8
- package/dist/useFilter.main.js +7 -7
- package/dist/useFilter.mjs +8 -8
- package/dist/useFilter.module.js +7 -7
- package/dist/useListFormatter.mjs +1 -1
- package/dist/useLocalizedStringFormatter.mjs +1 -1
- package/dist/useMessageFormatter.mjs +1 -1
- package/dist/useNumberFormatter.mjs +1 -1
- package/dist/utils.main.js +32 -32
- package/dist/utils.mjs +33 -33
- package/dist/utils.module.js +32 -32
- package/package.json +9 -9
- package/server/index.js +9 -9
- package/server/index.mjs +9 -9
- package/src/context.tsx +10 -4
package/dist/context.main.js
CHANGED
|
@@ -30,10 +30,16 @@ const $47fa5ec5ff482271$var$I18nContext = /*#__PURE__*/ (0, ($parcel$interopDefa
|
|
|
30
30
|
function $47fa5ec5ff482271$export$a54013f0d02a8f82(props) {
|
|
31
31
|
let { locale: locale, children: children } = props;
|
|
32
32
|
let defaultLocale = (0, $2919bdec75484e64$exports.useDefaultLocale)();
|
|
33
|
-
let value =
|
|
34
|
-
locale
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
let value = (0, ($parcel$interopDefault($e7RNT$react))).useMemo(()=>{
|
|
34
|
+
if (!locale) return defaultLocale;
|
|
35
|
+
return {
|
|
36
|
+
locale: locale,
|
|
37
|
+
direction: (0, $4d65847630a056a8$exports.isRTL)(locale) ? 'rtl' : 'ltr'
|
|
38
|
+
};
|
|
39
|
+
}, [
|
|
40
|
+
defaultLocale,
|
|
41
|
+
locale
|
|
42
|
+
]);
|
|
37
43
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($e7RNT$react))).createElement($47fa5ec5ff482271$var$I18nContext.Provider, {
|
|
38
44
|
value: value
|
|
39
45
|
}, children);
|
package/dist/context.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAaD,MAAM,kDAAc,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAgB;AAKhD,SAAS,0CAAa,KAAwB;IACnD,IAAI,UAAC,MAAM,YAAE,QAAQ,EAAC,GAAG;IACzB,IAAI,gBAAgB,CAAA,GAAA,0CAAe;IAEnC,IAAI,QAAgB,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAaD,MAAM,kDAAc,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAgB;AAKhD,SAAS,0CAAa,KAAwB;IACnD,IAAI,UAAC,MAAM,YAAE,QAAQ,EAAC,GAAG;IACzB,IAAI,gBAAgB,CAAA,GAAA,0CAAe;IAEnC,IAAI,QAAgB,CAAA,GAAA,sCAAI,EAAE,OAAO,CAAC;QAChC,IAAI,CAAC,QACH,OAAO;QAGT,OAAO;oBACL;YACA,WAAW,CAAA,GAAA,+BAAI,EAAE,UAAU,QAAQ;QACrC;IACF,GAAG;QAAC;QAAe;KAAO;IAE1B,qBACE,0DAAC,kCAAY,QAAQ;QAAC,OAAO;OAC1B;AAGP;AAKO,SAAS;IACd,IAAI,gBAAgB,CAAA,GAAA,0CAAe;IACnC,IAAI,UAAU,CAAA,GAAA,uBAAS,EAAE;IACzB,OAAO,WAAW;AACpB","sources":["packages/@react-aria/i18n/src/context.tsx"],"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\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\nexport interface I18nProviderProps {\n /** Contents that should have the locale applied. */\n children: ReactNode,\n /** The locale to apply to the children. */\n locale?: string\n}\n\nconst I18nContext = React.createContext<Locale | null>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps) {\n let {locale, children} = props;\n let defaultLocale = useDefaultLocale();\n\n let value: Locale = React.useMemo(() => {\n if (!locale) {\n return defaultLocale;\n }\n\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n }, [defaultLocale, locale]);\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"],"names":[],"version":3,"file":"context.main.js.map"}
|
package/dist/context.mjs
CHANGED
|
@@ -19,10 +19,16 @@ const $18f2051aff69b9bf$var$I18nContext = /*#__PURE__*/ (0, $h9FiU$react).create
|
|
|
19
19
|
function $18f2051aff69b9bf$export$a54013f0d02a8f82(props) {
|
|
20
20
|
let { locale: locale, children: children } = props;
|
|
21
21
|
let defaultLocale = (0, $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a)();
|
|
22
|
-
let value =
|
|
23
|
-
locale
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let value = (0, $h9FiU$react).useMemo(()=>{
|
|
23
|
+
if (!locale) return defaultLocale;
|
|
24
|
+
return {
|
|
25
|
+
locale: locale,
|
|
26
|
+
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? 'rtl' : 'ltr'
|
|
27
|
+
};
|
|
28
|
+
}, [
|
|
29
|
+
defaultLocale,
|
|
30
|
+
locale
|
|
31
|
+
]);
|
|
26
32
|
return /*#__PURE__*/ (0, $h9FiU$react).createElement($18f2051aff69b9bf$var$I18nContext.Provider, {
|
|
27
33
|
value: value
|
|
28
34
|
}, children);
|
|
@@ -35,4 +41,4 @@ function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
|
|
|
35
41
|
|
|
36
42
|
|
|
37
43
|
export {$18f2051aff69b9bf$export$a54013f0d02a8f82 as I18nProvider, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 as useLocale};
|
|
38
|
-
//# sourceMappingURL=context.
|
|
44
|
+
//# sourceMappingURL=context.module.js.map
|
package/dist/context.module.js
CHANGED
|
@@ -19,10 +19,16 @@ const $18f2051aff69b9bf$var$I18nContext = /*#__PURE__*/ (0, $h9FiU$react).create
|
|
|
19
19
|
function $18f2051aff69b9bf$export$a54013f0d02a8f82(props) {
|
|
20
20
|
let { locale: locale, children: children } = props;
|
|
21
21
|
let defaultLocale = (0, $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a)();
|
|
22
|
-
let value =
|
|
23
|
-
locale
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let value = (0, $h9FiU$react).useMemo(()=>{
|
|
23
|
+
if (!locale) return defaultLocale;
|
|
24
|
+
return {
|
|
25
|
+
locale: locale,
|
|
26
|
+
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? 'rtl' : 'ltr'
|
|
27
|
+
};
|
|
28
|
+
}, [
|
|
29
|
+
defaultLocale,
|
|
30
|
+
locale
|
|
31
|
+
]);
|
|
26
32
|
return /*#__PURE__*/ (0, $h9FiU$react).createElement($18f2051aff69b9bf$var$I18nContext.Provider, {
|
|
27
33
|
value: value
|
|
28
34
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAaD,MAAM,kDAAc,CAAA,GAAA,YAAI,EAAE,aAAa,CAAgB;AAKhD,SAAS,0CAAa,KAAwB;IACnD,IAAI,UAAC,MAAM,YAAE,QAAQ,EAAC,GAAG;IACzB,IAAI,gBAAgB,CAAA,GAAA,yCAAe;IAEnC,IAAI,QAAgB,
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAaD,MAAM,kDAAc,CAAA,GAAA,YAAI,EAAE,aAAa,CAAgB;AAKhD,SAAS,0CAAa,KAAwB;IACnD,IAAI,UAAC,MAAM,YAAE,QAAQ,EAAC,GAAG;IACzB,IAAI,gBAAgB,CAAA,GAAA,yCAAe;IAEnC,IAAI,QAAgB,CAAA,GAAA,YAAI,EAAE,OAAO,CAAC;QAChC,IAAI,CAAC,QACH,OAAO;QAGT,OAAO;oBACL;YACA,WAAW,CAAA,GAAA,yCAAI,EAAE,UAAU,QAAQ;QACrC;IACF,GAAG;QAAC;QAAe;KAAO;IAE1B,qBACE,gCAAC,kCAAY,QAAQ;QAAC,OAAO;OAC1B;AAGP;AAKO,SAAS;IACd,IAAI,gBAAgB,CAAA,GAAA,yCAAe;IACnC,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE;IACzB,OAAO,WAAW;AACpB","sources":["packages/@react-aria/i18n/src/context.tsx"],"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\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\nexport interface I18nProviderProps {\n /** Contents that should have the locale applied. */\n children: ReactNode,\n /** The locale to apply to the children. */\n locale?: string\n}\n\nconst I18nContext = React.createContext<Locale | null>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps) {\n let {locale, children} = props;\n let defaultLocale = useDefaultLocale();\n\n let value: Locale = React.useMemo(() => {\n if (!locale) {\n return defaultLocale;\n }\n\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n }, [defaultLocale, locale]);\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"],"names":[],"version":3,"file":"context.module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;ACiBA;IACE,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,SAAS,EAAE,SAAS,CAAA;CACrB;ACND;IACE,oDAAoD;IACpD,QAAQ,EAAE,SAAS,CAAC;IACpB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAID;;GAEG;AACH,6BAA6B,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"mappings":";;;;;;ACiBA;IACE,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,SAAS,EAAE,SAAS,CAAA;CACrB;ACND;IACE,oDAAoD;IACpD,QAAQ,EAAE,SAAS,CAAC;IACpB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAID;;GAEG;AACH,6BAA6B,KAAK,EAAE,iBAAiB,qBAoBpD;AAED;;GAEG;AACH,6BAA6B,MAAM,CAIlC;ACzCD,4BAA4B,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,KAAK,MAAM,CAAC;AAatF;;;;;GAKG;AACH,oCAAoC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAK5E;ACbD;;GAEG;AACH,6CAA6C,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,eAAe,GAAG,MAAM,EAAE,OAAO,EAAE,mBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,0BAA0B,CAAC,EAAE,CAAC,CAAC,CAElM;AAED;;;;GAIG;AACH,4CAA4C,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,eAAe,GAAG,MAAM,EAAE,OAAO,EAAE,mBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAIhM;AC5BD;;;;GAIG;AACH,iCAAiC,OAAO,GAAE,KAAK,iBAAsB,GAAG,KAAK,UAAU,CAGtF;ACND,qCAAsC,SAAQ,IAAI,CAAC,qBAAqB;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;GAIG;AACH,iCAAiC,OAAO,CAAC,EAAE,oBAAoB,GAAG,aAAa,CAK9E;ACfD;;;;GAIG;AACH,mCAAmC,OAAO,GAAE,mBAAwB,GAAG,KAAK,YAAY,CAGvF;ACRD;;;;GAIG;AACH,4BAA4B,OAAO,CAAC,EAAE,KAAK,eAAe,GAAG,KAAK,QAAQ,CAWzE;ACjBD;IACE,8DAA8D;IAC9D,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACvD,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACrD,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;CACrD;AAED;;;GAGG;AACH,0BAA0B,OAAO,CAAC,EAAE,KAAK,eAAe,GAAG,MAAM,CAsDhE;AC5DD,YAAY,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AAGxE,YAAY,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAEjE,YAAY,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC","sources":["packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useDefaultLocale.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useMessageFormatter.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useLocalizedStringFormatter.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useListFormatter.tsx","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useCollator.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/useFilter.ts","packages/@react-aria/i18n/src/packages/@react-aria/i18n/src/index.ts","packages/@react-aria/i18n/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {I18nProvider, useLocale} from './context';\nexport {useMessageFormatter} from './useMessageFormatter';\nexport {useLocalizedStringFormatter, useLocalizedStringDictionary} from './useLocalizedStringFormatter';\nexport {useListFormatter} from './useListFormatter';\nexport {useDateFormatter} from './useDateFormatter';\nexport {useNumberFormatter} from './useNumberFormatter';\nexport {useCollator} from './useCollator';\nexport {useFilter} from './useFilter';\n\nexport type {FormatMessage} from './useMessageFormatter';\nexport type {LocalizedStringFormatter} from '@internationalized/string';\nexport type {I18nProviderProps} from './context';\nexport type {Locale} from './useDefaultLocale';\nexport type {LocalizedStrings} from '@internationalized/message';\nexport type {DateFormatterOptions} from './useDateFormatter';\nexport type {DateFormatter} from '@internationalized/date';\nexport type {Filter} from './useFilter';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/dist/useCollator.main.js
CHANGED
|
@@ -20,7 +20,7 @@ $parcel$export(module.exports, "useCollator", () => $27a5ce66022270ad$export$a16
|
|
|
20
20
|
let $27a5ce66022270ad$var$cache = new Map();
|
|
21
21
|
function $27a5ce66022270ad$export$a16aca283550c30d(options) {
|
|
22
22
|
let { locale: locale } = (0, $47fa5ec5ff482271$exports.useLocale)();
|
|
23
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() :
|
|
23
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
|
|
24
24
|
if ($27a5ce66022270ad$var$cache.has(cacheKey)) return $27a5ce66022270ad$var$cache.get(cacheKey);
|
|
25
25
|
let formatter = new Intl.Collator(locale, options);
|
|
26
26
|
$27a5ce66022270ad$var$cache.set(cacheKey, formatter);
|
package/dist/useCollator.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import {useLocale as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7} from "./context.
|
|
|
14
14
|
let $325a3faab7a68acd$var$cache = new Map();
|
|
15
15
|
function $325a3faab7a68acd$export$a16aca283550c30d(options) {
|
|
16
16
|
let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
|
|
17
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() :
|
|
17
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
|
|
18
18
|
if ($325a3faab7a68acd$var$cache.has(cacheKey)) return $325a3faab7a68acd$var$cache.get(cacheKey);
|
|
19
19
|
let formatter = new Intl.Collator(locale, options);
|
|
20
20
|
$325a3faab7a68acd$var$cache.set(cacheKey, formatter);
|
|
@@ -23,4 +23,4 @@ function $325a3faab7a68acd$export$a16aca283550c30d(options) {
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
export {$325a3faab7a68acd$export$a16aca283550c30d as useCollator};
|
|
26
|
-
//# sourceMappingURL=useCollator.
|
|
26
|
+
//# sourceMappingURL=useCollator.module.js.map
|
|
@@ -14,7 +14,7 @@ import {useLocale as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7} from "./context.
|
|
|
14
14
|
let $325a3faab7a68acd$var$cache = new Map();
|
|
15
15
|
function $325a3faab7a68acd$export$a16aca283550c30d(options) {
|
|
16
16
|
let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
|
|
17
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() :
|
|
17
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : '');
|
|
18
18
|
if ($325a3faab7a68acd$var$cache.has(cacheKey)) return $325a3faab7a68acd$var$cache.get(cacheKey);
|
|
19
19
|
let formatter = new Intl.Collator(locale, options);
|
|
20
20
|
$325a3faab7a68acd$var$cache.set(cacheKey, formatter);
|
|
@@ -22,20 +22,20 @@ $parcel$export(module.exports, "useDefaultLocale", () => $2919bdec75484e64$expor
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
// Locale passed from server by PackageLocalizationProvider.
|
|
25
|
-
const $2919bdec75484e64$var$localeSymbol = Symbol.for(
|
|
25
|
+
const $2919bdec75484e64$var$localeSymbol = Symbol.for('react-aria.i18n.locale');
|
|
26
26
|
function $2919bdec75484e64$export$f09106e7c6677ec5() {
|
|
27
|
-
let locale = typeof window !==
|
|
27
|
+
let locale = typeof window !== 'undefined' && window[$2919bdec75484e64$var$localeSymbol] || typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
28
28
|
try {
|
|
29
29
|
// @ts-ignore
|
|
30
30
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
31
31
|
locale
|
|
32
32
|
]);
|
|
33
33
|
} catch (_err) {
|
|
34
|
-
locale =
|
|
34
|
+
locale = 'en-US';
|
|
35
35
|
}
|
|
36
36
|
return {
|
|
37
37
|
locale: locale,
|
|
38
|
-
direction: (0, $4d65847630a056a8$exports.isRTL)(locale) ?
|
|
38
|
+
direction: (0, $4d65847630a056a8$exports.isRTL)(locale) ? 'rtl' : 'ltr'
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
let $2919bdec75484e64$var$currentLocale = $2919bdec75484e64$export$f09106e7c6677ec5();
|
|
@@ -48,18 +48,18 @@ function $2919bdec75484e64$export$188ec29ebc2bdc3a() {
|
|
|
48
48
|
let isSSR = (0, $5Ie0C$reactariassr.useIsSSR)();
|
|
49
49
|
let [defaultLocale, setDefaultLocale] = (0, $5Ie0C$react.useState)($2919bdec75484e64$var$currentLocale);
|
|
50
50
|
(0, $5Ie0C$react.useEffect)(()=>{
|
|
51
|
-
if ($2919bdec75484e64$var$listeners.size === 0) window.addEventListener(
|
|
51
|
+
if ($2919bdec75484e64$var$listeners.size === 0) window.addEventListener('languagechange', $2919bdec75484e64$var$updateLocale);
|
|
52
52
|
$2919bdec75484e64$var$listeners.add(setDefaultLocale);
|
|
53
53
|
return ()=>{
|
|
54
54
|
$2919bdec75484e64$var$listeners.delete(setDefaultLocale);
|
|
55
|
-
if ($2919bdec75484e64$var$listeners.size === 0) window.removeEventListener(
|
|
55
|
+
if ($2919bdec75484e64$var$listeners.size === 0) window.removeEventListener('languagechange', $2919bdec75484e64$var$updateLocale);
|
|
56
56
|
};
|
|
57
57
|
}, []);
|
|
58
58
|
// We cannot determine the browser's language on the server, so default to
|
|
59
59
|
// en-US. This will be updated after hydration on the client to the correct value.
|
|
60
60
|
if (isSSR) return {
|
|
61
|
-
locale:
|
|
62
|
-
direction:
|
|
61
|
+
locale: 'en-US',
|
|
62
|
+
direction: 'ltr'
|
|
63
63
|
};
|
|
64
64
|
return defaultLocale;
|
|
65
65
|
}
|
|
@@ -16,20 +16,20 @@ import {useIsSSR as $ffhGL$useIsSSR} from "@react-aria/ssr";
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
// Locale passed from server by PackageLocalizationProvider.
|
|
19
|
-
const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for(
|
|
19
|
+
const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for('react-aria.i18n.locale');
|
|
20
20
|
function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
|
|
21
|
-
let locale = typeof window !==
|
|
21
|
+
let locale = typeof window !== 'undefined' && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
22
22
|
try {
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
25
25
|
locale
|
|
26
26
|
]);
|
|
27
27
|
} catch (_err) {
|
|
28
|
-
locale =
|
|
28
|
+
locale = 'en-US';
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
31
31
|
locale: locale,
|
|
32
|
-
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ?
|
|
32
|
+
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? 'rtl' : 'ltr'
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
let $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
|
|
@@ -42,22 +42,22 @@ function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
|
|
|
42
42
|
let isSSR = (0, $ffhGL$useIsSSR)();
|
|
43
43
|
let [defaultLocale, setDefaultLocale] = (0, $ffhGL$useState)($1e5a04cdaf7d1af8$var$currentLocale);
|
|
44
44
|
(0, $ffhGL$useEffect)(()=>{
|
|
45
|
-
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener(
|
|
45
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
|
|
46
46
|
$1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale);
|
|
47
47
|
return ()=>{
|
|
48
48
|
$1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale);
|
|
49
|
-
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener(
|
|
49
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
|
|
50
50
|
};
|
|
51
51
|
}, []);
|
|
52
52
|
// We cannot determine the browser's language on the server, so default to
|
|
53
53
|
// en-US. This will be updated after hydration on the client to the correct value.
|
|
54
54
|
if (isSSR) return {
|
|
55
|
-
locale:
|
|
56
|
-
direction:
|
|
55
|
+
locale: 'en-US',
|
|
56
|
+
direction: 'ltr'
|
|
57
57
|
};
|
|
58
58
|
return defaultLocale;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
export {$1e5a04cdaf7d1af8$export$f09106e7c6677ec5 as getDefaultLocale, $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a as useDefaultLocale};
|
|
63
|
-
//# sourceMappingURL=useDefaultLocale.
|
|
63
|
+
//# sourceMappingURL=useDefaultLocale.module.js.map
|
|
@@ -16,20 +16,20 @@ import {useIsSSR as $ffhGL$useIsSSR} from "@react-aria/ssr";
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
// Locale passed from server by PackageLocalizationProvider.
|
|
19
|
-
const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for(
|
|
19
|
+
const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for('react-aria.i18n.locale');
|
|
20
20
|
function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
|
|
21
|
-
let locale = typeof window !==
|
|
21
|
+
let locale = typeof window !== 'undefined' && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
22
22
|
try {
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
25
25
|
locale
|
|
26
26
|
]);
|
|
27
27
|
} catch (_err) {
|
|
28
|
-
locale =
|
|
28
|
+
locale = 'en-US';
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
31
31
|
locale: locale,
|
|
32
|
-
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ?
|
|
32
|
+
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? 'rtl' : 'ltr'
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
let $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
|
|
@@ -42,18 +42,18 @@ function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
|
|
|
42
42
|
let isSSR = (0, $ffhGL$useIsSSR)();
|
|
43
43
|
let [defaultLocale, setDefaultLocale] = (0, $ffhGL$useState)($1e5a04cdaf7d1af8$var$currentLocale);
|
|
44
44
|
(0, $ffhGL$useEffect)(()=>{
|
|
45
|
-
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener(
|
|
45
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
|
|
46
46
|
$1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale);
|
|
47
47
|
return ()=>{
|
|
48
48
|
$1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale);
|
|
49
|
-
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener(
|
|
49
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
|
|
50
50
|
};
|
|
51
51
|
}, []);
|
|
52
52
|
// We cannot determine the browser's language on the server, so default to
|
|
53
53
|
// en-US. This will be updated after hydration on the client to the correct value.
|
|
54
54
|
if (isSSR) return {
|
|
55
|
-
locale:
|
|
56
|
-
direction:
|
|
55
|
+
locale: 'en-US',
|
|
56
|
+
direction: 'ltr'
|
|
57
57
|
};
|
|
58
58
|
return defaultLocale;
|
|
59
59
|
}
|
package/dist/useFilter.main.js
CHANGED
|
@@ -21,7 +21,7 @@ $parcel$export(module.exports, "useFilter", () => $832d079b867c7223$export$3274c
|
|
|
21
21
|
|
|
22
22
|
function $832d079b867c7223$export$3274cf84b703fff(options) {
|
|
23
23
|
let collator = (0, $27a5ce66022270ad$exports.useCollator)({
|
|
24
|
-
usage:
|
|
24
|
+
usage: 'search',
|
|
25
25
|
...options
|
|
26
26
|
});
|
|
27
27
|
// TODO(later): these methods don't currently support the ignorePunctuation option.
|
|
@@ -29,24 +29,24 @@ function $832d079b867c7223$export$3274cf84b703fff(options) {
|
|
|
29
29
|
if (substring.length === 0) return true;
|
|
30
30
|
// Normalize both strings so we can slice safely
|
|
31
31
|
// TODO: take into account the ignorePunctuation option as well...
|
|
32
|
-
string = string.normalize(
|
|
33
|
-
substring = substring.normalize(
|
|
32
|
+
string = string.normalize('NFC');
|
|
33
|
+
substring = substring.normalize('NFC');
|
|
34
34
|
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
35
35
|
}, [
|
|
36
36
|
collator
|
|
37
37
|
]);
|
|
38
38
|
let endsWith = (0, $c0oFg$react.useCallback)((string, substring)=>{
|
|
39
39
|
if (substring.length === 0) return true;
|
|
40
|
-
string = string.normalize(
|
|
41
|
-
substring = substring.normalize(
|
|
40
|
+
string = string.normalize('NFC');
|
|
41
|
+
substring = substring.normalize('NFC');
|
|
42
42
|
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
43
43
|
}, [
|
|
44
44
|
collator
|
|
45
45
|
]);
|
|
46
46
|
let contains = (0, $c0oFg$react.useCallback)((string, substring)=>{
|
|
47
47
|
if (substring.length === 0) return true;
|
|
48
|
-
string = string.normalize(
|
|
49
|
-
substring = substring.normalize(
|
|
48
|
+
string = string.normalize('NFC');
|
|
49
|
+
substring = substring.normalize('NFC');
|
|
50
50
|
let scan = 0;
|
|
51
51
|
let sliceLen = substring.length;
|
|
52
52
|
for(; scan + sliceLen <= string.length; scan++){
|
package/dist/useFilter.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import {useCallback as $21ck9$useCallback, useMemo as $21ck9$useMemo} from "reac
|
|
|
15
15
|
|
|
16
16
|
function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
17
17
|
let collator = (0, $325a3faab7a68acd$export$a16aca283550c30d)({
|
|
18
|
-
usage:
|
|
18
|
+
usage: 'search',
|
|
19
19
|
...options
|
|
20
20
|
});
|
|
21
21
|
// TODO(later): these methods don't currently support the ignorePunctuation option.
|
|
@@ -23,24 +23,24 @@ function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
|
23
23
|
if (substring.length === 0) return true;
|
|
24
24
|
// Normalize both strings so we can slice safely
|
|
25
25
|
// TODO: take into account the ignorePunctuation option as well...
|
|
26
|
-
string = string.normalize(
|
|
27
|
-
substring = substring.normalize(
|
|
26
|
+
string = string.normalize('NFC');
|
|
27
|
+
substring = substring.normalize('NFC');
|
|
28
28
|
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
29
29
|
}, [
|
|
30
30
|
collator
|
|
31
31
|
]);
|
|
32
32
|
let endsWith = (0, $21ck9$useCallback)((string, substring)=>{
|
|
33
33
|
if (substring.length === 0) return true;
|
|
34
|
-
string = string.normalize(
|
|
35
|
-
substring = substring.normalize(
|
|
34
|
+
string = string.normalize('NFC');
|
|
35
|
+
substring = substring.normalize('NFC');
|
|
36
36
|
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
37
37
|
}, [
|
|
38
38
|
collator
|
|
39
39
|
]);
|
|
40
40
|
let contains = (0, $21ck9$useCallback)((string, substring)=>{
|
|
41
41
|
if (substring.length === 0) return true;
|
|
42
|
-
string = string.normalize(
|
|
43
|
-
substring = substring.normalize(
|
|
42
|
+
string = string.normalize('NFC');
|
|
43
|
+
substring = substring.normalize('NFC');
|
|
44
44
|
let scan = 0;
|
|
45
45
|
let sliceLen = substring.length;
|
|
46
46
|
for(; scan + sliceLen <= string.length; scan++){
|
|
@@ -64,4 +64,4 @@ function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
export {$bb77f239b46e8c72$export$3274cf84b703fff as useFilter};
|
|
67
|
-
//# sourceMappingURL=useFilter.
|
|
67
|
+
//# sourceMappingURL=useFilter.module.js.map
|
package/dist/useFilter.module.js
CHANGED
|
@@ -15,7 +15,7 @@ import {useCallback as $21ck9$useCallback, useMemo as $21ck9$useMemo} from "reac
|
|
|
15
15
|
|
|
16
16
|
function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
17
17
|
let collator = (0, $325a3faab7a68acd$export$a16aca283550c30d)({
|
|
18
|
-
usage:
|
|
18
|
+
usage: 'search',
|
|
19
19
|
...options
|
|
20
20
|
});
|
|
21
21
|
// TODO(later): these methods don't currently support the ignorePunctuation option.
|
|
@@ -23,24 +23,24 @@ function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
|
23
23
|
if (substring.length === 0) return true;
|
|
24
24
|
// Normalize both strings so we can slice safely
|
|
25
25
|
// TODO: take into account the ignorePunctuation option as well...
|
|
26
|
-
string = string.normalize(
|
|
27
|
-
substring = substring.normalize(
|
|
26
|
+
string = string.normalize('NFC');
|
|
27
|
+
substring = substring.normalize('NFC');
|
|
28
28
|
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
29
29
|
}, [
|
|
30
30
|
collator
|
|
31
31
|
]);
|
|
32
32
|
let endsWith = (0, $21ck9$useCallback)((string, substring)=>{
|
|
33
33
|
if (substring.length === 0) return true;
|
|
34
|
-
string = string.normalize(
|
|
35
|
-
substring = substring.normalize(
|
|
34
|
+
string = string.normalize('NFC');
|
|
35
|
+
substring = substring.normalize('NFC');
|
|
36
36
|
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
37
37
|
}, [
|
|
38
38
|
collator
|
|
39
39
|
]);
|
|
40
40
|
let contains = (0, $21ck9$useCallback)((string, substring)=>{
|
|
41
41
|
if (substring.length === 0) return true;
|
|
42
|
-
string = string.normalize(
|
|
43
|
-
substring = substring.normalize(
|
|
42
|
+
string = string.normalize('NFC');
|
|
43
|
+
substring = substring.normalize('NFC');
|
|
44
44
|
let scan = 0;
|
|
45
45
|
let sliceLen = substring.length;
|
|
46
46
|
for(; scan + sliceLen <= string.length; scan++){
|
|
@@ -38,4 +38,4 @@ function $fca6afa0e843324b$export$f12b703ca79dfbb1(strings, packageName) {
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
export {$fca6afa0e843324b$export$87b761675e8eaa10 as useLocalizedStringDictionary, $fca6afa0e843324b$export$f12b703ca79dfbb1 as useLocalizedStringFormatter};
|
|
41
|
-
//# sourceMappingURL=useLocalizedStringFormatter.
|
|
41
|
+
//# sourceMappingURL=useLocalizedStringFormatter.module.js.map
|
package/dist/utils.main.js
CHANGED
|
@@ -16,37 +16,37 @@ $parcel$export(module.exports, "isRTL", () => $4d65847630a056a8$export$702d680b2
|
|
|
16
16
|
* governing permissions and limitations under the License.
|
|
17
17
|
*/ // https://en.wikipedia.org/wiki/Right-to-left
|
|
18
18
|
const $4d65847630a056a8$var$RTL_SCRIPTS = new Set([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
'Arab',
|
|
20
|
+
'Syrc',
|
|
21
|
+
'Samr',
|
|
22
|
+
'Mand',
|
|
23
|
+
'Thaa',
|
|
24
|
+
'Mend',
|
|
25
|
+
'Nkoo',
|
|
26
|
+
'Adlm',
|
|
27
|
+
'Rohg',
|
|
28
|
+
'Hebr'
|
|
29
29
|
]);
|
|
30
30
|
const $4d65847630a056a8$var$RTL_LANGS = new Set([
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
'ae',
|
|
32
|
+
'ar',
|
|
33
|
+
'arc',
|
|
34
|
+
'bcc',
|
|
35
|
+
'bqi',
|
|
36
|
+
'ckb',
|
|
37
|
+
'dv',
|
|
38
|
+
'fa',
|
|
39
|
+
'glk',
|
|
40
|
+
'he',
|
|
41
|
+
'ku',
|
|
42
|
+
'mzn',
|
|
43
|
+
'nqo',
|
|
44
|
+
'pnb',
|
|
45
|
+
'ps',
|
|
46
|
+
'sd',
|
|
47
|
+
'ug',
|
|
48
|
+
'ur',
|
|
49
|
+
'yi'
|
|
50
50
|
]);
|
|
51
51
|
function $4d65847630a056a8$export$702d680b21cbd764(localeString) {
|
|
52
52
|
// If the Intl.Locale API is available, use it to get the locale's text direction.
|
|
@@ -56,14 +56,14 @@ function $4d65847630a056a8$export$702d680b21cbd764(localeString) {
|
|
|
56
56
|
// Use the text info object to get the direction if possible.
|
|
57
57
|
// @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.
|
|
58
58
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
|
|
59
|
-
let textInfo = typeof locale.getTextInfo ===
|
|
60
|
-
if (textInfo) return textInfo.direction ===
|
|
59
|
+
let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;
|
|
60
|
+
if (textInfo) return textInfo.direction === 'rtl';
|
|
61
61
|
// Fallback: guess using the script.
|
|
62
62
|
// This is more accurate than guessing by language, since languages can be written in multiple scripts.
|
|
63
63
|
if (locale.script) return $4d65847630a056a8$var$RTL_SCRIPTS.has(locale.script);
|
|
64
64
|
}
|
|
65
65
|
// If not, just guess by the language (first part of the locale)
|
|
66
|
-
let lang = localeString.split(
|
|
66
|
+
let lang = localeString.split('-')[0];
|
|
67
67
|
return $4d65847630a056a8$var$RTL_LANGS.has(lang);
|
|
68
68
|
}
|
|
69
69
|
|
package/dist/utils.mjs
CHANGED
|
@@ -10,37 +10,37 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/ // https://en.wikipedia.org/wiki/Right-to-left
|
|
12
12
|
const $148a7a147e38ea7f$var$RTL_SCRIPTS = new Set([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
'Arab',
|
|
14
|
+
'Syrc',
|
|
15
|
+
'Samr',
|
|
16
|
+
'Mand',
|
|
17
|
+
'Thaa',
|
|
18
|
+
'Mend',
|
|
19
|
+
'Nkoo',
|
|
20
|
+
'Adlm',
|
|
21
|
+
'Rohg',
|
|
22
|
+
'Hebr'
|
|
23
23
|
]);
|
|
24
24
|
const $148a7a147e38ea7f$var$RTL_LANGS = new Set([
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
'ae',
|
|
26
|
+
'ar',
|
|
27
|
+
'arc',
|
|
28
|
+
'bcc',
|
|
29
|
+
'bqi',
|
|
30
|
+
'ckb',
|
|
31
|
+
'dv',
|
|
32
|
+
'fa',
|
|
33
|
+
'glk',
|
|
34
|
+
'he',
|
|
35
|
+
'ku',
|
|
36
|
+
'mzn',
|
|
37
|
+
'nqo',
|
|
38
|
+
'pnb',
|
|
39
|
+
'ps',
|
|
40
|
+
'sd',
|
|
41
|
+
'ug',
|
|
42
|
+
'ur',
|
|
43
|
+
'yi'
|
|
44
44
|
]);
|
|
45
45
|
function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
|
|
46
46
|
// If the Intl.Locale API is available, use it to get the locale's text direction.
|
|
@@ -50,17 +50,17 @@ function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
|
|
|
50
50
|
// Use the text info object to get the direction if possible.
|
|
51
51
|
// @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.
|
|
52
52
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
|
|
53
|
-
let textInfo = typeof locale.getTextInfo ===
|
|
54
|
-
if (textInfo) return textInfo.direction ===
|
|
53
|
+
let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;
|
|
54
|
+
if (textInfo) return textInfo.direction === 'rtl';
|
|
55
55
|
// Fallback: guess using the script.
|
|
56
56
|
// This is more accurate than guessing by language, since languages can be written in multiple scripts.
|
|
57
57
|
if (locale.script) return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(locale.script);
|
|
58
58
|
}
|
|
59
59
|
// If not, just guess by the language (first part of the locale)
|
|
60
|
-
let lang = localeString.split(
|
|
60
|
+
let lang = localeString.split('-')[0];
|
|
61
61
|
return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
export {$148a7a147e38ea7f$export$702d680b21cbd764 as isRTL};
|
|
66
|
-
//# sourceMappingURL=utils.
|
|
66
|
+
//# sourceMappingURL=utils.module.js.map
|
package/dist/utils.module.js
CHANGED
|
@@ -10,37 +10,37 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/ // https://en.wikipedia.org/wiki/Right-to-left
|
|
12
12
|
const $148a7a147e38ea7f$var$RTL_SCRIPTS = new Set([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
'Arab',
|
|
14
|
+
'Syrc',
|
|
15
|
+
'Samr',
|
|
16
|
+
'Mand',
|
|
17
|
+
'Thaa',
|
|
18
|
+
'Mend',
|
|
19
|
+
'Nkoo',
|
|
20
|
+
'Adlm',
|
|
21
|
+
'Rohg',
|
|
22
|
+
'Hebr'
|
|
23
23
|
]);
|
|
24
24
|
const $148a7a147e38ea7f$var$RTL_LANGS = new Set([
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
'ae',
|
|
26
|
+
'ar',
|
|
27
|
+
'arc',
|
|
28
|
+
'bcc',
|
|
29
|
+
'bqi',
|
|
30
|
+
'ckb',
|
|
31
|
+
'dv',
|
|
32
|
+
'fa',
|
|
33
|
+
'glk',
|
|
34
|
+
'he',
|
|
35
|
+
'ku',
|
|
36
|
+
'mzn',
|
|
37
|
+
'nqo',
|
|
38
|
+
'pnb',
|
|
39
|
+
'ps',
|
|
40
|
+
'sd',
|
|
41
|
+
'ug',
|
|
42
|
+
'ur',
|
|
43
|
+
'yi'
|
|
44
44
|
]);
|
|
45
45
|
function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
|
|
46
46
|
// If the Intl.Locale API is available, use it to get the locale's text direction.
|
|
@@ -50,14 +50,14 @@ function $148a7a147e38ea7f$export$702d680b21cbd764(localeString) {
|
|
|
50
50
|
// Use the text info object to get the direction if possible.
|
|
51
51
|
// @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.
|
|
52
52
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
|
|
53
|
-
let textInfo = typeof locale.getTextInfo ===
|
|
54
|
-
if (textInfo) return textInfo.direction ===
|
|
53
|
+
let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;
|
|
54
|
+
if (textInfo) return textInfo.direction === 'rtl';
|
|
55
55
|
// Fallback: guess using the script.
|
|
56
56
|
// This is more accurate than guessing by language, since languages can be written in multiple scripts.
|
|
57
57
|
if (locale.script) return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(locale.script);
|
|
58
58
|
}
|
|
59
59
|
// If not, just guess by the language (first part of the locale)
|
|
60
|
-
let lang = localeString.split(
|
|
60
|
+
let lang = localeString.split('-')[0];
|
|
61
61
|
return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
|
|
62
62
|
}
|
|
63
63
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/i18n",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"url": "https://github.com/adobe/react-spectrum"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@internationalized/date": "^3.5.
|
|
51
|
-
"@internationalized/message": "^3.1.
|
|
52
|
-
"@internationalized/number": "^3.5.
|
|
53
|
-
"@internationalized/string": "^3.2.
|
|
54
|
-
"@react-aria/ssr": "^3.9.
|
|
55
|
-
"@react-aria/utils": "^3.24.
|
|
56
|
-
"@react-types/shared": "^3.23.
|
|
50
|
+
"@internationalized/date": "^3.5.4",
|
|
51
|
+
"@internationalized/message": "^3.1.4",
|
|
52
|
+
"@internationalized/number": "^3.5.3",
|
|
53
|
+
"@internationalized/string": "^3.2.3",
|
|
54
|
+
"@react-aria/ssr": "^3.9.4",
|
|
55
|
+
"@react-aria/utils": "^3.24.1",
|
|
56
|
+
"@react-types/shared": "^3.23.1",
|
|
57
57
|
"@swc/helpers": "^0.5.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
|
|
66
66
|
}
|
package/server/index.js
CHANGED
|
@@ -23,8 +23,8 @@ $parcel$export(module.exports, "getPackageLocalizationScript", () => $417d44b697
|
|
|
23
23
|
* governing permissions and limitations under the License.
|
|
24
24
|
*/
|
|
25
25
|
function $417d44b6975b2ee7$export$9ec1fc026a5460ba(props) {
|
|
26
|
-
if (typeof document !==
|
|
27
|
-
console.log(
|
|
26
|
+
if (typeof document !== 'undefined') {
|
|
27
|
+
console.log('PackageLocalizationProvider should only be rendered on the server.');
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
30
|
let { locale: locale, strings: strings } = props;
|
|
@@ -46,29 +46,29 @@ function $417d44b6975b2ee7$var$serialize(strings) {
|
|
|
46
46
|
let common = new Map();
|
|
47
47
|
for(let pkg in strings)for(let key in strings[pkg]){
|
|
48
48
|
let v = strings[pkg][key];
|
|
49
|
-
let s = typeof v ===
|
|
49
|
+
let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();
|
|
50
50
|
if (seen.has(s) && !common.has(s)) {
|
|
51
51
|
let name = String.fromCharCode(common.size > 25 ? common.size + 97 : common.size + 65);
|
|
52
52
|
common.set(s, name);
|
|
53
53
|
}
|
|
54
54
|
seen.add(s);
|
|
55
55
|
}
|
|
56
|
-
let res =
|
|
57
|
-
if (common.size > 0) res +=
|
|
56
|
+
let res = '';
|
|
57
|
+
if (common.size > 0) res += 'let ';
|
|
58
58
|
for (let [string, name] of common)res += `${name}=${string},`;
|
|
59
|
-
if (common.size > 0) res = res.slice(0, -1) +
|
|
59
|
+
if (common.size > 0) res = res.slice(0, -1) + ';';
|
|
60
60
|
res += "window[Symbol.for('react-aria.i18n.strings')]={";
|
|
61
61
|
for(let pkg in strings){
|
|
62
62
|
res += `'${pkg}':{`;
|
|
63
63
|
for(let key in strings[pkg]){
|
|
64
64
|
let v = strings[pkg][key];
|
|
65
|
-
let s = typeof v ===
|
|
65
|
+
let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();
|
|
66
66
|
if (common.has(s)) s = common.get(s);
|
|
67
67
|
res += `${/[ ()]/.test(key) ? JSON.stringify(key) : key}:${s},`;
|
|
68
68
|
}
|
|
69
|
-
res = res.slice(0, -1) +
|
|
69
|
+
res = res.slice(0, -1) + '},';
|
|
70
70
|
}
|
|
71
|
-
res = res.slice(0, -1) +
|
|
71
|
+
res = res.slice(0, -1) + '};';
|
|
72
72
|
$417d44b6975b2ee7$var$cache.set(strings, res);
|
|
73
73
|
return res;
|
|
74
74
|
}
|
package/server/index.mjs
CHANGED
|
@@ -12,8 +12,8 @@ import $7cMCw$react from "react";
|
|
|
12
12
|
* governing permissions and limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
function $f4fda66de26cefb3$export$9ec1fc026a5460ba(props) {
|
|
15
|
-
if (typeof document !==
|
|
16
|
-
console.log(
|
|
15
|
+
if (typeof document !== 'undefined') {
|
|
16
|
+
console.log('PackageLocalizationProvider should only be rendered on the server.');
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
let { locale: locale, strings: strings } = props;
|
|
@@ -35,29 +35,29 @@ function $f4fda66de26cefb3$var$serialize(strings) {
|
|
|
35
35
|
let common = new Map();
|
|
36
36
|
for(let pkg in strings)for(let key in strings[pkg]){
|
|
37
37
|
let v = strings[pkg][key];
|
|
38
|
-
let s = typeof v ===
|
|
38
|
+
let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();
|
|
39
39
|
if (seen.has(s) && !common.has(s)) {
|
|
40
40
|
let name = String.fromCharCode(common.size > 25 ? common.size + 97 : common.size + 65);
|
|
41
41
|
common.set(s, name);
|
|
42
42
|
}
|
|
43
43
|
seen.add(s);
|
|
44
44
|
}
|
|
45
|
-
let res =
|
|
46
|
-
if (common.size > 0) res +=
|
|
45
|
+
let res = '';
|
|
46
|
+
if (common.size > 0) res += 'let ';
|
|
47
47
|
for (let [string, name] of common)res += `${name}=${string},`;
|
|
48
|
-
if (common.size > 0) res = res.slice(0, -1) +
|
|
48
|
+
if (common.size > 0) res = res.slice(0, -1) + ';';
|
|
49
49
|
res += "window[Symbol.for('react-aria.i18n.strings')]={";
|
|
50
50
|
for(let pkg in strings){
|
|
51
51
|
res += `'${pkg}':{`;
|
|
52
52
|
for(let key in strings[pkg]){
|
|
53
53
|
let v = strings[pkg][key];
|
|
54
|
-
let s = typeof v ===
|
|
54
|
+
let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();
|
|
55
55
|
if (common.has(s)) s = common.get(s);
|
|
56
56
|
res += `${/[ ()]/.test(key) ? JSON.stringify(key) : key}:${s},`;
|
|
57
57
|
}
|
|
58
|
-
res = res.slice(0, -1) +
|
|
58
|
+
res = res.slice(0, -1) + '},';
|
|
59
59
|
}
|
|
60
|
-
res = res.slice(0, -1) +
|
|
60
|
+
res = res.slice(0, -1) + '};';
|
|
61
61
|
$f4fda66de26cefb3$var$cache.set(strings, res);
|
|
62
62
|
return res;
|
|
63
63
|
}
|
package/src/context.tsx
CHANGED
|
@@ -30,10 +30,16 @@ export function I18nProvider(props: I18nProviderProps) {
|
|
|
30
30
|
let {locale, children} = props;
|
|
31
31
|
let defaultLocale = useDefaultLocale();
|
|
32
32
|
|
|
33
|
-
let value: Locale =
|
|
34
|
-
locale
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
let value: Locale = React.useMemo(() => {
|
|
34
|
+
if (!locale) {
|
|
35
|
+
return defaultLocale;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
locale,
|
|
40
|
+
direction: isRTL(locale) ? 'rtl' : 'ltr'
|
|
41
|
+
};
|
|
42
|
+
}, [defaultLocale, locale]);
|
|
37
43
|
|
|
38
44
|
return (
|
|
39
45
|
<I18nContext.Provider value={value}>
|