@databiosphere/findable-ui 8.0.2 → 9.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 (126) hide show
  1. package/lib/components/Export/components/ExportToTerra/components/ExportToTerraReady/exportToTerraReady.js +2 -2
  2. package/lib/components/Export/components/ExportToTerra/components/TerraSetUpForm/components/FormStep/components/AcceptTerraTOS/acceptTerraTOS.js +2 -2
  3. package/lib/components/Export/components/ExportToTerra/components/TerraSetUpForm/components/FormStep/components/ConnectTerraToNIHAccount/connectTerraToNIHAccount.js +2 -2
  4. package/lib/components/Export/components/ExportToTerra/components/TerraSetUpForm/components/FormStep/components/CreateTerraAccount/createTerraAccount.js +2 -2
  5. package/lib/components/Filter/components/Filter/filter.js +2 -3
  6. package/lib/components/Filter/components/Filter/filter.styles.d.ts +3 -0
  7. package/lib/components/Filter/components/Filter/filter.styles.js +8 -1
  8. package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
  9. package/lib/components/Index/components/AzulFileDownload/azulFileDownload.js +5 -5
  10. package/lib/components/Index/components/AzulFileDownload/azulFileDownload.styles.d.ts +3 -0
  11. package/lib/components/Index/components/AzulFileDownload/azulFileDownload.styles.js +5 -0
  12. package/lib/components/Layout/components/ContentLayout/contentLayout.js +5 -3
  13. package/lib/components/Layout/components/ContentLayout/contentLayout.styles.d.ts +4 -0
  14. package/lib/components/Layout/components/ContentLayout/contentLayout.styles.js +7 -2
  15. package/lib/components/Layout/components/Footer/footer.js +1 -2
  16. package/lib/components/Layout/components/Footer/footer.styles.js +6 -1
  17. package/lib/components/Layout/components/Header/common/entities.d.ts +4 -0
  18. package/lib/components/Layout/components/Header/common/entities.js +5 -1
  19. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +1 -1
  20. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +9 -7
  21. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/common/constants.d.ts +4 -0
  22. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/common/constants.js +4 -0
  23. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/common/utils.d.ts +8 -0
  24. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/common/utils.js +12 -0
  25. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/searchBar.js +23 -7
  26. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/searchBar.styles.js +4 -3
  27. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +1 -1
  28. package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.js +2 -5
  29. package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.styles.d.ts +3 -0
  30. package/lib/components/Layout/components/Header/components/Content/components/Logo/logo.styles.js +11 -0
  31. package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.d.ts +15 -0
  32. package/lib/components/Layout/components/Header/components/Content/components/Navigation/common/utils.js +23 -0
  33. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationButtonLabel/navigationButtonLabel.d.ts +5 -0
  34. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationButtonLabel/navigationButtonLabel.js +5 -0
  35. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.js +3 -4
  36. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.styles.d.ts +3 -0
  37. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.styles.js +23 -2
  38. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/common/constants.d.ts +4 -0
  39. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/common/constants.js +19 -0
  40. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.d.ts +2 -1
  41. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.js +20 -19
  42. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.d.ts +30 -0
  43. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.js +16 -1
  44. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.js +13 -7
  45. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.d.ts +2 -0
  46. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +11 -6
  47. package/lib/components/Layout/components/Header/components/Content/components/Slogan/slogan.styles.js +3 -1
  48. package/lib/components/Layout/components/Header/header.styles.js +7 -0
  49. package/lib/components/Layout/components/Nav/nav.styles.js +6 -0
  50. package/lib/components/Layout/components/Sidebar/components/SidebarDrawer/sidebarDrawer.js +2 -3
  51. package/lib/components/Layout/components/Sidebar/components/SidebarDrawer/sidebarDrawer.styles.d.ts +3 -0
  52. package/lib/components/Layout/components/Sidebar/components/SidebarDrawer/sidebarDrawer.styles.js +8 -1
  53. package/lib/components/Layout/components/Sidebar/components/SidebarPositioner/sidebarPositioner.styles.js +1 -1
  54. package/lib/components/Layout/components/Sidebar/sidebar.styles.js +2 -1
  55. package/lib/components/Links/common/entities.d.ts +4 -0
  56. package/lib/components/Links/common/entities.js +5 -0
  57. package/lib/components/Links/common/utils.js +1 -1
  58. package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +2 -2
  59. package/lib/components/Links/components/Link/link.d.ts +1 -1
  60. package/lib/components/Links/components/Link/link.js +5 -5
  61. package/lib/components/Table/components/Pagination/pagination.js +3 -3
  62. package/lib/components/common/Button/components/CallToActionButton/callToActionButton.js +2 -2
  63. package/lib/components/common/Button/components/HelpIconButton/helpIconButton.js +3 -3
  64. package/lib/components/common/Card/components/CardActionArea/cardActionArea.js +2 -2
  65. package/lib/components/common/IconButton/iconButton.styles.d.ts +0 -15
  66. package/lib/components/common/IconButton/iconButton.styles.js +0 -82
  67. package/lib/components/common/Socials/socials.d.ts +1 -1
  68. package/lib/components/common/Socials/socials.js +4 -5
  69. package/lib/components/common/Socials/socials.styles.d.ts +1 -0
  70. package/lib/components/common/Socials/socials.styles.js +9 -0
  71. package/lib/hooks/useMenuWithPosition.d.ts +14 -0
  72. package/lib/hooks/useMenuWithPosition.js +33 -0
  73. package/lib/theme/common/components.js +59 -1
  74. package/package.json +1 -1
  75. package/src/components/Export/components/ExportToTerra/components/ExportToTerraReady/exportToTerraReady.tsx +9 -2
  76. package/src/components/Export/components/ExportToTerra/components/TerraSetUpForm/components/FormStep/components/AcceptTerraTOS/acceptTerraTOS.tsx +9 -2
  77. package/src/components/Export/components/ExportToTerra/components/TerraSetUpForm/components/FormStep/components/ConnectTerraToNIHAccount/connectTerraToNIHAccount.tsx +5 -2
  78. package/src/components/Export/components/ExportToTerra/components/TerraSetUpForm/components/FormStep/components/CreateTerraAccount/createTerraAccount.tsx +9 -2
  79. package/src/components/Filter/components/Filter/filter.styles.ts +9 -1
  80. package/src/components/Filter/components/Filter/filter.tsx +2 -3
  81. package/src/components/Index/components/AzulFileDownload/azulFileDownload.styles.ts +6 -0
  82. package/src/components/Index/components/AzulFileDownload/azulFileDownload.tsx +13 -12
  83. package/src/components/Layout/components/ContentLayout/contentLayout.styles.ts +9 -6
  84. package/src/components/Layout/components/ContentLayout/contentLayout.tsx +9 -4
  85. package/src/components/Layout/components/Footer/footer.styles.ts +6 -1
  86. package/src/components/Layout/components/Footer/footer.tsx +1 -8
  87. package/src/components/Layout/components/Header/common/entities.ts +5 -0
  88. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +23 -20
  89. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/common/constants.ts +4 -0
  90. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/common/utils.ts +17 -0
  91. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/searchBar.styles.ts +7 -3
  92. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchBar/searchBar.tsx +41 -16
  93. package/src/components/Layout/components/Header/components/Content/components/Logo/logo.styles.ts +12 -0
  94. package/src/components/Layout/components/Header/components/Content/components/Logo/logo.tsx +6 -18
  95. package/src/components/Layout/components/Header/components/Content/components/Navigation/common/utils.ts +27 -0
  96. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationButtonLabel/navigationButtonLabel.tsx +22 -0
  97. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.styles.ts +27 -2
  98. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.tsx +8 -5
  99. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/common/constants.ts +23 -0
  100. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.ts +17 -1
  101. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.tsx +25 -23
  102. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.tsx +26 -5
  103. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +29 -6
  104. package/src/components/Layout/components/Header/components/Content/components/Slogan/slogan.styles.ts +3 -1
  105. package/src/components/Layout/components/Header/header.styles.ts +7 -0
  106. package/src/components/Layout/components/Nav/nav.styles.ts +6 -0
  107. package/src/components/Layout/components/Sidebar/components/SidebarDrawer/sidebarDrawer.styles.ts +12 -1
  108. package/src/components/Layout/components/Sidebar/components/SidebarDrawer/sidebarDrawer.tsx +2 -7
  109. package/src/components/Layout/components/Sidebar/components/SidebarPositioner/sidebarPositioner.styles.ts +1 -1
  110. package/src/components/Layout/components/Sidebar/sidebar.styles.ts +2 -1
  111. package/src/components/Links/common/entities.ts +5 -0
  112. package/src/components/Links/common/utils.ts +1 -1
  113. package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +2 -1
  114. package/src/components/Links/components/Link/link.tsx +12 -4
  115. package/src/components/Table/components/Pagination/pagination.tsx +5 -3
  116. package/src/components/common/Button/components/CallToActionButton/callToActionButton.tsx +6 -3
  117. package/src/components/common/Button/components/HelpIconButton/helpIconButton.tsx +6 -3
  118. package/src/components/common/Card/components/CardActionArea/cardActionArea.tsx +9 -2
  119. package/src/components/common/IconButton/iconButton.styles.ts +0 -88
  120. package/src/components/common/Socials/socials.styles.ts +10 -0
  121. package/src/components/common/Socials/socials.tsx +12 -10
  122. package/src/hooks/useMenuWithPosition.ts +49 -0
  123. package/src/theme/common/components.ts +59 -0
  124. package/types/data-explorer-ui.d.ts +1 -0
  125. package/src/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.tsx +0 -15
  126. package/src/components/common/IconButton/components/LoadingIconButton/loadingIconButton.tsx +0 -15
@@ -0,0 +1,4 @@
1
+ export const SEARCH_PARAMETERS = {
2
+ CATEGORY: "category",
3
+ QUERY: "q",
4
+ };
@@ -0,0 +1,17 @@
1
+ import { ReadonlyURLSearchParams } from "next/navigation";
2
+ import { SEARCH_PARAMETERS } from "./constants";
3
+
4
+ /**
5
+ * Return the search params, for the given search string.
6
+ * @param searchParams - Current search params.
7
+ * @param searchStr - Search string.
8
+ * @returns updated search params.
9
+ */
10
+ export function getSearchParams(
11
+ searchParams: ReadonlyURLSearchParams,
12
+ searchStr: string
13
+ ): URLSearchParams {
14
+ const params = new URLSearchParams(searchParams.toString());
15
+ params.set(SEARCH_PARAMETERS.QUERY, searchStr);
16
+ return params;
17
+ }
@@ -1,5 +1,9 @@
1
1
  import styled from "@emotion/styled";
2
2
  import { Dialog, Input } from "@mui/material";
3
+ import {
4
+ inkLight,
5
+ smokeMain,
6
+ } from "../../../../../../../../../../../../styles/common/mixins/colors";
3
7
  import { IconButton } from "../../../../../../../../../../../common/IconButton/iconButton";
4
8
  import { HEADER_HEIGHT } from "../../../../../../../../common/constants";
5
9
 
@@ -22,16 +26,16 @@ export const SearchForm = styled.form`
22
26
  `;
23
27
 
24
28
  export const SearchInput = styled(Input)`
25
- border-bottom: 1px solid ${({ theme }) => theme.palette.smoke.main};
29
+ border-bottom: 1px solid ${smokeMain};
26
30
  height: 40px;
27
31
  padding: 0;
28
32
 
29
33
  &&.Mui-focused ::placeholder {
30
- color: ${({ theme }) => theme.palette.ink.light};
34
+ color: ${inkLight};
31
35
  opacity: 1;
32
36
  }
33
37
  `;
34
38
 
35
39
  export const ClearButton = styled(IconButton)`
36
- color: ${({ theme }) => theme.palette.ink.light};
40
+ color: ${inkLight};
37
41
  ` as typeof IconButton;
@@ -1,7 +1,18 @@
1
1
  import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
2
- import React, { ChangeEvent, FormEvent, useRef, useState } from "react";
2
+ import { useSearchParams } from "next/navigation";
3
+ import Router from "next/router";
4
+ import React, {
5
+ ChangeEvent,
6
+ FormEvent,
7
+ useCallback,
8
+ useRef,
9
+ useState,
10
+ } from "react";
11
+ import { isValidUrl } from "../../../../../../../../../../../../common/utils";
3
12
  import { ButtonPrimary } from "../../../../../../../../../../../common/Button/components/ButtonPrimary/buttonPrimary";
4
13
  import { SearchIcon } from "../../../../../../../../../../../common/CustomIcon/components/SearchIcon/searchIcon";
14
+ import { isClientSideNavigation } from "../../../../../../../../../../../Links/common/utils";
15
+ import { getSearchParams } from "./common/utils";
5
16
  import {
6
17
  ClearButton,
7
18
  SearchBar as SearchDialog,
@@ -23,6 +34,7 @@ export default function SearchBar({
23
34
  searchURL,
24
35
  }: Props): JSX.Element {
25
36
  const inputRef = useRef<HTMLInputElement>(null);
37
+ const searchParams = useSearchParams();
26
38
  const [searchTerm, setSearchTerm] = useState<string>("");
27
39
 
28
40
  /**
@@ -58,21 +70,34 @@ export default function SearchBar({
58
70
  * @param searchStr - Current search string.
59
71
  * @param url - Current configured search path.
60
72
  */
61
- const handleSubmit = (
62
- formEvent: FormEvent<HTMLFormElement>,
63
- searchStr: string,
64
- url?: string
65
- ): void => {
66
- formEvent.preventDefault();
67
- if (searchStr && url) {
68
- closeMenu();
69
- closeSearch();
70
- // Build search URL and redirect to it.
71
- const location = new URL(url);
72
- location.searchParams.set("q", searchStr);
73
- window.location.href = location.href;
74
- }
75
- };
73
+ const handleSubmit = useCallback(
74
+ (
75
+ formEvent: FormEvent<HTMLFormElement>,
76
+ searchStr: string,
77
+ url?: string
78
+ ): void => {
79
+ formEvent.preventDefault();
80
+ if (searchStr && url) {
81
+ closeMenu();
82
+ closeSearch();
83
+ if (isClientSideNavigation(url)) {
84
+ Router.push({
85
+ pathname: url,
86
+ search: getSearchParams(searchParams, searchStr).toString(),
87
+ });
88
+ return;
89
+ }
90
+ if (isValidUrl(url)) {
91
+ // Build search URL and redirect to it.
92
+ const location = new URL(url);
93
+ location.search = getSearchParams(searchParams, searchStr).toString();
94
+ window.location.href = location.href;
95
+ }
96
+ throw new Error("Invalid search URL.");
97
+ }
98
+ },
99
+ [closeMenu, closeSearch, searchParams]
100
+ );
76
101
 
77
102
  return (
78
103
  <SearchDialog
@@ -0,0 +1,12 @@
1
+ import styled from "@emotion/styled";
2
+ import { Link } from "../../../../../../../Links/components/Link/link";
3
+
4
+ export const StyledLink = styled(Link)`
5
+ &.MuiLink-root {
6
+ flex: none;
7
+ text-decoration: none !important;
8
+ img {
9
+ margin: 0;
10
+ }
11
+ }
12
+ `;
@@ -1,11 +1,10 @@
1
- import Link from "next/link";
2
1
  import React from "react";
3
2
  import {
4
3
  ImageSrc,
5
4
  StaticImage,
6
5
  } from "../../../../../../../common/StaticImage/staticImage";
7
6
  import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
8
- import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
7
+ import { StyledLink } from "./logo.styles";
9
8
 
10
9
  export interface LogoProps {
11
10
  alt: string;
@@ -26,23 +25,12 @@ export const Logo = ({
26
25
  target = ANCHOR_TARGET.SELF,
27
26
  width,
28
27
  }: LogoProps): JSX.Element => {
29
- const logo = (
30
- <StaticImage alt={alt} height={height} src={src} width={width} />
31
- );
32
- return isClientSideNavigation(link) ? (
33
- <Link href={link} legacyBehavior passHref>
34
- <a className={className} href="passHref" rel="noopener" target={target}>
35
- {logo}
36
- </a>
37
- </Link>
38
- ) : (
39
- <a
28
+ return (
29
+ <StyledLink
40
30
  className={className}
41
- href={link}
42
- rel="noopener noreferrer"
31
+ label={<StaticImage alt={alt} height={height} src={src} width={width} />}
43
32
  target={target}
44
- >
45
- {logo}
46
- </a>
33
+ url={link}
34
+ />
47
35
  );
48
36
  };
@@ -0,0 +1,27 @@
1
+ import { SELECTED_MATCH } from "../../../../../common/entities";
2
+
3
+ /**
4
+ * Returns true if the navigation link is selected.
5
+ * @param url - The URL of the navigation link.
6
+ * @param pathname - The current pathname.
7
+ * @param selectedMatch - The selected match type.
8
+ * @returns true if the navigation link is selected.
9
+ */
10
+ export function isNavigationLinkSelected(
11
+ url: string,
12
+ pathname?: string,
13
+ selectedMatch: SELECTED_MATCH = SELECTED_MATCH.STARTS_WITH
14
+ ): boolean {
15
+ if (!pathname) return false;
16
+ if (isSelectedMatchEqual(selectedMatch)) return url === pathname;
17
+ return pathname.startsWith(url);
18
+ }
19
+
20
+ /**
21
+ * Returns true if the selected match type is "EQUAL".
22
+ * @param selectedMatch - The selected match type.
23
+ * @returns True if the selected match type is "EQUAL".
24
+ */
25
+ export function isSelectedMatchEqual(selectedMatch: SELECTED_MATCH): boolean {
26
+ return selectedMatch === SELECTED_MATCH.EQUALS;
27
+ }
@@ -0,0 +1,22 @@
1
+ import { Typography } from "@mui/material";
2
+ import React, { Fragment, ReactNode } from "react";
3
+
4
+ export interface NavigationButtonLabelProps {
5
+ label: ReactNode;
6
+ }
7
+
8
+ export const NavigationButtonLabel = ({
9
+ label,
10
+ }: NavigationButtonLabelProps): JSX.Element => {
11
+ return (
12
+ <Fragment>
13
+ {typeof label === "string" ? (
14
+ <Typography component="span" noWrap>
15
+ {label}
16
+ </Typography>
17
+ ) : (
18
+ label
19
+ )}
20
+ </Fragment>
21
+ );
22
+ };
@@ -1,7 +1,33 @@
1
1
  import styled from "@emotion/styled";
2
- import { textHeadingSmall } from "../../../../../../../../../../styles/common/mixins/fonts";
2
+ import { Dialog as MDialog } from "@mui/material";
3
+ import { inkLight } from "../../../../../../../../../../styles/common/mixins/colors";
4
+ import {
5
+ textBody400,
6
+ textUppercase500,
7
+ } from "../../../../../../../../../../styles/common/mixins/fonts";
3
8
  import { Button as DXButton } from "../../../../../../../../../common/Button/button";
4
9
 
10
+ export const Dialog = styled(MDialog)`
11
+ + .MuiDialog-root {
12
+ .MuiButton-activeNav,
13
+ .MuiButton-nav {
14
+ ${textBody400};
15
+ padding: 6px 48px;
16
+
17
+ &.Mui-disabled {
18
+ ${textUppercase500};
19
+ color: ${inkLight};
20
+ margin-top: 20px;
21
+ opacity: 1;
22
+ }
23
+
24
+ &:first-of-type {
25
+ margin-top: 10px;
26
+ }
27
+ }
28
+ }
29
+ `;
30
+
5
31
  export const Content = styled.div`
6
32
  padding: 16px 0;
7
33
  overflow-x: hidden;
@@ -9,7 +35,6 @@ export const Content = styled.div`
9
35
  `;
10
36
 
11
37
  export const Button = styled(DXButton)`
12
- ${textHeadingSmall};
13
38
  gap: 8px;
14
39
  justify-content: flex-start;
15
40
  padding: 12px 24px;
@@ -1,5 +1,4 @@
1
1
  import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded";
2
- import { Dialog as MDialog } from "@mui/material";
3
2
  import React, { ReactNode, useState } from "react";
4
3
  import { Button } from "../../../../../../../../../common/Button/button";
5
4
  import { BackArrowIcon } from "../../../../../../../../../common/CustomIcon/components/BackArrowIcon/backArrowIcon";
@@ -9,7 +8,11 @@ import { DrawerNavigation as Navigation } from "../../../Actions/components/Menu
9
8
  import { Toolbar } from "../../../Actions/components/Menu/components/Toolbar/toolbar";
10
9
  import { MenuItem } from "../NavigationMenuItems/navigationMenuItems";
11
10
  import { Slide } from "./components/Slide/slide";
12
- import { Button as BackButton, Content } from "./navigationDrawer.styles";
11
+ import {
12
+ Button as BackButton,
13
+ Content,
14
+ Dialog,
15
+ } from "./navigationDrawer.styles";
13
16
 
14
17
  export interface NavigationDrawerProps {
15
18
  closeAncestor?: () => void;
@@ -46,7 +49,7 @@ export const NavigationDrawer = ({
46
49
  >
47
50
  {menuLabel}
48
51
  </Button>
49
- <MDialog
52
+ <Dialog
50
53
  disableScrollLock
51
54
  fullScreen
52
55
  hideBackdrop
@@ -65,7 +68,7 @@ export const NavigationDrawer = ({
65
68
  fullWidth
66
69
  onClick={closeDrawer}
67
70
  StartIcon={BackArrowIcon}
68
- variant="nav"
71
+ variant="backNav"
69
72
  >
70
73
  {menuLabel}
71
74
  </BackButton>
@@ -76,7 +79,7 @@ export const NavigationDrawer = ({
76
79
  pathname={pathname}
77
80
  />
78
81
  </Content>
79
- </MDialog>
82
+ </Dialog>
80
83
  </>
81
84
  );
82
85
  };
@@ -0,0 +1,23 @@
1
+ import { MenuProps as MMenuProps } from "@mui/material";
2
+
3
+ export const MENU_ANCHOR_ORIGIN_LEFT_BOTTOM: MMenuProps["anchorOrigin"] = {
4
+ horizontal: "left",
5
+ vertical: "bottom",
6
+ };
7
+
8
+ export const MENU_ANCHOR_ORIGIN_RIGHT_TOP: MMenuProps["anchorOrigin"] = {
9
+ horizontal: "right",
10
+ vertical: "top",
11
+ };
12
+
13
+ export const MENU_PROPS: Partial<MMenuProps> = {
14
+ slotProps: {
15
+ paper: {
16
+ variant: "menu",
17
+ },
18
+ },
19
+ transformOrigin: {
20
+ horizontal: "left",
21
+ vertical: "top",
22
+ },
23
+ };
@@ -1,6 +1,6 @@
1
1
  import { css } from "@emotion/react";
2
2
  import styled from "@emotion/styled";
3
- import { Menu as MMenu } from "@mui/material";
3
+ import { Menu as MMenu, MenuItem as MMenuItem } from "@mui/material";
4
4
  import {
5
5
  inkLight,
6
6
  smokeLight,
@@ -33,11 +33,13 @@ export const Menu = styled(MMenu)`
33
33
  .MuiListItemText-root {
34
34
  display: grid;
35
35
  gap: 4px;
36
+ white-space: normal;
36
37
 
37
38
  .MuiListItemText-primary {
38
39
  align-items: center;
39
40
  display: flex;
40
41
  gap: 4px;
42
+ min-width: 0;
41
43
  }
42
44
 
43
45
  .MuiListItemText-secondary {
@@ -46,6 +48,11 @@ export const Menu = styled(MMenu)`
46
48
  }
47
49
  }
48
50
 
51
+ &.Mui-disabled {
52
+ color: ${inkLight};
53
+ opacity: 1;
54
+ }
55
+
49
56
  &.Mui-selected {
50
57
  background-color: ${smokeLight};
51
58
  }
@@ -67,6 +74,11 @@ export const Menu = styled(MMenu)`
67
74
  margin: 8px 0;
68
75
  }
69
76
  }
77
+
78
+ .MuiPopover-root {
79
+ cursor: default;
80
+ z-index: -1;
81
+ }
70
82
  `;
71
83
 
72
84
  export const Button = styled(DXButton, {
@@ -79,3 +91,7 @@ export const Button = styled(DXButton, {
79
91
  background-color: ${smokeLight(props)};
80
92
  `};
81
93
  `;
94
+
95
+ export const StyledMenuItem = styled(MMenuItem)`
96
+ padding: 0;
97
+ `;
@@ -1,65 +1,67 @@
1
1
  import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded";
2
2
  import { MenuProps as MMenuProps } from "@mui/material";
3
- import React, { MouseEvent, ReactNode, useState } from "react";
3
+ import React, { Fragment, ReactNode } from "react";
4
4
  import { useBreakpoint } from "../../../../../../../../../../hooks/useBreakpoint";
5
+ import { useMenuWithPosition } from "../../../../../../../../../../hooks/useMenuWithPosition";
6
+ import { NavigationButtonLabel } from "../NavigationButtonLabel/navigationButtonLabel";
5
7
  import {
6
8
  MenuItem,
7
9
  NavigationMenuItems,
8
10
  } from "../NavigationMenuItems/navigationMenuItems";
9
- import { Button, Menu } from "./navigationMenu.styles";
11
+ import { MENU_ANCHOR_ORIGIN_LEFT_BOTTOM, MENU_PROPS } from "./common/constants";
12
+ import { Button, Menu, StyledMenuItem } from "./navigationMenu.styles";
10
13
 
11
14
  export interface NavLinkMenuProps {
12
15
  anchorOrigin?: MMenuProps["anchorOrigin"];
13
16
  closeAncestor?: () => void;
17
+ disablePortal?: boolean;
14
18
  menuItems: MenuItem[];
15
19
  menuLabel: ReactNode;
16
20
  pathname?: string;
17
21
  }
18
22
 
19
23
  export const NavigationMenu = ({
20
- anchorOrigin = { horizontal: "left", vertical: "bottom" },
24
+ anchorOrigin = MENU_ANCHOR_ORIGIN_LEFT_BOTTOM,
21
25
  closeAncestor,
26
+ disablePortal,
22
27
  menuItems,
23
28
  menuLabel,
24
29
  pathname,
25
30
  }: NavLinkMenuProps): JSX.Element => {
26
31
  const { mdUp } = useBreakpoint();
27
- const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
28
- const open = Boolean(anchorEl);
29
- const openMenu = (event: MouseEvent<HTMLButtonElement>): void => {
30
- setAnchorEl(event.currentTarget);
31
- };
32
- const closeMenu = (): void => {
33
- closeAncestor?.();
34
- setAnchorEl(null);
35
- };
32
+ const { anchorEl, onClose, onToggleOpen, open } = useMenuWithPosition();
33
+ const MenuItem = disablePortal ? StyledMenuItem : Fragment;
34
+ const menuItemProps = disablePortal ? { onMouseLeave: onClose } : {};
36
35
  return (
37
- <>
36
+ <MenuItem {...menuItemProps}>
38
37
  <Button
39
38
  EndIcon={ArrowDropDownRoundedIcon}
40
39
  isActive={open}
41
- onClick={openMenu}
40
+ onClick={onToggleOpen}
42
41
  variant="nav"
43
42
  >
44
- {menuLabel}
43
+ <NavigationButtonLabel label={menuLabel} />
45
44
  </Button>
46
45
  <Menu
46
+ {...MENU_PROPS}
47
47
  anchorEl={anchorEl}
48
48
  anchorOrigin={anchorOrigin}
49
- onClose={closeMenu}
50
- open={mdUp && open}
51
- slotProps={{ paper: { variant: "menu" } }}
52
- transformOrigin={{
53
- horizontal: "left",
54
- vertical: "top",
49
+ disablePortal={disablePortal}
50
+ onClose={(): void => {
51
+ onClose();
52
+ closeAncestor?.();
55
53
  }}
54
+ open={mdUp && open}
56
55
  >
57
56
  <NavigationMenuItems
58
- closeMenu={closeMenu}
57
+ closeMenu={(): void => {
58
+ onClose();
59
+ closeAncestor?.();
60
+ }}
59
61
  menuItems={menuItems}
60
62
  pathname={pathname}
61
63
  />
62
64
  </Menu>
63
- </>
65
+ </MenuItem>
64
66
  );
65
67
  };
@@ -10,10 +10,16 @@ import {
10
10
  TEXT_BODY_400,
11
11
  TEXT_BODY_500,
12
12
  TEXT_BODY_SMALL_400_2_LINES,
13
+ TEXT_UPPERCASE_500,
13
14
  } from "../../../../../../../../../../theme/common/typography";
14
- import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
15
+ import {
16
+ ANCHOR_TARGET,
17
+ REL_ATTRIBUTE,
18
+ } from "../../../../../../../../../Links/common/entities";
15
19
  import { isClientSideNavigation } from "../../../../../../../../../Links/common/utils";
20
+ import { isNavigationLinkSelected } from "../../common/utils";
16
21
  import { NavLinkItem } from "../../navigation";
22
+ import { MENU_ANCHOR_ORIGIN_RIGHT_TOP } from "../NavigationMenu/common/constants";
17
23
  import { NavigationMenu } from "../NavigationMenu/navigationMenu";
18
24
 
19
25
  export interface MenuItem extends NavLinkItem {
@@ -43,6 +49,7 @@ export const NavigationMenuItems = ({
43
49
  icon,
44
50
  label,
45
51
  menuItems: nestedMenuItems,
52
+ selectedMatch,
46
53
  target = ANCHOR_TARGET.SELF,
47
54
  url,
48
55
  },
@@ -51,8 +58,9 @@ export const NavigationMenuItems = ({
51
58
  nestedMenuItems ? (
52
59
  <NavigationMenu
53
60
  key={i}
54
- anchorOrigin={{ horizontal: "right", vertical: "top" }}
61
+ anchorOrigin={MENU_ANCHOR_ORIGIN_RIGHT_TOP}
55
62
  closeAncestor={closeMenu}
63
+ disablePortal
56
64
  menuItems={nestedMenuItems}
57
65
  menuLabel={label}
58
66
  pathname={pathname}
@@ -60,19 +68,32 @@ export const NavigationMenuItems = ({
60
68
  ) : (
61
69
  <Fragment key={i}>
62
70
  <MMenuItem
71
+ disabled={!url}
63
72
  onClick={(): void => {
64
73
  closeMenu();
65
74
  isClientSideNavigation(url)
66
75
  ? router.push(url)
67
- : window.open(url, target, "noopener noreferrer");
76
+ : window.open(
77
+ url,
78
+ target,
79
+ REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
80
+ );
68
81
  }}
69
- selected={url === pathname}
82
+ selected={isNavigationLinkSelected(
83
+ url,
84
+ pathname,
85
+ selectedMatch
86
+ )}
70
87
  >
71
88
  {icon && <ListItemIcon>{icon}</ListItemIcon>}
72
89
  <ListItemText
73
90
  primary={label}
74
91
  primaryTypographyProps={{
75
- variant: description ? TEXT_BODY_500 : TEXT_BODY_400,
92
+ variant: url
93
+ ? description
94
+ ? TEXT_BODY_500
95
+ : TEXT_BODY_400
96
+ : TEXT_UPPERCASE_500,
76
97
  }}
77
98
  secondary={description}
78
99
  secondaryTypographyProps={{
@@ -3,9 +3,15 @@ import { useRouter } from "next/router";
3
3
  import React, { CSSProperties, forwardRef, Fragment, ReactNode } from "react";
4
4
  import { useBreakpoint } from "../../../../../../../../hooks/useBreakpoint";
5
5
  import { BreakpointKey } from "../../../../../../../../hooks/useBreakpointHelper";
6
- import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
6
+ import {
7
+ ANCHOR_TARGET,
8
+ REL_ATTRIBUTE,
9
+ } from "../../../../../../../Links/common/entities";
7
10
  import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
11
+ import { SELECTED_MATCH } from "../../../../common/entities";
8
12
  import { HeaderProps } from "../../../../header";
13
+ import { isNavigationLinkSelected } from "./common/utils";
14
+ import { NavigationButtonLabel } from "./components/NavigationButtonLabel/navigationButtonLabel";
9
15
  import { NavigationDrawer } from "./components/NavigationDrawer/navigationDrawer";
10
16
  import { NavigationMenu } from "./components/NavigationMenu/navigationMenu";
11
17
  import { MenuItem } from "./components/NavigationMenuItems/navigationMenuItems";
@@ -16,6 +22,7 @@ export interface NavLinkItem {
16
22
  flatten?: Partial<Record<BreakpointKey, boolean>>;
17
23
  label: ReactNode;
18
24
  menuItems?: MenuItem[];
25
+ selectedMatch?: SELECTED_MATCH;
19
26
  target?: ANCHOR_TARGET;
20
27
  url: string;
21
28
  visible?: Partial<Record<BreakpointKey, boolean>>;
@@ -48,7 +55,14 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
48
55
  <Links ref={ref} className={className} style={style}>
49
56
  {links.map(
50
57
  (
51
- { divider, label, menuItems, target = ANCHOR_TARGET.SELF, url },
58
+ {
59
+ divider,
60
+ label,
61
+ menuItems,
62
+ selectedMatch,
63
+ target = ANCHOR_TARGET.SELF,
64
+ url,
65
+ },
52
66
  i
53
67
  ) =>
54
68
  menuItems ? (
@@ -74,15 +88,24 @@ export const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
74
88
  ) : (
75
89
  <Fragment key={i}>
76
90
  <Button
91
+ disabled={!url}
77
92
  onClick={(): void => {
93
+ closeAncestor?.();
78
94
  isClientSideNavigation(url)
79
95
  ? router.push(url)
80
- : window.open(url, target, "noopener noreferrer");
81
- closeAncestor?.();
96
+ : window.open(
97
+ url,
98
+ target,
99
+ REL_ATTRIBUTE.NO_OPENER_NO_REFERRER
100
+ );
82
101
  }}
83
- variant={url === pathname ? "activeNav" : "nav"}
102
+ variant={
103
+ isNavigationLinkSelected(url, pathname, selectedMatch)
104
+ ? "activeNav"
105
+ : "nav"
106
+ }
84
107
  >
85
- {label}
108
+ <NavigationButtonLabel label={label} />
86
109
  </Button>
87
110
  {divider && <Divider />}
88
111
  </Fragment>
@@ -22,5 +22,7 @@ export const Slogan = styled.div`
22
22
  `;
23
23
 
24
24
  export const Divider = styled(MDivider)`
25
- max-height: 32px;
25
+ align-self: center;
26
+ display: flex;
27
+ height: 32px;
26
28
  `;