@wise/dynamic-flow-client 5.8.1 → 5.9.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/DynamicFlowCore.js +5 -0
- package/build/common/errorBoundary/ErrorBoundary.js +26 -0
- package/build/common/errorBoundary/ErrorBoundary.test.js +29 -0
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +11 -0
- package/build/common/makeHttpClient/api-utils.js +3 -0
- package/build/common/makeHttpClient/index.js +1 -0
- package/build/common/makeHttpClient/makeHttpClient.js +10 -0
- package/build/common/makeHttpClient/makeHttpClient.test.js +186 -0
- package/build/common/messages/external-confirmation.messages.js +23 -0
- package/build/common/messages/file-upload.messages.js +13 -0
- package/build/common/messages/generic-error.messages.js +18 -0
- package/build/common/messages/help.messages.js +8 -0
- package/build/common/messages/multi-file-upload.messages.js +18 -0
- package/build/common/messages/multi-select.messages.js +8 -0
- package/build/common/messages/paragraph.messages.js +13 -0
- package/build/common/messages/repeatable.messages.js +23 -0
- package/build/common/messages/search.messages.js +8 -0
- package/build/common/messages/validation.array.messages.js +13 -0
- package/build/common/messages/validation.messages.js +53 -0
- package/build/controller/FlowController.js +368 -0
- package/build/controller/executePoll.js +49 -0
- package/build/controller/executeRefresh.js +39 -0
- package/build/controller/executeRequest.js +77 -0
- package/build/controller/executeSubmission.js +69 -0
- package/build/controller/getErrorMessage.js +7 -0
- package/build/controller/getRequestAbortController.js +13 -0
- package/build/controller/getResponseType.js +35 -0
- package/build/controller/getSafeHttpClient.js +8 -0
- package/build/controller/getStepCounter.js +16 -0
- package/build/controller/handleErrorResponse.js +26 -0
- package/build/controller/makeSafeHttpClient.js +8 -0
- package/build/controller/response-utils.js +72 -0
- package/build/domain/components/AlertComponent.js +1 -0
- package/build/domain/components/AllOfComponent.js +40 -0
- package/build/domain/components/BooleanInputComponent.js +50 -0
- package/build/domain/components/BoxComponent.js +3 -0
- package/build/domain/components/ButtonComponent.js +1 -0
- package/build/domain/components/ColumnsComponent.js +3 -0
- package/build/domain/components/ConstComponent.js +18 -0
- package/build/domain/components/ContainerComponent.js +3 -0
- package/build/domain/components/DateInputComponent.js +75 -0
- package/build/domain/components/DecisionComponent.js +1 -0
- package/build/domain/components/DividerComponent.js +1 -0
- package/build/domain/components/FormComponent.js +3 -0
- package/build/domain/components/FormattedValueComponent.js +44 -0
- package/build/domain/components/HeadingComponent.js +1 -0
- package/build/domain/components/ImageComponent.js +1 -0
- package/build/domain/components/InstructionsComponent.js +1 -0
- package/build/domain/components/IntegerInputComponent.js +74 -0
- package/build/domain/components/ListComponent.js +1 -0
- package/build/domain/components/LoadingIndicatorComponent.js +1 -0
- package/build/domain/components/MarkdownComponent.js +1 -0
- package/build/domain/components/MediaComponent.js +1 -0
- package/build/domain/components/ModalComponent.js +16 -0
- package/build/domain/components/ModalLayoutComponent.js +3 -0
- package/build/domain/components/MoneyInputComponent.js +57 -0
- package/build/domain/components/MultiSelectInputComponent.js +81 -0
- package/build/domain/components/MultiUploadInputComponent.js +88 -0
- package/build/domain/components/NumberInputComponent.js +73 -0
- package/build/domain/components/ObjectComponent.js +45 -0
- package/build/domain/components/ParagraphComponent.js +1 -0
- package/build/domain/components/PersistAsyncComponent.js +92 -0
- package/build/domain/components/ProgressComponent.js +1 -0
- package/build/domain/components/RepeatableComponent.js +103 -0
- package/build/domain/components/ReviewComponent.js +1 -0
- package/build/domain/components/RootDomainComponent.js +173 -0
- package/build/domain/components/SectionComponent.js +5 -0
- package/build/domain/components/SelectInputComponent.js +88 -0
- package/build/domain/components/StatusListComponent.js +1 -0
- package/build/domain/components/SubflowDomainComponent.js +9 -0
- package/build/domain/components/TabsComponent.js +1 -0
- package/build/domain/components/TextInputComponent.js +76 -0
- package/build/domain/components/TupleComponent.js +41 -0
- package/build/domain/components/UploadInputComponent.js +83 -0
- package/build/domain/components/UpsellComponent.js +25 -0
- package/build/domain/components/searchComponent/SearchComponent.js +92 -0
- package/build/domain/components/searchComponent/SearchComponent.test.js +190 -0
- package/build/domain/components/step/ExternalConfirmationComponent.js +28 -0
- package/build/domain/components/step/StepDomainComponent.js +73 -0
- package/build/domain/components/step/ToolbarComponent.js +1 -0
- package/build/domain/components/utils/WithUpdate.js +1 -0
- package/build/domain/components/utils/component-utils.js +12 -0
- package/build/domain/components/utils/debounce.js +34 -0
- package/build/domain/components/utils/debounce.test.js +67 -0
- package/build/domain/components/utils/file-utils.js +21 -0
- package/build/domain/components/utils/file-utils.test.js +27 -0
- package/build/domain/components/utils/getRandomId.js +1 -0
- package/build/domain/components/utils/isExactLocalValueMatch.js +14 -0
- package/build/domain/components/utils/isOrWasValid.js +5 -0
- package/build/domain/components/utils/isPartialModelMatch.js +18 -0
- package/build/domain/components/utils/isPartialModelMatch.test.js +74 -0
- package/build/domain/features/eventNames.js +24 -0
- package/build/domain/features/events.js +1 -0
- package/build/domain/features/persistAsync/getComponentMultiPersistAsync.js +50 -0
- package/build/domain/features/persistAsync/getInitialPersistedState.js +7 -0
- package/build/domain/features/persistAsync/getPerformPersistAsync.js +43 -0
- package/build/domain/features/persistAsync/getPerformPersistAsync.test.js +139 -0
- package/build/domain/features/polling/getStepPolling.js +43 -0
- package/build/domain/features/polling/getStepPolling.test.js +90 -0
- package/build/domain/features/prefetch/getStepPrefetch.js +43 -0
- package/build/domain/features/prefetch/request-cache.js +49 -0
- package/build/domain/features/prefetch/request-cache.test.js +70 -0
- package/build/domain/features/refreshAfter/getStepRefreshAfter.js +24 -0
- package/build/domain/features/refreshAfter/getStepRefreshAfter.test.js +40 -0
- package/build/domain/features/schema-on-change/getDebouncedSchemaOnChange.js +50 -0
- package/build/domain/features/schema-on-change/getSchemaOnChange.js +34 -0
- package/build/domain/features/search/getPerformSearchFunction.js +75 -0
- package/build/domain/features/search/getPerformSearchFunction.test.js +301 -0
- package/build/domain/features/summary/summary-utils.js +40 -0
- package/build/domain/features/summary/summary-utils.test.js +125 -0
- package/build/domain/features/utils/http-utils.js +21 -0
- package/build/domain/features/utils/response-utils.js +9 -0
- package/build/domain/features/validation/spec-utils.js +19 -0
- package/build/domain/features/validation/validateStringPattern.js +24 -0
- package/build/domain/features/validation/validation-functions.js +6 -0
- package/build/domain/features/validation/validation-functions.test.js +108 -0
- package/build/domain/features/validation/value-checks.js +125 -0
- package/build/domain/features/validation/value-checks.test.js +262 -0
- package/build/domain/features/validationAsync/getComponentValidationAsync.js +53 -0
- package/build/domain/features/validationAsync/getComponentValidationAsync.test.js +67 -0
- package/build/domain/features/validationAsync/getInitialValidationAsyncState.js +5 -0
- package/build/domain/features/validationAsync/getPerformValidationAsync.js +45 -0
- package/build/domain/features/validationAsync/getPerformValidationAsync.test.js +143 -0
- package/build/domain/mappers/layout/alertLayoutToComponent.js +16 -0
- package/build/domain/mappers/layout/boxLayoutToComponent.js +13 -0
- package/build/domain/mappers/layout/buttonLayoutToComponent.js +77 -0
- package/build/domain/mappers/layout/columnsLayoutToComponent.js +13 -0
- package/build/domain/mappers/layout/decisionLayoutToComponent.js +22 -0
- package/build/domain/mappers/layout/deprecatedListLayoutToComponent.js +30 -0
- package/build/domain/mappers/layout/dividerLayoutToComponent.js +2 -0
- package/build/domain/mappers/layout/formLayoutToComponent.js +19 -0
- package/build/domain/mappers/layout/headingLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/imageLayoutToComponent.js +20 -0
- package/build/domain/mappers/layout/infoLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/instructionsLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/listLayoutToComponent.js +39 -0
- package/build/domain/mappers/layout/loadingIndicatorLayoutToComponent.js +9 -0
- package/build/domain/mappers/layout/markdownLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/mediaLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/modalLayoutToComponent.js +17 -0
- package/build/domain/mappers/layout/modalToComponent.js +8 -0
- package/build/domain/mappers/layout/paragraphLayoutToComponent.js +12 -0
- package/build/domain/mappers/layout/progressLayoutToComponent.js +15 -0
- package/build/domain/mappers/layout/reviewLayoutToComponent.js +48 -0
- package/build/domain/mappers/layout/searchLayoutToComponent.js +44 -0
- package/build/domain/mappers/layout/sectionLayoutToComponent.js +15 -0
- package/build/domain/mappers/layout/statusListLayoutToComponent.js +15 -0
- package/build/domain/mappers/layout/tabsLayoutToComponent.js +16 -0
- package/build/domain/mappers/layout/upsellLayoutToComponent.js +25 -0
- package/build/domain/mappers/mapLayoutToComponent.js +81 -0
- package/build/domain/mappers/mapSchemaToComponent.js +61 -0
- package/build/domain/mappers/mapSchemaToComponent.test.js +112 -0
- package/build/domain/mappers/mapStepSchemas.js +17 -0
- package/build/domain/mappers/mapStepToComponent.js +132 -0
- package/build/domain/mappers/mapStepToComponent.test.js +221 -0
- package/build/domain/mappers/mapToolbarToComponent.js +15 -0
- package/build/domain/mappers/schema/allOfSchemaToComponent.js +16 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.js +26 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.js +55 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.js +67 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.js +57 -0
- package/build/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.js +20 -0
- package/build/domain/mappers/schema/blobSchemaToComponent.js +15 -0
- package/build/domain/mappers/schema/booleanSchemaToComponent.js +29 -0
- package/build/domain/mappers/schema/constSchemaToComponent.js +23 -0
- package/build/domain/mappers/schema/integerSchemaToComponent.js +28 -0
- package/build/domain/mappers/schema/numberSchemaToComponent.js +26 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/assertDisplayOrder.js +23 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent.js +9 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.js +119 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent.test.js +96 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.js +31 -0
- package/build/domain/mappers/schema/objectSchemaToComponent/objectSchemaToObjectComponent.test.js +99 -0
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.js +76 -0
- package/build/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.test.js +265 -0
- package/build/domain/mappers/schema/persistAsyncSchemaToComponent.js +29 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.js +18 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.test.js +133 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.js +48 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.js +37 -0
- package/build/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.js +28 -0
- package/build/domain/mappers/schema/tests/test-utils.js +16 -0
- package/build/domain/mappers/schema/types.js +1 -0
- package/build/domain/mappers/schema/utils/getPerformPersistAsyncFn.js +19 -0
- package/build/domain/mappers/schema/utils/getValidationAsyncInitialState.js +23 -0
- package/build/domain/mappers/schema/utils/mapCommonSchemaProps.js +16 -0
- package/build/domain/mappers/types.js +1 -0
- package/build/domain/mappers/utils/FeatureFlags.js +22 -0
- package/build/domain/mappers/utils/behavior-utils.js +44 -0
- package/build/domain/mappers/utils/call-to-action-utils.js +21 -0
- package/build/domain/mappers/utils/getAutocompleteString.js +76 -0
- package/build/domain/mappers/utils/getAutocompleteString.test.js +21 -0
- package/build/domain/mappers/utils/groupLayoutByPinned.js +38 -0
- package/build/domain/mappers/utils/groupLayoutByPinned.test.js +166 -0
- package/build/domain/mappers/utils/image.js +9 -0
- package/build/domain/mappers/utils/layout-utils.js +11 -0
- package/build/domain/mappers/utils/legacy-utils.js +49 -0
- package/build/domain/mappers/utils/media-utils.js +14 -0
- package/build/domain/mappers/utils/suggestions-utils.js +26 -0
- package/build/domain/mappers/utils/suggestions-utils.test.js +36 -0
- package/build/domain/mappers/utils/tags-utils.js +1 -0
- package/build/domain/mappers/utils/utils.js +35 -0
- package/build/domain/types.js +1 -0
- package/build/getSubflowCallbacks.js +38 -0
- package/build/i18n/index.js +40 -0
- package/build/index.js +8 -0
- package/build/main.js +112 -54
- package/build/main.mjs +111 -53
- package/build/renderers/CoreContainerRenderer.js +5 -0
- package/build/renderers/CoreRootRenderer.js +12 -0
- package/build/renderers/EmptyLoadingStateRenderer.js +5 -0
- package/build/renderers/getRenderFunction.js +24 -0
- package/build/renderers/getSchemaErrorMessageFunction.js +97 -0
- package/build/renderers/mappers/alertComponentToProps.js +2 -0
- package/build/renderers/mappers/allOfComponentToProps.js +6 -0
- package/build/renderers/mappers/booleanInputComponentToProps.js +5 -0
- package/build/renderers/mappers/boxComponentToProps.js +13 -0
- package/build/renderers/mappers/buttonComponentToProps.js +4 -0
- package/build/renderers/mappers/columnsComponentToProps.js +11 -0
- package/build/renderers/mappers/componentToRendererProps.js +164 -0
- package/build/renderers/mappers/constComponentToProps.js +5 -0
- package/build/renderers/mappers/containerComponentToProps.js +7 -0
- package/build/renderers/mappers/dateInputComponentToProps.js +2 -0
- package/build/renderers/mappers/decisionComponentToProps.js +16 -0
- package/build/renderers/mappers/dividerComponentToProps.js +2 -0
- package/build/renderers/mappers/externalComponentToProps.js +3 -0
- package/build/renderers/mappers/formComponentToProps.js +12 -0
- package/build/renderers/mappers/formattedValueComponentToProps.js +5 -0
- package/build/renderers/mappers/headingComponentToProps.js +2 -0
- package/build/renderers/mappers/hiddenComponentToProps.js +4 -0
- package/build/renderers/mappers/imageComponentToProps.js +2 -0
- package/build/renderers/mappers/instructionsComponentToProps.js +2 -0
- package/build/renderers/mappers/integerInputComponentToProps.js +2 -0
- package/build/renderers/mappers/listComponentToProps.js +2 -0
- package/build/renderers/mappers/loadingIndicatorComponentToProps.js +2 -0
- package/build/renderers/mappers/markdownComponentToProps.js +2 -0
- package/build/renderers/mappers/mediaComponentToProps.js +2 -0
- package/build/renderers/mappers/modalComponentToProps.js +11 -0
- package/build/renderers/mappers/modalLayoutComponentToProps.js +16 -0
- package/build/renderers/mappers/moneyInputComponentToProps.js +36 -0
- package/build/renderers/mappers/multiSelectComponentToProps.js +23 -0
- package/build/renderers/mappers/multiUploadInputComponentToProps.js +12 -0
- package/build/renderers/mappers/numberInputComponentToProps.js +2 -0
- package/build/renderers/mappers/objectComponentToProps.js +8 -0
- package/build/renderers/mappers/paragraphComponentToProps.js +2 -0
- package/build/renderers/mappers/persistAsyncComponentToProps.js +8 -0
- package/build/renderers/mappers/progressComponentToProps.js +2 -0
- package/build/renderers/mappers/repeatableComponentToProps.js +30 -0
- package/build/renderers/mappers/reviewComponentToProps.js +2 -0
- package/build/renderers/mappers/rootComponentToProps.js +21 -0
- package/build/renderers/mappers/searchComponentToProps.js +57 -0
- package/build/renderers/mappers/sectionComponentToProps.js +6 -0
- package/build/renderers/mappers/selectInputComponentToProps.js +26 -0
- package/build/renderers/mappers/statusListComponentToProps.js +2 -0
- package/build/renderers/mappers/subflowComponentToRendererProps.js +4 -0
- package/build/renderers/mappers/tabsComponentToProps.js +14 -0
- package/build/renderers/mappers/textInputComponentToProps.js +2 -0
- package/build/renderers/mappers/tupleComponentToProps.js +8 -0
- package/build/renderers/mappers/uploadInputComponentToProps.js +8 -0
- package/build/renderers/mappers/upsellComponentToProps.js +2 -0
- package/build/renderers/mappers/utils/getValidationState.js +12 -0
- package/build/renderers/mappers/utils/inputComponentToProps.js +26 -0
- package/build/renderers/mappers/utils/mapErrorsToValidationState.js +9 -0
- package/build/renderers/mappers/utils/pick.js +8 -0
- package/build/renderers/mappers/utils/selectInputOptionsToProps.js +11 -0
- package/build/renderers/stepComponentToProps.js +32 -0
- package/build/renderers/utils.js +69 -0
- package/build/renderers/utils.test.js +70 -0
- package/build/stories/dev-tools/ContainerQueries.story.js +66 -0
- package/build/stories/dev-tools/Debugger.story.js +38 -0
- package/build/stories/dev-tools/FixtureSelect.story.js +23 -0
- package/build/stories/dev-tools/TestServer.story.js +32 -0
- package/build/stories/examples/NativeFlow.story.js +80 -0
- package/build/stories/examples/Recipients.story.js +568 -0
- package/build/stories/spec/behavior/Copy.story.js +59 -0
- package/build/stories/spec/behavior/Modal.story.js +76 -0
- package/build/stories/spec/behavior/Subflow.story.js +267 -0
- package/build/stories/spec/layouts/Decision.story.js +241 -0
- package/build/stories/spec/layouts/Image.story.js +42 -0
- package/build/stories/spec/layouts/Modal.story.js +81 -0
- package/build/stories/spec/layouts/Search.story.js +325 -0
- package/build/stories/spec/layouts/Upsell.story.js +55 -0
- package/build/stories/spec/layouts/button/Button.story.js +100 -0
- package/build/stories/spec/layouts/button/PinnedButton.story.js +81 -0
- package/build/stories/spec/response/ActionResponse.story.js +66 -0
- package/build/stories/spec/schemas/MultiSelect.story.js +148 -0
- package/build/stories/spec/schemas/Upload.story.js +168 -0
- package/build/stories/spec/schemas/const/ConstLayout.story.js +159 -0
- package/build/stories/spec/schemas/const/ObjectConst.story.js +94 -0
- package/build/stories/spec/schemas/features/PersistAsync.story.js +176 -0
- package/build/stories/spec/schemas/features/ValidationAsync.story.js +103 -0
- package/build/stories/spec/schemas/object/FormattedValue.story.js +92 -0
- package/build/stories/spec/schemas/object/MoneyInput.story.js +240 -0
- package/build/stories/spec/schemas/oneOf/OneOfInitialisation.story.js +55 -0
- package/build/stories/spec/step/Controls.story.js +109 -0
- package/build/stories/spec/step/DFModal.story.js +58 -0
- package/build/stories/spec/step/Footer.story.js +70 -0
- package/build/stories/spec/step/Navigation.story.js +20 -0
- package/build/stories/spec/step/Tags.story.js +39 -0
- package/build/stories/spec/step/ToolBar.story.js +60 -0
- package/build/stories/spec/step/features/ErrorHandling.story.js +92 -0
- package/build/stories/spec/step/features/External.story.js +44 -0
- package/build/stories/spec/step/features/Polling.story.js +108 -0
- package/build/stories/spec/step/features/RefreshAfter.story.js +92 -0
- package/build/stories/spec/step/features/refresh/Refresh.story.js +258 -0
- package/build/stories/spec/step/features/refresh/RefreshWithPersistAsync.story.js +958 -0
- package/build/stories/types.js +1 -0
- package/build/stories/utils/fixtureHttpClient.js +70 -0
- package/build/stories/utils/getBasicStep.js +223 -0
- package/build/stories/utils/mockSearchHandler.js +71 -0
- package/build/stories/utils/render-utils.js +41 -0
- package/build/stories/visual-tests/layouts/NotUsingListItem.story.js +17 -0
- package/build/test-utils/DynamicFlowWise.js +32 -0
- package/build/test-utils/DynamicFlowWiseModal.js +34 -0
- package/build/test-utils/NeptuneProviders.js +11 -0
- package/build/test-utils/component-utils.js +5 -0
- package/build/test-utils/fetch-utils.js +45 -0
- package/build/test-utils/getMergedTestRenderers.js +34 -0
- package/build/test-utils/getRandomId.js +1 -0
- package/build/test-utils/index.js +3 -0
- package/build/test-utils/rtl-utils.js +7 -0
- package/build/test-utils/step-utils.js +6 -0
- package/build/test-utils/wait.js +3 -0
- package/build/tests/AlertLayout.test.js +78 -0
- package/build/tests/ArrayTuple.test.js +118 -0
- package/build/tests/ButtonLayout.test.js +308 -0
- package/build/tests/ConstLayout.test.js +95 -0
- package/build/tests/DateInput.test.js +163 -0
- package/build/tests/DecisionLayout.test.js +146 -0
- package/build/tests/DynamicFlow.test.js +147 -0
- package/build/tests/External.test.js +169 -0
- package/build/tests/Flow.test.js +328 -0
- package/build/tests/FormLayout.test.js +28 -0
- package/build/tests/FormattedValue.test.js +107 -0
- package/build/tests/ImageRenderer.test.js +78 -0
- package/build/tests/InitialAction.test.js +179 -0
- package/build/tests/InitialStep.test.js +168 -0
- package/build/tests/InstructionsLayout.test.js +45 -0
- package/build/tests/ListLayout.test.js +145 -0
- package/build/tests/Logging.test.js +53 -0
- package/build/tests/ModalBehavior.test.js +149 -0
- package/build/tests/MoneyInput.test.js +316 -0
- package/build/tests/MultiUpload.test.js +293 -0
- package/build/tests/NativeBack.test.js +267 -0
- package/build/tests/OneOfInitialisation.test.js +571 -0
- package/build/tests/PersistAsync.test.js +653 -0
- package/build/tests/Polling.test.js +617 -0
- package/build/tests/Prefetching.test.js +230 -0
- package/build/tests/RefreshAfter.test.js +63 -0
- package/build/tests/RefreshOnChange.ResponseHandling.test.js +205 -0
- package/build/tests/RefreshOnChange.test.js +233 -0
- package/build/tests/RefreshOnChange.with.Segmented.test.js +348 -0
- package/build/tests/RefreshOnChange.with.Tabs.test.js +358 -0
- package/build/tests/RefreshOnChangePreserve.test.js +224 -0
- package/build/tests/RendererProps.test.js +342 -0
- package/build/tests/Repeatable.test.js +107 -0
- package/build/tests/Rerendering.test.js +67 -0
- package/build/tests/ReviewLayout.test.js +274 -0
- package/build/tests/SchemaOnChange.test.js +133 -0
- package/build/tests/ScrollToError.test.js +217 -0
- package/build/tests/SegmentedControl.test.js +49 -0
- package/build/tests/SingleFileUpload.test.js +88 -0
- package/build/tests/StatusList.test.js +85 -0
- package/build/tests/Subflow.test.js +710 -0
- package/build/tests/Submission.ResponseHandling.test.js +557 -0
- package/build/tests/Submission.merging.test.js +202 -0
- package/build/tests/Submission.test.js +523 -0
- package/build/tests/Tags.test.js +475 -0
- package/build/tests/Upsell.test.js +126 -0
- package/build/tests/ValidationAsync.test.js +295 -0
- package/build/tests/legacy/Actions.test.js +158 -0
- package/build/tests/legacy/BackButton.test.js +114 -0
- package/build/tests/legacy/HiddenSchemas.test.js +246 -0
- package/build/tests/legacy/MultiSelect.test.js +497 -0
- package/build/tests/legacy/MultipleFileUploadSchema.test.js +341 -0
- package/build/tests/legacy/PersistAsync.blob-schema.test.js +224 -0
- package/build/tests/legacy/PersistAsync.string-schema.test.js +211 -0
- package/build/tests/legacy/RefreshStepOnChange.debouncing.test.js +209 -0
- package/build/tests/legacy/RefreshStepOnChange.test.js +424 -0
- package/build/tests/legacy/Search.test.js +437 -0
- package/build/tests/renderers/MultiSelectInputRendererProps.test.js +58 -0
- package/build/tests/renderers/SelectInputRendererProps.test.js +42 -0
- package/build/tests/renderers/TextInputRenderer.test.js +51 -0
- package/build/types/domain/components/UpsellComponent.d.ts +2 -3
- package/build/types/domain/components/UpsellComponent.d.ts.map +1 -1
- package/build/types/domain/components/searchComponent/SearchComponent.d.ts +5 -4
- package/build/types/domain/components/searchComponent/SearchComponent.d.ts.map +1 -1
- package/build/types/domain/features/search/getPerformSearchFunction.d.ts +1 -1
- package/build/types/domain/features/search/getPerformSearchFunction.d.ts.map +1 -1
- package/build/types/domain/mappers/layout/searchLayoutToComponent.d.ts +2 -1
- package/build/types/domain/mappers/layout/searchLayoutToComponent.d.ts.map +1 -1
- package/build/types/domain/mappers/layout/upsellLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/upsellLayoutToComponent.d.ts.map +1 -1
- package/build/types/renderers/EmptyLoadingStateRenderer.d.ts +3 -0
- package/build/types/renderers/EmptyLoadingStateRenderer.d.ts.map +1 -0
- package/build/types/renderers/mappers/rootComponentToProps.d.ts.map +1 -1
- package/build/types/renderers/mappers/searchComponentToProps.d.ts +1 -1
- package/build/types/renderers/mappers/searchComponentToProps.d.ts.map +1 -1
- package/build/types/renderers/mappers/upsellComponentToProps.d.ts +2 -2
- package/build/types/renderers/mappers/upsellComponentToProps.d.ts.map +1 -1
- package/build/types/test-utils/getMergedTestRenderers.d.ts +1 -1
- package/build/types/test-utils/getMergedTestRenderers.d.ts.map +1 -1
- package/build/types/useDynamicFlow.d.ts.map +1 -1
- package/build/types.js +1 -0
- package/build/useDynamicFlow.js +104 -0
- package/build/useDynamicFlowModal.js +58 -0
- package/build/utils/analyse-step.js +14 -0
- package/build/utils/component-utils.js +8 -0
- package/build/utils/component-utils.test.js +113 -0
- package/build/utils/getScrollToTop.js +12 -0
- package/build/utils/normalise-flow-id.js +1 -0
- package/build/utils/normalise-flow-id.test.js +24 -0
- package/build/utils/openLinkInNewTab.js +10 -0
- package/build/utils/recursiveMerge.js +40 -0
- package/build/utils/recursiveMerge.test.js +93 -0
- package/build/utils/type-utils.js +21 -0
- package/build/utils/type-validators.js +11 -0
- package/build/utils/type-validators.test.js +180 -0
- package/build/utils/useStableCallback.js +15 -0
- package/package.json +4 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createSectionComponent } from '../../components/SectionComponent';
|
|
2
|
+
import { mapLayoutToComponent } from '../mapLayoutToComponent';
|
|
3
|
+
import { getDomainLayerCallToAction } from '../utils/call-to-action-utils';
|
|
4
|
+
export const sectionLayoutToComponent = (uid, { analyticsId, control, title, components, callToAction, margin, tags }, mapperProps, schemaComponents) => {
|
|
5
|
+
return createSectionComponent({
|
|
6
|
+
uid,
|
|
7
|
+
analyticsId,
|
|
8
|
+
control,
|
|
9
|
+
title,
|
|
10
|
+
components: components.map((component, index) => mapLayoutToComponent(`${uid}.section-${index}`, component, mapperProps, schemaComponents)),
|
|
11
|
+
margin: margin !== null && margin !== void 0 ? margin : 'md',
|
|
12
|
+
callToAction: getDomainLayerCallToAction(callToAction, mapperProps),
|
|
13
|
+
tags,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createStatusListComponent } from '../../components/StatusListComponent';
|
|
2
|
+
import { getDomainLayerCallToAction } from '../utils/call-to-action-utils';
|
|
3
|
+
import { mapTags } from '../utils/tags-utils';
|
|
4
|
+
export const statusListLayoutToComponent = (uid, { analyticsId, control, items, margin, tags, title }, mapperProps) => createStatusListComponent({
|
|
5
|
+
uid,
|
|
6
|
+
analyticsId,
|
|
7
|
+
control,
|
|
8
|
+
items: items.map((item) => {
|
|
9
|
+
const callToAction = getDomainLayerCallToAction(item.callToAction, mapperProps);
|
|
10
|
+
return Object.assign(Object.assign({}, item), { callToAction, tags: mapTags(item) });
|
|
11
|
+
}),
|
|
12
|
+
margin: margin !== null && margin !== void 0 ? margin : 'md',
|
|
13
|
+
tags,
|
|
14
|
+
title,
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createTabsComponent } from '../../components/TabsComponent';
|
|
2
|
+
import { mapLayoutToComponent } from '../mapLayoutToComponent';
|
|
3
|
+
import { mapTags } from '../utils/tags-utils';
|
|
4
|
+
export const tabsLayoutToComponent = (uid, { analyticsId, control, margin, tags, tabs }, mapperProps, schemaComponents) => createTabsComponent({
|
|
5
|
+
uid,
|
|
6
|
+
analyticsId,
|
|
7
|
+
control,
|
|
8
|
+
margin: margin !== null && margin !== void 0 ? margin : 'md',
|
|
9
|
+
tags,
|
|
10
|
+
tabs: mapTabs(tabs, uid, mapperProps, schemaComponents),
|
|
11
|
+
});
|
|
12
|
+
const mapTabs = (tabs, uid, mapperProps, schemaComponents) => tabs.map(({ components, tag, tags, title }, tabIndex) => ({
|
|
13
|
+
title,
|
|
14
|
+
tags: mapTags({ tag, tags }),
|
|
15
|
+
components: components.map((c, componentIndex) => mapLayoutToComponent(`${uid}.tabs-${tabIndex}-${componentIndex}`, c, mapperProps, schemaComponents)),
|
|
16
|
+
}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createUpsellComponent } from '../../components/UpsellComponent';
|
|
2
|
+
import { getDomainLayerCallToAction } from '../utils/call-to-action-utils';
|
|
3
|
+
import { getDomainLayerMedia } from '../utils/media-utils';
|
|
4
|
+
export const upsellLayoutToComponent = (uid, { analyticsId, callToAction, control, margin, media, onDismiss, tags, text }, mapperProps) => {
|
|
5
|
+
const { onComponentUpdate } = mapperProps;
|
|
6
|
+
return createUpsellComponent({
|
|
7
|
+
uid,
|
|
8
|
+
analyticsId,
|
|
9
|
+
callToAction: getDomainLayerCallToAction(callToAction, mapperProps),
|
|
10
|
+
control,
|
|
11
|
+
margin: margin !== null && margin !== void 0 ? margin : 'md',
|
|
12
|
+
media: getDomainLayerMedia({ media }),
|
|
13
|
+
tags,
|
|
14
|
+
text,
|
|
15
|
+
onDismiss: onDismiss
|
|
16
|
+
? () => {
|
|
17
|
+
const { url, method } = onDismiss;
|
|
18
|
+
const body = method === 'GET' ? undefined : JSON.stringify(onDismiss.body);
|
|
19
|
+
void mapperProps.httpClient(url, { method, body }).catch(() => {
|
|
20
|
+
// we can ignore errors on dismiss upsell
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
: undefined,
|
|
24
|
+
}, onComponentUpdate);
|
|
25
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { alertLayoutToComponent } from './layout/alertLayoutToComponent';
|
|
2
|
+
import { boxLayoutToComponent } from './layout/boxLayoutToComponent';
|
|
3
|
+
import { buttonLayoutToComponent } from './layout/buttonLayoutToComponent';
|
|
4
|
+
import { columnsLayoutToComponent } from './layout/columnsLayoutToComponent';
|
|
5
|
+
import { decisionLayoutToComponent } from './layout/decisionLayoutToComponent';
|
|
6
|
+
import { deprecatedListLayoutToComponent, isDeprecatedListLayout, } from './layout/deprecatedListLayoutToComponent';
|
|
7
|
+
import { dividerLayoutToComponent } from './layout/dividerLayoutToComponent';
|
|
8
|
+
import { formLayoutToComponent } from './layout/formLayoutToComponent';
|
|
9
|
+
import { headingLayoutToComponent } from './layout/headingLayoutToComponent';
|
|
10
|
+
import { imageLayoutToComponent } from './layout/imageLayoutToComponent';
|
|
11
|
+
import { infoLayoutToComponent } from './layout/infoLayoutToComponent';
|
|
12
|
+
import { instructionsLayoutToComponent } from './layout/instructionsLayoutToComponent';
|
|
13
|
+
import { listLayoutToComponent } from './layout/listLayoutToComponent';
|
|
14
|
+
import { loadingIndicatorLayoutToComponent } from './layout/loadingIndicatorLayoutToComponent';
|
|
15
|
+
import { markdownLayoutToComponent } from './layout/markdownLayoutToComponent';
|
|
16
|
+
import { mediaLayoutToComponent } from './layout/mediaLayoutToComponent';
|
|
17
|
+
import { modalLayoutToComponent } from './layout/modalLayoutToComponent';
|
|
18
|
+
import { paragraphLayoutToComponent } from './layout/paragraphLayoutToComponent';
|
|
19
|
+
import { progressLayoutToComponent } from './layout/progressLayoutToComponent';
|
|
20
|
+
import { reviewLayoutToComponent } from './layout/reviewLayoutToComponent';
|
|
21
|
+
import { searchLayoutToComponent } from './layout/searchLayoutToComponent';
|
|
22
|
+
import { sectionLayoutToComponent } from './layout/sectionLayoutToComponent';
|
|
23
|
+
import { statusListLayoutToComponent } from './layout/statusListLayoutToComponent';
|
|
24
|
+
import { tabsLayoutToComponent } from './layout/tabsLayoutToComponent';
|
|
25
|
+
import { upsellLayoutToComponent } from './layout/upsellLayoutToComponent';
|
|
26
|
+
export const mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
|
|
27
|
+
switch (layout.type) {
|
|
28
|
+
case 'alert':
|
|
29
|
+
return alertLayoutToComponent(uid, layout, mapperProps);
|
|
30
|
+
case 'box':
|
|
31
|
+
return boxLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
32
|
+
case 'button':
|
|
33
|
+
return buttonLayoutToComponent(uid, layout, mapperProps);
|
|
34
|
+
case 'columns':
|
|
35
|
+
return columnsLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
36
|
+
case 'decision':
|
|
37
|
+
return decisionLayoutToComponent(uid, layout, mapperProps);
|
|
38
|
+
case 'divider':
|
|
39
|
+
return dividerLayoutToComponent(uid, layout);
|
|
40
|
+
case 'form':
|
|
41
|
+
return formLayoutToComponent(uid, layout, schemaComponents);
|
|
42
|
+
case 'heading':
|
|
43
|
+
return headingLayoutToComponent(uid, layout);
|
|
44
|
+
case 'image':
|
|
45
|
+
return imageLayoutToComponent(uid, layout);
|
|
46
|
+
case 'info':
|
|
47
|
+
return infoLayoutToComponent(uid, layout);
|
|
48
|
+
case 'instructions':
|
|
49
|
+
return instructionsLayoutToComponent(uid, layout);
|
|
50
|
+
case 'list':
|
|
51
|
+
return isDeprecatedListLayout(layout)
|
|
52
|
+
? deprecatedListLayoutToComponent(uid, layout)
|
|
53
|
+
: listLayoutToComponent(uid, layout, mapperProps);
|
|
54
|
+
case 'loading-indicator':
|
|
55
|
+
return loadingIndicatorLayoutToComponent(uid, layout);
|
|
56
|
+
case 'markdown':
|
|
57
|
+
return markdownLayoutToComponent(uid, layout);
|
|
58
|
+
case 'media':
|
|
59
|
+
return mediaLayoutToComponent(uid, layout);
|
|
60
|
+
case 'modal':
|
|
61
|
+
return modalLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
62
|
+
case 'paragraph':
|
|
63
|
+
return paragraphLayoutToComponent(uid, layout);
|
|
64
|
+
case 'progress':
|
|
65
|
+
return progressLayoutToComponent(uid, layout);
|
|
66
|
+
case 'review':
|
|
67
|
+
return reviewLayoutToComponent(uid, layout, mapperProps);
|
|
68
|
+
case 'search':
|
|
69
|
+
return searchLayoutToComponent(uid, layout, mapperProps);
|
|
70
|
+
case 'section':
|
|
71
|
+
return sectionLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
72
|
+
case 'status-list':
|
|
73
|
+
return statusListLayoutToComponent(uid, layout, mapperProps);
|
|
74
|
+
case 'tabs':
|
|
75
|
+
return tabsLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
76
|
+
case 'upsell':
|
|
77
|
+
return upsellLayoutToComponent(uid, layout, mapperProps);
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`Invalid layout type in ${JSON.stringify(layout)}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { numberSchemaToComponent } from './schema/numberSchemaToComponent';
|
|
2
|
+
import { isAllOfSchema, isArraySchema, isBlobSchema, isBooleanSchema, isConstSchema, isIntegerSchema, isNumberSchema, isObjectSchema, isOneOfSchema, isSchemaWithPersistAsync, isStringSchema, } from '../../utils/type-utils';
|
|
3
|
+
import { allOfSchemaToComponent } from './schema/allOfSchemaToComponent';
|
|
4
|
+
import { arraySchemaToComponent } from './schema/arraySchemaToComponent/arraySchemaToComponent';
|
|
5
|
+
import { blobSchemaToComponent } from './schema/blobSchemaToComponent';
|
|
6
|
+
import { booleanSchemaToComponent } from './schema/booleanSchemaToComponent';
|
|
7
|
+
import { constSchemaToComponent } from './schema/constSchemaToComponent';
|
|
8
|
+
import { integerSchemaToComponent } from './schema/integerSchemaToComponent';
|
|
9
|
+
import { objectSchemaToFormattedValueComponent } from './schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent';
|
|
10
|
+
import { objectSchemaToMoneyInputComponent } from './schema/objectSchemaToComponent/objectSchemaToMoneyInputComponent';
|
|
11
|
+
import { objectSchemaToObjectComponent } from './schema/objectSchemaToComponent/objectSchemaToObjectComponent';
|
|
12
|
+
import { oneOfSchemaToComponent } from './schema/oneOfSchemaToComponent/oneOfSchemaToComponent';
|
|
13
|
+
import { persistAsyncSchemaToComponent } from './schema/persistAsyncSchemaToComponent';
|
|
14
|
+
import { stringSchemaToComponent } from './schema/stringSchemaToComponent/stringSchemaToComponent';
|
|
15
|
+
export const mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
16
|
+
const { uid, schema } = schemaMapperProps;
|
|
17
|
+
if (isConstSchema(schema)) {
|
|
18
|
+
return constSchemaToComponent(uid, Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
19
|
+
}
|
|
20
|
+
if (isSchemaWithPersistAsync(schema)) {
|
|
21
|
+
return persistAsyncSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
22
|
+
}
|
|
23
|
+
if (isAllOfSchema(schema)) {
|
|
24
|
+
return allOfSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
25
|
+
}
|
|
26
|
+
if (isOneOfSchema(schema)) {
|
|
27
|
+
return oneOfSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
28
|
+
}
|
|
29
|
+
if (isBooleanSchema(schema)) {
|
|
30
|
+
return booleanSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
31
|
+
}
|
|
32
|
+
if (isObjectSchema(schema)) {
|
|
33
|
+
const { format } = schema;
|
|
34
|
+
if (format === 'money') {
|
|
35
|
+
return objectSchemaToMoneyInputComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
36
|
+
}
|
|
37
|
+
if (format != null && Object.keys(schema.properties).length === 0) {
|
|
38
|
+
return objectSchemaToFormattedValueComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema: Object.assign(Object.assign({}, schema), { format }) }), mapperProps);
|
|
39
|
+
}
|
|
40
|
+
return objectSchemaToObjectComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
41
|
+
}
|
|
42
|
+
if (isIntegerSchema(schema)) {
|
|
43
|
+
return integerSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
44
|
+
}
|
|
45
|
+
if (isNumberSchema(schema)) {
|
|
46
|
+
return numberSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
47
|
+
}
|
|
48
|
+
if (isStringSchema(schema)) {
|
|
49
|
+
return stringSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
50
|
+
}
|
|
51
|
+
if (isArraySchema(schema)) {
|
|
52
|
+
return arraySchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
53
|
+
}
|
|
54
|
+
if (isBlobSchema(schema)) {
|
|
55
|
+
if (!schemaMapperProps.onPersistAsync) {
|
|
56
|
+
throw new Error('Blob schemas can only be used as the schema of a persist async configuration.');
|
|
57
|
+
}
|
|
58
|
+
return blobSchemaToComponent(Object.assign(Object.assign({}, schemaMapperProps), { schema }), mapperProps);
|
|
59
|
+
}
|
|
60
|
+
throw new Error('Not yet supported');
|
|
61
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { getMockMapperProps, getMockSchemaMapperProps } from './schema/tests/test-utils';
|
|
2
|
+
import { mapSchemaToComponent } from './mapSchemaToComponent';
|
|
3
|
+
describe('mapSchemaToComponents', () => {
|
|
4
|
+
describe('when no alert is given', () => {
|
|
5
|
+
it('returns a StepComponent for the schema', () => {
|
|
6
|
+
const schema = {
|
|
7
|
+
type: 'string',
|
|
8
|
+
};
|
|
9
|
+
const component = mapSchemaToComponent(getMockSchemaMapperProps({ schema, model: null }), getMockMapperProps());
|
|
10
|
+
expect(component.type).toBe('text');
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
describe('when const schemas are given', () => {
|
|
14
|
+
const constSchemas = {
|
|
15
|
+
$id: '#schema',
|
|
16
|
+
type: 'object',
|
|
17
|
+
title: 'Object Schema',
|
|
18
|
+
displayOrder: ['cbs', 'cns', 'css', 'cos', 'cas'],
|
|
19
|
+
properties: {
|
|
20
|
+
cbs: {
|
|
21
|
+
title: 'Const boolean schema',
|
|
22
|
+
const: true,
|
|
23
|
+
},
|
|
24
|
+
cns: {
|
|
25
|
+
title: 'Const number schema',
|
|
26
|
+
const: 42,
|
|
27
|
+
},
|
|
28
|
+
css: {
|
|
29
|
+
title: 'Const string schema',
|
|
30
|
+
const: 'Hello World!',
|
|
31
|
+
},
|
|
32
|
+
cos: {
|
|
33
|
+
title: 'Const object schema',
|
|
34
|
+
const: {
|
|
35
|
+
name: 'John Doe',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
cas: {
|
|
39
|
+
title: 'Const array schema',
|
|
40
|
+
const: ['Hello', 'World!'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
describe('when the getValue function is called', () => {
|
|
45
|
+
it('returns the const values', async () => {
|
|
46
|
+
const component = mapSchemaToComponent(getMockSchemaMapperProps({ schema: constSchemas, model: null }), getMockMapperProps());
|
|
47
|
+
expect(await component.getSubmittableValue()).toStrictEqual({
|
|
48
|
+
cbs: true,
|
|
49
|
+
cns: 42,
|
|
50
|
+
css: 'Hello World!',
|
|
51
|
+
cos: { name: 'John Doe' },
|
|
52
|
+
cas: ['Hello', 'World!'],
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('when hidden schemas are given', () => {
|
|
58
|
+
const hiddenSchemas = {
|
|
59
|
+
$id: '#schema',
|
|
60
|
+
type: 'object',
|
|
61
|
+
title: 'Object Schema',
|
|
62
|
+
displayOrder: ['hbs', 'hns', 'hss'],
|
|
63
|
+
properties: {
|
|
64
|
+
hbs: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
title: 'Hidden boolean schema',
|
|
67
|
+
hidden: true,
|
|
68
|
+
default: true,
|
|
69
|
+
},
|
|
70
|
+
hns: {
|
|
71
|
+
type: 'number',
|
|
72
|
+
title: 'Hidden number schema',
|
|
73
|
+
hidden: true,
|
|
74
|
+
default: 42,
|
|
75
|
+
},
|
|
76
|
+
hss: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
title: 'Hidden string schema',
|
|
79
|
+
hidden: true,
|
|
80
|
+
default: 'Hello World!',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
describe('when model is null', () => {
|
|
85
|
+
describe('and the getValue function is called', () => {
|
|
86
|
+
it('returns the default values', async () => {
|
|
87
|
+
const component = mapSchemaToComponent(getMockSchemaMapperProps({ schema: hiddenSchemas, model: null }), getMockMapperProps());
|
|
88
|
+
expect(await component.getSubmittableValue()).toStrictEqual({
|
|
89
|
+
hbs: true,
|
|
90
|
+
hns: 42,
|
|
91
|
+
hss: 'Hello World!',
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('when model is not null', () => {
|
|
97
|
+
describe('and the getValue function is called', () => {
|
|
98
|
+
it('prefers to return the model values over the default values', async () => {
|
|
99
|
+
const component = mapSchemaToComponent(getMockSchemaMapperProps({
|
|
100
|
+
schema: hiddenSchemas,
|
|
101
|
+
model: { hbs: false, hns: 0, hss: 'Hello' },
|
|
102
|
+
}), getMockMapperProps());
|
|
103
|
+
expect(await component.getSubmittableValue()).toStrictEqual({
|
|
104
|
+
hbs: false,
|
|
105
|
+
hns: 0,
|
|
106
|
+
hss: 'Hello',
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { mapSchemaToComponent } from './mapSchemaToComponent';
|
|
2
|
+
export const mapStepSchemas = (uid, step, stepLocalValue, mapperProps, referencedSchemaIds) => {
|
|
3
|
+
const isReferenced = (schemaId) => schemaId != null && referencedSchemaIds.includes(schemaId);
|
|
4
|
+
return step.schemas.map((schema, i) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const schemaComponent = mapSchemaToComponent({
|
|
7
|
+
uid: `${uid}.schemas-${i}.${schema.$id}`,
|
|
8
|
+
schemaId: schema.$id,
|
|
9
|
+
schema,
|
|
10
|
+
model: (_a = step.model) !== null && _a !== void 0 ? _a : null,
|
|
11
|
+
localValue: stepLocalValue,
|
|
12
|
+
validationErrors: (_b = step.errors) === null || _b === void 0 ? void 0 : _b.validation,
|
|
13
|
+
required: true,
|
|
14
|
+
}, mapperProps);
|
|
15
|
+
return Object.assign(Object.assign({}, schemaComponent), { isSchemaReferencedInStep: isReferenced(schema.$id) });
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { createExternalConfirmation } from '../components/step/ExternalConfirmationComponent';
|
|
13
|
+
import { createStepComponent } from '../components/step/StepDomainComponent';
|
|
14
|
+
import { getStepPolling } from '../features/polling/getStepPolling';
|
|
15
|
+
import { getStepRefreshAfter } from '../features/refreshAfter/getStepRefreshAfter';
|
|
16
|
+
import { mapLayoutToComponent } from './mapLayoutToComponent';
|
|
17
|
+
import { mapStepSchemas } from './mapStepSchemas';
|
|
18
|
+
import { mapToolbarToComponent } from './mapToolbarToComponent';
|
|
19
|
+
import { groupLayoutByPinned } from './utils/groupLayoutByPinned';
|
|
20
|
+
import { normaliseMarginInLastComponent } from './utils/layout-utils';
|
|
21
|
+
import { getStepPrefetch } from '../features/prefetch/getStepPrefetch';
|
|
22
|
+
export const mapStepToComponent = (_a) => {
|
|
23
|
+
var _b;
|
|
24
|
+
var { uid: rootUid, loadingState, features, trackEvent, onPoll, onBehavior } = _a, restProps = __rest(_a, ["uid", "loadingState", "features", "trackEvent", "onPoll", "onBehavior"]);
|
|
25
|
+
const { etag, step, stepLocalValue, flowRequestCache, logEvent, onComponentUpdate } = restProps;
|
|
26
|
+
const { id, control, description, errors, external, key, navigation, polling, refreshAfter, title, tags, } = step;
|
|
27
|
+
const submissionBehaviors = [];
|
|
28
|
+
const registerSubmissionBehavior = (behavior) => {
|
|
29
|
+
if (behavior.type === 'action' && behavior.action.prefetch) {
|
|
30
|
+
// eslint-disable-next-line functional/immutable-data
|
|
31
|
+
submissionBehaviors.push(behavior);
|
|
32
|
+
}
|
|
33
|
+
if (behavior.type === 'subflow' &&
|
|
34
|
+
behavior.launchConfig.type === 'dynamic' &&
|
|
35
|
+
behavior.launchConfig.request.prefetch) {
|
|
36
|
+
// eslint-disable-next-line functional/immutable-data
|
|
37
|
+
submissionBehaviors.push(behavior);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const back = mapBackNavigation(navigation, onBehavior, features.isEnabled('nativeBack'));
|
|
41
|
+
const stepId = id || key;
|
|
42
|
+
if (stepId === undefined) {
|
|
43
|
+
throw new Error('Step must have an id or a key');
|
|
44
|
+
}
|
|
45
|
+
const uid = `${rootUid}.${stepId !== null && stepId !== void 0 ? stepId : 'step'}`;
|
|
46
|
+
const stepPolling = polling
|
|
47
|
+
? getStepPolling({
|
|
48
|
+
pollingConfig: polling,
|
|
49
|
+
logEvent,
|
|
50
|
+
onBehavior,
|
|
51
|
+
onPoll,
|
|
52
|
+
registerSubmissionBehavior,
|
|
53
|
+
})
|
|
54
|
+
: undefined;
|
|
55
|
+
const stepRefreshAfter = refreshAfter
|
|
56
|
+
? getStepRefreshAfter({ refreshAfter, logEvent, onBehavior })
|
|
57
|
+
: undefined;
|
|
58
|
+
const stepPrefetch = getStepPrefetch(restProps.httpClient, flowRequestCache, submissionBehaviors);
|
|
59
|
+
const externalConfirmation = (external === null || external === void 0 ? void 0 : external.url)
|
|
60
|
+
? createExternalConfirmation(`${uid}-external-confirmation`, external === null || external === void 0 ? void 0 : external.url, onComponentUpdate)
|
|
61
|
+
: undefined;
|
|
62
|
+
const mapperProps = Object.assign(Object.assign({}, restProps), { features,
|
|
63
|
+
trackEvent,
|
|
64
|
+
onBehavior,
|
|
65
|
+
registerSubmissionBehavior });
|
|
66
|
+
const referencedSchemaIds = getReferencedSchemaId(step);
|
|
67
|
+
const schemaComponents = mapStepSchemas(uid, step, stepLocalValue, mapperProps, referencedSchemaIds);
|
|
68
|
+
const { layout, footer } = getLayoutAndFooter(step, features);
|
|
69
|
+
const layoutComponents = layout.map((layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps, schemaComponents));
|
|
70
|
+
const footerComponents = normaliseMarginInLastComponent(footer).map((footerComponent, index) => mapLayoutToComponent(`${uid}.footer-${index}`, footerComponent, mapperProps, schemaComponents));
|
|
71
|
+
const toolbar = mapToolbarToComponent(uid, step.toolbar, mapperProps);
|
|
72
|
+
const stepComponent = createStepComponent({
|
|
73
|
+
uid,
|
|
74
|
+
back,
|
|
75
|
+
etag,
|
|
76
|
+
toolbar,
|
|
77
|
+
layoutComponents,
|
|
78
|
+
schemaComponents,
|
|
79
|
+
footerComponents,
|
|
80
|
+
control,
|
|
81
|
+
description,
|
|
82
|
+
error: errors === null || errors === void 0 ? void 0 : errors.error,
|
|
83
|
+
externalConfirmation,
|
|
84
|
+
loadingState,
|
|
85
|
+
stepPolling,
|
|
86
|
+
stepRefreshAfter,
|
|
87
|
+
title,
|
|
88
|
+
tags,
|
|
89
|
+
stackBehavior: (_b = navigation === null || navigation === void 0 ? void 0 : navigation.stackBehavior) !== null && _b !== void 0 ? _b : 'default',
|
|
90
|
+
stepPrefetch,
|
|
91
|
+
step,
|
|
92
|
+
onComponentUpdate,
|
|
93
|
+
trackEvent,
|
|
94
|
+
onBehavior,
|
|
95
|
+
});
|
|
96
|
+
return stepComponent;
|
|
97
|
+
};
|
|
98
|
+
const getReferencedSchemaId = (step) => {
|
|
99
|
+
const { schemas, layout } = step;
|
|
100
|
+
const stringifiedLayout = JSON.stringify(layout);
|
|
101
|
+
return schemas
|
|
102
|
+
.filter((schema) => stringifiedLayout.includes(`"schemaId":"${schema.$id}"`) ||
|
|
103
|
+
stringifiedLayout.includes(`"schema":{"$ref":"${schema.$id}"`))
|
|
104
|
+
.map((schema) => schema.$id)
|
|
105
|
+
.filter((schemaId) => schemaId !== undefined);
|
|
106
|
+
};
|
|
107
|
+
const mapBackNavigation = (navigation, onBehavior, isNativeBackEnabled) => {
|
|
108
|
+
var _a;
|
|
109
|
+
const backNavigation = (_a = navigation === null || navigation === void 0 ? void 0 : navigation.back) !== null && _a !== void 0 ? _a : navigation === null || navigation === void 0 ? void 0 : navigation.backButton;
|
|
110
|
+
const backBehavior = { type: 'back', action: backNavigation === null || backNavigation === void 0 ? void 0 : backNavigation.action };
|
|
111
|
+
return backNavigation || isNativeBackEnabled
|
|
112
|
+
? {
|
|
113
|
+
title: backNavigation === null || backNavigation === void 0 ? void 0 : backNavigation.title,
|
|
114
|
+
onClick: () => {
|
|
115
|
+
void onBehavior(backBehavior);
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
: undefined;
|
|
119
|
+
};
|
|
120
|
+
const getLayoutAndFooter = (step, features) => {
|
|
121
|
+
var _a;
|
|
122
|
+
if (step.footer) {
|
|
123
|
+
const { layout = [], footer = [] } = step;
|
|
124
|
+
return { layout, footer };
|
|
125
|
+
}
|
|
126
|
+
if (features.isEnabled('pinnedButtons')) {
|
|
127
|
+
const { pinned: footer, nonPinned: layout } = groupLayoutByPinned((_a = step.layout) !== null && _a !== void 0 ? _a : []);
|
|
128
|
+
return { layout, footer };
|
|
129
|
+
}
|
|
130
|
+
const { layout = [] } = step;
|
|
131
|
+
return { layout, footer: [] };
|
|
132
|
+
};
|