@wise/dynamic-flow-client 0.1.1 → 0.1.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/common/api/utils.d.ts +4 -0
- package/build/common/api/utils.js +13 -0
- package/build/common/contexts/dynamicFlowContext/dynamicFlowContext.d.ts +11 -0
- package/build/common/contexts/dynamicFlowContext/dynamicFlowContext.js +36 -0
- package/build/common/contexts/dynamicFlowContext/usePendingPromiseCounter.d.ts +4 -0
- package/build/common/contexts/dynamicFlowContext/usePendingPromiseCounter.js +13 -0
- package/build/common/contexts/fetcherContext/fetcherContext.d.ts +18 -0
- package/build/common/contexts/fetcherContext/fetcherContext.js +35 -0
- package/build/common/contexts/fetcherContext/index.d.ts +2 -0
- package/build/common/contexts/fetcherContext/index.js +2 -0
- package/build/common/contexts/fetcherContext/makeFetcher.d.ts +2 -0
- package/build/common/contexts/fetcherContext/makeFetcher.js +33 -0
- package/build/common/general/index.d.ts +2 -0
- package/build/common/general/index.js +22 -0
- package/build/common/hooks/useDebouncedFunction.d.ts +2 -0
- package/build/common/hooks/useDebouncedFunction.js +9 -0
- package/build/common/hooks/useDebouncedFunction.test.d.ts +1 -0
- package/build/common/hooks/useDebouncedFunction.test.js +59 -0
- package/build/common/hooks/usePersistAsync.d.ts +7 -0
- package/build/common/hooks/usePersistAsync.js +170 -0
- package/build/common/hooks/usePolling.d.ts +11 -0
- package/build/common/hooks/usePolling.js +48 -0
- package/build/common/hooks/usePrevious.d.ts +2 -0
- package/build/common/hooks/usePrevious.js +9 -0
- package/build/common/index.d.ts +4 -0
- package/build/common/index.js +4 -0
- package/build/common/logging/index.d.ts +22 -0
- package/build/common/logging/index.js +39 -0
- package/build/common/logging/spec.d.ts +1 -0
- package/build/common/logging/spec.js +45 -0
- package/build/common/messages.d.ts +8 -0
- package/build/common/messages.js +8 -0
- package/build/common/propsValues/dateMode.d.ts +4 -0
- package/build/common/propsValues/dateMode.js +4 -0
- package/build/common/propsValues/formControlType.d.ts +17 -0
- package/build/common/propsValues/formControlType.js +17 -0
- package/build/common/propsValues/monthFormat.d.ts +4 -0
- package/build/common/propsValues/monthFormat.js +4 -0
- package/build/common/propsValues/size.d.ts +7 -0
- package/build/common/propsValues/size.js +7 -0
- package/build/common/requirements.d.ts +10 -0
- package/build/common/requirements.js +50 -0
- package/build/common/schemaTypes/schemaTypes.d.ts +23 -0
- package/build/common/schemaTypes/schemaTypes.js +53 -0
- package/build/common/schemaTypes/shouldDebounceSchema.d.ts +2 -0
- package/build/common/schemaTypes/shouldDebounceSchema.js +6 -0
- package/build/common/stepTypes/stepTypes.d.ts +7 -0
- package/build/common/stepTypes/stepTypes.js +42 -0
- package/build/common/tracking/index.d.ts +15 -0
- package/build/common/tracking/index.js +33 -0
- package/build/common/tracking/spec.d.ts +1 -0
- package/build/common/tracking/spec.js +49 -0
- package/build/common/utils/file-utils.d.ts +4 -0
- package/build/common/utils/file-utils.js +45 -0
- package/build/common/utils/generate-random-id.d.ts +1 -0
- package/build/common/utils/generate-random-id.js +5 -0
- package/build/common/utils/generate-random-id.test.d.ts +1 -0
- package/build/common/utils/generate-random-id.test.js +12 -0
- package/build/common/validation/rule-validators/index.d.ts +10 -0
- package/build/common/validation/rule-validators/index.js +40 -0
- package/build/common/validation/rule-validators/spec.d.ts +1 -0
- package/build/common/validation/rule-validators/spec.js +145 -0
- package/build/common/validation/schema-validators/index.d.ts +9 -0
- package/build/common/validation/schema-validators/index.js +98 -0
- package/build/common/validation/schema-validators/spec.d.ts +1 -0
- package/build/common/validation/schema-validators/spec.js +137 -0
- package/build/common/validation/valid-model/index.d.ts +5 -0
- package/build/common/validation/valid-model/index.js +64 -0
- package/build/common/validation/valid-model/spec.d.ts +1 -0
- package/build/common/validation/valid-model/spec.js +605 -0
- package/build/common/validation/valid-model/utils.d.ts +11 -0
- package/build/common/validation/valid-model/utils.js +118 -0
- package/build/common/validation/validation-failures/index.d.ts +23 -0
- package/build/common/validation/validation-failures/index.js +140 -0
- package/build/common/validation/validation-failures/spec.d.ts +1 -0
- package/build/common/validation/validation-failures/spec.js +185 -0
- package/build/dynamic-flow-types/Action.d.ts +19 -0
- package/build/dynamic-flow-types/Action.js +1 -0
- package/build/dynamic-flow-types/FileUploadSchema.d.ts +23 -0
- package/build/dynamic-flow-types/FileUploadSchema.js +3 -0
- package/build/dynamic-flow-types/LayoutComponent.d.ts +129 -0
- package/build/dynamic-flow-types/LayoutComponent.js +1 -0
- package/build/dynamic-flow-types/Model.d.ts +12 -0
- package/build/dynamic-flow-types/Model.js +28 -0
- package/build/dynamic-flow-types/PersistAsync.d.ts +8 -0
- package/build/dynamic-flow-types/PersistAsync.js +1 -0
- package/build/dynamic-flow-types/Polling.d.ts +12 -0
- package/build/dynamic-flow-types/Polling.js +1 -0
- package/build/dynamic-flow-types/Promotion.d.ts +20 -0
- package/build/dynamic-flow-types/Promotion.js +1 -0
- package/build/dynamic-flow-types/Schema.d.ts +184 -0
- package/build/dynamic-flow-types/Schema.js +49 -0
- package/build/dynamic-flow-types/Step.d.ts +127 -0
- package/build/dynamic-flow-types/Step.js +4 -0
- package/build/dynamic-flow-types/ValidationAsync.d.ts +6 -0
- package/build/dynamic-flow-types/ValidationAsync.js +1 -0
- package/build/dynamic-flow-types/core.d.ts +29 -0
- package/build/dynamic-flow-types/core.js +1 -0
- package/build/dynamic-flow-types/index.d.ts +14 -0
- package/build/dynamic-flow-types/index.js +12 -0
- package/build/field/Field.d.ts +69 -0
- package/build/field/Field.js +311 -0
- package/build/field/index.d.ts +2 -0
- package/build/field/index.js +2 -0
- package/build/flow/DynamicFlow.d.ts +4 -0
- package/build/flow/DynamicFlow.js +368 -0
- package/build/flow/DynamicFlowStep.d.ts +9 -0
- package/build/flow/DynamicFlowStep.js +32 -0
- package/build/flow/errorBoundary/ErrorBoundary.d.ts +20 -0
- package/build/flow/errorBoundary/ErrorBoundary.js +45 -0
- package/build/flow/errorBoundary/ErrorBoundary.messages.d.ts +13 -0
- package/build/flow/errorBoundary/ErrorBoundary.messages.js +13 -0
- package/build/flow/errorBoundary/ErrorBoundaryAlert.d.ts +6 -0
- package/build/flow/errorBoundary/ErrorBoundaryAlert.js +12 -0
- package/build/flow/errorBoundary/index.d.ts +1 -0
- package/build/flow/errorBoundary/index.js +1 -0
- package/build/flow/fixtures/components/alert.d.ts +3 -0
- package/build/flow/fixtures/components/alert.js +31 -0
- package/build/flow/fixtures/components/box.d.ts +3 -0
- package/build/flow/fixtures/components/box.js +20 -0
- package/build/flow/fixtures/components/button.d.ts +3 -0
- package/build/flow/fixtures/components/button.js +65 -0
- package/build/flow/fixtures/components/columns.d.ts +3 -0
- package/build/flow/fixtures/components/columns.js +36 -0
- package/build/flow/fixtures/components/copyable.d.ts +3 -0
- package/build/flow/fixtures/components/copyable.js +22 -0
- package/build/flow/fixtures/components/decision.d.ts +3 -0
- package/build/flow/fixtures/components/decision.js +54 -0
- package/build/flow/fixtures/components/heading.d.ts +3 -0
- package/build/flow/fixtures/components/heading.js +14 -0
- package/build/flow/fixtures/components/image.d.ts +3 -0
- package/build/flow/fixtures/components/image.js +22 -0
- package/build/flow/fixtures/components/info.d.ts +3 -0
- package/build/flow/fixtures/components/info.js +17 -0
- package/build/flow/fixtures/components/list.d.ts +3 -0
- package/build/flow/fixtures/components/list.js +34 -0
- package/build/flow/fixtures/components/loading-indicator.d.ts +3 -0
- package/build/flow/fixtures/components/loading-indicator.js +16 -0
- package/build/flow/fixtures/components/paragraph.d.ts +3 -0
- package/build/flow/fixtures/components/paragraph.js +28 -0
- package/build/flow/fixtures/components/review.d.ts +3 -0
- package/build/flow/fixtures/components/review.js +60 -0
- package/build/flow/fixtures/examples/camera-capture.d.ts +3 -0
- package/build/flow/fixtures/examples/camera-capture.js +121 -0
- package/build/flow/fixtures/examples/recipient-update.d.ts +3 -0
- package/build/flow/fixtures/examples/recipient-update.js +250 -0
- package/build/flow/fixtures/examples/recipient.d.ts +3 -0
- package/build/flow/fixtures/examples/recipient.js +313 -0
- package/build/flow/fixtures/examples/single-file-upload.d.ts +3 -0
- package/build/flow/fixtures/examples/single-file-upload.js +96 -0
- package/build/flow/fixtures/examples/step-validation-errors.d.ts +3 -0
- package/build/flow/fixtures/examples/step-validation-errors.js +75 -0
- package/build/flow/fixtures/features/action-response.d.ts +3 -0
- package/build/flow/fixtures/features/action-response.js +29 -0
- package/build/flow/fixtures/features/external.d.ts +3 -0
- package/build/flow/fixtures/features/external.js +31 -0
- package/build/flow/fixtures/features/persist-async.d.ts +3 -0
- package/build/flow/fixtures/features/persist-async.js +44 -0
- package/build/flow/fixtures/features/polling.d.ts +3 -0
- package/build/flow/fixtures/features/polling.js +33 -0
- package/build/flow/fixtures/index.d.ts +42 -0
- package/build/flow/fixtures/index.js +66 -0
- package/build/flow/fixtures/responses/action-response-final.d.ts +3 -0
- package/build/flow/fixtures/responses/action-response-final.js +24 -0
- package/build/flow/fixtures/responses/action.d.ts +5 -0
- package/build/flow/fixtures/responses/action.js +2 -0
- package/build/flow/fixtures/responses/exit.d.ts +6 -0
- package/build/flow/fixtures/responses/exit.js +2 -0
- package/build/flow/fixtures/responses/recipient-update-final.d.ts +3 -0
- package/build/flow/fixtures/responses/recipient-update-final.js +24 -0
- package/build/flow/fixtures/schemas/basic-form.d.ts +3 -0
- package/build/flow/fixtures/schemas/basic-form.js +39 -0
- package/build/flow/fixtures/schemas/number-and-integer.d.ts +3 -0
- package/build/flow/fixtures/schemas/number-and-integer.js +41 -0
- package/build/flow/fixtures/schemas/one-of.d.ts +3 -0
- package/build/flow/fixtures/schemas/one-of.js +223 -0
- package/build/flow/fixtures/schemas/string-formats.d.ts +3 -0
- package/build/flow/fixtures/schemas/string-formats.js +58 -0
- package/build/flow/index.d.ts +1 -0
- package/build/flow/index.js +1 -0
- package/build/flow/response-parsers/index.d.ts +17 -0
- package/build/flow/response-parsers/index.js +112 -0
- package/build/flow/response-parsers/spec.d.ts +1 -0
- package/build/flow/response-parsers/spec.js +263 -0
- package/build/flow/stories/EditableDynamicFlow.d.ts +5 -0
- package/build/flow/stories/EditableDynamicFlow.js +61 -0
- package/build/flow/types.d.ts +77 -0
- package/build/flow/types.js +3 -0
- package/build/flow/useDebouncedRefresh/index.d.ts +1 -0
- package/build/flow/useDebouncedRefresh/index.js +1 -0
- package/build/flow/useDebouncedRefresh/useDebouncedRefresh.d.ts +5 -0
- package/build/flow/useDebouncedRefresh/useDebouncedRefresh.js +24 -0
- package/build/flow/useDynamicFlowState.d.ts +18 -0
- package/build/flow/useDynamicFlowState.js +111 -0
- package/build/flow/useLoader.d.ts +9 -0
- package/build/flow/useLoader.js +22 -0
- package/build/formControl/FormControl.d.ts +86 -0
- package/build/formControl/FormControl.js +241 -0
- package/build/formControl/index.d.ts +1 -0
- package/build/formControl/index.js +1 -0
- package/build/formControl/types.d.ts +57 -0
- package/build/formControl/types.js +1 -0
- package/build/formControl/value-utils.d.ts +9 -0
- package/build/formControl/value-utils.js +108 -0
- package/build/i18n/cs.json +8 -0
- package/build/i18n/de.json +34 -0
- package/build/i18n/en.json +38 -0
- package/build/i18n/es.json +34 -0
- package/build/i18n/fr.json +34 -0
- package/build/i18n/hu.json +34 -0
- package/build/i18n/id.json +34 -0
- package/build/i18n/index.d.ts +2 -0
- package/build/i18n/index.js +31 -0
- package/build/i18n/it.json +34 -0
- package/build/i18n/ja.json +34 -0
- package/build/i18n/pl.json +11 -0
- package/build/i18n/pt.json +34 -0
- package/build/i18n/ro.json +34 -0
- package/build/i18n/ru.json +34 -0
- package/build/i18n/th.json +34 -0
- package/build/i18n/tr.json +11 -0
- package/build/i18n/uk.json +8 -0
- package/build/i18n/zh-CN.json +34 -0
- package/build/i18n/zh.json +34 -0
- package/build/index.d.ts +12 -0
- package/build/index.js +11 -0
- package/build/jsonSchemaForm/JsonSchemaForm.d.ts +66 -0
- package/build/jsonSchemaForm/JsonSchemaForm.js +31 -0
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.d.ts +14 -0
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +54 -0
- package/build/jsonSchemaForm/allOfSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/allOfSchema/index.js +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.d.ts +15 -0
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +25 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +16 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +26 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.d.ts +18 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +141 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.d.ts +24 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +18 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/useFormattedDefaultErrorMessages.d.ts +9 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/useFormattedDefaultErrorMessages.js +14 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils.d.ts +6 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils.js +85 -0
- package/build/jsonSchemaForm/arrayTypeSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/arrayTypeSchema/index.js +1 -0
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.d.ts +22 -0
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +105 -0
- package/build/jsonSchemaForm/basicTypeSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/basicTypeSchema/index.js +1 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.d.ts +31 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +79 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.d.ts +53 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +53 -0
- package/build/jsonSchemaForm/controlFeedback/index.d.ts +1 -0
- package/build/jsonSchemaForm/controlFeedback/index.js +1 -0
- package/build/jsonSchemaForm/genericSchema/GenericSchema.d.ts +19 -0
- package/build/jsonSchemaForm/genericSchema/GenericSchema.js +122 -0
- package/build/jsonSchemaForm/genericSchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/genericSchema/index.js +1 -0
- package/build/jsonSchemaForm/help/Help.d.ts +8 -0
- package/build/jsonSchemaForm/help/Help.js +9 -0
- package/build/jsonSchemaForm/help/Help.messages.d.ts +8 -0
- package/build/jsonSchemaForm/help/Help.messages.js +8 -0
- package/build/jsonSchemaForm/help/index.d.ts +1 -0
- package/build/jsonSchemaForm/help/index.js +1 -0
- package/build/jsonSchemaForm/index.d.ts +1 -0
- package/build/jsonSchemaForm/index.js +1 -0
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.d.ts +16 -0
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +78 -0
- package/build/jsonSchemaForm/objectSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/objectSchema/index.js +1 -0
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.d.ts +15 -0
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +153 -0
- package/build/jsonSchemaForm/oneOfSchema/getActiveSchemaIndex.d.ts +3 -0
- package/build/jsonSchemaForm/oneOfSchema/getActiveSchemaIndex.js +40 -0
- package/build/jsonSchemaForm/oneOfSchema/getBestMatchingSchemaIndexForValue.d.ts +2 -0
- package/build/jsonSchemaForm/oneOfSchema/getBestMatchingSchemaIndexForValue.js +27 -0
- package/build/jsonSchemaForm/oneOfSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/oneOfSchema/index.js +1 -0
- package/build/jsonSchemaForm/oneOfSchema/isConstSchema.d.ts +3 -0
- package/build/jsonSchemaForm/oneOfSchema/isConstSchema.js +7 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.d.ts +16 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +26 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.d.ts +8 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +8 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/PersistAsyncBasicSchema.d.ts +21 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/PersistAsyncBasicSchema.js +168 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/index.d.ts +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/index.js +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/PersistAsyncBlobSchema.d.ts +20 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/PersistAsyncBlobSchema.js +127 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/UploadInputAdapter.d.ts +17 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/UploadInputAdapter.js +32 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/index.d.ts +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/index.js +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/persistAsyncSchema/index.js +1 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.d.ts +9 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +72 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchemaModelMatcher.d.ts +2 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchemaModelMatcher.js +8 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfCheckboxControl.d.ts +7 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfCheckboxControl.js +27 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfControl.d.ts +23 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfControl.js +31 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfRadioControl.d.ts +9 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfRadioControl.js +32 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/index.js +1 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.d.ts +8 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +55 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.d.ts +16 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +13 -0
- package/build/jsonSchemaForm/readOnlySchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/readOnlySchema/index.js +1 -0
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +25 -0
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +106 -0
- package/build/jsonSchemaForm/schemaFormControl/availableCurrencyFlags.d.ts +3 -0
- package/build/jsonSchemaForm/schemaFormControl/availableCurrencyFlags.js +73 -0
- package/build/jsonSchemaForm/schemaFormControl/index.d.ts +1 -0
- package/build/jsonSchemaForm/schemaFormControl/index.js +1 -0
- package/build/jsonSchemaForm/schemaFormControl/optionMapper.d.ts +40 -0
- package/build/jsonSchemaForm/schemaFormControl/optionMapper.js +89 -0
- package/build/jsonSchemaForm/schemas/allOf.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/allOf.json.js +119 -0
- package/build/jsonSchemaForm/schemas/audRecipient.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/audRecipient.json.js +1104 -0
- package/build/jsonSchemaForm/schemas/base64Url_MultipleFileUpload.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/base64Url_MultipleFileUpload.json.js +37 -0
- package/build/jsonSchemaForm/schemas/blob_MultipleFileUpload.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/blob_MultipleFileUpload.json.js +36 -0
- package/build/jsonSchemaForm/schemas/currency.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/currency.json.js +48 -0
- package/build/jsonSchemaForm/schemas/oneOf.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/oneOf.json.js +119 -0
- package/build/jsonSchemaForm/schemas/oneOfTabs.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/oneOfTabs.json.js +53 -0
- package/build/jsonSchemaForm/schemas/promotedOneOf.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/promotedOneOf.json.js +56 -0
- package/build/jsonSchemaForm/schemas/promotedOneOfCheckbox.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/promotedOneOfCheckbox.json.js +102 -0
- package/build/jsonSchemaForm/schemas/simple.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/simple.json.js +48 -0
- package/build/jsonSchemaForm/schemas/uploadPersistAsync.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/uploadPersistAsync.json.js +71 -0
- package/build/jsonSchemaForm/schemas/validationAsync.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/validationAsync.json.js +23 -0
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.d.ts +17 -0
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +149 -0
- package/build/jsonSchemaForm/validationAsyncSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/validationAsyncSchema/index.js +1 -0
- package/build/layout/DynamicLayout.d.ts +17 -0
- package/build/layout/DynamicLayout.js +75 -0
- package/build/layout/alert/index.d.ts +6 -0
- package/build/layout/alert/index.js +29 -0
- package/build/layout/box/index.d.ts +8 -0
- package/build/layout/box/index.js +41 -0
- package/build/layout/button/index.d.ts +8 -0
- package/build/layout/button/index.js +58 -0
- package/build/layout/columns/index.d.ts +8 -0
- package/build/layout/columns/index.js +38 -0
- package/build/layout/decision/index.d.ts +9 -0
- package/build/layout/decision/index.js +38 -0
- package/build/layout/divider/index.d.ts +7 -0
- package/build/layout/divider/index.js +9 -0
- package/build/layout/external/DynamicExternal.d.ts +8 -0
- package/build/layout/external/DynamicExternal.js +30 -0
- package/build/layout/external/DynamicExternal.messages.d.ts +8 -0
- package/build/layout/external/DynamicExternal.messages.js +8 -0
- package/build/layout/external/index.d.ts +1 -0
- package/build/layout/external/index.js +1 -0
- package/build/layout/external/useExternalStepPolling.d.ts +11 -0
- package/build/layout/external/useExternalStepPolling.js +68 -0
- package/build/layout/form/index.d.ts +8 -0
- package/build/layout/form/index.js +22 -0
- package/build/layout/heading/index.d.ts +6 -0
- package/build/layout/heading/index.js +31 -0
- package/build/layout/icon/index.d.ts +7 -0
- package/build/layout/icon/index.js +22 -0
- package/build/layout/image/index.d.ts +6 -0
- package/build/layout/image/index.js +126 -0
- package/build/layout/index.d.ts +1 -0
- package/build/layout/index.js +1 -0
- package/build/layout/info/index.d.ts +7 -0
- package/build/layout/info/index.js +19 -0
- package/build/layout/layouts/all.json.d.ts +3 -0
- package/build/layout/layouts/all.json.js +176 -0
- package/build/layout/layouts/final-step-layout.json.d.ts +3 -0
- package/build/layout/layouts/final-step-layout.json.js +39 -0
- package/build/layout/layouts/finalStep.json.d.ts +3 -0
- package/build/layout/layouts/finalStep.json.js +24 -0
- package/build/layout/layouts/list.json.d.ts +3 -0
- package/build/layout/layouts/list.json.js +33 -0
- package/build/layout/layouts/pay-in.json.d.ts +3 -0
- package/build/layout/layouts/pay-in.json.js +97 -0
- package/build/layout/layouts/review.json.d.ts +3 -0
- package/build/layout/layouts/review.json.js +160 -0
- package/build/layout/layouts/success.json.d.ts +3 -0
- package/build/layout/layouts/success.json.js +66 -0
- package/build/layout/list/index.d.ts +8 -0
- package/build/layout/list/index.js +30 -0
- package/build/layout/loading-indicator/index.d.ts +7 -0
- package/build/layout/loading-indicator/index.js +10 -0
- package/build/layout/loading-indicator/spec.d.ts +1 -0
- package/build/layout/loading-indicator/spec.js +11 -0
- package/build/layout/paragraph/DynamicParagraph.d.ts +7 -0
- package/build/layout/paragraph/DynamicParagraph.js +42 -0
- package/build/layout/paragraph/DynamicParagraph.messages.d.ts +13 -0
- package/build/layout/paragraph/DynamicParagraph.messages.js +13 -0
- package/build/layout/paragraph/index.d.ts +1 -0
- package/build/layout/paragraph/index.js +1 -0
- package/build/layout/paragraph/useSnackBarIfAvailable.d.ts +10 -0
- package/build/layout/paragraph/useSnackBarIfAvailable.js +9 -0
- package/build/layout/review/index.d.ts +9 -0
- package/build/layout/review/index.js +33 -0
- package/build/layout/utils.d.ts +7 -0
- package/build/layout/utils.js +31 -0
- package/build/main.css +143 -0
- package/build/schema.d.ts +1 -0
- package/build/schema.js +1 -0
- package/build/step/cameraStep/CameraStep.d.ts +8 -0
- package/build/step/cameraStep/CameraStep.js +125 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.d.ts +16 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +122 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.d.ts +18 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +18 -0
- package/build/step/cameraStep/cameraCapture/components/index.d.ts +8 -0
- package/build/step/cameraStep/cameraCapture/components/index.js +28 -0
- package/build/step/cameraStep/cameraCapture/hooks/index.d.ts +4 -0
- package/build/step/cameraStep/cameraCapture/hooks/index.js +80 -0
- package/build/step/cameraStep/cameraCapture/index.d.ts +1 -0
- package/build/step/cameraStep/cameraCapture/index.js +1 -0
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.d.ts +11 -0
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +78 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.d.ts +3 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +19 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.d.ts +13 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +13 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.d.ts +6 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +21 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.d.ts +18 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +18 -0
- package/build/step/cameraStep/cameraCapture/screens/index.d.ts +2 -0
- package/build/step/cameraStep/cameraCapture/screens/index.js +2 -0
- package/build/step/cameraStep/cameraCapture/tracking/index.d.ts +7 -0
- package/build/step/cameraStep/cameraCapture/tracking/index.js +101 -0
- package/build/step/cameraStep/cameraCapture/utils/index.d.ts +8 -0
- package/build/step/cameraStep/cameraCapture/utils/index.js +103 -0
- package/build/step/cameraStep/index.d.ts +1 -0
- package/build/step/cameraStep/index.js +1 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.d.ts +7 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +64 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.d.ts +23 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +23 -0
- package/build/step/externalConfirmationStep/index.d.ts +1 -0
- package/build/step/externalConfirmationStep/index.js +1 -0
- package/build/step/features/external/useExternal.d.ts +4 -0
- package/build/step/features/external/useExternal.js +15 -0
- package/build/step/features/index.d.ts +2 -0
- package/build/step/features/index.js +2 -0
- package/build/step/features/polling/useStepPolling.d.ts +2 -0
- package/build/step/features/polling/useStepPolling.js +44 -0
- package/build/step/index.d.ts +3 -0
- package/build/step/index.js +3 -0
- package/build/step/layoutStep/LayoutStep.d.ts +11 -0
- package/build/step/layoutStep/LayoutStep.js +34 -0
- package/build/step/layoutStep/index.d.ts +1 -0
- package/build/step/layoutStep/index.js +1 -0
- package/build/step/layoutStep/layoutService/convertStepToLayout.d.ts +8 -0
- package/build/step/layoutStep/layoutService/convertStepToLayout.js +217 -0
- package/build/step/layoutStep/layoutService/index.d.ts +2 -0
- package/build/step/layoutStep/layoutService/index.js +2 -0
- package/build/step/layoutStep/layoutService/inlineReferences.d.ts +7 -0
- package/build/step/layoutStep/layoutService/inlineReferences.js +91 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
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 { isArray, isEmpty } from '@transferwise/neptune-validation';
|
|
23
|
+
import classNames from 'classnames';
|
|
24
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
25
|
+
import { useDebouncedFunction } from '../../common/hooks/useDebouncedFunction';
|
|
26
|
+
import { useTracking } from '../../common/tracking';
|
|
27
|
+
import { generateRandomId } from '../../common/utils/generate-random-id';
|
|
28
|
+
import { getValidModelParts } from '../../common/validation/valid-model';
|
|
29
|
+
import { getValidationFailures } from '../../common/validation/validation-failures';
|
|
30
|
+
import DynamicAlert from '../../layout/alert';
|
|
31
|
+
import ControlFeedback from '../controlFeedback';
|
|
32
|
+
import GenericSchema from '../genericSchema';
|
|
33
|
+
import Help from '../help';
|
|
34
|
+
import SchemaFormControl from '../schemaFormControl';
|
|
35
|
+
import { getActiveSchemaIndex, getValidIndexFromValue } from './getActiveSchemaIndex';
|
|
36
|
+
import { isConstSchema, isNoNConstSchema } from './isConstSchema';
|
|
37
|
+
var OneOfSchema = function (props) {
|
|
38
|
+
var trackEvent = useTracking();
|
|
39
|
+
var _a = useState(false), changed = _a[0], setChanged = _a[1];
|
|
40
|
+
var _b = useState(false), focused = _b[0], setFocused = _b[1];
|
|
41
|
+
var _c = useState(false), blurred = _c[0], setBlurred = _c[1];
|
|
42
|
+
var id = useMemo(function () { return props.schema.$id || generateRandomId(); }, [props.schema.$id]);
|
|
43
|
+
var _d = useState(getActiveSchemaIndex(props.schema, props.model)), schemaIndex = _d[0], setSchemaIndex = _d[1];
|
|
44
|
+
var _e = useState(getModelPartsForSchemas(props.model, props.schema.oneOf)), models = _e[0], setModels = _e[1];
|
|
45
|
+
var debouncedTrackEvent = useDebouncedFunction(trackEvent, 200);
|
|
46
|
+
var onSearchChange = function (searchValue) {
|
|
47
|
+
debouncedTrackEvent('Dynamic Flow - OneOf Searched', {
|
|
48
|
+
oneOfId: props.schema.analyticsId,
|
|
49
|
+
searchValueLength: searchValue.length
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
// When the schema we receive from parent changes
|
|
53
|
+
useEffect(function () {
|
|
54
|
+
var modelIndex = getValidIndexFromValue(props.schema, props.model);
|
|
55
|
+
var defaultIndex = getValidIndexFromValue(props.schema, props.schema["default"]);
|
|
56
|
+
if (modelIndex === -1 && defaultIndex >= 0) {
|
|
57
|
+
onChooseNewSchema(defaultIndex, 'init');
|
|
58
|
+
}
|
|
59
|
+
}, [props.schema]);
|
|
60
|
+
if (!isArray(props.schema.oneOf)) {
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.error('Incorrect format', props.schema);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
var onChildModelChange = function (index, onChangeParameters) {
|
|
66
|
+
setModels(__spreadArray(__spreadArray(__spreadArray([], models.slice(0, index), true), [onChangeParameters.model], false), models.slice(index + 1), true));
|
|
67
|
+
setChanged(true);
|
|
68
|
+
props.onChange(onChangeParameters);
|
|
69
|
+
};
|
|
70
|
+
var onFocus = function () {
|
|
71
|
+
setFocused(true);
|
|
72
|
+
};
|
|
73
|
+
var onBlur = function () {
|
|
74
|
+
setFocused(false);
|
|
75
|
+
setBlurred(true);
|
|
76
|
+
};
|
|
77
|
+
// TODO: LOW avoid type assertion
|
|
78
|
+
var onChooseNewSchema = function (index, type) {
|
|
79
|
+
setSchemaIndex(index);
|
|
80
|
+
var newSchema = props.schema.oneOf[index];
|
|
81
|
+
if (isConstSchema(newSchema)) {
|
|
82
|
+
// If new schema is a const we want to share the parent schema, not the const
|
|
83
|
+
var model = newSchema["const"];
|
|
84
|
+
props.onChange({
|
|
85
|
+
model: model,
|
|
86
|
+
triggerSchema: props.schema,
|
|
87
|
+
triggerModel: model,
|
|
88
|
+
type: type
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
props.onChange({
|
|
93
|
+
model: models[index],
|
|
94
|
+
triggerSchema: newSchema,
|
|
95
|
+
triggerModel: models[index],
|
|
96
|
+
type: type
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (type !== 'init' && props.schema.analyticsId) {
|
|
100
|
+
trackEvent('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
|
+
return (_jsxs(_Fragment, { children: [(props.schema.oneOf.length > 1 || isConstSchema(props.schema.oneOf[0])) && (_jsxs(_Fragment, { children: [_jsxs("div", __assign({ className: classNames(formGroupClasses) }, { children: [getTitleAndHelp(props.schema, id), _jsx(SchemaFormControl, { id: id, schema: schemaForSelect, value: schemaIndex, disabled: props.disabled, onChange: onChooseNewSchema, onFocus: onFocus, onBlur: onBlur, onSearchChange: onSearchChange }), _jsx(ControlFeedback, { changed: changed, focused: focused, blurred: blurred, submitted: props.submitted, errors: errorsToString(props.errors), schema: props.schema, validations: validations, infoMessage: null })] })), props.schema.alert && _jsx(DynamicAlert, { component: props.schema.alert })] })), 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 }))] }));
|
|
114
|
+
};
|
|
115
|
+
function getTitleAndHelp(schema, id) {
|
|
116
|
+
var helpElement = schema.help ? _jsx(Help, { help: schema.help }) : null;
|
|
117
|
+
var titleElement = isConstSchema(schema.oneOf[0]) ? (_jsxs("label", __assign({ className: "control-label d-inline", htmlFor: id }, { children: [schema.title, " ", helpElement] }))) : (_jsxs("h4", __assign({ className: "m-b-2" }, { children: [schema.title, " ", helpElement] })));
|
|
118
|
+
return schema.title ? titleElement : helpElement;
|
|
119
|
+
}
|
|
120
|
+
function getValidations(props, schemaIndex) {
|
|
121
|
+
var selectedSchema = props.schema.oneOf[schemaIndex !== null && schemaIndex !== void 0 ? schemaIndex : -1];
|
|
122
|
+
if (isConstSchema(selectedSchema)) {
|
|
123
|
+
return getValidationFailures(selectedSchema["const"], props.schema, !!props.required);
|
|
124
|
+
}
|
|
125
|
+
if (schemaIndex === null || schemaIndex < 0) {
|
|
126
|
+
return getValidationFailures(null, props.schema, !!props.required);
|
|
127
|
+
}
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
function errorsToString(errors) {
|
|
131
|
+
// When oneOf represents a select, errors should be of type string
|
|
132
|
+
if (typeof errors === 'string') {
|
|
133
|
+
return errors;
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
function getModelPartsForSchemas(model, schemas) {
|
|
138
|
+
return schemas.map(function (schema) { return getValidModelParts(model, schema); });
|
|
139
|
+
}
|
|
140
|
+
// We want our model to be the index, so alter the oneOf schemas to be a const
|
|
141
|
+
function mapSchemasForSelect(schema) {
|
|
142
|
+
return __assign(__assign({}, schema), { oneOf: schema.oneOf.map(mapOneOfToConst) });
|
|
143
|
+
}
|
|
144
|
+
function mapOneOfToConst(schema, index) {
|
|
145
|
+
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;
|
|
146
|
+
// TODO LOW avoid type assertion below -- consider adding { type: 'integer' }
|
|
147
|
+
return { title: title, description: description, disabled: disabled, icon: icon, image: image, "const": index, keywords: keywords };
|
|
148
|
+
}
|
|
149
|
+
OneOfSchema.defaultProps = {
|
|
150
|
+
required: false,
|
|
151
|
+
disabled: false
|
|
152
|
+
};
|
|
153
|
+
export default OneOfSchema;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isUndefined } from '@transferwise/neptune-validation';
|
|
2
|
+
import { isValidSchema } from '../../common/validation/schema-validators';
|
|
3
|
+
import { isObjectModel } from '../../dynamic-flow-types';
|
|
4
|
+
import { isOneOfObjectSchema } from '../../dynamic-flow-types/Schema';
|
|
5
|
+
import { getBestMatchingSchemaIndexForValue } from './getBestMatchingSchemaIndexForValue';
|
|
6
|
+
import { isConstSchema, isNoNConstSchema } from './isConstSchema';
|
|
7
|
+
export var getActiveSchemaIndex = function (schema, model) {
|
|
8
|
+
var indexFromModel = getValidIndexFromValue(schema, model);
|
|
9
|
+
// If our model satisfies one of the schemas, use that schema.
|
|
10
|
+
if (indexFromModel >= 0) {
|
|
11
|
+
return indexFromModel;
|
|
12
|
+
}
|
|
13
|
+
// If we have a non-const oneOf and there's only one, active index must be the first one
|
|
14
|
+
if (schema.oneOf.length === 1 && isNoNConstSchema(schema.oneOf[0])) {
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
if (isConstSchema(schema.oneOf[0])) {
|
|
18
|
+
var indexFromDefault = getValidIndexFromValue(schema, schema["default"]);
|
|
19
|
+
// If the default value satisfies one of the schemas, use that schema.
|
|
20
|
+
if (indexFromDefault >= 0) {
|
|
21
|
+
return indexFromDefault;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (isOneOfObjectSchema(schema) && isObjectModel(model) && Object.keys(model).length >= 1) {
|
|
25
|
+
// Even if the model does not satisfy any of the schemas, it may be closer to one of them.
|
|
26
|
+
return getBestMatchingSchemaIndexForValue(schema, model);
|
|
27
|
+
}
|
|
28
|
+
if (isOneOfObjectSchema(schema) &&
|
|
29
|
+
!isUndefined(schema["default"]) &&
|
|
30
|
+
isObjectModel(schema["default"]) &&
|
|
31
|
+
Object.keys(schema["default"]).length >= 1) {
|
|
32
|
+
// Even if the default value does not satisfy any of the schemas, it may be closer to one of them.
|
|
33
|
+
return getBestMatchingSchemaIndexForValue(schema, schema["default"]);
|
|
34
|
+
}
|
|
35
|
+
// Otherwise do not default
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
export var getValidIndexFromValue = function (schema, value) {
|
|
39
|
+
return schema.oneOf.findIndex(function (childSchema) { return !isUndefined(value) && isValidSchema(value, childSchema); });
|
|
40
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isConstSchema, isNoNConstSchema } from './isConstSchema';
|
|
2
|
+
export function getBestMatchingSchemaIndexForValue(schema, value) {
|
|
3
|
+
if (value === null || value === undefined) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
var schemaPoints = schema.oneOf.map(function (childSchema) {
|
|
7
|
+
return getSchemaProperties(childSchema).reduce(function (total, _a) {
|
|
8
|
+
var key = _a[0], propertySchema = _a[1];
|
|
9
|
+
if (isConstSchema(propertySchema) && propertySchema["const"] === value[key]) {
|
|
10
|
+
return total + 2;
|
|
11
|
+
}
|
|
12
|
+
else if (isNoNConstSchema(propertySchema) && typeof value[key] !== 'undefined') {
|
|
13
|
+
return total + 1;
|
|
14
|
+
}
|
|
15
|
+
return total;
|
|
16
|
+
}, 0);
|
|
17
|
+
});
|
|
18
|
+
if (schemaPoints.every(function (p) { return p === schemaPoints[0]; })) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return schemaPoints.indexOf(Math.max.apply(Math, schemaPoints));
|
|
22
|
+
}
|
|
23
|
+
function getSchemaProperties(childSchema) {
|
|
24
|
+
return childSchema.properties !== null && typeof childSchema.properties === 'object'
|
|
25
|
+
? Object.entries(childSchema.properties)
|
|
26
|
+
: [];
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './OneOfSchema';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { isUndefined } from '@transferwise/neptune-validation';
|
|
2
|
+
export function isConstSchema(schema) {
|
|
3
|
+
return !isUndefined(schema === null || schema === void 0 ? void 0 : schema["const"]);
|
|
4
|
+
}
|
|
5
|
+
export function isNoNConstSchema(schema) {
|
|
6
|
+
return !!schema && !isConstSchema(schema);
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PersistAsyncSchema as PersistAsyncSchemaType } from '../../dynamic-flow-types';
|
|
3
|
+
import { GenericSchemaProps } from '../genericSchema/GenericSchema';
|
|
4
|
+
declare const PersistAsyncSchema: {
|
|
5
|
+
(props: PersistAsyncSchemaProps): JSX.Element;
|
|
6
|
+
defaultProps: {
|
|
7
|
+
required: boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type PersistAsyncSchemaProps = Omit<GenericSchemaProps, 'schema' | 'model' | 'errors'> & {
|
|
11
|
+
schema: PersistAsyncSchemaType;
|
|
12
|
+
model: string | null;
|
|
13
|
+
errors: string | null;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export default PersistAsyncSchema;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 PersistAsyncBasicSchema from './basic';
|
|
14
|
+
import PersistAsyncBlobSchema from './blob';
|
|
15
|
+
var PersistAsyncSchema = function (props) {
|
|
16
|
+
var schema = props.schema;
|
|
17
|
+
var persistAsyncSchemaType = schema.persistAsync.schema.type;
|
|
18
|
+
if (persistAsyncSchemaType === 'blob') {
|
|
19
|
+
return (_jsx(PersistAsyncBlobSchema, __assign({}, props)));
|
|
20
|
+
}
|
|
21
|
+
return _jsx(PersistAsyncBasicSchema, __assign({}, props));
|
|
22
|
+
};
|
|
23
|
+
PersistAsyncSchema.defaultProps = {
|
|
24
|
+
required: false
|
|
25
|
+
};
|
|
26
|
+
export default PersistAsyncSchema;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
export default defineMessages({
|
|
3
|
+
genericError: {
|
|
4
|
+
id: 'dynamicFlows.PersistAsyncSchema.genericError',
|
|
5
|
+
defaultMessage: 'Something went wrong, please try again later!',
|
|
6
|
+
description: 'Generic error message for persist async schema'
|
|
7
|
+
}
|
|
8
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PersistAsync, Schema } from '../../../dynamic-flow-types';
|
|
3
|
+
import { GenericSchemaProps } from '../../genericSchema/GenericSchema';
|
|
4
|
+
export declare const getIdFromResponse: (idProperty: string, response: Record<string, unknown>) => string | number;
|
|
5
|
+
export declare const getErrorFromResponse: (errorProperty: string, response: {
|
|
6
|
+
validation?: Record<string, unknown>;
|
|
7
|
+
}) => unknown;
|
|
8
|
+
declare const PersistAsyncBasicSchema: {
|
|
9
|
+
(props: PersistAsyncBasicSchemaProps): JSX.Element;
|
|
10
|
+
defaultProps: {
|
|
11
|
+
required: boolean;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type PersistAsyncBasicSchemaProps = Omit<GenericSchemaProps, 'schema'> & {
|
|
15
|
+
schema: Schema & {
|
|
16
|
+
persistAsync: PersistAsync;
|
|
17
|
+
};
|
|
18
|
+
errors: string | null;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export default PersistAsyncBasicSchema;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
38
|
+
import { isNull, isObject } from '@transferwise/neptune-validation';
|
|
39
|
+
import isEqual from 'lodash.isequal';
|
|
40
|
+
import { useEffect, useState } from 'react';
|
|
41
|
+
import { useIntl } from 'react-intl';
|
|
42
|
+
import { FormControlType } from '../../../common';
|
|
43
|
+
import { isStatus2xx, isStatus422 } from '../../../common/api/utils';
|
|
44
|
+
import { useFetcher } from '../../../common/contexts/fetcherContext';
|
|
45
|
+
import usePrevious from '../../../common/hooks/usePrevious';
|
|
46
|
+
import { useTracking } from '../../../common/tracking';
|
|
47
|
+
import { isValidSchema } from '../../../common/validation/schema-validators';
|
|
48
|
+
import BasicTypeSchema from '../../basicTypeSchema';
|
|
49
|
+
import { getControlType } from '../../schemaFormControl/SchemaFormControl';
|
|
50
|
+
import schema from '../../schemas/allOf.json';
|
|
51
|
+
import messages from '../PersistAsyncSchema.messages';
|
|
52
|
+
// TODO: LOW avoid type assertion below -- consider throwing if return value is not the expected type
|
|
53
|
+
export var getIdFromResponse = function (idProperty, response) {
|
|
54
|
+
return response[idProperty];
|
|
55
|
+
};
|
|
56
|
+
export var getErrorFromResponse = function (errorProperty, response) {
|
|
57
|
+
var _a;
|
|
58
|
+
return (_a = response.validation) === null || _a === void 0 ? void 0 : _a[errorProperty];
|
|
59
|
+
};
|
|
60
|
+
var controlTypesWithPersistOnChange = new Set([
|
|
61
|
+
FormControlType.RADIO,
|
|
62
|
+
FormControlType.SELECT,
|
|
63
|
+
FormControlType.DATELOOKUP,
|
|
64
|
+
FormControlType.FILE,
|
|
65
|
+
FormControlType.UPLOAD,
|
|
66
|
+
]);
|
|
67
|
+
var PersistAsyncBasicSchema = function (props) {
|
|
68
|
+
var intl = useIntl();
|
|
69
|
+
var fetcher = useFetcher();
|
|
70
|
+
var trackEvent = useTracking();
|
|
71
|
+
var _a = useState(null), persistAsyncModel = _a[0], setPersistAsyncModel = _a[1];
|
|
72
|
+
var previousPersistAsyncModel = usePrevious(persistAsyncModel);
|
|
73
|
+
var _b = useState(null), persistAsyncError = _b[0], setPersistAsyncError = _b[1];
|
|
74
|
+
var _c = useState(false), fieldSubmitted = _c[0], setFieldSubmitted = _c[1];
|
|
75
|
+
var _d = useState(null), abortController = _d[0], setAbortController = _d[1];
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (controlTypesWithPersistOnChange.has(
|
|
78
|
+
// TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
|
|
79
|
+
getControlType(props.schema.persistAsync.schema))) {
|
|
80
|
+
persistAsyncIfValid();
|
|
81
|
+
}
|
|
82
|
+
}, [persistAsyncModel]);
|
|
83
|
+
var setGenericPersistAsyncError = function () {
|
|
84
|
+
return setPersistAsyncError(intl.formatMessage(messages.genericError));
|
|
85
|
+
};
|
|
86
|
+
var getPersistAsyncResponse = function (currentPersistAsyncModel, persistAsyncSpec) { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
+
var signal, requestBody, persistAsyncFetch, response, responseBody, _a, idProperty, param, id, validation, error, _b;
|
|
88
|
+
var _c;
|
|
89
|
+
return __generator(this, function (_d) {
|
|
90
|
+
switch (_d.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
signal = abortCurrentRequestAndGetNewAbortSignal();
|
|
93
|
+
requestBody = (_c = {}, _c[persistAsyncSpec.param] = currentPersistAsyncModel, _c);
|
|
94
|
+
setFieldSubmitted(true); // persist async initiated implied the field has been submitted
|
|
95
|
+
_d.label = 1;
|
|
96
|
+
case 1:
|
|
97
|
+
_d.trys.push([1, 4, , 5]);
|
|
98
|
+
trackEvent('Dynamic Flow - PersistAsync', { status: 'pending', schemaId: schema.$id });
|
|
99
|
+
persistAsyncFetch = fetcher(persistAsyncSpec.url, {
|
|
100
|
+
method: persistAsyncSpec.method,
|
|
101
|
+
headers: { 'Content-Type': 'application/json' },
|
|
102
|
+
body: JSON.stringify(requestBody),
|
|
103
|
+
signal: signal
|
|
104
|
+
});
|
|
105
|
+
props.onPersistAsync(persistAsyncFetch);
|
|
106
|
+
return [4 /*yield*/, persistAsyncFetch];
|
|
107
|
+
case 2:
|
|
108
|
+
response = _d.sent();
|
|
109
|
+
return [4 /*yield*/, response.json()];
|
|
110
|
+
case 3:
|
|
111
|
+
responseBody = _d.sent();
|
|
112
|
+
if (!isObject(responseBody)) {
|
|
113
|
+
throw new Error('Response is not an object');
|
|
114
|
+
}
|
|
115
|
+
_a = props.schema.persistAsync, idProperty = _a.idProperty, param = _a.param;
|
|
116
|
+
if (isStatus2xx(response.status)) {
|
|
117
|
+
id = getIdFromResponse(idProperty, responseBody);
|
|
118
|
+
props.onChange({ model: id, triggerSchema: props.schema, triggerModel: id });
|
|
119
|
+
}
|
|
120
|
+
else if (isStatus422(response.status)) {
|
|
121
|
+
validation = responseBody.validation;
|
|
122
|
+
error = (isObject(validation) && (validation === null || validation === void 0 ? void 0 : validation[param])) || null;
|
|
123
|
+
setPersistAsyncError(error);
|
|
124
|
+
props.onChange({ model: null, triggerSchema: props.schema, triggerModel: null });
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
setGenericPersistAsyncError();
|
|
128
|
+
}
|
|
129
|
+
trackEvent('Dynamic Flow - PersistAsync', { status: 'success', schemaId: schema.$id });
|
|
130
|
+
return [3 /*break*/, 5];
|
|
131
|
+
case 4:
|
|
132
|
+
_b = _d.sent();
|
|
133
|
+
trackEvent('Dynamic Flow - PersistAsync', { status: 'failure', schemaId: schema.$id });
|
|
134
|
+
setGenericPersistAsyncError();
|
|
135
|
+
return [3 /*break*/, 5];
|
|
136
|
+
case 5: return [2 /*return*/];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); };
|
|
140
|
+
var abortCurrentRequestAndGetNewAbortSignal = function () {
|
|
141
|
+
if (abortController) {
|
|
142
|
+
abortController.abort();
|
|
143
|
+
}
|
|
144
|
+
var newAbortController = new AbortController();
|
|
145
|
+
setAbortController(newAbortController);
|
|
146
|
+
return newAbortController.signal;
|
|
147
|
+
};
|
|
148
|
+
var persistAsyncIfValid = function () {
|
|
149
|
+
if (!isNull(persistAsyncModel) && !isEqual(persistAsyncModel, previousPersistAsyncModel)) {
|
|
150
|
+
void getPersistAsyncResponse(persistAsyncModel, props.schema.persistAsync);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var onBlur = function () {
|
|
154
|
+
persistAsyncIfValid();
|
|
155
|
+
};
|
|
156
|
+
var persistAsyncOnChange = function (_a) {
|
|
157
|
+
var newPersistAsyncModel = _a.model;
|
|
158
|
+
setPersistAsyncError(null);
|
|
159
|
+
if (isValidSchema(newPersistAsyncModel, props.schema.persistAsync.schema)) {
|
|
160
|
+
setPersistAsyncModel(newPersistAsyncModel);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return (_jsx(BasicTypeSchema, { required: props.required, submitted: props.submitted || fieldSubmitted, schema: props.schema.persistAsync.schema, errors: persistAsyncError || props.errors, model: null, infoMessage: null, onChange: persistAsyncOnChange, onBlur: onBlur }));
|
|
164
|
+
};
|
|
165
|
+
PersistAsyncBasicSchema.defaultProps = {
|
|
166
|
+
required: false
|
|
167
|
+
};
|
|
168
|
+
export default PersistAsyncBasicSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PersistAsyncBasicSchema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PersistAsyncBasicSchema';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlobSchema, PersistAsync, Schema } from '../../../dynamic-flow-types';
|
|
3
|
+
import { GenericSchemaProps } from '../../genericSchema/GenericSchema';
|
|
4
|
+
declare const PersistAsyncBlobSchema: {
|
|
5
|
+
(props: PersistAsyncBlobSchemaProps): JSX.Element;
|
|
6
|
+
defaultProps: {
|
|
7
|
+
required: boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type PersistAsyncBlobSchemaProps = Omit<GenericSchemaProps, 'model'> & {
|
|
11
|
+
schema: Schema & {
|
|
12
|
+
persistAsync: PersistAsync & {
|
|
13
|
+
schema: BlobSchema;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
model: string | null;
|
|
17
|
+
errors: string | null;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export default PersistAsyncBlobSchema;
|