@databiosphere/findable-ui 34.0.0 → 35.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) 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/UseMetaCommands/types.js +5 -0
  102. package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.d.ts +2 -0
  103. package/lib/hooks/stateSyncManager/hooks/UseStateSync/hook.js +40 -0
  104. package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.d.ts +30 -0
  105. package/lib/hooks/stateSyncManager/hooks/UseStateSync/utils.js +41 -0
  106. package/lib/hooks/stateSyncManager/types.d.ts +26 -0
  107. package/lib/hooks/stateSyncManager/types.js +1 -0
  108. package/lib/hooks/useAuthentication/common/constants.d.ts +4 -0
  109. package/lib/hooks/useAuthentication/common/constants.js +19 -0
  110. package/lib/hooks/useAuthentication/common/entities.d.ts +25 -0
  111. package/lib/hooks/useAuthentication/common/entities.js +11 -0
  112. package/lib/hooks/useAuthentication/common/utils.d.ts +15 -0
  113. package/lib/hooks/useAuthentication/common/utils.js +25 -0
  114. package/lib/hooks/useAuthentication/useAuthentication.d.ts +6 -0
  115. package/lib/hooks/useAuthentication/useAuthentication.js +9 -0
  116. package/lib/hooks/useAuthentication/useAuthenticationComplete.d.ts +6 -0
  117. package/lib/hooks/useAuthentication/useAuthenticationComplete.js +55 -0
  118. package/lib/hooks/useAuthentication/useAuthenticationForm.d.ts +20 -0
  119. package/lib/hooks/useAuthentication/useAuthenticationForm.js +88 -0
  120. package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.d.ts +18 -0
  121. package/lib/hooks/useAuthentication/useAuthenticationNIHExpiry.js +50 -0
  122. package/lib/hooks/useAuthentication/useAuthenticationStatus.d.ts +20 -0
  123. package/lib/hooks/useAuthentication/useAuthenticationStatus.js +32 -0
  124. package/lib/hooks/useAuthentication/useFetchGoogleProfile.d.ts +21 -0
  125. package/lib/hooks/useAuthentication/useFetchGoogleProfile.js +41 -0
  126. package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.d.ts +18 -0
  127. package/lib/hooks/useAuthentication/useFetchTerraNIHProfile.js +62 -0
  128. package/lib/hooks/useAuthentication/useFetchTerraProfile.d.ts +24 -0
  129. package/lib/hooks/useAuthentication/useFetchTerraProfile.js +62 -0
  130. package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.d.ts +15 -0
  131. package/lib/hooks/useAuthentication/useFetchTerraTermsOfService.js +62 -0
  132. package/lib/hooks/useAuthentication/useTokenClient.d.ts +11 -0
  133. package/lib/hooks/useAuthentication/useTokenClient.js +29 -0
  134. package/lib/hooks/useAuthenticationConfig.d.ts +6 -0
  135. package/lib/hooks/useAuthenticationConfig.js +14 -0
  136. package/lib/hooks/useCategoryConfigs.d.ts +6 -0
  137. package/lib/hooks/useCategoryConfigs.js +17 -0
  138. package/lib/hooks/useEntityListRelatedView.d.ts +15 -0
  139. package/lib/hooks/useEntityListRelatedView.js +62 -0
  140. package/lib/hooks/useExploreMode.d.ts +14 -0
  141. package/lib/hooks/useExploreMode.js +20 -0
  142. package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.d.ts +15 -0
  143. package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.js +27 -0
  144. package/lib/hooks/useFileManifest/useFileManifestURL.d.ts +5 -0
  145. package/lib/hooks/useFileManifest/useFileManifestURL.js +11 -0
  146. package/lib/hooks/useFileManifest/useRequestFileManifest.d.ts +9 -0
  147. package/lib/hooks/useFileManifest/useRequestFileManifest.js +37 -0
  148. package/lib/hooks/useLayoutState.d.ts +6 -0
  149. package/lib/hooks/useLayoutState.js +9 -0
  150. package/lib/hooks/useMenu.d.ts +10 -0
  151. package/lib/hooks/useMenu.js +17 -0
  152. package/lib/hooks/useMenuWithPosition.d.ts +14 -0
  153. package/lib/hooks/useMenuWithPosition.js +33 -0
  154. package/lib/hooks/useSessionTimeout.d.ts +11 -0
  155. package/lib/hooks/useSessionTimeout.js +28 -0
  156. package/lib/providers/authentication.d.ts +51 -0
  157. package/lib/providers/authentication.js +110 -0
  158. package/lib/providers/exploreState/actions/stateToUrl/action.d.ts +9 -0
  159. package/lib/providers/exploreState/actions/stateToUrl/action.js +14 -0
  160. package/lib/providers/exploreState/actions/stateToUrl/dispatch.d.ts +7 -0
  161. package/lib/providers/exploreState/actions/{syncStateFromUrl → stateToUrl}/dispatch.js +3 -3
  162. package/lib/providers/exploreState/actions/stateToUrl/types.d.ts +12 -0
  163. package/lib/providers/exploreState/actions/stateToUrl/types.js +5 -0
  164. package/lib/providers/exploreState/actions/urlToState/action.d.ts +9 -0
  165. package/lib/providers/exploreState/actions/urlToState/action.js +38 -0
  166. package/lib/providers/exploreState/actions/urlToState/dispatch.d.ts +7 -0
  167. package/lib/providers/exploreState/actions/urlToState/dispatch.js +12 -0
  168. package/lib/providers/exploreState/actions/urlToState/types.d.ts +9 -0
  169. package/lib/providers/exploreState/actions/urlToState/types.js +1 -0
  170. package/lib/providers/exploreState/actions/urlToState/utils.d.ts +7 -0
  171. package/lib/providers/exploreState/actions/urlToState/utils.js +13 -0
  172. package/lib/providers/exploreState/entities/query/buildQuery.d.ts +30 -0
  173. package/lib/providers/exploreState/entities/query/buildQuery.js +51 -0
  174. package/lib/providers/exploreState/entities/state.d.ts +10 -0
  175. package/lib/providers/exploreState/entities/state.js +36 -0
  176. package/lib/providers/exploreState/entities/types.d.ts +16 -0
  177. package/lib/providers/exploreState/entities/types.js +1 -0
  178. package/lib/providers/exploreState/entities.d.ts +1 -1
  179. package/lib/providers/exploreState/initializer/constants.js +1 -0
  180. package/lib/providers/exploreState/initializer/utils.js +26 -1
  181. package/lib/providers/exploreState.d.ts +8 -4
  182. package/lib/providers/exploreState.js +23 -18
  183. package/lib/providers/layoutState.d.ts +40 -0
  184. package/lib/providers/layoutState.js +47 -0
  185. package/lib/providers/services/provider.d.ts +14 -0
  186. package/lib/providers/services/provider.js +18 -0
  187. package/lib/providers/services/wasPop/context.d.ts +2 -0
  188. package/lib/providers/services/wasPop/context.js +5 -0
  189. package/lib/providers/services/wasPop/hook.d.ts +2 -0
  190. package/lib/providers/services/wasPop/hook.js +5 -0
  191. package/lib/providers/services/wasPop/provider.d.ts +16 -0
  192. package/lib/providers/services/wasPop/provider.js +30 -0
  193. package/lib/providers/services/wasPop/types.d.ts +6 -0
  194. package/lib/providers/services/wasPop/types.js +1 -0
  195. package/lib/services/beforePopState/popStateBus.d.ts +20 -0
  196. package/lib/services/beforePopState/popStateBus.js +58 -0
  197. package/lib/services/beforePopState/types.d.ts +11 -0
  198. package/lib/services/beforePopState/types.js +1 -0
  199. package/lib/services/beforePopState/useOnPopState.d.ts +2 -0
  200. package/lib/services/beforePopState/useOnPopState.js +10 -0
  201. package/lib/services/beforePopState/usePopStateBus.d.ts +6 -0
  202. package/lib/services/beforePopState/usePopStateBus.js +12 -0
  203. package/lib/styles/common/mixins/shadows.d.ts +3 -0
  204. package/lib/styles/common/mixins/shadows.js +4 -0
  205. package/lib/styles/common/mui/palette.d.ts +47 -0
  206. package/lib/styles/common/mui/palette.js +47 -0
  207. package/lib/theme/common/entities.d.ts +6 -0
  208. package/lib/theme/common/entities.js +1 -0
  209. package/lib/views/ExploreView/exploreView.js +14 -0
  210. package/lib/views/ExploreView/utils.d.ts +14 -0
  211. package/lib/views/ExploreView/utils.js +17 -0
  212. package/package.json +1 -1
  213. package/src/hooks/stateSyncManager/hook.ts +47 -0
  214. package/src/hooks/stateSyncManager/hooks/UseBeforePopState/hook.ts +30 -0
  215. package/src/hooks/stateSyncManager/hooks/UseMetaCommands/hook.ts +30 -0
  216. package/src/hooks/stateSyncManager/hooks/UseMetaCommands/types.ts +4 -0
  217. package/src/hooks/stateSyncManager/hooks/UseStateSync/hook.ts +52 -0
  218. package/src/hooks/stateSyncManager/hooks/UseStateSync/utils.ts +58 -0
  219. package/src/hooks/stateSyncManager/types.ts +34 -0
  220. package/src/providers/exploreState/actions/stateToUrl/action.ts +20 -0
  221. package/src/providers/exploreState/actions/stateToUrl/dispatch.ts +14 -0
  222. package/src/providers/exploreState/actions/stateToUrl/types.ts +15 -0
  223. package/src/providers/exploreState/actions/urlToState/action.ts +74 -0
  224. package/src/providers/exploreState/actions/urlToState/dispatch.ts +14 -0
  225. package/src/providers/exploreState/actions/urlToState/types.ts +11 -0
  226. package/src/providers/exploreState/actions/urlToState/utils.ts +18 -0
  227. package/src/providers/exploreState/entities/query/buildQuery.ts +66 -0
  228. package/src/providers/exploreState/entities/state.ts +50 -0
  229. package/src/providers/exploreState/entities/types.ts +19 -0
  230. package/src/providers/exploreState/entities.ts +1 -1
  231. package/src/providers/exploreState/initializer/constants.ts +1 -0
  232. package/src/providers/exploreState/initializer/utils.ts +30 -1
  233. package/src/providers/exploreState.tsx +30 -24
  234. package/src/providers/services/provider.tsx +25 -0
  235. package/src/providers/services/wasPop/context.ts +7 -0
  236. package/src/providers/services/wasPop/hook.ts +7 -0
  237. package/src/providers/services/wasPop/provider.tsx +45 -0
  238. package/src/providers/services/wasPop/types.ts +7 -0
  239. package/src/services/beforePopState/popStateBus.ts +64 -0
  240. package/src/services/beforePopState/types.ts +15 -0
  241. package/src/services/beforePopState/useOnPopState.ts +15 -0
  242. package/src/services/beforePopState/usePopStateBus.ts +14 -0
  243. package/src/views/ExploreView/exploreView.tsx +15 -0
  244. package/src/views/ExploreView/utils.ts +25 -0
  245. package/lib/providers/exploreState/actions/syncStateFromUrl/action.d.ts +0 -10
  246. package/lib/providers/exploreState/actions/syncStateFromUrl/action.js +0 -25
  247. package/lib/providers/exploreState/actions/syncStateFromUrl/dispatch.d.ts +0 -7
  248. package/lib/providers/exploreState/actions/syncStateFromUrl/types.d.ts +0 -8
  249. package/lib/providers/exploreState/actions/syncStateFromUrl/utils.d.ts +0 -9
  250. package/lib/providers/exploreState/actions/syncStateFromUrl/utils.js +0 -23
  251. package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.d.ts +0 -18
  252. package/lib/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.js +0 -41
  253. package/lib/providers/exploreState/hooks/UseBeforePopState/utils.d.ts +0 -23
  254. package/lib/providers/exploreState/hooks/UseBeforePopState/utils.js +0 -68
  255. package/lib/providers/exploreState/hooks/UseMetaCommands/actions.d.ts +0 -13
  256. package/lib/providers/exploreState/hooks/UseMetaCommands/actions.js +0 -24
  257. package/lib/providers/exploreState/hooks/UseMetaCommands/types.d.ts +0 -4
  258. package/lib/providers/exploreState/hooks/UseMetaCommands/types.js +0 -5
  259. package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.d.ts +0 -2
  260. package/lib/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.js +0 -21
  261. package/lib/providers/exploreState/hooks/UseMetaCommands/utils.d.ts +0 -9
  262. package/lib/providers/exploreState/hooks/UseMetaCommands/utils.js +0 -25
  263. package/src/providers/exploreState/actions/syncStateFromUrl/action.ts +0 -44
  264. package/src/providers/exploreState/actions/syncStateFromUrl/dispatch.ts +0 -16
  265. package/src/providers/exploreState/actions/syncStateFromUrl/types.ts +0 -13
  266. package/src/providers/exploreState/actions/syncStateFromUrl/utils.ts +0 -31
  267. package/src/providers/exploreState/hooks/UseBeforePopState/useBeforePopState.ts +0 -46
  268. package/src/providers/exploreState/hooks/UseBeforePopState/utils.ts +0 -93
  269. package/src/providers/exploreState/hooks/UseMetaCommands/actions.ts +0 -29
  270. package/src/providers/exploreState/hooks/UseMetaCommands/types.ts +0 -4
  271. package/src/providers/exploreState/hooks/UseMetaCommands/useMetaCommands.ts +0 -27
  272. package/src/providers/exploreState/hooks/UseMetaCommands/utils.ts +0 -33
  273. /package/lib/{providers/exploreState/actions/syncStateFromUrl → components/DataDictionary/components/Table/columns}/types.js +0 -0
@@ -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
+ }
@@ -0,0 +1,66 @@
1
+ import { NextRouter } from "next/router";
2
+ import { SelectedFilter } from "../../../../common/entities";
3
+ import { EntityState } from "../types";
4
+
5
+ /**
6
+ * Builds a query object from entity related state.
7
+ * State values are expected to be undefined, string, or an array.
8
+ * Undefined values and empty arrays are not included in the query.
9
+ * @param entityListType - Entity list type.
10
+ * @param state - Entity related state.
11
+ * @returns A query object.
12
+ */
13
+ export function buildQuery(
14
+ entityListType: string,
15
+ state: EntityState
16
+ ): NextRouter["query"] {
17
+ const query: NextRouter["query"] = {};
18
+
19
+ for (const [key, value] of Object.entries(
20
+ getQueryState(entityListType, state)
21
+ )) {
22
+ // Handle the undefined case.
23
+ if (value === undefined) continue;
24
+
25
+ // Handle the string case.
26
+ if (typeof value === "string") {
27
+ query[key] = value;
28
+ continue;
29
+ }
30
+
31
+ // Handle the array case.
32
+ if (value.length === 0) continue;
33
+ query[key] = JSON.stringify(value);
34
+ }
35
+
36
+ return query;
37
+ }
38
+
39
+ /**
40
+ * Extracts URL-relevant values from the ExploreState for query parameter synchronization.
41
+ *
42
+ * This function maps specific properties from the full ExploreState to the
43
+ * ExploreQueryState interface, which contains only the subset of state that
44
+ * should be synchronized with the URL.
45
+ *
46
+ * The extracted properties are:
47
+ * - catalog: Current catalog selection (string | undefined)
48
+ * - entityListType: Entity list type (string)
49
+ * - ff: Feature flag state (string | undefined)
50
+ * - filter: Applied filters (SelectedFilter[])
51
+ *
52
+ * @param entityListType - Entity list type.
53
+ * @param state - Entity related state.
54
+ * @returns Subset of state used for URL query parameters.
55
+ */
56
+ export function getQueryState(
57
+ entityListType: string,
58
+ state: EntityState
59
+ ): Record<string, string | SelectedFilter[] | undefined> {
60
+ return {
61
+ catalog: state.catalogState,
62
+ entityListType,
63
+ ff: state.featureFlagState,
64
+ filter: state.filterState,
65
+ };
66
+ }
@@ -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 "./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: {},
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,21 +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";
38
- import { META_COMMAND } from "./exploreState/hooks/UseMetaCommands/types";
39
- import { useMetaCommands } from "./exploreState/hooks/UseMetaCommands/useMetaCommands";
40
+ import { buildNextEntities } from "./exploreState/entities/state";
41
+ import { EntitiesContext } from "./exploreState/entities/types";
40
42
  import {
41
43
  DEFAULT_PAGINATION_STATE,
42
44
  INITIAL_STATE,
@@ -88,6 +90,7 @@ export type ExploreState = {
88
90
  catalogState: CatalogState;
89
91
  categoryGroups?: CategoryGroup[];
90
92
  categoryViews: CategoryView[];
93
+ entities: EntitiesContext;
91
94
  entityPageState: EntityPageStateMapper;
92
95
  entityStateByCategoryGroupConfigKey: EntityStateByCategoryGroupConfigKey;
93
96
  featureFlagState: FeatureFlagState;
@@ -215,12 +218,6 @@ export function ExploreStateProvider({
215
218
  });
216
219
  }, [exploreDispatch, token]);
217
220
 
218
- // Meta-command related side effects.
219
- useMetaCommands({ exploreDispatch, exploreState });
220
-
221
- // Before pop state related side effects (forward / backward navigation by browser buttons).
222
- useBeforePopState({ exploreDispatch, exploreState });
223
-
224
221
  return (
225
222
  <ExploreStateContext.Provider value={exploreContextValue}>
226
223
  {children}
@@ -241,7 +238,7 @@ export enum ExploreActionKind {
241
238
  ResetExploreResponse = "RESET_EXPLORE_RESPONSE",
242
239
  ResetState = "RESET_STATE",
243
240
  SelectEntityType = "SELECT_ENTITY_TYPE",
244
- SyncStateFromUrl = "SYNC_STATE_FROM_URL",
241
+ StateToUrl = "STATE_TO_URL",
245
242
  UpdateColumnVisibility = "UPDATE_COLUMN_VISIBILITY",
246
243
  UpdateEntityFilters = "UPDATE_ENTITY_FILTERS",
247
244
  UpdateEntityViewAccess = "UPDATE_ENTITY_VIEW_ACCESS",
@@ -250,6 +247,7 @@ export enum ExploreActionKind {
250
247
  UpdateRowPreview = "UPDATE_ROW_PREVIEW",
251
248
  UpdateRowSelection = "UPDATE_ROW_SELECTION",
252
249
  UpdateSorting = "UPDATE_SORTING",
250
+ UrlToState = "URL_TO_STATE",
253
251
  }
254
252
 
255
253
  /**
@@ -265,7 +263,7 @@ export type ExploreAction =
265
263
  | ResetExploreResponseAction
266
264
  | ResetStateAction
267
265
  | SelectEntityTypeAction
268
- | SyncStateFromUrlAction
266
+ | StateToUrlAction
269
267
  | UpdateColumnVisibilityAction
270
268
  | UpdateEntityFiltersAction
271
269
  | UpdateEntityViewAccessAction
@@ -273,7 +271,8 @@ export type ExploreAction =
273
271
  | UpdateGroupingAction
274
272
  | UpdateRowPreviewAction
275
273
  | UpdateRowSelectionAction
276
- | UpdateSortingAction;
274
+ | UpdateSortingAction
275
+ | UrlToStateAction;
277
276
 
278
277
  /**
279
278
  * Apply saved filter action.
@@ -439,13 +438,14 @@ function exploreReducer(
439
438
  });
440
439
  return {
441
440
  ...state,
441
+ entities: buildNextEntities(state, state.tabValue, { filterState }),
442
442
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
443
443
  state,
444
444
  { grouping, rowPreview, rowSelection, sorting }
445
445
  ),
446
446
  filterCount: getFilterCount(filterState),
447
447
  filterState,
448
- meta: { command: META_COMMAND.NAVIGATE_TO_FILTERS },
448
+ meta: { command: META_COMMAND.STATE_TO_URL_PUSH },
449
449
  paginationState: resetPage(state.paginationState),
450
450
  rowPreview,
451
451
  };
@@ -465,13 +465,14 @@ function exploreReducer(
465
465
  });
466
466
  return {
467
467
  ...state,
468
+ entities: buildNextEntities(state, state.tabValue, { filterState }),
468
469
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
469
470
  state,
470
471
  { rowPreview, rowSelection }
471
472
  ),
472
473
  filterCount,
473
474
  filterState,
474
- meta: { command: META_COMMAND.NAVIGATE_TO_FILTERS },
475
+ meta: { command: META_COMMAND.STATE_TO_URL_PUSH },
475
476
  paginationState: resetPage(state.paginationState),
476
477
  rowPreview,
477
478
  };
@@ -578,8 +579,7 @@ function exploreReducer(
578
579
  **/
579
580
  case ExploreActionKind.SelectEntityType: {
580
581
  if (payload === state.tabValue) {
581
- // Update meta to match command "REPLACE_TO_FILTERS" - facilitates navigation to filters on return back to entity from elsewhere.
582
- return { ...state, meta: { command: META_COMMAND.REPLACE_TO_FILTERS } };
582
+ return state;
583
583
  }
584
584
  const entityState = getEntityState(
585
585
  state,
@@ -594,17 +594,16 @@ function exploreReducer(
594
594
  filterState: entityState.filterState,
595
595
  listItems: [],
596
596
  loading: true,
597
- meta: { command: META_COMMAND.REPLACE_TO_FILTERS },
598
597
  paginationState: { ...resetPage(state.paginationState), rows: 0 },
599
598
  rowPreview,
600
599
  tabValue: payload,
601
600
  };
602
601
  }
603
602
  /**
604
- * Sync state from URL.
603
+ * State >> URL sync
605
604
  */
606
- case ExploreActionKind.SyncStateFromUrl: {
607
- return syncStateFromUrlAction(state, payload);
605
+ case ExploreActionKind.StateToUrl: {
606
+ return stateToUrlAction(state, payload);
608
607
  }
609
608
  /**
610
609
  * Update column visibility
@@ -649,6 +648,7 @@ function exploreReducer(
649
648
  );
650
649
  return {
651
650
  ...state,
651
+ entities: buildNextEntities(state, entityListType, { filterState }),
652
652
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
653
653
  state,
654
654
  { grouping, rowPreview, rowSelection, sorting },
@@ -693,13 +693,14 @@ function exploreReducer(
693
693
  });
694
694
  return {
695
695
  ...state,
696
+ entities: buildNextEntities(state, state.tabValue, { filterState }),
696
697
  entityPageState: updateEntityPageStateWithCommonCategoryGroupConfigKey(
697
698
  state,
698
699
  { rowPreview, rowSelection }
699
700
  ),
700
701
  filterCount: getFilterCount(filterState),
701
702
  filterState,
702
- meta: { command: META_COMMAND.NAVIGATE_TO_FILTERS },
703
+ meta: { command: META_COMMAND.STATE_TO_URL_PUSH },
703
704
  paginationState: resetPage(state.paginationState),
704
705
  rowPreview,
705
706
  };
@@ -756,7 +757,12 @@ function exploreReducer(
756
757
  rowPreview,
757
758
  };
758
759
  }
759
-
760
+ /**
761
+ * URL >> state sync.
762
+ */
763
+ case ExploreActionKind.UrlToState: {
764
+ return urlToStateAction(state, payload);
765
+ }
760
766
  default:
761
767
  return state;
762
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
+ }