@wise/dynamic-flow-client 0.4.0-beta-d2067b.7 → 0.4.0
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/constants/DateMode.js +7 -0
- package/build/common/constants/FormControlType.js +20 -0
- package/build/common/constants/MonthFormat.js +7 -0
- package/build/common/constants/SchemaType.js +14 -0
- package/build/common/constants/Size.js +10 -0
- package/build/common/constants/index.js +21 -0
- package/build/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +41 -0
- package/build/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +17 -0
- package/build/common/contexts/eventsContext/EventsContext.js +39 -0
- package/build/common/contexts/fetcherContexts/FetcherContexts.js +42 -0
- package/build/common/contexts/index.js +20 -0
- package/build/common/contexts/logContext/LogContext.js +45 -0
- package/build/common/hooks/index.js +23 -0
- package/build/common/hooks/useDebouncedFunction/useDebouncedFunction.js +13 -0
- package/build/common/hooks/useExternal/useExternal.js +19 -0
- package/build/common/hooks/useExternalStepPolling/useExternalStepPolling.js +73 -0
- package/build/common/hooks/usePersistAsync/usePersistAsync.js +177 -0
- package/build/common/hooks/usePolling/usePolling.js +53 -0
- package/build/common/hooks/usePrevious/usePrevious.js +12 -0
- package/build/common/hooks/useStepPolling/useStepPolling.js +48 -0
- package/build/common/makeFetcher/index.js +17 -0
- package/build/common/makeFetcher/makeFetcher.js +37 -0
- package/build/common/messages.js +10 -0
- package/build/common/utils/api-utils.js +20 -0
- package/build/common/utils/date-utils.js +27 -0
- package/build/common/utils/debounce.js +42 -0
- package/build/common/utils/file-utils.js +51 -0
- package/build/common/utils/id-utils.js +9 -0
- package/build/common/utils/index.js +24 -0
- package/build/common/utils/is-equal.js +25 -0
- package/build/common/utils/schema-utils.js +55 -0
- package/build/common/utils/step-utils.js +47 -0
- package/build/common/validators/index.js +28 -0
- package/build/common/validators/models/model-validators.js +69 -0
- package/build/common/validators/models/models.utils.js +130 -0
- package/build/common/validators/schemas/schema-validators.js +101 -0
- package/build/common/validators/types/type-validators.js +25 -0
- package/build/common/validators/validationFailures/validation-failures.js +151 -0
- package/build/common/validators/validationFailures/validation-failures.utils.js +51 -0
- package/build/common/validators/values/value-validators.js +9 -0
- package/build/dynamicFlow/DynamicFlow.js +372 -0
- package/build/dynamicFlow/DynamicFlowStep.js +36 -0
- package/build/dynamicFlow/DynamicFlowTypes.js +8 -0
- package/build/dynamicFlow/index.js +16 -0
- package/build/dynamicFlow/stories/DynamicFlow.story.js +36 -0
- package/build/dynamicFlow/stories/EditableDynamicFlow.js +67 -0
- package/build/dynamicFlow/stories/fixtureFetcher.js +118 -0
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.js +47 -0
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.js +15 -0
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.js +19 -0
- package/build/dynamicFlow/utils/index.js +23 -0
- package/build/dynamicFlow/utils/responseParsers/response-parsers.js +131 -0
- package/build/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +27 -0
- package/build/dynamicFlow/utils/useDynamicFlowState.js +114 -0
- package/build/dynamicFlow/utils/useLoader.js +26 -0
- package/build/fixtures/components/alert.js +33 -0
- package/build/fixtures/components/box.js +22 -0
- package/build/fixtures/components/button.js +67 -0
- package/build/fixtures/components/columns.js +38 -0
- package/build/fixtures/components/copyable.js +24 -0
- package/build/fixtures/components/decision.js +56 -0
- package/build/fixtures/components/heading.js +16 -0
- package/build/fixtures/components/image.js +25 -0
- package/build/fixtures/components/index.js +40 -0
- package/build/fixtures/components/info.js +19 -0
- package/build/fixtures/components/list.js +36 -0
- package/build/fixtures/components/loading-indicator.js +18 -0
- package/build/fixtures/components/paragraph.js +30 -0
- package/build/fixtures/components/review.js +62 -0
- package/build/fixtures/examples/camera-capture.js +123 -0
- package/build/fixtures/examples/index.js +24 -0
- package/build/fixtures/examples/recipient-update.js +252 -0
- package/build/fixtures/examples/recipient.js +315 -0
- package/build/fixtures/examples/single-file-upload.js +100 -0
- package/build/fixtures/examples/step-validation-errors.js +77 -0
- package/build/fixtures/features/action-response.js +31 -0
- package/build/fixtures/features/external.js +33 -0
- package/build/fixtures/features/index.js +24 -0
- package/build/fixtures/features/persist-async.js +46 -0
- package/build/fixtures/features/polling.js +35 -0
- package/build/fixtures/features/validation-async.js +40 -0
- package/build/fixtures/index.js +49 -0
- package/build/fixtures/jsonSchemaForm/allOf.js +121 -0
- package/build/fixtures/jsonSchemaForm/audRecipient.js +1106 -0
- package/build/fixtures/jsonSchemaForm/currency.js +50 -0
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.js +39 -0
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.js +38 -0
- package/build/fixtures/jsonSchemaForm/oneOf.js +121 -0
- package/build/fixtures/jsonSchemaForm/oneOfTabs.js +55 -0
- package/build/fixtures/jsonSchemaForm/promotedOneOf.js +58 -0
- package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.js +104 -0
- package/build/fixtures/jsonSchemaForm/simple.js +50 -0
- package/build/fixtures/jsonSchemaForm/uploadPersistAsync.js +73 -0
- package/build/fixtures/jsonSchemaForm/validationAsync.js +25 -0
- package/build/fixtures/layouts/all.js +178 -0
- package/build/fixtures/layouts/final-step-layout.js +41 -0
- package/build/fixtures/layouts/index.js +26 -0
- package/build/fixtures/layouts/list.js +35 -0
- package/build/fixtures/layouts/pay-in.js +99 -0
- package/build/fixtures/layouts/review.js +162 -0
- package/build/fixtures/layouts/success.js +68 -0
- package/build/fixtures/responses/action-response-final.js +26 -0
- package/build/fixtures/responses/action.js +4 -0
- package/build/fixtures/responses/exit.js +4 -0
- package/build/fixtures/responses/index.js +22 -0
- package/build/fixtures/responses/recipient-update-final.js +26 -0
- package/build/fixtures/schemas/basic-form.js +41 -0
- package/build/fixtures/schemas/index.js +22 -0
- package/build/fixtures/schemas/number-and-integer.js +43 -0
- package/build/fixtures/schemas/one-of.js +225 -0
- package/build/fixtures/schemas/string-formats.js +64 -0
- package/build/fixtures/utils/image-util.js +22 -0
- package/build/formControl/FormControl.js +243 -0
- package/build/formControl/index.js +16 -0
- package/build/formControl/utils/index.js +17 -0
- package/build/formControl/utils/value-utils.js +116 -0
- package/build/i18n/index.js +36 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +35 -0
- package/build/jsonSchemaForm/JsonSchemaForm.js +34 -0
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +59 -0
- package/build/jsonSchemaForm/allOfSchema/index.js +16 -0
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +30 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +31 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +16 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +145 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +20 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +16 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +18 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +90 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +21 -0
- package/build/jsonSchemaForm/arrayTypeSchema/index.js +16 -0
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +108 -0
- package/build/jsonSchemaForm/basicTypeSchema/index.js +16 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +84 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +55 -0
- package/build/jsonSchemaForm/controlFeedback/index.js +16 -0
- package/build/jsonSchemaForm/genericSchema/GenericSchema.js +127 -0
- package/build/jsonSchemaForm/genericSchema/index.js +16 -0
- package/build/jsonSchemaForm/help/Help.js +14 -0
- package/build/jsonSchemaForm/help/Help.messages.js +10 -0
- package/build/jsonSchemaForm/help/index.js +16 -0
- package/build/jsonSchemaForm/index.js +16 -0
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +83 -0
- package/build/jsonSchemaForm/objectSchema/index.js +16 -0
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +155 -0
- package/build/jsonSchemaForm/oneOfSchema/index.js +16 -0
- package/build/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.js +13 -0
- package/build/jsonSchemaForm/oneOfSchema/utils/index.js +18 -0
- package/build/jsonSchemaForm/oneOfSchema/utils/one-of-utils.js +70 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +31 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +10 -0
- package/build/jsonSchemaForm/persistAsyncSchema/index.js +16 -0
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +173 -0
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +16 -0
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +131 -0
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +36 -0
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +16 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +77 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/index.js +16 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +12 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +29 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +36 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +34 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +60 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +15 -0
- package/build/jsonSchemaForm/readOnlySchema/index.js +16 -0
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +111 -0
- package/build/jsonSchemaForm/schemaFormControl/index.js +16 -0
- package/build/jsonSchemaForm/schemaFormControl/utils/currency-utils.js +77 -0
- package/build/jsonSchemaForm/schemaFormControl/utils/index.js +17 -0
- package/build/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +127 -0
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +151 -0
- package/build/jsonSchemaForm/validationAsyncSchema/index.js +16 -0
- package/build/layout/DynamicLayout.js +63 -0
- package/build/layout/alert/DynamicAlert.js +31 -0
- package/build/layout/box/DynamicBox.js +43 -0
- package/build/layout/button/DynamicButton.js +60 -0
- package/build/layout/columns/DynamicColumns.js +40 -0
- package/build/layout/decision/DynamicDecision.js +40 -0
- package/build/layout/divider/DynamicDivider.js +11 -0
- package/build/layout/external/DynamicExternal.js +37 -0
- package/build/layout/external/DynamicExternal.messages.js +10 -0
- package/build/layout/form/DynamicForm.js +27 -0
- package/build/layout/heading/DynamicHeading.js +33 -0
- package/build/layout/icon/DynamicIcon.js +50 -0
- package/build/layout/image/DynamicImage.js +112 -0
- package/build/layout/index.js +48 -0
- package/build/layout/info/DynamicInfo.js +21 -0
- package/build/layout/list/DynamicList.js +33 -0
- package/build/layout/loadingIndicator/DynamicLoadingIndicator.js +13 -0
- package/build/layout/paragraph/DynamicParagraph.js +48 -0
- package/build/layout/paragraph/DynamicParagraph.messages.js +15 -0
- package/build/layout/paragraph/useSnackBarIfAvailable.js +13 -0
- package/build/layout/review/DynamicReview.js +35 -0
- package/build/layout/utils.js +35 -0
- package/build/step/cameraStep/CameraStep.js +130 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +127 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +20 -0
- package/build/step/cameraStep/cameraCapture/components/index.js +36 -0
- package/build/step/cameraStep/cameraCapture/hooks/index.js +84 -0
- package/build/step/cameraStep/cameraCapture/index.js +16 -0
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +80 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +24 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +15 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +26 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +20 -0
- package/build/step/cameraStep/cameraCapture/screens/index.js +18 -0
- package/build/step/cameraStep/cameraCapture/tracking/index.js +104 -0
- package/build/step/cameraStep/cameraCapture/utils/index.js +114 -0
- package/build/step/cameraStep/index.js +16 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +69 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +25 -0
- package/build/step/externalConfirmationStep/index.js +16 -0
- package/build/step/index.js +20 -0
- package/build/step/layoutStep/LayoutStep.js +35 -0
- package/build/step/layoutStep/index.js +16 -0
- package/build/step/layoutStep/utils/index.js +18 -0
- package/build/step/layoutStep/utils/inline-reference-utils.js +95 -0
- package/build/step/layoutStep/utils/layout-utils.js +222 -0
- package/build/types/common/FormControl.js +2 -0
- package/build/types/index.d.ts +15 -10
- package/build/types/index.js +42 -0
- package/build/types/specification/Action.js +2 -0
- package/build/types/specification/FileUploadSchema.js +8 -0
- package/build/types/specification/LayoutComponent.js +2 -0
- package/build/types/specification/Model.js +38 -0
- package/build/types/specification/PersistAsync.js +2 -0
- package/build/types/specification/Polling.js +2 -0
- package/build/types/specification/Promotion.js +2 -0
- package/build/types/specification/Schema.js +67 -0
- package/build/types/specification/Step.js +8 -0
- package/build/types/specification/ValidationAsync.js +2 -0
- package/build/types/specification/core.js +2 -0
- package/package.json +23 -24
- package/build/main.js +0 -6980
- package/build/main.min.js +0 -10
- package/build/types/types/index.d.ts +0 -15
- /package/build/{types/common → common}/constants/DateMode.d.ts +0 -0
- /package/build/{types/common → common}/constants/FormControlType.d.ts +0 -0
- /package/build/{types/common → common}/constants/MonthFormat.d.ts +0 -0
- /package/build/{types/common → common}/constants/SchemaType.d.ts +0 -0
- /package/build/{types/common → common}/constants/Size.d.ts +0 -0
- /package/build/{types/common → common}/constants/index.d.ts +0 -0
- /package/build/{types/common → common}/contexts/dynamicFlowContexts/DynamicFlowContexts.d.ts +0 -0
- /package/build/{types/common → common}/contexts/dynamicFlowContexts/usePendingPromiseCounter.d.ts +0 -0
- /package/build/{types/common → common}/contexts/eventsContext/EventsContext.d.ts +0 -0
- /package/build/{types/common → common}/contexts/fetcherContexts/FetcherContexts.d.ts +0 -0
- /package/build/{types/common → common}/contexts/index.d.ts +0 -0
- /package/build/{types/common → common}/contexts/logContext/LogContext.d.ts +0 -0
- /package/build/{types/common → common}/hooks/index.d.ts +0 -0
- /package/build/{types/common → common}/hooks/useDebouncedFunction/useDebouncedFunction.d.ts +0 -0
- /package/build/{types/common → common}/hooks/useExternal/useExternal.d.ts +0 -0
- /package/build/{types/common → common}/hooks/useExternalStepPolling/useExternalStepPolling.d.ts +0 -0
- /package/build/{types/common → common}/hooks/usePersistAsync/usePersistAsync.d.ts +0 -0
- /package/build/{types/common → common}/hooks/usePolling/usePolling.d.ts +0 -0
- /package/build/{types/common → common}/hooks/usePrevious/usePrevious.d.ts +0 -0
- /package/build/{types/common → common}/hooks/useStepPolling/useStepPolling.d.ts +0 -0
- /package/build/{types/common → common}/makeFetcher/index.d.ts +0 -0
- /package/build/{types/common → common}/makeFetcher/makeFetcher.d.ts +0 -0
- /package/build/{types/common → common}/messages.d.ts +0 -0
- /package/build/{types/common → common}/utils/api-utils.d.ts +0 -0
- /package/build/{types/common → common}/utils/date-utils.d.ts +0 -0
- /package/build/{types/common → common}/utils/debounce.d.ts +0 -0
- /package/build/{types/common → common}/utils/file-utils.d.ts +0 -0
- /package/build/{types/common → common}/utils/id-utils.d.ts +0 -0
- /package/build/{types/common → common}/utils/index.d.ts +0 -0
- /package/build/{types/common → common}/utils/is-equal.d.ts +0 -0
- /package/build/{types/common → common}/utils/schema-utils.d.ts +0 -0
- /package/build/{types/common → common}/utils/step-utils.d.ts +0 -0
- /package/build/{types/common → common}/validators/index.d.ts +0 -0
- /package/build/{types/common → common}/validators/models/model-validators.d.ts +0 -0
- /package/build/{types/common → common}/validators/models/models.utils.d.ts +0 -0
- /package/build/{types/common → common}/validators/schemas/schema-validators.d.ts +0 -0
- /package/build/{types/common → common}/validators/types/type-validators.d.ts +0 -0
- /package/build/{types/common → common}/validators/validationFailures/validation-failures.d.ts +0 -0
- /package/build/{types/common → common}/validators/validationFailures/validation-failures.utils.d.ts +0 -0
- /package/build/{types/common → common}/validators/values/value-validators.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/DynamicFlow.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/DynamicFlowStep.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/DynamicFlowTypes.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/index.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/stories/DynamicFlow.story.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/stories/EditableDynamicFlow.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/stories/fixtureFetcher.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/errorBoundary/ErrorBoundary.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/errorBoundary/ErrorBoundary.messages.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/errorBoundary/ErrorBoundaryAlert.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/index.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/responseParsers/response-parsers.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/useDebouncedRefresh/useDebouncedRefresh.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/useDynamicFlowState.d.ts +0 -0
- /package/build/{types/dynamicFlow → dynamicFlow}/utils/useLoader.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/alert.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/box.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/button.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/columns.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/copyable.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/decision.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/heading.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/image.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/index.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/info.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/list.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/loading-indicator.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/paragraph.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/components/review.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/examples/camera-capture.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/examples/index.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/examples/recipient-update.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/examples/recipient.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/examples/single-file-upload.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/examples/step-validation-errors.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/features/action-response.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/features/external.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/features/index.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/features/persist-async.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/features/polling.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/features/validation-async.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/index.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/allOf.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/audRecipient.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/currency.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/multipleFileUploadBase64.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/multipleFileUploadBlob.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/oneOf.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/oneOfTabs.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/promotedOneOf.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/promotedOneOfCheckbox.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/simple.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/uploadPersistAsync.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/jsonSchemaForm/validationAsync.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/layouts/all.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/layouts/final-step-layout.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/layouts/index.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/layouts/list.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/layouts/pay-in.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/layouts/review.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/layouts/success.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/responses/action-response-final.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/responses/action.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/responses/exit.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/responses/index.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/responses/recipient-update-final.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/schemas/basic-form.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/schemas/index.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/schemas/number-and-integer.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/schemas/one-of.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/schemas/string-formats.d.ts +0 -0
- /package/build/{types/fixtures → fixtures}/utils/image-util.d.ts +0 -0
- /package/build/{types/formControl → formControl}/FormControl.d.ts +0 -0
- /package/build/{types/formControl → formControl}/index.d.ts +0 -0
- /package/build/{types/formControl → formControl}/utils/index.d.ts +0 -0
- /package/build/{types/formControl → formControl}/utils/value-utils.d.ts +0 -0
- /package/build/{types/i18n → i18n}/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/JsonSchemaForm.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/allOfSchema/AllOfSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/allOfSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/ArraySchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/arrayTypeSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/basicTypeSchema/BasicTypeSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/basicTypeSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/controlFeedback/ControlFeedback.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/controlFeedback/ControlFeedback.messages.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/controlFeedback/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/genericSchema/GenericSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/genericSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/help/Help.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/help/Help.messages.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/help/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/objectSchema/ObjectSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/objectSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/oneOfSchema/OneOfSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/oneOfSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/oneOfSchema/utils/const-schema-utils.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/oneOfSchema/utils/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/oneOfSchema/utils/one-of-utils.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/PersistAsyncSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/PersistAsyncSchema.messages.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/persistAsyncBasicSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/persistAsyncSchema/persistAsyncBlobSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/promotedOneOfSchema/PromotedOneOfSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/promotedOneOfSchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/promotedOneOfSchema/promoted-one-of-utils.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/readOnlySchema/ReadOnlySchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/readOnlySchema/ReadOnlySchema.messages.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/readOnlySchema/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/schemaFormControl/SchemaFormControl.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/schemaFormControl/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/schemaFormControl/utils/currency-utils.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/schemaFormControl/utils/index.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/schemaFormControl/utils/mapping-utils.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/validationAsyncSchema/ValidationAsyncSchema.d.ts +0 -0
- /package/build/{types/jsonSchemaForm → jsonSchemaForm}/validationAsyncSchema/index.d.ts +0 -0
- /package/build/{types/layout → layout}/DynamicLayout.d.ts +0 -0
- /package/build/{types/layout → layout}/alert/DynamicAlert.d.ts +0 -0
- /package/build/{types/layout → layout}/box/DynamicBox.d.ts +0 -0
- /package/build/{types/layout → layout}/button/DynamicButton.d.ts +0 -0
- /package/build/{types/layout → layout}/columns/DynamicColumns.d.ts +0 -0
- /package/build/{types/layout → layout}/decision/DynamicDecision.d.ts +0 -0
- /package/build/{types/layout → layout}/divider/DynamicDivider.d.ts +0 -0
- /package/build/{types/layout → layout}/external/DynamicExternal.d.ts +0 -0
- /package/build/{types/layout → layout}/external/DynamicExternal.messages.d.ts +0 -0
- /package/build/{types/layout → layout}/form/DynamicForm.d.ts +0 -0
- /package/build/{types/layout → layout}/heading/DynamicHeading.d.ts +0 -0
- /package/build/{types/layout → layout}/icon/DynamicIcon.d.ts +0 -0
- /package/build/{types/layout → layout}/image/DynamicImage.d.ts +0 -0
- /package/build/{types/layout → layout}/index.d.ts +0 -0
- /package/build/{types/layout → layout}/info/DynamicInfo.d.ts +0 -0
- /package/build/{types/layout → layout}/list/DynamicList.d.ts +0 -0
- /package/build/{types/layout → layout}/loadingIndicator/DynamicLoadingIndicator.d.ts +0 -0
- /package/build/{types/layout → layout}/paragraph/DynamicParagraph.d.ts +0 -0
- /package/build/{types/layout → layout}/paragraph/DynamicParagraph.messages.d.ts +0 -0
- /package/build/{types/layout → layout}/paragraph/useSnackBarIfAvailable.d.ts +0 -0
- /package/build/{types/layout → layout}/review/DynamicReview.d.ts +0 -0
- /package/build/{types/layout → layout}/utils.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/CameraStep.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/CameraCapture.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/CameraCapture.messages.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/components/index.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/hooks/index.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/index.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/overlay/Overlay.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/screens/index.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/tracking/index.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/cameraCapture/utils/index.d.ts +0 -0
- /package/build/{types/step → step}/cameraStep/index.d.ts +0 -0
- /package/build/{types/step → step}/externalConfirmationStep/ExternalConfirmationStep.d.ts +0 -0
- /package/build/{types/step → step}/externalConfirmationStep/ExternalConfirmationStep.messages.d.ts +0 -0
- /package/build/{types/step → step}/externalConfirmationStep/index.d.ts +0 -0
- /package/build/{types/step → step}/index.d.ts +0 -0
- /package/build/{types/step → step}/layoutStep/LayoutStep.d.ts +0 -0
- /package/build/{types/step → step}/layoutStep/index.d.ts +0 -0
- /package/build/{types/step → step}/layoutStep/utils/index.d.ts +0 -0
- /package/build/{types/step → step}/layoutStep/utils/inline-reference-utils.d.ts +0 -0
- /package/build/{types/step → step}/layoutStep/utils/layout-utils.d.ts +0 -0
- /package/build/types/{types/common → common}/FormControl.d.ts +0 -0
- /package/build/types/{types/specification → specification}/Action.d.ts +0 -0
- /package/build/types/{types/specification → specification}/FileUploadSchema.d.ts +0 -0
- /package/build/types/{types/specification → specification}/LayoutComponent.d.ts +0 -0
- /package/build/types/{types/specification → specification}/Model.d.ts +0 -0
- /package/build/types/{types/specification → specification}/PersistAsync.d.ts +0 -0
- /package/build/types/{types/specification → specification}/Polling.d.ts +0 -0
- /package/build/types/{types/specification → specification}/Promotion.d.ts +0 -0
- /package/build/types/{types/specification → specification}/Schema.d.ts +0 -0
- /package/build/types/{types/specification → specification}/Step.d.ts +0 -0
- /package/build/types/{types/specification → specification}/ValidationAsync.d.ts +0 -0
- /package/build/types/{types/specification → specification}/core.d.ts +0 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
51
|
+
var react_1 = require("react");
|
|
52
|
+
var react_intl_1 = require("react-intl");
|
|
53
|
+
var contexts_1 = require("../common/contexts");
|
|
54
|
+
var validators_1 = require("../common/validators");
|
|
55
|
+
var types_1 = require("../types");
|
|
56
|
+
var DynamicFlowStep_1 = require("./DynamicFlowStep");
|
|
57
|
+
var utils_1 = require("./utils");
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
59
|
+
var noop = function () { };
|
|
60
|
+
/**
|
|
61
|
+
* ## DynamicFlow
|
|
62
|
+
*
|
|
63
|
+
* The dynamic flow component is responsible for the asynchronous actions occuring
|
|
64
|
+
* within a dynamic flow, managing transitions between steps as well as refreshing
|
|
65
|
+
* requirements. It doesn't control any view logic, but takes the step definition
|
|
66
|
+
* and reformats it to use a LayoutStep for presentation.
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
var DynamicFlowComponent = function (_a) {
|
|
70
|
+
var flowId = _a.flowId, fetcher = _a.fetcher, flowUrl = _a.flowUrl, initialAction = _a.initialAction, initialStep = _a.initialStep, loaderConfig = _a.loaderConfig, _b = _a.displayStepTitle, displayStepTitle = _b === void 0 ? true : _b, onComplete = _a.onComplete, _c = _a.onStepChange, onStepChange = _c === void 0 ? noop : _c, onError = _a.onError, _d = _a.onEvent, onEvent = _d === void 0 ? noop : _d, _e = _a.onLog, onLog = _e === void 0 ? noop : _e;
|
|
71
|
+
var locale = (0, react_intl_1.useIntl)().locale;
|
|
72
|
+
var _f = (0, utils_1.useDynamicFlowState)(initialStep), formErrors = _f.formErrors, globalError = _f.globalError, step = _f.step, models = _f.models, etag = _f.etag, modelIsValid = _f.modelIsValid, setFormErrors = _f.setFormErrors, setGlobalError = _f.setGlobalError, setStepAndEtag = _f.setStepAndEtag, setSchemaModel = _f.setSchemaModel;
|
|
73
|
+
var _g = (0, react_1.useState)(false), submitted = _g[0], setSubmitted = _g[1];
|
|
74
|
+
var _h = (0, utils_1.useLoader)(loaderConfig, initialStep ? 'idle' : 'initial'), loadingState = _h.loadingState, setLoadingState = _h.setLoadingState, loader = _h.loader;
|
|
75
|
+
var logWarning = (0, contexts_1.getLogger)('warning', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
|
|
76
|
+
var logError = (0, contexts_1.getLogger)('error', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
|
|
77
|
+
var logCritical = (0, contexts_1.getLogger)('critical', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
|
|
78
|
+
var analyticsMetadata = (0, react_1.useMemo)(function () { var _a; return (__assign({ flowId: flowId, stepId: step === null || step === void 0 ? void 0 : step.key }, ((_a = step === null || step === void 0 ? void 0 : step.analytics) !== null && _a !== void 0 ? _a : {}))); }, [flowId, step]);
|
|
79
|
+
var dispatchEvent = (0, react_1.useMemo)(function () { return (0, contexts_1.getEventDispatcher)(onEvent, analyticsMetadata); }, [onEvent, analyticsMetadata]);
|
|
80
|
+
var triggerActionRequest = (0, react_1.useCallback)(function (_a) {
|
|
81
|
+
var action = _a.action, data = _a.data, etag = _a.etag;
|
|
82
|
+
var url = action.url, _b = action.method, method = _b === void 0 ? 'POST' : _b;
|
|
83
|
+
return fetcher(url !== null && url !== void 0 ? url : '', {
|
|
84
|
+
method: method,
|
|
85
|
+
headers: __assign({ 'accept-language': locale, 'Content-Type': 'application/json' }, (etag ? { 'If-None-Match': etag } : {})),
|
|
86
|
+
credentials: 'include',
|
|
87
|
+
body: method === 'GET' ? undefined : JSON.stringify(data)
|
|
88
|
+
});
|
|
89
|
+
}, [fetcher, locale]);
|
|
90
|
+
var fetchNextStep = function (action, data) {
|
|
91
|
+
if (data === void 0) { data = {}; }
|
|
92
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var response, error_1;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
switch (_a.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
setLoadingState(loadingState === 'initial' ? 'initial' : 'submission');
|
|
98
|
+
_a.label = 1;
|
|
99
|
+
case 1:
|
|
100
|
+
_a.trys.push([1, 3, , 4]);
|
|
101
|
+
dispatchEvent('Dynamic Flow - Step Submitted', { actionId: action.$id });
|
|
102
|
+
return [4 /*yield*/, triggerActionRequest({ action: action, data: data })];
|
|
103
|
+
case 2:
|
|
104
|
+
response = _a.sent();
|
|
105
|
+
return [2 /*return*/, handleFetchResponse(response, 'submission')];
|
|
106
|
+
case 3:
|
|
107
|
+
error_1 = _a.sent();
|
|
108
|
+
handleFetchError(error_1, 'Error fetching next step');
|
|
109
|
+
return [3 /*break*/, 4];
|
|
110
|
+
case 4: return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
var fetchRefreshStep = function (action, data, etag) { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
+
var response, error_2;
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
setLoadingState('refresh');
|
|
121
|
+
_a.label = 1;
|
|
122
|
+
case 1:
|
|
123
|
+
_a.trys.push([1, 4, , 5]);
|
|
124
|
+
dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'pending' });
|
|
125
|
+
return [4 /*yield*/, triggerActionRequest({ action: action, data: data, etag: etag })];
|
|
126
|
+
case 2:
|
|
127
|
+
response = _a.sent();
|
|
128
|
+
return [4 /*yield*/, handleFetchResponse(response, 'refresh')];
|
|
129
|
+
case 3:
|
|
130
|
+
_a.sent();
|
|
131
|
+
setLoadingState('idle');
|
|
132
|
+
return [3 /*break*/, 5];
|
|
133
|
+
case 4:
|
|
134
|
+
error_2 = _a.sent();
|
|
135
|
+
handleFetchError(error_2, 'Error fetching refresh step');
|
|
136
|
+
return [3 /*break*/, 5];
|
|
137
|
+
case 5: return [2 /*return*/];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}); };
|
|
141
|
+
var fetchExitResult = function (action, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
142
|
+
var response, exitResult, error_3;
|
|
143
|
+
return __generator(this, function (_a) {
|
|
144
|
+
switch (_a.label) {
|
|
145
|
+
case 0:
|
|
146
|
+
_a.trys.push([0, 3, , 4]);
|
|
147
|
+
return [4 /*yield*/, triggerActionRequest({ action: action, data: data })];
|
|
148
|
+
case 1:
|
|
149
|
+
response = _a.sent();
|
|
150
|
+
return [4 /*yield*/, (0, utils_1.parseExitResponse)(response)];
|
|
151
|
+
case 2:
|
|
152
|
+
exitResult = _a.sent();
|
|
153
|
+
onCloseWithEvent(__assign(__assign({}, exitResult), action.result));
|
|
154
|
+
return [3 /*break*/, 4];
|
|
155
|
+
case 3:
|
|
156
|
+
error_3 = _a.sent();
|
|
157
|
+
handleFetchError(error_3, 'Error fetching exit result');
|
|
158
|
+
return [3 /*break*/, 4];
|
|
159
|
+
case 4: return [2 /*return*/];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}); };
|
|
163
|
+
var debouncedFetchRefresh = (0, utils_1.useDebouncedRefresh)(fetchRefreshStep);
|
|
164
|
+
var onCloseWithEvent = (0, react_1.useCallback)(function (result) {
|
|
165
|
+
dispatchEvent('Dynamic Flow - Flow Finished', { result: 'success' });
|
|
166
|
+
onComplete(result);
|
|
167
|
+
}, [onComplete, dispatchEvent]);
|
|
168
|
+
(0, react_1.useEffect)(function () {
|
|
169
|
+
dispatchEvent('Dynamic Flow - Flow Started', {});
|
|
170
|
+
}, []);
|
|
171
|
+
(0, react_1.useEffect)(function () {
|
|
172
|
+
if (!initialStep) {
|
|
173
|
+
var action = __assign({ $id: '#initial-step-request', method: 'GET' }, initialAction);
|
|
174
|
+
void fetchNextStep(action, action.data);
|
|
175
|
+
}
|
|
176
|
+
}, [flowUrl, fetcher, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
|
|
177
|
+
var handleFetchResponse = function (response, fetchType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
var parsedResponse, step_1, etag_1, error_4;
|
|
179
|
+
return __generator(this, function (_a) {
|
|
180
|
+
switch (_a.label) {
|
|
181
|
+
case 0:
|
|
182
|
+
if (!response.ok) return [3 /*break*/, 4];
|
|
183
|
+
_a.label = 1;
|
|
184
|
+
case 1:
|
|
185
|
+
_a.trys.push([1, 3, , 4]);
|
|
186
|
+
return [4 /*yield*/, (0, utils_1.parseFetchResponse)(response)];
|
|
187
|
+
case 2:
|
|
188
|
+
parsedResponse = _a.sent();
|
|
189
|
+
switch (parsedResponse.type) {
|
|
190
|
+
case 'action':
|
|
191
|
+
void fetchNextStep(parsedResponse.action, parsedResponse.action.data);
|
|
192
|
+
return [2 /*return*/];
|
|
193
|
+
case 'exit':
|
|
194
|
+
return [2 /*return*/, onCloseWithEvent(parsedResponse.result)];
|
|
195
|
+
case 'step':
|
|
196
|
+
default: {
|
|
197
|
+
step_1 = parsedResponse.step, etag_1 = parsedResponse.etag;
|
|
198
|
+
return [2 /*return*/, fetchType === 'submission'
|
|
199
|
+
? updateStepAfterSubmission(step_1, etag_1)
|
|
200
|
+
: updateStepAfterRefresh(step_1, etag_1)];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return [3 /*break*/, 4];
|
|
204
|
+
case 3:
|
|
205
|
+
error_4 = _a.sent();
|
|
206
|
+
return [2 /*return*/, handleFetchError(error_4, 'Error parsing fetch response')];
|
|
207
|
+
case 4: return [2 /*return*/, handleErrorResponse(response, fetchType)];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}); };
|
|
211
|
+
var updateStepAfterSubmission = function (newStep, etag) {
|
|
212
|
+
var previousStep = step;
|
|
213
|
+
setStepAndEtag(newStep, etag);
|
|
214
|
+
onStepChange(newStep, previousStep);
|
|
215
|
+
setSubmitted(false);
|
|
216
|
+
setLoadingState('idle');
|
|
217
|
+
dispatchEvent('Dynamic Flow - Step Started', __assign({ stepId: newStep.key }, newStep === null || newStep === void 0 ? void 0 : newStep.analytics));
|
|
218
|
+
};
|
|
219
|
+
var updateStepAfterRefresh = function (step, etag) {
|
|
220
|
+
setStepAndEtag(step, etag);
|
|
221
|
+
setLoadingState('idle');
|
|
222
|
+
dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'success' });
|
|
223
|
+
};
|
|
224
|
+
var handleErrorResponse = function (response, fetchType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
+
var errorBody, action, error_5;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0:
|
|
229
|
+
if (response.status === 304) {
|
|
230
|
+
setLoadingState('idle');
|
|
231
|
+
return [2 /*return*/];
|
|
232
|
+
}
|
|
233
|
+
_a.label = 1;
|
|
234
|
+
case 1:
|
|
235
|
+
_a.trys.push([1, 5, , 6]);
|
|
236
|
+
return [4 /*yield*/, (0, utils_1.parseErrorResponse)(response)];
|
|
237
|
+
case 2:
|
|
238
|
+
errorBody = _a.sent();
|
|
239
|
+
if (!errorBody.refreshFormUrl) return [3 /*break*/, 4];
|
|
240
|
+
action = { url: errorBody === null || errorBody === void 0 ? void 0 : errorBody.refreshFormUrl, method: 'POST' };
|
|
241
|
+
return [4 /*yield*/, fetchRefreshStep(action, combineModels(models), etag)];
|
|
242
|
+
case 3:
|
|
243
|
+
_a.sent();
|
|
244
|
+
_a.label = 4;
|
|
245
|
+
case 4:
|
|
246
|
+
if (errorBody.validation) {
|
|
247
|
+
setFormErrors(errorBody.validation);
|
|
248
|
+
}
|
|
249
|
+
if (errorBody.error) {
|
|
250
|
+
setGlobalError(errorBody.error);
|
|
251
|
+
}
|
|
252
|
+
if (!errorBody.refreshFormUrl && !errorBody.validation && !errorBody.error) {
|
|
253
|
+
logError('Invalid response', 'Response body must contain at least one of the following properties: refreshFormUrl, validation, or error.');
|
|
254
|
+
throw errorBody;
|
|
255
|
+
}
|
|
256
|
+
return [3 /*break*/, 6];
|
|
257
|
+
case 5:
|
|
258
|
+
error_5 = _a.sent();
|
|
259
|
+
if (fetchType === 'refresh') {
|
|
260
|
+
dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'failure' });
|
|
261
|
+
}
|
|
262
|
+
dispatchEvent('Dynamic Flow - Flow Finished', { status: 'failure' });
|
|
263
|
+
onError(error_5, response.status);
|
|
264
|
+
logError('Invalid response', 'Error response body must be an object.');
|
|
265
|
+
return [3 /*break*/, 6];
|
|
266
|
+
case 6:
|
|
267
|
+
setLoadingState('idle');
|
|
268
|
+
return [2 /*return*/];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}); };
|
|
272
|
+
var handleFetchError = function (error, message) {
|
|
273
|
+
logCritical('Error fetching', message);
|
|
274
|
+
onError(error);
|
|
275
|
+
setLoadingState('idle');
|
|
276
|
+
};
|
|
277
|
+
var onModelChange = function (onModelChangeProps) {
|
|
278
|
+
var model = onModelChangeProps.model, formSchema = onModelChangeProps.formSchema;
|
|
279
|
+
var _a = formSchema.$id, $id = _a === void 0 ? '' : _a;
|
|
280
|
+
setGlobalError(null);
|
|
281
|
+
if (!(0, types_1.isObjectModel)(model)) {
|
|
282
|
+
// TODO: MC-3224
|
|
283
|
+
logCritical('Invalid model on change', 'onModelChange was called but the model argument is not an object');
|
|
284
|
+
}
|
|
285
|
+
var objectModel = model;
|
|
286
|
+
setSchemaModel($id, objectModel, function (updatedModels) {
|
|
287
|
+
refreshOnChangeIfNeeded(onModelChangeProps, updatedModels);
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
var refreshOnChangeIfNeeded = function (props, updatedModels) {
|
|
291
|
+
var triggerSchema = props.triggerSchema;
|
|
292
|
+
if (shouldTriggerRefresh(props)) {
|
|
293
|
+
var url = triggerSchema.refreshFormUrl || (step === null || step === void 0 ? void 0 : step.refreshFormUrl);
|
|
294
|
+
var action = { url: url, method: 'POST' };
|
|
295
|
+
debouncedFetchRefresh(action, combineModels(updatedModels), etag, triggerSchema);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
var onAction = function (action) { return __awaiter(void 0, void 0, void 0, function () {
|
|
299
|
+
var data, method, exit, url, result, submissionData, extraLoggingProps;
|
|
300
|
+
return __generator(this, function (_a) {
|
|
301
|
+
switch (_a.label) {
|
|
302
|
+
case 0:
|
|
303
|
+
data = action.data, method = action.method, exit = action.exit, url = action.url, result = action.result;
|
|
304
|
+
submissionData = __assign(__assign({}, combineModels(models)), data);
|
|
305
|
+
extraLoggingProps = {
|
|
306
|
+
url: action.url,
|
|
307
|
+
method: action.method,
|
|
308
|
+
currency: submissionData.currency,
|
|
309
|
+
type: submissionData.type
|
|
310
|
+
};
|
|
311
|
+
if (loadingState !== 'idle' || action.disabled) {
|
|
312
|
+
logWarning('Action supressed', loadingState !== 'idle'
|
|
313
|
+
? "onAction was supressed because loadingState is ".concat(loadingState)
|
|
314
|
+
: "onAction was supressed because action is disabled", extraLoggingProps);
|
|
315
|
+
return [2 /*return*/];
|
|
316
|
+
}
|
|
317
|
+
if (!exit) return [3 /*break*/, 7];
|
|
318
|
+
if (!url) return [3 /*break*/, 6];
|
|
319
|
+
if (!isSubmissionMethod(method)) return [3 /*break*/, 3];
|
|
320
|
+
setFormErrors(null);
|
|
321
|
+
setSubmitted(true);
|
|
322
|
+
if (!modelIsValid) return [3 /*break*/, 2];
|
|
323
|
+
return [4 /*yield*/, fetchExitResult(action, submissionData)];
|
|
324
|
+
case 1:
|
|
325
|
+
_a.sent();
|
|
326
|
+
_a.label = 2;
|
|
327
|
+
case 2: return [3 /*break*/, 5];
|
|
328
|
+
case 3: return [4 /*yield*/, fetchExitResult(action)];
|
|
329
|
+
case 4:
|
|
330
|
+
_a.sent();
|
|
331
|
+
_a.label = 5;
|
|
332
|
+
case 5: return [2 /*return*/];
|
|
333
|
+
case 6:
|
|
334
|
+
onCloseWithEvent(result);
|
|
335
|
+
return [2 /*return*/];
|
|
336
|
+
case 7:
|
|
337
|
+
if (isSubmissionMethod(method)) {
|
|
338
|
+
setFormErrors(null);
|
|
339
|
+
setSubmitted(true);
|
|
340
|
+
if (modelIsValid) {
|
|
341
|
+
void fetchNextStep(action, submissionData);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
dispatchEvent('Dynamic Flow - onAction supressed', __assign({ reason: 'invalid model' }, extraLoggingProps));
|
|
345
|
+
}
|
|
346
|
+
return [2 /*return*/];
|
|
347
|
+
}
|
|
348
|
+
void fetchNextStep(action);
|
|
349
|
+
return [2 /*return*/];
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}); };
|
|
353
|
+
return ((0, jsx_runtime_1.jsx)(contexts_1.LogProvider, __assign({ flowId: flowId, stepId: step === null || step === void 0 ? void 0 : step.key, onLog: onLog }, { children: (0, jsx_runtime_1.jsx)(contexts_1.EventsContextProvider, __assign({ metadata: analyticsMetadata, onEvent: onEvent }, { children: (0, jsx_runtime_1.jsx)(contexts_1.DynamicFlowProvider, __assign({ loading: loadingState !== 'idle' }, { children: (0, jsx_runtime_1.jsx)(contexts_1.FetcherProvider, __assign({ fetcher: fetcher }, { children: loader !== null ? (loader) : ((0, jsx_runtime_1.jsx)(DynamicFlowStep_1.DynamicFlowStep, { step: step, model: combineModels(models), submitted: submitted, globalError: globalError, formErrors: formErrors, stepLayoutOptions: { displayStepTitle: displayStepTitle }, onAction: function (action) {
|
|
354
|
+
void onAction(action);
|
|
355
|
+
}, onModelChange: onModelChange })) })) })) })) })));
|
|
356
|
+
};
|
|
357
|
+
var DynamicFlow = function (props) { return ((0, jsx_runtime_1.jsx)(utils_1.ErrorBoundary, __assign({ onError: props.onError }, { children: (0, jsx_runtime_1.jsx)(DynamicFlowComponent, __assign({}, props)) }))); };
|
|
358
|
+
exports["default"] = DynamicFlow;
|
|
359
|
+
var combineModels = function (formModels) {
|
|
360
|
+
return Object.values(formModels).reduce(function (previous, model) { return (__assign(__assign({}, previous), model)); }, {});
|
|
361
|
+
};
|
|
362
|
+
var isSubmissionMethod = function (method) {
|
|
363
|
+
if (method === void 0) { method = 'POST'; }
|
|
364
|
+
var submissionMethods = ['POST', 'PUT', 'PATCH'];
|
|
365
|
+
return submissionMethods.includes(method.toUpperCase());
|
|
366
|
+
};
|
|
367
|
+
var shouldTriggerRefresh = function (props) {
|
|
368
|
+
var type = props.type, triggerSchema = props.triggerSchema, triggerModel = props.triggerModel, _a = props.lastTriggerModel, lastTriggerModel = _a === void 0 ? null : _a;
|
|
369
|
+
var isValid = function () { return (0, validators_1.isValidSchema)(triggerModel, triggerSchema); };
|
|
370
|
+
var wasValid = function () { return (0, validators_1.isValidSchema)(lastTriggerModel, triggerSchema); };
|
|
371
|
+
return type !== 'init' && (triggerSchema === null || triggerSchema === void 0 ? void 0 : triggerSchema.refreshFormOnChange) && (isValid() || wasValid());
|
|
372
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
exports.__esModule = true;
|
|
14
|
+
exports.DynamicFlowStep = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var hooks_1 = require("../common/hooks");
|
|
17
|
+
var utils_1 = require("../common/utils");
|
|
18
|
+
var layout_1 = require("../layout");
|
|
19
|
+
var step_1 = require("../step");
|
|
20
|
+
var DynamicFlowStep = function (props) {
|
|
21
|
+
var _a;
|
|
22
|
+
var step = props.step, globalError = props.globalError;
|
|
23
|
+
var externalUrl = (_a = step === null || step === void 0 ? void 0 : step.external) === null || _a === void 0 ? void 0 : _a.url;
|
|
24
|
+
var _b = (0, hooks_1.useExternal)(externalUrl), requiresManualTrigger = _b.requiresManualTrigger, dismissConfirmation = _b.dismissConfirmation;
|
|
25
|
+
if (step === undefined) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (externalUrl && requiresManualTrigger) {
|
|
29
|
+
return (0, jsx_runtime_1.jsx)(step_1.ExternalConfirmationStep, { url: externalUrl, onClose: dismissConfirmation });
|
|
30
|
+
}
|
|
31
|
+
if ((0, utils_1.getStepType)(step) === 'camera') {
|
|
32
|
+
return (0, jsx_runtime_1.jsx)(step_1.CameraStep, __assign({}, props, { step: step }));
|
|
33
|
+
}
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalError ? ((0, jsx_runtime_1.jsx)(layout_1.DynamicAlert, { component: { context: 'negative', markdown: globalError, margin: 'lg' } })) : null, (0, jsx_runtime_1.jsx)(step_1.LayoutStep, __assign({}, props, { stepSpecification: step }))] }));
|
|
35
|
+
};
|
|
36
|
+
exports.DynamicFlowStep = DynamicFlowStep;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
exports.__esModule = true;
|
|
14
|
+
exports["default"] = void 0;
|
|
15
|
+
var DynamicFlow_1 = require("./DynamicFlow");
|
|
16
|
+
__createBinding(exports, DynamicFlow_1, "default");
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.getObjectKeys = void 0;
|
|
7
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
var addon_actions_1 = require("@storybook/addon-actions");
|
|
9
|
+
var react_1 = require("@storybook/react");
|
|
10
|
+
var fixtures_1 = require("../../fixtures");
|
|
11
|
+
var DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
|
|
12
|
+
var EditableDynamicFlow_1 = __importDefault(require("./EditableDynamicFlow"));
|
|
13
|
+
var fixtureFetcher_1 = require("./fixtureFetcher");
|
|
14
|
+
exports.getObjectKeys = Object.keys;
|
|
15
|
+
var storyMap = {};
|
|
16
|
+
var allStepNames = (0, exports.getObjectKeys)(fixtures_1.fixtures.steps);
|
|
17
|
+
allStepNames.forEach(function (stepName) {
|
|
18
|
+
var _a;
|
|
19
|
+
var label = (_a = fixtures_1.fixtures.steps[stepName].key) !== null && _a !== void 0 ? _a : stepName;
|
|
20
|
+
var _b = label.split('/'), group = _b[0], name = _b[1];
|
|
21
|
+
if (!storyMap[group]) {
|
|
22
|
+
storyMap[group] = (0, react_1.storiesOf)("Dynamic Flow/".concat(group), module);
|
|
23
|
+
}
|
|
24
|
+
storyMap[group].add(name, function () { return ((0, jsx_runtime_1.jsx)(DynamicFlow_1["default"], { flowId: "storybook", initialAction: { method: 'GET', url: "/steps/".concat(stepName) }, fetcher: fixtureFetcher_1.fixtureFetcher, loaderConfig: { size: 'xl', initial: true, submission: false }, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, stepName)); });
|
|
25
|
+
});
|
|
26
|
+
var editable = (0, react_1.storiesOf)("Dynamic Flow/Editable", module);
|
|
27
|
+
editable.add('Dynamic Flow', EditableDynamicFlow_1["default"], {
|
|
28
|
+
argTypes: {
|
|
29
|
+
initialStepName: {
|
|
30
|
+
label: 'Initial Step',
|
|
31
|
+
control: 'select',
|
|
32
|
+
options: Object.keys(fixtures_1.fixtures.steps)
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
args: { initialStepName: Object.keys(fixtures_1.fixtures)[0] }
|
|
36
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
exports.__esModule = true;
|
|
17
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
/* eslint-disable react/forbid-dom-props */
|
|
19
|
+
var addon_actions_1 = require("@storybook/addon-actions");
|
|
20
|
+
var react_1 = require("react");
|
|
21
|
+
var fixtures_1 = require("../../fixtures");
|
|
22
|
+
var DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
|
|
23
|
+
var fixtureFetcher_1 = require("./fixtureFetcher");
|
|
24
|
+
var EditableDynamicFlow = function (_a) {
|
|
25
|
+
var _b = _a.initialStepName, initialStepName = _b === void 0 ? '' : _b;
|
|
26
|
+
var selectedStep = fixtures_1.fixtures.steps[initialStepName] || {};
|
|
27
|
+
var selectedInitialStep = JSON.stringify(selectedStep, null, 2);
|
|
28
|
+
return (0, jsx_runtime_1.jsx)(InteractiveDemo, { selectedInitialStep: selectedInitialStep }, selectedInitialStep);
|
|
29
|
+
};
|
|
30
|
+
var InteractiveDemo = function (_a) {
|
|
31
|
+
var selectedInitialStep = _a.selectedInitialStep;
|
|
32
|
+
var _b = (0, react_1.useState)(selectedInitialStep), initialStep = _b[0], setInitialStep = _b[1];
|
|
33
|
+
var onTextAreaChange = function (event) {
|
|
34
|
+
setInitialStep(event.target.value);
|
|
35
|
+
};
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: { display: 'flex', gap: '1em' } }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: { flexBasis: '50%' } }, { children: [(0, jsx_runtime_1.jsx)("h3", { children: "Editable Demo" }), (0, jsx_runtime_1.jsxs)("p", { children: ["You can select an initial step from the drop down in the controls panel.", (0, jsx_runtime_1.jsx)("br", {}), "You can edit the JSON below and see the result on the right."] }), (0, jsx_runtime_1.jsx)("textarea", { wrap: "off", rows: 40, style: { fontFamily: 'monospace', fontSize: '0.9em', width: '100%' }, value: initialStep, onChange: onTextAreaChange })] })), (0, jsx_runtime_1.jsx)("div", __assign({ style: { flexBasis: '50%' } }, { children: (0, jsx_runtime_1.jsx)(DynamicFlow_1["default"], { flowId: "the-flow-id", initialStep: safeParseStepJson(initialStep), fetcher: fixtureFetcher_1.fixtureFetcher, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, initialStep) }))] })));
|
|
37
|
+
};
|
|
38
|
+
function safeParseStepJson(jsonStep) {
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(jsonStep);
|
|
41
|
+
}
|
|
42
|
+
catch (_a) {
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
console.warn('JSON parsing error');
|
|
45
|
+
return {
|
|
46
|
+
type: 'final',
|
|
47
|
+
layout: [
|
|
48
|
+
{
|
|
49
|
+
type: 'box',
|
|
50
|
+
width: 'lg',
|
|
51
|
+
components: [
|
|
52
|
+
{
|
|
53
|
+
type: 'alert',
|
|
54
|
+
markdown: "**Error parsing JSON.**",
|
|
55
|
+
context: 'warning'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'paragraph',
|
|
59
|
+
text: " Invalid syntax or missing elements are preventing the JSON code you entered from being parsed. Carefully review and edit the code for errors such as missing commas or brackets."
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports["default"] = EditableDynamicFlow;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
exports.fixtureFetcher = void 0;
|
|
51
|
+
var addon_actions_1 = require("@storybook/addon-actions");
|
|
52
|
+
var validators_1 = require("../../common/validators");
|
|
53
|
+
var fixtures_1 = require("../../fixtures");
|
|
54
|
+
var DynamicFlow_story_1 = require("./DynamicFlow.story");
|
|
55
|
+
var fixtureFetcher = function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var url;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
(0, addon_actions_1.action)('fixtureFetcher')(input, init);
|
|
59
|
+
url = getURL(input);
|
|
60
|
+
if (url.pathname.startsWith('/steps/')) {
|
|
61
|
+
return [2 /*return*/, respondWithFixture(fixtures_1.fixtures.steps, url, init)];
|
|
62
|
+
}
|
|
63
|
+
if (url.pathname.startsWith('/responses/')) {
|
|
64
|
+
return [2 /*return*/, respondWithFixture(fixtures_1.fixtures.responses, url, init)];
|
|
65
|
+
}
|
|
66
|
+
if (url.pathname.startsWith('/validate')) {
|
|
67
|
+
return [2 /*return*/, new Response(JSON.stringify({ message: 'Validation-async OK' }))];
|
|
68
|
+
}
|
|
69
|
+
return [2 /*return*/, new Response(null, { status: 404 })];
|
|
70
|
+
});
|
|
71
|
+
}); };
|
|
72
|
+
exports.fixtureFetcher = fixtureFetcher;
|
|
73
|
+
var getURL = function (input) {
|
|
74
|
+
if (input instanceof URL) {
|
|
75
|
+
return input;
|
|
76
|
+
}
|
|
77
|
+
if (input instanceof Request) {
|
|
78
|
+
return new URL(input.url, 'http://foo');
|
|
79
|
+
}
|
|
80
|
+
return new URL(input, 'http://foo');
|
|
81
|
+
};
|
|
82
|
+
var respondWithFixture = function (fixtures, url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var fixtureNames, name, fixture, body;
|
|
84
|
+
var _a;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
fixtureNames = (0, DynamicFlow_story_1.getObjectKeys)(fixtures);
|
|
89
|
+
name = url.pathname
|
|
90
|
+
.split('/')
|
|
91
|
+
.filter(function (part) { return !!part; })
|
|
92
|
+
.pop();
|
|
93
|
+
if (!fixtureNames.includes(name !== null && name !== void 0 ? name : '')) return [3 /*break*/, 3];
|
|
94
|
+
fixture = fixtures[name];
|
|
95
|
+
if (!url.searchParams.has('delay')) return [3 /*break*/, 2];
|
|
96
|
+
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, Number(url.searchParams.get('delay'))); })];
|
|
97
|
+
case 1:
|
|
98
|
+
_b.sent();
|
|
99
|
+
_b.label = 2;
|
|
100
|
+
case 2:
|
|
101
|
+
// by convention if the url contains a "refresh"query parameterm we use the payload as model
|
|
102
|
+
if (url.searchParams.has('refresh') &&
|
|
103
|
+
(init === null || init === void 0 ? void 0 : init.body) &&
|
|
104
|
+
typeof init.body === 'string' &&
|
|
105
|
+
(0, validators_1.isObject)(fixture)) {
|
|
106
|
+
body = JSON.parse(init.body);
|
|
107
|
+
return [2 /*return*/, new Response(JSON.stringify(__assign(__assign({}, fixture), { model: __assign(__assign({}, ((_a = fixture.model) !== null && _a !== void 0 ? _a : {})), body) })))];
|
|
108
|
+
}
|
|
109
|
+
if (url.pathname.includes('exit')) {
|
|
110
|
+
return [2 /*return*/, new Response(JSON.stringify(fixture), { headers: { 'X-DF-Exit': 'true' } })];
|
|
111
|
+
}
|
|
112
|
+
return [2 /*return*/, new Response(JSON.stringify(fixture))];
|
|
113
|
+
case 3:
|
|
114
|
+
(0, addon_actions_1.action)('ERROR 404')(url);
|
|
115
|
+
return [2 /*return*/, new Response(null, { status: 404 })];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}); };
|