@okta/odyssey-react-mui 1.9.3 → 1.9.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/CHANGELOG.md +8 -0
- package/dist/OdysseyTranslationProvider.js +6 -1
- package/dist/OdysseyTranslationProvider.js.map +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/theme/components.js +28 -1
- package/dist/theme/components.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/OdysseyTranslationProvider.tsx +17 -1
- package/src/theme/components.tsx +28 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.9.5](https://github.com/okta/odyssey/compare/v1.9.4...v1.9.5) (2023-12-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @okta/odyssey-react-mui
|
|
9
|
+
|
|
10
|
+
## [1.9.4](https://github.com/okta/odyssey/compare/v1.9.3...v1.9.4) (2023-12-15)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @okta/odyssey-react-mui
|
|
13
|
+
|
|
6
14
|
## [1.9.3](https://github.com/okta/odyssey/compare/v1.9.2...v1.9.3) (2023-12-12)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @okta/odyssey-react-mui
|
|
@@ -23,6 +23,7 @@ const mergeBundleOverrides = (languageCode, translationOverrides) => {
|
|
|
23
23
|
...translationStringOverrides
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
const formatLanguageCodeToHyphenated = languageCode => languageCode?.replaceAll("_", "-");
|
|
26
27
|
export const OdysseyTranslationProvider = _ref => {
|
|
27
28
|
let {
|
|
28
29
|
children,
|
|
@@ -30,7 +31,11 @@ export const OdysseyTranslationProvider = _ref => {
|
|
|
30
31
|
translationOverrides
|
|
31
32
|
} = _ref;
|
|
32
33
|
useEffect(() => {
|
|
33
|
-
|
|
34
|
+
const normalizedLanguageCode = formatLanguageCodeToHyphenated(languageCode);
|
|
35
|
+
const changeHtmlElementLanguageAttribute = () => {
|
|
36
|
+
window.document.documentElement.setAttribute("lang", normalizedLanguageCode || "en");
|
|
37
|
+
};
|
|
38
|
+
i18n.changeLanguage(normalizedLanguageCode || window.navigator.language, changeHtmlElementLanguageAttribute);
|
|
34
39
|
}, [languageCode]);
|
|
35
40
|
useEffect(() => {
|
|
36
41
|
if (translationOverrides) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","getTypedObjectKeys","jsx","_jsx","mergeBundleOverrides","languageCode","translationOverrides","translationStrings","translationStringOverrides","OdysseyTranslationProvider","_ref","children","
|
|
1
|
+
{"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","getTypedObjectKeys","jsx","_jsx","mergeBundleOverrides","languageCode","translationOverrides","translationStrings","translationStringOverrides","formatLanguageCodeToHyphenated","replaceAll","OdysseyTranslationProvider","_ref","children","normalizedLanguageCode","changeHtmlElementLanguageAttribute","window","document","documentElement","setAttribute","changeLanguage","navigator","language","forEach","bundle","addResourceBundle"],"sources":["../src/OdysseyTranslationProvider.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { ReactNode, useEffect } from \"react\";\n\nimport { DefaultSupportedLanguages } from \"./OdysseyTranslationProvider.types\";\n\nimport { i18n, defaultNS, resources } from \"./i18n\";\nimport { I18nextProvider } from \"react-i18next\";\nimport { getTypedObjectKeys } from \"./getTypedObjectKeys\";\n\nexport type OdysseyI18nResourceKeys = (typeof resources)[\"en\"];\n\nexport type TranslationOverrides<\n SupportedLanguages extends string = DefaultSupportedLanguages\n> = Record<SupportedLanguages, Partial<OdysseyI18nResourceKeys>>;\n\nconst mergeBundleOverrides = <SupportedLanguages extends string>(\n languageCode: SupportedLanguages,\n translationOverrides: TranslationOverrides<SupportedLanguages>\n) => {\n const translationStrings = resources[languageCode] || {};\n const translationStringOverrides = translationOverrides[languageCode];\n return {\n ...translationStrings,\n ...translationStringOverrides,\n };\n};\n\nexport type OdysseyTranslationProviderProps<\n SupportedLanguages extends string = DefaultSupportedLanguages\n> = {\n children: ReactNode;\n languageCode?: SupportedLanguages | DefaultSupportedLanguages;\n translationOverrides?: TranslationOverrides<SupportedLanguages>;\n};\n\nconst formatLanguageCodeToHyphenated = <SupportedLanguages extends string>(\n languageCode: OdysseyTranslationProviderProps<SupportedLanguages>[\"languageCode\"]\n) => languageCode?.replaceAll(\"_\", \"-\");\n\nexport const OdysseyTranslationProvider = <SupportedLanguages extends string>({\n children,\n languageCode,\n translationOverrides,\n}: OdysseyTranslationProviderProps<SupportedLanguages>) => {\n useEffect(() => {\n const normalizedLanguageCode =\n formatLanguageCodeToHyphenated<SupportedLanguages>(languageCode);\n\n const changeHtmlElementLanguageAttribute = () => {\n window.document.documentElement.setAttribute(\n \"lang\",\n normalizedLanguageCode || \"en\"\n );\n };\n // Defaults to the browser's language if available otherwise `en` will be used\n i18n.changeLanguage(\n normalizedLanguageCode || window.navigator.language,\n changeHtmlElementLanguageAttribute\n );\n }, [languageCode]);\n\n useEffect(() => {\n if (translationOverrides) {\n getTypedObjectKeys(translationOverrides).forEach((language) => {\n const bundle = mergeBundleOverrides<SupportedLanguages>(\n language,\n translationOverrides\n );\n i18n.addResourceBundle(language, defaultNS, bundle);\n });\n }\n }, [translationOverrides]);\n\n return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAoBA,SAAS,QAAQ,OAAO;AAAC,SAIpCC,IAAI,EAAEC,SAAS,EAAEC,SAAS;AACnC,SAASC,eAAe,QAAQ,eAAe;AAAC,SACvCC,kBAAkB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAQ3B,MAAMC,oBAAoB,GAAGA,CAC3BC,YAAgC,EAChCC,oBAA8D,KAC3D;EACH,MAAMC,kBAAkB,GAAGR,SAAS,CAACM,YAAY,CAAC,IAAI,CAAC,CAAC;EACxD,MAAMG,0BAA0B,GAAGF,oBAAoB,CAACD,YAAY,CAAC;EACrE,OAAO;IACL,GAAGE,kBAAkB;IACrB,GAAGC;EACL,CAAC;AACH,CAAC;AAUD,MAAMC,8BAA8B,GAClCJ,YAAiF,IAC9EA,YAAY,EAAEK,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;AAEvC,OAAO,MAAMC,0BAA0B,GAAGC,IAAA,IAIiB;EAAA,IAJmB;IAC5EC,QAAQ;IACRR,YAAY;IACZC;EACmD,CAAC,GAAAM,IAAA;EACpDhB,SAAS,CAAC,MAAM;IACd,MAAMkB,sBAAsB,GAC1BL,8BAA8B,CAAqBJ,YAAY,CAAC;IAElE,MAAMU,kCAAkC,GAAGA,CAAA,KAAM;MAC/CC,MAAM,CAACC,QAAQ,CAACC,eAAe,CAACC,YAAY,CAC1C,MAAM,EACNL,sBAAsB,IAAI,IAC5B,CAAC;IACH,CAAC;IAEDjB,IAAI,CAACuB,cAAc,CACjBN,sBAAsB,IAAIE,MAAM,CAACK,SAAS,CAACC,QAAQ,EACnDP,kCACF,CAAC;EACH,CAAC,EAAE,CAACV,YAAY,CAAC,CAAC;EAElBT,SAAS,CAAC,MAAM;IACd,IAAIU,oBAAoB,EAAE;MACxBL,kBAAkB,CAACK,oBAAoB,CAAC,CAACiB,OAAO,CAAED,QAAQ,IAAK;QAC7D,MAAME,MAAM,GAAGpB,oBAAoB,CACjCkB,QAAQ,EACRhB,oBACF,CAAC;QACDT,IAAI,CAAC4B,iBAAiB,CAACH,QAAQ,EAAExB,SAAS,EAAE0B,MAAM,CAAC;MACrD,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAAClB,oBAAoB,CAAC,CAAC;EAE1B,OAAOH,IAAA,CAACH,eAAe;IAACH,IAAI,EAAEA,IAAK;IAAAgB,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAClE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyTranslationProvider.d.ts","sourceRoot":"","sources":["../../src/OdysseyTranslationProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EAAmB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIpD,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;AAE/D,MAAM,MAAM,oBAAoB,CAC9B,kBAAkB,SAAS,MAAM,GAAG,yBAAyB,IAC3D,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAcjE,MAAM,MAAM,+BAA+B,CACzC,kBAAkB,SAAS,MAAM,GAAG,yBAAyB,IAC3D;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,kBAAkB,GAAG,yBAAyB,CAAC;IAC9D,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;CACjE,CAAC;
|
|
1
|
+
{"version":3,"file":"OdysseyTranslationProvider.d.ts","sourceRoot":"","sources":["../../src/OdysseyTranslationProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EAAmB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIpD,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;AAE/D,MAAM,MAAM,oBAAoB,CAC9B,kBAAkB,SAAS,MAAM,GAAG,yBAAyB,IAC3D,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAcjE,MAAM,MAAM,+BAA+B,CACzC,kBAAkB,SAAS,MAAM,GAAG,yBAAyB,IAC3D;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,kBAAkB,GAAG,yBAAyB,CAAC;IAC9D,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,CAAC;CACjE,CAAC;AAMF,eAAO,MAAM,0BAA0B,4JAmCtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/theme/components.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAmC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,eAAO,MAAM,UAAU;mBAIN,YAAY;;MAEzB,YAAY,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/theme/components.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAmC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,eAAO,MAAM,UAAU;mBAIN,YAAY;;MAEzB,YAAY,CAAC,YAAY,CAkhF5B,CAAC"}
|
package/dist/theme/components.js
CHANGED
|
@@ -914,6 +914,32 @@ export const components = _ref => {
|
|
|
914
914
|
html {
|
|
915
915
|
font-size: calc((${themeParam.typography.fontSize} / 16) * 100%);
|
|
916
916
|
}
|
|
917
|
+
|
|
918
|
+
:not(code) &, :not(pre) & {
|
|
919
|
+
:lang(el) {
|
|
920
|
+
font-family: 'Noto Sans', sans-serif;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
:lang(ja) {
|
|
924
|
+
font-family: 'Noto Sans JP', sans-serif;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
:lang(ko) {
|
|
928
|
+
font-family: 'Noto Sans KR', sans-serif;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
:lang(th) {
|
|
932
|
+
font-family: 'Noto Sans Thai', sans-serif;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
:lang(zh-CN) {
|
|
936
|
+
font-family: 'Noto Sans SC', sans-serif;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
:lang(zh-TW) {
|
|
940
|
+
font-family: 'Noto Sans TC', sans-serif;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
917
943
|
`
|
|
918
944
|
},
|
|
919
945
|
MuiScopedCssBaseline: {
|
|
@@ -1973,7 +1999,8 @@ export const components = _ref => {
|
|
|
1973
1999
|
fontWeight: odysseyTokens.TypographyWeightHeading
|
|
1974
2000
|
}),
|
|
1975
2001
|
...(ownerState.disabled && {
|
|
1976
|
-
color: odysseyTokens.TypographyColorDisabled
|
|
2002
|
+
color: odysseyTokens.TypographyColorDisabled,
|
|
2003
|
+
opacity: "1 !important"
|
|
1977
2004
|
}),
|
|
1978
2005
|
...(ownerState.wrapped && {
|
|
1979
2006
|
fontSize: odysseyTokens.TypographySizeSubordinate,
|