@wise/dynamic-flow-client 3.7.1 → 3.7.2-experimental-1ba6fef
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/build/common/errorBoundary/ErrorBoundary.js +44 -0
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +12 -0
- package/build/common/httpClientContext/HttpClientContext.js +24 -0
- package/build/common/httpClientContext/index.js +1 -0
- package/build/common/makeHttpClient/index.js +1 -0
- package/build/common/makeHttpClient/makeHttpClient.js +34 -0
- package/build/common/makeHttpClient/makeHttpClient.spec.js +141 -0
- package/build/common/messages/external-confirmation.messages.js +23 -0
- package/build/common/messages/generic-error.messages.js +18 -0
- package/build/common/messages/help.messages.js +8 -0
- package/build/common/messages/multi-file-upload.messages.js +18 -0
- package/build/common/messages/multi-select.messages.js +8 -0
- package/build/common/messages/paragraph.messages.js +13 -0
- package/build/common/messages/repeatable.messages.js +23 -0
- package/build/common/messages/validation.array.messages.js +13 -0
- package/build/common/messages/validation.messages.js +53 -0
- package/build/common/utils/api-utils.js +4 -0
- package/build/i18n/de.json +46 -46
- package/build/i18n/en.json +46 -46
- package/build/i18n/es.json +46 -46
- package/build/i18n/fr.json +46 -46
- package/build/i18n/hu.json +46 -46
- package/build/i18n/id.json +46 -46
- package/build/i18n/index.js +36 -0
- package/build/i18n/it.json +46 -46
- package/build/i18n/ja.json +46 -46
- package/build/i18n/pl.json +46 -46
- package/build/i18n/pt.json +46 -46
- package/build/i18n/ro.json +46 -46
- package/build/i18n/ru.json +46 -46
- package/build/i18n/th.json +46 -46
- package/build/i18n/tr.json +46 -46
- package/build/i18n/zh_CN.json +46 -46
- package/build/i18n/zh_HK.json +46 -46
- package/build/index.js +10 -0
- package/build/legacy/common/constants/DateMode.js +4 -0
- package/build/legacy/common/constants/FeatureName.js +4 -0
- package/build/legacy/common/constants/FormControlType.js +21 -0
- package/build/legacy/common/constants/MonthFormat.js +4 -0
- package/build/legacy/common/constants/Size.js +7 -0
- package/build/legacy/common/constants/index.js +4 -0
- package/build/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +25 -0
- package/build/legacy/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +15 -0
- package/build/legacy/common/contexts/eventsContext/EventsContext.js +38 -0
- package/build/legacy/common/contexts/eventsContext/EventsContext.spec.js +47 -0
- package/build/legacy/common/contexts/featureContext/FeatureContext.js +11 -0
- package/build/legacy/common/contexts/featureContext/FeatureContext.spec.js +30 -0
- package/build/legacy/common/contexts/index.js +3 -0
- package/build/legacy/common/contexts/logContext/LogContext.js +44 -0
- package/build/legacy/common/contexts/logContext/LogContext.spec.js +43 -0
- package/build/legacy/common/hooks/index.js +7 -0
- package/build/legacy/common/hooks/useDebouncedFunction/useDebouncedFunction.js +9 -0
- package/build/legacy/common/hooks/useDebouncedFunction/useDebouncedFunction.spec.js +59 -0
- package/build/legacy/common/hooks/useExternal/useExternal.js +16 -0
- package/build/legacy/common/hooks/useExternal/useExternal.spec.js +222 -0
- package/build/legacy/common/hooks/useExternalStepPolling/useExternalStepPolling.js +71 -0
- package/build/legacy/common/hooks/usePersistAsync/usePersistAsync.js +172 -0
- package/build/legacy/common/hooks/usePolling/usePolling.js +53 -0
- package/build/legacy/common/hooks/usePrevious/usePrevious.js +8 -0
- package/build/legacy/common/hooks/useStepPolling/useStepPolling.js +45 -0
- package/build/legacy/common/hooks/useStepPolling/useStepPolling.spec.js +288 -0
- package/build/legacy/common/messages.js +8 -0
- package/build/legacy/common/utils/api-utils.js +6 -0
- package/build/legacy/common/utils/date-utils.js +22 -0
- package/build/legacy/common/utils/debounce.js +39 -0
- package/build/legacy/common/utils/debounce.spec.js +72 -0
- package/build/legacy/common/utils/file-utils.js +45 -0
- package/build/legacy/common/utils/file-utils.spec.js +69 -0
- package/build/legacy/common/utils/id-utils.js +5 -0
- package/build/legacy/common/utils/id-utils.spec.js +12 -0
- package/build/legacy/common/utils/index.js +11 -0
- package/build/legacy/common/utils/is-equal.js +21 -0
- package/build/legacy/common/utils/is-equal.spec.js +88 -0
- package/build/legacy/common/utils/misc-utils.js +4 -0
- package/build/legacy/common/utils/mobile-utils.js +23 -0
- package/build/legacy/common/utils/mobile-utils.spec.js +71 -0
- package/build/legacy/common/utils/model-utils.js +33 -0
- package/build/legacy/common/utils/schema-utils.js +113 -0
- package/build/legacy/common/utils/step-utils.js +32 -0
- package/build/legacy/common/validators/index.js +5 -0
- package/build/legacy/common/validators/models/model-utils.js +119 -0
- package/build/legacy/common/validators/models/model-utils.spec.js +45 -0
- package/build/legacy/common/validators/models/model-validators.js +62 -0
- package/build/legacy/common/validators/models/model-validators.spec.js +647 -0
- package/build/legacy/common/validators/schemas/schema-validators.js +101 -0
- package/build/legacy/common/validators/schemas/schema-validators.spec.js +157 -0
- package/build/legacy/common/validators/types/type-validators.js +14 -0
- package/build/legacy/common/validators/types/type-validators.spec.js +147 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.js +139 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.spec.js +198 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.utils.js +40 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.utils.spec.js +145 -0
- package/build/legacy/common/validators/values/value-validators.js +6 -0
- package/build/legacy/common/validators/values/value-validators.spec.js +22 -0
- package/build/legacy/dynamic-flow-types.js +1 -0
- package/build/legacy/dynamicFlow/BackButton.js +22 -0
- package/build/legacy/dynamicFlow/DynamicFlow.js +348 -0
- package/build/legacy/dynamicFlow/DynamicFlowStep.js +37 -0
- package/build/legacy/dynamicFlow/DynamicFlowTypes.js +1 -0
- package/build/legacy/dynamicFlow/index.js +1 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/DynamicFlow.story.js +78 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/ErrorResponses.story.js +124 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/Examples.story.js +25 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/Features.story.js +33 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/JsonSchemaForm.story.js +31 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/RefreshOnChange.story.js +194 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/SearchFeature.story.js +253 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/ServerTest.story.js +44 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/Upload.story.js +212 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/ValidationAsync.story.js +156 -0
- package/build/legacy/dynamicFlow/stories/examples/ObjectConst.story.js +150 -0
- package/build/legacy/dynamicFlow/stories/fixtureHttpClient.js +117 -0
- package/build/legacy/dynamicFlow/stories/visual-tests/VisualTests.story.js +43 -0
- package/build/legacy/dynamicFlow/tests/Actions.spec.js +185 -0
- package/build/legacy/dynamicFlow/tests/AllOfSchema.spec.js +196 -0
- package/build/legacy/dynamicFlow/tests/AutocompleteHints.spec.js +59 -0
- package/build/legacy/dynamicFlow/tests/DynamicFlow.BackButton.spec.js +179 -0
- package/build/legacy/dynamicFlow/tests/DynamicFlow.search.spec.js +475 -0
- package/build/legacy/dynamicFlow/tests/DynamicFlow.spec.js +559 -0
- package/build/legacy/dynamicFlow/tests/DynamicImage.spec.js +287 -0
- package/build/legacy/dynamicFlow/tests/DynamicInstructions.spec.js +49 -0
- package/build/legacy/dynamicFlow/tests/HiddenSchemas.spec.js +307 -0
- package/build/legacy/dynamicFlow/tests/ModalLayout.spec.js +252 -0
- package/build/legacy/dynamicFlow/tests/MultiSelect.spec.js +327 -0
- package/build/legacy/dynamicFlow/tests/MultipleFileUploadSchema.spec.js +401 -0
- package/build/legacy/dynamicFlow/tests/ObjectSchema.spec.js +295 -0
- package/build/legacy/dynamicFlow/tests/OneOfSchema.spec.js +773 -0
- package/build/legacy/dynamicFlow/tests/PersistAsync.blob-schema.spec.js +331 -0
- package/build/legacy/dynamicFlow/tests/PersistAsync.string-schema.spec.js +389 -0
- package/build/legacy/dynamicFlow/tests/RefreshStepOnChange.debouncing.spec.js +391 -0
- package/build/legacy/dynamicFlow/tests/RefreshStepOnChange.spec.js +567 -0
- package/build/legacy/dynamicFlow/tests/RepeatableSchema.spec.js +977 -0
- package/build/legacy/dynamicFlow/tests/StepModel.spec.js +119 -0
- package/build/legacy/dynamicFlow/tests/ValidationAsync.spec.js +484 -0
- package/build/legacy/dynamicFlow/tests/ssr.spec.js +47 -0
- package/build/legacy/dynamicFlow/utils/index.js +5 -0
- package/build/legacy/dynamicFlow/utils/responseParsers/response-parsers.js +185 -0
- package/build/legacy/dynamicFlow/utils/responseParsers/response-parsers.spec.js +463 -0
- package/build/legacy/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +35 -0
- package/build/legacy/dynamicFlow/utils/useDynamicFlowState.js +137 -0
- package/build/legacy/dynamicFlow/utils/useLoader.js +22 -0
- package/build/legacy/formControl/FormControl.js +265 -0
- package/build/legacy/formControl/Select.spec.js +104 -0
- package/build/legacy/formControl/index.js +1 -0
- package/build/legacy/formControl/utils/getAutocompleteString.js +80 -0
- package/build/legacy/formControl/utils/getAutocompleteString.spec.js +30 -0
- package/build/legacy/formControl/utils/index.js +2 -0
- package/build/legacy/formControl/utils/value-utils.js +108 -0
- package/build/legacy/formControl/utils/value-utils.spec.js +158 -0
- package/build/legacy/jsonSchemaForm/JsonSchemaForm.end-to-end.spec.js +563 -0
- package/build/legacy/jsonSchemaForm/JsonSchemaForm.js +24 -0
- package/build/legacy/jsonSchemaForm/allOfSchema/AllOfSchema.js +50 -0
- package/build/legacy/jsonSchemaForm/allOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +25 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +34 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multiSelectSchema/MultiSelectSchema.js +73 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +141 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +2 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +79 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +14 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/ItemSummary.js +7 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.js +134 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.js +85 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.js +135 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.spec.js +909 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +100 -0
- package/build/legacy/jsonSchemaForm/basicTypeSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/controlFeedback/ControlFeedback.js +89 -0
- package/build/legacy/jsonSchemaForm/controlFeedback/index.js +1 -0
- package/build/legacy/jsonSchemaForm/genericSchema/GenericSchema.js +85 -0
- package/build/legacy/jsonSchemaForm/genericSchema/GenericSchema.rtl.spec.js +55 -0
- package/build/legacy/jsonSchemaForm/genericSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/help/Help.js +9 -0
- package/build/legacy/jsonSchemaForm/help/index.js +1 -0
- package/build/legacy/jsonSchemaForm/index.js +1 -0
- package/build/legacy/jsonSchemaForm/objectSchema/ObjectSchema.js +77 -0
- package/build/legacy/jsonSchemaForm/objectSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.js +155 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/utils.js +68 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +26 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +165 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +131 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +31 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +72 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +8 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +16 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +31 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +32 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +54 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +13 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +134 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.spec.js +312 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/index.js +1 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/utils/index.js +1 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +107 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.spec.js +220 -0
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +150 -0
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/index.js +1 -0
- package/build/legacy/layout/DynamicLayout.js +68 -0
- package/build/legacy/layout/alert/DynamicAlert.js +29 -0
- package/build/legacy/layout/box/DynamicBox.js +30 -0
- package/build/legacy/layout/button/DynamicButton.js +16 -0
- package/build/legacy/layout/button/DynamicButton.spec.js +141 -0
- package/build/legacy/layout/button/utils.js +45 -0
- package/build/legacy/layout/button/utils.spec.js +50 -0
- package/build/legacy/layout/columns/DynamicColumns.js +27 -0
- package/build/legacy/layout/decision/DynamicDecision.js +10 -0
- package/build/legacy/layout/divider/DynamicDivider.js +9 -0
- package/build/legacy/layout/external/DynamicExternal.js +32 -0
- package/build/legacy/layout/external/DynamicExternal.messages.js +8 -0
- package/build/legacy/layout/form/DynamicForm.js +22 -0
- package/build/legacy/layout/heading/DynamicHeading.js +40 -0
- package/build/legacy/layout/icon/DynamicIcon.js +17 -0
- package/build/legacy/layout/icon/DynamicIcon.spec.js +20 -0
- package/build/legacy/layout/icon/FlagIcon.js +11 -0
- package/build/legacy/layout/icon/NamedIcon.js +19 -0
- package/build/legacy/layout/image/DynamicImage.js +112 -0
- package/build/legacy/layout/index.js +20 -0
- package/build/legacy/layout/instructions/DynamicInstructions.js +19 -0
- package/build/legacy/layout/list/DynamicStatusList.js +37 -0
- package/build/legacy/layout/list/DynamicStatusList.spec.js +111 -0
- package/build/legacy/layout/loadingIndicator/DynamicLoadingIndicator.js +11 -0
- package/build/legacy/layout/loadingIndicator/DynamicLoadingIndicator.spec.js +25 -0
- package/build/legacy/layout/markdown/DynamicMarkdown.js +12 -0
- package/build/legacy/layout/markdown/DynamicMarkdown.spec.js +58 -0
- package/build/legacy/layout/modal/DynamicModal.js +26 -0
- package/build/legacy/layout/paragraph/DynamicParagraph.js +35 -0
- package/build/legacy/layout/paragraph/useSnackBarIfAvailable.js +9 -0
- package/build/legacy/layout/review/DynamicReview.js +47 -0
- package/build/legacy/layout/review/DynamicReview.spec.js +152 -0
- package/build/legacy/layout/search/DynamicSearch.js +83 -0
- package/build/legacy/layout/search/SearchInput.js +6 -0
- package/build/legacy/layout/search/SearchResults.js +20 -0
- package/build/legacy/layout/search/useSearch.js +137 -0
- package/build/legacy/layout/utils/getNavigationOptionMedia.js +17 -0
- package/build/legacy/layout/utils/index.js +32 -0
- package/build/legacy/step/cameraStep/CameraStep.js +124 -0
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.js +161 -0
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.messages.js +58 -0
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.spec.js +432 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/bottomBar/BottomBar.js +17 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/index.js +3 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.js +8 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.js +8 -0
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.js +62 -0
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useVideoConstraints.js +80 -0
- package/build/legacy/step/cameraStep/cameraCapture/index.js +1 -0
- package/build/legacy/step/cameraStep/cameraCapture/overlay/Overlay.js +77 -0
- package/build/legacy/step/cameraStep/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.js +7 -0
- package/build/legacy/step/cameraStep/cameraCapture/screens/index.js +1 -0
- package/build/legacy/step/cameraStep/cameraCapture/tracking/index.js +109 -0
- package/build/legacy/step/cameraStep/cameraCapture/types/index.js +7 -0
- package/build/legacy/step/cameraStep/cameraCapture/utils/index.js +107 -0
- package/build/legacy/step/cameraStep/index.js +1 -0
- package/build/legacy/step/externalConfirmationStep/ExternalConfirmationStep.js +64 -0
- package/build/legacy/step/externalConfirmationStep/index.js +1 -0
- package/build/legacy/step/index.js +3 -0
- package/build/legacy/step/layoutStep/LayoutStep.js +33 -0
- package/build/legacy/step/layoutStep/index.js +1 -0
- package/build/legacy/step/layoutStep/utils/index.js +2 -0
- package/build/legacy/step/layoutStep/utils/inline-reference-utils.js +105 -0
- package/build/legacy/step/layoutStep/utils/layout-utils.js +212 -0
- package/build/legacy/test-utils/DynamicFlowProviders.js +8 -0
- package/build/legacy/test-utils/index.js +4 -0
- package/build/legacy/test-utils/legacy-utils.js +69 -0
- package/build/legacy/test-utils/log-utils.js +9 -0
- package/build/main.js +1 -1
- package/build/main.min.js +1 -1
- package/build/main.mjs +1 -1
- package/build/revamp/DynamicFlowCore.js +299 -0
- package/build/revamp/DynamicFlowWise.js +69 -0
- package/build/revamp/DynamicFlowWise.spec.js +105 -0
- package/build/revamp/domain/components/AlertComponent.js +50 -0
- package/build/revamp/domain/components/AllOfComponent.js +72 -0
- package/build/revamp/domain/components/BooleanInputComponent.js +108 -0
- package/build/revamp/domain/components/BoxComponent.js +65 -0
- package/build/revamp/domain/components/ButtonComponent.js +50 -0
- package/build/revamp/domain/components/ColumnsComponent.js +74 -0
- package/build/revamp/domain/components/ConstComponent.js +50 -0
- package/build/revamp/domain/components/ContainerComponent.js +65 -0
- package/build/revamp/domain/components/DateInputComponent.js +127 -0
- package/build/revamp/domain/components/DecisionComponent.js +50 -0
- package/build/revamp/domain/components/DividerComponent.js +50 -0
- package/build/revamp/domain/components/FormComponent.js +65 -0
- package/build/revamp/domain/components/HeadingComponent.js +50 -0
- package/build/revamp/domain/components/ImageComponent.js +50 -0
- package/build/revamp/domain/components/InstructionsComponent.js +50 -0
- package/build/revamp/domain/components/IntegerInputComponent.js +125 -0
- package/build/revamp/domain/components/LoadingIndicatorComponent.js +50 -0
- package/build/revamp/domain/components/MarkdownComponent.js +50 -0
- package/build/revamp/domain/components/ModalComponent.js +65 -0
- package/build/revamp/domain/components/MultiUploadInputComponent.js +190 -0
- package/build/revamp/domain/components/NumberInputComponent.js +125 -0
- package/build/revamp/domain/components/ObjectComponent.js +104 -0
- package/build/revamp/domain/components/ParagraphComponent.js +50 -0
- package/build/revamp/domain/components/ReviewComponent.js +50 -0
- package/build/revamp/domain/components/SelectInputComponent.js +138 -0
- package/build/revamp/domain/components/StatusListComponent.js +50 -0
- package/build/revamp/domain/components/StepDomainComponent.js +87 -0
- package/build/revamp/domain/components/TextInputComponent.js +125 -0
- package/build/revamp/domain/components/UploadInputComponent.js +151 -0
- package/build/revamp/domain/components/repeatableComponent/RepeatableComponent.js +148 -0
- package/build/revamp/domain/components/repeatableComponent/RepeatableComponent.spec.js +145 -0
- package/build/revamp/domain/components/searchComponent/SearchComponent.js +111 -0
- package/build/revamp/domain/components/searchComponent/SearchComponent.spec.js +327 -0
- package/build/revamp/domain/components/utils/component-utils.js +18 -0
- package/build/revamp/domain/components/utils/debounce.js +38 -0
- package/build/revamp/domain/components/utils/debounce.spec.js +72 -0
- package/build/revamp/domain/components/utils/file-utils.js +46 -0
- package/build/revamp/domain/components/utils/getComponentForLocalValueKey.js +31 -0
- package/build/revamp/domain/components/utils/isPartialLocalValueMatch.js +40 -0
- package/build/revamp/domain/components/utils/isPartialLocalValueMatch.spec.js +108 -0
- package/build/revamp/domain/features/events.js +1 -0
- package/build/revamp/domain/features/persistAsync/getComponentPersistAsync.js +133 -0
- package/build/revamp/domain/features/persistAsync/getComponentPersistAsync.spec.js +199 -0
- package/build/revamp/domain/features/persistAsync/getInitialPersistedState.js +6 -0
- package/build/revamp/domain/features/persistAsync/getPerformPersistAsync.js +103 -0
- package/build/revamp/domain/features/persistAsync/getPerformPersistAsync.spec.js +280 -0
- package/build/revamp/domain/features/polling/getStepPolling.js +82 -0
- package/build/revamp/domain/features/polling/getStepPolling.spec.js +170 -0
- package/build/revamp/domain/features/refresh/getPerformRefresh.js +53 -0
- package/build/revamp/domain/features/search/getPerformSearchFunction.js +104 -0
- package/build/revamp/domain/features/search/getPerformSearchFunction.spec.js +260 -0
- package/build/revamp/domain/features/summary/summary-utils.js +39 -0
- package/build/revamp/domain/features/summary/summary-utils.spec.js +110 -0
- package/build/revamp/domain/features/utils/http-utils.js +34 -0
- package/build/revamp/domain/features/utils/response-utils.js +9 -0
- package/build/revamp/domain/features/validation/spec-utils.js +16 -0
- package/build/revamp/domain/features/validation/validation-functions.js +12 -0
- package/build/revamp/domain/features/validation/validation-functions.spec.js +110 -0
- package/build/revamp/domain/features/validation/value-checks.js +111 -0
- package/build/revamp/domain/features/validation/value-checks.spec.js +204 -0
- package/build/revamp/domain/features/validationAsync/getComponentValidationAsync.js +95 -0
- package/build/revamp/domain/features/validationAsync/getComponentValidationAsync.spec.js +177 -0
- package/build/revamp/domain/features/validationAsync/getInitialValidationState.js +5 -0
- package/build/revamp/domain/features/validationAsync/getPerformValidationAsync.js +107 -0
- package/build/revamp/domain/features/validationAsync/getPerformValidationAsync.spec.js +266 -0
- package/build/revamp/domain/mappers/layout/alertLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/boxLayoutToComponents.js +15 -0
- package/build/revamp/domain/mappers/layout/buttonLayoutToComponent.js +45 -0
- package/build/revamp/domain/mappers/layout/columnsLayoutToComponent.js +18 -0
- package/build/revamp/domain/mappers/layout/decisionLayoutToComponent.js +40 -0
- package/build/revamp/domain/mappers/layout/dividerLayoutToComponent.js +5 -0
- package/build/revamp/domain/mappers/layout/formLayoutToComponent.js +27 -0
- package/build/revamp/domain/mappers/layout/headingLayoutToComponent.js +13 -0
- package/build/revamp/domain/mappers/layout/imageLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/infoLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/instructionsLayoutToComponent.js +18 -0
- package/build/revamp/domain/mappers/layout/listLayoutToComponent.js +30 -0
- package/build/revamp/domain/mappers/layout/loadingIndicatorLayoutToComponent.js +5 -0
- package/build/revamp/domain/mappers/layout/markdownLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/modalLayoutToComponent.js +17 -0
- package/build/revamp/domain/mappers/layout/paragraphLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/reviewLayoutToComponent.js +51 -0
- package/build/revamp/domain/mappers/layout/searchLayoutToComponent.js +14 -0
- package/build/revamp/domain/mappers/layout/statusListLayoutToComponent.js +11 -0
- package/build/revamp/domain/mappers/mapLayoutToComponent.js +63 -0
- package/build/revamp/domain/mappers/mapSchemaToComponent.js +84 -0
- package/build/revamp/domain/mappers/mapSchemaToComponent.spec.js +197 -0
- package/build/revamp/domain/mappers/mapStepToComponent.js +159 -0
- package/build/revamp/domain/mappers/mapStepToComponent.spec.js +236 -0
- package/build/revamp/domain/mappers/schema/allOfSchemaToComponent.js +29 -0
- package/build/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.js +35 -0
- package/build/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.js +63 -0
- package/build/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.js +65 -0
- package/build/revamp/domain/mappers/schema/blobSchemaToComponent.js +30 -0
- package/build/revamp/domain/mappers/schema/booleanSchemaToComponent.js +38 -0
- package/build/revamp/domain/mappers/schema/constSchemaToComponent.js +14 -0
- package/build/revamp/domain/mappers/schema/integerSchemaToComponent.js +36 -0
- package/build/revamp/domain/mappers/schema/numberSchemaToComponent.js +35 -0
- package/build/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.js +41 -0
- package/build/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.spec.js +165 -0
- package/build/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.js +67 -0
- package/build/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.spec.js +316 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.js +14 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.spec.js +220 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.js +37 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.js +45 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.js +32 -0
- package/build/revamp/domain/mappers/schema/tests/test-utils.js +27 -0
- package/build/revamp/domain/mappers/schema/types.js +1 -0
- package/build/revamp/domain/mappers/schema/utils/getPersistAsyncInitialState.js +35 -0
- package/build/revamp/domain/mappers/schema/utils/getValidationAsyncInitialState.js +25 -0
- package/build/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.js +28 -0
- package/build/revamp/domain/mappers/types.js +1 -0
- package/build/revamp/domain/mappers/utils/getAutocompleteString.js +76 -0
- package/build/revamp/domain/mappers/utils/getAutocompleteString.spec.js +21 -0
- package/build/revamp/domain/mappers/utils/getRandomId.js +2 -0
- package/build/revamp/domain/mappers/utils/inlineAction.js +23 -0
- package/build/revamp/domain/mappers/utils/legacy-utils.js +53 -0
- package/build/revamp/domain/types.js +1 -0
- package/build/revamp/flow/executeRefresh.js +97 -0
- package/build/revamp/flow/executeSubmission.js +160 -0
- package/build/revamp/flow/getResponseType.js +76 -0
- package/build/revamp/flow/response-utils.js +92 -0
- package/build/revamp/renderers/CoreContainerRenderer.js +8 -0
- package/build/revamp/renderers/getRenderFunction.js +55 -0
- package/build/revamp/renderers/getSchemaErrorMessageFunction.js +90 -0
- package/build/revamp/renderers/mappers/alertComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/allOfComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/booleanInputComponentToProps.js +16 -0
- package/build/revamp/renderers/mappers/boxComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/buttonComponentToProps.js +14 -0
- package/build/revamp/renderers/mappers/columnsComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/componentToRendererProps.js +105 -0
- package/build/revamp/renderers/mappers/containerComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/dateInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/decisionComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/dividerComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/formComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/headingComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/hiddenComponentToProps.js +3 -0
- package/build/revamp/renderers/mappers/imageComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/instructionsComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/integerInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/loadingIndicatorComponentToProps.js +9 -0
- package/build/revamp/renderers/mappers/markdownComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/modalComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/multiUploadInputComponentToProps.js +24 -0
- package/build/revamp/renderers/mappers/numberInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/objectComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/paragraphComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/repeatableComponentToProps.js +40 -0
- package/build/revamp/renderers/mappers/reviewComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/searchComponentToProps.js +53 -0
- package/build/revamp/renderers/mappers/selectInputComponentToProps.js +29 -0
- package/build/revamp/renderers/mappers/statusListComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/textInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/uploadInputComponentToProps.js +16 -0
- package/build/revamp/renderers/mappers/utils/inputComponentToProps.js +27 -0
- package/build/revamp/renderers/step/BackButton.js +11 -0
- package/build/revamp/renderers/step/ExternalConfirmationDialog.js +20 -0
- package/build/revamp/renderers/step/StepRenderer.js +30 -0
- package/build/revamp/renderers/step/StepRendererContext.js +11 -0
- package/build/revamp/renderers/step/useExternal.js +15 -0
- package/build/revamp/renderers/stepComponentToProps.js +11 -0
- package/build/revamp/renderers/types.js +1 -0
- package/build/revamp/stories/dev-tools/ActionResponse.story.js +101 -0
- package/build/revamp/stories/dev-tools/DynamicFlowRevamp.story.js +314 -0
- package/build/revamp/stories/dev-tools/EditableStep.story.js +71 -0
- package/build/revamp/stories/dev-tools/ErrorHandling.story.js +149 -0
- package/build/revamp/stories/dev-tools/External.story.js +83 -0
- package/build/revamp/stories/dev-tools/OneOf.Inititalisation.story.js +123 -0
- package/build/revamp/stories/dev-tools/PersistAsync.story.js +168 -0
- package/build/revamp/stories/dev-tools/Polling.story.js +79 -0
- package/build/revamp/stories/dev-tools/RefreshOnChange.story.js +309 -0
- package/build/revamp/stories/dev-tools/RefreshOnChange.with.PersistAsync.story.js +1004 -0
- package/build/revamp/stories/dev-tools/SearchFeature.story.js +260 -0
- package/build/revamp/stories/dev-tools/ServerTest.story.js +81 -0
- package/build/revamp/stories/dev-tools/Upload.story.js +221 -0
- package/build/revamp/stories/dev-tools/ValidationAsync.story.js +161 -0
- package/build/revamp/stories/examples/ObjectConst.story.js +153 -0
- package/build/revamp/stories/examples/OneOfInitialisation.story.js +102 -0
- package/build/revamp/stories/utils/fixtureHttpClient.js +130 -0
- package/build/revamp/stories/utils/mockSearchHandler.js +125 -0
- package/build/revamp/stories/visual-tests/VisualTests.story.js +111 -0
- package/build/revamp/test-utils/component-utils.js +19 -0
- package/build/revamp/test-utils/step-utils.js +6 -0
- package/build/revamp/tests/ImageRenderer.spec.js +108 -0
- package/build/revamp/tests/InitialAction.spec.js +299 -0
- package/build/revamp/tests/InitialStep.spec.js +104 -0
- package/build/revamp/tests/Logging.spec.js +112 -0
- package/build/revamp/tests/OneOfInitialisation.spec.js +654 -0
- package/build/revamp/tests/Polling.spec.js +611 -0
- package/build/revamp/tests/RefreshOnChange.ResponseHandling.spec.js +322 -0
- package/build/revamp/tests/RefreshOnChange.with.Tabs.spec.js +390 -0
- package/build/revamp/tests/RefreshOnChangePreserve.spec.js +218 -0
- package/build/revamp/tests/Submission.ResponseHandling.spec.js +697 -0
- package/build/revamp/tests/Submission.spec.js +399 -0
- package/build/revamp/tests/legacy/BackButton.spec.js +189 -0
- package/build/revamp/tests/legacy/HiddenSchemas.spec.js +312 -0
- package/build/revamp/tests/legacy/MultipleFileUploadSchema.spec.js +447 -0
- package/build/revamp/tests/legacy/PersistAsync.blob-schema.spec.js +339 -0
- package/build/revamp/tests/legacy/PersistAsync.string-schema.spec.js +385 -0
- package/build/revamp/tests/legacy/RefreshStepOnChange.debouncing.spec.js +236 -0
- package/build/revamp/tests/legacy/RefreshStepOnChange.spec.js +623 -0
- package/build/revamp/tests/legacy/Search.spec.js +501 -0
- package/build/revamp/tests/legacy/ValidationAsync.spec.js +452 -0
- package/build/revamp/tests/legacy/useExternal.spec.js +235 -0
- package/build/revamp/types.js +1 -0
- package/build/revamp/utils/component-utils.js +86 -0
- package/build/revamp/utils/component-utils.spec.js +385 -0
- package/build/revamp/utils/findComponent.js +29 -0
- package/build/revamp/utils/findComponent.spec.js +92 -0
- package/build/revamp/utils/type-utils.js +56 -0
- package/build/revamp/utils/type-validators.js +16 -0
- package/build/revamp/utils/type-validators.spec.js +163 -0
- package/build/revamp/utils/useStableCallback.js +21 -0
- package/build/revamp/wise/renderers/AlertRenderer.js +11 -0
- package/build/revamp/wise/renderers/BooleanInputRenderer.js +34 -0
- package/build/revamp/wise/renderers/BoxRenderer.js +19 -0
- package/build/revamp/wise/renderers/ButtonRenderer.js +53 -0
- package/build/revamp/wise/renderers/ColumnsRenderer.js +14 -0
- package/build/revamp/wise/renderers/DateInputRenderer.js +35 -0
- package/build/revamp/wise/renderers/DecisionRenderer.js +18 -0
- package/build/revamp/wise/renderers/DividerRenderer.js +10 -0
- package/build/revamp/wise/renderers/FormRenderer.js +10 -0
- package/build/revamp/wise/renderers/FormSectionRenderer.js +16 -0
- package/build/revamp/wise/renderers/HeadingRenderer.js +57 -0
- package/build/revamp/wise/renderers/ImageRenderer.js +112 -0
- package/build/revamp/wise/renderers/InstructionsRenderer.js +23 -0
- package/build/revamp/wise/renderers/IntegerInputRenderer.js +38 -0
- package/build/revamp/wise/renderers/LoadingIndicatorRenderer.js +11 -0
- package/build/revamp/wise/renderers/MarkdownRenderer.js +11 -0
- package/build/revamp/wise/renderers/ModalRenderer.js +25 -0
- package/build/revamp/wise/renderers/MultiUploadInputRenderer.js +63 -0
- package/build/revamp/wise/renderers/NumberInputRenderer.js +38 -0
- package/build/revamp/wise/renderers/ParagraphRenderer.js +45 -0
- package/build/revamp/wise/renderers/RepeatableRenderer.js +58 -0
- package/build/revamp/wise/renderers/ReviewRenderer.js +35 -0
- package/build/revamp/wise/renderers/SearchRenderer/BlockSearchRendererComponent.js +59 -0
- package/build/revamp/wise/renderers/SearchRenderer/ErrorResult.js +11 -0
- package/build/revamp/wise/renderers/SearchRenderer/InlineSearchRendererComponent.js +63 -0
- package/build/revamp/wise/renderers/SearchRenderer/SearchRenderer.js +21 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/OptionMedia.js +16 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/RadioInputRendererComponent.js +14 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectInputRenderer.js +30 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectInputRendererComponent.js +56 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectTriggerMedia.js +16 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/TabInputRendererComponent.js +22 -0
- package/build/revamp/wise/renderers/StatusListRenderer.js +21 -0
- package/build/revamp/wise/renderers/TextInputRenderer.js +35 -0
- package/build/revamp/wise/renderers/UploadInputRenderer.js +136 -0
- package/build/revamp/wise/renderers/components/FieldInput.js +9 -0
- package/build/revamp/wise/renderers/components/Help.js +10 -0
- package/build/revamp/wise/renderers/components/LabelContentWithHelp.js +6 -0
- package/build/revamp/wise/renderers/components/UploadFieldInput.js +14 -0
- package/build/revamp/wise/renderers/components/VariableDateInput.js +30 -0
- package/build/revamp/wise/renderers/components/VariableTextInput.js +69 -0
- package/build/revamp/wise/renderers/components/icon/DynamicIcon.js +17 -0
- package/build/revamp/wise/renderers/components/icon/FlagIcon.js +11 -0
- package/build/revamp/wise/renderers/components/icon/NamedIcon.js +19 -0
- package/build/revamp/wise/renderers/components/icon/NavigationOptionMedia.js +20 -0
- package/build/revamp/wise/renderers/getWiseRenderers.js +57 -0
- package/build/revamp/wise/renderers/hooks/useSnackBarIfAvailable.js +6 -0
- package/build/revamp/wise/renderers/utils/file-utils.js +70 -0
- package/build/revamp/wise/renderers/utils/getRandomId.js +2 -0
- package/build/revamp/wise/renderers/utils/input-utils.js +6 -0
- package/build/revamp/wise/renderers/utils/layout-utils.js +31 -0
- package/build/revamp/wise/renderers/utils/value-utils.js +23 -0
- package/build/revamp/wise/renderers/utils/value-utils.spec.js +33 -0
- package/build/revamp/wise/renderers/validators/type-validators.js +15 -0
- package/build/test-utils/NeptuneProviders.js +23 -0
- package/build/test-utils/fetch-utils.js +104 -0
- package/build/test-utils/index.js +2 -0
- package/build/test-utils/rtl-utils.js +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ArraySchema';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { generateRandomId } from '../../common/utils';
|
|
5
|
+
import { getValidBasicModelOrNull, getValidationFailures, isNull, isUndefined, } from '../../common/validators';
|
|
6
|
+
import { DynamicAlert } from '../../layout';
|
|
7
|
+
import ControlFeedback from '../controlFeedback';
|
|
8
|
+
import Help from '../help';
|
|
9
|
+
import SchemaFormControl from '../schemaFormControl';
|
|
10
|
+
var isNullish = function (value) {
|
|
11
|
+
return isNull(value) || isUndefined(value);
|
|
12
|
+
};
|
|
13
|
+
var getDefaultValue = function (schema) {
|
|
14
|
+
return schema.type === 'boolean' && isNullish(schema.default) ? false : schema.default;
|
|
15
|
+
};
|
|
16
|
+
var BasicTypeSchema = function (props) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
var onChange = function (newModel, _type, metadata) {
|
|
19
|
+
setChanged(true);
|
|
20
|
+
setModelAndBroadcast(sanitiseModel(newModel), 'user', metadata);
|
|
21
|
+
};
|
|
22
|
+
var getValidationKeys = function (newModel) {
|
|
23
|
+
return getValidationFailures(newModel, props.schema, props.required);
|
|
24
|
+
}; // TODO: LOW avoid type assertion
|
|
25
|
+
var setModelAndBroadcast = function (newModel, type, metadata) {
|
|
26
|
+
setModel(newModel);
|
|
27
|
+
var validationKeys = getValidationKeys(newModel);
|
|
28
|
+
setValidations(validationKeys);
|
|
29
|
+
var broadcastModel = newModel;
|
|
30
|
+
setLastModel(broadcastModel);
|
|
31
|
+
if (broadcastModel !== lastModel) {
|
|
32
|
+
props.onChange({
|
|
33
|
+
model: broadcastModel,
|
|
34
|
+
triggerSchema: props.schema,
|
|
35
|
+
triggerModel: broadcastModel,
|
|
36
|
+
lastTriggerModel: lastModel,
|
|
37
|
+
type: type,
|
|
38
|
+
metadata: metadata,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var sanitiseModel = function (newModel) {
|
|
43
|
+
return getValidBasicModelOrNull(newModel, props.schema);
|
|
44
|
+
};
|
|
45
|
+
var onFocus = function () { return setFocused(true); };
|
|
46
|
+
var onBlur = function () {
|
|
47
|
+
setFocused(false);
|
|
48
|
+
setBlurred(true);
|
|
49
|
+
if (props.onBlur) {
|
|
50
|
+
props.onBlur();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var _d = useState((_a = props.model) !== null && _a !== void 0 ? _a : null), model = _d[0], setModel = _d[1];
|
|
54
|
+
var _e = useState((_b = props.model) !== null && _b !== void 0 ? _b : null), lastModel = _e[0], setLastModel = _e[1];
|
|
55
|
+
var _f = useState(false), changed = _f[0], setChanged = _f[1];
|
|
56
|
+
var _g = useState(false), focused = _g[0], setFocused = _g[1];
|
|
57
|
+
var _h = useState(false), blurred = _h[0], setBlurred = _h[1];
|
|
58
|
+
var _j = useState([]), validations = _j[0], setValidations = _j[1];
|
|
59
|
+
var id = useMemo(function () { return props.schema.$id || generateRandomId(); }, [props.schema.$id]);
|
|
60
|
+
var onSchemaChange = function () {
|
|
61
|
+
var defaultValue = getDefaultValue(props.schema);
|
|
62
|
+
// if no model, change to the default, only run this when the schema changes
|
|
63
|
+
if (isNullish(model) && !isNullish(defaultValue)) {
|
|
64
|
+
setModelAndBroadcast(defaultValue, 'init');
|
|
65
|
+
}
|
|
66
|
+
if (props.schema.const) {
|
|
67
|
+
setModelAndBroadcast(props.schema.const, 'init');
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var refreshValidations = function () {
|
|
71
|
+
setValidations(getValidationKeys(model));
|
|
72
|
+
};
|
|
73
|
+
var isConst = props.schema.const;
|
|
74
|
+
var isHidden = props.schema.hidden || isConst;
|
|
75
|
+
useEffect(refreshValidations, [props.model, props.submitted]);
|
|
76
|
+
useEffect(onSchemaChange, [props.schema]);
|
|
77
|
+
useEffect(function () {
|
|
78
|
+
var _a;
|
|
79
|
+
var newModel = (_a = props.model) !== null && _a !== void 0 ? _a : null;
|
|
80
|
+
if (newModel !== model) {
|
|
81
|
+
setModel(newModel);
|
|
82
|
+
}
|
|
83
|
+
}, [props.model]);
|
|
84
|
+
var formGroupClasses = {
|
|
85
|
+
'form-group': true,
|
|
86
|
+
'has-error': ((props.submitted || !changed) && !!props.errors) ||
|
|
87
|
+
((props.submitted || (changed && blurred)) && !!validations.length),
|
|
88
|
+
'has-info': !!props.schema.description || !!props.infoMessage,
|
|
89
|
+
};
|
|
90
|
+
var showLabel = props.schema.format !== 'file' && props.schema.type !== 'boolean';
|
|
91
|
+
var schemaHelp = props.schema.help;
|
|
92
|
+
var feedbackId = "".concat(id, "-feedback");
|
|
93
|
+
return !isHidden ? (_jsxs(_Fragment, { children: [props.schema.alert && _jsx(DynamicAlert, { component: props.schema.alert }), _jsxs("div", { className: classNames(formGroupClasses), children: [showLabel && (_jsxs("div", { className: "d-inline-block m-b-1", children: [_jsx("label", { className: "control-label d-inline", htmlFor: id, children: props.schema.title }), !!schemaHelp && _jsx(Help, { help: schemaHelp })] })), !showLabel && !!schemaHelp && _jsx(Help, { help: schemaHelp }), _jsx(SchemaFormControl, { id: id, schema: props.schema, value: model, disabled: !!props.disabled, onChange: onChange, onFocus: onFocus, onBlur: onBlur, describedBy: feedbackId }), _jsx(ControlFeedback, { id: feedbackId, changed: changed, focused: focused, blurred: blurred, submitted: props.submitted, errors: (_c = props.errors) !== null && _c !== void 0 ? _c : null, schema: props.schema, validations: validations, infoMessage: props.infoMessage })] })] })) : null;
|
|
94
|
+
};
|
|
95
|
+
BasicTypeSchema.defaultProps = {
|
|
96
|
+
required: false,
|
|
97
|
+
disabled: false,
|
|
98
|
+
onBlur: null,
|
|
99
|
+
};
|
|
100
|
+
export default BasicTypeSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './BasicTypeSchema';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { InlineAlert } from '@transferwise/components';
|
|
14
|
+
import { formatDate } from '@transferwise/formatting';
|
|
15
|
+
import { useIntl } from 'react-intl';
|
|
16
|
+
import validationArrayMessages from '../../../common/messages/validation.array.messages';
|
|
17
|
+
import controlFeedbackMessages from '../../../common/messages/validation.messages';
|
|
18
|
+
function ControlFeedback(props) {
|
|
19
|
+
var _a;
|
|
20
|
+
var defaultValidationMessages = useDefaultValidationMessages(props.schema);
|
|
21
|
+
var validationMessages = __assign(__assign(__assign({}, defaultValidationMessages), props.validationMessages), props.schema.validationMessages);
|
|
22
|
+
var isErrorVisible = (props.submitted || !props.changed) && Boolean(props.errors);
|
|
23
|
+
var isValidationVisible = !isErrorVisible &&
|
|
24
|
+
(props.submitted || (props.changed && props.blurred)) &&
|
|
25
|
+
Boolean((_a = props.validations) === null || _a === void 0 ? void 0 : _a.length);
|
|
26
|
+
var isDescriptionVisible = props.schema.type !== 'boolean' &&
|
|
27
|
+
props.schema.description &&
|
|
28
|
+
!isErrorVisible &&
|
|
29
|
+
!isValidationVisible;
|
|
30
|
+
var hasInfoMessage = Boolean(props.infoMessage);
|
|
31
|
+
return (_jsxs("div", { id: props.id, children: [isErrorVisible ? _jsx(InlineAlert, { type: "error", children: props.errors }) : null, isValidationVisible ? (_jsx(InlineAlert, { type: "error", children: props.validations.map(function (validation) { return (_jsx("div", { children: validationMessages[validation] }, validation)); }) })) : null, (isDescriptionVisible || hasInfoMessage) && (_jsxs(InlineAlert, { type: "info", children: [isDescriptionVisible && _jsx("div", { children: props.schema.description }), hasInfoMessage && _jsx("div", { children: props.infoMessage })] }))] }));
|
|
32
|
+
}
|
|
33
|
+
ControlFeedback.defaultProps = {
|
|
34
|
+
errors: '',
|
|
35
|
+
validations: [],
|
|
36
|
+
validationMessages: {},
|
|
37
|
+
validationAsyncSuccessMessage: null,
|
|
38
|
+
};
|
|
39
|
+
// TODO: avoid typre assertions in this function
|
|
40
|
+
function useDefaultValidationMessages(schema) {
|
|
41
|
+
var _a = useIntl(), formatMessage = _a.formatMessage, locale = _a.locale;
|
|
42
|
+
var formattedMessages = {
|
|
43
|
+
type: formatMessage(controlFeedbackMessages.type),
|
|
44
|
+
minimum: formatMessage(controlFeedbackMessages.minimum, {
|
|
45
|
+
minimum: schema.minimum,
|
|
46
|
+
}),
|
|
47
|
+
maximum: formatMessage(controlFeedbackMessages.maximum, {
|
|
48
|
+
maximum: schema.maximum,
|
|
49
|
+
}),
|
|
50
|
+
minLength: formatMessage(controlFeedbackMessages.minLength, {
|
|
51
|
+
minLength: schema.minLength,
|
|
52
|
+
}),
|
|
53
|
+
maxLength: formatMessage(controlFeedbackMessages.maxLength, {
|
|
54
|
+
maxLength: schema.maxLength,
|
|
55
|
+
}),
|
|
56
|
+
minItems: formatMessage(validationArrayMessages.minItemsError, {
|
|
57
|
+
minItems: schema.minItems,
|
|
58
|
+
}),
|
|
59
|
+
maxItems: formatMessage(validationArrayMessages.maxItemsError, {
|
|
60
|
+
maxItems: schema.maxItems,
|
|
61
|
+
}),
|
|
62
|
+
pattern: formatMessage(controlFeedbackMessages.pattern),
|
|
63
|
+
required: formatMessage(controlFeedbackMessages.required),
|
|
64
|
+
};
|
|
65
|
+
if (schema.format === 'date') {
|
|
66
|
+
var dateOverrides = {
|
|
67
|
+
pattern: formatMessage(controlFeedbackMessages.patternDate),
|
|
68
|
+
minimum: schema.minimum
|
|
69
|
+
? formatMessage(controlFeedbackMessages.minimumDate, {
|
|
70
|
+
minimum: formatDate(new Date(schema.minimum), locale, {
|
|
71
|
+
timeZone: 'UTC',
|
|
72
|
+
dateStyle: 'long',
|
|
73
|
+
}),
|
|
74
|
+
})
|
|
75
|
+
: undefined,
|
|
76
|
+
maximum: schema.maximum
|
|
77
|
+
? formatMessage(controlFeedbackMessages.maximumDate, {
|
|
78
|
+
maximum: formatDate(new Date(schema.maximum), locale, {
|
|
79
|
+
timeZone: 'UTC',
|
|
80
|
+
dateStyle: 'long',
|
|
81
|
+
}),
|
|
82
|
+
})
|
|
83
|
+
: undefined,
|
|
84
|
+
};
|
|
85
|
+
return __assign(__assign({}, formattedMessages), dateOverrides);
|
|
86
|
+
}
|
|
87
|
+
return formattedMessages;
|
|
88
|
+
}
|
|
89
|
+
export default ControlFeedback;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ControlFeedback';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { createElement as _createElement } from "react";
|
|
13
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { useEffect } from 'react';
|
|
15
|
+
import { getSchemaType, isBasicError, isNullableBasicModel, isNullableObjectModel, isNullableArrayModel, isNullableStringModel, isObjectModel, isAllOfSchema, isOneOfSchema, isObjectSchema, isArraySchema, isPersistAsyncSchema, isValidationAsyncSchema, isBasicSchema, isOneOfObjectSchema, } from '../../common/utils';
|
|
16
|
+
import AllOfSchema from '../allOfSchema';
|
|
17
|
+
import ArraySchema from '../arrayTypeSchema';
|
|
18
|
+
import BasicTypeSchema from '../basicTypeSchema';
|
|
19
|
+
import ObjectSchema from '../objectSchema';
|
|
20
|
+
import OneOfSchema from '../oneOfSchema';
|
|
21
|
+
import PersistAsyncSchema from '../persistAsyncSchema';
|
|
22
|
+
import PromotedOneOfSchema from '../promotedOneOfSchema';
|
|
23
|
+
import ReadOnlySchema from '../readOnlySchema';
|
|
24
|
+
import ValidationAsyncSchema from '../validationAsyncSchema';
|
|
25
|
+
import { useLogger } from '../../common/contexts';
|
|
26
|
+
function GenericSchemaForm(props) {
|
|
27
|
+
var schema = props.schema, _a = props.model, model = _a === void 0 ? null : _a, _b = props.errors, errors = _b === void 0 ? null : _b, _c = props.hideTitle, hideTitle = _c === void 0 ? false : _c, _d = props.disabled, disabled = _d === void 0 ? false : _d;
|
|
28
|
+
var schemaProps = __assign(__assign({}, props), { model: model, errors: errors, hideTitle: hideTitle, disabled: disabled });
|
|
29
|
+
var type = getSchemaType(schema);
|
|
30
|
+
var log = useLogger();
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
if (!isValidGenericSchema(schema, model, errors)) {
|
|
33
|
+
log.error('Invalid schema or model', "Schema of type ".concat(type || 'undefined', " requested, but schema did not pass validation."));
|
|
34
|
+
}
|
|
35
|
+
}, [JSON.stringify(schema), JSON.stringify(model), JSON.stringify(errors), type, log]);
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
37
|
+
switch (type) {
|
|
38
|
+
case 'readOnly':
|
|
39
|
+
return _jsx(ReadOnlySchema, __assign({}, schemaProps));
|
|
40
|
+
case 'persistAsync':
|
|
41
|
+
return _jsx(PersistAsyncSchema, __assign({}, schemaProps));
|
|
42
|
+
case 'validationAsync':
|
|
43
|
+
return _jsx(ValidationAsyncSchema, __assign({}, schemaProps));
|
|
44
|
+
case 'basic': {
|
|
45
|
+
var basicTypeProps = __assign({ infoMessage: null }, schemaProps);
|
|
46
|
+
return _jsx(BasicTypeSchema, __assign({}, basicTypeProps));
|
|
47
|
+
}
|
|
48
|
+
case 'object':
|
|
49
|
+
return _createElement(ObjectSchema, __assign({}, schemaProps, { key: JSON.stringify(schema) }));
|
|
50
|
+
case 'array':
|
|
51
|
+
return _jsx(ArraySchema, __assign({}, schemaProps));
|
|
52
|
+
case 'promotedOneOf':
|
|
53
|
+
return _jsx(PromotedOneOfSchema, __assign({}, schemaProps));
|
|
54
|
+
case 'oneOf':
|
|
55
|
+
return _jsx(OneOfSchema, __assign({}, schemaProps));
|
|
56
|
+
case 'allOf':
|
|
57
|
+
return _jsx(AllOfSchema, __assign({}, schemaProps));
|
|
58
|
+
}
|
|
59
|
+
return _jsx(_Fragment, {});
|
|
60
|
+
}
|
|
61
|
+
export default GenericSchemaForm;
|
|
62
|
+
// TODO: MC-3224 - We want to implement proper schema validation
|
|
63
|
+
var isValidGenericSchema = function (schema, model, errors) {
|
|
64
|
+
var type = getSchemaType(schema);
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
66
|
+
switch (type) {
|
|
67
|
+
case 'persistAsync':
|
|
68
|
+
return isPersistAsyncSchema(schema) && isNullableStringModel(model) && isBasicError(errors);
|
|
69
|
+
case 'validationAsync':
|
|
70
|
+
return isValidationAsyncSchema(schema) && isNullableBasicModel(model) && isBasicError(errors);
|
|
71
|
+
case 'basic':
|
|
72
|
+
return isBasicSchema(schema) && isNullableBasicModel(model) && isBasicError(errors);
|
|
73
|
+
case 'object':
|
|
74
|
+
return isObjectSchema(schema) && isNullableObjectModel(model);
|
|
75
|
+
case 'array':
|
|
76
|
+
return isArraySchema(schema) && isNullableArrayModel(model) && isBasicError(errors);
|
|
77
|
+
case 'promotedOneOf':
|
|
78
|
+
return isOneOfObjectSchema(schema) && isNullableObjectModel(model);
|
|
79
|
+
case 'oneOf':
|
|
80
|
+
return isOneOfSchema(schema);
|
|
81
|
+
case 'allOf':
|
|
82
|
+
return isAllOfSchema(schema) && isObjectModel(model);
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as loggingModule from '../../common/contexts/logContext/LogContext';
|
|
14
|
+
import { mockUseLogger, renderWithProviders } from '../../test-utils';
|
|
15
|
+
import GenericSchemaForm from './GenericSchema';
|
|
16
|
+
var mockLogger = mockUseLogger();
|
|
17
|
+
jest.spyOn(loggingModule, 'useLogger').mockImplementation(function () { return mockLogger; });
|
|
18
|
+
beforeEach(function () {
|
|
19
|
+
Object.values(mockLogger).forEach(function (logger) { return logger.mockClear(); });
|
|
20
|
+
});
|
|
21
|
+
describe('GenericSchema', function () {
|
|
22
|
+
var getProps = function () { return ({
|
|
23
|
+
schema: { type: 'string' },
|
|
24
|
+
model: null,
|
|
25
|
+
errors: null,
|
|
26
|
+
submitted: false,
|
|
27
|
+
onChange: jest.fn(),
|
|
28
|
+
onPersistAsync: jest.fn(),
|
|
29
|
+
}); };
|
|
30
|
+
describe('when an invalid schema-model combination is supplied', function () {
|
|
31
|
+
var getSchema = function () { return ({
|
|
32
|
+
$id: 'id',
|
|
33
|
+
type: 'string',
|
|
34
|
+
title: 'String Schema A',
|
|
35
|
+
}); };
|
|
36
|
+
var getModel = function () { return ({ name: 'Bob' }); };
|
|
37
|
+
it('logs an error', function () {
|
|
38
|
+
var consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
39
|
+
renderWithProviders(_jsx(GenericSchemaForm, __assign({}, getProps(), { schema: getSchema(), model: getModel() })));
|
|
40
|
+
expect(mockLogger.error).toHaveBeenCalledWith('Invalid schema or model', expect.anything());
|
|
41
|
+
expect(mockLogger.error).toHaveBeenCalledTimes(1);
|
|
42
|
+
consoleWarnSpy.mockRestore();
|
|
43
|
+
});
|
|
44
|
+
describe('when the component is re-rendered with an identical schema', function () {
|
|
45
|
+
it('only logs an error one time', function () {
|
|
46
|
+
var consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
47
|
+
var rerender = renderWithProviders(_jsx(GenericSchemaForm, __assign({}, getProps(), { schema: getSchema(), model: getModel() }))).rerender;
|
|
48
|
+
expect(mockLogger.error).toHaveBeenCalledTimes(1);
|
|
49
|
+
rerender(_jsx(GenericSchemaForm, __assign({}, getProps(), { schema: getSchema(), model: getModel() })));
|
|
50
|
+
expect(mockLogger.error).toHaveBeenCalledTimes(1);
|
|
51
|
+
consoleWarnSpy.mockRestore();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './GenericSchema';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Markdown, Info } from '@transferwise/components';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import helpMessages from '../../../common/messages/help.messages';
|
|
5
|
+
function Help(props) {
|
|
6
|
+
var intl = useIntl();
|
|
7
|
+
return (_jsx(Info, { className: "m-l-1", content: _jsx(Markdown, { config: { link: { target: '_blank' } }, children: props.help.markdown }), presentation: "POPOVER", size: "sm", "aria-label": intl.formatMessage(helpMessages.helpAria) }));
|
|
8
|
+
}
|
|
9
|
+
export default Help;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Help';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './JsonSchemaForm';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
+
import { Header } from '@transferwise/components';
|
|
23
|
+
import classNames from 'classnames';
|
|
24
|
+
import { useState, useEffect } from 'react';
|
|
25
|
+
import { isEqual } from '../../common/utils';
|
|
26
|
+
import { getValidObjectModelParts } from '../../common/validators';
|
|
27
|
+
import { DynamicAlert } from '../../layout';
|
|
28
|
+
import GenericSchema from '../genericSchema';
|
|
29
|
+
var getSchemaColumnClasses = function (width) { return ({
|
|
30
|
+
'col-xs-12': true,
|
|
31
|
+
'col-sm-6': width === 'md',
|
|
32
|
+
'col-sm-4': width === 'sm',
|
|
33
|
+
}); };
|
|
34
|
+
function ObjectSchema(props) {
|
|
35
|
+
var _a = useState(function () { return (__assign({}, getValidObjectModelParts(props.model, props.schema))); }), model = _a[0], setModel = _a[1];
|
|
36
|
+
var onChangeProperty = function (propertyName, onChangeProps) {
|
|
37
|
+
if (onChangeProps.model !== null) {
|
|
38
|
+
// FIXME we should not mutate the model here
|
|
39
|
+
model[propertyName] = onChangeProps.model;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
43
|
+
delete model[propertyName];
|
|
44
|
+
}
|
|
45
|
+
setModel(model);
|
|
46
|
+
props.onChange(__assign(__assign({}, onChangeProps), { model: model }));
|
|
47
|
+
};
|
|
48
|
+
var isRequired = function (propertyName) {
|
|
49
|
+
return props.schema.required && props.schema.required.includes(propertyName);
|
|
50
|
+
};
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
// When the schema changes, only retain valid parts of the model
|
|
53
|
+
var newModel = getValidObjectModelParts(model, props.schema) || {};
|
|
54
|
+
setModel(newModel);
|
|
55
|
+
if (!isEqual(newModel, model)) {
|
|
56
|
+
props.onChange({
|
|
57
|
+
model: newModel,
|
|
58
|
+
triggerSchema: props.schema,
|
|
59
|
+
triggerModel: newModel,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [props.schema]);
|
|
63
|
+
var allorderedPropertiesSet = new Set(__spreadArray(__spreadArray([], (props.schema.displayOrder || []), true), Object.keys(props.schema.properties), true));
|
|
64
|
+
var isPropertyDefined = function (propertyName) {
|
|
65
|
+
return typeof props.schema.properties[propertyName] !== 'undefined';
|
|
66
|
+
};
|
|
67
|
+
// eslint-disable-next-line unicorn/prefer-spread
|
|
68
|
+
var orderedPropertyNames = Array.from(allorderedPropertiesSet).filter(isPropertyDefined);
|
|
69
|
+
// TODO: LOW avoid type assertion -- what happens when props.errors is not an object?
|
|
70
|
+
var propsErrors = props.errors;
|
|
71
|
+
return (_jsxs(_Fragment, { children: [props.schema.alert && _jsx(DynamicAlert, { component: props.schema.alert }), _jsxs("fieldset", { children: [props.schema.title && !props.hideTitle && (_jsx(Header, { title: props.schema.title, as: "legend" })), props.schema.description && !props.hideTitle && _jsxs("p", { children: [" ", props.schema.description, " "] }), _jsx("div", { className: "row", children: orderedPropertyNames.map(function (propertyName) { return (_jsx("div", { className: classNames(getSchemaColumnClasses(props.schema.properties[propertyName].width)), children: _jsx(GenericSchema, { schema: props.schema.properties[propertyName], model: props.model && props.model[propertyName], errors: propsErrors === null || propsErrors === void 0 ? void 0 : propsErrors[propertyName], submitted: props.submitted, required: isRequired(propertyName), disabled: props.disabled, onChange: function (onChangeProps) { return onChangeProperty(propertyName, onChangeProps); }, onPersistAsync: props.onPersistAsync }) }, propertyName)); }) })] })] }));
|
|
72
|
+
}
|
|
73
|
+
ObjectSchema.defaultProps = {
|
|
74
|
+
hideTitle: false,
|
|
75
|
+
disabled: false,
|
|
76
|
+
};
|
|
77
|
+
export default ObjectSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ObjectSchema';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
+
import { Header } from '@transferwise/components';
|
|
23
|
+
import classNames from 'classnames';
|
|
24
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
25
|
+
import { useEventDispatcher } from '../../common/contexts';
|
|
26
|
+
import { useDebouncedFunction } from '../../common/hooks';
|
|
27
|
+
import { generateRandomId, isConstSchema, isNoNConstSchema } from '../../common/utils';
|
|
28
|
+
import { getValidModelParts, getValidationFailures, isArray, isEmpty, } from '../../common/validators';
|
|
29
|
+
import { DynamicAlert } from '../../layout';
|
|
30
|
+
import ControlFeedback from '../controlFeedback';
|
|
31
|
+
import GenericSchema from '../genericSchema';
|
|
32
|
+
import Help from '../help';
|
|
33
|
+
import SchemaFormControl from '../schemaFormControl';
|
|
34
|
+
import { getActiveSchemaIndex, getValidIndexFromValue } from './utils';
|
|
35
|
+
function OneOfSchema(props) {
|
|
36
|
+
var onEvent = useEventDispatcher();
|
|
37
|
+
var _a = useState(false), changed = _a[0], setChanged = _a[1];
|
|
38
|
+
var _b = useState(false), focused = _b[0], setFocused = _b[1];
|
|
39
|
+
var _c = useState(false), blurred = _c[0], setBlurred = _c[1];
|
|
40
|
+
var id = useMemo(function () { return props.schema.$id || generateRandomId(); }, [props.schema.$id]);
|
|
41
|
+
var _d = useState(getActiveSchemaIndex(props.schema, props.model)), schemaIndex = _d[0], setSchemaIndex = _d[1];
|
|
42
|
+
var _e = useState(getModelPartsForSchemas(props.model, props.schema.oneOf)), models = _e[0], setModels = _e[1];
|
|
43
|
+
var debouncedTrackEvent = useDebouncedFunction(onEvent, 200);
|
|
44
|
+
var onSearchChange = function (searchValue) {
|
|
45
|
+
debouncedTrackEvent('Dynamic Flow - OneOf Searched', {
|
|
46
|
+
oneOfId: props.schema.analyticsId,
|
|
47
|
+
searchValueLength: searchValue.length,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
// When the schema we receive from parent changes
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
var modelIndex = getValidIndexFromValue(props.schema, props.model);
|
|
53
|
+
var defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
|
|
54
|
+
if (modelIndex === -1 && defaultIndex >= 0) {
|
|
55
|
+
onChooseNewSchema(defaultIndex, 'init');
|
|
56
|
+
}
|
|
57
|
+
}, [props.schema]);
|
|
58
|
+
if (!isArray(props.schema.oneOf)) {
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.error('Incorrect format', props.schema);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
var onChildModelChange = function (index, onChangeParameters) {
|
|
64
|
+
setModels(__spreadArray(__spreadArray(__spreadArray([], models.slice(0, index), true), [onChangeParameters.model], false), models.slice(index + 1), true));
|
|
65
|
+
setChanged(true);
|
|
66
|
+
props.onChange(onChangeParameters);
|
|
67
|
+
};
|
|
68
|
+
var onFocus = function () {
|
|
69
|
+
setFocused(true);
|
|
70
|
+
};
|
|
71
|
+
var onBlur = function () {
|
|
72
|
+
setFocused(false);
|
|
73
|
+
setBlurred(true);
|
|
74
|
+
};
|
|
75
|
+
// TODO: LOW avoid type assertion
|
|
76
|
+
var onChooseNewSchema = function (index, type, metadata) {
|
|
77
|
+
setSchemaIndex(index);
|
|
78
|
+
var newSchema = props.schema.oneOf[index];
|
|
79
|
+
if (isConstSchema(newSchema)) {
|
|
80
|
+
// If new schema is a const we want to share the parent schema, not the const
|
|
81
|
+
var model = newSchema.const;
|
|
82
|
+
props.onChange({
|
|
83
|
+
model: model,
|
|
84
|
+
triggerSchema: props.schema,
|
|
85
|
+
triggerModel: model,
|
|
86
|
+
type: type,
|
|
87
|
+
metadata: metadata,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
props.onChange({
|
|
92
|
+
model: models[index],
|
|
93
|
+
triggerSchema: newSchema,
|
|
94
|
+
triggerModel: models[index],
|
|
95
|
+
type: type,
|
|
96
|
+
metadata: metadata,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (type !== 'init' && props.schema.analyticsId) {
|
|
100
|
+
onEvent('Dynamic Flow - OneOf Selected', {
|
|
101
|
+
oneOfId: props.schema.analyticsId,
|
|
102
|
+
schemaId: newSchema === null || newSchema === void 0 ? void 0 : newSchema.analyticsId,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var schemaForSelect = mapSchemasForSelect(props.schema);
|
|
107
|
+
var validations = getValidations(props, schemaIndex);
|
|
108
|
+
var formGroupClasses = {
|
|
109
|
+
'form-group': true,
|
|
110
|
+
'has-error': (!changed && props.errors && !isEmpty(props.errors)) ||
|
|
111
|
+
((props.submitted || (changed && blurred)) && validations.length),
|
|
112
|
+
};
|
|
113
|
+
var feedbackId = "".concat(id, "-feedback");
|
|
114
|
+
return (_jsxs(_Fragment, { children: [(props.schema.oneOf.length > 1 || isConstSchema(props.schema.oneOf[0])) && (_jsxs(_Fragment, { children: [props.schema.alert && _jsx(DynamicAlert, { component: props.schema.alert }), _jsxs("div", { className: classNames(formGroupClasses), children: [getTitleAndHelp(props.schema, id), _jsx(SchemaFormControl, { id: id, schema: schemaForSelect, value: schemaIndex, disabled: props.disabled, describedBy: feedbackId, onChange: onChooseNewSchema, onFocus: onFocus, onBlur: onBlur, onSearchChange: onSearchChange }), _jsx(ControlFeedback, { id: feedbackId, changed: changed, focused: focused, blurred: blurred, submitted: props.submitted, errors: errorsToString(props.errors), schema: props.schema, validations: validations, infoMessage: null })] })] })), isNoNConstSchema(props.schema.oneOf[schemaIndex]) && (_jsx(GenericSchema, { schema: props.schema.oneOf[schemaIndex], model: models[schemaIndex], errors: props.errors, submitted: props.submitted, hideTitle: true, disabled: props.disabled, onChange: function (parameters) { return onChildModelChange(schemaIndex, parameters); }, onPersistAsync: props.onPersistAsync }))] }));
|
|
115
|
+
}
|
|
116
|
+
function getTitleAndHelp(schema, forId) {
|
|
117
|
+
var _a;
|
|
118
|
+
var helpElement = schema.help ? _jsx(Help, { help: schema.help }) : null;
|
|
119
|
+
var titleElement = isConstSchema(schema.oneOf[0]) ? (_jsx("div", { className: "m-b-1", children: _jsxs("label", { className: "control-label d-inline", htmlFor: forId, children: [schema.title, " ", helpElement] }) })) : (_jsx(_Fragment, { children: helpElement ? (_jsxs("h4", { className: "m-b-2", children: [schema.title, " ", helpElement] })) : (_jsx(Header, { title: (_a = schema.title) !== null && _a !== void 0 ? _a : '' })) }));
|
|
120
|
+
return schema.title ? titleElement : helpElement;
|
|
121
|
+
}
|
|
122
|
+
function getValidations(props, schemaIndex) {
|
|
123
|
+
var selectedSchema = props.schema.oneOf[schemaIndex !== null && schemaIndex !== void 0 ? schemaIndex : -1];
|
|
124
|
+
if (isConstSchema(selectedSchema)) {
|
|
125
|
+
return getValidationFailures(selectedSchema.const, props.schema, Boolean(props.required));
|
|
126
|
+
}
|
|
127
|
+
if (schemaIndex === null || schemaIndex < 0) {
|
|
128
|
+
return getValidationFailures(null, props.schema, Boolean(props.required));
|
|
129
|
+
}
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
function errorsToString(errors) {
|
|
133
|
+
// When oneOf represents a select, errors should be of type string
|
|
134
|
+
if (typeof errors === 'string') {
|
|
135
|
+
return errors;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
function getModelPartsForSchemas(model, schemas) {
|
|
140
|
+
return schemas.map(function (schema) { return getValidModelParts(model, schema); });
|
|
141
|
+
}
|
|
142
|
+
// We want our model to be the index, so alter the oneOf schemas to be a const
|
|
143
|
+
function mapSchemasForSelect(schema) {
|
|
144
|
+
return __assign(__assign({}, schema), { oneOf: schema.oneOf.map(mapOneOfToConst) });
|
|
145
|
+
}
|
|
146
|
+
function mapOneOfToConst(schema, index) {
|
|
147
|
+
var title = schema.title, description = schema.description, _a = schema.disabled, disabled = _a === void 0 ? false : _a, icon = schema.icon, image = schema.image, keywords = schema.keywords;
|
|
148
|
+
// TODO LOW avoid type assertion below -- consider adding { type: 'integer' }
|
|
149
|
+
return { title: title, description: description, disabled: disabled, icon: icon, image: image, const: index, keywords: keywords };
|
|
150
|
+
}
|
|
151
|
+
OneOfSchema.defaultProps = {
|
|
152
|
+
required: false,
|
|
153
|
+
disabled: false,
|
|
154
|
+
};
|
|
155
|
+
export default OneOfSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './OneOfSchema';
|