@wise/dynamic-flow-client 3.5.0-experimental-b041af5 → 3.5.0-experimental-63c768d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/common/errorBoundary/ErrorBoundary.js +44 -0
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +12 -0
- package/build/common/makeHttpClient/makeHttpClient.spec.js +141 -0
- package/build/common/messages/external-confirmation.messages.js +23 -0
- package/build/i18n/de.json +46 -46
- package/build/i18n/en.json +46 -46
- package/build/i18n/es.json +46 -46
- package/build/i18n/fr.json +46 -46
- package/build/i18n/hu.json +46 -46
- package/build/i18n/id.json +46 -46
- package/build/i18n/index.js +36 -0
- package/build/i18n/it.json +46 -46
- package/build/i18n/ja.json +46 -46
- package/build/i18n/pl.json +46 -46
- package/build/i18n/pt.json +46 -46
- package/build/i18n/ro.json +46 -46
- package/build/i18n/ru.json +46 -46
- package/build/i18n/th.json +46 -46
- package/build/i18n/tr.json +46 -46
- package/build/i18n/zh_CN.json +46 -46
- package/build/i18n/zh_HK.json +46 -46
- package/build/index.js +10 -0
- package/build/legacy/common/contexts/eventsContext/EventsContext.spec.js +58 -0
- package/build/legacy/common/contexts/featureContext/FeatureContext.spec.js +41 -0
- package/build/legacy/common/contexts/logContext/LogContext.spec.js +54 -0
- package/build/legacy/common/hooks/useDebouncedFunction/useDebouncedFunction.spec.js +59 -0
- package/build/legacy/common/hooks/useExternal/useExternal.spec.js +236 -0
- package/build/legacy/common/hooks/useStepPolling/useStepPolling.spec.js +288 -0
- package/build/legacy/common/utils/debounce.spec.js +72 -0
- package/build/legacy/common/utils/file-utils.spec.js +69 -0
- package/build/legacy/common/utils/id-utils.spec.js +12 -0
- package/build/legacy/common/utils/is-equal.spec.js +88 -0
- package/build/legacy/common/utils/mobile-utils.spec.js +71 -0
- package/build/legacy/common/validators/models/model-utils.spec.js +45 -0
- package/build/legacy/common/validators/models/model-validators.spec.js +647 -0
- package/build/legacy/common/validators/schemas/schema-validators.spec.js +157 -0
- package/build/legacy/common/validators/types/type-validators.spec.js +147 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.spec.js +198 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.utils.spec.js +145 -0
- package/build/legacy/common/validators/values/value-validators.spec.js +22 -0
- package/build/legacy/dynamicFlow/BackButton.js +22 -0
- package/build/legacy/dynamicFlow/DynamicFlow.js +346 -0
- package/build/legacy/dynamicFlow/DynamicFlowStep.js +37 -0
- package/build/legacy/dynamicFlow/DynamicFlowTypes.js +1 -0
- package/build/legacy/dynamicFlow/index.js +1 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/DynamicFlow.story.js +78 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/ErrorResponses.story.js +124 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/Examples.story.js +25 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/Features.story.js +33 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/JsonSchemaForm.story.js +31 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/RefreshOnChange.story.js +194 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/SearchFeature.story.js +114 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/ServerTest.story.js +44 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/Upload.story.js +212 -0
- package/build/legacy/dynamicFlow/stories/dev-tools/ValidationAsync.story.js +156 -0
- package/build/legacy/dynamicFlow/stories/examples/ObjectConst.story.js +150 -0
- package/build/legacy/dynamicFlow/stories/fixtureHttpClient.js +117 -0
- package/build/legacy/dynamicFlow/stories/visual-tests/VisualTests.story.js +43 -0
- package/build/legacy/dynamicFlow/tests/Actions.spec.js +185 -0
- package/build/legacy/dynamicFlow/tests/AllOfSchema.spec.js +196 -0
- package/build/legacy/dynamicFlow/tests/AutocompleteHints.spec.js +59 -0
- package/build/legacy/dynamicFlow/tests/DynamicFlow.BackButton.spec.js +179 -0
- package/build/legacy/dynamicFlow/tests/DynamicFlow.search.spec.js +475 -0
- package/build/legacy/dynamicFlow/tests/DynamicFlow.spec.js +559 -0
- package/build/legacy/dynamicFlow/tests/DynamicImage.spec.js +287 -0
- package/build/legacy/dynamicFlow/tests/DynamicInstructions.spec.js +49 -0
- package/build/legacy/dynamicFlow/tests/HiddenSchemas.spec.js +307 -0
- package/build/legacy/dynamicFlow/tests/ModalLayout.spec.js +252 -0
- package/build/legacy/dynamicFlow/tests/MultiSelect.spec.js +327 -0
- package/build/legacy/dynamicFlow/tests/MultipleFileUploadSchema.spec.js +401 -0
- package/build/legacy/dynamicFlow/tests/ObjectSchema.spec.js +295 -0
- package/build/legacy/dynamicFlow/tests/OneOfSchema.spec.js +773 -0
- package/build/legacy/dynamicFlow/tests/PersistAsync.blob-schema.spec.js +331 -0
- package/build/legacy/dynamicFlow/tests/PersistAsync.string-schema.spec.js +389 -0
- package/build/legacy/dynamicFlow/tests/RefreshStepOnChange.debouncing.spec.js +273 -0
- package/build/legacy/dynamicFlow/tests/RefreshStepOnChange.spec.js +567 -0
- package/build/legacy/dynamicFlow/tests/RepeatableSchema.spec.js +977 -0
- package/build/legacy/dynamicFlow/tests/StepModel.spec.js +119 -0
- package/build/legacy/dynamicFlow/tests/ValidationAsync.spec.js +484 -0
- package/build/legacy/dynamicFlow/tests/ssr.spec.js +47 -0
- package/build/legacy/dynamicFlow/utils/index.js +5 -0
- package/build/legacy/dynamicFlow/utils/responseParsers/response-parsers.js +185 -0
- package/build/legacy/dynamicFlow/utils/responseParsers/response-parsers.spec.js +463 -0
- package/build/legacy/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +26 -0
- package/build/legacy/dynamicFlow/utils/useDynamicFlowState.js +137 -0
- package/build/legacy/dynamicFlow/utils/useLoader.js +22 -0
- package/build/legacy/formControl/Select.spec.js +104 -0
- package/build/legacy/formControl/utils/getAutocompleteString.spec.js +30 -0
- package/build/legacy/formControl/utils/value-utils.spec.js +158 -0
- package/build/legacy/jsonSchemaForm/JsonSchemaForm.end-to-end.spec.js +563 -0
- package/build/legacy/jsonSchemaForm/JsonSchemaForm.js +24 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +25 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +34 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.js +134 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.js +85 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.js +135 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.spec.js +909 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/genericSchema/GenericSchema.js +85 -0
- package/build/legacy/jsonSchemaForm/genericSchema/GenericSchema.rtl.spec.js +55 -0
- package/build/legacy/jsonSchemaForm/genericSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/index.js +1 -0
- package/build/legacy/jsonSchemaForm/objectSchema/ObjectSchema.js +77 -0
- package/build/legacy/jsonSchemaForm/objectSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.js +155 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/utils.js +68 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +26 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +131 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +31 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +72 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +8 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +27 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +31 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +32 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +54 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +13 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.spec.js +312 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.spec.js +231 -0
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +150 -0
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/index.js +1 -0
- package/build/legacy/layout/button/DynamicButton.spec.js +152 -0
- package/build/legacy/layout/button/utils.spec.js +50 -0
- package/build/legacy/layout/icon/DynamicIcon.spec.js +20 -0
- package/build/legacy/layout/list/DynamicStatusList.spec.js +111 -0
- package/build/legacy/layout/loadingIndicator/DynamicLoadingIndicator.spec.js +25 -0
- package/build/legacy/layout/markdown/DynamicMarkdown.spec.js +58 -0
- package/build/legacy/layout/review/DynamicReview.spec.js +152 -0
- package/build/legacy/step/cameraStep/CameraStep.js +124 -0
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.js +161 -0
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.spec.js +432 -0
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.js +60 -0
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useVideoConstraints.js +80 -0
- package/build/legacy/step/cameraStep/cameraCapture/index.js +1 -0
- package/build/legacy/step/cameraStep/cameraCapture/overlay/Overlay.js +77 -0
- package/build/legacy/step/cameraStep/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.js +18 -0
- package/build/legacy/step/cameraStep/cameraCapture/screens/index.js +1 -0
- package/build/legacy/step/cameraStep/cameraCapture/tracking/index.js +109 -0
- package/build/legacy/step/cameraStep/cameraCapture/utils/index.js +107 -0
- package/build/legacy/step/cameraStep/index.js +1 -0
- package/build/legacy/step/externalConfirmationStep/ExternalConfirmationStep.js +64 -0
- package/build/legacy/step/externalConfirmationStep/index.js +1 -0
- package/build/legacy/step/index.js +3 -0
- package/build/legacy/test-utils/DynamicFlowProviders.js +19 -0
- package/build/legacy/test-utils/index.js +4 -0
- package/build/legacy/test-utils/legacy-utils.js +69 -0
- package/build/legacy/test-utils/log-utils.js +9 -0
- package/build/main.js +6 -2
- package/build/main.min.js +1 -1
- package/build/main.mjs +6 -2
- package/build/revamp/DynamicFlowCore.js +299 -0
- package/build/revamp/DynamicFlowWise.js +69 -0
- package/build/revamp/DynamicFlowWise.spec.js +105 -0
- package/build/revamp/domain/components/AlertComponent.js +50 -0
- package/build/revamp/domain/components/AllOfComponent.js +72 -0
- package/build/revamp/domain/components/BooleanInputComponent.js +108 -0
- package/build/revamp/domain/components/BoxComponent.js +65 -0
- package/build/revamp/domain/components/ButtonComponent.js +50 -0
- package/build/revamp/domain/components/ColumnsComponent.js +74 -0
- package/build/revamp/domain/components/ConstComponent.js +50 -0
- package/build/revamp/domain/components/ContainerComponent.js +65 -0
- package/build/revamp/domain/components/DateInputComponent.js +127 -0
- package/build/revamp/domain/components/DecisionComponent.js +50 -0
- package/build/revamp/domain/components/DividerComponent.js +50 -0
- package/build/revamp/domain/components/FormComponent.js +65 -0
- package/build/revamp/domain/components/HeadingComponent.js +50 -0
- package/build/revamp/domain/components/ImageComponent.js +50 -0
- package/build/revamp/domain/components/InstructionsComponent.js +50 -0
- package/build/revamp/domain/components/IntegerInputComponent.js +125 -0
- package/build/revamp/domain/components/LoadingIndicatorComponent.js +50 -0
- package/build/revamp/domain/components/MarkdownComponent.js +50 -0
- package/build/revamp/domain/components/ModalComponent.js +65 -0
- package/build/revamp/domain/components/MultiUploadInputComponent.js +190 -0
- package/build/revamp/domain/components/NumberInputComponent.js +125 -0
- package/build/revamp/domain/components/ObjectComponent.js +104 -0
- package/build/revamp/domain/components/ParagraphComponent.js +50 -0
- package/build/revamp/domain/components/ReviewComponent.js +50 -0
- package/build/revamp/domain/components/SelectInputComponent.js +138 -0
- package/build/revamp/domain/components/StatusListComponent.js +50 -0
- package/build/revamp/domain/components/StepDomainComponent.js +93 -0
- package/build/revamp/domain/components/TextInputComponent.js +125 -0
- package/build/revamp/domain/components/UploadInputComponent.js +151 -0
- package/build/revamp/domain/components/repeatableComponent/RepeatableComponent.js +148 -0
- package/build/revamp/domain/components/repeatableComponent/RepeatableComponent.spec.js +145 -0
- package/build/revamp/domain/components/searchComponent/SearchComponent.js +108 -0
- package/build/revamp/domain/components/searchComponent/SearchComponent.spec.js +327 -0
- package/build/revamp/domain/components/utils/component-utils.js +18 -0
- package/build/revamp/domain/components/utils/debounce.js +38 -0
- package/build/revamp/domain/components/utils/debounce.spec.js +72 -0
- package/build/revamp/domain/components/utils/file-utils.js +46 -0
- package/build/revamp/domain/components/utils/getComponentForLocalValueKey.js +31 -0
- package/build/revamp/domain/components/utils/isPartialLocalValueMatch.js +40 -0
- package/build/revamp/domain/components/utils/isPartialLocalValueMatch.spec.js +108 -0
- package/build/revamp/domain/features/events.js +1 -0
- package/build/revamp/domain/features/persistAsync/getComponentPersistAsync.js +133 -0
- package/build/revamp/domain/features/persistAsync/getComponentPersistAsync.spec.js +199 -0
- package/build/revamp/domain/features/persistAsync/getInitialPersistedState.js +6 -0
- package/build/revamp/domain/features/persistAsync/getPerformPersistAsync.js +103 -0
- package/build/revamp/domain/features/persistAsync/getPerformPersistAsync.spec.js +280 -0
- package/build/revamp/domain/features/refresh/getPerformRefresh.js +53 -0
- package/build/revamp/domain/features/search/getPerformSearchFunction.js +104 -0
- package/build/revamp/domain/features/search/getPerformSearchFunction.spec.js +260 -0
- package/build/revamp/domain/features/summary/summary-utils.js +39 -0
- package/build/revamp/domain/features/summary/summary-utils.spec.js +110 -0
- package/build/revamp/domain/features/utils/http-utils.js +34 -0
- package/build/revamp/domain/features/utils/response-utils.js +9 -0
- package/build/revamp/domain/features/validation/spec-utils.js +16 -0
- package/build/revamp/domain/features/validation/validation-functions.js +12 -0
- package/build/revamp/domain/features/validation/validation-functions.spec.js +110 -0
- package/build/revamp/domain/features/validation/value-checks.js +111 -0
- package/build/revamp/domain/features/validation/value-checks.spec.js +204 -0
- package/build/revamp/domain/features/validationAsync/getComponentValidationAsync.js +94 -0
- package/build/revamp/domain/features/validationAsync/getComponentValidationAsync.spec.js +177 -0
- package/build/revamp/domain/features/validationAsync/getInitialValidationState.js +5 -0
- package/build/revamp/domain/features/validationAsync/getPerformValidationAsync.js +107 -0
- package/build/revamp/domain/features/validationAsync/getPerformValidationAsync.spec.js +266 -0
- package/build/revamp/domain/mappers/layout/alertLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/boxLayoutToComponents.js +15 -0
- package/build/revamp/domain/mappers/layout/buttonLayoutToComponent.js +64 -0
- package/build/revamp/domain/mappers/layout/columnsLayoutToComponent.js +18 -0
- package/build/revamp/domain/mappers/layout/decisionLayoutToComponent.js +36 -0
- package/build/revamp/domain/mappers/layout/dividerLayoutToComponent.js +5 -0
- package/build/revamp/domain/mappers/layout/formLayoutToComponent.js +27 -0
- package/build/revamp/domain/mappers/layout/headingLayoutToComponent.js +13 -0
- package/build/revamp/domain/mappers/layout/imageLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/infoLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/instructionsLayoutToComponent.js +18 -0
- package/build/revamp/domain/mappers/layout/listLayoutToComponent.js +30 -0
- package/build/revamp/domain/mappers/layout/loadingIndicatorLayoutToComponent.js +5 -0
- package/build/revamp/domain/mappers/layout/markdownLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/modalLayoutToComponent.js +17 -0
- package/build/revamp/domain/mappers/layout/paragraphLayoutToComponent.js +12 -0
- package/build/revamp/domain/mappers/layout/reviewLayoutToComponent.js +51 -0
- package/build/revamp/domain/mappers/layout/searchLayoutToComponent.js +14 -0
- package/build/revamp/domain/mappers/layout/statusListLayoutToComponent.js +11 -0
- package/build/revamp/domain/mappers/mapLayoutToComponent.js +63 -0
- package/build/revamp/domain/mappers/mapSchemaToComponent.js +84 -0
- package/build/revamp/domain/mappers/mapSchemaToComponent.spec.js +197 -0
- package/build/revamp/domain/mappers/mapStepToComponent.js +143 -0
- package/build/revamp/domain/mappers/mapStepToComponent.spec.js +184 -0
- package/build/revamp/domain/mappers/schema/allOfSchemaToComponent.js +29 -0
- package/build/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.js +35 -0
- package/build/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.js +63 -0
- package/build/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.js +65 -0
- package/build/revamp/domain/mappers/schema/blobSchemaToComponent.js +30 -0
- package/build/revamp/domain/mappers/schema/booleanSchemaToComponent.js +38 -0
- package/build/revamp/domain/mappers/schema/constSchemaToComponent.js +14 -0
- package/build/revamp/domain/mappers/schema/integerSchemaToComponent.js +36 -0
- package/build/revamp/domain/mappers/schema/numberSchemaToComponent.js +35 -0
- package/build/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.js +41 -0
- package/build/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.spec.js +165 -0
- package/build/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.js +67 -0
- package/build/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.spec.js +316 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.js +14 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.spec.js +220 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.js +37 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.js +45 -0
- package/build/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.js +32 -0
- package/build/revamp/domain/mappers/schema/tests/test-utils.js +27 -0
- package/build/revamp/domain/mappers/schema/types.js +1 -0
- package/build/revamp/domain/mappers/schema/utils/getPersistAsyncInitialState.js +35 -0
- package/build/revamp/domain/mappers/schema/utils/getValidationAsyncInitialState.js +25 -0
- package/build/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.js +28 -0
- package/build/revamp/domain/mappers/types.js +1 -0
- package/build/revamp/domain/mappers/utils/getAutocompleteString.js +76 -0
- package/build/revamp/domain/mappers/utils/getAutocompleteString.spec.js +21 -0
- package/build/revamp/domain/mappers/utils/getRandomId.js +2 -0
- package/build/revamp/domain/mappers/utils/legacy-utils.js +53 -0
- package/build/revamp/domain/types.js +1 -0
- package/build/revamp/flow/executeRefresh.js +97 -0
- package/build/revamp/flow/executeSubmission.js +152 -0
- package/build/revamp/flow/getResponseType.js +76 -0
- package/build/revamp/flow/response-utils.js +88 -0
- package/build/revamp/renderers/CoreContainerRenderer.js +8 -0
- package/build/revamp/renderers/LoadingContext.js +7 -0
- package/build/revamp/renderers/getRenderFunction.js +55 -0
- package/build/revamp/renderers/getSchemaErrorMessageFunction.js +90 -0
- package/build/revamp/renderers/mappers/alertComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/allOfComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/booleanInputComponentToProps.js +16 -0
- package/build/revamp/renderers/mappers/boxComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/buttonComponentToProps.js +14 -0
- package/build/revamp/renderers/mappers/columnsComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/componentToRendererProps.js +105 -0
- package/build/revamp/renderers/mappers/containerComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/dateInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/decisionComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/dividerComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/formComponentToProps.js +4 -0
- package/build/revamp/renderers/mappers/headingComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/hiddenComponentToProps.js +3 -0
- package/build/revamp/renderers/mappers/imageComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/instructionsComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/integerInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/loadingIndicatorComponentToProps.js +9 -0
- package/build/revamp/renderers/mappers/markdownComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/modalComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/multiUploadInputComponentToProps.js +24 -0
- package/build/revamp/renderers/mappers/numberInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/objectComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/paragraphComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/repeatableComponentToProps.js +40 -0
- package/build/revamp/renderers/mappers/reviewComponentToProps.js +11 -0
- package/build/revamp/renderers/mappers/searchComponentToProps.js +49 -0
- package/build/revamp/renderers/mappers/selectInputComponentToProps.js +29 -0
- package/build/revamp/renderers/mappers/statusListComponentToProps.js +10 -0
- package/build/revamp/renderers/mappers/textInputComponentToProps.js +13 -0
- package/build/revamp/renderers/mappers/uploadInputComponentToProps.js +16 -0
- package/build/revamp/renderers/mappers/utils/inputComponentToProps.js +27 -0
- package/build/revamp/renderers/step/ExternalConfirmationDialog.js +31 -0
- package/build/revamp/renderers/step/StepRenderer.js +29 -0
- package/build/revamp/renderers/step/useExternal.js +15 -0
- package/build/revamp/renderers/stepComponentToProps.js +9 -0
- package/build/revamp/renderers/types.js +1 -0
- package/build/revamp/stories/dev-tools/DynamicFlowRevamp.story.js +304 -0
- package/build/revamp/stories/dev-tools/EditableStep.story.js +71 -0
- package/build/revamp/stories/dev-tools/ErrorHandling.story.js +149 -0
- package/build/revamp/stories/dev-tools/External.story.js +83 -0
- package/build/revamp/stories/dev-tools/OneOf.Inititalisation.story.js +123 -0
- package/build/revamp/stories/dev-tools/PersistAsync.story.js +168 -0
- package/build/revamp/stories/dev-tools/RefreshOnChange.story.js +309 -0
- package/build/revamp/stories/dev-tools/RefreshOnChange.with.PersistAsync.story.js +1004 -0
- package/build/revamp/stories/dev-tools/ServerTest.story.js +81 -0
- package/build/revamp/stories/dev-tools/Upload.story.js +221 -0
- package/build/revamp/stories/dev-tools/ValidationAsync.story.js +161 -0
- package/build/revamp/stories/examples/ObjectConst.story.js +153 -0
- package/build/revamp/stories/examples/OneOfInitialisation.story.js +102 -0
- package/build/revamp/stories/utils/fixtureHttpClient.js +130 -0
- package/build/revamp/stories/utils/mockSearchHandler.js +125 -0
- package/build/revamp/stories/visual-tests/VisualTests.story.js +111 -0
- package/build/revamp/test-utils/component-utils.js +19 -0
- package/build/revamp/test-utils/step-utils.js +6 -0
- package/build/revamp/tests/ImageRenderer.spec.js +108 -0
- package/build/revamp/tests/InitialAction.spec.js +281 -0
- package/build/revamp/tests/InitialStep.spec.js +104 -0
- package/build/revamp/tests/Logging.spec.js +112 -0
- package/build/revamp/tests/OneOfInitialisation.spec.js +654 -0
- package/build/revamp/tests/RefreshOnChange.ResponseHandling.spec.js +322 -0
- package/build/revamp/tests/RefreshOnChange.with.Tabs.spec.js +390 -0
- package/build/revamp/tests/RefreshOnChangePreserve.spec.js +218 -0
- package/build/revamp/tests/Submission.ResponseHandling.spec.js +697 -0
- package/build/revamp/tests/Submission.spec.js +399 -0
- package/build/revamp/tests/legacy/HiddenSchemas.spec.js +312 -0
- package/build/revamp/tests/legacy/MultipleFileUploadSchema.spec.js +447 -0
- package/build/revamp/tests/legacy/PersistAsync.blob-schema.spec.js +339 -0
- package/build/revamp/tests/legacy/PersistAsync.string-schema.spec.js +385 -0
- package/build/revamp/tests/legacy/RefreshStepOnChange.debouncing.spec.js +235 -0
- package/build/revamp/tests/legacy/RefreshStepOnChange.spec.js +623 -0
- package/build/revamp/tests/legacy/ValidationAsync.spec.js +452 -0
- package/build/revamp/tests/legacy/useExternal.spec.js +235 -0
- package/build/revamp/types.js +1 -0
- package/build/revamp/utils/component-utils.js +86 -0
- package/build/revamp/utils/component-utils.spec.js +385 -0
- package/build/revamp/utils/findComponent.js +29 -0
- package/build/revamp/utils/findComponent.spec.js +92 -0
- package/build/revamp/utils/type-utils.js +56 -0
- package/build/revamp/utils/type-validators.js +16 -0
- package/build/revamp/utils/type-validators.spec.js +163 -0
- package/build/revamp/utils/useStableCallback.js +21 -0
- package/build/revamp/wise/renderers/AlertRenderer.js +11 -0
- package/build/revamp/wise/renderers/BooleanInputRenderer.js +34 -0
- package/build/revamp/wise/renderers/BoxRenderer.js +30 -0
- package/build/revamp/wise/renderers/ButtonRenderer.js +64 -0
- package/build/revamp/wise/renderers/ColumnsRenderer.js +25 -0
- package/build/revamp/wise/renderers/DateInputRenderer.js +35 -0
- package/build/revamp/wise/renderers/DecisionRenderer.js +29 -0
- package/build/revamp/wise/renderers/DividerRenderer.js +10 -0
- package/build/revamp/wise/renderers/FormRenderer.js +21 -0
- package/build/revamp/wise/renderers/FormSectionRenderer.js +16 -0
- package/build/revamp/wise/renderers/HeadingRenderer.js +57 -0
- package/build/revamp/wise/renderers/ImageRenderer.js +111 -0
- package/build/revamp/wise/renderers/InstructionsRenderer.js +34 -0
- package/build/revamp/wise/renderers/IntegerInputRenderer.js +38 -0
- package/build/revamp/wise/renderers/LoadingIndicatorRenderer.js +11 -0
- package/build/revamp/wise/renderers/MarkdownRenderer.js +22 -0
- package/build/revamp/wise/renderers/ModalRenderer.js +25 -0
- package/build/revamp/wise/renderers/MultiUploadInputRenderer.js +74 -0
- package/build/revamp/wise/renderers/NumberInputRenderer.js +38 -0
- package/build/revamp/wise/renderers/ParagraphRenderer.js +44 -0
- package/build/revamp/wise/renderers/RepeatableRenderer.js +58 -0
- package/build/revamp/wise/renderers/ReviewRenderer.js +46 -0
- package/build/revamp/wise/renderers/SearchRenderer.js +63 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/OptionMedia.js +27 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/RadioInputRendererComponent.js +25 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectInputRenderer.js +30 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectInputRendererComponent.js +56 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/SelectTriggerMedia.js +27 -0
- package/build/revamp/wise/renderers/SelectInputRenderer/TabInputRendererComponent.js +33 -0
- package/build/revamp/wise/renderers/StatusListRenderer.js +32 -0
- package/build/revamp/wise/renderers/TextInputRenderer.js +35 -0
- package/build/revamp/wise/renderers/UploadInputRenderer.js +136 -0
- package/build/revamp/wise/renderers/components/FieldInput.js +20 -0
- package/build/revamp/wise/renderers/components/Help.js +21 -0
- package/build/revamp/wise/renderers/components/LabelContentWithHelp.js +6 -0
- package/build/revamp/wise/renderers/components/UploadFieldInput.js +25 -0
- package/build/revamp/wise/renderers/components/VariableDateInput.js +30 -0
- package/build/revamp/wise/renderers/components/VariableTextInput.js +69 -0
- package/build/revamp/wise/renderers/components/icon/DynamicIcon.js +17 -0
- package/build/revamp/wise/renderers/components/icon/FlagIcon.js +198 -0
- package/build/revamp/wise/renderers/components/icon/NamedIcon.js +19 -0
- package/build/revamp/wise/renderers/components/icon/NavigationOptionMedia.js +31 -0
- package/build/revamp/wise/renderers/getWiseRenderers.js +57 -0
- package/build/revamp/wise/renderers/hooks/useSnackBarIfAvailable.js +6 -0
- package/build/revamp/wise/renderers/utils/file-utils.js +70 -0
- package/build/revamp/wise/renderers/utils/getRandomId.js +2 -0
- package/build/revamp/wise/renderers/utils/input-utils.js +6 -0
- package/build/revamp/wise/renderers/utils/layout-utils.js +31 -0
- package/build/revamp/wise/renderers/utils/value-utils.js +23 -0
- package/build/revamp/wise/renderers/utils/value-utils.spec.js +33 -0
- package/build/revamp/wise/renderers/validators/type-validators.js +15 -0
- package/build/test-utils/NeptuneProviders.js +23 -0
- package/build/test-utils/fetch-utils.js +104 -0
- package/build/test-utils/index.js +2 -0
- package/build/test-utils/rtl-utils.js +20 -0
- package/package.json +3 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { debounce, getSchemaType } from '../../../common/utils';
|
|
3
|
+
var DEBOUNCE_DELAY = 1000; // milliseconds
|
|
4
|
+
export function useDebouncedRefresh(fetchRefresh) {
|
|
5
|
+
var map = useRef(new Map());
|
|
6
|
+
var retrieveOrCreate = function (key) {
|
|
7
|
+
if (map.current.has(key)) {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9
|
+
return map.current.get(key);
|
|
10
|
+
}
|
|
11
|
+
var debouncedFetchRefresh = debounce(function (url, data, etag) { return fetchRefresh(url, data, etag); }, DEBOUNCE_DELAY);
|
|
12
|
+
map.current.set(key, debouncedFetchRefresh);
|
|
13
|
+
return debouncedFetchRefresh;
|
|
14
|
+
};
|
|
15
|
+
return function (url, data, etag, schema) {
|
|
16
|
+
var debouncedFetchRefresh = retrieveOrCreate(url);
|
|
17
|
+
debouncedFetchRefresh(url, data, etag);
|
|
18
|
+
if (!schema || !shouldDebounceSchema(schema)) {
|
|
19
|
+
debouncedFetchRefresh.flush();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// TODO: only exporting for testing. we should improve the tests
|
|
24
|
+
export var shouldDebounceSchema = function (schema) {
|
|
25
|
+
return getSchemaType(schema) === 'basic' && schema.type !== 'boolean' && schema.format !== 'base64url';
|
|
26
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { useMemo, useState } from 'react';
|
|
22
|
+
import { isValidSchema, getValidObjectModelParts } from '../../common/validators';
|
|
23
|
+
export var useDynamicFlowState = function (initialStep) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
var _c = useState((_a = initialStep === null || initialStep === void 0 ? void 0 : initialStep.errors) === null || _a === void 0 ? void 0 : _a.validation), formErrors = _c[0], setFormErrors = _c[1];
|
|
26
|
+
var _d = useState((_b = initialStep === null || initialStep === void 0 ? void 0 : initialStep.errors) === null || _b === void 0 ? void 0 : _b.error), globalError = _d[0], setGlobalError = _d[1];
|
|
27
|
+
var _e = useState({
|
|
28
|
+
step: initialStep || undefined,
|
|
29
|
+
models: (initialStep === null || initialStep === void 0 ? void 0 : initialStep.model)
|
|
30
|
+
? buildInitialModels(initialStep.model, getAllSchemas(initialStep))
|
|
31
|
+
: {},
|
|
32
|
+
etag: undefined
|
|
33
|
+
}), stepAndModels = _e[0], setStepAndModels = _e[1];
|
|
34
|
+
var step = stepAndModels.step, models = stepAndModels.models, etag = stepAndModels.etag;
|
|
35
|
+
var setStepAndEtag = function (step, etag) {
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
|
+
setStepAndModels({
|
|
38
|
+
step: step,
|
|
39
|
+
models: step.model ? buildInitialModels(step.model, getAllSchemas(step)) : {},
|
|
40
|
+
etag: etag
|
|
41
|
+
});
|
|
42
|
+
setFormErrors((_b = (_a = step === null || step === void 0 ? void 0 : step.errors) === null || _a === void 0 ? void 0 : _a.validation) !== null && _b !== void 0 ? _b : null);
|
|
43
|
+
setGlobalError((_d = (_c = step === null || step === void 0 ? void 0 : step.errors) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : null);
|
|
44
|
+
};
|
|
45
|
+
var setSchemaModel = function (schemaId, objectModel, onModelsUpdated) {
|
|
46
|
+
setStepAndModels(function (previous) {
|
|
47
|
+
var _a;
|
|
48
|
+
var updatedModels = __assign(__assign({}, previous.models), (_a = {}, _a[schemaId] = objectModel, _a));
|
|
49
|
+
var updatedState = {
|
|
50
|
+
step: previous.step,
|
|
51
|
+
models: updatedModels,
|
|
52
|
+
etag: previous.etag
|
|
53
|
+
};
|
|
54
|
+
onModelsUpdated(updatedModels);
|
|
55
|
+
return updatedState;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var modelIsValid = useMemo(function () { return areModelsValid(models, getAllValidatableSchemas(step)); }, [models, step]);
|
|
59
|
+
return {
|
|
60
|
+
formErrors: formErrors,
|
|
61
|
+
globalError: globalError,
|
|
62
|
+
step: step,
|
|
63
|
+
models: models,
|
|
64
|
+
etag: etag,
|
|
65
|
+
modelIsValid: modelIsValid,
|
|
66
|
+
setFormErrors: setFormErrors,
|
|
67
|
+
setGlobalError: setGlobalError,
|
|
68
|
+
setStepAndEtag: setStepAndEtag,
|
|
69
|
+
setSchemaModel: setSchemaModel
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
var buildInitialModels = function (model, schemas) {
|
|
73
|
+
if (schemas === void 0) { schemas = []; }
|
|
74
|
+
return schemas.reduce(function (acc, schema) {
|
|
75
|
+
var _a;
|
|
76
|
+
if (!schema.$id) {
|
|
77
|
+
// TODO: DF-473 - Remove type assertions once we're confident people have had time to fix any errors
|
|
78
|
+
// eslint-disable-next-line no-console
|
|
79
|
+
console.warn('Schema without $id property found.');
|
|
80
|
+
}
|
|
81
|
+
return __assign(__assign({}, acc), (_a = {}, _a[schema.$id || ''] = getValidObjectModelParts(model, schema) || {}, _a));
|
|
82
|
+
}, {});
|
|
83
|
+
};
|
|
84
|
+
var getAllSchemas = function (step) { return __spreadArray(__spreadArray([], getAllSchemasInLayout((step === null || step === void 0 ? void 0 : step.layout) || []), true), ((step === null || step === void 0 ? void 0 : step.schemas) || []), true); };
|
|
85
|
+
var getAllSchemasInLayout = function (components) {
|
|
86
|
+
return components.flatMap(function (component) {
|
|
87
|
+
switch (component.type) {
|
|
88
|
+
case 'columns':
|
|
89
|
+
return __spreadArray([], getAllSchemasInLayout(__spreadArray(__spreadArray([], component.left, true), component.right, true)), true);
|
|
90
|
+
case 'box':
|
|
91
|
+
return getAllSchemasInLayout(component.components);
|
|
92
|
+
case 'form':
|
|
93
|
+
return isInlineSchema(component.schema) ? [component.schema] : [];
|
|
94
|
+
default:
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
var getAllValidatableSchemas = function (step) { return __spreadArray(__spreadArray([], getAllReferencedSchemaIds((step === null || step === void 0 ? void 0 : step.layout) || [])
|
|
100
|
+
.map(function (id) { return ((step === null || step === void 0 ? void 0 : step.schemas) || []).find(function (schema) { return schema.$id === id; }); })
|
|
101
|
+
.filter(Boolean), true), getAllSchemasInLayout((step === null || step === void 0 ? void 0 : step.layout) || []), true); };
|
|
102
|
+
var getAllReferencedSchemaIds = function (components) {
|
|
103
|
+
return components
|
|
104
|
+
.flatMap(function (component) {
|
|
105
|
+
switch (component.type) {
|
|
106
|
+
case 'columns':
|
|
107
|
+
return __spreadArray([], getAllReferencedSchemaIds(__spreadArray(__spreadArray([], component.left, true), component.right, true)), true);
|
|
108
|
+
case 'box':
|
|
109
|
+
return getAllReferencedSchemaIds(component.components);
|
|
110
|
+
case 'form':
|
|
111
|
+
return [getSchemaReference(component)];
|
|
112
|
+
default:
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
.filter(Boolean);
|
|
117
|
+
};
|
|
118
|
+
var areModelsValid = function (formModels, schemas) {
|
|
119
|
+
if (schemas === void 0) { schemas = []; }
|
|
120
|
+
return !(schemas === null || schemas === void 0 ? void 0 : schemas.some(function (schema) {
|
|
121
|
+
if (!schema.$id) {
|
|
122
|
+
// TODO: DF-473
|
|
123
|
+
// eslint-disable-next-line no-console
|
|
124
|
+
console.warn('Schema without $id property found.');
|
|
125
|
+
}
|
|
126
|
+
return !isValidSchema(formModels[schema.$id || ''] || {}, schema);
|
|
127
|
+
}));
|
|
128
|
+
};
|
|
129
|
+
var getSchemaReference = function (component) {
|
|
130
|
+
if (component.schema && !isInlineSchema(component.schema)) {
|
|
131
|
+
return component.schema.$ref;
|
|
132
|
+
}
|
|
133
|
+
return component.schemaId;
|
|
134
|
+
};
|
|
135
|
+
var isInlineSchema = function (schema) {
|
|
136
|
+
return schema !== undefined && typeof schema === 'object' && !Object.hasOwnProperty.call(schema, '$ref');
|
|
137
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { Loader, Size } from '@transferwise/components';
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
export function useLoader(loaderConfig, initialState) {
|
|
16
|
+
var config = __assign({ size: Size.EXTRA_LARGE, initial: true, submission: false }, loaderConfig);
|
|
17
|
+
var _a = useState(initialState), loadingState = _a[0], setLoadingState = _a[1];
|
|
18
|
+
var shouldDisplayLoader = (config.initial && loadingState === 'initial') ||
|
|
19
|
+
(config.submission && loadingState === 'submission');
|
|
20
|
+
var loader = shouldDisplayLoader ? (_jsx(Loader, { size: config.size, classNames: { 'tw-loader': 'tw-loader m-x-auto' }, "data-testid": "loader" })) : null;
|
|
21
|
+
return { isLoading: loadingState !== 'idle', setLoadingState: setLoadingState, loader: loader };
|
|
22
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
+
// patching tests that won't work in Enzyme
|
|
50
|
+
import { screen } from '@testing-library/react';
|
|
51
|
+
import { userEvent } from '@testing-library/user-event';
|
|
52
|
+
import { renderWithProviders } from '../test-utils';
|
|
53
|
+
import FormControl from './FormControl';
|
|
54
|
+
describe('FormControl', function () {
|
|
55
|
+
var user = userEvent.setup();
|
|
56
|
+
var defaultProps = {
|
|
57
|
+
id: 'control',
|
|
58
|
+
placeholder: 'placeholder',
|
|
59
|
+
name: 'control',
|
|
60
|
+
disabled: false,
|
|
61
|
+
readOnly: false,
|
|
62
|
+
required: true,
|
|
63
|
+
value: undefined,
|
|
64
|
+
size: undefined,
|
|
65
|
+
describedBy: undefined,
|
|
66
|
+
onChange: jest.fn(),
|
|
67
|
+
onBlur: jest.fn(),
|
|
68
|
+
onFocus: jest.fn()
|
|
69
|
+
};
|
|
70
|
+
describe('SelectInput', function () {
|
|
71
|
+
it('should call the search change handler if search is enabled', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var options, onSearchChange, i, props;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
options = [];
|
|
77
|
+
onSearchChange = jest.fn();
|
|
78
|
+
for (i = 0; i < 20; i += 1) {
|
|
79
|
+
options.push({ value: i, label: 'something' });
|
|
80
|
+
}
|
|
81
|
+
props = {
|
|
82
|
+
type: 'select',
|
|
83
|
+
options: options,
|
|
84
|
+
search: true,
|
|
85
|
+
onSearchChange: onSearchChange
|
|
86
|
+
};
|
|
87
|
+
renderWithProviders(_jsx(FormControl, __assign({}, __assign(__assign({}, defaultProps), props))));
|
|
88
|
+
return [4 /*yield*/, user.click(screen.getByText('placeholder'))];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
expect(screen.getByRole('searchbox')).toBeInTheDocument();
|
|
92
|
+
return [4 /*yield*/, user.click(screen.getByRole('searchbox'))];
|
|
93
|
+
case 2:
|
|
94
|
+
_a.sent();
|
|
95
|
+
return [4 /*yield*/, user.keyboard('test')];
|
|
96
|
+
case 3:
|
|
97
|
+
_a.sent();
|
|
98
|
+
expect(onSearchChange).toHaveBeenCalledWith('test');
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}); });
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getAutocompleteString } from './getAutocompleteString';
|
|
2
|
+
describe('getAutocompleteString', function () {
|
|
3
|
+
it('should return "off" if no hints are provided', function () {
|
|
4
|
+
expect(getAutocompleteString([])).toBe('off');
|
|
5
|
+
});
|
|
6
|
+
it('should return a string for valid hints', function () {
|
|
7
|
+
expect(getAutocompleteString(['name-prefix'])).toBe('honorific-prefix');
|
|
8
|
+
});
|
|
9
|
+
it('should return a space delimited, concatenated string for multiple valid hints', function () {
|
|
10
|
+
expect(getAutocompleteString(['name', 'billing'])).toBe('name billing');
|
|
11
|
+
});
|
|
12
|
+
it('should discard invalid hints', function () {
|
|
13
|
+
// @ts-expect-error testing an invalid hint
|
|
14
|
+
expect(getAutocompleteString(['name', 'cats'])).toBe('name');
|
|
15
|
+
});
|
|
16
|
+
it('should return "off" if no valid hints are provided', function () {
|
|
17
|
+
// @ts-expect-error testing an invalid hint
|
|
18
|
+
expect(getAutocompleteString(['cats'])).toBe('off');
|
|
19
|
+
});
|
|
20
|
+
it('should return built strings for valid hints', function () {
|
|
21
|
+
expect(getAutocompleteString(['birthdate'], { suffix: '-day' })).toBe('bday-day');
|
|
22
|
+
});
|
|
23
|
+
it("should return \"off\" when given a valid hint, which when the suffix is added is not a valid hint", function () {
|
|
24
|
+
expect(getAutocompleteString(['postal-code'], { suffix: '-day' })).toBe('off');
|
|
25
|
+
});
|
|
26
|
+
it('should discard invalid hints, even when suffix is present', function () {
|
|
27
|
+
// @ts-expect-error testing an invalid hint
|
|
28
|
+
expect(getAutocompleteString(['country', 'cats'], { suffix: '-name' })).toBe('country-name');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { getSafeBooleanValue, getSafeDateOrStringValue, getSafeDateStringValue, getSafeStringOrNumberValue, getSafeStringValue, } from './value-utils';
|
|
2
|
+
describe('getSafeStringValue', function () {
|
|
3
|
+
afterEach(function () {
|
|
4
|
+
jest.clearAllMocks();
|
|
5
|
+
});
|
|
6
|
+
it('returns undefined when value is null', function () {
|
|
7
|
+
expect(getSafeStringValue(null)).toBeUndefined();
|
|
8
|
+
});
|
|
9
|
+
it('returns undefined and logs a warning if value is an object', function () {
|
|
10
|
+
var mockWarn = jest.fn();
|
|
11
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
12
|
+
expect(getSafeStringValue({ value: 1, label: 'One' })).toBeUndefined();
|
|
13
|
+
expect(mockWarn).toHaveBeenCalledTimes(1);
|
|
14
|
+
});
|
|
15
|
+
it('returns undefined and logs a warning if value is not a string', function () {
|
|
16
|
+
var mockWarn = jest.fn();
|
|
17
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
18
|
+
expect(getSafeStringValue(1)).toBeUndefined();
|
|
19
|
+
expect(getSafeStringValue(false)).toBeUndefined();
|
|
20
|
+
expect(getSafeStringValue(new Date())).toBeUndefined();
|
|
21
|
+
expect(mockWarn).toHaveBeenCalledTimes(3);
|
|
22
|
+
});
|
|
23
|
+
it('returns value when value is a string', function () {
|
|
24
|
+
expect(getSafeStringValue('')).toBe('');
|
|
25
|
+
expect(getSafeStringValue('cat')).toBe('cat');
|
|
26
|
+
});
|
|
27
|
+
describe('when coerceValue is true', function () {
|
|
28
|
+
it('returns coerced value and logs a warning if value is not a string', function () {
|
|
29
|
+
var mockWarn = jest.fn();
|
|
30
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
31
|
+
expect(getSafeStringValue(1, { coerceValue: true })).toBe('1');
|
|
32
|
+
expect(getSafeStringValue(false, { coerceValue: true })).toBe('false');
|
|
33
|
+
expect(mockWarn).toHaveBeenCalledTimes(2);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('getSafeStringOrNumberValue', function () {
|
|
38
|
+
afterEach(function () {
|
|
39
|
+
jest.clearAllMocks();
|
|
40
|
+
});
|
|
41
|
+
it('returns undefined when value is null', function () {
|
|
42
|
+
expect(getSafeStringOrNumberValue(null)).toBeUndefined();
|
|
43
|
+
});
|
|
44
|
+
it('returns undefined when value is NaN', function () {
|
|
45
|
+
expect(getSafeStringOrNumberValue(NaN)).toBeUndefined();
|
|
46
|
+
});
|
|
47
|
+
it('returns value if value is a valid number', function () {
|
|
48
|
+
expect(getSafeStringOrNumberValue(10)).toBe(10);
|
|
49
|
+
expect(getSafeStringOrNumberValue(10.5)).toBe(10.5);
|
|
50
|
+
});
|
|
51
|
+
it('returns undefined and logs a warning if value is an object', function () {
|
|
52
|
+
var mockWarn = jest.fn();
|
|
53
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
54
|
+
expect(getSafeStringOrNumberValue({ value: 1, label: 'One' })).toBeUndefined();
|
|
55
|
+
expect(mockWarn).toHaveBeenCalledTimes(1);
|
|
56
|
+
});
|
|
57
|
+
it('returns undefined and logs a warning if value is not a string', function () {
|
|
58
|
+
var mockWarn = jest.fn();
|
|
59
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
60
|
+
expect(getSafeStringOrNumberValue(false)).toBeUndefined();
|
|
61
|
+
expect(mockWarn).toHaveBeenCalledTimes(1);
|
|
62
|
+
});
|
|
63
|
+
it('returns value when value is a string', function () {
|
|
64
|
+
expect(getSafeStringOrNumberValue('')).toBe('');
|
|
65
|
+
expect(getSafeStringOrNumberValue('cat')).toBe('cat');
|
|
66
|
+
});
|
|
67
|
+
describe('when coerceValue is true', function () {
|
|
68
|
+
it('returns coerced value and logs a warning if value is not a string', function () {
|
|
69
|
+
var mockWarn = jest.fn();
|
|
70
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
71
|
+
expect(getSafeStringOrNumberValue(false, { coerceValue: true })).toBe('false');
|
|
72
|
+
expect(mockWarn).toHaveBeenCalledTimes(1);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('getSafeBooleanValue', function () {
|
|
77
|
+
afterEach(function () {
|
|
78
|
+
jest.clearAllMocks();
|
|
79
|
+
});
|
|
80
|
+
it('returns false when value is null', function () {
|
|
81
|
+
expect(getSafeBooleanValue(null)).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
it('returns undefined and logs a warning if value is not a boolean', function () {
|
|
84
|
+
var mockWarn = jest.fn();
|
|
85
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
86
|
+
expect(getSafeBooleanValue(1)).toBeUndefined();
|
|
87
|
+
expect(getSafeBooleanValue(NaN)).toBeUndefined();
|
|
88
|
+
expect(getSafeBooleanValue(new Date())).toBeUndefined();
|
|
89
|
+
expect(getSafeBooleanValue('cat')).toBeUndefined();
|
|
90
|
+
expect(getSafeBooleanValue({ value: 1, label: 'One' })).toBeUndefined();
|
|
91
|
+
expect(mockWarn).toHaveBeenCalledTimes(5);
|
|
92
|
+
});
|
|
93
|
+
it('returns value when value is a boolean', function () {
|
|
94
|
+
expect(getSafeBooleanValue(true)).toBe(true);
|
|
95
|
+
expect(getSafeBooleanValue(false)).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
describe('when coerceValue is true', function () {
|
|
98
|
+
it('returns coerced value and logs a warning if value is not a boolean', function () {
|
|
99
|
+
var mockWarn = jest.fn();
|
|
100
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
101
|
+
expect(getSafeBooleanValue(1, { coerceValue: true })).toBe(true);
|
|
102
|
+
expect(getSafeBooleanValue(NaN, { coerceValue: true })).toBe(false);
|
|
103
|
+
expect(getSafeBooleanValue('cat', { coerceValue: true })).toBe(true);
|
|
104
|
+
expect(getSafeBooleanValue(new Date(), { coerceValue: true })).toBe(true);
|
|
105
|
+
expect(getSafeBooleanValue({ value: 1, label: 'One' }, { coerceValue: true })).toBe(true);
|
|
106
|
+
expect(mockWarn).toHaveBeenCalledTimes(5);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
describe('getSafeDateOrStringValue', function () {
|
|
111
|
+
afterEach(function () {
|
|
112
|
+
jest.clearAllMocks();
|
|
113
|
+
});
|
|
114
|
+
it('returns undefined when value is null', function () {
|
|
115
|
+
expect(getSafeDateOrStringValue(null)).toBeUndefined();
|
|
116
|
+
});
|
|
117
|
+
it('returns value if value is a string', function () {
|
|
118
|
+
expect(getSafeDateOrStringValue('2019-04-06')).toBe('2019-04-06');
|
|
119
|
+
});
|
|
120
|
+
it('returns value if value is a Date', function () {
|
|
121
|
+
var date = new Date();
|
|
122
|
+
expect(getSafeDateOrStringValue(date)).toBe(date);
|
|
123
|
+
});
|
|
124
|
+
it('returns undefined and logs a warning if value is not a date or a string', function () {
|
|
125
|
+
var mockWarn = jest.fn();
|
|
126
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
127
|
+
expect(getSafeDateOrStringValue(1)).toBeUndefined();
|
|
128
|
+
expect(getSafeDateOrStringValue(false)).toBeUndefined();
|
|
129
|
+
expect(getSafeDateOrStringValue({ value: 1, label: 'One' })).toBeUndefined();
|
|
130
|
+
expect(mockWarn).toHaveBeenCalledTimes(3);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('getSafeDateStringValue', function () {
|
|
134
|
+
afterEach(function () {
|
|
135
|
+
jest.clearAllMocks();
|
|
136
|
+
});
|
|
137
|
+
it('returns null when value is null', function () {
|
|
138
|
+
expect(getSafeDateStringValue(null)).toBeNull();
|
|
139
|
+
});
|
|
140
|
+
it('returns null and logs a warning if value is not a string', function () {
|
|
141
|
+
var mockWarn = jest.fn();
|
|
142
|
+
jest.spyOn(console, 'warn').mockImplementation(mockWarn);
|
|
143
|
+
expect(getSafeDateStringValue(1)).toBeNull();
|
|
144
|
+
expect(getSafeDateStringValue(false)).toBeNull();
|
|
145
|
+
expect(getSafeDateStringValue(new Date())).toBeNull();
|
|
146
|
+
expect(getSafeDateStringValue({ value: 1, label: 'One' })).toBeNull();
|
|
147
|
+
expect(mockWarn).toHaveBeenCalledTimes(4);
|
|
148
|
+
});
|
|
149
|
+
it('returns value as a date if value is a correctly formatted date string', function () {
|
|
150
|
+
var _a;
|
|
151
|
+
expect((_a = getSafeDateStringValue('2019-04-06')) === null || _a === void 0 ? void 0 : _a.toDateString()).toStrictEqual(new Date(2019, 3, 6).toDateString());
|
|
152
|
+
});
|
|
153
|
+
it('returns null if value is an incorrectly formatted date string', function () {
|
|
154
|
+
expect(getSafeDateStringValue('')).toBeNull();
|
|
155
|
+
expect(getSafeDateStringValue('cat')).toBeNull();
|
|
156
|
+
expect(getSafeDateStringValue('2022')).toBeNull();
|
|
157
|
+
});
|
|
158
|
+
});
|