@react-aria/i18n 3.12.2 → 3.12.4
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/useDefaultLocale.main.js +1 -2
- package/dist/useDefaultLocale.main.js.map +1 -1
- package/dist/useDefaultLocale.mjs +1 -2
- package/dist/useDefaultLocale.module.js +1 -2
- package/dist/useDefaultLocale.module.js.map +1 -1
- package/dist/utils.main.js +0 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +0 -1
- package/dist/utils.module.js +0 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +10 -10
- package/server/index.js.map +1 -1
- package/server/index.mjs.map +1 -1
- package/src/useDefaultLocale.ts +1 -2
- package/src/utils.ts +0 -1
|
@@ -26,11 +26,10 @@ const $2919bdec75484e64$var$localeSymbol = Symbol.for('react-aria.i18n.locale');
|
|
|
26
26
|
function $2919bdec75484e64$export$f09106e7c6677ec5() {
|
|
27
27
|
let locale = typeof window !== 'undefined' && window[$2919bdec75484e64$var$localeSymbol] || typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
28
28
|
try {
|
|
29
|
-
// @ts-ignore
|
|
30
29
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
31
30
|
locale
|
|
32
31
|
]);
|
|
33
|
-
} catch
|
|
32
|
+
} catch {
|
|
34
33
|
locale = 'en-US';
|
|
35
34
|
}
|
|
36
35
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAcD,4DAA4D;AAC5D,MAAM,qCAAe,OAAO,GAAG,CAAC;AAKzB,SAAS;IACd,IAAI,SAAS,OAAO,WAAW,eAAe,MAAM,CAAC,mCAAa,IAE5D,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KACjF;IAEL,IAAI;QACF,
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAcD,4DAA4D;AAC5D,MAAM,qCAAe,OAAO,GAAG,CAAC;AAKzB,SAAS;IACd,IAAI,SAAS,OAAO,WAAW,eAAe,MAAM,CAAC,mCAAa,IAE5D,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KACjF;IAEL,IAAI;QACF,KAAK,cAAc,CAAC,kBAAkB,CAAC;YAAC;SAAO;IACjD,EAAE,OAAM;QACN,SAAS;IACX;IACA,OAAO;gBACL;QACA,WAAW,CAAA,GAAA,+BAAI,EAAE,UAAU,QAAQ;IACrC;AACF;AAEA,IAAI,sCAAgB;AACpB,IAAI,kCAAY,IAAI;AAEpB,SAAS;IACP,sCAAgB;IAChB,KAAK,IAAI,YAAY,gCACnB,SAAS;AAEb;AAKO,SAAS;IACd,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEjD,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,gCAAU,IAAI,KAAK,GACrB,OAAO,gBAAgB,CAAC,kBAAkB;QAG5C,gCAAU,GAAG,CAAC;QAEd,OAAO;YACL,gCAAU,MAAM,CAAC;YACjB,IAAI,gCAAU,IAAI,KAAK,GACrB,OAAO,mBAAmB,CAAC,kBAAkB;QAEjD;IACF,GAAG,EAAE;IAEL,0EAA0E;IAC1E,kFAAkF;IAClF,IAAI,OACF,OAAO;QACL,QAAQ;QACR,WAAW;IACb;IAGF,OAAO;AACT","sources":["packages/@react-aria/i18n/src/useDefaultLocale.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\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string,\n /** The writing direction for the locale. */\n direction: Direction\n}\n\n// Locale passed from server by PackageLocalizationProvider.\nconst localeSymbol = Symbol.for('react-aria.i18n.locale');\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n let locale = typeof window !== 'undefined' && window[localeSymbol]\n // @ts-ignore\n || (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage))\n || 'en-US';\n\n try {\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr'\n };\n }\n\n return defaultLocale;\n}\n"],"names":[],"version":3,"file":"useDefaultLocale.main.js.map"}
|
|
@@ -20,11 +20,10 @@ const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for('react-aria.i18n.locale');
|
|
|
20
20
|
function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
|
|
21
21
|
let locale = typeof window !== 'undefined' && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
22
22
|
try {
|
|
23
|
-
// @ts-ignore
|
|
24
23
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
25
24
|
locale
|
|
26
25
|
]);
|
|
27
|
-
} catch
|
|
26
|
+
} catch {
|
|
28
27
|
locale = 'en-US';
|
|
29
28
|
}
|
|
30
29
|
return {
|
|
@@ -20,11 +20,10 @@ const $1e5a04cdaf7d1af8$var$localeSymbol = Symbol.for('react-aria.i18n.locale');
|
|
|
20
20
|
function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
|
|
21
21
|
let locale = typeof window !== 'undefined' && window[$1e5a04cdaf7d1af8$var$localeSymbol] || typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
22
22
|
try {
|
|
23
|
-
// @ts-ignore
|
|
24
23
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
25
24
|
locale
|
|
26
25
|
]);
|
|
27
|
-
} catch
|
|
26
|
+
} catch {
|
|
28
27
|
locale = 'en-US';
|
|
29
28
|
}
|
|
30
29
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAcD,4DAA4D;AAC5D,MAAM,qCAAe,OAAO,GAAG,CAAC;AAKzB,SAAS;IACd,IAAI,SAAS,OAAO,WAAW,eAAe,MAAM,CAAC,mCAAa,IAE5D,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KACjF;IAEL,IAAI;QACF,
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAcD,4DAA4D;AAC5D,MAAM,qCAAe,OAAO,GAAG,CAAC;AAKzB,SAAS;IACd,IAAI,SAAS,OAAO,WAAW,eAAe,MAAM,CAAC,mCAAa,IAE5D,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KACjF;IAEL,IAAI;QACF,KAAK,cAAc,CAAC,kBAAkB,CAAC;YAAC;SAAO;IACjD,EAAE,OAAM;QACN,SAAS;IACX;IACA,OAAO;gBACL;QACA,WAAW,CAAA,GAAA,yCAAI,EAAE,UAAU,QAAQ;IACrC;AACF;AAEA,IAAI,sCAAgB;AACpB,IAAI,kCAAY,IAAI;AAEpB,SAAS;IACP,sCAAgB;IAChB,KAAK,IAAI,YAAY,gCACnB,SAAS;AAEb;AAKO,SAAS;IACd,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAE;IAEjD,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,gCAAU,IAAI,KAAK,GACrB,OAAO,gBAAgB,CAAC,kBAAkB;QAG5C,gCAAU,GAAG,CAAC;QAEd,OAAO;YACL,gCAAU,MAAM,CAAC;YACjB,IAAI,gCAAU,IAAI,KAAK,GACrB,OAAO,mBAAmB,CAAC,kBAAkB;QAEjD;IACF,GAAG,EAAE;IAEL,0EAA0E;IAC1E,kFAAkF;IAClF,IAAI,OACF,OAAO;QACL,QAAQ;QACR,WAAW;IACb;IAGF,OAAO;AACT","sources":["packages/@react-aria/i18n/src/useDefaultLocale.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\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string,\n /** The writing direction for the locale. */\n direction: Direction\n}\n\n// Locale passed from server by PackageLocalizationProvider.\nconst localeSymbol = Symbol.for('react-aria.i18n.locale');\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n let locale = typeof window !== 'undefined' && window[localeSymbol]\n // @ts-ignore\n || (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage))\n || 'en-US';\n\n try {\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr'\n };\n }\n\n return defaultLocale;\n}\n"],"names":[],"version":3,"file":"useDefaultLocale.module.js.map"}
|
package/dist/utils.main.js
CHANGED
|
@@ -50,7 +50,6 @@ const $4d65847630a056a8$var$RTL_LANGS = new Set([
|
|
|
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.
|
|
53
|
-
// @ts-ignore
|
|
54
53
|
if (Intl.Locale) {
|
|
55
54
|
let locale = new Intl.Locale(localeString).maximize();
|
|
56
55
|
// Use the text info object to get the direction if possible.
|
package/dist/utils.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,8CAA8C;AAC9C,MAAM,oCAAc,IAAI,IAAI;IAAC;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;CAAO;AAC5G,MAAM,kCAAY,IAAI,IAAI;IAAC;IAAM;IAAM;IAAO;IAAO;IAAO;IAAO;IAAM;IAAM;IAAO;IAAM;IAAM;IAAO;IAAO;IAAO;IAAM;IAAM;IAAM;IAAM;CAAK;AAK7I,SAAS,0CAAM,YAAoB;IACxC,kFAAkF;IAClF,
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,8CAA8C;AAC9C,MAAM,oCAAc,IAAI,IAAI;IAAC;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;CAAO;AAC5G,MAAM,kCAAY,IAAI,IAAI;IAAC;IAAM;IAAM;IAAO;IAAO;IAAO;IAAO;IAAM;IAAM;IAAO;IAAM;IAAM;IAAO;IAAO;IAAO;IAAM;IAAM;IAAM;IAAM;CAAK;AAK7I,SAAS,0CAAM,YAAoB;IACxC,kFAAkF;IAClF,IAAI,KAAK,MAAM,EAAE;QACf,IAAI,SAAS,IAAI,KAAK,MAAM,CAAC,cAAc,QAAQ;QAEnD,6DAA6D;QAC7D,6GAA6G;QAC7G,2GAA2G;QAC3G,IAAI,WAAW,OAAO,OAAO,WAAW,KAAK,aAAa,OAAO,WAAW,KAAK,OAAO,QAAQ;QAChG,IAAI,UACF,OAAO,SAAS,SAAS,KAAK;QAGhC,oCAAoC;QACpC,uGAAuG;QACvG,IAAI,OAAO,MAAM,EACf,OAAO,kCAAY,GAAG,CAAC,OAAO,MAAM;IAExC;IAEA,gEAAgE;IAChE,IAAI,OAAO,aAAa,KAAK,CAAC,IAAI,CAAC,EAAE;IACrC,OAAO,gCAAU,GAAG,CAAC;AACvB","sources":["packages/@react-aria/i18n/src/utils.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// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(localeString: string) {\n // If the Intl.Locale API is available, use it to get the locale's text direction.\n if (Intl.Locale) {\n let locale = new Intl.Locale(localeString).maximize();\n\n // Use the text info object to get the direction if possible.\n // @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo\n let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;\n if (textInfo) {\n return textInfo.direction === 'rtl';\n }\n\n // Fallback: guess using the script.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n if (locale.script) {\n return RTL_SCRIPTS.has(locale.script);\n }\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = localeString.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
|
package/dist/utils.mjs
CHANGED
|
@@ -44,7 +44,6 @@ const $148a7a147e38ea7f$var$RTL_LANGS = new Set([
|
|
|
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.
|
|
47
|
-
// @ts-ignore
|
|
48
47
|
if (Intl.Locale) {
|
|
49
48
|
let locale = new Intl.Locale(localeString).maximize();
|
|
50
49
|
// Use the text info object to get the direction if possible.
|
package/dist/utils.module.js
CHANGED
|
@@ -44,7 +44,6 @@ const $148a7a147e38ea7f$var$RTL_LANGS = new Set([
|
|
|
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.
|
|
47
|
-
// @ts-ignore
|
|
48
47
|
if (Intl.Locale) {
|
|
49
48
|
let locale = new Intl.Locale(localeString).maximize();
|
|
50
49
|
// Use the text info object to get the direction if possible.
|
package/dist/utils.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAED,8CAA8C;AAC9C,MAAM,oCAAc,IAAI,IAAI;IAAC;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;CAAO;AAC5G,MAAM,kCAAY,IAAI,IAAI;IAAC;IAAM;IAAM;IAAO;IAAO;IAAO;IAAO;IAAM;IAAM;IAAO;IAAM;IAAM;IAAO;IAAO;IAAO;IAAM;IAAM;IAAM;IAAM;CAAK;AAK7I,SAAS,0CAAM,YAAoB;IACxC,kFAAkF;IAClF,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAED,8CAA8C;AAC9C,MAAM,oCAAc,IAAI,IAAI;IAAC;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;CAAO;AAC5G,MAAM,kCAAY,IAAI,IAAI;IAAC;IAAM;IAAM;IAAO;IAAO;IAAO;IAAO;IAAM;IAAM;IAAO;IAAM;IAAM;IAAO;IAAO;IAAO;IAAM;IAAM;IAAM;IAAM;CAAK;AAK7I,SAAS,0CAAM,YAAoB;IACxC,kFAAkF;IAClF,IAAI,KAAK,MAAM,EAAE;QACf,IAAI,SAAS,IAAI,KAAK,MAAM,CAAC,cAAc,QAAQ;QAEnD,6DAA6D;QAC7D,6GAA6G;QAC7G,2GAA2G;QAC3G,IAAI,WAAW,OAAO,OAAO,WAAW,KAAK,aAAa,OAAO,WAAW,KAAK,OAAO,QAAQ;QAChG,IAAI,UACF,OAAO,SAAS,SAAS,KAAK;QAGhC,oCAAoC;QACpC,uGAAuG;QACvG,IAAI,OAAO,MAAM,EACf,OAAO,kCAAY,GAAG,CAAC,OAAO,MAAM;IAExC;IAEA,gEAAgE;IAChE,IAAI,OAAO,aAAa,KAAK,CAAC,IAAI,CAAC,EAAE;IACrC,OAAO,gCAAU,GAAG,CAAC;AACvB","sources":["packages/@react-aria/i18n/src/utils.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// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(localeString: string) {\n // If the Intl.Locale API is available, use it to get the locale's text direction.\n if (Intl.Locale) {\n let locale = new Intl.Locale(localeString).maximize();\n\n // Use the text info object to get the direction if possible.\n // @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo\n let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;\n if (textInfo) {\n return textInfo.direction === 'rtl';\n }\n\n // Fallback: guess using the script.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n if (locale.script) {\n return RTL_SCRIPTS.has(locale.script);\n }\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = localeString.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/i18n",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.4",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -47,20 +47,20 @@
|
|
|
47
47
|
"url": "https://github.com/adobe/react-spectrum"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@internationalized/date": "^3.
|
|
51
|
-
"@internationalized/message": "^3.1.
|
|
52
|
-
"@internationalized/number": "^3.
|
|
53
|
-
"@internationalized/string": "^3.2.
|
|
54
|
-
"@react-aria/ssr": "^3.9.
|
|
55
|
-
"@react-aria/utils": "^3.
|
|
56
|
-
"@react-types/shared": "^3.
|
|
50
|
+
"@internationalized/date": "^3.6.0",
|
|
51
|
+
"@internationalized/message": "^3.1.6",
|
|
52
|
+
"@internationalized/number": "^3.6.0",
|
|
53
|
+
"@internationalized/string": "^3.2.5",
|
|
54
|
+
"@react-aria/ssr": "^3.9.7",
|
|
55
|
+
"@react-aria/utils": "^3.26.0",
|
|
56
|
+
"@react-types/shared": "^3.26.0",
|
|
57
57
|
"@swc/helpers": "^0.5.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
60
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
66
66
|
}
|
package/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAmBM,SAAS,0CAA4B,KAAuC;IACjF,IAAI,OAAO,aAAa,aAAa;QACnC,QAAQ,GAAG,CAAC;QACZ,OAAO;IACT;IAEA,IAAI,SAAC,KAAK,UAAE,MAAM,WAAE,OAAO,EAAC,GAAG;IAC/B,4DAA4D;IAC5D,2DAA2D;IAC3D,qBAAO,0DAAC;QAAO,OAAO,OAAO,WAAW,cAAc,QAAQ;QAAI,0BAAA;QAAyB,yBAAyB;YAAC,QAAQ,0CAA6B,QAAQ;QAAQ;;AAC5K;AAKO,SAAS,0CAA6B,MAAc,EAAE,OAAgC;IAC3F,OAAO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OAAO,GAAG,CAAC;YAEjB,OAAO,GAAG,QAAQ,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACjE;QACA,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM;IAC3B;IACA,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM;IACzB,4BAAM,GAAG,CAAC,SAAS;IACnB,OAAO;AACT","sources":["packages/@react-aria/i18n/src/server.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 type {LocalizedString} from '@internationalized/string';\nimport React from 'react';\n\ntype PackageLocalizedStrings = {\n [packageName: string]: Record<string, LocalizedString>\n};\n\ninterface PackageLocalizationProviderProps {\n locale: string,\n strings: PackageLocalizedStrings,\n nonce?: string\n}\n\n/**\n * A PackageLocalizationProvider can be rendered on the server to inject the localized strings\n * needed by the client into the initial HTML.\n */\nexport function PackageLocalizationProvider(props: PackageLocalizationProviderProps) {\n if (typeof document !== 'undefined') {\n console.log('PackageLocalizationProvider should only be rendered on the server.');\n return null;\n }\n\n let {nonce, locale, strings} = props;\n // suppressHydrationWarning is necessary because the browser\n // remove the nonce parameter from the DOM before hydration\n return <script nonce={typeof window === 'undefined' ? nonce : ''} suppressHydrationWarning dangerouslySetInnerHTML={{__html: getPackageLocalizationScript(locale, strings)}} />;\n}\n\n/**\n * Returns the content for an inline `<script>` tag to inject localized strings into initial HTML.\n */\nexport function getPackageLocalizationScript(locale: string, strings: PackageLocalizedStrings) {\n return `window[Symbol.for('react-aria.i18n.locale')]=${JSON.stringify(locale)};{${serialize(strings)}}`;\n}\n\nconst cache = new WeakMap<PackageLocalizedStrings, string>();\n\nfunction serialize(strings: PackageLocalizedStrings): string {\n let cached = cache.get(strings);\n if (cached) {\n return cached;\n }\n\n // Find common strings between packages and hoist them into variables.\n let seen = new Set();\n let common = new Map();\n for (let pkg in strings) {\n for (let key in strings[pkg]) {\n let v = strings[pkg][key];\n let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();\n if (seen.has(s) && !common.has(s)) {\n let name = String.fromCharCode(common.size > 25 ? common.size + 97 : common.size + 65);\n common.set(s, name);\n }\n seen.add(s);\n }\n }\n\n let res = '';\n if (common.size > 0) {\n res += 'let ';\n }\n for (let [string, name] of common) {\n res += `${name}=${string},`;\n }\n if (common.size > 0) {\n res = res.slice(0, -1) + ';';\n }\n\n res += \"window[Symbol.for('react-aria.i18n.strings')]={\";\n for (let pkg in strings) {\n res += `'${pkg}':{`;\n for (let key in strings[pkg]) {\n let v = strings[pkg][key];\n let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();\n if (common.has(s)) {\n s = common.get(s);\n }\n res += `${/[ ()]/.test(key) ? JSON.stringify(key) : key}:${s},`;\n }\n res = res.slice(0, -1) + '},';\n }\n res = res.slice(0, -1) + '};';\n cache.set(strings, res);\n return res;\n}\n"],"names":[],"version":3,"file":"index.js.map"}
|
package/server/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAmBM,SAAS,0CAA4B,KAAuC;IACjF,IAAI,OAAO,aAAa,aAAa;QACnC,QAAQ,GAAG,CAAC;QACZ,OAAO;IACT;IAEA,IAAI,SAAC,KAAK,UAAE,MAAM,WAAE,OAAO,EAAC,GAAG;IAC/B,4DAA4D;IAC5D,2DAA2D;IAC3D,qBAAO,gCAAC;QAAO,OAAO,OAAO,WAAW,cAAc,QAAQ;QAAI,0BAAA;QAAyB,yBAAyB;YAAC,QAAQ,0CAA6B,QAAQ;QAAQ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AAQ;YAC9D,IAAI,OAAO,GAAG,CAAC,IACb,IAAI,OAAO,GAAG,CAAC;YAEjB,OAAO,GAAG,QAAQ,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACjE;QACA,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM;IAC3B;IACA,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM;IACzB,4BAAM,GAAG,CAAC,SAAS;IACnB,OAAO;AACT","sources":["packages/@react-aria/i18n/src/server.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 type {LocalizedString} from '@internationalized/string';\nimport React from 'react';\n\ntype PackageLocalizedStrings = {\n [packageName: string]: Record<string, LocalizedString>\n};\n\ninterface PackageLocalizationProviderProps {\n locale: string,\n strings: PackageLocalizedStrings,\n nonce?: string\n}\n\n/**\n * A PackageLocalizationProvider can be rendered on the server to inject the localized strings\n * needed by the client into the initial HTML.\n */\nexport function PackageLocalizationProvider(props: PackageLocalizationProviderProps) {\n if (typeof document !== 'undefined') {\n console.log('PackageLocalizationProvider should only be rendered on the server.');\n return null;\n }\n\n let {nonce, locale, strings} = props;\n // suppressHydrationWarning is necessary because the browser\n // remove the nonce parameter from the DOM before hydration\n return <script nonce={typeof window === 'undefined' ? nonce : ''} suppressHydrationWarning dangerouslySetInnerHTML={{__html: getPackageLocalizationScript(locale, strings)}} />;\n}\n\n/**\n * Returns the content for an inline `<script>` tag to inject localized strings into initial HTML.\n */\nexport function getPackageLocalizationScript(locale: string, strings: PackageLocalizedStrings) {\n return `window[Symbol.for('react-aria.i18n.locale')]=${JSON.stringify(locale)};{${serialize(strings)}}`;\n}\n\nconst cache = new WeakMap<PackageLocalizedStrings, string>();\n\nfunction serialize(strings: PackageLocalizedStrings): string {\n let cached = cache.get(strings);\n if (cached) {\n return cached;\n }\n\n // Find common strings between packages and hoist them into variables.\n let seen = new Set();\n let common = new Map();\n for (let pkg in strings) {\n for (let key in strings[pkg]) {\n let v = strings[pkg][key];\n let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();\n if (seen.has(s) && !common.has(s)) {\n let name = String.fromCharCode(common.size > 25 ? common.size + 97 : common.size + 65);\n common.set(s, name);\n }\n seen.add(s);\n }\n }\n\n let res = '';\n if (common.size > 0) {\n res += 'let ';\n }\n for (let [string, name] of common) {\n res += `${name}=${string},`;\n }\n if (common.size > 0) {\n res = res.slice(0, -1) + ';';\n }\n\n res += \"window[Symbol.for('react-aria.i18n.strings')]={\";\n for (let pkg in strings) {\n res += `'${pkg}':{`;\n for (let key in strings[pkg]) {\n let v = strings[pkg][key];\n let s = typeof v === 'string' ? JSON.stringify(v) : v.toString();\n if (common.has(s)) {\n s = common.get(s);\n }\n res += `${/[ ()]/.test(key) ? JSON.stringify(key) : key}:${s},`;\n }\n res = res.slice(0, -1) + '},';\n }\n res = res.slice(0, -1) + '};';\n cache.set(strings, res);\n return res;\n}\n"],"names":[],"version":3,"file":"index.mjs.map"}
|
package/src/useDefaultLocale.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -19,7 +19,6 @@ const RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', '
|
|
|
19
19
|
*/
|
|
20
20
|
export function isRTL(localeString: string) {
|
|
21
21
|
// If the Intl.Locale API is available, use it to get the locale's text direction.
|
|
22
|
-
// @ts-ignore
|
|
23
22
|
if (Intl.Locale) {
|
|
24
23
|
let locale = new Intl.Locale(localeString).maximize();
|
|
25
24
|
|