@beinformed/ui 1.18.3 → 1.18.6
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 +17 -0
- package/esm/constants/Constants.js +1 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +10 -3
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useAuthentication.js +7 -50
- package/esm/hooks/useAuthentication.js.map +1 -1
- package/esm/i18n/Locales.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/form/FormModel.js +3 -1
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/esm/models/tab/TabModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +100 -21
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/redux/actions/Preferences.js +2 -2
- package/esm/redux/actions/Preferences.js.map +1 -1
- package/esm/redux/actions/SignOut.js +6 -2
- package/esm/redux/actions/SignOut.js.map +1 -1
- package/esm/redux/connectors/SignIn.js +3 -2
- package/esm/redux/connectors/SignIn.js.map +1 -1
- package/esm/redux/connectors/SignOut.js +4 -1
- package/esm/redux/connectors/SignOut.js.map +1 -1
- package/esm/redux/reducers/AuthReducer.js +0 -10
- package/esm/redux/reducers/AuthReducer.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +2 -0
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/lib/constants/Constants.js +3 -1
- package/lib/constants/Constants.js.flow +1 -0
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/LayoutHints.js.map +1 -1
- package/lib/constants/Settings.js +13 -3
- package/lib/constants/Settings.js.flow +8 -3
- package/lib/constants/Settings.js.map +1 -1
- package/lib/exceptions/FetchException.js.map +1 -1
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +15 -1
- package/lib/hooks/useAllFormsOnModel.js.map +1 -1
- package/lib/hooks/useAuthentication.js +7 -55
- package/lib/hooks/useAuthentication.js.flow +4 -37
- package/lib/hooks/useAuthentication.js.map +1 -1
- package/lib/hooks/useContent.js.map +1 -1
- package/lib/hooks/useDeepCompareEffect.js.map +1 -1
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/hooks/useModal.js.map +1 -1
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/lib/hooks/useModels.js.map +1 -1
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/hooks/useModularUIRequest.js.map +1 -1
- package/lib/hooks/useNotification.js.map +1 -1
- package/lib/hooks/usePreference.js.map +1 -1
- package/lib/hooks/useProgressIndicator.js.map +1 -1
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/i18n/Locale.js.map +1 -1
- package/lib/i18n/Locales.js.map +1 -1
- package/lib/i18n/Message.js.map +1 -1
- package/lib/i18n/withMessage.js.map +1 -1
- package/lib/models/actions/ActionModel.js.map +1 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/attributes/AttributeCollection.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/AttributeSetModel.js.map +1 -1
- package/lib/models/attributes/BooleanAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
- package/lib/models/attributes/CompositeAttributeModel.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/models/attributes/MemoAttributeModel.js.map +1 -1
- package/lib/models/attributes/MoneyAttributeModel.js.map +1 -1
- package/lib/models/attributes/NumberAttributeModel.js.map +1 -1
- package/lib/models/attributes/StringAttributeModel.js.map +1 -1
- package/lib/models/attributes/XMLAttributeModel.js.map +1 -1
- package/lib/models/attributes/_createAttribute.js.map +1 -1
- package/lib/models/attributes/input-constraints/ConstraintCollection.js.map +1 -1
- package/lib/models/attributes/input-constraints/ConstraintModel.js.map +1 -1
- package/lib/models/attributes/input-constraints/DateTimeDateFormatConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/DateTimeTimeFormatConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/FileSizeConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/IBANConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/NumberBoundaryConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/NumberFormatConstraint.js.map +1 -1
- package/lib/models/base/BaseCollection.js.map +1 -1
- package/lib/models/base/BaseModel.js.map +1 -1
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/concepts/BusinessScenarioModel.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/lib/models/detail/DetailModel.js.map +1 -1
- package/lib/models/filters/BaseFilterModel.js.map +1 -1
- package/lib/models/form/FormModel.js +3 -1
- package/lib/models/form/FormModel.js.flow +1 -1
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/links/LinkModel.js.map +1 -1
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/models/list/ListHeaderModel.js.map +1 -1
- package/lib/models/list/ListItemCollection.js.map +1 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/lookup/LookupOptionsModel.js.map +1 -1
- package/lib/models/paging/PagingModel.js.map +1 -1
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/parameter/Parameter.js.map +1 -1
- package/lib/models/process/ProcessStatusSettingsModel.js.map +1 -1
- package/lib/models/resolveModel.js.map +1 -1
- package/lib/models/sorting/SortingModel.js.map +1 -1
- package/lib/models/tab/TabModel.js.map +1 -1
- package/lib/models/user/UserProfileModel.js.map +1 -1
- package/lib/models/user/UserServicesModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +102 -21
- package/lib/modularui/Authenticate.js.flow +75 -20
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/ModularUIResponse.js.map +1 -1
- package/lib/react/ErrorBoundaryFallback.js.map +1 -1
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-client/rehydrate.js.map +1 -1
- package/lib/react-server/__tests__/serverUtil.spec.js.flow +6 -4
- package/lib/react-server/createSSRComplete.js.map +1 -1
- package/lib/react-server/renderSSRComplete.js.map +1 -1
- package/lib/react-server/renderSSRMinimal.js.map +1 -1
- package/lib/react-server/serverNoSSR.js.map +1 -1
- package/lib/react-server/serverSSR.js.map +1 -1
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/react-theme/ThemeProvider.js.map +1 -1
- package/lib/react-theme/createTheme.js.map +1 -1
- package/lib/react-theme/useTheme.js.map +1 -1
- package/lib/react-theme/utils/background.js.map +1 -1
- package/lib/react-theme/utils/colors.js.map +1 -1
- package/lib/react-theme/utils/contrast.js.map +1 -1
- package/lib/react-theme/utils/corners.js.map +1 -1
- package/lib/react-theme/utils/spacers.js.map +1 -1
- package/lib/react-theme/utils/themeProps.js.map +1 -1
- package/lib/redux/_i18n/actions.js.map +1 -1
- package/lib/redux/_i18n/reducer.js.map +1 -1
- package/lib/redux/_modularui/actions.js.map +1 -1
- package/lib/redux/_modularui/connector.js.map +1 -1
- package/lib/redux/_modularui/middleware.js.map +1 -1
- package/lib/redux/_modularui/modularuiUtils.js.map +1 -1
- package/lib/redux/_modularui/reducer.js.map +1 -1
- package/lib/redux/_modularui/selectors.js.map +1 -1
- package/lib/redux/_modularui/withModularUI.js.map +1 -1
- package/lib/redux/_router/connectors.js.map +1 -1
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/Authorization.js.map +1 -1
- package/lib/redux/actions/Error.js.map +1 -1
- package/lib/redux/actions/Form.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormAutosubmit.js.map +1 -1
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/lib/redux/actions/Notification.js.map +1 -1
- package/lib/redux/actions/Preferences.js +1 -1
- package/lib/redux/actions/Preferences.js.flow +7 -3
- package/lib/redux/actions/Preferences.js.map +1 -1
- package/lib/redux/actions/SignIn.js.map +1 -1
- package/lib/redux/actions/SignOut.js +6 -1
- package/lib/redux/actions/SignOut.js.flow +9 -5
- package/lib/redux/actions/SignOut.js.map +1 -1
- package/lib/redux/connectors/Application.js.map +1 -1
- package/lib/redux/connectors/Breadcrumb.js.map +1 -1
- package/lib/redux/connectors/CaseView.js.map +1 -1
- package/lib/redux/connectors/ConceptDetail.js.map +1 -1
- package/lib/redux/connectors/ContentBrowser.js.map +1 -1
- package/lib/redux/connectors/ContentDetail.js.map +1 -1
- package/lib/redux/connectors/ContentDetailSection.js.map +1 -1
- package/lib/redux/connectors/Form.js.map +1 -1
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/connectors/ListDetail.js.map +1 -1
- package/lib/redux/connectors/Modal.js.map +1 -1
- package/lib/redux/connectors/ModelCatalog.js.map +1 -1
- package/lib/redux/connectors/Notification.js.map +1 -1
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/redux/connectors/Preferences.js.map +1 -1
- package/lib/redux/connectors/Progress.js.map +1 -1
- package/lib/redux/connectors/ProgressIndicator.js.map +1 -1
- package/lib/redux/connectors/QuickSearch.js.map +1 -1
- package/lib/redux/connectors/SignIn.js +3 -5
- package/lib/redux/connectors/SignIn.js.flow +1 -6
- package/lib/redux/connectors/SignIn.js.map +1 -1
- package/lib/redux/connectors/SignOut.js +5 -1
- package/lib/redux/connectors/SignOut.js.flow +2 -1
- package/lib/redux/connectors/SignOut.js.map +1 -1
- package/lib/redux/connectors/Tab.js.map +1 -1
- package/lib/redux/reducers/AuthReducer.js +0 -11
- package/lib/redux/reducers/AuthReducer.js.flow +0 -11
- package/lib/redux/reducers/AuthReducer.js.map +1 -1
- package/lib/redux/reducers/__tests__/AuthReducer.spec.js.flow +0 -9
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/redux/types.js.flow +0 -1
- package/lib/redux/types.js.map +1 -1
- package/lib/utils/browser/Cookies.js.map +1 -1
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/utils/fetch/universalFetch.js.map +1 -1
- package/lib/utils/fetch/xhr.js.map +1 -1
- package/lib/utils/helpers/checkResource.js +2 -0
- package/lib/utils/helpers/checkResource.js.flow +3 -0
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/lib/utils/helpers/objects.js.map +1 -1
- package/lib/utils/helpers/sanitizeHtml.js.map +1 -1
- package/lib/utils/helpers/text.js.map +1 -1
- package/lib/utils/number/formatValue.js.map +1 -1
- package/lib/utils/number/parseNumbers.js.map +1 -1
- package/package.json +22 -22
- package/src/constants/Constants.js +1 -0
- package/src/constants/Settings.js +8 -3
- package/src/hooks/__tests__/useAuthentication.spec.js +15 -1
- package/src/hooks/useAuthentication.js +4 -37
- package/src/models/form/FormModel.js +1 -1
- package/src/modularui/Authenticate.js +75 -20
- package/src/react-server/__tests__/serverUtil.spec.js +6 -4
- package/src/redux/actions/Preferences.js +7 -3
- package/src/redux/actions/SignOut.js +9 -5
- package/src/redux/connectors/SignIn.js +1 -6
- package/src/redux/connectors/SignOut.js +2 -1
- package/src/redux/reducers/AuthReducer.js +0 -11
- package/src/redux/reducers/__tests__/AuthReducer.spec.js +0 -9
- package/src/redux/types.js +0 -1
- package/src/utils/helpers/checkResource.js +3 -0
|
@@ -1,49 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.useLogout = exports.useLogin = void 0;
|
|
9
7
|
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
11
|
-
|
|
12
8
|
var _reactRedux = require("react-redux");
|
|
13
9
|
|
|
14
10
|
var _selectors = require("../redux/_modularui/selectors");
|
|
15
11
|
|
|
16
12
|
var _actions = require("../redux/actions");
|
|
17
13
|
|
|
18
|
-
var _UserServicesModel = _interopRequireDefault(require("../models/user/UserServicesModel"));
|
|
19
|
-
|
|
20
|
-
var _react = require("react");
|
|
21
|
-
|
|
22
|
-
var getIsAuthenticated = function getIsAuthenticated(isAuthenticated, application) {
|
|
23
|
-
if (!application) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var userServicesModel = application.userServices;
|
|
28
|
-
|
|
29
|
-
if (userServicesModel instanceof _UserServicesModel.default) {
|
|
30
|
-
return isAuthenticated && userServicesModel.isLoggedIn;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return false;
|
|
34
|
-
};
|
|
35
14
|
/**
|
|
36
15
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
16
|
var useLogin = function useLogin() {
|
|
17
|
+
var _application$isLogged;
|
|
18
|
+
|
|
40
19
|
var dispatch = (0, _reactRedux.useDispatch)();
|
|
41
20
|
var application = (0, _reactRedux.useSelector)(_selectors.getApplication);
|
|
42
21
|
var auth = (0, _reactRedux.useSelector)(function (state) {
|
|
43
22
|
return state.auth;
|
|
44
23
|
});
|
|
45
24
|
return {
|
|
46
|
-
isAuthenticated:
|
|
25
|
+
isAuthenticated: (_application$isLogged = application === null || application === void 0 ? void 0 : application.isLoggedIn) !== null && _application$isLogged !== void 0 ? _application$isLogged : false,
|
|
47
26
|
errorMessage: auth.error,
|
|
48
27
|
resetErrors: function resetErrors() {
|
|
49
28
|
return dispatch((0, _actions.resetAuthErrors)());
|
|
@@ -60,41 +39,14 @@ var useLogin = function useLogin() {
|
|
|
60
39
|
exports.useLogin = useLogin;
|
|
61
40
|
|
|
62
41
|
var useLogout = function useLogout() {
|
|
42
|
+
var _application$isLogged2;
|
|
43
|
+
|
|
63
44
|
var dispatch = (0, _reactRedux.useDispatch)();
|
|
64
45
|
var application = (0, _reactRedux.useSelector)(_selectors.getApplication);
|
|
65
|
-
var auth = (0, _reactRedux.useSelector)(function (state) {
|
|
66
|
-
var _state$auth;
|
|
67
|
-
|
|
68
|
-
return ((_state$auth = state.auth) === null || _state$auth === void 0 ? void 0 : _state$auth.isAuthenticated) || false;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
var _useState = (0, _react.useState)(false),
|
|
72
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
73
|
-
cancel = _useState2[0],
|
|
74
|
-
setCancel = _useState2[1];
|
|
75
|
-
|
|
76
|
-
var _useState3 = (0, _react.useState)(function () {
|
|
77
|
-
return getIsAuthenticated(auth, application);
|
|
78
|
-
}),
|
|
79
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
80
|
-
isAuthenticated = _useState4[0],
|
|
81
|
-
setIsAuthenticated = _useState4[1]; // set cancel to true when the component this hook is used on, has been unmounted
|
|
82
|
-
// prevents state changes after unmount
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
(0, _react.useEffect)(function () {
|
|
86
|
-
return function () {
|
|
87
|
-
setCancel(true);
|
|
88
|
-
};
|
|
89
|
-
}, []);
|
|
90
46
|
return {
|
|
91
|
-
isAuthenticated:
|
|
47
|
+
isAuthenticated: (_application$isLogged2 = application === null || application === void 0 ? void 0 : application.isLoggedIn) !== null && _application$isLogged2 !== void 0 ? _application$isLogged2 : false,
|
|
92
48
|
logout: function logout() {
|
|
93
|
-
return dispatch((0, _actions.logout)())
|
|
94
|
-
if (!cancel) {
|
|
95
|
-
setIsAuthenticated(false);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
49
|
+
return dispatch((0, _actions.logout)());
|
|
98
50
|
}
|
|
99
51
|
};
|
|
100
52
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { useSelector, useDispatch } from "react-redux";
|
|
3
|
+
|
|
3
4
|
import { getApplication } from "../redux/_modularui/selectors";
|
|
4
5
|
import { login, logout, resetAuthErrors } from "../redux/actions";
|
|
5
|
-
import UserServicesModel from "../models/user/UserServicesModel";
|
|
6
|
-
import { useState, useEffect } from "react";
|
|
7
6
|
|
|
8
7
|
import type { ResetAuthErrorsAction } from "../redux/types";
|
|
9
8
|
type LoginHook = {
|
|
@@ -17,19 +16,6 @@ type LogoutHook = {
|
|
|
17
16
|
logout: () => void,
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
const getIsAuthenticated = (isAuthenticated, application) => {
|
|
21
|
-
if (!application) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const userServicesModel = application.userServices;
|
|
26
|
-
if (userServicesModel instanceof UserServicesModel) {
|
|
27
|
-
return isAuthenticated && userServicesModel.isLoggedIn;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
19
|
/**
|
|
34
20
|
*/
|
|
35
21
|
export const useLogin = (): LoginHook => {
|
|
@@ -39,7 +25,7 @@ export const useLogin = (): LoginHook => {
|
|
|
39
25
|
const auth = useSelector((state) => state.auth);
|
|
40
26
|
|
|
41
27
|
return {
|
|
42
|
-
isAuthenticated:
|
|
28
|
+
isAuthenticated: application?.isLoggedIn ?? false,
|
|
43
29
|
errorMessage: auth.error,
|
|
44
30
|
resetErrors: () => dispatch(resetAuthErrors()),
|
|
45
31
|
login: (username: string, password: string) =>
|
|
@@ -52,28 +38,9 @@ export const useLogin = (): LoginHook => {
|
|
|
52
38
|
export const useLogout = (): LogoutHook => {
|
|
53
39
|
const dispatch = useDispatch();
|
|
54
40
|
const application = useSelector(getApplication);
|
|
55
|
-
const auth = useSelector((state) => state.auth?.isAuthenticated || false);
|
|
56
|
-
|
|
57
|
-
const [cancel, setCancel] = useState(false);
|
|
58
|
-
const [isAuthenticated, setIsAuthenticated] = useState(() =>
|
|
59
|
-
getIsAuthenticated(auth, application)
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// set cancel to true when the component this hook is used on, has been unmounted
|
|
63
|
-
// prevents state changes after unmount
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
return () => {
|
|
66
|
-
setCancel(true);
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
41
|
|
|
70
42
|
return {
|
|
71
|
-
isAuthenticated,
|
|
72
|
-
logout: () =>
|
|
73
|
-
dispatch(logout()).then(() => {
|
|
74
|
-
if (!cancel) {
|
|
75
|
-
setIsAuthenticated(false);
|
|
76
|
-
}
|
|
77
|
-
}),
|
|
43
|
+
isAuthenticated: application?.isLoggedIn ?? false,
|
|
44
|
+
logout: () => dispatch(logout()),
|
|
78
45
|
};
|
|
79
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthentication.js","names":["
|
|
1
|
+
{"version":3,"file":"useAuthentication.js","names":["useLogin","dispatch","useDispatch","application","useSelector","getApplication","auth","state","isAuthenticated","isLoggedIn","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","useLogout","logout"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { getApplication } from \"../redux/_modularui/selectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\ntype LoginHook = {\n isAuthenticated: boolean,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n logout: () => void,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n const dispatch = useDispatch();\n\n const application = useSelector(getApplication);\n const auth = useSelector((state) => state.auth);\n\n return {\n isAuthenticated: application?.isLoggedIn ?? false,\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n const application = useSelector(getApplication);\n\n return {\n isAuthenticated: application?.isLoggedIn ?? false,\n logout: () => dispatch(logout()),\n };\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AAcA;AACA;AACO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,GAAiB;EAAA;;EACvC,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EAEA,IAAMC,WAAW,GAAG,IAAAC,uBAAA,EAAYC,yBAAZ,CAApB;EACA,IAAMC,IAAI,GAAG,IAAAF,uBAAA,EAAY,UAACG,KAAD;IAAA,OAAWA,KAAK,CAACD,IAAjB;EAAA,CAAZ,CAAb;EAEA,OAAO;IACLE,eAAe,2BAAEL,WAAF,aAAEA,WAAF,uBAAEA,WAAW,CAAEM,UAAf,yEAA6B,KADvC;IAELC,YAAY,EAAEJ,IAAI,CAACK,KAFd;IAGLC,WAAW,EAAE;MAAA,OAAMX,QAAQ,CAAC,IAAAY,wBAAA,GAAD,CAAd;IAAA,CAHR;IAILC,KAAK,EAAE,eAACC,QAAD,EAAmBC,QAAnB;MAAA,OACLf,QAAQ,CAAC,IAAAa,cAAA,EAAMC,QAAN,EAAgBC,QAAhB,CAAD,CADH;IAAA;EAJF,CAAP;AAOD,CAbM;AAeP;AACA;;;;;AACO,IAAMC,SAAS,GAAG,SAAZA,SAAY,GAAkB;EAAA;;EACzC,IAAMhB,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EACA,IAAMC,WAAW,GAAG,IAAAC,uBAAA,EAAYC,yBAAZ,CAApB;EAEA,OAAO;IACLG,eAAe,4BAAEL,WAAF,aAAEA,WAAF,uBAAEA,WAAW,CAAEM,UAAf,2EAA6B,KADvC;IAELS,MAAM,EAAE;MAAA,OAAMjB,QAAQ,CAAC,IAAAiB,eAAA,GAAD,CAAd;IAAA;EAFH,CAAP;AAID,CARM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.js","names":["useContentFromSourceReferences","sourceReferences","renderChildSections","content","setContent","localeCode","state","i18n","locale","start","finish","hrefs","sourceReference","link","selfhref","href","index","self","indexOf","toString","allHrefs","requests","JSON","parse","modularuiRequest","ModularUIRequest","fetchContent","all","then","responseContent"],"sources":["../../src/hooks/useContent.js"],"sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\nimport { useSelector } from \"react-redux\";\n\nimport SourceReferenceCollection from \"../models/concepts/SourceReferenceCollection\";\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport { useProgressIndicator } from \"../hooks/useProgressIndicator\";\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 = useSelector((state) => state.i18n.locale ?? \"en\");\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;;AACA;;AAEA;;AACA;;AAEA;;AAIA;AACA;AACA;AACO,IAAMA,8BAA8B,GAAG,SAAjCA,8BAAiC,CAC5CC,gBAD4C,EAE5CC,mBAF4C,EAGpB;EAAA;;EACxB,gBAA8B,
|
|
1
|
+
{"version":3,"file":"useContent.js","names":["useContentFromSourceReferences","sourceReferences","renderChildSections","useState","content","setContent","localeCode","useSelector","state","i18n","locale","useProgressIndicator","start","finish","hrefs","sourceReference","link","selfhref","href","index","self","indexOf","toString","allHrefs","useEffect","requests","JSON","parse","modularuiRequest","ModularUIRequest","fetchContent","all","then","responseContent"],"sources":["../../src/hooks/useContent.js"],"sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\nimport { useSelector } from \"react-redux\";\n\nimport SourceReferenceCollection from \"../models/concepts/SourceReferenceCollection\";\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport { useProgressIndicator } from \"../hooks/useProgressIndicator\";\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 = useSelector((state) => state.i18n.locale ?? \"en\");\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;;AACA;;AAEA;;AACA;;AAEA;;AAIA;AACA;AACA;AACO,IAAMA,8BAA8B,GAAG,SAAjCA,8BAAiC,CAC5CC,gBAD4C,EAE5CC,mBAF4C,EAGpB;EAAA;;EACxB,gBAA8B,IAAAC,eAAA,EAAS,EAAT,CAA9B;EAAA;EAAA,IAAOC,OAAP;EAAA,IAAgBC,UAAhB;;EACA,IAAMC,UAAU,GAAG,IAAAC,uBAAA,EAAY,UAACC,KAAD;IAAA;;IAAA,6BAAWA,KAAK,CAACC,IAAN,CAAWC,MAAtB,mEAAgC,IAAhC;EAAA,CAAZ,CAAnB;;EAEA,4BAA0B,IAAAC,2CAAA,GAA1B;EAAA,IAAQC,KAAR,yBAAQA,KAAR;EAAA,IAAeC,MAAf,yBAAeA,MAAf;;EAEA,IAAMC,KAAK,GAAG,gFAAAb,gBAAgB,MAAhB,CAAAA,gBAAgB,EACvB,UAACc,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,wBAAeT,KAAf,CAAjB;EACA,IAAAU,gBAAA,EAAU,YAAM;IAAA;;IACd,IAAMC,QAAQ,GAAG,8BAAAC,IAAI,CAACC,KAAL,CAAWJ,QAAX,mBAAyB,UAACL,IAAD,EAAU;MAClD,IAAMU,gBAAgB,GAAG,IAAIC,yBAAJ,CAAqBX,IAArB,CAAzB;MACAU,gBAAgB,CAAClB,MAAjB,GAA0BJ,UAA1B;MACA,OAAOsB,gBAAgB,CAACE,YAAjB,CAA8B5B,mBAA9B,CAAP;IACD,CAJgB,CAAjB;IAMAU,KAAK;;IACL,iBAAQmB,GAAR,CAAYN,QAAZ,EAAsBO,IAAtB,CAA2B,UAACC,eAAD,EAAqB;MAC9C5B,UAAU,CAAC4B,eAAD,CAAV;MACApB,MAAM;IACP,CAHD,EARc,CAad;IACA;;EACD,CAfD,EAeG,CAACU,QAAD,EAAWjB,UAAX,EAAuBJ,mBAAvB,CAfH;EAiBA,OAAOE,OAAP;AACD,CAjCM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepCompareEffect.js","names":["useDeepCompareMemoize","value","ref","React","useRef","signalRef","current","useDeepCompareEffect","callback","dependencies","useEffect"],"sources":["../../src/hooks/useDeepCompareEffect.js"],"sourcesContent":["// @flow\nimport * as React from \"react\";\nimport { dequal as deepEqual } from \"dequal/lite\";\n\ntype Callback = () => void | (() => void);\ntype DependencyList = Array<mixed>;\n\n/**\n * As copied from https://github.com/kentcdodds/use-deep-compare-effect/\n * Need to copy this, because the dependency on dequal breaks in ie11\n */\nconst useDeepCompareMemoize = (value: DependencyList) => {\n const ref = React.useRef<DependencyList | null>(null); // NOSONAR\n const signalRef = React.useRef<number>(0);\n\n if (!deepEqual(value, ref.current)) {\n ref.current = value;\n signalRef.current += 1;\n }\n\n return [signalRef.current];\n};\n\n/**\n */\nexport function useDeepCompareEffect(\n callback: Callback,\n dependencies: DependencyList\n): void {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useEffect(callback, useDeepCompareMemoize(dependencies));\n}\n\nexport default useDeepCompareEffect;\n"],"mappings":";;;;;;;;;;;;;;AACA;;AACA;;;;;;AAKA;AACA;AACA;AACA;AACA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,KAAD,EAA2B;EACvD,IAAMC,GAAG,GAAGC,KAAK,CAACC,MAAN,CAAoC,IAApC,CAAZ,CADuD,CACA;;EACvD,IAAMC,SAAS,GAAGF,KAAK,CAACC,MAAN,CAAqB,CAArB,CAAlB;;EAEA,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"useDeepCompareEffect.js","names":["useDeepCompareMemoize","value","ref","React","useRef","signalRef","deepEqual","current","useDeepCompareEffect","callback","dependencies","useEffect"],"sources":["../../src/hooks/useDeepCompareEffect.js"],"sourcesContent":["// @flow\nimport * as React from \"react\";\nimport { dequal as deepEqual } from \"dequal/lite\";\n\ntype Callback = () => void | (() => void);\ntype DependencyList = Array<mixed>;\n\n/**\n * As copied from https://github.com/kentcdodds/use-deep-compare-effect/\n * Need to copy this, because the dependency on dequal breaks in ie11\n */\nconst useDeepCompareMemoize = (value: DependencyList) => {\n const ref = React.useRef<DependencyList | null>(null); // NOSONAR\n const signalRef = React.useRef<number>(0);\n\n if (!deepEqual(value, ref.current)) {\n ref.current = value;\n signalRef.current += 1;\n }\n\n return [signalRef.current];\n};\n\n/**\n */\nexport function useDeepCompareEffect(\n callback: Callback,\n dependencies: DependencyList\n): void {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useEffect(callback, useDeepCompareMemoize(dependencies));\n}\n\nexport default useDeepCompareEffect;\n"],"mappings":";;;;;;;;;;;;;;AACA;;AACA;;;;;;AAKA;AACA;AACA;AACA;AACA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,KAAD,EAA2B;EACvD,IAAMC,GAAG,GAAGC,KAAK,CAACC,MAAN,CAAoC,IAApC,CAAZ,CADuD,CACA;;EACvD,IAAMC,SAAS,GAAGF,KAAK,CAACC,MAAN,CAAqB,CAArB,CAAlB;;EAEA,IAAI,CAAC,IAAAE,YAAA,EAAUL,KAAV,EAAiBC,GAAG,CAACK,OAArB,CAAL,EAAoC;IAClCL,GAAG,CAACK,OAAJ,GAAcN,KAAd;IACAI,SAAS,CAACE,OAAV,IAAqB,CAArB;EACD;;EAED,OAAO,CAACF,SAAS,CAACE,OAAX,CAAP;AACD,CAVD;AAYA;AACA;;;AACO,SAASC,oBAAT,CACLC,QADK,EAELC,YAFK,EAGC;EACN;EACA,OAAOP,KAAK,CAACQ,SAAN,CAAgBF,QAAhB,EAA0BT,qBAAqB,CAACU,YAAD,CAA/C,CAAP;AACD;;eAEcF,oB"}
|
package/lib/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["useForm","href","formHref","Href","addParameter","form","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateModelAction,\n} from \"../redux/_modularui\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateModelAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateModelAction,\n cancel: (object: FormObjectModel) => UpdateModelAction,\n remove: (object: FormObjectModel) => UpdateModelAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAUA;;AA6BA;AACA;AACA;AACO,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAqC;EAC1D,IAAMC,QAAQ,GAAG,IAAIC,aAAJ,CAASF,IAAT,CAAjB;;EAEA,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["useForm","href","formHref","Href","getSetting","addParameter","form","useModularUI","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","useDispatch","previous","previousObject","cancel","cancelForm","submit","loadModularUI","connectKey","selfhref","data","formdata","updateModel","remove","removeModelByKey","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","updateFormAttribute","useAttributeSet","save","addRepeatableAttributeSet","cancelRepeatableAttributeSet","removeRepeatableAttributeSet"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateModelAction,\n} from \"../redux/_modularui\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateModelAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateModelAction,\n cancel: (object: FormObjectModel) => UpdateModelAction,\n remove: (object: FormObjectModel) => UpdateModelAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAUA;;AA6BA;AACA;AACA;AACO,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAqC;EAC1D,IAAMC,QAAQ,GAAG,IAAIC,aAAJ,CAASF,IAAT,CAAjB;;EAEA,IAAI,CAAC,IAAAG,qBAAA,EAAW,oBAAX,CAAL,EAAuC;IACrCF,QAAQ,CAACG,YAAT,CAAsB,QAAtB,EAAgC,OAAhC;EACD;;EAED,IAAMC,IAAI,GAAG,IAAAC,0BAAA,EAAa,MAAb,EAAqBL,QAArB,EAA+B;IAC1CM,MAAM,EAAEC,uBAAA,CAAaC,IADqB;IAE1CC,WAAW,EAAEC,kBAF6B;IAG1CC,eAAe,EAAE;EAHyB,CAA/B,CAAb;;EAMA,IAAIP,IAAJ,aAAIA,IAAJ,eAAIA,IAAI,CAAEQ,KAAV,EAAiB;IACf,OAAOR,IAAI,CAACQ,KAAZ;EACD;AACF,CAhBM;AAkBP;AACA;AACA;;;;;AACO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,GAA0B;EACzD,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;;EAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACZ,IAAD;IAAA,OAAqBU,QAAQ,CAAC,IAAAG,uBAAA,EAAeb,IAAf,CAAD,CAA7B;EAAA,CAAjB;;EAEA,IAAMc,MAAM,GAAG,SAATA,MAAS,CAACd,IAAD;IAAA,OAAqBU,QAAQ,CAAC,IAAAK,mBAAA,EAAWf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,IAAD,EAAuC;EACpE,IAAMU,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EAEA,OAAO;IACLuB,IAAI,EAAE;MAAA,OAAMxB,QAAQ,CAAC,IAAAyB,kCAAA,EAA0BnC,IAA1B,CAAD,CAAd;IAAA,CADD;IAELc,MAAM,EAAE,gBAACc,MAAD;MAAA,OACNlB,QAAQ,CAAC,IAAA0B,qCAAA,EAA6BpC,IAA7B,EAAmC4B,MAAnC,CAAD,CADF;IAAA,CAFH;IAILL,MAAM,EAAE,gBAACK,MAAD;MAAA,OACNlB,QAAQ,CAAC,IAAA2B,qCAAA,EAA6BrC,IAA7B,EAAmC4B,MAAnC,CAAD,CADF;IAAA;EAJH,CAAP;AAOD,CAVM"}
|
package/lib/hooks/useI18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.js","names":["getLocaleCode","state","i18n","locale","getLocales","locales","getMessage","localeCode","id","defaultMessage","placeholders","getLocale","args","useMessage","useTranslate"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\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 (\n id?: string | null,\n defaultMessage?: string | null,\n placeholders?: Object\n ) =>\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 | null,\n defaultMessage?: string | null,\n placeholders?: Object | null\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\nexport { useTranslate, useMessage };\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;AAEA,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,
|
|
1
|
+
{"version":3,"file":"useI18n.js","names":["getLocaleCode","state","i18n","locale","getLocales","locales","getMessage","createSelector","localeCode","memoize","id","defaultMessage","placeholders","getLocale","args","useMessage","useSelector","useTranslate"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\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 (\n id?: string | null,\n defaultMessage?: string | null,\n placeholders?: Object\n ) =>\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 | null,\n defaultMessage?: string | null,\n placeholders?: Object | null\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\nexport { useTranslate, useMessage };\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;AAEA,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,UACEC,EADF,EAEEC,cAFF,EAGEC,YAHF;IAAA,OAKEP,OAAO,CACJQ,SADH,CACaL,UADb,EAEGF,UAFH,CAEcI,EAFd,EAEkBC,cAFlB,EAEkCC,YAFlC,CALF;EAAA,CADF,EASE;IAAA,kCAAIE,IAAJ;MAAIA,IAAJ;IAAA;;IAAA,OAAa,wBAAeA,IAAf,CAAb;EAAA,CATF,CADF;AAAA,CAFiB,CAAnB;AAgBA;AACA;;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACjBL,EADiB,EAEjBC,cAFiB,EAGjBC,YAHiB;EAAA,OAIT,IAAAI,uBAAA,EAAYV,UAAZ,EAAwBI,EAAxB,EAA4BC,cAA5B,EAA4CC,YAA5C,CAJS;AAAA,CAAnB;AAMA;AACA;;;;;AACA,IAAMK,YAAY,GAAG,SAAfA,YAAe;EAAA,OAAyB,IAAAD,uBAAA,EAAYV,UAAZ,CAAzB;AAAA,CAArB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModal.js","names":["useModal","modalId","IllegalArgumentException","dispatch","modal","modals","m","key","show","close","size","visible"],"sources":["../../src/hooks/useModal.js"],"sourcesContent":["// @flow\nimport { useCallback } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { showModal, closeModal } from \"../redux/actions/Modals\";\nimport { IllegalArgumentException } from \"../exceptions\";\n\ntype ModalHook = (modalId: string) => {\n key: string | null,\n size: string | null,\n visible: boolean,\n show: () => void,\n close: () => void,\n};\n\n/**\n * Manage modals\n */\nexport const useModal: ModalHook = (modalId: string) => {\n if (!modalId) {\n throw new IllegalArgumentException(\n \"Missing modalId argument for useModal hook\"\n );\n }\n\n const dispatch = useDispatch();\n const modal = useSelector(({ modals }) =>\n modals.modals.find((m) => m.key === modalId)\n );\n\n const show = useCallback(() => {\n dispatch(showModal(modalId));\n }, [dispatch, modalId]);\n\n const close = useCallback(() => {\n dispatch(closeModal(modalId));\n }, [dispatch, modalId]);\n\n return {\n key: modal ? modal.key : null,\n size: modal ? modal.size : null,\n visible: modal ? modal.visible : false,\n show,\n close,\n };\n};\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAUA;AACA;AACA;AACO,IAAMA,QAAmB,GAAG,SAAtBA,QAAsB,CAACC,OAAD,EAAqB;EACtD,IAAI,CAACA,OAAL,EAAc;IACZ,MAAM,IAAIC,oCAAJ,CACJ,4CADI,CAAN;EAGD;;EAED,IAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"useModal.js","names":["useModal","modalId","IllegalArgumentException","dispatch","useDispatch","modal","useSelector","modals","m","key","show","useCallback","showModal","close","closeModal","size","visible"],"sources":["../../src/hooks/useModal.js"],"sourcesContent":["// @flow\nimport { useCallback } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { showModal, closeModal } from \"../redux/actions/Modals\";\nimport { IllegalArgumentException } from \"../exceptions\";\n\ntype ModalHook = (modalId: string) => {\n key: string | null,\n size: string | null,\n visible: boolean,\n show: () => void,\n close: () => void,\n};\n\n/**\n * Manage modals\n */\nexport const useModal: ModalHook = (modalId: string) => {\n if (!modalId) {\n throw new IllegalArgumentException(\n \"Missing modalId argument for useModal hook\"\n );\n }\n\n const dispatch = useDispatch();\n const modal = useSelector(({ modals }) =>\n modals.modals.find((m) => m.key === modalId)\n );\n\n const show = useCallback(() => {\n dispatch(showModal(modalId));\n }, [dispatch, modalId]);\n\n const close = useCallback(() => {\n dispatch(closeModal(modalId));\n }, [dispatch, modalId]);\n\n return {\n key: modal ? modal.key : null,\n size: modal ? modal.size : null,\n visible: modal ? modal.visible : false,\n show,\n close,\n };\n};\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AAUA;AACA;AACA;AACO,IAAMA,QAAmB,GAAG,SAAtBA,QAAsB,CAACC,OAAD,EAAqB;EACtD,IAAI,CAACA,OAAL,EAAc;IACZ,MAAM,IAAIC,oCAAJ,CACJ,4CADI,CAAN;EAGD;;EAED,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EACA,IAAMC,KAAK,GAAG,IAAAC,uBAAA,EAAY;IAAA;;IAAA,IAAGC,MAAH,QAAGA,MAAH;IAAA,OACxB,8BAAAA,MAAM,CAACA,MAAP,iBAAmB,UAACC,CAAD;MAAA,OAAOA,CAAC,CAACC,GAAF,KAAUR,OAAjB;IAAA,CAAnB,CADwB;EAAA,CAAZ,CAAd;EAIA,IAAMS,IAAI,GAAG,IAAAC,kBAAA,EAAY,YAAM;IAC7BR,QAAQ,CAAC,IAAAS,iBAAA,EAAUX,OAAV,CAAD,CAAR;EACD,CAFY,EAEV,CAACE,QAAD,EAAWF,OAAX,CAFU,CAAb;EAIA,IAAMY,KAAK,GAAG,IAAAF,kBAAA,EAAY,YAAM;IAC9BR,QAAQ,CAAC,IAAAW,kBAAA,EAAWb,OAAX,CAAD,CAAR;EACD,CAFa,EAEX,CAACE,QAAD,EAAWF,OAAX,CAFW,CAAd;EAIA,OAAO;IACLQ,GAAG,EAAEJ,KAAK,GAAGA,KAAK,CAACI,GAAT,GAAe,IADpB;IAELM,IAAI,EAAEV,KAAK,GAAGA,KAAK,CAACU,IAAT,GAAgB,IAFtB;IAGLC,OAAO,EAAEX,KAAK,GAAGA,KAAK,CAACW,OAAT,GAAmB,KAH5B;IAILN,IAAI,EAAJA,IAJK;IAKLG,KAAK,EAALA;EALK,CAAP;AAOD,CA3BM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["useModelCatalog","expectedModels","targetModel","ModelCatalogModel","useConceptIndex","href","ConceptIndexModel","getHref","context","dynamic","location","replace","search","useConceptDetail","concept","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","contentSection","ContentModel","useContentType","contentType","ContentTypeModel"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (href: string): ?ConceptIndexModel =>\n useModularUIBasic(\"conceptindex\", href, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n\nconst getHref = (context, dynamic, location) => {\n let href = dynamic;\n if (!href.startsWith(`/${context}/`)) {\n href = `/${context}/${href}`;\n }\n\n href = href.replace(/\\/\\//g, \"/\");\n\n if (location?.search) {\n href = `${href}${location.search}`;\n }\n\n return href;\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = getHref(\"concepts\", concept, location);\n return useModularUIBasic(\"conceptdetail\", href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (href: string): ?ContentIndexModel =>\n useModularUIBasic(\"contentindex\", href, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n\n/**\n */\nexport const useContentTOC = (content: string): ?ContentTOCModel => {\n const location = useLocation();\n const href = getHref(\"content\", content, location);\n return useModularUIBasic(\"contenttoc\", href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (contentSection: string): ?ContentModel => {\n const href = getHref(\"content\", contentSection);\n return useModularUIBasic(\"content\", href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (contentType: string): ?ContentTypeModel => {\n const href = getHref(\"contenttypes\", contentType);\n return useModularUIBasic(\"contenttypes\", href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n"],"mappings":";;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;AACA;AACO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB;EAAA,OAC7B,
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["useModelCatalog","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","useConceptIndex","href","ConceptIndexModel","getHref","context","dynamic","location","replace","search","useConceptDetail","concept","useLocation","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","contentSection","ContentModel","useContentType","contentType","ContentTypeModel"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (href: string): ?ConceptIndexModel =>\n useModularUIBasic(\"conceptindex\", href, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n\nconst getHref = (context, dynamic, location) => {\n let href = dynamic;\n if (!href.startsWith(`/${context}/`)) {\n href = `/${context}/${href}`;\n }\n\n href = href.replace(/\\/\\//g, \"/\");\n\n if (location?.search) {\n href = `${href}${location.search}`;\n }\n\n return href;\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = getHref(\"concepts\", concept, location);\n return useModularUIBasic(\"conceptdetail\", href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (href: string): ?ContentIndexModel =>\n useModularUIBasic(\"contentindex\", href, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n\n/**\n */\nexport const useContentTOC = (content: string): ?ContentTOCModel => {\n const location = useLocation();\n const href = getHref(\"content\", content, location);\n return useModularUIBasic(\"contenttoc\", href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (contentSection: string): ?ContentModel => {\n const href = getHref(\"content\", contentSection);\n return useModularUIBasic(\"content\", href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (contentType: string): ?ContentTypeModel => {\n const href = getHref(\"contenttypes\", contentType);\n return useModularUIBasic(\"contenttypes\", href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n"],"mappings":";;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;AACA;AACO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB;EAAA,OAC7B,IAAAC,oCAAA,EAAkB,cAAlB,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load","model","options"],"sources":["../../src/hooks/useModels.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport { reloadModel } from \"../redux/_modularui/actions\";\n\nimport type { ModularUIModel } from \"../models/types\";\n\ntype UseModels = () => {\n reload: (model: ModularUIModel, options?: any) => void,\n};\n\n/**\n * Hook that contains the reload property that can be used to reload a model\n */\nexport const useModels: UseModels = () => {\n const dispatch = useDispatch();\n return {\n reload: (model: ModularUIModel, options?: Object) => {\n dispatch(reloadModel(model, options));\n },\n };\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AAQA;AACA;AACA;AACO,IAAMA,SAAoB,GAAG,SAAvBA,SAAuB,GAAM;EACxC,IAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"useModels.js","names":["useModels","dispatch","useDispatch","reload","model","options","reloadModel"],"sources":["../../src/hooks/useModels.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport { reloadModel } from \"../redux/_modularui/actions\";\n\nimport type { ModularUIModel } from \"../models/types\";\n\ntype UseModels = () => {\n reload: (model: ModularUIModel, options?: any) => void,\n};\n\n/**\n * Hook that contains the reload property that can be used to reload a model\n */\nexport const useModels: UseModels = () => {\n const dispatch = useDispatch();\n return {\n reload: (model: ModularUIModel, options?: Object) => {\n dispatch(reloadModel(model, options));\n },\n };\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AAQA;AACA;AACA;AACO,IAAMA,SAAoB,GAAG,SAAvBA,SAAuB,GAAM;EACxC,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EACA,OAAO;IACLC,MAAM,EAAE,gBAACC,KAAD,EAAwBC,OAAxB,EAA6C;MACnDJ,QAAQ,CAAC,IAAAK,oBAAA,EAAYF,KAAZ,EAAmBC,OAAnB,CAAD,CAAR;IACD;EAHI,CAAP;AAKD,CAPM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUI.js","names":["useKeyForHook","modelKey","url","locale","state","i18n","split","useModularUI","options","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","href","toString","key","prevOptions","prevHref","isOldReload","current","isReload","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 type Href from \"../models/href/Href\";\nimport type { RequestBaseOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useSelector((state) => state.i18n.locale);\n\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;;AACA;;AAEA;;AACA;;AAEA;;AAKA;AACA;AACA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,QAAD,EAAmBC,GAAnB,EAAmC;EAAA;;EACvD,IAAMC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"useModularUI.js","names":["useKeyForHook","modelKey","url","locale","useSelector","state","i18n","split","useModularUI","options","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","prevOptions","useRef","prevHref","useDeepCompareEffect","isOldReload","current","isReload","loadModularUI","useEffect","removeModelByKey","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 type Href from \"../models/href/Href\";\nimport type { RequestBaseOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useSelector((state) => state.i18n.locale);\n\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};\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AT,GAAmBR,IAAnB;EACD,CAbD,EAaG,CAACE,GAAD,EAAMF,IAAN,EAAYP,OAAZ,CAbH;EAeA,4BAAoCA,OAApC,CAAQI,eAAR;EAAA,IAAQA,eAAR,sCAA0B,KAA1B;EACA,IAAAc,gBAAA,EAAU,YAAM;IACd,OAAO,YAAM;MACX,IAAId,eAAJ,EAAqB;QACnBC,QAAQ,CAAC,IAAAc,yBAAA,EAAiBV,GAAjB,CAAD,CAAR;MACD;IACF,CAJD;EAKD,CAND,EAMG,CAACJ,QAAD,EAAWI,GAAX,EAAgBL,eAAhB,CANH,EAzBQ,CAiCR;;EACA,OAAO,IAAAT,uBAAA,EAAY,UAACC,KAAD,EAAW;IAC5B,OAAOA,KAAK,CAACwB,SAAN,CAAgBX,GAAhB,CAAP;EACD,CAFM,CAAP;AAGD,CA5CM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIBasic.js","names":["useModularUIBasic","key","href","options","expectedModels","targetModel","undefined","location","IllegalArgumentException","useModularUIOptions","state","reload","pathname","toString","isReload","modularUI","model","length","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T> = {\n expectedModels: Array<string>,\n targetModel?: Class<T>,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n }\n): ?T => {\n const location = useLocation();\n if (!href) {\n throw new IllegalArgumentException(\"Missing href\");\n }\n\n const useModularUIOptions = {};\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AAEA;;AASA;AACA;AACO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAC/BC,GAD+B,EAE/BC,IAF+B,EAOxB;EAAA;;EAAA,IAJPC,OAIO,uEAJgC;IACrCC,cAAc,EAAE,EADqB;IAErCC,WAAW,EAAEC;EAFwB,CAIhC;EACP,IAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["useModularUIBasic","key","href","options","expectedModels","targetModel","undefined","location","useLocation","IllegalArgumentException","useModularUIOptions","state","reload","pathname","toString","isReload","modularUI","useModularUI","model","length","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T> = {\n expectedModels: Array<string>,\n targetModel?: Class<T>,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n }\n): ?T => {\n const location = useLocation();\n if (!href) {\n throw new IllegalArgumentException(\"Missing href\");\n }\n\n const useModularUIOptions = {};\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAEA;;AAEA;;AASA;AACA;AACO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAC/BC,GAD+B,EAE/BC,IAF+B,EAOxB;EAAA;;EAAA,IAJPC,OAIO,uEAJgC;IACrCC,cAAc,EAAE,EADqB;IAErCC,WAAW,EAAEC;EAFwB,CAIhC;EACP,IAAMC,QAAQ,GAAG,IAAAC,sBAAA,GAAjB;;EACA,IAAI,CAACN,IAAL,EAAW;IACT,MAAM,IAAIO,oCAAJ,CAA6B,cAA7B,CAAN;EACD;;EAED,IAAMC,mBAAmB,GAAG,EAA5B;;EACA,IAAIP,OAAO,CAACE,WAAZ,EAAyB;IACvBK,mBAAmB,CAACL,WAApB,GAAkCF,OAAO,CAACE,WAA1C;EACD,CATM,CAWP;;;EACA,IAAI,mBAAAE,QAAQ,CAACI,KAAT,4DAAgBC,MAAhB,IAA0B,oCAAAL,QAAQ,CAACM,QAAT,iBAA6BX,IAAI,CAACY,QAAL,EAA7B,CAA9B,EAA6E;IAC3EJ,mBAAmB,CAACK,QAApB,GAA+B,IAA/B;EACD;;EAED,IAAMC,SAAS,GAAG,IAAAC,0BAAA,EAAahB,GAAb,EAAkBC,IAAlB,EAAwBQ,mBAAxB,CAAlB;;EAEA,IAAIM,SAAJ,aAAIA,SAAJ,eAAIA,SAAS,CAAEE,KAAf,EAAsB;IACpB,IAAQA,KAAR,GAAkBF,SAAlB,CAAQE,KAAR;;IACA,IAAIf,OAAO,CAACC,cAAR,CAAuBe,MAAvB,GAAgC,CAApC,EAAuC;MACrC,IAAMC,cAAc,GAAGjB,OAAO,CAACC,cAAR,CAAuBiB,IAAvB,CAA4B,UAACC,aAAD,EAAmB;QACpE,OAAOJ,KAAK,CAACK,IAAN,KAAeD,aAAtB;MACD,CAFsB,CAAvB;;MAIA,IAAI,CAACF,cAAL,EAAqB;QACnBI,OAAO,CAACC,KAAR,CAAcT,SAAd,EAAyB,oBAAzB,EAA+Cb,OAAO,CAACC,cAAvD;QACA,MAAM,IAAIsB,iCAAJ,CAA0B,mCAA1B,CAAN;MACD;IACF;;IAED,OAAOR,KAAP;EACD;AACF,CAxCM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIModel.js","names":["useApplication","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListDetail","ListDetailModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","DetailModel","useQuicksearch","CaseSearchModel","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ?ApplicationModel =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): ?TabModel =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): ?CaseViewModel =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ?ListModel | ?GroupingPanelModel | ?DetailModel =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ?ListModel =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListDetail = (href: string): ?ListDetailModel =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): ?GroupingPanelModel =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): ?DetailModel =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): ?CaseSearchModel =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): ?UserProfileModel =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;AACA;AACA;AACO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB;EAAA,OAC5B,
|
|
1
|
+
{"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListDetail","ListDetailModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","DetailModel","useQuicksearch","CaseSearchModel","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ?ApplicationModel =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): ?TabModel =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): ?CaseViewModel =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ?ListModel | ?GroupingPanelModel | ?DetailModel =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ?ListModel =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListDetail = (href: string): ?ListDetailModel =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): ?GroupingPanelModel =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): ?DetailModel =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): ?CaseSearchModel =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): ?UserProfileModel =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;AACA;AACA;AACO,IAAMA,cAAc,GAAG,SAAjBA,cAAiB;EAAA,OAC5B,IAAAC,oCAAA,EAAkB,aAAlB,EAAiC,GAAjC,EAAsC;IACpCC,cAAc,EAAE,CAAC,aAAD,CADoB;IAEpCC,WAAW,EAAEC;EAFuB,CAAtC,CAD4B;AAAA,CAAvB;AAMP;AACA;AACA;;;;;AACO,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,IAAD;EAAA,OACpB,IAAAL,oCAAA,EAAkB,KAAlB,EAAyBK,IAAzB,EAA+B;IAC7BJ,cAAc,EAAE,CAAC,KAAD,CADa;IAE7BC,WAAW,EAAEI;EAFgB,CAA/B,CADoB;AAAA,CAAf;AAMP;AACA;AACA;;;;;AACO,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACF,IAAD;EAAA,OACzB,IAAAL,oCAAA,EAAkB,UAAlB,EAA8BK,IAA9B,EAAoC;IAClCJ,cAAc,EAAE,CAAC,UAAD,CADkB;IAElCC,WAAW,EAAEM;EAFqB,CAApC,CADyB;AAAA,CAApB;AAMP;AACA;;;;;AACO,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CACtBJ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AAD,CADqB;IAErCC,WAAW,EAAEiB;EAFwB,CAAvC,CAD4B;AAAA,CAAvB;AAMP;AACA;;;;;AACO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACf,IAAD;EAAA,OAC5B,IAAAL,oCAAA,EAAkB,aAAlB,EAAiCK,IAAjC,EAAuC;IACrCJ,cAAc,EAAE,CAAC,aAAD,CADqB;IAErCC,WAAW,EAAEmB;EAFwB,CAAvC,CAD4B;AAAA,CAAvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","state","i18n","locale","localeCode","href","options","request","ModularUIRequest","useModularUIRequest"],"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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotification.js","names":["useNotification","dispatch","state","notification","render","messageType","message","error","dismiss"],"sources":["../../src/hooks/useNotification.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { dismissNotification } from \"../redux/actions\";\n\nimport type {\n DismissNotificationAction,\n NotificationState,\n} from \"../redux/types\";\ntype NotificationHook = {\n ...NotificationState,\n dismiss: () => DismissNotificationAction,\n};\n\n/**\n */\nexport const useNotification = (): NotificationHook => {\n const dispatch = useDispatch();\n const { render, messageType, message, error } = useSelector(\n (state) => state.notification\n );\n\n return {\n render,\n messageType,\n message,\n error,\n dismiss: () => dispatch(dismissNotification()),\n };\n};\n"],"mappings":";;;;;;;AACA;;AACA;;AAWA;AACA;AACO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,GAAwB;EACrD,IAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"useNotification.js","names":["useNotification","dispatch","useDispatch","useSelector","state","notification","render","messageType","message","error","dismiss","dismissNotification"],"sources":["../../src/hooks/useNotification.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { dismissNotification } from \"../redux/actions\";\n\nimport type {\n DismissNotificationAction,\n NotificationState,\n} from \"../redux/types\";\ntype NotificationHook = {\n ...NotificationState,\n dismiss: () => DismissNotificationAction,\n};\n\n/**\n */\nexport const useNotification = (): NotificationHook => {\n const dispatch = useDispatch();\n const { render, messageType, message, error } = useSelector(\n (state) => state.notification\n );\n\n return {\n render,\n messageType,\n message,\n error,\n dismiss: () => dispatch(dismissNotification()),\n };\n};\n"],"mappings":";;;;;;;AACA;;AACA;;AAWA;AACA;AACO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,GAAwB;EACrD,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;;EACA,mBAAgD,IAAAC,uBAAA,EAC9C,UAACC,KAAD;IAAA,OAAWA,KAAK,CAACC,YAAjB;EAAA,CAD8C,CAAhD;EAAA,IAAQC,MAAR,gBAAQA,MAAR;EAAA,IAAgBC,WAAhB,gBAAgBA,WAAhB;EAAA,IAA6BC,OAA7B,gBAA6BA,OAA7B;EAAA,IAAsCC,KAAtC,gBAAsCA,KAAtC;;EAIA,OAAO;IACLH,MAAM,EAANA,MADK;IAELC,WAAW,EAAXA,WAFK;IAGLC,OAAO,EAAPA,OAHK;IAILC,KAAK,EAALA,KAJK;IAKLC,OAAO,EAAE;MAAA,OAAMT,QAAQ,CAAC,IAAAU,4BAAA,GAAD,CAAd;IAAA;EALJ,CAAP;AAOD,CAbM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreference.js","names":["usePreference","preferenceNames","requestedPreferences","Array","isArray","state","preferences"],"sources":["../../src/hooks/usePreference.js"],"sourcesContent":["// @flow\nimport pick from \"lodash/pick\";\nimport { useSelector } from \"react-redux\";\n\nimport type { PreferencesState } from \"../redux/types\";\n\n/**\n */\nexport const usePreference = (\n preferenceNames: string | Array<string>\n): PreferencesState => {\n const requestedPreferences = Array.isArray(preferenceNames)\n ? preferenceNames\n : [preferenceNames];\n\n return useSelector((state) => pick(state.preferences, requestedPreferences));\n};\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAIA;AACA;AACO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAC3BC,eAD2B,EAEN;EACrB,IAAMC,oBAAoB,GAAGC,KAAK,CAACC,OAAN,CAAcH,eAAd,IACzBA,eADyB,GAEzB,CAACA,eAAD,CAFJ;EAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"usePreference.js","names":["usePreference","preferenceNames","requestedPreferences","Array","isArray","useSelector","state","pick","preferences"],"sources":["../../src/hooks/usePreference.js"],"sourcesContent":["// @flow\nimport pick from \"lodash/pick\";\nimport { useSelector } from \"react-redux\";\n\nimport type { PreferencesState } from \"../redux/types\";\n\n/**\n */\nexport const usePreference = (\n preferenceNames: string | Array<string>\n): PreferencesState => {\n const requestedPreferences = Array.isArray(preferenceNames)\n ? preferenceNames\n : [preferenceNames];\n\n return useSelector((state) => pick(state.preferences, requestedPreferences));\n};\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAIA;AACA;AACO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAC3BC,eAD2B,EAEN;EACrB,IAAMC,oBAAoB,GAAGC,KAAK,CAACC,OAAN,CAAcH,eAAd,IACzBA,eADyB,GAEzB,CAACA,eAAD,CAFJ;EAIA,OAAO,IAAAI,uBAAA,EAAY,UAACC,KAAD;IAAA,OAAW,IAAAC,aAAA,EAAKD,KAAK,CAACE,WAAX,EAAwBN,oBAAxB,CAAX;EAAA,CAAZ,CAAP;AACD,CARM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProgressIndicator.js","names":["useProgressIndicator","dispatch","progress","state","progressindicator","start","finish","reset","update","percentComplete"],"sources":["../../src/hooks/useProgressIndicator.js"],"sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport {\n startProgress,\n finishProgress,\n resetProgress,\n updateProgress,\n} from \"../redux/actions/ProgressIndicator\";\nimport type { ProgressIndicatorState } from \"../redux/types\";\n\ntype ProgressIndicatorHook = {\n ...ProgressIndicatorState,\n start: () => void,\n finish: () => void,\n reset: () => void,\n update: (percentComplete: number) => void,\n};\n\n/**\n */\nexport const useProgressIndicator = (): ProgressIndicatorHook => {\n const dispatch = useDispatch();\n const progress = useSelector((state) => state.progressindicator);\n\n return {\n ...progress,\n start: () => dispatch(startProgress()),\n finish: () => dispatch(finishProgress()),\n reset: () => dispatch(resetProgress()),\n update: (percentComplete: number) =>\n dispatch(updateProgress(percentComplete)),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;AAgBA;AACA;AACO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,GAA6B;EAC/D,IAAMC,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"useProgressIndicator.js","names":["useProgressIndicator","dispatch","useDispatch","progress","useSelector","state","progressindicator","start","startProgress","finish","finishProgress","reset","resetProgress","update","percentComplete","updateProgress"],"sources":["../../src/hooks/useProgressIndicator.js"],"sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport {\n startProgress,\n finishProgress,\n resetProgress,\n updateProgress,\n} from \"../redux/actions/ProgressIndicator\";\nimport type { ProgressIndicatorState } from \"../redux/types\";\n\ntype ProgressIndicatorHook = {\n ...ProgressIndicatorState,\n start: () => void,\n finish: () => void,\n reset: () => void,\n update: (percentComplete: number) => void,\n};\n\n/**\n */\nexport const useProgressIndicator = (): ProgressIndicatorHook => {\n const dispatch = useDispatch();\n const progress = useSelector((state) => state.progressindicator);\n\n return {\n ...progress,\n start: () => dispatch(startProgress()),\n finish: () => dispatch(finishProgress()),\n reset: () => dispatch(resetProgress()),\n update: (percentComplete: number) =>\n dispatch(updateProgress(percentComplete)),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;AAgBA;AACA;AACO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,GAA6B;EAC/D,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EACA,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,EAAY,UAACC,KAAD;IAAA,OAAWA,KAAK,CAACC,iBAAjB;EAAA,CAAZ,CAAjB;EAEA,uCACKH,QADL;IAEEI,KAAK,EAAE;MAAA,OAAMN,QAAQ,CAAC,IAAAO,gCAAA,GAAD,CAAd;IAAA,CAFT;IAGEC,MAAM,EAAE;MAAA,OAAMR,QAAQ,CAAC,IAAAS,iCAAA,GAAD,CAAd;IAAA,CAHV;IAIEC,KAAK,EAAE;MAAA,OAAMV,QAAQ,CAAC,IAAAW,gCAAA,GAAD,CAAd;IAAA,CAJT;IAKEC,MAAM,EAAE,gBAACC,eAAD;MAAA,OACNb,QAAQ,CAAC,IAAAc,iCAAA,EAAeD,eAAf,CAAD,CADF;IAAA;EALV;AAQD,CAZM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRouter.js","names":["useLocation","state","router","location","useLocationKey","key","useQuerystring","search","usePathname","pathname","useNavigation","dispatch","push","replace","go","delta","goBack","goForward"],"sources":["../../src/hooks/useRouter.js"],"sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport type { Location, LocationShape } from \"react-router\";\n\nimport { push, replace, go, goBack, goForward } from \"../redux/_router/actions\";\nimport type {\n GoAction,\n GoBackAction,\n GoForwardAction,\n PushAction,\n ReplaceAction,\n} from \"../redux\";\n\ntype UseLocationHook = () => Location;\ntype UseLocationKeyHook = () => string;\ntype UseQuerystringHook = () => string;\ntype UsePathnameHook = () => string;\ntype UseNavigationHook = () => {\n push: (location: LocationShape | string, state?: { ... }) => PushAction,\n replace: (location: LocationShape | string, state?: { ... }) => ReplaceAction,\n go: (delta: number) => GoAction,\n goBack: () => GoBackAction,\n goForward: () => GoForwardAction,\n};\n\n/**\n */\nexport const useLocation: UseLocationHook = () =>\n useSelector((state) => state.router.location);\n\n/**\n */\nexport const useLocationKey: UseLocationKeyHook = () =>\n useLocation()?.key ?? \"\";\n\n/**\n */\nexport const useQuerystring: UseQuerystringHook = () => useLocation()?.search;\n\n/**\n */\nexport const usePathname: UsePathnameHook = () => useLocation()?.pathname;\n\n/**\n */\nexport const useNavigation: UseNavigationHook = () => {\n const dispatch = useDispatch();\n\n return {\n push: (location: LocationShape | string, state?: { ... }) =>\n dispatch(push(location, state)),\n replace: (location: LocationShape | string, state?: { ... }) =>\n dispatch(replace(location, state)),\n go: (delta: number) => dispatch(go(delta)),\n goBack: () => dispatch(goBack()),\n goForward: () => dispatch(goForward()),\n };\n};\n"],"mappings":";;;;;;;AACA;;AAGA;;AAqBA;AACA;AACO,IAAMA,WAA4B,GAAG,SAA/BA,WAA+B;EAAA,OAC1C,
|
|
1
|
+
{"version":3,"file":"useRouter.js","names":["useLocation","useSelector","state","router","location","useLocationKey","key","useQuerystring","search","usePathname","pathname","useNavigation","dispatch","useDispatch","push","replace","go","delta","goBack","goForward"],"sources":["../../src/hooks/useRouter.js"],"sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport type { Location, LocationShape } from \"react-router\";\n\nimport { push, replace, go, goBack, goForward } from \"../redux/_router/actions\";\nimport type {\n GoAction,\n GoBackAction,\n GoForwardAction,\n PushAction,\n ReplaceAction,\n} from \"../redux\";\n\ntype UseLocationHook = () => Location;\ntype UseLocationKeyHook = () => string;\ntype UseQuerystringHook = () => string;\ntype UsePathnameHook = () => string;\ntype UseNavigationHook = () => {\n push: (location: LocationShape | string, state?: { ... }) => PushAction,\n replace: (location: LocationShape | string, state?: { ... }) => ReplaceAction,\n go: (delta: number) => GoAction,\n goBack: () => GoBackAction,\n goForward: () => GoForwardAction,\n};\n\n/**\n */\nexport const useLocation: UseLocationHook = () =>\n useSelector((state) => state.router.location);\n\n/**\n */\nexport const useLocationKey: UseLocationKeyHook = () =>\n useLocation()?.key ?? \"\";\n\n/**\n */\nexport const useQuerystring: UseQuerystringHook = () => useLocation()?.search;\n\n/**\n */\nexport const usePathname: UsePathnameHook = () => useLocation()?.pathname;\n\n/**\n */\nexport const useNavigation: UseNavigationHook = () => {\n const dispatch = useDispatch();\n\n return {\n push: (location: LocationShape | string, state?: { ... }) =>\n dispatch(push(location, state)),\n replace: (location: LocationShape | string, state?: { ... }) =>\n dispatch(replace(location, state)),\n go: (delta: number) => dispatch(go(delta)),\n goBack: () => dispatch(goBack()),\n goForward: () => dispatch(goForward()),\n };\n};\n"],"mappings":";;;;;;;AACA;;AAGA;;AAqBA;AACA;AACO,IAAMA,WAA4B,GAAG,SAA/BA,WAA+B;EAAA,OAC1C,IAAAC,uBAAA,EAAY,UAACC,KAAD;IAAA,OAAWA,KAAK,CAACC,MAAN,CAAaC,QAAxB;EAAA,CAAZ,CAD0C;AAAA,CAArC;AAGP;AACA;;;;;AACO,IAAMC,cAAkC,GAAG,SAArCA,cAAqC;EAAA;;EAAA,2CAChDL,WAAW,EADqC,iDAChD,aAAeM,GADiC,+DAC1B,EAD0B;AAAA,CAA3C;AAGP;AACA;;;;;AACO,IAAMC,cAAkC,GAAG,SAArCA,cAAqC;EAAA;;EAAA,wBAAMP,WAAW,EAAjB,kDAAM,cAAeQ,MAArB;AAAA,CAA3C;AAEP;AACA;;;;;AACO,IAAMC,WAA4B,GAAG,SAA/BA,WAA+B;EAAA;;EAAA,wBAAMT,WAAW,EAAjB,kDAAM,cAAeU,QAArB;AAAA,CAArC;AAEP;AACA;;;;;AACO,IAAMC,aAAgC,GAAG,SAAnCA,aAAmC,GAAM;EACpD,IAAMC,QAAQ,GAAG,IAAAC,uBAAA,GAAjB;EAEA,OAAO;IACLC,IAAI,EAAE,cAACV,QAAD,EAAmCF,KAAnC;MAAA,OACJU,QAAQ,CAAC,IAAAE,aAAA,EAAKV,QAAL,EAAeF,KAAf,CAAD,CADJ;IAAA,CADD;IAGLa,OAAO,EAAE,iBAACX,QAAD,EAAmCF,KAAnC;MAAA,OACPU,QAAQ,CAAC,IAAAG,gBAAA,EAAQX,QAAR,EAAkBF,KAAlB,CAAD,CADD;IAAA,CAHJ;IAKLc,EAAE,EAAE,YAACC,KAAD;MAAA,OAAmBL,QAAQ,CAAC,IAAAI,WAAA,EAAGC,KAAH,CAAD,CAA3B;IAAA,CALC;IAMLC,MAAM,EAAE;MAAA,OAAMN,QAAQ,CAAC,IAAAM,eAAA,GAAD,CAAd;IAAA,CANH;IAOLC,SAAS,EAAE;MAAA,OAAMP,QAAQ,CAAC,IAAAO,kBAAA,GAAD,CAAd;IAAA;EAPN,CAAP;AASD,CAZM"}
|
package/lib/i18n/Locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locale.js","names":["Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","console","debug","fixPlaceHolders","parameters","getBaseMessage"],"sources":["../../src/i18n/Locale.js"],"sourcesContent":["// @flow\nimport formatMessage from \"format-message\";\n\nimport languages from \"./languages\";\nimport { IllegalStateException } from \"../exceptions\";\n\nimport { getSetting } from \"../constants\";\n\nimport type { LocaleConfiguration, MessageParameters } from \"./types\";\n\n/**\n * Create a locale\n */\nclass Locale {\n _code: string;\n _messages: { [string]: string };\n _errors: { [string]: string };\n _nativeName: ?string;\n\n constructor(locale: LocaleConfiguration) {\n this._code = locale.code;\n\n this._messages = this.fixPlaceHoldersInObject(locale.messages);\n this._errors = this.fixPlaceHoldersInObject(locale.errors);\n\n this._nativeName = locale.nativeName;\n\n formatMessage.setup({\n missingTranslation: \"ignore\",\n });\n }\n\n /**\n * Retrieve locale code\n */\n get code(): string {\n return this._code;\n }\n\n /**\n * Retrieve nativeName\n */\n get nativeName(): string {\n if (this._nativeName) {\n return this._nativeName;\n }\n\n const aLocale = this.code.split(\"-\");\n\n if (aLocale.length > 0) {\n const language = languages.lang[aLocale[0]];\n\n if (language) {\n return (\n language[1] + (aLocale[1] ? ` (${aLocale[1].toUpperCase()})` : \"\")\n );\n }\n }\n\n throw new IllegalStateException(\n `Can not find language name based on locale: ${this.code}`\n );\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHolders(message: ?string): null | string {\n if (typeof message === \"string\") {\n return message\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\");\n }\n\n return null;\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHoldersInObject(messages: Object = {}): Object {\n return JSON.parse(\n JSON.stringify(messages)\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\")\n );\n }\n\n /**\n * Retrieve message by id\n */\n getBaseMessage(id: string, defaultMessage?: string): string {\n if (!id && !defaultMessage) {\n return \"[message: id or defaultMessage missing]\";\n }\n\n const messageFromLocale = this._messages[id] || this._errors[id];\n\n if (\n (typeof process === \"undefined\" ||\n process.env.NODE_ENV !== \"production\") &&\n !messageFromLocale &&\n id &&\n getSetting(\"DEBUG_I18N_MESSAGE_NOT_FOUND\")\n ) {\n // eslint-disable-next-line no-console\n console.debug(\n `Message with id ${id} not found for locale ${this.code} in layout translations`\n );\n }\n return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;\n }\n\n /**\n * Format message using formatMessage library\n */\n formatMessage(message: string, parameters?: MessageParameters): string {\n if (parameters) {\n return formatMessage(message, parameters);\n }\n\n return message;\n }\n\n /**\n * Retrieve a messages with replaced parameters\n */\n getMessage(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ): string {\n const message = this.getBaseMessage(id, defaultMessage);\n return this.formatMessage(message, parameters);\n }\n\n /**\n * Add or change messages for this locale. It is not possible to remove messages.\n */\n update(messages: Object = {}, errors: Object = {}) {\n this._messages = {\n ...this._messages,\n ...this.fixPlaceHoldersInObject(messages),\n };\n\n this._errors = {\n ...this._errors,\n ...this.fixPlaceHoldersInObject(errors),\n };\n }\n}\n\nexport default Locale;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;;;;;;;AAIA;AACA;AACA;IACMA,M;EAMJ,gBAAYC,MAAZ,EAAyC;IAAA;IAAA;IAAA;IAAA;IAAA;IACvC,KAAKC,KAAL,GAAaD,MAAM,CAACE,IAApB;IAEA,KAAKC,SAAL,GAAiB,KAAKC,uBAAL,CAA6BJ,MAAM,CAACK,QAApC,CAAjB;IACA,KAAKC,OAAL,GAAe,KAAKF,uBAAL,CAA6BJ,MAAM,CAACO,MAApC,CAAf;IAEA,KAAKC,WAAL,GAAmBR,MAAM,CAACS,UAA1B;;IAEAC,
|
|
1
|
+
{"version":3,"file":"Locale.js","names":["Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","getSetting","console","debug","fixPlaceHolders","parameters","getBaseMessage"],"sources":["../../src/i18n/Locale.js"],"sourcesContent":["// @flow\nimport formatMessage from \"format-message\";\n\nimport languages from \"./languages\";\nimport { IllegalStateException } from \"../exceptions\";\n\nimport { getSetting } from \"../constants\";\n\nimport type { LocaleConfiguration, MessageParameters } from \"./types\";\n\n/**\n * Create a locale\n */\nclass Locale {\n _code: string;\n _messages: { [string]: string };\n _errors: { [string]: string };\n _nativeName: ?string;\n\n constructor(locale: LocaleConfiguration) {\n this._code = locale.code;\n\n this._messages = this.fixPlaceHoldersInObject(locale.messages);\n this._errors = this.fixPlaceHoldersInObject(locale.errors);\n\n this._nativeName = locale.nativeName;\n\n formatMessage.setup({\n missingTranslation: \"ignore\",\n });\n }\n\n /**\n * Retrieve locale code\n */\n get code(): string {\n return this._code;\n }\n\n /**\n * Retrieve nativeName\n */\n get nativeName(): string {\n if (this._nativeName) {\n return this._nativeName;\n }\n\n const aLocale = this.code.split(\"-\");\n\n if (aLocale.length > 0) {\n const language = languages.lang[aLocale[0]];\n\n if (language) {\n return (\n language[1] + (aLocale[1] ? ` (${aLocale[1].toUpperCase()})` : \"\")\n );\n }\n }\n\n throw new IllegalStateException(\n `Can not find language name based on locale: ${this.code}`\n );\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHolders(message: ?string): null | string {\n if (typeof message === \"string\") {\n return message\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\");\n }\n\n return null;\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHoldersInObject(messages: Object = {}): Object {\n return JSON.parse(\n JSON.stringify(messages)\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\")\n );\n }\n\n /**\n * Retrieve message by id\n */\n getBaseMessage(id: string, defaultMessage?: string): string {\n if (!id && !defaultMessage) {\n return \"[message: id or defaultMessage missing]\";\n }\n\n const messageFromLocale = this._messages[id] || this._errors[id];\n\n if (\n (typeof process === \"undefined\" ||\n process.env.NODE_ENV !== \"production\") &&\n !messageFromLocale &&\n id &&\n getSetting(\"DEBUG_I18N_MESSAGE_NOT_FOUND\")\n ) {\n // eslint-disable-next-line no-console\n console.debug(\n `Message with id ${id} not found for locale ${this.code} in layout translations`\n );\n }\n return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;\n }\n\n /**\n * Format message using formatMessage library\n */\n formatMessage(message: string, parameters?: MessageParameters): string {\n if (parameters) {\n return formatMessage(message, parameters);\n }\n\n return message;\n }\n\n /**\n * Retrieve a messages with replaced parameters\n */\n getMessage(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ): string {\n const message = this.getBaseMessage(id, defaultMessage);\n return this.formatMessage(message, parameters);\n }\n\n /**\n * Add or change messages for this locale. It is not possible to remove messages.\n */\n update(messages: Object = {}, errors: Object = {}) {\n this._messages = {\n ...this._messages,\n ...this.fixPlaceHoldersInObject(messages),\n };\n\n this._errors = {\n ...this._errors,\n ...this.fixPlaceHoldersInObject(errors),\n };\n }\n}\n\nexport default Locale;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;;;;;;;AAIA;AACA;AACA;IACMA,M;EAMJ,gBAAYC,MAAZ,EAAyC;IAAA;IAAA;IAAA;IAAA;IAAA;IACvC,KAAKC,KAAL,GAAaD,MAAM,CAACE,IAApB;IAEA,KAAKC,SAAL,GAAiB,KAAKC,uBAAL,CAA6BJ,MAAM,CAACK,QAApC,CAAjB;IACA,KAAKC,OAAL,GAAe,KAAKF,uBAAL,CAA6BJ,MAAM,CAACO,MAApC,CAAf;IAEA,KAAKC,WAAL,GAAmBR,MAAM,CAACS,UA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locales.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locales.js","names":["availableLocales","code","messages","errors","englishErrors","dutchErrors","createLocalesWithConfiguredErrors","configuredErrors","availableLocale","Locales","locales","locale","Locale","localeCode","some","item","hasLocale","IllegalArgumentException","acceptLanguageHeader","acceptLanguages","match","preferredLocales","availableLocaleCodes","length","getLocale","update","add","hydatedLocales","_collection","_code","_messages","_errors","BaseCollection"],"sources":["../../src/i18n/Locales.js"],"sourcesContent":["// @flow\nimport Locale from \"./Locale\";\n\nimport englishErrors from \"./translations/beinformed_error_messages_en.nl\";\nimport dutchErrors from \"./translations/beinformed_error_messages_nl.nl\";\n\nimport BaseCollection from \"../models/base/BaseCollection\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport type { LocaleConfiguration } from \"./types\";\n\ntype ErrorMessageObject = {\n [languageCode: string]: {\n [messageID: string]: string,\n },\n};\n\ntype HydratedLocales = {\n _collection: Array<{\n _code: string,\n _messages: {\n [string]: string,\n },\n _errors: {\n [string]: string,\n },\n }>,\n};\n\n/**\n * Array of available locales\n * Order of locales is the preferred order of locales.\n * When user has an accept language header that does not correspond to the locales array,\n * the first one is used as the preferred language\n */\nexport const availableLocales: Array<LocaleConfiguration> = [\n {\n code: \"en\",\n messages: {},\n errors: englishErrors,\n },\n {\n code: \"nl\",\n messages: {},\n errors: dutchErrors,\n },\n];\n\n/**\n * Merge an object with custom error messages (exported and translated from be informed for example) and merge them with the existing translations.\n */\nexport const createLocalesWithConfiguredErrors = (\n configuredErrors: ErrorMessageObject\n): Array<Object> =>\n availableLocales.map((availableLocale) => {\n if (configuredErrors[availableLocale.code]) {\n return {\n ...availableLocale,\n errors: {\n ...availableLocale.errors,\n ...configuredErrors[availableLocale.code],\n },\n };\n }\n\n return availableLocale;\n });\n\n/**\n * Locales, collection of Locale\n */\nclass Locales extends BaseCollection<Locale> {\n constructor(locales: Array<LocaleConfiguration> = availableLocales) {\n super(locales.map((locale) => new Locale(locale)));\n }\n\n /**\n * rehydrate\n */\n static rehydrate(hydatedLocales: HydratedLocales): Locales {\n if (hydatedLocales && hydatedLocales._collection) {\n return new Locales(\n hydatedLocales._collection.map((locale) => ({\n code: locale._code,\n messages: locale._messages,\n errors: locale._errors,\n }))\n );\n }\n\n return new Locales([]);\n }\n\n /**\n * Check if locale with localeCode exists\n */\n hasLocale(localeCode: string): boolean {\n return this.some((item) => localeCode.startsWith(item.code));\n }\n\n /**\n * Retrieve locales by localeCode from Locales collection\n */\n getLocale(localeCode: string): Locale {\n if (this.hasLocale(localeCode)) {\n const locale = this.find((item) => localeCode.startsWith(item.code));\n if (locale) {\n return locale;\n }\n }\n throw new IllegalArgumentException(\n `Locale configuration for locale ${localeCode} not found`\n );\n }\n\n /**\n * Retrieve all available locale codes\n */\n get availableLocaleCodes(): Array<string> {\n return this.map((locale) => locale.code);\n }\n\n /**\n * Retrieve preferred locale based on the accept header of a browser\n */\n getPreferredLocale(acceptLanguageHeader: string | null): void | string {\n if (acceptLanguageHeader != null) {\n const acceptLanguages =\n acceptLanguageHeader.match(/[-A-Za-z]{2,10}/gu) || [];\n\n const preferredLocales = acceptLanguages\n .filter((locale) =>\n this.availableLocaleCodes.some((availableLocale) =>\n locale.startsWith(availableLocale)\n )\n )\n .map((locale) =>\n this.availableLocaleCodes.find((availableLocale) =>\n locale.startsWith(availableLocale)\n )\n );\n\n if (preferredLocales.length > 0) {\n return preferredLocales[0];\n }\n }\n\n return this.availableLocaleCodes[0];\n }\n\n /**\n * Add or change messages and errors for the given locale.<br>\n * It is not possible to remove messages.\n */\n update(locale: string, messages: Object = {}, errors: Object = {}) {\n if (this.hasLocale(locale)) {\n this.getLocale(locale).update(messages, errors);\n } else {\n this.add(\n new Locale({\n code: locale,\n messages,\n errors,\n })\n );\n }\n }\n}\n\nexport default Locales;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;;;;;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AAU,yBAAAF,UAAU,MAAV,CAAAA,UAAU,EAAYE,IAAI,CAACd,IAAjB,CAApB;QAAA,CAAV,CAAf;;QACA,IAAIU,MAAJ,EAAY;UACV,OAAOA,MAAP;QACD;MACF;;MACD,MAAM,IAAIM,oCAAJ,2CAC+BJ,UAD/B,gBAAN;IAGD;IAED;AACF;AACA;;;;SACE,eAA0C;MAAA;;MACxC,OAAO,oDAAS,UAACF,MAAD;QAAA,OAAYA,MAAM,CAACV,IAAnB;MAAA,CAAT,CAAP;IACD;IAED;AACF;AACA;;;;WACE,4BAAmBiB,oBAAnB,EAAuE;MAAA;;MACrE,IAAIA,oBAAoB,IAAI,IAA5B,EAAkC;QAAA;;QAChC,IAAMC,eAAe,GACnBD,oBAAoB,CAACE,KAArB,CAA2B,qBAA3B,KAAmD,EADrD;QAGA,IAAMC,gBAAgB,GAAG,mDAAAF,eAAe,MAAf,CAAAA,eAAe,EAC9B,UAACR,MAAD;UAAA,OACN,KAAI,CAACW,oBAAL,CAA0BR,IAA1B,CAA+B,UAACN,eAAD;YAAA,OAC7B,yBAAAG,MAAM,MAAN,CAAAA,MAAM,EAAYH,eAAZ,CADuB;UAAA,CAA/B,CADM;QAAA,CAD8B,CAAf,kBAMlB,UAACG,MAAD;UAAA;;UAAA,OACH
|
|
1
|
+
{"version":3,"file":"Locales.js","names":["availableLocales","code","messages","errors","englishErrors","dutchErrors","createLocalesWithConfiguredErrors","configuredErrors","availableLocale","Locales","locales","locale","Locale","localeCode","some","item","hasLocale","IllegalArgumentException","acceptLanguageHeader","acceptLanguages","match","preferredLocales","availableLocaleCodes","length","getLocale","update","add","hydatedLocales","_collection","_code","_messages","_errors","BaseCollection"],"sources":["../../src/i18n/Locales.js"],"sourcesContent":["// @flow\nimport Locale from \"./Locale\";\n\nimport englishErrors from \"./translations/beinformed_error_messages_en.nl\";\nimport dutchErrors from \"./translations/beinformed_error_messages_nl.nl\";\n\nimport BaseCollection from \"../models/base/BaseCollection\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport type { LocaleConfiguration } from \"./types\";\n\ntype ErrorMessageObject = {\n [languageCode: string]: {\n [messageID: string]: string,\n },\n};\n\ntype HydratedLocales = {\n _collection: Array<{\n _code: string,\n _messages: {\n [string]: string,\n },\n _errors: {\n [string]: string,\n },\n }>,\n};\n\n/**\n * Array of available locales\n * Order of locales is the preferred order of locales.\n * When user has an accept language header that does not correspond to the locales array,\n * the first one is used as the preferred language\n */\nexport const availableLocales: Array<LocaleConfiguration> = [\n {\n code: \"en\",\n messages: {},\n errors: englishErrors,\n },\n {\n code: \"nl\",\n messages: {},\n errors: dutchErrors,\n },\n];\n\n/**\n * Merge an object with custom error messages (exported and translated from be informed for example) and merge them with the existing translations.\n */\nexport const createLocalesWithConfiguredErrors = (\n configuredErrors: ErrorMessageObject\n): Array<Object> =>\n availableLocales.map((availableLocale) => {\n if (configuredErrors[availableLocale.code]) {\n return {\n ...availableLocale,\n errors: {\n ...availableLocale.errors,\n ...configuredErrors[availableLocale.code],\n },\n };\n }\n\n return availableLocale;\n });\n\n/**\n * Locales, collection of Locale\n */\nclass Locales extends BaseCollection<Locale> {\n constructor(locales: Array<LocaleConfiguration> = availableLocales) {\n super(locales.map((locale) => new Locale(locale)));\n }\n\n /**\n * rehydrate\n */\n static rehydrate(hydatedLocales: HydratedLocales): Locales {\n if (hydatedLocales && hydatedLocales._collection) {\n return new Locales(\n hydatedLocales._collection.map((locale) => ({\n code: locale._code,\n messages: locale._messages,\n errors: locale._errors,\n }))\n );\n }\n\n return new Locales([]);\n }\n\n /**\n * Check if locale with localeCode exists\n */\n hasLocale(localeCode: string): boolean {\n return this.some((item) => localeCode.startsWith(item.code));\n }\n\n /**\n * Retrieve locales by localeCode from Locales collection\n */\n getLocale(localeCode: string): Locale {\n if (this.hasLocale(localeCode)) {\n const locale = this.find((item) => localeCode.startsWith(item.code));\n if (locale) {\n return locale;\n }\n }\n throw new IllegalArgumentException(\n `Locale configuration for locale ${localeCode} not found`\n );\n }\n\n /**\n * Retrieve all available locale codes\n */\n get availableLocaleCodes(): Array<string> {\n return this.map((locale) => locale.code);\n }\n\n /**\n * Retrieve preferred locale based on the accept header of a browser\n */\n getPreferredLocale(acceptLanguageHeader: string | null): void | string {\n if (acceptLanguageHeader != null) {\n const acceptLanguages =\n acceptLanguageHeader.match(/[-A-Za-z]{2,10}/gu) || [];\n\n const preferredLocales = acceptLanguages\n .filter((locale) =>\n this.availableLocaleCodes.some((availableLocale) =>\n locale.startsWith(availableLocale)\n )\n )\n .map((locale) =>\n this.availableLocaleCodes.find((availableLocale) =>\n locale.startsWith(availableLocale)\n )\n );\n\n if (preferredLocales.length > 0) {\n return preferredLocales[0];\n }\n }\n\n return this.availableLocaleCodes[0];\n }\n\n /**\n * Add or change messages and errors for the given locale.<br>\n * It is not possible to remove messages.\n */\n update(locale: string, messages: Object = {}, errors: Object = {}) {\n if (this.hasLocale(locale)) {\n this.getLocale(locale).update(messages, errors);\n } else {\n this.add(\n new Locale({\n code: locale,\n messages,\n errors,\n })\n );\n }\n }\n}\n\nexport default Locales;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;;;;;;;;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,gBAA4C,GAAG,CAC1D;EACEC,IAAI,EAAE,IADR;EAEEC,QAAQ,EAAE,EAFZ;EAGEC,MAAM,EAAEC;AAHV,CAD0D,EAM1D;EACEH,IAAI,EAAE,IADR;EAEEC,QAAQ,EAAE,EAFZ;EAGEC,MAAM,EAAEE;AAHV,CAN0D,CAArD;AAaP;AACA;AACA;;;;AACO,IAAMC,iCAAiC,GAAG,SAApCA,iCAAoC,CAC/CC,gBAD+C;EAAA,OAG/C,kBAAAP,gBAAgB,MAAhB,CAAAA,gBAAgB,EAAK,UAACQ,eAAD,EAAqB;IACxC,IAAID,gBAAgB,CAACC,eAAe,CAACP,IAAjB,CAApB,EAA4C;MA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;YAC1CV,IAAI,EAAEU,MAAM,CAACkB,KAD6B;YAE1C3B,QAAQ,EAAES,MAAM,CAACmB,SAFyB;YAG1C3B,MAAM,EAAEQ,MAAM,CAACoB;UAH2B,CAAb;QAAA,CAA/B,CADK,CAAP;MAOD;;MAED,OAAO,IAAItB,OAAJ,CAAY,EAAZ,CAAP;IACD;;;EApBmBuB,wB;;eAkGPvB,O"}
|
package/lib/i18n/Message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","names":["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 | 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,
|
|
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"}
|