@okta/odyssey-react-mui 1.9.12 → 1.9.14

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 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.14](https://github.com/okta/odyssey/compare/v1.9.13...v1.9.14) (2024-01-05)
7
+
8
+ **Note:** Version bump only for package @okta/odyssey-react-mui
9
+
10
+ ## [1.9.13](https://github.com/okta/odyssey/compare/v1.9.12...v1.9.13) (2024-01-04)
11
+
12
+ **Note:** Version bump only for package @okta/odyssey-react-mui
13
+
6
14
  ## [1.9.12](https://github.com/okta/odyssey/compare/v1.9.11...v1.9.12) (2023-12-22)
7
15
 
8
16
  **Note:** Version bump only for package @okta/odyssey-react-mui
package/dist/Badge.js CHANGED
@@ -38,38 +38,39 @@ const Badge = _ref => {
38
38
  type = "default"
39
39
  } = _ref;
40
40
  const odysseyDesignTokens = useOdysseyDesignTokens();
41
- const greaterThanZeroContentMax = badgeContentMax > 0 ? badgeContentMax : 1;
42
- const threeDigitLimitedMax = greaterThanZeroContentMax > 999 ? 999 : greaterThanZeroContentMax;
43
- const isOverContentMax = Boolean(badgeContent && badgeContent > threeDigitLimitedMax);
44
- const overContentMaxMessage = `${greaterThanZeroContentMax}+`;
45
- const formattedContent = isOverContentMax ? overContentMaxMessage : badgeContent;
46
- const contentIsLongerThanOneChar = formattedContent?.toString()?.length > 1;
47
- const badgeStyles = useMemo(() => ({
48
- display: "inline-flex",
49
- alignItems: "center",
50
- justifyContent: "center",
51
- minWidth: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,
52
- height: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,
53
- minHeight: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,
54
- padding: `0 calc(${odysseyDesignTokens.Spacing1} * 1.5)`,
55
- backgroundColor: badgeTypeColors(odysseyDesignTokens)[type].background,
56
- color: badgeTypeColors(odysseyDesignTokens)[type].font,
57
- borderRadius: contentIsLongerThanOneChar ? `${odysseyDesignTokens.BorderRadiusOuter}` : "50%",
58
- fontSize: `${odysseyDesignTokens.TypographyScale0}`,
59
- fontFamily: `${odysseyDesignTokens.TypographyFamilyMono}`,
60
- fontWeight: `${odysseyDesignTokens.TypographyWeightBodyBold}`,
61
- lineHeight: 1
62
- }), [type, contentIsLongerThanOneChar, odysseyDesignTokens]);
63
- const shouldHideBadge = badgeContent <= 0 || !badgeContent;
64
- if (shouldHideBadge) {
65
- return null;
66
- }
67
- return _jsx(Box, {
68
- sx: badgeStyles,
69
- "data-se": testId,
70
- translate: translate,
71
- children: formattedContent
72
- });
41
+ const renderBadge = useMemo(() => {
42
+ const greaterThanZeroContentMax = badgeContentMax > 0 ? badgeContentMax : 1;
43
+ const threeDigitLimitedMax = greaterThanZeroContentMax > 999 ? 999 : greaterThanZeroContentMax;
44
+ const isOverContentMax = badgeContent > threeDigitLimitedMax;
45
+ const overContentMaxMessage = `${greaterThanZeroContentMax}+`;
46
+ const formattedContent = isOverContentMax ? overContentMaxMessage : badgeContent.toString();
47
+ const badgeStyles = {
48
+ display: "inline-flex",
49
+ alignItems: "center",
50
+ justifyContent: "center",
51
+ minWidth: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,
52
+ height: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,
53
+ minHeight: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,
54
+ padding: "0 6px",
55
+ backgroundColor: badgeTypeColors(odysseyDesignTokens)[type].background,
56
+ color: badgeTypeColors(odysseyDesignTokens)[type].font,
57
+ borderRadius: formattedContent.length > 1 ? `${odysseyDesignTokens.BorderRadiusOuter}` : "50%",
58
+ fontSize: `${odysseyDesignTokens.TypographyScale0}`,
59
+ fontFamily: `${odysseyDesignTokens.TypographyFamilyMono}`,
60
+ fontWeight: `${odysseyDesignTokens.TypographyWeightBodyBold}`,
61
+ lineHeight: 1,
62
+ transitionDuration: `${odysseyDesignTokens.TransitionDurationMain}`,
63
+ transitionProperty: `background-color, color`
64
+ };
65
+ const hasNotificationCount = badgeContent && badgeContent > 0;
66
+ return hasNotificationCount ? _jsx(Box, {
67
+ sx: badgeStyles,
68
+ "data-se": testId,
69
+ translate: translate,
70
+ children: formattedContent
71
+ }) : null;
72
+ }, [badgeContent, badgeContentMax, odysseyDesignTokens, testId, translate, type]);
73
+ return renderBadge;
73
74
  };
74
75
  const MemoizedBadge = memo(Badge);
75
76
  MemoizedBadge.displayName = "Badge";
package/dist/Badge.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.js","names":["memo","useMemo","useOdysseyDesignTokens","Box","jsx","_jsx","badgeTypeValues","badgeTypeColors","odysseyTokens","default","background","HueNeutral200","font","TypographyColorBody","attention","PalettePrimaryMain","TypographyColorInverse","danger","PaletteDangerMain","Badge","_ref","badgeContent","badgeContentMax","testId","translate","type","odysseyDesignTokens","greaterThanZeroContentMax","threeDigitLimitedMax","isOverContentMax","Boolean","overContentMaxMessage","formattedContent","contentIsLongerThanOneChar","toString","length","badgeStyles","display","alignItems","justifyContent","minWidth","Spacing4","Spacing1","height","minHeight","padding","backgroundColor","color","borderRadius","BorderRadiusOuter","fontSize","TypographyScale0","fontFamily","TypographyFamilyMono","fontWeight","TypographyWeightBodyBold","lineHeight","shouldHideBadge","sx","children","MemoizedBadge","displayName"],"sources":["../src/Badge.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 { CSSProperties, memo, useMemo } from \"react\";\n\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext\";\nimport { Box } from \"./Box\";\nimport type { AllowedProps } from \"./AllowedProps\";\n\nexport const badgeTypeValues = [\"default\", \"attention\", \"danger\"] as const;\n\nexport type BadgeProps = {\n badgeContent: number;\n badgeContentMax?: number;\n type?: (typeof badgeTypeValues)[number];\n} & AllowedProps;\n\nconst badgeTypeColors = (odysseyTokens: DesignTokens) => ({\n default: {\n background: odysseyTokens.HueNeutral200,\n font: odysseyTokens.TypographyColorBody,\n },\n attention: {\n background: odysseyTokens.PalettePrimaryMain,\n font: odysseyTokens.TypographyColorInverse,\n },\n danger: {\n background: odysseyTokens.PaletteDangerMain,\n font: odysseyTokens.TypographyColorInverse,\n },\n});\n\nconst Badge = ({\n badgeContent,\n badgeContentMax = 999,\n testId,\n translate,\n type = \"default\",\n}: BadgeProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const greaterThanZeroContentMax = badgeContentMax > 0 ? badgeContentMax : 1;\n const threeDigitLimitedMax =\n greaterThanZeroContentMax > 999 ? 999 : greaterThanZeroContentMax;\n const isOverContentMax = Boolean(\n badgeContent && badgeContent > threeDigitLimitedMax\n );\n const overContentMaxMessage = `${greaterThanZeroContentMax}+`;\n const formattedContent = isOverContentMax\n ? overContentMaxMessage\n : badgeContent;\n const contentIsLongerThanOneChar = formattedContent?.toString()?.length > 1;\n\n const badgeStyles = useMemo<CSSProperties>(\n () => ({\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minWidth: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,\n height: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,\n minHeight: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,\n // 6px horizontal padding per design requirements\n padding: `0 calc(${odysseyDesignTokens.Spacing1} * 1.5)`,\n backgroundColor: badgeTypeColors(odysseyDesignTokens)[type].background,\n color: badgeTypeColors(odysseyDesignTokens)[type].font,\n borderRadius: contentIsLongerThanOneChar\n ? `${odysseyDesignTokens.BorderRadiusOuter}`\n : \"50%\",\n fontSize: `${odysseyDesignTokens.TypographyScale0}`,\n fontFamily: `${odysseyDesignTokens.TypographyFamilyMono}`,\n fontWeight: `${odysseyDesignTokens.TypographyWeightBodyBold}`,\n lineHeight: 1,\n }),\n [type, contentIsLongerThanOneChar, odysseyDesignTokens]\n );\n\n const shouldHideBadge = badgeContent <= 0 || !badgeContent;\n\n if (shouldHideBadge) {\n return null;\n }\n\n return (\n <Box sx={badgeStyles} data-se={testId} translate={translate}>\n {formattedContent}\n </Box>\n );\n};\n\nconst MemoizedBadge = memo(Badge);\nMemoizedBadge.displayName = \"Badge\";\n\nexport { MemoizedBadge as Badge };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAwBA,IAAI,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAGnDC,sBAAsB;AAAA,SAGfC,GAAG;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGZ,OAAO,MAAMC,eAAe,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAU;AAQ1E,MAAMC,eAAe,GAAIC,aAA2B,KAAM;EACxDC,OAAO,EAAE;IACPC,UAAU,EAAEF,aAAa,CAACG,aAAa;IACvCC,IAAI,EAAEJ,aAAa,CAACK;EACtB,CAAC;EACDC,SAAS,EAAE;IACTJ,UAAU,EAAEF,aAAa,CAACO,kBAAkB;IAC5CH,IAAI,EAAEJ,aAAa,CAACQ;EACtB,CAAC;EACDC,MAAM,EAAE;IACNP,UAAU,EAAEF,aAAa,CAACU,iBAAiB;IAC3CN,IAA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B,mBAAmB,CAAC,CAACD,IAAI,CAAC,CAACb,IAAI;IACtDoC,YAAY,EAAEf,0BAA0B,GACnC,GAAEP,mBAAmB,CAACuB,iBAAkB,EAAC,GAC1C,KAAK;IACTC,QAAQ,EAAG,GAAExB,mBAAmB,CAACyB,gBAAiB,EAAC;IACnDC,UAAU,EAAG,GAAE1B,mBAAmB,CAAC2B,oBAAqB,EAAC;IACzDC,UAAU,EAAG,GAAE5B,mBAAmB,CAAC6B,wBAAyB,EAAC;IAC7DC,UAAU,EAAE;EACd,CAAC,CAAC,EACF,CAAC/B,IAAI,EAAEQ,0BAA0B,EAAEP,mBAAmB,CACxD,CAAC;EAED,MAAM+B,eAAe,GAAGpC,YAAY,IAAI,CAAC,IAAI,CAACA,YAAY;EAE1D,IAAIoC,eAAe,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,OACEpD,IAAA,CAACF,GAAG;IAACuD,EAAE,EAAEtB,WAAY;IAAC,WAASb,MAAO;IAACC,SAAS,EAAEA,SAAU;IAAAmC,QAAA,EACzD3B;EAAgB,CACd,CAAC;AAEV,CAAC;AAED,MAAM4B,aAAa,GAAG5D,IAAI,CAACmB,KAAK,CAAC;AACjCyC,aAAa,CAACC,WAAW,GAAG,OAAO;AAEnC,SAASD,aAAa,IAAIzC,KAAK"}
1
+ {"version":3,"file":"Badge.js","names":["memo","useMemo","useOdysseyDesignTokens","Box","jsx","_jsx","badgeTypeValues","badgeTypeColors","odysseyTokens","default","background","HueNeutral200","font","TypographyColorBody","attention","PalettePrimaryMain","TypographyColorInverse","danger","PaletteDangerMain","Badge","_ref","badgeContent","badgeContentMax","testId","translate","type","odysseyDesignTokens","renderBadge","greaterThanZeroContentMax","threeDigitLimitedMax","isOverContentMax","overContentMaxMessage","formattedContent","toString","badgeStyles","display","alignItems","justifyContent","minWidth","Spacing4","Spacing1","height","minHeight","padding","backgroundColor","color","borderRadius","length","BorderRadiusOuter","fontSize","TypographyScale0","fontFamily","TypographyFamilyMono","fontWeight","TypographyWeightBodyBold","lineHeight","transitionDuration","TransitionDurationMain","transitionProperty","hasNotificationCount","sx","children","MemoizedBadge","displayName"],"sources":["../src/Badge.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 { CSSProperties, memo, useMemo } from \"react\";\n\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext\";\nimport { Box } from \"./Box\";\nimport type { AllowedProps } from \"./AllowedProps\";\n\nexport const badgeTypeValues = [\"default\", \"attention\", \"danger\"] as const;\n\nexport type BadgeProps = {\n badgeContent: number;\n badgeContentMax?: number;\n type?: (typeof badgeTypeValues)[number];\n} & AllowedProps;\n\nconst badgeTypeColors = (odysseyTokens: DesignTokens) => ({\n default: {\n background: odysseyTokens.HueNeutral200,\n font: odysseyTokens.TypographyColorBody,\n },\n attention: {\n background: odysseyTokens.PalettePrimaryMain,\n font: odysseyTokens.TypographyColorInverse,\n },\n danger: {\n background: odysseyTokens.PaletteDangerMain,\n font: odysseyTokens.TypographyColorInverse,\n },\n});\n\nconst Badge = ({\n badgeContent,\n badgeContentMax = 999,\n testId,\n translate,\n type = \"default\",\n}: BadgeProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const renderBadge = useMemo(() => {\n const greaterThanZeroContentMax = badgeContentMax > 0 ? badgeContentMax : 1;\n const threeDigitLimitedMax =\n greaterThanZeroContentMax > 999 ? 999 : greaterThanZeroContentMax;\n const isOverContentMax = badgeContent > threeDigitLimitedMax;\n const overContentMaxMessage = `${greaterThanZeroContentMax}+`;\n const formattedContent = isOverContentMax\n ? overContentMaxMessage\n : badgeContent.toString();\n\n const badgeStyles: CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n minWidth: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,\n height: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,\n minHeight: `calc(${odysseyDesignTokens.Spacing4} + ${odysseyDesignTokens.Spacing1})`,\n // 6px horizontal padding per design requirements\n padding: \"0 6px\",\n backgroundColor: badgeTypeColors(odysseyDesignTokens)[type].background,\n color: badgeTypeColors(odysseyDesignTokens)[type].font,\n borderRadius:\n formattedContent.length > 1\n ? `${odysseyDesignTokens.BorderRadiusOuter}`\n : \"50%\",\n fontSize: `${odysseyDesignTokens.TypographyScale0}`,\n fontFamily: `${odysseyDesignTokens.TypographyFamilyMono}`,\n fontWeight: `${odysseyDesignTokens.TypographyWeightBodyBold}`,\n lineHeight: 1,\n transitionDuration: `${odysseyDesignTokens.TransitionDurationMain}`,\n transitionProperty: `background-color, color`,\n };\n\n const hasNotificationCount = badgeContent && badgeContent > 0;\n\n return hasNotificationCount ? (\n <Box sx={badgeStyles} data-se={testId} translate={translate}>\n {formattedContent}\n </Box>\n ) : null;\n }, [\n badgeContent,\n badgeContentMax,\n odysseyDesignTokens,\n testId,\n translate,\n type,\n ]);\n\n return renderBadge;\n};\n\nconst MemoizedBadge = memo(Badge);\nMemoizedBadge.displayName = \"Badge\";\n\nexport { MemoizedBadge as Badge };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAwBA,IAAI,EAAEC,OAAO,QAAQ,OAAO;AAAC,SAGnDC,sBAAsB;AAAA,SAGfC,GAAG;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGZ,OAAO,MAAMC,eAAe,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAU;AAQ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ttribute = () => {
37
37
  window.document.documentElement.setAttribute("lang", normalizedLanguageCode || "en");
38
38
  };
39
- i18n.changeLanguage(normalizedLanguageCode || window.navigator.language, changeHtmlElementLanguageAttribute);
39
+ i18n.changeLanguage(languageCode || window.navigator.language, changeHtmlElementLanguageAttribute);
40
40
  }, [languageCode]);
41
41
  useEffect(() => {
42
42
  if (translationOverrides) {
@@ -1 +1 @@
1
- {"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","getTypedObjectKeys","jsx","_jsx","odysseyI18nResourceKeysList","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\"];\nexport const odysseyI18nResourceKeysList = getTypedObjectKeys(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,QA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Q,EAAEzB,SAAS,EAAE2B,MAAM,CAAC;MACrD,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAAClB,oBAAoB,CAAC,CAAC;EAE1B,OAAOJ,IAAA,CAACH,eAAe;IAACH,IAAI,EAAEA,IAAK;IAAAiB,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAClE,CAAC"}
1
+ {"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","getTypedObjectKeys","jsx","_jsx","odysseyI18nResourceKeysList","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\"];\nexport const odysseyI18nResourceKeysList = getTypedObjectKeys(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 languageCode || 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;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AC;MACrD,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAAClB,oBAAoB,CAAC,CAAC;EAE1B,OAAOJ,IAAA,CAACH,eAAe;IAACH,IAAI,EAAEA,IAAK;IAAAiB,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAClE,CAAC"}
package/dist/Tabs.js CHANGED
@@ -11,18 +11,44 @@ import _Tab from "@mui/material/Tab";
11
11
  * See the License for the specific language governing permissions and limitations under the License.
12
12
  */
13
13
 
14
- import { TabContext as MuiTabContext, TabList as MuiTabList, TabPanel as MuiTabPanel } from "@mui/lab";
15
14
  import { memo, useCallback, useEffect, useState } from "react";
15
+ import { TabContext as MuiTabContext, TabList as MuiTabList, TabPanel as MuiTabPanel } from "@mui/lab";
16
+ import { useOdysseyDesignTokens } from "./OdysseyDesignTokensContext.js";
17
+ import { Badge } from "./Badge.js";
18
+ import { Box } from "./Box.js";
16
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { Fragment as _Fragment } from "react/jsx-runtime";
17
21
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
- const Tabs = _ref => {
22
+ const TabLabel = _ref => {
23
+ let {
24
+ label,
25
+ notificationCount,
26
+ notificationCountMax,
27
+ tabState,
28
+ value
29
+ } = _ref;
30
+ const odysseyDesignTokens = useOdysseyDesignTokens();
31
+ return _jsxs(_Fragment, {
32
+ children: [label, notificationCount !== undefined && notificationCount > 0 && _jsx(Box, {
33
+ sx: {
34
+ marginInlineStart: notificationCount ? odysseyDesignTokens.Spacing2 : 0
35
+ },
36
+ children: _jsx(Badge, {
37
+ badgeContent: notificationCount,
38
+ badgeContentMax: notificationCountMax,
39
+ type: value === tabState ? "attention" : "default"
40
+ })
41
+ })]
42
+ });
43
+ };
44
+ const Tabs = _ref2 => {
19
45
  let {
20
46
  ariaLabel,
21
47
  initialValue,
22
48
  tabs,
23
49
  value,
24
50
  onChange: onChangeProp
25
- } = _ref;
51
+ } = _ref2;
26
52
  const [tabState, setTabState] = useState(initialValue ?? value ?? "0");
27
53
  const onChange = useCallback((event, value) => {
28
54
  setTabState(value);
@@ -33,18 +59,36 @@ const Tabs = _ref => {
33
59
  setTabState(value);
34
60
  }
35
61
  }, [value]);
62
+ const renderTab = useCallback((tab, index) => {
63
+ const {
64
+ testId,
65
+ isDisabled,
66
+ label,
67
+ startIcon,
68
+ value,
69
+ notificationCount,
70
+ notificationCountMax
71
+ } = tab;
72
+ return _jsx(_Tab, {
73
+ "data-se": testId,
74
+ disabled: isDisabled,
75
+ icon: startIcon,
76
+ label: _jsx(TabLabel, {
77
+ label: label,
78
+ notificationCount: notificationCount,
79
+ notificationCountMax: notificationCountMax,
80
+ tabState: tabState,
81
+ value: value
82
+ }),
83
+ value: value ? value : index.toString()
84
+ }, value ? value : index.toString());
85
+ }, [tabState]);
36
86
  return _jsxs(MuiTabContext, {
37
87
  value: tabState,
38
88
  children: [_jsx(MuiTabList, {
39
89
  onChange: onChange,
40
90
  "aria-label": ariaLabel,
41
- children: tabs.map((tab, index) => _jsx(_Tab, {
42
- "data-se": tab.testId,
43
- disabled: tab.isDisabled,
44
- icon: tab.startIcon,
45
- label: tab.label,
46
- value: tab.value ? tab.value : index.toString()
47
- }, tab.value ? tab.value : index.toString()))
91
+ children: tabs.map((tab, index) => renderTab(tab, index))
48
92
  }), tabs.map((tab, index) => _jsx(MuiTabPanel, {
49
93
  value: tab.value ? tab.value : index.toString(),
50
94
  children: tab.children
package/dist/Tabs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","names":["TabContext","MuiTabContext","TabList","MuiTabList","TabPanel","MuiTabPanel","memo","useCallback","useEffect","useState","jsx","_jsx","jsxs","_jsxs","Tabs","_ref","ariaLabel","initialValue","tabs","value","onChange","onChangeProp","tabState","setTabState","event","undefined","children","map","tab","index","_Tab","testId","disabled","isDisabled","icon","startIcon","label","toString","MemoizedTabs","displayName"],"sources":["../src/Tabs.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-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 {\n TabContext as MuiTabContext,\n TabList as MuiTabList,\n TabListProps as MuiTabListProps,\n TabPanel as MuiTabPanel,\n} from \"@mui/lab\";\nimport { Tab as MuiTab } from \"@mui/material\";\nimport {\n ReactElement,\n ReactNode,\n memo,\n useCallback,\n useEffect,\n useState,\n} from \"react\";\nimport { AllowedProps } from \"./AllowedProps\";\n\nexport type TabItemProps = {\n /**\n * The content of the Tab itself\n */\n children: ReactNode;\n /**\n * If `true`, the TabItem is disabled\n */\n isDisabled?: boolean;\n /**\n * The label text for the TabItem\n */\n label: string;\n /**\n * An optional icon to display at the start of the TabItem\n */\n startIcon?: ReactElement;\n /**\n * The value associated with the TabItem\n */\n value?: string;\n} & AllowedProps;\n\nexport type TabsProps = {\n /**\n * The ARIA label for the full Tabs group\n */\n ariaLabel?: string;\n /**\n * @deprecated please use the `value` prop instead\n * When `value` is provided, `initialValue` isn't used.\n */\n initialValue?: string;\n /**\n * The TabItems to be included in the Tabs group\n */\n tabs: TabItemProps[];\n /**\n * Identifier for the selected tab.\n */\n value?: string;\n /**\n * Callback fired when the active tab is changed.\n */\n onChange?: MuiTabListProps[\"onChange\"];\n};\n\nconst Tabs = ({\n ariaLabel,\n initialValue,\n tabs,\n value,\n onChange: onChangeProp,\n}: TabsProps) => {\n const [tabState, setTabState] = useState(initialValue ?? value ?? \"0\");\n\n const onChange = useCallback<NonNullable<MuiTabListProps[\"onChange\"]>>(\n (event, value: string) => {\n setTabState(value);\n onChangeProp?.(event, value);\n },\n [onChangeProp]\n );\n\n useEffect(() => {\n if (value !== undefined) {\n setTabState(value);\n }\n }, [value]);\n\n return (\n <MuiTabContext value={tabState}>\n <MuiTabList onChange={onChange} aria-label={ariaLabel}>\n {tabs.map((tab, index) => (\n <MuiTab\n data-se={tab.testId}\n disabled={tab.isDisabled}\n icon={tab.startIcon}\n label={tab.label}\n value={tab.value ? tab.value : index.toString()}\n key={tab.value ? tab.value : index.toString()}\n />\n ))}\n </MuiTabList>\n {tabs.map((tab, index) => (\n <MuiTabPanel\n value={tab.value ? tab.value : index.toString()}\n key={tab.value ? tab.value : index.toString()}\n >\n {tab.children}\n </MuiTabPanel>\n ))}\n </MuiTabContext>\n );\n};\n\nconst MemoizedTabs = memo(Tabs);\nMemoizedTabs.displayName = \"Tabs\";\n\nexport { MemoizedTabs as Tabs };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,UAAU,IAAIC,aAAa,EAC3BC,OAAO,IAAIC,UAAU,EAErBC,QAAQ,IAAIC,WAAW,QAClB,UAAU;AAEjB,SAGEC,IAAI,EACJC,WAAW,EACXC,SAAS,EACTC,QAAQ,QACH,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAkDf,MAAMC,IAAI,GAAGC,IAAA,IAMI;EAAA,IANH;IACZC,SAAS;IACTC,YAAY;IACZC,IAAI;IACJC,KAAK;IACLC,QAAQ,EAAEC;EACD,CAAC,GAAAN,IAAA;EACV,MAAM,CAACO,QAAQ,EAAEC,WAAW,CAAC,GAAGd,QAAQ,CAACQ,YAAY,IAAIE,KAAK,IAAI,GAAG,CAAC;EAEtE,MAAMC,QAAQ,GAAGb,WAAW,CAC1B,CAACiB,KAAK,EAAEL,KAAa,KAAK;IACxBI,WAAW,CAACJ,KAAK,CAAC;IAClBE,YAAY,GAAGG,KAAK,EAAEL,KAAK,CAAC;EAC9B,CAAC,EACD,CAACE,YAAY,CACf,CAAC;EAEDb,SAAS,CAAC,MAA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Tabs.js","names":["memo","useCallback","useEffect","useState","TabContext","MuiTabContext","TabList","MuiTabList","TabPanel","MuiTabPanel","useOdysseyDesignTokens","Badge","Box","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","TabLabel","_ref","label","notificationCount","notificationCountMax","tabState","value","odysseyDesignTokens","children","undefined","sx","marginInlineStart","Spacing2","badgeContent","badgeContentMax","type","Tabs","_ref2","ariaLabel","initialValue","tabs","onChange","onChangeProp","setTabState","event","renderTab","tab","index","testId","isDisabled","startIcon","_Tab","disabled","icon","toString","map","MemoizedTabs","displayName"],"sources":["../src/Tabs.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-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 {\n ReactElement,\n ReactNode,\n memo,\n useCallback,\n useEffect,\n useState,\n} from \"react\";\nimport {\n TabContext as MuiTabContext,\n TabList as MuiTabList,\n TabListProps as MuiTabListProps,\n TabPanel as MuiTabPanel,\n} from \"@mui/lab\";\nimport { Tab as MuiTab } from \"@mui/material\";\n\nimport { useOdysseyDesignTokens } from \"./OdysseyDesignTokensContext\";\nimport { Badge, BadgeProps } from \"./Badge\";\nimport { AllowedProps } from \"./AllowedProps\";\nimport { Box } from \"./Box\";\n\nexport type TabItemProps = {\n /**\n * The content of the Tab itself\n */\n children: ReactNode;\n /**\n * If `true`, the TabItem is disabled\n */\n isDisabled?: boolean;\n /**\n * The label text for the TabItem\n */\n label: string;\n /**\n * An optional icon to display at the start of the TabItem\n */\n startIcon?: ReactElement;\n /**\n * The value associated with the TabItem\n */\n value?: string;\n} & {\n notificationCount?: BadgeProps[\"badgeContent\"];\n notificationCountMax?: BadgeProps[\"badgeContentMax\"];\n} & AllowedProps;\n\nexport type TabsProps = {\n /**\n * The ARIA label for the full Tabs group\n */\n ariaLabel?: string;\n /**\n * @deprecated please use the `value` prop instead\n * When `value` is provided, `initialValue` isn't used.\n */\n initialValue?: string;\n /**\n * The TabItems to be included in the Tabs group\n */\n tabs: TabItemProps[];\n /**\n * Identifier for the selected tab.\n */\n value?: string;\n /**\n * Callback fired when the active tab is changed.\n */\n onChange?: MuiTabListProps[\"onChange\"];\n};\n\nconst TabLabel = ({\n label,\n notificationCount,\n notificationCountMax,\n tabState,\n value,\n}: Pick<\n TabItemProps,\n \"label\" | \"notificationCount\" | \"notificationCountMax\" | \"value\"\n> & {\n tabState: string;\n}) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n return (\n <>\n {label}\n {notificationCount !== undefined && notificationCount > 0 && (\n <Box\n sx={{\n marginInlineStart: notificationCount\n ? odysseyDesignTokens.Spacing2\n : 0,\n }}\n >\n <Badge\n badgeContent={notificationCount}\n badgeContentMax={notificationCountMax}\n type={value === tabState ? \"attention\" : \"default\"}\n />\n </Box>\n )}\n </>\n );\n};\n\nconst Tabs = ({\n ariaLabel,\n initialValue,\n tabs,\n value,\n onChange: onChangeProp,\n}: TabsProps) => {\n const [tabState, setTabState] = useState(initialValue ?? value ?? \"0\");\n\n const onChange = useCallback<NonNullable<MuiTabListProps[\"onChange\"]>>(\n (event, value: string) => {\n setTabState(value);\n onChangeProp?.(event, value);\n },\n [onChangeProp]\n );\n\n useEffect(() => {\n if (value !== undefined) {\n setTabState(value);\n }\n }, [value]);\n\n const renderTab = useCallback(\n (tab, index) => {\n const {\n testId,\n isDisabled,\n label,\n startIcon,\n value,\n notificationCount,\n notificationCountMax,\n } = tab;\n\n return (\n <MuiTab\n data-se={testId}\n disabled={isDisabled}\n icon={startIcon}\n label={\n <TabLabel\n label={label}\n notificationCount={notificationCount}\n notificationCountMax={notificationCountMax}\n tabState={tabState}\n value={value}\n />\n }\n value={value ? value : index.toString()}\n key={value ? value : index.toString()}\n />\n );\n },\n [tabState]\n );\n\n return (\n <MuiTabContext value={tabState}>\n <MuiTabList onChange={onChange} aria-label={ariaLabel}>\n {tabs.map((tab, index) => renderTab(tab, index))}\n </MuiTabList>\n {tabs.map((tab, index) => (\n <MuiTabPanel\n value={tab.value ? tab.value : index.toString()}\n key={tab.value ? tab.value : index.toString()}\n >\n {tab.children}\n </MuiTabPanel>\n ))}\n </MuiTabContext>\n );\n};\n\nconst MemoizedTabs = memo(Tabs);\nMemoizedTabs.displayName = \"Tabs\";\n\nexport { MemoizedTabs as Tabs };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAGEA,IAAI,EACJC,WAAW,EACXC,SAAS,EACTC,QAAQ,QACH,OAAO;AACd,SACEC,UAAU,IAAIC,aAAa,EAC3BC,OAAO,IAAIC,UAAU,EAErBC,QAAQ,IAAIC,WAAW,QAClB,UAAU;AAAC,SAGTC,sBAAsB;AAAA,SACtBC,KAAK;AAAA,SAELC,GAAG;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAoDZ,MAAMC,QAAQ,GAAGC,IAAA,IAWX;EAAA,IAXY;IAChBC,KAAK;IACLC,iBAAiB;IACjBC,oBAAoB;IACpBC,QAAQ;IACRC;EAMF,CAAC,GAAAL,IAAA;EACC,MAAMM,mBAAmB,GAAGhB,sBAAsB,CAAC,CAAC;EAEpD,OACEQ,KAAA,CAAAF,SAAA;IAAAW,QAAA,GACGN,KAAK,EACLC,iBAAiB,KAAKM,SAAS,IAAIN,iBAAiB,GAAG,CAAC,IACvDR,IAAA,CAACF,GAAG;MACFiB,EAAE,EAAE;QACFC,iBAAiB,EAAER,iBAAiB,GAChCI,mBAAmB,CAACK,QAAQ,GAC5B;MACN,CAAE;MAAAJ,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E,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;CACzC,GAAG,YAAY,CAAC;AA0EjB,QAAA,MAAM,aAAa,oGAnDhB,UAAU,wBAmDoB,CAAC;AAGlC,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/Badge.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,eAAe,6CAA8C,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;CACzC,GAAG,YAAY,CAAC;AA8EjB,QAAA,MAAM,aAAa,oGAvDhB,UAAU,wBAuDoB,CAAC;AAGlC,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,CAAC"}
@@ -9,8 +9,9 @@
9
9
  *
10
10
  * See the License for the specific language governing permissions and limitations under the License.
11
11
  */
12
- import { TabListProps as MuiTabListProps } from "@mui/lab";
13
12
  import { ReactElement, ReactNode } from "react";
13
+ import { TabListProps as MuiTabListProps } from "@mui/lab";
14
+ import { BadgeProps } from "./Badge";
14
15
  import { AllowedProps } from "./AllowedProps";
15
16
  export type TabItemProps = {
16
17
  /**
@@ -33,6 +34,9 @@ export type TabItemProps = {
33
34
  * The value associated with the TabItem
34
35
  */
35
36
  value?: string;
37
+ } & {
38
+ notificationCount?: BadgeProps["badgeContent"];
39
+ notificationCountMax?: BadgeProps["badgeContentMax"];
36
40
  } & AllowedProps;
37
41
  export type TabsProps = {
38
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/Tabs.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGL,YAAY,IAAI,eAAe,EAEhC,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,YAAY,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,YAAY,CAAC;AAEjB,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;CACxC,CAAC;AAmDF,QAAA,MAAM,YAAY,0GA3Cf,SAAS,iBA2CmB,CAAC;AAGhC,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../src/Tabs.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,YAAY,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,YAAY,IAAI,eAAe,EAEhC,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG;IACF,iBAAiB,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAC/C,oBAAoB,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;CACtD,GAAG,YAAY,CAAC;AAEjB,MAAM,MAAM,SAAS,GAAG;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;CACxC,CAAC;AAgHF,QAAA,MAAM,YAAY,0GApEf,SAAS,iBAoEmB,CAAC;AAGhC,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,CAAC"}
@@ -2069,7 +2069,7 @@ export const components = _ref => {
2069
2069
  return {
2070
2070
  maxWidth: `calc(${odysseyTokens.TypographyLineLengthMax} / 2)`,
2071
2071
  minWidth: "unset",
2072
- minHeight: "unset",
2072
+ minHeight: odysseyTokens.Spacing9,
2073
2073
  padding: `${odysseyTokens.Spacing4} ${odysseyTokens.Spacing1}`,
2074
2074
  fontSize: odysseyTokens.TypographySizeHeading6,
2075
2075
  fontFamily: odysseyTokens.TypographyFamilyHeading,