@databiosphere/findable-ui 34.1.0 → 35.0.2
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.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +26 -0
- package/lib/components/DataDictionary/components/Table/columns/columnDef.d.ts +6 -0
- package/lib/components/DataDictionary/components/Table/columns/columnDef.js +33 -0
- package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.d.ts +5 -0
- package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.js +5 -0
- package/lib/components/DataDictionary/components/Table/columns/types.d.ts +2 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +4 -0
- package/lib/components/DataDictionary/components/Table/components/BasicCell/types.js +1 -0
- package/lib/components/Detail/components/Table/components/TableHead/tableHead.d.ts +8 -0
- package/lib/components/Detail/components/Table/components/TableHead/tableHead.js +36 -0
- package/lib/components/Filter/components/Filter/filter.stories.d.ts +25 -0
- package/lib/components/Filter/components/Filter/filter.stories.js +42 -0
- package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +16 -0
- package/lib/components/Filter/components/FilterTag/filterTag.stories.js +17 -0
- package/lib/components/Filter/components/Filters/filters.stories.d.ts +6 -0
- package/lib/components/Filter/components/Filters/filters.stories.js +91 -0
- package/lib/components/Index/components/Cell/cell.d.ts +7 -0
- package/lib/components/Index/components/Cell/cell.js +10 -0
- package/lib/components/Index/components/EntitiesView/constants.d.ts +1 -0
- package/lib/components/Index/components/EntitiesView/constants.js +1 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.d.ts +13 -0
- package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.js +18 -0
- package/lib/components/Index/components/Hero/hero.stories.d.ts +23 -0
- package/lib/components/Index/components/Hero/hero.stories.js +22 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.d.ts +8 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.js +57 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.d.ts +4 -0
- package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.js +10 -0
- package/lib/components/Index/components/NTag/nTag.d.ts +10 -0
- package/lib/components/Index/components/NTag/nTag.js +8 -0
- package/lib/components/Index/components/NTagCell/nTagCell.d.ts +11 -0
- package/lib/components/Index/components/NTagCell/nTagCell.js +29 -0
- package/lib/components/Index/components/NTagCell/nTagCell.stories.d.ts +5 -0
- package/lib/components/Index/components/NTagCell/nTagCell.stories.js +16 -0
- package/lib/components/Index/components/TitleCell/titleCell.d.ts +6 -0
- package/lib/components/Index/components/TitleCell/titleCell.js +10 -0
- package/lib/components/Index/components/TitleCell/titleCell.styles.d.ts +3 -0
- package/lib/components/Index/components/TitleCell/titleCell.styles.js +6 -0
- package/lib/components/Index/index.stories.d.ts +6 -0
- package/lib/components/Index/index.stories.js +26 -0
- package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.d.ts +6 -0
- package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.js +10 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.d.ts +5 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.js +29 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.d.ts +6 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +13 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +36 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.js +9 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.d.ts +5 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +10 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +36 -0
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.js +9 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
- package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
- package/lib/components/Layout/components/Outline/common/constants.d.ts +2 -0
- package/lib/components/Layout/components/Outline/common/constants.js +1 -0
- package/lib/components/Login/login.stories.d.ts +6 -0
- package/lib/components/Login/login.stories.js +31 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.d.ts +16 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +28 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.d.ts +5 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.js +46 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +3 -0
- package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +21 -0
- package/lib/components/Table/components/EntityViewToggle/entityViewToggle.d.ts +2 -0
- package/lib/components/Table/components/EntityViewToggle/entityViewToggle.js +37 -0
- package/lib/components/TableCreator/common/constants.d.ts +6 -0
- package/lib/components/TableCreator/common/constants.js +19 -0
- package/lib/components/TableCreator/common/entities.d.ts +5 -0
- package/lib/components/TableCreator/common/entities.js +1 -0
- package/lib/components/TableCreator/tableCreator.styles.d.ts +4 -0
- package/lib/components/TableCreator/tableCreator.styles.js +4 -0
- package/lib/components/common/Alert/alert.stories.d.ts +6 -0
- package/lib/components/common/Alert/alert.stories.js +36 -0
- package/lib/components/common/Alert/components/AlertText/alertText.styles.d.ts +4 -0
- package/lib/components/common/Alert/components/AlertText/alertText.styles.js +19 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.d.ts +7 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.js +5 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.d.ts +3 -0
- package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.js +19 -0
- package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.d.ts +10 -0
- package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.js +16 -0
- package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.d.ts +3 -0
- package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.js +21 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.d.ts +3 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.js +6 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.styles.d.ts +7 -0
- package/lib/components/common/Button/components/LoginButton/loginButton.styles.js +11 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.d.ts +5 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.js +10 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.d.ts +3 -0
- package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.js +9 -0
- package/lib/hooks/stateSyncManager/hook.d.ts +19 -0
- package/lib/hooks/stateSyncManager/hook.js +35 -0
- package/lib/hooks/stateSyncManager/hooks/UseBeforePopState/hook.d.ts +1 -0
- package/lib/hooks/stateSyncManager/hooks/UseBeforePopState/hook.js +21 -0
- package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/hook.d.ts +2 -0
- package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/hook.js +23 -0
- package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/types.d.ts +4 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.d.ts +2 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.js +40 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.d.ts +30 -0
- package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.js +41 -0
- package/lib/hooks/stateSyncManager/types.d.ts +26 -0
- package/lib/hooks/stateSyncManager/types.js +1 -0
- package/lib/hooks/useAuthentication/common/constants.d.ts +4 -0
- package/lib/hooks/useAuthentication/common/constants.js +19 -0
- package/lib/hooks/useAuthentication/common/entities.d.ts +25 -0
- package/lib/hooks/useAuthentication/common/entities.js +11 -0
- package/lib/hooks/useAuthentication/common/utils.d.ts +15 -0
- package/lib/hooks/useAuthentication/common/utils.js +25 -0
- package/lib/hooks/useAuthentication/useAuthentication.d.ts +6 -0
- package/lib/hooks/useAuthentication/useAuthentication.js +9 -0
- package/lib/hooks/useAuthentication/useAuthenticationComplete.d.ts +6 -0
- package/lib/hooks/useAuthentication/useAuthenticationComplete.js +55 -0
- package/lib/hooks/useAuthentication/useAuthenticationForm.d.ts +20 -0
- package/lib/hooks/useAuthentication/useAuthenticationForm.js +88 -0
- package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.d.ts +18 -0
- package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.js +50 -0
- package/lib/hooks/useAuthentication/useAuthenticationStatus.d.ts +20 -0
- package/lib/hooks/useAuthentication/useAuthenticationStatus.js +32 -0
- package/lib/hooks/useAuthentication/useFetchGoogleProfile.d.ts +21 -0
- package/lib/hooks/useAuthentication/useFetchGoogleProfile.js +41 -0
- package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.d.ts +18 -0
- package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.js +62 -0
- package/lib/hooks/useAuthentication/useFetchTerraProfile.d.ts +24 -0
- package/lib/hooks/useAuthentication/useFetchTerraProfile.js +62 -0
- package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.d.ts +15 -0
- package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.js +62 -0
- package/lib/hooks/useAuthentication/useTokenClient.d.ts +11 -0
- package/lib/hooks/useAuthentication/useTokenClient.js +29 -0
- package/lib/hooks/useAuthenticationConfig.d.ts +6 -0
- package/lib/hooks/useAuthenticationConfig.js +14 -0
- package/lib/hooks/useCategoryConfigs.d.ts +6 -0
- package/lib/hooks/useCategoryConfigs.js +17 -0
- package/lib/hooks/useEntityListRelatedView.d.ts +15 -0
- package/lib/hooks/useEntityListRelatedView.js +62 -0
- package/lib/hooks/useExploreMode.d.ts +14 -0
- package/lib/hooks/useExploreMode.js +20 -0
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.d.ts +15 -0
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.js +27 -0
- package/lib/hooks/useFileManifest/useFileManifestURL.d.ts +5 -0
- package/lib/hooks/useFileManifest/useFileManifestURL.js +11 -0
- package/lib/hooks/useFileManifest/useRequestFileManifest.d.ts +9 -0
- package/lib/hooks/useFileManifest/useRequestFileManifest.js +37 -0
- package/lib/hooks/useLayoutState.d.ts +6 -0
- package/lib/hooks/useLayoutState.js +9 -0
- package/lib/hooks/useMenu.d.ts +10 -0
- package/lib/hooks/useMenu.js +17 -0
- package/lib/hooks/useMenuWithPosition.d.ts +14 -0
- package/lib/hooks/useMenuWithPosition.js +33 -0
- package/lib/hooks/useSessionTimeout.d.ts +11 -0
- package/lib/hooks/useSessionTimeout.js +28 -0
- package/lib/providers/authentication.d.ts +51 -0
- package/lib/providers/authentication.js +110 -0
- package/lib/providers/exploreState/actions/stateToUrl/action.d.ts +9 -0
- package/lib/providers/exploreState/actions/stateToUrl/action.js +14 -0
- package/lib/providers/exploreState/actions/stateToUrl/dispatch.d.ts +7 -0
- package/lib/providers/exploreState/actions/{syncStateFromUrl → stateToUrl}/dispatch.js +3 -3
- package/lib/providers/exploreState/actions/stateToUrl/types.d.ts +12 -0
- package/lib/providers/exploreState/actions/stateToUrl/types.js +5 -0
- package/lib/providers/exploreState/actions/urlToState/action.d.ts +9 -0
- package/lib/providers/exploreState/actions/urlToState/action.js +38 -0
- package/lib/providers/exploreState/actions/urlToState/dispatch.d.ts +7 -0
- package/lib/providers/exploreState/actions/urlToState/dispatch.js +12 -0
- package/lib/providers/exploreState/actions/urlToState/types.d.ts +9 -0
- package/lib/providers/exploreState/actions/urlToState/types.js +1 -0
- package/lib/providers/exploreState/actions/urlToState/utils.d.ts +7 -0
- package/lib/providers/exploreState/actions/urlToState/utils.js +13 -0
- package/lib/providers/{exploreStateSync/hooks/UseMetaCommands/utils.d.ts → exploreState/entities/query/buildQuery.d.ts} +10 -14
- package/lib/providers/{exploreStateSync/hooks/UseMetaCommands/utils.js → exploreState/entities/query/buildQuery.js} +13 -21
- package/lib/providers/exploreState/entities/state.d.ts +10 -0
- package/lib/providers/exploreState/entities/state.js +36 -0
- package/lib/providers/exploreState/entities/types.d.ts +16 -0
- package/lib/providers/exploreState/entities/types.js +1 -0
- package/lib/providers/exploreState/entities.d.ts +1 -1
- package/lib/providers/exploreState/initializer/constants.js +1 -0
- package/lib/providers/exploreState/initializer/utils.js +26 -1
- package/lib/providers/exploreState.d.ts +8 -4
- package/lib/providers/exploreState.js +20 -15
- package/lib/providers/layoutState.d.ts +40 -0
- package/lib/providers/layoutState.js +47 -0
- package/lib/providers/services/provider.d.ts +14 -0
- package/lib/providers/services/provider.js +18 -0
- package/lib/providers/services/wasPop/context.d.ts +2 -0
- package/lib/providers/services/wasPop/context.js +5 -0
- package/lib/providers/services/wasPop/hook.d.ts +2 -0
- package/lib/providers/services/wasPop/hook.js +5 -0
- package/lib/providers/services/wasPop/provider.d.ts +16 -0
- package/lib/providers/services/wasPop/provider.js +30 -0
- package/lib/providers/services/wasPop/types.d.ts +6 -0
- package/lib/providers/services/wasPop/types.js +1 -0
- package/lib/services/beforePopState/popStateBus.d.ts +20 -0
- package/lib/services/beforePopState/popStateBus.js +58 -0
- package/lib/services/beforePopState/types.d.ts +11 -0
- package/lib/services/beforePopState/types.js +1 -0
- package/lib/services/beforePopState/useOnPopState.d.ts +2 -0
- package/lib/services/beforePopState/useOnPopState.js +10 -0
- package/lib/services/beforePopState/usePopStateBus.d.ts +6 -0
- package/lib/services/beforePopState/usePopStateBus.js +12 -0
- package/lib/styles/common/mixins/shadows.d.ts +3 -0
- package/lib/styles/common/mixins/shadows.js +4 -0
- package/lib/styles/common/mui/palette.d.ts +47 -0
- package/lib/styles/common/mui/palette.js +47 -0
- package/lib/theme/common/entities.d.ts +6 -0
- package/lib/theme/common/entities.js +1 -0
- package/lib/views/ExploreView/exploreView.js +15 -2
- package/lib/views/ExploreView/utils.d.ts +14 -0
- package/lib/views/ExploreView/utils.js +17 -0
- package/package.json +1 -1
- package/src/hooks/stateSyncManager/hook.ts +47 -0
- package/src/hooks/stateSyncManager/hooks/UseBeforePopState/hook.ts +30 -0
- package/src/hooks/stateSyncManager/hooks/UseMetaCommands/hook.ts +30 -0
- package/src/hooks/stateSyncManager/hooks/UseMetaCommands/types.ts +4 -0
- package/src/hooks/stateSyncManager/hooks/UseStateSync/hook.ts +52 -0
- package/src/hooks/stateSyncManager/hooks/UseStateSync/utils.ts +58 -0
- package/src/hooks/stateSyncManager/types.ts +34 -0
- package/src/providers/exploreState/actions/stateToUrl/action.ts +20 -0
- package/src/providers/exploreState/actions/stateToUrl/dispatch.ts +14 -0
- package/src/providers/exploreState/actions/stateToUrl/types.ts +15 -0
- package/src/providers/exploreState/actions/urlToState/action.ts +74 -0
- package/src/providers/exploreState/actions/urlToState/dispatch.ts +14 -0
- package/src/providers/exploreState/actions/urlToState/types.ts +11 -0
- package/src/providers/exploreState/actions/urlToState/utils.ts +18 -0
- package/src/providers/{exploreStateSync/hooks/UseMetaCommands/utils.ts → exploreState/entities/query/buildQuery.ts} +23 -26
- package/src/providers/exploreState/entities/state.ts +50 -0
- package/src/providers/exploreState/entities/types.ts +19 -0
- package/src/providers/exploreState/entities.ts +1 -1
- package/src/providers/exploreState/initializer/constants.ts +1 -0
- package/src/providers/exploreState/initializer/utils.ts +30 -1
- package/src/providers/exploreState.tsx +27 -20
- package/src/providers/services/provider.tsx +25 -0
- package/src/providers/services/wasPop/context.ts +7 -0
- package/src/providers/services/wasPop/hook.ts +7 -0
- package/src/providers/services/wasPop/provider.tsx +45 -0
- package/src/providers/services/wasPop/types.ts +7 -0
- package/src/services/beforePopState/popStateBus.ts +64 -0
- package/src/services/beforePopState/types.ts +15 -0
- package/src/services/beforePopState/useOnPopState.ts +15 -0
- package/src/services/beforePopState/usePopStateBus.ts +14 -0
- package/src/views/ExploreView/exploreView.tsx +17 -3
- package/src/views/ExploreView/utils.ts +25 -0
- package/lib/providers/exploreState/actions/syncStateFromUrl/action.d.ts +0 -10
- package/lib/providers/exploreState/actions/syncStateFromUrl/action.js +0 -25
- package/lib/providers/exploreState/actions/syncStateFromUrl/dispatch.d.ts +0 -7
- package/lib/providers/exploreState/actions/syncStateFromUrl/types.d.ts +0 -8
- package/lib/providers/exploreState/actions/syncStateFromUrl/utils.d.ts +0 -9
- package/lib/providers/exploreState/actions/syncStateFromUrl/utils.js +0 -23
- package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.d.ts +0 -18
- package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.js +0 -41
- package/lib/providers/exploreState/hooks/UseBeforePopState/utils.d.ts +0 -23
- package/lib/providers/exploreState/hooks/UseBeforePopState/utils.js +0 -68
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.d.ts +0 -10
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.js +0 -18
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.d.ts +0 -1
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.js +0 -33
- package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.d.ts +0 -11
- package/lib/providers/exploreStateSync/provider.d.ts +0 -19
- package/lib/providers/exploreStateSync/provider.js +0 -22
- package/src/providers/exploreState/actions/syncStateFromUrl/action.ts +0 -44
- package/src/providers/exploreState/actions/syncStateFromUrl/dispatch.ts +0 -16
- package/src/providers/exploreState/actions/syncStateFromUrl/types.ts +0 -13
- package/src/providers/exploreState/actions/syncStateFromUrl/utils.ts +0 -31
- package/src/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.ts +0 -46
- package/src/providers/exploreState/hooks/UseBeforePopState/utils.ts +0 -93
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/handlers.ts +0 -25
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/hook.ts +0 -38
- package/src/providers/exploreStateSync/hooks/UseMetaCommands/types.ts +0 -13
- package/src/providers/exploreStateSync/provider.tsx +0 -29
- /package/lib/{providers/exploreState/actions/syncStateFromUrl → components/DataDictionary/components/Table/columns}/types.js +0 -0
- /package/lib/{providers/exploreStateSync → hooks/stateSyncManager}/hooks/UseMetaCommands/types.js +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ExploreState } from "../../../exploreState";
|
|
2
|
-
import { getFilterCount } from "../../../exploreState/utils";
|
|
3
|
-
import { SyncStateFromUrlPayload } from "./types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Builds the next state, syncing the catalog state, feature flag state, and filter state.
|
|
7
|
-
* @param state - Explore state.
|
|
8
|
-
* @param payload - Payload.
|
|
9
|
-
* @returns state.
|
|
10
|
-
*/
|
|
11
|
-
export function buildNextState(
|
|
12
|
-
state: ExploreState,
|
|
13
|
-
payload: SyncStateFromUrlPayload
|
|
14
|
-
): Partial<ExploreState> {
|
|
15
|
-
// Initialize filter count and filter state from current state.
|
|
16
|
-
let filterCount = state.filterCount;
|
|
17
|
-
let filterState = state.filterState;
|
|
18
|
-
|
|
19
|
-
// Only update filter count and filter state if the payload entityListType matches the current tab value.
|
|
20
|
-
if (payload.entityListType === state.tabValue) {
|
|
21
|
-
filterCount = getFilterCount(payload.filterState);
|
|
22
|
-
filterState = payload.filterState;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
catalogState: payload.catalogState,
|
|
27
|
-
featureFlagState: payload.featureFlagState,
|
|
28
|
-
filterCount,
|
|
29
|
-
filterState,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useRouter } from "next/router";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { ExploreStateContextProps } from "../../../exploreState";
|
|
4
|
-
import { syncStateFromUrl } from "../../../exploreState/actions/syncStateFromUrl/dispatch";
|
|
5
|
-
import { getSyncStateFromUrl } from "./utils";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* useBeforePopState
|
|
9
|
-
*
|
|
10
|
-
* Keeps ExploreState, URL, and page props aligned when the user clicks
|
|
11
|
-
* the browser Back / Forward buttons.
|
|
12
|
-
*
|
|
13
|
-
* This hook runs inside `ExploreStateProvider` (mounted once in `_app`).
|
|
14
|
-
* It adds a single `router.beforePopState` handler that:
|
|
15
|
-
* - Parses the destination URL.
|
|
16
|
-
* - Dispatches `syncStateFromUrl` so filters, catalogue, and feature-flags in context match the URL.
|
|
17
|
-
* - Calls `router.replace(...{ shallow: false })` to trigger a full page transition, ensuring Next.js
|
|
18
|
-
* re-executes data-fetching methods that shallow routing would otherwise skip.
|
|
19
|
-
*
|
|
20
|
-
* The provider never unmounts, and a second call to `router.beforePopState` simply overwrites the handler.
|
|
21
|
-
* Cleaning up here would wipe out any handler registered later by other code.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
export const useBeforePopState = ({
|
|
25
|
-
exploreDispatch,
|
|
26
|
-
}: ExploreStateContextProps): void => {
|
|
27
|
-
const router = useRouter();
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
router.beforePopState(({ as, options, url }) => {
|
|
30
|
-
// Grab the expected state from URL.
|
|
31
|
-
const payload = getSyncStateFromUrl(url, as);
|
|
32
|
-
// Only dispatch if the url contains the dynamic segment `[entityListType]`.
|
|
33
|
-
if (payload.entityListType) {
|
|
34
|
-
// Sync state from URL.
|
|
35
|
-
exploreDispatch(syncStateFromUrl(payload));
|
|
36
|
-
// Force a full route transition to ensure page props are refreshed.
|
|
37
|
-
router.replace(url, as, { ...options, shallow: false });
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
// Return true to allow the popstate event to continue.
|
|
41
|
-
return true;
|
|
42
|
-
});
|
|
43
|
-
// No cleanup handler: see the JSDoc above for why we do not reset beforePopState here.
|
|
44
|
-
// Resetting would remove any handler registered by other parts of the app after this hook mounted.
|
|
45
|
-
}, [exploreDispatch, router]);
|
|
46
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { SelectedFilter } from "../../../../common/entities";
|
|
2
|
-
import { SyncStateFromUrlPayload } from "../../../exploreState/actions/syncStateFromUrl/types";
|
|
3
|
-
import { EXPLORE_URL_PARAMS } from "../../../exploreState/constants";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns the filters from the resolved URL.
|
|
7
|
-
* @param paramValue - The filter parameter value.
|
|
8
|
-
* @returns The filters or an empty array.
|
|
9
|
-
*/
|
|
10
|
-
export function decodeFiltersParamValue(
|
|
11
|
-
paramValue: string | undefined
|
|
12
|
-
): SelectedFilter[] {
|
|
13
|
-
return JSON.parse(decodeURIComponent(paramValue || "[]"));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Returns the dynamic segment from the resolved URL.
|
|
18
|
-
* @param pattern - The pattern URL.
|
|
19
|
-
* @param resolved - The resolved URL.
|
|
20
|
-
* @param dynamicSegment - The dynamic segment to extract.
|
|
21
|
-
* @returns The dynamic segment or an empty string.
|
|
22
|
-
*/
|
|
23
|
-
function getDynamicSegment(
|
|
24
|
-
pattern: string,
|
|
25
|
-
resolved: string,
|
|
26
|
-
dynamicSegment = "[entityListType]"
|
|
27
|
-
): string {
|
|
28
|
-
// Remove query strings.
|
|
29
|
-
const patternPath = pattern.split("?")[0];
|
|
30
|
-
const resolvedPath = resolved.split("?")[0];
|
|
31
|
-
|
|
32
|
-
// Check if the pattern ends with the dynamic segment e.g. /data/[entityListType].
|
|
33
|
-
// We are not interested in a pattern the suggests we are on an entity page e.g. /data/[entityListType]/[entityId].
|
|
34
|
-
if (!patternPath.endsWith(`/${dynamicSegment}`)) return "";
|
|
35
|
-
|
|
36
|
-
// Split into segments.
|
|
37
|
-
const patternSegments = patternPath.split("/");
|
|
38
|
-
const resolvedSegments = resolvedPath.split("/");
|
|
39
|
-
|
|
40
|
-
// Find the dynamic segment.
|
|
41
|
-
const idx = patternSegments.findIndex((seg) => seg === dynamicSegment);
|
|
42
|
-
|
|
43
|
-
if (idx === -1) return "";
|
|
44
|
-
|
|
45
|
-
return resolvedSegments[idx] || "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Returns a parameter from the resolved URL.
|
|
50
|
-
* @param resolved - The resolved URL.
|
|
51
|
-
* @param param - The parameter to extract.
|
|
52
|
-
* @returns The parameter value or undefined.
|
|
53
|
-
*/
|
|
54
|
-
export function getParamValue(
|
|
55
|
-
resolved: string,
|
|
56
|
-
param: string
|
|
57
|
-
): string | undefined {
|
|
58
|
-
// Grab the params from the resolved URL.
|
|
59
|
-
const params = new URLSearchParams(resolved.split("?")[1]);
|
|
60
|
-
const paramValue = params.get(param);
|
|
61
|
-
|
|
62
|
-
// Return the parameter value or undefined.
|
|
63
|
-
if (!paramValue) return;
|
|
64
|
-
|
|
65
|
-
return paramValue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Returns the entity list type, filters, and feature flag state from the URL.
|
|
70
|
-
* A dynamic segment that is not exactly `[entityListType]` is not supported will return entityListType as an empty string.
|
|
71
|
-
* @param url - The URL to extract from.
|
|
72
|
-
* @param as - The resolved URL.
|
|
73
|
-
* @returns An object containing the entity list type, filters, and feature flag state.
|
|
74
|
-
*/
|
|
75
|
-
export function getSyncStateFromUrl(
|
|
76
|
-
url: string,
|
|
77
|
-
as: string
|
|
78
|
-
): SyncStateFromUrlPayload {
|
|
79
|
-
// Get the entity list type from the url.
|
|
80
|
-
const entityListType = getDynamicSegment(url, as);
|
|
81
|
-
|
|
82
|
-
// Get the param values for each param.
|
|
83
|
-
const [catalogState, featureFlagState, filter] = [
|
|
84
|
-
EXPLORE_URL_PARAMS.CATALOG,
|
|
85
|
-
EXPLORE_URL_PARAMS.FEATURE_FLAG,
|
|
86
|
-
EXPLORE_URL_PARAMS.FILTER,
|
|
87
|
-
].map((param) => getParamValue(as, param));
|
|
88
|
-
|
|
89
|
-
// Decode the filter param value to selected filters.
|
|
90
|
-
const filterState = decodeFiltersParamValue(filter);
|
|
91
|
-
|
|
92
|
-
return { catalogState, entityListType, featureFlagState, filterState };
|
|
93
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Router, { NextRouter } from "next/router";
|
|
2
|
-
import { ExploreQueryState } from "./types";
|
|
3
|
-
import { buildQuery, stringifyQuery } from "./utils";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Updates the URL query parameters based on state.
|
|
7
|
-
* Pushes or replaces the query to the router.
|
|
8
|
-
* @param state - State -- partial explore state.
|
|
9
|
-
* @param currentQuery - Query -- current.
|
|
10
|
-
* @param method - "push" or "replace".
|
|
11
|
-
*/
|
|
12
|
-
export function updateUrlFromState(
|
|
13
|
-
state: ExploreQueryState,
|
|
14
|
-
currentQuery: NextRouter["query"],
|
|
15
|
-
method: "push" | "replace" = "push"
|
|
16
|
-
): void {
|
|
17
|
-
// Build the next query.
|
|
18
|
-
const query = buildQuery(state);
|
|
19
|
-
|
|
20
|
-
// Do nothing if the next query is the same as the current query.
|
|
21
|
-
if (stringifyQuery(query) === stringifyQuery(currentQuery)) return;
|
|
22
|
-
|
|
23
|
-
// Push or replace the query to the router.
|
|
24
|
-
Router[method]({ query }, undefined, { shallow: true });
|
|
25
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useRouter } from "next/router";
|
|
2
|
-
import { useEffect, useMemo } from "react";
|
|
3
|
-
import { useExploreState } from "../../../../hooks/useExploreState";
|
|
4
|
-
import { clearMeta } from "../../../exploreState/actions/clearMeta/dispatch";
|
|
5
|
-
import { updateUrlFromState } from "./handlers";
|
|
6
|
-
import { META_COMMAND } from "./types";
|
|
7
|
-
import { getQueryState } from "./utils";
|
|
8
|
-
|
|
9
|
-
export const useMetaCommands = (): void => {
|
|
10
|
-
const { exploreDispatch, exploreState } = useExploreState();
|
|
11
|
-
|
|
12
|
-
// Router must be ready before executing any meta-command side effects.
|
|
13
|
-
const { isReady, query } = useRouter();
|
|
14
|
-
|
|
15
|
-
// Command.
|
|
16
|
-
const command = exploreState.meta?.command;
|
|
17
|
-
|
|
18
|
-
// Extract relevant state to update URL.
|
|
19
|
-
const state = useMemo(() => getQueryState(exploreState), [exploreState]);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
// Do nothing if the router is not ready.
|
|
23
|
-
if (!isReady) return;
|
|
24
|
-
|
|
25
|
-
switch (command) {
|
|
26
|
-
case META_COMMAND.STATE_TO_URL_PUSH:
|
|
27
|
-
updateUrlFromState(state, query);
|
|
28
|
-
exploreDispatch(clearMeta());
|
|
29
|
-
break;
|
|
30
|
-
case META_COMMAND.STATE_TO_URL_REPLACE:
|
|
31
|
-
updateUrlFromState(state, query, "replace");
|
|
32
|
-
exploreDispatch(clearMeta());
|
|
33
|
-
break;
|
|
34
|
-
default:
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}, [command, exploreDispatch, isReady, query, state]);
|
|
38
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ExploreState } from "../../../exploreState";
|
|
2
|
-
|
|
3
|
-
export interface ExploreQueryState {
|
|
4
|
-
catalog: ExploreState["catalogState"];
|
|
5
|
-
entityListType: ExploreState["tabValue"];
|
|
6
|
-
ff: ExploreState["featureFlagState"];
|
|
7
|
-
filter: ExploreState["filterState"];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export enum META_COMMAND {
|
|
11
|
-
STATE_TO_URL_PUSH = "STATE_TO_URL_PUSH",
|
|
12
|
-
STATE_TO_URL_REPLACE = "STATE_TO_URL_REPLACE",
|
|
13
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
import { useMetaCommands } from "./hooks/UseMetaCommands/hook";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Synchronizes the ExploreView component's state with the Next.js URL.
|
|
6
|
-
*
|
|
7
|
-
* Listens for reducer meta-commands (`STATE_TO_URL_PUSH`/`STATE_TO_URL_REPLACE`)
|
|
8
|
-
* and updates the URL accordingly using router methods.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* ```tsx
|
|
12
|
-
* <ExploreStateProvider>
|
|
13
|
-
* <ExploreStateSyncProvider>
|
|
14
|
-
* <ExploreView />
|
|
15
|
-
* </ExploreStateSyncProvider>
|
|
16
|
-
* </ExploreStateProvider>
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export function ExploreStateSyncProvider({
|
|
21
|
-
children,
|
|
22
|
-
}: {
|
|
23
|
-
children: ReactNode;
|
|
24
|
-
}): JSX.Element {
|
|
25
|
-
// Meta-command related side effects.
|
|
26
|
-
useMetaCommands();
|
|
27
|
-
|
|
28
|
-
return <>{children}</>;
|
|
29
|
-
}
|
|
File without changes
|
/package/lib/{providers/exploreStateSync → hooks/stateSyncManager}/hooks/UseMetaCommands/types.js
RENAMED
|
File without changes
|