@wise/dynamic-flow-client 3.5.0-experimental-6654c72 → 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/makeHttpClient/makeHttpClient.spec.js +141 -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/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/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/responseParsers/response-parsers.spec.js +463 -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/arrayTypeSchema/arrayListSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.spec.js +909 -0
- package/build/legacy/jsonSchemaForm/genericSchema/GenericSchema.rtl.spec.js +55 -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/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/cameraCapture/CameraCapture.spec.js +432 -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 +20 -20
- package/build/main.min.js +1 -1
- package/build/main.mjs +20 -20
- 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/repeatableComponent/RepeatableComponent.spec.js +145 -0
- package/build/revamp/domain/components/searchComponent/SearchComponent.spec.js +327 -0
- package/build/revamp/domain/components/utils/debounce.spec.js +72 -0
- package/build/revamp/domain/components/utils/isPartialLocalValueMatch.spec.js +108 -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.spec.js +280 -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.spec.js +110 -0
- package/build/revamp/domain/features/validation/spec-utils.js +16 -0
- package/build/revamp/domain/features/validation/validation-functions.spec.js +110 -0
- package/build/revamp/domain/features/validation/value-checks.spec.js +204 -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.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/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/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 +1 -1
- 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/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/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-validators.spec.js +163 -0
- package/build/revamp/utils/useStableCallback.js +21 -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/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/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,78 @@
|
|
|
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, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
/* eslint-disable react/forbid-dom-props */
|
|
14
|
+
import { action } from '@storybook/addon-actions';
|
|
15
|
+
import { layouts, schemas, examples } from '@wise/dynamic-flow-fixtures';
|
|
16
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
17
|
+
import DynamicFlow from '../../DynamicFlow';
|
|
18
|
+
import { fixtureHttpClient } from '../fixtureHttpClient';
|
|
19
|
+
var fixtures = __assign(__assign(__assign({}, schemas), layouts), examples);
|
|
20
|
+
function EditableDynamicFlow(_a) {
|
|
21
|
+
var _b = _a.initialStepName, initialStepName = _b === void 0 ? '' : _b;
|
|
22
|
+
var selectedStep = fixtures[initialStepName] || {};
|
|
23
|
+
var selectedInitialStep = JSON.stringify(selectedStep, null, 2);
|
|
24
|
+
return _jsx(InteractiveDemo, { selectedInitialStep: selectedInitialStep }, selectedInitialStep);
|
|
25
|
+
}
|
|
26
|
+
var initialAction = { url: '/initial' };
|
|
27
|
+
function InteractiveDemo(_a) {
|
|
28
|
+
var selectedInitialStep = _a.selectedInitialStep;
|
|
29
|
+
var _b = useState(200), initialStatusCode = _b[0], setInitialStatusCode = _b[1];
|
|
30
|
+
var _c = useState(selectedInitialStep), initialStep = _c[0], setInitialStep = _c[1];
|
|
31
|
+
var onTextAreaChange = function (event) {
|
|
32
|
+
setInitialStep(event.target.value);
|
|
33
|
+
};
|
|
34
|
+
var httpClient = useCallback(function (input, init) {
|
|
35
|
+
action('httpClient')(input, init);
|
|
36
|
+
if (String(input) === '/initial') {
|
|
37
|
+
return Promise.resolve(new Response(initialStep, { status: initialStatusCode }));
|
|
38
|
+
}
|
|
39
|
+
return fixtureHttpClient(input, init);
|
|
40
|
+
}, [initialStep, initialStatusCode]);
|
|
41
|
+
return (_jsxs("div", __assign({ style: { display: 'flex', gap: '1em' } }, { children: [_jsxs("div", __assign({ style: { flexBasis: '50%' } }, { children: [_jsx("h3", { children: "Editable Demo" }), _jsxs("p", { children: ["You can specify a response status code and body, and DF will load your step.", _jsx("br", {}), "(for ideas, you can select an initial step from the drop down in the controls panel)"] }), _jsxs("fieldset", { children: [_jsx("label", __assign({ htmlFor: "status-code" }, { children: "Response Status code: " })), _jsx(StatusCodeSelect, { id: "status-code", state: [initialStatusCode, setInitialStatusCode] })] }), _jsxs("fieldset", { children: [_jsx("label", __assign({ htmlFor: "textarea" }, { children: "Response Body:" })), _jsx(InvalidJsonWarning, { initialStep: initialStep }), _jsx("textarea", { id: "textarea", wrap: "off", rows: 40, style: { fontFamily: 'monospace', fontSize: '0.9em', width: '100%' }, value: initialStep, onChange: onTextAreaChange })] })] })), _jsx("div", __assign({ style: { flexBasis: '50%' } }, { children: _jsx(DynamicFlow, { flowId: "the-flow-id", initialAction: initialAction, httpClient: httpClient, onCompletion: action('onCompletion'), onError: action('onError'), onEvent: action('onEvent'), onLog: action('onLog') }, "".concat(initialStep, "-").concat(initialStatusCode)) }))] })));
|
|
42
|
+
}
|
|
43
|
+
function InvalidJsonWarning(_a) {
|
|
44
|
+
var initialStep = _a.initialStep;
|
|
45
|
+
var validJson = useMemo(function () { return isValidJson(initialStep); }, [initialStep]);
|
|
46
|
+
return !validJson ? (_jsx("p", { children: "\u274C Invalid syntax or missing elements are preventing the JSON code you entered from being parsed." })) : null;
|
|
47
|
+
}
|
|
48
|
+
var isValidJson = function (value) {
|
|
49
|
+
try {
|
|
50
|
+
JSON.parse(value);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
catch (_a) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
function StatusCodeSelect(_a) {
|
|
58
|
+
var id = _a.id, _b = _a.state, value = _b[0], setValue = _b[1];
|
|
59
|
+
return (_jsxs("select", __assign({ id: id, value: value, onChange: function (event) { return setValue(Number.parseInt(event.target.value, 10)); } }, { children: [_jsx("option", { children: "200" }), _jsx("option", { children: "400" }), _jsx("option", { children: "500" })] })));
|
|
60
|
+
}
|
|
61
|
+
var meta = {
|
|
62
|
+
title: 'Dev Tools/Dynamic Flow',
|
|
63
|
+
component: EditableDynamicFlow
|
|
64
|
+
};
|
|
65
|
+
export var EditableStep = {
|
|
66
|
+
argTypes: {
|
|
67
|
+
initialStepName: {
|
|
68
|
+
label: 'Initial Step',
|
|
69
|
+
control: 'select',
|
|
70
|
+
options: Object.keys(fixtures)
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
args: { initialStepName: Object.keys(fixtures)[0] },
|
|
74
|
+
parameters: {
|
|
75
|
+
chromatic: { disableSnapshot: true }
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export default meta;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import DynamicFlow from '../../DynamicFlow';
|
|
4
|
+
var cases = {
|
|
5
|
+
'/422-global-error': {
|
|
6
|
+
btnText: 'Status 422 with a global error',
|
|
7
|
+
paragraph: 'It should display a global error on screen. This is valid, expected behaviour.',
|
|
8
|
+
btnType: 'primary',
|
|
9
|
+
status: 422,
|
|
10
|
+
body: "{\"error\": \"Global Error\"}"
|
|
11
|
+
},
|
|
12
|
+
'/422-non-json-parseable': {
|
|
13
|
+
btnText: 'Error 422 with non-json-parseable response body',
|
|
14
|
+
btnType: 'negative',
|
|
15
|
+
paragraph: 'It should trigger onError and onLog. This is not expected behaviour.',
|
|
16
|
+
status: 422,
|
|
17
|
+
body: "Any string that CANNOT be parsed as JSON."
|
|
18
|
+
},
|
|
19
|
+
'/422-json-parseable': {
|
|
20
|
+
btnText: 'Error 422 with json-parseable response body',
|
|
21
|
+
btnType: 'negative',
|
|
22
|
+
paragraph: "It should trigger onError and onLog. This is not expected behaviour.",
|
|
23
|
+
status: 422,
|
|
24
|
+
body: "{ \"valid\": \"JSON\" }"
|
|
25
|
+
},
|
|
26
|
+
'/200-json-parseable': {
|
|
27
|
+
btnText: "Status 200 with json-parseable response body",
|
|
28
|
+
btnType: 'negative',
|
|
29
|
+
paragraph: "This is not expected behaviour because the response does not cointain the DF-X-Exit header. It should trigger onError and onLog, but it doesn't!.",
|
|
30
|
+
status: 200,
|
|
31
|
+
body: "{ \"valid\": \"JSON\" }"
|
|
32
|
+
},
|
|
33
|
+
'/200-bad-action': {
|
|
34
|
+
btnText: "Status 200 with bad action body",
|
|
35
|
+
btnType: 'negative',
|
|
36
|
+
paragraph: 'It should trigger onError and onLog. This is not expected behaviour.',
|
|
37
|
+
status: 200,
|
|
38
|
+
body: "{ \"action\": {\"bad\": \"action\"} }"
|
|
39
|
+
},
|
|
40
|
+
'/422-json-parseable-non-object': {
|
|
41
|
+
btnText: 'Error 422 with json-parseable response body, but not an object',
|
|
42
|
+
btnType: 'negative',
|
|
43
|
+
paragraph: 'It should trigger onError and onLog. This is not expected behaviour.',
|
|
44
|
+
status: 422,
|
|
45
|
+
body: "\"A string literal can be parsed as JSON.\""
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var httpClient = function (input, init) {
|
|
49
|
+
action('httpClient')(input, init);
|
|
50
|
+
var testCase = cases[String(input)];
|
|
51
|
+
var response = testCase
|
|
52
|
+
? new Response(testCase.body, { status: testCase.status })
|
|
53
|
+
: new Response(null, { status: 404 });
|
|
54
|
+
return Promise.resolve(response);
|
|
55
|
+
};
|
|
56
|
+
var initialStep = getInitialStep();
|
|
57
|
+
function ErrorResponsesStory() {
|
|
58
|
+
return (_jsx(DynamicFlow, { flowId: "simulate-errors", initialStep: initialStep, httpClient: httpClient, loaderConfig: { size: 'xl', initial: true, submission: false }, onCompletion: action('onCompletion'), onError: action('onError'), onEvent: action('onEvent'), onLog: action('onLog') }));
|
|
59
|
+
}
|
|
60
|
+
function getTestCaseBoxLayout(url, testCase, index) {
|
|
61
|
+
var btnText = testCase.btnText, paragraph = testCase.paragraph, btnType = testCase.btnType, status = testCase.status, body = testCase.body;
|
|
62
|
+
return {
|
|
63
|
+
type: 'box',
|
|
64
|
+
border: true,
|
|
65
|
+
margin: 'xl',
|
|
66
|
+
components: [
|
|
67
|
+
{
|
|
68
|
+
type: 'button',
|
|
69
|
+
action: {
|
|
70
|
+
title: btnText,
|
|
71
|
+
type: btnType,
|
|
72
|
+
url: url,
|
|
73
|
+
data: { 'button-id': index }
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'paragraph',
|
|
78
|
+
text: "Response status: ".concat(status, " - body: ").concat(body, "."),
|
|
79
|
+
align: 'center',
|
|
80
|
+
margin: 'xs'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'paragraph',
|
|
84
|
+
text: paragraph,
|
|
85
|
+
align: 'center',
|
|
86
|
+
margin: 'md'
|
|
87
|
+
},
|
|
88
|
+
]
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function getInitialStep() {
|
|
92
|
+
return {
|
|
93
|
+
type: 'form',
|
|
94
|
+
id: 'Examples/Simulate Errors',
|
|
95
|
+
title: 'Simulate Errors',
|
|
96
|
+
description: 'Click any of the buttons to simulate an error as described below.',
|
|
97
|
+
schemas: [],
|
|
98
|
+
layout: [
|
|
99
|
+
{
|
|
100
|
+
type: 'paragraph',
|
|
101
|
+
text: 'Press any buttons and see the httpClient requests and responses in the Actions panel.',
|
|
102
|
+
align: 'center'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'box',
|
|
106
|
+
width: 'md',
|
|
107
|
+
components: Object.keys(cases).map(function (url, index) {
|
|
108
|
+
return getTestCaseBoxLayout(url, cases[url], index);
|
|
109
|
+
})
|
|
110
|
+
},
|
|
111
|
+
]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
var meta = {
|
|
115
|
+
title: 'Dev Tools/Responses',
|
|
116
|
+
component: ErrorResponsesStory
|
|
117
|
+
};
|
|
118
|
+
export var ErrorResponses = {
|
|
119
|
+
render: function () { return _jsx(ErrorResponsesStory, {}); },
|
|
120
|
+
parameters: {
|
|
121
|
+
chromatic: { disableSnapshot: true }
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
export default meta;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import { storiesOf } from '@storybook/react';
|
|
4
|
+
import { examples } from '@wise/dynamic-flow-fixtures';
|
|
5
|
+
import DynamicFlow from '../../DynamicFlow';
|
|
6
|
+
import { getObjectKeys } from '../fixtureHttpClient';
|
|
7
|
+
var storyMap = {};
|
|
8
|
+
var allStepNames = getObjectKeys(examples);
|
|
9
|
+
var httpClient = function (input, init) {
|
|
10
|
+
action('httpClient')(input, init);
|
|
11
|
+
return fetch(input, init);
|
|
12
|
+
};
|
|
13
|
+
allStepNames.forEach(function (stepName) {
|
|
14
|
+
// eslint-disable-next-line import/namespace
|
|
15
|
+
var label = examples[stepName].id;
|
|
16
|
+
if (label) {
|
|
17
|
+
var _a = label.split('/'), group = _a[0], name_1 = _a[1];
|
|
18
|
+
storyMap[group] || (storyMap[group] = storiesOf("Dev Tools/".concat(group), module).addParameters({
|
|
19
|
+
chromatic: { disableSnapshot: true }
|
|
20
|
+
}));
|
|
21
|
+
storyMap[group].add(name_1, function () { return (_jsx(DynamicFlow, { flowId: "storybook",
|
|
22
|
+
// eslint-disable-next-line import/namespace
|
|
23
|
+
initialStep: examples[stepName], httpClient: httpClient, loaderConfig: { size: 'xl', initial: true, submission: false }, onCompletion: action('onCompletion'), onError: action('onError'), onEvent: action('onEvent'), onLog: action('onLog') }, stepName)); });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import { storiesOf } from '@storybook/react';
|
|
4
|
+
import { features } from '@wise/dynamic-flow-fixtures';
|
|
5
|
+
import DynamicFlow from '../../DynamicFlow';
|
|
6
|
+
var storyMap = {};
|
|
7
|
+
var selectedStepNames = [
|
|
8
|
+
'actionResponse',
|
|
9
|
+
'arrayUploadBase64',
|
|
10
|
+
'external',
|
|
11
|
+
'multiSelect',
|
|
12
|
+
'persistAsync',
|
|
13
|
+
'polling',
|
|
14
|
+
'search',
|
|
15
|
+
'modal',
|
|
16
|
+
];
|
|
17
|
+
var httpClient = function (input, init) {
|
|
18
|
+
action('httpClient')(input, init);
|
|
19
|
+
return fetch(input, init);
|
|
20
|
+
};
|
|
21
|
+
selectedStepNames.forEach(function (stepName) {
|
|
22
|
+
// eslint-disable-next-line import/namespace
|
|
23
|
+
var label = features[stepName].id;
|
|
24
|
+
if (label) {
|
|
25
|
+
var _a = label.split('/'), group = _a[0], name_1 = _a[1];
|
|
26
|
+
storyMap[group] || (storyMap[group] = storiesOf("Dev Tools/".concat(group), module).addParameters({
|
|
27
|
+
chromatic: { disableSnapshot: true }
|
|
28
|
+
}));
|
|
29
|
+
storyMap[group].add(name_1, function () { return (_jsx(DynamicFlow, { flowId: "storybook",
|
|
30
|
+
// eslint-disable-next-line import/namespace
|
|
31
|
+
initialStep: features[stepName], httpClient: httpClient, loaderConfig: { size: 'xl', initial: true, submission: false }, onCompletion: action('onCompletion'), onError: action('onError'), onEvent: action('onEvent'), onLog: action('onLog') }, stepName)); });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import { schemas } from '@wise/dynamic-flow-fixtures';
|
|
4
|
+
import JsonSchemaForm from '../../../jsonSchemaForm/JsonSchemaForm';
|
|
5
|
+
// eslint-disable-next-line import/namespace
|
|
6
|
+
var getStepByName = function (name) { return schemas[name]; };
|
|
7
|
+
var validStepNames = Object.keys(schemas).filter(function (stepName) { var _a; return (_a = getStepByName(stepName).schemas) === null || _a === void 0 ? void 0 : _a.length; });
|
|
8
|
+
function JsonSchemaFormStory(_a) {
|
|
9
|
+
var _b;
|
|
10
|
+
var _c = _a.stepName, stepName = _c === void 0 ? '' : _c;
|
|
11
|
+
var schema = (_b = getStepByName(stepName).schemas) === null || _b === void 0 ? void 0 : _b[0];
|
|
12
|
+
return (_jsx(JsonSchemaForm, { schema: schema !== null && schema !== void 0 ? schema : {}, submitted: false, disabled: false, onPersistAsync: action('onPersistAsync'), onChange: action('onChange'), onEvent: action('onEvent'), onLog: action('onLog') }, JSON.stringify(schema)));
|
|
13
|
+
}
|
|
14
|
+
var meta = {
|
|
15
|
+
title: 'Dev Tools/JsonSchemaForm',
|
|
16
|
+
component: JsonSchemaFormStory
|
|
17
|
+
};
|
|
18
|
+
export var Default = {
|
|
19
|
+
argTypes: {
|
|
20
|
+
stepName: {
|
|
21
|
+
label: 'Initial Schema from step',
|
|
22
|
+
control: 'select',
|
|
23
|
+
options: validStepNames
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
args: { stepName: validStepNames[validStepNames.length - 1] },
|
|
27
|
+
parameters: {
|
|
28
|
+
chromatic: { disableSnapshot: true }
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export default meta;
|
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
import { action } from '@storybook/addon-actions';
|
|
50
|
+
import DynamicFlow from '../../DynamicFlow';
|
|
51
|
+
import { getMockHttpClient, respondWith } from '../../../../test-utils';
|
|
52
|
+
import { abortableDelay } from '../../../../test-utils/fetch-utils';
|
|
53
|
+
var getRespondWithDelay = function (delayMs) { return function (_, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
var customStep;
|
|
55
|
+
var _a, _b, _c;
|
|
56
|
+
return __generator(this, function (_d) {
|
|
57
|
+
switch (_d.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
customStep = __assign(__assign({}, refreshedStep), { model: JSON.parse((_b = (_a = init === null || init === void 0 ? void 0 : init.body) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '{}') });
|
|
60
|
+
return [4 /*yield*/, abortableDelay(delayMs, (_c = init === null || init === void 0 ? void 0 : init.signal) !== null && _c !== void 0 ? _c : null)];
|
|
61
|
+
case 1:
|
|
62
|
+
_d.sent();
|
|
63
|
+
return [2 /*return*/, respondWith(customStep)];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}); }; };
|
|
67
|
+
var httpClient = getMockHttpClient({
|
|
68
|
+
'/submit': function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
69
|
+
return [2 /*return*/, respondWith(initialStep)];
|
|
70
|
+
}); }); },
|
|
71
|
+
'/refresh': getRespondWithDelay(0),
|
|
72
|
+
'/refresh-with-delay': getRespondWithDelay(2000),
|
|
73
|
+
'/persist': function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
74
|
+
return [2 /*return*/, respondWith({ token: '123' })];
|
|
75
|
+
}); }); }
|
|
76
|
+
});
|
|
77
|
+
export default {
|
|
78
|
+
component: DynamicFlow,
|
|
79
|
+
title: 'Dev Tools/Features/Refresh On Change',
|
|
80
|
+
parameters: {
|
|
81
|
+
chromatic: { disableSnapshot: true }
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export function RefreshOnChange() {
|
|
85
|
+
return renderWithStep(initialStep);
|
|
86
|
+
}
|
|
87
|
+
var renderWithStep = function (step) { return (_jsx(DynamicFlow, { flowId: "new-df-flow-id", httpClient: function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
action('httpClient')(input, init === null || init === void 0 ? void 0 : init.body);
|
|
90
|
+
return [2 /*return*/, httpClient(input, init)];
|
|
91
|
+
});
|
|
92
|
+
}); }, initialStep: step, onCompletion: action('onCompletion'), onEvent: action('onEvent'), onError: action('onEvent'), onLog: action('onLog') })); };
|
|
93
|
+
var objectSchemaProps = {
|
|
94
|
+
name: {
|
|
95
|
+
title: 'Full name',
|
|
96
|
+
type: 'string',
|
|
97
|
+
refreshStepOnChange: true
|
|
98
|
+
},
|
|
99
|
+
colour: {
|
|
100
|
+
title: 'Favourite colour',
|
|
101
|
+
oneOf: [
|
|
102
|
+
{ title: 'Red', "const": 'red' },
|
|
103
|
+
{ title: 'Blue', "const": 'blue' },
|
|
104
|
+
{ title: 'Yellow', "const": 'yellow' },
|
|
105
|
+
{ title: 'Green', "const": 'green' },
|
|
106
|
+
],
|
|
107
|
+
refreshStepOnChange: true
|
|
108
|
+
},
|
|
109
|
+
age: {
|
|
110
|
+
title: 'Age',
|
|
111
|
+
type: 'integer',
|
|
112
|
+
refreshFormUrl: '/refresh-with-delay',
|
|
113
|
+
description: 'This field has a delayed refresh',
|
|
114
|
+
refreshStepOnChange: true
|
|
115
|
+
},
|
|
116
|
+
tnc: {
|
|
117
|
+
title: 'Terms and conditions',
|
|
118
|
+
type: 'boolean',
|
|
119
|
+
refreshStepOnChange: true
|
|
120
|
+
},
|
|
121
|
+
'credit-card-number': {
|
|
122
|
+
title: 'Credit card number',
|
|
123
|
+
type: 'string',
|
|
124
|
+
persistAsync: {
|
|
125
|
+
url: '/persist',
|
|
126
|
+
method: 'POST',
|
|
127
|
+
param: 'credit-card-number',
|
|
128
|
+
idProperty: 'token',
|
|
129
|
+
schema: {
|
|
130
|
+
description: 'This field will trigger persist async but not refresh on change',
|
|
131
|
+
title: 'Credit Card Number',
|
|
132
|
+
type: 'string',
|
|
133
|
+
control: 'numeric'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var initialStep = {
|
|
139
|
+
id: 'Features/Refresh on Change',
|
|
140
|
+
title: 'Refresh on Change Feature',
|
|
141
|
+
schemas: [
|
|
142
|
+
{
|
|
143
|
+
$id: '#schema',
|
|
144
|
+
type: 'object',
|
|
145
|
+
displayOrder: ['name', 'colour', 'age', 'float', 'tnc', 'credit-card-number'],
|
|
146
|
+
properties: __assign(__assign({}, objectSchemaProps), { float: {
|
|
147
|
+
title: 'Float',
|
|
148
|
+
description: 'This field will disappear after refresh on change',
|
|
149
|
+
type: 'number',
|
|
150
|
+
refreshStepOnChange: true
|
|
151
|
+
} })
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
layout: [
|
|
155
|
+
{ type: 'paragraph', text: 'This step will refresh when any of the fields are changed' },
|
|
156
|
+
{
|
|
157
|
+
type: 'form',
|
|
158
|
+
schemaId: '#schema'
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: 'button',
|
|
162
|
+
title: 'Submit',
|
|
163
|
+
control: 'primary',
|
|
164
|
+
action: { url: '/submit' }
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
refreshUrl: '/refresh'
|
|
168
|
+
};
|
|
169
|
+
var refreshedStep = {
|
|
170
|
+
id: 'Features/Refresh on Change',
|
|
171
|
+
title: 'Step refreshed!',
|
|
172
|
+
schemas: [
|
|
173
|
+
{
|
|
174
|
+
$id: '#schema',
|
|
175
|
+
type: 'object',
|
|
176
|
+
displayOrder: ['name', 'colour', 'age', 'tnc', 'credit-card-number'],
|
|
177
|
+
properties: objectSchemaProps
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
layout: [
|
|
181
|
+
{ type: 'paragraph', text: 'This step will refresh when any of the fields are changed' },
|
|
182
|
+
{
|
|
183
|
+
type: 'form',
|
|
184
|
+
schemaId: '#schema'
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
type: 'button',
|
|
188
|
+
title: 'Submit',
|
|
189
|
+
control: 'primary',
|
|
190
|
+
action: { url: '/submit' }
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
refreshUrl: '/refresh'
|
|
194
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
+
/* eslint-disable react/forbid-dom-props */
|
|
23
|
+
import { action } from '@storybook/addon-actions';
|
|
24
|
+
import { storiesOf } from '@storybook/react';
|
|
25
|
+
import { features } from '@wise/dynamic-flow-fixtures';
|
|
26
|
+
import DynamicFlow from '../../DynamicFlow';
|
|
27
|
+
import { abortableDelay } from '../../../../test-utils/fetch-utils';
|
|
28
|
+
var storyMap = {};
|
|
29
|
+
var group = 'Dev Tools';
|
|
30
|
+
storyMap[group] || (storyMap[group] = storiesOf("".concat(group, "/Features/Search"), module).addParameters({
|
|
31
|
+
chromatic: { disableSnapshot: true }
|
|
32
|
+
}));
|
|
33
|
+
storyMap[group].add('Search', function () { return (_jsxs(_Fragment, { children: [_jsx("div", __assign({ style: { display: 'flex', justifyContent: 'center' } }, { children: _jsxs("ul", { children: [_jsx("li", { children: "If your search term has 3 or fewer characters, the search results will take 2 seconds to load." }), _jsx("li", { children: "If your search term has more than 3 characters, the search results will take 1 second to load." }), _jsx("li", { children: "If your search term is \"nothing\", then the search results will take 1 second to load, but will be empty." }), _jsx("li", { children: "If your search term is \"error\", then the search results will take 1 second to load, with a status 500." })] }) })), _jsx(DynamicFlow, { flowId: "storybook", initialStep: features.search, httpClient: httpClient, loaderConfig: { size: 'xl', initial: true, submission: false }, onCompletion: action('onCompletion'), onError: action('onError'), onEvent: action('onEvent'), onLog: action('onLog') }, "search")] })); });
|
|
34
|
+
var httpClient = function (input, init) {
|
|
35
|
+
var _a;
|
|
36
|
+
action('httpClient')(input, init);
|
|
37
|
+
var query = (init === null || init === void 0 ? void 0 : init.method) === 'POST'
|
|
38
|
+
? Object.values(JSON.parse(init.body))[0]
|
|
39
|
+
: String(input).split('=')[1];
|
|
40
|
+
var signal = (_a = init === null || init === void 0 ? void 0 : init.signal) !== null && _a !== void 0 ? _a : null;
|
|
41
|
+
if (query === 'nothing') {
|
|
42
|
+
return abortableDelay(1000, signal).then(function () {
|
|
43
|
+
return Promise.resolve(new Response(JSON.stringify({ results: [] })));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (query === 'error') {
|
|
47
|
+
return abortableDelay(1000, signal).then(function () {
|
|
48
|
+
return Promise.resolve(new Response(null, { status: 500 }));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (String(input).startsWith('/search')) {
|
|
52
|
+
var delay = query.length <= 3 ? 2000 : 1000;
|
|
53
|
+
return abortableDelay(delay, signal).then(function () {
|
|
54
|
+
return Promise.resolve(new Response(JSON.stringify({ results: getFakeSearchResults(query) })));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (String(input).startsWith('/more-search')) {
|
|
58
|
+
return abortableDelay(1000, signal).then(function () {
|
|
59
|
+
return Promise.resolve(new Response(JSON.stringify({ results: getMoreFakeSearchResults(query) })));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return fetch(input, init);
|
|
63
|
+
};
|
|
64
|
+
var getFakeSearchResults = function (query) { return __spreadArray(__spreadArray([], Array(3)
|
|
65
|
+
.fill(null)
|
|
66
|
+
.map(function (_, index) { return ({
|
|
67
|
+
type: 'action',
|
|
68
|
+
title: "Result #".concat(index + 1, " for ").concat(decodeURIComponent(query)),
|
|
69
|
+
description: "This is a search result for ".concat(decodeURIComponent(query), ". The type is \"action\"."),
|
|
70
|
+
icon: { name: 'building' },
|
|
71
|
+
value: {
|
|
72
|
+
url: "/next-step?result=".concat(index + 1),
|
|
73
|
+
method: 'GET'
|
|
74
|
+
}
|
|
75
|
+
}); }), true), [
|
|
76
|
+
{
|
|
77
|
+
type: 'search',
|
|
78
|
+
title: "Search for \"more ".concat(decodeURIComponent(query), "\""),
|
|
79
|
+
description: "Search for \"get more ".concat(decodeURIComponent(query), "\" description. This is a search result using GET method."),
|
|
80
|
+
icon: { name: 'search' },
|
|
81
|
+
value: {
|
|
82
|
+
url: '/more-search',
|
|
83
|
+
method: 'GET',
|
|
84
|
+
param: 'query',
|
|
85
|
+
query: "get more ".concat(decodeURIComponent(query))
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'search',
|
|
90
|
+
title: "Search for \"more ".concat(decodeURIComponent(query), "\""),
|
|
91
|
+
description: "Search for \"post more ".concat(decodeURIComponent(query), "\" description. This is a search result using POST method."),
|
|
92
|
+
icon: { name: 'search' },
|
|
93
|
+
value: {
|
|
94
|
+
url: '/more-search',
|
|
95
|
+
method: 'POST',
|
|
96
|
+
param: 'query',
|
|
97
|
+
query: "post more ".concat(decodeURIComponent(query))
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
], false); };
|
|
101
|
+
var getMoreFakeSearchResults = function (query) {
|
|
102
|
+
return Array(3)
|
|
103
|
+
.fill(null)
|
|
104
|
+
.map(function (_, index) { return ({
|
|
105
|
+
type: 'action',
|
|
106
|
+
title: "Another result for \"".concat(decodeURIComponent(query), "\" - ").concat(index + 1),
|
|
107
|
+
description: "Description for this thing.",
|
|
108
|
+
icon: { name: 'cog' },
|
|
109
|
+
value: {
|
|
110
|
+
url: "/next-step?result=".concat(index + 1),
|
|
111
|
+
method: 'GET'
|
|
112
|
+
}
|
|
113
|
+
}); });
|
|
114
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { makeHttpClient } from '../../../../common/makeHttpClient';
|
|
14
|
+
import DynamicFlow from '../..';
|
|
15
|
+
var customFetch = makeHttpClient('http://localhost:8888/');
|
|
16
|
+
var httpClient = function (input, init) {
|
|
17
|
+
console.log('customFetch', input, init);
|
|
18
|
+
// Add the no-cors header before making the request
|
|
19
|
+
return customFetch(input, __assign({}, init));
|
|
20
|
+
};
|
|
21
|
+
export default {
|
|
22
|
+
component: DynamicFlow,
|
|
23
|
+
title: 'Dev Tools/Examples/Server Test',
|
|
24
|
+
parameters: {
|
|
25
|
+
chromatic: { disableSnapshot: true }
|
|
26
|
+
},
|
|
27
|
+
argTypes: {
|
|
28
|
+
persistAsync: {
|
|
29
|
+
options: ['succeed', 'failGenerically', 'failValidation'],
|
|
30
|
+
type: 'select',
|
|
31
|
+
defaultValue: 'succeed'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export function Basic() {
|
|
36
|
+
var initialAction = { method: 'GET', url: 'http://localhost:8888' };
|
|
37
|
+
return (_jsx(DynamicFlow, { flowId: "demo-app-flow", initialAction: initialAction, httpClient: httpClient, onCompletion: function (result) {
|
|
38
|
+
console.log('Flow exited with', result);
|
|
39
|
+
}, onEvent: function (name, props) {
|
|
40
|
+
console.log('🔈 ', name, " with ".concat(JSON.stringify(props)));
|
|
41
|
+
}, onError: function (error, statusCode) {
|
|
42
|
+
console.error('Flow Error:', error, 'status code', statusCode);
|
|
43
|
+
} }));
|
|
44
|
+
}
|