@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.
Files changed (272) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/lib/components/DataDictionary/components/Table/columns/columnDef.d.ts +6 -0
  4. package/lib/components/DataDictionary/components/Table/columns/columnDef.js +33 -0
  5. package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.d.ts +5 -0
  6. package/lib/components/DataDictionary/components/Table/columns/columnIdentifier.js +5 -0
  7. package/lib/components/DataDictionary/components/Table/columns/types.d.ts +2 -0
  8. package/lib/components/DataDictionary/components/Table/components/BasicCell/types.d.ts +4 -0
  9. package/lib/components/DataDictionary/components/Table/components/BasicCell/types.js +1 -0
  10. package/lib/components/Detail/components/Table/components/TableHead/tableHead.d.ts +8 -0
  11. package/lib/components/Detail/components/Table/components/TableHead/tableHead.js +36 -0
  12. package/lib/components/Filter/components/Filter/filter.stories.d.ts +25 -0
  13. package/lib/components/Filter/components/Filter/filter.stories.js +42 -0
  14. package/lib/components/Filter/components/FilterTag/filterTag.stories.d.ts +16 -0
  15. package/lib/components/Filter/components/FilterTag/filterTag.stories.js +17 -0
  16. package/lib/components/Filter/components/Filters/filters.stories.d.ts +6 -0
  17. package/lib/components/Filter/components/Filters/filters.stories.js +91 -0
  18. package/lib/components/Index/components/Cell/cell.d.ts +7 -0
  19. package/lib/components/Index/components/Cell/cell.js +10 -0
  20. package/lib/components/Index/components/EntitiesView/constants.d.ts +1 -0
  21. package/lib/components/Index/components/EntitiesView/constants.js +1 -0
  22. package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.d.ts +13 -0
  23. package/lib/components/Index/components/Hero/components/Summaries/summaries.stories.js +18 -0
  24. package/lib/components/Index/components/Hero/hero.stories.d.ts +23 -0
  25. package/lib/components/Index/components/Hero/hero.stories.js +22 -0
  26. package/lib/components/Index/components/NTag/components/Tooltip/tooltip.d.ts +8 -0
  27. package/lib/components/Index/components/NTag/components/Tooltip/tooltip.js +57 -0
  28. package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.d.ts +4 -0
  29. package/lib/components/Index/components/NTag/components/Tooltip/tooltip.styles.js +10 -0
  30. package/lib/components/Index/components/NTag/nTag.d.ts +10 -0
  31. package/lib/components/Index/components/NTag/nTag.js +8 -0
  32. package/lib/components/Index/components/NTagCell/nTagCell.d.ts +11 -0
  33. package/lib/components/Index/components/NTagCell/nTagCell.js +29 -0
  34. package/lib/components/Index/components/NTagCell/nTagCell.stories.d.ts +5 -0
  35. package/lib/components/Index/components/NTagCell/nTagCell.stories.js +16 -0
  36. package/lib/components/Index/components/TitleCell/titleCell.d.ts +6 -0
  37. package/lib/components/Index/components/TitleCell/titleCell.js +10 -0
  38. package/lib/components/Index/components/TitleCell/titleCell.styles.d.ts +3 -0
  39. package/lib/components/Index/components/TitleCell/titleCell.styles.js +6 -0
  40. package/lib/components/Index/index.stories.d.ts +6 -0
  41. package/lib/components/Index/index.stories.js +26 -0
  42. package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.d.ts +6 -0
  43. package/lib/components/Layout/components/BackPage/components/BackPageHero/backPageHero.stories.js +10 -0
  44. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.d.ts +5 -0
  45. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.stories.js +29 -0
  46. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.d.ts +6 -0
  47. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.js +13 -0
  48. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.d.ts +36 -0
  49. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/RequestAuthentication/requestAuthentication.styles.js +9 -0
  50. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.d.ts +5 -0
  51. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.js +10 -0
  52. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.d.ts +36 -0
  53. package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Search/components/SearchButton/searchButton.styles.js +9 -0
  54. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.d.ts +5 -0
  55. package/lib/components/Layout/components/Header/hooks/useMeasureHeader.js +19 -0
  56. package/lib/components/Layout/components/Outline/common/constants.d.ts +2 -0
  57. package/lib/components/Layout/components/Outline/common/constants.js +1 -0
  58. package/lib/components/Login/login.stories.d.ts +6 -0
  59. package/lib/components/Login/login.stories.js +31 -0
  60. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.d.ts +16 -0
  61. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.js +28 -0
  62. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.d.ts +5 -0
  63. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.stories.js +46 -0
  64. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.d.ts +3 -0
  65. package/lib/components/Table/components/CheckboxMenu/checkboxMenu.styles.js +21 -0
  66. package/lib/components/Table/components/EntityViewToggle/entityViewToggle.d.ts +2 -0
  67. package/lib/components/Table/components/EntityViewToggle/entityViewToggle.js +37 -0
  68. package/lib/components/TableCreator/common/constants.d.ts +6 -0
  69. package/lib/components/TableCreator/common/constants.js +19 -0
  70. package/lib/components/TableCreator/common/entities.d.ts +5 -0
  71. package/lib/components/TableCreator/common/entities.js +1 -0
  72. package/lib/components/TableCreator/tableCreator.styles.d.ts +4 -0
  73. package/lib/components/TableCreator/tableCreator.styles.js +4 -0
  74. package/lib/components/common/Alert/alert.stories.d.ts +6 -0
  75. package/lib/components/common/Alert/alert.stories.js +36 -0
  76. package/lib/components/common/Alert/components/AlertText/alertText.styles.d.ts +4 -0
  77. package/lib/components/common/Alert/components/AlertText/alertText.styles.js +19 -0
  78. package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.d.ts +7 -0
  79. package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.js +5 -0
  80. package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.d.ts +3 -0
  81. package/lib/components/common/Banner/components/BannerPrimary/bannerPrimary.styles.js +19 -0
  82. package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.d.ts +10 -0
  83. package/lib/components/common/Banner/components/DismissibleBanner/dismissibleBanner.js +16 -0
  84. package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.d.ts +3 -0
  85. package/lib/components/common/Banner/components/SessionTimeout/sessionTimeout.styles.js +21 -0
  86. package/lib/components/common/Button/components/LoginButton/loginButton.d.ts +3 -0
  87. package/lib/components/common/Button/components/LoginButton/loginButton.js +6 -0
  88. package/lib/components/common/Button/components/LoginButton/loginButton.styles.d.ts +7 -0
  89. package/lib/components/common/Button/components/LoginButton/loginButton.styles.js +11 -0
  90. package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.d.ts +5 -0
  91. package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.js +10 -0
  92. package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.d.ts +3 -0
  93. package/lib/components/common/IconButton/components/LoadingIconButton/loadingIconButton.stories.js +9 -0
  94. package/lib/hooks/stateSyncManager/hook.d.ts +19 -0
  95. package/lib/hooks/stateSyncManager/hook.js +35 -0
  96. package/lib/hooks/stateSyncManager/hooks/UseBeforePopState/hook.d.ts +1 -0
  97. package/lib/hooks/stateSyncManager/hooks/UseBeforePopState/hook.js +21 -0
  98. package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/hook.d.ts +2 -0
  99. package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/hook.js +23 -0
  100. package/lib/hooks/stateSyncManager/hooks/UseMetaCommands/types.d.ts +4 -0
  101. package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.d.ts +2 -0
  102. package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.js +40 -0
  103. package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.d.ts +30 -0
  104. package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.js +41 -0
  105. package/lib/hooks/stateSyncManager/types.d.ts +26 -0
  106. package/lib/hooks/stateSyncManager/types.js +1 -0
  107. package/lib/hooks/useAuthentication/common/constants.d.ts +4 -0
  108. package/lib/hooks/useAuthentication/common/constants.js +19 -0
  109. package/lib/hooks/useAuthentication/common/entities.d.ts +25 -0
  110. package/lib/hooks/useAuthentication/common/entities.js +11 -0
  111. package/lib/hooks/useAuthentication/common/utils.d.ts +15 -0
  112. package/lib/hooks/useAuthentication/common/utils.js +25 -0
  113. package/lib/hooks/useAuthentication/useAuthentication.d.ts +6 -0
  114. package/lib/hooks/useAuthentication/useAuthentication.js +9 -0
  115. package/lib/hooks/useAuthentication/useAuthenticationComplete.d.ts +6 -0
  116. package/lib/hooks/useAuthentication/useAuthenticationComplete.js +55 -0
  117. package/lib/hooks/useAuthentication/useAuthenticationForm.d.ts +20 -0
  118. package/lib/hooks/useAuthentication/useAuthenticationForm.js +88 -0
  119. package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.d.ts +18 -0
  120. package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.js +50 -0
  121. package/lib/hooks/useAuthentication/useAuthenticationStatus.d.ts +20 -0
  122. package/lib/hooks/useAuthentication/useAuthenticationStatus.js +32 -0
  123. package/lib/hooks/useAuthentication/useFetchGoogleProfile.d.ts +21 -0
  124. package/lib/hooks/useAuthentication/useFetchGoogleProfile.js +41 -0
  125. package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.d.ts +18 -0
  126. package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.js +62 -0
  127. package/lib/hooks/useAuthentication/useFetchTerraProfile.d.ts +24 -0
  128. package/lib/hooks/useAuthentication/useFetchTerraProfile.js +62 -0
  129. package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.d.ts +15 -0
  130. package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.js +62 -0
  131. package/lib/hooks/useAuthentication/useTokenClient.d.ts +11 -0
  132. package/lib/hooks/useAuthentication/useTokenClient.js +29 -0
  133. package/lib/hooks/useAuthenticationConfig.d.ts +6 -0
  134. package/lib/hooks/useAuthenticationConfig.js +14 -0
  135. package/lib/hooks/useCategoryConfigs.d.ts +6 -0
  136. package/lib/hooks/useCategoryConfigs.js +17 -0
  137. package/lib/hooks/useEntityListRelatedView.d.ts +15 -0
  138. package/lib/hooks/useEntityListRelatedView.js +62 -0
  139. package/lib/hooks/useExploreMode.d.ts +14 -0
  140. package/lib/hooks/useExploreMode.js +20 -0
  141. package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.d.ts +15 -0
  142. package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.js +27 -0
  143. package/lib/hooks/useFileManifest/useFileManifestURL.d.ts +5 -0
  144. package/lib/hooks/useFileManifest/useFileManifestURL.js +11 -0
  145. package/lib/hooks/useFileManifest/useRequestFileManifest.d.ts +9 -0
  146. package/lib/hooks/useFileManifest/useRequestFileManifest.js +37 -0
  147. package/lib/hooks/useLayoutState.d.ts +6 -0
  148. package/lib/hooks/useLayoutState.js +9 -0
  149. package/lib/hooks/useMenu.d.ts +10 -0
  150. package/lib/hooks/useMenu.js +17 -0
  151. package/lib/hooks/useMenuWithPosition.d.ts +14 -0
  152. package/lib/hooks/useMenuWithPosition.js +33 -0
  153. package/lib/hooks/useSessionTimeout.d.ts +11 -0
  154. package/lib/hooks/useSessionTimeout.js +28 -0
  155. package/lib/providers/authentication.d.ts +51 -0
  156. package/lib/providers/authentication.js +110 -0
  157. package/lib/providers/exploreState/actions/stateToUrl/action.d.ts +9 -0
  158. package/lib/providers/exploreState/actions/stateToUrl/action.js +14 -0
  159. package/lib/providers/exploreState/actions/stateToUrl/dispatch.d.ts +7 -0
  160. package/lib/providers/exploreState/actions/{syncStateFromUrl → stateToUrl}/dispatch.js +3 -3
  161. package/lib/providers/exploreState/actions/stateToUrl/types.d.ts +12 -0
  162. package/lib/providers/exploreState/actions/stateToUrl/types.js +5 -0
  163. package/lib/providers/exploreState/actions/urlToState/action.d.ts +9 -0
  164. package/lib/providers/exploreState/actions/urlToState/action.js +38 -0
  165. package/lib/providers/exploreState/actions/urlToState/dispatch.d.ts +7 -0
  166. package/lib/providers/exploreState/actions/urlToState/dispatch.js +12 -0
  167. package/lib/providers/exploreState/actions/urlToState/types.d.ts +9 -0
  168. package/lib/providers/exploreState/actions/urlToState/types.js +1 -0
  169. package/lib/providers/exploreState/actions/urlToState/utils.d.ts +7 -0
  170. package/lib/providers/exploreState/actions/urlToState/utils.js +13 -0
  171. package/lib/providers/{exploreStateSync/hooks/UseMetaCommands/utils.d.ts → exploreState/entities/query/buildQuery.d.ts} +10 -14
  172. package/lib/providers/{exploreStateSync/hooks/UseMetaCommands/utils.js → exploreState/entities/query/buildQuery.js} +13 -21
  173. package/lib/providers/exploreState/entities/state.d.ts +10 -0
  174. package/lib/providers/exploreState/entities/state.js +36 -0
  175. package/lib/providers/exploreState/entities/types.d.ts +16 -0
  176. package/lib/providers/exploreState/entities/types.js +1 -0
  177. package/lib/providers/exploreState/entities.d.ts +1 -1
  178. package/lib/providers/exploreState/initializer/constants.js +1 -0
  179. package/lib/providers/exploreState/initializer/utils.js +26 -1
  180. package/lib/providers/exploreState.d.ts +8 -4
  181. package/lib/providers/exploreState.js +20 -15
  182. package/lib/providers/layoutState.d.ts +40 -0
  183. package/lib/providers/layoutState.js +47 -0
  184. package/lib/providers/services/provider.d.ts +14 -0
  185. package/lib/providers/services/provider.js +18 -0
  186. package/lib/providers/services/wasPop/context.d.ts +2 -0
  187. package/lib/providers/services/wasPop/context.js +5 -0
  188. package/lib/providers/services/wasPop/hook.d.ts +2 -0
  189. package/lib/providers/services/wasPop/hook.js +5 -0
  190. package/lib/providers/services/wasPop/provider.d.ts +16 -0
  191. package/lib/providers/services/wasPop/provider.js +30 -0
  192. package/lib/providers/services/wasPop/types.d.ts +6 -0
  193. package/lib/providers/services/wasPop/types.js +1 -0
  194. package/lib/services/beforePopState/popStateBus.d.ts +20 -0
  195. package/lib/services/beforePopState/popStateBus.js +58 -0
  196. package/lib/services/beforePopState/types.d.ts +11 -0
  197. package/lib/services/beforePopState/types.js +1 -0
  198. package/lib/services/beforePopState/useOnPopState.d.ts +2 -0
  199. package/lib/services/beforePopState/useOnPopState.js +10 -0
  200. package/lib/services/beforePopState/usePopStateBus.d.ts +6 -0
  201. package/lib/services/beforePopState/usePopStateBus.js +12 -0
  202. package/lib/styles/common/mixins/shadows.d.ts +3 -0
  203. package/lib/styles/common/mixins/shadows.js +4 -0
  204. package/lib/styles/common/mui/palette.d.ts +47 -0
  205. package/lib/styles/common/mui/palette.js +47 -0
  206. package/lib/theme/common/entities.d.ts +6 -0
  207. package/lib/theme/common/entities.js +1 -0
  208. package/lib/views/ExploreView/exploreView.js +15 -2
  209. package/lib/views/ExploreView/utils.d.ts +14 -0
  210. package/lib/views/ExploreView/utils.js +17 -0
  211. package/package.json +1 -1
  212. package/src/hooks/stateSyncManager/hook.ts +47 -0
  213. package/src/hooks/stateSyncManager/hooks/UseBeforePopState/hook.ts +30 -0
  214. package/src/hooks/stateSyncManager/hooks/UseMetaCommands/hook.ts +30 -0
  215. package/src/hooks/stateSyncManager/hooks/UseMetaCommands/types.ts +4 -0
  216. package/src/hooks/stateSyncManager/hooks/UseStateSync/hook.ts +52 -0
  217. package/src/hooks/stateSyncManager/hooks/UseStateSync/utils.ts +58 -0
  218. package/src/hooks/stateSyncManager/types.ts +34 -0
  219. package/src/providers/exploreState/actions/stateToUrl/action.ts +20 -0
  220. package/src/providers/exploreState/actions/stateToUrl/dispatch.ts +14 -0
  221. package/src/providers/exploreState/actions/stateToUrl/types.ts +15 -0
  222. package/src/providers/exploreState/actions/urlToState/action.ts +74 -0
  223. package/src/providers/exploreState/actions/urlToState/dispatch.ts +14 -0
  224. package/src/providers/exploreState/actions/urlToState/types.ts +11 -0
  225. package/src/providers/exploreState/actions/urlToState/utils.ts +18 -0
  226. package/src/providers/{exploreStateSync/hooks/UseMetaCommands/utils.ts → exploreState/entities/query/buildQuery.ts} +23 -26
  227. package/src/providers/exploreState/entities/state.ts +50 -0
  228. package/src/providers/exploreState/entities/types.ts +19 -0
  229. package/src/providers/exploreState/entities.ts +1 -1
  230. package/src/providers/exploreState/initializer/constants.ts +1 -0
  231. package/src/providers/exploreState/initializer/utils.ts +30 -1
  232. package/src/providers/exploreState.tsx +27 -20
  233. package/src/providers/services/provider.tsx +25 -0
  234. package/src/providers/services/wasPop/context.ts +7 -0
  235. package/src/providers/services/wasPop/hook.ts +7 -0
  236. package/src/providers/services/wasPop/provider.tsx +45 -0
  237. package/src/providers/services/wasPop/types.ts +7 -0
  238. package/src/services/beforePopState/popStateBus.ts +64 -0
  239. package/src/services/beforePopState/types.ts +15 -0
  240. package/src/services/beforePopState/useOnPopState.ts +15 -0
  241. package/src/services/beforePopState/usePopStateBus.ts +14 -0
  242. package/src/views/ExploreView/exploreView.tsx +17 -3
  243. package/src/views/ExploreView/utils.ts +25 -0
  244. package/lib/providers/exploreState/actions/syncStateFromUrl/action.d.ts +0 -10
  245. package/lib/providers/exploreState/actions/syncStateFromUrl/action.js +0 -25
  246. package/lib/providers/exploreState/actions/syncStateFromUrl/dispatch.d.ts +0 -7
  247. package/lib/providers/exploreState/actions/syncStateFromUrl/types.d.ts +0 -8
  248. package/lib/providers/exploreState/actions/syncStateFromUrl/utils.d.ts +0 -9
  249. package/lib/providers/exploreState/actions/syncStateFromUrl/utils.js +0 -23
  250. package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.d.ts +0 -18
  251. package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.js +0 -41
  252. package/lib/providers/exploreState/hooks/UseBeforePopState/utils.d.ts +0 -23
  253. package/lib/providers/exploreState/hooks/UseBeforePopState/utils.js +0 -68
  254. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.d.ts +0 -10
  255. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/handlers.js +0 -18
  256. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.d.ts +0 -1
  257. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/hook.js +0 -33
  258. package/lib/providers/exploreStateSync/hooks/UseMetaCommands/types.d.ts +0 -11
  259. package/lib/providers/exploreStateSync/provider.d.ts +0 -19
  260. package/lib/providers/exploreStateSync/provider.js +0 -22
  261. package/src/providers/exploreState/actions/syncStateFromUrl/action.ts +0 -44
  262. package/src/providers/exploreState/actions/syncStateFromUrl/dispatch.ts +0 -16
  263. package/src/providers/exploreState/actions/syncStateFromUrl/types.ts +0 -13
  264. package/src/providers/exploreState/actions/syncStateFromUrl/utils.ts +0 -31
  265. package/src/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.ts +0 -46
  266. package/src/providers/exploreState/hooks/UseBeforePopState/utils.ts +0 -93
  267. package/src/providers/exploreStateSync/hooks/UseMetaCommands/handlers.ts +0 -25
  268. package/src/providers/exploreStateSync/hooks/UseMetaCommands/hook.ts +0 -38
  269. package/src/providers/exploreStateSync/hooks/UseMetaCommands/types.ts +0 -13
  270. package/src/providers/exploreStateSync/provider.tsx +0 -29
  271. /package/lib/{providers/exploreState/actions/syncStateFromUrl → components/DataDictionary/components/Table/columns}/types.js +0 -0
  272. /package/lib/{providers/exploreStateSync → hooks/stateSyncManager}/hooks/UseMetaCommands/types.js +0 -0
@@ -0,0 +1,64 @@
1
+ import Router from "next/router";
2
+ import { BeforePopStateCallback, NextHistoryState } from "./types";
3
+
4
+ /**
5
+ * Pop‐State Event Bus
6
+ *
7
+ * Provides a centralized mechanism for components to intercept
8
+ * and optionally prevent Back/Forward navigation (Next.js beforePopState).
9
+ */
10
+
11
+ /**
12
+ * A set of callback functions that will run before Next.js performs a pop.
13
+ * Each callback returns `true` to allow navigation or `false` to block.
14
+ */
15
+ const beforePopCallbacks = new Set<BeforePopStateCallback>();
16
+
17
+ /**
18
+ * Register a callback to be invoked immediately before any Next.js pop navigation.
19
+ * Return `false` from your callback to prevent the pop; otherwise return `true`.
20
+ * @param cb - The callback function to register.
21
+ */
22
+ export function registerBeforePopCallback(cb: BeforePopStateCallback): void {
23
+ beforePopCallbacks.add(cb);
24
+ }
25
+
26
+ /**
27
+ * Unregister a previously registered “before pop” callback.
28
+ * @param cb - The callback function to unregister.
29
+ */
30
+ export function unregisterBeforePopCallback(cb: BeforePopStateCallback): void {
31
+ beforePopCallbacks.delete(cb);
32
+ }
33
+
34
+ /**
35
+ * Ensures that we only hook into Next.js once. After install, any pop event
36
+ * will first invoke all registered callbacks and only proceed if all return true.
37
+ */
38
+ let hasInstalledInterceptor = false;
39
+
40
+ /**
41
+ * Install the global “before pop” interceptor into Next.js’s router.
42
+ * Subsequent calls to this function will be no‐ops.
43
+ *
44
+ * This method must be called once (e.g. in your app’s top‐level code)
45
+ * to enable the pop‐state bus.
46
+ */
47
+ export function registerPopStateHandler(): void {
48
+ if (hasInstalledInterceptor) return;
49
+ hasInstalledInterceptor = true;
50
+
51
+ Router.beforePopState((state: NextHistoryState) => {
52
+ // Iteratively call every callback. If any returns false, block navigation.
53
+ let allAllow = true;
54
+ beforePopCallbacks.forEach((cb) => {
55
+ try {
56
+ if (cb(state) === false) allAllow = false;
57
+ } catch (e: unknown) {
58
+ console.error("Pop listener failed:", e);
59
+ }
60
+ });
61
+
62
+ return allAllow;
63
+ });
64
+ }
@@ -0,0 +1,15 @@
1
+ import Router from "next/router";
2
+
3
+ /**
4
+ * Type representing the callback function passed to beforePopState.
5
+ * Extracted from the Next.js Router.beforePopState API.
6
+ */
7
+ export type BeforePopStateCallback = Parameters<
8
+ typeof Router.beforePopState
9
+ >[0];
10
+
11
+ /**
12
+ * Type representing the state passed to beforePopState.
13
+ * Extracted from the Next.js Router.beforePopState API.
14
+ */
15
+ export type NextHistoryState = Parameters<BeforePopStateCallback>[0];
@@ -0,0 +1,15 @@
1
+ import { useEffect } from "react";
2
+ import {
3
+ registerBeforePopCallback,
4
+ unregisterBeforePopCallback,
5
+ } from "./popStateBus";
6
+ import { BeforePopStateCallback } from "./types";
7
+
8
+ export const useOnPopState = (cb: BeforePopStateCallback): void => {
9
+ useEffect(() => {
10
+ registerBeforePopCallback(cb);
11
+ return (): void => {
12
+ unregisterBeforePopCallback(cb);
13
+ };
14
+ }, [cb]);
15
+ };
@@ -0,0 +1,14 @@
1
+ import { useEffect } from "react";
2
+ import { registerPopStateHandler } from "./popStateBus";
3
+
4
+ /**
5
+ * Registers the single global `router.beforePopState` handler that
6
+ * fans out to all feature listeners.
7
+ * Safe to call multiple times - only the first invocation does the real install.
8
+ */
9
+
10
+ export const usePopStateBus = (): void => {
11
+ useEffect(() => {
12
+ registerPopStateHandler();
13
+ }, []);
14
+ };
@@ -25,6 +25,7 @@ import {
25
25
  ComponentsConfig,
26
26
  SummaryConfig,
27
27
  } from "../../config/entities";
28
+ import { useStateSyncManager } from "../../hooks/stateSyncManager/hook";
28
29
  import {
29
30
  BREAKPOINT_FN_NAME,
30
31
  useBreakpointHelper,
@@ -34,10 +35,13 @@ import { useEntityList } from "../../hooks/useEntityList";
34
35
  import { useExploreState } from "../../hooks/useExploreState";
35
36
  import { useSummary } from "../../hooks/useSummary";
36
37
  import { ExploreActionKind } from "../../providers/exploreState";
38
+ import { clearMeta } from "../../providers/exploreState/actions/clearMeta/dispatch";
39
+ import { stateToUrl } from "../../providers/exploreState/actions/stateToUrl/dispatch";
40
+ import { urlToState } from "../../providers/exploreState/actions/urlToState/dispatch";
37
41
  import { SELECT_CATEGORY_KEY } from "../../providers/exploreState/constants";
38
- import { ExploreStateSyncProvider } from "../../providers/exploreStateSync/provider";
39
42
  import { TEST_IDS } from "../../tests/testIds";
40
43
  import { DESKTOP_SM } from "../../theme/common/breakpoints";
44
+ import { buildStateSyncManagerContext } from "./utils";
41
45
 
42
46
  export interface ExploreViewProps extends AzulEntitiesStaticResponse {
43
47
  className?: string;
@@ -60,6 +64,16 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
60
64
  [categoryGroups, categoryViews]
61
65
  );
62
66
 
67
+ /**
68
+ * State sync manager.
69
+ * Handles state synchronization between the explore state and the URL.
70
+ */
71
+ useStateSyncManager({
72
+ actions: { clearMeta, stateToUrl, urlToState },
73
+ dispatch: exploreDispatch,
74
+ state: buildStateSyncManagerContext(exploreState, props),
75
+ });
76
+
63
77
  /**
64
78
  * Closes filter drawer.
65
79
  */
@@ -142,7 +156,7 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
142
156
  }, [entityListType, exploreDispatch]);
143
157
 
144
158
  return (
145
- <ExploreStateSyncProvider>
159
+ <>
146
160
  {categoryViews && !!categoryViews.length && (
147
161
  <Sidebar drawerOpen={isDrawerOpen} onDrawerClose={onCloseDrawer}>
148
162
  <SidebarTools data-testid={TEST_IDS.FILTER_CONTROLS}>
@@ -183,7 +197,7 @@ export const ExploreView = (props: ExploreViewProps): JSX.Element => {
183
197
  Tabs={<Tabs />}
184
198
  title={entityConfig.explorerTitle || explorerTitle}
185
199
  />
186
- </ExploreStateSyncProvider>
200
+ </>
187
201
  );
188
202
  };
189
203
 
@@ -0,0 +1,25 @@
1
+ import { ComponentProps } from "react";
2
+ import { StateSyncManagerContext } from "../../hooks/stateSyncManager/types";
3
+ import { ExploreState } from "../../providers/exploreState";
4
+ import { EXPLORE_URL_PARAMS } from "../../providers/exploreState/constants";
5
+ import { ExploreView } from "./exploreView";
6
+
7
+ /**
8
+ *Builds the state sync manager context object for URL-state synchronization.
9
+ * - Command: The meta command that signals a URL update operation is needed e.g. "STATE_TO_URL_PUSH" or "STATE_TO_URL_REPLACE".
10
+ * - ParamKeys: Expected list of URL parameter keys that should be synchronized with state e.g. "filter", "catalog".
11
+ * - Query: Entity related query object from state that should be synchronized with the URL.
12
+ * @param exploreState - Explore state.
13
+ * @param pageProps - Page props.
14
+ * @returns The state sync manager context.
15
+ */
16
+ export function buildStateSyncManagerContext(
17
+ exploreState: ExploreState,
18
+ pageProps: ComponentProps<typeof ExploreView>
19
+ ): StateSyncManagerContext {
20
+ return {
21
+ command: exploreState.meta?.command,
22
+ paramKeys: Object.values(EXPLORE_URL_PARAMS),
23
+ query: exploreState.entities[pageProps.entityListType].query,
24
+ };
25
+ }
@@ -1,10 +0,0 @@
1
- import { ExploreState } from "../../../exploreState";
2
- import { SyncStateFromUrlPayload } from "./types";
3
- /**
4
- * Reducer function to handle the "sync state from URL" action.
5
- * Updates the catalog state, feature flag state, and the payload entity's filter state.
6
- * @param state - Explore State.
7
- * @param payload - Payload.
8
- * @returns explore state.
9
- */
10
- export declare function syncStateFromUrlAction(state: ExploreState, payload: SyncStateFromUrlPayload): ExploreState;
@@ -1,25 +0,0 @@
1
- import { getEntityCategoryGroupConfigKey, updateEntityStateByCategoryGroupConfigKey, } from "../../utils";
2
- import { buildNextState } from "./utils";
3
- /**
4
- * Reducer function to handle the "sync state from URL" action.
5
- * Updates the catalog state, feature flag state, and the payload entity's filter state.
6
- * @param state - Explore State.
7
- * @param payload - Payload.
8
- * @returns explore state.
9
- */
10
- export function syncStateFromUrlAction(state, payload) {
11
- // Build the next state.
12
- const nextState = buildNextState(state, payload);
13
- // Grab the category group config key for the payload entityListType.
14
- const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(payload.entityListType, state.entityPageState);
15
- // Update the entity state by category group config key.
16
- updateEntityStateByCategoryGroupConfigKey(state, {
17
- filterState: payload.filterState,
18
- savedFilterState: [],
19
- }, categoryGroupConfigKey);
20
- // Return the updated state.
21
- return {
22
- ...state,
23
- ...nextState,
24
- };
25
- }
@@ -1,7 +0,0 @@
1
- import { SyncStateFromUrlAction, SyncStateFromUrlPayload } from "./types";
2
- /**
3
- * Action creator for syncing state from URL.
4
- * @param payload - Payload.
5
- * @returns Action with payload and action type.
6
- */
7
- export declare function syncStateFromUrl(payload: SyncStateFromUrlPayload): SyncStateFromUrlAction;
@@ -1,8 +0,0 @@
1
- import { ExploreActionKind, ExploreState } from "../../../exploreState";
2
- export type SyncStateFromUrlAction = {
3
- payload: SyncStateFromUrlPayload;
4
- type: ExploreActionKind.SyncStateFromUrl;
5
- };
6
- export type SyncStateFromUrlPayload = Pick<ExploreState, "catalogState" | "featureFlagState" | "filterState"> & {
7
- entityListType: string;
8
- };
@@ -1,9 +0,0 @@
1
- import { ExploreState } from "../../../exploreState";
2
- import { SyncStateFromUrlPayload } from "./types";
3
- /**
4
- * Builds the next state, syncing the catalog state, feature flag state, and filter state.
5
- * @param state - Explore state.
6
- * @param payload - Payload.
7
- * @returns state.
8
- */
9
- export declare function buildNextState(state: ExploreState, payload: SyncStateFromUrlPayload): Partial<ExploreState>;
@@ -1,23 +0,0 @@
1
- import { getFilterCount } from "../../../exploreState/utils";
2
- /**
3
- * Builds the next state, syncing the catalog state, feature flag state, and filter state.
4
- * @param state - Explore state.
5
- * @param payload - Payload.
6
- * @returns state.
7
- */
8
- export function buildNextState(state, payload) {
9
- // Initialize filter count and filter state from current state.
10
- let filterCount = state.filterCount;
11
- let filterState = state.filterState;
12
- // Only update filter count and filter state if the payload entityListType matches the current tab value.
13
- if (payload.entityListType === state.tabValue) {
14
- filterCount = getFilterCount(payload.filterState);
15
- filterState = payload.filterState;
16
- }
17
- return {
18
- catalogState: payload.catalogState,
19
- featureFlagState: payload.featureFlagState,
20
- filterCount,
21
- filterState,
22
- };
23
- }
@@ -1,18 +0,0 @@
1
- import { ExploreStateContextProps } from "../../../exploreState";
2
- /**
3
- * useBeforePopState
4
- *
5
- * Keeps ExploreState, URL, and page props aligned when the user clicks
6
- * the browser Back / Forward buttons.
7
- *
8
- * This hook runs inside `ExploreStateProvider` (mounted once in `_app`).
9
- * It adds a single `router.beforePopState` handler that:
10
- * - Parses the destination URL.
11
- * - Dispatches `syncStateFromUrl` so filters, catalogue, and feature-flags in context match the URL.
12
- * - Calls `router.replace(...{ shallow: false })` to trigger a full page transition, ensuring Next.js
13
- * re-executes data-fetching methods that shallow routing would otherwise skip.
14
- *
15
- * The provider never unmounts, and a second call to `router.beforePopState` simply overwrites the handler.
16
- * Cleaning up here would wipe out any handler registered later by other code.
17
- */
18
- export declare const useBeforePopState: ({ exploreDispatch, }: ExploreStateContextProps) => void;
@@ -1,41 +0,0 @@
1
- import { useRouter } from "next/router";
2
- import { useEffect } from "react";
3
- import { syncStateFromUrl } from "../../../exploreState/actions/syncStateFromUrl/dispatch";
4
- import { getSyncStateFromUrl } from "./utils";
5
- /**
6
- * useBeforePopState
7
- *
8
- * Keeps ExploreState, URL, and page props aligned when the user clicks
9
- * the browser Back / Forward buttons.
10
- *
11
- * This hook runs inside `ExploreStateProvider` (mounted once in `_app`).
12
- * It adds a single `router.beforePopState` handler that:
13
- * - Parses the destination URL.
14
- * - Dispatches `syncStateFromUrl` so filters, catalogue, and feature-flags in context match the URL.
15
- * - Calls `router.replace(...{ shallow: false })` to trigger a full page transition, ensuring Next.js
16
- * re-executes data-fetching methods that shallow routing would otherwise skip.
17
- *
18
- * The provider never unmounts, and a second call to `router.beforePopState` simply overwrites the handler.
19
- * Cleaning up here would wipe out any handler registered later by other code.
20
- */
21
- export const useBeforePopState = ({ exploreDispatch, }) => {
22
- const router = useRouter();
23
- useEffect(() => {
24
- router.beforePopState(({ as, options, url }) => {
25
- // Grab the expected state from URL.
26
- const payload = getSyncStateFromUrl(url, as);
27
- // Only dispatch if the url contains the dynamic segment `[entityListType]`.
28
- if (payload.entityListType) {
29
- // Sync state from URL.
30
- exploreDispatch(syncStateFromUrl(payload));
31
- // Force a full route transition to ensure page props are refreshed.
32
- router.replace(url, as, { ...options, shallow: false });
33
- return false;
34
- }
35
- // Return true to allow the popstate event to continue.
36
- return true;
37
- });
38
- // No cleanup handler: see the JSDoc above for why we do not reset beforePopState here.
39
- // Resetting would remove any handler registered by other parts of the app after this hook mounted.
40
- }, [exploreDispatch, router]);
41
- };
@@ -1,23 +0,0 @@
1
- import { SelectedFilter } from "../../../../common/entities";
2
- import { SyncStateFromUrlPayload } from "../../../exploreState/actions/syncStateFromUrl/types";
3
- /**
4
- * Returns the filters from the resolved URL.
5
- * @param paramValue - The filter parameter value.
6
- * @returns The filters or an empty array.
7
- */
8
- export declare function decodeFiltersParamValue(paramValue: string | undefined): SelectedFilter[];
9
- /**
10
- * Returns a parameter from the resolved URL.
11
- * @param resolved - The resolved URL.
12
- * @param param - The parameter to extract.
13
- * @returns The parameter value or undefined.
14
- */
15
- export declare function getParamValue(resolved: string, param: string): string | undefined;
16
- /**
17
- * Returns the entity list type, filters, and feature flag state from the URL.
18
- * A dynamic segment that is not exactly `[entityListType]` is not supported will return entityListType as an empty string.
19
- * @param url - The URL to extract from.
20
- * @param as - The resolved URL.
21
- * @returns An object containing the entity list type, filters, and feature flag state.
22
- */
23
- export declare function getSyncStateFromUrl(url: string, as: string): SyncStateFromUrlPayload;
@@ -1,68 +0,0 @@
1
- import { EXPLORE_URL_PARAMS } from "../../../exploreState/constants";
2
- /**
3
- * Returns the filters from the resolved URL.
4
- * @param paramValue - The filter parameter value.
5
- * @returns The filters or an empty array.
6
- */
7
- export function decodeFiltersParamValue(paramValue) {
8
- return JSON.parse(decodeURIComponent(paramValue || "[]"));
9
- }
10
- /**
11
- * Returns the dynamic segment from the resolved URL.
12
- * @param pattern - The pattern URL.
13
- * @param resolved - The resolved URL.
14
- * @param dynamicSegment - The dynamic segment to extract.
15
- * @returns The dynamic segment or an empty string.
16
- */
17
- function getDynamicSegment(pattern, resolved, dynamicSegment = "[entityListType]") {
18
- // Remove query strings.
19
- const patternPath = pattern.split("?")[0];
20
- const resolvedPath = resolved.split("?")[0];
21
- // Check if the pattern ends with the dynamic segment e.g. /data/[entityListType].
22
- // We are not interested in a pattern the suggests we are on an entity page e.g. /data/[entityListType]/[entityId].
23
- if (!patternPath.endsWith(`/${dynamicSegment}`))
24
- return "";
25
- // Split into segments.
26
- const patternSegments = patternPath.split("/");
27
- const resolvedSegments = resolvedPath.split("/");
28
- // Find the dynamic segment.
29
- const idx = patternSegments.findIndex((seg) => seg === dynamicSegment);
30
- if (idx === -1)
31
- return "";
32
- return resolvedSegments[idx] || "";
33
- }
34
- /**
35
- * Returns a parameter from the resolved URL.
36
- * @param resolved - The resolved URL.
37
- * @param param - The parameter to extract.
38
- * @returns The parameter value or undefined.
39
- */
40
- export function getParamValue(resolved, param) {
41
- // Grab the params from the resolved URL.
42
- const params = new URLSearchParams(resolved.split("?")[1]);
43
- const paramValue = params.get(param);
44
- // Return the parameter value or undefined.
45
- if (!paramValue)
46
- return;
47
- return paramValue;
48
- }
49
- /**
50
- * Returns the entity list type, filters, and feature flag state from the URL.
51
- * A dynamic segment that is not exactly `[entityListType]` is not supported will return entityListType as an empty string.
52
- * @param url - The URL to extract from.
53
- * @param as - The resolved URL.
54
- * @returns An object containing the entity list type, filters, and feature flag state.
55
- */
56
- export function getSyncStateFromUrl(url, as) {
57
- // Get the entity list type from the url.
58
- const entityListType = getDynamicSegment(url, as);
59
- // Get the param values for each param.
60
- const [catalogState, featureFlagState, filter] = [
61
- EXPLORE_URL_PARAMS.CATALOG,
62
- EXPLORE_URL_PARAMS.FEATURE_FLAG,
63
- EXPLORE_URL_PARAMS.FILTER,
64
- ].map((param) => getParamValue(as, param));
65
- // Decode the filter param value to selected filters.
66
- const filterState = decodeFiltersParamValue(filter);
67
- return { catalogState, entityListType, featureFlagState, filterState };
68
- }
@@ -1,10 +0,0 @@
1
- import { NextRouter } from "next/router";
2
- import { ExploreQueryState } from "./types";
3
- /**
4
- * Updates the URL query parameters based on state.
5
- * Pushes or replaces the query to the router.
6
- * @param state - State -- partial explore state.
7
- * @param currentQuery - Query -- current.
8
- * @param method - "push" or "replace".
9
- */
10
- export declare function updateUrlFromState(state: ExploreQueryState, currentQuery: NextRouter["query"], method?: "push" | "replace"): void;
@@ -1,18 +0,0 @@
1
- import Router from "next/router";
2
- import { buildQuery, stringifyQuery } from "./utils";
3
- /**
4
- * Updates the URL query parameters based on state.
5
- * Pushes or replaces the query to the router.
6
- * @param state - State -- partial explore state.
7
- * @param currentQuery - Query -- current.
8
- * @param method - "push" or "replace".
9
- */
10
- export function updateUrlFromState(state, currentQuery, method = "push") {
11
- // Build the next query.
12
- const query = buildQuery(state);
13
- // Do nothing if the next query is the same as the current query.
14
- if (stringifyQuery(query) === stringifyQuery(currentQuery))
15
- return;
16
- // Push or replace the query to the router.
17
- Router[method]({ query }, undefined, { shallow: true });
18
- }
@@ -1 +0,0 @@
1
- export declare const useMetaCommands: () => void;
@@ -1,33 +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
- export const useMetaCommands = () => {
9
- const { exploreDispatch, exploreState } = useExploreState();
10
- // Router must be ready before executing any meta-command side effects.
11
- const { isReady, query } = useRouter();
12
- // Command.
13
- const command = exploreState.meta?.command;
14
- // Extract relevant state to update URL.
15
- const state = useMemo(() => getQueryState(exploreState), [exploreState]);
16
- useEffect(() => {
17
- // Do nothing if the router is not ready.
18
- if (!isReady)
19
- return;
20
- switch (command) {
21
- case META_COMMAND.STATE_TO_URL_PUSH:
22
- updateUrlFromState(state, query);
23
- exploreDispatch(clearMeta());
24
- break;
25
- case META_COMMAND.STATE_TO_URL_REPLACE:
26
- updateUrlFromState(state, query, "replace");
27
- exploreDispatch(clearMeta());
28
- break;
29
- default:
30
- break;
31
- }
32
- }, [command, exploreDispatch, isReady, query, state]);
33
- };
@@ -1,11 +0,0 @@
1
- import { ExploreState } from "../../../exploreState";
2
- export interface ExploreQueryState {
3
- catalog: ExploreState["catalogState"];
4
- entityListType: ExploreState["tabValue"];
5
- ff: ExploreState["featureFlagState"];
6
- filter: ExploreState["filterState"];
7
- }
8
- export declare enum META_COMMAND {
9
- STATE_TO_URL_PUSH = "STATE_TO_URL_PUSH",
10
- STATE_TO_URL_REPLACE = "STATE_TO_URL_REPLACE"
11
- }
@@ -1,19 +0,0 @@
1
- import { ReactNode } from "react";
2
- /**
3
- * Synchronizes the ExploreView component's state with the Next.js URL.
4
- *
5
- * Listens for reducer meta-commands (`STATE_TO_URL_PUSH`/`STATE_TO_URL_REPLACE`)
6
- * and updates the URL accordingly using router methods.
7
- *
8
- * Usage:
9
- * ```tsx
10
- * <ExploreStateProvider>
11
- * <ExploreStateSyncProvider>
12
- * <ExploreView />
13
- * </ExploreStateSyncProvider>
14
- * </ExploreStateProvider>
15
- * ```
16
- */
17
- export declare function ExploreStateSyncProvider({ children, }: {
18
- children: ReactNode;
19
- }): JSX.Element;
@@ -1,22 +0,0 @@
1
- import React from "react";
2
- import { useMetaCommands } from "./hooks/UseMetaCommands/hook";
3
- /**
4
- * Synchronizes the ExploreView component's state with the Next.js URL.
5
- *
6
- * Listens for reducer meta-commands (`STATE_TO_URL_PUSH`/`STATE_TO_URL_REPLACE`)
7
- * and updates the URL accordingly using router methods.
8
- *
9
- * Usage:
10
- * ```tsx
11
- * <ExploreStateProvider>
12
- * <ExploreStateSyncProvider>
13
- * <ExploreView />
14
- * </ExploreStateSyncProvider>
15
- * </ExploreStateProvider>
16
- * ```
17
- */
18
- export function ExploreStateSyncProvider({ children, }) {
19
- // Meta-command related side effects.
20
- useMetaCommands();
21
- return React.createElement(React.Fragment, null, children);
22
- }
@@ -1,44 +0,0 @@
1
- import { ExploreState } from "../../../exploreState";
2
- import {
3
- getEntityCategoryGroupConfigKey,
4
- updateEntityStateByCategoryGroupConfigKey,
5
- } from "../../utils";
6
- import { SyncStateFromUrlPayload } from "./types";
7
- import { buildNextState } from "./utils";
8
-
9
- /**
10
- * Reducer function to handle the "sync state from URL" action.
11
- * Updates the catalog state, feature flag state, and the payload entity's filter state.
12
- * @param state - Explore State.
13
- * @param payload - Payload.
14
- * @returns explore state.
15
- */
16
- export function syncStateFromUrlAction(
17
- state: ExploreState,
18
- payload: SyncStateFromUrlPayload
19
- ): ExploreState {
20
- // Build the next state.
21
- const nextState = buildNextState(state, payload);
22
-
23
- // Grab the category group config key for the payload entityListType.
24
- const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
25
- payload.entityListType,
26
- state.entityPageState
27
- );
28
-
29
- // Update the entity state by category group config key.
30
- updateEntityStateByCategoryGroupConfigKey(
31
- state,
32
- {
33
- filterState: payload.filterState,
34
- savedFilterState: [],
35
- },
36
- categoryGroupConfigKey
37
- );
38
-
39
- // Return the updated state.
40
- return {
41
- ...state,
42
- ...nextState,
43
- };
44
- }
@@ -1,16 +0,0 @@
1
- import { ExploreActionKind } from "../../../exploreState";
2
- import { SyncStateFromUrlAction, SyncStateFromUrlPayload } from "./types";
3
-
4
- /**
5
- * Action creator for syncing state from URL.
6
- * @param payload - Payload.
7
- * @returns Action with payload and action type.
8
- */
9
- export function syncStateFromUrl(
10
- payload: SyncStateFromUrlPayload
11
- ): SyncStateFromUrlAction {
12
- return {
13
- payload,
14
- type: ExploreActionKind.SyncStateFromUrl,
15
- };
16
- }
@@ -1,13 +0,0 @@
1
- import { ExploreActionKind, ExploreState } from "../../../exploreState";
2
-
3
- export type SyncStateFromUrlAction = {
4
- payload: SyncStateFromUrlPayload;
5
- type: ExploreActionKind.SyncStateFromUrl;
6
- };
7
-
8
- export type SyncStateFromUrlPayload = Pick<
9
- ExploreState,
10
- "catalogState" | "featureFlagState" | "filterState"
11
- > & {
12
- entityListType: string;
13
- };