@databiosphere/findable-ui 7.0.0 → 8.0.1

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 (90) hide show
  1. package/lib/common/entities.d.ts +0 -9
  2. package/lib/common/entities.js +1 -9
  3. package/lib/components/Filter/components/FilterLabel/filterLabel.styles.d.ts +1 -1
  4. package/lib/components/Index/components/Tabs/common/utils.d.ts +8 -0
  5. package/lib/components/Index/components/Tabs/common/utils.js +18 -0
  6. package/lib/components/Index/components/Tabs/tabs.d.ts +2 -0
  7. package/lib/components/Index/components/Tabs/tabs.js +20 -0
  8. package/lib/components/Layout/components/Header/common/constants.d.ts +4 -9
  9. package/lib/components/Layout/components/Header/common/constants.js +8 -9
  10. package/lib/components/Layout/components/Header/common/entities.d.ts +6 -0
  11. package/lib/components/Layout/components/Header/common/utils.d.ts +12 -17
  12. package/lib/components/Layout/components/Header/common/utils.js +77 -59
  13. package/lib/components/Layout/components/Header/components/Announcements/announcements.d.ts +6 -0
  14. package/lib/components/Layout/components/Header/components/Announcements/announcements.js +7 -0
  15. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.d.ts +1 -2
  16. package/lib/components/Layout/components/Header/components/Content/components/Actions/actions.js +2 -2
  17. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +8 -15
  18. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +1 -1
  19. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Content/components/Navigation/navigation.styles.js +2 -0
  20. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.d.ts +4 -3
  21. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.js +4 -3
  22. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.d.ts +1 -0
  23. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.js +18 -20
  24. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +5 -12
  25. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +1 -1
  26. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.d.ts +2 -1
  27. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.js +2 -2
  28. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.d.ts +2 -1
  29. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.js +5 -6
  30. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.js +10 -4
  31. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.d.ts +2 -1
  32. package/lib/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.js +3 -3
  33. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.d.ts +4 -3
  34. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.js +6 -8
  35. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.d.ts +1 -6
  36. package/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.js +5 -19
  37. package/lib/components/Layout/components/Header/header.d.ts +5 -7
  38. package/lib/components/Layout/components/Header/header.js +38 -59
  39. package/lib/components/Layout/components/Header/header.stories.js +38 -41
  40. package/lib/components/Layout/components/Header/header.styles.d.ts +13 -1
  41. package/lib/components/Layout/components/Header/header.styles.js +23 -3
  42. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.d.ts +20 -0
  43. package/lib/components/Layout/components/Header/hooks/useHeaderVisibility.js +46 -0
  44. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
  45. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
  46. package/lib/config/entities.d.ts +2 -0
  47. package/lib/config/utils.js +1 -2
  48. package/lib/hooks/useBreakpoint.d.ts +17 -0
  49. package/lib/hooks/useBreakpoint.js +34 -0
  50. package/lib/hooks/useBreakpointHelper.d.ts +1 -1
  51. package/lib/hooks/useCurrentBreakpoint.d.ts +3 -0
  52. package/lib/hooks/useCurrentBreakpoint.js +11 -0
  53. package/lib/hooks/useMenu.d.ts +10 -0
  54. package/lib/hooks/useMenu.js +17 -0
  55. package/lib/theme/common/components.js +17 -0
  56. package/lib/views/ExploreView/exploreView.js +4 -29
  57. package/package.json +1 -1
  58. package/src/common/entities.ts +0 -11
  59. package/src/components/Index/components/Tabs/common/utils.ts +33 -0
  60. package/src/components/Index/components/Tabs/tabs.tsx +23 -0
  61. package/src/components/Layout/components/Header/common/constants.ts +14 -10
  62. package/src/components/Layout/components/Header/common/entities.ts +7 -0
  63. package/src/components/Layout/components/Header/common/utils.ts +89 -66
  64. package/src/components/Layout/components/Header/components/Announcements/announcements.tsx +14 -0
  65. package/src/components/Layout/components/Header/components/Content/components/Actions/actions.tsx +2 -6
  66. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.tsx +21 -32
  67. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Content/components/Navigation/navigation.styles.ts +2 -0
  68. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/components/Toolbar/toolbar.tsx +8 -6
  69. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Menu/menu.tsx +22 -27
  70. package/src/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.tsx +11 -22
  71. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationDrawer/navigationDrawer.tsx +3 -0
  72. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.styles.ts +15 -5
  73. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenu/navigationMenu.tsx +10 -8
  74. package/src/components/Layout/components/Header/components/Content/components/Navigation/components/NavigationMenuItems/navigationMenuItems.tsx +4 -0
  75. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.styles.ts +6 -30
  76. package/src/components/Layout/components/Header/components/Content/components/Navigation/navigation.tsx +12 -21
  77. package/src/components/Layout/components/Header/header.stories.tsx +38 -41
  78. package/src/components/Layout/components/Header/header.styles.ts +27 -4
  79. package/src/components/Layout/components/Header/header.tsx +102 -137
  80. package/src/components/Layout/components/Header/hooks/useHeaderVisibility.ts +74 -0
  81. package/src/components/Layout/components/Header/hooks/useMeasureHeader.ts +28 -0
  82. package/src/config/entities.ts +2 -0
  83. package/src/config/utils.ts +1 -2
  84. package/src/hooks/useBreakpoint.ts +54 -0
  85. package/src/hooks/useBreakpointHelper.ts +1 -1
  86. package/src/hooks/useCurrentBreakpoint.ts +23 -0
  87. package/src/hooks/useMenu.ts +27 -0
  88. package/src/theme/common/components.ts +17 -0
  89. package/src/views/ExploreView/exploreView.tsx +5 -34
  90. package/types/data-explorer-ui.d.ts +1 -0
@@ -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
- export const NavigationMenu = ({ anchorOrigin = { horizontal: "left", vertical: "bottom" }, closeAncestor, menuItems, menuLabel, }) => {
8
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
6
+ export const NavigationMenu = ({ anchorOrigin = { horizontal: "left", vertical: "bottom" }, closeAncestor, menuItems, menuLabel, pathname, }) => {
7
+ const { mdUp } = useBreakpoint();
9
8
  const [anchorEl, setAnchorEl] = useState(null);
10
9
  const open = Boolean(anchorEl);
11
10
  const openMenu = (event) => {
@@ -17,9 +16,9 @@ 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
  } },
24
- React.createElement(NavigationMenuItems, { closeMenu: closeMenu, menuItems: menuItems }))));
23
+ React.createElement(NavigationMenuItems, { closeMenu: closeMenu, menuItems: menuItems, pathname: pathname }))));
25
24
  };
@@ -1,10 +1,11 @@
1
1
  import { css } from "@emotion/react";
2
2
  import styled from "@emotion/styled";
3
3
  import { Menu as MMenu } from "@mui/material";
4
+ import { inkLight, smokeLight, smokeMain, } from "../../../../../../../../../../styles/common/mixins/colors";
4
5
  import { Button as DXButton } from "../../../../../../../../../common/Button/button";
5
6
  export const Menu = styled(MMenu) `
6
7
  .MuiPaper-menu {
7
- border-color: ${({ theme }) => theme.palette.smoke.main};
8
+ border-color: ${smokeMain};
8
9
  margin: 4px 0;
9
10
  max-width: 324px;
10
11
  min-width: 204px;
@@ -31,12 +32,17 @@ export const Menu = styled(MMenu) `
31
32
  }
32
33
 
33
34
  .MuiListItemText-secondary {
34
- color: ${({ theme }) => theme.palette.ink.light};
35
+ color: ${inkLight};
35
36
  white-space: normal;
36
37
  }
37
38
  }
39
+
40
+ &.Mui-selected {
41
+ background-color: ${smokeLight};
42
+ }
38
43
  }
39
44
 
45
+ .MuiButton-activeNav,
40
46
  .MuiButton-nav {
41
47
  font-weight: 400;
42
48
  justify-content: space-between;
@@ -57,8 +63,8 @@ export const Button = styled(DXButton, {
57
63
  shouldForwardProp: (prop) => prop !== "isActive",
58
64
  }) `
59
65
  // Button is "active" i.e. menu is open.
60
- ${({ isActive, theme }) => isActive &&
66
+ ${(props) => props.isActive &&
61
67
  css `
62
- background-color: ${theme.palette.smoke.light};
68
+ background-color: ${smokeLight(props)};
63
69
  `};
64
70
  `;
@@ -7,5 +7,6 @@ export interface MenuItem extends NavLinkItem {
7
7
  export interface NavLinkMenuProps {
8
8
  closeMenu: () => void;
9
9
  menuItems: MenuItem[];
10
+ pathname?: string;
10
11
  }
11
- export declare const NavigationMenuItems: ({ closeMenu, menuItems, }: NavLinkMenuProps) => JSX.Element;
12
+ export declare const NavigationMenuItems: ({ closeMenu, menuItems, pathname, }: NavLinkMenuProps) => JSX.Element;
@@ -5,15 +5,15 @@ import { TEXT_BODY_400, TEXT_BODY_500, TEXT_BODY_SMALL_400_2_LINES, } from "../.
5
5
  import { ANCHOR_TARGET } from "../../../../../../../../../Links/common/entities";
6
6
  import { isClientSideNavigation } from "../../../../../../../../../Links/common/utils";
7
7
  import { NavigationMenu } from "../NavigationMenu/navigationMenu";
8
- export const NavigationMenuItems = ({ closeMenu, menuItems, }) => {
8
+ export const NavigationMenuItems = ({ closeMenu, menuItems, pathname, }) => {
9
9
  const router = useRouter();
10
- return (React.createElement(React.Fragment, null, menuItems.map(({ description, divider, icon, label, menuItems: nestedMenuItems, target = ANCHOR_TARGET.SELF, url, }, i) => nestedMenuItems ? (React.createElement(NavigationMenu, { key: i, anchorOrigin: { horizontal: "right", vertical: "top" }, closeAncestor: closeMenu, menuItems: nestedMenuItems, menuLabel: label })) : (React.createElement(Fragment, { key: i },
10
+ return (React.createElement(React.Fragment, null, menuItems.map(({ description, divider, icon, label, menuItems: nestedMenuItems, target = ANCHOR_TARGET.SELF, url, }, i) => nestedMenuItems ? (React.createElement(NavigationMenu, { key: i, anchorOrigin: { horizontal: "right", vertical: "top" }, closeAncestor: closeMenu, menuItems: nestedMenuItems, menuLabel: label, pathname: pathname })) : (React.createElement(Fragment, { key: i },
11
11
  React.createElement(MMenuItem, { onClick: () => {
12
12
  closeMenu();
13
13
  isClientSideNavigation(url)
14
14
  ? router.push(url)
15
15
  : window.open(url, target, "noopener noreferrer");
16
- } },
16
+ }, selected: url === pathname },
17
17
  icon && React.createElement(ListItemIcon, null, icon),
18
18
  React.createElement(ListItemText, { primary: label, primaryTypographyProps: {
19
19
  variant: description ? TEXT_BODY_500 : TEXT_BODY_400,
@@ -1,22 +1,23 @@
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;
19
19
  links: NavLinkItem[];
20
+ pathname?: string;
20
21
  style?: CSSProperties;
21
22
  }
22
23
  export declare const Navigation: React.ForwardRefExoticComponent<NavigationProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,25 +1,23 @@
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, pathname, 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, pathname: pathname })) : (React.createElement(NavigationDrawer, { closeAncestor: closeAncestor, headerProps: headerProps, menuItems: menuItems, menuLabel: label, pathname: pathname })),
17
15
  divider && React.createElement(Divider, null))) : (React.createElement(Fragment, { key: i },
18
16
  React.createElement(Button, { onClick: () => {
19
17
  isClientSideNavigation(url)
20
18
  ? router.push(url)
21
19
  : window.open(url, target, "noopener noreferrer");
22
20
  closeAncestor?.();
23
- }, variant: "nav" }, label),
21
+ }, variant: url === pathname ? "activeNav" : "nav" }, label),
24
22
  divider && React.createElement(Divider, null))))));
25
23
  });
@@ -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>, {}>;
@@ -1,6 +1,4 @@
1
- import { css } from "@emotion/react";
2
1
  import styled from "@emotion/styled";
3
- import { ELEMENT_ALIGNMENT, } from "../../../../../../../../common/entities";
4
2
  import { mediaDesktopSmallUp } from "../../../../../../../../styles/common/mixins/breakpoints";
5
3
  import { textBody500 } from "../../../../../../../../styles/common/mixins/fonts";
6
4
  export const Navigation = styled("div") `
@@ -10,24 +8,12 @@ export const Navigation = styled("div") `
10
8
  gap: 8px;
11
9
  justify-content: flex-start;
12
10
 
13
- // Left alignment.
14
- ${({ alignment }) => alignment === ELEMENT_ALIGNMENT.LEFT &&
15
- css `
16
- margin-left: 24px;
17
- `};
18
-
19
- // Center alignment.
20
- ${({ alignment }) => alignment === ELEMENT_ALIGNMENT.CENTER &&
21
- css `
22
- justify-content: center;
23
- `};
24
-
25
- // Right alignment.
26
- ${({ alignment }) => alignment === ELEMENT_ALIGNMENT.RIGHT &&
27
- css `
28
- justify-content: flex-end;
29
- `};
11
+ ${mediaDesktopSmallUp} {
12
+ flex: unset;
13
+ justify-content: inherit;
14
+ }
30
15
 
16
+ .MuiButton-activeNav,
31
17
  .MuiButton-nav {
32
18
  ${textBody500};
33
19
  padding: 6px 12px;
@@ -1,15 +1,13 @@
1
1
  import { ReactNode } from "react";
2
- import { ElementAlignment } from "../../../../common/entities";
3
- import { SocialMedia } from "./common/entities";
4
- import { NavLinkItem } from "./components/Content/components/Navigation/navigation";
2
+ import { ComponentsConfig } from "../../../../config/entities";
3
+ import { Navigation, SocialMedia } from "./common/entities";
5
4
  export interface HeaderProps {
6
5
  actions?: ReactNode;
7
- Announcements?: ReactNode;
6
+ announcements?: ComponentsConfig;
8
7
  authenticationEnabled?: boolean;
9
8
  className?: string;
10
- Logo: ReactNode;
11
- navAlignment?: ElementAlignment;
12
- navLinks: NavLinkItem[];
9
+ logo: ReactNode;
10
+ navigation?: Navigation;
13
11
  searchEnabled?: boolean;
14
12
  searchURL?: string;
15
13
  slogan?: ReactNode;
@@ -1,69 +1,48 @@
1
1
  import { Fade, Toolbar } from "@mui/material";
2
- import React, { useCallback, useEffect, useRef, useState, } from "react";
3
- import { ELEMENT_ALIGNMENT, } from "../../../../common/entities";
4
- import { BREAKPOINT_FN_NAME, useBreakpointHelper, } from "../../../../hooks/useBreakpointHelper";
5
- import { useLayoutState } from "../../../../hooks/useLayoutState";
6
- import { getBorderBoxSizeHeight, useResizeObserver, } from "../../../../hooks/useResizeObserver";
7
- import { LayoutActionKind } from "../../../../providers/layoutState";
8
- import { DESKTOP, DESKTOP_SM } from "../../../../theme/common/breakpoints";
9
- import { FADE_TRANSITION_PROPS } from "./common/constants";
10
- import { getHeaderNavigationLinks } from "./common/utils";
2
+ import { usePathname } from "next/navigation";
3
+ import React from "react";
4
+ import { useBreakpoint } from "../../../../hooks/useBreakpoint";
5
+ import { useMenu } from "../../../../hooks/useMenu";
6
+ import { APP_BAR_PROPS, FADE_TRANSITION_PROPS, TOOLBAR_PROPS, } from "./common/constants";
7
+ import { getNavigationLinks } from "./common/utils";
8
+ import { Announcements } from "./components/Announcements/announcements";
11
9
  import { Actions } from "./components/Content/components/Actions/actions";
12
10
  import { Authentication } from "./components/Content/components/Actions/components/Authentication/authentication";
13
11
  import { Menu } from "./components/Content/components/Actions/components/Menu/menu";
14
12
  import { Search } from "./components/Content/components/Actions/components/Search/search";
15
- import { Navigation, } from "./components/Content/components/Navigation/navigation";
13
+ import { Navigation as DXNavigation } from "./components/Content/components/Navigation/navigation";
16
14
  import { Slogan } from "./components/Content/components/Slogan/slogan";
17
15
  import { Divider } from "./components/Content/components/Slogan/slogan.styles";
18
16
  import { Socials } from "./components/Content/components/Socials/socials.styles";
19
- import { AppBar as HeaderAppBar, HeaderSmAppBar } from "./header.styles";
17
+ import { AppBar, Center, Left, Right } from "./header.styles";
18
+ import { useHeaderVisibility } from "./hooks/useHeaderVisibility";
19
+ import { useMeasureHeader } from "./hooks/useMeasureHeader";
20
20
  export const Header = ({ ...headerProps }) => {
21
- const { Announcements, authenticationEnabled, actions, className, Logo, navAlignment = ELEMENT_ALIGNMENT.LEFT, navLinks, searchEnabled, searchURL, slogan, socialMedia, } = headerProps;
22
- const { layoutDispatch } = useLayoutState();
23
- const headerRef = useRef(null);
24
- const { height } = useResizeObserver(headerRef, getBorderBoxSizeHeight) || {};
25
- const [menuOpen, setMenuOpen] = useState(false);
26
- const onlySmDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, DESKTOP_SM);
27
- const smDesktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP_SM);
28
- const desktop = useBreakpointHelper(BREAKPOINT_FN_NAME.UP, DESKTOP);
29
- const AppBar = navAlignment === ELEMENT_ALIGNMENT.RIGHT ? HeaderSmAppBar : HeaderAppBar;
30
- const showActions = searchEnabled || authenticationEnabled || !smDesktop;
31
- const isNavigationIn = smDesktop;
32
- const isSloganIn = Boolean(slogan) && smDesktop;
33
- const isSocialsIn = Boolean(socialMedia) && desktop;
34
- const fadeProps = FADE_TRANSITION_PROPS;
35
- // Closes header menu.
36
- const closeMenu = useCallback(() => {
37
- setMenuOpen(false);
38
- }, []);
39
- // Opens header menu.
40
- const openMenu = useCallback(() => {
41
- setMenuOpen(true);
42
- }, []);
43
- // Updates layout state header height.
44
- useEffect(() => {
45
- if (!height)
46
- return;
47
- layoutDispatch({
48
- payload: height,
49
- type: LayoutActionKind.UpdateHeaderHeight,
50
- });
51
- }, [height, layoutDispatch]);
52
- return (React.createElement(AppBar, { ref: headerRef, className: className, elevation: 1, position: "fixed" },
53
- Announcements,
54
- React.createElement(Toolbar, { variant: "dense" },
55
- Logo,
56
- React.createElement(Fade, { in: isSloganIn, style: { transitionDelay: isSloganIn ? "50ms" : "0ms" }, ...fadeProps },
57
- React.createElement(Divider, { orientation: "vertical" })),
58
- React.createElement(Fade, { in: isSloganIn, style: { transitionDelay: isSloganIn ? "50ms" : "0ms" }, ...fadeProps },
59
- React.createElement(Slogan, { slogan: slogan })),
60
- React.createElement(Fade, { in: isNavigationIn, ...fadeProps },
61
- React.createElement(Navigation, { alignment: navAlignment, headerProps: headerProps, links: getHeaderNavigationLinks(navLinks, socialMedia, onlySmDesktop) })),
62
- socialMedia && (React.createElement(Fade, { in: isSocialsIn, ...fadeProps },
63
- React.createElement(Socials, { buttonSize: "small", socials: socialMedia.socials }))),
64
- React.createElement(Actions, { showActions: showActions },
65
- React.createElement(Search, { closeMenu: closeMenu, searchEnabled: searchEnabled, searchURL: searchURL }),
66
- React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: closeMenu }),
67
- actions,
68
- React.createElement(Menu, { closeMenu: closeMenu, headerProps: headerProps, open: menuOpen, openMenu: openMenu })))));
21
+ const { breakpoint } = useBreakpoint();
22
+ const { isIn } = useHeaderVisibility(headerProps);
23
+ const { headerRef } = useMeasureHeader();
24
+ const { onClose, onOpen, open } = useMenu();
25
+ const pathname = usePathname();
26
+ const { actions, announcements, authenticationEnabled, className, logo, navigation: [navItemsL, navItemsC, navItemsR] = [], searchEnabled, searchURL, slogan, socialMedia, } = headerProps;
27
+ const navigationProps = { headerProps, pathname };
28
+ return (React.createElement(AppBar, { ...APP_BAR_PROPS, ref: headerRef, className: className },
29
+ React.createElement(Announcements, { announcements: announcements }),
30
+ React.createElement(Toolbar, { ...TOOLBAR_PROPS },
31
+ React.createElement(Fade, { ...FADE_TRANSITION_PROPS, in: isIn.isLeftGroupIn },
32
+ React.createElement(Left, null,
33
+ logo,
34
+ isIn.isSloganIn && React.createElement(Divider, { flexItem: true, orientation: "vertical" }),
35
+ isIn.isSloganIn && React.createElement(Slogan, { slogan: slogan }),
36
+ isIn.isLeftNavigationIn && (React.createElement(DXNavigation, { ...navigationProps, links: getNavigationLinks(navItemsL, breakpoint) })))),
37
+ React.createElement(Fade, { ...FADE_TRANSITION_PROPS, in: isIn.isCenterGroupIn },
38
+ React.createElement(Center, null, isIn.isCenterNavigationIn && (React.createElement(DXNavigation, { ...navigationProps, links: getNavigationLinks(navItemsC, breakpoint) })))),
39
+ React.createElement(Fade, { ...FADE_TRANSITION_PROPS, in: isIn.isRightGroupIn },
40
+ React.createElement(Right, null,
41
+ isIn.isRightNavigationIn && (React.createElement(DXNavigation, { ...navigationProps, links: getNavigationLinks(navItemsR) })),
42
+ isIn.isSocialsIn && (React.createElement(Socials, { buttonSize: "small", socials: socialMedia?.socials || [] })),
43
+ isIn.isActionsIn && (React.createElement(Actions, null,
44
+ React.createElement(Search, { closeMenu: onClose, searchEnabled: searchEnabled, searchURL: searchURL }),
45
+ React.createElement(Authentication, { authenticationEnabled: authenticationEnabled, closeMenu: onClose }),
46
+ actions,
47
+ React.createElement(Menu, { ...navigationProps, closeMenu: onClose, open: open, openMenu: onOpen }))))))));
69
48
  };
@@ -1,21 +1,15 @@
1
1
  import React from "react";
2
- import { ELEMENT_ALIGNMENT } from "../../../../common/entities";
3
2
  import logo from "../../../../images/logo.svg";
4
3
  import { DiscourseIcon } from "../../../common/CustomIcon/components/DiscourseIcon/discourseIcon";
5
4
  import { GitHubIcon } from "../../../common/CustomIcon/components/GitHubIcon/gitHubIcon";
6
5
  import { XIcon } from "../../../common/CustomIcon/components/XIcon/xIcon";
7
6
  import { YouTubeIcon } from "../../../common/CustomIcon/components/YouTubeIcon/youTubeIcon";
8
- import { HEADER_NAVIGATION_LABEL } from "./common/constants";
9
7
  import { Logo } from "./components/Content/components/Logo/logo";
10
8
  import { Header } from "./header";
11
9
  export default {
12
10
  argTypes: {
13
- Logo: { control: { disable: true } },
14
11
  authenticationEnabled: { control: "boolean" },
15
- navAlignment: {
16
- control: "select",
17
- options: [ELEMENT_ALIGNMENT.LEFT, ELEMENT_ALIGNMENT.CENTER],
18
- },
12
+ logo: { control: { disable: true } },
19
13
  navLinks: { control: "array" },
20
14
  searchEnabled: { control: "boolean" },
21
15
  slogan: { control: "text" },
@@ -30,45 +24,48 @@ export default {
30
24
  const url = "/";
31
25
  export const HeaderStory = {
32
26
  args: {
33
- Logo: React.createElement(Logo, { alt: "Logo", height: 40, link: "/", src: logo }),
34
27
  authenticationEnabled: false,
35
- navAlignment: ELEMENT_ALIGNMENT.CENTER,
36
- navLinks: [
37
- {
38
- label: "Overview",
39
- url,
40
- },
41
- {
42
- label: "Learn",
43
- url,
44
- },
45
- {
46
- label: "Datasets",
47
- url,
48
- },
49
- {
50
- label: "More",
51
- menuItems: [
52
- {
53
- label: "Team",
54
- url,
55
- },
56
- {
57
- label: "FAQ",
58
- url,
59
- },
60
- {
61
- label: "Help",
62
- url,
63
- },
64
- ],
65
- url: "",
66
- },
28
+ logo: React.createElement(Logo, { alt: "Logo", height: 40, link: "/", src: logo }),
29
+ navigation: [
30
+ undefined,
31
+ [
32
+ {
33
+ label: "Overview",
34
+ url,
35
+ },
36
+ {
37
+ label: "Learn",
38
+ url,
39
+ },
40
+ {
41
+ label: "Datasets",
42
+ url,
43
+ },
44
+ {
45
+ label: "More",
46
+ menuItems: [
47
+ {
48
+ label: "Team",
49
+ url,
50
+ },
51
+ {
52
+ label: "FAQ",
53
+ url,
54
+ },
55
+ {
56
+ label: "Help",
57
+ url,
58
+ },
59
+ ],
60
+ url: "",
61
+ },
62
+ ],
63
+ undefined,
67
64
  ],
68
65
  searchEnabled: true,
69
66
  slogan: "Header Slogan",
70
67
  socialMedia: {
71
- label: HEADER_NAVIGATION_LABEL.SOCIALS,
68
+ label: "Follow Us",
72
69
  socials: [
73
70
  {
74
71
  Icon: XIcon,
@@ -1,2 +1,14 @@
1
+ /// <reference types="react" />
1
2
  export declare const AppBar: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").AppBarTypeMap<{}, "header">>;
2
- export declare const HeaderSmAppBar: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").AppBarTypeMap<{}, "header">>;
3
+ export declare const Left: import("@emotion/styled").StyledComponent<{
4
+ theme?: import("@emotion/react").Theme | undefined;
5
+ as?: import("react").ElementType<any> | undefined;
6
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
7
+ export declare const Center: import("@emotion/styled").StyledComponent<{
8
+ theme?: import("@emotion/react").Theme | undefined;
9
+ as?: import("react").ElementType<any> | undefined;
10
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
11
+ export declare const Right: import("@emotion/styled").StyledComponent<{
12
+ theme?: import("@emotion/react").Theme | undefined;
13
+ as?: import("react").ElementType<any> | undefined;
14
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -1,3 +1,4 @@
1
+ import { css } from "@emotion/react";
1
2
  import styled from "@emotion/styled";
2
3
  import { AppBar as MAppBar } from "@mui/material";
3
4
  import { HEADER_HEIGHT } from "./common/constants";
@@ -14,8 +15,27 @@ export const AppBar = styled(MAppBar) `
14
15
  min-height: unset;
15
16
  }
16
17
  `;
17
- export const HeaderSmAppBar = styled(AppBar) `
18
- .MuiToolbar-root {
19
- gap: 8px;
18
+ const group = css `
19
+ align-items: center;
20
+ display: flex;
21
+ flex: 1;
22
+ `;
23
+ export const Left = styled.div `
24
+ ${group};
25
+ gap: 16px;
26
+ justify-content: flex-start;
27
+
28
+ .MuiButton-navPrimary {
29
+ &:first-of-type {
30
+ margin-left: 24px;
31
+ }
20
32
  }
21
33
  `;
34
+ export const Center = styled.div `
35
+ ${group};
36
+ justify-content: center;
37
+ `;
38
+ export const Right = styled.div `
39
+ ${group};
40
+ justify-content: flex-end;
41
+ `;
@@ -0,0 +1,20 @@
1
+ import { HeaderProps } from "../header";
2
+ export interface UseHeaderVisibility {
3
+ isIn: {
4
+ isActionsIn: boolean;
5
+ isCenterGroupIn: boolean;
6
+ isCenterNavigationIn: boolean;
7
+ isLeftGroupIn: boolean;
8
+ isLeftNavigationIn: boolean;
9
+ isRightGroupIn: boolean;
10
+ isRightNavigationIn: boolean;
11
+ isSloganIn: boolean;
12
+ isSocialsIn: boolean;
13
+ };
14
+ }
15
+ /**
16
+ * Returns header component visibility for header related rendering logic.
17
+ * @param headerProps - Header component props.
18
+ * @returns header component visibility.
19
+ */
20
+ export declare const useHeaderVisibility: (headerProps: HeaderProps) => UseHeaderVisibility;
@@ -0,0 +1,46 @@
1
+ import { useBreakpoint } from "../../../../../hooks/useBreakpoint";
2
+ /**
3
+ * Returns header component visibility for header related rendering logic.
4
+ * @param headerProps - Header component props.
5
+ * @returns header component visibility.
6
+ */
7
+ export const useHeaderVisibility = (headerProps) => {
8
+ const { lgUp, mdUp } = useBreakpoint();
9
+ // Header configuration.
10
+ const { actions, authenticationEnabled, logo, navigation: [navItemsL, navItemsC, navItemsR] = [], searchEnabled, slogan, socialMedia, } = headerProps;
11
+ // Header content.
12
+ const hasActions = Boolean(actions);
13
+ const hasLogo = Boolean(logo);
14
+ const hasMenu = !mdUp;
15
+ const hasNavItemsC = Boolean(navItemsC);
16
+ const hasNavItemsL = Boolean(navItemsL);
17
+ const hasNavItemsR = Boolean(navItemsR);
18
+ const hasSlogan = Boolean(slogan);
19
+ const hasSocials = Boolean(socialMedia);
20
+ // Determines header content visibility.
21
+ const isActionsIn = hasActions || searchEnabled || authenticationEnabled || hasMenu;
22
+ const isNavigationIn = mdUp;
23
+ const isSloganIn = hasSlogan && mdUp;
24
+ const isSocialsIn = hasSocials && lgUp;
25
+ // Determines navigation visibility.
26
+ const isCenterNavigationIn = isNavigationIn && hasNavItemsC;
27
+ const isLeftNavigationIn = isNavigationIn && hasNavItemsL;
28
+ const isRightNavigationIn = isNavigationIn && hasNavItemsR;
29
+ // Determines group visibility.
30
+ const isLeftGroupIn = hasLogo || isSocialsIn || isLeftNavigationIn;
31
+ const isCenterGroupIn = isCenterNavigationIn;
32
+ const isRightGroupIn = isRightNavigationIn || isSocialsIn || isActionsIn;
33
+ return {
34
+ isIn: {
35
+ isActionsIn,
36
+ isCenterGroupIn,
37
+ isCenterNavigationIn,
38
+ isLeftGroupIn,
39
+ isLeftNavigationIn,
40
+ isRightGroupIn,
41
+ isRightNavigationIn,
42
+ isSloganIn,
43
+ isSocialsIn,
44
+ },
45
+ };
46
+ };
@@ -0,0 +1,5 @@
1
+ import { RefObject } from "react";
2
+ export interface UseMeasureHeader {
3
+ headerRef: RefObject<HTMLElement>;
4
+ }
5
+ export declare const useMeasureHeader: () => UseMeasureHeader;
@@ -0,0 +1,19 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { useLayoutState } from "../../../../../hooks/useLayoutState";
3
+ import { getBorderBoxSizeHeight, useResizeObserver, } from "../../../../../hooks/useResizeObserver";
4
+ import { LayoutActionKind } from "../../../../../providers/layoutState";
5
+ export const useMeasureHeader = () => {
6
+ const { layoutDispatch } = useLayoutState();
7
+ const headerRef = useRef(null);
8
+ const { height } = useResizeObserver(headerRef, getBorderBoxSizeHeight) || {};
9
+ // Updates layout state header height.
10
+ useEffect(() => {
11
+ if (!height)
12
+ return;
13
+ layoutDispatch({
14
+ payload: height,
15
+ type: LayoutActionKind.UpdateHeaderHeight,
16
+ });
17
+ }, [height, layoutDispatch]);
18
+ return { headerRef };
19
+ };
@@ -128,6 +128,7 @@ export interface EntityConfig<T = any, I = any> extends TabConfig {
128
128
  detail: BackPageConfig;
129
129
  entityMapper?: EntityMapper<T, I>;
130
130
  exploreMode: ExploreMode;
131
+ explorerTitle?: SiteConfig["explorerTitle"];
131
132
  getId?: GetIdFunction<T>;
132
133
  getTitle?: GetTitleFunction<T>;
133
134
  list: ListConfig;
@@ -212,6 +213,7 @@ export interface ListViewConfig {
212
213
  enableDownload?: boolean;
213
214
  enableRowPreview?: boolean;
214
215
  enableRowSelection?: boolean;
216
+ enableTab?: boolean;
215
217
  listHero?: ComponentsConfig;
216
218
  rowPreviewView?: ComponentsConfig;
217
219
  rowSelectionView?: ComponentsConfig;
@@ -20,8 +20,7 @@ export function getDefaultConfig() {
20
20
  socials: [],
21
21
  },
22
22
  header: {
23
- Logo: null,
24
- navLinks: [],
23
+ logo: null,
25
24
  },
26
25
  },
27
26
  redirectRootToPath: "",