@beinformed/ui 1.65.1 → 1.65.3

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 (68) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/esm/hooks/useList.js +4 -4
  3. package/esm/hooks/useList.js.flow +5 -5
  4. package/esm/hooks/useList.js.map +1 -1
  5. package/esm/hooks/useModularUI.js +3 -10
  6. package/esm/hooks/useModularUI.js.flow +3 -14
  7. package/esm/hooks/useModularUI.js.map +1 -1
  8. package/esm/hooks/useModularUIBasic.js +37 -12
  9. package/esm/hooks/useModularUIBasic.js.flow +47 -10
  10. package/esm/hooks/useModularUIBasic.js.map +1 -1
  11. package/esm/hooks/useModularUIKey.js +11 -0
  12. package/esm/hooks/useModularUIKey.js.flow +14 -0
  13. package/esm/hooks/useModularUIKey.js.map +1 -0
  14. package/esm/hooks/usePanel.js +8 -3
  15. package/esm/hooks/usePanel.js.flow +4 -3
  16. package/esm/hooks/usePanel.js.map +1 -1
  17. package/esm/models/href/Href.js +1 -1
  18. package/esm/models/href/Href.js.flow +1 -1
  19. package/esm/models/href/Href.js.map +1 -1
  20. package/esm/models/list/ListModel.js +5 -1
  21. package/esm/models/list/ListModel.js.flow +7 -3
  22. package/esm/models/list/ListModel.js.map +1 -1
  23. package/esm/models/sorting/SortOptionModel.js +7 -0
  24. package/esm/models/sorting/SortOptionModel.js.flow +7 -0
  25. package/esm/models/sorting/SortOptionModel.js.map +1 -1
  26. package/esm/models/sorting/SortingModel.js +14 -2
  27. package/esm/models/sorting/SortingModel.js.flow +14 -2
  28. package/esm/models/sorting/SortingModel.js.map +1 -1
  29. package/esm/redux/_modularui/ModularUIConnector.js +7 -6
  30. package/esm/redux/_modularui/ModularUIConnector.js.flow +6 -4
  31. package/esm/redux/_modularui/ModularUIConnector.js.map +1 -1
  32. package/esm/redux/actions/SignIn.js +15 -15
  33. package/esm/redux/actions/SignIn.js.flow +25 -26
  34. package/esm/redux/actions/SignIn.js.map +1 -1
  35. package/lib/hooks/useList.js +4 -4
  36. package/lib/hooks/useList.js.map +1 -1
  37. package/lib/hooks/useModularUI.js +3 -10
  38. package/lib/hooks/useModularUI.js.map +1 -1
  39. package/lib/hooks/useModularUIBasic.js +39 -14
  40. package/lib/hooks/useModularUIBasic.js.map +1 -1
  41. package/lib/hooks/useModularUIKey.js +17 -0
  42. package/lib/hooks/useModularUIKey.js.map +1 -0
  43. package/lib/hooks/usePanel.js +8 -3
  44. package/lib/hooks/usePanel.js.map +1 -1
  45. package/lib/models/href/Href.js +1 -1
  46. package/lib/models/href/Href.js.map +1 -1
  47. package/lib/models/list/ListModel.js +5 -1
  48. package/lib/models/list/ListModel.js.map +1 -1
  49. package/lib/models/sorting/SortOptionModel.js +7 -0
  50. package/lib/models/sorting/SortOptionModel.js.map +1 -1
  51. package/lib/models/sorting/SortingModel.js +14 -2
  52. package/lib/models/sorting/SortingModel.js.map +1 -1
  53. package/lib/redux/_modularui/ModularUIConnector.js +7 -6
  54. package/lib/redux/_modularui/ModularUIConnector.js.map +1 -1
  55. package/lib/redux/actions/SignIn.js +15 -15
  56. package/lib/redux/actions/SignIn.js.map +1 -1
  57. package/package.json +6 -6
  58. package/src/hooks/useList.js +5 -5
  59. package/src/hooks/useModularUI.js +3 -14
  60. package/src/hooks/useModularUIBasic.js +47 -10
  61. package/src/hooks/useModularUIKey.js +14 -0
  62. package/src/hooks/usePanel.js +4 -3
  63. package/src/models/href/Href.js +1 -1
  64. package/src/models/list/ListModel.js +7 -3
  65. package/src/models/sorting/SortOptionModel.js +7 -0
  66. package/src/models/sorting/SortingModel.js +14 -2
  67. package/src/redux/_modularui/ModularUIConnector.js +6 -4
  68. package/src/redux/actions/SignIn.js +25 -26
package/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
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.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.1...v1.65.3) (2026-01-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **hooks:** correct useEffect cleanup syntax and loosen `undefined` check in Href methods ([452cb01](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/452cb01180a852996bae753d108004e35d9f52bc))
11
+ * **hooks:** modularui basic hook, add removeOnUnmount ([137c86c](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/137c86ca5bf9b4c934b16ef4477e3d6f6fddf657))
12
+ * **hooks:** refactor key generation and reload handling for modular UI hooks ([11f3131](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/11f3131cadf4b79139f0ad8d8dd1357c429367f4))
13
+ * **list:** update list filters from filter array ([26039b7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/26039b77b58b8172cb39514399367726e98b2d85))
14
+ * **login:** handle failing login attempt ([1ace402](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/1ace402589fdfe9270feec9d342452358edbac59))
15
+ * **sorting:** add reset functionality and improve sort value handling ([c39188d](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/c39188d96f5986301b18d2d236cfd77db8c5a101))
16
+ * **use-panel:** improve panel key in store ([79e55fb](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/79e55fb932db26e6a2112f182d9ff4741003565e))
17
+
18
+ ## [1.65.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.1...v1.65.2) (2025-12-19)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **hooks:** modularui basic hook, add removeOnUnmount ([137c86c](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/137c86ca5bf9b4c934b16ef4477e3d6f6fddf657))
24
+ * **hooks:** refactor key generation and reload handling for modular UI hooks ([11f3131](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/11f3131cadf4b79139f0ad8d8dd1357c429367f4))
25
+ * **login:** handle failing login attempt ([1ace402](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/1ace402589fdfe9270feec9d342452358edbac59))
26
+ * **use-panel:** improve panel key in store ([79e55fb](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/79e55fb932db26e6a2112f182d9ff4741003565e))
27
+
5
28
  ## [1.65.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.65.0...v1.65.1) (2025-12-18)
6
29
 
7
30
 
@@ -37,7 +37,7 @@ export const useListDetail = (href, options) => useModularUIBasic("listdetail",
37
37
  export const useListNavigation = () => {
38
38
  const history = useHistory();
39
39
  const dispatch = useDispatch();
40
- const fetch = (list, resetPage = false) => {
40
+ const update = (list, resetPage = false) => {
41
41
  const listHref = list.selfhref;
42
42
  if (resetPage) {
43
43
  listHref.page = null;
@@ -47,7 +47,7 @@ export const useListNavigation = () => {
47
47
  search: listHref.querystring,
48
48
  state: list.formdata
49
49
  });
50
- return dispatch(loadModularUI(list.connectKey, listHref, {
50
+ dispatch(loadModularUI(list.connectKey, listHref, {
51
51
  method: HTTP_METHODS.POST,
52
52
  data: list.formdata,
53
53
  targetModel: ListModel
@@ -56,14 +56,14 @@ export const useListNavigation = () => {
56
56
  history.push({
57
57
  search: listHref.querystring
58
58
  });
59
- return dispatch(loadModularUI(list.connectKey, listHref, {
59
+ dispatch(loadModularUI(list.connectKey, listHref, {
60
60
  method: HTTP_METHODS.GET,
61
61
  targetModel: ListModel
62
62
  }));
63
63
  }
64
64
  };
65
65
  return {
66
- fetch
66
+ update
67
67
  };
68
68
  };
69
69
  //# sourceMappingURL=useList.js.map
@@ -12,7 +12,7 @@ import type { HookOptions } from "./useModularUIBasic";
12
12
  import { useHistory } from "react-router";
13
13
 
14
14
  type ListNavigationHook = {
15
- fetch: (list: ListModel, resetPage?: boolean) => void,
15
+ update: (list: ListModel, resetPage?: boolean) => void,
16
16
  };
17
17
 
18
18
  /**
@@ -58,7 +58,7 @@ export const useListNavigation = (): ListNavigationHook => {
58
58
  const history = useHistory();
59
59
  const dispatch = useDispatch();
60
60
 
61
- const fetch = (list: ListModel, resetPage: boolean = false) => {
61
+ const update = (list: ListModel, resetPage: boolean = false) => {
62
62
  const listHref = list.selfhref;
63
63
  if (resetPage) {
64
64
  listHref.page = null;
@@ -66,7 +66,7 @@ export const useListNavigation = (): ListNavigationHook => {
66
66
 
67
67
  if (list.requestMethod === HTTP_METHODS.POST) {
68
68
  history.push({ search: listHref.querystring, state: list.formdata });
69
- return dispatch(
69
+ dispatch(
70
70
  loadModularUI(list.connectKey, listHref, {
71
71
  method: HTTP_METHODS.POST,
72
72
  data: list.formdata,
@@ -75,7 +75,7 @@ export const useListNavigation = (): ListNavigationHook => {
75
75
  );
76
76
  } else {
77
77
  history.push({ search: listHref.querystring });
78
- return dispatch(
78
+ dispatch(
79
79
  loadModularUI(list.connectKey, listHref, {
80
80
  method: HTTP_METHODS.GET,
81
81
  targetModel: ListModel,
@@ -85,6 +85,6 @@ export const useListNavigation = (): ListNavigationHook => {
85
85
  };
86
86
 
87
87
  return {
88
- fetch,
88
+ update,
89
89
  };
90
90
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useList.js","names":["useModularUIBasic","useDispatch","HTTP_METHODS","loadModularUI","DetailModel","ListModel","ListDetailModel","Href","useHistory","useList","href","options","expectedModels","targetModel","useListOrDetail","useListDetail","forceTargetModel","useListNavigation","history","dispatch","fetch","list","resetPage","listHref","selfhref","page","requestMethod","POST","push","search","querystring","state","formdata","connectKey","method","data","GET"],"sources":["../../src/hooks/useList.js"],"sourcesContent":["// @flow\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { useDispatch } from \"react-redux\";\nimport { HTTP_METHODS } from \"../constants/Constants\";\nimport { loadModularUI } from \"../redux\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport Href from \"../models/href/Href\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport { useHistory } from \"react-router\";\n\ntype ListNavigationHook = {\n fetch: (list: ListModel, resetPage?: boolean) => void,\n};\n\n/**\n */\nexport const useList = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\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\", \"Detail\"],\n targetModel: [ListModel, 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 = (): ListNavigationHook => {\n const history = useHistory();\n const dispatch = useDispatch();\n\n const fetch = (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 history.push({ search: listHref.querystring, state: list.formdata });\n return dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.POST,\n data: list.formdata,\n targetModel: ListModel,\n }),\n );\n } else {\n history.push({ search: listHref.querystring });\n return dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.GET,\n targetModel: ListModel,\n }),\n );\n }\n };\n\n return {\n fetch,\n };\n};\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,e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AI,CAAC;QAAEC,MAAM,EAAEN,QAAQ,CAACO,WAAW;QAAEC,KAAK,EAAEV,IAAI,CAACW;MAAS,CAAC,CAAC;MACpE,OAAOb,QAAQ,CACbhB,aAAa,CAACkB,IAAI,CAACY,UAAU,EAAEV,QAAQ,EAAE;QACvCW,MAAM,EAAEhC,YAAY,CAACyB,IAAI;QACzBQ,IAAI,EAAEd,IAAI,CAACW,QAAQ;QACnBnB,WAAW,EAAER;MACf,CAAC,CACH,CAAC;IACH,CAAC,MAAM;MACLa,OAAO,CAACU,IAAI,CAAC;QAAEC,MAAM,EAAEN,QAAQ,CAACO;MAAY,CAAC,CAAC;MAC9C,OAAOX,QAAQ,CACbhB,aAAa,CAACkB,IAAI,CAACY,UAAU,EAAEV,QAAQ,EAAE;QACvCW,MAAM,EAAEhC,YAAY,CAACkC,GAAG;QACxBvB,WAAW,EAAER;MACf,CAAC,CACH,CAAC;IACH;EACF,CAAC;EAED,OAAO;IACLe;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useList.js","names":["useModularUIBasic","useDispatch","HTTP_METHODS","loadModularUI","DetailModel","ListModel","ListDetailModel","Href","useHistory","useList","href","options","expectedModels","targetModel","useListOrDetail","useListDetail","forceTargetModel","useListNavigation","history","dispatch","update","list","resetPage","listHref","selfhref","page","requestMethod","POST","push","search","querystring","state","formdata","connectKey","method","data","GET"],"sources":["../../src/hooks/useList.js"],"sourcesContent":["// @flow\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { useDispatch } from \"react-redux\";\nimport { HTTP_METHODS } from \"../constants/Constants\";\nimport { loadModularUI } from \"../redux\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport Href from \"../models/href/Href\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport { useHistory } from \"react-router\";\n\ntype ListNavigationHook = {\n update: (list: ListModel, resetPage?: boolean) => void,\n};\n\n/**\n */\nexport const useList = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\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\", \"Detail\"],\n targetModel: [ListModel, 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 = (): ListNavigationHook => {\n const history = useHistory();\n const dispatch = useDispatch();\n\n const update = (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 history.push({ search: listHref.querystring, state: list.formdata });\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.POST,\n data: list.formdata,\n targetModel: ListModel,\n }),\n );\n } else {\n history.push({ search: listHref.querystring });\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.GET,\n targetModel: ListModel,\n }),\n );\n }\n };\n\n return {\n update,\n };\n};\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,IAAI,MAAM,qBAAqB;AAGtC,SAASC,UAAU,QAAQ,cAAc;AAMzC;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CACrBC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AAI,CAACY,UAAU,EAAEV,QAAQ,EAAE;QACvCW,MAAM,EAAEhC,YAAY,CAACyB,IAAI;QACzBQ,IAAI,EAAEd,IAAI,CAACW,QAAQ;QACnBnB,WAAW,EAAER;MACf,CAAC,CACH,CAAC;IACH,CAAC,MAAM;MACLa,OAAO,CAACU,IAAI,CAAC;QAAEC,MAAM,EAAEN,QAAQ,CAACO;MAAY,CAAC,CAAC;MAC9CX,QAAQ,CACNhB,aAAa,CAACkB,IAAI,CAACY,UAAU,EAAEV,QAAQ,EAAE;QACvCW,MAAM,EAAEhC,YAAY,CAACkC,GAAG;QACxBvB,WAAW,EAAER;MACf,CAAC,CACH,CAAC;IACH;EACF,CAAC;EAED,OAAO;IACLe;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -4,17 +4,10 @@ import { useLocation } from "react-router";
4
4
  import { HTTP_METHODS } from "../constants";
5
5
  import { loadModularUI, removeModelByKey } from "../redux/_modularui/ModularUIActions";
6
6
  import useDeepCompareEffect from "./useDeepCompareEffect";
7
- import { useLocale } from "./useI18n";
7
+ import { useModularUIKey } from "./useModularUIKey";
8
8
  import Href from "../models/href/Href";
9
9
  /**
10
- */
11
- const useKeyForHook = (modelKey, url) => {
12
- const locale = useLocale();
13
- return useMemo(() => `${modelKey}(${url.split("?")[0]})(${locale})`, [modelKey, url, locale]);
14
- };
15
-
16
- /**
17
- * Use redux action and selector to retrieve the correct modular ui service model
10
+ * Core hook to retrieve information for a Be Informed modular ui resource
18
11
  */
19
12
  export const useModularUI = (modelKey, url, options = {
20
13
  method: HTTP_METHODS.GET,
@@ -22,7 +15,7 @@ export const useModularUI = (modelKey, url, options = {
22
15
  }) => {
23
16
  const dispatch = useDispatch();
24
17
  const href = useMemo(() => url?.toString() || "", [url]);
25
- const key = useKeyForHook(modelKey, href);
18
+ const key = useModularUIKey(modelKey, href);
26
19
  const modelSelector = useMemo(() => state => state.modularui[key], [key]);
27
20
  const model = useSelector(modelSelector);
28
21
  if (url instanceof Href) {
@@ -10,24 +10,13 @@ import {
10
10
  } from "../redux/_modularui/ModularUIActions";
11
11
 
12
12
  import useDeepCompareEffect from "./useDeepCompareEffect";
13
+ import { useModularUIKey } from "./useModularUIKey";
13
14
 
14
- import { useLocale } from "./useI18n";
15
15
  import Href from "../models/href/Href";
16
-
17
16
  import type { RequestModularUIOptions } from "../utils";
18
17
 
19
18
  /**
20
- */
21
- const useKeyForHook = (modelKey: string, url: string) => {
22
- const locale = useLocale();
23
- return useMemo(
24
- () => `${modelKey}(${url.split("?")[0]})(${locale})`,
25
- [modelKey, url, locale],
26
- );
27
- };
28
-
29
- /**
30
- * Use redux action and selector to retrieve the correct modular ui service model
19
+ * Core hook to retrieve information for a Be Informed modular ui resource
31
20
  */
32
21
  export const useModularUI = (
33
22
  modelKey: string,
@@ -39,7 +28,7 @@ export const useModularUI = (
39
28
  ): any => {
40
29
  const dispatch = useDispatch();
41
30
  const href = useMemo(() => url?.toString() || "", [url]);
42
- const key = useKeyForHook(modelKey, href);
31
+ const key = useModularUIKey(modelKey, href);
43
32
 
44
33
  const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);
45
34
  const model = useSelector(modelSelector);
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useMemo","useDispatch","useSelector","useLocation","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","Href","useKeyForHook","modelKey","url","locale","split","useModularUI","options","method","GET","removeOnUnmount","dispatch","href","toString","key","modelSelector","state","modularui","model","origin","contextPath","location","redirectLocation","forceLoad","equals","prevOptions","prevHref","prevForceLoad","isOldReload","current","isReload","doForceLoad"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return useMemo(\n () => `${modelKey}(${url.split(\"?\")[0]})(${locale})`,\n [modelKey, url, locale],\n );\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useKeyForHook(modelKey, href);\n\n const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);\n const model = useSelector(modelSelector);\n\n if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceLoad =\n model == null ||\n (redirectLocation instanceof Href ? redirectLocation?.equals(href) : false);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceLoad = useRef(forceLoad);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceLoad = forceLoad && !prevForceLoad.current;\n\n if (href !== \"\" && (doForceLoad || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceLoad.current = forceLoad;\n }, [key, href, options, forceLoad]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AAClD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AM;QACXC,QAAQ,CAACd,gBAAgB,CAACiB,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACH,QAAQ,EAAEG,GAAG,EAAEP,OAAO,CAACG,eAAe,CAAC,CAAC;EAE5C,OAAOQ,KAAK;AACd,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useMemo","useDispatch","useSelector","useLocation","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useModularUIKey","Href","useModularUI","modelKey","url","options","method","GET","removeOnUnmount","dispatch","href","toString","key","modelSelector","state","modularui","model","origin","contextPath","location","redirectLocation","forceLoad","equals","prevOptions","prevHref","prevForceLoad","isOldReload","current","isReload","doForceLoad"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\nimport { useModularUIKey } from \"./useModularUIKey\";\n\nimport Href from \"../models/href/Href\";\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n * Core hook to retrieve information for a Be Informed modular ui resource\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useModularUIKey(modelKey, href);\n\n const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);\n const model = useSelector(modelSelector);\n\n if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceLoad =\n model == null ||\n (redirectLocation instanceof Href ? redirectLocation?.equals(href) : false);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceLoad = useRef(forceLoad);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceLoad = forceLoad && !prevForceLoad.current;\n\n if (href !== \"\" && (doForceLoad || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceLoad.current = forceLoad;\n }, [key, href, options, forceLoad]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,WAAW,QAAQ,cAAc;AAE1C,SAASC,YAAY,QAAQ,cAAc;AAC3C,SACEC,aAAa,EACbC,gBAAgB,QACX,sCAAsC;AAE7C,OAAOC,oBAAoB,MAAM,wBAAwB;AACzD,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,OAAOC,IAAI,MAAM,qBAAqB;AAGtC;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAGA,CAC1BC,QAAgB,EAChBC,GAAkB,EAClBC,OAAgC,GAAG;EACjCC,MAAM,EAAEV,YAAY,CAACW,GAAG;EACxBC,eAAe,EAAE;AACnB,CAAC,KACO;EACR,MAAMC,QAAQ,GAAGhB,WAAW,CAAC,CAAC;EAC9B,MAAMiB,IAAI,GAAGlB,OAAO,CAAC,MAAMY,GAAG,EAAEO,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAACP,GAAG,CAAC,CAAC;EACxD,MAAMQ,GAAG,GAAGZ,eAAe,CAACG,QAAQ,EAAEO,IAAI,CAAC;EAE3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OAAO;IAC7BmB,QAAQ,CAACG,OAAO,GAAGjB,IAAI;IACvBe,aAAa,CAACE,OAAO,GAAGN,SAAS;EACnC,CAAC,EAAE,CAACT,GAAG,EAAEF,IAAI,EAAEL,OAAO,EAAEgB,SAAS,CAAC,CAAC;EAEnC/B,SAAS,CAAC,MAAM;IACd,IAAIe,OAAO,CAACG,eAAe,EAAE;MAC3B,OAAO,MAAM;QACXC,QAAQ,CAACX,gBAAgB,CAACc,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACH,QAAQ,EAAEG,GAAG,EAAEP,OAAO,CAACG,eAAe,CAAC,CAAC;EAE5C,OAAOQ,KAAK;AACd,CAAC","ignoreList":[]}
@@ -1,17 +1,19 @@
1
- import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
2
1
  import { useLocation } from "react-router";
2
+ import { useSelector } from "react-redux";
3
3
  import { useMemo } from "react";
4
4
  import { useModularUI } from "./useModularUI";
5
+ import { MODULARUI_STATUS } from "../constants";
6
+ import { useModularUIKey } from "./useModularUIKey";
5
7
  // Helper to create useModularUI options
6
- const createUseModularUIOptions = (options, href, location) => {
7
- var _context;
8
+ const createUseModularUIOptions = (options, href, mustReload) => {
8
9
  const baseOptions = {
9
10
  targetModel: undefined,
10
11
  forceTargetModel: undefined,
11
12
  isReload: false,
12
13
  origin: undefined,
13
14
  contextPath: undefined,
14
- cache: false
15
+ cache: false,
16
+ removeOnUnmount: false
15
17
  };
16
18
 
17
19
  // Handle targetModel and forceTargetModel
@@ -24,11 +26,12 @@ const createUseModularUIOptions = (options, href, location) => {
24
26
  if (options.cache) {
25
27
  baseOptions.cache = options.cache;
26
28
  }
27
-
28
- // Check for reload if location matches href
29
- if (location.state?.reload && _startsWithInstanceProperty(_context = location.pathname).call(_context, href)) {
29
+ if (mustReload) {
30
30
  baseOptions.isReload = true;
31
31
  }
32
+ if (options.removeOnUnmount) {
33
+ baseOptions.removeOnUnmount = true;
34
+ }
32
35
 
33
36
  // Handle origin and contextPath options
34
37
  baseOptions.origin = options.origin ?? baseOptions.origin;
@@ -49,17 +52,19 @@ const validateModel = (model, expectedModels) => {
49
52
  /**
50
53
  * useModularUIBasic Hook
51
54
  */
52
- export const useModularUIBasic = (key, href, options = {
55
+ export const useModularUIBasic = (defaultKey, href, options = {
53
56
  expectedModels: [],
54
57
  targetModel: undefined,
55
58
  forceTargetModel: false,
56
59
  origin: undefined,
57
- contextPath: undefined
60
+ contextPath: undefined,
61
+ key: undefined
58
62
  }) => {
59
- const location = useLocation();
60
63
  const memoizedHref = useMemo(() => href.toString(), [href]);
61
- const useModularUIOptions = useMemo(() => createUseModularUIOptions(options, memoizedHref, location), [options, memoizedHref, location]);
62
- const modularUI = useModularUI(key, href, useModularUIOptions);
64
+ const key = options.key ?? defaultKey;
65
+ const mustReload = useReload(key, memoizedHref);
66
+ const modularUIOptions = useMemo(() => createUseModularUIOptions(options, memoizedHref, mustReload), [options, memoizedHref, mustReload]);
67
+ const modularUI = useModularUI(key, href, modularUIOptions);
63
68
  const expectedModels = useMemo(() => options.expectedModels ?? [], [options.expectedModels]);
64
69
  return useMemo(() => {
65
70
  if (modularUI?.model) {
@@ -69,4 +74,24 @@ export const useModularUIBasic = (key, href, options = {
69
74
  return null;
70
75
  }, [expectedModels, modularUI]);
71
76
  };
77
+
78
+ /**
79
+ * Check if the model corresponding to a modular ui service should be reloaded
80
+ */
81
+ export const useReload = (modelKey, url) => {
82
+ const location = useLocation();
83
+ const key = useModularUIKey(modelKey, url);
84
+ const modelEntry = useSelector(state => state.modularui[key]);
85
+ if (modelEntry) {
86
+ const reload = location.state?.reload || 0;
87
+ if (reload > 0) {
88
+ const isFullyLoaded = modelEntry?.status === MODULARUI_STATUS.FINISHED;
89
+ const lastModification = modelEntry?.lastModification ?? 0;
90
+ if (isFullyLoaded && lastModification < reload) {
91
+ return true;
92
+ }
93
+ }
94
+ }
95
+ return false;
96
+ };
72
97
  //# sourceMappingURL=useModularUIBasic.js.map
@@ -1,12 +1,18 @@
1
1
  // @flow
2
- import type { ModularUIModel, Href } from "../models";
3
2
  import { useLocation } from "react-router";
3
+ 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";
8
+ import { useModularUIKey } from "./useModularUIKey";
9
+
10
+ import type { ModularUIModel, Href } from "../models";
7
11
  export type HookOptions = {
12
+ key?: string,
8
13
  origin?: string,
9
14
  contextPath?: string,
15
+ removeOnUnmount?: boolean,
10
16
  };
11
17
 
12
18
  export type UseModularUIBasicOptions<T: ModularUIModel> = {
@@ -16,13 +22,16 @@ export type UseModularUIBasicOptions<T: ModularUIModel> = {
16
22
  origin?: string,
17
23
  contextPath?: string,
18
24
  cache?: boolean,
25
+ key?: string,
26
+ isReload?: boolean,
27
+ removeOnUnmount?: boolean,
19
28
  };
20
29
 
21
30
  // Helper to create useModularUI options
22
31
  const createUseModularUIOptions = <T: ModularUIModel>(
23
32
  options: UseModularUIBasicOptions<T>,
24
33
  href: string,
25
- location: any,
34
+ mustReload: boolean,
26
35
  ): Object => {
27
36
  const baseOptions = {
28
37
  targetModel: undefined,
@@ -31,6 +40,7 @@ const createUseModularUIOptions = <T: ModularUIModel>(
31
40
  origin: undefined,
32
41
  contextPath: undefined,
33
42
  cache: false,
43
+ removeOnUnmount: false,
34
44
  };
35
45
 
36
46
  // Handle targetModel and forceTargetModel
@@ -44,11 +54,14 @@ const createUseModularUIOptions = <T: ModularUIModel>(
44
54
  baseOptions.cache = options.cache;
45
55
  }
46
56
 
47
- // Check for reload if location matches href
48
- if (location.state?.reload && location.pathname.startsWith(href)) {
57
+ if (mustReload) {
49
58
  baseOptions.isReload = true;
50
59
  }
51
60
 
61
+ if (options.removeOnUnmount) {
62
+ baseOptions.removeOnUnmount = true;
63
+ }
64
+
52
65
  // Handle origin and contextPath options
53
66
  baseOptions.origin = options.origin ?? baseOptions.origin;
54
67
  baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;
@@ -72,7 +85,7 @@ const validateModel = (model: any, expectedModels: Array<string>) => {
72
85
  * useModularUIBasic Hook
73
86
  */
74
87
  export const useModularUIBasic = <T: ModularUIModel>(
75
- key: string,
88
+ defaultKey: string,
76
89
  href: string | Href,
77
90
  options: UseModularUIBasicOptions<T> = {
78
91
  expectedModels: [],
@@ -80,16 +93,19 @@ export const useModularUIBasic = <T: ModularUIModel>(
80
93
  forceTargetModel: false,
81
94
  origin: undefined,
82
95
  contextPath: undefined,
96
+ key: undefined,
83
97
  },
84
98
  ): T | null => {
85
- const location = useLocation();
86
99
  const memoizedHref = useMemo(() => href.toString(), [href]);
87
- const useModularUIOptions = useMemo(
88
- () => createUseModularUIOptions(options, memoizedHref, location),
89
- [options, memoizedHref, location],
100
+ const key = options.key ?? defaultKey;
101
+
102
+ const mustReload = useReload(key, memoizedHref);
103
+ const modularUIOptions = useMemo(
104
+ () => createUseModularUIOptions(options, memoizedHref, mustReload),
105
+ [options, memoizedHref, mustReload],
90
106
  );
91
107
 
92
- const modularUI = useModularUI(key, href, useModularUIOptions);
108
+ const modularUI = useModularUI(key, href, modularUIOptions);
93
109
  const expectedModels = useMemo(
94
110
  () => options.expectedModels ?? [],
95
111
  [options.expectedModels],
@@ -103,3 +119,24 @@ export const useModularUIBasic = <T: ModularUIModel>(
103
119
  return null;
104
120
  }, [expectedModels, modularUI]);
105
121
  };
122
+
123
+ /**
124
+ * Check if the model corresponding to a modular ui service should be reloaded
125
+ */
126
+ export const useReload = (modelKey: string, url: string): boolean => {
127
+ const location = useLocation();
128
+ const key = useModularUIKey(modelKey, url);
129
+ const modelEntry = useSelector((state) => state.modularui[key]);
130
+
131
+ if (modelEntry) {
132
+ const reload = location.state?.reload || 0;
133
+ if (reload > 0) {
134
+ const isFullyLoaded = modelEntry?.status === MODULARUI_STATUS.FINISHED;
135
+ const lastModification = modelEntry?.lastModification ?? 0;
136
+ if (isFullyLoaded && lastModification < reload) {
137
+ return true;
138
+ }
139
+ }
140
+ }
141
+ return false;
142
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIBasic.js","names":["useLocation","useMemo","useModularUI","createUseModularUIOptions","options","href","location","_context","baseOptions","targetModel","undefined","forceTargetModel","isReload","origin","contextPath","cache","state","reload","_startsWithInstanceProperty","pathname","call","validateModel","model","expectedModels","length","isCorrectModel","some","expectedModel","type","console","warn","useModularUIBasic","key","memoizedHref","toString","useModularUIOptions","modularUI"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel, Href } from \"../models\";\nimport { useLocation } from \"react-router\";\nimport { useMemo } from \"react\";\nimport { useModularUI } from \"./useModularUI\";\n\nexport type HookOptions = {\n origin?: string,\n contextPath?: string,\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};\n\n// Helper to create useModularUI options\nconst createUseModularUIOptions = <T: ModularUIModel>(\n options: UseModularUIBasicOptions<T>,\n href: string,\n location: any,\n): Object => {\n const baseOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n origin: undefined,\n contextPath: undefined,\n cache: 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 // Check for reload if location matches href\n if (location.state?.reload && location.pathname.startsWith(href)) {\n baseOptions.isReload = 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 key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n origin: undefined,\n contextPath: undefined,\n },\n): T | null => {\n const location = useLocation();\n const memoizedHref = useMemo(() => href.toString(), [href]);\n const useModularUIOptions = useMemo(\n () => createUseModularUIOptions(options, memoizedHref, location),\n [options, memoizedHref, location],\n );\n\n const modularUI = useModularUI(key, href, useModularUIOptions);\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"],"mappings":";AAEA,SAASA,WAAW,QAAQ,cAAc;AAC1C,SAASC,OAAO,QAAQ,OAAO;AAC/B,SAASC,YAAY,QAAQ,gBAAgB;AAgB7C;AACA,MAAMC,yBAAyB,GAAGA,CAChCC,OAAoC,EACpCC,IAAY,EACZC,QAAa,KACF;EAAA,IAAAC,QAAA;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;EACT,CAAC;;EAED;EACA,IAAIX,OAAO,CAACK,WAAW,EAAE;IACvBD,WAAW,CAACC,WAAW,GAAGL,OAAO,CAACK,WAAW;IAC7CD,WAAW,CAACG,gBAAgB,GAAGP,OAAO,CAACO,gBAAgB;EACzD;;EAEA;EACA,IAAIP,OAAO,CAACW,KAAK,EAAE;IACjBP,WAAW,CAACO,KAAK,GAAGX,OAAO,CAACW,KAAK;EACnC;;E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AQ,CAAC,EAChE,CAACF,OAAO,EAAE6B,YAAY,EAAE3B,QAAQ,CAClC,CAAC;EAED,MAAM8B,SAAS,GAAGlC,YAAY,CAAC8B,GAAG,EAAE3B,IAAI,EAAE8B,mBAAmB,CAAC;EAC9D,MAAMZ,cAAc,GAAGtB,OAAO,CAC5B,MAAMG,OAAO,CAACmB,cAAc,IAAI,EAAE,EAClC,CAACnB,OAAO,CAACmB,cAAc,CACzB,CAAC;EAED,OAAOtB,OAAO,CAAC,MAAgB;IAC7B,IAAImC,SAAS,EAAEd,KAAK,EAAE;MACpBD,aAAa,CAACe,SAAS,CAACd,KAAK,EAAEC,cAAc,CAAC;MAC9C,OAAOa,SAAS,CAACd,KAAK;IACxB;IACA,OAAO,IAAI;EACb,CAAC,EAAE,CAACC,cAAc,EAAEa,SAAS,CAAC,CAAC;AACjC,CAAC","ignoreList":[]}
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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IAAI;MACb;IACF;EACF;EACA,OAAO,KAAK;AACd,CAAC","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import { useLocale } from "./useI18n";
2
+ import { useMemo } from "react";
3
+
4
+ /**
5
+ * Generates the key that is used in the modular ui reducer of redux
6
+ */
7
+ export const useModularUIKey = (modelKey, url) => {
8
+ const locale = useLocale();
9
+ return useMemo(() => `${modelKey}(${url.split("?")[0]})(${locale})`, [modelKey, url, locale]);
10
+ };
11
+ //# sourceMappingURL=useModularUIKey.js.map
@@ -0,0 +1,14 @@
1
+ // @flow
2
+ import { useLocale } from "./useI18n";
3
+ import { useMemo } from "react";
4
+
5
+ /**
6
+ * Generates the key that is used in the modular ui reducer of redux
7
+ */
8
+ export const useModularUIKey = (modelKey: string, url: string): string => {
9
+ const locale = useLocale();
10
+ return useMemo(
11
+ () => `${modelKey}(${url.split("?")[0]})(${locale})`,
12
+ [modelKey, url, locale],
13
+ );
14
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useModularUIKey.js","names":["useLocale","useMemo","useModularUIKey","modelKey","url","locale","split"],"sources":["../../src/hooks/useModularUIKey.js"],"sourcesContent":["// @flow\nimport { useLocale } from \"./useI18n\";\nimport { useMemo } from \"react\";\n\n/**\n * Generates the key that is used in the modular ui reducer of redux\n */\nexport const useModularUIKey = (modelKey: string, url: string): string => {\n const locale = useLocale();\n return useMemo(\n () => `${modelKey}(${url.split(\"?\")[0]})(${locale})`,\n [modelKey, url, locale],\n );\n};\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,WAAW;AACrC,SAASC,OAAO,QAAQ,OAAO;;AAE/B;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAa;EACxE,MAAMC,MAAM,GAAGL,SAAS,CAAC,CAAC;EAC1B,OAAOC,OAAO,CACZ,MAAM,GAAGE,QAAQ,IAAIC,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKD,MAAM,GAAG,EACpD,CAACF,QAAQ,EAAEC,GAAG,EAAEC,MAAM,CACxB,CAAC;AACH,CAAC","ignoreList":[]}
@@ -38,11 +38,16 @@ const useUrl = (href, fromRoute = false) => {
38
38
  /**
39
39
  */
40
40
  export const usePanel = (href, options) => {
41
- const url = useUrl(href, options?.fromRoute || false);
41
+ const {
42
+ fromRoute,
43
+ ...hookOptions
44
+ } = options || {
45
+ fromRoute: false
46
+ };
47
+ const url = useUrl(href, fromRoute || false);
42
48
  const basicOptions = {
43
49
  expectedModels: ["List", "GroupingPanel", "Detail"],
44
- origin: options?.origin,
45
- contextPath: options?.contextPath
50
+ ...hookOptions
46
51
  };
47
52
  return useModularUIBasic("panel", url, basicOptions);
48
53
  };
@@ -65,11 +65,12 @@ export const usePanel = (
65
65
  href?: string | Href,
66
66
  options?: HookOptions & { fromRoute?: boolean },
67
67
  ): ListModel | GroupingPanelModel | DetailModel | null => {
68
- const url = useUrl(href, options?.fromRoute || false);
68
+ const { fromRoute, ...hookOptions } = options || { fromRoute: false };
69
+
70
+ const url = useUrl(href, fromRoute || false);
69
71
  const basicOptions = {
70
72
  expectedModels: ["List", "GroupingPanel", "Detail"],
71
- origin: options?.origin,
72
- contextPath: options?.contextPath,
73
+ ...(hookOptions: HookOptions),
73
74
  };
74
75
 
75
76
  return useModularUIBasic("panel", url, basicOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"usePanel.js","names":["useState","useMemo","useLocation","useRouteMatch","Href","useModularUIBasic","useUrl","href","fromRoute","previousUrl","setPreviousUrl","previousExact","setPreviousExact","match","location","_context","url","isExact","addParametersFromString","search","equalsWithParameters","shouldUpdate","Function","call","bind","_startsWithInstanceProperty","usePanel","options","basicOptions","expectedModels","origin","contextPath"],"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 type GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport type ListModel from \"../models/list/ListModel\";\nimport type DetailModel from \"../models/detail/DetailModel\";\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 url = useUrl(href, options?.fromRoute || false);\n const basicOptions = {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n origin: options?.origin,\n contextPath: options?.contextPath,\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;AAOvD,MAAMC,MAAM,GAAGA,CAACC,IAAoB,EAAEC,SAAkB,GAAG,KAAK,KAAK;EACnE,MAAM,CAACC,WAAW,EAAEC,cAA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KAAK,CAACI,OAAO,EACbJ,KAAK,CAACG,GAAG,EACTL,aAAa,EACbG,QAAQ,CAACK,MAAM,CAChB,CAAC;AACJ,CAAC;;AAED;AACA;AACA,OAAO,MAAMO,QAAQ,GAAGA,CACtBnB,IAAoB,EACpBoB,OAA+C,KACS;EACxD,MAAMX,GAAG,GAAGV,MAAM,CAACC,IAAI,EAAEoB,OAAO,EAAEnB,SAAS,IAAI,KAAK,CAAC;EACrD,MAAMoB,YAAY,GAAG;IACnBC,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,CAAC;IACnDC,MAAM,EAAEH,OAAO,EAAEG,MAAM;IACvBC,WAAW,EAAEJ,OAAO,EAAEI;EACxB,CAAC;EAED,OAAO1B,iBAAiB,CAAC,OAAO,EAAEW,GAAG,EAAEY,YAAY,CAAC;AACtD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"usePanel.js","names":["useState","useMemo","useLocation","useRouteMatch","Href","useModularUIBasic","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"],"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 type GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport type ListModel from \"../models/list/ListModel\";\nimport type DetailModel from \"../models/detail/DetailModel\";\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\"],\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;AAOvD,MAAMC,MAAM,GAAGA,CAACC,IAAoB,EAAEC,SAAkB,GAAG,KAAK,KAAK;EACnE,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGV,QAAQ,CAAC,IAAI,CAAC;EACpD,MAAM,CAACW,aAAa,EAAEC,gBAAgB,CAAC,GAAGZ,QAAQ,CAAC,KAAK,CAAC;EAEzD,MAAMa,KAAK,GAAGV,aAAa,CAAC,CAAC;EAC7B,MAAMW,QAAQ,GAAGZ,WAAW,CAAC,CAAC;EAE9B,OAAOD,OAAO,CAAC,MAAM;IAAA,IAAAc,QAAA;IACnB,IAAIR,IAAI,IAAI,IA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,MAAMQ,GAAG,GAAGV,MAAM,CAACC,IAAI,EAAEC,SAAS,IAAI,KAAK,CAAC;EAC5C,MAAMqB,YAAY,GAAG;IACnBC,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,CAAC;IACnD,GAAIF;EACN,CAAC;EAED,OAAOvB,iBAAiB,CAAC,OAAO,EAAEW,GAAG,EAAEa,YAAY,CAAC;AACtD,CAAC","ignoreList":[]}
@@ -237,7 +237,7 @@ class Href {
237
237
  * Remove a parameter from the parameter collection
238
238
  */
239
239
  removeParameter(name, prefix, value) {
240
- if (value !== undefined) {
240
+ if (value != undefined) {
241
241
  var _context4;
242
242
  const valueToRemove = value;
243
243
  this._parameters = _mapInstanceProperty(_context4 = this._parameters).call(_context4, param => {
@@ -281,7 +281,7 @@ class Href {
281
281
  * Remove a parameter from the parameter collection
282
282
  */
283
283
  removeParameter(name: string, prefix: ?string, value: ?string): Href {
284
- if (value !== undefined) {
284
+ if (value != undefined) {
285
285
  const valueToRemove = value;
286
286
 
287
287
  this._parameters = this._parameters.map((param) => {