@beinformed/ui 1.19.5 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/constants/Constants.js +5 -0
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/hooks/useContent.js +2 -6
  5. package/esm/hooks/useContent.js.map +1 -1
  6. package/esm/hooks/useI18n.js +10 -11
  7. package/esm/hooks/useI18n.js.map +1 -1
  8. package/esm/hooks/useModularUI.js +2 -3
  9. package/esm/hooks/useModularUI.js.map +1 -1
  10. package/esm/hooks/useModularUIRequest.js +2 -5
  11. package/esm/hooks/useModularUIRequest.js.map +1 -1
  12. package/esm/i18n/Message.js.map +1 -1
  13. package/esm/i18n/withMessage.js +2 -10
  14. package/esm/i18n/withMessage.js.map +1 -1
  15. package/esm/redux/_modularui/connector.js +3 -4
  16. package/esm/redux/_modularui/connector.js.map +1 -1
  17. package/esm/redux/_modularui/selectors.js +22 -5
  18. package/esm/redux/_modularui/selectors.js.map +1 -1
  19. package/esm/redux/_modularui/withModularUI.js +2 -10
  20. package/esm/redux/_modularui/withModularUI.js.map +1 -1
  21. package/esm/redux/actions/Application.js +26 -7
  22. package/esm/redux/actions/Application.js.map +1 -1
  23. package/esm/redux/selectors/i18n.js +16 -0
  24. package/esm/redux/selectors/i18n.js.map +1 -0
  25. package/esm/utils/datetime/DateTimeUtil.js +3 -1
  26. package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
  27. package/lib/constants/Constants.js +8 -2
  28. package/lib/constants/Constants.js.flow +5 -0
  29. package/lib/constants/Constants.js.map +1 -1
  30. package/lib/hooks/__tests__/useAuthentication.spec.js.flow +0 -8
  31. package/lib/hooks/useContent.js +3 -7
  32. package/lib/hooks/useContent.js.flow +2 -2
  33. package/lib/hooks/useContent.js.map +1 -1
  34. package/lib/hooks/useI18n.js +12 -9
  35. package/lib/hooks/useI18n.js.flow +10 -11
  36. package/lib/hooks/useI18n.js.map +1 -1
  37. package/lib/hooks/useModularUI.js +3 -3
  38. package/lib/hooks/useModularUI.js.flow +3 -2
  39. package/lib/hooks/useModularUI.js.map +1 -1
  40. package/lib/hooks/useModularUIRequest.js +2 -4
  41. package/lib/hooks/useModularUIRequest.js.flow +8 -10
  42. package/lib/hooks/useModularUIRequest.js.map +1 -1
  43. package/lib/i18n/Message.js.flow +1 -1
  44. package/lib/i18n/Message.js.map +1 -1
  45. package/lib/i18n/withMessage.js +2 -8
  46. package/lib/i18n/withMessage.js.flow +3 -4
  47. package/lib/i18n/withMessage.js.map +1 -1
  48. package/lib/redux/_modularui/connector.js +3 -3
  49. package/lib/redux/_modularui/connector.js.flow +3 -2
  50. package/lib/redux/_modularui/connector.js.map +1 -1
  51. package/lib/redux/_modularui/selectors.js +26 -6
  52. package/lib/redux/_modularui/selectors.js.flow +19 -1
  53. package/lib/redux/_modularui/selectors.js.map +1 -1
  54. package/lib/redux/_modularui/withModularUI.js +3 -9
  55. package/lib/redux/_modularui/withModularUI.js.flow +3 -5
  56. package/lib/redux/_modularui/withModularUI.js.map +1 -1
  57. package/lib/redux/actions/Application.js +31 -8
  58. package/lib/redux/actions/Application.js.flow +6 -8
  59. package/lib/redux/actions/Application.js.map +1 -1
  60. package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -5
  61. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +1 -1
  62. package/lib/redux/selectors/i18n.js +28 -0
  63. package/lib/redux/selectors/i18n.js.flow +15 -0
  64. package/lib/redux/selectors/i18n.js.map +1 -0
  65. package/lib/utils/datetime/DateTimeUtil.js +3 -1
  66. package/lib/utils/datetime/DateTimeUtil.js.flow +1 -1
  67. package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/constants/Constants.js +5 -0
  70. package/src/hooks/__tests__/useAuthentication.spec.js +0 -8
  71. package/src/hooks/useContent.js +2 -2
  72. package/src/hooks/useI18n.js +10 -11
  73. package/src/hooks/useModularUI.js +3 -2
  74. package/src/hooks/useModularUIRequest.js +8 -10
  75. package/src/i18n/Message.js +1 -1
  76. package/src/i18n/withMessage.js +3 -4
  77. package/src/redux/_modularui/connector.js +3 -2
  78. package/src/redux/_modularui/selectors.js +19 -1
  79. package/src/redux/_modularui/withModularUI.js +3 -5
  80. package/src/redux/actions/Application.js +6 -8
  81. package/src/redux/actions/__tests__/Application.spec.js +1 -5
  82. package/src/redux/actions/__tests__/Authorization.spec.js +1 -1
  83. package/src/redux/selectors/i18n.js +15 -0
  84. package/src/utils/datetime/DateTimeUtil.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","state","i18n","locale","localeCode","href","options","request","ModularUIRequest","useModularUIRequest","useSelector"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { RequestBaseOptions } from \"../utils\";\nimport type Href from \"../models/href/Href\";\n\nconst getModularUIRequest = createSelector(\n [(state) => state.i18n.locale ?? \"en\"],\n (localeCode) => {\n return (href: Href, options?: $Shape<RequestBaseOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n }\n);\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestBaseOptions>\n) => ModularUIRequest) => useSelector(getModularUIRequest);\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AAKA,IAAMA,mBAAmB,GAAG,IAAAC,wBAAA,EAC1B,CAAC,UAACC,KAAD;EAAA;;EAAA,6BAAWA,KAAK,CAACC,IAAN,CAAWC,MAAtB,mEAAgC,IAAhC;AAAA,CAAD,CAD0B,EAE1B,UAACC,UAAD,EAAgB;EACd,OAAO,UAACC,IAAD,EAAaC,OAAb,EAAsD;IAC3D,IAAMC,OAAO,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAhB;IACAC,OAAO,CAACJ,MAAR,GAAiBC,UAAjB;IACA,OAAOG,OAAP;EACD,CAJD;AAKD,CARyB,CAA5B;AAWA;AACA;AACA;;AACO,IAAME,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,OAGT,IAAAC,uBAAA,EAAYX,mBAAZ,CAHS;AAAA,CAA5B"}
1
+ {"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","getLocale","localeCode","href","options","request","ModularUIRequest","locale","useModularUIRequest","useSelector"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport type { RequestBaseOptions } from \"../utils\";\nimport type Href from \"../models/href/Href\";\n\nconst getModularUIRequest = createSelector([getLocale], (localeCode) => {\n return (href: Href, options?: $Shape<RequestBaseOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n});\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestBaseOptions>\n) => ModularUIRequest) => useSelector(getModularUIRequest);\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAKA,IAAMA,mBAAmB,GAAG,IAAAC,wBAAA,EAAe,CAACC,eAAD,CAAf,EAA4B,UAACC,UAAD,EAAgB;EACtE,OAAO,UAACC,IAAD,EAAaC,OAAb,EAAsD;IAC3D,IAAMC,OAAO,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAhB;IACAC,OAAO,CAACE,MAAR,GAAiBL,UAAjB;IACA,OAAOG,OAAP;EACD,CAJD;AAKD,CAN2B,CAA5B;AAQA;AACA;AACA;;AACO,IAAMG,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,OAGT,IAAAC,uBAAA,EAAYV,mBAAZ,CAHS;AAAA,CAA5B"}
@@ -6,7 +6,7 @@ import { useMessage } from "../hooks/useI18n";
6
6
 
7
7
  type MessageProps = {
8
8
  +className?: string,
9
- +id?: string | null,
9
+ +id: string,
10
10
  +defaultMessage?: string | null,
11
11
  +children?: string,
12
12
  +data?: Object | null,
@@ -1 +1 @@
1
- {"version":3,"file":"Message.js","names":["Message","memo","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","useMessage","styles","hideVisually","__html","displayName"],"sources":["../../src/i18n/Message.js"],"sourcesContent":["// @flow\nimport { memo } from \"react\";\nimport { hideVisually } from \"polished\";\n\nimport { useMessage } from \"../hooks/useI18n\";\n\ntype MessageProps = {\n +className?: string,\n +id?: string | null,\n +defaultMessage?: string | null,\n +children?: string,\n +data?: Object | null,\n +screenreaderOnly?: boolean,\n +allowHTML?: boolean,\n};\n\n/**\n * Message React component\n */\nconst Message: React$AbstractComponent<MessageProps, mixed> =\n memo<MessageProps>(\n ({\n className,\n id,\n defaultMessage,\n children,\n data,\n screenreaderOnly = false,\n allowHTML = false,\n }: MessageProps) => {\n const translatedMessage = useMessage(\n id,\n defaultMessage || children,\n data\n );\n\n if (screenreaderOnly) {\n const styles = {\n ...hideVisually(),\n };\n\n return (\n <span className={className} style={styles}>\n {translatedMessage}\n </span>\n );\n }\n\n if (allowHTML) {\n return (\n <span\n className={className}\n dangerouslySetInnerHTML={{\n __html: translatedMessage,\n }}\n />\n );\n }\n\n return <span className={className}>{translatedMessage}</span>;\n }\n );\n\nMessage.displayName = \"BI.Message\";\n\nexport default Message;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;;;AAYA;AACA;AACA;AACA,IAAMA,OAAqD,gBACzD,IAAAC,WAAA,EACE,gBAQoB;EAAA,IAPlBC,SAOkB,QAPlBA,SAOkB;EAAA,IANlBC,EAMkB,QANlBA,EAMkB;EAAA,IALlBC,cAKkB,QALlBA,cAKkB;EAAA,IAJlBC,QAIkB,QAJlBA,QAIkB;EAAA,IAHlBC,IAGkB,QAHlBA,IAGkB;EAAA,iCAFlBC,gBAEkB;EAAA,IAFlBA,gBAEkB,sCAFC,KAED;EAAA,0BADlBC,SACkB;EAAA,IADlBA,SACkB,+BADN,KACM;EAClB,IAAMC,iBAAiB,GAAG,IAAAC,mBAAA,EACxBP,EADwB,EAExBC,cAAc,IAAIC,QAFM,EAGxBC,IAHwB,CAA1B;;EAMA,IAAIC,gBAAJ,EAAsB;IACpB,IAAMI,MAAM,qBACP,IAAAC,sBAAA,GADO,CAAZ;;IAIA,oBACE;MAAM,SAAS,EAAEV,SAAjB;MAA4B,KAAK,EAAES,MAAnC;MAAA,UACGF;IADH,EADF;EAKD;;EAED,IAAID,SAAJ,EAAe;IACb,oBACE;MACE,SAAS,EAAEN,SADb;MAEE,uBAAuB,EAAE;QACvBW,MAAM,EAAEJ;MADe;IAF3B,EADF;EAQD;;EAED,oBAAO;IAAM,SAAS,EAAEP,SAAjB;IAAA,UAA6BO;EAA7B,EAAP;AACD,CAxCH,CADF;AA4CAT,OAAO,CAACc,WAAR,GAAsB,YAAtB;eAEed,O"}
1
+ {"version":3,"file":"Message.js","names":["Message","memo","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","useMessage","styles","hideVisually","__html","displayName"],"sources":["../../src/i18n/Message.js"],"sourcesContent":["// @flow\nimport { memo } from \"react\";\nimport { hideVisually } from \"polished\";\n\nimport { useMessage } from \"../hooks/useI18n\";\n\ntype MessageProps = {\n +className?: string,\n +id: string,\n +defaultMessage?: string | null,\n +children?: string,\n +data?: Object | null,\n +screenreaderOnly?: boolean,\n +allowHTML?: boolean,\n};\n\n/**\n * Message React component\n */\nconst Message: React$AbstractComponent<MessageProps, mixed> =\n memo<MessageProps>(\n ({\n className,\n id,\n defaultMessage,\n children,\n data,\n screenreaderOnly = false,\n allowHTML = false,\n }: MessageProps) => {\n const translatedMessage = useMessage(\n id,\n defaultMessage || children,\n data\n );\n\n if (screenreaderOnly) {\n const styles = {\n ...hideVisually(),\n };\n\n return (\n <span className={className} style={styles}>\n {translatedMessage}\n </span>\n );\n }\n\n if (allowHTML) {\n return (\n <span\n className={className}\n dangerouslySetInnerHTML={{\n __html: translatedMessage,\n }}\n />\n );\n }\n\n return <span className={className}>{translatedMessage}</span>;\n }\n );\n\nMessage.displayName = \"BI.Message\";\n\nexport default Message;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;;;AAYA;AACA;AACA;AACA,IAAMA,OAAqD,gBACzD,IAAAC,WAAA,EACE,gBAQoB;EAAA,IAPlBC,SAOkB,QAPlBA,SAOkB;EAAA,IANlBC,EAMkB,QANlBA,EAMkB;EAAA,IALlBC,cAKkB,QALlBA,cAKkB;EAAA,IAJlBC,QAIkB,QAJlBA,QAIkB;EAAA,IAHlBC,IAGkB,QAHlBA,IAGkB;EAAA,iCAFlBC,gBAEkB;EAAA,IAFlBA,gBAEkB,sCAFC,KAED;EAAA,0BADlBC,SACkB;EAAA,IADlBA,SACkB,+BADN,KACM;EAClB,IAAMC,iBAAiB,GAAG,IAAAC,mBAAA,EACxBP,EADwB,EAExBC,cAAc,IAAIC,QAFM,EAGxBC,IAHwB,CAA1B;;EAMA,IAAIC,gBAAJ,EAAsB;IACpB,IAAMI,MAAM,qBACP,IAAAC,sBAAA,GADO,CAAZ;;IAIA,oBACE;MAAM,SAAS,EAAEV,SAAjB;MAA4B,KAAK,EAAES,MAAnC;MAAA,UACGF;IADH,EADF;EAKD;;EAED,IAAID,SAAJ,EAAe;IACb,oBACE;MACE,SAAS,EAAEN,SADb;MAEE,uBAAuB,EAAE;QACvBW,MAAM,EAAEJ;MADe;IAF3B,EADF;EAQD;;EAED,oBAAO;IAAM,SAAS,EAAEP,SAAjB;IAAA,UAA6BO;EAA7B,EAAP;AACD,CAxCH,CADF;AA4CAT,OAAO,CAACc,WAAR,GAAsB,YAAtB;eAEed,O"}
@@ -15,15 +15,9 @@ var _reselect = require("reselect");
15
15
 
16
16
  var _memoize = _interopRequireDefault(require("lodash/memoize"));
17
17
 
18
- var getLocaleCode = function getLocaleCode(state) {
19
- return state.i18n.locale || "en";
20
- };
21
-
22
- var getLocales = function getLocales(state) {
23
- return state.i18n.locales;
24
- };
18
+ var _i18n = require("../redux/selectors/i18n");
25
19
 
26
- var getMessage = (0, _reselect.createSelector)([getLocales, getLocaleCode], function (locales, localeCode) {
20
+ var getMessage = (0, _reselect.createSelector)([_i18n.getLocales, _i18n.getLocale], function (locales, localeCode) {
27
21
  return (0, _memoize.default)(function (id, defaultMessage, placeholders) {
28
22
  return locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders);
29
23
  }, function () {
@@ -4,6 +4,8 @@ import { connect } from "react-redux";
4
4
  import { createSelector } from "reselect";
5
5
  import memoize from "lodash/memoize";
6
6
 
7
+ import { getLocales, getLocale } from "../redux/selectors/i18n";
8
+
7
9
  import type { ReduxState } from "../redux/types";
8
10
  import type { ComponentType } from "react";
9
11
 
@@ -20,11 +22,8 @@ type Props = {
20
22
  ...
21
23
  };
22
24
 
23
- const getLocaleCode = (state) => state.i18n.locale || "en";
24
- const getLocales = (state) => state.i18n.locales;
25
-
26
25
  const getMessage = createSelector(
27
- [getLocales, getLocaleCode],
26
+ [getLocales, getLocale],
28
27
  (locales, localeCode) =>
29
28
  memoize(
30
29
  (id: string, defaultMessage?: string, placeholders?: Object) =>
@@ -1 +1 @@
1
- {"version":3,"file":"withMessage.js","names":["getLocaleCode","state","i18n","locale","getLocales","locales","getMessage","createSelector","localeCode","memoize","id","defaultMessage","placeholders","getLocale","args","mapStateToProps","message","withMessage","connect"],"sources":["../../src/i18n/withMessage.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport type { ReduxState } from \"../redux/types\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n +message: (\n id: string,\n defaultMessage: string,\n placeholders: { ... }\n ) => string,\n};\n\ntype Props = {\n ...StateProps,\n ...\n};\n\nconst getLocaleCode = (state) => state.i18n.locale || \"en\";\nconst getLocales = (state) => state.i18n.locales;\n\nconst getMessage = createSelector(\n [getLocales, getLocaleCode],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args)\n )\n);\n\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n message: getMessage(state),\n});\n\n/**\n */\nconst withMessage: ComponentType<any> = connect<Props, {}, StateProps, _, _, _>(\n mapStateToProps\n);\n\nexport default withMessage;\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AAkBA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;EAAA,OAAWA,KAAK,CAACC,IAAN,CAAWC,MAAX,IAAqB,IAAhC;AAAA,CAAtB;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACH,KAAD;EAAA,OAAWA,KAAK,CAACC,IAAN,CAAWG,OAAtB;AAAA,CAAnB;;AAEA,IAAMC,UAAU,GAAG,IAAAC,wBAAA,EACjB,CAACH,UAAD,EAAaJ,aAAb,CADiB,EAEjB,UAACK,OAAD,EAAUG,UAAV;EAAA,OACE,IAAAC,gBAAA,EACE,UAACC,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEP,OAAO,CACJQ,SADH,CACaL,UADb,EAEGF,UAFH,CAEcI,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADF,EAKE;IAAA,kCAAIE,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CALF,CADF;AAAA,CAFiB,CAAnB;;AAYA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACd,KAAD;EAAA,OAAoC;IAC1De,OAAO,EAAEV,UAAU,CAACL,KAAD;EADuC,CAApC;AAAA,CAAxB;AAIA;AACA;;;AACA,IAAMgB,WAA+B,GAAG,IAAAC,mBAAA,EACtCH,eADsC,CAAxC;eAIeE,W"}
1
+ {"version":3,"file":"withMessage.js","names":["getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","mapStateToProps","state","message","withMessage","connect"],"sources":["../../src/i18n/withMessage.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\n\nimport type { ReduxState } from \"../redux/types\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n +message: (\n id: string,\n defaultMessage: string,\n placeholders: { ... }\n ) => string,\n};\n\ntype Props = {\n ...StateProps,\n ...\n};\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args)\n )\n);\n\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n message: getMessage(state),\n});\n\n/**\n */\nconst withMessage: ComponentType<any> = connect<Props, {}, StateProps, _, _, _>(\n mapStateToProps\n);\n\nexport default withMessage;\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAkBA,IAAMA,UAAU,GAAG,IAAAC,wBAAA,EACjB,CAACC,gBAAD,EAAaC,eAAb,CADiB,EAEjB,UAACC,OAAD,EAAUC,UAAV;EAAA,OACE,IAAAC,gBAAA,EACE,UAACC,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEL,OAAO,CACJD,SADH,CACaE,UADb,EAEGL,UAFH,CAEcO,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADF,EAKE;IAAA,kCAAIC,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CALF,CADF;AAAA,CAFiB,CAAnB;;AAYA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;EAAA,OAAoC;IAC1DC,OAAO,EAAEb,UAAU,CAACY,KAAD;EADuC,CAApC;AAAA,CAAxB;AAIA;AACA;;;AACA,IAAME,WAA+B,GAAG,IAAAC,mBAAA,EACtCJ,eADsC,CAAxC;eAIeG,W"}
@@ -37,6 +37,8 @@ var _modularuiUtils = require("./modularuiUtils");
37
37
 
38
38
  var _useModularUI = require("../../hooks/useModularUI");
39
39
 
40
+ var _useI18n = require("../../hooks/useI18n");
41
+
40
42
  var _jsxRuntime = require("react/jsx-runtime");
41
43
 
42
44
  var _excluded = ["propName", "removeOnUnmount"];
@@ -100,9 +102,7 @@ var connector = function connector(name, resource) {
100
102
  };
101
103
  }, [dispatch, modelKey]); // Create new properties object to inject modularui properties to own props
102
104
 
103
- var locale = (0, _reactRedux.useSelector)(function (state) {
104
- return state.i18n.locale;
105
- });
105
+ var locale = (0, _useI18n.useLocale)();
106
106
  var newProps = (_newProps = {
107
107
  modelKey: modelKey
108
108
  }, (0, _defineProperty2.default)(_newProps, propName, modelEntry ? modelEntry.model : null), (0, _defineProperty2.default)(_newProps, "location", location), (0, _defineProperty2.default)(_newProps, "status", modelEntry ? modelEntry.status : null), (0, _defineProperty2.default)(_newProps, "lastModification", modelEntry ? modelEntry.lastModification : null), (0, _defineProperty2.default)(_newProps, "hasModel", Boolean(modelEntry)), (0, _defineProperty2.default)(_newProps, "locale", locale), (0, _defineProperty2.default)(_newProps, "fetchModularUI", handleFetch), (0, _defineProperty2.default)(_newProps, "reloadModel", handleManualReload), _newProps);
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import { useEffect } from "react";
3
- import { useDispatch, useSelector } from "react-redux";
3
+ import { useDispatch } from "react-redux";
4
4
  import { useLocation } from "react-router";
5
5
 
6
6
  import { loadModularUI, reloadModel, removeModelByKey } from "./actions";
@@ -10,6 +10,7 @@ import { getDisplayName } from "../../react/utils";
10
10
 
11
11
  import { useUrl, useReload } from "./modularuiUtils";
12
12
  import { useModularUI } from "../../hooks/useModularUI";
13
+ import { useLocale } from "../../hooks/useI18n";
13
14
 
14
15
  import type { ComponentType, Node } from "react";
15
16
  import type { Location } from "react-router";
@@ -88,7 +89,7 @@ const connector = (
88
89
  }, [dispatch, modelKey]);
89
90
 
90
91
  // Create new properties object to inject modularui properties to own props
91
- const locale = useSelector((state) => state.i18n.locale);
92
+ const locale = useLocale();
92
93
  const newProps: InjectedProps = {
93
94
  modelKey,
94
95
  [propName]: modelEntry ? modelEntry.model : null,
@@ -1 +1 @@
1
- {"version":3,"file":"connector.js","names":["connector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","useSelector","i18n","newProps","status","lastModification","Boolean"],"sources":["../../../src/redux/_modularui/connector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { loadModularUI, reloadModel, removeModelByKey } from \"./actions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./modularuiUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\n/**\n */\nconst connector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false }\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(loadModularUI(modelKey, href, fetchOptions));\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, { ...otherOptions, isReload: true })\n );\n }\n }, [dispatch, doReload, url, modelKey]);\n\n // Remove model when hoc unloads\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(modelKey));\n }\n };\n }, [dispatch, modelKey]);\n\n // Create new properties object to inject modularui properties to own props\n const locale = useSelector((state) => state.i18n.locale);\n const newProps: InjectedProps = {\n modelKey,\n [propName]: modelEntry ? modelEntry.model : null,\n location,\n status: modelEntry ? modelEntry.status : null,\n lastModification: modelEntry ? modelEntry.lastModification : null,\n hasModel: Boolean(modelEntry),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.modularui(${getDisplayName(\n WrappedComponent,\n name\n )}`;\n\n return WrappedComponent;\n };\n};\n\nexport default connector;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;;;;;;;;;AAmBA;AACA;AACA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAChBC,IADgB,EAEhBC,QAFgB,EAI8C;EAAA,IAD9DC,OAC8D,uEADlC;IAAEC,QAAQ,EAAE,MAAZ;IAAoBC,eAAe,EAAE;EAArC,CACkC;EAC9D,wBAIIF,OAJJ,CACEC,QADF;EAAA,IACEA,QADF,kCACa,MADb;EAAA,4BAIID,OAJJ,CAEEE,eAFF;EAAA,IAEEA,eAFF,sCAEoB,KAFpB;EAAA,IAGKC,YAHL,0CAIIH,OAJJ;EAMA,OAAO,UAACI,SAAD,EAAmC;IACxC,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD,EAAgB;MAAA;;MACvC,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;MACA,IAAMC,QAAQ,GAAG,IAAAC,wBAAA,GAAjB;MAEA,IAAMC,GAAG,GAAG,IAAAC,sBAAA,EAAOb,QAAP;QAAmBU,QAAQ,EAARA;MAAnB,GAAgCH,KAAhC,EAAZ;MACA,IAAMO,WAAW,GAAG,IAAAC,qBAAA,EAAeV,SAAf,EAA0BN,IAA1B,EAAgCQ,KAAK,CAACS,SAAtC,CAApB,CALuC,CAOvC;;MACA,IAAMC,UAAU,GAAG,IAAAC,0BAAA,EAAaJ,WAAb,EAA0BF,GAA1B,EAA+BR,YAA/B,CAAnB;MACA,IAAMe,QAAQ,GAAGF,UAAH,aAAGA,UAAH,4CAAGA,UAAU,CAAEG,KAAf,sDAAG,kBAAmBC,UAApC,CATuC,CAWvC;;MACA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CACzBF,KADyB,EAEzBG,aAFyB,EAGtB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B,IAFjB,wDAG3BV,QAH2B,sDAInBO,UAAU,GAAGA,UAAU,CAACuB,MAAd,GAAuB,IAJd,gEAKTvB,UAAU,GAAGA,UAAU,CAACwB,gBAAd,GAAiC,IALlC,wDAMjBC,OAAO,CAACzB,UAAD,CANU,sDAO3BmB,MAP2B,8DAQXX,WARW,2DASdH,kBATc,aAA7B;MAYA,oBAAO,qBAAC,SAAD,kCAAef,KAAf,GAA0BgC,QAA1B,EAAP;IACD,CA5DD;;IA8DAjC,gBAAgB,CAACQ,WAAjB,0BAA+C,IAAAC,qBAAA,EAC7CT,gBAD6C,EAE7CP,IAF6C,CAA/C;IAKA,OAAOO,gBAAP;EACD,CArED;AAsED,CAjFD;;eAmFeR,S"}
1
+ {"version":3,"file":"connector.js","names":["connector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","useLocale","newProps","status","lastModification","Boolean"],"sources":["../../../src/redux/_modularui/connector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { loadModularUI, reloadModel, removeModelByKey } from \"./actions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./modularuiUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\n/**\n */\nconst connector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false }\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(loadModularUI(modelKey, href, fetchOptions));\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, { ...otherOptions, isReload: true })\n );\n }\n }, [dispatch, doReload, url, modelKey]);\n\n // Remove model when hoc unloads\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(modelKey));\n }\n };\n }, [dispatch, modelKey]);\n\n // Create new properties object to inject modularui properties to own props\n const locale = useLocale();\n const newProps: InjectedProps = {\n modelKey,\n [propName]: modelEntry ? modelEntry.model : null,\n location,\n status: modelEntry ? modelEntry.status : null,\n lastModification: modelEntry ? modelEntry.lastModification : null,\n hasModel: Boolean(modelEntry),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.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,GAAGA,UAAU,CAACuB,gBAAd,GAAiC,IALlC,wDAMjBC,OAAO,CAACxB,UAAD,CANU,sDAO3BmB,MAP2B,8DAQXX,WARW,2DASdH,kBATc,aAA7B;MAYA,oBAAO,qBAAC,SAAD,kCAAef,KAAf,GAA0B+B,QAA1B,EAAP;IACD,CA5DD;;IA8DAhC,gBAAgB,CAACQ,WAAjB,0BAA+C,IAAAC,qBAAA,EAC7CT,gBAD6C,EAE7CP,IAF6C,CAA/C;IAKA,OAAOO,gBAAP;EACD,CArED;AAsED,CAjFD;;eAmFeR,S"}
@@ -15,7 +15,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
15
15
  Object.defineProperty(exports, "__esModule", {
16
16
  value: true
17
17
  });
18
- exports.modelByHref = exports.keyByHref = exports.getTab = exports.getPreference = exports.getModelsByType = exports.getForm = exports.getFirstModelByInstance = exports.getCaseView = exports.getApplication = exports.getAllModelsByInstance = exports.getActiveModels = exports.getActiveModelByInstance = void 0;
18
+ exports.modelByHref = exports.keyByHref = exports.getTab = exports.getPreference = exports.getModelsByType = exports.getForm = exports.getFirstModelByInstance = exports.getCaseView = exports.getApplication = exports.getAllModelsByInstance = exports.getActiveModels = exports.getActiveModelByInstance = exports.allKeysByHref = void 0;
19
19
 
20
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
21
21
 
@@ -221,11 +221,31 @@ var keyByHref = function keyByHref(state, href) {
221
221
  return null;
222
222
  };
223
223
  /**
224
+ * Returns all model keys found in the store, restrict on href
224
225
  */
225
226
 
226
227
 
227
228
  exports.keyByHref = keyByHref;
228
229
 
230
+ var allKeysByHref = function allKeysByHref(state, href) {
231
+ if (state && state.modularui) {
232
+ var _context7;
233
+
234
+ var findHref = href instanceof _Href.default ? href : new _Href.default(href);
235
+ return (0, _filter.default)(_context7 = (0, _keys.default)(state.modularui)).call(_context7, function (key) {
236
+ var model = state.modularui[key].model;
237
+ return model && model.selfhref && model.selfhref.equals(findHref);
238
+ });
239
+ }
240
+
241
+ return [];
242
+ };
243
+ /**
244
+ */
245
+
246
+
247
+ exports.allKeysByHref = allKeysByHref;
248
+
229
249
  var getLocation = function getLocation(state) {
230
250
  var _state$router;
231
251
 
@@ -274,9 +294,9 @@ var getActiveModels = (0, _reselect.createSelectorCreator)(_reselect.defaultMemo
274
294
  if (location) {
275
295
  var locationParts = location.split("/");
276
296
  locationParts.reduce(function (accumulator, current) {
277
- var _context7;
297
+ var _context8;
278
298
 
279
- var path = (0, _concat.default)(_context7 = "".concat(accumulator, "/")).call(_context7, current); // Remove modelcatalog part to match breadcrumb parts
299
+ var path = (0, _concat.default)(_context8 = "".concat(accumulator, "/")).call(_context8, current); // Remove modelcatalog part to match breadcrumb parts
280
300
 
281
301
  var comparePath = decodeURIComponent(path).replace("/modelcatalog/", "/");
282
302
  var foundEntry = (0, _find.default)(models).call(models, function (model) {
@@ -325,11 +345,11 @@ exports.getPreference = getPreference;
325
345
 
326
346
  var getModelsByType = function getModelsByType(state, type) {
327
347
  if (state && state.modularui) {
328
- var _context8, _context9;
348
+ var _context9, _context10;
329
349
 
330
- return (0, _map.default)(_context8 = (0, _filter.default)(_context9 = (0, _keys.default)(state.modularui)).call(_context9, function (key) {
350
+ return (0, _map.default)(_context9 = (0, _filter.default)(_context10 = (0, _keys.default)(state.modularui)).call(_context10, function (key) {
331
351
  return state.modularui[key] && state.modularui[key].model && state.modularui[key].model.type === type;
332
- })).call(_context8, function (key) {
352
+ })).call(_context9, function (key) {
333
353
  return state.modularui[key].model;
334
354
  });
335
355
  }
@@ -150,7 +150,6 @@ export const keyByHref = (state: ReduxState, href: Href | string): ?string => {
150
150
 
151
151
  return Object.keys(state.modularui).find((key) => {
152
152
  const { model } = state.modularui[key];
153
-
154
153
  return model && model.selfhref && model.selfhref.equals(findHref);
155
154
  });
156
155
  }
@@ -158,6 +157,25 @@ export const keyByHref = (state: ReduxState, href: Href | string): ?string => {
158
157
  return null;
159
158
  };
160
159
 
160
+ /**
161
+ * Returns all model keys found in the store, restrict on href
162
+ */
163
+ export const allKeysByHref = (
164
+ state: ReduxState,
165
+ href: Href | string
166
+ ): Array<string> => {
167
+ if (state && state.modularui) {
168
+ const findHref = href instanceof Href ? href : new Href(href);
169
+
170
+ return Object.keys(state.modularui).filter((key) => {
171
+ const { model } = state.modularui[key];
172
+ return model && model.selfhref && model.selfhref.equals(findHref);
173
+ });
174
+ }
175
+
176
+ return [];
177
+ };
178
+
161
179
  /**
162
180
  */
163
181
  const getLocation = (state): string => state?.router?.location.pathname;
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.js","names":["getAllModelsByInstance","state","instance","locale","i18n","modularui","key","model","getFirstModelByInstance","getActiveModelByInstance","location","getLocation","selfhref","path","getApplication","ApplicationModel","getTab","TabModel","getCaseView","CaseViewModel","getForm","FormModel","modelByHref","href","findHref","Href","modelConfigKey","equals","keyByHref","router","pathname","getModels","models","forEach","modelKey","modelEntry","has","label","type","modelInfo","selfContentLink","ContentModel","ContentTOCModel","push","getActiveModels","createSelectorCreator","defaultMemoize","value","other","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType"],"sources":["../../../src/redux/_modularui/selectors.js"],"sourcesContent":["// @flow\nimport { createSelectorCreator, defaultMemoize } from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n */\nconst getLocation = (state): string => state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other)\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\"\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath)\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAKA;AACA;AACO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,CACpCC,KADoC,EAEpCC,QAFoC,EAGV;EAAA;;EAC1B,IAAMC,MAAM,GAAG,CAAAF,KAAK,SAAL,IAAAA,KAAK,WAAL,2BAAAA,KAAK,CAAEG,IAAP,4DAAaD,MAAb,KAAuB,IAAtC;EACA,IAAME,SAAS,GAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,SAAzB;;EAEA,IAAIA,SAAJ,EAAe;IAAA;;IACb,OAAO,iFAAYA,SAAZ,mBACG,UAACC,GAAD,EAAS;MACf,IAAQC,KAAR,GAAkBF,SAAS,CAACC,GAAD,CAA3B,CAAQC,KAAR;MACA,OAAOA,KAAK,YAAYL,QAAjB,IAA6BK,KAAK,CAACJ,MAAN,KAAiBA,MAArD;IACD,CAJI,kBAKA,UAACG,GAAD;MAAA,OAASD,SAAS,CAACC,GAAD,CAAT,CAAeC,KAAxB;IAAA,CALA,CAAP;EAMD;;EAED,OAAO,EAAP;AACD,CAjBM;AAm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ACA;;;;AACO,IAAMY,aAAa,GAAG,SAAhBA,aAAgB,CAC3B5D,KAD2B,EAE3B6D,cAF2B,EAGA;EAC3B,IAAI7D,KAAK,IAAIA,KAAK,CAAC8D,WAAnB,EAAgC;IAC9B,OAAO9D,KAAK,CAAC8D,WAAN,CAAkBD,cAAlB,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CATM;AAWP;AACA;AACA;;;;;AACO,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAC7B/D,KAD6B,EAE7BqC,IAF6B,EAGH;EAC1B,IAAIrC,KAAK,IAAIA,KAAK,CAACI,SAAnB,EAA8B;IAAA;;IAC5B,OAAO,kFAAYJ,KAAK,CAACI,SAAlB,mBAEH,UAACC,GAAD;MAAA,OACEL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,KACAL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KADrB,IAEAN,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAArB,CAA2B+B,IAA3B,KAAoCA,IAHtC;IAAA,CAFG,mBAOA,UAAChC,GAAD;MAAA,OAASL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAA9B;IAAA,CAPA,CAAP;EAQD;;EAED,OAAO,EAAP;AACD,CAhBM"}
1
+ {"version":3,"file":"selectors.js","names":["getAllModelsByInstance","state","instance","locale","i18n","modularui","key","model","getFirstModelByInstance","getActiveModelByInstance","location","getLocation","selfhref","path","getApplication","ApplicationModel","getTab","TabModel","getCaseView","CaseViewModel","getForm","FormModel","modelByHref","href","findHref","Href","modelConfigKey","equals","keyByHref","allKeysByHref","router","pathname","getModels","models","forEach","modelKey","modelEntry","has","label","type","modelInfo","selfContentLink","ContentModel","ContentTOCModel","push","getActiveModels","createSelectorCreator","defaultMemoize","value","other","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType"],"sources":["../../../src/redux/_modularui/selectors.js"],"sourcesContent":["// @flow\nimport { createSelectorCreator, defaultMemoize } from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state): string => state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other)\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\"\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath)\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;A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,CALE;AA6CP;AACA;;;;AACO,IAAMY,aAAa,GAAG,SAAhBA,aAAgB,CAC3B7D,KAD2B,EAE3B8D,cAF2B,EAGA;EAC3B,IAAI9D,KAAK,IAAIA,KAAK,CAAC+D,WAAnB,EAAgC;IAC9B,OAAO/D,KAAK,CAAC+D,WAAN,CAAkBD,cAAlB,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CATM;AAWP;AACA;AACA;;;;;AACO,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAC7BhE,KAD6B,EAE7BsC,IAF6B,EAGH;EAC1B,IAAItC,KAAK,IAAIA,KAAK,CAACI,SAAnB,EAA8B;IAAA;;IAC5B,OAAO,mFAAYJ,KAAK,CAACI,SAAlB,oBAEH,UAACC,GAAD;MAAA,OACEL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,KACAL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KADrB,IAEAN,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAArB,CAA2BgC,IAA3B,KAAoCA,IAHtC;IAAA,CAFG,mBAOA,UAACjC,GAAD;MAAA,OAASL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAA9B;IAAA,CAPA,CAAP;EAQD;;EAED,OAAO,EAAP;AACD,CAhBM"}
@@ -17,17 +17,11 @@ var _ProgressIndicator = require("../actions/ProgressIndicator");
17
17
 
18
18
  var _Error = require("../actions/Error");
19
19
 
20
- var _actions = require("./actions");
21
-
22
- /**
23
- */
24
- var getLocaleCode = function getLocaleCode(state) {
25
- var _state$i18n$locale;
20
+ var _i18n = require("../selectors/i18n");
26
21
 
27
- return (_state$i18n$locale = state.i18n.locale) !== null && _state$i18n$locale !== void 0 ? _state$i18n$locale : "en";
28
- };
22
+ var _actions = require("./actions");
29
23
 
30
- var modularui = (0, _reselect.createSelector)([getLocaleCode], function (localeCode) {
24
+ var modularui = (0, _reselect.createSelector)([_i18n.getLocale], function (localeCode) {
31
25
  return function (href) {
32
26
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
33
27
  var modularuiRequest = new _ModularUIRequest.default(href, options);
@@ -9,6 +9,8 @@ import { startProgress, finishProgress } from "../actions/ProgressIndicator";
9
9
 
10
10
  import { handleError } from "../actions/Error";
11
11
 
12
+ import { getLocale } from "../selectors/i18n";
13
+
12
14
  import { reloadModel } from "./actions";
13
15
 
14
16
  import type {
@@ -43,12 +45,8 @@ type Props = {
43
45
  ...DispatchProps,
44
46
  };
45
47
 
46
- /**
47
- */
48
- const getLocaleCode = (state) => state.i18n.locale ?? "en";
49
-
50
48
  const modularui = createSelector(
51
- [getLocaleCode],
49
+ [getLocale],
52
50
  (localeCode) =>
53
51
  (href, options = {}) => {
54
52
  const modularuiRequest = new ModularUIRequest(href, options);
@@ -1 +1 @@
1
- {"version":3,"file":"withModularUI.js","names":["getLocaleCode","state","i18n","locale","modularui","createSelector","localeCode","href","options","modularuiRequest","ModularUIRequest","mapStateToProps","mapDispatchToProps","startProgress","finishProgress","reloadModel","handleError","withModularui","connect"],"sources":["../../../src/redux/_modularui/withModularUI.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport { reloadModel } from \"./actions\";\n\nimport type {\n ReduxState,\n StartProgressAction,\n FinishProgressAction,\n ThunkAction,\n} from \"../types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { RequestBaseOptions } from \"../../utils/fetch/types\";\nimport type FetchException from \"../../exceptions/FetchException\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n modularui: (href: Href, options: any) => ModularUIRequest,\n locale: string,\n};\n\ntype DispatchProps = {\n startProgress: () => StartProgressAction,\n finishProgress: () => FinishProgressAction,\n reloadModel: (\n model: ModularUIModel,\n options?: RequestBaseOptions\n ) => ThunkAction,\n handleError: (error: Error | FetchException) => ThunkAction,\n};\n\ntype Props = {\n ...StateProps,\n ...DispatchProps,\n};\n\n/**\n */\nconst getLocaleCode = (state) => state.i18n.locale ?? \"en\";\n\nconst modularui = createSelector(\n [getLocaleCode],\n (localeCode) =>\n (href, options = {}) => {\n const modularuiRequest = new ModularUIRequest(href, options);\n modularuiRequest.locale = localeCode;\n return modularuiRequest;\n }\n);\n\n/**\n */\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n modularui: modularui(state),\n locale: state.i18n.locale,\n});\n\nconst mapDispatchToProps: DispatchProps = {\n startProgress,\n finishProgress,\n reloadModel,\n handleError,\n};\n\n/**\n * Injects the modular ui service and the progress start and finish actions\n * This can be used to request modular ui services inside react view components\n */\nconst withModularui: ComponentType<any> = connect<\n Props,\n {},\n StateProps,\n _,\n _,\n _\n>(mapStateToProps, mapDispatchToProps);\n\nexport default withModularui;\n"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAkCA;AACA;AACA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD;EAAA;;EAAA,6BAAWA,KAAK,CAACC,IAAN,CAAWC,MAAtB,mEAAgC,IAAhC;AAAA,CAAtB;;AAEA,IAAMC,SAAS,GAAG,IAAAC,wBAAA,EAChB,CAACL,aAAD,CADgB,EAEhB,UAACM,UAAD;EAAA,OACE,UAACC,IAAD,EAAwB;IAAA,IAAjBC,OAAiB,uEAAP,EAAO;IACtB,IAAMC,gBAAgB,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAzB;IACAC,gBAAgB,CAACN,MAAjB,GAA0BG,UAA1B;IACA,OAAOG,gBAAP;EACD,CALH;AAAA,CAFgB,CAAlB;AAUA;AACA;;AACA,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAACV,KAAD;EAAA,OAAoC;IAC1DG,SAAS,EAAEA,SAAS,CAACH,KAAD,CADsC;IAE1DE,MAAM,EAAEF,KAAK,CAACC,IAAN,CAAWC;EAFuC,CAApC;AAAA,CAAxB;;AAKA,IAAMS,kBAAiC,GAAG;EACxCC,aAAa,EAAbA,gCADwC;EAExCC,cAAc,EAAdA,iCAFwC;EAGxCC,WAAW,EAAXA,oBAHwC;EAIxCC,WAAW,EAAXA;AAJwC,CAA1C;AAOA;AACA;AACA;AACA;;AACA,IAAMC,aAAiC,GAAG,IAAAC,mBAAA,EAOxCP,eAPwC,EAOvBC,kBAPuB,CAA1C;eASeK,a"}
1
+ {"version":3,"file":"withModularUI.js","names":["modularui","createSelector","getLocale","localeCode","href","options","modularuiRequest","ModularUIRequest","locale","mapStateToProps","state","i18n","mapDispatchToProps","startProgress","finishProgress","reloadModel","handleError","withModularui","connect"],"sources":["../../../src/redux/_modularui/withModularUI.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport { getLocale } from \"../selectors/i18n\";\n\nimport { reloadModel } from \"./actions\";\n\nimport type {\n ReduxState,\n StartProgressAction,\n FinishProgressAction,\n ThunkAction,\n} from \"../types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { RequestBaseOptions } from \"../../utils/fetch/types\";\nimport type FetchException from \"../../exceptions/FetchException\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n modularui: (href: Href, options: any) => ModularUIRequest,\n locale: string,\n};\n\ntype DispatchProps = {\n startProgress: () => StartProgressAction,\n finishProgress: () => FinishProgressAction,\n reloadModel: (\n model: ModularUIModel,\n options?: RequestBaseOptions\n ) => ThunkAction,\n handleError: (error: Error | FetchException) => ThunkAction,\n};\n\ntype Props = {\n ...StateProps,\n ...DispatchProps,\n};\n\nconst modularui = createSelector(\n [getLocale],\n (localeCode) =>\n (href, options = {}) => {\n const modularuiRequest = new ModularUIRequest(href, options);\n modularuiRequest.locale = localeCode;\n return modularuiRequest;\n }\n);\n\n/**\n */\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n modularui: modularui(state),\n locale: state.i18n.locale,\n});\n\nconst mapDispatchToProps: DispatchProps = {\n startProgress,\n finishProgress,\n reloadModel,\n handleError,\n};\n\n/**\n * Injects the modular ui service and the progress start and finish actions\n * This can be used to request modular ui services inside react view components\n */\nconst withModularui: ComponentType<any> = connect<\n Props,\n {},\n StateProps,\n _,\n _,\n _\n>(mapStateToProps, mapDispatchToProps);\n\nexport default withModularui;\n"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAkCA,IAAMA,SAAS,GAAG,IAAAC,wBAAA,EAChB,CAACC,eAAD,CADgB,EAEhB,UAACC,UAAD;EAAA,OACE,UAACC,IAAD,EAAwB;IAAA,IAAjBC,OAAiB,uEAAP,EAAO;IACtB,IAAMC,gBAAgB,GAAG,IAAIC,yBAAJ,CAAqBH,IAArB,EAA2BC,OAA3B,CAAzB;IACAC,gBAAgB,CAACE,MAAjB,GAA0BL,UAA1B;IACA,OAAOG,gBAAP;EACD,CALH;AAAA,CAFgB,CAAlB;AAUA;AACA;;AACA,IAAMG,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;EAAA,OAAoC;IAC1DV,SAAS,EAAEA,SAAS,CAACU,KAAD,CADsC;IAE1DF,MAAM,EAAEE,KAAK,CAACC,IAAN,CAAWH;EAFuC,CAApC;AAAA,CAAxB;;AAKA,IAAMI,kBAAiC,GAAG;EACxCC,aAAa,EAAbA,gCADwC;EAExCC,cAAc,EAAdA,iCAFwC;EAGxCC,WAAW,EAAXA,oBAHwC;EAIxCC,WAAW,EAAXA;AAJwC,CAA1C;AAOA;AACA;AACA;AACA;;AACA,IAAMC,aAAiC,GAAG,IAAAC,mBAAA,EAOxCT,eAPwC,EAOvBG,kBAPuB,CAA1C;eASeK,a"}
@@ -1,5 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
4
+
5
+ var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
6
+
7
+ var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
8
+
9
+ var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
10
+
3
11
  Object.defineProperty(exports, "__esModule", {
4
12
  value: true
5
13
  });
@@ -11,20 +19,35 @@ var _selectors = require("../_modularui/selectors");
11
19
 
12
20
  var _models = require("../../models");
13
21
 
22
+ var _i18n = require("../selectors/i18n");
23
+
24
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
25
+
26
+ function _unsupportedIterableToArray(o, minLen) { var _context; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context = Object.prototype.toString.call(o)).call(_context, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
+
28
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
29
+
14
30
  /**
15
31
  */
16
32
  var reloadApplication = function reloadApplication() {
17
33
  return function (dispatch, getState) {
18
- var modelKey = (0, _selectors.keyByHref)(getState(), "/");
19
-
20
- if (!modelKey) {
21
- var _getState$i18n;
22
-
23
- var locale = (_getState$i18n = getState().i18n) === null || _getState$i18n === void 0 ? void 0 : _getState$i18n.locale;
24
- modelKey = "application(/)(".concat(locale, ")");
34
+ var allKeys = (0, _selectors.allKeysByHref)(getState(), "/");
35
+
36
+ var _iterator = _createForOfIteratorHelper(allKeys),
37
+ _step;
38
+
39
+ try {
40
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
41
+ var key = _step.value;
42
+ dispatch((0, _actions.removeModelByKey)(key));
43
+ }
44
+ } catch (err) {
45
+ _iterator.e(err);
46
+ } finally {
47
+ _iterator.f();
25
48
  }
26
49
 
27
- dispatch((0, _actions.removeModelByKey)(modelKey));
50
+ var modelKey = "application(/)(".concat((0, _i18n.getLocale)(getState()), ")");
28
51
  return dispatch((0, _actions.loadModularUI)(modelKey, new _models.Href("/", "Application"), {
29
52
  targetModel: _models.ApplicationModel
30
53
  }));
@@ -1,7 +1,8 @@
1
1
  // @flow
2
2
  import { loadModularUI, removeModelByKey } from "../_modularui/actions";
3
- import { keyByHref } from "../_modularui/selectors";
3
+ import { allKeysByHref } from "../_modularui/selectors";
4
4
  import { ApplicationModel, Href } from "../../models";
5
+ import { getLocale } from "../selectors/i18n";
5
6
 
6
7
  import type { Dispatch, GetState, ThunkAction } from "../types";
7
8
 
@@ -9,15 +10,12 @@ import type { Dispatch, GetState, ThunkAction } from "../types";
9
10
  */
10
11
  export const reloadApplication =
11
12
  (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {
12
- let modelKey = keyByHref(getState(), "/");
13
-
14
- if (!modelKey) {
15
- const locale = getState().i18n?.locale;
16
- modelKey = `application(/)(${locale})`;
13
+ const allKeys = allKeysByHref(getState(), "/");
14
+ for (const key of allKeys) {
15
+ dispatch(removeModelByKey(key));
17
16
  }
18
17
 
19
- dispatch(removeModelByKey(modelKey));
20
-
18
+ const modelKey = `application(/)(${getLocale(getState())})`;
21
19
  return dispatch(
22
20
  loadModularUI(modelKey, new Href("/", "Application"), {
23
21
  targetModel: ApplicationModel,
@@ -1 +1 @@
1
- {"version":3,"file":"Application.js","names":["reloadApplication","dispatch","getState","modelKey","keyByHref","locale","i18n","removeModelByKey","loadModularUI","Href","targetModel","ApplicationModel"],"sources":["../../../src/redux/actions/Application.js"],"sourcesContent":["// @flow\nimport { loadModularUI, removeModelByKey } from \"../_modularui/actions\";\nimport { keyByHref } from \"../_modularui/selectors\";\nimport { ApplicationModel, Href } from \"../../models\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\n\n/**\n */\nexport const reloadApplication =\n (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {\n let modelKey = keyByHref(getState(), \"/\");\n\n if (!modelKey) {\n const locale = getState().i18n?.locale;\n modelKey = `application(/)(${locale})`;\n }\n\n dispatch(removeModelByKey(modelKey));\n\n return dispatch(\n loadModularUI(modelKey, new Href(\"/\", \"Application\"), {\n targetModel: ApplicationModel,\n })\n );\n };\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AAIA;AACA;AACO,IAAMA,iBAAiB,GAC5B,SADWA,iBACX;EAAA,OAAmB,UAACC,QAAD,EAAqBC,QAArB,EAA4C;IAC7D,IAAIC,QAAQ,GAAG,IAAAC,oBAAA,EAAUF,QAAQ,EAAlB,EAAsB,GAAtB,CAAf;;IAEA,IAAI,CAACC,QAAL,EAAe;MAAA;;MACb,IAAME,MAAM,qBAAGH,QAAQ,GAAGI,IAAd,mDAAG,eAAiBD,MAAhC;MACAF,QAAQ,4BAAqBE,MAArB,MAAR;IACD;;IAEDJ,QAAQ,CAAC,IAAAM,yBAAA,EAAiBJ,QAAjB,CAAD,CAAR;IAEA,OAAOF,QAAQ,CACb,IAAAO,sBAAA,EAAcL,QAAd,EAAwB,IAAIM,YAAJ,CAAS,GAAT,EAAc,aAAd,CAAxB,EAAsD;MACpDC,WAAW,EAAEC;IADuC,CAAtD,CADa,CAAf;EAKD,CAfD;AAAA,CADK"}
1
+ {"version":3,"file":"Application.js","names":["reloadApplication","dispatch","getState","allKeys","allKeysByHref","key","removeModelByKey","modelKey","getLocale","loadModularUI","Href","targetModel","ApplicationModel"],"sources":["../../../src/redux/actions/Application.js"],"sourcesContent":["// @flow\nimport { loadModularUI, removeModelByKey } from \"../_modularui/actions\";\nimport { allKeysByHref } from \"../_modularui/selectors\";\nimport { ApplicationModel, Href } from \"../../models\";\nimport { getLocale } from \"../selectors/i18n\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\n\n/**\n */\nexport const reloadApplication =\n (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {\n const allKeys = allKeysByHref(getState(), \"/\");\n for (const key of allKeys) {\n dispatch(removeModelByKey(key));\n }\n\n const modelKey = `application(/)(${getLocale(getState())})`;\n return dispatch(\n loadModularUI(modelKey, new Href(\"/\", \"Application\"), {\n targetModel: ApplicationModel,\n })\n );\n };\n"],"mappings":";;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAIA;AACA;AACO,IAAMA,iBAAiB,GAC5B,SADWA,iBACX;EAAA,OAAmB,UAACC,QAAD,EAAqBC,QAArB,EAA4C;IAC7D,IAAMC,OAAO,GAAG,IAAAC,wBAAA,EAAcF,QAAQ,EAAtB,EAA0B,GAA1B,CAAhB;;IAD6D,2CAE3CC,OAF2C;IAAA;;IAAA;MAE7D,oDAA2B;QAAA,IAAhBE,GAAgB;QACzBJ,QAAQ,CAAC,IAAAK,yBAAA,EAAiBD,GAAjB,CAAD,CAAR;MACD;IAJ4D;MAAA;IAAA;MAAA;IAAA;;IAM7D,IAAME,QAAQ,4BAAqB,IAAAC,eAAA,EAAUN,QAAQ,EAAlB,CAArB,MAAd;IACA,OAAOD,QAAQ,CACb,IAAAQ,sBAAA,EAAcF,QAAd,EAAwB,IAAIG,YAAJ,CAAS,GAAT,EAAc,aAAd,CAAxB,EAAsD;MACpDC,WAAW,EAAEC;IADuC,CAAtD,CADa,CAAf;EAKD,CAZD;AAAA,CADK"}
@@ -16,10 +16,6 @@ describe("application actions", () => {
16
16
  await store.dispatch(reloadApplication());
17
17
 
18
18
  expect(store.getActions()).toStrictEqual([
19
- {
20
- type: "MODULARUI/REMOVE_KEY",
21
- payload: "application(/)(en)",
22
- },
23
19
  {
24
20
  type: "MODULARUI/STATUS",
25
21
  payload: { key: "application(/)(en)", status: "LOADING" },
@@ -49,7 +45,7 @@ describe("application actions", () => {
49
45
  },
50
46
  {
51
47
  type: "MODULARUI/STATUS",
52
- payload: { key: "/", status: "LOADING" },
48
+ payload: { key: "application(/)(en)", status: "LOADING" },
53
49
  },
54
50
  { type: "START_PROGRESS" },
55
51
  expect.objectContaining({
@@ -45,7 +45,7 @@ describe("authorization actions", () => {
45
45
  },
46
46
  {
47
47
  type: "MODULARUI/STATUS",
48
- payload: { key: "/", status: "LOADING" },
48
+ payload: { key: "application(/)(en)", status: "LOADING" },
49
49
  },
50
50
  {
51
51
  type: "START_PROGRESS",
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLocales = exports.getLocale = void 0;
7
+
8
+ /**
9
+ * Retrieve the locale from state
10
+ */
11
+ var getLocale = function getLocale(state) {
12
+ var _state$i18n$locale, _state$i18n;
13
+
14
+ return (_state$i18n$locale = (_state$i18n = state.i18n) === null || _state$i18n === void 0 ? void 0 : _state$i18n.locale) !== null && _state$i18n$locale !== void 0 ? _state$i18n$locale : "en";
15
+ };
16
+ /**
17
+ * Retrieve all available locales in the store
18
+ */
19
+
20
+
21
+ exports.getLocale = getLocale;
22
+
23
+ var getLocales = function getLocales(state) {
24
+ return state.i18n.locales;
25
+ };
26
+
27
+ exports.getLocales = getLocales;
28
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1,15 @@
1
+ // @flow
2
+ import type Locales from "../../i18n/Locales";
3
+ import type { ReduxState } from "../types";
4
+
5
+ /**
6
+ * Retrieve the locale from state
7
+ */
8
+ export const getLocale = (state: ReduxState): string => {
9
+ return state.i18n?.locale ?? "en";
10
+ };
11
+
12
+ /**
13
+ * Retrieve all available locales in the store
14
+ */
15
+ export const getLocales = (state: ReduxState): Locales => state.i18n.locales;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","names":["getLocale","state","i18n","locale","getLocales","locales"],"sources":["../../../src/redux/selectors/i18n.js"],"sourcesContent":["// @flow\nimport type Locales from \"../../i18n/Locales\";\nimport type { ReduxState } from \"../types\";\n\n/**\n * Retrieve the locale from state\n */\nexport const getLocale = (state: ReduxState): string => {\n return state.i18n?.locale ?? \"en\";\n};\n\n/**\n * Retrieve all available locales in the store\n */\nexport const getLocales = (state: ReduxState): Locales => state.i18n.locales;\n"],"mappings":";;;;;;;AAIA;AACA;AACA;AACO,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,KAAD,EAA+B;EAAA;;EACtD,4CAAOA,KAAK,CAACC,IAAb,gDAAO,YAAYC,MAAnB,mEAA6B,IAA7B;AACD,CAFM;AAIP;AACA;AACA;;;;;AACO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACH,KAAD;EAAA,OAAgCA,KAAK,CAACC,IAAN,CAAWG,OAA3C;AAAA,CAAnB"}