@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
@@ -12,7 +12,7 @@ export enum BREAKPOINT_FN_NAME {
12
12
  }
13
13
 
14
14
  type BreakpointFnName = BREAKPOINT_FN_NAME;
15
- type BreakpointKey = Breakpoint;
15
+ export type BreakpointKey = Breakpoint;
16
16
 
17
17
  export const useBreakpointHelper = (
18
18
  fnName: BreakpointFnName,
@@ -0,0 +1,23 @@
1
+ import { Breakpoint } from "@mui/material";
2
+ import { useMemo } from "react";
3
+ import {
4
+ BreakpointKey,
5
+ BREAKPOINT_FN_NAME,
6
+ useBreakpointHelper,
7
+ } from "./useBreakpointHelper";
8
+
9
+ export type UseCurrentBreakpoint = BreakpointKey | undefined;
10
+
11
+ const breakpointKeys: BreakpointKey[] = ["xs", "sm", "md", "lg"];
12
+
13
+ export const useCurrentBreakpoint = (): UseCurrentBreakpoint => {
14
+ const xs = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "xs");
15
+ const sm = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "sm");
16
+ const md = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "md");
17
+ const lg = useBreakpointHelper(BREAKPOINT_FN_NAME.ONLY, "lg");
18
+ const breakpoints: Record<Breakpoint, boolean> = useMemo(
19
+ () => ({ lg, md, sm, xs }),
20
+ [lg, md, sm, xs]
21
+ );
22
+ return breakpointKeys.find((key) => breakpoints[key]);
23
+ };
@@ -0,0 +1,27 @@
1
+ import { useCallback, useState } from "react";
2
+
3
+ export interface UseMenu {
4
+ onClose: () => void;
5
+ onOpen: () => void;
6
+ open: boolean;
7
+ }
8
+
9
+ /**
10
+ * Menu functionality for menu dropdown.
11
+ * @returns menu functionality.
12
+ */
13
+ export const useMenu = (): UseMenu => {
14
+ const [open, setOpen] = useState<boolean>(false);
15
+
16
+ // Closes header menu.
17
+ const onClose = useCallback((): void => {
18
+ setOpen(false);
19
+ }, []);
20
+
21
+ // Opens header menu.
22
+ const onOpen = useCallback((): void => {
23
+ setOpen(true);
24
+ }, []);
25
+
26
+ return { onClose, onOpen, open };
27
+ };
@@ -1,4 +1,3 @@
1
- import { useRouter } from "next/router";
2
1
  import React, { useEffect, useMemo, useState } from "react";
3
2
  import {
4
3
  AzulEntitiesStaticResponse,
@@ -11,7 +10,6 @@ import {
11
10
  CategoryValueKey,
12
11
  SelectCategoryView,
13
12
  } from "../../common/entities";
14
- import { Tab, Tabs, TabValue } from "../../components/common/Tabs/tabs";
15
13
  import { ComponentCreator } from "../../components/ComponentCreator/ComponentCreator";
16
14
  import { ClearAllFilters } from "../../components/Filter/components/ClearAllFilters/clearAllFilters";
17
15
  import {
@@ -19,6 +17,7 @@ import {
19
17
  Filters,
20
18
  } from "../../components/Filter/components/Filters/filters";
21
19
  import { SearchAllFilters } from "../../components/Filter/components/SearchAllFilters/searchAllFilters";
20
+ import { Tabs } from "../../components/Index/components/Tabs/tabs";
22
21
  import { Index as IndexView } from "../../components/Index/index";
23
22
  import { SidebarButton } from "../../components/Layout/components/Sidebar/components/SidebarButton/sidebarButton";
24
23
  import { SidebarLabel } from "../../components/Layout/components/Sidebar/components/SidebarLabel/sidebarLabel";
@@ -47,33 +46,15 @@ export interface ExploreViewProps extends AzulEntitiesStaticResponse {
47
46
  className?: string;
48
47
  }
49
48
 
50
- /**
51
- * Returns tabs to be used as a prop for the Tabs component.
52
- * @param entities - Entities config.
53
- * @returns tabs list.
54
- */
55
- function getTabs(entities: EntityConfig[]): Tab[] {
56
- return entities.map(
57
- ({ label, route, tabIcon: icon, tabIconPosition: iconPosition }) => ({
58
- icon,
59
- iconPosition,
60
- label,
61
- value: route,
62
- })
63
- );
64
- }
65
-
66
49
  export const ExploreView = (props: ExploreViewProps): JSX.Element => {
67
50
  const [isDrawerOpen, setIsDrawerOpen] = useState<boolean>(false);
68
51
  const tabletDown = useBreakpointHelper(BREAKPOINT_FN_NAME.DOWN, DESKTOP_SM);
69
52
  const { config, entityConfig } = useConfig(); // Get app level config.
70
53
  const { exploreDispatch, exploreState } = useExploreState(); // Get the useReducer state and dispatch for "Explore".
71
- const { entities, explorerTitle, summaryConfig, trackingConfig } = config;
54
+ const { explorerTitle, summaryConfig, trackingConfig } = config;
72
55
  const { listView } = entityConfig;
73
56
  const { listHero, subTitleHero } = listView || {};
74
- const { categoryGroups, categoryViews, filterCount, tabValue } = exploreState;
75
- const { push } = useRouter();
76
- const tabs = getTabs(entities);
57
+ const { categoryGroups, categoryViews, filterCount } = exploreState;
77
58
  const { response: summaryResponse } = useSummary(); // Fetch summary.
78
59
  useEntityList(props); // Fetch entities.
79
60
  const { entityListType } = props;
@@ -145,16 +126,6 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
145
126
  setIsDrawerOpen(true);
146
127
  };
147
128
 
148
- /**
149
- * Callback fired when selected tab value changes.
150
- * - Sets state tabsValue to selected tab value.
151
- * - Executes a pushState and resets pagination.
152
- * @param tabValue - Selected tab value.
153
- */
154
- const onTabChange = (tabValue: TabValue): void => {
155
- push(`/${tabValue}`);
156
- };
157
-
158
129
  /**
159
130
  * Dispatch a SelectedEntityType action when entityListType changes.
160
131
  */
@@ -206,8 +177,8 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
206
177
  }
207
178
  SubTitleHero={renderComponent(subTitleHero)}
208
179
  Summaries={renderSummary(summaryConfig, summaryResponse)}
209
- Tabs={<Tabs onTabChange={onTabChange} tabs={tabs} value={tabValue} />}
210
- title={explorerTitle}
180
+ Tabs={<Tabs />}
181
+ title={entityConfig.explorerTitle || explorerTitle}
211
182
  />
212
183
  </>
213
184
  );