@beinformed/ui 1.63.2 → 1.63.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/esm/constants/Settings.js +3 -14
- package/esm/constants/Settings.js.map +1 -1
- package/esm/exceptions/NotFoundException.js +1 -2
- package/esm/exceptions/NotFoundException.js.map +1 -1
- package/esm/hooks/useI18n.js +1 -6
- package/esm/hooks/useI18n.js.map +1 -1
- package/esm/hooks/useModal.js +3 -4
- package/esm/hooks/useModal.js.map +1 -1
- package/esm/hooks/useModelCatalog.js +10 -30
- package/esm/hooks/useModelCatalog.js.map +1 -1
- package/esm/hooks/useModularUI.js +4 -5
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +7 -8
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/i18n/Locale.js +2 -5
- package/esm/i18n/Locale.js.map +1 -1
- package/esm/i18n/Locales.js +2 -5
- package/esm/i18n/Locales.js.map +1 -1
- package/esm/i18n/Message.js +9 -10
- package/esm/i18n/Message.js.map +1 -1
- package/esm/i18n/withMessage.js +1 -6
- package/esm/i18n/withMessage.js.map +1 -1
- package/esm/models/actions/ActionCollection.js +3 -6
- package/esm/models/actions/ActionCollection.js.map +1 -1
- package/esm/models/actions/ActionModel.js +1 -4
- package/esm/models/actions/ActionModel.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +2 -2
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/attributes/AttributeCollection.js +4 -14
- package/esm/models/attributes/AttributeCollection.js.map +1 -1
- package/esm/models/attributes/AttributeDataHelper.js +1 -2
- package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
- package/esm/models/attributes/AttributeSetModel.js +1 -5
- package/esm/models/attributes/AttributeSetModel.js.map +1 -1
- package/esm/models/attributes/CaptchaAttributeModel.js +2 -2
- package/esm/models/attributes/CaptchaAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +1 -3
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js +3 -9
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +2 -8
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/PasswordAttributeModel.js +2 -2
- package/esm/models/attributes/PasswordAttributeModel.js.map +1 -1
- package/esm/models/attributes/UploadAttributeModel.js +2 -2
- package/esm/models/attributes/UploadAttributeModel.js.map +1 -1
- package/esm/models/attributes/input-constraints/ConstraintCollection.js +1 -2
- package/esm/models/attributes/input-constraints/ConstraintCollection.js.map +1 -1
- package/esm/models/attributes/input-constraints/ConstraintModel.js +1 -2
- package/esm/models/attributes/input-constraints/ConstraintModel.js.map +1 -1
- package/esm/models/attributes/input-constraints/DateBoundaryConstraint.js +1 -4
- package/esm/models/attributes/input-constraints/DateBoundaryConstraint.js.map +1 -1
- package/esm/models/attributes/input-constraints/NumberBoundaryConstraint.js +1 -6
- package/esm/models/attributes/input-constraints/NumberBoundaryConstraint.js.map +1 -1
- package/esm/models/attributes/input-constraints/NumberGroupingConstraint.js +1 -4
- package/esm/models/attributes/input-constraints/NumberGroupingConstraint.js.map +1 -1
- package/esm/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js +1 -2
- package/esm/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js.map +1 -1
- package/esm/models/attributes/layouthint-rules/DependentAttribute.js +2 -2
- package/esm/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
- package/esm/models/base/BaseCollection.js +1 -2
- package/esm/models/base/BaseCollection.js.map +1 -1
- package/esm/models/base/BaseModel.js +6 -9
- package/esm/models/base/BaseModel.js.map +1 -1
- package/esm/models/base/ResourceModel.js +1 -2
- package/esm/models/base/ResourceModel.js.map +1 -1
- package/esm/models/concepts/BusinessScenarioModel.js +2 -2
- package/esm/models/concepts/BusinessScenarioModel.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +1 -2
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +1 -3
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/ConceptRelationCollection.js +1 -4
- package/esm/models/concepts/ConceptRelationCollection.js.map +1 -1
- package/esm/models/concepts/ConceptRelationModel.js +1 -3
- package/esm/models/concepts/ConceptRelationModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceCollection.js +1 -4
- package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +7 -3
- package/esm/models/concepts/SourceReferenceModel.js.flow +6 -0
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +1 -3
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/ContentTOCModel.js +2 -2
- package/esm/models/content/ContentTOCModel.js.map +1 -1
- package/esm/models/contentconfiguration/ContentConfigurationElements.js +1 -2
- package/esm/models/contentconfiguration/ContentConfigurationElements.js.map +1 -1
- package/esm/models/error/ErrorModel.js +1 -3
- package/esm/models/error/ErrorModel.js.map +1 -1
- package/esm/models/filters/FilterCollection.js +1 -4
- package/esm/models/filters/FilterCollection.js.map +1 -1
- package/esm/models/form/FormModel.js +3 -9
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +2 -4
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/href/Href.js +3 -6
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/href/ListHref.js +1 -2
- package/esm/models/href/ListHref.js.map +1 -1
- package/esm/models/layouthint/LayoutHintCollection.js +3 -10
- package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/esm/models/links/LinkCollection.js +6 -15
- package/esm/models/links/LinkCollection.js.map +1 -1
- package/esm/models/list/ListModel.js +2 -2
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/modelcatalog/ModelCategoryCollection.js +1 -2
- package/esm/models/modelcatalog/ModelCategoryCollection.js.map +1 -1
- package/esm/models/parameter/Parameter.js +2 -4
- package/esm/models/parameter/Parameter.js.map +1 -1
- package/esm/models/resolveModel.js +1 -2
- package/esm/models/resolveModel.js.map +1 -1
- package/esm/models/sorting/SortingModel.js +1 -2
- package/esm/models/sorting/SortingModel.js.map +1 -1
- package/esm/models/user/UserServicesModel.js +2 -2
- package/esm/models/user/UserServicesModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +1 -2
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/react/ErrorBoundary.js +2 -2
- package/esm/react/ErrorBoundary.js.map +1 -1
- package/esm/react/ErrorBoundaryFallback.js +13 -16
- package/esm/react/ErrorBoundaryFallback.js.map +1 -1
- package/esm/react/utils.js +1 -3
- package/esm/react/utils.js.map +1 -1
- package/esm/react-client/Init.js +20 -23
- package/esm/react-client/Init.js.map +1 -1
- package/esm/react-client/client.js +9 -13
- package/esm/react-client/client.js.map +1 -1
- package/esm/react-server/renderSSRComplete.js +9 -10
- package/esm/react-server/renderSSRComplete.js.map +1 -1
- package/esm/react-server/renderSSRMinimal.js +7 -8
- package/esm/react-server/renderSSRMinimal.js.map +1 -1
- package/esm/react-server/serverNoSSR.js +11 -12
- package/esm/react-server/serverNoSSR.js.map +1 -1
- package/esm/react-server/serverSSR.js +11 -12
- package/esm/react-server/serverSSR.js.map +1 -1
- package/esm/react-server/serverUtil.js +1 -3
- package/esm/react-server/serverUtil.js.map +1 -1
- package/esm/react-theme/ThemeProvider.js +7 -11
- package/esm/react-theme/ThemeProvider.js.map +1 -1
- package/esm/react-theme/createTheme.js +3 -10
- package/esm/react-theme/createTheme.js.map +1 -1
- package/esm/react-theme/utils/background.js +3 -4
- package/esm/react-theme/utils/background.js.map +1 -1
- package/esm/react-theme/utils/colors.js +7 -16
- package/esm/react-theme/utils/colors.js.map +1 -1
- package/esm/react-theme/utils/contrast.js +11 -19
- package/esm/react-theme/utils/contrast.js.map +1 -1
- package/esm/react-theme/utils/corners.js +10 -16
- package/esm/react-theme/utils/corners.js.map +1 -1
- package/esm/react-theme/utils/spacers.js +15 -38
- package/esm/react-theme/utils/spacers.js.map +1 -1
- package/esm/react-theme/utils/themeProps.js +7 -22
- package/esm/react-theme/utils/themeProps.js.map +1 -1
- package/esm/redux/_i18n/I18nReducer.js +5 -8
- package/esm/redux/_i18n/I18nReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +19 -23
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIConnector.js +4 -5
- package/esm/redux/_modularui/ModularUIConnector.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +14 -19
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUIUtils.js +1 -2
- package/esm/redux/_modularui/ModularUIUtils.js.map +1 -1
- package/esm/redux/_modularui/withModularUI.js +1 -2
- package/esm/redux/_modularui/withModularUI.js.map +1 -1
- package/esm/redux/_router/RouterReducer.js +1 -3
- package/esm/redux/_router/RouterReducer.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +34 -37
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/FormAutosubmit.js +1 -2
- package/esm/redux/actions/FormAutosubmit.js.map +1 -1
- package/esm/redux/actions/Preferences.js +8 -15
- package/esm/redux/actions/Preferences.js.map +1 -1
- package/esm/redux/connectors/CaseView.js +3 -6
- package/esm/redux/connectors/CaseView.js.map +1 -1
- package/esm/redux/connectors/ConceptDetail.js +4 -7
- package/esm/redux/connectors/ConceptDetail.js.map +1 -1
- package/esm/redux/connectors/ContentBrowser.js +3 -6
- package/esm/redux/connectors/ContentBrowser.js.map +1 -1
- package/esm/redux/connectors/ContentDetail.js +4 -7
- package/esm/redux/connectors/ContentDetail.js.map +1 -1
- package/esm/redux/connectors/ContentDetailSection.js +5 -8
- package/esm/redux/connectors/ContentDetailSection.js.map +1 -1
- package/esm/redux/connectors/Form.js +4 -5
- package/esm/redux/connectors/Form.js.map +1 -1
- package/esm/redux/connectors/FormAttributeSet.js +5 -8
- package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
- package/esm/redux/connectors/ListDetail.js +3 -6
- package/esm/redux/connectors/ListDetail.js.map +1 -1
- package/esm/redux/connectors/ModelCatalog.js +3 -6
- package/esm/redux/connectors/ModelCatalog.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +5 -6
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/redux/connectors/QuickSearch.js +3 -6
- package/esm/redux/connectors/QuickSearch.js.map +1 -1
- package/esm/redux/connectors/Tab.js +3 -6
- package/esm/redux/connectors/Tab.js.map +1 -1
- package/esm/redux/reducers/AuthReducer.js +1 -3
- package/esm/redux/reducers/AuthReducer.js.map +1 -1
- package/esm/redux/reducers/ErrorReducer.js +1 -3
- package/esm/redux/reducers/ErrorReducer.js.map +1 -1
- package/esm/redux/reducers/ModalsReducer.js +1 -3
- package/esm/redux/reducers/ModalsReducer.js.map +1 -1
- package/esm/redux/reducers/ModelCatalogReducer.js +1 -3
- package/esm/redux/reducers/ModelCatalogReducer.js.map +1 -1
- package/esm/redux/reducers/NotificationReducer.js +1 -3
- package/esm/redux/reducers/NotificationReducer.js.map +1 -1
- package/esm/redux/reducers/PreferencesReducer.js +1 -3
- package/esm/redux/reducers/PreferencesReducer.js.map +1 -1
- package/esm/redux/reducers/ProgressIndicatorReducer.js +1 -3
- package/esm/redux/reducers/ProgressIndicatorReducer.js.map +1 -1
- package/esm/redux/store/beforeRenderHooks.js +1 -3
- package/esm/redux/store/beforeRenderHooks.js.map +1 -1
- package/esm/utils/browser/Cache.js +1 -5
- package/esm/utils/browser/Cache.js.map +1 -1
- package/esm/utils/datetime/DateTimeUtil.js +45 -91
- package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
- package/esm/utils/fetch/xhr.js +1 -2
- package/esm/utils/fetch/xhr.js.map +1 -1
- package/esm/utils/helpers/repositoryResource.js +1 -3
- package/esm/utils/helpers/repositoryResource.js.map +1 -1
- package/esm/utils/helpers/sanitizeHtml.js +3 -4
- package/esm/utils/helpers/sanitizeHtml.js.map +1 -1
- package/esm/utils/number/DecimalFormat.js +1 -2
- package/esm/utils/number/DecimalFormat.js.map +1 -1
- package/esm/utils/number/formatValue.js +1 -4
- package/esm/utils/number/formatValue.js.map +1 -1
- package/esm/utils/number/parseNumbers.js +2 -6
- package/esm/utils/number/parseNumbers.js.map +1 -1
- package/lib/constants/Settings.js +3 -14
- package/lib/constants/Settings.js.map +1 -1
- package/lib/exceptions/NotFoundException.js +1 -2
- package/lib/exceptions/NotFoundException.js.map +1 -1
- package/lib/hooks/useI18n.js +1 -6
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/hooks/useModal.js +3 -4
- package/lib/hooks/useModal.js.map +1 -1
- package/lib/hooks/useModelCatalog.js +10 -30
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/lib/hooks/useModularUI.js +4 -5
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +7 -8
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/i18n/Locale.js +2 -5
- package/lib/i18n/Locale.js.map +1 -1
- package/lib/i18n/Locales.js +2 -5
- package/lib/i18n/Locales.js.map +1 -1
- package/lib/i18n/Message.js +9 -10
- package/lib/i18n/Message.js.map +1 -1
- package/lib/i18n/withMessage.js +1 -6
- package/lib/i18n/withMessage.js.map +1 -1
- package/lib/models/actions/ActionCollection.js +3 -6
- package/lib/models/actions/ActionCollection.js.map +1 -1
- package/lib/models/actions/ActionModel.js +1 -4
- package/lib/models/actions/ActionModel.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +2 -2
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/attributes/AttributeCollection.js +4 -14
- package/lib/models/attributes/AttributeCollection.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js +1 -2
- package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
- package/lib/models/attributes/AttributeSetModel.js +1 -5
- package/lib/models/attributes/AttributeSetModel.js.map +1 -1
- package/lib/models/attributes/CaptchaAttributeModel.js +2 -2
- package/lib/models/attributes/CaptchaAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +1 -3
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js +3 -9
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +2 -8
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/PasswordAttributeModel.js +2 -2
- package/lib/models/attributes/PasswordAttributeModel.js.map +1 -1
- package/lib/models/attributes/UploadAttributeModel.js +2 -2
- package/lib/models/attributes/UploadAttributeModel.js.map +1 -1
- package/lib/models/attributes/input-constraints/ConstraintCollection.js +1 -2
- package/lib/models/attributes/input-constraints/ConstraintCollection.js.map +1 -1
- package/lib/models/attributes/input-constraints/ConstraintModel.js +1 -2
- package/lib/models/attributes/input-constraints/ConstraintModel.js.map +1 -1
- package/lib/models/attributes/input-constraints/DateBoundaryConstraint.js +1 -4
- package/lib/models/attributes/input-constraints/DateBoundaryConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/NumberBoundaryConstraint.js +1 -6
- package/lib/models/attributes/input-constraints/NumberBoundaryConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/NumberGroupingConstraint.js +1 -4
- package/lib/models/attributes/input-constraints/NumberGroupingConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js +1 -2
- package/lib/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js.map +1 -1
- package/lib/models/attributes/layouthint-rules/DependentAttribute.js +2 -2
- package/lib/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
- package/lib/models/base/BaseCollection.js +1 -2
- package/lib/models/base/BaseCollection.js.map +1 -1
- package/lib/models/base/BaseModel.js +6 -9
- package/lib/models/base/BaseModel.js.map +1 -1
- package/lib/models/base/ResourceModel.js +1 -2
- package/lib/models/base/ResourceModel.js.map +1 -1
- package/lib/models/concepts/BusinessScenarioModel.js +2 -2
- package/lib/models/concepts/BusinessScenarioModel.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +1 -2
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +1 -3
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/ConceptRelationCollection.js +1 -4
- package/lib/models/concepts/ConceptRelationCollection.js.map +1 -1
- package/lib/models/concepts/ConceptRelationModel.js +1 -3
- package/lib/models/concepts/ConceptRelationModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceCollection.js +1 -4
- package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +7 -3
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js +1 -3
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.js +2 -2
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/contentconfiguration/ContentConfigurationElements.js +1 -2
- package/lib/models/contentconfiguration/ContentConfigurationElements.js.map +1 -1
- package/lib/models/error/ErrorModel.js +1 -3
- package/lib/models/error/ErrorModel.js.map +1 -1
- package/lib/models/filters/FilterCollection.js +1 -4
- package/lib/models/filters/FilterCollection.js.map +1 -1
- package/lib/models/form/FormModel.js +3 -9
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js +2 -4
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/href/Href.js +3 -6
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/ListHref.js +1 -2
- package/lib/models/href/ListHref.js.map +1 -1
- package/lib/models/layouthint/LayoutHintCollection.js +3 -10
- package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/lib/models/links/LinkCollection.js +6 -15
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/list/ListModel.js +2 -2
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/modelcatalog/ModelCategoryCollection.js +1 -2
- package/lib/models/modelcatalog/ModelCategoryCollection.js.map +1 -1
- package/lib/models/parameter/Parameter.js +2 -4
- package/lib/models/parameter/Parameter.js.map +1 -1
- package/lib/models/resolveModel.js +1 -2
- package/lib/models/resolveModel.js.map +1 -1
- package/lib/models/sorting/SortingModel.js +1 -2
- package/lib/models/sorting/SortingModel.js.map +1 -1
- package/lib/models/user/UserServicesModel.js +2 -2
- package/lib/models/user/UserServicesModel.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +1 -2
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/react/ErrorBoundary.js +2 -2
- package/lib/react/ErrorBoundary.js.map +1 -1
- package/lib/react/ErrorBoundaryFallback.js +13 -16
- package/lib/react/ErrorBoundaryFallback.js.map +1 -1
- package/lib/react/utils.js +1 -3
- package/lib/react/utils.js.map +1 -1
- package/lib/react-client/Init.js +20 -23
- package/lib/react-client/Init.js.map +1 -1
- package/lib/react-client/client.js +9 -13
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-server/renderSSRComplete.js +9 -10
- package/lib/react-server/renderSSRComplete.js.map +1 -1
- package/lib/react-server/renderSSRMinimal.js +7 -8
- package/lib/react-server/renderSSRMinimal.js.map +1 -1
- package/lib/react-server/serverNoSSR.js +11 -12
- package/lib/react-server/serverNoSSR.js.map +1 -1
- package/lib/react-server/serverSSR.js +11 -12
- package/lib/react-server/serverSSR.js.map +1 -1
- package/lib/react-server/serverUtil.js +1 -3
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/react-theme/ThemeProvider.js +7 -11
- package/lib/react-theme/ThemeProvider.js.map +1 -1
- package/lib/react-theme/createTheme.js +3 -10
- package/lib/react-theme/createTheme.js.map +1 -1
- package/lib/react-theme/utils/background.js +3 -4
- package/lib/react-theme/utils/background.js.map +1 -1
- package/lib/react-theme/utils/colors.js +7 -16
- package/lib/react-theme/utils/colors.js.map +1 -1
- package/lib/react-theme/utils/contrast.js +11 -19
- package/lib/react-theme/utils/contrast.js.map +1 -1
- package/lib/react-theme/utils/corners.js +10 -16
- package/lib/react-theme/utils/corners.js.map +1 -1
- package/lib/react-theme/utils/spacers.js +15 -38
- package/lib/react-theme/utils/spacers.js.map +1 -1
- package/lib/react-theme/utils/themeProps.js +7 -22
- package/lib/react-theme/utils/themeProps.js.map +1 -1
- package/lib/redux/_i18n/I18nReducer.js +5 -8
- package/lib/redux/_i18n/I18nReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +19 -23
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIConnector.js +4 -5
- package/lib/redux/_modularui/ModularUIConnector.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +14 -19
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUIUtils.js +1 -2
- package/lib/redux/_modularui/ModularUIUtils.js.map +1 -1
- package/lib/redux/_modularui/withModularUI.js +1 -2
- package/lib/redux/_modularui/withModularUI.js.map +1 -1
- package/lib/redux/_router/RouterReducer.js +1 -3
- package/lib/redux/_router/RouterReducer.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +34 -37
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAutosubmit.js +1 -2
- package/lib/redux/actions/FormAutosubmit.js.map +1 -1
- package/lib/redux/actions/Preferences.js +8 -15
- package/lib/redux/actions/Preferences.js.map +1 -1
- package/lib/redux/connectors/CaseView.js +3 -6
- package/lib/redux/connectors/CaseView.js.map +1 -1
- package/lib/redux/connectors/ConceptDetail.js +4 -7
- package/lib/redux/connectors/ConceptDetail.js.map +1 -1
- package/lib/redux/connectors/ContentBrowser.js +3 -6
- package/lib/redux/connectors/ContentBrowser.js.map +1 -1
- package/lib/redux/connectors/ContentDetail.js +4 -7
- package/lib/redux/connectors/ContentDetail.js.map +1 -1
- package/lib/redux/connectors/ContentDetailSection.js +5 -8
- package/lib/redux/connectors/ContentDetailSection.js.map +1 -1
- package/lib/redux/connectors/Form.js +4 -5
- package/lib/redux/connectors/Form.js.map +1 -1
- package/lib/redux/connectors/FormAttributeSet.js +5 -8
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/connectors/ListDetail.js +3 -6
- package/lib/redux/connectors/ListDetail.js.map +1 -1
- package/lib/redux/connectors/ModelCatalog.js +3 -6
- package/lib/redux/connectors/ModelCatalog.js.map +1 -1
- package/lib/redux/connectors/PanelRenderer.js +5 -6
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/redux/connectors/QuickSearch.js +3 -6
- package/lib/redux/connectors/QuickSearch.js.map +1 -1
- package/lib/redux/connectors/Tab.js +3 -6
- package/lib/redux/connectors/Tab.js.map +1 -1
- package/lib/redux/reducers/AuthReducer.js +1 -3
- package/lib/redux/reducers/AuthReducer.js.map +1 -1
- package/lib/redux/reducers/ErrorReducer.js +1 -3
- package/lib/redux/reducers/ErrorReducer.js.map +1 -1
- package/lib/redux/reducers/ModalsReducer.js +1 -3
- package/lib/redux/reducers/ModalsReducer.js.map +1 -1
- package/lib/redux/reducers/ModelCatalogReducer.js +1 -3
- package/lib/redux/reducers/ModelCatalogReducer.js.map +1 -1
- package/lib/redux/reducers/NotificationReducer.js +1 -3
- package/lib/redux/reducers/NotificationReducer.js.map +1 -1
- package/lib/redux/reducers/PreferencesReducer.js +1 -3
- package/lib/redux/reducers/PreferencesReducer.js.map +1 -1
- package/lib/redux/reducers/ProgressIndicatorReducer.js +1 -3
- package/lib/redux/reducers/ProgressIndicatorReducer.js.map +1 -1
- package/lib/redux/store/beforeRenderHooks.js +1 -3
- package/lib/redux/store/beforeRenderHooks.js.map +1 -1
- package/lib/utils/browser/Cache.js +1 -5
- package/lib/utils/browser/Cache.js.map +1 -1
- package/lib/utils/datetime/DateTimeUtil.js +45 -91
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/utils/fetch/xhr.js +1 -2
- package/lib/utils/fetch/xhr.js.map +1 -1
- package/lib/utils/helpers/repositoryResource.js +1 -3
- package/lib/utils/helpers/repositoryResource.js.map +1 -1
- package/lib/utils/helpers/sanitizeHtml.js +3 -4
- package/lib/utils/helpers/sanitizeHtml.js.map +1 -1
- package/lib/utils/number/DecimalFormat.js +1 -2
- package/lib/utils/number/DecimalFormat.js.map +1 -1
- package/lib/utils/number/formatValue.js +1 -4
- package/lib/utils/number/formatValue.js.map +1 -1
- package/lib/utils/number/parseNumbers.js +2 -6
- package/lib/utils/number/parseNumbers.js.map +1 -1
- package/package.json +22 -22
- package/src/models/concepts/SourceReferenceModel.js +6 -0
|
@@ -136,21 +136,13 @@ const getBasePathServer = () => getSetting("CONTEXT_PATH_SERVER", getBasePath())
|
|
|
136
136
|
* Path to upload service
|
|
137
137
|
*/
|
|
138
138
|
exports.getBasePathServer = getBasePathServer;
|
|
139
|
-
const getUploadPath =
|
|
140
|
-
let contextPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBasePathModularUI();
|
|
141
|
-
let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
142
|
-
return `${origin}${contextPath}${_Constants.UPLOAD_PATH}`;
|
|
143
|
-
};
|
|
139
|
+
const getUploadPath = (contextPath = getBasePathModularUI(), origin = "") => `${origin}${contextPath}${_Constants.UPLOAD_PATH}`;
|
|
144
140
|
|
|
145
141
|
/**
|
|
146
142
|
* Path to captcha service
|
|
147
143
|
*/
|
|
148
144
|
exports.getUploadPath = getUploadPath;
|
|
149
|
-
const getCaptchaPath =
|
|
150
|
-
let contextPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getBasePathModularUI();
|
|
151
|
-
let origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
152
|
-
return `${origin}${contextPath}${_Constants.CAPTCHA_PATH}`;
|
|
153
|
-
};
|
|
145
|
+
const getCaptchaPath = (contextPath = getBasePathModularUI(), origin = "") => `${origin}${contextPath}${_Constants.CAPTCHA_PATH}`;
|
|
154
146
|
|
|
155
147
|
/**
|
|
156
148
|
*/
|
|
@@ -178,10 +170,7 @@ const loginType = () => getSetting(_Constants.LOGIN_TYPE, _Constants.INTERNAL_LO
|
|
|
178
170
|
/**
|
|
179
171
|
*/
|
|
180
172
|
exports.loginType = loginType;
|
|
181
|
-
const loginPath =
|
|
182
|
-
let clientName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "FormClient";
|
|
183
|
-
return getSetting(_Constants.LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);
|
|
184
|
-
};
|
|
173
|
+
const loginPath = (clientName = "FormClient") => getSetting(_Constants.LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);
|
|
185
174
|
/**
|
|
186
175
|
*/
|
|
187
176
|
exports.loginPath = loginPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.js","names":["_objects","require","_repositoryResource","_Constants","serverBase","__CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","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_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","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","BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE","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","XHR_ALWAYS_WITH_CREDENTIALS","HIDE_WHEN_EMPTY_IGNORE_TASKS","SHOW_AVATARS","COMPLETE_SOURCE","settings","setSettings","config","isPlainObject","_assign","default","exports","getSetting","key","defaultValue","has","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getBasePathModularUI","getBasePathServer","getUploadPath","arguments","length","origin","UPLOAD_PATH","getCaptchaPath","CAPTCHA_PATH","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","isIncludeTimeOffsetInDateTimes","INCLUDE_TIME_OFFSET","getEnabledLocales","loginType","LOGIN_TYPE","INTERNAL_LOGIN_TYPE","JAAS","loginPath","clientName","LOGIN_PATH_SETTING","loginUsernameField","LOGIN_USERNAME_SETTING","loginPasswordField","LOGIN_PASSWORD_SETTING","logoutPath","LOGOUT_PATH_SETTING","getSwimLaneDiagramConfiguration","configLocation","_startsWith","call","getRepositoryResourceUrl","setContextPath","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n INCLUDE_TIME_OFFSET,\n INTERNAL_LOGIN_TYPE,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\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 // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\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 BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/System\",\n ],\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 XHR_ALWAYS_WITH_CREDENTIALS: false,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n\n SHOW_AVATARS: true,\n\n COMPLETE_SOURCE: false,\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 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 * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * The context path is retrieved on the server using the context path property as set in the runtime properties\n * This can be manually override by setting the UI setting 'CONTEXT_PATH'\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * The context path to modular ui rest services\n */\nexport const getBasePathModularUI = (): string =>\n getSetting(\"CONTEXT_PATH_SERVER\", getBasePath());\n\n/**\n * Used to link the css and js files in the server templates\n */\nexport const getBasePathServer = (): string =>\n getSetting(\"CONTEXT_PATH_SERVER\", getBasePath());\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (\n contextPath: string = getBasePathModularUI(),\n origin: string = \"\",\n): string => `${origin}${contextPath}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (\n contextPath: string = getBasePathModularUI(),\n origin: string = \"\",\n): string => `${origin}${contextPath}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n */\nexport const isIncludeTimeOffsetInDateTimes = (): boolean =>\n getSetting(INCLUDE_TIME_OFFSET, false);\n\n/**\n */\nexport const getEnabledLocales = (): Array<string> =>\n getSetting(\"ENABLED_LOCALES\", [\"en\"]);\n\n/**\n * Login type, only available when pac4j is configured\n *\n * Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS\n */\nexport const loginType = (): string =>\n getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);\n\n/**\n */\nexport const loginPath = (clientName: string = \"FormClient\"): string =>\n getSetting(LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);\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, \"/logout\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\",\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Set the context path for requests to be informed\n */\nexport const setContextPath = (contextPath: string) => {\n setSetting(\"CONTEXT_PATH\", contextPath);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAeA,MAAMG,UAAU,GACd,OAAOC,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAGA,gBAAgB;AAEnE,MAAMC,eAA4C,GAAG;EACnD;EACAC,YAAY,EACVH,UAAU,KACT,OAAOI,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,WAAW,GAChDD,MAAM,CAACC,WAAW,GAClB,aAAa,CAAC;EAEpB;EACAC,mBAAmB,EAAE,IAAI;EAEzB;EACAC,4BAA4B,EAAE,IAAI;EAElC;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,kBAAkB,EAAE,KAAK;EAEzB;EACAC,sBAAsB,EAAE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Ac,EAAE;EACvC;EACA,OAAO,IAAAG,4CAAwB,EAACH,cAAc,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AAFAxC,OAAA,CAAAuC,+BAAA,GAAAA,+BAAA;AAGO,MAAMK,cAAc,GAAIrF,WAAmB,IAAK;EACrDgD,UAAU,CAAC,cAAc,EAAEhD,WAAW,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AAFAyC,OAAA,CAAA4C,cAAA,GAAAA,cAAA;AAGO,MAAMC,IAAY,GAAA7C,OAAA,CAAA6C,IAAA,GAAGlC,WAAW,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Settings.js","names":["_objects","require","_repositoryResource","_Constants","serverBase","__CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","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_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","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","BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE","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","XHR_ALWAYS_WITH_CREDENTIALS","HIDE_WHEN_EMPTY_IGNORE_TASKS","SHOW_AVATARS","COMPLETE_SOURCE","settings","setSettings","config","isPlainObject","_assign","default","exports","getSetting","key","defaultValue","has","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getBasePathModularUI","getBasePathServer","getUploadPath","origin","UPLOAD_PATH","getCaptchaPath","CAPTCHA_PATH","hasAllContentInData","ALL_CONTENT_IN_DATA_SETTING","isIncludeTimeOffsetInDateTimes","INCLUDE_TIME_OFFSET","getEnabledLocales","loginType","LOGIN_TYPE","INTERNAL_LOGIN_TYPE","JAAS","loginPath","clientName","LOGIN_PATH_SETTING","loginUsernameField","LOGIN_USERNAME_SETTING","loginPasswordField","LOGIN_PASSWORD_SETTING","logoutPath","LOGOUT_PATH_SETTING","getSwimLaneDiagramConfiguration","configLocation","_startsWith","call","getRepositoryResourceUrl","setContextPath","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n INCLUDE_TIME_OFFSET,\n INTERNAL_LOGIN_TYPE,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\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 // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\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 BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/System\",\n ],\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 XHR_ALWAYS_WITH_CREDENTIALS: false,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n\n SHOW_AVATARS: true,\n\n COMPLETE_SOURCE: false,\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 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 * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * The context path is retrieved on the server using the context path property as set in the runtime properties\n * This can be manually override by setting the UI setting 'CONTEXT_PATH'\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * The context path to modular ui rest services\n */\nexport const getBasePathModularUI = (): string =>\n getSetting(\"CONTEXT_PATH_SERVER\", getBasePath());\n\n/**\n * Used to link the css and js files in the server templates\n */\nexport const getBasePathServer = (): string =>\n getSetting(\"CONTEXT_PATH_SERVER\", getBasePath());\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (\n contextPath: string = getBasePathModularUI(),\n origin: string = \"\",\n): string => `${origin}${contextPath}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (\n contextPath: string = getBasePathModularUI(),\n origin: string = \"\",\n): string => `${origin}${contextPath}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n */\nexport const isIncludeTimeOffsetInDateTimes = (): boolean =>\n getSetting(INCLUDE_TIME_OFFSET, false);\n\n/**\n */\nexport const getEnabledLocales = (): Array<string> =>\n getSetting(\"ENABLED_LOCALES\", [\"en\"]);\n\n/**\n * Login type, only available when pac4j is configured\n *\n * Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS\n */\nexport const loginType = (): string =>\n getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);\n\n/**\n */\nexport const loginPath = (clientName: string = \"FormClient\"): string =>\n getSetting(LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);\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, \"/logout\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\",\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Set the context path for requests to be informed\n */\nexport const setContextPath = (contextPath: string) => {\n setSetting(\"CONTEXT_PATH\", contextPath);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAeA,MAAMG,UAAU,GACd,OAAOC,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAGA,gBAAgB;AAEnE,MAAMC,eAA4C,GAAG;EACnD;EACAC,YAAY,EACVH,UAAU,KACT,OAAOI,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,WAAW,GAChDD,MAAM,CAACC,WAAW,GAClB,aAAa,CAAC;EAEpB;EACAC,mBAAmB,EAAE,IAAI;EAEzB;EACAC,4BAA4B,EAAE,IAAI;EAElC;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,kBAAkB,EAAE,KAAK;EAEzB;EACAC,sBAAsB,EAAE,IAAI;EAE5B;EACAC,qCAAqC,EAAE,IAAI;EAE3C;EACAC,oCAAoC,EAAE,KAAK;EAE3C;EACAC,oBAAoB,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;EAE/C;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,6BAA6B,EAAE,IAAI;EAEnC;EACAC,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;EAE7B;EACAC,wBAAwB,EAAE,KAAK;EAE/B;EACAC,yBAAyB,EAAE,KAAK;EAEhC;EACAC,wCAAwC,EAAE,KAAK;EAE/C;EACAC,UAAU,EAAE,SAAS;EAErB;EACAC,wBAAwB,EAAE,EAAE;EAE5B;EACAC,WAAW,EAAE,UAAU;EAEvB;EACAC,qBAAq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D,WAAmB,GAAAwB,OAAA,CAAAxB,WAAA,GAAG2D,UAAU,CAAC,CAAC;;AAE/C;AACA;AACA;AACO,MAAME,+BAAuC,GAAGA,CAAA,KAAM;EAC3D,IAAIC,cAAc,GAAGrC,UAAU,CAC7B,iCAAiC,EACjC,kCACF,CAAC;EACD,IAAI,CAAC,IAAAsC,WAAA,CAAAxC,OAAA,EAAAuC,cAAc,EAAAE,IAAA,CAAdF,cAAc,EAAY,GAAG,CAAC,EAAE;IACnCA,cAAc,GAAG,IAAIA,cAAc,EAAE;EACvC;EACA,OAAO,IAAAG,4CAAwB,EAACH,cAAc,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AAFAtC,OAAA,CAAAqC,+BAAA,GAAAA,+BAAA;AAGO,MAAMK,cAAc,GAAInF,WAAmB,IAAK;EACrDgD,UAAU,CAAC,cAAc,EAAEhD,WAAW,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AAFAyC,OAAA,CAAA0C,cAAA,GAAAA,cAAA;AAGO,MAAMC,IAAY,GAAA3C,OAAA,CAAA2C,IAAA,GAAGhC,WAAW,CAAC,CAAC","ignoreList":[]}
|
|
@@ -10,8 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
|
10
10
|
* NotFoundException
|
|
11
11
|
*/
|
|
12
12
|
class NotFoundException extends Error {
|
|
13
|
-
constructor(url, method) {
|
|
14
|
-
let isReload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
13
|
+
constructor(url, method, isReload = false) {
|
|
15
14
|
super(`Resource ${url} with method ${method} not found`);
|
|
16
15
|
(0, _defineProperty2.default)(this, "status", void 0);
|
|
17
16
|
(0, _defineProperty2.default)(this, "isReload", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotFoundException.js","names":["NotFoundException","Error","constructor","url","method","isReload","
|
|
1
|
+
{"version":3,"file":"NotFoundException.js","names":["NotFoundException","Error","constructor","url","method","isReload","_defineProperty2","default","name","id","status","_default","exports"],"sources":["../../src/exceptions/NotFoundException.js"],"sourcesContent":["// @flow\n/**\n * NotFoundException\n */\nclass NotFoundException extends Error {\n status: number;\n isReload: boolean;\n id: string;\n\n constructor(url: string, method: string, isReload: boolean = false) {\n super(`Resource ${url} with method ${method} not found`);\n\n this.name = \"NotFoundException\";\n this.id = \"NotFoundException\";\n this.status = 404;\n this.isReload = isReload;\n }\n}\n\nexport default NotFoundException;\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,SAASC,KAAK,CAAC;EAKpCC,WAAWA,CAACC,GAAW,EAAEC,MAAc,EAAEC,QAAiB,GAAG,KAAK,EAAE;IAClE,KAAK,CAAC,YAAYF,GAAG,gBAAgBC,MAAM,YAAY,CAAC;IAAC,IAAAE,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzD,IAAI,CAACC,IAAI,GAAG,mBAAmB;IAC/B,IAAI,CAACC,EAAE,GAAG,mBAAmB;IAC7B,IAAI,CAACC,MAAM,GAAG,GAAG;IACjB,IAAI,CAACL,QAAQ,GAAGA,QAAQ;EAC1B;AACF;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAL,OAAA,GAEcP,iBAAiB","ignoreList":[]}
|
package/lib/hooks/useI18n.js
CHANGED
|
@@ -11,12 +11,7 @@ var _reactRedux = require("react-redux");
|
|
|
11
11
|
var _reselect = require("reselect");
|
|
12
12
|
var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
13
13
|
var _i18n = require("../redux/selectors/i18n");
|
|
14
|
-
const getMessage = (0, _reselect.createSelector)([_i18n.getLocales, _i18n.getLocale], (locales, localeCode) => (0, _memoize.default)((id, defaultMessage, placeholders) => locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders),
|
|
15
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
-
args[_key] = arguments[_key];
|
|
17
|
-
}
|
|
18
|
-
return (0, _stringify.default)(args);
|
|
19
|
-
}));
|
|
14
|
+
const getMessage = (0, _reselect.createSelector)([_i18n.getLocales, _i18n.getLocale], (locales, localeCode) => (0, _memoize.default)((id, defaultMessage, placeholders) => locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders), (...args) => (0, _stringify.default)(args)));
|
|
20
15
|
|
|
21
16
|
/**
|
|
22
17
|
*/
|
package/lib/hooks/useI18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useI18n.js","names":["_reactRedux","require","_reselect","_memoize","_interopRequireDefault","_i18n","getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","
|
|
1
|
+
{"version":3,"file":"useI18n.js","names":["_reactRedux","require","_reselect","_memoize","_interopRequireDefault","_i18n","getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","_stringify","default","useMessage","useSelector","exports","useTranslate","useLocale","getLocaleCodes","state","i18n","_map","call","locale","code","useLocaleCodes"],"sources":["../../src/hooks/useI18n.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args),\n ),\n);\n\n/**\n */\nconst useMessage = (\n id: string,\n defaultMessage?: string,\n placeholders?: Object | null,\n): any => useSelector(getMessage)(id, defaultMessage, placeholders);\n\n/**\n */\nconst useTranslate = (): ((...any) => any) => useSelector(getMessage);\n\n/**\n */\nconst useLocale = (): string => useSelector(getLocale);\n\nconst getLocaleCodes = createSelector(\n (state) => state.i18n.locales,\n (locales) => locales.map((locale) => locale.code),\n);\n\n/**\n * Retrieve all available locale codes\n */\nconst useLocaleCodes = (): Array<string> => useSelector(getLocaleCodes);\n\nexport { useTranslate, useMessage, useLocale, useLocaleCodes };\n"],"mappings":";;;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,MAAMK,UAAU,GAAG,IAAAC,wBAAc,EAC/B,CAACC,gBAAU,EAAEC,eAAS,CAAC,EACvB,CAACC,OAAO,EAAEC,UAAU,KAClB,IAAAC,gBAAO,EACL,CAACC,EAAU,EAAEC,cAAuB,EAAEC,YAAqB,KACzDL,OAAO,CACJD,SAAS,CAACE,UAAU,CAAC,CACrBL,UAAU,CAACO,EAAE,EAAEC,cAAc,EAAEC,YAAY,CAAC,EACjD,CAAC,GAAGC,IAAI,KAAK,IAAAC,UAAA,CAAAC,OAAA,EAAeF,IAAI,CAClC,CACJ,CAAC;;AAED;AACA;AACA,MAAMG,UAAU,GAAGA,CACjBN,EAAU,EACVC,cAAuB,EACvBC,YAA4B,KACpB,IAAAK,uBAAW,EAACd,UAAU,CAAC,CAACO,EAAE,EAAEC,cAAc,EAAEC,YAAY,CAAC;;AAEnE;AACA;AADAM,OAAA,CAAAF,UAAA,GAAAA,UAAA;AAEA,MAAMG,YAAY,GAAGA,CAAA,KAAyB,IAAAF,uBAAW,EAACd,UAAU,CAAC;;AAErE;AACA;AADAe,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAEA,MAAMC,SAAS,GAAGA,CAAA,KAAc,IAAAH,uBAAW,EAACX,eAAS,CAAC;AAACY,OAAA,CAAAE,SAAA,GAAAA,SAAA;AAEvD,MAAMC,cAAc,GAAG,IAAAjB,wBAAc,EAClCkB,KAAK,IAAKA,KAAK,CAACC,IAAI,CAAChB,OAAO,EAC5BA,OAAO,IAAK,IAAAiB,IAAA,CAAAT,OAAA,EAAAR,OAAO,EAAAkB,IAAA,CAAPlB,OAAO,EAAMmB,MAAM,IAAKA,MAAM,CAACC,IAAI,CAClD,CAAC;;AAED;AACA;AACA;AACA,MAAMC,cAAc,GAAGA,CAAA,KAAqB,IAAAX,uBAAW,EAACI,cAAc,CAAC;AAACH,OAAA,CAAAU,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/lib/hooks/useModal.js
CHANGED
|
@@ -18,11 +18,10 @@ const useModal = modalId => {
|
|
|
18
18
|
throw new _exceptions.IllegalArgumentException("Missing modalId argument for useModal hook");
|
|
19
19
|
}
|
|
20
20
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
21
|
-
const modal = (0, _reactRedux.useSelector)(
|
|
21
|
+
const modal = (0, _reactRedux.useSelector)(({
|
|
22
|
+
modals
|
|
23
|
+
}) => {
|
|
22
24
|
var _context;
|
|
23
|
-
let {
|
|
24
|
-
modals
|
|
25
|
-
} = _ref;
|
|
26
25
|
return (0, _find.default)(_context = modals.modals).call(_context, m => m.key === modalId);
|
|
27
26
|
});
|
|
28
27
|
const show = (0, _react.useCallback)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModal.js","names":["_react","require","_reactRedux","_Modals","_exceptions","useModal","modalId","IllegalArgumentException","dispatch","useDispatch","modal","useSelector","
|
|
1
|
+
{"version":3,"file":"useModal.js","names":["_react","require","_reactRedux","_Modals","_exceptions","useModal","modalId","IllegalArgumentException","dispatch","useDispatch","modal","useSelector","modals","_context","_find","default","call","m","key","show","useCallback","showModal","close","closeModal","size","visible","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAUA;AACA;AACA;AACO,MAAMI,QAAmB,GAAIC,OAAe,IAAK;EACtD,IAAI,CAACA,OAAO,EAAE;IACZ,MAAM,IAAIC,oCAAwB,CAChC,4CACF,CAAC;EACH;EAEA,MAAMC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAC9B,MAAMC,KAAK,GAAG,IAAAC,uBAAW,EAAC,CAAC;IAAEC;EAAO,CAAC;IAAA,IAAAC,QAAA;IAAA,OACnC,IAAAC,KAAA,CAAAC,OAAA,EAAAF,QAAA,GAAAD,MAAM,CAACA,MAAM,EAAAI,IAAA,CAAAH,QAAA,EAAOI,CAAC,IAAKA,CAAC,CAACC,GAAG,KAAKZ,OAAO,CAAC;EAAA,CAC9C,CAAC;EAED,MAAMa,IAAI,GAAG,IAAAC,kBAAW,EAAC,MAAM;IAC7BZ,QAAQ,CAAC,IAAAa,iBAAS,EAACf,OAAO,CAAC,CAAC;EAC9B,CAAC,EAAE,CAACE,QAAQ,EAAEF,OAAO,CAAC,CAAC;EAEvB,MAAMgB,KAAK,GAAG,IAAAF,kBAAW,EAAC,MAAM;IAC9BZ,QAAQ,CAAC,IAAAe,kBAAU,EAACjB,OAAO,CAAC,CAAC;EAC/B,CAAC,EAAE,CAACE,QAAQ,EAAEF,OAAO,CAAC,CAAC;EAEvB,OAAO;IACLY,GAAG,EAAER,KAAK,GAAGA,KAAK,CAACQ,GAAG,GAAG,IAAI;IAC7BM,IAAI,EAAEd,KAAK,GAAGA,KAAK,CAACc,IAAI,GAAG,IAAI;IAC/BC,OAAO,EAAEf,KAAK,GAAGA,KAAK,CAACe,OAAO,GAAG,KAAK;IACtCN,IAAI;IACJG;EACF,CAAC;AACH,CAAC;AAACI,OAAA,CAAArB,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -32,9 +32,7 @@ const useModelCatalog = options => (0, _useModularUIBasic.useModularUIBasic)("mo
|
|
|
32
32
|
/**
|
|
33
33
|
*/
|
|
34
34
|
exports.useModelCatalog = useModelCatalog;
|
|
35
|
-
const useConceptIndex =
|
|
36
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptindex";
|
|
37
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
35
|
+
const useConceptIndex = (href, key = "conceptindex", options) => {
|
|
38
36
|
const {
|
|
39
37
|
entryDate
|
|
40
38
|
} = useEntryDate();
|
|
@@ -50,9 +48,7 @@ const useConceptIndex = function (href) {
|
|
|
50
48
|
/**
|
|
51
49
|
*/
|
|
52
50
|
exports.useConceptIndex = useConceptIndex;
|
|
53
|
-
const useConceptDetail =
|
|
54
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptdetail";
|
|
55
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
51
|
+
const useConceptDetail = (concept, key = "conceptdetail", options) => {
|
|
56
52
|
const {
|
|
57
53
|
entryDate
|
|
58
54
|
} = useEntryDate();
|
|
@@ -67,9 +63,7 @@ const useConceptDetail = function (concept) {
|
|
|
67
63
|
/**
|
|
68
64
|
*/
|
|
69
65
|
exports.useConceptDetail = useConceptDetail;
|
|
70
|
-
const useContentIndex =
|
|
71
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentindex";
|
|
72
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
66
|
+
const useContentIndex = (href, key = "contentindex", options) => {
|
|
73
67
|
const url = (0, _createHref.filterParameters)(href, ["index", "label", "type"]);
|
|
74
68
|
return (0, _useModularUIBasic.useModularUIBasic)(key, url, {
|
|
75
69
|
expectedModels: ["ContentIndex"],
|
|
@@ -81,9 +75,7 @@ const useContentIndex = function (href) {
|
|
|
81
75
|
/**
|
|
82
76
|
*/
|
|
83
77
|
exports.useContentIndex = useContentIndex;
|
|
84
|
-
const useContentTOC =
|
|
85
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttoc";
|
|
86
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
78
|
+
const useContentTOC = (content, key = "contenttoc", options) => {
|
|
87
79
|
const {
|
|
88
80
|
entryDate
|
|
89
81
|
} = useEntryDate();
|
|
@@ -99,9 +91,7 @@ const useContentTOC = function (content) {
|
|
|
99
91
|
/**
|
|
100
92
|
*/
|
|
101
93
|
exports.useContentTOC = useContentTOC;
|
|
102
|
-
const useContent =
|
|
103
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
|
|
104
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
94
|
+
const useContent = (content, key = "content", options) => {
|
|
105
95
|
const {
|
|
106
96
|
entryDate
|
|
107
97
|
} = useEntryDate();
|
|
@@ -116,9 +106,7 @@ const useContent = function (content) {
|
|
|
116
106
|
/**
|
|
117
107
|
*/
|
|
118
108
|
exports.useContent = useContent;
|
|
119
|
-
const useCompleteSource =
|
|
120
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
|
|
121
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
109
|
+
const useCompleteSource = (content, key = "content", options) => {
|
|
122
110
|
const {
|
|
123
111
|
entryDate
|
|
124
112
|
} = useEntryDate();
|
|
@@ -136,9 +124,7 @@ const useCompleteSource = function (content) {
|
|
|
136
124
|
/**
|
|
137
125
|
*/
|
|
138
126
|
exports.useCompleteSource = useCompleteSource;
|
|
139
|
-
const useContentType =
|
|
140
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttypes";
|
|
141
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
127
|
+
const useContentType = (contentType, key = "contenttypes", options) => {
|
|
142
128
|
const href = (0, _createHref.createHref)("contenttypes", contentType, null, null, []);
|
|
143
129
|
return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
|
|
144
130
|
expectedModels: ["ContentType"],
|
|
@@ -167,9 +153,7 @@ const getSearchHref = (uri, filters) => {
|
|
|
167
153
|
|
|
168
154
|
/**
|
|
169
155
|
*/
|
|
170
|
-
const useConceptSearch =
|
|
171
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptSearch";
|
|
172
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
156
|
+
const useConceptSearch = (filters, key = "conceptSearch", options) => {
|
|
173
157
|
const href = getSearchHref("/concepts", filters);
|
|
174
158
|
return useConceptIndex(href, key, options);
|
|
175
159
|
};
|
|
@@ -177,9 +161,7 @@ const useConceptSearch = function (filters) {
|
|
|
177
161
|
/**
|
|
178
162
|
*/
|
|
179
163
|
exports.useConceptSearch = useConceptSearch;
|
|
180
|
-
const useContentSearch =
|
|
181
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentSearch";
|
|
182
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
164
|
+
const useContentSearch = (filters, key = "contentSearch", options) => {
|
|
183
165
|
const href = getSearchHref("/content", filters);
|
|
184
166
|
return useContentIndex(href, key, options);
|
|
185
167
|
};
|
|
@@ -200,9 +182,7 @@ const useEntryDate = () => {
|
|
|
200
182
|
/**
|
|
201
183
|
*/
|
|
202
184
|
exports.useEntryDate = useEntryDate;
|
|
203
|
-
const useRelatedConcepts =
|
|
204
|
-
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "relatedconcepts";
|
|
205
|
-
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
185
|
+
const useRelatedConcepts = (href, key = "relatedconcepts", options) => {
|
|
206
186
|
const {
|
|
207
187
|
entryDate
|
|
208
188
|
} = useEntryDate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["_reactRedux","require","_useRouter","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","_modelcatalog","_ModelCatalog","_Href","useModelCatalog","options","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","filterParameters","setParameter","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","useCompleteSource","contentHref","Href","removeParameter","addParameter","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","useDispatch","useSelector","getEntryDate","setEntryDate","updateEntryDate","useRelatedConcepts"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\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\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useCompleteSource = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n let contentHref = new Href(content);\n contentHref.removeParameter(\"complete\");\n contentHref.addParameter(\"complete\", \"true\");\n\n const href = createHref(\"content\", contentHref, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n\n/**\n */\nexport const useRelatedConcepts = (\n href: string | Href,\n key?: string = \"relatedconcepts\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\"modelcategory\"]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAA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,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,iBAAiB;EAAA,IAChCT,OAAqD,GAAAS,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAM;IAAEC;EAAU,CAAC,GAAGC,YAAY,CAAC,CAAC;EACpC,MAAMC,GAAG,GAAG,IAAAC,4BAAgB,EAACR,IAAI,EAAE,CAAC,eAAe,CAAC,CAAC;EACrDO,GAAG,CAACE,YAAY,CAAC,WAAW,EAAEJ,SAAS,CAAC;EAExC,OAAO,IAAAX,oCAAiB,EAACO,GAAG,EAAEM,GAAG,EAAE;IACjCZ,cAAc,EAAE,CAAC,cAAc,CAAC;IAChCC,WAAW,EAAEc,0BAAiB;IAC9B,GAAGjB;EACL,CAAC,CAAC;AACJ,CAAC;AAACK,OAAA,CAAAqD,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["_reactRedux","require","_useRouter","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","_modelcatalog","_ModelCatalog","_Href","useModelCatalog","options","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","entryDate","useEntryDate","url","filterParameters","setParameter","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","useCompleteSource","contentHref","Href","removeParameter","addParameter","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","filterValue","value","Array","isArray","join","replace","push","length","useConceptSearch","useContentSearch","dispatch","useDispatch","useSelector","getEntryDate","setEntryDate","updateEntryDate","useRelatedConcepts"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\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\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useCompleteSource = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n let contentHref = new Href(content);\n contentHref.removeParameter(\"complete\");\n contentHref.addParameter(\"complete\", \"true\");\n\n const href = createHref(\"content\", contentHref, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n\n/**\n */\nexport const useRelatedConcepts = (\n href: string | Href,\n key?: string = \"relatedconcepts\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\"modelcategory\"]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,mBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,sBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,kBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,gBAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,aAAA,GAAAN,sBAAA,CAAAJ,OAAA;AAEA,IAAAW,kBAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AAEA,IAAAa,aAAA,GAAAb,OAAA;AACA,IAAAc,aAAA,GAAAd,OAAA;AAEA,IAAAe,KAAA,GAAAX,sBAAA,CAAAJ,OAAA;AAWA;AACA;AACO,MAAMgB,eAAe,GAC1BC,OAAqD,IAErD,IAAAC,oCAAiB,EAAC,cAAc,EAAE,eAAe,EAAE;EACjDC,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEC,0BAAiB;EAC9B,GAAGJ;AACL,CAAC,CAAC;;AAEJ;AACA;AADAK,OAAA,CAAAN,eAAA,GAAAA,eAAA;AAEO,MAAMO,eAAe,GAAGA,CAC7BC,IAAmB,EACnBC,GAAY,GAAG,cAAc,EAC7BR,OAAqD,KAC9B;EACvB,MAAM;IAAES;EAAU,CAAC,GAAGC,YAAY,CAAC,CAAC;EACpC,MAAMC,GAAG,GAAG,IAAAC,4BAAgB,EAACL,IAAI,EAAE,CACjC,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,YAAY,EAAG7C,SAAmB,IAAKyC,QAAQ,CAAC,IAAAK,6BAAe,EAAC9C,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC;;AAED;AACA;AADAJ,OAAA,CAAAK,YAAA,GAAAA,YAAA;AAEO,MAAM8C,kBAAkB,GAAGA,CAChCjD,IAAmB,EACnBC,GAAY,GAAG,iBAAiB,EAChCR,OAAqD,KAC9B;EACvB,MAAM;IAAES;EAAU,CAAC,GAAGC,YAAY,CAAC,CAAC;EACpC,MAAMC,GAAG,GAAG,IAAAC,4BAAgB,EAACL,IAAI,EAAE,CAAC,eAAe,CAAC,CAAC;EACrDI,GAAG,CAACE,YAAY,CAAC,WAAW,EAAEJ,SAAS,CAAC;EAExC,OAAO,IAAAR,oCAAiB,EAACO,GAAG,EAAEG,GAAG,EAAE;IACjCT,cAAc,EAAE,CAAC,cAAc,CAAC;IAChCC,WAAW,EAAEW,0BAAiB;IAC9B,GAAGd;EACL,CAAC,CAAC;AACJ,CAAC;AAACK,OAAA,CAAAmD,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -23,11 +23,10 @@ const useKeyForHook = (modelKey, url) => {
|
|
|
23
23
|
/**
|
|
24
24
|
* Use redux action and selector to retrieve the correct modular ui service model
|
|
25
25
|
*/
|
|
26
|
-
const useModularUI =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
26
|
+
const useModularUI = (modelKey, url, options = {
|
|
27
|
+
method: _constants.HTTP_METHODS.GET,
|
|
28
|
+
removeOnUnmount: false
|
|
29
|
+
}) => {
|
|
31
30
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
32
31
|
const href = (0, _react.useMemo)(() => url?.toString() || "", [url]);
|
|
33
32
|
const key = useKeyForHook(modelKey, href);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_reactRouter","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","_Href","useKeyForHook","modelKey","url","locale","useLocale","useMemo","split","useModularUI","options","
|
|
1
|
+
{"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_reactRouter","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","_Href","useKeyForHook","modelKey","url","locale","useLocale","useMemo","split","useModularUI","options","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","modelSelector","state","modularui","model","useSelector","Href","origin","contextPath","location","useLocation","redirectLocation","forceLoad","equals","prevOptions","useRef","prevHref","prevForceLoad","useDeepCompareEffect","isOldReload","current","isReload","doForceLoad","loadModularUI","useEffect","removeModelByKey","exports"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return useMemo(\n () => `${modelKey}(${url.split(\"?\")[0]})(${locale})`,\n [modelKey, url, locale],\n );\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useKeyForHook(modelKey, href);\n\n const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);\n const model = useSelector(modelSelector);\n\n if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceLoad =\n model == null ||\n (redirectLocation instanceof Href ? redirectLocation?.equals(href) : false);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceLoad = useRef(forceLoad);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceLoad = forceLoad && !prevForceLoad.current;\n\n if (href !== \"\" && (doForceLoad || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceLoad.current = forceLoad;\n }, [key, href, options, forceLoad]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAEA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAF,sBAAA,CAAAN,OAAA;AAIA;AACA;AACA,MAAMS,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAG,IAAAC,kBAAS,EAAC,CAAC;EAC1B,OAAO,IAAAC,cAAO,EACZ,MAAM,GAAGJ,QAAQ,IAAIC,GAAG,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKH,MAAM,GAAG,EACpD,CAACF,QAAQ,EAAEC,GAAG,EAAEC,MAAM,CACxB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACO,MAAMI,YAAY,GAAG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6BAAoB,EAAC,MAAM;IACzB;IACA,MAAMC,WAAW,GACfH,QAAQ,CAACI,OAAO,KAAKtB,IAAI,IACzBgB,WAAW,CAACM,OAAO,CAACC,QAAQ,IAC5B,CAAC9B,OAAO,CAAC8B,QAAQ;IAEnB,MAAMC,WAAW,GAAGV,SAAS,IAAI,CAACK,aAAa,CAACG,OAAO;IAEvD,IAAItB,IAAI,KAAK,EAAE,KAAKwB,WAAW,IAAI,CAACH,WAAW,CAAC,EAAE;MAChDvB,QAAQ,CAAC,IAAA2B,+BAAa,EAACvB,GAAG,EAAEF,IAAI,EAAEP,OAAO,CAAC,CAAC;IAC7C;IAEAuB,WAAW,CAACM,OAAO,GAAG7B,OAAO;IAC7ByB,QAAQ,CAACI,OAAO,GAAGtB,IAAI;IACvBmB,aAAa,CAACG,OAAO,GAAGR,SAAS;EACnC,CAAC,EAAE,CAACZ,GAAG,EAAEF,IAAI,EAAEP,OAAO,EAAEqB,SAAS,CAAC,CAAC;EAEnC,IAAAY,gBAAS,EAAC,MAAM;IACd,IAAIjC,OAAO,CAACI,eAAe,EAAE;MAC3B,OAAO,MAAM;QACXC,QAAQ,CAAC,IAAA6B,kCAAgB,EAACzB,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACJ,QAAQ,EAAEI,GAAG,EAAET,OAAO,CAACI,eAAe,CAAC,CAAC;EAE5C,OAAOS,KAAK;AACd,CAAC;AAACsB,OAAA,CAAApC,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -56,14 +56,13 @@ const validateModel = (model, expectedModels) => {
|
|
|
56
56
|
/**
|
|
57
57
|
* useModularUIBasic Hook
|
|
58
58
|
*/
|
|
59
|
-
const useModularUIBasic =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
59
|
+
const useModularUIBasic = (key, href, options = {
|
|
60
|
+
expectedModels: [],
|
|
61
|
+
targetModel: undefined,
|
|
62
|
+
forceTargetModel: false,
|
|
63
|
+
origin: undefined,
|
|
64
|
+
contextPath: undefined
|
|
65
|
+
}) => {
|
|
67
66
|
const location = (0, _useRouter.useLocation)();
|
|
68
67
|
const memoizedHref = (0, _react.useMemo)(() => href.toString(), [href]);
|
|
69
68
|
const useModularUIOptions = (0, _react.useMemo)(() => createUseModularUIOptions(options, memoizedHref, location), [options, memoizedHref, location]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIBasic.js","names":["_react","require","_useModularUI","_useRouter","createUseModularUIOptions","options","href","location","_context","baseOptions","targetModel","undefined","forceTargetModel","isReload","origin","contextPath","cache","state","reload","_startsWith","default","pathname","call","validateModel","model","expectedModels","length","isCorrectModel","some","expectedModel","type","console","warn","useModularUIBasic","key","
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["_react","require","_useModularUI","_useRouter","createUseModularUIOptions","options","href","location","_context","baseOptions","targetModel","undefined","forceTargetModel","isReload","origin","contextPath","cache","state","reload","_startsWith","default","pathname","call","validateModel","model","expectedModels","length","isCorrectModel","some","expectedModel","type","console","warn","useModularUIBasic","key","useLocation","memoizedHref","useMemo","toString","useModularUIOptions","modularUI","useModularUI","exports"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useMemo } from \"react\";\nimport { useModularUI } from \"./useModularUI\";\nimport { useLocation } from \"./useRouter\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n origin?: string,\n contextPath?: string,\n cache?: boolean,\n};\n\n// Helper to create useModularUI options\nconst createUseModularUIOptions = <T: ModularUIModel>(\n options: UseModularUIBasicOptions<T>,\n href: string,\n location: any,\n): Object => {\n const baseOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n origin: undefined,\n contextPath: undefined,\n cache: false,\n };\n\n // Handle targetModel and forceTargetModel\n if (options.targetModel) {\n baseOptions.targetModel = options.targetModel;\n baseOptions.forceTargetModel = options.forceTargetModel;\n }\n\n // Handle cache option\n if (options.cache) {\n baseOptions.cache = options.cache;\n }\n\n // Check for reload if location matches href\n if (location.state?.reload && location.pathname.startsWith(href)) {\n baseOptions.isReload = true;\n }\n\n // Handle origin and contextPath options\n baseOptions.origin = options.origin ?? baseOptions.origin;\n baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;\n\n return baseOptions;\n};\n\n// Helper to validate the model against expectedModels\nconst validateModel = (model: any, expectedModels: Array<string>) => {\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some(\n (expectedModel) => model.type === expectedModel,\n );\n if (!isCorrectModel) {\n console.warn(model, \"is not of instance\", expectedModels);\n }\n }\n};\n\n/**\n * useModularUIBasic Hook\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n origin: undefined,\n contextPath: undefined,\n },\n): T | null => {\n const location = useLocation();\n const memoizedHref = useMemo(() => href.toString(), [href]);\n const useModularUIOptions = useMemo(\n () => createUseModularUIOptions(options, memoizedHref, location),\n [options, memoizedHref, location],\n );\n\n const modularUI = useModularUI(key, href, useModularUIOptions);\n const expectedModels = useMemo(\n () => options.expectedModels ?? [],\n [options.expectedModels],\n );\n\n return useMemo((): T | null => {\n if (modularUI?.model) {\n validateModel(modularUI.model, expectedModels);\n return modularUI.model;\n }\n return null;\n }, [expectedModels, modularUI]);\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAaA;AACA,MAAMG,yBAAyB,GAAGA,CAChCC,OAAoC,EACpCC,IAAY,EACZC,QAAa,KACF;EAAA,IAAAC,QAAA;EACX,MAAMC,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/BC,GAAW,EACX5B,IAAmB,EACnBD,OAAoC,GAAG;EACrCoB,cAAc,EAAE,EAAE;EAClBf,WAAW,EAAEC,SAAS;EACtBC,gBAAgB,EAAE,KAAK;EACvBE,MAAM,EAAEH,SAAS;EACjBI,WAAW,EAAEJ;AACf,CAAC,KACY;EACb,MAAMJ,QAAQ,GAAG,IAAA4B,sBAAW,EAAC,CAAC;EAC9B,MAAMC,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM/B,IAAI,CAACgC,QAAQ,CAAC,CAAC,EAAE,CAAChC,IAAI,CAAC,CAAC;EAC3D,MAAMiC,mBAAmB,GAAG,IAAAF,cAAO,EACjC,MAAMjC,yBAAyB,CAACC,OAAO,EAAE+B,YAAY,EAAE7B,QAAQ,CAAC,EAChE,CAACF,OAAO,EAAE+B,YAAY,EAAE7B,QAAQ,CAClC,CAAC;EAED,MAAMiC,SAAS,GAAG,IAAAC,0BAAY,EAACP,GAAG,EAAE5B,IAAI,EAAEiC,mBAAmB,CAAC;EAC9D,MAAMd,cAAc,GAAG,IAAAY,cAAO,EAC5B,MAAMhC,OAAO,CAACoB,cAAc,IAAI,EAAE,EAClC,CAACpB,OAAO,CAACoB,cAAc,CACzB,CAAC;EAED,OAAO,IAAAY,cAAO,EAAC,MAAgB;IAC7B,IAAIG,SAAS,EAAEhB,KAAK,EAAE;MACpBD,aAAa,CAACiB,SAAS,CAAChB,KAAK,EAAEC,cAAc,CAAC;MAC9C,OAAOe,SAAS,CAAChB,KAAK;IACxB;IACA,OAAO,IAAI;EACb,CAAC,EAAE,CAACC,cAAc,EAAEe,SAAS,CAAC,CAAC;AACjC,CAAC;AAACE,OAAA,CAAAT,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/lib/i18n/Locale.js
CHANGED
|
@@ -70,8 +70,7 @@ class Locale {
|
|
|
70
70
|
* where the ICU messageformat module uses {placeholder_name}.
|
|
71
71
|
* This method converts the ${} to {}
|
|
72
72
|
*/
|
|
73
|
-
fixPlaceHoldersInObject() {
|
|
74
|
-
let messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
73
|
+
fixPlaceHoldersInObject(messages = {}) {
|
|
75
74
|
return JSON.parse((0, _stringify.default)(messages).replace(/'\$\{(?<key>.*?)}'/g, "''{$<key>}''").replace(/\$\{(?<key>.*?)}/g, "{$<key>}"));
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -111,9 +110,7 @@ class Locale {
|
|
|
111
110
|
/**
|
|
112
111
|
* Add or change messages for this locale. It is not possible to remove messages.
|
|
113
112
|
*/
|
|
114
|
-
update() {
|
|
115
|
-
let messages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
116
|
-
let errors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
113
|
+
update(messages = {}, errors = {}) {
|
|
117
114
|
this._messages = {
|
|
118
115
|
...this._messages,
|
|
119
116
|
...this.fixPlaceHoldersInObject(messages)
|
package/lib/i18n/Locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locale.js","names":["_formatMessage","_interopRequireDefault","require","_languages","_exceptions","_constants","Locale","constructor","locale","_defineProperty2","default","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","fixPlaceHolders","message","replace","
|
|
1
|
+
{"version":3,"file":"Locale.js","names":["_formatMessage","_interopRequireDefault","require","_languages","_exceptions","_constants","Locale","constructor","locale","_defineProperty2","default","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","fixPlaceHolders","message","replace","JSON","parse","_stringify","getBaseMessage","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","getSetting","console","debug","parameters","getMessage","update","_default","exports"],"sources":["../../src/i18n/Locale.js"],"sourcesContent":["// @flow\nimport formatMessage from \"format-message\";\n\nimport languages from \"./languages\";\nimport { IllegalStateException } from \"../exceptions\";\n\nimport { getSetting } from \"../constants\";\n\nimport type { LocaleConfiguration, MessageParameters } from \"./types\";\n\n/**\n * Create a locale\n */\nclass Locale {\n _code: string;\n _messages: { [string]: string };\n _errors: { [string]: string };\n _nativeName: ?string;\n\n constructor(locale: LocaleConfiguration) {\n this._code = locale.code;\n\n this._messages = this.fixPlaceHoldersInObject(locale.messages);\n this._errors = this.fixPlaceHoldersInObject(locale.errors);\n\n this._nativeName = locale.nativeName;\n\n formatMessage.setup({\n missingTranslation: \"ignore\",\n });\n }\n\n /**\n * Retrieve locale code\n */\n get code(): string {\n return this._code;\n }\n\n /**\n * Retrieve nativeName\n */\n get nativeName(): string {\n if (this._nativeName) {\n return this._nativeName;\n }\n\n const aLocale = this.code.split(\"-\");\n\n if (aLocale.length > 0) {\n const language = languages.lang[aLocale[0]];\n\n if (language) {\n return (\n language[1] + (aLocale[1] ? ` (${aLocale[1].toUpperCase()})` : \"\")\n );\n }\n }\n\n throw new IllegalStateException(\n `Can not find language name based on locale: ${this.code}`,\n );\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHolders(message: ?string): null | string {\n if (typeof message === \"string\") {\n return message\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\");\n }\n\n return null;\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHoldersInObject(messages: Object = {}): Object {\n return JSON.parse(\n JSON.stringify(messages)\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\"),\n );\n }\n\n /**\n * Retrieve message by id\n */\n getBaseMessage(id: string, defaultMessage?: string): string {\n if (!id && !defaultMessage) {\n return \"[message: id or defaultMessage missing]\";\n }\n\n const messageFromLocale = this._messages[id] || this._errors[id];\n\n if (\n (typeof process === \"undefined\" ||\n process.env.NODE_ENV !== \"production\") &&\n !messageFromLocale &&\n id &&\n getSetting(\"DEBUG_I18N_MESSAGE_NOT_FOUND\")\n ) {\n // eslint-disable-next-line no-console\n console.debug(\n `Message with id ${id} not found for locale ${this.code} in layout translations`,\n );\n }\n return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;\n }\n\n /**\n * Format message using formatMessage library\n */\n formatMessage(message: string, parameters?: MessageParameters): string {\n if (parameters) {\n return formatMessage(message, parameters);\n }\n\n return message;\n }\n\n /**\n * Retrieve a messages with replaced parameters\n */\n getMessage(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters,\n ): string {\n const message = this.getBaseMessage(id, defaultMessage);\n return this.formatMessage(message, parameters);\n }\n\n /**\n * Add or change messages for this locale. It is not possible to remove messages.\n */\n update(messages: Object = {}, errors: Object = {}) {\n this._messages = {\n ...this._messages,\n ...this.fixPlaceHoldersInObject(messages),\n };\n\n this._errors = {\n ...this._errors,\n ...this.fixPlaceHoldersInObject(errors),\n };\n }\n}\n\nexport default Locale;\n"],"mappings":";;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AAIA;AACA;AACA;AACA,MAAMI,MAAM,CAAC;EAMXC,WAAWA,CAACC,MAA2B,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACvC,IAAI,CAACC,KAAK,GAAGH,MAAM,CAACI,IAAI;IAExB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AACY,OAAO,EAAEe,UAAU,CAAC;EAChD;;EAEA;AACF;AACA;EACEE,MAAMA,CAAClC,QAAgB,GAAG,CAAC,CAAC,EAAEE,MAAc,GAAG,CAAC,CAAC,EAAE;IACjD,IAAI,CAACJ,SAAS,GAAG;MACf,GAAG,IAAI,CAACA,SAAS;MACjB,GAAG,IAAI,CAACC,uBAAuB,CAACC,QAAQ;IAC1C,CAAC;IAED,IAAI,CAACC,OAAO,GAAG;MACb,GAAG,IAAI,CAACA,OAAO;MACf,GAAG,IAAI,CAACF,uBAAuB,CAACG,MAAM;IACxC,CAAC;EACH;AACF;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAAzC,OAAA,GAEcJ,MAAM","ignoreList":[]}
|
package/lib/i18n/Locales.js
CHANGED
|
@@ -51,8 +51,7 @@ const createLocalesWithConfiguredErrors = configuredErrors => (0, _map.default)(
|
|
|
51
51
|
*/
|
|
52
52
|
exports.createLocalesWithConfiguredErrors = createLocalesWithConfiguredErrors;
|
|
53
53
|
class Locales extends _BaseCollection.default {
|
|
54
|
-
constructor() {
|
|
55
|
-
let locales = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : availableLocales;
|
|
54
|
+
constructor(locales = availableLocales) {
|
|
56
55
|
super((0, _map.default)(locales).call(locales, locale => new _Locale.default(locale)));
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -122,9 +121,7 @@ class Locales extends _BaseCollection.default {
|
|
|
122
121
|
* Add or change messages and errors for the given locale.<br>
|
|
123
122
|
* It is not possible to remove messages.
|
|
124
123
|
*/
|
|
125
|
-
update(locale) {
|
|
126
|
-
let messages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
127
|
-
let errors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
124
|
+
update(locale, messages = {}, errors = {}) {
|
|
128
125
|
if (this.hasLocale(locale)) {
|
|
129
126
|
this.getLocale(locale).update(messages, errors);
|
|
130
127
|
} else {
|