@beinformed/ui 1.20.0 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -2
- package/esm/hooks/useContent.js +2 -6
- package/esm/hooks/useContent.js.map +1 -1
- package/esm/hooks/useI18n.js +10 -11
- package/esm/hooks/useI18n.js.map +1 -1
- package/esm/hooks/useModularUI.js +2 -3
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIRequest.js +2 -5
- package/esm/hooks/useModularUIRequest.js.map +1 -1
- package/esm/i18n/Message.js.map +1 -1
- package/esm/i18n/withMessage.js +2 -10
- package/esm/i18n/withMessage.js.map +1 -1
- package/esm/redux/_modularui/connector.js +3 -4
- package/esm/redux/_modularui/connector.js.map +1 -1
- package/esm/redux/_modularui/selectors.js +22 -5
- package/esm/redux/_modularui/selectors.js.map +1 -1
- package/esm/redux/_modularui/withModularUI.js +2 -10
- package/esm/redux/_modularui/withModularUI.js.map +1 -1
- package/esm/redux/actions/Application.js +26 -7
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/selectors/i18n.js +16 -0
- package/esm/redux/selectors/i18n.js.map +1 -0
- package/esm/utils/datetime/DateTimeUtil.js +3 -1
- package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +0 -8
- package/lib/hooks/useContent.js +3 -7
- package/lib/hooks/useContent.js.flow +2 -2
- package/lib/hooks/useContent.js.map +1 -1
- package/lib/hooks/useI18n.js +12 -9
- package/lib/hooks/useI18n.js.flow +10 -11
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/hooks/useModularUI.js +3 -3
- package/lib/hooks/useModularUI.js.flow +3 -2
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIRequest.js +2 -4
- package/lib/hooks/useModularUIRequest.js.flow +8 -10
- package/lib/hooks/useModularUIRequest.js.map +1 -1
- package/lib/i18n/Message.js.flow +1 -1
- package/lib/i18n/Message.js.map +1 -1
- package/lib/i18n/withMessage.js +2 -8
- package/lib/i18n/withMessage.js.flow +3 -4
- package/lib/i18n/withMessage.js.map +1 -1
- package/lib/redux/_modularui/connector.js +3 -3
- package/lib/redux/_modularui/connector.js.flow +3 -2
- package/lib/redux/_modularui/connector.js.map +1 -1
- package/lib/redux/_modularui/selectors.js +26 -6
- package/lib/redux/_modularui/selectors.js.flow +19 -1
- package/lib/redux/_modularui/selectors.js.map +1 -1
- package/lib/redux/_modularui/withModularUI.js +3 -9
- package/lib/redux/_modularui/withModularUI.js.flow +3 -5
- package/lib/redux/_modularui/withModularUI.js.map +1 -1
- package/lib/redux/actions/Application.js +31 -8
- package/lib/redux/actions/Application.js.flow +6 -8
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -5
- package/lib/redux/actions/__tests__/Authorization.spec.js.flow +1 -1
- package/lib/redux/selectors/i18n.js +28 -0
- package/lib/redux/selectors/i18n.js.flow +15 -0
- package/lib/redux/selectors/i18n.js.map +1 -0
- package/lib/utils/datetime/DateTimeUtil.js +3 -1
- package/lib/utils/datetime/DateTimeUtil.js.flow +1 -1
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/__tests__/useAuthentication.spec.js +0 -8
- package/src/hooks/useContent.js +2 -2
- package/src/hooks/useI18n.js +10 -11
- package/src/hooks/useModularUI.js +3 -2
- package/src/hooks/useModularUIRequest.js +8 -10
- package/src/i18n/Message.js +1 -1
- package/src/i18n/withMessage.js +3 -4
- package/src/redux/_modularui/connector.js +3 -2
- package/src/redux/_modularui/selectors.js +19 -1
- package/src/redux/_modularui/withModularUI.js +3 -5
- package/src/redux/actions/Application.js +6 -8
- package/src/redux/actions/__tests__/Application.spec.js +1 -5
- package/src/redux/actions/__tests__/Authorization.spec.js +1 -1
- package/src/redux/selectors/i18n.js +15 -0
- package/src/utils/datetime/DateTimeUtil.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### [1.20.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.20.0...v1.20.1) (2022-06-21)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
6
8
|
|
|
9
|
+
- **i18n:** add useLocale hook and use generic getLocale selector ([acb5a3a](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/acb5a3a0a0d1c5576a3c985fea600c46cfe8bb26))
|
|
10
|
+
- **reload:** improve reload of application after locale switch ([c3c4c93](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/c3c4c93d5115381056c5af6a086a9b441d46586e))
|
|
11
|
+
|
|
12
|
+
## [1.20.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.19.5...v1.20.0) (2022-06-21)
|
|
7
13
|
|
|
8
14
|
### Features
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
- **Constants:** add administrator login path ([dd42692](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/dd426927e6fad5adb270b22b900d1d2f87b2cecb))
|
|
11
17
|
|
|
12
18
|
### [1.19.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.19.4...v1.19.5) (2022-06-17)
|
|
13
19
|
|
package/esm/hooks/useContent.js
CHANGED
|
@@ -4,10 +4,10 @@ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
|
4
4
|
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
5
5
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
6
6
|
import { useState, useEffect } from "react";
|
|
7
|
-
import { useSelector } from "react-redux";
|
|
8
7
|
import SourceReferenceCollection from "../models/concepts/SourceReferenceCollection";
|
|
9
8
|
import ModularUIRequest from "../modularui/ModularUIRequest";
|
|
10
9
|
import { useProgressIndicator } from "../hooks/useProgressIndicator";
|
|
10
|
+
import { useLocale } from "../hooks/useI18n";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Hook to retrieve multiple source references at once
|
|
@@ -20,11 +20,7 @@ export var useContentFromSourceReferences = function useContentFromSourceReferen
|
|
|
20
20
|
content = _useState2[0],
|
|
21
21
|
setContent = _useState2[1];
|
|
22
22
|
|
|
23
|
-
var localeCode =
|
|
24
|
-
var _state$i18n$locale;
|
|
25
|
-
|
|
26
|
-
return (_state$i18n$locale = state.i18n.locale) !== null && _state$i18n$locale !== void 0 ? _state$i18n$locale : "en";
|
|
27
|
-
});
|
|
23
|
+
var localeCode = useLocale();
|
|
28
24
|
|
|
29
25
|
var _useProgressIndicator = useProgressIndicator(),
|
|
30
26
|
start = _useProgressIndicator.start,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.js","names":["useState","useEffect","
|
|
1
|
+
{"version":3,"file":"useContent.js","names":["useState","useEffect","SourceReferenceCollection","ModularUIRequest","useProgressIndicator","useLocale","useContentFromSourceReferences","sourceReferences","renderChildSections","content","setContent","localeCode","start","finish","hrefs","sourceReference","link","selfhref","href","index","self","indexOf","toString","allHrefs","requests","JSON","parse","modularuiRequest","locale","fetchContent","all","then","responseContent"],"sources":["../../src/hooks/useContent.js"],"sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\n\nimport SourceReferenceCollection from \"../models/concepts/SourceReferenceCollection\";\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport { useProgressIndicator } from \"../hooks/useProgressIndicator\";\nimport { useLocale } from \"../hooks/useI18n\";\n\nimport type ContentModel from \"../models/content/ContentModel\";\n\n/**\n * Hook to retrieve multiple source references at once\n */\nexport const useContentFromSourceReferences = (\n sourceReferences: SourceReferenceCollection,\n renderChildSections: boolean\n): Array<ContentModel> => {\n const [content, setContent] = useState([]);\n const localeCode = useLocale();\n\n const { start, finish } = useProgressIndicator();\n\n const hrefs = sourceReferences\n .map((sourceReference) => sourceReference.link.selfhref.href)\n .filter((href, index, self) => self.indexOf(href) === index)\n .map((href) => href.toString());\n\n const allHrefs = JSON.stringify(hrefs);\n useEffect(() => {\n const requests = JSON.parse(allHrefs).map((href) => {\n const modularuiRequest = new ModularUIRequest(href);\n modularuiRequest.locale = localeCode;\n return modularuiRequest.fetchContent(renderChildSections);\n });\n\n start();\n Promise.all(requests).then((responseContent) => {\n setContent(responseContent);\n finish();\n });\n\n // start and finish don't change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allHrefs, localeCode, renderChildSections]);\n\n return content;\n};\n"],"mappings":";;;;;AACA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AAEA,OAAOC,yBAAP,MAAsC,8CAAtC;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AAEA,SAASC,oBAAT,QAAqC,+BAArC;AACA,SAASC,SAAT,QAA0B,kBAA1B;;AAIA;AACA;AACA;AACA,OAAO,IAAMC,8BAA8B,GAAG,SAAjCA,8BAAiC,CAC5CC,gBAD4C,EAE5CC,mBAF4C,EAGpB;EAAA;;EACxB,gBAA8BR,QAAQ,CAAC,EAAD,CAAtC;EAAA;EAAA,IAAOS,OAAP;EAAA,IAAgBC,UAAhB;;EACA,IAAMC,UAAU,GAAGN,SAAS,EAA5B;;EAEA,4BAA0BD,oBAAoB,EAA9C;EAAA,IAAQQ,KAAR,yBAAQA,KAAR;EAAA,IAAeC,MAAf,yBAAeA,MAAf;;EAEA,IAAMC,KAAK,GAAG,yFAAAP,gBAAgB,MAAhB,CAAAA,gBAAgB,EACvB,UAACQ,eAAD;IAAA,OAAqBA,eAAe,CAACC,IAAhB,CAAqBC,QAArB,CAA8BC,IAAnD;EAAA,CADuB,CAAhB,kBAEJ,UAACA,IAAD,EAAOC,KAAP,EAAcC,IAAd;IAAA,OAAuBA,IAAI,CAACC,OAAL,CAAaH,IAAb,MAAuBC,KAA9C;EAAA,CAFI,kBAGP,UAACD,IAAD;IAAA,OAAUA,IAAI,CAACI,QAAL,EAAV;EAAA,CAHO,CAAd;;EAKA,IAAMC,QAAQ,GAAG,gBAAeT,KAAf,CAAjB;;EACAb,SAAS,CAAC,YAAM;IAAA;;IACd,IAAMuB,QAAQ,GAAG,iCAAAC,IAAI,CAACC,KAAL,CAAWH,QAAX,mBAAyB,UAACL,IAAD,EAAU;MAClD,IAAMS,gBAAgB,GAAG,IAAIxB,gBAAJ,CAAqBe,IAArB,CAAzB;MACAS,gBAAgB,CAACC,MAAjB,GAA0BjB,UAA1B;MACA,OAAOgB,gBAAgB,CAACE,YAAjB,CAA8BrB,mBAA9B,CAAP;IACD,CAJgB,CAAjB;;IAMAI,KAAK;;IACL,SAAQkB,GAAR,CAAYN,QAAZ,EAAsBO,IAAtB,CAA2B,UAACC,eAAD,EAAqB;MAC9CtB,UAAU,CAACsB,eAAD,CAAV;MACAnB,MAAM;IACP,CAHD,EARc,CAad;IACA;;EACD,CAfQ,EAeN,CAACU,QAAD,EAAWZ,UAAX,EAAuBH,mBAAvB,CAfM,CAAT;EAiBA,OAAOC,OAAP;AACD,CAjCM"}
|
package/esm/hooks/useI18n.js
CHANGED
|
@@ -2,16 +2,8 @@ import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringif
|
|
|
2
2
|
import { useSelector } from "react-redux";
|
|
3
3
|
import { createSelector } from "reselect";
|
|
4
4
|
import memoize from "lodash/memoize";
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
return state.i18n.locale || "en";
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
var getLocales = function getLocales(state) {
|
|
11
|
-
return state.i18n.locales;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var getMessage = createSelector([getLocales, getLocaleCode], function (locales, localeCode) {
|
|
5
|
+
import { getLocales, getLocale } from "../redux/selectors/i18n";
|
|
6
|
+
var getMessage = createSelector([getLocales, getLocale], function (locales, localeCode) {
|
|
15
7
|
return memoize(function (id, defaultMessage, placeholders) {
|
|
16
8
|
return locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders);
|
|
17
9
|
}, function () {
|
|
@@ -35,6 +27,13 @@ var useMessage = function useMessage(id, defaultMessage, placeholders) {
|
|
|
35
27
|
var useTranslate = function useTranslate() {
|
|
36
28
|
return useSelector(getMessage);
|
|
37
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var useLocale = function useLocale() {
|
|
35
|
+
return useSelector(getLocale);
|
|
36
|
+
};
|
|
38
37
|
|
|
39
|
-
export { useTranslate, useMessage };
|
|
38
|
+
export { useTranslate, useMessage, useLocale };
|
|
40
39
|
//# sourceMappingURL=useI18n.js.map
|
package/esm/hooks/useI18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.js","names":["useSelector","createSelector","memoize","
|
|
1
|
+
{"version":3,"file":"useI18n.js","names":["useSelector","createSelector","memoize","getLocales","getLocale","getMessage","locales","localeCode","id","defaultMessage","placeholders","args","useMessage","useTranslate","useLocale"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\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\n/**\n */\nconst useMessage = (\n id: string,\n defaultMessage?: string,\n placeholders?: Object | null\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\n/**\n */\nconst useLocale = (): string => useSelector(getLocale);\n\nexport { useTranslate, useMessage, useLocale };\n"],"mappings":";AACA,SAASA,WAAT,QAA4B,aAA5B;AACA,SAASC,cAAT,QAA+B,UAA/B;AACA,OAAOC,OAAP,MAAoB,gBAApB;AAEA,SAASC,UAAT,EAAqBC,SAArB,QAAsC,yBAAtC;AAEA,IAAMC,UAAU,GAAGJ,cAAc,CAC/B,CAACE,UAAD,EAAaC,SAAb,CAD+B,EAE/B,UAACE,OAAD,EAAUC,UAAV;EAAA,OACEL,OAAO,CACL,UAACM,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEJ,OAAO,CACJF,SADH,CACaG,UADb,EAEGF,UAFH,CAEcG,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADK,EAKL;IAAA,kCAAIC,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,gBAAeA,IAAf,CAAb;EAAA,CALK,CADT;AAAA,CAF+B,CAAjC;AAYA;AACA;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACjBJ,EADiB,EAEjBC,cAFiB,EAGjBC,YAHiB;EAAA,OAITV,WAAW,CAACK,UAAD,CAAX,CAAwBG,EAAxB,EAA4BC,cAA5B,EAA4CC,YAA5C,CAJS;AAAA,CAAnB;AAMA;AACA;;;AACA,IAAMG,YAAY,GAAG,SAAfA,YAAe;EAAA,OAAyBb,WAAW,CAACK,UAAD,CAApC;AAAA,CAArB;AAEA;AACA;;;AACA,IAAMS,SAAS,GAAG,SAAZA,SAAY;EAAA,OAAcd,WAAW,CAACI,SAAD,CAAzB;AAAA,CAAlB;;AAEA,SAASS,YAAT,EAAuBD,UAAvB,EAAmCE,SAAnC"}
|
|
@@ -4,15 +4,14 @@ import { useDispatch, useSelector } from "react-redux";
|
|
|
4
4
|
import { HTTP_METHODS } from "../constants";
|
|
5
5
|
import { loadModularUI, removeModelByKey } from "../redux/_modularui/actions";
|
|
6
6
|
import useDeepCompareEffect from "./useDeepCompareEffect";
|
|
7
|
+
import { useLocale } from "./useI18n";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
*/
|
|
10
11
|
var useKeyForHook = function useKeyForHook(modelKey, url) {
|
|
11
12
|
var _context, _context2;
|
|
12
13
|
|
|
13
|
-
var locale =
|
|
14
|
-
return state.i18n.locale;
|
|
15
|
-
});
|
|
14
|
+
var locale = useLocale();
|
|
16
15
|
return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(modelKey, "(")).call(_context2, url.split("?")[0], ")(")).call(_context, locale, ")");
|
|
17
16
|
};
|
|
18
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useDispatch","useSelector","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useKeyForHook","modelKey","url","locale","
|
|
1
|
+
{"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useDispatch","useSelector","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","useKeyForHook","modelKey","url","locale","split","useModularUI","options","method","GET","removeOnUnmount","dispatch","href","toString","key","prevOptions","prevHref","isOldReload","current","isReload","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui/actions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestBaseOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\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: RequestBaseOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n }\n): any => {\n const dispatch = useDispatch();\n const href = url.toString();\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\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 if (!isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":";AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,SAASC,WAAT,EAAsBC,WAAtB,QAAyC,aAAzC;AAEA,SAASC,YAAT,QAA6B,cAA7B;AACA,SAASC,aAAT,EAAwBC,gBAAxB,QAAgD,6BAAhD;AAEA,OAAOC,oBAAP,MAAiC,wBAAjC;AAEA,SAASC,SAAT,QAA0B,WAA1B;;AAKA;AACA;AACA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,QAAD,EAAmBC,GAAnB,EAAmC;EAAA;;EACvD,IAAMC,MAAM,GAAGJ,SAAS,EAAxB;EACA,wFAAUE,QAAV,wBAAsBC,GAAG,CAACE,KAAJ,CAAU,GAAV,EAAe,CAAf,CAAtB,wBAA4CD,MAA5C;AACD,CAHD;AAKA;AACA;AACA;;;AACA,OAAO,IAAME,YAAY,GAAG,SAAfA,YAAe,CAC1BJ,QAD0B,EAE1BC,GAF0B,EAOlB;EAAA,IAJRI,OAIQ,uEAJsB;IAC5BC,MAAM,EAAEZ,YAAY,CAACa,GADO;IAE5BC,eAAe,EAAE;EAFW,CAItB;EACR,IAAMC,QAAQ,GAAGjB,WAAW,EAA5B;EACA,IAAMkB,IAAI,GAAGT,GAAG,CAACU,QAAJ,EAAb;EACA,IAAMC,GAAG,GAAGb,aAAa,CAACC,QAAD,EAAWU,IAAX,CAAzB;EAEA,IAAMG,WAAW,GAAGtB,MAAM,CAACc,OAAD,CAA1B;EACA,IAAMS,QAAQ,GAAGvB,MAAM,CAACmB,IAAD,CAAvB,CANQ,CAQR;;EACAb,oBAAoB,CAAC,YAAM;IACzB;IACA,IAAMkB,WAAW,GACfD,QAAQ,CAACE,OAAT,KAAqBN,IAArB,IACAG,WAAW,CAACG,OAAZ,CAAoBC,QADpB,IAEA,CAACZ,OAAO,CAACY,QAHX;;IAKA,IAAI,CAACF,WAAL,EAAkB;MAChBN,QAAQ,CAACd,aAAa,CAACiB,GAAD,EAAMF,IAAN,EAAYL,OAAZ,CAAd,CAAR;IACD;;IAEDQ,WAAW,CAACG,OAAZ,GAAsBX,OAAtB;IACAS,QAAQ,CAACE,OAAT,GAAmBN,IAAnB;EACD,CAbmB,EAajB,CAACE,GAAD,EAAMF,IAAN,EAAYL,OAAZ,CAbiB,CAApB;EAeA,4BAAoCA,OAApC,CAAQG,eAAR;EAAA,IAAQA,eAAR,sCAA0B,KAA1B;EACAlB,SAAS,CAAC,YAAM;IACd,OAAO,YAAM;MACX,IAAIkB,eAAJ,EAAqB;QACnBC,QAAQ,CAACb,gBAAgB,CAACgB,GAAD,CAAjB,CAAR;MACD;IACF,CAJD;EAKD,CANQ,EAMN,CAACH,QAAD,EAAWG,GAAX,EAAgBJ,eAAhB,CANM,CAAT,CAzBQ,CAiCR;;EACA,OAAOf,WAAW,CAAC,UAACyB,KAAD,EAAW;IAC5B,OAAOA,KAAK,CAACC,SAAN,CAAgBP,GAAhB,CAAP;EACD,CAFiB,CAAlB;AAGD,CA5CM"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { createSelector } from "reselect";
|
|
2
2
|
import { useSelector } from "react-redux";
|
|
3
3
|
import ModularUIRequest from "../modularui/ModularUIRequest";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return (_state$i18n$locale = state.i18n.locale) !== null && _state$i18n$locale !== void 0 ? _state$i18n$locale : "en";
|
|
8
|
-
}], function (localeCode) {
|
|
4
|
+
import { getLocale } from "../redux/selectors/i18n";
|
|
5
|
+
var getModularUIRequest = createSelector([getLocale], function (localeCode) {
|
|
9
6
|
return function (href, options) {
|
|
10
7
|
var request = new ModularUIRequest(href, options);
|
|
11
8
|
request.locale = localeCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIRequest.js","names":["createSelector","useSelector","ModularUIRequest","
|
|
1
|
+
{"version":3,"file":"useModularUIRequest.js","names":["createSelector","useSelector","ModularUIRequest","getLocale","getModularUIRequest","localeCode","href","options","request","locale","useModularUIRequest"],"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,SAASA,cAAT,QAA+B,UAA/B;AACA,SAASC,WAAT,QAA4B,aAA5B;AAEA,OAAOC,gBAAP,MAA6B,+BAA7B;AACA,SAASC,SAAT,QAA0B,yBAA1B;AAKA,IAAMC,mBAAmB,GAAGJ,cAAc,CAAC,CAACG,SAAD,CAAD,EAAc,UAACE,UAAD,EAAgB;EACtE,OAAO,UAACC,IAAD,EAAaC,OAAb,EAAsD;IAC3D,IAAMC,OAAO,GAAG,IAAIN,gBAAJ,CAAqBI,IAArB,EAA2BC,OAA3B,CAAhB;IACAC,OAAO,CAACC,MAAR,GAAiBJ,UAAjB;IACA,OAAOG,OAAP;EACD,CAJD;AAKD,CANyC,CAA1C;AAQA;AACA;AACA;;AACA,OAAO,IAAME,mBAAmB,GAAG,SAAtBA,mBAAsB;EAAA,OAGTT,WAAW,CAACG,mBAAD,CAHF;AAAA,CAA5B"}
|
package/esm/i18n/Message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","names":["memo","hideVisually","useMessage","Message","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","styles","__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
|
|
1
|
+
{"version":3,"file":"Message.js","names":["memo","hideVisually","useMessage","Message","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","styles","__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,SAASA,IAAT,QAAqB,OAArB;AACA,SAASC,YAAT,QAA6B,UAA7B;AAEA,SAASC,UAAT,QAA2B,kBAA3B;;;AAYA;AACA;AACA;AACA,IAAMC,OAAqD,gBACzDH,IAAI,CACF,gBAQoB;EAAA,IAPlBI,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,GAAGT,UAAU,CAClCG,EADkC,EAElCC,cAAc,IAAIC,QAFgB,EAGlCC,IAHkC,CAApC;;EAMA,IAAIC,gBAAJ,EAAsB;IACpB,IAAMG,MAAM,qBACPX,YAAY,EADL,CAAZ;;IAIA,oBACE;MAAM,SAAS,EAAEG,SAAjB;MAA4B,KAAK,EAAEQ,MAAnC;MAAA,UACGD;IADH,EADF;EAKD;;EAED,IAAID,SAAJ,EAAe;IACb,oBACE;MACE,SAAS,EAAEN,SADb;MAEE,uBAAuB,EAAE;QACvBS,MAAM,EAAEF;MADe;IAF3B,EADF;EAQD;;EAED,oBAAO;IAAM,SAAS,EAAEP,SAAjB;IAAA,UAA6BO;EAA7B,EAAP;AACD,CAxCC,CADN;AA4CAR,OAAO,CAACW,WAAR,GAAsB,YAAtB;AAEA,eAAeX,OAAf"}
|
package/esm/i18n/withMessage.js
CHANGED
|
@@ -2,16 +2,8 @@ import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringif
|
|
|
2
2
|
import { connect } from "react-redux";
|
|
3
3
|
import { createSelector } from "reselect";
|
|
4
4
|
import memoize from "lodash/memoize";
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
return state.i18n.locale || "en";
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
var getLocales = function getLocales(state) {
|
|
11
|
-
return state.i18n.locales;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var getMessage = createSelector([getLocales, getLocaleCode], function (locales, localeCode) {
|
|
5
|
+
import { getLocales, getLocale } from "../redux/selectors/i18n";
|
|
6
|
+
var getMessage = createSelector([getLocales, getLocale], function (locales, localeCode) {
|
|
15
7
|
return memoize(function (id, defaultMessage, placeholders) {
|
|
16
8
|
return locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders);
|
|
17
9
|
}, function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withMessage.js","names":["connect","createSelector","memoize","
|
|
1
|
+
{"version":3,"file":"withMessage.js","names":["connect","createSelector","memoize","getLocales","getLocale","getMessage","locales","localeCode","id","defaultMessage","placeholders","args","mapStateToProps","state","message","withMessage"],"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,SAASA,OAAT,QAAwB,aAAxB;AAEA,SAASC,cAAT,QAA+B,UAA/B;AACA,OAAOC,OAAP,MAAoB,gBAApB;AAEA,SAASC,UAAT,EAAqBC,SAArB,QAAsC,yBAAtC;AAkBA,IAAMC,UAAU,GAAGJ,cAAc,CAC/B,CAACE,UAAD,EAAaC,SAAb,CAD+B,EAE/B,UAACE,OAAD,EAAUC,UAAV;EAAA,OACEL,OAAO,CACL,UAACM,EAAD,EAAaC,cAAb,EAAsCC,YAAtC;IAAA,OACEJ,OAAO,CACJF,SADH,CACaG,UADb,EAEGF,UAFH,CAEcG,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CADF;EAAA,CADK,EAKL;IAAA,kCAAIC,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,gBAAeA,IAAf,CAAb;EAAA,CALK,CADT;AAAA,CAF+B,CAAjC;;AAYA,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;EAAA,OAAoC;IAC1DC,OAAO,EAAET,UAAU,CAACQ,KAAD;EADuC,CAApC;AAAA,CAAxB;AAIA;AACA;;;AACA,IAAME,WAA+B,GAAGf,OAAO,CAC7CY,eAD6C,CAA/C;AAIA,eAAeG,WAAf"}
|
|
@@ -12,13 +12,14 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
|
12
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
13
|
|
|
14
14
|
import { useEffect } from "react";
|
|
15
|
-
import { useDispatch
|
|
15
|
+
import { useDispatch } from "react-redux";
|
|
16
16
|
import { useLocation } from "react-router";
|
|
17
17
|
import { loadModularUI, reloadModel, removeModelByKey } from "./actions";
|
|
18
18
|
import Href from "../../models/href/Href";
|
|
19
19
|
import { getDisplayName } from "../../react/utils";
|
|
20
20
|
import { useUrl, useReload } from "./modularuiUtils";
|
|
21
21
|
import { useModularUI } from "../../hooks/useModularUI";
|
|
22
|
+
import { useLocale } from "../../hooks/useI18n";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -78,9 +79,7 @@ var connector = function connector(name, resource) {
|
|
|
78
79
|
};
|
|
79
80
|
}, [dispatch, modelKey]); // Create new properties object to inject modularui properties to own props
|
|
80
81
|
|
|
81
|
-
var locale =
|
|
82
|
-
return state.i18n.locale;
|
|
83
|
-
});
|
|
82
|
+
var locale = useLocale();
|
|
84
83
|
var newProps = (_newProps = {
|
|
85
84
|
modelKey: modelKey
|
|
86
85
|
}, _defineProperty(_newProps, propName, modelEntry ? modelEntry.model : null), _defineProperty(_newProps, "location", location), _defineProperty(_newProps, "status", modelEntry ? modelEntry.status : null), _defineProperty(_newProps, "lastModification", modelEntry ? modelEntry.lastModification : null), _defineProperty(_newProps, "hasModel", Boolean(modelEntry)), _defineProperty(_newProps, "locale", locale), _defineProperty(_newProps, "fetchModularUI", handleFetch), _defineProperty(_newProps, "reloadModel", handleManualReload), _newProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","names":["useEffect","useDispatch","
|
|
1
|
+
{"version":3,"file":"connector.js","names":["useEffect","useDispatch","useLocation","loadModularUI","reloadModel","removeModelByKey","Href","getDisplayName","useUrl","useReload","useModularUI","useLocale","connector","name","resource","options","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","location","url","displayName","contextId","modelEntry","modelKey","model","connectKey","handleManualReload","reloadOptions","handleFetch","href","fetchOptions","reload","state","doReload","isReload","locale","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.modularui(${getDisplayName(\n WrappedComponent,\n name\n )}`;\n\n return WrappedComponent;\n };\n};\n\nexport default connector;\n"],"mappings":";;;;;;;;;;;;;AACA,SAASA,SAAT,QAA0B,OAA1B;AACA,SAASC,WAAT,QAA4B,aAA5B;AACA,SAASC,WAAT,QAA4B,cAA5B;AAEA,SAASC,aAAT,EAAwBC,WAAxB,EAAqCC,gBAArC,QAA6D,WAA7D;AAEA,OAAOC,IAAP,MAAiB,wBAAjB;AACA,SAASC,cAAT,QAA+B,mBAA/B;AAEA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,kBAAlC;AACA,SAASC,YAAT,QAA6B,0BAA7B;AACA,SAASC,SAAT,QAA0B,qBAA1B;;;AAmBA;AACA;AACA,IAAMC,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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
|
|
170
|
+
* Returns all model keys found in the store, restrict on href
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
export var allKeysByHref = function allKeysByHref(state, href) {
|
|
174
|
+
if (state && state.modularui) {
|
|
175
|
+
var _context7;
|
|
176
|
+
|
|
177
|
+
var findHref = href instanceof Href ? href : new Href(href);
|
|
178
|
+
return _filterInstanceProperty(_context7 = _Object$keys(state.modularui)).call(_context7, function (key) {
|
|
179
|
+
var model = state.modularui[key].model;
|
|
180
|
+
return model && model.selfhref && model.selfhref.equals(findHref);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return [];
|
|
185
|
+
};
|
|
169
186
|
/**
|
|
170
187
|
*/
|
|
171
188
|
|
|
@@ -219,9 +236,9 @@ export var getActiveModels = createSelectorCreator(defaultMemoize, function (val
|
|
|
219
236
|
if (location) {
|
|
220
237
|
var locationParts = location.split("/");
|
|
221
238
|
locationParts.reduce(function (accumulator, current) {
|
|
222
|
-
var
|
|
239
|
+
var _context8;
|
|
223
240
|
|
|
224
|
-
var path = _concatInstanceProperty(
|
|
241
|
+
var path = _concatInstanceProperty(_context8 = "".concat(accumulator, "/")).call(_context8, current); // Remove modelcatalog part to match breadcrumb parts
|
|
225
242
|
|
|
226
243
|
|
|
227
244
|
var comparePath = decodeURIComponent(path).replace("/modelcatalog/", "/");
|
|
@@ -267,11 +284,11 @@ export var getPreference = function getPreference(state, preferenceName) {
|
|
|
267
284
|
|
|
268
285
|
export var getModelsByType = function getModelsByType(state, type) {
|
|
269
286
|
if (state && state.modularui) {
|
|
270
|
-
var
|
|
287
|
+
var _context9, _context10;
|
|
271
288
|
|
|
272
|
-
return _mapInstanceProperty(
|
|
289
|
+
return _mapInstanceProperty(_context9 = _filterInstanceProperty(_context10 = _Object$keys(state.modularui)).call(_context10, function (key) {
|
|
273
290
|
return state.modularui[key] && state.modularui[key].model && state.modularui[key].model.type === type;
|
|
274
|
-
})).call(
|
|
291
|
+
})).call(_context9, function (key) {
|
|
275
292
|
return state.modularui[key].model;
|
|
276
293
|
});
|
|
277
294
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","names":["createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","getAllModelsByInstance","state","instance","locale","i18n","modularui","key","model","getFirstModelByInstance","getActiveModelByInstance","location","getLocation","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","findHref","modelConfigKey","equals","keyByHref","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","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,SAASA,qBAAT,EAAgCC,cAAhC,QAAsD,UAAtD;AACA,SAASC,GAAT,QAAoB,6BAApB;AAEA,OAAOC,IAAP,MAAiB,wBAAjB;AACA,OAAOC,YAAP,MAAyB,mCAAzB;AACA,OAAOC,eAAP,MAA4B,sCAA5B;AACA,OAAOC,gBAAP,MAA6B,2CAA7B;AACA,OAAOC,QAAP,MAAqB,2BAArB;AACA,OAAOC,aAAP,MAA0B,qCAA1B;AACA,OAAOC,SAAP,MAAsB,6BAAtB;;AAKA;AACA;AACA,OAAO,IAAMC,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;AAmBP;AACA;;AACA,OAAO,IAAMC,uBAAuB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OAAO,IAAMY,aAAa,GAAG,SAAhBA,aAAgB,CAC3BlD,KAD2B,EAE3BmD,cAF2B,EAGA;EAC3B,IAAInD,KAAK,IAAIA,KAAK,CAACoD,WAAnB,EAAgC;IAC9B,OAAOpD,KAAK,CAACoD,WAAN,CAAkBD,cAAlB,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CATM;AAWP;AACA;AACA;;AACA,OAAO,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAC7BrD,KAD6B,EAE7B+B,IAF6B,EAGH;EAC1B,IAAI/B,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,CAA2ByB,IAA3B,KAAoCA,IAHtC;IAAA,CAFG,mBAOA,UAAC1B,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":["createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","getAllModelsByInstance","state","instance","locale","i18n","modularui","key","model","getFirstModelByInstance","getActiveModelByInstance","location","getLocation","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","findHref","modelConfigKey","equals","keyByHref","allKeysByHref","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","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,SAASA,qBAAT,EAAgCC,cAAhC,QAAsD,UAAtD;AACA,SAASC,GAAT,Q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WAAhB,CAA4BC,QAA5B,EAAzB,EADJ,GAEIvC,QAHN;QAKA4B,aAAa,CAACJ,IAAd,CAAmB;UAAE9B,GAAG,EAAHA,GAAF;UAAOa,IAAI,EAAJA,IAAP;UAAaa,KAAK,EAALA,KAAb;UAAoBC,IAAI,EAAJA;QAApB,CAAnB;MACD;;MAED,OAAOpB,IAAP;IACD,CAzBD;EA0BD;;EAED,OAAO2B,aAAP;AACD,CAtCI,CALE;AA6CP;AACA;;AACA,OAAO,IAAMY,aAAa,GAAG,SAAhBA,aAAgB,CAC3BnD,KAD2B,EAE3BoD,cAF2B,EAGA;EAC3B,IAAIpD,KAAK,IAAIA,KAAK,CAACqD,WAAnB,EAAgC;IAC9B,OAAOrD,KAAK,CAACqD,WAAN,CAAkBD,cAAlB,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CATM;AAWP;AACA;AACA;;AACA,OAAO,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAC7BtD,KAD6B,EAE7BgC,IAF6B,EAGH;EAC1B,IAAIhC,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,CAA2B0B,IAA3B,KAAoCA,IAHtC;IAAA,CAFG,mBAOA,UAAC3B,GAAD;MAAA,OAASL,KAAK,CAACI,SAAN,CAAgBC,GAAhB,EAAqBC,KAA9B;IAAA,CAPA,CAAP;EAQD;;EAED,OAAO,EAAP;AACD,CAhBM"}
|
|
@@ -3,17 +3,9 @@ import { createSelector } from "reselect";
|
|
|
3
3
|
import ModularUIRequest from "../../modularui/ModularUIRequest";
|
|
4
4
|
import { startProgress, finishProgress } from "../actions/ProgressIndicator";
|
|
5
5
|
import { handleError } from "../actions/Error";
|
|
6
|
+
import { getLocale } from "../selectors/i18n";
|
|
6
7
|
import { reloadModel } from "./actions";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*/
|
|
10
|
-
var getLocaleCode = function getLocaleCode(state) {
|
|
11
|
-
var _state$i18n$locale;
|
|
12
|
-
|
|
13
|
-
return (_state$i18n$locale = state.i18n.locale) !== null && _state$i18n$locale !== void 0 ? _state$i18n$locale : "en";
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
var modularui = createSelector([getLocaleCode], function (localeCode) {
|
|
8
|
+
var modularui = createSelector([getLocale], function (localeCode) {
|
|
17
9
|
return function (href) {
|
|
18
10
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
19
11
|
var modularuiRequest = new ModularUIRequest(href, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withModularUI.js","names":["connect","createSelector","ModularUIRequest","startProgress","finishProgress","handleError","
|
|
1
|
+
{"version":3,"file":"withModularUI.js","names":["connect","createSelector","ModularUIRequest","startProgress","finishProgress","handleError","getLocale","reloadModel","modularui","localeCode","href","options","modularuiRequest","locale","mapStateToProps","state","i18n","mapDispatchToProps","withModularui"],"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,SAASA,OAAT,QAAwB,aAAxB;AAEA,SAASC,cAAT,QAA+B,UAA/B;AAEA,OAAOC,gBAAP,MAA6B,kCAA7B;AAEA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,8BAA9C;AAEA,SAASC,WAAT,QAA4B,kBAA5B;AAEA,SAASC,SAAT,QAA0B,mBAA1B;AAEA,SAASC,WAAT,QAA4B,WAA5B;AAkCA,IAAMC,SAAS,GAAGP,cAAc,CAC9B,CAACK,SAAD,CAD8B,EAE9B,UAACG,UAAD;EAAA,OACE,UAACC,IAAD,EAAwB;IAAA,IAAjBC,OAAiB,uEAAP,EAAO;IACtB,IAAMC,gBAAgB,GAAG,IAAIV,gBAAJ,CAAqBQ,IAArB,EAA2BC,OAA3B,CAAzB;IACAC,gBAAgB,CAACC,MAAjB,GAA0BJ,UAA1B;IACA,OAAOG,gBAAP;EACD,CALH;AAAA,CAF8B,CAAhC;AAUA;AACA;;AACA,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD;EAAA,OAAoC;IAC1DP,SAAS,EAAEA,SAAS,CAACO,KAAD,CADsC;IAE1DF,MAAM,EAAEE,KAAK,CAACC,IAAN,CAAWH;EAFuC,CAApC;AAAA,CAAxB;;AAKA,IAAMI,kBAAiC,GAAG;EACxCd,aAAa,EAAbA,aADwC;EAExCC,cAAc,EAAdA,cAFwC;EAGxCG,WAAW,EAAXA,WAHwC;EAIxCF,WAAW,EAAXA;AAJwC,CAA1C;AAOA;AACA;AACA;AACA;;AACA,IAAMa,aAAiC,GAAGlB,OAAO,CAO/Cc,eAP+C,EAO9BG,kBAP8B,CAAjD;AASA,eAAeC,aAAf"}
|
|
@@ -1,21 +1,40 @@
|
|
|
1
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
2
|
+
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
3
|
+
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
4
|
+
import _getIteratorMethod from "@babel/runtime-corejs3/core-js/get-iterator-method";
|
|
5
|
+
|
|
6
|
+
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; } } }; }
|
|
7
|
+
|
|
8
|
+
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); }
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
1
12
|
import { loadModularUI, removeModelByKey } from "../_modularui/actions";
|
|
2
|
-
import {
|
|
13
|
+
import { allKeysByHref } from "../_modularui/selectors";
|
|
3
14
|
import { ApplicationModel, Href } from "../../models";
|
|
15
|
+
import { getLocale } from "../selectors/i18n";
|
|
4
16
|
|
|
5
17
|
/**
|
|
6
18
|
*/
|
|
7
19
|
export var reloadApplication = function reloadApplication() {
|
|
8
20
|
return function (dispatch, getState) {
|
|
9
|
-
var
|
|
21
|
+
var allKeys = allKeysByHref(getState(), "/");
|
|
10
22
|
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
var _iterator = _createForOfIteratorHelper(allKeys),
|
|
24
|
+
_step;
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
try {
|
|
27
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
28
|
+
var key = _step.value;
|
|
29
|
+
dispatch(removeModelByKey(key));
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
_iterator.e(err);
|
|
33
|
+
} finally {
|
|
34
|
+
_iterator.f();
|
|
16
35
|
}
|
|
17
36
|
|
|
18
|
-
|
|
37
|
+
var modelKey = "application(/)(".concat(getLocale(getState()), ")");
|
|
19
38
|
return dispatch(loadModularUI(modelKey, new Href("/", "Application"), {
|
|
20
39
|
targetModel: ApplicationModel
|
|
21
40
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.js","names":["loadModularUI","removeModelByKey","
|
|
1
|
+
{"version":3,"file":"Application.js","names":["loadModularUI","removeModelByKey","allKeysByHref","ApplicationModel","Href","getLocale","reloadApplication","dispatch","getState","allKeys","key","modelKey","targetModel"],"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,SAASA,aAAT,EAAwBC,gBAAxB,QAAgD,uBAAhD;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,gBAAT,EAA2BC,IAA3B,QAAuC,cAAvC;AACA,SAASC,SAAT,QAA0B,mBAA1B;;AAIA;AACA;AACA,OAAO,IAAMC,iBAAiB,GAC5B,SADWA,iBACX;EAAA,OAAmB,UAACC,QAAD,EAAqBC,QAArB,EAA4C;IAC7D,IAAMC,OAAO,GAAGP,aAAa,CAACM,QAAQ,EAAT,EAAa,GAAb,CAA7B;;IAD6D,2CAE3CC,OAF2C;IAAA;;IAAA;MAE7D,oDAA2B;QAAA,IAAhBC,GAAgB;QACzBH,QAAQ,CAACN,gBAAgB,CAACS,GAAD,CAAjB,CAAR;MACD;IAJ4D;MAAA;IAAA;MAAA;IAAA;;IAM7D,IAAMC,QAAQ,4BAAqBN,SAAS,CAACG,QAAQ,EAAT,CAA9B,MAAd;IACA,OAAOD,QAAQ,CACbP,aAAa,CAACW,QAAD,EAAW,IAAIP,IAAJ,CAAS,GAAT,EAAc,aAAd,CAAX,EAAyC;MACpDQ,WAAW,EAAET;IADuC,CAAzC,CADA,CAAf;EAKD,CAZD;AAAA,CADK"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieve the locale from state
|
|
3
|
+
*/
|
|
4
|
+
export var getLocale = function getLocale(state) {
|
|
5
|
+
var _state$i18n$locale, _state$i18n;
|
|
6
|
+
|
|
7
|
+
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";
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve all available locales in the store
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export var getLocales = function getLocales(state) {
|
|
14
|
+
return state.i18n.locales;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -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;AACA,OAAO,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;;AACA,OAAO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACH,KAAD;EAAA,OAAgCA,KAAK,CAACC,IAAN,CAAWG,OAA3C;AAAA,CAAnB"}
|
|
@@ -25,7 +25,9 @@ var BaseDateTimeUtil = /*#__PURE__*/function () {
|
|
|
25
25
|
_createClass(BaseDateTimeUtil, [{
|
|
26
26
|
key: "getLocale",
|
|
27
27
|
value: function getLocale() {
|
|
28
|
-
var
|
|
28
|
+
var _getCookie;
|
|
29
|
+
|
|
30
|
+
var locale = (_getCookie = getCookie("locale")) !== null && _getCookie !== void 0 ? _getCookie : "en";
|
|
29
31
|
|
|
30
32
|
if (locale === "nl") {
|
|
31
33
|
return nl;
|