@okta/odyssey-react-mui 1.35.0 → 1.35.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.
Files changed (145) hide show
  1. package/dist/cjs/DatePickers/useOdysseyDateFields.cjs +2 -2
  2. package/dist/cjs/DatePickers/useOdysseyDateFields.cjs.map +1 -1
  3. package/dist/cjs/Field.cjs +1 -1
  4. package/dist/cjs/Field.cjs.map +1 -1
  5. package/dist/cjs/Pagination/Pagination.cjs +0 -6
  6. package/dist/cjs/Pagination/Pagination.cjs.map +1 -1
  7. package/dist/cjs/inputUtils.cjs +1 -1
  8. package/dist/cjs/inputUtils.cjs.map +1 -1
  9. package/dist/cjs/labs/DataFilters.cjs +4 -4
  10. package/dist/cjs/labs/DataFilters.cjs.map +1 -1
  11. package/dist/cjs/labs/DataView/DataCard.cjs +18 -18
  12. package/dist/cjs/labs/DataView/DataCard.cjs.map +1 -1
  13. package/dist/cjs/labs/DataView/DataView.cjs +10 -10
  14. package/dist/cjs/labs/DataView/DataView.cjs.map +1 -1
  15. package/dist/cjs/labs/DataView/TableLayoutContent.cjs +4 -1
  16. package/dist/cjs/labs/DataView/TableLayoutContent.cjs.map +1 -1
  17. package/dist/cjs/labs/DataView/useFilterConversion.cjs +1 -1
  18. package/dist/cjs/labs/DataView/useFilterConversion.cjs.map +1 -1
  19. package/dist/cjs/theme/StringWithValue.cjs +6 -0
  20. package/dist/cjs/theme/StringWithValue.cjs.map +1 -0
  21. package/dist/cjs/theme/components.cjs +2590 -2592
  22. package/dist/cjs/theme/components.cjs.map +1 -1
  23. package/dist/cjs/theme/useMediaQuery.cjs +4 -4
  24. package/dist/cjs/theme/useMediaQuery.cjs.map +1 -1
  25. package/dist/cjs/ui-shell/InnerAppContainer.cjs +60 -0
  26. package/dist/cjs/ui-shell/InnerAppContainer.cjs.map +1 -0
  27. package/dist/cjs/ui-shell/NarrowUiShellContent.cjs +6 -1
  28. package/dist/cjs/ui-shell/NarrowUiShellContent.cjs.map +1 -1
  29. package/dist/cjs/ui-shell/SideNav/SideNav.cjs +79 -48
  30. package/dist/cjs/ui-shell/SideNav/SideNav.cjs.map +1 -1
  31. package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs +84 -112
  32. package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs.map +1 -1
  33. package/dist/cjs/ui-shell/TopNav/TopNav.cjs +1 -6
  34. package/dist/cjs/ui-shell/TopNav/TopNav.cjs.map +1 -1
  35. package/dist/cjs/ui-shell/UiShell.cjs +6 -5
  36. package/dist/cjs/ui-shell/UiShell.cjs.map +1 -1
  37. package/dist/cjs/ui-shell/WideUiShellContent.cjs +10 -4
  38. package/dist/cjs/ui-shell/WideUiShellContent.cjs.map +1 -1
  39. package/dist/cjs/ui-shell/index.cjs +29 -9
  40. package/dist/cjs/ui-shell/index.cjs.map +1 -1
  41. package/dist/cjs/ui-shell/renderUiShell.cjs +2 -0
  42. package/dist/cjs/ui-shell/renderUiShell.cjs.map +1 -1
  43. package/dist/cjs/ui-shell/useMatchAppElementToUiShellAppArea.cjs +3 -2
  44. package/dist/cjs/ui-shell/useMatchAppElementToUiShellAppArea.cjs.map +1 -1
  45. package/dist/cjs/ui-shell/useScrollState.cjs +71 -21
  46. package/dist/cjs/ui-shell/useScrollState.cjs.map +1 -1
  47. package/dist/cjs/ui-shell/useUiShellBreakpoints.cjs +20 -15
  48. package/dist/cjs/ui-shell/useUiShellBreakpoints.cjs.map +1 -1
  49. package/dist/cjs/web-component/createReactRootElements.cjs +5 -3
  50. package/dist/cjs/web-component/createReactRootElements.cjs.map +1 -1
  51. package/dist/cjs/web-component/renderReactInWebComponent.cjs +21 -7
  52. package/dist/cjs/web-component/renderReactInWebComponent.cjs.map +1 -1
  53. package/dist/esm/DatePickers/useOdysseyDateFields.js +2 -2
  54. package/dist/esm/DatePickers/useOdysseyDateFields.js.map +1 -1
  55. package/dist/esm/Field.js +1 -1
  56. package/dist/esm/Field.js.map +1 -1
  57. package/dist/esm/Pagination/Pagination.js +0 -6
  58. package/dist/esm/Pagination/Pagination.js.map +1 -1
  59. package/dist/esm/inputUtils.js +1 -1
  60. package/dist/esm/inputUtils.js.map +1 -1
  61. package/dist/esm/labs/DataFilters.js +4 -4
  62. package/dist/esm/labs/DataFilters.js.map +1 -1
  63. package/dist/esm/labs/DataView/DataCard.js +18 -18
  64. package/dist/esm/labs/DataView/DataCard.js.map +1 -1
  65. package/dist/esm/labs/DataView/DataView.js +10 -10
  66. package/dist/esm/labs/DataView/DataView.js.map +1 -1
  67. package/dist/esm/labs/DataView/TableLayoutContent.js +4 -1
  68. package/dist/esm/labs/DataView/TableLayoutContent.js.map +1 -1
  69. package/dist/esm/labs/DataView/useFilterConversion.js +1 -1
  70. package/dist/esm/labs/DataView/useFilterConversion.js.map +1 -1
  71. package/dist/esm/theme/StringWithValue.js +2 -0
  72. package/dist/esm/theme/StringWithValue.js.map +1 -0
  73. package/dist/esm/theme/components.js +2607 -2609
  74. package/dist/esm/theme/components.js.map +1 -1
  75. package/dist/esm/theme/useMediaQuery.js +5 -5
  76. package/dist/esm/theme/useMediaQuery.js.map +1 -1
  77. package/dist/esm/ui-shell/InnerAppContainer.js +56 -0
  78. package/dist/esm/ui-shell/InnerAppContainer.js.map +1 -0
  79. package/dist/esm/ui-shell/NarrowUiShellContent.js +6 -1
  80. package/dist/esm/ui-shell/NarrowUiShellContent.js.map +1 -1
  81. package/dist/esm/ui-shell/SideNav/SideNav.js +80 -49
  82. package/dist/esm/ui-shell/SideNav/SideNav.js.map +1 -1
  83. package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js +85 -113
  84. package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js.map +1 -1
  85. package/dist/esm/ui-shell/TopNav/TopNav.js +1 -6
  86. package/dist/esm/ui-shell/TopNav/TopNav.js.map +1 -1
  87. package/dist/esm/ui-shell/UiShell.js +6 -5
  88. package/dist/esm/ui-shell/UiShell.js.map +1 -1
  89. package/dist/esm/ui-shell/WideUiShellContent.js +10 -4
  90. package/dist/esm/ui-shell/WideUiShellContent.js.map +1 -1
  91. package/dist/esm/ui-shell/index.js +3 -1
  92. package/dist/esm/ui-shell/index.js.map +1 -1
  93. package/dist/esm/ui-shell/renderUiShell.js +2 -0
  94. package/dist/esm/ui-shell/renderUiShell.js.map +1 -1
  95. package/dist/esm/ui-shell/useMatchAppElementToUiShellAppArea.js +3 -2
  96. package/dist/esm/ui-shell/useMatchAppElementToUiShellAppArea.js.map +1 -1
  97. package/dist/esm/ui-shell/useScrollState.js +67 -21
  98. package/dist/esm/ui-shell/useScrollState.js.map +1 -1
  99. package/dist/esm/ui-shell/useUiShellBreakpoints.js +19 -14
  100. package/dist/esm/ui-shell/useUiShellBreakpoints.js.map +1 -1
  101. package/dist/esm/web-component/createReactRootElements.js +4 -2
  102. package/dist/esm/web-component/createReactRootElements.js.map +1 -1
  103. package/dist/esm/web-component/renderReactInWebComponent.js +19 -5
  104. package/dist/esm/web-component/renderReactInWebComponent.js.map +1 -1
  105. package/dist/index.cjs +1 -1
  106. package/dist/index.mjs +1 -1
  107. package/dist/index.scss +1 -1
  108. package/dist/tsconfig.production.tsbuildinfo +1 -1
  109. package/dist/tsconfig.tsbuildinfo +1 -1
  110. package/dist/types/DatePickers/useOdysseyDateFields.d.ts.map +1 -1
  111. package/dist/types/Pagination/Pagination.d.ts.map +1 -1
  112. package/dist/types/labs/DataView/DataCard.d.ts.map +1 -1
  113. package/dist/types/labs/DataView/DataView.d.ts.map +1 -1
  114. package/dist/types/labs/DataView/TableLayoutContent.d.ts.map +1 -1
  115. package/dist/types/theme/StringWithValue.d.ts +13 -0
  116. package/dist/types/theme/StringWithValue.d.ts.map +1 -0
  117. package/dist/types/theme/components.d.ts.map +1 -1
  118. package/dist/types/theme/useMediaQuery.d.ts +2 -1
  119. package/dist/types/theme/useMediaQuery.d.ts.map +1 -1
  120. package/dist/types/ui-shell/InnerAppContainer.d.ts +35 -0
  121. package/dist/types/ui-shell/InnerAppContainer.d.ts.map +1 -0
  122. package/dist/types/ui-shell/NarrowUiShellContent.d.ts.map +1 -1
  123. package/dist/types/ui-shell/SideNav/SideNav.d.ts +2 -0
  124. package/dist/types/ui-shell/SideNav/SideNav.d.ts.map +1 -1
  125. package/dist/types/ui-shell/SideNav/SideNavToggleButton.d.ts +15 -8
  126. package/dist/types/ui-shell/SideNav/SideNavToggleButton.d.ts.map +1 -1
  127. package/dist/types/ui-shell/TopNav/TopNav.d.ts +1 -1
  128. package/dist/types/ui-shell/TopNav/TopNav.d.ts.map +1 -1
  129. package/dist/types/ui-shell/UiShell.d.ts +8 -1
  130. package/dist/types/ui-shell/UiShell.d.ts.map +1 -1
  131. package/dist/types/ui-shell/WideUiShellContent.d.ts.map +1 -1
  132. package/dist/types/ui-shell/index.d.ts +3 -1
  133. package/dist/types/ui-shell/index.d.ts.map +1 -1
  134. package/dist/types/ui-shell/renderUiShell.d.ts +2 -2
  135. package/dist/types/ui-shell/renderUiShell.d.ts.map +1 -1
  136. package/dist/types/ui-shell/useMatchAppElementToUiShellAppArea.d.ts.map +1 -1
  137. package/dist/types/ui-shell/useScrollState.d.ts +9 -1
  138. package/dist/types/ui-shell/useScrollState.d.ts.map +1 -1
  139. package/dist/types/ui-shell/useUiShellBreakpoints.d.ts +15 -5
  140. package/dist/types/ui-shell/useUiShellBreakpoints.d.ts.map +1 -1
  141. package/dist/types/web-component/createReactRootElements.d.ts +2 -0
  142. package/dist/types/web-component/createReactRootElements.d.ts.map +1 -1
  143. package/dist/types/web-component/renderReactInWebComponent.d.ts +1 -1
  144. package/dist/types/web-component/renderReactInWebComponent.d.ts.map +1 -1
  145. package/package.json +17 -14
@@ -23,16 +23,13 @@ const StyledRightSideContainer = styled("div")(() => ({
23
23
  flexShrink: 0
24
24
  }));
25
25
  const StyledTopNavContainer = styled("div", {
26
- shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "isScrolled" && prop !== "topNavBackgroundColor"
26
+ shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "topNavBackgroundColor"
27
27
  })(({
28
28
  odysseyDesignTokens,
29
- isScrolled,
30
29
  topNavBackgroundColor
31
30
  }) => ({
32
31
  alignItems: "center",
33
32
  backgroundColor: topNavBackgroundColor,
34
- boxShadow: isScrolled ? odysseyDesignTokens.DepthMedium : undefined,
35
- clipPath: "inset(0 0 -100vh 0)",
36
33
  display: "flex",
37
34
  gap: odysseyDesignTokens.Spacing4,
38
35
  height: "100%",
@@ -49,7 +46,6 @@ const StyledTopNavContainer = styled("div", {
49
46
  })
50
47
  }));
51
48
  const TopNav = ({
52
- isScrolled,
53
49
  leftSideComponent,
54
50
  rightSideComponent
55
51
  }) => {
@@ -57,7 +53,6 @@ const TopNav = ({
57
53
  const uiShellContext = useUiShellContext();
58
54
  return _jsxs(StyledTopNavContainer, {
59
55
  odysseyDesignTokens: odysseyDesignTokens,
60
- isScrolled: isScrolled,
61
56
  topNavBackgroundColor: uiShellContext?.topNavBackgroundColor,
62
57
  children: [_jsx(StyledLeftSideContainer, {
63
58
  children: leftSideComponent ?? _jsx("div", {})
@@ -1 +1 @@
1
- {"version":3,"file":"TopNav.js","names":["styled","memo","useOdysseyDesignTokens","useUiShellContext","TOP_NAV_HEIGHT","UI_SHELL_BASE_Z_INDEX","jsx","_jsx","jsxs","_jsxs","StyledLeftSideContainer","flexGrow","StyledRightSideContainer","flexShrink","StyledTopNavContainer","shouldForwardProp","prop","odysseyDesignTokens","isScrolled","topNavBackgroundColor","alignItems","backgroundColor","boxShadow","DepthMedium","undefined","clipPath","display","gap","Spacing4","height","justifyContent","maxHeight","minHeight","paddingBlock","Spacing2","paddingInline","Spacing8","position","transition","TransitionDurationMain","TransitionTimingMain","zIndex","HueNeutralWhite","borderBottom","BorderWidthMain","BorderStyleMain","HueNeutral100","TopNav","leftSideComponent","rightSideComponent","uiShellContext","children","MemoizedTopNav","displayName"],"sources":["../../../../src/ui-shell/TopNav/TopNav.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 styled from \"@emotion/styled\";\nimport { memo, type ReactElement } from \"react\";\n\nimport type { HtmlProps } from \"../../HtmlProps.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../../OdysseyDesignTokensContext.js\";\nimport {\n UiShellColors,\n useUiShellContext,\n} from \"../../ui-shell/UiShellProvider.js\";\nimport {\n TOP_NAV_HEIGHT,\n UI_SHELL_BASE_Z_INDEX,\n} from \"../uiShellSharedConstants.js\";\n\nconst StyledLeftSideContainer = styled(\"div\")(() => ({\n flexGrow: 1,\n}));\n\nconst StyledRightSideContainer = styled(\"div\")(() => ({\n flexShrink: 0,\n}));\n\nconst StyledTopNavContainer = styled(\"div\", {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" &&\n prop !== \"isScrolled\" &&\n prop !== \"topNavBackgroundColor\",\n})<{\n isScrolled?: boolean;\n odysseyDesignTokens: DesignTokens;\n topNavBackgroundColor?: UiShellColors[\"topNavBackgroundColor\"];\n}>(({ odysseyDesignTokens, isScrolled, topNavBackgroundColor }) => ({\n alignItems: \"center\",\n backgroundColor: topNavBackgroundColor,\n boxShadow: isScrolled ? odysseyDesignTokens.DepthMedium : undefined,\n clipPath: \"inset(0 0 -100vh 0)\",\n display: \"flex\",\n gap: odysseyDesignTokens.Spacing4,\n height: \"100%\",\n justifyContent: \"space-between\",\n maxHeight: TOP_NAV_HEIGHT,\n minHeight: TOP_NAV_HEIGHT,\n paddingBlock: odysseyDesignTokens.Spacing2,\n paddingInline: odysseyDesignTokens.Spacing8,\n position: \"relative\",\n transition: `box-shadow ${odysseyDesignTokens.TransitionDurationMain} ${odysseyDesignTokens.TransitionTimingMain}`,\n zIndex: UI_SHELL_BASE_Z_INDEX,\n\n ...(topNavBackgroundColor === odysseyDesignTokens.HueNeutralWhite && {\n borderBottom: `${odysseyDesignTokens.BorderWidthMain} ${odysseyDesignTokens.BorderStyleMain} ${odysseyDesignTokens.HueNeutral100}`,\n }),\n}));\n\nexport type TopNavProps = {\n /**\n * Whether or not the underlying content has been scrolled\n */\n isScrolled?: boolean;\n /**\n * React components that render into the left side of the top nav.\n */\n leftSideComponent?: ReactElement;\n /**\n * React components that render into the right side of the top nav.\n */\n rightSideComponent?: ReactElement;\n} & Pick<HtmlProps, \"testId\">;\n\nconst TopNav = ({\n isScrolled,\n leftSideComponent,\n rightSideComponent,\n}: TopNavProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const uiShellContext = useUiShellContext();\n\n return (\n <StyledTopNavContainer\n odysseyDesignTokens={odysseyDesignTokens}\n isScrolled={isScrolled}\n topNavBackgroundColor={uiShellContext?.topNavBackgroundColor}\n >\n <StyledLeftSideContainer>\n {leftSideComponent ?? <div />}\n </StyledLeftSideContainer>\n <StyledRightSideContainer>\n {rightSideComponent ?? <div />}\n </StyledRightSideContainer>\n </StyledTopNavContainer>\n );\n};\n\nconst MemoizedTopNav = memo(TopNav);\nMemoizedTopNav.displayName = \"TopNav\";\n\nexport { MemoizedTopNav as TopNav };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SAASC,IAAI,QAA2B,OAAO;AAG/C,SAEEC,sBAAsB,QACjB,qCAAqC;AAC5C,SAEEC,iBAAiB,QACZ,mCAAmC;AAC1C,SACEC,cAAc,EACdC,qBAAqB,QAChB,8BAA8B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtC,MAAMC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MAAM,GAAGA,CAAC;EACd7B,UAAU;EACV8B,iBAAiB;EACjBC;AACW,CAAC,KAAK;EACjB,MAAMhC,mBAAmB,GAAGf,sBAAsB,CAAC,CAAC;EACpD,MAAMgD,cAAc,GAAG/C,iBAAiB,CAAC,CAAC;EAE1C,OACEM,KAAA,CAACK,qBAAqB;IACpBG,mBAAmB,EAAEA,mBAAoB;IACzCC,UAAU,EAAEA,UAAW;IACvBC,qBAAqB,EAAE+B,cAAc,EAAE/B,qBAAsB;IAAAgC,QAAA,GAE7D5C,IAAA,CAACG,uBAAuB;MAAAyC,QAAA,EACrBH,iBAAiB,IAAIzC,IAAA,UAAM;IAAC,CACN,CAAC,EAC1BA,IAAA,CAACK,wBAAwB;MAAAuC,QAAA,EACtBF,kBAAkB,IAAI1C,IAAA,UAAM;IAAC,CACN,CAAC;EAAA,CACN,CAAC;AAE5B,CAAC;AAED,MAAM6C,cAAc,GAAGnD,IAAI,CAAC8C,MAAM,CAAC;AACnCK,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIL,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"TopNav.js","names":["styled","memo","useOdysseyDesignTokens","useUiShellContext","TOP_NAV_HEIGHT","UI_SHELL_BASE_Z_INDEX","jsx","_jsx","jsxs","_jsxs","StyledLeftSideContainer","flexGrow","StyledRightSideContainer","flexShrink","StyledTopNavContainer","shouldForwardProp","prop","odysseyDesignTokens","topNavBackgroundColor","alignItems","backgroundColor","display","gap","Spacing4","height","justifyContent","maxHeight","minHeight","paddingBlock","Spacing2","paddingInline","Spacing8","position","transition","TransitionDurationMain","TransitionTimingMain","zIndex","HueNeutralWhite","borderBottom","BorderWidthMain","BorderStyleMain","HueNeutral100","TopNav","leftSideComponent","rightSideComponent","uiShellContext","children","MemoizedTopNav","displayName"],"sources":["../../../../src/ui-shell/TopNav/TopNav.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 styled from \"@emotion/styled\";\nimport { memo, type ReactElement } from \"react\";\n\nimport type { HtmlProps } from \"../../HtmlProps.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../../OdysseyDesignTokensContext.js\";\nimport {\n UiShellColors,\n useUiShellContext,\n} from \"../../ui-shell/UiShellProvider.js\";\nimport {\n TOP_NAV_HEIGHT,\n UI_SHELL_BASE_Z_INDEX,\n} from \"../uiShellSharedConstants.js\";\n\nconst StyledLeftSideContainer = styled(\"div\")(() => ({\n flexGrow: 1,\n}));\n\nconst StyledRightSideContainer = styled(\"div\")(() => ({\n flexShrink: 0,\n}));\n\nconst StyledTopNavContainer = styled(\"div\", {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" && prop !== \"topNavBackgroundColor\",\n})<{\n odysseyDesignTokens: DesignTokens;\n topNavBackgroundColor?: UiShellColors[\"topNavBackgroundColor\"];\n}>(({ odysseyDesignTokens, topNavBackgroundColor }) => ({\n alignItems: \"center\",\n backgroundColor: topNavBackgroundColor,\n display: \"flex\",\n gap: odysseyDesignTokens.Spacing4,\n height: \"100%\",\n justifyContent: \"space-between\",\n maxHeight: TOP_NAV_HEIGHT,\n minHeight: TOP_NAV_HEIGHT,\n paddingBlock: odysseyDesignTokens.Spacing2,\n paddingInline: odysseyDesignTokens.Spacing8,\n position: \"relative\",\n transition: `box-shadow ${odysseyDesignTokens.TransitionDurationMain} ${odysseyDesignTokens.TransitionTimingMain}`,\n zIndex: UI_SHELL_BASE_Z_INDEX,\n\n ...(topNavBackgroundColor === odysseyDesignTokens.HueNeutralWhite && {\n borderBottom: `${odysseyDesignTokens.BorderWidthMain} ${odysseyDesignTokens.BorderStyleMain} ${odysseyDesignTokens.HueNeutral100}`,\n }),\n}));\n\nexport type TopNavProps = {\n /**\n * Whether or not the underlying content has been scrolled\n */\n isScrolled?: boolean;\n /**\n * React components that render into the left side of the top nav.\n */\n leftSideComponent?: ReactElement;\n /**\n * React components that render into the right side of the top nav.\n */\n rightSideComponent?: ReactElement;\n} & Pick<HtmlProps, \"testId\">;\n\nconst TopNav = ({ leftSideComponent, rightSideComponent }: TopNavProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const uiShellContext = useUiShellContext();\n\n return (\n <StyledTopNavContainer\n odysseyDesignTokens={odysseyDesignTokens}\n topNavBackgroundColor={uiShellContext?.topNavBackgroundColor}\n >\n <StyledLeftSideContainer>\n {leftSideComponent ?? <div />}\n </StyledLeftSideContainer>\n <StyledRightSideContainer>\n {rightSideComponent ?? <div />}\n </StyledRightSideContainer>\n </StyledTopNavContainer>\n );\n};\n\nconst MemoizedTopNav = memo(TopNav);\nMemoizedTopNav.displayName = \"TopNav\";\n\nexport { MemoizedTopNav as TopNav };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SAASC,IAAI,QAA2B,OAAO;AAG/C,SAEEC,sBAAsB,QACjB,qCAAqC;AAC5C,SAEEC,iBAAiB,QACZ,mCAAmC;AAC1C,SACEC,cAAc,EACdC,qBAAqB,QAChB,8BAA8B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtC,MAAMC,uBAAuB,GAAGV,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO;EACnDW,QAAQ,EAAE;AACZ,CAAC,CAAC,CAAC;AAEH,MAAMC,wBAAwB,GAAGZ,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO;EACpDa,UAAU,EAAE;AACd,CA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rBH,iBAAiB,IAAIpC,IAAA,UAAM;IAAC,CACN,CAAC,EAC1BA,IAAA,CAACK,wBAAwB;MAAAkC,QAAA,EACtBF,kBAAkB,IAAIrC,IAAA,UAAM;IAAC,CACN,CAAC;EAAA,CACN,CAAC;AAE5B,CAAC;AAED,MAAMwC,cAAc,GAAG9C,IAAI,CAACyC,MAAM,CAAC;AACnCK,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIL,MAAM","ignoreList":[]}
@@ -31,6 +31,7 @@ const UiShell = ({
31
31
  appBackgroundContrastMode,
32
32
  appElement,
33
33
  appElementScrollingMode,
34
+ breakpointConfig,
34
35
  closeSideNavMenu,
35
36
  hasStandardAppContentPadding,
36
37
  initialVisibleSections,
@@ -46,7 +47,7 @@ const UiShell = ({
46
47
  uiShellStylesElement
47
48
  }) => {
48
49
  const [componentProps, setComponentProps] = useState(defaultComponentProps);
49
- const activeBreakpoint = useUiShellBreakpoints();
50
+ const activeBreakpoint = useUiShellBreakpoints(breakpointConfig);
50
51
  useEffect(() => {
51
52
  const unsubscribe = subscribeToPropChanges(componentProps => {
52
53
  setComponentProps(componentProps || defaultComponentProps);
@@ -73,7 +74,7 @@ const UiShell = ({
73
74
  subscribeToCloseRightSideMenu: subscribeToCloseRightSideMenu,
74
75
  subscribeToCloseSideNavMenu: subscribeToCloseSideNavMenu,
75
76
  topNavBackgroundColor: topNavBackgroundColor,
76
- children: [activeBreakpoint === "constrained" && _jsx(NarrowUiShellContent, {
77
+ children: [activeBreakpoint === "narrow" && _jsx(NarrowUiShellContent, {
77
78
  ...componentProps,
78
79
  appElement: appElement,
79
80
  appElementScrollingMode: appElementScrollingMode,
@@ -81,13 +82,13 @@ const UiShell = ({
81
82
  initialVisibleSections: initialVisibleSections,
82
83
  onError: onError,
83
84
  optionalComponents: optionalComponents
84
- }), (activeBreakpoint === "compact" || activeBreakpoint === "comfortable") && _jsx(WideUiShellContent, {
85
+ }), (activeBreakpoint === "medium" || activeBreakpoint === "wide") && _jsx(WideUiShellContent, {
85
86
  ...componentProps,
86
87
  ...(componentProps.sideNavProps ? {
87
88
  sideNavProps: {
88
89
  ...componentProps.sideNavProps,
89
- isCollapsed: activeBreakpoint === "compact" || componentProps.sideNavProps?.isCollapsed,
90
- isCollapsible: activeBreakpoint === "compact" || componentProps.sideNavProps?.isCollapsible
90
+ isCollapsed: activeBreakpoint === "medium" || componentProps.sideNavProps?.isCollapsed,
91
+ isCollapsible: activeBreakpoint === "medium" || componentProps.sideNavProps?.isCollapsible
91
92
  }
92
93
  } : {}),
93
94
  appElement: appElement,
@@ -1 +1 @@
1
- {"version":3,"file":"UiShell.js","names":["memo","useEffect","useState","ErrorBoundary","CssBaseline","NarrowUiShellContent","OdysseyProvider","UiShellProvider","useUiShellBreakpoints","WideUiShellContent","jsx","_jsx","jsxs","_jsxs","defaultComponentProps","sideNavProps","undefined","topNavProps","errorComponent","UiShell","appBackgroundColor","appBackgroundContrastMode","appElement","appElementScrollingMode","closeSideNavMenu","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","onSubscriptionCreated","optionalComponents","sideNavBackgroundColor","subscribeToCloseRightSideMenu","subscribeToCloseSideNavMenu","subscribeToPropChanges","topNavBackgroundColor","uiShellAppElement","uiShellStylesElement","componentProps","setComponentProps","activeBreakpoint","unsubscribe","fallback","children","emotionRootElement","shadowRootElement","isCollapsed","isCollapsible","MemoizedUiShell","displayName"],"sources":["../../../src/ui-shell/UiShell.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { memo, useEffect, useState, type SetStateAction } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { type ReactRootElements } from \"../web-component/createReactRootElements.js\";\nimport { CssBaseline } from \"../CssBaseline.js\";\nimport { NarrowUiShellContent } from \"./NarrowUiShellContent.js\";\nimport { OdysseyProvider } from \"../OdysseyProvider.js\";\nimport { UiShellProvider, UiShellProviderProps } from \"./UiShellProvider.js\";\nimport {\n UiShellNavComponentProps,\n UiShellContentProps,\n} from \"./uiShellContentTypes.js\";\nimport { useUiShellBreakpoints } from \"./useUiShellBreakpoints.js\";\nimport { WideUiShellContent } from \"./WideUiShellContent.js\";\nimport { MessageBus } from \"./createMessageBus.js\";\n\nexport const defaultComponentProps: UiShellNavComponentProps = {\n sideNavProps: undefined,\n topNavProps: undefined,\n} as const;\n\nconst errorComponent = <div data-error />;\n\nexport type UiShellProps = {\n /**\n * Notifies when subscribed to prop changes.\n *\n * UI Shell listens to prop updates, and it won't subscribe synchronously. Because of that, this callback notifies when that subscription is ready.\n */\n onSubscriptionCreated: () => void;\n /**\n * This is a callback that provides a subscriber callback to listen for changes to state.\n * It allows UI Shell to listen for state changes.\n *\n * The props coming in this callback go directly to a React state; therefore, it shares the same signature and provides a previous state.\n */\n subscribeToPropChanges: MessageBus<\n SetStateAction<UiShellNavComponentProps>\n >[\"subscribe\"];\n /**\n * Element inside UI Shell's React root component renders into. If using a web component, this is going to exist inside it.\n */\n uiShellAppElement: ReactRootElements[\"appRootElement\"];\n /**\n * Typically, this is your `<head>` element. If using a web component, you need to create one yourself as Shadow DOM's don't have a `<head>`.\n */\n uiShellStylesElement: ReactRootElements[\"stylesRootElement\"];\n} & UiShellProviderProps &\n Pick<\n UiShellContentProps,\n | \"appElement\"\n | \"appElementScrollingMode\"\n | \"hasStandardAppContentPadding\"\n | \"initialVisibleSections\"\n | \"onError\"\n | \"optionalComponents\"\n >;\n\n/**\n * Our new Unified Platform UI Shell.\n *\n * This includes the top and side navigation as well as the footer and provides a spot for your app to render into.\n *\n * If an error occurs, this will revert to only showing the app.\n */\nconst UiShell = ({\n appBackgroundColor,\n appBackgroundContrastMode,\n appElement,\n appElementScrollingMode,\n closeSideNavMenu,\n hasStandardAppContentPadding,\n initialVisibleSections,\n onError = console.error,\n onSubscriptionCreated,\n optionalComponents,\n sideNavBackgroundColor,\n subscribeToCloseRightSideMenu,\n subscribeToCloseSideNavMenu,\n subscribeToPropChanges,\n topNavBackgroundColor,\n uiShellAppElement,\n uiShellStylesElement,\n}: UiShellProps) => {\n const [componentProps, setComponentProps] = useState(defaultComponentProps);\n\n const activeBreakpoint = useUiShellBreakpoints();\n\n useEffect(() => {\n const unsubscribe = subscribeToPropChanges((componentProps) => {\n // If for some reason nothing is passed as `componentProps`, we fallback on `defaultComponentProps` as a safety mechanism to ensure nothing breaks.\n setComponentProps(componentProps || defaultComponentProps);\n });\n\n onSubscriptionCreated();\n\n return () => {\n unsubscribe();\n };\n }, [onSubscriptionCreated, subscribeToPropChanges]);\n\n return activeBreakpoint === \"none\" ? null : (\n <ErrorBoundary fallback={errorComponent} onError={onError}>\n <OdysseyProvider\n emotionRootElement={uiShellStylesElement}\n shadowRootElement={uiShellAppElement}\n >\n <ErrorBoundary fallback={errorComponent} onError={onError}>\n <CssBaseline />\n\n <UiShellProvider\n appBackgroundColor={appBackgroundColor}\n appBackgroundContrastMode={appBackgroundContrastMode}\n closeSideNavMenu={closeSideNavMenu}\n sideNavBackgroundColor={sideNavBackgroundColor}\n subscribeToCloseRightSideMenu={subscribeToCloseRightSideMenu}\n subscribeToCloseSideNavMenu={subscribeToCloseSideNavMenu}\n topNavBackgroundColor={topNavBackgroundColor}\n >\n {activeBreakpoint === \"constrained\" && (\n <NarrowUiShellContent\n {...componentProps}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n optionalComponents={optionalComponents}\n />\n )}\n\n {(activeBreakpoint === \"compact\" ||\n activeBreakpoint === \"comfortable\") && (\n <WideUiShellContent\n {...{\n ...componentProps,\n ...(componentProps.sideNavProps\n ? {\n sideNavProps: {\n ...componentProps.sideNavProps,\n isCollapsed:\n activeBreakpoint === \"compact\" ||\n componentProps.sideNavProps?.isCollapsed,\n isCollapsible:\n activeBreakpoint === \"compact\" ||\n componentProps.sideNavProps?.isCollapsible,\n // We have to use `as` because sideNavProps expects you to have `sideNavItems` defined even though it had to be passed in `...componentProps.sideNavProps`.\n } as typeof componentProps.sideNavProps,\n }\n : {}),\n }}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n optionalComponents={optionalComponents}\n />\n )}\n </UiShellProvider>\n </ErrorBoundary>\n </OdysseyProvider>\n </ErrorBoundary>\n );\n};\n\nconst MemoizedUiShell = memo(UiShell);\nMemoizedUiShell.displayName = \"UiShell\";\n\nexport { MemoizedUiShell as UiShell };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAA6B,OAAO;AACtE,SAASC,aAAa,QAAQ,sBAAsB;AAGpD,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAA8B,sBAAsB;AAK5E,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,kBAAkB,QAAQ,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAG7D,OAAO,MAAMC,qBAA+C,GAAG;EAC7DC,YAAY,EAAEC,SAAS;EACvBC,WAAW,EAAED;AACf,CAAU;AAEV,MAAME,cAAc,GAAGP,IAAA;EAAK;AAAU,CAAE,CAAC;AA4CzC,MAAMQ,OAAO,GAAGA,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.js","names":["memo","useEffect","useState","ErrorBoundary","CssBaseline","NarrowUiShellContent","OdysseyProvider","UiShellProvider","useUiShellBreakpoints","WideUiShellContent","jsx","_jsx","jsxs","_jsxs","defaultComponentProps","sideNavProps","undefined","topNavProps","errorComponent","UiShell","appBackgroundColor","appBackgroundContrastMode","appElement","appElementScrollingMode","breakpointConfig","closeSideNavMenu","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","onSubscriptionCreated","optionalComponents","sideNavBackgroundColor","subscribeToCloseRightSideMenu","subscribeToCloseSideNavMenu","subscribeToPropChanges","topNavBackgroundColor","uiShellAppElement","uiShellStylesElement","componentProps","setComponentProps","activeBreakpoint","unsubscribe","fallback","children","emotionRootElement","shadowRootElement","isCollapsed","isCollapsible","MemoizedUiShell","displayName"],"sources":["../../../src/ui-shell/UiShell.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { memo, useEffect, useState, type SetStateAction } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { type ReactRootElements } from \"../web-component/createReactRootElements.js\";\nimport { CssBaseline } from \"../CssBaseline.js\";\nimport { NarrowUiShellContent } from \"./NarrowUiShellContent.js\";\nimport { OdysseyProvider } from \"../OdysseyProvider.js\";\nimport { UiShellProvider, UiShellProviderProps } from \"./UiShellProvider.js\";\nimport {\n UiShellNavComponentProps,\n UiShellContentProps,\n} from \"./uiShellContentTypes.js\";\nimport {\n UiShellBreakpointConfig,\n useUiShellBreakpoints,\n} from \"./useUiShellBreakpoints.js\";\nimport { WideUiShellContent } from \"./WideUiShellContent.js\";\nimport { MessageBus } from \"./createMessageBus.js\";\n\nexport const defaultComponentProps: UiShellNavComponentProps = {\n sideNavProps: undefined,\n topNavProps: undefined,\n} as const;\n\nconst errorComponent = <div data-error />;\n\nexport type UiShellProps = {\n /**\n * Customized breakpoints for UI Shell.\n *\n * The defaults are set for you. Pass these only if your app doesn't work properly with the defaults (like Admin).\n */\n breakpointConfig?: UiShellBreakpointConfig;\n /**\n * Notifies when subscribed to prop changes.\n *\n * UI Shell listens to prop updates, and it won't subscribe synchronously. Because of that, this callback notifies when that subscription is ready.\n */\n onSubscriptionCreated: () => void;\n /**\n * This is a callback that provides a subscriber callback to listen for changes to state.\n * It allows UI Shell to listen for state changes.\n *\n * The props coming in this callback go directly to a React state; therefore, it shares the same signature and provides a previous state.\n */\n subscribeToPropChanges: MessageBus<\n SetStateAction<UiShellNavComponentProps>\n >[\"subscribe\"];\n /**\n * Element inside UI Shell's React root component renders into. If using a web component, this is going to exist inside it.\n */\n uiShellAppElement: ReactRootElements[\"appRootElement\"];\n /**\n * Typically, this is your `<head>` element. If using a web component, you need to create one yourself as Shadow DOM's don't have a `<head>`.\n */\n uiShellStylesElement: ReactRootElements[\"stylesRootElement\"];\n} & UiShellProviderProps &\n Pick<\n UiShellContentProps,\n | \"appElement\"\n | \"appElementScrollingMode\"\n | \"hasStandardAppContentPadding\"\n | \"initialVisibleSections\"\n | \"onError\"\n | \"optionalComponents\"\n >;\n\n/**\n * Our new Unified Platform UI Shell.\n *\n * This includes the top and side navigation as well as the footer and provides a spot for your app to render into.\n *\n * If an error occurs, this will revert to only showing the app.\n */\nconst UiShell = ({\n appBackgroundColor,\n appBackgroundContrastMode,\n appElement,\n appElementScrollingMode,\n breakpointConfig,\n closeSideNavMenu,\n hasStandardAppContentPadding,\n initialVisibleSections,\n onError = console.error,\n onSubscriptionCreated,\n optionalComponents,\n sideNavBackgroundColor,\n subscribeToCloseRightSideMenu,\n subscribeToCloseSideNavMenu,\n subscribeToPropChanges,\n topNavBackgroundColor,\n uiShellAppElement,\n uiShellStylesElement,\n}: UiShellProps) => {\n const [componentProps, setComponentProps] = useState(defaultComponentProps);\n\n const activeBreakpoint = useUiShellBreakpoints(breakpointConfig);\n\n useEffect(() => {\n const unsubscribe = subscribeToPropChanges((componentProps) => {\n // If for some reason nothing is passed as `componentProps`, we fallback on `defaultComponentProps` as a safety mechanism to ensure nothing breaks.\n setComponentProps(componentProps || defaultComponentProps);\n });\n\n onSubscriptionCreated();\n\n return () => {\n unsubscribe();\n };\n }, [onSubscriptionCreated, subscribeToPropChanges]);\n\n return activeBreakpoint === \"none\" ? null : (\n <ErrorBoundary fallback={errorComponent} onError={onError}>\n <OdysseyProvider\n emotionRootElement={uiShellStylesElement}\n shadowRootElement={uiShellAppElement}\n >\n <ErrorBoundary fallback={errorComponent} onError={onError}>\n <CssBaseline />\n\n <UiShellProvider\n appBackgroundColor={appBackgroundColor}\n appBackgroundContrastMode={appBackgroundContrastMode}\n closeSideNavMenu={closeSideNavMenu}\n sideNavBackgroundColor={sideNavBackgroundColor}\n subscribeToCloseRightSideMenu={subscribeToCloseRightSideMenu}\n subscribeToCloseSideNavMenu={subscribeToCloseSideNavMenu}\n topNavBackgroundColor={topNavBackgroundColor}\n >\n {activeBreakpoint === \"narrow\" && (\n <NarrowUiShellContent\n {...componentProps}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n optionalComponents={optionalComponents}\n />\n )}\n\n {(activeBreakpoint === \"medium\" || activeBreakpoint === \"wide\") && (\n <WideUiShellContent\n {...{\n ...componentProps,\n ...(componentProps.sideNavProps\n ? {\n sideNavProps: {\n ...componentProps.sideNavProps,\n isCollapsed:\n activeBreakpoint === \"medium\" ||\n componentProps.sideNavProps?.isCollapsed,\n isCollapsible:\n activeBreakpoint === \"medium\" ||\n componentProps.sideNavProps?.isCollapsible,\n // We have to use `as` because sideNavProps expects you to have `sideNavItems` defined even though it had to be passed in `...componentProps.sideNavProps`.\n } as typeof componentProps.sideNavProps,\n }\n : {}),\n }}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n optionalComponents={optionalComponents}\n />\n )}\n </UiShellProvider>\n </ErrorBoundary>\n </OdysseyProvider>\n </ErrorBoundary>\n );\n};\n\nconst MemoizedUiShell = memo(UiShell);\nMemoizedUiShell.displayName = \"UiShell\";\n\nexport { MemoizedUiShell as UiShell };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAEC,SAAS,EAAEC,QAAQ,QAA6B,OAAO;AACtE,SAASC,aAAa,QAAQ,sBAAsB;AAGpD,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,eAAe,QAA8B,sBAAsB;AAK5E,SAEEC,qBAAqB,QAChB,4BAA4B;AACnC,SAASC,kBAAkB,QAAQ,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAG7D,OAAO,MAAMC,qBAA+C,GAAG;EAC7DC,YAAY,EAAEC,SAAS;EACvBC,WAAW,EAAED;AACf,CAAU;AAEV,MAAME,cAAc,GAAGP,IAAA;EAAK;AAAU,CAAE,CAAC;AAkDzC,MAAMQ,OAAO,GAAGA,CAAC;EACfC,kBAAkB;EAClBC,yBAAyB;EACzBC,UAAU;EACVC,uBAAuB;EACvBC,gBAAgB;EAChBC,gBAAgB;EAChBC,4BAA4B;EAC5BC,sBAAsB;EACtBC,OAAO,GAAGC,OAAO,CAACC,KAAK;EACvBC,qBAAqB;EACrBC,kBAAkB;EAClBC,sBAAsB;EACtBC,6BAA6B;EAC7BC,2BAA2B;EAC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lB,UAAU,EAAEA,UAAW;YACvBC,uBAAuB,EAAEA,uBAAwB;YACjDG,4BAA4B,EAAEA,4BAA6B;YAC3DC,sBAAsB,EAAEA,sBAAuB;YAC/CC,OAAO,EAAEA,OAAQ;YACjBI,kBAAkB,EAAEA;UAAmB,CACxC,CACF,EAEA,CAACU,gBAAgB,KAAK,QAAQ,IAAIA,gBAAgB,KAAK,MAAM,KAC5D/B,IAAA,CAACF,kBAAkB;YAEf,GAAG+B,cAAc;YACjB,IAAIA,cAAc,CAACzB,YAAY,GAC3B;cACEA,YAAY,EAAE;gBACZ,GAAGyB,cAAc,CAACzB,YAAY;gBAC9BiC,WAAW,EACTN,gBAAgB,KAAK,QAAQ,IAC7BF,cAAc,CAACzB,YAAY,EAAEiC,WAAW;gBAC1CC,aAAa,EACXP,gBAAgB,KAAK,QAAQ,IAC7BF,cAAc,CAACzB,YAAY,EAAEkC;cAEjC;YACF,CAAC,GACD,CAAC,CAAC,CAAC;YAET3B,UAAU,EAAEA,UAAW;YACvBC,uBAAuB,EAAEA,uBAAwB;YACjDG,4BAA4B,EAAEA,4BAA6B;YAC3DC,sBAAsB,EAAEA,sBAAuB;YAC/CC,OAAO,EAAEA,OAAQ;YACjBI,kBAAkB,EAAEA;UAAmB,CACxC,CACF;QAAA,CACc,CAAC;MAAA,CACL;IAAC,CACD;EAAC,CACL,CAChB;AACH,CAAC;AAED,MAAMkB,eAAe,GAAGlD,IAAI,CAACmB,OAAO,CAAC;AACrC+B,eAAe,CAACC,WAAW,GAAG,SAAS;AAEvC,SAASD,eAAe,IAAI/B,OAAO","ignoreList":[]}
@@ -14,6 +14,7 @@ import styled from "@emotion/styled";
14
14
  import { memo, useRef } from "react";
15
15
  import { ErrorBoundary } from "react-error-boundary";
16
16
  import { AppSwitcher } from "./AppSwitcher/index.js";
17
+ import { InnerAppContainer } from "./InnerAppContainer.js";
17
18
  import { useOdysseyDesignTokens } from "../OdysseyDesignTokensContext.js";
18
19
  import { SideNav } from "./SideNav/index.js";
19
20
  import { TopNav } from "./TopNav/index.js";
@@ -22,13 +23,16 @@ import { useMatchAppElementToUiShellAppArea } from "./useMatchAppElementToUiShel
22
23
  import { useUiShellContext } from "./UiShellProvider.js";
23
24
  import { emptySideNavItems } from "./uiShellSharedConstants.js";
24
25
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
26
+ const appSwitcherDefaultAppIcons = [];
25
27
  const StyledAppContainer = styled("div", {
26
28
  shouldForwardProp: prop => prop !== "appBackgroundColor" && prop !== "odysseyDesignTokens"
27
29
  })(({
28
30
  appBackgroundColor
29
31
  }) => ({
32
+ backgroundColor: appBackgroundColor,
30
33
  gridArea: "app-content",
31
- backgroundColor: appBackgroundColor
34
+ pointerEvents: "none",
35
+ position: "relative"
32
36
  }));
33
37
  const StyledAppSwitcherContainer = styled("div")({
34
38
  gridArea: "app-switcher"
@@ -98,8 +102,8 @@ const WideUiShellContent = ({
98
102
  fallback: null,
99
103
  onError: onError,
100
104
  children: _jsx(AppSwitcher, {
105
+ appIcons: appSwitcherDefaultAppIcons,
101
106
  isLoading: true,
102
- appIcons: [],
103
107
  selectedAppName: ""
104
108
  })
105
109
  }), appSwitcherProps && _jsx(ErrorBoundary, {
@@ -147,7 +151,6 @@ const WideUiShellContent = ({
147
151
  onError: onError,
148
152
  children: _jsx(TopNav, {
149
153
  ...topNavProps,
150
- isScrolled: isContentScrolled,
151
154
  leftSideComponent: optionalComponents?.topNavLeftSide,
152
155
  rightSideComponent: optionalComponents?.topNavRightSide
153
156
  })
@@ -155,7 +158,10 @@ const WideUiShellContent = ({
155
158
  }), _jsx(StyledAppContainer, {
156
159
  appBackgroundColor: uiShellContext?.appBackgroundColor,
157
160
  tabIndex: 0,
158
- ref: uiShellAppAreaRef
161
+ ref: uiShellAppAreaRef,
162
+ children: _jsx(InnerAppContainer, {
163
+ isContentScrolled: isContentScrolled
164
+ })
159
165
  })]
160
166
  });
161
167
  };
@@ -1 +1 @@
1
- {"version":3,"file":"WideUiShellContent.js","names":["styled","memo","useRef","ErrorBoundary","AppSwitcher","useOdysseyDesignTokens","SideNav","TopNav","useScrollState","useMatchAppElementToUiShellAppArea","useUiShellContext","emptySideNavItems","jsx","_jsx","jsxs","_jsxs","StyledAppContainer","shouldForwardProp","prop","appBackgroundColor","gridArea","backgroundColor","StyledAppSwitcherContainer","StyledBannersContainer","StyledSideNavContainer","StyledShellContainer","odysseyDesignTokens","HueNeutral50","display","gridGap","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","width","StyledTopNavContainer","WideUiShellContent","appElement","appElementScrollingMode","appSwitcherProps","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","optionalComponents","sideNavProps","topNavProps","uiShellContext","isContentScrolled","sideNavContainerRef","topNavContainerRef","uiShellAppAreaRef","parentContainerRef","paddingMode","uiShellResizableRefs","ref","children","banners","includes","fallback","isLoading","appIcons","selectedAppName","undefined","sideNavItems","hasCustomFooter","sideNavFooter","footerComponent","footerItems","leftSideComponent","topNavLeftSide","rightSideComponent","topNavRightSide","isScrolled","tabIndex","MemoizedWideUiShellContent","displayName"],"sources":["../../../src/ui-shell/WideUiShellContent.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 styled from \"@emotion/styled\";\nimport { memo, useRef } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { AppSwitcher } from \"./AppSwitcher/index.js\";\nimport {\n useOdysseyDesignTokens,\n type DesignTokens,\n} from \"../OdysseyDesignTokensContext.js\";\nimport {\n UiShellNavComponentProps,\n UiShellContentProps,\n} from \"./uiShellContentTypes.js\";\nimport { SideNav } from \"./SideNav/index.js\";\nimport { TopNav } from \"./TopNav/index.js\";\nimport { useScrollState } from \"./useScrollState.js\";\nimport { useMatchAppElementToUiShellAppArea } from \"./useMatchAppElementToUiShellAppArea.js\";\nimport { UiShellColors, useUiShellContext } from \"./UiShellProvider.js\";\nimport { emptySideNavItems } from \"./uiShellSharedConstants.js\";\n\nconst StyledAppContainer = styled(\"div\", {\n shouldForwardProp: (prop) =>\n prop !== \"appBackgroundColor\" && prop !== \"odysseyDesignTokens\",\n})<{\n appBackgroundColor?: UiShellColors[\"appBackgroundColor\"];\n}>(({ appBackgroundColor }) => ({\n gridArea: \"app-content\",\n backgroundColor: appBackgroundColor,\n}));\n\nconst StyledAppSwitcherContainer = styled(\"div\")({\n gridArea: \"app-switcher\",\n});\n\nconst StyledBannersContainer = styled(\"div\")({\n gridArea: \"banners\",\n});\n\nconst StyledSideNavContainer = styled(\"div\")({\n gridArea: \"side-nav\",\n});\n\nconst StyledShellContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n display: \"grid\",\n gridGap: 0,\n gridTemplateAreas: `\n \"banners banners banners\"\n \"app-switcher side-nav top-nav\"\n \"app-switcher side-nav app-content\"\n `,\n gridTemplateColumns: \"auto auto 1fr\",\n gridTemplateRows: \"auto auto 1fr\",\n height: \"100vh\",\n width: \"100vw\",\n}));\n\nconst StyledTopNavContainer = styled(\"div\")({\n gridArea: \"top-nav\",\n});\n\nexport type WideUiShellContentProps = UiShellNavComponentProps &\n UiShellContentProps;\n\n/**\n * Our new Unified Platform UI Shell.\n *\n * This includes the top and side navigation as well as the footer and provides a spot for your app to render into.\n *\n * If an error occurs, this will revert to only showing the app.\n */\nconst WideUiShellContent = ({\n appElement,\n appElementScrollingMode,\n appSwitcherProps,\n hasStandardAppContentPadding = true,\n initialVisibleSections = [\"TopNav\", \"SideNav\", \"AppSwitcher\"],\n onError = console.error,\n optionalComponents,\n sideNavProps,\n topNavProps,\n}: WideUiShellContentProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const uiShellContext = useUiShellContext();\n\n const { isContentScrolled } = useScrollState(appElement);\n\n const sideNavContainerRef = useRef<HTMLDivElement>(null);\n const topNavContainerRef = useRef<HTMLDivElement>(null);\n const uiShellAppAreaRef = useRef<HTMLDivElement>(null);\n\n const { parentContainerRef } = useMatchAppElementToUiShellAppArea({\n appElement,\n appElementScrollingMode,\n paddingMode: hasStandardAppContentPadding ? \"comfortable\" : \"none\",\n uiShellAppAreaRef,\n uiShellResizableRefs: [\n sideNavContainerRef,\n topNavContainerRef,\n uiShellAppAreaRef,\n ],\n });\n\n return (\n <StyledShellContainer\n odysseyDesignTokens={odysseyDesignTokens}\n ref={parentContainerRef}\n >\n <StyledBannersContainer>\n {optionalComponents?.banners}\n </StyledBannersContainer>\n\n <StyledAppSwitcherContainer>\n {\n /* If AppSwitcher should be initially visible and we have not yet received props, render AppSwitcher in the loading state */\n initialVisibleSections?.includes(\"AppSwitcher\") &&\n !appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher isLoading appIcons={[]} selectedAppName=\"\" />\n </ErrorBoundary>\n )\n }\n\n {appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher {...appSwitcherProps} />\n </ErrorBoundary>\n )}\n </StyledAppSwitcherContainer>\n\n <StyledSideNavContainer ref={sideNavContainerRef}>\n {\n /* If SideNav should be initially visible and we have not yet received props, render SideNav with minimal inputs */\n initialVisibleSections?.includes(\"SideNav\") &&\n sideNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav isLoading sideNavItems={emptySideNavItems} />\n </ErrorBoundary>\n )\n }\n\n {sideNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav\n {...{\n ...sideNavProps,\n ...(sideNavProps.hasCustomFooter &&\n optionalComponents?.sideNavFooter\n ? {\n footerComponent: optionalComponents.sideNavFooter,\n footerItems: undefined,\n hasCustomFooter: sideNavProps.hasCustomFooter,\n }\n : {\n footerItems: sideNavProps.footerItems,\n hasCustomFooter: false,\n }),\n }}\n />\n </ErrorBoundary>\n )}\n </StyledSideNavContainer>\n\n <StyledTopNavContainer ref={topNavContainerRef}>\n {\n /* If TopNav should be initially visible and we have not yet received props, render Topnav with minimal inputs */\n initialVisibleSections?.includes(\"TopNav\") &&\n topNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )\n }\n\n {topNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n {...topNavProps}\n isScrolled={isContentScrolled}\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )}\n </StyledTopNavContainer>\n\n <StyledAppContainer\n appBackgroundColor={uiShellContext?.appBackgroundColor}\n tabIndex={0}\n ref={uiShellAppAreaRef}\n />\n </StyledShellContainer>\n );\n};\n\nconst MemoizedWideUiShellContent = memo(WideUiShellContent);\nMemoizedWideUiShellContent.displayName = \"WideUiShellContent\";\n\nexport { MemoizedWideUiShellContent as WideUiShellContent };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SAASC,IAAI,EAAEC,MAAM,QAAQ,OAAO;AACpC,SAASC,aAAa,QAAQ,sBAAsB;AAEpD,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SACEC,sBAAsB,QAEjB,kCAAkC;AAKzC,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,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AEL,kBAAmB;MAAAM,QAAA,GAG3ChB,sBAAsB,EAAEkB,QAAQ,CAAC,QAAQ,CAAC,IACxCZ,WAAW,KAAKiB,SAAS,IACvBnD,IAAA,CAACV,aAAa;QAACyD,QAAQ,EAAE,IAAK;QAAClB,OAAO,EAAEA,OAAQ;QAAAe,QAAA,EAC9C5C,IAAA,CAACN,MAAM;UACL+D,iBAAiB,EAAEzB,kBAAkB,EAAE0B,cAAe;UACtDC,kBAAkB,EAAE3B,kBAAkB,EAAE4B;QAAgB,CACzD;MAAC,CACW,CAChB,EAGJ1B,WAAW,IACVlC,IAAA,CAACV,aAAa;QAACyD,QAAQ,EAAE,IAAK;QAAClB,OAAO,EAAEA,OAAQ;QAAAe,QAAA,EAC9C5C,IAAA,CAACN,MAAM;UAAA,GACDwC,WAAW;UACf2B,UAAU,EAAEzB,iBAAkB;UAC9BqB,iBAAiB,EAAEzB,kBAAkB,EAAE0B,cAAe;UACtDC,kBAAkB,EAAE3B,kBAAkB,EAAE4B;QAAgB,CACzD;MAAC,CACW,CAChB;IAAA,CACoB,CAAC,EAExB5D,IAAA,CAACG,kBAAkB;MACjBG,kBAAkB,EAAE6B,cAAc,EAAE7B,kBAAmB;MACvDwD,QAAQ,EAAE,CAAE;MACZnB,GAAG,EAAEJ;IAAkB,CACxB,CAAC;EAAA,CACkB,CAAC;AAE3B,CAAC;AAED,MAAMwB,0BAA0B,GAAG3E,IAAI,CAACmC,kBAAkB,CAAC;AAC3DwC,0BAA0B,CAACC,WAAW,GAAG,oBAAoB;AAE7D,SAASD,0BAA0B,IAAIxC,kBAAkB","ignoreList":[]}
1
+ {"version":3,"file":"WideUiShellContent.js","names":["styled","memo","useRef","ErrorBoundary","AppSwitcher","InnerAppContainer","useOdysseyDesignTokens","SideNav","TopNav","useScrollState","useMatchAppElementToUiShellAppArea","useUiShellContext","emptySideNavItems","jsx","_jsx","jsxs","_jsxs","appSwitcherDefaultAppIcons","StyledAppContainer","shouldForwardProp","prop","appBackgroundColor","backgroundColor","gridArea","pointerEvents","position","StyledAppSwitcherContainer","StyledBannersContainer","StyledSideNavContainer","StyledShellContainer","odysseyDesignTokens","HueNeutral50","display","gridGap","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","width","StyledTopNavContainer","WideUiShellContent","appElement","appElementScrollingMode","appSwitcherProps","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","optionalComponents","sideNavProps","topNavProps","uiShellContext","isContentScrolled","sideNavContainerRef","topNavContainerRef","uiShellAppAreaRef","parentContainerRef","paddingMode","uiShellResizableRefs","ref","children","banners","includes","fallback","appIcons","isLoading","selectedAppName","undefined","sideNavItems","hasCustomFooter","sideNavFooter","footerComponent","footerItems","leftSideComponent","topNavLeftSide","rightSideComponent","topNavRightSide","tabIndex","MemoizedWideUiShellContent","displayName"],"sources":["../../../src/ui-shell/WideUiShellContent.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 styled from \"@emotion/styled\";\nimport { memo, useRef } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { AppSwitcher } from \"./AppSwitcher/index.js\";\nimport { AppSwitcherAppIconData } from \"./AppSwitcher/AppSwitcherApp.js\";\nimport { InnerAppContainer } from \"./InnerAppContainer.js\";\nimport {\n useOdysseyDesignTokens,\n type DesignTokens,\n} from \"../OdysseyDesignTokensContext.js\";\nimport { SideNav } from \"./SideNav/index.js\";\nimport { TopNav } from \"./TopNav/index.js\";\nimport { useScrollState } from \"./useScrollState.js\";\nimport { useMatchAppElementToUiShellAppArea } from \"./useMatchAppElementToUiShellAppArea.js\";\nimport {\n UiShellNavComponentProps,\n UiShellContentProps,\n} from \"./uiShellContentTypes.js\";\nimport { UiShellColors, useUiShellContext } from \"./UiShellProvider.js\";\nimport { emptySideNavItems } from \"./uiShellSharedConstants.js\";\n\nconst appSwitcherDefaultAppIcons = [] satisfies AppSwitcherAppIconData[];\n\nconst StyledAppContainer = styled(\"div\", {\n shouldForwardProp: (prop) =>\n prop !== \"appBackgroundColor\" && prop !== \"odysseyDesignTokens\",\n})<{\n appBackgroundColor?: UiShellColors[\"appBackgroundColor\"];\n}>(({ appBackgroundColor }) => ({\n backgroundColor: appBackgroundColor,\n gridArea: \"app-content\",\n pointerEvents: \"none\",\n position: \"relative\",\n}));\n\nconst StyledAppSwitcherContainer = styled(\"div\")({\n gridArea: \"app-switcher\",\n});\n\nconst StyledBannersContainer = styled(\"div\")({\n gridArea: \"banners\",\n});\n\nconst StyledSideNavContainer = styled(\"div\")({\n gridArea: \"side-nav\",\n});\n\nconst StyledShellContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n display: \"grid\",\n gridGap: 0,\n gridTemplateAreas: `\n \"banners banners banners\"\n \"app-switcher side-nav top-nav\"\n \"app-switcher side-nav app-content\"\n `,\n gridTemplateColumns: \"auto auto 1fr\",\n gridTemplateRows: \"auto auto 1fr\",\n height: \"100vh\",\n width: \"100vw\",\n}));\n\nconst StyledTopNavContainer = styled(\"div\")({\n gridArea: \"top-nav\",\n});\n\nexport type WideUiShellContentProps = UiShellNavComponentProps &\n UiShellContentProps;\n\n/**\n * Our new Unified Platform UI Shell.\n *\n * This includes the top and side navigation as well as the footer and provides a spot for your app to render into.\n *\n * If an error occurs, this will revert to only showing the app.\n */\nconst WideUiShellContent = ({\n appElement,\n appElementScrollingMode,\n appSwitcherProps,\n hasStandardAppContentPadding = true,\n initialVisibleSections = [\"TopNav\", \"SideNav\", \"AppSwitcher\"],\n onError = console.error,\n optionalComponents,\n sideNavProps,\n topNavProps,\n}: WideUiShellContentProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const uiShellContext = useUiShellContext();\n\n const { isContentScrolled } = useScrollState(appElement);\n\n const sideNavContainerRef = useRef<HTMLDivElement>(null);\n const topNavContainerRef = useRef<HTMLDivElement>(null);\n const uiShellAppAreaRef = useRef<HTMLDivElement>(null);\n\n const { parentContainerRef } = useMatchAppElementToUiShellAppArea({\n appElement,\n appElementScrollingMode,\n paddingMode: hasStandardAppContentPadding ? \"comfortable\" : \"none\",\n uiShellAppAreaRef,\n uiShellResizableRefs: [\n sideNavContainerRef,\n topNavContainerRef,\n uiShellAppAreaRef,\n ],\n });\n\n return (\n <StyledShellContainer\n odysseyDesignTokens={odysseyDesignTokens}\n ref={parentContainerRef}\n >\n <StyledBannersContainer>\n {optionalComponents?.banners}\n </StyledBannersContainer>\n\n <StyledAppSwitcherContainer>\n {\n /* If AppSwitcher should be initially visible and we have not yet received props, render AppSwitcher in the loading state */\n initialVisibleSections?.includes(\"AppSwitcher\") &&\n !appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher\n appIcons={appSwitcherDefaultAppIcons}\n isLoading\n selectedAppName=\"\"\n />\n </ErrorBoundary>\n )\n }\n\n {appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher {...appSwitcherProps} />\n </ErrorBoundary>\n )}\n </StyledAppSwitcherContainer>\n\n <StyledSideNavContainer ref={sideNavContainerRef}>\n {\n /* If SideNav should be initially visible and we have not yet received props, render SideNav with minimal inputs */\n initialVisibleSections?.includes(\"SideNav\") &&\n sideNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav isLoading sideNavItems={emptySideNavItems} />\n </ErrorBoundary>\n )\n }\n\n {sideNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav\n {...{\n ...sideNavProps,\n ...(sideNavProps.hasCustomFooter &&\n optionalComponents?.sideNavFooter\n ? {\n footerComponent: optionalComponents.sideNavFooter,\n footerItems: undefined,\n hasCustomFooter: sideNavProps.hasCustomFooter,\n }\n : {\n footerItems: sideNavProps.footerItems,\n hasCustomFooter: false,\n }),\n }}\n />\n </ErrorBoundary>\n )}\n </StyledSideNavContainer>\n\n <StyledTopNavContainer ref={topNavContainerRef}>\n {\n /* If TopNav should be initially visible and we have not yet received props, render Topnav with minimal inputs */\n initialVisibleSections?.includes(\"TopNav\") &&\n topNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )\n }\n\n {topNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n {...topNavProps}\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )}\n </StyledTopNavContainer>\n\n <StyledAppContainer\n appBackgroundColor={uiShellContext?.appBackgroundColor}\n tabIndex={0}\n ref={uiShellAppAreaRef}\n >\n <InnerAppContainer isContentScrolled={isContentScrolled} />\n </StyledAppContainer>\n </StyledShellContainer>\n );\n};\n\nconst MemoizedWideUiShellContent = memo(WideUiShellContent);\nMemoizedWideUiShellContent.displayName = \"WideUiShellContent\";\n\nexport { MemoizedWideUiShellContent as WideUiShellContent };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SAASC,IAAI,EAAEC,MAAM,QAAQ,OAAO;AACpC,SAASC,aAAa,QAAQ,sBAAsB;AAEpD,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SACEC,sBAAsB,QAEjB,kCAAk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[]}
@@ -11,13 +11,15 @@
11
11
  */
12
12
 
13
13
  export * from "./AppSwitcher/index.js";
14
+ export * from "./InnerAppContainer.js";
14
15
  export * from "./NarrowUiShellContent.js";
15
16
  export * from "./renderUiShell.js";
16
17
  export * from "./SideNav/index.js";
17
18
  export * from "./TopNav/index.js";
18
19
  export * from "./uiShellContentTypes.js";
19
20
  export * from "./useHasUiShell.js";
20
- export * from "../web-component/renderReactInWebComponent.js";
21
21
  export * from "./WideUiShellContent.js";
22
+ export * from "../web-component/renderReactInWebComponent.js";
22
23
  export { UiShell } from "./UiShell.js";
24
+ export { adminAppUiShellBreakpoints } from "./useUiShellBreakpoints.js";
23
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["UiShell"],"sources":["../../../src/ui-shell/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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\nexport * from \"./AppSwitcher/index.js\";\nexport * from \"./NarrowUiShellContent.js\";\nexport * from \"./renderUiShell.js\";\nexport * from \"./SideNav/index.js\";\nexport * from \"./TopNav/index.js\";\nexport * from \"./uiShellContentTypes.js\";\nexport * from \"./useHasUiShell.js\";\nexport * from \"../web-component/renderReactInWebComponent.js\"; // This is located here because some teams use React v17, and this uses React v18's `ReactDOM/client` import which isn't in older versions.\nexport * from \"./WideUiShellContent.js\";\n\nexport { UiShell, type UiShellProps } from \"./UiShell.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,wBAAwB;AACtC,cAAc,2BAA2B;AACzC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAClC,cAAc,+CAA+C;AAC7D,cAAc,yBAAyB;AAEvC,SAASA,OAAO,QAA2B,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["UiShell","adminAppUiShellBreakpoints"],"sources":["../../../src/ui-shell/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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\nexport * from \"./AppSwitcher/index.js\";\nexport * from \"./InnerAppContainer.js\";\nexport * from \"./NarrowUiShellContent.js\";\nexport * from \"./renderUiShell.js\";\nexport * from \"./SideNav/index.js\";\nexport * from \"./TopNav/index.js\";\nexport * from \"./uiShellContentTypes.js\";\nexport * from \"./useHasUiShell.js\";\nexport * from \"./WideUiShellContent.js\";\n\nexport * from \"../web-component/renderReactInWebComponent.js\"; // This is located here because some teams use React v17, and this uses React v18's `ReactDOM/client` import which isn't in older versions.\n\nexport { UiShell, type UiShellProps } from \"./UiShell.js\";\nexport { adminAppUiShellBreakpoints } from \"./useUiShellBreakpoints.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,2BAA2B;AACzC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAClC,cAAc,yBAAyB;AAEvC,cAAc,+CAA+C;AAE7D,SAASA,OAAO,QAA2B,cAAc;AACzD,SAASC,0BAA0B,QAAQ,4BAA4B","ignoreList":[]}
@@ -29,6 +29,7 @@ export const renderUiShell = ({
29
29
  appBackgroundContrastMode,
30
30
  appElement: providedAppElement,
31
31
  appElementScrollingMode,
32
+ breakpointConfig,
32
33
  hasStandardAppContentPadding,
33
34
  initialVisibleSections,
34
35
  onError = console.error,
@@ -71,6 +72,7 @@ export const renderUiShell = ({
71
72
  }),
72
73
  onError: onError,
73
74
  children: _jsx(UiShell, {
75
+ breakpointConfig: breakpointConfig,
74
76
  appBackgroundColor: appBackgroundColor,
75
77
  appBackgroundContrastMode: appBackgroundContrastMode,
76
78
  appElement: appElement,
@@ -1 +1 @@
1
- {"version":3,"file":"renderUiShell.js","names":["ErrorBoundary","bufferLatest","createMessageBus","UiShell","uiShellDataAttribute","renderReactInWebComponent","jsx","_jsx","optionalComponentSlotNames","banners","rightSideMenu","sideNavFooter","topNavLeftSide","topNavRightSide","renderUiShell","appBackgroundColor","appBackgroundContrastMode","appElement","providedAppElement","appElementScrollingMode","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","parentElement","sideNavBackgroundColor","topNavBackgroundColor","document","createElement","setAttribute","publish","publishPropChanges","subscribe","subscribeToPropChanges","publishSubscriptionCreated","subscribeToReactAppSubscribed","publishAfterReactAppReadyForProps","closeRightSideMenu","subscribeToCloseRightSideMenu","closeSideNavMenu","subscribeToCloseSideNavMenu","slottedElements","Object","fromEntries","entries","map","optionalComponentKey","slotName","element","webComponentChildren","values","uiShellElement","getReactComponent","reactRootElements","fallback","children","onSubscriptionCreated","optionalComponents","name","uiShellAppElement","appRootElement","uiShellStylesElement","stylesRootElement","webComponentParentElement","appendChild","setComponentProps"],"sources":["../../../src/ui-shell/renderUiShell.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { type SetStateAction } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { bufferLatest } from \"./bufferLatest.js\";\nimport { createMessageBus } from \"./createMessageBus.js\";\nimport { UiShell, UiShellProps } from \"./UiShell.js\";\nimport { UiShellNavComponentProps } from \"./uiShellContentTypes.js\";\nimport { uiShellDataAttribute } from \"./useHasUiShell.js\";\nimport { renderReactInWebComponent } from \"../web-component/renderReactInWebComponent.js\";\n\nexport const optionalComponentSlotNames: Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n string\n> = {\n banners: \"banners\",\n rightSideMenu: \"right-side-menu\",\n sideNavFooter: \"side-nav-footer\",\n topNavLeftSide: \"top-nav-left-side\",\n topNavRightSide: \"top-nav-right-side\",\n};\n\n/**\n * This function renders UI Shell in a web component.\n * This function is agnostic to the UI framework for your app is using. Your application can be another web component, a React app, or even vanilla HTML.\n *\n * **All styles are self-contained.** Even though your application visually renders as children of the web component, its within the global `document` scope, not the web component's `ShadowRoot`. That means any global styles will not affect UI Shell but will affect your application.\n *\n * It places your app's root element in a web component <slot> and ensures it remains rendered in the event of a UI Shell error.\n * It also provides you with other elements fitted to slots in the web component. **In React, you can portal to these components.**\n */\nexport const renderUiShell = ({\n appBackgroundColor,\n appBackgroundContrastMode,\n appElement: providedAppElement,\n appElementScrollingMode,\n hasStandardAppContentPadding,\n initialVisibleSections,\n onError = console.error,\n parentElement,\n sideNavBackgroundColor,\n topNavBackgroundColor,\n}: {\n /**\n * Notifies when a React rendering error occurs. This could be useful for logging, reporting priority 0 issues, and recovering UI Shell when errors occur.\n */\n onError?: () => void;\n /**\n * HTML element used as the container for UI Shell and the App. They're siblings inside this element.\n */\n parentElement: HTMLElement;\n} & Pick<\n UiShellProps,\n | \"appBackgroundColor\"\n | \"appBackgroundContrastMode\"\n | \"appElementScrollingMode\"\n | \"hasStandardAppContentPadding\"\n | \"initialVisibleSections\"\n | \"sideNavBackgroundColor\"\n | \"topNavBackgroundColor\"\n> &\n Partial<Pick<UiShellProps, \"appElement\">>) => {\n const appElement = providedAppElement || document.createElement(\"div\");\n\n // Add this attribute so `PageTemplate` and potentially other components will know if they're in UI Shell with special padding already available.\n parentElement.setAttribute(uiShellDataAttribute, \"\");\n\n const { publish: publishPropChanges, subscribe: subscribeToPropChanges } =\n createMessageBus<SetStateAction<UiShellNavComponentProps>>();\n\n const {\n publish: publishSubscriptionCreated,\n subscribe: subscribeToReactAppSubscribed,\n } = createMessageBus();\n\n const publishAfterReactAppReadyForProps = bufferLatest({\n publish: publishPropChanges,\n subscribe: subscribeToReactAppSubscribed,\n });\n\n const {\n publish: closeRightSideMenu,\n subscribe: subscribeToCloseRightSideMenu,\n } = createMessageBus();\n\n const { publish: closeSideNavMenu, subscribe: subscribeToCloseSideNavMenu } =\n createMessageBus();\n\n const slottedElements = Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => {\n const element = document.createElement(\"div\");\n\n element.setAttribute(\"slot\", slotName);\n\n return [optionalComponentKey, element];\n },\n ),\n ) as Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n HTMLDivElement\n >;\n\n const webComponentChildren = Object.values(slottedElements);\n\n const uiShellElement = renderReactInWebComponent({\n getReactComponent: (reactRootElements) => (\n <ErrorBoundary fallback={<div data-error />} onError={onError}>\n <UiShell\n appBackgroundColor={appBackgroundColor}\n appBackgroundContrastMode={appBackgroundContrastMode}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n closeSideNavMenu={closeSideNavMenu}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n onSubscriptionCreated={publishSubscriptionCreated}\n // `optionalComponents` doesn't need to be memoized because gets passed in once, and this isn't a React component.\n optionalComponents={Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => [\n optionalComponentKey,\n <slot name={slotName} />,\n ],\n ),\n )}\n sideNavBackgroundColor={sideNavBackgroundColor}\n subscribeToCloseRightSideMenu={subscribeToCloseRightSideMenu}\n subscribeToCloseSideNavMenu={subscribeToCloseSideNavMenu}\n subscribeToPropChanges={subscribeToPropChanges}\n topNavBackgroundColor={topNavBackgroundColor}\n uiShellAppElement={reactRootElements.appRootElement}\n uiShellStylesElement={reactRootElements.stylesRootElement}\n />\n </ErrorBoundary>\n ),\n webComponentParentElement: parentElement,\n webComponentChildren,\n });\n\n parentElement.appendChild(appElement);\n\n return {\n appElement,\n closeRightSideMenu,\n closeSideNavMenu,\n setComponentProps: publishAfterReactAppReadyForProps,\n slottedElements,\n uiShellElement,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,aAAa,QAAQ,sBAAsB;AAEpD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,OAAO,QAAsB,cAAc;AAEpD,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,yBAAyB,QAAQ,+CAA+C;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1F,OAAO,MAAMC,0BAGZ,GAAG;EACFC,OAAO,EAAE,SAAS;EAClBC,aAAa,EAAE,iBAAiB;EAChCC,aAAa,EAAE,iBAAiB;EAChCC,cAAc,EAAE,mBAAmB;EACnCC,eAAe,EAAE;AACnB,CAAC;AAWD,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAC5BC,kBAAkB;EAClBC,yBAAyB;EACzBC,UAAU,EAAEC,kBAAkB;EAC9BC,uBAAuB;EACvBC,4BAA4B;EAC5BC,s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1
+ {"version":3,"file":"renderUiShell.js","names":["ErrorBoundary","bufferLatest","createMessageBus","UiShell","uiShellDataAttribute","renderReactInWebComponent","jsx","_jsx","optionalComponentSlotNames","banners","rightSideMenu","sideNavFooter","topNavLeftSide","topNavRightSide","renderUiShell","appBackgroundColor","appBackgroundContrastMode","appElement","providedAppElement","appElementScrollingMode","breakpointConfig","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","parentElement","sideNavBackgroundColor","topNavBackgroundColor","document","createElement","setAttribute","publish","publishPropChanges","subscribe","subscribeToPropChanges","publishSubscriptionCreated","subscribeToReactAppSubscribed","publishAfterReactAppReadyForProps","closeRightSideMenu","subscribeToCloseRightSideMenu","closeSideNavMenu","subscribeToCloseSideNavMenu","slottedElements","Object","fromEntries","entries","map","optionalComponentKey","slotName","element","webComponentChildren","values","uiShellElement","getReactComponent","reactRootElements","fallback","children","onSubscriptionCreated","optionalComponents","name","uiShellAppElement","appRootElement","uiShellStylesElement","stylesRootElement","webComponentParentElement","appendChild","setComponentProps"],"sources":["../../../src/ui-shell/renderUiShell.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { type SetStateAction } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { bufferLatest } from \"./bufferLatest.js\";\nimport { createMessageBus } from \"./createMessageBus.js\";\nimport { UiShell, UiShellProps } from \"./UiShell.js\";\nimport { UiShellNavComponentProps } from \"./uiShellContentTypes.js\";\nimport { uiShellDataAttribute } from \"./useHasUiShell.js\";\nimport { renderReactInWebComponent } from \"../web-component/renderReactInWebComponent.js\";\n\nexport const optionalComponentSlotNames: Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n string\n> = {\n banners: \"banners\",\n rightSideMenu: \"right-side-menu\",\n sideNavFooter: \"side-nav-footer\",\n topNavLeftSide: \"top-nav-left-side\",\n topNavRightSide: \"top-nav-right-side\",\n};\n\n/**\n * This function renders UI Shell in a web component.\n * This function is agnostic to the UI framework for your app is using. Your application can be another web component, a React app, or even vanilla HTML.\n *\n * **All styles are self-contained.** Even though your application visually renders as children of the web component, its within the global `document` scope, not the web component's `ShadowRoot`. That means any global styles will not affect UI Shell but will affect your application.\n *\n * It places your app's root element in a web component <slot> and ensures it remains rendered in the event of a UI Shell error.\n * It also provides you with other elements fitted to slots in the web component. **In React, you can portal to these components.**\n */\nexport const renderUiShell = ({\n appBackgroundColor,\n appBackgroundContrastMode,\n appElement: providedAppElement,\n appElementScrollingMode,\n breakpointConfig,\n hasStandardAppContentPadding,\n initialVisibleSections,\n onError = console.error,\n parentElement,\n sideNavBackgroundColor,\n topNavBackgroundColor,\n}: {\n /**\n * Notifies when a React rendering error occurs. This could be useful for logging, reporting priority 0 issues, and recovering UI Shell when errors occur.\n */\n onError?: () => void;\n /**\n * HTML element used as the container for UI Shell and the App. They're siblings inside this element.\n */\n parentElement: HTMLElement;\n} & Pick<\n UiShellProps,\n | \"appBackgroundColor\"\n | \"appBackgroundContrastMode\"\n | \"appElementScrollingMode\"\n | \"breakpointConfig\"\n | \"hasStandardAppContentPadding\"\n | \"initialVisibleSections\"\n | \"sideNavBackgroundColor\"\n | \"topNavBackgroundColor\"\n> &\n Partial<Pick<UiShellProps, \"appElement\">>) => {\n const appElement = providedAppElement || document.createElement(\"div\");\n\n // Add this attribute so `PageTemplate` and potentially other components will know if they're in UI Shell with special padding already available.\n parentElement.setAttribute(uiShellDataAttribute, \"\");\n\n const { publish: publishPropChanges, subscribe: subscribeToPropChanges } =\n createMessageBus<SetStateAction<UiShellNavComponentProps>>();\n\n const {\n publish: publishSubscriptionCreated,\n subscribe: subscribeToReactAppSubscribed,\n } = createMessageBus();\n\n const publishAfterReactAppReadyForProps = bufferLatest({\n publish: publishPropChanges,\n subscribe: subscribeToReactAppSubscribed,\n });\n\n const {\n publish: closeRightSideMenu,\n subscribe: subscribeToCloseRightSideMenu,\n } = createMessageBus();\n\n const { publish: closeSideNavMenu, subscribe: subscribeToCloseSideNavMenu } =\n createMessageBus();\n\n const slottedElements = Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => {\n const element = document.createElement(\"div\");\n\n element.setAttribute(\"slot\", slotName);\n\n return [optionalComponentKey, element];\n },\n ),\n ) as Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n HTMLDivElement\n >;\n\n const webComponentChildren = Object.values(slottedElements);\n\n const uiShellElement = renderReactInWebComponent({\n getReactComponent: (reactRootElements) => (\n <ErrorBoundary fallback={<div data-error />} onError={onError}>\n <UiShell\n breakpointConfig={breakpointConfig}\n appBackgroundColor={appBackgroundColor}\n appBackgroundContrastMode={appBackgroundContrastMode}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n closeSideNavMenu={closeSideNavMenu}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n onSubscriptionCreated={publishSubscriptionCreated}\n // `optionalComponents` doesn't need to be memoized because gets passed in once, and this isn't a React component.\n optionalComponents={Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => [\n optionalComponentKey,\n <slot name={slotName} />,\n ],\n ),\n )}\n sideNavBackgroundColor={sideNavBackgroundColor}\n subscribeToCloseRightSideMenu={subscribeToCloseRightSideMenu}\n subscribeToCloseSideNavMenu={subscribeToCloseSideNavMenu}\n subscribeToPropChanges={subscribeToPropChanges}\n topNavBackgroundColor={topNavBackgroundColor}\n uiShellAppElement={reactRootElements.appRootElement}\n uiShellStylesElement={reactRootElements.stylesRootElement}\n />\n </ErrorBoundary>\n ),\n webComponentParentElement: parentElement,\n webComponentChildren,\n });\n\n parentElement.appendChild(appElement);\n\n return {\n appElement,\n closeRightSideMenu,\n closeSideNavMenu,\n setComponentProps: publishAfterReactAppReadyForProps,\n slottedElements,\n uiShellElement,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,aAAa,QAAQ,sBAAsB;AAEpD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,OAAO,QAAsB,cAAc;AAEpD,SAASC,oBAAoB,QAAQ,oBAAoB;AACzD,SAASC,yBAAyB,QAAQ,+CAA+C;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE1F,OAAO,MAAMC,0BAGZ,GAAG;EACFC,OAAO,EAAE,SAAS;EAClBC,aAAa,EAAE,iBAAiB;EAChCC,aAAa,EAAE,iBAAiB;EAChCC,cAAc,EAAE,mBAAmB;EACnCC,eAAe,EAAE;AACnB,CAAC;AAWD,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAC5BC,kBAAkB;EAClBC,yBAAyB;EACzBC,UAAU,EAAEC,kBAAkB;EAC9BC,uBAAuB;EACvBC,gBAAgB;EAChBC,4BAA4B;EAC5BC,sBAAsB;EACtBC,OAAO,GAAGC,OAAO,CAACC,KAAK;EACvBC,aAAa;EACbC,sBAAsB;EACtBC;AAqBwC,CAAC,KAAK;EAC9C,MAAMX,UAAU,GAAGC,kBAAkB,IAAIW,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAGtEJ,aAAa,CAACK,YAAY,CAAC3B,oBAAoB,EAAE,EAAE,CAAC;EAEpD,MAAM;IAAE4B,OAAO,EAAEC,kBAAkB;IAAEC,SAAS,EAAEC;EAAuB,CAAC,GACtEjC,gBAAgB,CAA2C,CAAC;EAE9D,MAAM;IACJ8B,OAAO,EAAEI,0BAA0B;IACnCF,SAAS,E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C3DC,sBAAsB,EAAEA,sBAAuB;QAC/CC,OAAO,EAAEA,OAAQ;QACjBmC,qBAAqB,EAAEtB,0BAA2B;QAElDuB,kBAAkB,EAAEf,MAAM,CAACC,WAAW,CACpCD,MAAM,CAACE,OAAO,CAACtC,0BAA0B,CAAC,CAACuC,GAAG,CAC5C,CAAC,CAACC,oBAAoB,EAAEC,QAAQ,CAAC,KAAK,CACpCD,oBAAoB,EACpBzC,IAAA;UAAMqD,IAAI,EAAEX;QAAS,CAAE,CAAC,CAE5B,CACF,CAAE;QACFtB,sBAAsB,EAAEA,sBAAuB;QAC/Ca,6BAA6B,EAAEA,6BAA8B;QAC7DE,2BAA2B,EAAEA,2BAA4B;QACzDP,sBAAsB,EAAEA,sBAAuB;QAC/CP,qBAAqB,EAAEA,qBAAsB;QAC7CiC,iBAAiB,EAAEN,iBAAiB,CAACO,cAAe;QACpDC,oBAAoB,EAAER,iBAAiB,CAACS;MAAkB,CAC3D;IAAC,CACW,CAChB;IACDC,yBAAyB,EAAEvC,aAAa;IACxCyB;EACF,CAAC,CAAC;EAEFzB,aAAa,CAACwC,WAAW,CAACjD,UAAU,CAAC;EAErC,OAAO;IACLA,UAAU;IACVsB,kBAAkB;IAClBE,gBAAgB;IAChB0B,iBAAiB,EAAE7B,iCAAiC;IACpDK,eAAe;IACfU;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -26,7 +26,6 @@ export const setStylesToMatchElement = ({
26
26
  appContainerElement.style.setProperty("left", `${appContentReferenceRectangle.left - parentElementRectangle.left}px`);
27
27
  appContainerElement.style.setProperty("width", `${appContentReferenceRectangle.width}px`);
28
28
  appContainerElement.style.setProperty("height", `${appContentReferenceRectangle.height}px`);
29
- appContainerElement.style.setProperty("z-index", "1");
30
29
  Object.entries(additionalStyles).forEach(([cssPropertyName, cssPropertyValue]) => {
31
30
  appContainerElement.style.setProperty(convertCamelCaseToKebabCase(cssPropertyName), String(cssPropertyValue));
32
31
  });
@@ -41,6 +40,8 @@ export const useMatchAppElementToUiShellAppArea = ({
41
40
  const odysseyDesignTokens = useOdysseyDesignTokens();
42
41
  const parentContainerRef = useRef(null);
43
42
  const appContainerElementStyles = useMemo(() => ({
43
+ boxSizing: "border-box",
44
+ zIndex: 1,
44
45
  ...(paddingMode === "comfortable" ? {
45
46
  paddingBlock: odysseyDesignTokens.Spacing5,
46
47
  paddingInline: odysseyDesignTokens.Spacing8
@@ -91,7 +92,7 @@ export const useMatchAppElementToUiShellAppArea = ({
91
92
  };
92
93
  }
93
94
  return () => {};
94
- }, [appElement, appContainerElementStyles, uiShellAppAreaRef]);
95
+ }, [appElement, appContainerElementStyles, uiShellAppAreaRef, uiShellResizableRefs]);
95
96
  return {
96
97
  parentContainerRef
97
98
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useMatchAppElementToUiShellAppArea.js","names":["useEffect","useMemo","useRef","useOdysseyDesignTokens","convertCamelCaseToKebabCase","string","replace","toLowerCase","setStylesToMatchElement","additionalStyles","appContainerElement","appContentReferenceElement","parentElement","appContentReferenceRectangle","getBoundingClientRect","parentElementRectangle","style","setProperty","top","left","width","height","Object","entries","forEach","cssPropertyName","cssPropertyValue","String","useMatchAppElementToUiShellAppArea","appElement","appElementScrollingMode","paddingMode","uiShellAppAreaRef","uiShellResizableRefs","odysseyDesignTokens","parentContainerRef","appContainerElementStyles","paddingBlock","Spacing5","paddingInline","Spacing8","overflowX","overflowY","current","animationFrameId","updateStyles","cancelAnimationFrame","requestAnimationFrame","resizingElements","map","resizingRef","filter","element","Boolean","observer","ResizeObserver","resizingElement","addEventListener","observe","disconnect","removeEventListener"],"sources":["../../../src/ui-shell/useMatchAppElementToUiShellAppArea.ts"],"sourcesContent":["/*!\n * Copyright (c) 2025-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, RefObject, useEffect, useMemo, useRef } from \"react\";\n\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext.js\";\nimport { UiShellContentProps } from \"./uiShellContentTypes.js\";\n\nexport const convertCamelCaseToKebabCase = (string: string) =>\n string.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\nexport const setStylesToMatchElement = ({\n additionalStyles,\n appContainerElement,\n appContentReferenceElement,\n parentElement,\n}: {\n additionalStyles: CSSProperties;\n appContainerElement: HTMLElement;\n appContentReferenceElement: HTMLElement;\n parentElement: HTMLElement;\n}) => {\n const appContentReferenceRectangle =\n appContentReferenceElement.getBoundingClientRect();\n const parentElementRectangle = parentElement.getBoundingClientRect();\n\n appContainerElement.style.setProperty(\"position\", \"absolute\");\n appContainerElement.style.setProperty(\n \"top\",\n `${appContentReferenceRectangle.top - parentElementRectangle.top}px`,\n );\n appContainerElement.style.setProperty(\n \"left\",\n `${appContentReferenceRectangle.left - parentElementRectangle.left}px`,\n );\n appContainerElement.style.setProperty(\n \"width\",\n `${appContentReferenceRectangle.width}px`,\n );\n appContainerElement.style.setProperty(\n \"height\",\n `${appContentReferenceRectangle.height}px`,\n );\n appContainerElement.style.setProperty(\"z-index\", \"1\");\n\n (\n Object.entries(additionalStyles) as Array<\n [\n keyof typeof additionalStyles,\n (typeof additionalStyles)[keyof typeof additionalStyles],\n ]\n >\n ).forEach(([cssPropertyName, cssPropertyValue]) => {\n appContainerElement.style.setProperty(\n convertCamelCaseToKebabCase(cssPropertyName),\n String(cssPropertyValue),\n );\n });\n};\n\nexport type UseMatchAppElementToUiShellAppAreaProps = {\n /**\n * Padding around the app area. \"comfortable\" is designed for wider views whereas \"compact\" is designed for narrower views.\n */\n paddingMode: \"comfortable\" | \"compact\" | \"none\";\n /**\n * Ref for the App Container in UI Shell. This should be the one inside the Shell, **not** the element we're going to align.\n */\n uiShellAppAreaRef: RefObject<HTMLDivElement>;\n /**\n * Array of refs of items that indirectly resize the app content area such as \"side nav\" and \"top nav\".\n */\n uiShellResizableRefs: Array<RefObject<HTMLDivElement>>;\n} & Pick<UiShellContentProps, \"appElement\" | \"appElementScrollingMode\">;\n\nexport const useMatchAppElementToUiShellAppArea = ({\n appElement,\n appElementScrollingMode,\n paddingMode,\n uiShellAppAreaRef,\n uiShellResizableRefs,\n}: UseMatchAppElementToUiShellAppAreaProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const parentContainerRef = useRef<HTMLDivElement>(null);\n\n const appContainerElementStyles = useMemo<CSSProperties>(\n () => ({\n ...(paddingMode === \"comfortable\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing8,\n }\n : {}),\n ...(paddingMode === \"compact\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing5,\n }\n : {}),\n ...(appElementScrollingMode === \"horizontal\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowX: \"auto\",\n }\n : {\n overflowX: \"hidden\",\n }),\n ...(appElementScrollingMode === \"vertical\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowY: \"auto\",\n }\n : {\n overflowY: \"hidden\",\n }),\n }),\n [appElementScrollingMode, paddingMode, odysseyDesignTokens],\n );\n\n useEffect(() => {\n // Once `appContainerRef` is rendered, we can position `appContainerElement` on top to match.\n if (uiShellAppAreaRef.current && appElement && parentContainerRef.current) {\n let animationFrameId: number;\n\n const updateStyles = () => {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = requestAnimationFrame(() => {\n if (uiShellAppAreaRef.current && parentContainerRef.current) {\n setStylesToMatchElement({\n additionalStyles: appContainerElementStyles,\n appContentReferenceElement: uiShellAppAreaRef.current,\n appContainerElement: appElement,\n parentElement: parentContainerRef.current,\n });\n }\n });\n };\n\n // These refs might change by the time we unsubscribe, so we need to keep references to the original elements.\n const resizingElements = uiShellResizableRefs\n .map((resizingRef) => resizingRef.current)\n .filter((element): element is NonNullable<typeof element> =>\n Boolean(element),\n );\n\n // Set up a mutation observer to sync later updates\n const observer = new ResizeObserver(updateStyles);\n\n // document.addEventListener(\"ready\", updateStyles);\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.addEventListener(\"transitionend\", updateStyles);\n\n observer.observe(resizingElement);\n });\n\n // Set the initial styles\n updateStyles();\n\n return () => {\n observer.disconnect();\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.removeEventListener(\"transitionend\", updateStyles);\n });\n };\n }\n return () => {};\n }, [appElement, appContainerElementStyles, uiShellAppAreaRef]);\n\n return {\n parentContainerRef,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAmCA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE5E,SAASC,sBAAsB,QAAQ,kCAAkC;AAGzE,OAAO,MAAMC,2BAA2B,GAAIC,MAAc,IACxDA,MAAM,CAACC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAACC,WAAW,CAAC,CAAC;AAEjD,OAAO,MAAMC,uBAAuB,GAAGA,CAAC;EACtCC,gBAAgB;EAChBC,mBAAmB;EACnBC,0BAA0B;EAC1BC;AAMF,CAAC,KAAK;EACJ,MAAMC,4BAA4B,GAChCF,0BAA0B,CAACG,qBAAqB,CAAC,CAAC;EACpD,MAAMC,sBAAsB,GAAGH,aAAa,CAACE,qBAAqB,CAAC,CAAC;EAEpEJ,mBAAmB,CAACM,KAAK,CAACC,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC;EAC7DP,mBAAmB,CAACM,KAAK,CAACC,WAAW,CACnC,KAAK,EACL,GAAGJ,4BAA4B,CAACK,GAAG,GAAGH,sBAAsB,CAACG,GAAG,IAClE,CAAC;EACDR,mBAAmB,CAACM,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,eAAe,CAAC;MACnC,CAAC,CAAC;MAGFX,YAAY,CAAC,CAAC;MAEd,OAAO,MAAM;QACXS,QAAQ,CAACK,UAAU,CAAC,CAAC;QAErBX,gBAAgB,CAACxB,OAAO,CAAEgC,eAAe,IAAK;UAC5CA,eAAe,CAACI,mBAAmB,CAAC,eAAe,EAAEf,YAAY,CAAC;QACpE,CAAC,CAAC;MACJ,CAAC;IACH;IACA,OAAO,MAAM,CAAC,CAAC;EACjB,CAAC,EAAE,CAAChB,UAAU,EAAEO,yBAAyB,EAAEJ,iBAAiB,CAAC,CAAC;EAE9D,OAAO;IACLG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useMatchAppElementToUiShellAppArea.js","names":["useEffect","useMemo","useRef","useOdysseyDesignTokens","convertCamelCaseToKebabCase","string","replace","toLowerCase","setStylesToMatchElement","additionalStyles","appContainerElement","appContentReferenceElement","parentElement","appContentReferenceRectangle","getBoundingClientRect","parentElementRectangle","style","setProperty","top","left","width","height","Object","entries","forEach","cssPropertyName","cssPropertyValue","String","useMatchAppElementToUiShellAppArea","appElement","appElementScrollingMode","paddingMode","uiShellAppAreaRef","uiShellResizableRefs","odysseyDesignTokens","parentContainerRef","appContainerElementStyles","boxSizing","zIndex","paddingBlock","Spacing5","paddingInline","Spacing8","overflowX","overflowY","current","animationFrameId","updateStyles","cancelAnimationFrame","requestAnimationFrame","resizingElements","map","resizingRef","filter","element","Boolean","observer","ResizeObserver","resizingElement","addEventListener","observe","disconnect","removeEventListener"],"sources":["../../../src/ui-shell/useMatchAppElementToUiShellAppArea.ts"],"sourcesContent":["/*!\n * Copyright (c) 2025-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, RefObject, useEffect, useMemo, useRef } from \"react\";\n\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext.js\";\nimport { UiShellContentProps } from \"./uiShellContentTypes.js\";\n\nexport const convertCamelCaseToKebabCase = (string: string) =>\n string.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\nexport const setStylesToMatchElement = ({\n additionalStyles,\n appContainerElement,\n appContentReferenceElement,\n parentElement,\n}: {\n additionalStyles: CSSProperties;\n appContainerElement: HTMLElement;\n appContentReferenceElement: HTMLElement;\n parentElement: HTMLElement;\n}) => {\n const appContentReferenceRectangle =\n appContentReferenceElement.getBoundingClientRect();\n const parentElementRectangle = parentElement.getBoundingClientRect();\n\n appContainerElement.style.setProperty(\"position\", \"absolute\");\n appContainerElement.style.setProperty(\n \"top\",\n `${appContentReferenceRectangle.top - parentElementRectangle.top}px`,\n );\n appContainerElement.style.setProperty(\n \"left\",\n `${appContentReferenceRectangle.left - parentElementRectangle.left}px`,\n );\n appContainerElement.style.setProperty(\n \"width\",\n `${appContentReferenceRectangle.width}px`,\n );\n appContainerElement.style.setProperty(\n \"height\",\n `${appContentReferenceRectangle.height}px`,\n );\n\n (\n Object.entries(additionalStyles) as Array<\n [\n keyof typeof additionalStyles,\n (typeof additionalStyles)[keyof typeof additionalStyles],\n ]\n >\n ).forEach(([cssPropertyName, cssPropertyValue]) => {\n appContainerElement.style.setProperty(\n convertCamelCaseToKebabCase(cssPropertyName),\n String(cssPropertyValue),\n );\n });\n};\n\nexport type UseMatchAppElementToUiShellAppAreaProps = {\n /**\n * Padding around the app area. \"comfortable\" is designed for wider views whereas \"compact\" is designed for narrower views.\n */\n paddingMode: \"comfortable\" | \"compact\" | \"none\";\n /**\n * Ref for the App Container in UI Shell. This should be the one inside the Shell, **not** the element we're going to align.\n */\n uiShellAppAreaRef: RefObject<HTMLDivElement>;\n /**\n * Array of refs of items that indirectly resize the app content area such as \"side nav\" and \"top nav\".\n */\n uiShellResizableRefs: Array<RefObject<HTMLDivElement>>;\n} & Pick<UiShellContentProps, \"appElement\" | \"appElementScrollingMode\">;\n\nexport const useMatchAppElementToUiShellAppArea = ({\n appElement,\n appElementScrollingMode,\n paddingMode,\n uiShellAppAreaRef,\n uiShellResizableRefs,\n}: UseMatchAppElementToUiShellAppAreaProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const parentContainerRef = useRef<HTMLDivElement>(null);\n\n const appContainerElementStyles = useMemo<CSSProperties>(\n () => ({\n boxSizing: \"border-box\",\n zIndex: 1,\n ...(paddingMode === \"comfortable\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing8,\n }\n : {}),\n\n ...(paddingMode === \"compact\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing5,\n }\n : {}),\n\n ...(appElementScrollingMode === \"horizontal\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowX: \"auto\",\n }\n : {\n overflowX: \"hidden\",\n }),\n\n ...(appElementScrollingMode === \"vertical\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowY: \"auto\",\n }\n : {\n overflowY: \"hidden\",\n }),\n }),\n [appElementScrollingMode, paddingMode, odysseyDesignTokens],\n );\n\n useEffect(() => {\n // Once `appContainerRef` is rendered, we can position `appContainerElement` on top to match.\n if (uiShellAppAreaRef.current && appElement && parentContainerRef.current) {\n let animationFrameId: number;\n\n const updateStyles = () => {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = requestAnimationFrame(() => {\n if (uiShellAppAreaRef.current && parentContainerRef.current) {\n setStylesToMatchElement({\n additionalStyles: appContainerElementStyles,\n appContentReferenceElement: uiShellAppAreaRef.current,\n appContainerElement: appElement,\n parentElement: parentContainerRef.current,\n });\n }\n });\n };\n\n // These refs might change by the time we unsubscribe, so we need to keep references to the original elements.\n const resizingElements = uiShellResizableRefs\n .map((resizingRef) => resizingRef.current)\n .filter((element): element is NonNullable<typeof element> =>\n Boolean(element),\n );\n\n // Set up a mutation observer to sync later updates\n const observer = new ResizeObserver(updateStyles);\n\n // document.addEventListener(\"ready\", updateStyles);\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.addEventListener(\"transitionend\", updateStyles);\n\n observer.observe(resizingElement);\n });\n\n // Set the initial styles\n updateStyles();\n\n return () => {\n observer.disconnect();\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.removeEventListener(\"transitionend\", updateStyles);\n });\n };\n }\n return () => {};\n }, [\n appElement,\n appContainerElementStyles,\n uiShellAppAreaRef,\n uiShellResizableRefs,\n ]);\n\n return {\n parentContainerRef,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAmCA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE5E,SAASC,sBAAsB,QAAQ,kCAAkC;AAGzE,OAAO,MAAMC,2BAA2B,GAAIC,MAAc,IACxDA,MAAM,CAACC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAACC,WAAW,CAAC,CAAC;AAEjD,OAAO,MAAMC,uBAAuB,GAAGA,CAAC;EACtCC,gBAAgB;EAChBC,mBAAmB;EACnBC,0BAA0B;EAC1BC;AAMF,CAAC,KAAK;EACJ,MAAMC,4BAA4B,GAChCF,0BAA0B,CAACG,qBAAqB,CAAC,CAAC;EACpD,MAAMC,sBAAsB,GAAGH,aAAa,CAACE,qBAAqB,CAAC,CAAC;EAEpEJ,mBAAmB,CAACM,KAAK,CAACC,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC;EAC7DP,mBAAmB,CAACM,KAAK,CAACC,WAAW,CACnC,KAAK,EACL,GAAGJ,4BAA4B,CAACK,GAAG,GAAGH,sBAAsB,CAACG,GAAG,IAClE,CAAC;EACDR,mBAAmB,CAACM,KAAK,CAACC,WA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AAC;MAGFX,YAAY,CAAC,CAAC;MAEd,OAAO,MAAM;QACXS,QAAQ,CAACK,UAAU,CAAC,CAAC;QAErBX,gBAAgB,CAAC1B,OAAO,CAAEkC,eAAe,IAAK;UAC5CA,eAAe,CAACI,mBAAmB,CAAC,eAAe,EAAEf,YAAY,CAAC;QACpE,CAAC,CAAC;MACJ,CAAC;IACH;IACA,OAAO,MAAM,CAAC,CAAC;EACjB,CAAC,EAAE,CACDlB,UAAU,EACVO,yBAAyB,EACzBJ,iBAAiB,EACjBC,oBAAoB,CACrB,CAAC;EAEF,OAAO;IACLE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -10,30 +10,76 @@
10
10
  * See the License for the specific language governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { useEffect, useMemo, useState } from "react";
14
- export const useScrollState = scrollableContentElement => {
15
- const [isContentScrolled, setIsContentScrolled] = useState(false);
16
- const scrollableElement = useMemo(() => scrollableContentElement, [scrollableContentElement]);
17
- useEffect(() => {
18
- if (scrollableElement) {
19
- let requestedAnimationFrameId;
20
- const updateScrollState = () => {
21
- cancelAnimationFrame(requestedAnimationFrameId);
22
- requestedAnimationFrameId = requestAnimationFrame(() => {
23
- setIsContentScrolled(scrollableElement.scrollTop > 0);
24
- });
25
- };
13
+ import { useCallback, useEffect, useRef, useState } from "react";
14
+ export const getIsScrollHeightElement = ({
15
+ containerElement,
16
+ scrollableElement
17
+ }) => {
18
+ const containerElementHeight = containerElement.getBoundingClientRect().height;
19
+ const scrollableElementHeight = scrollableElement.getBoundingClientRect().height;
20
+ return scrollableElementHeight - containerElementHeight >= 0;
21
+ };
22
+ export const getIsYAxisScrollContainer = element => {
23
+ const overflowY = window.getComputedStyle(element).overflowY;
24
+ return overflowY === "auto" || overflowY === "scroll";
25
+ };
26
+ export const getIsYAxisScrolling = element => element.scrollHeight > element.clientHeight ? getIsYAxisScrollContainer(element) : false;
27
+ export const getNestedScrollContainers = containerElement => Array.from(containerElement.querySelectorAll("*")).filter(element => getIsYAxisScrollContainer(element)).filter(scrollableElement => getIsScrollHeightElement({
28
+ containerElement,
29
+ scrollableElement
30
+ }));
31
+ export const fakeDefaultContainerElement = document.createElement("div");
32
+ export const useScrollState = containerElement => {
33
+ const [isScrolled, setIsScrolled] = useState(false);
34
+ const requestedAnimationFrameIdRef = useRef(0);
35
+ const scrollableElementsRef = useRef([]);
36
+ const updateScrollState = useCallback(() => {
37
+ cancelAnimationFrame(requestedAnimationFrameIdRef.current);
38
+ requestedAnimationFrameIdRef.current = requestAnimationFrame(() => {
39
+ setIsScrolled(scrollableElementsRef.current.reduce((isScrolled, scrollableElement) => isScrolled || scrollableElement.scrollTop > 0, false));
40
+ });
41
+ }, []);
42
+ const addScrollEventListeners = useCallback(() => {
43
+ scrollableElementsRef.current.forEach(scrollableElement => {
26
44
  scrollableElement.addEventListener("scroll", updateScrollState);
27
- updateScrollState();
28
- return () => {
29
- scrollableElement.removeEventListener("scroll", updateScrollState);
30
- cancelAnimationFrame(requestedAnimationFrameId);
31
- };
45
+ });
46
+ }, [updateScrollState]);
47
+ const removeScrollEventListeners = useCallback(() => {
48
+ scrollableElementsRef.current.forEach(scrollableElement => {
49
+ scrollableElement.removeEventListener("scroll", updateScrollState);
50
+ });
51
+ }, [updateScrollState]);
52
+ const updateScrollableElements = useCallback(() => {
53
+ const computedContainerElement = containerElement || fakeDefaultContainerElement;
54
+ scrollableElementsRef.current = getNestedScrollContainers(computedContainerElement).concat(computedContainerElement);
55
+ }, [containerElement]);
56
+ const updateScrollListeners = useCallback(() => {
57
+ removeScrollEventListeners();
58
+ updateScrollableElements();
59
+ addScrollEventListeners();
60
+ updateScrollState();
61
+ }, [addScrollEventListeners, removeScrollEventListeners, updateScrollableElements, updateScrollState]);
62
+ useEffect(() => {
63
+ const mutationObserver = new MutationObserver(() => {
64
+ updateScrollListeners();
65
+ });
66
+ if (containerElement) {
67
+ mutationObserver.observe(containerElement, {
68
+ attributes: true,
69
+ attributeFilter: ["style"],
70
+ childList: true,
71
+ subtree: true
72
+ });
32
73
  }
33
- return () => {};
34
- }, [scrollableElement]);
74
+ updateScrollListeners();
75
+ return () => {
76
+ cancelAnimationFrame(requestedAnimationFrameIdRef.current);
77
+ removeScrollEventListeners();
78
+ mutationObserver.disconnect();
79
+ };
80
+ }, [containerElement, removeScrollEventListeners, updateScrollListeners]);
35
81
  return {
36
- isContentScrolled
82
+ isContentScrolled: isScrolled
37
83
  };
38
84
  };
39
85
  //# sourceMappingURL=useScrollState.js.map