@beinformed/ui 1.18.2 → 1.18.5
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 +21 -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/list/ListModel.js +1 -1
- package/esm/models/list/ListModel.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 +1 -1
- package/lib/models/list/ListModel.js.flow +1 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/list/__tests__/ListModel.spec.js.flow +13 -0
- 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/models/list/ListModel.js +1 -1
- package/src/models/list/__tests__/ListModel.spec.js +13 -0
- package/src/models/list/__tests__/related-contributions.json +42 -0
- package/src/models/list/__tests__/related-data.json +32 -0
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutHints.js","names":["getHint","hint","LayoutHintConfiguration","MANDATORY","DISABLED","DEPENDENT_ATTRIBUTE_CONTROL","DEPENDENT_ATTRIBUTE","CONFIRM_PASSWORD","SORT_OPTIONS","TITLE","IGNORE_FORMAT_SETTING","DELETE_ACTION","UPDATE_ACTION","CREATE_ACTION","INITIAL_TOTAL_FILESIZE","MAX_TOTAL_FILESIZE","SHOW_ONE_RESULT_AS_DETAIL","HIDE_WHEN_EMPTY","INITIAL_FILTER","CASEVIEW_LINK","RENDER_SECTION_LABEL","getLayoutHintConfiguration"],"sources":["../../src/constants/LayoutHints.js"],"sourcesContent":["// @flow\nimport { LayoutHintConfiguration } from \"./LayoutHintConfig\";\n\n/**\n * Retrieve layout hint by id from the layout hint configuration\n */\nconst getHint = (hint: string): string => {\n if (LayoutHintConfiguration[hint]) {\n return LayoutHintConfiguration[hint].hint;\n }\n\n return \"\";\n};\n\n/**\n * Layout-hint: Indicates a mandatory attribute. Should be used together with the dependency hint.\n */\nexport const MANDATORY: string = getHint(\"MANDATORY\");\n\n/**\n * Layout-hint: Indicates a disabled attribute.\n * @constant\n */\nexport const DISABLED: string = getHint(\"DISABLED\");\n\n/*\n * --------------------------------\n * SELECT DEPENDENT ATTRIBUTES\n * --------------------------------\n */\n/**\n * Layout-hint: Marks the choice attribute where other attributes depend on. The unique control id is a unique id that can be used in the hint for the show|hide action on the dependent attribute.\n */\nexport const DEPENDENT_ATTRIBUTE_CONTROL = \"dependent-control\";\n/**\n */\nexport const DEPENDENT_ATTRIBUTE = \"dependent-attribute:\";\n\n/*\n * --------------------------------\n * ATTRIBUTES\n * --------------------------------\n */\n/**\n * Layout-hint: Password attribute must be confirmed using a second password attribute.\n */\nexport const CONFIRM_PASSWORD: string = getHint(\"CONFIRM_PASSWORD\");\n/**\n * Layout-hint: Sort options alphabetically\n */\nexport const SORT_OPTIONS: string = getHint(\"SORT_OPTIONS\");\n/**\n * Layout-hint: Marks an attribute as a title attribute\n */\nexport const TITLE: string = getHint(\"TITLE\");\n/**\n * Layout-hint: Ignore the global input format for specific attribute\n */\nexport const IGNORE_FORMAT_SETTING: string = getHint(\"IGNORE_FORMAT_SETTING\");\n\n/*\n * --------------------------------\n * FORM\n * --------------------------------\n */\n/**\n * Layout-hint: Mark task as delete task\n */\nexport const DELETE_ACTION: string = getHint(\"DELETE_ACTION\");\n/**\n * Layout-hint: Mark task as update task\n */\nexport const UPDATE_ACTION: string = getHint(\"UPDATE_ACTION\");\n/**\n * Layout-hint: Mark task as create task\n */\nexport const CREATE_ACTION: string = getHint(\"CREATE_ACTION\");\n\n/*\n * --------------------------------\n * UPLOAD TOTAL FILE SIZE\n * --------------------------------\n */\n/**\n * Layout-hint: Used in conjunction with an upload attribute, this hint is set on a read only attribute containing the file size currently used.\n */\nexport const INITIAL_TOTAL_FILESIZE: string = getHint(\"INITIAL_TOTAL_FILESIZE\");\n/**\n * Layout-hint: Used in conjunction with an upload attribute, this hint is set on a read only attribute containing the maximum allowed total file size.\n */\nexport const MAX_TOTAL_FILESIZE: string = getHint(\"MAX_TOTAL_FILESIZE\");\n\n/*\n * --------------------------------\n * LISTS\n * --------------------------------\n */\n/**\n * Layout-hint: A list with only one detail must be shown as a detail\n */\nexport const SHOW_ONE_RESULT_AS_DETAIL: string = getHint(\n \"SHOW_ONE_RESULT_AS_DETAIL\"\n);\n/**\n * Layout-hint: A list without list-items and list-tasks should not be shown.\n */\nexport const HIDE_WHEN_EMPTY: string = getHint(\"HIDE_WHEN_EMPTY\");\n/**\n * Layout-hint: Sets a default value on a filter\n */\nexport const INITIAL_FILTER: string = \"initial-filter:\";\n/**\n * Layout-hint: Mark a case id reference attribute as the reference to the case view. Replaces the self link of a list item\n */\nexport const CASEVIEW_LINK: string = getHint(\"CASEVIEW_LINK\");\n\n/**\n * Layout-hint: Set on configuration of instruments to show content in a popover on a label\n */\nexport const RENDER_SECTION_LABEL = \"render-section-label\";\n\n/**\n */\nexport const getLayoutHintConfiguration = (): Object => LayoutHintConfiguration;\n\nexport default getHint;\n"],"mappings":";;;;;;;AACA;;AAEA;AACA;AACA;AACA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAA0B;EACxC,IAAIC,
|
|
1
|
+
{"version":3,"file":"LayoutHints.js","names":["getHint","hint","LayoutHintConfiguration","MANDATORY","DISABLED","DEPENDENT_ATTRIBUTE_CONTROL","DEPENDENT_ATTRIBUTE","CONFIRM_PASSWORD","SORT_OPTIONS","TITLE","IGNORE_FORMAT_SETTING","DELETE_ACTION","UPDATE_ACTION","CREATE_ACTION","INITIAL_TOTAL_FILESIZE","MAX_TOTAL_FILESIZE","SHOW_ONE_RESULT_AS_DETAIL","HIDE_WHEN_EMPTY","INITIAL_FILTER","CASEVIEW_LINK","RENDER_SECTION_LABEL","getLayoutHintConfiguration"],"sources":["../../src/constants/LayoutHints.js"],"sourcesContent":["// @flow\nimport { LayoutHintConfiguration } from \"./LayoutHintConfig\";\n\n/**\n * Retrieve layout hint by id from the layout hint configuration\n */\nconst getHint = (hint: string): string => {\n if (LayoutHintConfiguration[hint]) {\n return LayoutHintConfiguration[hint].hint;\n }\n\n return \"\";\n};\n\n/**\n * Layout-hint: Indicates a mandatory attribute. Should be used together with the dependency hint.\n */\nexport const MANDATORY: string = getHint(\"MANDATORY\");\n\n/**\n * Layout-hint: Indicates a disabled attribute.\n * @constant\n */\nexport const DISABLED: string = getHint(\"DISABLED\");\n\n/*\n * --------------------------------\n * SELECT DEPENDENT ATTRIBUTES\n * --------------------------------\n */\n/**\n * Layout-hint: Marks the choice attribute where other attributes depend on. The unique control id is a unique id that can be used in the hint for the show|hide action on the dependent attribute.\n */\nexport const DEPENDENT_ATTRIBUTE_CONTROL = \"dependent-control\";\n/**\n */\nexport const DEPENDENT_ATTRIBUTE = \"dependent-attribute:\";\n\n/*\n * --------------------------------\n * ATTRIBUTES\n * --------------------------------\n */\n/**\n * Layout-hint: Password attribute must be confirmed using a second password attribute.\n */\nexport const CONFIRM_PASSWORD: string = getHint(\"CONFIRM_PASSWORD\");\n/**\n * Layout-hint: Sort options alphabetically\n */\nexport const SORT_OPTIONS: string = getHint(\"SORT_OPTIONS\");\n/**\n * Layout-hint: Marks an attribute as a title attribute\n */\nexport const TITLE: string = getHint(\"TITLE\");\n/**\n * Layout-hint: Ignore the global input format for specific attribute\n */\nexport const IGNORE_FORMAT_SETTING: string = getHint(\"IGNORE_FORMAT_SETTING\");\n\n/*\n * --------------------------------\n * FORM\n * --------------------------------\n */\n/**\n * Layout-hint: Mark task as delete task\n */\nexport const DELETE_ACTION: string = getHint(\"DELETE_ACTION\");\n/**\n * Layout-hint: Mark task as update task\n */\nexport const UPDATE_ACTION: string = getHint(\"UPDATE_ACTION\");\n/**\n * Layout-hint: Mark task as create task\n */\nexport const CREATE_ACTION: string = getHint(\"CREATE_ACTION\");\n\n/*\n * --------------------------------\n * UPLOAD TOTAL FILE SIZE\n * --------------------------------\n */\n/**\n * Layout-hint: Used in conjunction with an upload attribute, this hint is set on a read only attribute containing the file size currently used.\n */\nexport const INITIAL_TOTAL_FILESIZE: string = getHint(\"INITIAL_TOTAL_FILESIZE\");\n/**\n * Layout-hint: Used in conjunction with an upload attribute, this hint is set on a read only attribute containing the maximum allowed total file size.\n */\nexport const MAX_TOTAL_FILESIZE: string = getHint(\"MAX_TOTAL_FILESIZE\");\n\n/*\n * --------------------------------\n * LISTS\n * --------------------------------\n */\n/**\n * Layout-hint: A list with only one detail must be shown as a detail\n */\nexport const SHOW_ONE_RESULT_AS_DETAIL: string = getHint(\n \"SHOW_ONE_RESULT_AS_DETAIL\"\n);\n/**\n * Layout-hint: A list without list-items and list-tasks should not be shown.\n */\nexport const HIDE_WHEN_EMPTY: string = getHint(\"HIDE_WHEN_EMPTY\");\n/**\n * Layout-hint: Sets a default value on a filter\n */\nexport const INITIAL_FILTER: string = \"initial-filter:\";\n/**\n * Layout-hint: Mark a case id reference attribute as the reference to the case view. Replaces the self link of a list item\n */\nexport const CASEVIEW_LINK: string = getHint(\"CASEVIEW_LINK\");\n\n/**\n * Layout-hint: Set on configuration of instruments to show content in a popover on a label\n */\nexport const RENDER_SECTION_LABEL = \"render-section-label\";\n\n/**\n */\nexport const getLayoutHintConfiguration = (): Object => LayoutHintConfiguration;\n\nexport default getHint;\n"],"mappings":";;;;;;;AACA;;AAEA;AACA;AACA;AACA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAA0B;EACxC,IAAIC,yCAAA,CAAwBD,IAAxB,CAAJ,EAAmC;IACjC,OAAOC,yCAAA,CAAwBD,IAAxB,EAA8BA,IAArC;EACD;;EAED,OAAO,EAAP;AACD,CAND;AAQA;AACA;AACA;;;AACO,IAAME,SAAiB,GAAGH,OAAO,CAAC,WAAD,CAAjC;AAEP;AACA;AACA;AACA;;;AACO,IAAMI,QAAgB,GAAGJ,OAAO,CAAC,UAAD,CAAhC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;EAAA,OAAcnB,yCAAd;AAAA,CAAnC;;;eAEQF,O"}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.setSettings = exports.setSetting = exports.logoutPath = exports.loginUsernameField = exports.loginPath = exports.loginPasswordField = exports.hasAllContentInData = exports.getSetting = exports.allSettings = void 0;
|
|
8
|
+
exports.setSettings = exports.setSetting = exports.logoutPath = exports.loginUsernameField = exports.loginType = exports.loginPath = exports.loginPasswordField = exports.hasAllContentInData = exports.getSetting = exports.allSettings = void 0;
|
|
9
9
|
|
|
10
10
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
11
11
|
|
|
@@ -112,13 +112,23 @@ var hasAllContentInData = function hasAllContentInData() {
|
|
|
112
112
|
return getSetting(_Constants.ALL_CONTENT_IN_DATA_SETTING, true);
|
|
113
113
|
};
|
|
114
114
|
/**
|
|
115
|
+
* Login type, only available when pac4j is configured
|
|
115
116
|
*/
|
|
116
117
|
|
|
117
118
|
|
|
118
119
|
exports.hasAllContentInData = hasAllContentInData;
|
|
119
120
|
|
|
121
|
+
var loginType = function loginType() {
|
|
122
|
+
return getSetting(_Constants.LOGIN_TYPE, "JAAS");
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
exports.loginType = loginType;
|
|
129
|
+
|
|
120
130
|
var loginPath = function loginPath() {
|
|
121
|
-
return getSetting(_Constants.LOGIN_PATH_SETTING, "
|
|
131
|
+
return getSetting(_Constants.LOGIN_PATH_SETTING, "/j_security_check");
|
|
122
132
|
};
|
|
123
133
|
/**
|
|
124
134
|
*/
|
|
@@ -145,7 +155,7 @@ var loginPasswordField = function loginPasswordField() {
|
|
|
145
155
|
exports.loginPasswordField = loginPasswordField;
|
|
146
156
|
|
|
147
157
|
var logoutPath = function logoutPath() {
|
|
148
|
-
return getSetting(_Constants.LOGOUT_PATH_SETTING, "
|
|
158
|
+
return getSetting(_Constants.LOGOUT_PATH_SETTING, "/Logoff");
|
|
149
159
|
};
|
|
150
160
|
|
|
151
161
|
exports.logoutPath = logoutPath;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { isPlainObject, has } from "../utils/helpers/objects";
|
|
3
3
|
import {
|
|
4
|
-
BASE,
|
|
5
4
|
ALL_CONTENT_IN_DATA_SETTING,
|
|
5
|
+
LOGIN_TYPE,
|
|
6
6
|
LOGIN_PATH_SETTING,
|
|
7
7
|
LOGIN_USERNAME_SETTING,
|
|
8
8
|
LOGIN_PASSWORD_SETTING,
|
|
@@ -123,10 +123,15 @@ export const allSettings = (): { [name: string]: Setting } => settings;
|
|
|
123
123
|
export const hasAllContentInData = (): boolean =>
|
|
124
124
|
getSetting(ALL_CONTENT_IN_DATA_SETTING, true);
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Login type, only available when pac4j is configured
|
|
128
|
+
*/
|
|
129
|
+
export const loginType = (): string => getSetting(LOGIN_TYPE, "JAAS");
|
|
130
|
+
|
|
126
131
|
/**
|
|
127
132
|
*/
|
|
128
133
|
export const loginPath = (): string =>
|
|
129
|
-
getSetting(LOGIN_PATH_SETTING,
|
|
134
|
+
getSetting(LOGIN_PATH_SETTING, "/j_security_check");
|
|
130
135
|
/**
|
|
131
136
|
*/
|
|
132
137
|
export const loginUsernameField = (): string =>
|
|
@@ -138,4 +143,4 @@ export const loginPasswordField = (): string =>
|
|
|
138
143
|
/**
|
|
139
144
|
*/
|
|
140
145
|
export const logoutPath = (): string =>
|
|
141
|
-
getSetting(LOGOUT_PATH_SETTING,
|
|
146
|
+
getSetting(LOGOUT_PATH_SETTING, "/Logoff");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.js","names":["defaultSettings","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","DATE_INPUT_FORMAT","DATE_READONLY_FORMAT","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","settings","setSettings","config","getSetting","key","defaultValue","undefined","Error","setSetting","value","allSettings","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","
|
|
1
|
+
{"version":3,"file":"Settings.js","names":["defaultSettings","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","DATE_INPUT_FORMAT","DATE_READONLY_FORMAT","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","settings","setSettings","config","isPlainObject","getSetting","key","defaultValue","has","undefined","Error","setSetting","value","allSettings","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","loginType","LOGIN_TYPE","loginPath","LOGIN_PATH_SETTING","loginUsernameField","LOGIN_USERNAME_SETTING","loginPasswordField","LOGIN_PASSWORD_SETTING","logoutPath","LOGOUT_PATH_SETTING"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst defaultSettings = {\n // Debug missing i18n messages in layout\n DEBUG_I18N_MESSAGE_NOT_FOUND: true,\n\n // Time to show the notification bar\n HIDE_NOTIFICATION_TIMEOUT: 5000,\n\n // Always commit form, does not show result pages for instruments\n ALWAYS_COMMIT_FORM: false,\n\n // Render instrument and event question labels on forms (might result in duplicate labels)\n RENDER_QUESTION_LABELS: true,\n\n // Render mandatory indications on attributes\n RENDER_MANDATORY_ATTRIBUTE_INDICATION: true,\n\n // Render optional indications on attributes\n RENDER_OPTIONAL_ATTRIBUTE_INDICATION: false,\n\n // Renders a toggle with supported list views, options are ListView and TableView\n AVAILABLE_LIST_VIEWS: [\"ListView\", \"TableView\"],\n\n // Toggle client side validation\n USE_CLIENTSIDE_VALIDATION: true,\n\n // Indicates if server validation should be used when a form field is changed\n USE_INSTANT_SERVER_VALIDATION: true,\n\n // Indicates which locales are enabled\n ENABLED_LOCALES: [\"en\", \"nl\"],\n\n // Render forms in a modal\n RENDER_FORMS_IN_MODAL: true,\n\n // Wait timeout before rendering submit wait icon\n SHOW_SUBMIT_WAIT_TIMEOUT: 300,\n\n // Swim lane diagram configuration file\n SWIM_LANE_DIAGRAM_CONFIGURATION: \"/Library/Diagrams/Overviews.json\",\n\n // Business scenario concept types\n BUSINESS_SCENARIO_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/BusinessScenario\",\n ],\n BUSINESS_SCENARIO_STEP_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/ScenarioStep\",\n ],\n BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/Persona\",\n ],\n\n // Input format for dates. Without this setting having a value, the contributions format is used\n DATE_INPUT_FORMAT: \"\",\n\n // Readonly format for dates. Without this setting having a value, the contributions format is used\n DATE_READONLY_FORMAT: \"\",\n\n // indicates on what day the week starts (0 = Sunday)\n CALENDAR_WEEK_STARTS_ON: 1,\n\n // indicates which date indicates the first week of the year\n CALENDAR_FIRST_WEEK_CONTAINS_DATE: 1,\n\n // parameters that are added for the ui state, but should not be send to the modular ui\n UI_PARAMETERS: [],\n\n // disable hide-when-empty hint for layouts running on Be Informed versions older than 21.1\n ALLOW_HIDE_WHEN_EMPTY_ON_TABS: true,\n\n // reload the complete page on signout, usefull when third party authentication is in place\n PAGE_RELOAD_ON_UNAUTHORIZED_ERROR: false,\n\n XHR_TIMEOUT_MS: 300000,\n};\n\nlet settings = defaultSettings;\n\n/**\n */\nexport const setSettings = (config: Object) => {\n if (isPlainObject(config)) {\n settings = Object.assign(defaultSettings, config);\n }\n};\n\n/**\n */\nexport const getSetting = (key: string, defaultValue?: any): any => {\n if (!has(settings, key) && defaultValue === undefined) {\n throw new Error(\n `Setting with name ${key} not found and no defaultValue given`\n );\n }\n\n return settings[key] ?? defaultValue;\n};\n\n/**\n */\nexport const setSetting = (key: string, value: any) => {\n settings[key] = value;\n};\n\n/**\n */\nexport const allSettings = (): { [name: string]: Setting } => settings;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n * Login type, only available when pac4j is configured\n */\nexport const loginType = (): string => getSetting(LOGIN_TYPE, \"JAAS\");\n\n/**\n */\nexport const loginPath = (): string =>\n getSetting(LOGIN_PATH_SETTING, \"/j_security_check\");\n/**\n */\nexport const loginUsernameField = (): string =>\n getSetting(LOGIN_USERNAME_SETTING, \"j_username\");\n/**\n */\nexport const loginPasswordField = (): string =>\n getSetting(LOGIN_PASSWORD_SETTING, \"j_password\");\n/**\n */\nexport const logoutPath = (): string =>\n getSetting(LOGOUT_PATH_SETTING, \"/Logoff\");\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAWA,IAAMA,eAAe,GAAG;EACtB;EACAC,4BAA4B,EAAE,IAFR;EAItB;EACAC,yBAAyB,EAAE,IALL;EAOtB;EACAC,kBAAkB,EAAE,KARE;EAUtB;EACAC,sBAAsB,EAAE,IAXF;EAatB;EACAC,qCAAqC,EAAE,IAdjB;EAgBtB;EACAC,oCAAoC,EAAE,KAjBhB;EAmBtB;EACAC,oBAAoB,EAAE,CAAC,UAAD,EAAa,WAAb,CApBA;EAsBtB;EACAC,yBAAyB,EAAE,IAvBL;EAyBtB;EACAC,6BAA6B,EAAE,IA1BT;EA4BtB;EACAC,eAAe,EAAE,CAAC,IAAD,EAAO,IAAP,CA7BK;EA+BtB;EACAC,qBAAqB,EAAE,IAhCD;EAkCtB;EACAC,wBAAwB,EAAE,GAnCJ;EAqCtB;EACAC,+BAA+B,EAAE,kCAtCX;EAwCtB;EACAC,8BAA8B,EAAE,CAC9B,yDAD8B,CAzCV;EA4CtBC,mCAAmC,EAAE,CACnC,qDADmC,CA5Cf;EA+CtBC,sCAAsC,EAAE,CACtC,gDADsC,CA/ClB;EAmDtB;EACAC,iBAAiB,EAAE,EApDG;EAsDtB;EACAC,oBAAoB,EAAE,EAvDA;EAyDtB;EACAC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P;AACA;;;;;AACO,IAAMC,SAAS,GAAG,SAAZA,SAAY;EAAA,OACvBb,UAAU,CAACc,6BAAD,EAAqB,mBAArB,CADa;AAAA,CAAlB;AAEP;AACA;;;;;AACO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB;EAAA,OAChCf,UAAU,CAACgB,iCAAD,EAAyB,YAAzB,CADsB;AAAA,CAA3B;AAEP;AACA;;;;;AACO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB;EAAA,OAChCjB,UAAU,CAACkB,iCAAD,EAAyB,YAAzB,CADsB;AAAA,CAA3B;AAEP;AACA;;;;;AACO,IAAMC,UAAU,GAAG,SAAbA,UAAa;EAAA,OACxBnB,UAAU,CAACoB,8BAAD,EAAsB,SAAtB,CADc;AAAA,CAAnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchException.js","names":["CLIENT_ERROR_CODE","getErrorInfo","errorResponse","requestOptions","defaultErrorInfo","id","defaultMessage","url","method","HTTP_METHODS","GET","properties","param","error","key","errors","FetchException","failedRequest","errorInfo","name","request","status","response","parameters","Error","captureStackTrace"],"sources":["../../src/exceptions/FetchException.js"],"sourcesContent":["// @flow\nimport { has } from \"../utils/helpers/objects\";\n\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport type { MessageParameters } from \"../i18n/types\";\nimport type { RequestOptions } from \"../utils/fetch/types\";\n\nexport type ModularUIErrorResponse = {\n error: {\n id: string,\n properties: {\n [propertyName: string]: string | number,\n ...\n },\n },\n};\n\ntype RequestResult = { status: number };\ntype RequestParameters = { [key: string]: any };\n\nconst CLIENT_ERROR_CODE = 400;\n\n/**\n * @private\n */\nconst getErrorInfo = (\n errorResponse: ?ModularUIErrorResponse,\n requestOptions: ?RequestOptions\n) => {\n const defaultErrorInfo = {\n id: \"Error.CannotRequestResource\",\n defaultMessage: `Cannot request resource ${\n requestOptions?.url ?? \"\"\n } with method ${requestOptions?.method ?? HTTP_METHODS.GET}`,\n properties: {},\n param: null,\n };\n\n if (!errorResponse) {\n return defaultErrorInfo;\n }\n\n if (has(errorResponse, \"error\")) {\n return {\n ...defaultErrorInfo,\n ...errorResponse.error,\n };\n }\n\n const [key] = Object.keys(errorResponse);\n if (has(errorResponse[key], \"errors\")) {\n return {\n ...defaultErrorInfo,\n // $FlowFixMe[prop-missing] - not sure in what case this could happen\n ...errorResponse[key].errors,\n };\n }\n\n return defaultErrorInfo;\n};\n\n/**\n * FetchException\n */\nexport default class FetchException extends Error {\n request: ?RequestResult | XMLHttpRequest;\n status: number;\n response: ?ModularUIErrorResponse;\n parameters: ?RequestParameters;\n properties: MessageParameters;\n requestOptions: ?RequestOptions;\n id: string;\n\n constructor(\n errorResponse: ?ModularUIErrorResponse,\n failedRequest?: ?RequestResult | XMLHttpRequest,\n requestOptions?: RequestOptions\n ) {\n const errorInfo = getErrorInfo(errorResponse, requestOptions);\n super(errorInfo.id);\n\n this.name = errorInfo.id;\n this.id = errorInfo.id;\n this.request = failedRequest;\n this.requestOptions = requestOptions;\n\n this.status =\n failedRequest && failedRequest.status\n ? failedRequest.status\n : CLIENT_ERROR_CODE;\n\n this.response = errorResponse;\n this.properties = errorInfo.properties ?? {};\n this.parameters = errorInfo.param ?? null;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FetchException);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;;;;;;;;;AAkBA,IAAMA,iBAAiB,GAAG,GAA1B;AAEA;AACA;AACA;;AACA,IAAMC,YAAY,GAAG,SAAfA,YAAe,CACnBC,aADmB,EAEnBC,cAFmB,EAGhB;EAAA;;EACH,IAAMC,gBAAgB,GAAG;IACvBC,EAAE,EAAE,6BADmB;IAEvBC,cAAc,2FACZH,cADY,aACZA,cADY,uBACZA,cAAc,CAAEI,GADJ,qEACW,EADX,4DAEEJ,cAFF,aAEEA,cAFF,uBAEEA,cAAc,CAAEK,MAFlB,yEAE4BC,
|
|
1
|
+
{"version":3,"file":"FetchException.js","names":["CLIENT_ERROR_CODE","getErrorInfo","errorResponse","requestOptions","defaultErrorInfo","id","defaultMessage","url","method","HTTP_METHODS","GET","properties","param","has","error","key","errors","FetchException","failedRequest","errorInfo","name","request","status","response","parameters","Error","captureStackTrace"],"sources":["../../src/exceptions/FetchException.js"],"sourcesContent":["// @flow\nimport { has } from \"../utils/helpers/objects\";\n\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport type { MessageParameters } from \"../i18n/types\";\nimport type { RequestOptions } from \"../utils/fetch/types\";\n\nexport type ModularUIErrorResponse = {\n error: {\n id: string,\n properties: {\n [propertyName: string]: string | number,\n ...\n },\n },\n};\n\ntype RequestResult = { status: number };\ntype RequestParameters = { [key: string]: any };\n\nconst CLIENT_ERROR_CODE = 400;\n\n/**\n * @private\n */\nconst getErrorInfo = (\n errorResponse: ?ModularUIErrorResponse,\n requestOptions: ?RequestOptions\n) => {\n const defaultErrorInfo = {\n id: \"Error.CannotRequestResource\",\n defaultMessage: `Cannot request resource ${\n requestOptions?.url ?? \"\"\n } with method ${requestOptions?.method ?? HTTP_METHODS.GET}`,\n properties: {},\n param: null,\n };\n\n if (!errorResponse) {\n return defaultErrorInfo;\n }\n\n if (has(errorResponse, \"error\")) {\n return {\n ...defaultErrorInfo,\n ...errorResponse.error,\n };\n }\n\n const [key] = Object.keys(errorResponse);\n if (has(errorResponse[key], \"errors\")) {\n return {\n ...defaultErrorInfo,\n // $FlowFixMe[prop-missing] - not sure in what case this could happen\n ...errorResponse[key].errors,\n };\n }\n\n return defaultErrorInfo;\n};\n\n/**\n * FetchException\n */\nexport default class FetchException extends Error {\n request: ?RequestResult | XMLHttpRequest;\n status: number;\n response: ?ModularUIErrorResponse;\n parameters: ?RequestParameters;\n properties: MessageParameters;\n requestOptions: ?RequestOptions;\n id: string;\n\n constructor(\n errorResponse: ?ModularUIErrorResponse,\n failedRequest?: ?RequestResult | XMLHttpRequest,\n requestOptions?: RequestOptions\n ) {\n const errorInfo = getErrorInfo(errorResponse, requestOptions);\n super(errorInfo.id);\n\n this.name = errorInfo.id;\n this.id = errorInfo.id;\n this.request = failedRequest;\n this.requestOptions = requestOptions;\n\n this.status =\n failedRequest && failedRequest.status\n ? failedRequest.status\n : CLIENT_ERROR_CODE;\n\n this.response = errorResponse;\n this.properties = errorInfo.properties ?? {};\n this.parameters = errorInfo.param ?? null;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FetchException);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;;;;;;;;;AAkBA,IAAMA,iBAAiB,GAAG,GAA1B;AAEA;AACA;AACA;;AACA,IAAMC,YAAY,GAAG,SAAfA,YAAe,CACnBC,aADmB,EAEnBC,cAFmB,EAGhB;EAAA;;EACH,IAAMC,gBAAgB,GAAG;IACvBC,EAAE,EAAE,6BADmB;IAEvBC,cAAc,2FACZH,cADY,aACZA,cADY,uBACZA,cAAc,CAAEI,GADJ,qEACW,EADX,4DAEEJ,cAFF,aAEEA,cAFF,uBAEEA,cAAc,CAAEK,MAFlB,yEAE4BC,uBAAA,CAAaC,GAFzC,CAFS;IAKvBC,UAAU,EAAE,EALW;IAMvBC,KAAK,EAAE;EANgB,CAAzB;;EASA,IAAI,CAACV,aAAL,EAAoB;IAClB,OAAOE,gBAAP;EACD;;EAED,IAAI,IAAAS,YAAA,EAAIX,aAAJ,EAAmB,OAAnB,CAAJ,EAAiC;IAC/B,uCACKE,gBADL,GAEKF,aAAa,CAACY,KAFnB;EAID;;EAED,mBAAc,mBAAYZ,aAAZ,CAAd;EAAA;EAAA,IAAOa,GAAP;;EACA,IAAI,IAAAF,YAAA,EAAIX,aAAa,CAACa,GAAD,CAAjB,EAAwB,QAAxB,CAAJ,EAAuC;IACrC,uCACKX,gBADL,GAGKF,aAAa,CAACa,GAAD,CAAb,CAAmBC,MAHxB;EAKD;;EAED,OAAOZ,gBAAP;AACD,CAlCD;AAoCA;AACA;AACA;;;IACqBa,c;;;;;EASnB,wBACEf,aADF,EAEEgB,aAFF,EAGEf,cAHF,EAIE;IAAA;;IAAA;;IAAA;IACA,IAAMgB,SAAS,GAAGlB,YAAY,CAACC,aAAD,EAAgBC,cAAhB,CAA9B;IACA,0BAAMgB,SAAS,CAACd,EAAhB;IAFA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAIA,MAAKe,IAAL,GAAYD,SAAS,CAACd,EAAtB;IACA,MAAKA,EAAL,GAAUc,SAAS,CAACd,EAApB;IACA,MAAKgB,OAAL,GAAeH,aAAf;IACA,MAAKf,cAAL,GAAsBA,cAAtB;IAEA,MAAKmB,MAAL,GACEJ,aAAa,IAAIA,aAAa,CAACI,MAA/B,GACIJ,aAAa,CAACI,MADlB,GAEItB,iBAHN;IAKA,MAAKuB,QAAL,GAAgBrB,aAAhB;IACA,MAAKS,UAAL,4BAAkBQ,SAAS,CAACR,UAA5B,yEAA0C,EAA1C;IACA,MAAKa,UAAL,uBAAkBL,SAAS,CAACP,KAA5B,+DAAqC,IAArC;;IAEA,IAAIa,KAAK,CAACC,iBAAV,EAA6B;MAC3BD,KAAK,CAACC,iBAAN,8CAA8BT,cAA9B;IACD;;IApBD;EAqBD;;;+CAlCyCQ,K"}
|
|
@@ -88,7 +88,8 @@ describe("authentication hooks", () => {
|
|
|
88
88
|
return res.status(200).body({ data: "ok" });
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
const store = mockStore({ auth: {} });
|
|
91
|
+
const store = mockStore({ auth: {}, i18n: { locale: "en" } });
|
|
92
|
+
|
|
92
93
|
/**
|
|
93
94
|
*/
|
|
94
95
|
const wrapper = ({ children }) => (
|
|
@@ -107,6 +108,19 @@ describe("authentication hooks", () => {
|
|
|
107
108
|
expect(store.getActions()).toStrictEqual([
|
|
108
109
|
{ type: "START_PROGRESS" },
|
|
109
110
|
{ type: "MODULARUI/RESET" },
|
|
111
|
+
{
|
|
112
|
+
type: "MODULARUI/STATUS",
|
|
113
|
+
payload: { key: "application(/)(en)", status: "LOADING" },
|
|
114
|
+
},
|
|
115
|
+
{ type: "START_PROGRESS" },
|
|
116
|
+
expect.objectContaining({
|
|
117
|
+
type: "MODULARUI/FETCH",
|
|
118
|
+
payload: expect.objectContaining({
|
|
119
|
+
href: new Href("/", "Application"),
|
|
120
|
+
}),
|
|
121
|
+
}),
|
|
122
|
+
{ type: "FINISH_PROGRESS" },
|
|
123
|
+
|
|
110
124
|
{ type: "AUTHENTICATION_LOGOUT" },
|
|
111
125
|
{ type: "FINISH_PROGRESS" },
|
|
112
126
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAllFormsOnModel.js","names":["useRetrieveFormsOnModel","model","modularui","forms","setForms","requestCount","setRequestCount","responseCount","setResponseCount","requests","getActions","action","href","selfhref","addParameter","method","HTTP_METHODS","POST","fetch","then","form","FormModel","tokens","name","length","all","responses","actionForms","Object","actionCollection","createActions","getActionsByType","isDisabled","allActions","ListModel","listItemCollection","forEach","listItem","updateActions","push","actions","unique"],"sources":["../../src/hooks/useAllFormsOnModel.js"],"sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\n\nimport { useModularUIRequest } from \"./useModularUIRequest\";\n\nimport { HTTP_METHODS } from \"../constants\";\n\nimport ListModel from \"../models/list/ListModel\";\nimport FormModel from \"../models/form/FormModel\";\n\nimport type DetailModel from \"../models/detail/DetailModel\";\nimport type TabModel from \"../models/tab/TabModel\";\nimport type ActionModel from \"../models/actions/ActionModel\";\n\n/**\n * Retrieve all forms configured on a model with actions\n * @param model\n * @returns Object - { actionName: FormModel }\n */\nexport const useRetrieveFormsOnModel = (\n model: ListModel | DetailModel | TabModel\n): null | { [actionName: string]: FormModel } => {\n const modularui = useModularUIRequest();\n const [forms, setForms] = useState(null);\n const [requestCount, setRequestCount] = useState(0);\n const [responseCount, setResponseCount] = useState(0);\n\n useEffect(() => {\n const requests = getActions(model).map((action) => {\n const href = action.selfhref.addParameter(\"commit\", \"false\");\n\n return modularui(href, { method: HTTP_METHODS.POST })\n .fetch()\n .then((form) => {\n if (form instanceof FormModel) {\n form.tokens = [];\n }\n return { [action.name]: form };\n });\n });\n\n setRequestCount(requests.length);\n\n Promise.all(requests).then((responses) => {\n // put response array in object\n const actionForms = Object.assign({}, ...responses);\n setForms(actionForms);\n setResponseCount(responses.length);\n });\n }, [model, modularui]);\n\n if (responseCount === requestCount) {\n return forms;\n }\n\n return null;\n};\n\nconst getActions = (\n model: ListModel | DetailModel | TabModel\n): Array<ActionModel> => {\n if (!model.actionCollection) {\n return [];\n }\n\n const createActions = model.actionCollection\n .getActionsByType(\"create\")\n .filter((action) => !action.isDisabled);\n\n const allActions = [...createActions];\n\n if (model instanceof ListModel) {\n model.listItemCollection.forEach((listItem) => {\n const updateActions = listItem.actionCollection\n .getActionsByType(\"update\")\n .filter((action) => !action.isDisabled);\n\n allActions.push(...updateActions);\n });\n }\n\n const actions = [];\n const unique = [];\n allActions.forEach((action) => {\n if (!unique.includes(action.name)) {\n unique.push(action.name);\n actions.push(action);\n }\n });\n\n return actions;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAMA;AACA;AACA;AACA;AACA;AACO,IAAMA,uBAAuB,GAAG,SAA1BA,uBAA0B,CACrCC,KADqC,EAEU;EAC/C,IAAMC,SAAS,GAAG
|
|
1
|
+
{"version":3,"file":"useAllFormsOnModel.js","names":["useRetrieveFormsOnModel","model","modularui","useModularUIRequest","useState","forms","setForms","requestCount","setRequestCount","responseCount","setResponseCount","useEffect","requests","getActions","action","href","selfhref","addParameter","method","HTTP_METHODS","POST","fetch","then","form","FormModel","tokens","name","length","all","responses","actionForms","Object","actionCollection","createActions","getActionsByType","isDisabled","allActions","ListModel","listItemCollection","forEach","listItem","updateActions","push","actions","unique"],"sources":["../../src/hooks/useAllFormsOnModel.js"],"sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\n\nimport { useModularUIRequest } from \"./useModularUIRequest\";\n\nimport { HTTP_METHODS } from \"../constants\";\n\nimport ListModel from \"../models/list/ListModel\";\nimport FormModel from \"../models/form/FormModel\";\n\nimport type DetailModel from \"../models/detail/DetailModel\";\nimport type TabModel from \"../models/tab/TabModel\";\nimport type ActionModel from \"../models/actions/ActionModel\";\n\n/**\n * Retrieve all forms configured on a model with actions\n * @param model\n * @returns Object - { actionName: FormModel }\n */\nexport const useRetrieveFormsOnModel = (\n model: ListModel | DetailModel | TabModel\n): null | { [actionName: string]: FormModel } => {\n const modularui = useModularUIRequest();\n const [forms, setForms] = useState(null);\n const [requestCount, setRequestCount] = useState(0);\n const [responseCount, setResponseCount] = useState(0);\n\n useEffect(() => {\n const requests = getActions(model).map((action) => {\n const href = action.selfhref.addParameter(\"commit\", \"false\");\n\n return modularui(href, { method: HTTP_METHODS.POST })\n .fetch()\n .then((form) => {\n if (form instanceof FormModel) {\n form.tokens = [];\n }\n return { [action.name]: form };\n });\n });\n\n setRequestCount(requests.length);\n\n Promise.all(requests).then((responses) => {\n // put response array in object\n const actionForms = Object.assign({}, ...responses);\n setForms(actionForms);\n setResponseCount(responses.length);\n });\n }, [model, modularui]);\n\n if (responseCount === requestCount) {\n return forms;\n }\n\n return null;\n};\n\nconst getActions = (\n model: ListModel | DetailModel | TabModel\n): Array<ActionModel> => {\n if (!model.actionCollection) {\n return [];\n }\n\n const createActions = model.actionCollection\n .getActionsByType(\"create\")\n .filter((action) => !action.isDisabled);\n\n const allActions = [...createActions];\n\n if (model instanceof ListModel) {\n model.listItemCollection.forEach((listItem) => {\n const updateActions = listItem.actionCollection\n .getActionsByType(\"update\")\n .filter((action) => !action.isDisabled);\n\n allActions.push(...updateActions);\n });\n }\n\n const actions = [];\n const unique = [];\n allActions.forEach((action) => {\n if (!unique.includes(action.name)) {\n unique.push(action.name);\n actions.push(action);\n }\n });\n\n return actions;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;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,CAjCD"}
|
|
@@ -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,CAAC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CAAA,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,EAAkC,eAAlC,EAAmD;IACjDC,cAAc,EAAE,CAAC,cAAD,CADiC;IAEjDC,WAAW,EAAEC;EAFoC,CAAnD,CAD6B;AAAA,CAAxB;AAMP;AACA;;;;;AACO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,IAAD;EAAA,OAC7B,IAAAL,oCAAA,EAAkB,cAAlB,EAAkCK,IAAlC,EAAwC;IACtCJ,cAAc,EAAE,CAAC,cAAD,CADsB;IAEtCC,WAAW,EAAEI;EAFyB,CAAxC,CAD6B;AAAA,CAAxB;;;;AAMP,IAAMC,OAAO,GAAG,SA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D,EAAYY,OAAZ,EAAqBT,QAArB,CAApB;EACA,OAAO,IAAAV,oCAAA,EAAkB,YAAlB,EAAgCK,IAAhC,EAAsC;IAC3CJ,cAAc,EAAE,CAAC,YAAD,CAD2B;IAE3CC,WAAW,EAAEkB;EAF8B,CAAtC,CAAP;AAID,CAPM;AASP;AACA;;;;;AACO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,cAAD,EAA2C;EACnE,IAAMjB,IAAI,GAAGE,OAAO,CAAC,SAAD,EAAYe,cAAZ,CAApB;EACA,OAAO,IAAAtB,oCAAA,EAAkB,SAAlB,EAA6BK,IAA7B,EAAmC;IACxCJ,cAAc,EAAE,CAAC,SAAD,CADwB;IAExCC,WAAW,EAAEqB;EAF2B,CAAnC,CAAP;AAID,CANM;AAQP;AACA;;;;;AACO,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,WAAD,EAA4C;EACxE,IAAMpB,IAAI,GAAGE,OAAO,CAAC,cAAD,EAAiBkB,WAAjB,CAApB;EACA,OAAO,IAAAzB,oCAAA,EAAkB,cAAlB,EAAkCK,IAAlC,EAAwC;IAC7CJ,cAAc,EAAE,CAAC,aAAD,CAD6B;IAE7CC,WAAW,EAAEwB;EAFgC,CAAxC,CAAP;AAID,CANM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModels.js","names":["useModels","dispatch","reload","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};\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,IAAAC,uBAAA,EAAY,UAACC,KAAD;IAAA,OAAWA,KAAK,CAACC,IAAN,CAAWH,MAAtB;EAAA,CAAZ,CAAf;EAEA,kFAAUF,QAAV,wBAAsBC,GAAG,CAACK,KAAJ,CAAU,GAAV,EAAe,CAAf,CAAtB,wBAA4CJ,MAA5C;AACD,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