@wise/dynamic-flow-client 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.js +9606 -0
- package/build/main.min.js +31 -0
- package/build/types/index.d.ts +11 -15
- package/build/types/types/index.d.ts +15 -0
- package/package.json +6 -5
- package/build/common/constants/DateMode.js +0 -7
- package/build/common/constants/FormControlType.js +0 -20
- package/build/common/constants/MonthFormat.js +0 -7
- package/build/common/constants/SchemaType.js +0 -14
- package/build/common/constants/Size.js +0 -10
- package/build/common/constants/index.js +0 -21
- package/build/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +0 -29
- package/build/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +0 -19
- package/build/common/contexts/eventsContext/EventsContext.js +0 -22
- package/build/common/contexts/fetcherContexts/FetcherContexts.js +0 -29
- package/build/common/contexts/index.js +0 -20
- package/build/common/contexts/logContext/LogContext.js +0 -27
- package/build/common/hooks/index.js +0 -23
- package/build/common/hooks/useDebouncedFunction/useDebouncedFunction.js +0 -13
- package/build/common/hooks/useExternal/useExternal.js +0 -19
- package/build/common/hooks/useExternalStepPolling/useExternalStepPolling.js +0 -62
- package/build/common/hooks/usePersistAsync/usePersistAsync.js +0 -98
- package/build/common/hooks/usePolling/usePolling.js +0 -52
- package/build/common/hooks/usePrevious/usePrevious.js +0 -12
- package/build/common/hooks/useStepPolling/useStepPolling.js +0 -49
- package/build/common/makeFetcher/index.js +0 -17
- package/build/common/makeFetcher/makeFetcher.js +0 -23
- package/build/common/messages.js +0 -10
- package/build/common/utils/api-utils.js +0 -19
- package/build/common/utils/date-utils.js +0 -27
- package/build/common/utils/debounce.js +0 -38
- package/build/common/utils/file-utils.js +0 -38
- package/build/common/utils/id-utils.js +0 -8
- package/build/common/utils/index.js +0 -24
- package/build/common/utils/is-equal.js +0 -25
- package/build/common/utils/schema-utils.js +0 -55
- package/build/common/utils/step-utils.js +0 -47
- package/build/common/validators/index.js +0 -28
- package/build/common/validators/models/model-validators.js +0 -69
- package/build/common/validators/models/models.utils.js +0 -117
- package/build/common/validators/schemas/schema-validators.js +0 -99
- package/build/common/validators/types/type-validators.js +0 -21
- package/build/common/validators/validationFailures/validation-failures.js +0 -151
- package/build/common/validators/validationFailures/validation-failures.utils.js +0 -49
- package/build/common/validators/values/value-validators.js +0 -7
- package/build/dynamicFlow/DynamicFlow.js +0 -250
- package/build/dynamicFlow/DynamicFlowStep.js +0 -25
- package/build/dynamicFlow/DynamicFlowTypes.js +0 -8
- package/build/dynamicFlow/index.js +0 -8
- package/build/dynamicFlow/stories/DynamicFlow.story.js +0 -36
- package/build/dynamicFlow/stories/EditableDynamicFlow.js +0 -54
- package/build/dynamicFlow/stories/fixtureFetcher.js +0 -60
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.js +0 -29
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.js +0 -15
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.js +0 -18
- package/build/dynamicFlow/utils/index.js +0 -26
- package/build/dynamicFlow/utils/responseParsers/response-parsers.js +0 -66
- package/build/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +0 -27
- package/build/dynamicFlow/utils/useDynamicFlowState.js +0 -91
- package/build/dynamicFlow/utils/useLoader.js +0 -15
- package/build/fixtures/components/alert.js +0 -33
- package/build/fixtures/components/box.js +0 -22
- package/build/fixtures/components/button.js +0 -56
- package/build/fixtures/components/columns.js +0 -38
- package/build/fixtures/components/copyable.js +0 -24
- package/build/fixtures/components/decision.js +0 -56
- package/build/fixtures/components/heading.js +0 -16
- package/build/fixtures/components/image.js +0 -25
- package/build/fixtures/components/index.js +0 -32
- package/build/fixtures/components/info.js +0 -35
- package/build/fixtures/components/list.js +0 -36
- package/build/fixtures/components/loading-indicator.js +0 -18
- package/build/fixtures/components/paragraph.js +0 -30
- package/build/fixtures/components/review.js +0 -62
- package/build/fixtures/examples/camera-capture.js +0 -123
- package/build/fixtures/examples/index.js +0 -16
- package/build/fixtures/examples/recipient-update.js +0 -252
- package/build/fixtures/examples/recipient.js +0 -315
- package/build/fixtures/examples/single-file-upload.js +0 -100
- package/build/fixtures/examples/step-validation-errors.js +0 -77
- package/build/fixtures/features/action-response.js +0 -31
- package/build/fixtures/features/external.js +0 -33
- package/build/fixtures/features/index.js +0 -16
- package/build/fixtures/features/persist-async.js +0 -46
- package/build/fixtures/features/polling.js +0 -35
- package/build/fixtures/features/validation-async.js +0 -40
- package/build/fixtures/index.js +0 -38
- package/build/fixtures/jsonSchemaForm/allOf.js +0 -121
- package/build/fixtures/jsonSchemaForm/audRecipient.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/audRecipient.js +0 -1106
- package/build/fixtures/jsonSchemaForm/currency.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/currency.js +0 -50
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.js +0 -39
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.js +0 -38
- package/build/fixtures/jsonSchemaForm/oneOf.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/oneOf.js +0 -121
- package/build/fixtures/jsonSchemaForm/oneOfTabs.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/oneOfTabs.js +0 -55
- package/build/fixtures/jsonSchemaForm/promotedOneOf.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/promotedOneOf.js +0 -58
- package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.js +0 -104
- package/build/fixtures/jsonSchemaForm/simple.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/simple.js +0 -50
- package/build/fixtures/jsonSchemaForm/uploadPersistAsync.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/uploadPersistAsync.js +0 -73
- package/build/fixtures/jsonSchemaForm/validationAsync.d.ts +0 -3
- package/build/fixtures/jsonSchemaForm/validationAsync.js +0 -25
- package/build/fixtures/layouts/all.js +0 -178
- package/build/fixtures/layouts/final-step-layout.js +0 -41
- package/build/fixtures/layouts/index.js +0 -18
- package/build/fixtures/layouts/list.js +0 -35
- package/build/fixtures/layouts/pay-in.js +0 -99
- package/build/fixtures/layouts/review.js +0 -162
- package/build/fixtures/layouts/success.js +0 -68
- package/build/fixtures/responses/action-response-final.js +0 -26
- package/build/fixtures/responses/action.js +0 -4
- package/build/fixtures/responses/exit.js +0 -4
- package/build/fixtures/responses/index.js +0 -14
- package/build/fixtures/responses/recipient-update-final.js +0 -26
- package/build/fixtures/schemas/basic-form.js +0 -41
- package/build/fixtures/schemas/index.js +0 -14
- package/build/fixtures/schemas/number-and-integer.js +0 -43
- package/build/fixtures/schemas/one-of.js +0 -222
- package/build/fixtures/schemas/string-formats.js +0 -64
- package/build/fixtures/utils/image-util.js +0 -22
- package/build/formControl/FormControl.js +0 -213
- package/build/formControl/index.js +0 -8
- package/build/formControl/utils/index.js +0 -17
- package/build/formControl/utils/value-utils.js +0 -111
- package/build/i18n/index.js +0 -36
- package/build/index.d.ts +0 -11
- package/build/index.js +0 -38
- package/build/jsonSchemaForm/JsonSchemaForm.js +0 -22
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +0 -46
- package/build/jsonSchemaForm/allOfSchema/index.js +0 -8
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +0 -19
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +0 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +0 -8
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +0 -86
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +0 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +0 -8
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +0 -18
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +0 -38
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +0 -20
- package/build/jsonSchemaForm/arrayTypeSchema/index.js +0 -8
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +0 -91
- package/build/jsonSchemaForm/basicTypeSchema/index.js +0 -8
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +0 -73
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +0 -55
- package/build/jsonSchemaForm/controlFeedback/index.js +0 -8
- package/build/jsonSchemaForm/genericSchema/GenericSchema.js +0 -118
- package/build/jsonSchemaForm/genericSchema/index.js +0 -8
- package/build/jsonSchemaForm/help/Help.js +0 -14
- package/build/jsonSchemaForm/help/Help.messages.js +0 -10
- package/build/jsonSchemaForm/help/index.js +0 -8
- package/build/jsonSchemaForm/index.js +0 -8
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +0 -62
- package/build/jsonSchemaForm/objectSchema/index.js +0 -8
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +0 -135
- package/build/jsonSchemaForm/oneOfSchema/index.js +0 -8
- package/build/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.js +0 -13
- package/build/jsonSchemaForm/oneOfSchema/utils/index.js +0 -18
- package/build/jsonSchemaForm/oneOfSchema/utils/one-of-utils.js +0 -69
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +0 -20
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +0 -10
- package/build/jsonSchemaForm/persistAsyncSchema/index.js +0 -8
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +0 -119
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +0 -8
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +0 -66
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +0 -36
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +0 -8
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +0 -58
- package/build/jsonSchemaForm/promotedOneOfSchema/index.js +0 -8
- package/build/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +0 -12
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +0 -18
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +0 -25
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +0 -23
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +0 -58
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +0 -15
- package/build/jsonSchemaForm/readOnlySchema/index.js +0 -8
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +0 -98
- package/build/jsonSchemaForm/schemaFormControl/index.js +0 -8
- package/build/jsonSchemaForm/schemaFormControl/utils/currency-utils.js +0 -77
- package/build/jsonSchemaForm/schemaFormControl/utils/index.js +0 -17
- package/build/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +0 -110
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +0 -89
- package/build/jsonSchemaForm/validationAsyncSchema/index.js +0 -8
- package/build/layout/DynamicLayout.js +0 -52
- package/build/layout/alert/DynamicAlert.js +0 -31
- package/build/layout/box/DynamicBox.js +0 -32
- package/build/layout/button/DynamicButton.js +0 -49
- package/build/layout/columns/DynamicColumns.js +0 -29
- package/build/layout/decision/DynamicDecision.js +0 -29
- package/build/layout/divider/DynamicDivider.js +0 -10
- package/build/layout/external/DynamicExternal.js +0 -25
- package/build/layout/external/DynamicExternal.messages.js +0 -10
- package/build/layout/form/DynamicForm.js +0 -16
- package/build/layout/heading/DynamicHeading.js +0 -22
- package/build/layout/icon/DynamicIcon.js +0 -49
- package/build/layout/image/DynamicImage.js +0 -62
- package/build/layout/index.js +0 -40
- package/build/layout/info/DynamicInfo.js +0 -9
- package/build/layout/list/DynamicList.js +0 -21
- package/build/layout/loadingIndicator/DynamicLoadingIndicator.js +0 -12
- package/build/layout/paragraph/DynamicParagraph.js +0 -30
- package/build/layout/paragraph/DynamicParagraph.messages.js +0 -15
- package/build/layout/paragraph/useSnackBarIfAvailable.js +0 -13
- package/build/layout/review/DynamicReview.js +0 -23
- package/build/layout/utils.js +0 -33
- package/build/step/cameraStep/CameraStep.js +0 -84
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +0 -70
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +0 -20
- package/build/step/cameraStep/cameraCapture/components/index.js +0 -18
- package/build/step/cameraStep/cameraCapture/hooks/index.js +0 -29
- package/build/step/cameraStep/cameraCapture/index.js +0 -8
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +0 -68
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +0 -13
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +0 -15
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +0 -14
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +0 -20
- package/build/step/cameraStep/cameraCapture/screens/index.js +0 -10
- package/build/step/cameraStep/cameraCapture/tracking/index.js +0 -22
- package/build/step/cameraStep/cameraCapture/utils/index.js +0 -51
- package/build/step/cameraStep/index.js +0 -8
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +0 -68
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +0 -25
- package/build/step/externalConfirmationStep/index.js +0 -8
- package/build/step/index.js +0 -12
- package/build/step/layoutStep/LayoutStep.js +0 -35
- package/build/step/layoutStep/index.js +0 -8
- package/build/step/layoutStep/utils/index.js +0 -7
- package/build/step/layoutStep/utils/inline-reference-utils.js +0 -78
- package/build/step/layoutStep/utils/layout-utils.js +0 -203
- package/build/types/common/FormControl.js +0 -2
- package/build/types/index.js +0 -42
- package/build/types/specification/Action.js +0 -2
- package/build/types/specification/FileUploadSchema.js +0 -8
- package/build/types/specification/LayoutComponent.js +0 -2
- package/build/types/specification/Model.js +0 -30
- package/build/types/specification/PersistAsync.js +0 -2
- package/build/types/specification/Polling.js +0 -2
- package/build/types/specification/Promotion.js +0 -2
- package/build/types/specification/Schema.js +0 -67
- package/build/types/specification/Step.js +0 -6
- package/build/types/specification/ValidationAsync.js +0 -2
- package/build/types/specification/core.js +0 -2
- /package/build/{common → types/common}/constants/DateMode.d.ts +0 -0
- /package/build/{common → types/common}/constants/FormControlType.d.ts +0 -0
- /package/build/{common → types/common}/constants/MonthFormat.d.ts +0 -0
- /package/build/{common → types/common}/constants/SchemaType.d.ts +0 -0
- /package/build/{common → types/common}/constants/Size.d.ts +0 -0
- /package/build/{common → types/common}/constants/index.d.ts +0 -0
- /package/build/{common → types/common}/contexts/dynamicFlowContexts/DynamicFlowContexts.d.ts +0 -0
- /package/build/{common → types/common}/contexts/dynamicFlowContexts/usePendingPromiseCounter.d.ts +0 -0
- /package/build/{common → types/common}/contexts/eventsContext/EventsContext.d.ts +0 -0
- /package/build/{common → types/common}/contexts/fetcherContexts/FetcherContexts.d.ts +0 -0
- /package/build/{common → types/common}/contexts/index.d.ts +0 -0
- /package/build/{common → types/common}/contexts/logContext/LogContext.d.ts +0 -0
- /package/build/{common → types/common}/hooks/index.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useDebouncedFunction/useDebouncedFunction.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useExternal/useExternal.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useExternalStepPolling/useExternalStepPolling.d.ts +0 -0
- /package/build/{common → types/common}/hooks/usePersistAsync/usePersistAsync.d.ts +0 -0
- /package/build/{common → types/common}/hooks/usePolling/usePolling.d.ts +0 -0
- /package/build/{common → types/common}/hooks/usePrevious/usePrevious.d.ts +0 -0
- /package/build/{common → types/common}/hooks/useStepPolling/useStepPolling.d.ts +0 -0
- /package/build/{common → types/common}/makeFetcher/index.d.ts +0 -0
- /package/build/{common → types/common}/makeFetcher/makeFetcher.d.ts +0 -0
- /package/build/{common → types/common}/messages.d.ts +0 -0
- /package/build/{common → types/common}/utils/api-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/date-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/debounce.d.ts +0 -0
- /package/build/{common → types/common}/utils/file-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/id-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/index.d.ts +0 -0
- /package/build/{common → types/common}/utils/is-equal.d.ts +0 -0
- /package/build/{common → types/common}/utils/schema-utils.d.ts +0 -0
- /package/build/{common → types/common}/utils/step-utils.d.ts +0 -0
- /package/build/{common → types/common}/validators/index.d.ts +0 -0
- /package/build/{common → types/common}/validators/models/model-validators.d.ts +0 -0
- /package/build/{common → types/common}/validators/models/models.utils.d.ts +0 -0
- /package/build/{common → types/common}/validators/schemas/schema-validators.d.ts +0 -0
- /package/build/{common → types/common}/validators/types/type-validators.d.ts +0 -0
- /package/build/{common → types/common}/validators/validationFailures/validation-failures.d.ts +0 -0
- /package/build/{common → types/common}/validators/validationFailures/validation-failures.utils.d.ts +0 -0
- /package/build/{common → types/common}/validators/values/value-validators.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/DynamicFlow.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/DynamicFlowStep.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/DynamicFlowTypes.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/index.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/stories/DynamicFlow.story.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/stories/EditableDynamicFlow.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/stories/fixtureFetcher.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/errorBoundary/ErrorBoundary.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/errorBoundary/ErrorBoundary.messages.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/errorBoundary/ErrorBoundaryAlert.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/index.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/responseParsers/response-parsers.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/useDebouncedRefresh/useDebouncedRefresh.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/useDynamicFlowState.d.ts +0 -0
- /package/build/{dynamicFlow → types/dynamicFlow}/utils/useLoader.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/alert.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/box.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/button.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/columns.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/copyable.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/decision.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/heading.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/image.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/info.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/list.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/loading-indicator.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/paragraph.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/components/review.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/camera-capture.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/recipient-update.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/recipient.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/single-file-upload.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/examples/step-validation-errors.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/action-response.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/external.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/persist-async.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/polling.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/features/validation-async.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/jsonSchemaForm/allOf.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/all.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/final-step-layout.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/list.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/pay-in.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/review.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/layouts/success.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/action-response-final.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/action.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/exit.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/responses/recipient-update-final.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/basic-form.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/index.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/number-and-integer.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/one-of.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/schemas/string-formats.d.ts +0 -0
- /package/build/{fixtures → types/fixtures}/utils/image-util.d.ts +0 -0
- /package/build/{formControl → types/formControl}/FormControl.d.ts +0 -0
- /package/build/{formControl → types/formControl}/index.d.ts +0 -0
- /package/build/{formControl → types/formControl}/utils/index.d.ts +0 -0
- /package/build/{formControl → types/formControl}/utils/value-utils.d.ts +0 -0
- /package/build/{i18n → types/i18n}/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/JsonSchemaForm.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/allOfSchema/AllOfSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/allOfSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/ArraySchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/arrayTypeSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/basicTypeSchema/BasicTypeSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/basicTypeSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/controlFeedback/ControlFeedback.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/controlFeedback/ControlFeedback.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/controlFeedback/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/genericSchema/GenericSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/genericSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/help/Help.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/help/Help.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/help/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/objectSchema/ObjectSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/objectSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/OneOfSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/utils/const-schema-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/utils/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/oneOfSchema/utils/one-of-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/PersistAsyncSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/PersistAsyncSchema.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBasicSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/PromotedOneOfSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promoted-one-of-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/readOnlySchema/ReadOnlySchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/readOnlySchema/ReadOnlySchema.messages.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/readOnlySchema/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/SchemaFormControl.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/utils/currency-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/utils/index.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/schemaFormControl/utils/mapping-utils.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/validationAsyncSchema/ValidationAsyncSchema.d.ts +0 -0
- /package/build/{jsonSchemaForm → types/jsonSchemaForm}/validationAsyncSchema/index.d.ts +0 -0
- /package/build/{layout → types/layout}/DynamicLayout.d.ts +0 -0
- /package/build/{layout → types/layout}/alert/DynamicAlert.d.ts +0 -0
- /package/build/{layout → types/layout}/box/DynamicBox.d.ts +0 -0
- /package/build/{layout → types/layout}/button/DynamicButton.d.ts +0 -0
- /package/build/{layout → types/layout}/columns/DynamicColumns.d.ts +0 -0
- /package/build/{layout → types/layout}/decision/DynamicDecision.d.ts +0 -0
- /package/build/{layout → types/layout}/divider/DynamicDivider.d.ts +0 -0
- /package/build/{layout → types/layout}/external/DynamicExternal.d.ts +0 -0
- /package/build/{layout → types/layout}/external/DynamicExternal.messages.d.ts +0 -0
- /package/build/{layout → types/layout}/form/DynamicForm.d.ts +0 -0
- /package/build/{layout → types/layout}/heading/DynamicHeading.d.ts +0 -0
- /package/build/{layout → types/layout}/icon/DynamicIcon.d.ts +0 -0
- /package/build/{layout → types/layout}/image/DynamicImage.d.ts +0 -0
- /package/build/{layout → types/layout}/index.d.ts +0 -0
- /package/build/{layout → types/layout}/info/DynamicInfo.d.ts +0 -0
- /package/build/{layout → types/layout}/list/DynamicList.d.ts +0 -0
- /package/build/{layout → types/layout}/loadingIndicator/DynamicLoadingIndicator.d.ts +0 -0
- /package/build/{layout → types/layout}/paragraph/DynamicParagraph.d.ts +0 -0
- /package/build/{layout → types/layout}/paragraph/DynamicParagraph.messages.d.ts +0 -0
- /package/build/{layout → types/layout}/paragraph/useSnackBarIfAvailable.d.ts +0 -0
- /package/build/{layout → types/layout}/review/DynamicReview.d.ts +0 -0
- /package/build/{layout → types/layout}/utils.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/CameraStep.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/CameraCapture.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/CameraCapture.messages.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/components/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/hooks/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/overlay/Overlay.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/screens/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/tracking/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/cameraCapture/utils/index.d.ts +0 -0
- /package/build/{step → types/step}/cameraStep/index.d.ts +0 -0
- /package/build/{step → types/step}/externalConfirmationStep/ExternalConfirmationStep.d.ts +0 -0
- /package/build/{step → types/step}/externalConfirmationStep/ExternalConfirmationStep.messages.d.ts +0 -0
- /package/build/{step → types/step}/externalConfirmationStep/index.d.ts +0 -0
- /package/build/{step → types/step}/index.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/LayoutStep.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/index.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/utils/index.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/utils/inline-reference-utils.d.ts +0 -0
- /package/build/{step → types/step}/layoutStep/utils/layout-utils.d.ts +0 -0
- /package/build/types/{common → types/common}/FormControl.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Action.d.ts +0 -0
- /package/build/types/{specification → types/specification}/FileUploadSchema.d.ts +0 -0
- /package/build/types/{specification → types/specification}/LayoutComponent.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Model.d.ts +0 -0
- /package/build/types/{specification → types/specification}/PersistAsync.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Polling.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Promotion.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Schema.d.ts +0 -0
- /package/build/types/{specification → types/specification}/Step.d.ts +0 -0
- /package/build/types/{specification → types/specification}/ValidationAsync.d.ts +0 -0
- /package/build/types/{specification → types/specification}/core.d.ts +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const components_1 = require("@transferwise/components");
|
|
8
|
-
const formatting_1 = require("@transferwise/formatting");
|
|
9
|
-
const react_intl_1 = require("react-intl");
|
|
10
|
-
const ControlFeedback_messages_1 = __importDefault(require("./ControlFeedback.messages"));
|
|
11
|
-
const ControlFeedback = (props) => {
|
|
12
|
-
var _a;
|
|
13
|
-
const defaultValidationMessages = useDefaultValidationMessages(props.schema);
|
|
14
|
-
const validationMessages = Object.assign(Object.assign(Object.assign({}, defaultValidationMessages), props.validationMessages), props.schema.validationMessages);
|
|
15
|
-
const isErrorVisible = (props.submitted || !props.changed) && !!props.errors;
|
|
16
|
-
const isValidationVisible = !isErrorVisible &&
|
|
17
|
-
(props.submitted || (props.changed && props.blurred)) &&
|
|
18
|
-
!!((_a = props.validations) === null || _a === void 0 ? void 0 : _a.length);
|
|
19
|
-
const isDescriptionVisible = props.focused && props.schema.description && !isValidationVisible;
|
|
20
|
-
const hasInfoMessage = !!props.infoMessage;
|
|
21
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [isErrorVisible ? (0, jsx_runtime_1.jsx)(components_1.InlineAlert, Object.assign({ type: "error" }, { children: props.errors })) : null, isValidationVisible ? ((0, jsx_runtime_1.jsx)(components_1.InlineAlert, Object.assign({ type: "error" }, { children: props.validations.map((validation) => ((0, jsx_runtime_1.jsx)("div", { children: validationMessages[validation] }, validation))) }))) : null, (isDescriptionVisible || hasInfoMessage) && ((0, jsx_runtime_1.jsxs)(components_1.InlineAlert, Object.assign({ type: "info" }, { children: [isDescriptionVisible && (0, jsx_runtime_1.jsx)("div", { children: props.schema.description }), hasInfoMessage && (0, jsx_runtime_1.jsx)("div", { children: props.infoMessage })] })))] }));
|
|
22
|
-
};
|
|
23
|
-
ControlFeedback.defaultProps = {
|
|
24
|
-
errors: '',
|
|
25
|
-
validations: [],
|
|
26
|
-
validationMessages: {},
|
|
27
|
-
validationAsyncSuccessMessage: null,
|
|
28
|
-
};
|
|
29
|
-
// TODO: avoid typre assertions in this function
|
|
30
|
-
function useDefaultValidationMessages(schema) {
|
|
31
|
-
const { formatMessage, locale } = (0, react_intl_1.useIntl)();
|
|
32
|
-
const formattedMessages = {
|
|
33
|
-
type: formatMessage(ControlFeedback_messages_1.default.type),
|
|
34
|
-
minimum: formatMessage(ControlFeedback_messages_1.default.minimum, {
|
|
35
|
-
minimum: schema.minimum,
|
|
36
|
-
}),
|
|
37
|
-
maximum: formatMessage(ControlFeedback_messages_1.default.maximum, {
|
|
38
|
-
maximum: schema.maximum,
|
|
39
|
-
}),
|
|
40
|
-
minLength: formatMessage(ControlFeedback_messages_1.default.minLength, {
|
|
41
|
-
minLength: schema.minLength,
|
|
42
|
-
}),
|
|
43
|
-
maxLength: formatMessage(ControlFeedback_messages_1.default.maxLength, {
|
|
44
|
-
maxLength: schema.maxLength,
|
|
45
|
-
}),
|
|
46
|
-
pattern: formatMessage(ControlFeedback_messages_1.default.pattern),
|
|
47
|
-
required: formatMessage(ControlFeedback_messages_1.default.required),
|
|
48
|
-
};
|
|
49
|
-
if (schema.format === 'date') {
|
|
50
|
-
const dateOverrides = {
|
|
51
|
-
pattern: formatMessage(ControlFeedback_messages_1.default.patternDate),
|
|
52
|
-
minimum: schema.minimum
|
|
53
|
-
? formatMessage(ControlFeedback_messages_1.default.minimumDate, {
|
|
54
|
-
minimum: (0, formatting_1.formatDate)(new Date(schema.minimum), locale, {
|
|
55
|
-
timeZone: 'UTC',
|
|
56
|
-
dateStyle: 'long',
|
|
57
|
-
}),
|
|
58
|
-
})
|
|
59
|
-
: undefined,
|
|
60
|
-
maximum: schema.maximum
|
|
61
|
-
? formatMessage(ControlFeedback_messages_1.default.maximumDate, {
|
|
62
|
-
maximum: (0, formatting_1.formatDate)(new Date(schema.maximum), locale, {
|
|
63
|
-
timeZone: 'UTC',
|
|
64
|
-
dateStyle: 'long',
|
|
65
|
-
}),
|
|
66
|
-
})
|
|
67
|
-
: undefined,
|
|
68
|
-
};
|
|
69
|
-
return Object.assign(Object.assign({}, formattedMessages), dateOverrides);
|
|
70
|
-
}
|
|
71
|
-
return formattedMessages;
|
|
72
|
-
}
|
|
73
|
-
exports.default = ControlFeedback;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_intl_1 = require("react-intl");
|
|
4
|
-
exports.default = (0, react_intl_1.defineMessages)({
|
|
5
|
-
type: {
|
|
6
|
-
id: 'dynamicFlows.ControlFeedback.type',
|
|
7
|
-
defaultMessage: 'Incorrect type',
|
|
8
|
-
description: '',
|
|
9
|
-
},
|
|
10
|
-
minimum: {
|
|
11
|
-
id: 'dynamicFlows.ControlFeedback.minimum',
|
|
12
|
-
defaultMessage: `Please enter a number that's {minimum} or more.`,
|
|
13
|
-
description: '',
|
|
14
|
-
},
|
|
15
|
-
maximum: {
|
|
16
|
-
id: 'dynamicFlows.ControlFeedback.maximum',
|
|
17
|
-
defaultMessage: `Please enter a number that's {maximum} or less.`,
|
|
18
|
-
description: '',
|
|
19
|
-
},
|
|
20
|
-
minLength: {
|
|
21
|
-
id: 'dynamicFlows.ControlFeedback.minLength',
|
|
22
|
-
defaultMessage: 'Please enter at least {minLength} characters.',
|
|
23
|
-
description: '',
|
|
24
|
-
},
|
|
25
|
-
maxLength: {
|
|
26
|
-
id: 'dynamicFlows.ControlFeedback.maxLength',
|
|
27
|
-
defaultMessage: 'Please enter {maxLength} or fewer characters.',
|
|
28
|
-
description: '',
|
|
29
|
-
},
|
|
30
|
-
minimumDate: {
|
|
31
|
-
id: 'dynamicFlows.ControlFeedback.minimumDate',
|
|
32
|
-
defaultMessage: `Please enter a date that's on or after {minimum}.`,
|
|
33
|
-
description: '',
|
|
34
|
-
},
|
|
35
|
-
maximumDate: {
|
|
36
|
-
id: 'dynamicFlows.ControlFeedback.maximumDate',
|
|
37
|
-
defaultMessage: `Please enter a date that's on or before {maximum}.`,
|
|
38
|
-
description: '',
|
|
39
|
-
},
|
|
40
|
-
pattern: {
|
|
41
|
-
id: 'dynamicFlows.ControlFeedback.pattern',
|
|
42
|
-
defaultMessage: 'Please enter this in the correct format.',
|
|
43
|
-
description: '',
|
|
44
|
-
},
|
|
45
|
-
patternDate: {
|
|
46
|
-
id: 'dynamicFlows.ControlFeedback.patternDate',
|
|
47
|
-
defaultMessage: 'Please enter a date in the corrrect format.',
|
|
48
|
-
description: '',
|
|
49
|
-
},
|
|
50
|
-
required: {
|
|
51
|
-
id: 'dynamicFlows.ControlFeedback.required',
|
|
52
|
-
defaultMessage: 'Please fill out this field.',
|
|
53
|
-
description: '',
|
|
54
|
-
},
|
|
55
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var ControlFeedback_1 = require("./ControlFeedback");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ControlFeedback_1).default; } });
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const contexts_1 = require("../../common/contexts");
|
|
8
|
-
const utils_1 = require("../../common/utils");
|
|
9
|
-
const types_1 = require("../../types");
|
|
10
|
-
const Schema_1 = require("../../types/specification/Schema");
|
|
11
|
-
const allOfSchema_1 = __importDefault(require("../allOfSchema"));
|
|
12
|
-
const arrayTypeSchema_1 = __importDefault(require("../arrayTypeSchema"));
|
|
13
|
-
const basicTypeSchema_1 = __importDefault(require("../basicTypeSchema"));
|
|
14
|
-
const objectSchema_1 = __importDefault(require("../objectSchema"));
|
|
15
|
-
const oneOfSchema_1 = __importDefault(require("../oneOfSchema"));
|
|
16
|
-
const persistAsyncSchema_1 = __importDefault(require("../persistAsyncSchema"));
|
|
17
|
-
const promotedOneOfSchema_1 = __importDefault(require("../promotedOneOfSchema"));
|
|
18
|
-
const readOnlySchema_1 = __importDefault(require("../readOnlySchema"));
|
|
19
|
-
const validationAsyncSchema_1 = __importDefault(require("../validationAsyncSchema"));
|
|
20
|
-
const GenericSchemaForm = (props) => {
|
|
21
|
-
const { schema, model = null, errors = null, hideTitle = false, disabled = false } = props;
|
|
22
|
-
const schemaProps = Object.assign(Object.assign({}, props), { model, errors, hideTitle, disabled });
|
|
23
|
-
const type = (0, utils_1.getSchemaType)(schema);
|
|
24
|
-
const log = (0, contexts_1.useLogger)();
|
|
25
|
-
const logInvalidSchemaWarning = () => log.error('Invalid schema or model', `Schema of type ${type || 'undefined'} requested, but schema did not pass validation.`);
|
|
26
|
-
switch (type) {
|
|
27
|
-
case 'readOnly':
|
|
28
|
-
return (0, jsx_runtime_1.jsx)(readOnlySchema_1.default, Object.assign({}, schemaProps));
|
|
29
|
-
case 'persistAsync':
|
|
30
|
-
if ((0, types_1.isPersistAsyncSchema)(schema) && (0, types_1.isNullableStringModel)(model) && (0, types_1.isBasicError)(errors)) {
|
|
31
|
-
const filteredProps = Object.assign(Object.assign({}, schemaProps), { schema, model, errors });
|
|
32
|
-
return (0, jsx_runtime_1.jsx)(persistAsyncSchema_1.default, Object.assign({}, filteredProps));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
// TODO: MC-3224 Remove this once people have had a chance to fix errors
|
|
36
|
-
logInvalidSchemaWarning();
|
|
37
|
-
return (0, jsx_runtime_1.jsx)(persistAsyncSchema_1.default, Object.assign({}, props));
|
|
38
|
-
}
|
|
39
|
-
case 'validationAsync':
|
|
40
|
-
if ((0, types_1.isValidationAsyncSchema)(schema) && (0, types_1.isNullableBasicModel)(model) && (0, types_1.isBasicError)(errors)) {
|
|
41
|
-
const filteredProps = Object.assign(Object.assign({}, schemaProps), { schema, model, errors });
|
|
42
|
-
return (0, jsx_runtime_1.jsx)(validationAsyncSchema_1.default, Object.assign({}, filteredProps));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
// TODO: MC-3224
|
|
46
|
-
logInvalidSchemaWarning();
|
|
47
|
-
return (0, jsx_runtime_1.jsx)(validationAsyncSchema_1.default, Object.assign({}, props));
|
|
48
|
-
}
|
|
49
|
-
case 'basic': {
|
|
50
|
-
if ((0, types_1.isBasicSchema)(schema) && (0, types_1.isNullableBasicModel)(model) && (0, types_1.isBasicError)(errors)) {
|
|
51
|
-
const filteredProps = Object.assign(Object.assign({ infoMessage: null }, schemaProps), { schema,
|
|
52
|
-
model,
|
|
53
|
-
errors });
|
|
54
|
-
return (0, jsx_runtime_1.jsx)(basicTypeSchema_1.default, Object.assign({}, filteredProps));
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const filteredProps = Object.assign(Object.assign({ infoMessage: null }, schemaProps), { schema,
|
|
58
|
-
model,
|
|
59
|
-
errors });
|
|
60
|
-
// TODO: MC-3224
|
|
61
|
-
logInvalidSchemaWarning();
|
|
62
|
-
return (0, jsx_runtime_1.jsx)(basicTypeSchema_1.default, Object.assign({}, filteredProps));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
case 'object':
|
|
66
|
-
if ((0, types_1.isObjectSchema)(schema) && (0, types_1.isNullableObjectModel)(model)) {
|
|
67
|
-
const filteredProps = Object.assign(Object.assign({}, schemaProps), { schema, model, errors });
|
|
68
|
-
return (0, jsx_runtime_1.jsx)(objectSchema_1.default, Object.assign({}, filteredProps), JSON.stringify(schema));
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// TODO: MC-3224
|
|
72
|
-
logInvalidSchemaWarning();
|
|
73
|
-
return (0, jsx_runtime_1.jsx)(objectSchema_1.default, Object.assign({}, props));
|
|
74
|
-
}
|
|
75
|
-
case 'array':
|
|
76
|
-
if ((0, types_1.isArraySchema)(schema) && (0, types_1.isNullableArrayModel)(model) && (0, types_1.isBasicError)(errors)) {
|
|
77
|
-
const filteredProps = Object.assign(Object.assign({}, schemaProps), { schema, model, errors });
|
|
78
|
-
return (0, jsx_runtime_1.jsx)(arrayTypeSchema_1.default, Object.assign({}, filteredProps));
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// TODO: MC-3224
|
|
82
|
-
logInvalidSchemaWarning();
|
|
83
|
-
return (0, jsx_runtime_1.jsx)(arrayTypeSchema_1.default, Object.assign({}, props));
|
|
84
|
-
}
|
|
85
|
-
case 'promotedOneOf':
|
|
86
|
-
if ((0, Schema_1.isOneOfObjectSchema)(schema) && (0, types_1.isNullableObjectModel)(model)) {
|
|
87
|
-
const filteredProps = Object.assign(Object.assign({}, schemaProps), { schema, model, errors });
|
|
88
|
-
return (0, jsx_runtime_1.jsx)(promotedOneOfSchema_1.default, Object.assign({}, filteredProps));
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
// TODO: MC-3224
|
|
92
|
-
logInvalidSchemaWarning();
|
|
93
|
-
return (0, jsx_runtime_1.jsx)(promotedOneOfSchema_1.default, Object.assign({}, props));
|
|
94
|
-
}
|
|
95
|
-
case 'oneOf':
|
|
96
|
-
if ((0, types_1.isOneOfSchema)(schema)) {
|
|
97
|
-
const filteredProps = Object.assign(Object.assign({}, schemaProps), { schema, model, errors });
|
|
98
|
-
return (0, jsx_runtime_1.jsx)(oneOfSchema_1.default, Object.assign({}, filteredProps));
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// TODO: MC-3224
|
|
102
|
-
logInvalidSchemaWarning();
|
|
103
|
-
return (0, jsx_runtime_1.jsx)(oneOfSchema_1.default, Object.assign({}, props));
|
|
104
|
-
}
|
|
105
|
-
case 'allOf':
|
|
106
|
-
if ((0, Schema_1.isAllOfSchema)(schema) && (0, types_1.isObjectModel)(model)) {
|
|
107
|
-
const filteredProps = Object.assign(Object.assign({}, schemaProps), { schema, model, errors });
|
|
108
|
-
return (0, jsx_runtime_1.jsx)(allOfSchema_1.default, Object.assign({}, filteredProps));
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// TODO: MC-3224
|
|
112
|
-
logInvalidSchemaWarning();
|
|
113
|
-
return (0, jsx_runtime_1.jsx)(allOfSchema_1.default, Object.assign({}, props));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
117
|
-
};
|
|
118
|
-
exports.default = GenericSchemaForm;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var GenericSchema_1 = require("./GenericSchema");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(GenericSchema_1).default; } });
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const components_1 = require("@transferwise/components");
|
|
8
|
-
const react_intl_1 = require("react-intl");
|
|
9
|
-
const Help_messages_1 = __importDefault(require("./Help.messages"));
|
|
10
|
-
const Help = (props) => {
|
|
11
|
-
const intl = (0, react_intl_1.useIntl)();
|
|
12
|
-
return ((0, jsx_runtime_1.jsx)(components_1.Info, { className: "m-l-1", content: (0, jsx_runtime_1.jsx)(components_1.Markdown, { children: props.help.markdown }), presentation: "POPOVER", size: "sm", "aria-label": intl.formatMessage(Help_messages_1.default.helpAria) }));
|
|
13
|
-
};
|
|
14
|
-
exports.default = Help;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_intl_1 = require("react-intl");
|
|
4
|
-
exports.default = (0, react_intl_1.defineMessages)({
|
|
5
|
-
helpAria: {
|
|
6
|
-
id: 'dynamicFlows.Help.ariaLabel',
|
|
7
|
-
defaultMessage: 'Click here for more info.',
|
|
8
|
-
description: 'Aria label for help.',
|
|
9
|
-
},
|
|
10
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var Help_1 = require("./Help");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(Help_1).default; } });
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var JsonSchemaForm_1 = require("./JsonSchemaForm");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(JsonSchemaForm_1).default; } });
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const utils_1 = require("../../common/utils");
|
|
10
|
-
const validators_1 = require("../../common/validators");
|
|
11
|
-
const layout_1 = require("../../layout");
|
|
12
|
-
const genericSchema_1 = __importDefault(require("../genericSchema"));
|
|
13
|
-
const getSchemaColumnClasses = (width) => {
|
|
14
|
-
return {
|
|
15
|
-
'col-xs-12': true,
|
|
16
|
-
'col-sm-6': width === 'md',
|
|
17
|
-
'col-sm-4': width === 'sm',
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
const ObjectSchema = (props) => {
|
|
21
|
-
const [model, setModel] = (0, react_1.useState)(() => (Object.assign({}, (0, validators_1.getValidObjectModelParts)(props.model, props.schema))));
|
|
22
|
-
const onChangeProperty = (propertyName, onChangeProps) => {
|
|
23
|
-
if (onChangeProps.model !== null) {
|
|
24
|
-
// FIXME we should not mutate the model here
|
|
25
|
-
// eslint-disable-next-line fp/no-mutation
|
|
26
|
-
model[propertyName] = onChangeProps.model;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
delete model[propertyName];
|
|
30
|
-
}
|
|
31
|
-
setModel(model);
|
|
32
|
-
props.onChange(Object.assign(Object.assign({}, onChangeProps), { model }));
|
|
33
|
-
};
|
|
34
|
-
const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
|
|
35
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
-
// When the schema changes, only retain valid parts of the model
|
|
37
|
-
const newModel = (0, validators_1.getValidObjectModelParts)(model, props.schema) || {};
|
|
38
|
-
setModel(newModel);
|
|
39
|
-
if (!(0, utils_1.isEqual)(newModel, model)) {
|
|
40
|
-
props.onChange({
|
|
41
|
-
model: newModel,
|
|
42
|
-
triggerSchema: props.schema,
|
|
43
|
-
triggerModel: newModel,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}, [props.schema]);
|
|
47
|
-
const allorderedPropertiesSet = new Set([
|
|
48
|
-
...(props.schema.displayOrder || []),
|
|
49
|
-
...Object.keys(props.schema.properties),
|
|
50
|
-
]);
|
|
51
|
-
const isPropertyDefined = (propertyName) => typeof props.schema.properties[propertyName] !== 'undefined';
|
|
52
|
-
// eslint-disable-next-line unicorn/prefer-spread
|
|
53
|
-
const orderedPropertyNames = Array.from(allorderedPropertiesSet).filter(isPropertyDefined);
|
|
54
|
-
// TODO: LOW avoid type assertion -- what happens when props.errors is not an object?
|
|
55
|
-
const propsErrors = props.errors;
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)("fieldset", { children: [props.schema.title && !props.hideTitle && (0, jsx_runtime_1.jsxs)("legend", { children: [" ", props.schema.title, " "] }), props.schema.description && !props.hideTitle && (0, jsx_runtime_1.jsxs)("p", { children: [" ", props.schema.description, " "] }), props.schema.alert && (0, jsx_runtime_1.jsx)(layout_1.DynamicAlert, { component: props.schema.alert }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "row" }, { children: orderedPropertyNames.map((propertyName) => ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, classnames_1.default)(getSchemaColumnClasses(props.schema.properties[propertyName].width)) }, { children: (0, jsx_runtime_1.jsx)(genericSchema_1.default, { schema: props.schema.properties[propertyName], model: props.model && props.model[propertyName], errors: propsErrors && propsErrors[propertyName], submitted: props.submitted, required: isRequired(propertyName), disabled: props.disabled, onChange: (onChangeProps) => onChangeProperty(propertyName, onChangeProps), onPersistAsync: props.onPersistAsync }) }), propertyName))) }))] }));
|
|
57
|
-
};
|
|
58
|
-
ObjectSchema.defaultProps = {
|
|
59
|
-
hideTitle: false,
|
|
60
|
-
disabled: false,
|
|
61
|
-
};
|
|
62
|
-
exports.default = ObjectSchema;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var ObjectSchema_1 = require("./ObjectSchema");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ObjectSchema_1).default; } });
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const contexts_1 = require("../../common/contexts");
|
|
10
|
-
const hooks_1 = require("../../common/hooks");
|
|
11
|
-
const utils_1 = require("../../common/utils");
|
|
12
|
-
const validators_1 = require("../../common/validators");
|
|
13
|
-
const layout_1 = require("../../layout");
|
|
14
|
-
const controlFeedback_1 = __importDefault(require("../controlFeedback"));
|
|
15
|
-
const genericSchema_1 = __importDefault(require("../genericSchema"));
|
|
16
|
-
const help_1 = __importDefault(require("../help"));
|
|
17
|
-
const schemaFormControl_1 = __importDefault(require("../schemaFormControl"));
|
|
18
|
-
const utils_2 = require("./utils");
|
|
19
|
-
const OneOfSchema = (props) => {
|
|
20
|
-
const onEvent = (0, contexts_1.useEventDispatcher)();
|
|
21
|
-
const [changed, setChanged] = (0, react_1.useState)(false);
|
|
22
|
-
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
23
|
-
const [blurred, setBlurred] = (0, react_1.useState)(false);
|
|
24
|
-
const id = (0, react_1.useMemo)(() => props.schema.$id || (0, utils_1.generateRandomId)(), [props.schema.$id]);
|
|
25
|
-
const [schemaIndex, setSchemaIndex] = (0, react_1.useState)((0, utils_2.getActiveSchemaIndex)(props.schema, props.model));
|
|
26
|
-
const [models, setModels] = (0, react_1.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
|
|
27
|
-
const debouncedTrackEvent = (0, hooks_1.useDebouncedFunction)(onEvent, 200);
|
|
28
|
-
const onSearchChange = (searchValue) => {
|
|
29
|
-
debouncedTrackEvent('Dynamic Flow - OneOf Searched', {
|
|
30
|
-
oneOfId: props.schema.analyticsId,
|
|
31
|
-
searchValueLength: searchValue.length,
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
// When the schema we receive from parent changes
|
|
35
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
-
const modelIndex = (0, utils_2.getValidIndexFromValue)(props.schema, props.model);
|
|
37
|
-
const defaultIndex = (0, utils_2.getValidIndexFromValue)(props.schema, props.schema.default);
|
|
38
|
-
if (modelIndex === -1 && defaultIndex >= 0) {
|
|
39
|
-
onChooseNewSchema(defaultIndex, 'init');
|
|
40
|
-
}
|
|
41
|
-
}, [props.schema]);
|
|
42
|
-
if (!(0, validators_1.isArray)(props.schema.oneOf)) {
|
|
43
|
-
// eslint-disable-next-line no-console
|
|
44
|
-
console.error('Incorrect format', props.schema);
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const onChildModelChange = (index, onChangeParameters) => {
|
|
48
|
-
setModels([...models.slice(0, index), onChangeParameters.model, ...models.slice(index + 1)]);
|
|
49
|
-
setChanged(true);
|
|
50
|
-
props.onChange(onChangeParameters);
|
|
51
|
-
};
|
|
52
|
-
const onFocus = () => {
|
|
53
|
-
setFocused(true);
|
|
54
|
-
};
|
|
55
|
-
const onBlur = () => {
|
|
56
|
-
setFocused(false);
|
|
57
|
-
setBlurred(true);
|
|
58
|
-
};
|
|
59
|
-
// TODO: LOW avoid type assertion
|
|
60
|
-
const onChooseNewSchema = (index, type) => {
|
|
61
|
-
setSchemaIndex(index);
|
|
62
|
-
const newSchema = props.schema.oneOf[index];
|
|
63
|
-
if ((0, utils_2.isConstSchema)(newSchema)) {
|
|
64
|
-
// If new schema is a const we want to share the parent schema, not the const
|
|
65
|
-
const model = newSchema.const;
|
|
66
|
-
props.onChange({
|
|
67
|
-
model,
|
|
68
|
-
triggerSchema: props.schema,
|
|
69
|
-
triggerModel: model,
|
|
70
|
-
type,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
props.onChange({
|
|
75
|
-
model: models[index],
|
|
76
|
-
triggerSchema: newSchema,
|
|
77
|
-
triggerModel: models[index],
|
|
78
|
-
type,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (type !== 'init' && props.schema.analyticsId) {
|
|
82
|
-
onEvent('Dynamic Flow - OneOf Selected', {
|
|
83
|
-
oneOfId: props.schema.analyticsId,
|
|
84
|
-
schemaId: newSchema === null || newSchema === void 0 ? void 0 : newSchema.analyticsId,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const schemaForSelect = mapSchemasForSelect(props.schema);
|
|
89
|
-
const validations = getValidations(props, schemaIndex);
|
|
90
|
-
const formGroupClasses = {
|
|
91
|
-
'form-group': true,
|
|
92
|
-
'has-error': (!changed && props.errors && !(0, validators_1.isEmpty)(props.errors)) ||
|
|
93
|
-
((props.submitted || (changed && blurred)) && validations.length),
|
|
94
|
-
};
|
|
95
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(props.schema.oneOf.length > 1 || (0, utils_2.isConstSchema)(props.schema.oneOf[0])) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)(formGroupClasses) }, { children: [getTitleAndHelp(props.schema, id), (0, jsx_runtime_1.jsx)(schemaFormControl_1.default, { id: id, schema: schemaForSelect, value: schemaIndex, disabled: props.disabled, onChange: onChooseNewSchema, onFocus: onFocus, onBlur: onBlur, onSearchChange: onSearchChange }), (0, jsx_runtime_1.jsx)(controlFeedback_1.default, { changed: changed, focused: focused, blurred: blurred, submitted: props.submitted, errors: errorsToString(props.errors), schema: props.schema, validations: validations, infoMessage: null })] })), props.schema.alert && (0, jsx_runtime_1.jsx)(layout_1.DynamicAlert, { component: props.schema.alert })] })), (0, utils_2.isNoNConstSchema)(props.schema.oneOf[schemaIndex]) && ((0, jsx_runtime_1.jsx)(genericSchema_1.default, { schema: props.schema.oneOf[schemaIndex], model: models[schemaIndex], errors: props.errors, submitted: props.submitted, hideTitle: true, disabled: props.disabled, onChange: (parameters) => onChildModelChange(schemaIndex, parameters), onPersistAsync: props.onPersistAsync }))] }));
|
|
96
|
-
};
|
|
97
|
-
function getTitleAndHelp(schema, id) {
|
|
98
|
-
const helpElement = schema.help ? (0, jsx_runtime_1.jsx)(help_1.default, { help: schema.help }) : null;
|
|
99
|
-
const titleElement = (0, utils_2.isConstSchema)(schema.oneOf[0]) ? ((0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "control-label d-inline", htmlFor: id }, { children: [schema.title, " ", helpElement] }))) : ((0, jsx_runtime_1.jsxs)("h4", Object.assign({ className: "m-b-2" }, { children: [schema.title, " ", helpElement] })));
|
|
100
|
-
return schema.title ? titleElement : helpElement;
|
|
101
|
-
}
|
|
102
|
-
function getValidations(props, schemaIndex) {
|
|
103
|
-
const selectedSchema = props.schema.oneOf[schemaIndex !== null && schemaIndex !== void 0 ? schemaIndex : -1];
|
|
104
|
-
if ((0, utils_2.isConstSchema)(selectedSchema)) {
|
|
105
|
-
return (0, validators_1.getValidationFailures)(selectedSchema.const, props.schema, !!props.required);
|
|
106
|
-
}
|
|
107
|
-
if (schemaIndex === null || schemaIndex < 0) {
|
|
108
|
-
return (0, validators_1.getValidationFailures)(null, props.schema, !!props.required);
|
|
109
|
-
}
|
|
110
|
-
return [];
|
|
111
|
-
}
|
|
112
|
-
function errorsToString(errors) {
|
|
113
|
-
// When oneOf represents a select, errors should be of type string
|
|
114
|
-
if (typeof errors === 'string') {
|
|
115
|
-
return errors;
|
|
116
|
-
}
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
function getModelPartsForSchemas(model, schemas) {
|
|
120
|
-
return schemas.map((schema) => (0, validators_1.getValidModelParts)(model, schema));
|
|
121
|
-
}
|
|
122
|
-
// We want our model to be the index, so alter the oneOf schemas to be a const
|
|
123
|
-
function mapSchemasForSelect(schema) {
|
|
124
|
-
return Object.assign(Object.assign({}, schema), { oneOf: schema.oneOf.map(mapOneOfToConst) });
|
|
125
|
-
}
|
|
126
|
-
function mapOneOfToConst(schema, index) {
|
|
127
|
-
const { title, description, disabled = false, icon, image, keywords } = schema;
|
|
128
|
-
// TODO LOW avoid type assertion below -- consider adding { type: 'integer' }
|
|
129
|
-
return { title, description, disabled, icon, image, const: index, keywords };
|
|
130
|
-
}
|
|
131
|
-
OneOfSchema.defaultProps = {
|
|
132
|
-
required: false,
|
|
133
|
-
disabled: false,
|
|
134
|
-
};
|
|
135
|
-
exports.default = OneOfSchema;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var OneOfSchema_1 = require("./OneOfSchema");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(OneOfSchema_1).default; } });
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNoNConstSchema = exports.isConstSchema = void 0;
|
|
4
|
-
const validators_1 = require("../../../common/validators");
|
|
5
|
-
// TODO HD Move this out of here
|
|
6
|
-
function isConstSchema(schema) {
|
|
7
|
-
return !(0, validators_1.isUndefined)(schema === null || schema === void 0 ? void 0 : schema.const);
|
|
8
|
-
}
|
|
9
|
-
exports.isConstSchema = isConstSchema;
|
|
10
|
-
function isNoNConstSchema(schema) {
|
|
11
|
-
return !!schema && !isConstSchema(schema);
|
|
12
|
-
}
|
|
13
|
-
exports.isNoNConstSchema = isNoNConstSchema;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./const-schema-utils"), exports);
|
|
18
|
-
__exportStar(require("./one-of-utils"), exports);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBestMatchingSchemaIndexForValue = exports.getValidIndexFromValue = exports.getActiveSchemaIndex = void 0;
|
|
4
|
-
const validators_1 = require("../../../common/validators");
|
|
5
|
-
const types_1 = require("../../../types");
|
|
6
|
-
const Schema_1 = require("../../../types/specification/Schema");
|
|
7
|
-
const const_schema_utils_1 = require("./const-schema-utils");
|
|
8
|
-
const getActiveSchemaIndex = (schema, model) => {
|
|
9
|
-
const indexFromModel = (0, exports.getValidIndexFromValue)(schema, model);
|
|
10
|
-
// If our model satisfies one of the schemas, use that schema.
|
|
11
|
-
if (indexFromModel >= 0) {
|
|
12
|
-
return indexFromModel;
|
|
13
|
-
}
|
|
14
|
-
// If we have a non-const oneOf and there's only one, active index must be the first one
|
|
15
|
-
if (schema.oneOf.length === 1 && (0, const_schema_utils_1.isNoNConstSchema)(schema.oneOf[0])) {
|
|
16
|
-
return 0;
|
|
17
|
-
}
|
|
18
|
-
if ((0, const_schema_utils_1.isConstSchema)(schema.oneOf[0])) {
|
|
19
|
-
const indexFromDefault = (0, exports.getValidIndexFromValue)(schema, schema.default);
|
|
20
|
-
// If the default value satisfies one of the schemas, use that schema.
|
|
21
|
-
if (indexFromDefault >= 0) {
|
|
22
|
-
return indexFromDefault;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if ((0, Schema_1.isOneOfObjectSchema)(schema) && (0, types_1.isObjectModel)(model) && Object.keys(model).length >= 1) {
|
|
26
|
-
// Even if the model does not satisfy any of the schemas, it may be closer to one of them.
|
|
27
|
-
return getBestMatchingSchemaIndexForValue(schema, model);
|
|
28
|
-
}
|
|
29
|
-
if ((0, Schema_1.isOneOfObjectSchema)(schema) &&
|
|
30
|
-
!(0, validators_1.isUndefined)(schema.default) &&
|
|
31
|
-
(0, types_1.isObjectModel)(schema.default) &&
|
|
32
|
-
Object.keys(schema.default).length >= 1) {
|
|
33
|
-
// Even if the default value does not satisfy any of the schemas, it may be closer to one of them.
|
|
34
|
-
return getBestMatchingSchemaIndexForValue(schema, schema.default);
|
|
35
|
-
}
|
|
36
|
-
// Otherwise do not default
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
39
|
-
exports.getActiveSchemaIndex = getActiveSchemaIndex;
|
|
40
|
-
const getValidIndexFromValue = (schema, value) => {
|
|
41
|
-
return schema.oneOf.findIndex((childSchema) => !(0, validators_1.isUndefined)(value) && (0, validators_1.isValidSchema)(value, childSchema));
|
|
42
|
-
};
|
|
43
|
-
exports.getValidIndexFromValue = getValidIndexFromValue;
|
|
44
|
-
function getBestMatchingSchemaIndexForValue(schema, value) {
|
|
45
|
-
if (value === null || value === undefined) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
const schemaPoints = schema.oneOf.map((childSchema) => {
|
|
49
|
-
return getSchemaProperties(childSchema).reduce((total, [key, propertySchema]) => {
|
|
50
|
-
if ((0, const_schema_utils_1.isConstSchema)(propertySchema) && propertySchema.const === value[key]) {
|
|
51
|
-
return total + 2;
|
|
52
|
-
}
|
|
53
|
-
else if ((0, const_schema_utils_1.isNoNConstSchema)(propertySchema) && typeof value[key] !== 'undefined') {
|
|
54
|
-
return total + 1;
|
|
55
|
-
}
|
|
56
|
-
return total;
|
|
57
|
-
}, 0);
|
|
58
|
-
});
|
|
59
|
-
if (schemaPoints.every((p) => p === schemaPoints[0])) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return schemaPoints.indexOf(Math.max(...schemaPoints));
|
|
63
|
-
}
|
|
64
|
-
exports.getBestMatchingSchemaIndexForValue = getBestMatchingSchemaIndexForValue;
|
|
65
|
-
function getSchemaProperties(childSchema) {
|
|
66
|
-
return childSchema.properties !== null && typeof childSchema.properties === 'object'
|
|
67
|
-
? Object.entries(childSchema.properties)
|
|
68
|
-
: [];
|
|
69
|
-
}
|