@databiosphere/findable-ui 22.0.0 → 23.0.0

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 (192) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/lib/common/selectors.d.ts +6 -2
  4. package/lib/common/selectors.js +7 -2
  5. package/lib/components/DataDictionary/components/Entities/constants.d.ts +1 -0
  6. package/lib/components/DataDictionary/components/Entities/constants.js +2 -1
  7. package/lib/components/DataDictionary/components/Entities/entities.d.ts +1 -1
  8. package/lib/components/DataDictionary/components/Entities/entities.js +2 -2
  9. package/lib/components/DataDictionary/components/Entities/types.d.ts +2 -0
  10. package/lib/components/DataDictionary/components/Entity/entity.d.ts +1 -1
  11. package/lib/components/DataDictionary/components/Entity/entity.js +9 -4
  12. package/lib/components/DataDictionary/components/Entity/entity.styles.d.ts +2 -0
  13. package/lib/components/DataDictionary/components/Entity/entity.styles.js +10 -0
  14. package/lib/components/DataDictionary/components/Entity/types.d.ts +2 -0
  15. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.d.ts +2 -0
  16. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.js +5 -0
  17. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.d.ts +5 -0
  18. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.js +19 -0
  19. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/types.d.ts +5 -0
  20. package/lib/components/DataDictionary/components/Layout/components/EntitiesLayout/types.js +1 -0
  21. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.d.ts +2 -0
  22. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.js +6 -0
  23. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.d.ts +9 -0
  24. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.js +26 -0
  25. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/types.d.ts +5 -0
  26. package/lib/components/DataDictionary/components/Layout/components/OutlineLayout/types.js +1 -0
  27. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.d.ts +2 -0
  28. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.js +5 -0
  29. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.d.ts +5 -0
  30. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.js +16 -0
  31. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/types.d.ts +5 -0
  32. package/lib/components/DataDictionary/components/Layout/components/TitleLayout/types.js +1 -0
  33. package/lib/components/DataDictionary/components/Layout/constants.d.ts +5 -0
  34. package/lib/components/DataDictionary/components/Layout/constants.js +5 -0
  35. package/lib/components/DataDictionary/components/Outline/components/ContentsTab/constants.d.ts +2 -0
  36. package/lib/components/DataDictionary/components/Outline/components/ContentsTab/constants.js +5 -0
  37. package/lib/components/DataDictionary/components/Outline/components/ContentsTab/contentsTab.d.ts +1 -0
  38. package/lib/components/DataDictionary/components/Outline/components/ContentsTab/contentsTab.js +6 -0
  39. package/lib/components/DataDictionary/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +3 -0
  40. package/lib/components/DataDictionary/components/Outline/components/ContentsTab/contentsTab.styles.js +7 -0
  41. package/lib/components/DataDictionary/components/Outline/outline.d.ts +2 -0
  42. package/lib/components/DataDictionary/components/Outline/outline.js +6 -0
  43. package/lib/components/DataDictionary/components/Outline/outline.styles.d.ts +3 -0
  44. package/lib/components/DataDictionary/components/Outline/outline.styles.js +19 -0
  45. package/lib/components/DataDictionary/components/Outline/types.d.ts +5 -0
  46. package/lib/components/DataDictionary/components/Outline/types.js +1 -0
  47. package/lib/components/DataDictionary/components/Outline/utils.d.ts +8 -0
  48. package/lib/components/DataDictionary/components/Outline/utils.js +15 -0
  49. package/lib/components/DataDictionary/components/Table/components/BasicCell/basicCell.js +2 -2
  50. package/lib/components/DataDictionary/components/Title/title.d.ts +2 -0
  51. package/lib/components/DataDictionary/components/Title/title.js +3 -0
  52. package/lib/components/DataDictionary/components/Title/title.styles.d.ts +3 -0
  53. package/lib/components/DataDictionary/components/Title/title.styles.js +17 -0
  54. package/lib/components/DataDictionary/dataDictionary.d.ts +2 -2
  55. package/lib/components/DataDictionary/dataDictionary.js +17 -3
  56. package/lib/components/DataDictionary/dataDictionary.styles.d.ts +5 -1
  57. package/lib/components/DataDictionary/dataDictionary.styles.js +16 -3
  58. package/lib/components/DataDictionary/hooks/UseDataDictionary/hook.js +2 -1
  59. package/lib/components/DataDictionary/hooks/UseLayoutSpacing/hook.d.ts +2 -0
  60. package/lib/components/DataDictionary/hooks/UseLayoutSpacing/hook.js +10 -0
  61. package/lib/components/DataDictionary/hooks/UseLayoutSpacing/types.d.ts +7 -0
  62. package/lib/components/DataDictionary/hooks/UseLayoutSpacing/types.js +1 -0
  63. package/lib/components/DataDictionary/types.d.ts +9 -0
  64. package/lib/components/DataDictionary/types.js +1 -0
  65. package/lib/components/Error/error.js +3 -3
  66. package/lib/components/Filter/components/SearchAllFilters/searchAllFilters.js +3 -3
  67. package/lib/components/Index/index.js +3 -4
  68. package/lib/components/Layout/components/ContentLayout/contentLayout.js +7 -7
  69. package/lib/components/Layout/components/Footer/footer.js +4 -1
  70. package/lib/components/Layout/components/Footer/footer.styles.js +1 -0
  71. package/lib/components/Layout/components/Header/header.js +4 -3
  72. package/lib/components/Layout/components/Main/main.js +3 -4
  73. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.d.ts +1 -5
  74. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.js +5 -3
  75. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.d.ts +1 -1
  76. package/lib/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.js +2 -2
  77. package/lib/components/Layout/components/Outline/components/ContentsTab/types.d.ts +5 -0
  78. package/lib/components/Layout/components/Outline/components/ContentsTab/types.js +1 -0
  79. package/lib/components/Layout/components/Outline/hooks/UseHash/hook.d.ts +11 -0
  80. package/lib/components/Layout/components/Outline/hooks/UseHash/hook.js +16 -0
  81. package/lib/components/Layout/components/Outline/hooks/UseHash/types.d.ts +3 -0
  82. package/lib/components/Layout/components/Outline/hooks/UseHash/types.js +1 -0
  83. package/lib/components/Layout/components/Outline/hooks/UseTabs/constants.d.ts +2 -0
  84. package/lib/components/Layout/components/Outline/hooks/UseTabs/hook.d.ts +3 -0
  85. package/lib/components/Layout/components/Outline/hooks/UseTabs/hook.js +24 -0
  86. package/lib/components/Layout/components/Outline/hooks/UseTabs/utils.d.ts +9 -0
  87. package/lib/components/Layout/components/Outline/hooks/UseTabs/utils.js +13 -0
  88. package/lib/components/Layout/components/Outline/outline.d.ts +2 -13
  89. package/lib/components/Layout/components/Outline/outline.js +8 -32
  90. package/lib/components/Layout/components/Outline/outline.styles.d.ts +2 -2
  91. package/lib/components/Layout/components/Outline/outline.styles.js +2 -2
  92. package/lib/components/Layout/components/Outline/types.d.ts +14 -0
  93. package/lib/components/Layout/components/Outline/types.js +1 -0
  94. package/lib/components/Layout/components/Sidebar/components/SidebarPositioner/sidebarPositioner.js +4 -4
  95. package/lib/components/Login/components/Section/components/Warning/warning.js +2 -3
  96. package/lib/components/Table/components/TableCell/components/RowPositionCell/constants.js +2 -2
  97. package/lib/components/common/AnchorLink/anchorLink.d.ts +6 -0
  98. package/lib/components/common/LoginDialog/constants.js +4 -4
  99. package/lib/providers/layoutDimensions/constants.d.ts +2 -0
  100. package/lib/providers/layoutDimensions/constants.js +4 -0
  101. package/lib/providers/layoutDimensions/context.d.ts +2 -0
  102. package/lib/providers/layoutDimensions/context.js +7 -0
  103. package/lib/providers/layoutDimensions/hook.d.ts +2 -0
  104. package/lib/providers/layoutDimensions/hook.js +5 -0
  105. package/lib/providers/layoutDimensions/provider.d.ts +2 -0
  106. package/lib/providers/layoutDimensions/provider.js +14 -0
  107. package/lib/providers/layoutDimensions/types.d.ts +14 -0
  108. package/lib/providers/layoutDimensions/types.js +1 -0
  109. package/lib/styles/common/mui/tab.d.ts +7 -0
  110. package/lib/styles/common/mui/tab.js +9 -0
  111. package/lib/styles/common/mui/tabs.d.ts +9 -0
  112. package/lib/styles/common/mui/tabs.js +11 -0
  113. package/lib/styles/common/mui/typography.d.ts +8 -2
  114. package/lib/styles/common/mui/typography.js +8 -2
  115. package/package.json +1 -1
  116. package/src/common/selectors.ts +6 -3
  117. package/src/components/DataDictionary/components/Entities/constants.ts +3 -1
  118. package/src/components/DataDictionary/components/Entities/entities.tsx +2 -2
  119. package/src/components/DataDictionary/components/Entities/types.ts +2 -0
  120. package/src/components/DataDictionary/components/Entity/entity.styles.ts +12 -0
  121. package/src/components/DataDictionary/components/Entity/entity.tsx +17 -7
  122. package/src/components/DataDictionary/components/Entity/types.ts +2 -0
  123. package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.styles.ts +22 -0
  124. package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/entitiesLayout.tsx +10 -0
  125. package/src/components/DataDictionary/components/Layout/components/EntitiesLayout/types.ts +6 -0
  126. package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.styles.ts +31 -0
  127. package/src/components/DataDictionary/components/Layout/components/OutlineLayout/outlineLayout.tsx +14 -0
  128. package/src/components/DataDictionary/components/Layout/components/OutlineLayout/types.ts +6 -0
  129. package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.styles.ts +18 -0
  130. package/src/components/DataDictionary/components/Layout/components/TitleLayout/titleLayout.tsx +10 -0
  131. package/src/components/DataDictionary/components/Layout/components/TitleLayout/types.ts +6 -0
  132. package/src/components/DataDictionary/components/Layout/constants.ts +5 -0
  133. package/src/components/DataDictionary/components/Outline/components/ContentsTab/constants.ts +7 -0
  134. package/src/components/DataDictionary/components/Outline/components/ContentsTab/contentsTab.styles.ts +8 -0
  135. package/src/components/DataDictionary/components/Outline/components/ContentsTab/contentsTab.tsx +7 -0
  136. package/src/components/DataDictionary/components/Outline/outline.styles.ts +24 -0
  137. package/src/components/DataDictionary/components/Outline/outline.tsx +11 -0
  138. package/src/components/DataDictionary/components/Outline/types.ts +6 -0
  139. package/src/components/DataDictionary/components/Outline/utils.ts +18 -0
  140. package/src/components/DataDictionary/components/Table/components/BasicCell/basicCell.tsx +6 -2
  141. package/src/components/DataDictionary/components/Title/title.styles.ts +18 -0
  142. package/src/components/DataDictionary/components/Title/title.tsx +8 -0
  143. package/src/components/DataDictionary/dataDictionary.styles.ts +17 -3
  144. package/src/components/DataDictionary/dataDictionary.tsx +26 -4
  145. package/src/components/DataDictionary/hooks/UseDataDictionary/hook.ts +2 -1
  146. package/src/components/DataDictionary/hooks/UseLayoutSpacing/hook.ts +12 -0
  147. package/src/components/DataDictionary/hooks/UseLayoutSpacing/types.ts +8 -0
  148. package/src/components/DataDictionary/types.ts +10 -0
  149. package/src/components/Error/error.tsx +3 -5
  150. package/src/components/Filter/components/SearchAllFilters/searchAllFilters.tsx +3 -3
  151. package/src/components/Index/index.tsx +3 -4
  152. package/src/components/Layout/components/ContentLayout/contentLayout.tsx +7 -9
  153. package/src/components/Layout/components/Footer/footer.styles.ts +1 -0
  154. package/src/components/Layout/components/Footer/footer.tsx +5 -0
  155. package/src/components/Layout/components/Header/header.tsx +9 -3
  156. package/src/components/Layout/components/Main/main.tsx +3 -4
  157. package/src/components/Layout/components/Outline/components/ContentsTab/contentsTab.styles.ts +2 -2
  158. package/src/components/Layout/components/Outline/components/ContentsTab/contentsTab.tsx +8 -11
  159. package/src/components/Layout/components/Outline/components/ContentsTab/types.ts +8 -0
  160. package/src/components/Layout/components/Outline/hooks/UseHash/hook.ts +17 -0
  161. package/src/components/Layout/components/Outline/hooks/UseHash/types.ts +3 -0
  162. package/src/components/Layout/components/Outline/hooks/UseTabs/constants.ts +3 -0
  163. package/src/components/Layout/components/Outline/hooks/UseTabs/hook.ts +32 -0
  164. package/src/components/Layout/components/Outline/hooks/UseTabs/utils.ts +18 -0
  165. package/src/components/Layout/components/Outline/outline.styles.ts +2 -2
  166. package/src/components/Layout/components/Outline/outline.tsx +22 -59
  167. package/src/components/Layout/components/Outline/types.ts +16 -0
  168. package/src/components/Layout/components/Sidebar/components/SidebarPositioner/sidebarPositioner.tsx +7 -6
  169. package/src/components/Login/components/Section/components/Warning/warning.tsx +3 -4
  170. package/src/components/Table/components/TableCell/components/RowPositionCell/constants.ts +2 -2
  171. package/src/components/common/AnchorLink/anchorLink.tsx +7 -0
  172. package/src/components/common/LoginDialog/constants.ts +4 -4
  173. package/src/providers/layoutDimensions/constants.ts +6 -0
  174. package/src/providers/layoutDimensions/context.tsx +10 -0
  175. package/src/providers/layoutDimensions/hook.ts +7 -0
  176. package/src/providers/layoutDimensions/provider.tsx +29 -0
  177. package/src/providers/layoutDimensions/types.ts +17 -0
  178. package/src/styles/common/mui/tab.ts +16 -0
  179. package/src/styles/common/mui/tabs.ts +20 -0
  180. package/src/styles/common/mui/typography.ts +14 -2
  181. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +0 -5
  182. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +0 -19
  183. package/lib/components/Layout/components/Outline/common/constants.d.ts +0 -2
  184. package/lib/hooks/useLayoutState.d.ts +0 -6
  185. package/lib/hooks/useLayoutState.js +0 -9
  186. package/lib/providers/layoutState.d.ts +0 -40
  187. package/lib/providers/layoutState.js +0 -47
  188. package/src/components/Layout/components/Header/hooks/useMeasureHeader.ts +0 -28
  189. package/src/components/Layout/components/Outline/common/constants.ts +0 -3
  190. package/src/hooks/useLayoutState.ts +0 -13
  191. package/src/providers/layoutState.tsx +0 -94
  192. /package/lib/components/Layout/components/Outline/{common → hooks/UseTabs}/constants.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { useRouter } from "next/router";
2
2
  import React, { ReactNode } from "react";
3
- import { useLayoutState } from "../../../../hooks/useLayoutState";
3
+ import { useLayoutDimensions } from "../../../../providers/layoutDimensions/hook";
4
4
  import { BaseComponentProps } from "../../../types";
5
5
  import { LayoutStyle } from "./common/entities";
6
6
  import {
@@ -29,9 +29,7 @@ export const ContentLayout = ({
29
29
  outline,
30
30
  }: BaseComponentProps & ContentLayoutProps): JSX.Element => {
31
31
  const { asPath } = useRouter();
32
- const {
33
- layoutState: { headerHeight },
34
- } = useLayoutState();
32
+ const { dimensions } = useLayoutDimensions();
35
33
  return (
36
34
  <Layout
37
35
  className={className}
@@ -40,16 +38,16 @@ export const ContentLayout = ({
40
38
  >
41
39
  {navigation && (
42
40
  <NavigationGrid
43
- headerHeight={headerHeight}
41
+ headerHeight={dimensions.header.height}
44
42
  panelColor={layoutStyle?.navigation}
45
43
  >
46
- <Positioner headerHeight={headerHeight}>
44
+ <Positioner headerHeight={dimensions.header.height}>
47
45
  <Navigation>{navigation}</Navigation>
48
46
  </Positioner>
49
47
  </NavigationGrid>
50
48
  )}
51
49
  <ContentGrid
52
- headerHeight={headerHeight}
50
+ headerHeight={dimensions.header.height}
53
51
  panelColor={layoutStyle?.content}
54
52
  >
55
53
  <Content>{content}</Content>
@@ -57,10 +55,10 @@ export const ContentLayout = ({
57
55
  {outline && (
58
56
  <OutlineGrid
59
57
  key={getOutlineKey(asPath)}
60
- headerHeight={headerHeight}
58
+ headerHeight={dimensions.header.height}
61
59
  panelColor={layoutStyle?.outline}
62
60
  >
63
- <Positioner headerHeight={headerHeight}>
61
+ <Positioner headerHeight={dimensions.header.height}>
64
62
  <Outline>{outline}</Outline>
65
63
  </Positioner>
66
64
  </OutlineGrid>
@@ -8,6 +8,7 @@ import { Link as DXLink } from "../../../Links/components/Link/link";
8
8
 
9
9
  export const AppBar = styled(MAppBar)`
10
10
  padding: 16px 0;
11
+ z-index: 1; /* required for outline or navigation overflow */
11
12
 
12
13
  .MuiToolbar-root {
13
14
  align-items: flex-start;
@@ -1,5 +1,7 @@
1
1
  import { Toolbar } from "@mui/material";
2
2
  import React, { ReactNode } from "react";
3
+ import { SELECTOR } from "../../../../common/selectors";
4
+ import { useLayoutDimensions } from "../../../../providers/layoutDimensions/hook";
3
5
  import { Social } from "../../../common/Socials/socials";
4
6
  import { ANCHOR_TARGET } from "../../../Links/common/entities";
5
7
  import { isNodeBoolean } from "../../../utils";
@@ -22,11 +24,14 @@ export const Footer = ({
22
24
  socials,
23
25
  versionInfo,
24
26
  }: FooterProps): JSX.Element => {
27
+ const { footerRef } = useLayoutDimensions();
25
28
  return (
26
29
  <AppBar
27
30
  className={className}
28
31
  color="inherit"
29
32
  component="footer"
33
+ id={SELECTOR.FOOTER}
34
+ ref={footerRef}
30
35
  variant="footer"
31
36
  >
32
37
  <Toolbar variant="dense">
@@ -1,7 +1,9 @@
1
1
  import { Fade, Toolbar } from "@mui/material";
2
2
  import { usePathname } from "next/navigation";
3
3
  import React, { ReactNode } from "react";
4
+ import { SELECTOR } from "../../../../common/selectors";
4
5
  import { ComponentsConfig } from "../../../../config/entities";
6
+ import { useLayoutDimensions } from "../../../../providers/layoutDimensions/hook";
5
7
  import {
6
8
  APP_BAR_PROPS,
7
9
  FADE_TRANSITION_PROPS,
@@ -29,7 +31,6 @@ import { Socials } from "./components/Content/components/Socials/socials.styles"
29
31
  import { AppBar, Center, Left, Right } from "./header.styles";
30
32
  import { useHeaderNavigation } from "./hooks/useHeaderNavigation";
31
33
  import { useHeaderVisibility } from "./hooks/useHeaderVisibility";
32
- import { useMeasureHeader } from "./hooks/useMeasureHeader";
33
34
  import { useMenu } from "./hooks/useMenu";
34
35
 
35
36
  export interface HeaderProps {
@@ -48,7 +49,7 @@ export interface HeaderProps {
48
49
  export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
49
50
  const { navigation } = useHeaderNavigation(headerProps);
50
51
  const { isIn } = useHeaderVisibility({ ...headerProps, navigation });
51
- const { headerRef } = useMeasureHeader();
52
+ const { headerRef } = useLayoutDimensions();
52
53
  const { onClose, onOpen, open } = useMenu();
53
54
  const pathname = usePathname() ?? "";
54
55
  const {
@@ -68,7 +69,12 @@ export const Header = ({ ...headerProps }: HeaderProps): JSX.Element => {
68
69
  pathname,
69
70
  };
70
71
  return (
71
- <AppBar {...APP_BAR_PROPS} ref={headerRef} className={className}>
72
+ <AppBar
73
+ {...APP_BAR_PROPS}
74
+ className={className}
75
+ id={SELECTOR.HEADER}
76
+ ref={headerRef}
77
+ >
72
78
  {/* Announcements */}
73
79
  <Announcements announcements={announcements} />
74
80
  {/* Toolbar */}
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from "react";
2
- import { useLayoutState } from "../../../../hooks/useLayoutState";
2
+ import { useLayoutDimensions } from "../../../../providers/layoutDimensions/hook";
3
3
  import { MainWithOffset } from "./main.styles";
4
4
 
5
5
  export interface MainProps {
@@ -8,10 +8,9 @@ export interface MainProps {
8
8
  }
9
9
 
10
10
  export const Main = ({ children, className }: MainProps): JSX.Element => {
11
- const { layoutState } = useLayoutState();
12
- const { headerHeight } = layoutState;
11
+ const { dimensions } = useLayoutDimensions();
13
12
  return (
14
- <MainWithOffset className={className} offset={headerHeight}>
13
+ <MainWithOffset className={className} offset={dimensions.header.height}>
15
14
  {children}
16
15
  </MainWithOffset>
17
16
  );
@@ -1,10 +1,10 @@
1
1
  import styled from "@emotion/styled";
2
- import { Tab as MTab } from "@mui/material";
2
+ import { Tab } from "@mui/material";
3
3
  import { inkLight } from "../../../../../../styles/common/mixins/colors";
4
4
  import { textUppercase500 } from "../../../../../../styles/common/mixins/fonts";
5
5
  import { tab } from "../../outline.styles";
6
6
 
7
- export const Tab = styled(MTab)`
7
+ export const StyledTab = styled(Tab)`
8
8
  ${tab};
9
9
 
10
10
  && {
@@ -1,24 +1,21 @@
1
- import { TabProps as MTabProps } from "@mui/material";
2
1
  import React from "react";
2
+ import { FONT_SIZE } from "../../../../../../styles/common/mui/icon";
3
+ import { TAB_PROPS } from "../../../../../../styles/common/mui/tab";
3
4
  import { Segment } from "../../../../../common/CustomIcon/components/Segment/segment";
4
- import { Tab } from "./contentsTab.styles";
5
-
6
- export interface ContentsTabProps extends Omit<MTabProps, "value"> {
7
- className?: string;
8
- value: string;
9
- }
5
+ import { StyledTab } from "./contentsTab.styles";
6
+ import { ContentsTabProps } from "./types";
10
7
 
11
8
  export const ContentsTab = ({
12
9
  className,
13
10
  value,
14
- ...props /* Spread props to allow for Mui Tab specific prop overrides. */
11
+ ...props /* MuiTabProps. */
15
12
  }: ContentsTabProps): JSX.Element => {
16
13
  return (
17
- <Tab
14
+ <StyledTab
18
15
  className={className}
19
16
  label="Contents"
20
- icon={<Segment fontSize="small" />}
21
- iconPosition="start"
17
+ icon={<Segment fontSize={FONT_SIZE.SMALL} />}
18
+ iconPosition={TAB_PROPS.ICON_POSITION.START}
22
19
  value={value}
23
20
  {...props}
24
21
  />
@@ -0,0 +1,8 @@
1
+ import { TabProps } from "@mui/material";
2
+ import { BaseComponentProps } from "../../../../../types";
3
+
4
+ export interface ContentsTabProps
5
+ extends BaseComponentProps,
6
+ Omit<TabProps, "value"> {
7
+ value: string;
8
+ }
@@ -0,0 +1,17 @@
1
+ import { isSSR } from "../../../../../../utils/ssr";
2
+ import { UseHash } from "./types";
3
+
4
+ /**
5
+ * Hook to get the current URL hash without the leading '#' character.
6
+ *
7
+ * @description
8
+ * Extracts the hash from window.location.hash and removes the leading '#'.
9
+ * Returns empty string when running in SSR environment.
10
+ *
11
+ * @returns Object containing the hash without leading '#', or empty string if SSR.
12
+ */
13
+ export function useHash(): UseHash {
14
+ if (isSSR()) return { hash: "" };
15
+ const { hash } = window.location;
16
+ return { hash: hash.replace(/^#/, "") };
17
+ }
@@ -0,0 +1,3 @@
1
+ export interface UseHash {
2
+ hash: string;
3
+ }
@@ -0,0 +1,3 @@
1
+ import { TabProps } from "@mui/material";
2
+
3
+ export const DEFAULT_TAB_VALUE: TabProps["value"] = "";
@@ -0,0 +1,32 @@
1
+ import { TabsProps } from "@mui/material";
2
+ import Router from "next/router";
3
+ import { SyntheticEvent, useCallback, useEffect, useState } from "react";
4
+ import { TABS_PROPS } from "../../../../../../styles/common/mui/tabs";
5
+ import { OutlineItem } from "../../types";
6
+ import { useHash } from "../UseHash/hook";
7
+ import { DEFAULT_TAB_VALUE } from "./constants";
8
+ import { getNextValue } from "./utils";
9
+
10
+ export function useTabs(
11
+ outline: OutlineItem[]
12
+ ): Pick<TabsProps, "indicatorColor" | "onChange" | "orientation" | "value"> {
13
+ const [value, setValue] = useState<TabsProps["value"]>(DEFAULT_TAB_VALUE);
14
+ const { hash } = useHash();
15
+
16
+ const onChange = useCallback((_event: SyntheticEvent, hash: string): void => {
17
+ Router.push({ hash });
18
+ }, []);
19
+
20
+ useEffect(() => {
21
+ setValue(getNextValue(hash, outline));
22
+ }, [hash, outline]);
23
+
24
+ return {
25
+ indicatorColor: value
26
+ ? TABS_PROPS.INDICATOR_COLOR.PRIMARY
27
+ : TABS_PROPS.INDICATOR_COLOR.TRANSPARENT,
28
+ onChange,
29
+ orientation: TABS_PROPS.ORIENTATION.VERTICAL,
30
+ value,
31
+ };
32
+ }
@@ -0,0 +1,18 @@
1
+ import { TabsProps } from "@mui/material";
2
+ import { OutlineItem } from "../../types";
3
+ import { DEFAULT_TAB_VALUE } from "./constants";
4
+
5
+ /**
6
+ * Returns the tab value for navigation.
7
+ * @param hash - The current hash from the URL.
8
+ * @param outlineItems - Outline items.
9
+ * @returns The item's hash if found and enabled, otherwise returns the default tab value.
10
+ */
11
+ export function getNextValue(
12
+ hash: string,
13
+ outlineItems: OutlineItem[]
14
+ ): TabsProps["value"] {
15
+ const item = outlineItems.find((item) => item.hash === hash);
16
+ if (!item || item.disabled) return DEFAULT_TAB_VALUE;
17
+ return item.hash;
18
+ }
@@ -24,7 +24,7 @@ export const tab = css`
24
24
  }
25
25
  `;
26
26
 
27
- export const Tabs = styled(MTabs)`
27
+ export const StyledTabs = styled(MTabs)`
28
28
  align-self: flex-start;
29
29
  box-shadow: inset 1px 0 ${smokeMain};
30
30
  margin: 0;
@@ -46,7 +46,7 @@ export const Tabs = styled(MTabs)`
46
46
  }
47
47
  `;
48
48
 
49
- export const Tab = styled(MTab, {
49
+ export const StyledTab = styled(MTab, {
50
50
  shouldForwardProp: (prop) => prop !== "depth",
51
51
  })<Props>`
52
52
  ${tab};
@@ -1,72 +1,35 @@
1
- import { useRouter } from "next/router";
2
- import React, { ElementType, SyntheticEvent, useEffect, useState } from "react";
3
- import { DEFAULT_TAB_VALUE } from "./common/constants";
4
- import { ContentsTabProps } from "./components/ContentsTab/contentsTab";
5
- import { Tab, Tabs } from "./outline.styles";
6
-
7
- export interface OutlineItem {
8
- depth: number;
9
- hash: string;
10
- value: string;
11
- }
12
-
13
- export interface OutlineProps {
14
- className?: string;
15
- Contents: ElementType<ContentsTabProps>;
16
- outline: OutlineItem[];
17
- }
1
+ import React from "react";
2
+ import { DEFAULT_TAB_VALUE } from "./hooks/UseTabs/constants";
3
+ import { useTabs } from "./hooks/UseTabs/hook";
4
+ import { StyledTab, StyledTabs } from "./outline.styles";
5
+ import { OutlineProps } from "./types";
18
6
 
19
7
  export const Outline = ({
20
8
  className,
21
9
  Contents,
22
10
  outline,
23
- ...props /* Spread props to allow for Mui Tabs specific prop overrides. */
24
- }: OutlineProps): JSX.Element => {
25
- const { asPath, push } = useRouter();
26
- const [activeTab, setActiveTab] = useState<string>("");
27
-
28
- // Callback fired when selected tab value changes.
29
- const handleChange = (
30
- _event: SyntheticEvent<Element, Event>,
31
- tabValue: string
32
- ): void => {
33
- push(`#${tabValue}`);
34
- };
35
-
36
- // Update active tab when path changes.
37
- useEffect(() => {
38
- setActiveTab(getActiveTab(outline, asPath));
39
- }, [asPath, outline]);
40
-
11
+ ...props /* MuiTabsProps */
12
+ }: OutlineProps): JSX.Element | null => {
13
+ const { indicatorColor, onChange, orientation, value } = useTabs(outline);
41
14
  return (
42
- <Tabs
15
+ <StyledTabs
43
16
  className={className}
44
- indicatorColor={activeTab ? "primary" : "transparent"}
45
- onChange={handleChange}
46
- orientation="vertical"
47
- value={activeTab}
17
+ indicatorColor={indicatorColor}
18
+ onChange={onChange}
19
+ orientation={orientation}
20
+ value={value}
48
21
  {...props}
49
22
  >
50
23
  <Contents value={DEFAULT_TAB_VALUE} />
51
- {outline.map(({ depth, hash, value }) => (
52
- <Tab key={hash} depth={depth} label={value} value={hash} />
24
+ {outline.map(({ depth, disabled, hash, value }) => (
25
+ <StyledTab
26
+ depth={depth}
27
+ disabled={disabled}
28
+ key={hash}
29
+ label={value}
30
+ value={hash}
31
+ />
53
32
  ))}
54
- </Tabs>
33
+ </StyledTabs>
55
34
  );
56
35
  };
57
-
58
- /**
59
- * Initializes active tab.
60
- * @param outline - Outline items.
61
- * @param asPath - Current path.
62
- * @returns active tab.
63
- */
64
- function getActiveTab(outline: OutlineItem[], asPath: string): string {
65
- if (asPath.includes("#")) {
66
- const hashLink = asPath.split("#")[1];
67
- if (outline.some(({ hash }) => hash === hashLink)) {
68
- return hashLink;
69
- }
70
- }
71
- return DEFAULT_TAB_VALUE;
72
- }
@@ -0,0 +1,16 @@
1
+ import { TabsProps } from "@mui/material";
2
+ import { ElementType } from "react";
3
+ import { BaseComponentProps } from "../../../types";
4
+ import { ContentsTabProps } from "./components/ContentsTab/types";
5
+
6
+ export interface OutlineItem {
7
+ depth: number;
8
+ disabled?: boolean;
9
+ hash: string;
10
+ value: string;
11
+ }
12
+
13
+ export interface OutlineProps extends BaseComponentProps, TabsProps {
14
+ Contents: ElementType<ContentsTabProps>;
15
+ outline: OutlineItem[];
16
+ }
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from "react";
2
- import { SIDEBAR_POSITIONER } from "../../../../../../common/selectors";
3
- import { useLayoutState } from "../../../../../../hooks/useLayoutState";
2
+ import { SELECTOR } from "../../../../../../common/selectors";
3
+ import { useLayoutDimensions } from "../../../../../../providers/layoutDimensions/hook";
4
4
  import { SidebarPositioner as Positioner } from "./sidebarPositioner.styles";
5
5
 
6
6
  export interface SidebarPositionerProps {
@@ -10,11 +10,12 @@ export interface SidebarPositionerProps {
10
10
  export const SidebarPositioner = ({
11
11
  children,
12
12
  }: SidebarPositionerProps): JSX.Element => {
13
- const {
14
- layoutState: { headerHeight },
15
- } = useLayoutState();
13
+ const { dimensions } = useLayoutDimensions();
16
14
  return (
17
- <Positioner headerHeight={headerHeight} id={SIDEBAR_POSITIONER}>
15
+ <Positioner
16
+ headerHeight={dimensions.header.height}
17
+ id={SELECTOR.SIDEBAR_POSITIONER}
18
+ >
18
19
  {children}
19
20
  </Positioner>
20
21
  );
@@ -1,7 +1,6 @@
1
1
  import { Typography, TypographyProps } from "@mui/material";
2
2
  import React from "react";
3
- import { COLOR } from "../../../../../../styles/common/mui/typography";
4
- import { TEXT_BODY_SMALL_400 } from "../../../../../../theme/common/typography";
3
+ import { TYPOGRAPHY_PROPS } from "../../../../../../styles/common/mui/typography";
5
4
  import { BaseComponentProps } from "../../../../../types";
6
5
 
7
6
  export const Warning = ({
@@ -13,9 +12,9 @@ export const Warning = ({
13
12
  return (
14
13
  <Typography
15
14
  className={className}
16
- color={COLOR.INK_LIGHT}
15
+ color={TYPOGRAPHY_PROPS.COLOR.INK_LIGHT}
17
16
  mt={6}
18
- variant={TEXT_BODY_SMALL_400}
17
+ variant={TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_SMALL_400}
19
18
  {...props}
20
19
  >
21
20
  {children}
@@ -1,7 +1,7 @@
1
1
  import { TypographyOwnProps } from "@mui/material";
2
- import { VARIANT } from "../../../../../../styles/common/mui/typography";
2
+ import { TYPOGRAPHY_PROPS as MUI_TYPOGRAPHY_PROPS } from "../../../../../../styles/common/mui/typography";
3
3
 
4
4
  export const TYPOGRAPHY_PROPS: Partial<TypographyOwnProps> = {
5
5
  sx: { marginRight: -2, paddingLeft: 2 },
6
- variant: VARIANT.INHERIT,
6
+ variant: MUI_TYPOGRAPHY_PROPS.VARIANT.INHERIT,
7
7
  };
@@ -2,6 +2,13 @@ import LinkRoundedIcon from "@mui/icons-material/LinkRounded";
2
2
  import React from "react";
3
3
  import { AnchorLink as Link } from "./anchorLink.styles";
4
4
 
5
+ /**
6
+ * An anchor link component that provides deep linking functionality.
7
+ * @important The parent element must have `position: relative` CSS property
8
+ * to ensure proper positioning of the anchor link icon, and hover pseudo-class
9
+ * to change opacity of the icon.
10
+ */
11
+
5
12
  interface AnchorLinkProps {
6
13
  anchorLink: string;
7
14
  className?: string;
@@ -6,12 +6,12 @@ import {
6
6
  IconProps,
7
7
  } from "@mui/material";
8
8
  import { FONT_SIZE } from "../../../styles/common/mui/icon";
9
- import { COLOR, VARIANT } from "../../../styles/common/mui/typography";
9
+ import { TYPOGRAPHY_PROPS } from "../../../styles/common/mui/typography";
10
10
 
11
11
  export const DIALOG_CONTENT_TEXT_PROPS: DialogContentTextProps = {
12
- color: COLOR.INK_LIGHT,
12
+ color: TYPOGRAPHY_PROPS.COLOR.INK_LIGHT,
13
13
  component: "div",
14
- variant: VARIANT.TEXT_BODY_400,
14
+ variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_400,
15
15
  };
16
16
 
17
17
  export const DIALOG_PROPS: Partial<DialogProps> = {
@@ -19,7 +19,7 @@ export const DIALOG_PROPS: Partial<DialogProps> = {
19
19
  };
20
20
 
21
21
  export const DIALOG_TITLE_PROPS: DialogTitleProps = {
22
- variant: VARIANT.TEXT_HEADING_SMALL,
22
+ variant: TYPOGRAPHY_PROPS.VARIANT.TEXT_HEADING_SMALL,
23
23
  };
24
24
 
25
25
  export const ICON_BUTTON_PROPS: IconButtonProps = {
@@ -0,0 +1,6 @@
1
+ import { LayoutDimensions } from "./types";
2
+
3
+ export const DEFAULT_LAYOUT_DIMENSIONS: LayoutDimensions = {
4
+ footer: { height: 0 },
5
+ header: { height: 0 },
6
+ };
@@ -0,0 +1,10 @@
1
+ import { createContext } from "react";
2
+ import { DEFAULT_LAYOUT_DIMENSIONS } from "./constants";
3
+ import { LayoutDimensionsContextProps } from "./types";
4
+
5
+ export const LayoutDimensionsContext =
6
+ createContext<LayoutDimensionsContextProps>({
7
+ dimensions: DEFAULT_LAYOUT_DIMENSIONS,
8
+ footerRef: null,
9
+ headerRef: null,
10
+ });
@@ -0,0 +1,7 @@
1
+ import { useContext } from "react";
2
+ import { LayoutDimensionsContext } from "./context";
3
+ import { LayoutDimensionsContextProps } from "./types";
4
+
5
+ export const useLayoutDimensions = (): LayoutDimensionsContextProps => {
6
+ return useContext<LayoutDimensionsContextProps>(LayoutDimensionsContext);
7
+ };
@@ -0,0 +1,29 @@
1
+ import React, { useRef } from "react";
2
+ import {
3
+ getBorderBoxSizeHeight,
4
+ useResizeObserver,
5
+ } from "../../hooks/useResizeObserver";
6
+ import { LayoutDimensionsContext } from "./context";
7
+ import { LayoutDimensions, LayoutDimensionsProviderProps } from "./types";
8
+
9
+ export const LayoutDimensionsProvider = ({
10
+ children,
11
+ }: LayoutDimensionsProviderProps): JSX.Element => {
12
+ const footerRef = useRef<HTMLElement>(null);
13
+ const headerRef = useRef<HTMLElement>(null);
14
+ const footerRect = useResizeObserver(footerRef, getBorderBoxSizeHeight);
15
+ const headerRect = useResizeObserver(headerRef, getBorderBoxSizeHeight);
16
+
17
+ const dimensions: LayoutDimensions = {
18
+ footer: { height: footerRect?.height ?? 0 },
19
+ header: { height: headerRect?.height ?? 0 },
20
+ };
21
+
22
+ return (
23
+ <LayoutDimensionsContext.Provider
24
+ value={{ dimensions, footerRef, headerRef }}
25
+ >
26
+ {children}
27
+ </LayoutDimensionsContext.Provider>
28
+ );
29
+ };
@@ -0,0 +1,17 @@
1
+ import { ReactNode, RefObject } from "react";
2
+ import { ElementRect } from "../../hooks/useResizeObserver";
3
+
4
+ export interface LayoutDimensions {
5
+ footer: Pick<ElementRect, "height">;
6
+ header: Pick<ElementRect, "height">;
7
+ }
8
+
9
+ export interface LayoutDimensionsContextProps {
10
+ dimensions: LayoutDimensions;
11
+ footerRef: RefObject<HTMLElement> | null;
12
+ headerRef: RefObject<HTMLElement> | null;
13
+ }
14
+
15
+ export interface LayoutDimensionsProviderProps {
16
+ children: ReactNode | ReactNode[];
17
+ }
@@ -0,0 +1,16 @@
1
+ import { TabProps } from "@mui/material";
2
+
3
+ type TabPropsOptions = {
4
+ ICON_POSITION: typeof ICON_POSITION;
5
+ };
6
+
7
+ const ICON_POSITION: Record<string, TabProps["iconPosition"]> = {
8
+ BOTTOM: "bottom",
9
+ END: "end",
10
+ START: "start",
11
+ TOP: "top",
12
+ };
13
+
14
+ export const TAB_PROPS: TabPropsOptions = {
15
+ ICON_POSITION,
16
+ };
@@ -0,0 +1,20 @@
1
+ import { TabsProps } from "@mui/material";
2
+
3
+ type TabsPropsOptions = {
4
+ INDICATOR_COLOR: typeof INDICATOR_COLOR;
5
+ ORIENTATION: typeof ORIENTATION;
6
+ };
7
+
8
+ const INDICATOR_COLOR: Record<string, TabsProps["indicatorColor"]> = {
9
+ PRIMARY: "primary",
10
+ TRANSPARENT: "transparent",
11
+ };
12
+
13
+ const ORIENTATION: Record<string, TabsProps["orientation"]> = {
14
+ VERTICAL: "vertical",
15
+ };
16
+
17
+ export const TABS_PROPS: TabsPropsOptions = {
18
+ INDICATOR_COLOR,
19
+ ORIENTATION,
20
+ };
@@ -1,14 +1,26 @@
1
1
  import { TypographyOwnProps } from "@mui/material";
2
2
 
3
- export const COLOR: Record<string, TypographyOwnProps["color"]> = {
3
+ type TypographyPropsOptions = {
4
+ COLOR: typeof COLOR;
5
+ VARIANT: typeof VARIANT;
6
+ };
7
+
8
+ const COLOR: Record<string, TypographyOwnProps["color"]> = {
4
9
  INHERIT: "inherit",
5
10
  INK_LIGHT: "ink.light",
6
11
  INK_MAIN: "ink.main",
7
12
  };
8
13
 
9
- export const VARIANT: Record<string, TypographyOwnProps["variant"]> = {
14
+ const VARIANT: Record<string, TypographyOwnProps["variant"]> = {
10
15
  INHERIT: "inherit",
11
16
  TEXT_BODY_400: "text-body-400",
12
17
  TEXT_BODY_400_2_LINES: "text-body-400-2lines",
18
+ TEXT_BODY_SMALL_400: "text-body-small-400",
19
+ TEXT_HEADING_LARGE: "text-heading-large",
13
20
  TEXT_HEADING_SMALL: "text-heading-small",
14
21
  };
22
+
23
+ export const TYPOGRAPHY_PROPS: TypographyPropsOptions = {
24
+ COLOR,
25
+ VARIANT,
26
+ };