@databiosphere/findable-ui 7.0.0 → 8.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 (72) hide show
  1. package/lib/common/entities.d.ts +0 -9
  2. package/lib/common/entities.js +1 -9
  3. package/lib/components/Index/components/Tabs/common/utils.d.ts +8 -0
  4. package/lib/components/Index/components/Tabs/common/utils.js +18 -0
  5. package/lib/components/Index/components/Tabs/tabs.d.ts +2 -0
  6. package/lib/components/Index/components/Tabs/tabs.js +20 -0
  7. package/lib/components/Layout/components/Header/common/constants.d.ts +4 -9
  8. package/lib/components/Layout/components/Header/common/constants.js +8 -9
  9. package/lib/components/Layout/components/Header/common/entities.d.ts +6 -0
  10. package/lib/components/Layout/components/Header/common/utils.d.ts +12 -17
  11. package/lib/components/Layout/components/Header/common/utils.js +77 -59
  12. package/lib/components/Layout/components/Header/components/Announcements/announcements.d.ts +6 -0
  13. package/lib/components/Layout/components/Header/components/Announcements/announcements.js +7 -0
  14. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.d.ts +1 -2
  15. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.js +2 -2
  16. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +8 -15
  17. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.d.ts +4 -3
  18. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +4 -3
  19. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.js +17 -19
  20. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +5 -12
  21. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.js +3 -4
  22. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.d.ts +3 -3
  23. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +5 -7
  24. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.d.ts +1 -6
  25. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.js +4 -19
  26. package/lib/components/Layout/components/Header/header.d.ts +5 -7
  27. package/lib/components/Layout/components/Header/header.js +35 -59
  28. package/lib/components/Layout/components/Header/header.stories.js +38 -41
  29. package/lib/components/Layout/components/Header/header.styles.d.ts +13 -1
  30. package/lib/components/Layout/components/Header/header.styles.js +23 -3
  31. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.d.ts +20 -0
  32. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.js +46 -0
  33. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
  34. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
  35. package/lib/config/entities.d.ts +2 -0
  36. package/lib/config/utils.js +1 -2
  37. package/lib/hooks/useBreakpoint.d.ts +17 -0
  38. package/lib/hooks/useBreakpoint.js +34 -0
  39. package/lib/hooks/useBreakpointHelper.d.ts +1 -1
  40. package/lib/hooks/useCurrentBreakpoint.d.ts +3 -0
  41. package/lib/hooks/useCurrentBreakpoint.js +11 -0
  42. package/lib/hooks/useMenu.d.ts +10 -0
  43. package/lib/hooks/useMenu.js +17 -0
  44. package/lib/views/ExploreView/exploreView.js +4 -29
  45. package/package.json +1 -1
  46. package/src/common/entities.ts +0 -11
  47. package/src/components/Index/components/Tabs/common/utils.ts +33 -0
  48. package/src/components/Index/components/Tabs/tabs.tsx +23 -0
  49. package/src/components/Layout/components/Header/common/constants.ts +14 -10
  50. package/src/components/Layout/components/Header/common/entities.ts +7 -0
  51. package/src/components/Layout/components/Header/common/utils.ts +89 -66
  52. package/src/components/Layout/components/Header/components/Announcements/announcements.tsx +14 -0
  53. package/src/components/Layout/components/Header/components/Content/components/Actions/actions.tsx +2 -6
  54. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.tsx +21 -32
  55. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +8 -6
  56. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.tsx +19 -26
  57. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx +11 -22
  58. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.tsx +3 -7
  59. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.ts +5 -30
  60. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +8 -27
  61. package/src/components/Layout/components/Header/header.stories.tsx +38 -41
  62. package/src/components/Layout/components/Header/header.styles.ts +27 -4
  63. package/src/components/Layout/components/Header/header.tsx +99 -137
  64. package/src/components/Layout/components/Header/hooks/useHeaderVisibility.ts +74 -0
  65. package/src/components/Layout/components/Header/hooks/useMeasureHeader.ts +28 -0
  66. package/src/config/entities.ts +2 -0
  67. package/src/config/utils.ts +1 -2
  68. package/src/hooks/useBreakpoint.ts +54 -0
  69. package/src/hooks/useBreakpointHelper.ts +1 -1
  70. package/src/hooks/useCurrentBreakpoint.ts +23 -0
  71. package/src/hooks/useMenu.ts +27 -0
  72. package/src/views/ExploreView/exploreView.tsx +5 -34
@@ -14,15 +14,6 @@ export interface CategoryTag {
14
14
  * Category values to be used as keys. For example, "Homo sapiens" or "10X 3' v2 sequencing".
15
15
  */
16
16
  export declare type CategoryValueKey = string;
17
- /**
18
- * Element alignment.
19
- */
20
- export declare enum ELEMENT_ALIGNMENT {
21
- CENTER = "CENTER",
22
- LEFT = "LEFT",
23
- RIGHT = "RIGHT"
24
- }
25
- export declare type ElementAlignment = ELEMENT_ALIGNMENT;
26
17
  /**
27
18
  * Set of selected category values.
28
19
  */
@@ -1,9 +1 @@
1
- /**
2
- * Element alignment.
3
- */
4
- export var ELEMENT_ALIGNMENT;
5
- (function (ELEMENT_ALIGNMENT) {
6
- ELEMENT_ALIGNMENT["CENTER"] = "CENTER";
7
- ELEMENT_ALIGNMENT["LEFT"] = "LEFT";
8
- ELEMENT_ALIGNMENT["RIGHT"] = "RIGHT";
9
- })(ELEMENT_ALIGNMENT || (ELEMENT_ALIGNMENT = {}));
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { EntityConfig } from "../../../../../config/entities";
2
+ import { Tab } from "../../../../common/Tabs/tabs";
3
+ /**
4
+ * Returns entity list tabs list for the tabs component.
5
+ * @param entities - Entities config.
6
+ * @returns tabs list.
7
+ */
8
+ export declare function getEntityListTabs(entities: EntityConfig[]): Tab[];
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns entity list tabs list for the tabs component.
3
+ * @param entities - Entities config.
4
+ * @returns tabs list.
5
+ */
6
+ export function getEntityListTabs(entities) {
7
+ return entities.reduce((acc, { label, listView: { enableTab = true } = {}, route, tabIcon: icon, tabIconPosition: iconPosition, }) => {
8
+ if (enableTab) {
9
+ acc.push({
10
+ icon,
11
+ iconPosition,
12
+ label,
13
+ value: route,
14
+ });
15
+ }
16
+ return acc;
17
+ }, []);
18
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Tabs: () => JSX.Element | null;
@@ -0,0 +1,20 @@
1
+ import Router from "next/router";
2
+ import React, { useCallback, useMemo } from "react";
3
+ import { useConfig } from "../../../../hooks/useConfig";
4
+ import { useExploreState } from "../../../../hooks/useExploreState";
5
+ import { Tabs as DXTabs } from "../../../common/Tabs/tabs";
6
+ import { getEntityListTabs } from "./common/utils";
7
+ export const Tabs = () => {
8
+ const { config } = useConfig();
9
+ const { exploreState } = useExploreState();
10
+ const { entities } = config;
11
+ const { tabValue } = exploreState;
12
+ const tabs = useMemo(() => getEntityListTabs(entities), [entities]);
13
+ // Callback fired when selected tab value changes.
14
+ const onTabChange = useCallback(async (tabValue) => {
15
+ await Router.push(`/${tabValue}`);
16
+ }, []);
17
+ if (tabs.length <= 1)
18
+ return null;
19
+ return React.createElement(DXTabs, { onTabChange: onTabChange, tabs: tabs, value: tabValue });
20
+ };
@@ -1,14 +1,9 @@
1
+ import { AppBarProps as MAppBarProps, ToolbarProps as MToolbarProps } from "@mui/material";
1
2
  export declare const HEADER_HEIGHT = 56;
2
- export declare const HEADER_FADE_TIMEOUT = 0;
3
+ export declare const APP_BAR_PROPS: Partial<MAppBarProps>;
3
4
  export declare const FADE_TRANSITION_PROPS: {
5
+ appear: boolean;
4
6
  timeout: number;
5
7
  unmountOnExit: boolean;
6
8
  };
7
- export declare const HEADER_NAVIGATION_LABEL: {
8
- MORE: string;
9
- SOCIALS: string;
10
- };
11
- export declare const SWITCH_TRANSITION_PROPS: {
12
- timeout: number;
13
- unmountOnExit: boolean;
14
- };
9
+ export declare const TOOLBAR_PROPS: Partial<MToolbarProps>;
@@ -1,14 +1,13 @@
1
1
  export const HEADER_HEIGHT = 56;
2
- export const HEADER_FADE_TIMEOUT = 0;
3
- export const FADE_TRANSITION_PROPS = {
4
- timeout: HEADER_FADE_TIMEOUT,
5
- unmountOnExit: true,
6
- };
7
- export const HEADER_NAVIGATION_LABEL = {
8
- MORE: "More",
9
- SOCIALS: "Follow Us",
2
+ export const APP_BAR_PROPS = {
3
+ elevation: 1,
4
+ position: "fixed",
10
5
  };
11
- export const SWITCH_TRANSITION_PROPS = {
6
+ export const FADE_TRANSITION_PROPS = {
7
+ appear: false,
12
8
  timeout: 0,
13
9
  unmountOnExit: true,
14
10
  };
11
+ export const TOOLBAR_PROPS = {
12
+ variant: "dense",
13
+ };
@@ -1,5 +1,11 @@
1
1
  import { ReactNode } from "react";
2
2
  import { Social } from "../../../../common/Socials/socials";
3
+ import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
4
+ export declare type Navigation = [
5
+ NavLinkItem[] | undefined,
6
+ NavLinkItem[] | undefined,
7
+ NavLinkItem[] | undefined
8
+ ];
3
9
  export interface SocialMedia {
4
10
  label: ReactNode;
5
11
  socials: Social[];
@@ -1,22 +1,17 @@
1
+ import { Breakpoint } from "@mui/material";
1
2
  import { NavLinkItem } from "../components/Content/components/Navigation/navigation";
2
- import { SocialMedia } from "./entities";
3
+ import { Navigation } from "./entities";
3
4
  /**
4
- * Returns the navigation links as configured, where the "More" menu is flattened.
5
- * @param links - Header navigation links.
6
- * @returns header navigation links, without links grouped under the "More" menu.
5
+ * Returns the configured menu navigation links, for the current breakpoint.
6
+ * @param navigation - Navigation links.
7
+ * @param breakpoint - Current breakpoint.
8
+ * @returns navigation links.
7
9
  */
8
- export declare function flattenMoreLink(links: NavLinkItem[]): NavLinkItem[];
10
+ export declare function getMenuNavigationLinks(navigation?: Navigation, breakpoint?: Breakpoint): NavLinkItem[];
9
11
  /**
10
- * Returns the navigation links as configured, all menu links specified as "flatten" are flattened, including the "More" menu.
11
- * @param links - Header navigation links.
12
- * @returns header navigation links.
12
+ * Returns configured navigation links, for the current breakpoint.
13
+ * @param navigationLinks - Navigation links.
14
+ * @param breakpoint - Current breakpoint.
15
+ * @returns navigation links.
13
16
  */
14
- export declare function flattenNavigationLinks(links: NavLinkItem[]): NavLinkItem[];
15
- /**
16
- * Returns header navigation links with socials appended with the corresponding label "Follow Us".
17
- * @param links - Header navigation links.
18
- * @param socialMedia - Header social media.
19
- * @param onlySmDesktop - Media breakpoint query is "true" for small desktop only.
20
- * @returns header navigation links.
21
- */
22
- export declare function getHeaderNavigationLinks(links: NavLinkItem[], socialMedia: SocialMedia | undefined, onlySmDesktop: boolean): NavLinkItem[];
17
+ export declare function getNavigationLinks(navigationLinks?: NavLinkItem[], breakpoint?: Breakpoint): NavLinkItem[];
@@ -1,72 +1,90 @@
1
- import { RenderComponent } from "../../../../ComponentCreator/components/RenderComponent/renderComponent";
2
- import { ANCHOR_TARGET } from "../../../../Links/common/entities";
3
- import { HEADER_NAVIGATION_LABEL } from "./constants";
4
1
  /**
5
- * Returns the navigation links as configured, where the "More" menu is flattened.
6
- * @param links - Header navigation links.
7
- * @returns header navigation links, without links grouped under the "More" menu.
2
+ * Returns the configured menu navigation links, for the current breakpoint.
3
+ * @param navigation - Navigation links.
4
+ * @param breakpoint - Current breakpoint.
5
+ * @returns navigation links.
8
6
  */
9
- export function flattenMoreLink(links) {
10
- return links.flatMap((link) => {
11
- if (link.label === HEADER_NAVIGATION_LABEL.MORE) {
12
- if (link.flatten === false) {
13
- return link;
14
- }
15
- return link.menuItems;
16
- }
17
- return link;
18
- });
7
+ export function getMenuNavigationLinks(navigation, breakpoint) {
8
+ if (!navigation)
9
+ return [];
10
+ const navLinkItems = navigation.reduce((acc, navLinkItems) => {
11
+ if (!navLinkItems)
12
+ return acc;
13
+ acc.push(...navLinkItems);
14
+ return acc;
15
+ }, []);
16
+ return getNavigationLinks(navLinkItems, breakpoint);
19
17
  }
20
18
  /**
21
- * Returns the navigation links as configured, all menu links specified as "flatten" are flattened, including the "More" menu.
22
- * @param links - Header navigation links.
23
- * @returns header navigation links.
19
+ * Returns configured navigation links, for the current breakpoint.
20
+ * @param navigationLinks - Navigation links.
21
+ * @param breakpoint - Current breakpoint.
22
+ * @returns navigation links.
24
23
  */
25
- export function flattenNavigationLinks(links) {
26
- return links.flatMap((link) => {
27
- if (link.flatten || link.label === HEADER_NAVIGATION_LABEL.MORE) {
28
- return link.menuItems;
24
+ export function getNavigationLinks(navigationLinks, breakpoint) {
25
+ if (!navigationLinks)
26
+ return [];
27
+ return navigationLinks.reduce((acc, navLinkItem) => {
28
+ const processedNavLink = processNavLinkItem(navLinkItem, breakpoint);
29
+ if (processedNavLink) {
30
+ acc.push(...processedNavLink);
29
31
  }
30
- return link;
31
- });
32
+ return acc;
33
+ }, []);
32
34
  }
33
35
  /**
34
- * Returns header navigation links with socials appended with the corresponding label "Follow Us".
35
- * @param links - Header navigation links.
36
- * @param socialMedia - Header social media.
37
- * @param onlySmDesktop - Media breakpoint query is "true" for small desktop only.
38
- * @returns header navigation links.
36
+ * Returns true if the link is flattened at the current breakpoint.
37
+ * @param navLinkItem - Navigation link.
38
+ * @param breakpoint - Current breakpoint.
39
+ * @returns true if the link is flattened.
39
40
  */
40
- export function getHeaderNavigationLinks(links, socialMedia, onlySmDesktop) {
41
- if (onlySmDesktop) {
42
- const navLinks = [...links];
43
- if (socialMedia) {
44
- navLinks.push({
45
- label: socialMedia.label,
46
- menuItems: getFollowUsMenuItems(socialMedia.socials),
47
- url: "",
48
- });
49
- }
50
- return navLinks;
51
- }
52
- // Return the links without the "More" or "Follow Us" menu.
53
- return flattenMoreLink(links);
41
+ function isLinkFlattened(navLinkItem, breakpoint) {
42
+ if (!breakpoint)
43
+ return false; // Default is not flattened.
44
+ if (!navLinkItem.flatten)
45
+ return false; // Default is not flattened.
46
+ return navLinkItem.flatten[breakpoint] === true;
54
47
  }
55
48
  /**
56
- * Returns menu items for the "Follow Us" menu.
57
- * @param socials - Social configuration.
58
- * @returns a list of social menu items for the "Follow Us" menu.
49
+ * Returns true if the link is visible at the current breakpoint.
50
+ * @param navLinkItem - Navigation link.
51
+ * @param breakpoint - Current breakpoint.
52
+ * @returns true if the link is visible.
59
53
  */
60
- function getFollowUsMenuItems(socials) {
61
- return socials.map(({ Icon, label, url }) => {
62
- return {
63
- icon: RenderComponent({
64
- Component: Icon,
65
- ...{ fontSize: "small" },
66
- }),
67
- label,
68
- target: ANCHOR_TARGET.BLANK,
69
- url,
70
- };
71
- });
54
+ function isLinkVisible(navLinkItem, breakpoint) {
55
+ if (!breakpoint)
56
+ return true; // Default is visible.
57
+ if (!navLinkItem.visible)
58
+ return true; // Default is visible.
59
+ return navLinkItem.visible[breakpoint] !== false;
60
+ }
61
+ /**
62
+ * Returns the processed navigation link item.
63
+ * Flattens menu items, and removes items that are not visible for the current breakpoint.
64
+ * @param navLinkItem - Navigation link.
65
+ * @param breakpoint - Current breakpoint.
66
+ * @returns processed navigation link item.
67
+ */
68
+ function processNavLinkItem(navLinkItem, breakpoint) {
69
+ if (isLinkVisible(navLinkItem, breakpoint)) {
70
+ const cloneLink = { ...navLinkItem };
71
+ // Recursively process menu items.
72
+ if (cloneLink.menuItems) {
73
+ const menuItems = getNavigationLinks(navLinkItem.menuItems, breakpoint);
74
+ // Remove menu items if empty.
75
+ if (menuItems.length === 0) {
76
+ delete cloneLink.menuItems;
77
+ }
78
+ else {
79
+ // Flatten the menu items if the navigation is flattened.
80
+ if (isLinkFlattened(cloneLink, breakpoint)) {
81
+ return menuItems;
82
+ }
83
+ else {
84
+ cloneLink.menuItems = menuItems;
85
+ }
86
+ }
87
+ }
88
+ return [cloneLink];
89
+ }
72
90
  }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { ComponentsConfig } from "../../../../../../config/entities";
3
+ export interface AnnouncementsProps {
4
+ announcements?: ComponentsConfig;
5
+ }
6
+ export declare const Announcements: ({ announcements, }: AnnouncementsProps) => JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { ComponentCreator } from "../../../../../ComponentCreator/ComponentCreator";
3
+ export const Announcements = ({ announcements, }) => {
4
+ if (!announcements)
5
+ return null;
6
+ return React.createElement(ComponentCreator, { components: announcements, response: {} });
7
+ };
@@ -1,6 +1,5 @@
1
1
  import { ReactNode } from "react";
2
2
  export interface ActionsProps {
3
3
  children: ReactNode | ReactNode[];
4
- showActions?: boolean;
5
4
  }
6
- export declare const Actions: ({ children, showActions, }: ActionsProps) => JSX.Element;
5
+ export declare const Actions: ({ children }: ActionsProps) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import { HeaderActions } from "./actions.styles";
3
- export const Actions = ({ children, showActions = true, }) => {
4
- return React.createElement(React.Fragment, null, showActions && React.createElement(HeaderActions, null, children));
3
+ export const Actions = ({ children }) => {
4
+ return React.createElement(HeaderActions, null, children);
5
5
  };
@@ -1,20 +1,13 @@
1
1
  import LoginRoundedIcon from "@mui/icons-material/LoginRounded";
2
- import { Fade, IconButton } from "@mui/material";
2
+ import { IconButton as MIconButton } from "@mui/material";
3
3
  import React from "react";
4
- import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../../../../../../../../../hooks/useBreakpointHelper";
5
- import { DESKTOP_SM } from "../../../../../../../../../../../../theme/common/breakpoints";
6
- import { SWITCH_TRANSITION_PROPS } from "../../../../../../../../common/constants";
4
+ import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
7
5
  import { Button } from "./requestAuthentication.styles";
8
6
  export const RequestAuthentication = ({ closeMenu, requestAuthorization, }) => {
9
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
10
- const switchProps = SWITCH_TRANSITION_PROPS;
11
- return (React.createElement(React.Fragment, null,
12
- React.createElement(Fade, { in: smDesktop, ...switchProps },
13
- React.createElement(Button, { onClick: requestAuthorization, startIcon: React.createElement(LoginRoundedIcon, null), variant: "nav" }, "Sign in")),
14
- React.createElement(Fade, { in: !smDesktop, ...switchProps },
15
- React.createElement(IconButton, { color: "ink", onClick: () => {
16
- closeMenu();
17
- requestAuthorization();
18
- } },
19
- React.createElement(LoginRoundedIcon, null)))));
7
+ const { mdUp } = useBreakpoint();
8
+ return mdUp ? (React.createElement(Button, { onClick: requestAuthorization, startIcon: React.createElement(LoginRoundedIcon, null), variant: "nav" }, "Sign in")) : (React.createElement(MIconButton, { color: "ink", onClick: () => {
9
+ closeMenu();
10
+ requestAuthorization();
11
+ } },
12
+ React.createElement(LoginRoundedIcon, null)));
20
13
  };
@@ -1,11 +1,12 @@
1
1
  import { ReactNode } from "react";
2
+ import { ComponentsConfig } from "../../../../../../../../../../../../config/entities";
2
3
  export interface DialogTitleProps {
3
4
  actions?: ReactNode;
4
- Announcements?: ReactNode;
5
+ announcements?: ComponentsConfig;
5
6
  authenticationEnabled?: boolean;
6
- Logo?: ReactNode;
7
+ logo?: ReactNode;
7
8
  onClose: () => void;
8
9
  searchEnabled?: boolean;
9
10
  searchURL?: string;
10
11
  }
11
- export declare const Toolbar: ({ actions, Announcements, authenticationEnabled, Logo, onClose, searchEnabled, searchURL, }: DialogTitleProps) => JSX.Element;
12
+ export declare const Toolbar: ({ actions, announcements, authenticationEnabled, logo, onClose, searchEnabled, searchURL, }: DialogTitleProps) => JSX.Element;
@@ -1,14 +1,15 @@
1
1
  import CloseRoundedIcon from "@mui/icons-material/CloseRounded";
2
2
  import { IconButton, Toolbar as MToolbar } from "@mui/material";
3
3
  import React, { Fragment } from "react";
4
+ import { Announcements } from "../../../../../../../Announcements/announcements";
4
5
  import { Actions } from "../../../../actions";
5
6
  import { Authentication } from "../../../Authentication/authentication";
6
7
  import { Search } from "../../../Search/search";
7
- export const Toolbar = ({ actions, Announcements, authenticationEnabled, Logo, onClose, searchEnabled, searchURL, }) => {
8
+ export const Toolbar = ({ actions, announcements, authenticationEnabled, logo, onClose, searchEnabled, searchURL, }) => {
8
9
  return (React.createElement(Fragment, null,
9
- Announcements,
10
+ React.createElement(Announcements, { announcements: announcements }),
10
11
  React.createElement(MToolbar, null,
11
- Logo,
12
+ logo,
12
13
  React.createElement(Actions, null,
13
14
  React.createElement(Search, { closeMenu: onClose, searchEnabled: searchEnabled, searchURL: searchURL }),
14
15
  React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: onClose }),
@@ -1,10 +1,8 @@
1
1
  import MenuRoundedIcon from "@mui/icons-material/MenuRounded";
2
2
  import { Dialog as MDialog, Fade, IconButton } from "@mui/material";
3
- import React, { forwardRef, useEffect } from "react";
4
- import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../../../../../../../hooks/useBreakpointHelper";
5
- import { DESKTOP_SM } from "../../../../../../../../../../theme/common/breakpoints";
6
- import { SWITCH_TRANSITION_PROPS } from "../../../../../../common/constants";
7
- import { flattenNavigationLinks } from "../../../../../../common/utils";
3
+ import React, { forwardRef, Fragment, useEffect } from "react";
4
+ import { useBreakpoint } from "../../../../../../../../../../hooks/useBreakpoint";
5
+ import { getMenuNavigationLinks } from "../../../../../../common/utils";
8
6
  import { AppBar } from "../../../../../../header.styles";
9
7
  import { Content } from "../../../../content.styles";
10
8
  import { Slogan } from "../../../Slogan/slogan";
@@ -12,24 +10,24 @@ import { Navigation } from "./components/Content/components/Navigation/navigatio
12
10
  import { Socials } from "./components/Content/components/Socials/socials.styles";
13
11
  import { Toolbar } from "./components/Toolbar/toolbar";
14
12
  export const Menu = forwardRef(function HeaderMenu({ closeMenu, headerProps, open, openMenu, style }, ref) {
15
- const { navLinks, slogan, socialMedia } = headerProps;
16
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
17
- const switchProps = SWITCH_TRANSITION_PROPS;
18
- // Set drawer open state to false on change of media breakpoint from mobile to "small desktop".
13
+ const { navigation, slogan, socialMedia } = headerProps;
14
+ const { breakpoint, smDown } = useBreakpoint();
15
+ // Set drawer open state to false on change of media breakpoint from small desktop "md" and up.
19
16
  useEffect(() => {
20
- if (smDesktop) {
21
- closeMenu();
22
- }
23
- }, [closeMenu, smDesktop]);
24
- return (React.createElement(React.Fragment, null,
25
- React.createElement(Fade, { in: !smDesktop, ...switchProps },
26
- React.createElement(IconButton, { color: "ink", onClick: openMenu, ref: ref, style: style },
27
- React.createElement(MenuRoundedIcon, null))),
28
- React.createElement(MDialog, { disableScrollLock: true, fullScreen: true, hideBackdrop: true, keepMounted: false, onClose: closeMenu, open: open, PaperProps: { elevation: 0 }, TransitionComponent: Fade, transitionDuration: smDesktop ? 0 : 600, TransitionProps: { easing: "ease-out" } },
17
+ if (smDown)
18
+ return;
19
+ closeMenu();
20
+ }, [closeMenu, smDown]);
21
+ if (!smDown)
22
+ return null;
23
+ return (React.createElement(Fragment, null,
24
+ React.createElement(IconButton, { color: "ink", onClick: openMenu, ref: ref, style: style },
25
+ React.createElement(MenuRoundedIcon, null)),
26
+ React.createElement(MDialog, { disableScrollLock: true, fullScreen: true, hideBackdrop: true, keepMounted: false, onClose: closeMenu, open: open, PaperProps: { elevation: 0 }, TransitionComponent: Fade, transitionDuration: smDown ? 600 : 0, TransitionProps: { easing: "ease-out" } },
29
27
  React.createElement(AppBar, { component: "div", elevation: 0 },
30
28
  React.createElement(Toolbar, { onClose: closeMenu, ...headerProps })),
31
29
  React.createElement(Content, null,
32
30
  slogan && React.createElement(Slogan, { slogan: slogan }),
33
- React.createElement(Navigation, { closeAncestor: closeMenu, headerProps: headerProps, links: flattenNavigationLinks(navLinks) }),
31
+ React.createElement(Navigation, { closeAncestor: closeMenu, headerProps: headerProps, links: getMenuNavigationLinks(navigation, breakpoint) }),
34
32
  socialMedia && (React.createElement(Socials, { buttonSize: "xlarge", socials: socialMedia.socials }))))));
35
33
  });
@@ -1,17 +1,10 @@
1
- import { Fade, IconButton } from "@mui/material";
1
+ import { IconButton } from "@mui/material";
2
2
  import React from "react";
3
- import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../../../../../../../../../hooks/useBreakpointHelper";
4
- import { DESKTOP_SM } from "../../../../../../../../../../../../theme/common/breakpoints";
3
+ import { useBreakpoint } from "../../../../../../../../../../../../hooks/useBreakpoint";
5
4
  import { SearchIcon } from "../../../../../../../../../../../common/CustomIcon/components/SearchIcon/searchIcon";
6
- import { SWITCH_TRANSITION_PROPS } from "../../../../../../../../common/constants";
7
5
  import { Button } from "./searchButton.styles";
8
6
  export const SearchButton = ({ openSearch }) => {
9
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
10
- const switchProps = SWITCH_TRANSITION_PROPS;
11
- return (React.createElement(React.Fragment, null,
12
- React.createElement(Fade, { in: smDesktop, ...switchProps },
13
- React.createElement(Button, { onClick: openSearch, startIcon: React.createElement(SearchIcon, null), variant: "nav" }, "Search")),
14
- React.createElement(Fade, { in: !smDesktop, ...switchProps },
15
- React.createElement(IconButton, { color: "ink", onClick: openSearch },
16
- React.createElement(SearchIcon, { fontSize: "medium" })))));
7
+ const { mdUp } = useBreakpoint();
8
+ return mdUp ? (React.createElement(Button, { onClick: openSearch, startIcon: React.createElement(SearchIcon, null), variant: "nav" }, "Search")) : (React.createElement(IconButton, { color: "ink", onClick: openSearch },
9
+ React.createElement(SearchIcon, { fontSize: "medium" })));
17
10
  };
@@ -1,11 +1,10 @@
1
1
  import ArrowDropDownRoundedIcon from "@mui/icons-material/ArrowDropDownRounded";
2
2
  import React, { useState } from "react";
3
- import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../../../../../../../hooks/useBreakpointHelper";
4
- import { DESKTOP_SM } from "../../../../../../../../../../theme/common/breakpoints";
3
+ import { useBreakpoint } from "../../../../../../../../../../hooks/useBreakpoint";
5
4
  import { NavigationMenuItems, } from "../NavigationMenuItems/navigationMenuItems";
6
5
  import { Button, Menu } from "./navigationMenu.styles";
7
6
  export const NavigationMenu = ({ anchorOrigin = { horizontal: "left", vertical: "bottom" }, closeAncestor, menuItems, menuLabel, }) => {
8
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
7
+ const { mdUp } = useBreakpoint();
9
8
  const [anchorEl, setAnchorEl] = useState(null);
10
9
  const open = Boolean(anchorEl);
11
10
  const openMenu = (event) => {
@@ -17,7 +16,7 @@ export const NavigationMenu = ({ anchorOrigin = { horizontal: "left", vertical:
17
16
  };
18
17
  return (React.createElement(React.Fragment, null,
19
18
  React.createElement(Button, { EndIcon: ArrowDropDownRoundedIcon, isActive: open, onClick: openMenu, variant: "nav" }, menuLabel),
20
- React.createElement(Menu, { anchorEl: anchorEl, anchorOrigin: anchorOrigin, onClose: closeMenu, open: smDesktop && open, slotProps: { paper: { variant: "menu" } }, transformOrigin: {
19
+ React.createElement(Menu, { anchorEl: anchorEl, anchorOrigin: anchorOrigin, onClose: closeMenu, open: mdUp && open, slotProps: { paper: { variant: "menu" } }, transformOrigin: {
21
20
  horizontal: "left",
22
21
  vertical: "top",
23
22
  } },
@@ -1,18 +1,18 @@
1
1
  import React, { CSSProperties, ReactNode } from "react";
2
- import { ElementAlignment } from "../../../../../../../../common/entities";
2
+ import { BreakpointKey } from "../../../../../../../../hooks/useBreakpointHelper";
3
3
  import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
4
4
  import { HeaderProps } from "../../../../header";
5
5
  import { MenuItem } from "./components/NavigationMenuItems/navigationMenuItems";
6
6
  export interface NavLinkItem {
7
7
  divider?: boolean;
8
- flatten?: boolean;
8
+ flatten?: Partial<Record<BreakpointKey, boolean>>;
9
9
  label: ReactNode;
10
10
  menuItems?: MenuItem[];
11
11
  target?: ANCHOR_TARGET;
12
12
  url: string;
13
+ visible?: Partial<Record<BreakpointKey, boolean>>;
13
14
  }
14
15
  export interface NavigationProps {
15
- alignment?: ElementAlignment;
16
16
  className?: string;
17
17
  closeAncestor?: () => void;
18
18
  headerProps?: HeaderProps;
@@ -1,19 +1,17 @@
1
1
  import { Button, Divider } from "@mui/material";
2
2
  import { useRouter } from "next/router";
3
3
  import React, { forwardRef, Fragment } from "react";
4
- import { ELEMENT_ALIGNMENT, } from "../../../../../../../../common/entities";
5
- import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../../../../../hooks/useBreakpointHelper";
6
- import { DESKTOP_SM } from "../../../../../../../../theme/common/breakpoints";
4
+ import { useBreakpoint } from "../../../../../../../../hooks/useBreakpoint";
7
5
  import { ANCHOR_TARGET } from "../../../../../../../Links/common/entities";
8
6
  import { isClientSideNavigation } from "../../../../../../../Links/common/utils";
9
7
  import { NavigationDrawer } from "./components/NavigationDrawer/navigationDrawer";
10
8
  import { NavigationMenu } from "./components/NavigationMenu/navigationMenu";
11
9
  import { Navigation as Links } from "./navigation.styles";
12
- export const Navigation = forwardRef(function Navigation({ alignment = ELEMENT_ALIGNMENT.LEFT, className, closeAncestor, headerProps, links, style, }, ref) {
13
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
10
+ export const Navigation = forwardRef(function Navigation({ className, closeAncestor, headerProps, links, style }, ref) {
11
+ const { mdUp } = useBreakpoint();
14
12
  const router = useRouter();
15
- return (React.createElement(Links, { ref: ref, alignment: alignment, className: className, style: style }, links.map(({ divider, label, menuItems, target = ANCHOR_TARGET.SELF, url }, i) => menuItems ? (React.createElement(Fragment, { key: i },
16
- smDesktop ? (React.createElement(NavigationMenu, { closeAncestor: closeAncestor, menuItems: menuItems, menuLabel: label })) : (React.createElement(NavigationDrawer, { closeAncestor: closeAncestor, headerProps: headerProps, menuItems: menuItems, menuLabel: label })),
13
+ return (React.createElement(Links, { ref: ref, className: className, style: style }, links.map(({ divider, label, menuItems, target = ANCHOR_TARGET.SELF, url }, i) => menuItems ? (React.createElement(Fragment, { key: i },
14
+ mdUp ? (React.createElement(NavigationMenu, { closeAncestor: closeAncestor, menuItems: menuItems, menuLabel: label })) : (React.createElement(NavigationDrawer, { closeAncestor: closeAncestor, headerProps: headerProps, menuItems: menuItems, menuLabel: label })),
17
15
  divider && React.createElement(Divider, null))) : (React.createElement(Fragment, { key: i },
18
16
  React.createElement(Button, { onClick: () => {
19
17
  isClientSideNavigation(url)
@@ -1,10 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ElementAlignment } from "../../../../../../../../common/entities";
3
- interface Props {
4
- alignment: ElementAlignment;
5
- }
6
2
  export declare const Navigation: import("@emotion/styled").StyledComponent<{
7
3
  theme?: import("@emotion/react").Theme | undefined;
8
4
  as?: import("react").ElementType<any> | undefined;
9
- } & Props, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
10
- export {};
5
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;