@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","arguments","length","undefined","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getEnabledLocales","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getEnabledLocales } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getEnabledLocales().includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n store.dispatch(setDateTimeSettings());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAC,uBAAA,CAAAN,OAAA;AAGA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AASA,IAAAU,SAAA,GAAAV,OAAA;AAEA,IAAAW,WAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,KAAA,GAAAb,OAAA;AAEA,IAAAc,iBAAA,GAAAX,sBAAA,CAAAH,OAAA;AAA6D,SAAAM,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAA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AMO,UAAU,GAAGA,CACjBC,KAAU,EACVC,IAAY,EACZC,aAAsB,KACX;EACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAY,CAAC,CAAC;EAClC,MAAMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAACpF,OAAA,CAAA8E,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getEnabledLocales","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","undefined","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getEnabledLocales } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getEnabledLocales().includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n store.dispatch(setDateTimeSettings());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;A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Theme = _interopRequireDefault(require("./createTheme"));
|
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
/**
|
|
13
13
|
*/
|
|
14
|
-
const ThemeProvider =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
preferences
|
|
22
|
-
} = _ref2;
|
|
23
|
-
return preferences.theme;
|
|
24
|
-
});
|
|
14
|
+
const ThemeProvider = ({
|
|
15
|
+
theme,
|
|
16
|
+
children
|
|
17
|
+
}) => {
|
|
18
|
+
const storedTheme = (0, _reactRedux.useSelector)(({
|
|
19
|
+
preferences
|
|
20
|
+
}) => preferences.theme);
|
|
25
21
|
const finalTheme = (0, _createTheme.default)(storedTheme, theme);
|
|
26
22
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledComponents.ThemeProvider, {
|
|
27
23
|
theme: finalTheme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.js","names":["_reactRedux","require","_styledComponents","_createTheme","_interopRequireDefault","_jsxRuntime","ThemeProvider","
|
|
1
|
+
{"version":3,"file":"ThemeProvider.js","names":["_reactRedux","require","_styledComponents","_createTheme","_interopRequireDefault","_jsxRuntime","ThemeProvider","theme","children","storedTheme","useSelector","preferences","finalTheme","createTheme","jsx","displayName","_default","exports","default"],"sources":["../../src/react-theme/ThemeProvider.js"],"sourcesContent":["// @flow\nimport { useSelector } from \"react-redux\";\nimport { ThemeProvider as SCThemeProvider } from \"styled-components\";\n\nimport createTheme from \"./createTheme\";\n\nimport type { Node } from \"react\";\nimport type { Theme } from \"./types\";\n\nexport type Props = {\n +theme?: Theme | Array<Theme>,\n +children: Node,\n};\n\n/**\n */\nconst ThemeProvider = ({ theme, children }: Props): Node => {\n const storedTheme = useSelector(({ preferences }) => preferences.theme);\n const finalTheme = createTheme(storedTheme, theme);\n\n return <SCThemeProvider theme={finalTheme}>{children}</SCThemeProvider>;\n};\nThemeProvider.displayName = \"BI.ThemeProvider\";\n\nexport default ThemeProvider;\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAwC,IAAAI,WAAA,GAAAJ,OAAA;AAUxC;AACA;AACA,MAAMK,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAgB,CAAC,KAAW;EAC1D,MAAMC,WAAW,GAAG,IAAAC,uBAAW,EAAC,CAAC;IAAEC;EAAY,CAAC,KAAKA,WAAW,CAACJ,KAAK,CAAC;EACvE,MAAMK,UAAU,GAAG,IAAAC,oBAAW,EAACJ,WAAW,EAAEF,KAAK,CAAC;EAElD,oBAAO,IAAAF,WAAA,CAAAS,GAAA,EAACZ,iBAAA,CAAAI,aAAe;IAACC,KAAK,EAAEK,UAAW;IAAAJ,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AACzE,CAAC;AACDF,aAAa,CAACS,WAAW,GAAG,kBAAkB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEhCZ,aAAa","ignoreList":[]}
|
|
@@ -15,8 +15,7 @@ const replacePlaceholders = inputTheme => {
|
|
|
15
15
|
var _context;
|
|
16
16
|
const possibleKeys = (0, _map.default)(_context = (0, _keys.default)(inputTheme)).call(_context, key => `\\b${key}\\b`).join("|");
|
|
17
17
|
const re = new RegExp(`\\$(${possibleKeys})`, "g");
|
|
18
|
-
(0, _entries.default)(inputTheme).forEach(
|
|
19
|
-
let [key, value] = _ref;
|
|
18
|
+
(0, _entries.default)(inputTheme).forEach(([key, value]) => {
|
|
20
19
|
if (key !== "settings" && typeof value === "string") {
|
|
21
20
|
inputTheme[key] = value.replace(re,
|
|
22
21
|
// $FlowIssue[incompatible-call]
|
|
@@ -25,14 +24,11 @@ const replacePlaceholders = inputTheme => {
|
|
|
25
24
|
});
|
|
26
25
|
return inputTheme;
|
|
27
26
|
};
|
|
28
|
-
const generateTheme =
|
|
27
|
+
const generateTheme = (storedTheme, ...themeElements) => {
|
|
29
28
|
const storedSettings = storedTheme?.settings ?? {};
|
|
30
29
|
let generatedTheme = {
|
|
31
30
|
settings: {}
|
|
32
31
|
};
|
|
33
|
-
for (var _len = arguments.length, themeElements = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
34
|
-
themeElements[_key - 1] = arguments[_key];
|
|
35
|
-
}
|
|
36
32
|
for (const element of themeElements) {
|
|
37
33
|
if (typeof element === "function") {
|
|
38
34
|
generatedTheme = element(replacePlaceholders(generatedTheme));
|
|
@@ -101,10 +97,7 @@ const generateTheme = function (storedTheme) {
|
|
|
101
97
|
* SECONDARY_COLOR: "#00ff00",
|
|
102
98
|
* }
|
|
103
99
|
*/
|
|
104
|
-
const createTheme =
|
|
105
|
-
for (var _len2 = arguments.length, themeConfigs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
106
|
-
themeConfigs[_key2 - 1] = arguments[_key2];
|
|
107
|
-
}
|
|
100
|
+
const createTheme = (storedTheme, ...themeConfigs) => {
|
|
108
101
|
const customTheme = generateTheme(storedTheme, ...(0, _flattenDeep.default)(themeConfigs));
|
|
109
102
|
if (customTheme) {
|
|
110
103
|
(0, _Settings.setSettings)(customTheme.settings);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.js","names":["_flattenDeep","_interopRequireDefault","require","_objects","_Settings","replacePlaceholders","inputTheme","_context","possibleKeys","_map","default","_keys","call","key","join","re","RegExp","_entries","forEach","
|
|
1
|
+
{"version":3,"file":"createTheme.js","names":["_flattenDeep","_interopRequireDefault","require","_objects","_Settings","replacePlaceholders","inputTheme","_context","possibleKeys","_map","default","_keys","call","key","join","re","RegExp","_entries","forEach","value","replace","match","capture","generateTheme","storedTheme","themeElements","storedSettings","settings","generatedTheme","element","isPlainObject","generatedSettings","createTheme","themeConfigs","customTheme","flattenDeep","setSettings","_default","exports"],"sources":["../../src/react-theme/createTheme.js"],"sourcesContent":["// @flow\nimport flattenDeep from \"lodash/flattenDeep\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport { setSettings } from \"../constants/Settings\";\n\nimport type { Theme } from \"./types\";\n\nconst replacePlaceholders = (inputTheme: Theme) => {\n const possibleKeys = Object.keys(inputTheme)\n .map((key) => `\\\\b${key}\\\\b`)\n .join(\"|\");\n\n const re = new RegExp(`\\\\$(${possibleKeys})`, \"g\");\n Object.entries(inputTheme).forEach(([key, value]) => {\n if (key !== \"settings\" && typeof value === \"string\") {\n inputTheme[key] = value.replace(\n re,\n // $FlowIssue[incompatible-call]\n (match, capture) => inputTheme[capture],\n );\n }\n });\n\n return inputTheme;\n};\n\nconst generateTheme = (storedTheme: Theme, ...themeElements: Array<Theme>) => {\n const storedSettings = storedTheme?.settings ?? {};\n\n let generatedTheme = { settings: {} };\n for (const element of themeElements) {\n if (typeof element === \"function\") {\n generatedTheme = element(replacePlaceholders(generatedTheme));\n } else if (isPlainObject(element)) {\n const generatedSettings = generatedTheme.settings;\n // $FlowFixMe[cannot-spread-indexer]\n generatedTheme = { ...generatedTheme, ...element, ...storedTheme };\n if (\"settings\" in element) {\n generatedTheme.settings = {\n ...generatedSettings,\n ...element.settings,\n ...storedSettings,\n };\n }\n }\n }\n\n // final - replace any assignments inside the theme\n return replacePlaceholders(generatedTheme);\n};\n\n/**\n * Create a theme from multiple theme configuration objects.\n * Properties are overwriten by iterating the configuration objects from left to right.\n *\n * The first argument represents a stored theme part, this is optional. The stored theme part will overwrite every part in the collection of theme parts.\n * Thus a stored configuration is leading as it can be configured by a modeller through the repository.\n *\n * Placeholders can be used, they are replaced before calling a function theme part or at the end of the theme creation.\n *\n * Both objects and function can be used, where a function receives the previous objects as input arguments.\n * For example using the method createTheme(ThemeObject, ThemeObject2, ThemeFunction, ThemeFunction2), will be handled as:\n *\n * ThemeFunction2(ThemeFunction1({ ...ThemeObject, ...ThemeObject2 }))\n *\n * @example\n * Example where the primary color of the default theme is overwritten with a primary color of the custom theme,\n * but the button bg still uses the yiq function of the default theme:\n *\n * const DefaultTheme = {\n * PRIMARY_COLOR: \"#0000ff\",\n * SECONDARY_COLOR: \"#00ff00\",\n * BUTTON_COLOR: \"$PRIMARY_COLOR\"\n * }\n *\n * const createDefaultTheme = (input) => ({\n * ...input,\n * BUTTON_BG: getContrastYIQ(input.BUTTON_COLOR)\n * })\n *\n * const CustomTheme = {\n * PRIMARY_COLOR: \"#ff0000\"\n * }\n *\n * createTheme(null, DefaultTheme, CustomTheme, createDefaultTheme);\n *\n * // Result:\n * {\n * PRIMARY_COLOR: \"#ff0000\",\n * BUTTON_COLOR: \"#ff0000\",\n * BUTTON_BG: \"#fff\",\n * SECONDARY_COLOR: \"#00ff00\",\n * }\n */\nconst createTheme = (\n storedTheme: Theme,\n ...themeConfigs: Array<Theme | Array<Theme> | void>\n):\n | any\n | {}\n | {\n INPUT_FOCUS_BORDER_COLOR?: string,\n LINK_HOVER_COLOR?: string,\n PAGING_HOVER_COLOR?: string,\n settings?: { [settingName: string]: string },\n } => {\n const customTheme = generateTheme(storedTheme, ...flattenDeep(themeConfigs));\n\n if (customTheme) {\n setSettings(customTheme.settings);\n }\n\n return customTheme;\n};\n\nexport default createTheme;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAIA,MAAMG,mBAAmB,GAAIC,UAAiB,IAAK;EAAA,IAAAC,QAAA;EACjD,MAAMC,YAAY,GAAG,IAAAC,IAAA,CAAAC,OAAA,EAAAH,QAAA,OAAAI,KAAA,CAAAD,OAAA,EAAYJ,UAAU,CAAC,EAAAM,IAAA,CAAAL,QAAA,EACpCM,GAAG,IAAK,MAAMA,GAAG,KAAK,CAAC,CAC5BC,IAAI,CAAC,GAAG,CAAC;EAEZ,M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AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,WAAW,GAAGA,CAClBR,WAAkB,EAClB,GAAGS,YAAgD,KAS5C;EACP,MAAMC,WAAW,GAAGX,aAAa,CAACC,WAAW,EAAE,GAAG,IAAAW,oBAAW,EAACF,YAAY,CAAC,CAAC;EAE5E,IAAIC,WAAW,EAAE;IACf,IAAAE,qBAAW,EAACF,WAAW,CAACP,QAAQ,CAAC;EACnC;EAEA,OAAOO,WAAW;AACpB,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAA5B,OAAA,GAEasB,WAAW","ignoreList":[]}
|
|
@@ -7,10 +7,9 @@ exports.renderBackground = void 0;
|
|
|
7
7
|
var _themeProps = require("./themeProps");
|
|
8
8
|
/**
|
|
9
9
|
*/
|
|
10
|
-
const renderBackground = (path, defaultValue) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} = _ref;
|
|
10
|
+
const renderBackground = (path, defaultValue) => ({
|
|
11
|
+
theme
|
|
12
|
+
}) => {
|
|
14
13
|
const value = (0, _themeProps.getThemeProp)(theme, path, defaultValue);
|
|
15
14
|
if (typeof value === "string") {
|
|
16
15
|
return `background: ${value}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background.js","names":["_themeProps","require","renderBackground","path","defaultValue","
|
|
1
|
+
{"version":3,"file":"background.js","names":["_themeProps","require","renderBackground","path","defaultValue","theme","value","getThemeProp","exports"],"sources":["../../../src/react-theme/utils/background.js"],"sourcesContent":["// @flow\nimport { getThemeProp } from \"./themeProps\";\n\nimport type { ThemePropValue, UtilThemeProps } from \"../types\";\n\n/**\n */\nconst renderBackground =\n (path: string, defaultValue?: string): ((UtilThemeProps) => ThemePropValue) =>\n ({ theme }: UtilThemeProps) => {\n const value = getThemeProp(theme, path, defaultValue);\n\n if (typeof value === \"string\") {\n return `background: ${value}`;\n }\n\n return value;\n };\n\nexport { renderBackground };\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAIA;AACA;AACA,MAAMC,gBAAgB,GACpBA,CAACC,IAAY,EAAEC,YAAqB,KACpC,CAAC;EAAEC;AAAsB,CAAC,KAAK;EAC7B,MAAMC,KAAK,GAAG,IAAAC,wBAAY,EAACF,KAAK,EAAEF,IAAI,EAAEC,YAAY,CAAC;EAErD,IAAI,OAAOE,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO,eAAeA,KAAK,EAAE;EAC/B;EAEA,OAAOA,KAAK;AACd,CAAC;AAACE,OAAA,CAAAN,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -11,12 +11,9 @@ var _themeProps = require("./themeProps");
|
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
*/
|
|
14
|
-
const darkenColor = (amount, path, defaultValue) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} = _ref;
|
|
18
|
-
return (0, _polished.darken)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
|
|
19
|
-
};
|
|
14
|
+
const darkenColor = (amount, path, defaultValue) => ({
|
|
15
|
+
theme
|
|
16
|
+
}) => (0, _polished.darken)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
|
|
20
17
|
|
|
21
18
|
/*
|
|
22
19
|
* Themed color x amount lightened
|
|
@@ -24,12 +21,9 @@ const darkenColor = (amount, path, defaultValue) => _ref => {
|
|
|
24
21
|
/**
|
|
25
22
|
*/
|
|
26
23
|
exports.darkenColor = darkenColor;
|
|
27
|
-
const lightenColor = (amount, path, defaultValue) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} = _ref2;
|
|
31
|
-
return (0, _polished.lighten)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
|
|
32
|
-
};
|
|
24
|
+
const lightenColor = (amount, path, defaultValue) => ({
|
|
25
|
+
theme
|
|
26
|
+
}) => (0, _polished.lighten)(amount, (0, _themeProps.getThemeProp)(theme, path, defaultValue));
|
|
33
27
|
|
|
34
28
|
/*
|
|
35
29
|
* Make a color lighter or darker in the same color family
|
|
@@ -37,9 +31,6 @@ const lightenColor = (amount, path, defaultValue) => _ref2 => {
|
|
|
37
31
|
/**
|
|
38
32
|
*/
|
|
39
33
|
exports.lightenColor = lightenColor;
|
|
40
|
-
const changeHSL =
|
|
41
|
-
let hueAdjustment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
42
|
-
return (0, _polished.hsl)((0, _polished.parseToHsl)(color).hue + hueAdjustment, saturation, lightness);
|
|
43
|
-
};
|
|
34
|
+
const changeHSL = (color, saturation, lightness, hueAdjustment = 0) => (0, _polished.hsl)((0, _polished.parseToHsl)(color).hue + hueAdjustment, saturation, lightness);
|
|
44
35
|
exports.changeHSL = changeHSL;
|
|
45
36
|
//# sourceMappingURL=colors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","names":["_polished","require","_themeProps","darkenColor","amount","path","defaultValue","
|
|
1
|
+
{"version":3,"file":"colors.js","names":["_polished","require","_themeProps","darkenColor","amount","path","defaultValue","theme","darken","getThemeProp","exports","lightenColor","lighten","changeHSL","color","saturation","lightness","hueAdjustment","hsl","parseToHsl","hue"],"sources":["../../../src/react-theme/utils/colors.js"],"sourcesContent":["// @flow\nimport { darken, hsl, lighten, parseToHsl } from \"polished\";\nimport { getThemeProp } from \"./themeProps\";\n\nimport type { UtilThemeProps } from \"../types\";\n\n/*\n * Themed color x amount darkened\n */\n/**\n */\nconst darkenColor =\n (\n amount: number | string,\n path: string,\n defaultValue?: string,\n ): ((UtilThemeProps) => string) =>\n ({ theme }: UtilThemeProps) =>\n darken(amount, getThemeProp(theme, path, defaultValue));\n\n/*\n * Themed color x amount lightened\n */\n/**\n */\nconst lightenColor =\n (\n amount: number | string,\n path: string,\n defaultValue?: string,\n ): ((UtilThemeProps) => string) =>\n ({ theme }: UtilThemeProps) =>\n lighten(amount, getThemeProp(theme, path, defaultValue));\n\n/*\n * Make a color lighter or darker in the same color family\n */\n/**\n */\nconst changeHSL = (\n color: string,\n saturation?: number,\n lightness?: number,\n hueAdjustment: number = 0,\n): string => hsl(parseToHsl(color).hue + hueAdjustment, saturation, lightness);\n\nexport { darkenColor, lightenColor, changeHSL };\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA,MAAME,WAAW,GACfA,CACEC,MAAuB,EACvBC,IAAY,EACZC,YAAqB,KAEvB,CAAC;EAAEC;AAAsB,CAAC,KACxB,IAAAC,gBAAM,EAACJ,MAAM,EAAE,IAAAK,wBAAY,EAACF,KAAK,EAAEF,IAAI,EAAEC,YAAY,CAAC,CAAC;;AAE3D;AACA;AACA;AACA;AACA;AADAI,OAAA,CAAAP,WAAA,GAAAA,WAAA;AAEA,MAAMQ,YAAY,GAChBA,CACEP,MAAuB,EACvBC,IAAY,EACZC,YAAqB,KAEvB,CAAC;EAAEC;AAAsB,CAAC,KACxB,IAAAK,iBAAO,EAACR,MAAM,EAAE,IAAAK,wBAAY,EAACF,KAAK,EAAEF,IAAI,EAAEC,YAAY,CAAC,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AADAI,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAEA,MAAME,SAAS,GAAGA,CAChBC,KAAa,EACbC,UAAmB,EACnBC,SAAkB,EAClBC,aAAqB,GAAG,CAAC,KACd,IAAAC,aAAG,EAAC,IAAAC,oBAAU,EAACL,KAAK,CAAC,CAACM,GAAG,GAAGH,aAAa,EAAEF,UAAU,EAAEC,SAAS,CAAC;AAACN,OAAA,CAAAG,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -35,10 +35,7 @@ const getYIQ = color => {
|
|
|
35
35
|
* the preferred color is returned
|
|
36
36
|
*/
|
|
37
37
|
exports.getYIQ = getYIQ;
|
|
38
|
-
const getContrastYIQ =
|
|
39
|
-
let dark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "#212529";
|
|
40
|
-
let light = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "#fff";
|
|
41
|
-
let preferredColor = arguments.length > 3 ? arguments[3] : undefined;
|
|
38
|
+
const getContrastYIQ = (color, dark = "#212529", light = "#fff", preferredColor) => {
|
|
42
39
|
const yiqColor = getYIQ(color);
|
|
43
40
|
if (preferredColor && getColorContrast(color, preferredColor) >= 4.5) {
|
|
44
41
|
return preferredColor;
|
|
@@ -75,21 +72,16 @@ const getBackgroundColor = (theme, bgColorProperty, defaultValue) => {
|
|
|
75
72
|
* Retrieve the contrast color for the given background property,
|
|
76
73
|
* based on theme properties
|
|
77
74
|
*/
|
|
78
|
-
const renderContrastColor =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const preferredColor = (0, _themeProps.getThemeStringProp)(theme, preferredColorProperty);
|
|
89
|
-
const darkColor = (0, _themeProps.getThemeStringProp)(theme, standardDarkProperty, "#212529");
|
|
90
|
-
const lightColor = (0, _themeProps.getThemeStringProp)(theme, standardLightProperty, "#fff");
|
|
91
|
-
return getContrastYIQ(bgColor, darkColor, lightColor, preferredColor);
|
|
92
|
-
};
|
|
75
|
+
const renderContrastColor = (bgColorProperty, preferredColorProperty, standardDarkProperty = "YIQ_DARK_COLOR", standardLightProperty = "YIQ_LIGHT_COLOR") => ({
|
|
76
|
+
theme = {
|
|
77
|
+
settings: {}
|
|
78
|
+
}
|
|
79
|
+
}) => {
|
|
80
|
+
const bgColor = getBackgroundColor(theme, bgColorProperty, "#ffffff");
|
|
81
|
+
const preferredColor = (0, _themeProps.getThemeStringProp)(theme, preferredColorProperty);
|
|
82
|
+
const darkColor = (0, _themeProps.getThemeStringProp)(theme, standardDarkProperty, "#212529");
|
|
83
|
+
const lightColor = (0, _themeProps.getThemeStringProp)(theme, standardLightProperty, "#fff");
|
|
84
|
+
return getContrastYIQ(bgColor, darkColor, lightColor, preferredColor);
|
|
93
85
|
};
|
|
94
86
|
exports.renderContrastColor = renderContrastColor;
|
|
95
87
|
//# sourceMappingURL=contrast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contrast.js","names":["_polished","require","_themeProps","_exceptions","getColorContrast","color1","color2","luminance1","getLuminance","luminance2","parseFloat","toFixed","exports","getYIQ","color","rgb","parseToRgb","red","green","blue","getContrastYIQ","dark","
|
|
1
|
+
{"version":3,"file":"contrast.js","names":["_polished","require","_themeProps","_exceptions","getColorContrast","color1","color2","luminance1","getLuminance","luminance2","parseFloat","toFixed","exports","getYIQ","color","rgb","parseToRgb","red","green","blue","getContrastYIQ","dark","light","preferredColor","yiqColor","darkColor","lightColor","getBackgroundColor","theme","bgColorProperty","defaultValue","bgColor","getProp","backgroundColor","ThemePropertyException","renderContrastColor","preferredColorProperty","standardDarkProperty","standardLightProperty","settings","getThemeStringProp"],"sources":["../../../src/react-theme/utils/contrast.js"],"sourcesContent":["// @flow\nimport { getLuminance, parseToRgb } from \"polished\";\n\nimport { getThemeStringProp, getProp } from \"./themeProps\";\n\nimport { ThemePropertyException } from \"../../exceptions\";\n\nimport type { Theme, UtilThemeProps } from \"../types\";\n\n/**\n * calculate the contrast ratio of two colors\n */\nconst getColorContrast = (color1: string, color2: string): number => {\n const luminance1 = getLuminance(color1);\n const luminance2 = getLuminance(color2);\n return parseFloat(\n (luminance1 > luminance2\n ? (luminance1 + 0.05) / (luminance2 + 0.05)\n : (luminance2 + 0.05) / (luminance1 + 0.05)\n ).toFixed(2),\n );\n};\n\n/*\n * The YIQ equation converts the RGB color (0 to 255) into a YIQ color space.\n * YIQ is the standard formula for calculating the perceived brightness of a color,\n * and is recommended by the World Wide Web Consortium (W3C).\n */\n/**\n */\nconst getYIQ = (color: string): number => {\n const rgb = parseToRgb(color);\n\n return (rgb.red * 299 + rgb.green * 587 + rgb.blue * 114) / 1000;\n};\n\n/**\n * Get dark or light color, depending on the given color\n * When the contrast between the color and the light or dark color is too low,\n * the preferred color is returned\n */\nconst getContrastYIQ = (\n color: string,\n dark: string = \"#212529\",\n light: string = \"#fff\",\n preferredColor?: string,\n): string => {\n const yiqColor = getYIQ(color);\n\n if (preferredColor && getColorContrast(color, preferredColor) >= 4.5) {\n return preferredColor;\n }\n\n const darkColor = getYIQ(dark) < 127.5 ? dark : \"#212529\";\n const lightColor = getYIQ(light) > 127.5 ? light : \"#fff\";\n\n if (yiqColor > 127.5) {\n if (getColorContrast(color, darkColor) < 3) {\n return \"#212529\";\n }\n\n return darkColor;\n }\n\n if (getColorContrast(color, lightColor) < 3) {\n return \"#fff\";\n }\n return lightColor;\n};\n\n/**\n */\nconst getBackgroundColor = (\n theme: Theme,\n bgColorProperty: string,\n defaultValue: string,\n) => {\n let bgColor = getProp(theme, bgColorProperty, defaultValue);\n\n if (typeof bgColor === \"object\") {\n bgColor = bgColor?.backgroundColor ?? defaultValue;\n }\n\n if (typeof bgColor === \"string\") {\n return bgColor;\n }\n\n throw new ThemePropertyException(\n `${bgColorProperty} is not a string, but: ${typeof bgColor}`,\n );\n};\n\n/**\n * Retrieve the contrast color for the given background property,\n * based on theme properties\n */\nconst renderContrastColor =\n (\n bgColorProperty: string,\n preferredColorProperty?: string,\n standardDarkProperty: string = \"YIQ_DARK_COLOR\",\n standardLightProperty: string = \"YIQ_LIGHT_COLOR\",\n ): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) => {\n const bgColor = getBackgroundColor(theme, bgColorProperty, \"#ffffff\");\n const preferredColor = getThemeStringProp(theme, preferredColorProperty);\n const darkColor = getThemeStringProp(\n theme,\n standardDarkProperty,\n \"#212529\",\n );\n const lightColor = getThemeStringProp(theme, standardLightProperty, \"#fff\");\n\n return getContrastYIQ(bgColor, darkColor, lightColor, preferredColor);\n };\n\nexport { getColorContrast, getYIQ, getContrastYIQ, renderContrastColor };\n"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAIA;AACA;AACA;AACA,MAAMG,gBAAgB,GAAGA,CAACC,MAAc,EAAEC,MAAc,KAAa;EACnE,MAAMC,UAAU,GAAG,IAAAC,sBAAY,EAACH,MAAM,CAAC;EACvC,MAAMI,UAAU,GAAG,IAAAD,sBAAY,EAACF,MAAM,CAAC;EACvC,OAAOI,UAAU,CACf,CAACH,UAAU,GAAGE,UAAU,GACpB,CAACF,UAAU,GAAG,IAAI,KAAKE,UAAU,GAAG,IAAI,CAAC,GACzC,CAACA,UAAU,GAAG,IAAI,KAAKF,UAAU,GAAG,IAAI,CAAC,EAC3CI,OAAO,CAAC,CAAC,CACb,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AADAC,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AAEA,MAAMS,MAAM,GAAIC,KAAa,IAAa;EACxC,MAAMC,GAAG,GAAG,IAAAC,oBAAU,EAACF,KAAK,CAAC;EAE7B,OAAO,CAACC,GAAG,CAACE,GAAG,GAAG,GAAG,GAAGF,GAAG,CAACG,KAAK,GAAG,GAAG,GAAGH,GAAG,CAACI,IAAI,GAAG,GAAG,IAAI,IAAI;AAClE,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAP,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAKA,MAAMO,cAAc,GAAGA,CACrBN,KAAa,EACbO,IAAY,GAAG,SAAS,EACxBC,KAAa,GAAG,MAAM,EACtBC,cAAuB,KACZ;EACX,MAAMC,QAAQ,GAAGX,MAAM,CAACC,KAAK,CAAC;EAE9B,IAAIS,cAAc,IAAInB,gBAAgB,CAAC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C,KAAK;EAChD,MAAMR,OAAO,GAAGJ,kBAAkB,CAACC,KAAK,EAAEC,eAAe,EAAE,SAAS,CAAC;EACrE,MAAMN,cAAc,GAAG,IAAAiB,8BAAkB,EAACZ,KAAK,EAAEQ,sBAAsB,CAAC;EACxE,MAAMX,SAAS,GAAG,IAAAe,8BAAkB,EAClCZ,KAAK,EACLS,oBAAoB,EACpB,SACF,CAAC;EACD,MAAMX,UAAU,GAAG,IAAAc,8BAAkB,EAACZ,KAAK,EAAEU,qBAAqB,EAAE,MAAM,CAAC;EAE3E,OAAOlB,cAAc,CAACW,OAAO,EAAEN,SAAS,EAAEC,UAAU,EAAEH,cAAc,CAAC;AACvE,CAAC;AAACX,OAAA,CAAAuB,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -13,22 +13,16 @@ const DEFAULT_CORNER_PROPERTY = "border-radius";
|
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
15
|
*/
|
|
16
|
-
const roundedCorners =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (theme.ROUNDED_CORNERS) {
|
|
27
|
-
const propertyName = property && property !== DEFAULT_CORNER_PROPERTY ? `border-${property}-radius` : DEFAULT_CORNER_PROPERTY;
|
|
28
|
-
return `${propertyName}: ${(0, _themeProps.getThemeStringProp)(theme, path, defaultValue)}`;
|
|
29
|
-
}
|
|
30
|
-
return "";
|
|
31
|
-
};
|
|
16
|
+
const roundedCorners = (property = DEFAULT_CORNER_PROPERTY, path = "BORDER_RADIUS", defaultValue = "0.25rem") => ({
|
|
17
|
+
theme = {
|
|
18
|
+
settings: {}
|
|
19
|
+
}
|
|
20
|
+
}) => {
|
|
21
|
+
if (theme.ROUNDED_CORNERS) {
|
|
22
|
+
const propertyName = property && property !== DEFAULT_CORNER_PROPERTY ? `border-${property}-radius` : DEFAULT_CORNER_PROPERTY;
|
|
23
|
+
return `${propertyName}: ${(0, _themeProps.getThemeStringProp)(theme, path, defaultValue)}`;
|
|
24
|
+
}
|
|
25
|
+
return "";
|
|
32
26
|
};
|
|
33
27
|
exports.roundedCorners = roundedCorners;
|
|
34
28
|
//# sourceMappingURL=corners.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corners.js","names":["_themeProps","require","DEFAULT_CORNER_PROPERTY","roundedCorners","property","
|
|
1
|
+
{"version":3,"file":"corners.js","names":["_themeProps","require","DEFAULT_CORNER_PROPERTY","roundedCorners","property","path","defaultValue","theme","settings","ROUNDED_CORNERS","propertyName","getThemeStringProp","exports"],"sources":["../../../src/react-theme/utils/corners.js"],"sourcesContent":["// @flow\nimport { getThemeStringProp } from \"./themeProps\";\n\nimport type { UtilThemeProps } from \"../types\";\n\nconst DEFAULT_CORNER_PROPERTY = \"border-radius\";\n\n/*\n * Border radius based on the theme setting for rounded corners\n * When ROUNDED_CORNERS is not true in the theme, no rounded corners are returned\n */\n/**\n */\nconst roundedCorners =\n (\n property: string = DEFAULT_CORNER_PROPERTY,\n path: string = \"BORDER_RADIUS\",\n defaultValue: string = \"0.25rem\",\n ): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) => {\n if (theme.ROUNDED_CORNERS) {\n const propertyName =\n property && property !== DEFAULT_CORNER_PROPERTY\n ? `border-${property}-radius`\n : DEFAULT_CORNER_PROPERTY;\n\n return `${propertyName}: ${getThemeStringProp(\n theme,\n path,\n defaultValue,\n )}`;\n }\n\n return \"\";\n };\n\nexport { roundedCorners };\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAIA,MAAMC,uBAAuB,GAAG,eAAe;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAClBA,CACEC,QAAgB,GAAGF,uBAAuB,EAC1CG,IAAY,GAAG,eAAe,EAC9BC,YAAoB,GAAG,SAAS,KAElC,CAAC;EAAEC,KAAK,GAAG;IAAEC,QAAQ,EAAE,CAAC;EAAE;AAAkB,CAAC,KAAK;EAChD,IAAID,KAAK,CAACE,eAAe,EAAE;IACzB,MAAMC,YAAY,GAChBN,QAAQ,IAAIA,QAAQ,KAAKF,uBAAuB,GAC5C,UAAUE,QAAQ,SAAS,GAC3BF,uBAAuB;IAE7B,OAAO,GAAGQ,YAAY,KAAK,IAAAC,8BAAkB,EAC3CJ,KAAK,EACLF,IAAI,EACJC,YACF,CAAC,EAAE;EACL;EAEA,OAAO,EAAE;AACX,CAAC;AAACM,OAAA,CAAAT,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -12,10 +12,7 @@ var _IllegalArgumentException = _interopRequireDefault(require("../../exceptions
|
|
|
12
12
|
var _IllegalStateException = _interopRequireDefault(require("../../exceptions/IllegalStateException"));
|
|
13
13
|
/**
|
|
14
14
|
*/
|
|
15
|
-
const getSize =
|
|
16
|
-
let ratio = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
17
|
-
let path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "SPACER";
|
|
18
|
-
let unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "rem";
|
|
15
|
+
const getSize = (theme, ratio = 1, path = "SPACER", unit = "rem") => {
|
|
19
16
|
if (typeof ratio === "string") {
|
|
20
17
|
return ratio;
|
|
21
18
|
}
|
|
@@ -34,17 +31,11 @@ const getSize = function (theme) {
|
|
|
34
31
|
*/
|
|
35
32
|
/**
|
|
36
33
|
*/
|
|
37
|
-
const spacer =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
settings: {}
|
|
43
|
-
}
|
|
44
|
-
} = _ref;
|
|
45
|
-
return getSize(theme, ratio);
|
|
46
|
-
};
|
|
47
|
-
};
|
|
34
|
+
const spacer = (ratio = 1) => ({
|
|
35
|
+
theme = {
|
|
36
|
+
settings: {}
|
|
37
|
+
}
|
|
38
|
+
}) => getSize(theme, ratio);
|
|
48
39
|
|
|
49
40
|
/*
|
|
50
41
|
* Render spacers based on the given ratio * theme SPACER
|
|
@@ -54,19 +45,11 @@ const spacer = function () {
|
|
|
54
45
|
/**
|
|
55
46
|
*/
|
|
56
47
|
exports.spacer = spacer;
|
|
57
|
-
const spacers =
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
const spacers = (...ratios) => ({
|
|
49
|
+
theme = {
|
|
50
|
+
settings: {}
|
|
60
51
|
}
|
|
61
|
-
|
|
62
|
-
let {
|
|
63
|
-
theme = {
|
|
64
|
-
settings: {}
|
|
65
|
-
}
|
|
66
|
-
} = _ref2;
|
|
67
|
-
return (0, _map.default)(ratios).call(ratios, ratio => getSize(theme, ratio)).join(" ");
|
|
68
|
-
};
|
|
69
|
-
};
|
|
52
|
+
}) => (0, _map.default)(ratios).call(ratios, ratio => getSize(theme, ratio)).join(" ");
|
|
70
53
|
|
|
71
54
|
/*
|
|
72
55
|
* Render a gutter based on GUTTER property
|
|
@@ -74,16 +57,10 @@ const spacers = function () {
|
|
|
74
57
|
/**
|
|
75
58
|
*/
|
|
76
59
|
exports.spacers = spacers;
|
|
77
|
-
const gutter =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
settings: {}
|
|
83
|
-
}
|
|
84
|
-
} = _ref3;
|
|
85
|
-
return getSize(theme, ratio, "GRID_GUTTER", "px");
|
|
86
|
-
};
|
|
87
|
-
};
|
|
60
|
+
const gutter = (ratio = 1) => ({
|
|
61
|
+
theme = {
|
|
62
|
+
settings: {}
|
|
63
|
+
}
|
|
64
|
+
}) => getSize(theme, ratio, "GRID_GUTTER", "px");
|
|
88
65
|
exports.gutter = gutter;
|
|
89
66
|
//# sourceMappingURL=spacers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacers.js","names":["_big","_interopRequireDefault","require","_IllegalArgumentException","_IllegalStateException","getSize","theme","ratio","
|
|
1
|
+
{"version":3,"file":"spacers.js","names":["_big","_interopRequireDefault","require","_IllegalArgumentException","_IllegalStateException","getSize","theme","ratio","path","unit","size","Big","times","IllegalStateException","IllegalArgumentException","_stringify","default","spacer","settings","exports","spacers","ratios","_map","call","join","gutter"],"sources":["../../../src/react-theme/utils/spacers.js"],"sourcesContent":["// @flow\nimport Big from \"big.js\";\n\nimport type { Theme, UtilThemeProps } from \"../types\";\nimport IllegalArgumentException from \"../../exceptions/IllegalArgumentException\";\nimport IllegalStateException from \"../../exceptions/IllegalStateException\";\n\n/**\n */\nconst getSize = (\n theme: Theme,\n ratio: number | string = 1,\n path: string = \"SPACER\",\n unit: string = \"rem\",\n) => {\n if (typeof ratio === \"string\") {\n return ratio;\n }\n\n if (typeof ratio === \"number\") {\n if (typeof theme[path] === \"number\") {\n const size = Big(ratio).times(theme[path]);\n return `${size}${unit}`;\n }\n throw new IllegalStateException(`Size ${path} must be a number`);\n }\n\n throw new IllegalArgumentException(\n `Ratio ${JSON.stringify(ratio)} must be a string or number`,\n );\n};\n\n/*\n * Render spacers based on the given ratio * theme SPACER\n */\n/**\n */\nconst spacer =\n (ratio: number = 1): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n getSize(theme, ratio);\n\n/*\n * Render spacers based on the given ratio * theme SPACER\n * Ratio's can be given clockwise with shorthand,\n * spacers(0.5, 1) with a spacer of 0.8 will give \"0.4rem 1rem\";\n */\n/**\n */\nconst spacers =\n (...ratios: Array<number | \"auto\">): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n ratios.map((ratio) => getSize(theme, ratio)).join(\" \");\n\n/*\n * Render a gutter based on GUTTER property\n */\n/**\n */\nconst gutter =\n (ratio: number = 1): ((UtilThemeProps) => string) =>\n ({ theme = { settings: {} } }: UtilThemeProps) =>\n getSize(theme, ratio, \"GRID_GUTTER\", \"px\");\n\nexport { spacer, spacers, gutter };\n"],"mappings":";;;;;;;;;AACA,IAAAA,IAAA,GAAAC,sB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,IAAKF,OAAO,CAACC,KAAK,EAAEC,KAAK,CAAC,CAAC,CAACiB,IAAI,CAAC,GAAG,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AADAL,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAEA,MAAMK,MAAM,GACVA,CAAClB,KAAa,GAAG,CAAC,KAClB,CAAC;EAAED,KAAK,GAAG;IAAEY,QAAQ,EAAE,CAAC;EAAE;AAAkB,CAAC,KAC3Cb,OAAO,CAACC,KAAK,EAAEC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC;AAACY,OAAA,CAAAM,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -8,20 +8,14 @@ var _objects = require("../../utils/helpers/objects");
|
|
|
8
8
|
var _exceptions = require("../../exceptions");
|
|
9
9
|
/**
|
|
10
10
|
*/
|
|
11
|
-
const getProp =
|
|
12
|
-
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
|
-
let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
14
|
-
let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
11
|
+
const getProp = (theme = {}, path = "", defaultValue = "") => {
|
|
15
12
|
return path === "" ? defaultValue : (0, _objects.get)(theme, path, defaultValue);
|
|
16
13
|
};
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
*/
|
|
20
17
|
exports.getProp = getProp;
|
|
21
|
-
const getThemeProp =
|
|
22
|
-
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
23
|
-
let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
24
|
-
let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
18
|
+
const getThemeProp = (theme = {}, path = "", defaultValue = "") => {
|
|
25
19
|
const value = getProp(theme, path, defaultValue);
|
|
26
20
|
if (value != null && (typeof value === "string" || typeof value === "number" || typeof value === "object")) {
|
|
27
21
|
return value;
|
|
@@ -32,10 +26,7 @@ const getThemeProp = function () {
|
|
|
32
26
|
/**
|
|
33
27
|
*/
|
|
34
28
|
exports.getThemeProp = getThemeProp;
|
|
35
|
-
const getThemeStringProp =
|
|
36
|
-
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
37
|
-
let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
38
|
-
let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
29
|
+
const getThemeStringProp = (theme = {}, path = "", defaultValue = "") => {
|
|
39
30
|
const value = getProp(theme, path, defaultValue);
|
|
40
31
|
if (typeof value === "string") {
|
|
41
32
|
return value;
|
|
@@ -48,10 +39,7 @@ const getThemeStringProp = function () {
|
|
|
48
39
|
/**
|
|
49
40
|
*/
|
|
50
41
|
exports.getThemeStringProp = getThemeStringProp;
|
|
51
|
-
const getThemeNumberProp =
|
|
52
|
-
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
53
|
-
let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
54
|
-
let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
42
|
+
const getThemeNumberProp = (theme = {}, path = "", defaultValue = 0) => {
|
|
55
43
|
const value = getProp(theme, path, defaultValue);
|
|
56
44
|
if (typeof value === "number") {
|
|
57
45
|
return value;
|
|
@@ -65,11 +53,8 @@ const getThemeNumberProp = function () {
|
|
|
65
53
|
/**
|
|
66
54
|
*/
|
|
67
55
|
exports.getThemeNumberProp = getThemeNumberProp;
|
|
68
|
-
const themeProp = (path, defaultValue) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} = _ref;
|
|
72
|
-
return getThemeProp(theme, path, defaultValue);
|
|
73
|
-
};
|
|
56
|
+
const themeProp = (path, defaultValue) => ({
|
|
57
|
+
theme
|
|
58
|
+
}) => getThemeProp(theme, path, defaultValue);
|
|
74
59
|
exports.themeProp = themeProp;
|
|
75
60
|
//# sourceMappingURL=themeProps.js.map
|