@beinformed/ui 1.65.9 → 1.65.11

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 (84) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/esm/hooks/useDeepCompareEffect.js +22 -8
  3. package/esm/hooks/useDeepCompareEffect.js.flow +26 -10
  4. package/esm/hooks/useDeepCompareEffect.js.map +1 -1
  5. package/esm/hooks/useList.js +18 -15
  6. package/esm/hooks/useList.js.flow +17 -16
  7. package/esm/hooks/useList.js.map +1 -1
  8. package/esm/hooks/useModularUIBasic.js +10 -3
  9. package/esm/hooks/useModularUIBasic.js.flow +11 -1
  10. package/esm/hooks/useModularUIBasic.js.map +1 -1
  11. package/esm/hooks/usePanel.js.flow +1 -1
  12. package/esm/hooks/usePanel.js.map +1 -1
  13. package/esm/hooks/useRouter.js +12 -6
  14. package/esm/hooks/useRouter.js.flow +29 -23
  15. package/esm/hooks/useRouter.js.map +1 -1
  16. package/esm/models/attributes/AttributeModel.js +14 -0
  17. package/esm/models/attributes/AttributeModel.js.flow +14 -0
  18. package/esm/models/attributes/AttributeModel.js.map +1 -1
  19. package/esm/models/attributes/CompositeAttributeModel.js +11 -11
  20. package/esm/models/attributes/CompositeAttributeModel.js.flow +11 -11
  21. package/esm/models/attributes/CompositeAttributeModel.js.map +1 -1
  22. package/esm/models/attributes/PasswordAttributeModel.js +3 -3
  23. package/esm/models/attributes/PasswordAttributeModel.js.flow +3 -3
  24. package/esm/models/attributes/PasswordAttributeModel.js.map +1 -1
  25. package/esm/models/filters/FilterModel.js +1 -1
  26. package/esm/models/filters/FilterModel.js.flow +1 -1
  27. package/esm/models/filters/FilterModel.js.map +1 -1
  28. package/esm/models/filters/RangeFilterModel.js +1 -1
  29. package/esm/models/filters/RangeFilterModel.js.flow +1 -1
  30. package/esm/models/filters/RangeFilterModel.js.map +1 -1
  31. package/esm/models/href/Href.js +27 -2
  32. package/esm/models/href/Href.js.flow +30 -2
  33. package/esm/models/href/Href.js.map +1 -1
  34. package/esm/models/href/ListHref.js +3 -2
  35. package/esm/models/href/ListHref.js.flow +4 -2
  36. package/esm/models/href/ListHref.js.map +1 -1
  37. package/esm/models/list/ListModel.js +7 -1
  38. package/esm/models/list/ListModel.js.flow +8 -2
  39. package/esm/models/list/ListModel.js.map +1 -1
  40. package/esm/models/parameter/Parameter.js +6 -6
  41. package/esm/models/parameter/Parameter.js.flow +6 -6
  42. package/esm/models/parameter/Parameter.js.map +1 -1
  43. package/lib/hooks/useDeepCompareEffect.js +22 -11
  44. package/lib/hooks/useDeepCompareEffect.js.map +1 -1
  45. package/lib/hooks/useList.js +18 -15
  46. package/lib/hooks/useList.js.map +1 -1
  47. package/lib/hooks/useModularUIBasic.js +9 -2
  48. package/lib/hooks/useModularUIBasic.js.map +1 -1
  49. package/lib/hooks/usePanel.js.map +1 -1
  50. package/lib/hooks/useRouter.js +12 -6
  51. package/lib/hooks/useRouter.js.map +1 -1
  52. package/lib/models/attributes/AttributeModel.js +14 -0
  53. package/lib/models/attributes/AttributeModel.js.map +1 -1
  54. package/lib/models/attributes/CompositeAttributeModel.js +11 -11
  55. package/lib/models/attributes/CompositeAttributeModel.js.map +1 -1
  56. package/lib/models/attributes/PasswordAttributeModel.js +3 -3
  57. package/lib/models/attributes/PasswordAttributeModel.js.map +1 -1
  58. package/lib/models/filters/FilterModel.js +1 -1
  59. package/lib/models/filters/FilterModel.js.map +1 -1
  60. package/lib/models/filters/RangeFilterModel.js +1 -1
  61. package/lib/models/filters/RangeFilterModel.js.map +1 -1
  62. package/lib/models/href/Href.js +27 -2
  63. package/lib/models/href/Href.js.map +1 -1
  64. package/lib/models/href/ListHref.js +3 -2
  65. package/lib/models/href/ListHref.js.map +1 -1
  66. package/lib/models/list/ListModel.js +7 -1
  67. package/lib/models/list/ListModel.js.map +1 -1
  68. package/lib/models/parameter/Parameter.js +6 -6
  69. package/lib/models/parameter/Parameter.js.map +1 -1
  70. package/package.json +4 -4
  71. package/src/hooks/useDeepCompareEffect.js +26 -10
  72. package/src/hooks/useList.js +17 -16
  73. package/src/hooks/useModularUIBasic.js +11 -1
  74. package/src/hooks/usePanel.js +1 -1
  75. package/src/hooks/useRouter.js +29 -23
  76. package/src/models/attributes/AttributeModel.js +14 -0
  77. package/src/models/attributes/CompositeAttributeModel.js +11 -11
  78. package/src/models/attributes/PasswordAttributeModel.js +3 -3
  79. package/src/models/filters/FilterModel.js +1 -1
  80. package/src/models/filters/RangeFilterModel.js +1 -1
  81. package/src/models/href/Href.js +30 -2
  82. package/src/models/href/ListHref.js +4 -2
  83. package/src/models/list/ListModel.js +8 -2
  84. package/src/models/parameter/Parameter.js +6 -6
package/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.65.11](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.10...v1.65.11) (2026-01-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **hooks:** enhance `useRouter` hooks with memoization and type improvements ([b24ebb3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/b24ebb30c541c7736ba750bd059de107fce7b559))
11
+ * **hooks:** improve `useDeepCompareEffect` with validation and cleanup logic ([90fb49d](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/90fb49d9cd7731f81c6bb319d1c3865d19500d1b))
12
+ * **hooks:** make it possible to post formdata using the basic modular ui hooks ([4a49624](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/4a4962419497bf7300839be791a22d0a84158159))
13
+ * **href:** add support for formdata and public querystring handling ([2978cda](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/2978cdac3d22eff45e217aa39910b10afb8f9abb))
14
+ * **parameter:** decode parameter name to retrieve prefix ([a0b89a0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/a0b89a0121eb6bf46de1e695ff09cffa8df8e224))
15
+
16
+ ## [1.65.10](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.9...v1.65.10) (2026-01-09)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **hooks:** ensure `updatePageSize` goes to first page on change ([54f3f27](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/54f3f2717efe87eb6bef412f7d6cbc0aa698f0aa))
22
+ * **href:** ensure empty string is excluded from querystring parameters ([910ef89](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/910ef89901d61b90f2ef29cf727fd34ce86daea5))
23
+ * **list-update:** add prefix to filters to handle grouped lists ([2ae83f8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/2ae83f8942ff1a8a3d7715fa6834f5d796f6ad6b))
24
+ * **models:** refactor validity handling for consistency across attribute models ([d555d41](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d555d411738ef99b9b500bdb2e700c9dd303945a))
25
+
5
26
  ## [1.65.9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.8...v1.65.9) (2026-01-08)
6
27
 
7
28
 
@@ -1,24 +1,38 @@
1
- import * as React from "react";
1
+ import { useRef, useEffect } from "react";
2
2
  import { dequal as deepEqual } from "dequal/lite";
3
3
  /**
4
- * As copied from https://github.com/kentcdodds/use-deep-compare-effect/
5
- * Need to copy this, because the dependency on dequal breaks in ie11
4
+ * Validates that dependencies are used correctly.
5
+ * Deep compare should not be used with empty arrays or no dependencies.
6
6
  */
7
+ function checkDeps(deps) {
8
+ if (process.env.NODE_ENV !== "production") {
9
+ if (!deps || deps.length === 0) {
10
+ console.warn("useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead.");
11
+ }
12
+ }
13
+ }
7
14
  const useDeepCompareMemoize = value => {
8
- const ref = React.useRef(null); // NOSONAR
9
- const signalRef = React.useRef(0);
15
+ const ref = useRef(value);
16
+
17
+ // Only update the ref if the deep equality check fails
10
18
  if (!deepEqual(value, ref.current)) {
11
19
  ref.current = value;
12
- signalRef.current += 1;
13
20
  }
14
- return [signalRef.current];
21
+ return ref.current;
15
22
  };
16
23
 
17
24
  /**
25
+ * A version of useEffect that accepts a deep comparison of dependencies.
18
26
  */
19
27
  export function useDeepCompareEffect(callback, dependencies) {
28
+ if (process.env.NODE_ENV !== "production") {
29
+ checkDeps(dependencies);
30
+ }
31
+
32
+ // We use the memoized ref as the dependency.
33
+ // React's shallow check will only trigger when the ref object itself changes.
20
34
  // eslint-disable-next-line react-hooks/exhaustive-deps
21
- return React.useEffect(callback, useDeepCompareMemoize(dependencies));
35
+ useEffect(callback, useDeepCompareMemoize(dependencies));
22
36
  }
23
37
  export default useDeepCompareEffect;
24
38
  //# sourceMappingURL=useDeepCompareEffect.js.map
@@ -1,34 +1,50 @@
1
1
  // @flow
2
- import * as React from "react";
2
+ import { useRef, useEffect } from "react";
3
3
  import { dequal as deepEqual } from "dequal/lite";
4
4
 
5
5
  type Callback = () => void | (() => void);
6
- type DependencyList = Array<mixed>;
6
+ type DependencyList = $ReadOnlyArray<any>;
7
7
 
8
8
  /**
9
- * As copied from https://github.com/kentcdodds/use-deep-compare-effect/
10
- * Need to copy this, because the dependency on dequal breaks in ie11
9
+ * Validates that dependencies are used correctly.
10
+ * Deep compare should not be used with empty arrays or no dependencies.
11
11
  */
12
- const useDeepCompareMemoize = (value: DependencyList) => {
13
- const ref = React.useRef<DependencyList | null>(null); // NOSONAR
14
- const signalRef = React.useRef<number>(0);
12
+ function checkDeps(deps: DependencyList) {
13
+ if (process.env.NODE_ENV !== "production") {
14
+ if (!deps || deps.length === 0) {
15
+ console.warn(
16
+ "useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead.",
17
+ );
18
+ }
19
+ }
20
+ }
21
+
22
+ const useDeepCompareMemoize = (value: DependencyList): DependencyList => {
23
+ const ref = useRef<DependencyList>(value);
15
24
 
25
+ // Only update the ref if the deep equality check fails
16
26
  if (!deepEqual(value, ref.current)) {
17
27
  ref.current = value;
18
- signalRef.current += 1;
19
28
  }
20
29
 
21
- return [signalRef.current];
30
+ return ref.current;
22
31
  };
23
32
 
24
33
  /**
34
+ * A version of useEffect that accepts a deep comparison of dependencies.
25
35
  */
26
36
  export function useDeepCompareEffect(
27
37
  callback: Callback,
28
38
  dependencies: DependencyList,
29
39
  ): void {
40
+ if (process.env.NODE_ENV !== "production") {
41
+ checkDeps(dependencies);
42
+ }
43
+
44
+ // We use the memoized ref as the dependency.
45
+ // React's shallow check will only trigger when the ref object itself changes.
30
46
  // eslint-disable-next-line react-hooks/exhaustive-deps
31
- return React.useEffect(callback, useDeepCompareMemoize(dependencies));
47
+ useEffect(callback, useDeepCompareMemoize(dependencies));
32
48
  }
33
49
 
34
50
  export default useDeepCompareEffect;
@@ -1 +1 @@
1
- {"version":3,"file":"useDeepCompareEffect.js","names":["React","dequal","deepEqual","useDeepCompareMemoize","value","ref","useRef","signalRef","current","useDeepCompareEffect","callback","dependencies","useEffect"],"sources":["../../src/hooks/useDeepCompareEffect.js"],"sourcesContent":["// @flow\nimport * as React from \"react\";\nimport { dequal as deepEqual } from \"dequal/lite\";\n\ntype Callback = () => void | (() => void);\ntype DependencyList = Array<mixed>;\n\n/**\n * As copied from https://github.com/kentcdodds/use-deep-compare-effect/\n * Need to copy this, because the dependency on dequal breaks in ie11\n */\nconst useDeepCompareMemoize = (value: DependencyList) => {\n const ref = React.useRef<DependencyList | null>(null); // NOSONAR\n const signalRef = React.useRef<number>(0);\n\n if (!deepEqual(value, ref.current)) {\n ref.current = value;\n signalRef.current += 1;\n }\n\n return [signalRef.current];\n};\n\n/**\n */\nexport function useDeepCompareEffect(\n callback: Callback,\n dependencies: DependencyList,\n): void {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useEffect(callback, useDeepCompareMemoize(dependencies));\n}\n\nexport default useDeepCompareEffect;\n"],"mappings":"AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,MAAM,IAAIC,SAAS,QAAQ,aAAa;AAKjD;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAIC,KAAqB,IAAK;EACvD,MAAMC,GAAG,GAAGL,KAAK,CAACM,MAAM,CAAwB,IAAI,CAAC,CAAC,CAAC;EACvD,MAAMC,SAAS,GAAGP,KAAK,CAACM,MAAM,CAAS,CAAC,CAAC;EAEzC,IAAI,CAACJ,SAAS,CAACE,KAAK,EAAEC,GAAG,CAACG,OAAO,CAAC,EAAE;IAClCH,GAAG,CAACG,OAAO,GAAGJ,KAAK;IACnBG,SAAS,CAACC,OAAO,IAAI,CAAC;EACxB;EAEA,OAAO,CAACD,SAAS,CAACC,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,QAAkB,EAClBC,YAA4B,EACtB;EACN;EACA,OAAOX,KAAK,CAACY,SAAS,CAACF,QAAQ,EAAEP,qBAAqB,CAACQ,YAAY,CAAC,CAAC;AACvE;AAEA,eAAeF,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"useDeepCompareEffect.js","names":["useRef","useEffect","dequal","deepEqual","checkDeps","deps","process","env","NODE_ENV","length","console","warn","useDeepCompareMemoize","value","ref","current","useDeepCompareEffect","callback","dependencies"],"sources":["../../src/hooks/useDeepCompareEffect.js"],"sourcesContent":["// @flow\nimport { useRef, useEffect } from \"react\";\nimport { dequal as deepEqual } from \"dequal/lite\";\n\ntype Callback = () => void | (() => void);\ntype DependencyList = $ReadOnlyArray<any>;\n\n/**\n * Validates that dependencies are used correctly.\n * Deep compare should not be used with empty arrays or no dependencies.\n */\nfunction checkDeps(deps: DependencyList) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!deps || deps.length === 0) {\n console.warn(\n \"useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead.\",\n );\n }\n }\n}\n\nconst useDeepCompareMemoize = (value: DependencyList): DependencyList => {\n const ref = useRef<DependencyList>(value);\n\n // Only update the ref if the deep equality check fails\n if (!deepEqual(value, ref.current)) {\n ref.current = value;\n }\n\n return ref.current;\n};\n\n/**\n * A version of useEffect that accepts a deep comparison of dependencies.\n */\nexport function useDeepCompareEffect(\n callback: Callback,\n dependencies: DependencyList,\n): void {\n if (process.env.NODE_ENV !== \"production\") {\n checkDeps(dependencies);\n }\n\n // We use the memoized ref as the dependency.\n // React's shallow check will only trigger when the ref object itself changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(callback, useDeepCompareMemoize(dependencies));\n}\n\nexport default useDeepCompareEffect;\n"],"mappings":"AACA,SAASA,MAAM,EAAEC,SAAS,QAAQ,OAAO;AACzC,SAASC,MAAM,IAAIC,SAAS,QAAQ,aAAa;AAKjD;AACA;AACA;AACA;AACA,SAASC,SAASA,CAACC,IAAoB,EAAE;EACvC,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAI,CAACH,IAAI,IAAIA,IAAI,CAACI,MAAM,KAAK,CAAC,EAAE;MAC9BC,OAAO,CAACC,IAAI,CACV,4FACF,CAAC;IACH;EACF;AACF;AAEA,MAAMC,qBAAqB,GAAIC,KAAqB,IAAqB;EACvE,MAAMC,GAAG,GAAGd,MAAM,CAAiBa,KAAK,CAAC;;EAEzC;EACA,IAAI,CAACV,SAAS,CAACU,KAAK,EAAEC,GAAG,CAACC,OAAO,CAAC,EAAE;IAClCD,GAAG,CAACC,OAAO,GAAGF,KAAK;EACrB;EAEA,OAAOC,GAAG,CAACC,OAAO;AACpB,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClCC,QAAkB,EAClBC,YAA4B,EACtB;EACN,IAAIZ,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzCJ,SAAS,CAACc,YAAY,CAAC;EACzB;;EAEA;EACA;EACA;EACAjB,SAAS,CAACgB,QAAQ,EAAEL,qBAAqB,CAACM,YAAY,CAAC,CAAC;AAC1D;AAEA,eAAeF,oBAAoB","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import { useHistory } from "react-router";
2
1
  import { useDispatch } from "react-redux";
3
2
  import { useModularUIBasic } from "./useModularUIBasic";
4
3
  import { HTTP_METHODS } from "../constants/Constants";
5
4
  import { loadModularUI } from "../redux";
5
+ import { useNavigation } from "./useRouter";
6
6
  import DetailModel from "../models/detail/DetailModel";
7
7
  import ListModel from "../models/list/ListModel";
8
8
  import CaseSearchModel from "../models/search/CaseSearchModel";
@@ -40,14 +40,15 @@ export const useListDetail = (href, options) => useModularUIBasic("listdetail",
40
40
  /**
41
41
  */
42
42
  export const useListNavigation = ({
43
- syncLocation,
44
- historyAction
45
- } = {
46
- syncLocation: true,
47
- historyAction: "push"
48
- }) => {
49
- const history = useHistory();
43
+ syncLocation = true,
44
+ historyAction = "push"
45
+ } = {}) => {
46
+ const {
47
+ push,
48
+ replace
49
+ } = useNavigation();
50
50
  const dispatch = useDispatch();
51
+ const navigate = historyAction === "push" ? push : replace;
51
52
  const update = useCallback((list, resetPage = false) => {
52
53
  const listHref = list.selfhref;
53
54
  if (resetPage) {
@@ -55,9 +56,11 @@ export const useListNavigation = ({
55
56
  }
56
57
  if (list.requestMethod === HTTP_METHODS.POST) {
57
58
  if (syncLocation) {
58
- history[historyAction]({
59
- search: listHref.querystring,
60
- state: list.formdata
59
+ navigate({
60
+ search: listHref.getQuerystring(true),
61
+ state: {
62
+ formdata: list.formdata
63
+ }
61
64
  });
62
65
  }
63
66
  dispatch(loadModularUI(list.connectKey, listHref, {
@@ -67,8 +70,8 @@ export const useListNavigation = ({
67
70
  }));
68
71
  } else {
69
72
  if (syncLocation) {
70
- history[historyAction]({
71
- search: listHref.querystring
73
+ navigate({
74
+ search: listHref.getQuerystring(true)
72
75
  });
73
76
  }
74
77
  dispatch(loadModularUI(list.connectKey, listHref, {
@@ -76,7 +79,7 @@ export const useListNavigation = ({
76
79
  targetModel: [ListModel, CaseSearchModel]
77
80
  }));
78
81
  }
79
- }, [dispatch, history, historyAction, syncLocation]);
82
+ }, [dispatch, navigate, syncLocation]);
80
83
  const updateFilters = useCallback((list, filters) => {
81
84
  list.filterCollection = filters;
82
85
  update(list, true);
@@ -109,7 +112,7 @@ export const useListNavigation = ({
109
112
  }, [update]);
110
113
  const updatePageSize = useCallback((list, pagesize) => {
111
114
  list.paging.pagesize.value = pagesize;
112
- update(list);
115
+ update(list, true);
113
116
  }, [update]);
114
117
  return useMemo(() => ({
115
118
  update,
@@ -1,5 +1,4 @@
1
1
  // @flow
2
- import { useHistory } from "react-router";
3
2
  import { useDispatch } from "react-redux";
4
3
 
5
4
  import { useModularUIBasic } from "./useModularUIBasic";
@@ -7,6 +6,8 @@ import { HTTP_METHODS } from "../constants/Constants";
7
6
 
8
7
  import { loadModularUI } from "../redux";
9
8
 
9
+ import { useNavigation } from "./useRouter";
10
+
10
11
  import DetailModel from "../models/detail/DetailModel";
11
12
  import ListModel from "../models/list/ListModel";
12
13
  import CaseSearchModel from "../models/search/CaseSearchModel";
@@ -37,8 +38,8 @@ type ListNavigationHook = {
37
38
  };
38
39
 
39
40
  type ListNavigationOptions = {
40
- syncLocation: boolean,
41
- historyAction: "push" | "replace",
41
+ syncLocation?: boolean,
42
+ historyAction?: "push" | "replace",
42
43
  };
43
44
 
44
45
  /**
@@ -80,15 +81,15 @@ export const useListDetail = (
80
81
 
81
82
  /**
82
83
  */
83
- export const useListNavigation = (
84
- { syncLocation, historyAction }: ListNavigationOptions = {
85
- syncLocation: true,
86
- historyAction: "push",
87
- },
88
- ): ListNavigationHook => {
89
- const history = useHistory();
84
+ export const useListNavigation = ({
85
+ syncLocation = true,
86
+ historyAction = "push",
87
+ }: ListNavigationOptions = {}): ListNavigationHook => {
88
+ const { push, replace } = useNavigation();
90
89
  const dispatch = useDispatch();
91
90
 
91
+ const navigate = historyAction === "push" ? push : replace;
92
+
92
93
  const update = useCallback(
93
94
  (list: ListModel, resetPage: boolean = false) => {
94
95
  const listHref = list.selfhref;
@@ -98,9 +99,9 @@ export const useListNavigation = (
98
99
 
99
100
  if (list.requestMethod === HTTP_METHODS.POST) {
100
101
  if (syncLocation) {
101
- history[historyAction]({
102
- search: listHref.querystring,
103
- state: list.formdata,
102
+ navigate({
103
+ search: listHref.getQuerystring(true),
104
+ state: { formdata: list.formdata },
104
105
  });
105
106
  }
106
107
 
@@ -113,7 +114,7 @@ export const useListNavigation = (
113
114
  );
114
115
  } else {
115
116
  if (syncLocation) {
116
- history[historyAction]({ search: listHref.querystring });
117
+ navigate({ search: listHref.getQuerystring(true) });
117
118
  }
118
119
  dispatch(
119
120
  loadModularUI(list.connectKey, listHref, {
@@ -123,7 +124,7 @@ export const useListNavigation = (
123
124
  );
124
125
  }
125
126
  },
126
- [dispatch, history, historyAction, syncLocation],
127
+ [dispatch, navigate, syncLocation],
127
128
  );
128
129
 
129
130
  const updateFilters = useCallback(
@@ -190,7 +191,7 @@ export const useListNavigation = (
190
191
  const updatePageSize = useCallback(
191
192
  (list: ListModel, pagesize: number) => {
192
193
  list.paging.pagesize.value = pagesize;
193
- update(list);
194
+ update(list, true);
194
195
  },
195
196
  [update],
196
197
  );
@@ -1 +1 @@
1
- {"version":3,"file":"useList.js","names":["useHistory","useDispatch","useModularUIBasic","HTTP_METHODS","loadModularUI","DetailModel","ListModel","CaseSearchModel","ListDetailModel","Href","FilterCollection","AssignmentFilterModel","FilterModel","useCallback","useMemo","useList","href","options","expectedModels","targetModel","useListOrDetail","useListDetail","forceTargetModel","useListNavigation","syncLocation","historyAction","history","dispatch","update","list","resetPage","listHref","selfhref","page","requestMethod","POST","search","querystring","state","formdata","connectKey","method","data","GET","updateFilters","filters","filterCollection","updateFilter","filter","value","attribute","Error","resetFilters","reset","removeFilter","getFilterByName","name","updateSort","sortOption","sorting","updatePage","paging","updatePageSize","pagesize"],"sources":["../../src/hooks/useList.js"],"sourcesContent":["// @flow\nimport { useHistory } from \"react-router\";\nimport { useDispatch } from \"react-redux\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport { loadModularUI } from \"../redux\";\n\nimport DetailModel from \"../models/detail/DetailModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport Href from \"../models/href/Href\";\nimport FilterCollection from \"../models/filters/FilterCollection\";\nimport AssignmentFilterModel from \"../models/filters/AssignmentFilterModel\";\nimport FilterModel from \"../models/filters/FilterModel\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport type { AttributeType, IFilter } from \"../models/types\";\nimport { useCallback, useMemo } from \"react\";\n\ntype ListNavigationHook = {\n update: (list: ListModel, resetPage?: boolean) => void,\n updateFilters: (list: ListModel, filters: FilterCollection) => void,\n updateFilter: (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => void,\n updateSort: (list: ListModel, sortOption: string) => void,\n updatePage: (list: ListModel, page: number) => void,\n updatePageSize: (list: ListModel, pagesize: number) => void,\n resetFilters: (list: ListModel) => void,\n removeFilter: (list: ListModel, filter: IFilter) => void,\n};\n\ntype ListNavigationOptions = {\n syncLocation: boolean,\n historyAction: \"push\" | \"replace\",\n};\n\n/**\n */\nexport const useList = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\"],\n targetModel: [ListModel, CaseSearchModel],\n ...options,\n });\n\n/**\n */\nexport const useListOrDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\", \"Detail\"],\n targetModel: [ListModel, CaseSearchModel, DetailModel],\n ...options,\n });\n\n/**\n */\nexport const useListDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n ...options,\n });\n\n/**\n */\nexport const useListNavigation = (\n { syncLocation, historyAction }: ListNavigationOptions = {\n syncLocation: true,\n historyAction: \"push\",\n },\n): ListNavigationHook => {\n const history = useHistory();\n const dispatch = useDispatch();\n\n const update = useCallback(\n (list: ListModel, resetPage: boolean = false) => {\n const listHref = list.selfhref;\n if (resetPage) {\n listHref.page = null;\n }\n\n if (list.requestMethod === HTTP_METHODS.POST) {\n if (syncLocation) {\n history[historyAction]({\n search: listHref.querystring,\n state: list.formdata,\n });\n }\n\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.POST,\n data: list.formdata,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n } else {\n if (syncLocation) {\n history[historyAction]({ search: listHref.querystring });\n }\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.GET,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n }\n },\n [dispatch, history, historyAction, syncLocation],\n );\n\n const updateFilters = useCallback(\n (list: ListModel, filters: FilterCollection) => {\n list.filterCollection = filters;\n update(list, true);\n },\n [update],\n );\n\n const updateFilter = useCallback(\n (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => {\n if (attribute) {\n filter.update(attribute, value);\n } else if (filter instanceof AssignmentFilterModel) {\n throw new Error(\n \"Need the attribute to update for AssigmentFilterModel\",\n );\n } else if (filter instanceof FilterModel) {\n filter.update(filter.attribute, value);\n }\n update(list, true);\n },\n [update],\n );\n\n const resetFilters = useCallback(\n (list: ListModel) => {\n list.filterCollection.reset();\n update(list, true);\n },\n [update],\n );\n\n const removeFilter = useCallback(\n (list: ListModel, filter: IFilter) => {\n list.filterCollection.getFilterByName(filter.name)?.reset();\n update(list, true);\n },\n [update],\n );\n\n const updateSort = useCallback(\n (list: ListModel, sortOption: string) => {\n list.sorting.value = sortOption;\n update(list, true);\n },\n [update],\n );\n\n const updatePage = useCallback(\n (list: ListModel, page: number) => {\n list.paging.page = page;\n update(list);\n },\n [update],\n );\n\n const updatePageSize = useCallback(\n (list: ListModel, pagesize: number) => {\n list.paging.pagesize.value = pagesize;\n update(list);\n },\n [update],\n );\n\n return useMemo(\n () => ({\n update,\n updateFilters,\n updateFilter,\n updateSort,\n updatePage,\n updatePageSize,\n resetFilters,\n removeFilter,\n }),\n [\n removeFilter,\n resetFilters,\n update,\n updateFilter,\n updateFilters,\n updatePage,\n updatePageSize,\n updateSort,\n ],\n );\n};\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,YAAY,QAAQ,wBAAwB;AAErD,SAASC,aAAa,QAAQ,UAAU;AAExC,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,IAAI,MAAM,qBAAqB;AACtC,OAAOC,gBAAgB,MAAM,oCAAoC;AACjE,OAAOC,qBAAqB,MAAM,yCAAyC;AAC3E,OAAOC,WAAW,MAAM,+BAA+B;AAIvD,SAASC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAuB5C;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CACrBC,IAAmB,EACnBC,OAAqB,KAErBf,iBAAiB,CAAC,MAAM,EAAEc,IAAI,EAAE;EAC9BE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;EACtCC,WAAW,EAAE,CAACb,SAAS,EAAEC,eAAe,CAAC;EACzC,GAAGU;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMG,eAAe,GAAGA,CAC7BJ,IAAmB,EACnBC,OAAqB,KAErBf,iBAAiB,CAAC,MAAM,EAAEc,IAAI,EAAE;EAC9BE,cAAc,EAAE,CAAC,MAAM,EAAE,YAAY,EA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AC","ignoreList":[]}
1
+ {"version":3,"file":"useList.js","names":["useDispatch","useModularUIBasic","HTTP_METHODS","loadModularUI","useNavigation","DetailModel","ListModel","CaseSearchModel","ListDetailModel","Href","FilterCollection","AssignmentFilterModel","FilterModel","useCallback","useMemo","useList","href","options","expectedModels","targetModel","useListOrDetail","useListDetail","forceTargetModel","useListNavigation","syncLocation","historyAction","push","replace","dispatch","navigate","update","list","resetPage","listHref","selfhref","page","requestMethod","POST","search","getQuerystring","state","formdata","connectKey","method","data","GET","updateFilters","filters","filterCollection","updateFilter","filter","value","attribute","Error","resetFilters","reset","removeFilter","getFilterByName","name","updateSort","sortOption","sorting","updatePage","paging","updatePageSize","pagesize"],"sources":["../../src/hooks/useList.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport { loadModularUI } from \"../redux\";\n\nimport { useNavigation } from \"./useRouter\";\n\nimport DetailModel from \"../models/detail/DetailModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport Href from \"../models/href/Href\";\nimport FilterCollection from \"../models/filters/FilterCollection\";\nimport AssignmentFilterModel from \"../models/filters/AssignmentFilterModel\";\nimport FilterModel from \"../models/filters/FilterModel\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport type { AttributeType, IFilter } from \"../models/types\";\nimport { useCallback, useMemo } from \"react\";\n\ntype ListNavigationHook = {\n update: (list: ListModel, resetPage?: boolean) => void,\n updateFilters: (list: ListModel, filters: FilterCollection) => void,\n updateFilter: (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => void,\n updateSort: (list: ListModel, sortOption: string) => void,\n updatePage: (list: ListModel, page: number) => void,\n updatePageSize: (list: ListModel, pagesize: number) => void,\n resetFilters: (list: ListModel) => void,\n removeFilter: (list: ListModel, filter: IFilter) => void,\n};\n\ntype ListNavigationOptions = {\n syncLocation?: boolean,\n historyAction?: \"push\" | \"replace\",\n};\n\n/**\n */\nexport const useList = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\"],\n targetModel: [ListModel, CaseSearchModel],\n ...options,\n });\n\n/**\n */\nexport const useListOrDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\", \"Detail\"],\n targetModel: [ListModel, CaseSearchModel, DetailModel],\n ...options,\n });\n\n/**\n */\nexport const useListDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n ...options,\n });\n\n/**\n */\nexport const useListNavigation = ({\n syncLocation = true,\n historyAction = \"push\",\n}: ListNavigationOptions = {}): ListNavigationHook => {\n const { push, replace } = useNavigation();\n const dispatch = useDispatch();\n\n const navigate = historyAction === \"push\" ? push : replace;\n\n const update = useCallback(\n (list: ListModel, resetPage: boolean = false) => {\n const listHref = list.selfhref;\n if (resetPage) {\n listHref.page = null;\n }\n\n if (list.requestMethod === HTTP_METHODS.POST) {\n if (syncLocation) {\n navigate({\n search: listHref.getQuerystring(true),\n state: { formdata: list.formdata },\n });\n }\n\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.POST,\n data: list.formdata,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n } else {\n if (syncLocation) {\n navigate({ search: listHref.getQuerystring(true) });\n }\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.GET,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n }\n },\n [dispatch, navigate, syncLocation],\n );\n\n const updateFilters = useCallback(\n (list: ListModel, filters: FilterCollection) => {\n list.filterCollection = filters;\n update(list, true);\n },\n [update],\n );\n\n const updateFilter = useCallback(\n (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => {\n if (attribute) {\n filter.update(attribute, value);\n } else if (filter instanceof AssignmentFilterModel) {\n throw new Error(\n \"Need the attribute to update for AssigmentFilterModel\",\n );\n } else if (filter instanceof FilterModel) {\n filter.update(filter.attribute, value);\n }\n update(list, true);\n },\n [update],\n );\n\n const resetFilters = useCallback(\n (list: ListModel) => {\n list.filterCollection.reset();\n update(list, true);\n },\n [update],\n );\n\n const removeFilter = useCallback(\n (list: ListModel, filter: IFilter) => {\n list.filterCollection.getFilterByName(filter.name)?.reset();\n update(list, true);\n },\n [update],\n );\n\n const updateSort = useCallback(\n (list: ListModel, sortOption: string) => {\n list.sorting.value = sortOption;\n update(list, true);\n },\n [update],\n );\n\n const updatePage = useCallback(\n (list: ListModel, page: number) => {\n list.paging.page = page;\n update(list);\n },\n [update],\n );\n\n const updatePageSize = useCallback(\n (list: ListModel, pagesize: number) => {\n list.paging.pagesize.value = pagesize;\n update(list, true);\n },\n [update],\n );\n\n return useMemo(\n () => ({\n update,\n updateFilters,\n updateFilter,\n updateSort,\n updatePage,\n updatePageSize,\n resetFilters,\n removeFilter,\n }),\n [\n removeFilter,\n resetFilters,\n update,\n updateFilter,\n updateFilters,\n updatePage,\n updatePageSize,\n updateSort,\n ],\n );\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,YAAY,QAAQ,wBAAwB;AAErD,SAASC,aAAa,QAAQ,UAAU;AAExC,SAASC,aAAa,QAAQ,aAAa;AAE3C,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,IAAI,MAAM,qBAAqB;AAC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;EAED,MAAMgC,UAAU,GAAGjD,WAAW,CAC5B,CAACkB,IAAe,EAAEI,IAAY,KAAK;IACjCJ,IAAI,CAACgC,MAAM,CAAC5B,IAAI,GAAGA,IAAI;IACvBL,MAAM,CAACC,IAAI,CAAC;EACd,CAAC,EACD,CAACD,MAAM,CACT,CAAC;EAED,MAAMkC,cAAc,GAAGnD,WAAW,CAChC,CAACkB,IAAe,EAAEkC,QAAgB,KAAK;IACrClC,IAAI,CAACgC,MAAM,CAACE,QAAQ,CAACd,KAAK,GAAGc,QAAQ;IACrCnC,MAAM,CAACC,IAAI,EAAE,IAAI,CAAC;EACpB,CAAC,EACD,CAACD,MAAM,CACT,CAAC;EAED,OAAOhB,OAAO,CACZ,OAAO;IACLgB,MAAM;IACNgB,aAAa;IACbG,YAAY;IACZU,UAAU;IACVG,UAAU;IACVE,cAAc;IACdV,YAAY;IACZE;EACF,CAAC,CAAC,EACF,CACEA,YAAY,EACZF,YAAY,EACZxB,MAAM,EACNmB,YAAY,EACZH,aAAa,EACbgB,UAAU,EACVE,cAAc,EACdL,UAAU,CAEd,CAAC;AACH,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { useLocation } from "react-router";
2
2
  import { useSelector } from "react-redux";
3
3
  import { useMemo } from "react";
4
4
  import { useModularUI } from "./useModularUI";
5
- import { MODULARUI_STATUS } from "../constants";
5
+ import { HTTP_METHODS, MODULARUI_STATUS } from "../constants";
6
6
  import { useModularUIKey } from "./useModularUIKey";
7
7
  // Helper to create useModularUI options
8
8
  const createUseModularUIOptions = (options, href, mustReload) => {
@@ -13,7 +13,9 @@ const createUseModularUIOptions = (options, href, mustReload) => {
13
13
  origin: undefined,
14
14
  contextPath: undefined,
15
15
  cache: false,
16
- removeOnUnmount: false
16
+ removeOnUnmount: false,
17
+ method: HTTP_METHODS.GET,
18
+ data: undefined
17
19
  };
18
20
 
19
21
  // Handle targetModel and forceTargetModel
@@ -32,6 +34,10 @@ const createUseModularUIOptions = (options, href, mustReload) => {
32
34
  if (options.removeOnUnmount) {
33
35
  baseOptions.removeOnUnmount = true;
34
36
  }
37
+ if (options.formdata != null) {
38
+ baseOptions.method = HTTP_METHODS.POST;
39
+ baseOptions.data = options.formdata;
40
+ }
35
41
 
36
42
  // Handle origin and contextPath options
37
43
  baseOptions.origin = options.origin ?? baseOptions.origin;
@@ -58,7 +64,8 @@ export const useModularUIBasic = (defaultKey, href, options = {
58
64
  forceTargetModel: false,
59
65
  origin: undefined,
60
66
  contextPath: undefined,
61
- key: undefined
67
+ key: undefined,
68
+ formdata: undefined
62
69
  }) => {
63
70
  const memoizedHref = useMemo(() => href.toString(), [href]);
64
71
  const key = options.key ?? defaultKey;
@@ -4,7 +4,7 @@ import { useSelector } from "react-redux";
4
4
  import { useMemo } from "react";
5
5
  import { useModularUI } from "./useModularUI";
6
6
 
7
- import { MODULARUI_STATUS } from "../constants";
7
+ import { HTTP_METHODS, MODULARUI_STATUS } from "../constants";
8
8
  import { useModularUIKey } from "./useModularUIKey";
9
9
 
10
10
  import type { ModularUIModel, Href } from "../models";
@@ -13,6 +13,7 @@ export type HookOptions = {
13
13
  origin?: string,
14
14
  contextPath?: string,
15
15
  removeOnUnmount?: boolean,
16
+ formdata?: any,
16
17
  };
17
18
 
18
19
  export type UseModularUIBasicOptions<T: ModularUIModel> = {
@@ -25,6 +26,7 @@ export type UseModularUIBasicOptions<T: ModularUIModel> = {
25
26
  key?: string,
26
27
  isReload?: boolean,
27
28
  removeOnUnmount?: boolean,
29
+ formdata?: any,
28
30
  };
29
31
 
30
32
  // Helper to create useModularUI options
@@ -41,6 +43,8 @@ const createUseModularUIOptions = <T: ModularUIModel>(
41
43
  contextPath: undefined,
42
44
  cache: false,
43
45
  removeOnUnmount: false,
46
+ method: HTTP_METHODS.GET,
47
+ data: undefined,
44
48
  };
45
49
 
46
50
  // Handle targetModel and forceTargetModel
@@ -62,6 +66,11 @@ const createUseModularUIOptions = <T: ModularUIModel>(
62
66
  baseOptions.removeOnUnmount = true;
63
67
  }
64
68
 
69
+ if (options.formdata != null) {
70
+ baseOptions.method = HTTP_METHODS.POST;
71
+ baseOptions.data = options.formdata;
72
+ }
73
+
65
74
  // Handle origin and contextPath options
66
75
  baseOptions.origin = options.origin ?? baseOptions.origin;
67
76
  baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;
@@ -94,6 +103,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
94
103
  origin: undefined,
95
104
  contextPath: undefined,
96
105
  key: undefined,
106
+ formdata: undefined,
97
107
  },
98
108
  ): T | null => {
99
109
  const memoizedHref = useMemo(() => href.toString(), [href]);
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIBasic.js","names":["useLocation","useSelector","useMemo","useModularUI","MODULARUI_STATUS","useModularUIKey","createUseModularUIOptions","options","href","mustReload","baseOptions","targetModel","undefined","forceTargetModel","isReload","origin","contextPath","cache","removeOnUnmount","validateModel","model","expectedModels","length","isCorrectModel","some","expectedModel","type","console","warn","useModularUIBasic","defaultKey","key","memoizedHref","toString","useReload","modularUIOptions","modularUI","modelKey","url","location","modelEntry","state","modularui","reload","isFullyLoaded","status","FINISHED","lastModification"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"react-router\";\nimport { useSelector } from \"react-redux\";\nimport { useMemo } from \"react\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport { MODULARUI_STATUS } from \"../constants\";\nimport { useModularUIKey } from \"./useModularUIKey\";\n\nimport type { ModularUIModel, Href } from \"../models\";\nexport type HookOptions = {\n key?: string,\n origin?: string,\n contextPath?: string,\n removeOnUnmount?: boolean,\n};\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n origin?: string,\n contextPath?: string,\n cache?: boolean,\n key?: string,\n isReload?: boolean,\n removeOnUnmount?: boolean,\n};\n\n// Helper to create useModularUI options\nconst createUseModularUIOptions = <T: ModularUIModel>(\n options: UseModularUIBasicOptions<T>,\n href: string,\n mustReload: boolean,\n): Object => {\n const baseOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n origin: undefined,\n contextPath: undefined,\n cache: false,\n removeOnUnmount: false,\n };\n\n // Handle targetModel and forceTargetModel\n if (options.targetModel) {\n baseOptions.targetModel = options.targetModel;\n baseOptions.forceTargetModel = options.forceTargetModel;\n }\n\n // Handle cache option\n if (options.cache) {\n baseOptions.cache = options.cache;\n }\n\n if (mustReload) {\n baseOptions.isReload = true;\n }\n\n if (options.removeOnUnmount) {\n baseOptions.removeOnUnmount = true;\n }\n\n // Handle origin and contextPath options\n baseOptions.origin = options.origin ?? baseOptions.origin;\n baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;\n\n return baseOptions;\n};\n\n// Helper to validate the model against expectedModels\nconst validateModel = (model: any, expectedModels: Array<string>) => {\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some(\n (expectedModel) => model.type === expectedModel,\n );\n if (!isCorrectModel) {\n console.warn(model, \"is not of instance\", expectedModels);\n }\n }\n};\n\n/**\n * useModularUIBasic Hook\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n defaultKey: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n origin: undefined,\n contextPath: undefined,\n key: undefined,\n },\n): T | null => {\n const memoizedHref = useMemo(() => href.toString(), [href]);\n const key = options.key ?? defaultKey;\n\n const mustReload = useReload(key, memoizedHref);\n const modularUIOptions = useMemo(\n () => createUseModularUIOptions(options, memoizedHref, mustReload),\n [options, memoizedHref, mustReload],\n );\n\n const modularUI = useModularUI(key, href, modularUIOptions);\n const expectedModels = useMemo(\n () => options.expectedModels ?? [],\n [options.expectedModels],\n );\n\n return useMemo((): T | null => {\n if (modularUI?.model) {\n validateModel(modularUI.model, expectedModels);\n return modularUI.model;\n }\n return null;\n }, [expectedModels, modularUI]);\n};\n\n/**\n * Check if the model corresponding to a modular ui service should be reloaded\n */\nexport const useReload = (modelKey: string, url: string): boolean => {\n const location = useLocation();\n const key = useModularUIKey(modelKey, url);\n const modelEntry = useSelector((state) => state.modularui[key]);\n\n if (modelEntry) {\n const reload = location.state?.reload || 0;\n if (reload > 0) {\n const isFullyLoaded = modelEntry?.status === MODULARUI_STATUS.FINISHED;\n const lastModification = modelEntry?.lastModification ?? 0;\n if (isFullyLoaded && lastModification < reload) {\n return true;\n }\n }\n }\n return false;\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,cAAc;AAC1C,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,OAAO,QAAQ,OAAO;AAC/B,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,gBAAgB,QAAQ,cAAc;AAC/C,SAASC,eAAe,QAAQ,mBAAmB;AAsBnD;AACA,MAAMC,yBAAyB,GAAGA,CAChCC,OAAoC,EACpCC,IAAY,EACZC,UAAmB,KACR;EACX,MAAMC,WAAW,GAAG;IAClBC,WAAW,EAAEC,SAAS;IACtBC,gBAAgB,EAAED,SAAS;IAC3BE,QAAQ,EAAE,KAAK;IACfC,MAAM,EAAEH,SAAS;IACjBI,WAAW,EAAEJ,SAAS;IACtBK,KAAK,EAAE,KAAK;IACZC,eAAe,EAAE;EACnB,CAAC;;EAED;EACA,IAAIX,OAAO,CAACI,WAAW,EAAE;IACvBD,WAAW,CAACC,WAAW,GAAGJ,OAAO,CAACI,WAAW;IAC7CD,WAAW,CAACG,gBAAgB,GAAGN,OAAO,CAACM,gBAAgB;EACzD;;EAEA;EACA,IAAIN,OAAO,CAACU,KAAK,EAAE;IACjBP,WAAW,CAACO,KAAK,GAAGV,OAAO,CAACU,KAAK;EACnC;EAEA,IAAIR,UAAU,EAAE;IACdC,WAAW,CAACI,QAAQ,GAAG,IAAI;EAC7B;EAEA,IAAIP,OAAO,CAACW,eAAe,EAAE;IAC3BR,WAAW,CAACQ,eAAe,GAAG,IAAI;EACpC;;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,YAAY,CAAC4B,GAAG,EAAEvB,IAAI,EAAE2B,gBAAgB,CAAC;EAC3D,MAAMd,cAAc,GAAGnB,OAAO,CAC5B,MAAMK,OAAO,CAACc,cAAc,IAAI,EAAE,EAClC,CAACd,OAAO,CAACc,cAAc,CACzB,CAAC;EAED,OAAOnB,OAAO,CAAC,MAAgB;IAC7B,IAAIkC,SAAS,EAAEhB,KAAK,EAAE;MACpBD,aAAa,CAACiB,SAAS,CAAChB,KAAK,EAAEC,cAAc,CAAC;MAC9C,OAAOe,SAAS,CAAChB,KAAK;IACxB;IACA,OAAO,IAAI;EACb,CAAC,EAAE,CAACC,cAAc,EAAEe,SAAS,CAAC,CAAC;AACjC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMF,SAAS,GAAGA,CAACG,QAAgB,EAAEC,GAAW,KAAc;EACnE,MAAMC,QAAQ,GAAGvC,WAAW,CAAC,CAAC;EAC9B,MAAM+B,GAAG,GAAG1B,eAAe,CAACgC,QAAQ,EAAEC,GAAG,CAAC;EAC1C,MAAME,UAAU,GAAGvC,WAAW,CAAEwC,KAAK,IAAKA,KAAK,CAACC,SAAS,CAACX,GAAG,CAAC,CAAC;EAE/D,IAAIS,UAAU,EAAE;IACd,MAAMG,MAAM,GAAGJ,QAAQ,CAACE,KAAK,EAAEE,MAAM,IAAI,CAAC;IAC1C,IAAIA,MAAM,GAAG,CAAC,EAAE;MACd,MAAMC,aAAa,GAAGJ,UAAU,EAAEK,MAAM,KAAKzC,gBAAgB,CAAC0C,QAAQ;MACtE,MAAMC,gBAAgB,GAAGP,UAAU,EAAEO,gBAAgB,IAAI,CAAC;MAC1D,IAAIH,aAAa,IAAIG,gBAAgB,GAAGJ,MAAM,EAAE;QAC9C,OAAO,IAAI;MACb;IACF;EACF;EACA,OAAO,KAAK;AACd,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUIBasic.js","names":["useLocation","useSelector","useMemo","useModularUI","HTTP_METHODS","MODULARUI_STATUS","useModularUIKey","createUseModularUIOptions","options","href","mustReload","baseOptions","targetModel","undefined","forceTargetModel","isReload","origin","contextPath","cache","removeOnUnmount","method","GET","data","formdata","POST","validateModel","model","expectedModels","length","isCorrectModel","some","expectedModel","type","console","warn","useModularUIBasic","defaultKey","key","memoizedHref","toString","useReload","modularUIOptions","modularUI","modelKey","url","location","modelEntry","state","modularui","reload","isFullyLoaded","status","FINISHED","lastModification"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"react-router\";\nimport { useSelector } from \"react-redux\";\nimport { useMemo } from \"react\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../constants\";\nimport { useModularUIKey } from \"./useModularUIKey\";\n\nimport type { ModularUIModel, Href } from \"../models\";\nexport type HookOptions = {\n key?: string,\n origin?: string,\n contextPath?: string,\n removeOnUnmount?: boolean,\n formdata?: any,\n};\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n origin?: string,\n contextPath?: string,\n cache?: boolean,\n key?: string,\n isReload?: boolean,\n removeOnUnmount?: boolean,\n formdata?: any,\n};\n\n// Helper to create useModularUI options\nconst createUseModularUIOptions = <T: ModularUIModel>(\n options: UseModularUIBasicOptions<T>,\n href: string,\n mustReload: boolean,\n): Object => {\n const baseOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n origin: undefined,\n contextPath: undefined,\n cache: false,\n removeOnUnmount: false,\n method: HTTP_METHODS.GET,\n data: undefined,\n };\n\n // Handle targetModel and forceTargetModel\n if (options.targetModel) {\n baseOptions.targetModel = options.targetModel;\n baseOptions.forceTargetModel = options.forceTargetModel;\n }\n\n // Handle cache option\n if (options.cache) {\n baseOptions.cache = options.cache;\n }\n\n if (mustReload) {\n baseOptions.isReload = true;\n }\n\n if (options.removeOnUnmount) {\n baseOptions.removeOnUnmount = true;\n }\n\n if (options.formdata != null) {\n baseOptions.method = HTTP_METHODS.POST;\n baseOptions.data = options.formdata;\n }\n\n // Handle origin and contextPath options\n baseOptions.origin = options.origin ?? baseOptions.origin;\n baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;\n\n return baseOptions;\n};\n\n// Helper to validate the model against expectedModels\nconst validateModel = (model: any, expectedModels: Array<string>) => {\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some(\n (expectedModel) => model.type === expectedModel,\n );\n if (!isCorrectModel) {\n console.warn(model, \"is not of instance\", expectedModels);\n }\n }\n};\n\n/**\n * useModularUIBasic Hook\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n defaultKey: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n origin: undefined,\n contextPath: undefined,\n key: undefined,\n formdata: undefined,\n },\n): T | null => {\n const memoizedHref = useMemo(() => href.toString(), [href]);\n const key = options.key ?? defaultKey;\n\n const mustReload = useReload(key, memoizedHref);\n const modularUIOptions = useMemo(\n () => createUseModularUIOptions(options, memoizedHref, mustReload),\n [options, memoizedHref, mustReload],\n );\n\n const modularUI = useModularUI(key, href, modularUIOptions);\n const expectedModels = useMemo(\n () => options.expectedModels ?? [],\n [options.expectedModels],\n );\n\n return useMemo((): T | null => {\n if (modularUI?.model) {\n validateModel(modularUI.model, expectedModels);\n return modularUI.model;\n }\n return null;\n }, [expectedModels, modularUI]);\n};\n\n/**\n * Check if the model corresponding to a modular ui service should be reloaded\n */\nexport const useReload = (modelKey: string, url: string): boolean => {\n const location = useLocation();\n const key = useModularUIKey(modelKey, url);\n const modelEntry = useSelector((state) => state.modularui[key]);\n\n if (modelEntry) {\n const reload = location.state?.reload || 0;\n if (reload > 0) {\n const isFullyLoaded = modelEntry?.status === MODULARUI_STATUS.FINISHED;\n const lastModification = modelEntry?.lastModification ?? 0;\n if (isFullyLoaded && lastModification < reload) {\n return true;\n }\n }\n }\n return false;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AEgC,gBAAgB,CAAC;EAC3D,MAAMd,cAAc,GAAGzB,OAAO,CAC5B,MAAMM,OAAO,CAACmB,cAAc,IAAI,EAAE,EAClC,CAACnB,OAAO,CAACmB,cAAc,CACzB,CAAC;EAED,OAAOzB,OAAO,CAAC,MAAgB;IAC7B,IAAIwC,SAAS,EAAEhB,KAAK,EAAE;MACpBD,aAAa,CAACiB,SAAS,CAAChB,KAAK,EAAEC,cAAc,CAAC;MAC9C,OAAOe,SAAS,CAAChB,KAAK;IACxB;IACA,OAAO,IAAI;EACb,CAAC,EAAE,CAACC,cAAc,EAAEe,SAAS,CAAC,CAAC;AACjC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMF,SAAS,GAAGA,CAACG,QAAgB,EAAEC,GAAW,KAAc;EACnE,MAAMC,QAAQ,GAAG7C,WAAW,CAAC,CAAC;EAC9B,MAAMqC,GAAG,GAAG/B,eAAe,CAACqC,QAAQ,EAAEC,GAAG,CAAC;EAC1C,MAAME,UAAU,GAAG7C,WAAW,CAAE8C,KAAK,IAAKA,KAAK,CAACC,SAAS,CAACX,GAAG,CAAC,CAAC;EAE/D,IAAIS,UAAU,EAAE;IACd,MAAMG,MAAM,GAAGJ,QAAQ,CAACE,KAAK,EAAEE,MAAM,IAAI,CAAC;IAC1C,IAAIA,MAAM,GAAG,CAAC,EAAE;MACd,MAAMC,aAAa,GAAGJ,UAAU,EAAEK,MAAM,KAAK9C,gBAAgB,CAAC+C,QAAQ;MACtE,MAAMC,gBAAgB,GAAGP,UAAU,EAAEO,gBAAgB,IAAI,CAAC;MAC1D,IAAIH,aAAa,IAAIG,gBAAgB,GAAGJ,MAAM,EAAE;QAC9C,OAAO,IAAI;MACb;IACF;EACF;EACA,OAAO,KAAK;AACd,CAAC","ignoreList":[]}
@@ -64,7 +64,7 @@ const useUrl = (href?: string | Href, fromRoute: boolean = false) => {
64
64
  */
65
65
  export const usePanel = (
66
66
  href?: string | Href,
67
- options?: HookOptions & { fromRoute?: boolean },
67
+ options?: { ...HookOptions, fromRoute?: boolean },
68
68
  ): ListModel | GroupingPanelModel | DetailModel | null => {
69
69
  const { fromRoute, ...hookOptions } = options || { fromRoute: false };
70
70
 
@@ -1 +1 @@
1
- {"version":3,"file":"usePanel.js","names":["useState","useMemo","useLocation","useRouteMatch","Href","useModularUIBasic","GroupingPanelModel","ListModel","DetailModel","CaseSearchModel","useUrl","href","fromRoute","previousUrl","setPreviousUrl","previousExact","setPreviousExact","match","location","_context","url","isExact","addParametersFromString","search","equalsWithParameters","shouldUpdate","Function","call","bind","_startsWithInstanceProperty","usePanel","options","hookOptions","basicOptions","expectedModels","targetModel"],"sources":["../../src/hooks/usePanel.js"],"sourcesContent":["// @flow\nimport { useState, useMemo } from \"react\";\nimport { useLocation, useRouteMatch } from \"react-router\";\nimport Href from \"../models/href/Href\";\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\n\nconst useUrl = (href?: string | Href, fromRoute: boolean = false) => {\n const [previousUrl, setPreviousUrl] = useState(null);\n const [previousExact, setPreviousExact] = useState(false);\n\n const match = useRouteMatch();\n const location = useLocation();\n\n return useMemo(() => {\n if (href == null && previousUrl == null) {\n return new Href(\"\");\n }\n\n const url = href instanceof Href ? href : new Href(href);\n\n if (!fromRoute) {\n return url;\n }\n\n if (match.isExact) {\n url.addParametersFromString(location.search);\n }\n\n // Check equality to prevent unnecessary state updates\n if (url.equalsWithParameters(previousUrl)) {\n return previousUrl || url;\n }\n\n const shouldUpdate =\n match.isExact === true ||\n previousExact === match.isExact ||\n !previousUrl?.startsWith(match.url);\n\n if (shouldUpdate) {\n setPreviousUrl(url);\n setPreviousExact(match.isExact);\n return url;\n }\n\n return previousUrl || new Href(\"\");\n }, [\n href,\n previousUrl,\n fromRoute,\n match.isExact,\n match.url,\n previousExact,\n location.search,\n ]);\n};\n\n/**\n */\nexport const usePanel = (\n href?: string | Href,\n options?: HookOptions & { fromRoute?: boolean },\n): ListModel | GroupingPanelModel | DetailModel | null => {\n const { fromRoute, ...hookOptions } = options || { fromRoute: false };\n\n const url = useUrl(href, fromRoute || false);\n const basicOptions = {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\", \"CaseSearch\"],\n targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],\n ...(hookOptions: HookOptions),\n };\n\n return useModularUIBasic(\"panel\", url, basicOptions);\n};\n"],"mappings":";AACA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AACzC,SAASC,WAAW,EAAEC,aAAa,QAAQ,cAAc;AACzD,OAAOC,IAAI,MAAM,qBAAqB;AACtC,SAASC,iBAAiB,QAAQ,qBAAqB;AAGvD,OAAOC,kBAAkB,MAAM,qCAAqC;AACpE,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,eAAe,MAAM,kCAAkC;AAE9D,MAAMC,MAAM,GAAGA,CAACC,IAAoB,EAAEC,SAAkB,GAAG,KAAK,KAAK;EACnE,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGd,QAAQ,CAAC,IAAI,CAAC;EACpD,MAAM,CAACe,aAAa,EAAEC,gBAAgB,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAEzD,MAAMiB,KAAK,GAAGd,aAAa,CAAC,CAAC;EAC7B,MAAMe,QAAQ,GAAGhB,WAAW,CAAC,CAAC;EAE9B,OAAOD,OAAO,CAAC,MAAM;IAAA,IAAAkB,QAAA;IACnB,IAAIR,IAAI,IAAI,IAAI,IAAIE,WAAW,IAAI,IAAI,EAAE;MACvC,OAAO,IAAIT,IAAI,CAAC,EAAE,CAAC;IACrB;IAEA,MAAMgB,GAAG,GAAGT,IAAI,YAAYP,IAAI,GAAGO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,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC;IACjEC,WAAW,EAAE,CAAC5B,SAAS,EAAED,kBAAkB,EAAEE,WAAW,EAAEC,eAAe,CAAC;IAC1E,GAAIuB;EACN,CAAC;EAED,OAAO3B,iBAAiB,CAAC,OAAO,EAAEe,GAAG,EAAEa,YAAY,CAAC;AACtD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"usePanel.js","names":["useState","useMemo","useLocation","useRouteMatch","Href","useModularUIBasic","GroupingPanelModel","ListModel","DetailModel","CaseSearchModel","useUrl","href","fromRoute","previousUrl","setPreviousUrl","previousExact","setPreviousExact","match","location","_context","url","isExact","addParametersFromString","search","equalsWithParameters","shouldUpdate","Function","call","bind","_startsWithInstanceProperty","usePanel","options","hookOptions","basicOptions","expectedModels","targetModel"],"sources":["../../src/hooks/usePanel.js"],"sourcesContent":["// @flow\nimport { useState, useMemo } from \"react\";\nimport { useLocation, useRouteMatch } from \"react-router\";\nimport Href from \"../models/href/Href\";\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\n\nconst useUrl = (href?: string | Href, fromRoute: boolean = false) => {\n const [previousUrl, setPreviousUrl] = useState(null);\n const [previousExact, setPreviousExact] = useState(false);\n\n const match = useRouteMatch();\n const location = useLocation();\n\n return useMemo(() => {\n if (href == null && previousUrl == null) {\n return new Href(\"\");\n }\n\n const url = href instanceof Href ? href : new Href(href);\n\n if (!fromRoute) {\n return url;\n }\n\n if (match.isExact) {\n url.addParametersFromString(location.search);\n }\n\n // Check equality to prevent unnecessary state updates\n if (url.equalsWithParameters(previousUrl)) {\n return previousUrl || url;\n }\n\n const shouldUpdate =\n match.isExact === true ||\n previousExact === match.isExact ||\n !previousUrl?.startsWith(match.url);\n\n if (shouldUpdate) {\n setPreviousUrl(url);\n setPreviousExact(match.isExact);\n return url;\n }\n\n return previousUrl || new Href(\"\");\n }, [\n href,\n previousUrl,\n fromRoute,\n match.isExact,\n match.url,\n previousExact,\n location.search,\n ]);\n};\n\n/**\n */\nexport const usePanel = (\n href?: string | Href,\n options?: { ...HookOptions, fromRoute?: boolean },\n): ListModel | GroupingPanelModel | DetailModel | null => {\n const { fromRoute, ...hookOptions } = options || { fromRoute: false };\n\n const url = useUrl(href, fromRoute || false);\n const basicOptions = {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\", \"CaseSearch\"],\n targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],\n ...(hookOptions: HookOptions),\n };\n\n return useModularUIBasic(\"panel\", url, basicOptions);\n};\n"],"mappings":";AACA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AACzC,SAASC,WAAW,EAAEC,aAAa,QAAQ,cAAc;AACzD,OAAOC,IAAI,MAAM,qBAAqB;AACtC,SAASC,iBAAiB,QAAQ,qBAAqB;AAGvD,OAAOC,kBAAkB,MAAM,qCAAqC;AACpE,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,eAAe,MAAM,kCAAkC;AAE9D,MAAMC,MAAM,GAAGA,CAACC,IAAoB,EAAEC,SAAkB,GAAG,KAAK,KAAK;EACnE,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGd,QAAQ,CAAC,IAAI,CAAC;EACpD,MAAM,CAACe,aAAa,EAAEC,gBAAgB,CAAC,GAAGhB,QAAQ,CAAC,KAAK,CAAC;EAEzD,MAAMiB,KAAK,GAAGd,aAAa,CAAC,CAAC;EAC7B,MAAMe,QAAQ,GAAGhB,WAAW,CAAC,CAAC;EAE9B,OAAOD,OAAO,CAAC,MAAM;IAAA,IAAAkB,QAAA;IACnB,IAAIR,IAAI,IAAI,IAAI,IAAIE,WAAW,IAAI,IAAI,E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CAACC,IAAI,EAAEC,SAAS,IAAI,KAAK,CAAC;EAC5C,MAAMqB,YAAY,GAAG;IACnBC,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC;IACjEC,WAAW,EAAE,CAAC5B,SAAS,EAAED,kBAAkB,EAAEE,WAAW,EAAEC,eAAe,CAAC;IAC1E,GAAIuB;EACN,CAAC;EAED,OAAO3B,iBAAiB,CAAC,OAAO,EAAEe,GAAG,EAAEa,YAAY,CAAC;AACtD,CAAC","ignoreList":[]}
@@ -1,31 +1,37 @@
1
+ import { useMemo } from "react";
1
2
  import { useDispatch, useSelector } from "react-redux";
2
3
  import { push, replace, go, goBack, goForward } from "../redux/_router/RouterActions";
3
4
  /**
5
+ * Returns the full location object from the router state.
4
6
  */
5
- export const useLocation = () => useSelector(state => state.router.location);
7
+ export const useLocation = () => useSelector(state => state.router?.location || {});
6
8
 
7
9
  /**
10
+ * Returns the unique key of the current location.
8
11
  */
9
- export const useLocationKey = () => useLocation()?.key ?? "";
12
+ export const useLocationKey = () => useSelector(state => state.router?.location?.key ?? "");
10
13
 
11
14
  /**
15
+ * Returns the current search (querystring) portion of the URL.
12
16
  */
13
- export const useQuerystring = () => useLocation()?.search;
17
+ export const useQuerystring = () => useSelector(state => state.router?.location?.search ?? "");
14
18
 
15
19
  /**
20
+ * Returns the current URL pathname.
16
21
  */
17
- export const usePathname = () => useLocation()?.pathname;
22
+ export const usePathname = () => useSelector(state => state.router?.location?.pathname ?? "");
18
23
 
19
24
  /**
25
+ * Provides navigation methods.
20
26
  */
21
27
  export const useNavigation = () => {
22
28
  const dispatch = useDispatch();
23
- return {
29
+ return useMemo(() => ({
24
30
  push: (location, state) => dispatch(push(location, state)),
25
31
  replace: (location, state) => dispatch(replace(location, state)),
26
32
  go: delta => dispatch(go(delta)),
27
33
  goBack: () => dispatch(goBack()),
28
34
  goForward: () => dispatch(goForward())
29
- };
35
+ }), [dispatch]);
30
36
  };
31
37
  //# sourceMappingURL=useRouter.js.map