@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,16 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
exports["default"] = void 0;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
15
7
|
var DynamicFlow_1 = require("./DynamicFlow");
|
|
16
|
-
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(DynamicFlow_1).default; } });
|
|
@@ -2,35 +2,35 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getObjectKeys = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const addon_actions_1 = require("@storybook/addon-actions");
|
|
9
|
+
const react_1 = require("@storybook/react");
|
|
10
|
+
const fixtures_1 = require("../../fixtures");
|
|
11
|
+
const DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
|
|
12
|
+
const EditableDynamicFlow_1 = __importDefault(require("./EditableDynamicFlow"));
|
|
13
|
+
const fixtureFetcher_1 = require("./fixtureFetcher");
|
|
14
14
|
exports.getObjectKeys = Object.keys;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
allStepNames.forEach(
|
|
15
|
+
const storyMap = {};
|
|
16
|
+
const allStepNames = (0, exports.getObjectKeys)(fixtures_1.fixtures.steps);
|
|
17
|
+
allStepNames.forEach((stepName) => {
|
|
18
18
|
var _a;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const label = (_a = fixtures_1.fixtures.steps[stepName].key) !== null && _a !== void 0 ? _a : stepName;
|
|
20
|
+
const [group, name] = label.split('/');
|
|
21
21
|
if (!storyMap[group]) {
|
|
22
|
-
storyMap[group] = (0, react_1.storiesOf)(
|
|
22
|
+
storyMap[group] = (0, react_1.storiesOf)(`Dynamic Flow/${group}`, module);
|
|
23
23
|
}
|
|
24
|
-
storyMap[group].add(name,
|
|
24
|
+
storyMap[group].add(name, () => ((0, jsx_runtime_1.jsx)(DynamicFlow_1.default, { flowId: "storybook", initialAction: { method: 'GET', url: `/steps/${stepName}` }, fetcher: fixtureFetcher_1.fixtureFetcher, loaderConfig: { size: 'xl', initial: true, submission: false }, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, stepName)));
|
|
25
25
|
});
|
|
26
|
-
|
|
27
|
-
editable.add('Dynamic Flow', EditableDynamicFlow_1
|
|
26
|
+
const editable = (0, react_1.storiesOf)(`Dynamic Flow/Editable`, module);
|
|
27
|
+
editable.add('Dynamic Flow', EditableDynamicFlow_1.default, {
|
|
28
28
|
argTypes: {
|
|
29
29
|
initialStepName: {
|
|
30
30
|
label: 'Initial Step',
|
|
31
31
|
control: 'select',
|
|
32
|
-
options: Object.keys(fixtures_1.fixtures.steps)
|
|
33
|
-
}
|
|
32
|
+
options: Object.keys(fixtures_1.fixtures.steps),
|
|
33
|
+
},
|
|
34
34
|
},
|
|
35
|
-
args: { initialStepName: Object.keys(fixtures_1.fixtures)[0] }
|
|
35
|
+
args: { initialStepName: Object.keys(fixtures_1.fixtures)[0] },
|
|
36
36
|
});
|
|
@@ -1,39 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
|
-
exports
|
|
17
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
7
|
/* eslint-disable react/forbid-dom-props */
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var selectedInitialStep = JSON.stringify(selectedStep, null, 2);
|
|
8
|
+
const addon_actions_1 = require("@storybook/addon-actions");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const fixtures_1 = require("../../fixtures");
|
|
11
|
+
const DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
|
|
12
|
+
const fixtureFetcher_1 = require("./fixtureFetcher");
|
|
13
|
+
const EditableDynamicFlow = ({ initialStepName = '' }) => {
|
|
14
|
+
const selectedStep = fixtures_1.fixtures.steps[initialStepName] || {};
|
|
15
|
+
const selectedInitialStep = JSON.stringify(selectedStep, null, 2);
|
|
28
16
|
return (0, jsx_runtime_1.jsx)(InteractiveDemo, { selectedInitialStep: selectedInitialStep }, selectedInitialStep);
|
|
29
17
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var onTextAreaChange = function (event) {
|
|
18
|
+
const InteractiveDemo = ({ selectedInitialStep }) => {
|
|
19
|
+
const [initialStep, setInitialStep] = (0, react_1.useState)(selectedInitialStep);
|
|
20
|
+
const onTextAreaChange = (event) => {
|
|
34
21
|
setInitialStep(event.target.value);
|
|
35
22
|
};
|
|
36
|
-
return ((0, jsx_runtime_1.jsxs)("div",
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ style: { display: 'flex', gap: '1em' } }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ style: { flexBasis: '50%' } }, { children: [(0, jsx_runtime_1.jsx)("h3", { children: "Editable Demo" }), (0, jsx_runtime_1.jsxs)("p", { children: ["You can select an initial step from the drop down in the controls panel.", (0, jsx_runtime_1.jsx)("br", {}), "You can edit the JSON below and see the result on the right."] }), (0, jsx_runtime_1.jsx)("textarea", { wrap: "off", rows: 40, style: { fontFamily: 'monospace', fontSize: '0.9em', width: '100%' }, value: initialStep, onChange: onTextAreaChange })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ style: { flexBasis: '50%' } }, { children: (0, jsx_runtime_1.jsx)(DynamicFlow_1.default, { flowId: "the-flow-id", initialStep: safeParseStepJson(initialStep), fetcher: fixtureFetcher_1.fixtureFetcher, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, initialStep) }))] })));
|
|
37
24
|
};
|
|
38
25
|
function safeParseStepJson(jsonStep) {
|
|
39
26
|
try {
|
|
@@ -51,17 +38,17 @@ function safeParseStepJson(jsonStep) {
|
|
|
51
38
|
components: [
|
|
52
39
|
{
|
|
53
40
|
type: 'alert',
|
|
54
|
-
markdown:
|
|
55
|
-
context: 'warning'
|
|
41
|
+
markdown: `**Error parsing JSON.**`,
|
|
42
|
+
context: 'warning',
|
|
56
43
|
},
|
|
57
44
|
{
|
|
58
45
|
type: 'paragraph',
|
|
59
|
-
text:
|
|
46
|
+
text: ` Invalid syntax or missing elements are preventing the JSON code you entered from being parsed. Carefully review and edit the code for errors such as missing commas or brackets.`,
|
|
60
47
|
},
|
|
61
|
-
]
|
|
48
|
+
],
|
|
62
49
|
},
|
|
63
|
-
]
|
|
50
|
+
],
|
|
64
51
|
};
|
|
65
52
|
}
|
|
66
53
|
}
|
|
67
|
-
exports
|
|
54
|
+
exports.default = EditableDynamicFlow;
|
|
@@ -1,76 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 };
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fixtureFetcher = void 0;
|
|
4
|
+
const addon_actions_1 = require("@storybook/addon-actions");
|
|
5
|
+
const validators_1 = require("../../common/validators");
|
|
6
|
+
const fixtures_1 = require("../../fixtures");
|
|
7
|
+
const DynamicFlow_story_1 = require("./DynamicFlow.story");
|
|
8
|
+
const fixtureFetcher = async (input, init) => {
|
|
9
|
+
(0, addon_actions_1.action)('fixtureFetcher')(input, init);
|
|
10
|
+
const url = getURL(input);
|
|
11
|
+
if (url.pathname.startsWith('/steps/')) {
|
|
12
|
+
return respondWithFixture(fixtures_1.fixtures.steps, url, init);
|
|
47
13
|
}
|
|
14
|
+
if (url.pathname.startsWith('/responses/')) {
|
|
15
|
+
return respondWithFixture(fixtures_1.fixtures.responses, url, init);
|
|
16
|
+
}
|
|
17
|
+
if (url.pathname.startsWith('/validate')) {
|
|
18
|
+
return new Response(JSON.stringify({ message: 'Validation-async OK' }));
|
|
19
|
+
}
|
|
20
|
+
return new Response(null, { status: 404 });
|
|
48
21
|
};
|
|
49
|
-
exports.__esModule = true;
|
|
50
|
-
exports.fixtureFetcher = void 0;
|
|
51
|
-
var addon_actions_1 = require("@storybook/addon-actions");
|
|
52
|
-
var validators_1 = require("../../common/validators");
|
|
53
|
-
var fixtures_1 = require("../../fixtures");
|
|
54
|
-
var DynamicFlow_story_1 = require("./DynamicFlow.story");
|
|
55
|
-
var fixtureFetcher = function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var url;
|
|
57
|
-
return __generator(this, function (_a) {
|
|
58
|
-
(0, addon_actions_1.action)('fixtureFetcher')(input, init);
|
|
59
|
-
url = getURL(input);
|
|
60
|
-
if (url.pathname.startsWith('/steps/')) {
|
|
61
|
-
return [2 /*return*/, respondWithFixture(fixtures_1.fixtures.steps, url, init)];
|
|
62
|
-
}
|
|
63
|
-
if (url.pathname.startsWith('/responses/')) {
|
|
64
|
-
return [2 /*return*/, respondWithFixture(fixtures_1.fixtures.responses, url, init)];
|
|
65
|
-
}
|
|
66
|
-
if (url.pathname.startsWith('/validate')) {
|
|
67
|
-
return [2 /*return*/, new Response(JSON.stringify({ message: 'Validation-async OK' }))];
|
|
68
|
-
}
|
|
69
|
-
return [2 /*return*/, new Response(null, { status: 404 })];
|
|
70
|
-
});
|
|
71
|
-
}); };
|
|
72
22
|
exports.fixtureFetcher = fixtureFetcher;
|
|
73
|
-
|
|
23
|
+
const getURL = (input) => {
|
|
74
24
|
if (input instanceof URL) {
|
|
75
25
|
return input;
|
|
76
26
|
}
|
|
@@ -79,40 +29,32 @@ var getURL = function (input) {
|
|
|
79
29
|
}
|
|
80
30
|
return new URL(input, 'http://foo');
|
|
81
31
|
};
|
|
82
|
-
|
|
83
|
-
var fixtureNames, name, fixture, body;
|
|
32
|
+
const respondWithFixture = async (fixtures, url, init) => {
|
|
84
33
|
var _a;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
(init === null || init === void 0 ? void 0 : init.body) &&
|
|
104
|
-
typeof init.body === 'string' &&
|
|
105
|
-
(0, validators_1.isObject)(fixture)) {
|
|
106
|
-
body = JSON.parse(init.body);
|
|
107
|
-
return [2 /*return*/, new Response(JSON.stringify(__assign(__assign({}, fixture), { model: __assign(__assign({}, ((_a = fixture.model) !== null && _a !== void 0 ? _a : {})), body) })))];
|
|
108
|
-
}
|
|
109
|
-
if (url.pathname.includes('exit')) {
|
|
110
|
-
return [2 /*return*/, new Response(JSON.stringify(fixture), { headers: { 'X-DF-Exit': 'true' } })];
|
|
111
|
-
}
|
|
112
|
-
return [2 /*return*/, new Response(JSON.stringify(fixture))];
|
|
113
|
-
case 3:
|
|
114
|
-
(0, addon_actions_1.action)('ERROR 404')(url);
|
|
115
|
-
return [2 /*return*/, new Response(null, { status: 404 })];
|
|
34
|
+
const fixtureNames = (0, DynamicFlow_story_1.getObjectKeys)(fixtures);
|
|
35
|
+
const name = url.pathname
|
|
36
|
+
.split('/')
|
|
37
|
+
.filter((part) => !!part)
|
|
38
|
+
.pop();
|
|
39
|
+
if (fixtureNames.includes(name !== null && name !== void 0 ? name : '')) {
|
|
40
|
+
const fixture = fixtures[name];
|
|
41
|
+
// by convention if the url contains a "delay" query parameter, we delay the response
|
|
42
|
+
if (url.searchParams.has('delay')) {
|
|
43
|
+
await new Promise((resolve) => setTimeout(resolve, Number(url.searchParams.get('delay'))));
|
|
44
|
+
}
|
|
45
|
+
// by convention if the url contains a "refresh"query parameterm we use the payload as model
|
|
46
|
+
if (url.searchParams.has('refresh') &&
|
|
47
|
+
(init === null || init === void 0 ? void 0 : init.body) &&
|
|
48
|
+
typeof init.body === 'string' &&
|
|
49
|
+
(0, validators_1.isObject)(fixture)) {
|
|
50
|
+
const body = JSON.parse(init.body);
|
|
51
|
+
return new Response(JSON.stringify(Object.assign(Object.assign({}, fixture), { model: Object.assign(Object.assign({}, ((_a = fixture.model) !== null && _a !== void 0 ? _a : {})), body) })));
|
|
116
52
|
}
|
|
117
|
-
|
|
118
|
-
|
|
53
|
+
if (url.pathname.includes('exit')) {
|
|
54
|
+
return new Response(JSON.stringify(fixture), { headers: { 'X-DF-Exit': 'true' } });
|
|
55
|
+
}
|
|
56
|
+
return new Response(JSON.stringify(fixture));
|
|
57
|
+
}
|
|
58
|
+
(0, addon_actions_1.action)('ERROR 404')(url);
|
|
59
|
+
return new Response(null, { status: 404 });
|
|
60
|
+
};
|
|
@@ -1,47 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
exports.__esModule = true;
|
|
18
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
var react_1 = require("react");
|
|
20
|
-
var ErrorBoundaryAlert_1 = require("./ErrorBoundaryAlert");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ErrorBoundaryAlert_1 = require("./ErrorBoundaryAlert");
|
|
21
6
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_this.setState({ hasError: false, isFatalError: false });
|
|
7
|
+
const noop = () => { };
|
|
8
|
+
class ErrorBoundary extends react_1.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.handleErrorReset = () => {
|
|
12
|
+
this.setState({ hasError: false, isFatalError: false });
|
|
29
13
|
};
|
|
30
|
-
|
|
31
|
-
return _this;
|
|
14
|
+
this.state = { hasError: false, isFatalError: false };
|
|
32
15
|
}
|
|
33
|
-
|
|
16
|
+
static getDerivedStateFromError() {
|
|
34
17
|
return { hasError: true, isFatalError: true };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
}
|
|
19
|
+
componentDidCatch(error) {
|
|
20
|
+
const { onError = noop } = this.props;
|
|
38
21
|
onError(error);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
const { children } = this.props;
|
|
25
|
+
const { hasError, isFatalError } = this.state;
|
|
43
26
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [hasError && (0, jsx_runtime_1.jsx)(ErrorBoundaryAlert_1.ErrorBoundaryAlert, { onDismiss: this.handleErrorReset }), !isFatalError && children] }));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
exports["default"] = ErrorBoundary;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = ErrorBoundary;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
|
|
4
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_intl_1 = require("react-intl");
|
|
4
|
+
exports.default = (0, react_intl_1.defineMessages)({
|
|
5
5
|
errorAlert: {
|
|
6
6
|
id: 'dynamicFlows.ErrorBoundary.errorAlert',
|
|
7
7
|
defaultMessage: 'Oops. Something went wrong...',
|
|
8
|
-
description: 'Generic error message for when something has gone wrong'
|
|
8
|
+
description: 'Generic error message for when something has gone wrong',
|
|
9
9
|
},
|
|
10
10
|
retry: {
|
|
11
11
|
id: 'dynamicFlows.ErrorBoundary.retry',
|
|
12
12
|
defaultMessage: 'Retry',
|
|
13
|
-
description: 'Retry'
|
|
14
|
-
}
|
|
13
|
+
description: 'Retry',
|
|
14
|
+
},
|
|
15
15
|
});
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
exports
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ErrorBoundaryAlert = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var formatMessage = (0, react_intl_1.useIntl)().formatMessage;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const components_1 = require("@transferwise/components");
|
|
9
|
+
const react_intl_1 = require("react-intl");
|
|
10
|
+
const ErrorBoundary_messages_1 = __importDefault(require("./ErrorBoundary.messages"));
|
|
11
|
+
const ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
12
|
+
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
14
13
|
return ((0, jsx_runtime_1.jsx)(components_1.Alert, { action: {
|
|
15
|
-
text: formatMessage(ErrorBoundary_messages_1
|
|
16
|
-
href: window.location.href
|
|
17
|
-
}, message: formatMessage(ErrorBoundary_messages_1
|
|
14
|
+
text: formatMessage(ErrorBoundary_messages_1.default.retry),
|
|
15
|
+
href: window.location.href,
|
|
16
|
+
}, message: formatMessage(ErrorBoundary_messages_1.default.errorAlert), type: components_1.Sentiment.NEGATIVE, className: "m-b-3", onDismiss: onDismiss }));
|
|
18
17
|
};
|
|
19
18
|
exports.ErrorBoundaryAlert = ErrorBoundaryAlert;
|
|
@@ -13,11 +13,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
20
|
exports.ErrorBoundary = void 0;
|
|
18
21
|
__exportStar(require("./useDebouncedRefresh/useDebouncedRefresh"), exports);
|
|
19
22
|
__exportStar(require("./useDynamicFlowState"), exports);
|
|
20
23
|
__exportStar(require("./useLoader"), exports);
|
|
21
24
|
var ErrorBoundary_1 = require("./errorBoundary/ErrorBoundary");
|
|
22
|
-
|
|
25
|
+
Object.defineProperty(exports, "ErrorBoundary", { enumerable: true, get: function () { return __importDefault(ErrorBoundary_1).default; } });
|
|
23
26
|
__exportStar(require("./responseParsers/response-parsers"), exports);
|