@beinformed/ui 1.65.13 → 1.65.14
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/hooks/useList.js.flow +4 -1
- package/esm/hooks/useList.js.map +1 -1
- package/lib/hooks/useList.js.map +1 -1
- package/package.json +1 -2
- package/src/builder/__tests__/LayoutHintConfig.json +0 -20
- package/src/builder/__tests__/mergeLayoutHintConfigurations.spec.js +0 -71
- package/src/builder/__tests__/subdir/LayoutHintConfig.json +0 -20
- package/src/builder/index.js +0 -2
- package/src/builder/mergeLayoutHintConfigurations.js +0 -62
- package/src/constants/Constants.js +0 -196
- package/src/constants/LayoutHintConfig.js +0 -186
- package/src/constants/LayoutHints.js +0 -134
- package/src/constants/Settings.js +0 -267
- package/src/constants/index.js +0 -4
- package/src/exceptions/ConfigurationException.js +0 -13
- package/src/exceptions/FetchException.js +0 -101
- package/src/exceptions/IllegalArgumentException.js +0 -12
- package/src/exceptions/IllegalReturnException.js +0 -11
- package/src/exceptions/IllegalStateException.js +0 -12
- package/src/exceptions/JsonParseException.js +0 -12
- package/src/exceptions/MissingPropertyException.js +0 -13
- package/src/exceptions/NetworkException.js +0 -20
- package/src/exceptions/NotAllowedUriException.js +0 -12
- package/src/exceptions/NotFoundException.js +0 -20
- package/src/exceptions/ServerRequestException.js +0 -12
- package/src/exceptions/ThemePropertyException.js +0 -12
- package/src/exceptions/TimeoutException.js +0 -13
- package/src/exceptions/UnauthorizedException.js +0 -26
- package/src/exceptions/UnsupportedOperationException.js +0 -12
- package/src/exceptions/index.js +0 -16
- package/src/hooks/__tests__/UseModularUIModel.spec.js +0 -194
- package/src/hooks/__tests__/useAuthentication.spec.js +0 -166
- package/src/hooks/__tests__/useForm.spec.js +0 -300
- package/src/hooks/__tests__/useI18n.spec.js +0 -30
- package/src/hooks/__tests__/useModal.spec.js +0 -67
- package/src/hooks/__tests__/useModelCatalog.spec.js +0 -180
- package/src/hooks/__tests__/useModels.spec.js +0 -138
- package/src/hooks/__tests__/useModularUIBasic.spec.js +0 -126
- package/src/hooks/__tests__/useNotification.spec.js +0 -47
- package/src/hooks/__tests__/usePreference.spec.js +0 -72
- package/src/hooks/__tests__/useProgressIndicator.spec.js +0 -67
- package/src/hooks/index.js +0 -21
- package/src/hooks/useAllFormsOnModel.js +0 -92
- package/src/hooks/useAuthentication.js +0 -113
- package/src/hooks/useContent.js +0 -48
- package/src/hooks/useDeepCompareEffect.js +0 -50
- package/src/hooks/useForm.js +0 -156
- package/src/hooks/useI18n.js +0 -46
- package/src/hooks/useList.js +0 -221
- package/src/hooks/useLookup.js +0 -82
- package/src/hooks/useModal.js +0 -46
- package/src/hooks/useModelCatalog.js +0 -256
- package/src/hooks/useModels.js +0 -50
- package/src/hooks/useModularUI.js +0 -79
- package/src/hooks/useModularUIBasic.js +0 -152
- package/src/hooks/useModularUIKey.js +0 -14
- package/src/hooks/useModularUIModel.js +0 -86
- package/src/hooks/useModularUIRequest.js +0 -25
- package/src/hooks/useNotification.js +0 -48
- package/src/hooks/usePanel.js +0 -79
- package/src/hooks/usePreference.js +0 -27
- package/src/hooks/useProgressIndicator.js +0 -50
- package/src/hooks/useRouter.js +0 -70
- package/src/hooks/useSearch.js +0 -31
- package/src/i18n/Locale.js +0 -157
- package/src/i18n/Locales.js +0 -171
- package/src/i18n/Message.js +0 -66
- package/src/i18n/__tests__/Locale.spec.js +0 -108
- package/src/i18n/__tests__/Locales.spec.js +0 -137
- package/src/i18n/index.js +0 -12
- package/src/i18n/languages.js +0 -207
- package/src/i18n/translations/beinformed_error_messages_en.nl.js +0 -98
- package/src/i18n/translations/beinformed_error_messages_nl.nl.js +0 -98
- package/src/i18n/types.js +0 -23
- package/src/i18n/withMessage.js +0 -47
- package/src/index.js +0 -7
- package/src/models/__tests__/resolveModel.spec.js +0 -34
- package/src/models/actions/ActionCollection.js +0 -100
- package/src/models/actions/ActionModel.js +0 -207
- package/src/models/actions/__mock__/action.js +0 -35
- package/src/models/actions/__tests__/ActionCollection.spec.js +0 -98
- package/src/models/actions/__tests__/ActionModel.spec.js +0 -75
- package/src/models/application/ApplicationModel.js +0 -168
- package/src/models/application/__mock__/application.js +0 -14
- package/src/models/application/__mock__/contributions.json +0 -312
- package/src/models/application/__mock__/data.json +0 -263
- package/src/models/application/__tests__/Application.spec.js +0 -99
- package/src/models/application/__tests__/webapp.json +0 -42
- package/src/models/application/__tests__/webappContributions.json +0 -43
- package/src/models/attributes/AttributeCollection.js +0 -306
- package/src/models/attributes/AttributeContent.js +0 -233
- package/src/models/attributes/AttributeDataHelper.js +0 -323
- package/src/models/attributes/AttributeModel.js +0 -1021
- package/src/models/attributes/AttributeSetModel.js +0 -117
- package/src/models/attributes/BooleanAttributeModel.js +0 -319
- package/src/models/attributes/CaptchaAttributeModel.js +0 -51
- package/src/models/attributes/ChoiceAttributeModel.js +0 -520
- package/src/models/attributes/ChoiceAttributeOptionCollection.js +0 -372
- package/src/models/attributes/ChoiceAttributeOptionModel.js +0 -415
- package/src/models/attributes/CompositeAttributeChildCollection.js +0 -254
- package/src/models/attributes/CompositeAttributeModel.js +0 -439
- package/src/models/attributes/DatetimeAttributeModel.js +0 -566
- package/src/models/attributes/HelptextAttributeModel.js +0 -54
- package/src/models/attributes/LabelAttributeModel.js +0 -36
- package/src/models/attributes/MemoAttributeModel.js +0 -43
- package/src/models/attributes/MoneyAttributeModel.js +0 -45
- package/src/models/attributes/NumberAttributeModel.js +0 -255
- package/src/models/attributes/PasswordAttributeModel.js +0 -245
- package/src/models/attributes/StringAttributeModel.js +0 -314
- package/src/models/attributes/UploadAttributeModel.js +0 -261
- package/src/models/attributes/XMLAttributeModel.js +0 -51
- package/src/models/attributes/__mock__/_ActionFieldsContributions.json +0 -12
- package/src/models/attributes/__mock__/_ActionFieldsData.json +0 -7
- package/src/models/attributes/__mock__/_FormCollectionContribution.json +0 -419
- package/src/models/attributes/__mock__/_FormCollectionData.json +0 -122
- package/src/models/attributes/__mock__/_InstrumentQuestionContributions.json +0 -178
- package/src/models/attributes/__mock__/_ListAttributeContributions.json +0 -82
- package/src/models/attributes/__mock__/_ListAttributeData.json +0 -70
- package/src/models/attributes/__mock__/_ListDetailContributions.json +0 -75
- package/src/models/attributes/__mock__/_ListDetailData.json +0 -38
- package/src/models/attributes/__mock__/_TreeFormAttributeContribution.json +0 -117
- package/src/models/attributes/__mock__/_TreeFormAttributeData.json +0 -27
- package/src/models/attributes/__mock__/form.contributions.json +0 -410
- package/src/models/attributes/__mock__/form.data.json +0 -113
- package/src/models/attributes/__mock__/form.js +0 -6
- package/src/models/attributes/__mock__/list.contributions.json +0 -110
- package/src/models/attributes/__mock__/list.data.json +0 -84
- package/src/models/attributes/__mock__/list.js +0 -6
- package/src/models/attributes/__tests__/AttributeCollection.spec.js +0 -160
- package/src/models/attributes/__tests__/AttributeCollectionComposite.spec.js +0 -146
- package/src/models/attributes/__tests__/AttributeContent.spec.js +0 -225
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +0 -634
- package/src/models/attributes/__tests__/AttributeModel.spec.js +0 -274
- package/src/models/attributes/__tests__/AttributeSetModel.spec.js +0 -39
- package/src/models/attributes/__tests__/BooleanAttributeModel.spec.js +0 -107
- package/src/models/attributes/__tests__/CaptchaAttributeModel.spec.js +0 -13
- package/src/models/attributes/__tests__/ChoiceAttributeModel.spec.js +0 -750
- package/src/models/attributes/__tests__/ChoiceAttributeOptionCollection.spec.js +0 -507
- package/src/models/attributes/__tests__/ChoiceAttributeOptionModel.spec.js +0 -107
- package/src/models/attributes/__tests__/CompositeAttributeModel.spec.js +0 -467
- package/src/models/attributes/__tests__/DateAttributeModel.spec.js +0 -134
- package/src/models/attributes/__tests__/DatetimeAttributeModel.spec.js +0 -206
- package/src/models/attributes/__tests__/DatetimeAttributeModel_offset.spec.js +0 -345
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +0 -64
- package/src/models/attributes/__tests__/LabelAttributeModel.spec.js +0 -13
- package/src/models/attributes/__tests__/LookupAttributeModel.spec.js +0 -47
- package/src/models/attributes/__tests__/MemoAttributeModel.spec.js +0 -28
- package/src/models/attributes/__tests__/MoneyAttributeModel.spec.js +0 -22
- package/src/models/attributes/__tests__/NumberAttributeModel.spec.js +0 -67
- package/src/models/attributes/__tests__/PasswordAttributeModel.spec.js +0 -49
- package/src/models/attributes/__tests__/StringAttributeModel.spec.js +0 -125
- package/src/models/attributes/__tests__/TimeAttributeModel.spec.js +0 -57
- package/src/models/attributes/__tests__/TimestampModel.spec.js +0 -43
- package/src/models/attributes/__tests__/UploadAttributeModel.spec.js +0 -67
- package/src/models/attributes/__tests__/XMLAttributeModel.spec.js +0 -17
- package/src/models/attributes/__tests__/_createAttribute.spec.js +0 -106
- package/src/models/attributes/__tests__/createAttributeComposite.spec.js +0 -151
- package/src/models/attributes/__tests__/createAttributeDynamicSchema.spec.js +0 -134
- package/src/models/attributes/_createAttribute.js +0 -147
- package/src/models/attributes/input-constraints/BSNConstraint.js +0 -80
- package/src/models/attributes/input-constraints/ConstraintCollection.js +0 -65
- package/src/models/attributes/input-constraints/ConstraintModel.js +0 -76
- package/src/models/attributes/input-constraints/DateBoundaryConstraint.js +0 -240
- package/src/models/attributes/input-constraints/DateTimeDateFormatConstraint.js +0 -72
- package/src/models/attributes/input-constraints/DateTimeTimeFormatConstraint.js +0 -72
- package/src/models/attributes/input-constraints/DatetimeFormatConstraint.js +0 -132
- package/src/models/attributes/input-constraints/FileExtensionConstraint.js +0 -60
- package/src/models/attributes/input-constraints/FileSizeConstraint.js +0 -101
- package/src/models/attributes/input-constraints/IBANConstraint.js +0 -46
- package/src/models/attributes/input-constraints/MandatoryConstraint.js +0 -54
- package/src/models/attributes/input-constraints/MandatoryRangeConstraint.js +0 -84
- package/src/models/attributes/input-constraints/NumberBoundaryConstraint.js +0 -213
- package/src/models/attributes/input-constraints/NumberFormatConstraint.js +0 -153
- package/src/models/attributes/input-constraints/NumberGroupingConstraint.js +0 -140
- package/src/models/attributes/input-constraints/PasswordConfirmConstraint.js +0 -68
- package/src/models/attributes/input-constraints/PasswordLowerAndUpperCaseConstraint.js +0 -44
- package/src/models/attributes/input-constraints/PasswordMinNumericCharactersConstraint.js +0 -60
- package/src/models/attributes/input-constraints/PasswordMinSpecialCharactersConstraint.js +0 -60
- package/src/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.js +0 -72
- package/src/models/attributes/input-constraints/RangeConstraint.js +0 -161
- package/src/models/attributes/input-constraints/RegexConstraint.js +0 -72
- package/src/models/attributes/input-constraints/StringLengthConstraint.js +0 -179
- package/src/models/attributes/input-constraints/XMLConstraint.js +0 -62
- package/src/models/attributes/input-constraints/__tests__/BSNConstraint.spec.js +0 -25
- package/src/models/attributes/input-constraints/__tests__/ConstraintCollection.spec.js +0 -9
- package/src/models/attributes/input-constraints/__tests__/ConstraintModel.spec.js +0 -35
- package/src/models/attributes/input-constraints/__tests__/DateBoundaryConstraint.spec.js +0 -117
- package/src/models/attributes/input-constraints/__tests__/DateTimeDateFormatConstraint.spec.js +0 -30
- package/src/models/attributes/input-constraints/__tests__/DateTimeTimeFormatConstraint.spec.js +0 -54
- package/src/models/attributes/input-constraints/__tests__/DatetimeFormatConstraint.spec.js +0 -79
- package/src/models/attributes/input-constraints/__tests__/FileExtensionConstraint.spec.js +0 -20
- package/src/models/attributes/input-constraints/__tests__/FileSizeConstraint.spec.js +0 -53
- package/src/models/attributes/input-constraints/__tests__/IBANConstraint.spec.js +0 -12
- package/src/models/attributes/input-constraints/__tests__/MandatoryConstraint.spec.js +0 -14
- package/src/models/attributes/input-constraints/__tests__/NumberBoundaryConstraint.spec.js +0 -46
- package/src/models/attributes/input-constraints/__tests__/NumberFormatConstraint.spec.js +0 -137
- package/src/models/attributes/input-constraints/__tests__/NumberGroupingConstraint.spec.js +0 -85
- package/src/models/attributes/input-constraints/__tests__/PasswordConfirmConstraint.spec.js +0 -21
- package/src/models/attributes/input-constraints/__tests__/PasswordLowerAndUpperCaseConstraint.spec.js +0 -14
- package/src/models/attributes/input-constraints/__tests__/PasswordMinNumericCharactersConstraint.spec.js +0 -11
- package/src/models/attributes/input-constraints/__tests__/PasswordMinSpecialCharactersConstraint.spec.js +0 -11
- package/src/models/attributes/input-constraints/__tests__/PasswordThreeConsecutiveCharactersNotAllowedConstraint.spec.js +0 -22
- package/src/models/attributes/input-constraints/__tests__/RegexConstraint.spec.js +0 -42
- package/src/models/attributes/input-constraints/__tests__/StringLengthConstraint.spec.js +0 -102
- package/src/models/attributes/input-constraints/__tests__/XMLConstraint.spec.js +0 -15
- package/src/models/attributes/layouthint-rules/BaseLayoutHintRule.js +0 -74
- package/src/models/attributes/layouthint-rules/DependentAttribute.js +0 -246
- package/src/models/attributes/layouthint-rules/LayoutHintRuleCollection.js +0 -101
- package/src/models/attributes/layouthint-rules/RemainingTotalUploadSize.js +0 -67
- package/src/models/attributes/layouthint-rules/__mock__/MockedCollectionFactory.js +0 -54
- package/src/models/attributes/layouthint-rules/__tests__/BaseLayoutHintRule.spec.js +0 -29
- package/src/models/attributes/layouthint-rules/__tests__/DependentAttribute.spec.js +0 -310
- package/src/models/attributes/layouthint-rules/__tests__/LayoutHintRuleCollection.spec.js +0 -58
- package/src/models/attributes/layouthint-rules/__tests__/RemainingTotalUploadSize.spec.js +0 -24
- package/src/models/base/BaseCollection.js +0 -191
- package/src/models/base/BaseModel.js +0 -155
- package/src/models/base/ResourceCollection.js +0 -42
- package/src/models/base/ResourceModel.js +0 -246
- package/src/models/base/__tests__/BaseCollection.spec.js +0 -108
- package/src/models/base/__tests__/BaseModel.spec.js +0 -85
- package/src/models/base/__tests__/ResourceCollection.spec.js +0 -51
- package/src/models/base/__tests__/ResourceModel.spec.js +0 -100
- package/src/models/base/__tests__/webapp.json +0 -52
- package/src/models/caseview/CaseViewModel.js +0 -188
- package/src/models/caseview/__mock__/caseview.js +0 -14
- package/src/models/caseview/__mock__/contributions.json +0 -146
- package/src/models/caseview/__mock__/data.json +0 -21
- package/src/models/caseview/__tests__/CaseViewModel.spec.js +0 -132
- package/src/models/caseview/__tests__/caseview.json +0 -49
- package/src/models/caseview/__tests__/caseviewContributions.json +0 -118
- package/src/models/caseview/__tests__/caseview_local_taskgroup.json +0 -57
- package/src/models/concepts/BusinessScenarioModel.js +0 -176
- package/src/models/concepts/ConceptDetailModel.js +0 -349
- package/src/models/concepts/ConceptIndexModel.js +0 -186
- package/src/models/concepts/ConceptLinkModel.js +0 -208
- package/src/models/concepts/ConceptRelationCollection.js +0 -95
- package/src/models/concepts/ConceptRelationModel.js +0 -129
- package/src/models/concepts/ConceptTypeDetailModel.js +0 -128
- package/src/models/concepts/SourceReferenceCollection.js +0 -40
- package/src/models/concepts/SourceReferenceModel.js +0 -126
- package/src/models/concepts/__mock__/business_scenario.js +0 -26
- package/src/models/concepts/__mock__/business_scenario_data.json +0 -234
- package/src/models/concepts/__mock__/business_scenario_step.json +0 -64
- package/src/models/concepts/__mock__/conceptdetail.js +0 -27
- package/src/models/concepts/__mock__/conceptdetail_contributions.json +0 -156
- package/src/models/concepts/__mock__/conceptdetail_data.json +0 -164
- package/src/models/concepts/__mock__/conceptindex.js +0 -15
- package/src/models/concepts/__mock__/conceptindex_contributions.json +0 -86
- package/src/models/concepts/__mock__/conceptindex_data.json +0 -329
- package/src/models/concepts/__mock__/concepttype.js +0 -13
- package/src/models/concepts/__mock__/concepttype_Calculation.json +0 -75
- package/src/models/concepts/__mock__/concepttype_contributions.json +0 -139
- package/src/models/concepts/__mock__/concepttype_data.json +0 -32
- package/src/models/concepts/__mock__/concepttype_hierarchy.js +0 -13
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +0 -32
- package/src/models/concepts/__mock__/related_concepts.js +0 -12
- package/src/models/concepts/__mock__/related_concepts_contributions.json +0 -41
- package/src/models/concepts/__mock__/related_concepts_data.json +0 -2408
- package/src/models/concepts/__mock__/relation_with_props_and_tf_data.js +0 -27
- package/src/models/concepts/__mock__/relation_with_props_and_tf_data.json +0 -67
- package/src/models/concepts/__tests__/BusinessScenarioModel.spec.js +0 -28
- package/src/models/concepts/__tests__/ConceptDetailModel.spec.js +0 -65
- package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +0 -42
- package/src/models/concepts/__tests__/ConceptLinkModel.spec.js +0 -9
- package/src/models/concepts/__tests__/ConceptRelationCollection.spec.js +0 -9
- package/src/models/concepts/__tests__/ConceptRelationModel.spec.js +0 -53
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +0 -31
- package/src/models/concepts/__tests__/RelatedConcepts.spec.js +0 -58
- package/src/models/concepts/__tests__/SourceReferenceCollection.spec.js +0 -9
- package/src/models/concepts/__tests__/SourceReferenceModel.spec.js +0 -108
- package/src/models/content/ContentIndexModel.js +0 -165
- package/src/models/content/ContentLinkModel.js +0 -308
- package/src/models/content/ContentModel.js +0 -227
- package/src/models/content/ContentTOCModel.js +0 -237
- package/src/models/content/ContentTypeModel.js +0 -71
- package/src/models/content/SectionModel.js +0 -236
- package/src/models/content/SubSectionModel.js +0 -181
- package/src/models/content/__tests__/ContentIndexModel.spec.js +0 -40
- package/src/models/content/__tests__/ContentLinkModel.spec.js +0 -129
- package/src/models/content/__tests__/ContentModel.spec.js +0 -241
- package/src/models/content/__tests__/Formalsource.spec.js +0 -133
- package/src/models/content/__tests__/content-index-contributions.json +0 -50
- package/src/models/content/__tests__/content-index.json +0 -164
- package/src/models/content/__tests__/content-with-childsections.json +0 -105
- package/src/models/content/__tests__/content-with-sections.json +0 -105
- package/src/models/content/__tests__/content-with-subsections.json +0 -119
- package/src/models/content/__tests__/content-with-subsections2.json +0 -79
- package/src/models/content/__tests__/content.json +0 -31
- package/src/models/content/__tests__/contributions.json +0 -84
- package/src/models/content/__tests__/formalsource-complete.json +0 -235
- package/src/models/content/__tests__/formalsource-contributions.json +0 -110
- package/src/models/content/__tests__/formalsource-section-contributions.json +0 -84
- package/src/models/content/__tests__/formalsource-section.json +0 -60
- package/src/models/content/__tests__/formalsource-toc.json +0 -122
- package/src/models/contentconfiguration/ContentConfiguration.js +0 -70
- package/src/models/contentconfiguration/ContentConfigurationElements.js +0 -152
- package/src/models/contentconfiguration/ContentConfigurationEndResults.js +0 -45
- package/src/models/contentconfiguration/ContentConfigurationQuestions.js +0 -60
- package/src/models/contentconfiguration/ContentConfigurationResults.js +0 -105
- package/src/models/contentconfiguration/__tests__/ContentConfigurationElements.spec.js +0 -29
- package/src/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js +0 -101
- package/src/models/detail/DetailModel.js +0 -241
- package/src/models/detail/__tests__/DetailModel.spec.js +0 -41
- package/src/models/detail/__tests__/detail.json +0 -37
- package/src/models/detail/__tests__/detailContributions.json +0 -124
- package/src/models/error/ErrorCollection.js +0 -127
- package/src/models/error/ErrorModel.js +0 -83
- package/src/models/error/ErrorResponse.js +0 -343
- package/src/models/error/__tests__/ErrorCollection.spec.js +0 -41
- package/src/models/error/__tests__/ErrorModel.spec.js +0 -24
- package/src/models/filters/AssignmentFilterModel.js +0 -218
- package/src/models/filters/BaseFilterModel.js +0 -146
- package/src/models/filters/ConceptIndexFilterModel.js +0 -43
- package/src/models/filters/FilterCollection.js +0 -227
- package/src/models/filters/FilterModel.js +0 -151
- package/src/models/filters/RangeFilterModel.js +0 -36
- package/src/models/filters/StringFilterModel.js +0 -167
- package/src/models/filters/__tests__/AssignmentFilterModel.spec.js +0 -140
- package/src/models/filters/__tests__/FilterCollection.spec.js +0 -68
- package/src/models/filters/__tests__/FilterModel.spec.js +0 -65
- package/src/models/filters/__tests__/RangeFilterModel.spec.js +0 -55
- package/src/models/filters/__tests__/ZipcodeFilter.spec.js +0 -145
- package/src/models/filters/__tests__/filters.json +0 -91
- package/src/models/filters/__tests__/filtersContributions.json +0 -110
- package/src/models/form/FormModel.js +0 -1280
- package/src/models/form/FormObjectModel.js +0 -590
- package/src/models/form/__mock__/contributions.json +0 -525
- package/src/models/form/__mock__/data.json +0 -78
- package/src/models/form/__mock__/form.js +0 -17
- package/src/models/form/__tests__/FormContributions.json +0 -495
- package/src/models/form/__tests__/FormContributionsUnknownRepeat.json +0 -67
- package/src/models/form/__tests__/FormInstrumentContributions.json +0 -183
- package/src/models/form/__tests__/FormModel.getters.spec.js +0 -149
- package/src/models/form/__tests__/FormModel.instrument.spec.js +0 -202
- package/src/models/form/__tests__/FormModel.repeating.spec.js +0 -65
- package/src/models/form/__tests__/FormModel.selfhref.spec.js +0 -84
- package/src/models/form/__tests__/FormModel.spec.js +0 -752
- package/src/models/form/__tests__/FormModel.unknown-repeat.spec.js +0 -52
- package/src/models/form/__tests__/FormObjectModel.spec.js +0 -180
- package/src/models/form/__tests__/FormResultData.spec.js +0 -86
- package/src/models/form/__tests__/FormValidation.spec.js +0 -79
- package/src/models/form/__tests__/FormValidationContributions.json +0 -45
- package/src/models/form/__tests__/FormValidationDataInitial.json +0 -33
- package/src/models/form/__tests__/FormValidationDataUpdate1.json +0 -25
- package/src/models/form/__tests__/FormValidationDataUpdate2.json +0 -33
- package/src/models/form/__tests__/FormWithContent.spec.js +0 -71
- package/src/models/form/__tests__/FormWithContentContributions.json +0 -242
- package/src/models/form/__tests__/FormWithContentData.json +0 -244
- package/src/models/grouping/GroupingModel.js +0 -232
- package/src/models/grouping/__tests__/GroupingModel.spec.js +0 -80
- package/src/models/href/Href.js +0 -592
- package/src/models/href/ListHref.js +0 -161
- package/src/models/href/__tests__/Href.spec.js +0 -184
- package/src/models/href/__tests__/ListHref.spec.js +0 -61
- package/src/models/href/__tests__/list.json +0 -2417
- package/src/models/href/__tests__/listContributions.json +0 -330
- package/src/models/index.js +0 -177
- package/src/models/layouthint/LayoutHintCollection.js +0 -116
- package/src/models/layouthint/__tests__/LayoutHintCollection.spec.js +0 -89
- package/src/models/links/LinkCollection.js +0 -169
- package/src/models/links/LinkModel.js +0 -246
- package/src/models/links/__tests__/LinkCollection.spec.js +0 -426
- package/src/models/links/__tests__/LinkModel.spec.js +0 -103
- package/src/models/links/__tests__/normalizeLinkJSON.spec.js +0 -212
- package/src/models/links/normalizeLinkJSON.js +0 -121
- package/src/models/list/ListDetailModel.js +0 -332
- package/src/models/list/ListHeaderModel.js +0 -96
- package/src/models/list/ListItemCollection.js +0 -80
- package/src/models/list/ListItemModel.js +0 -111
- package/src/models/list/ListModel.js +0 -485
- package/src/models/list/__mock__/caselist.contributions.json +0 -372
- package/src/models/list/__mock__/caselist.data.json +0 -519
- package/src/models/list/__mock__/caselist.js +0 -14
- package/src/models/list/__tests__/ListDetailModel.hierarchy.spec.js +0 -88
- package/src/models/list/__tests__/ListDetailModel.spec.js +0 -96
- package/src/models/list/__tests__/ListItemCollection.spec.js +0 -22
- package/src/models/list/__tests__/ListModel.spec.js +0 -152
- package/src/models/list/__tests__/ListResultDetail.spec.js +0 -37
- package/src/models/list/__tests__/caselist-34.contributions.json +0 -146
- package/src/models/list/__tests__/caselist-34.data.json +0 -21
- package/src/models/list/__tests__/hierarchy.json +0 -185
- package/src/models/list/__tests__/hierarchyContributions.json +0 -582
- package/src/models/list/__tests__/instrument-detail-contributions.json +0 -761
- package/src/models/list/__tests__/instrument-detail-data.json +0 -66
- package/src/models/list/__tests__/list.json +0 -2426
- package/src/models/list/__tests__/listContributions.json +0 -349
- package/src/models/list/__tests__/related-contributions.json +0 -42
- package/src/models/list/__tests__/related-data.json +0 -32
- package/src/models/lookup/LookupOptionCollection.js +0 -54
- package/src/models/lookup/LookupOptionsModel.js +0 -81
- package/src/models/lookup/__tests__/LookupOptionCollection.spec.js +0 -80
- package/src/models/lookup/__tests__/LookupOptionsModel.spec.js +0 -82
- package/src/models/lookup/__tests__/_LookupOptionsContributions.json +0 -29
- package/src/models/lookup/__tests__/_LookupOptionsData.json +0 -34
- package/src/models/lookup/__tests__/_LookupOptionsListContributions.json +0 -129
- package/src/models/lookup/__tests__/_LookupOptionsListData.json +0 -134
- package/src/models/lookup/__tests__/_TaxonomyAttributeData.json +0 -42
- package/src/models/modelcatalog/ModelCatalogModel.js +0 -73
- package/src/models/modelcatalog/ModelCategoryCollection.js +0 -22
- package/src/models/modelcatalog/ModelCategoryModel.js +0 -63
- package/src/models/modelcatalog/__mock__/contributions.json +0 -6
- package/src/models/modelcatalog/__mock__/data.json +0 -29
- package/src/models/modelcatalog/__mock__/modelcatalog.js +0 -14
- package/src/models/modelcatalog/__tests__/ModelCatalogModel.spec.js +0 -49
- package/src/models/paging/PagesizeModel.js +0 -50
- package/src/models/paging/PagingModel.js +0 -105
- package/src/models/paging/__tests__/PageSizeModel.spec.js +0 -31
- package/src/models/paging/__tests__/PagingModel.spec.js +0 -40
- package/src/models/paging/__tests__/list.json +0 -8
- package/src/models/paging/__tests__/listContributions.json +0 -7
- package/src/models/panels/GroupingPanelModel.js +0 -164
- package/src/models/panels/__tests__/GroupingPanelModel.spec.js +0 -142
- package/src/models/panels/__tests__/groupingPanel.json +0 -49
- package/src/models/panels/__tests__/groupingPanelContributions.json +0 -59
- package/src/models/parameter/Parameter.js +0 -117
- package/src/models/parameter/__tests__/Parameter.spec.js +0 -125
- package/src/models/process/ProcessStatusSettingsModel.js +0 -88
- package/src/models/process/__tests__/ProcessStatusSettingsModel.spec.js +0 -52
- package/src/models/resolveModel.js +0 -92
- package/src/models/search/CaseSearchModel.js +0 -46
- package/src/models/search/__tests__/CaseSearchModel.spec.js +0 -10
- package/src/models/sorting/SortOptionModel.js +0 -114
- package/src/models/sorting/SortingModel.js +0 -140
- package/src/models/sorting/__tests__/SortingModel.spec.js +0 -96
- package/src/models/tab/TabModel.js +0 -160
- package/src/models/tab/__mock__/contributions.json +0 -77
- package/src/models/tab/__mock__/data.json +0 -20
- package/src/models/tab/__mock__/personContributions.json +0 -35
- package/src/models/tab/__mock__/personData.json +0 -21
- package/src/models/tab/__mock__/tab.js +0 -14
- package/src/models/tab/__mock__/tabPerson.js +0 -14
- package/src/models/tab/__tests__/TabModel.spec.js +0 -72
- package/src/models/tab/__tests__/tab.json +0 -37
- package/src/models/tab/__tests__/tabContributions.json +0 -39
- package/src/models/taskgroup/TaskGroupCollection.js +0 -16
- package/src/models/taskgroup/TaskGroupModel.js +0 -102
- package/src/models/taskgroup/__mock__/contributions.json +0 -18
- package/src/models/taskgroup/__mock__/data.json +0 -21
- package/src/models/taskgroup/__mock__/taskgroup.js +0 -14
- package/src/models/taskgroup/__tests__/TaskGroupModel.spec.js +0 -26
- package/src/models/taskgroup/__tests__/taskgroup.json +0 -25
- package/src/models/taskgroup/__tests__/taskgroupContributions.json +0 -23
- package/src/models/types.js +0 -291
- package/src/models/user/UserModel.js +0 -57
- package/src/models/user/UserProfileModel.js +0 -54
- package/src/models/user/UserServicesModel.js +0 -136
- package/src/models/user/__mock__/contributions.json +0 -148
- package/src/models/user/__mock__/data.json +0 -22
- package/src/models/user/__tests__/UserModel.spec.js +0 -43
- package/src/models/user/__tests__/UserProfileModel.spec.js +0 -45
- package/src/models/user/__tests__/UserServicesModel.spec.js +0 -55
- package/src/modularui/Authenticate.js +0 -217
- package/src/modularui/CaptchaRequest.js +0 -104
- package/src/modularui/ModularUIError.js +0 -25
- package/src/modularui/ModularUIRequest.js +0 -872
- package/src/modularui/ModularUIResponse.js +0 -160
- package/src/modularui/UploadRequest.js +0 -151
- package/src/modularui/__tests__/CustomContextPath.spec.js +0 -61
- package/src/modularui/__tests__/ModularUIError.spec.js +0 -22
- package/src/modularui/__tests__/ModularUIRequest.spec.js +0 -495
- package/src/modularui/__tests__/contributions.json +0 -312
- package/src/modularui/__tests__/data.json +0 -263
- package/src/modularui/index.js +0 -6
- package/src/modularui/types.js +0 -4
- package/src/react/ErrorBoundary.js +0 -61
- package/src/react/ErrorBoundaryFallback.js +0 -46
- package/src/react/index.js +0 -3
- package/src/react/utils.js +0 -33
- package/src/react-client/Init.js +0 -46
- package/src/react-client/client.js +0 -309
- package/src/react-client/contextPath.js +0 -30
- package/src/react-client/index.js +0 -4
- package/src/react-client/rehydrate.js +0 -94
- package/src/react-server/__tests__/htmlpage.spec.js +0 -75
- package/src/react-server/__tests__/requestInformation.spec.js +0 -266
- package/src/react-server/__tests__/serverUtil.spec.js +0 -183
- package/src/react-server/contextPath.js +0 -8
- package/src/react-server/createSSRComplete.js +0 -63
- package/src/react-server/htmlpage.js +0 -55
- package/src/react-server/index.js +0 -13
- package/src/react-server/renderSSRComplete.js +0 -111
- package/src/react-server/renderSSRMinimal.js +0 -54
- package/src/react-server/requestInformation.js +0 -68
- package/src/react-server/serverNoSSR.js +0 -87
- package/src/react-server/serverSSR.js +0 -70
- package/src/react-server/serverUtil.js +0 -279
- package/src/react-theme/ThemeProvider.js +0 -25
- package/src/react-theme/__tests__/ThemeProvider.spec.js +0 -84
- package/src/react-theme/__tests__/createTheme.spec.js +0 -172
- package/src/react-theme/createTheme.js +0 -118
- package/src/react-theme/index.js +0 -15
- package/src/react-theme/types.js +0 -16
- package/src/react-theme/useTheme.js +0 -13
- package/src/react-theme/utils/__tests__/background.spec.js +0 -30
- package/src/react-theme/utils/__tests__/colors.spec.js +0 -30
- package/src/react-theme/utils/__tests__/contrast.spec.js +0 -44
- package/src/react-theme/utils/__tests__/corners.spec.js +0 -27
- package/src/react-theme/utils/__tests__/spacers.spec.js +0 -44
- package/src/react-theme/utils/__tests__/themeProps.spec.js +0 -72
- package/src/react-theme/utils/background.js +0 -20
- package/src/react-theme/utils/colors.js +0 -47
- package/src/react-theme/utils/contrast.js +0 -117
- package/src/react-theme/utils/corners.js +0 -37
- package/src/react-theme/utils/spacers.js +0 -65
- package/src/react-theme/utils/themeProps.js +0 -90
- package/src/redux/_i18n/I18nActions.js +0 -38
- package/src/redux/_i18n/I18nReducer.js +0 -91
- package/src/redux/_i18n/__tests__/actions.spec.js +0 -37
- package/src/redux/_i18n/__tests__/reducer.spec.js +0 -29
- package/src/redux/_i18n/index.js +0 -6
- package/src/redux/_i18n/types.js +0 -20
- package/src/redux/_modularui/ModularUIActions.js +0 -227
- package/src/redux/_modularui/ModularUIConnector.js +0 -157
- package/src/redux/_modularui/ModularUIMiddleware.js +0 -182
- package/src/redux/_modularui/ModularUIReducer.js +0 -169
- package/src/redux/_modularui/ModularUISelectors.js +0 -322
- package/src/redux/_modularui/ModularUIUtils.js +0 -96
- package/src/redux/_modularui/__tests__/actions.spec.js +0 -159
- package/src/redux/_modularui/__tests__/reducer.spec.js +0 -134
- package/src/redux/_modularui/__tests__/selectors.spec.js +0 -153
- package/src/redux/_modularui/index.js +0 -11
- package/src/redux/_modularui/types.js +0 -121
- package/src/redux/_modularui/withModularUI.js +0 -85
- package/src/redux/_router/RouterActions.js +0 -75
- package/src/redux/_router/RouterConnectors.js +0 -97
- package/src/redux/_router/RouterMiddleware.js +0 -37
- package/src/redux/_router/RouterReducer.js +0 -21
- package/src/redux/_router/__tests__/actions.spec.js +0 -109
- package/src/redux/_router/__tests__/hooks.spec.js +0 -98
- package/src/redux/_router/__tests__/middleware.spec.js +0 -62
- package/src/redux/_router/__tests__/reducer.spec.js +0 -26
- package/src/redux/_router/index.js +0 -8
- package/src/redux/_router/types.js +0 -43
- package/src/redux/actions/Application.js +0 -45
- package/src/redux/actions/Authorization.js +0 -65
- package/src/redux/actions/Error.js +0 -95
- package/src/redux/actions/Form.js +0 -42
- package/src/redux/actions/FormAttributeSet.js +0 -98
- package/src/redux/actions/FormAttributeSetRepeatable.js +0 -45
- package/src/redux/actions/FormAutosave.js +0 -73
- package/src/redux/actions/FormAutosubmit.js +0 -43
- package/src/redux/actions/FormAutoupdate.js +0 -47
- package/src/redux/actions/FormValidations.js +0 -71
- package/src/redux/actions/Modals.js +0 -16
- package/src/redux/actions/ModelCatalog.js +0 -12
- package/src/redux/actions/Notification.js +0 -101
- package/src/redux/actions/Preferences.js +0 -173
- package/src/redux/actions/ProgressIndicator.js +0 -39
- package/src/redux/actions/SignIn.js +0 -102
- package/src/redux/actions/SignOut.js +0 -29
- package/src/redux/actions/__tests__/Application.spec.js +0 -52
- package/src/redux/actions/__tests__/Authorization.spec.js +0 -121
- package/src/redux/actions/__tests__/CustomErrorResponseHandler.spec.js +0 -72
- package/src/redux/actions/__tests__/Error-server.spec.js +0 -134
- package/src/redux/actions/__tests__/Error.spec.js +0 -116
- package/src/redux/actions/__tests__/Form.spec.js +0 -39
- package/src/redux/actions/__tests__/Modals.spec.js +0 -34
- package/src/redux/actions/__tests__/Notification.spec.js +0 -94
- package/src/redux/actions/__tests__/Preferences.spec.js +0 -71
- package/src/redux/actions/__tests__/ProgressIndicator.spec.js +0 -53
- package/src/redux/actions/index.js +0 -17
- package/src/redux/connectors/Application.js +0 -14
- package/src/redux/connectors/Breadcrumb.js +0 -28
- package/src/redux/connectors/CaseView.js +0 -14
- package/src/redux/connectors/ConceptDetail.js +0 -12
- package/src/redux/connectors/ContentBrowser.js +0 -14
- package/src/redux/connectors/ContentDetail.js +0 -13
- package/src/redux/connectors/ContentDetailSection.js +0 -17
- package/src/redux/connectors/Form.js +0 -83
- package/src/redux/connectors/FormAttributeSet.js +0 -85
- package/src/redux/connectors/ListDetail.js +0 -16
- package/src/redux/connectors/Modal.js +0 -47
- package/src/redux/connectors/ModelCatalog.js +0 -14
- package/src/redux/connectors/Notification.js +0 -47
- package/src/redux/connectors/PanelRenderer.js +0 -29
- package/src/redux/connectors/Preferences.js +0 -53
- package/src/redux/connectors/Progress.js +0 -35
- package/src/redux/connectors/ProgressIndicator.js +0 -35
- package/src/redux/connectors/QuickSearch.js +0 -36
- package/src/redux/connectors/SignIn.js +0 -47
- package/src/redux/connectors/SignOut.js +0 -38
- package/src/redux/connectors/Tab.js +0 -14
- package/src/redux/connectors/index.js +0 -22
- package/src/redux/index.js +0 -27
- package/src/redux/reducers/AuthReducer.js +0 -56
- package/src/redux/reducers/ErrorReducer.js +0 -22
- package/src/redux/reducers/ModalsReducer.js +0 -58
- package/src/redux/reducers/ModelCatalogReducer.js +0 -34
- package/src/redux/reducers/NotificationReducer.js +0 -45
- package/src/redux/reducers/PreferencesReducer.js +0 -31
- package/src/redux/reducers/ProgressIndicatorReducer.js +0 -60
- package/src/redux/reducers/__tests__/AuthReducer.spec.js +0 -95
- package/src/redux/reducers/__tests__/ErrorReducer.spec.js +0 -17
- package/src/redux/reducers/__tests__/ModalsReducer.spec.js +0 -34
- package/src/redux/reducers/__tests__/ModelCatalogReducer.spec.js +0 -23
- package/src/redux/reducers/__tests__/NotificationReducer.spec.js +0 -53
- package/src/redux/reducers/__tests__/PreferencesReducer.spec.js +0 -31
- package/src/redux/reducers/__tests__/ProgressIndicatorReducer.spec.js +0 -82
- package/src/redux/reducers/createReducer.js +0 -55
- package/src/redux/reducers/index.js +0 -10
- package/src/redux/selectors/i18n.js +0 -15
- package/src/redux/selectors/index.js +0 -3
- package/src/redux/selectors/modelcatalog.js +0 -11
- package/src/redux/store/__tests__/beforeRenderHooks.spec.js +0 -13
- package/src/redux/store/beforeRenderHooks.js +0 -26
- package/src/redux/store/configureStore.js +0 -59
- package/src/redux/types.js +0 -241
- package/src/utils/browser/Cache.js +0 -157
- package/src/utils/browser/Cookies.js +0 -44
- package/src/utils/browser/__tests__/Cookies.spec.js +0 -51
- package/src/utils/datetime/DateTimeUtil.js +0 -858
- package/src/utils/datetime/__tests__/DateTime.spec.js +0 -873
- package/src/utils/datetime/__tests__/DateTimeFormat.spec.js +0 -146
- package/src/utils/fetch/__mocks__/applicationContributions.json +0 -323
- package/src/utils/fetch/__mocks__/applicationData.json +0 -216
- package/src/utils/fetch/__mocks__/formContributions.json +0 -527
- package/src/utils/fetch/__mocks__/formData.json +0 -21
- package/src/utils/fetch/__mocks__/universalFetch.js +0 -38
- package/src/utils/fetch/__tests__/xhr.spec.js +0 -281
- package/src/utils/fetch/serverFetch.js +0 -33
- package/src/utils/fetch/types.js +0 -46
- package/src/utils/fetch/universalFetch.js +0 -106
- package/src/utils/fetch/xhr.js +0 -409
- package/src/utils/helpers/__tests__/checkResource.spec.js +0 -60
- package/src/utils/helpers/__tests__/createHash.spec.js +0 -11
- package/src/utils/helpers/__tests__/createHref.spec.js +0 -39
- package/src/utils/helpers/__tests__/objects.spec.js +0 -50
- package/src/utils/helpers/__tests__/sanitizeHTML.spec.js +0 -69
- package/src/utils/helpers/checkResource.js +0 -43
- package/src/utils/helpers/createHash.js +0 -28
- package/src/utils/helpers/createHref.js +0 -117
- package/src/utils/helpers/createUUID.js +0 -13
- package/src/utils/helpers/index.js +0 -9
- package/src/utils/helpers/objects.js +0 -33
- package/src/utils/helpers/repositoryResource.js +0 -22
- package/src/utils/helpers/sanitizeHtml.js +0 -55
- package/src/utils/helpers/text.js +0 -23
- package/src/utils/index.js +0 -22
- package/src/utils/number/DecimalFormat.js +0 -410
- package/src/utils/number/__tests__/formatValue.spec.js +0 -36
- package/src/utils/number/__tests__/parseNumbers.spec.js +0 -50
- package/src/utils/number/formatValue.js +0 -60
- package/src/utils/number/parseNumbers.js +0 -94
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import configureMockStore from "redux-mock-store";
|
|
2
|
-
import thunk from "redux-thunk";
|
|
3
|
-
import { Provider } from "react-redux";
|
|
4
|
-
import { renderHook } from "@testing-library/react";
|
|
5
|
-
import xhrMock from "xhr-mock";
|
|
6
|
-
|
|
7
|
-
import { useModularUIBasic } from "../useModularUIBasic";
|
|
8
|
-
import { ApplicationModel, Href } from "../../models";
|
|
9
|
-
import { useLocation } from "react-router";
|
|
10
|
-
|
|
11
|
-
const middlewares = [thunk];
|
|
12
|
-
const mockStore = configureMockStore(middlewares);
|
|
13
|
-
|
|
14
|
-
jest.mock("react-router", () => ({
|
|
15
|
-
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
16
|
-
useLocation: jest.fn(), // Mock useLocation
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const JSON_TYPE = "application/json";
|
|
20
|
-
|
|
21
|
-
describe("modularui hooks", () => {
|
|
22
|
-
// replace the real XHR object with the mock XHR object before each test
|
|
23
|
-
// eslint-disable-next-line jest/no-hooks
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
useLocation.mockReturnValue({
|
|
26
|
-
state: null,
|
|
27
|
-
});
|
|
28
|
-
xhrMock.setup();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// put the real XHR object back and clear the mocks after each test
|
|
32
|
-
// eslint-disable-next-line jest/no-hooks
|
|
33
|
-
afterEach(() => xhrMock.teardown());
|
|
34
|
-
|
|
35
|
-
it("useModularUIBasic", () => {
|
|
36
|
-
expect.assertions(2);
|
|
37
|
-
|
|
38
|
-
xhrMock.get("/BeInformed/", (req, res) => {
|
|
39
|
-
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
40
|
-
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
41
|
-
return res.status(200).body({ data: "ok" });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const store = mockStore({
|
|
45
|
-
modularui: {},
|
|
46
|
-
router: { location: {} },
|
|
47
|
-
i18n: { locale: "en" },
|
|
48
|
-
});
|
|
49
|
-
/**
|
|
50
|
-
*/
|
|
51
|
-
const wrapper = ({ children }) => (
|
|
52
|
-
<Provider store={store}>{children}</Provider>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const { result } = renderHook(
|
|
56
|
-
() =>
|
|
57
|
-
useModularUIBasic("app", "/", {
|
|
58
|
-
expectedModels: ["Application"],
|
|
59
|
-
targetModel: ApplicationModel,
|
|
60
|
-
}),
|
|
61
|
-
{
|
|
62
|
-
wrapper,
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
expect(result.current).toBeNull();
|
|
67
|
-
|
|
68
|
-
expect(store.getActions()).toStrictEqual([
|
|
69
|
-
{ type: "START_PROGRESS" },
|
|
70
|
-
{
|
|
71
|
-
type: "MODULARUI/FETCH",
|
|
72
|
-
payload: expect.objectContaining({
|
|
73
|
-
href: new Href("/"),
|
|
74
|
-
locale: "en",
|
|
75
|
-
targetModel: ApplicationModel,
|
|
76
|
-
}),
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("useModularUIBasic with reload", () => {
|
|
82
|
-
expect.assertions(2);
|
|
83
|
-
|
|
84
|
-
xhrMock.get("/BeInformed/", (req, res) => {
|
|
85
|
-
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
86
|
-
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
87
|
-
return res.status(200).body({ data: "ok" });
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const store = mockStore({
|
|
91
|
-
modularui: {},
|
|
92
|
-
router: { location: { pathname: "/", state: { reload: true } } },
|
|
93
|
-
i18n: { locale: "en" },
|
|
94
|
-
});
|
|
95
|
-
/**
|
|
96
|
-
*/
|
|
97
|
-
const wrapper = ({ children }) => (
|
|
98
|
-
<Provider store={store}>{children}</Provider>
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const { result } = renderHook(
|
|
102
|
-
() =>
|
|
103
|
-
useModularUIBasic("app", "/", {
|
|
104
|
-
expectedModels: ["Application"],
|
|
105
|
-
targetModel: ApplicationModel,
|
|
106
|
-
}),
|
|
107
|
-
{
|
|
108
|
-
wrapper,
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
expect(result.current).toBeNull();
|
|
113
|
-
|
|
114
|
-
expect(store.getActions()).toStrictEqual([
|
|
115
|
-
{ type: "START_PROGRESS" },
|
|
116
|
-
{
|
|
117
|
-
type: "MODULARUI/FETCH",
|
|
118
|
-
payload: expect.objectContaining({
|
|
119
|
-
href: new Href("/"),
|
|
120
|
-
locale: "en",
|
|
121
|
-
targetModel: ApplicationModel,
|
|
122
|
-
}),
|
|
123
|
-
},
|
|
124
|
-
]);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import configureMockStore from "redux-mock-store";
|
|
2
|
-
import { Provider } from "react-redux";
|
|
3
|
-
import { renderHook } from "@testing-library/react";
|
|
4
|
-
import { useNotification } from "../useNotification";
|
|
5
|
-
|
|
6
|
-
const mockStore = configureMockStore();
|
|
7
|
-
|
|
8
|
-
describe("notification hooks", () => {
|
|
9
|
-
it("useNotification", () => {
|
|
10
|
-
const store = mockStore({
|
|
11
|
-
notification: {
|
|
12
|
-
render: true,
|
|
13
|
-
messageType: "notification",
|
|
14
|
-
message: {
|
|
15
|
-
id: "notification",
|
|
16
|
-
defaultMessage: "message",
|
|
17
|
-
},
|
|
18
|
-
error: null,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*/
|
|
24
|
-
const wrapper = ({ children }) => (
|
|
25
|
-
<Provider store={store}>{children}</Provider>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const { result } = renderHook(() => useNotification(), {
|
|
29
|
-
wrapper,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
expect(result.current.render).toBe(true);
|
|
33
|
-
expect(result.current.messageType).toBe("notification");
|
|
34
|
-
expect(result.current.message.id).toBe("notification");
|
|
35
|
-
expect(result.current.message.defaultMessage).toBe("message");
|
|
36
|
-
|
|
37
|
-
expect(typeof result.current.dismiss).toBe("function");
|
|
38
|
-
|
|
39
|
-
result.current.dismiss();
|
|
40
|
-
|
|
41
|
-
expect(store.getActions()).toStrictEqual([
|
|
42
|
-
{
|
|
43
|
-
type: "DISMISS_NOTIFICATION",
|
|
44
|
-
},
|
|
45
|
-
]);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import configureMockStore from "redux-mock-store";
|
|
2
|
-
import { Provider } from "react-redux";
|
|
3
|
-
import { renderHook } from "@testing-library/react";
|
|
4
|
-
import { usePreference } from "../usePreference";
|
|
5
|
-
|
|
6
|
-
const mockStore = configureMockStore();
|
|
7
|
-
|
|
8
|
-
describe("preferences hooks", () => {
|
|
9
|
-
it("usePreference - exist", () => {
|
|
10
|
-
const store = mockStore({
|
|
11
|
-
preferences: {
|
|
12
|
-
name: "value",
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*/
|
|
18
|
-
const wrapper = ({ children }) => (
|
|
19
|
-
<Provider store={store}>{children}</Provider>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const { result } = renderHook(() => usePreference("name"), {
|
|
23
|
-
wrapper,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
expect(result.current.name).toBe("value");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("usePreference - multiple", () => {
|
|
30
|
-
const store = mockStore({
|
|
31
|
-
preferences: {
|
|
32
|
-
name1: "value1",
|
|
33
|
-
name2: "value2",
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
*/
|
|
39
|
-
const wrapper = ({ children }) => (
|
|
40
|
-
<Provider store={store}>{children}</Provider>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const { result } = renderHook(
|
|
44
|
-
() => usePreference(["name1", "name2", "name3"]),
|
|
45
|
-
{
|
|
46
|
-
wrapper,
|
|
47
|
-
},
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
expect(result.current).toStrictEqual({ name1: "value1", name2: "value2" });
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("usePreference not existing", () => {
|
|
54
|
-
const store = mockStore({
|
|
55
|
-
preferences: {
|
|
56
|
-
name: "value",
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
*/
|
|
62
|
-
const wrapper = ({ children }) => (
|
|
63
|
-
<Provider store={store}>{children}</Provider>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const { result } = renderHook(() => usePreference("not-existing"), {
|
|
67
|
-
wrapper,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(result.current.name).toBeUndefined();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import configureMockStore from "redux-mock-store";
|
|
2
|
-
import { Provider } from "react-redux";
|
|
3
|
-
import { renderHook } from "@testing-library/react";
|
|
4
|
-
import { useProgressIndicator } from "../useProgressIndicator";
|
|
5
|
-
|
|
6
|
-
const mockStore = configureMockStore();
|
|
7
|
-
|
|
8
|
-
describe("progressindicator hooks", () => {
|
|
9
|
-
it("useProgressIndicator", () => {
|
|
10
|
-
const store = mockStore({
|
|
11
|
-
progressindicator: {},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*/
|
|
16
|
-
const wrapper = ({ children }) => (
|
|
17
|
-
<Provider store={store}>{children}</Provider>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const { result } = renderHook(() => useProgressIndicator(), {
|
|
21
|
-
wrapper,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
expect(typeof result.current.start).toBe("function");
|
|
25
|
-
expect(typeof result.current.finish).toBe("function");
|
|
26
|
-
expect(typeof result.current.reset).toBe("function");
|
|
27
|
-
expect(typeof result.current.update).toBe("function");
|
|
28
|
-
|
|
29
|
-
result.current.start();
|
|
30
|
-
|
|
31
|
-
expect(store.getActions()).toStrictEqual([
|
|
32
|
-
{
|
|
33
|
-
type: "START_PROGRESS",
|
|
34
|
-
},
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
store.clearActions();
|
|
38
|
-
result.current.finish();
|
|
39
|
-
|
|
40
|
-
expect(store.getActions()).toStrictEqual([
|
|
41
|
-
{
|
|
42
|
-
type: "FINISH_PROGRESS",
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
store.clearActions();
|
|
47
|
-
result.current.reset();
|
|
48
|
-
|
|
49
|
-
expect(store.getActions()).toStrictEqual([
|
|
50
|
-
{
|
|
51
|
-
type: "RESET_PROGRESS",
|
|
52
|
-
},
|
|
53
|
-
]);
|
|
54
|
-
|
|
55
|
-
store.clearActions();
|
|
56
|
-
result.current.update(50);
|
|
57
|
-
|
|
58
|
-
expect(store.getActions()).toStrictEqual([
|
|
59
|
-
{
|
|
60
|
-
type: "UPDATE_PROGRESS",
|
|
61
|
-
payload: {
|
|
62
|
-
percentComplete: 50,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
]);
|
|
66
|
-
});
|
|
67
|
-
});
|
package/src/hooks/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
export * from "./useAllFormsOnModel";
|
|
3
|
-
export * from "./useAuthentication";
|
|
4
|
-
export * from "./useContent";
|
|
5
|
-
export * from "./useForm";
|
|
6
|
-
export * from "./useI18n";
|
|
7
|
-
export * from "./useList";
|
|
8
|
-
export * from "./useLookup";
|
|
9
|
-
export * from "./useModal";
|
|
10
|
-
export * from "./useModelCatalog";
|
|
11
|
-
export * from "./useModels";
|
|
12
|
-
export * from "./useModularUI";
|
|
13
|
-
export * from "./useModularUIBasic";
|
|
14
|
-
export * from "./useModularUIModel";
|
|
15
|
-
export * from "./useModularUIRequest";
|
|
16
|
-
export * from "./useNotification";
|
|
17
|
-
export * from "./usePanel";
|
|
18
|
-
export * from "./usePreference";
|
|
19
|
-
export * from "./useProgressIndicator";
|
|
20
|
-
export * from "./useRouter";
|
|
21
|
-
export * from "./useSearch";
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
|
|
4
|
-
import { useModularUIRequest } from "./useModularUIRequest";
|
|
5
|
-
|
|
6
|
-
import { HTTP_METHODS } from "../constants";
|
|
7
|
-
|
|
8
|
-
import ListModel from "../models/list/ListModel";
|
|
9
|
-
import FormModel from "../models/form/FormModel";
|
|
10
|
-
|
|
11
|
-
import type DetailModel from "../models/detail/DetailModel";
|
|
12
|
-
import type TabModel from "../models/tab/TabModel";
|
|
13
|
-
import type ActionModel from "../models/actions/ActionModel";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Retrieve all forms configured on a model with actions
|
|
17
|
-
* @param model
|
|
18
|
-
* @returns Object - { actionName: FormModel }
|
|
19
|
-
*/
|
|
20
|
-
export const useRetrieveFormsOnModel = (
|
|
21
|
-
model: ListModel | DetailModel | TabModel,
|
|
22
|
-
): null | { [actionName: string]: FormModel } => {
|
|
23
|
-
const modularui = useModularUIRequest();
|
|
24
|
-
const [forms, setForms] = useState(null);
|
|
25
|
-
const [requestCount, setRequestCount] = useState(0);
|
|
26
|
-
const [responseCount, setResponseCount] = useState(0);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const requests = getActions(model).map((action) => {
|
|
30
|
-
const href = action.selfhref.addParameter("commit", "false");
|
|
31
|
-
|
|
32
|
-
return modularui(href, { method: HTTP_METHODS.POST })
|
|
33
|
-
.fetch()
|
|
34
|
-
.then((form) => {
|
|
35
|
-
if (form instanceof FormModel) {
|
|
36
|
-
form.tokens = [];
|
|
37
|
-
}
|
|
38
|
-
return { [action.name]: form };
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
setRequestCount(requests.length);
|
|
43
|
-
|
|
44
|
-
Promise.all(requests).then((responses) => {
|
|
45
|
-
// put response array in object
|
|
46
|
-
const actionForms = Object.assign({}, ...responses);
|
|
47
|
-
setForms(actionForms);
|
|
48
|
-
setResponseCount(responses.length);
|
|
49
|
-
});
|
|
50
|
-
}, [model, modularui]);
|
|
51
|
-
|
|
52
|
-
if (responseCount === requestCount) {
|
|
53
|
-
return forms;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return null;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getActions = (
|
|
60
|
-
model: ListModel | DetailModel | TabModel,
|
|
61
|
-
): Array<ActionModel> => {
|
|
62
|
-
if (!model.actionCollection) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const createActions = model.actionCollection
|
|
67
|
-
.getActionsByType("create")
|
|
68
|
-
.filter((action) => !action.isDisabled);
|
|
69
|
-
|
|
70
|
-
const allActions = [...createActions];
|
|
71
|
-
|
|
72
|
-
if (model instanceof ListModel) {
|
|
73
|
-
model.listItemCollection.forEach((listItem) => {
|
|
74
|
-
const updateActions = listItem.actionCollection
|
|
75
|
-
.getActionsByType("update")
|
|
76
|
-
.filter((action) => !action.isDisabled);
|
|
77
|
-
|
|
78
|
-
allActions.push(...updateActions);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const actions = [];
|
|
83
|
-
const unique = [];
|
|
84
|
-
allActions.forEach((action) => {
|
|
85
|
-
if (!unique.includes(action.name)) {
|
|
86
|
-
unique.push(action.name);
|
|
87
|
-
actions.push(action);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return actions;
|
|
92
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { useSelector, useDispatch } from "react-redux";
|
|
3
|
-
|
|
4
|
-
import { login, logout, resetAuthErrors } from "../redux/actions";
|
|
5
|
-
|
|
6
|
-
import Cache from "../utils/browser/Cache";
|
|
7
|
-
import {
|
|
8
|
-
getBasePath,
|
|
9
|
-
getBasePathServer,
|
|
10
|
-
INTERNAL_LOGIN_TYPE,
|
|
11
|
-
} from "../constants";
|
|
12
|
-
import { IllegalStateException } from "../exceptions";
|
|
13
|
-
import { Authenticate } from "../modularui";
|
|
14
|
-
import { useApplication } from "./useModularUIModel";
|
|
15
|
-
|
|
16
|
-
import type { ResetAuthErrorsAction } from "../redux/types";
|
|
17
|
-
import type { AuthenticationType } from "../models/types";
|
|
18
|
-
|
|
19
|
-
type LoginHook = {
|
|
20
|
-
isAuthenticated: boolean,
|
|
21
|
-
primaryAuthenticationType: AuthenticationType,
|
|
22
|
-
authenticationTypes: Array<AuthenticationType>,
|
|
23
|
-
errorMessage: ?string,
|
|
24
|
-
resetErrors: () => ResetAuthErrorsAction,
|
|
25
|
-
login: (username: string, password: string) => void,
|
|
26
|
-
redirectLogin: (authenticationType: AuthenticationType) => void,
|
|
27
|
-
};
|
|
28
|
-
type LogoutHook = {
|
|
29
|
-
isAuthenticated: boolean,
|
|
30
|
-
primaryAuthenticationType: AuthenticationType,
|
|
31
|
-
authenticationTypes: Array<AuthenticationType>,
|
|
32
|
-
logout: () => void,
|
|
33
|
-
logoutUrl: string,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*/
|
|
38
|
-
export const useLogin = (): LoginHook => {
|
|
39
|
-
Cache.setItem("isRedirectLogin", false);
|
|
40
|
-
|
|
41
|
-
const dispatch = useDispatch();
|
|
42
|
-
|
|
43
|
-
const application = useApplication();
|
|
44
|
-
const auth = useSelector((state) => state.auth);
|
|
45
|
-
|
|
46
|
-
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
47
|
-
|
|
48
|
-
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
isAuthenticated,
|
|
52
|
-
primaryAuthenticationType:
|
|
53
|
-
primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
54
|
-
authenticationTypes: application?.authenticationTypes ?? [],
|
|
55
|
-
errorMessage: auth.error,
|
|
56
|
-
resetErrors: () => dispatch(resetAuthErrors()),
|
|
57
|
-
login: (username: string, password: string) =>
|
|
58
|
-
dispatch(login(username, password)),
|
|
59
|
-
redirectLogin: (authenticationType: AuthenticationType) => {
|
|
60
|
-
if (Cache.getItem("isRedirectLogin")) {
|
|
61
|
-
// prevent endless loop in redirects when authentication type can't be redirected
|
|
62
|
-
throw new IllegalStateException(
|
|
63
|
-
`Could not redirect to '${
|
|
64
|
-
authenticationType.authentication
|
|
65
|
-
}' using url: '${authenticationType.redirectUri ?? ""}'`,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!isAuthenticated) {
|
|
70
|
-
Cache.setItem("isRedirectLogin", true);
|
|
71
|
-
window.location.assign(
|
|
72
|
-
`${getBasePathServer()}${authenticationType.redirectUri ?? ""}`,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
*/
|
|
81
|
-
export const useLogout = (): LogoutHook => {
|
|
82
|
-
const dispatch = useDispatch();
|
|
83
|
-
|
|
84
|
-
const application = useApplication();
|
|
85
|
-
|
|
86
|
-
const BASE_PATH = getBasePath();
|
|
87
|
-
|
|
88
|
-
const authenticate = new Authenticate();
|
|
89
|
-
|
|
90
|
-
const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
|
|
91
|
-
|
|
92
|
-
const isAuthenticated = application?.isLoggedIn ?? false;
|
|
93
|
-
return {
|
|
94
|
-
isAuthenticated,
|
|
95
|
-
primaryAuthenticationType:
|
|
96
|
-
primaryAuthenticationType ?? application?.authenticationTypes[0],
|
|
97
|
-
authenticationTypes: application?.authenticationTypes ?? [],
|
|
98
|
-
logout: () => {
|
|
99
|
-
const type = authenticate.authenticationType;
|
|
100
|
-
if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
|
|
101
|
-
authenticate.redirectToLogout();
|
|
102
|
-
} else if (Cache.getItem("isRedirectLogin")) {
|
|
103
|
-
const origin = window.location.origin;
|
|
104
|
-
const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;
|
|
105
|
-
Cache.setItem("isRedirectLogin", false);
|
|
106
|
-
window.location.assign(url);
|
|
107
|
-
} else {
|
|
108
|
-
return dispatch(logout());
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
logoutUrl: authenticate.getLogoutUrl(),
|
|
112
|
-
};
|
|
113
|
-
};
|
package/src/hooks/useContent.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { useState, useEffect } from "react";
|
|
3
|
-
|
|
4
|
-
import SourceReferenceCollection from "../models/concepts/SourceReferenceCollection";
|
|
5
|
-
import ModularUIRequest from "../modularui/ModularUIRequest";
|
|
6
|
-
|
|
7
|
-
import { useProgressIndicator } from "../hooks/useProgressIndicator";
|
|
8
|
-
import { useLocale } from "../hooks/useI18n";
|
|
9
|
-
|
|
10
|
-
import type ContentModel from "../models/content/ContentModel";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Hook to retrieve multiple source references at once
|
|
14
|
-
*/
|
|
15
|
-
export const useContentFromSourceReferences = (
|
|
16
|
-
sourceReferences: SourceReferenceCollection,
|
|
17
|
-
renderChildSections: boolean,
|
|
18
|
-
): Array<ContentModel> => {
|
|
19
|
-
const [content, setContent] = useState([]);
|
|
20
|
-
const localeCode = useLocale();
|
|
21
|
-
|
|
22
|
-
const { start, finish } = useProgressIndicator();
|
|
23
|
-
|
|
24
|
-
const hrefs = sourceReferences
|
|
25
|
-
.map((sourceReference) => sourceReference.link.selfhref.href)
|
|
26
|
-
.filter((href, index, self) => self.indexOf(href) === index)
|
|
27
|
-
.map((href) => href.toString());
|
|
28
|
-
|
|
29
|
-
const allHrefs = JSON.stringify(hrefs);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const requests = JSON.parse(allHrefs).map((href) => {
|
|
32
|
-
const modularuiRequest = new ModularUIRequest(href);
|
|
33
|
-
modularuiRequest.locale = localeCode;
|
|
34
|
-
return modularuiRequest.fetchContent(renderChildSections);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
start();
|
|
38
|
-
Promise.all(requests).then((responseContent) => {
|
|
39
|
-
setContent(responseContent);
|
|
40
|
-
finish();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// start and finish don't change
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
}, [allHrefs, localeCode, renderChildSections]);
|
|
46
|
-
|
|
47
|
-
return content;
|
|
48
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { useRef, useEffect } from "react";
|
|
3
|
-
import { dequal as deepEqual } from "dequal/lite";
|
|
4
|
-
|
|
5
|
-
type Callback = () => void | (() => void);
|
|
6
|
-
type DependencyList = $ReadOnlyArray<any>;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Validates that dependencies are used correctly.
|
|
10
|
-
* Deep compare should not be used with empty arrays or no dependencies.
|
|
11
|
-
*/
|
|
12
|
-
function checkDeps(deps: DependencyList) {
|
|
13
|
-
if (process.env.NODE_ENV !== "production") {
|
|
14
|
-
if (!deps || deps.length === 0) {
|
|
15
|
-
console.warn(
|
|
16
|
-
"useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead.",
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const useDeepCompareMemoize = (value: DependencyList): DependencyList => {
|
|
23
|
-
const ref = useRef<DependencyList>(value);
|
|
24
|
-
|
|
25
|
-
// Only update the ref if the deep equality check fails
|
|
26
|
-
if (!deepEqual(value, ref.current)) {
|
|
27
|
-
ref.current = value;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return ref.current;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* A version of useEffect that accepts a deep comparison of dependencies.
|
|
35
|
-
*/
|
|
36
|
-
export function useDeepCompareEffect(
|
|
37
|
-
callback: Callback,
|
|
38
|
-
dependencies: DependencyList,
|
|
39
|
-
): void {
|
|
40
|
-
if (process.env.NODE_ENV !== "production") {
|
|
41
|
-
checkDeps(dependencies);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// We use the memoized ref as the dependency.
|
|
45
|
-
// React's shallow check will only trigger when the ref object itself changes.
|
|
46
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
-
useEffect(callback, useDeepCompareMemoize(dependencies));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default useDeepCompareEffect;
|