@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,20 @@
1
+ import { META_COMMAND } from "../../../../hooks/stateSyncManager/hooks/UseMetaCommands/types";
2
+ import { ExploreState } from "../../../exploreState";
3
+ import { ROUTER_METHOD, StateToUrlPayload } from "./types";
4
+
5
+ /**
6
+ * Reducer function to handle the "state >> URL sync" action.
7
+ * @param state - State.
8
+ * @param payload - Payload.
9
+ * @returns state.
10
+ */
11
+ export function stateToUrlAction(
12
+ state: ExploreState,
13
+ payload: StateToUrlPayload
14
+ ): ExploreState {
15
+ const command =
16
+ payload.method === ROUTER_METHOD.PUSH
17
+ ? META_COMMAND.STATE_TO_URL_PUSH
18
+ : META_COMMAND.STATE_TO_URL_REPLACE;
19
+ return { ...state, meta: { command } };
20
+ }
@@ -0,0 +1,14 @@
1
+ import { ExploreActionKind } from "../../../exploreState";
2
+ import { StateToUrlAction, StateToUrlPayload } from "./types";
3
+
4
+ /**
5
+ * Action creator for state >> URL sync.
6
+ * @param payload - Payload.
7
+ * @returns Action with payload and action type.
8
+ */
9
+ export function stateToUrl(payload: StateToUrlPayload): StateToUrlAction {
10
+ return {
11
+ payload,
12
+ type: ExploreActionKind.StateToUrl,
13
+ };
14
+ }
@@ -0,0 +1,15 @@
1
+ import { ExploreActionKind } from "../../../exploreState";
2
+
3
+ export enum ROUTER_METHOD {
4
+ PUSH = "push",
5
+ REPLACE = "replace",
6
+ }
7
+
8
+ export type StateToUrlAction = {
9
+ payload: StateToUrlPayload;
10
+ type: ExploreActionKind.StateToUrl;
11
+ };
12
+
13
+ export type StateToUrlPayload = {
14
+ method: ROUTER_METHOD;
15
+ };
@@ -0,0 +1,74 @@
1
+ import {
2
+ CatalogState,
3
+ ExploreState,
4
+ FeatureFlagState,
5
+ } from "../../../exploreState";
6
+ import { EXPLORE_URL_PARAMS } from "../../../exploreState/constants";
7
+ import { buildNextEntities } from "../../entities/state";
8
+ import {
9
+ getEntityCategoryGroupConfigKey,
10
+ getFilterCount,
11
+ updateEntityStateByCategoryGroupConfigKey,
12
+ } from "../../utils";
13
+ import { UrlToStatePayload } from "./types";
14
+ import { decodeFilterParamValue } from "./utils";
15
+
16
+ /**
17
+ * Reducer function to handle the "URL >> state sync" action.
18
+ * @param state - State.
19
+ * @param payload - Payload.
20
+ * @returns state.
21
+ */
22
+ export function urlToStateAction(
23
+ state: ExploreState,
24
+ payload: UrlToStatePayload
25
+ ): ExploreState {
26
+ const { query } = payload;
27
+
28
+ // Get the entity list type from the query.
29
+ const { entityListType } = query;
30
+
31
+ // If the entityListType is not a string, return the current state.
32
+ if (typeof entityListType !== "string") return state;
33
+
34
+ // Decode the catalog param value to catalog state.
35
+ const catalogState = query[EXPLORE_URL_PARAMS.CATALOG] as CatalogState;
36
+
37
+ // Decode the filter param value to selected filters.
38
+ const filterState = decodeFilterParamValue(query[EXPLORE_URL_PARAMS.FILTER]);
39
+
40
+ // Decode the feature flag param value to feature flag state.
41
+ const featureFlagState = query[
42
+ EXPLORE_URL_PARAMS.FEATURE_FLAG
43
+ ] as FeatureFlagState;
44
+
45
+ // Grab the category group config key for the entityListType.
46
+ const categoryGroupConfigKey = getEntityCategoryGroupConfigKey(
47
+ entityListType,
48
+ state.entityPageState
49
+ );
50
+
51
+ // Update the entity state by category group config key.
52
+ updateEntityStateByCategoryGroupConfigKey(
53
+ state,
54
+ { filterState, savedFilterState: [] },
55
+ categoryGroupConfigKey
56
+ );
57
+
58
+ return {
59
+ ...state,
60
+ catalogState,
61
+ entities: buildNextEntities(
62
+ { ...state, catalogState, featureFlagState },
63
+ entityListType,
64
+ { filterState }
65
+ ),
66
+ featureFlagState,
67
+ filterCount:
68
+ entityListType === state.tabValue
69
+ ? getFilterCount(filterState)
70
+ : state.filterCount,
71
+ filterState:
72
+ entityListType === state.tabValue ? filterState : state.filterState,
73
+ };
74
+ }
@@ -0,0 +1,14 @@
1
+ import { ExploreActionKind } from "../../../exploreState";
2
+ import { UrlToStateAction, UrlToStatePayload } from "./types";
3
+
4
+ /**
5
+ * Action creator for URL >> state sync.
6
+ * @param payload - Payload.
7
+ * @returns Action with payload and action type.
8
+ */
9
+ export function urlToState(payload: UrlToStatePayload): UrlToStateAction {
10
+ return {
11
+ payload,
12
+ type: ExploreActionKind.UrlToState,
13
+ };
14
+ }
@@ -0,0 +1,11 @@
1
+ import { NextRouter } from "next/router";
2
+ import { ExploreActionKind } from "../../../exploreState";
3
+
4
+ export type UrlToStateAction = {
5
+ payload: UrlToStatePayload;
6
+ type: ExploreActionKind.UrlToState;
7
+ };
8
+
9
+ export type UrlToStatePayload = {
10
+ query: NextRouter["query"];
11
+ };
@@ -0,0 +1,18 @@
1
+ import { SelectedFilter } from "../../../../common/entities";
2
+
3
+ /**
4
+ * Returns the selected filters from the filter parameter value.
5
+ * @param paramValue - The filter parameter value.
6
+ * @returns The selected filters or an empty array.
7
+ */
8
+ export function decodeFilterParamValue(
9
+ paramValue: string | string[] | undefined
10
+ ): SelectedFilter[] {
11
+ if (typeof paramValue === "string") {
12
+ // Return decoded filter param value if it is a string.
13
+ return JSON.parse(decodeURIComponent(paramValue));
14
+ }
15
+
16
+ // Default to an empty array.
17
+ return [];
18
+ }
@@ -1,18 +1,24 @@
1
1
  import { NextRouter } from "next/router";
2
- import { ExploreState } from "../../../exploreState";
3
- import { ExploreQueryState } from "./types";
2
+ import { SelectedFilter } from "../../../../common/entities";
3
+ import { EntityState } from "../types";
4
4
 
5
5
  /**
6
- * Builds a query object from state.
6
+ * Builds a query object from entity related state.
7
7
  * State values are expected to be undefined, string, or an array.
8
8
  * Undefined values and empty arrays are not included in the query.
9
- * @param state - State -- partial explore state.
9
+ * @param entityListType - Entity list type.
10
+ * @param state - Entity related state.
10
11
  * @returns A query object.
11
12
  */
12
- export function buildQuery(state: ExploreQueryState): NextRouter["query"] {
13
+ export function buildQuery(
14
+ entityListType: string,
15
+ state: EntityState
16
+ ): NextRouter["query"] {
13
17
  const query: NextRouter["query"] = {};
14
18
 
15
- for (const [key, value] of Object.entries(state)) {
19
+ for (const [key, value] of Object.entries(
20
+ getQueryState(entityListType, state)
21
+ )) {
16
22
  // Handle the undefined case.
17
23
  if (value === undefined) continue;
18
24
 
@@ -39,31 +45,22 @@ export function buildQuery(state: ExploreQueryState): NextRouter["query"] {
39
45
  *
40
46
  * The extracted properties are:
41
47
  * - catalog: Current catalog selection (string | undefined)
42
- * - entityListType: Current active tab value (string)
48
+ * - entityListType: Entity list type (string)
43
49
  * - ff: Feature flag state (string | undefined)
44
50
  * - filter: Applied filters (SelectedFilter[])
45
51
  *
46
- * @param exploreState - Explore state.
52
+ * @param entityListType - Entity list type.
53
+ * @param state - Entity related state.
47
54
  * @returns Subset of state used for URL query parameters.
48
55
  */
49
- export function getQueryState(exploreState: ExploreState): ExploreQueryState {
56
+ export function getQueryState(
57
+ entityListType: string,
58
+ state: EntityState
59
+ ): Record<string, string | SelectedFilter[] | undefined> {
50
60
  return {
51
- catalog: exploreState.catalogState,
52
- entityListType: exploreState.tabValue,
53
- ff: exploreState.featureFlagState,
54
- filter: exploreState.filterState,
61
+ catalog: state.catalogState,
62
+ entityListType,
63
+ ff: state.featureFlagState,
64
+ filter: state.filterState,
55
65
  };
56
66
  }
57
-
58
- /**
59
- * Returns a sorted string representation of a query object.
60
- * @param query - Query object.
61
- * @returns Sorted string representation of the query object.
62
- */
63
- export function stringifyQuery(query: NextRouter["query"]): string {
64
- return JSON.stringify(
65
- Object.keys(query)
66
- .sort()
67
- .reduce((acc, key) => ({ ...acc, [key]: query[key] }), {})
68
- );
69
- }
@@ -0,0 +1,50 @@
1
+ import { ExploreState } from "../../exploreState";
2
+ import { buildQuery } from "./query/buildQuery";
3
+ import { EntitiesContext, EntityState } from "./types";
4
+
5
+ /**
6
+ * Builds the next entities context.
7
+ * @param state - State.
8
+ * @param entityListType - Entity list type.
9
+ * @param nextEntityState - Next entity state.
10
+ * @returns Next entities context.
11
+ */
12
+ export function buildNextEntities(
13
+ state: ExploreState,
14
+ entityListType: string,
15
+ nextEntityState: Pick<EntityState, "filterState">
16
+ ): EntitiesContext {
17
+ // Get the entity key for the current entity.
18
+ // Other entities may share the same key and therefore filter state.
19
+ const key = state.entities[entityListType].entityKey;
20
+
21
+ const entities: EntitiesContext = {};
22
+
23
+ for (const [entityPath, entity] of Object.entries(state.entities)) {
24
+ // Grab the entity key for the entity.
25
+ const entityKey = entity.entityKey;
26
+
27
+ if (entityKey !== key) {
28
+ // For entities that do not share the same key, leave the context unchanged.
29
+ entities[entityPath] = entity;
30
+ continue;
31
+ }
32
+
33
+ // Clone the entity context.
34
+ const entityContext = { ...entity };
35
+
36
+ // Update entity context with "shared" context (e.g. filterState).
37
+ entityContext.query = buildQuery(entityPath, {
38
+ ...nextEntityState,
39
+ catalogState: state.catalogState,
40
+ featureFlagState: state.featureFlagState,
41
+ });
42
+
43
+ // At some point, we may need to update the entity context with additional properties that
44
+ // are not "shared" (e.g. column grouping).
45
+ // For now, this is not needed and so we update entities with the updated entity context and continue.
46
+ entities[entityPath] = entityContext;
47
+ }
48
+
49
+ return entities;
50
+ }
@@ -0,0 +1,19 @@
1
+ import { NextRouter } from "next/router";
2
+ import { SelectedFilter } from "../../../common/entities";
3
+ import { EntityPath } from "../../../config/entities";
4
+ import { CatalogState, FeatureFlagState } from "../../exploreState";
5
+
6
+ export interface EntitiesContext {
7
+ [key: EntityPath]: EntityContext;
8
+ }
9
+
10
+ export interface EntityContext {
11
+ entityKey: string;
12
+ query: NextRouter["query"];
13
+ }
14
+
15
+ export interface EntityState {
16
+ catalogState: CatalogState;
17
+ featureFlagState: FeatureFlagState;
18
+ filterState: SelectedFilter[];
19
+ }
@@ -18,7 +18,7 @@ import {
18
18
  EntityPath,
19
19
  SavedFilter,
20
20
  } from "../../config/entities";
21
- import { META_COMMAND } from "../exploreStateSync/hooks/UseMetaCommands/types";
21
+ import { META_COMMAND } from "../../hooks/stateSyncManager/hooks/UseMetaCommands/types";
22
22
 
23
23
  export interface EntityPageState {
24
24
  categoryGroupConfigKey: CategoryGroupConfigKey;
@@ -29,6 +29,7 @@ export const DEFAULT_PAGINATION_STATE: PaginationState = {
29
29
  export const INITIAL_STATE: ExploreState = {
30
30
  catalogState: undefined,
31
31
  categoryViews: [],
32
+ entities: {},
32
33
  entityPageState: {},
33
34
  entityStateByCategoryGroupConfigKey: new Map(),
34
35
  featureFlagState: undefined,
@@ -21,6 +21,8 @@ import {
21
21
  EntityStateByCategoryGroupConfigKey,
22
22
  SavedFilterByCategoryValueKey,
23
23
  } from "../entities";
24
+ import { buildNextEntities } from "../entities/state";
25
+ import { EntitiesContext } from "../entities/types";
24
26
  import { getEntityCategoryGroupConfigKey, getFilterCount } from "../utils";
25
27
  import {
26
28
  DEFAULT_CATEGORY_GROUP_SAVED_FILTERS,
@@ -186,6 +188,23 @@ function initEntityPageState(config: SiteConfig): EntityPageStateMapper {
186
188
  }, {} as EntityPageStateMapper);
187
189
  }
188
190
 
191
+ /**
192
+ * Initializes entities context.
193
+ * @param entityPageState - Entity page state.
194
+ * @returns Entities context.
195
+ */
196
+ function initEntities(entityPageState: EntityPageStateMapper): EntitiesContext {
197
+ return Object.keys(entityPageState).reduce((acc, entityPath) => {
198
+ return {
199
+ ...acc,
200
+ [entityPath]: {
201
+ entityKey: entityPageState[entityPath].categoryGroupConfigKey,
202
+ query: { entityListType: entityPath },
203
+ },
204
+ };
205
+ }, {} as EntitiesContext);
206
+ }
207
+
189
208
  /**
190
209
  * Initializes entity state by category group config key.
191
210
  * @param config - Site config.
@@ -294,10 +313,14 @@ export function initReducerArguments(
294
313
  entityStateByCategoryGroupConfigKey,
295
314
  categoryGroupConfigKey
296
315
  );
297
- return {
316
+ const entities = initEntities(entityPageState);
317
+
318
+ // Initialize state.
319
+ const state = {
298
320
  ...INITIAL_STATE,
299
321
  catalogState: decodedCatalogParam,
300
322
  categoryGroups,
323
+ entities,
301
324
  entityPageState,
302
325
  entityStateByCategoryGroupConfigKey,
303
326
  featureFlagState: decodedFeatureFlagParam,
@@ -305,4 +328,10 @@ export function initReducerArguments(
305
328
  filterState,
306
329
  tabValue: entityListType,
307
330
  };
331
+
332
+ // Return state with entities (updated by initial state).
333
+ return {
334
+ ...state,
335
+ entities: buildNextEntities(state, entityListType, { filterState }),
336
+ };
308
337
  }
@@ -14,6 +14,7 @@ import { SelectedFilter } from "../common/entities";
14
14
  import { RowPreviewState } from "../components/Table/features/RowPreview/entities";
15
15
  import { CategoryGroup, SiteConfig } from "../config/entities";
16
16
  import { useToken } from "../hooks/authentication/token/useToken";
17
+ import { META_COMMAND } from "../hooks/stateSyncManager/hooks/UseMetaCommands/types";
17
18
  import {
18
19
  buildCategoryViews,
19
20
  buildNextFilterState,
@@ -22,19 +23,22 @@ import { useConfig } from "../hooks/useConfig";
22
23
  import { useURLFilterParams } from "../hooks/useURLFilterParams";
23
24
  import { clearMetaAction } from "./exploreState/actions/clearMeta/action";
24
25
  import { ClearMetaAction } from "./exploreState/actions/clearMeta/types";
25
- import { syncStateFromUrlAction } from "./exploreState/actions/syncStateFromUrl/action";
26
- import { SyncStateFromUrlAction } from "./exploreState/actions/syncStateFromUrl/types";
26
+ import { stateToUrlAction } from "./exploreState/actions/stateToUrl/action";
27
+ import { StateToUrlAction } from "./exploreState/actions/stateToUrl/types";
27
28
  import { updateGroupingAction } from "./exploreState/actions/updateGrouping/action";
28
29
  import { UpdateGroupingAction } from "./exploreState/actions/updateGrouping/types";
29
30
  import { updateColumnVisibilityAction } from "./exploreState/actions/updateVisibility/action";
30
31
  import { UpdateColumnVisibilityAction } from "./exploreState/actions/updateVisibility/types";
32
+ import { urlToStateAction } from "./exploreState/actions/urlToState/action";
33
+ import { UrlToStateAction } from "./exploreState/actions/urlToState/types";
31
34
  import {
32
35
  EntityPageStateMapper,
33
36
  EntityStateByCategoryGroupConfigKey,
34
37
  ListItem,
35
38
  Meta,
36
39
  } from "./exploreState/entities";
37
- import { useBeforePopState } from "./exploreState/hooks/UseBeforePopState/useBeforePopState";
40
+ import { buildNextEntities } from "./exploreState/entities/state";
41
+ import { EntitiesContext } from "./exploreState/entities/types";
38
42
  import {
39
43
  DEFAULT_PAGINATION_STATE,
40
44
  INITIAL_STATE,
@@ -68,7 +72,6 @@ import {
68
72
  updateEntityStateByCategoryGroupConfigKey,
69
73
  updateSelectColumnVisibility,
70
74
  } from "./exploreState/utils";
71
- import { META_COMMAND } from "./exploreStateSync/hooks/UseMetaCommands/types";
72
75
 
73
76
  export type CatalogState = string | undefined;
74
77
 
@@ -87,6 +90,7 @@ export type ExploreState = {
87
90
  catalogState: CatalogState;
88
91
  categoryGroups?: CategoryGroup[];
89
92
  categoryViews: CategoryView[];
93
+ entities: EntitiesContext;
90
94
  entityPageState: EntityPageStateMapper;
91
95
  entityStateByCategoryGroupConfigKey: EntityStateByCategoryGroupConfigKey;
92
96
  featureFlagState: FeatureFlagState;
@@ -214,9 +218,6 @@ export function ExploreStateProvider({
214
218
  });
215
219
  }, [exploreDispatch, token]);
216
220
 
217
- // Before pop state related side effects (forward / backward navigation by browser buttons).
218
- useBeforePopState({ exploreDispatch, exploreState });
219
-
220
221
  return (
221
222
  <ExploreStateContext.Provider value={exploreContextValue}>
222
223
  {children}
@@ -237,7 +238,7 @@ export enum ExploreActionKind {
237
238
  ResetExploreResponse = "RESET_EXPLORE_RESPONSE",
238
239
  ResetState = "RESET_STATE",
239
240
  SelectEntityType = "SELECT_ENTITY_TYPE",
240
- SyncStateFromUrl = "SYNC_STATE_FROM_URL",
241
+ StateToUrl = "STATE_TO_URL",
241
242
  UpdateColumnVisibility = "UPDATE_COLUMN_VISIBILITY",
242
243
  UpdateEntityFilters = "UPDATE_ENTITY_FILTERS",
243
244
  UpdateEntityViewAccess = "UPDATE_ENTITY_VIEW_ACCESS",
@@ -246,6 +247,7 @@ export enum ExploreActionKind {
246
247
  UpdateRowPreview = "UPDATE_ROW_PREVIEW",
247
248
  UpdateRowSelection = "UPDATE_ROW_SELECTION",
248
249
  UpdateSorting = "UPDATE_SORTING",
250
+ UrlToState = "URL_TO_STATE",
249
251
  }
250
252
 
251
253
  /**
@@ -261,7 +263,7 @@ export type ExploreAction =
261
263
  | ResetExploreResponseAction
262
264
  | ResetStateAction
263
265
  | SelectEntityTypeAction
264
- | SyncStateFromUrlAction
266
+ | StateToUrlAction
265
267
  | UpdateColumnVisibilityAction
266
268
  | UpdateEntityFiltersAction
267
269
  | UpdateEntityViewAccessAction
@@ -269,7 +271,8 @@ export type ExploreAction =
269
271
  | UpdateGroupingAction
270
272
  | UpdateRowPreviewAction
271
273
  | UpdateRowSelectionAction
272
- | UpdateSortingAction;
274
+ | UpdateSortingAction
275
+ | UrlToStateAction;
273
276
 
274
277
  /**
275
278
  * Apply saved filter action.
@@ -435,6 +438,7 @@ function exploreReducer(
435
438
  });
436
439
  return {
437
440
  ...state,
441
+ entities: buildNextEntities(state, state.tabValue, { filterState }),
438
442
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
439
443
  state,
440
444
  { grouping, rowPreview, rowSelection, sorting }
@@ -461,6 +465,7 @@ function exploreReducer(
461
465
  });
462
466
  return {
463
467
  ...state,
468
+ entities: buildNextEntities(state, state.tabValue, { filterState }),
464
469
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
465
470
  state,
466
471
  { rowPreview, rowSelection }
@@ -574,11 +579,7 @@ function exploreReducer(
574
579
  **/
575
580
  case ExploreActionKind.SelectEntityType: {
576
581
  if (payload === state.tabValue) {
577
- // Update meta to match command "STATE_TO_URL_REPLACE" - facilitates navigation to filters on return back to entity from elsewhere.
578
- return {
579
- ...state,
580
- meta: { command: META_COMMAND.STATE_TO_URL_REPLACE },
581
- };
582
+ return state;
582
583
  }
583
584
  const entityState = getEntityState(
584
585
  state,
@@ -593,17 +594,16 @@ function exploreReducer(
593
594
  filterState: entityState.filterState,
594
595
  listItems: [],
595
596
  loading: true,
596
- meta: { command: META_COMMAND.STATE_TO_URL_REPLACE },
597
597
  paginationState: { ...resetPage(state.paginationState), rows: 0 },
598
598
  rowPreview,
599
599
  tabValue: payload,
600
600
  };
601
601
  }
602
602
  /**
603
- * Sync state from URL.
603
+ * State >> URL sync
604
604
  */
605
- case ExploreActionKind.SyncStateFromUrl: {
606
- return syncStateFromUrlAction(state, payload);
605
+ case ExploreActionKind.StateToUrl: {
606
+ return stateToUrlAction(state, payload);
607
607
  }
608
608
  /**
609
609
  * Update column visibility
@@ -648,6 +648,7 @@ function exploreReducer(
648
648
  );
649
649
  return {
650
650
  ...state,
651
+ entities: buildNextEntities(state, entityListType, { filterState }),
651
652
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
652
653
  state,
653
654
  { grouping, rowPreview, rowSelection, sorting },
@@ -692,6 +693,7 @@ function exploreReducer(
692
693
  });
693
694
  return {
694
695
  ...state,
696
+ entities: buildNextEntities(state, state.tabValue, { filterState }),
695
697
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
696
698
  state,
697
699
  { rowPreview, rowSelection }
@@ -755,7 +757,12 @@ function exploreReducer(
755
757
  rowPreview,
756
758
  };
757
759
  }
758
-
760
+ /**
761
+ * URL >> state sync.
762
+ */
763
+ case ExploreActionKind.UrlToState: {
764
+ return urlToStateAction(state, payload);
765
+ }
759
766
  default:
760
767
  return state;
761
768
  }
@@ -0,0 +1,25 @@
1
+ import React, { ReactNode } from "react";
2
+ import { usePopStateBus } from "../../services/beforePopState/usePopStateBus";
3
+ import { WasPopProvider } from "./wasPop/provider";
4
+
5
+ /**
6
+ * ServicesProvider is a component that initializes and provides access to various service-related
7
+ * functionality throughout the application.
8
+ *
9
+ * This provider:
10
+ * 1. Registers the pop state bus to handle browser navigation events.
11
+ * 2. Provides the WasPopProvider context to track browser back/forward navigation
12
+ *
13
+ * This provider should be placed at the _app root level to ensure all components have access to these services.
14
+ */
15
+
16
+ export function ServicesProvider({
17
+ children,
18
+ }: {
19
+ children: ReactNode;
20
+ }): JSX.Element {
21
+ // Register the pop state bus.
22
+ usePopStateBus();
23
+
24
+ return <WasPopProvider>{children}</WasPopProvider>;
25
+ }
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react";
2
+ import { WasPopContextProps } from "./types";
3
+
4
+ export const WasPopContext = createContext<WasPopContextProps>({
5
+ onClearPopRef: () => {},
6
+ popRef: { current: undefined },
7
+ });
@@ -0,0 +1,7 @@
1
+ import { useContext } from "react";
2
+ import { WasPopContext } from "./context";
3
+ import { WasPopContextProps } from "./types";
4
+
5
+ export const useWasPop = (): WasPopContextProps => {
6
+ return useContext(WasPopContext);
7
+ };
@@ -0,0 +1,45 @@
1
+ import React, { ReactNode, useCallback, useRef } from "react";
2
+ import { NextHistoryState } from "../../../services/beforePopState/types";
3
+ import { useOnPopState } from "../../../services/beforePopState/useOnPopState";
4
+ import { WasPopContext } from "./context";
5
+
6
+ /**
7
+ * WasPopProvider tracks browser navigation events to determine if the current route change
8
+ * was triggered by a popstate event (browser back/forward navigation).
9
+ *
10
+ * This provider:
11
+ * 1. Registers callbacks for route change events.
12
+ * 2. Tracks when navigation occurs via browser back/forward buttons
13
+ * 3. Provides this state via context to child components
14
+ *
15
+ * This allows components to respond differently to user-initiated navigation versus
16
+ * browser history navigation.
17
+ */
18
+
19
+ export function WasPopProvider({
20
+ children,
21
+ }: {
22
+ children: ReactNode;
23
+ }): JSX.Element {
24
+ const popRef = useRef<NextHistoryState | undefined>();
25
+
26
+ // Pop callback.
27
+ const onBeforePopState = useCallback((state: NextHistoryState) => {
28
+ popRef.current = state;
29
+ return true;
30
+ }, []);
31
+
32
+ // Clear pop ref.
33
+ const onClearPopRef = useCallback(() => {
34
+ popRef.current = undefined;
35
+ }, []);
36
+
37
+ // Register the callback to be invoked before pop.
38
+ useOnPopState(onBeforePopState);
39
+
40
+ return (
41
+ <WasPopContext.Provider value={{ onClearPopRef, popRef }}>
42
+ {children}
43
+ </WasPopContext.Provider>
44
+ );
45
+ }
@@ -0,0 +1,7 @@
1
+ import { MutableRefObject } from "react";
2
+ import { NextHistoryState } from "../../../services/beforePopState/types";
3
+
4
+ export interface WasPopContextProps {
5
+ onClearPopRef: () => void;
6
+ popRef: MutableRefObject<NextHistoryState | undefined>;
7
+ }