@beinformed/ui 1.63.2 → 1.63.4
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 +15 -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/Authenticate.js +4 -6
- package/esm/modularui/Authenticate.js.flow +6 -6
- package/esm/modularui/Authenticate.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/Authenticate.js +4 -6
- package/lib/modularui/Authenticate.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 +23 -23
- package/src/models/concepts/SourceReferenceModel.js +6 -0
- package/src/modularui/Authenticate.js +6 -6
|
@@ -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,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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AAC;;AAED;AACA;AACA;AAFAK,OAAA,CAAA8C,gBAAA,GAAAA,gBAAA;AAGO,MAAMtC,YAAY,GAAGA,CAAA,KAGtB;EACJ,MAAMuC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAC9B,MAAMzC,SAAS,GAAG,IAAA0C,uBAAW,EAACC,0BAAY,CAAC;EAE3C,OAAO;IACL3C,SAAS;IACT4C,YAAY,EAAG5C,SAAmB,IAAKwC,QAAQ,CAAC,IAAAK,6BAAe,EAAC7C,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC;;AAED;AACA;AADAP,OAAA,CAAAQ,YAAA,GAAAA,YAAA;AAEO,MAAM6C,kBAAkB,GAAG,SAAAA,CAChCnD,IAAmB,EAGI;EAAA,IAFvBC,GAAY,GAAAC,SAAA,CAAAC,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;A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
|
/**
|
|
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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AAgB,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,WAAW,GAAG;IAClBC,WAAW,EAAEC,SAAS;IACtBC,gBAAgB,EAAED,SAAS;IAC3BE,QAAQ,EAAE,KAAK;IACfC,MAAM,EAAEH,SAAS;IACjBI,WAAW,EAAEJ,SAAS;IACtBK,KAAK,EAAE;EACT,CAAC;;EAED;EACA,IAAIX,OAAO,CAACK,WAAW,EAAE;IACvBD,WAAW,CAACC,WAAW,GAAGL,OAAO,CAACK,WAAW;IAC7CD,WAAW,CAACG,gBAAgB,GAAGP,OAAO,CAACO,gBAAgB;EACzD;;EAEA;EACA,IAAIP,OAAO,CAACW,KAAK,EAAE;IACjBP,WAAW,CAACO,KAAK,GAAGX,OAAO,CAACW,KAAK;EACnC;;EAEA;EACA,IAAIT,QAAQ,CAACU,KAAK,EAAEC,MAAM,IAAI,IAAAC,WAAA,CAAAC,OAAA,EAAAZ,QAAA,GAAAD,QAAQ,CAACc,QAAQ,EAAAC,IAAA,CAAAd,QAAA,EAAYF,IAAI,CAAC,EAAE;IAChEG,WAAW,CAACI,QAAQ,GAAG,IAAI;EAC7B;;EAEA;EACAJ,WAAW,CAACK,MAAM,GAAGT,OAAO,CAACS,MAAM,IAAIL,WAAW,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AAO,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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AAmBR,EAAE,yBAAyB,IAAI,CAAC1B,IAAI,yBACzD,CAAC;IACH;IACA,OAAO4B,iBAAiB,IAAI,IAAI,CAACT,eAAe,CAACQ,cAAc,CAAC,IAAID,EAAE;EACxE;;EAEA;AACF;AACA;EACElB,aAAaA,CAACY,OAAe,EAAEe,UAA8B,EAAU;IACrE,IAAIA,UAAU,EAAE;MACd,OAAO,IAAA3B,sBAAa,EAACY,OAAO,EAAEe,UAAU,CAAC;IAC3C;IAEA,OAAOf,OAAO;EAChB;;EAEA;AACF;AACA;EACEgB,UAAUA,CACRV,EAAU,EACVC,cAAuB,EACvBQ,UAA8B,EACtB;IACR,MAAMf,OAAO,GAAG,IAAI,CAACK,cAAc,CAACC,EAAE,EAAEC,cAAc,CAAC;IACvD,OAAO,IAAI,CAACnB,aAAa,CAACY,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 {
|
package/lib/i18n/Locales.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Locales.js","names":["_Locale","_interopRequireDefault","require","_beinformed_error_messages_en","_beinformed_error_messages_nl","_BaseCollection","_exceptions","availableLocales","exports","code","messages","errors","englishErrors","dutchErrors","createLocalesWithConfiguredErrors","configuredErrors","_map","default","call","availableLocale","Locales","BaseCollection","constructor","locales","
|
|
1
|
+
{"version":3,"file":"Locales.js","names":["_Locale","_interopRequireDefault","require","_beinformed_error_messages_en","_beinformed_error_messages_nl","_BaseCollection","_exceptions","availableLocales","exports","code","messages","errors","englishErrors","dutchErrors","createLocalesWithConfiguredErrors","configuredErrors","_map","default","call","availableLocale","Locales","BaseCollection","constructor","locales","locale","Locale","rehydrate","hydatedLocales","_collection","_context","_code","_messages","_errors","hasLocale","localeCode","some","item","_startsWith","getLocale","_context2","_find","IllegalArgumentException","availableLocaleCodes","_context3","getPreferredLocale","acceptLanguageHeader","_context4","acceptLanguages","match","preferredLocales","_filter","_context5","length","update","add","_default"],"sources":["../../src/i18n/Locales.js"],"sourcesContent":["// @flow\nimport Locale from \"./Locale\";\n\nimport englishErrors from \"./translations/beinformed_error_messages_en.nl\";\nimport dutchErrors from \"./translations/beinformed_error_messages_nl.nl\";\n\nimport BaseCollection from \"../models/base/BaseCollection\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport type { LocaleConfiguration } from \"./types\";\n\ntype ErrorMessageObject = {\n [languageCode: string]: {\n [messageID: string]: string,\n },\n};\n\ntype HydratedLocales = {\n _collection: Array<{\n _code: string,\n _messages: {\n [string]: string,\n },\n _errors: {\n [string]: string,\n },\n }>,\n};\n\n/**\n * Array of available locales\n * Order of locales is the preferred order of locales.\n * When user has an accept language header that does not correspond to the locales array,\n * the first one is used as the preferred language\n */\nexport const availableLocales: Array<LocaleConfiguration> = [\n {\n code: \"en\",\n messages: {},\n errors: englishErrors,\n },\n {\n code: \"nl\",\n messages: {},\n errors: dutchErrors,\n },\n];\n\n/**\n * Merge an object with custom error messages (exported and translated from be informed for example) and merge them with the existing translations.\n */\nexport const createLocalesWithConfiguredErrors = (\n configuredErrors: ErrorMessageObject,\n): Array<Object> =>\n availableLocales.map((availableLocale) => {\n if (configuredErrors[availableLocale.code]) {\n return {\n ...availableLocale,\n errors: {\n ...availableLocale.errors,\n ...configuredErrors[availableLocale.code],\n },\n };\n }\n\n return availableLocale;\n });\n\n/**\n * Locales, collection of Locale\n */\nclass Locales extends BaseCollection<Locale> {\n constructor(locales: Array<LocaleConfiguration> = availableLocales) {\n super(locales.map((locale) => new Locale(locale)));\n }\n\n /**\n * rehydrate\n */\n static rehydrate(hydatedLocales: HydratedLocales): Locales {\n if (hydatedLocales && hydatedLocales._collection) {\n return new Locales(\n hydatedLocales._collection.map((locale) => ({\n code: locale._code,\n messages: locale._messages,\n errors: locale._errors,\n })),\n );\n }\n\n return new Locales([]);\n }\n\n /**\n * Check if locale with localeCode exists\n */\n hasLocale(localeCode: string): boolean {\n return this.some((item) => localeCode.startsWith(item.code));\n }\n\n /**\n * Retrieve locales by localeCode from Locales collection\n */\n getLocale(localeCode: string): Locale {\n if (this.hasLocale(localeCode)) {\n const locale = this.find((item) => localeCode.startsWith(item.code));\n if (locale) {\n return locale;\n }\n }\n throw new IllegalArgumentException(\n `Locale configuration for locale ${localeCode} not found`,\n );\n }\n\n /**\n * Retrieve all available locale codes\n */\n get availableLocaleCodes(): Array<string> {\n return this.map((locale) => locale.code);\n }\n\n /**\n * Retrieve preferred locale based on the accept header of a browser\n */\n getPreferredLocale(acceptLanguageHeader: string | null): void | string {\n if (acceptLanguageHeader != null) {\n const acceptLanguages =\n acceptLanguageHeader.match(/[-A-Za-z]{2,10}/gu) || [];\n\n const preferredLocales = acceptLanguages\n .filter((locale) =>\n this.availableLocaleCodes.some((availableLocale) =>\n locale.startsWith(availableLocale),\n ),\n )\n .map((locale) =>\n this.availableLocaleCodes.find((availableLocale) =>\n locale.startsWith(availableLocale),\n ),\n );\n\n if (preferredLocales.length > 0) {\n return preferredLocales[0];\n }\n }\n\n return this.availableLocaleCodes[0];\n }\n\n /**\n * Add or change messages and errors for the given locale.<br>\n * It is not possible to remove messages.\n */\n update(locale: string, messages: Object = {}, errors: Object = {}) {\n if (this.hasLocale(locale)) {\n this.getLocale(locale).update(messages, errors);\n } else {\n this.add(\n new Locale({\n code: locale,\n messages,\n errors,\n }),\n );\n }\n }\n}\n\nexport default Locales;\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,6BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,6BAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AAsBA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,gBAA4C,GAAAC,OAAA,CAAAD,gBAAA,GAAG,CAC1D;EACEE,IAAI,EAAE,IAAI;EACVC,QAAQ,EAAE,CAAC,CAAC;EACZC,MAAM,EAAEC;AACV,CAAC,EACD;EACEH,IAAI,EAAE,IAAI;EACVC,QAAQ,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EAC7BvB,MAAM,IACb,IAAI,CAACkB,oBAAoB,CAACP,IAAI,CAAEhB,eAAe,IAC7C,IAAAkB,WAAA,CAAApB,OAAA,EAAAO,MAAM,EAAAN,IAAA,CAANM,MAAM,EAAYL,eAAe,CACnC,CACF,CAAC,EAAAD,IAAA,CAAA4B,SAAA,EACKtB,MAAM;QAAA,IAAA2B,SAAA;QAAA,OACV,IAAAX,KAAA,CAAAvB,OAAA,EAAAkC,SAAA,OAAI,CAACT,oBAAoB,EAAAxB,IAAA,CAAAiC,SAAA,EAAOhC,eAAe,IAC7C,IAAAkB,WAAA,CAAApB,OAAA,EAAAO,MAAM,EAAAN,IAAA,CAANM,MAAM,EAAYL,eAAe,CACnC,CAAC;MAAA,CACH,CAAC;MAEH,IAAI8B,gBAAgB,CAACG,MAAM,GAAG,CAAC,EAAE;QAC/B,OAAOH,gBAAgB,CAAC,CAAC,CAAC;MAC5B;IACF;IAEA,OAAO,IAAI,CAACP,oBAAoB,CAAC,CAAC,CAAC;EACrC;;EAEA;AACF;AACA;AACA;EACEW,MAAMA,CAAC7B,MAAc,EAAEd,QAAgB,GAAG,CAAC,CAAC,EAAEC,MAAc,GAAG,CAAC,CAAC,EAAE;IACjE,IAAI,IAAI,CAACsB,SAAS,CAACT,MAAM,CAAC,EAAE;MAC1B,IAAI,CAACc,SAAS,CAACd,MAAM,CAAC,CAAC6B,MAAM,CAAC3C,QAAQ,EAAEC,MAAM,CAAC;IACjD,CAAC,MAAM;MACL,IAAI,CAAC2C,GAAG,CACN,IAAI7B,eAAM,CAAC;QACThB,IAAI,EAAEe,MAAM;QACZd,QAAQ;QACRC;MACF,CAAC,CACH,CAAC;IACH;EACF;AACF;AAAC,IAAA4C,QAAA,GAAA/C,OAAA,CAAAS,OAAA,GAEcG,OAAO","ignoreList":[]}
|
package/lib/i18n/Message.js
CHANGED
|
@@ -11,16 +11,15 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
11
11
|
/**
|
|
12
12
|
* Message React component
|
|
13
13
|
*/
|
|
14
|
-
const Message = /*#__PURE__*/(0, _react.memo)(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} = _ref;
|
|
14
|
+
const Message = /*#__PURE__*/(0, _react.memo)(({
|
|
15
|
+
className,
|
|
16
|
+
id,
|
|
17
|
+
defaultMessage,
|
|
18
|
+
children,
|
|
19
|
+
data,
|
|
20
|
+
screenreaderOnly = false,
|
|
21
|
+
allowHTML = false
|
|
22
|
+
}) => {
|
|
24
23
|
const translatedMessage = (0, _useI18n.useMessage)(id, defaultMessage || children, data);
|
|
25
24
|
if (screenreaderOnly) {
|
|
26
25
|
const styles = {
|
package/lib/i18n/Message.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","names":["_react","require","_polished","_useI18n","_jsxRuntime","Message","memo","
|
|
1
|
+
{"version":3,"file":"Message.js","names":["_react","require","_polished","_useI18n","_jsxRuntime","Message","memo","className","id","defaultMessage","children","data","screenreaderOnly","allowHTML","translatedMessage","useMessage","styles","hideVisually","jsx","style","dangerouslySetInnerHTML","__html","displayName","_default","exports","default"],"sources":["../../src/i18n/Message.js"],"sourcesContent":["// @flow\nimport { memo } from \"react\";\nimport { hideVisually } from \"polished\";\n\nimport { useMessage } from \"../hooks/useI18n\";\n\ntype MessageProps = {\n +className?: string,\n +id: string,\n +defaultMessage?: string | null,\n +children?: string,\n +data?: Object | null,\n +screenreaderOnly?: boolean,\n +allowHTML?: boolean,\n};\n\n/**\n * Message React component\n */\nconst Message: React$AbstractComponent<MessageProps, mixed> =\n memo<MessageProps>(\n ({\n className,\n id,\n defaultMessage,\n children,\n data,\n screenreaderOnly = false,\n allowHTML = false,\n }: MessageProps) => {\n const translatedMessage = useMessage(\n id,\n defaultMessage || children,\n data,\n );\n\n if (screenreaderOnly) {\n const styles = {\n ...hideVisually(),\n };\n\n return (\n <span className={className} style={styles}>\n {translatedMessage}\n </span>\n );\n }\n\n if (allowHTML) {\n return (\n <span\n className={className}\n dangerouslySetInnerHTML={{\n __html: translatedMessage,\n }}\n />\n );\n }\n\n return <span className={className}>{translatedMessage}</span>;\n },\n );\n\nMessage.displayName = \"BI.Message\";\n\nexport default Message;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAA8C,IAAAG,WAAA,GAAAH,OAAA;AAY9C;AACA;AACA;AACA,MAAMI,OAAqD,gBACzD,IAAAC,WAAI,EACF,CAAC;EACCC,SAAS;EACTC,EAAE;EACFC,cAAc;EACdC,QAAQ;EACRC,IAAI;EACJC,gBAAgB,GAAG,KAAK;EACxBC,SAAS,GAAG;AACA,CAAC,KAAK;EAClB,MAAMC,iBAAiB,GAAG,IAAAC,mBAAU,EAClCP,EAAE,EACFC,cAAc,IAAIC,QAAQ,EAC1BC,IACF,CAAC;EAED,IAAIC,gBAAgB,EAAE;IACpB,MAAMI,MAAM,GAAG;MACb,GAAG,IAAAC,sBAAY,EAAC;IAClB,CAAC;IAED,oBACE,IAAAb,WAAA,CAAAc,GAAA;MAAMX,SAAS,EAAEA,SAAU;MAACY,KAAK,EAAEH,MAAO;MAAAN,QAAA,EACvCI;IAAiB,CACd,CAAC;EAEX;EAEA,IAAID,SAAS,EAAE;IACb,oBACE,IAAAT,WAAA,CAAAc,GAAA;MACEX,SAAS,EAAEA,SAAU;MACrBa,uBAAuB,EAAE;QACvBC,MAAM,EAAEP;MACV;IAAE,CACH,CAAC;EAEN;EAEA,oBAAO,IAAAV,WAAA,CAAAc,GAAA;IAAMX,SAAS,EAAEA,SAAU;IAAAG,QAAA,EAAEI;EAAiB,CAAO,CAAC;AAC/D,CACF,CAAC;AAEHT,OAAO,CAACiB,WAAW,GAAG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEpBpB,OAAO","ignoreList":[]}
|
package/lib/i18n/withMessage.js
CHANGED
|
@@ -10,12 +10,7 @@ var _reactRedux = require("react-redux");
|
|
|
10
10
|
var _reselect = require("reselect");
|
|
11
11
|
var _memoize = _interopRequireDefault(require("lodash/memoize"));
|
|
12
12
|
var _i18n = require("../redux/selectors/i18n");
|
|
13
|
-
const getMessage = (0, _reselect.createSelector)([_i18n.getLocales, _i18n.getLocale], (locales, localeCode) => (0, _memoize.default)((id, defaultMessage, placeholders) => locales.getLocale(localeCode).getMessage(id, defaultMessage, placeholders),
|
|
14
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
-
args[_key] = arguments[_key];
|
|
16
|
-
}
|
|
17
|
-
return (0, _stringify.default)(args);
|
|
18
|
-
}));
|
|
13
|
+
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)));
|
|
19
14
|
const mapStateToProps = state => ({
|
|
20
15
|
message: getMessage(state)
|
|
21
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withMessage.js","names":["_reactRedux","require","_reselect","_memoize","_interopRequireDefault","_i18n","getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","
|
|
1
|
+
{"version":3,"file":"withMessage.js","names":["_reactRedux","require","_reselect","_memoize","_interopRequireDefault","_i18n","getMessage","createSelector","getLocales","getLocale","locales","localeCode","memoize","id","defaultMessage","placeholders","args","_stringify","default","mapStateToProps","state","message","withMessage","connect","_default","exports"],"sources":["../../src/i18n/withMessage.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { createSelector } from \"reselect\";\nimport memoize from \"lodash/memoize\";\n\nimport { getLocales, getLocale } from \"../redux/selectors/i18n\";\n\nimport type { ReduxState } from \"../redux/types\";\nimport type { ComponentType } from \"react\";\n\ntype StateProps = {\n +message: (\n id: string,\n defaultMessage: string,\n placeholders: { ... },\n ) => string,\n};\n\ntype Props = {\n ...StateProps,\n ...\n};\n\nconst getMessage = createSelector(\n [getLocales, getLocale],\n (locales, localeCode) =>\n memoize(\n (id: string, defaultMessage?: string, placeholders?: Object) =>\n locales\n .getLocale(localeCode)\n .getMessage(id, defaultMessage, placeholders),\n (...args) => JSON.stringify(args),\n ),\n);\n\nconst mapStateToProps = (state: ReduxState): StateProps => ({\n message: getMessage(state),\n});\n\n/**\n */\nconst withMessage: ComponentType<any> = connect<Props, {}, StateProps, _, _, _>(\n mapStateToProps,\n);\n\nexport default withMessage;\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAkBA,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,MAAMG,eAAe,GAAIC,KAAiB,KAAkB;EAC1DC,OAAO,EAAEf,UAAU,CAACc,KAAK;AAC3B,CAAC,CAAC;;AAEF;AACA;AACA,MAAME,WAA+B,GAAG,IAAAC,mBAAO,EAC7CJ,eACF,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAP,OAAA,GAEaI,WAAW","ignoreList":[]}
|
|
@@ -56,11 +56,8 @@ class ActionCollection extends _BaseCollection.default {
|
|
|
56
56
|
/**
|
|
57
57
|
* Retrieve actions including a layout hint
|
|
58
58
|
*/
|
|
59
|
-
getActionsByLayoutHint() {
|
|
59
|
+
getActionsByLayoutHint(...hints) {
|
|
60
60
|
var _context3;
|
|
61
|
-
for (var _len = arguments.length, hints = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
62
|
-
hints[_key] = arguments[_key];
|
|
63
|
-
}
|
|
64
61
|
const newCollection = new ActionCollection();
|
|
65
62
|
newCollection.collection = (0, _filter.default)(_context3 = this).call(_context3, action => action.layouthint.has(...hints));
|
|
66
63
|
return newCollection;
|
|
@@ -69,8 +66,8 @@ class ActionCollection extends _BaseCollection.default {
|
|
|
69
66
|
/**
|
|
70
67
|
* Indicates if an action with layout hint exists
|
|
71
68
|
*/
|
|
72
|
-
hasActionsByLayoutHint() {
|
|
73
|
-
return this.getActionsByLayoutHint(...
|
|
69
|
+
hasActionsByLayoutHint(...hints) {
|
|
70
|
+
return this.getActionsByLayoutHint(...hints).length > 0;
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionCollection.js","names":["_BaseCollection","_interopRequireDefault","require","_ActionModel","ActionCollection","BaseCollection","constructor","actions","actionsContributions","modelOptions","Array","isArray","collection","actionModels","actionData","actionContribution","_find","default","call","name","type","push","ActionModel","getActionByKey","key","_context","newCollection","_filter","action","first","getActionsByType","_context2","_includes","getActionsByLayoutHint","
|
|
1
|
+
{"version":3,"file":"ActionCollection.js","names":["_BaseCollection","_interopRequireDefault","require","_ActionModel","ActionCollection","BaseCollection","constructor","actions","actionsContributions","modelOptions","Array","isArray","collection","actionModels","actionData","actionContribution","_find","default","call","name","type","push","ActionModel","getActionByKey","key","_context","newCollection","_filter","action","first","getActionsByType","_context2","_includes","getActionsByLayoutHint","hints","_context3","layouthint","has","hasActionsByLayoutHint","length","routePath","_context4","enabledRoutes","isDisabled","path","_map","selfhref","join","exports"],"sources":["../../../src/models/actions/ActionCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ActionModel from \"./ActionModel\";\nimport type { ModelOptions } from \"../types\";\n\n/**\n * Collection of actions\n */\nexport default class ActionCollection extends BaseCollection<ActionModel> {\n constructor(\n actions?: Object,\n actionsContributions?: Object,\n modelOptions?: ModelOptions,\n ) {\n super();\n\n // no actions gives an empty collection\n if (!Array.isArray(actions)) {\n this.collection = [];\n } else if (Array.isArray(actionsContributions)) {\n const actionModels = [];\n for (const actionData of actions) {\n const actionContribution = actionsContributions.find(\n (actionContribution) =>\n actionContribution.name === actionData.name &&\n actionContribution.type !== \"service-operation\",\n );\n\n if (actionContribution) {\n actionModels.push(\n new ActionModel(actionData, actionContribution, modelOptions),\n );\n }\n }\n\n this.collection = actionModels;\n }\n }\n\n /**\n * Retrieve action by key\n */\n getActionByKey(key: string): ActionModel | null {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) => action.key === key);\n\n return newCollection.first;\n }\n\n /**\n * Retrieve actions by type\n */\n getActionsByType(type: string | Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n Array.isArray(type) ? type.includes(action.type) : action.type === type,\n );\n\n return newCollection;\n }\n\n /**\n * Retrieve actions including a layout hint\n */\n getActionsByLayoutHint(...hints: Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n action.layouthint.has(...hints),\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if an action with layout hint exists\n */\n hasActionsByLayoutHint(...hints: Array<string>): boolean {\n return this.getActionsByLayoutHint(...hints).length > 0;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n const enabledRoutes = this.collection.filter(\n (action) => !action.isDisabled,\n );\n\n if (enabledRoutes.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = enabledRoutes.map((action) => action.selfhref.path).join(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,CAAC;IAED,IAAID,aAAa,CAACH,MAAM,KAAK,CAAC,EAAE;MAC9B,OAAO,wBAAwB;IACjC;IAEA,MAAMK,IAAI,GAAG,IAAAC,IAAA,CAAA5B,OAAA,EAAAyB,aAAa,EAAAxB,IAAA,CAAbwB,aAAa,EAAMd,MAAM,IAAKA,MAAM,CAACkB,QAAQ,CAACF,IAAI,CAAC,CAACG,IAAI,CAAC,GAAG,CAAC;IAE1E,OAAO,IAAI,CAACR,MAAM,GAAG,CAAC,GAAG,IAAIK,IAAI,GAAG,GAAGA,IAAI;EAC7C;AACF;AAACI,OAAA,CAAA/B,OAAA,GAAAb,gBAAA","ignoreList":[]}
|
|
@@ -31,10 +31,7 @@ class ActionModel extends _BaseModel.default {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
*/
|
|
34
|
-
static createFromHref(name, href, label) {
|
|
35
|
-
let type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "form";
|
|
36
|
-
let origin = arguments.length > 4 ? arguments[4] : undefined;
|
|
37
|
-
let contextPath = arguments.length > 5 ? arguments[5] : undefined;
|
|
34
|
+
static createFromHref(name, href, label, type = "form", origin, contextPath) {
|
|
38
35
|
const data = {
|
|
39
36
|
name,
|
|
40
37
|
href
|