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