@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,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FormControlType = void 0;
|
|
4
4
|
exports.FormControlType = {
|
|
5
5
|
RADIO: 'radio',
|
|
@@ -16,5 +16,5 @@ exports.FormControlType = {
|
|
|
16
16
|
TEXT: 'text',
|
|
17
17
|
TEXTAREA: 'textarea',
|
|
18
18
|
UPLOAD: 'upload',
|
|
19
|
-
TAB: 'tab'
|
|
19
|
+
TAB: 'tab',
|
|
20
20
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SchemaType = void 0;
|
|
4
4
|
exports.SchemaType = {
|
|
5
5
|
READ_ONLY: 'readOnly',
|
|
@@ -10,5 +10,5 @@ exports.SchemaType = {
|
|
|
10
10
|
ONE_OF: 'oneOf',
|
|
11
11
|
ALL_OF: 'allOf',
|
|
12
12
|
BASIC: 'basic',
|
|
13
|
-
ARRAY: 'array'
|
|
13
|
+
ARRAY: 'array',
|
|
14
14
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Size = void 0;
|
|
4
4
|
exports.Size = {
|
|
5
5
|
EXTRA_SMALL: 'xs',
|
|
6
6
|
SMALL: 'sm',
|
|
7
7
|
MEDIUM: 'md',
|
|
8
8
|
LARGE: 'lg',
|
|
9
|
-
EXTRA_LARGE: 'xl'
|
|
9
|
+
EXTRA_LARGE: 'xl',
|
|
10
10
|
};
|
|
@@ -13,7 +13,7 @@ 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
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./DateMode"), exports);
|
|
18
18
|
__exportStar(require("./FormControlType"), exports);
|
|
19
19
|
__exportStar(require("./MonthFormat"), exports);
|
|
@@ -1,41 +1,29 @@
|
|
|
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.useDynamicFlow = exports.DynamicFlowProvider = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const usePendingPromiseCounter_1 = require("./usePendingPromiseCounter");
|
|
7
|
+
const defaultContextValue = {
|
|
19
8
|
loading: false,
|
|
20
|
-
registerPersistAsyncPromise:
|
|
9
|
+
registerPersistAsyncPromise: (promise) => {
|
|
21
10
|
//
|
|
22
|
-
}
|
|
11
|
+
},
|
|
23
12
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var providerValue = (0, react_1.useMemo)(function () {
|
|
13
|
+
const DFContext = (0, react_1.createContext)(defaultContextValue);
|
|
14
|
+
const DynamicFlowProvider = ({ loading, children }) => {
|
|
15
|
+
const { pendingPromises, addPendingPromise } = (0, usePendingPromiseCounter_1.usePendingPromiseCounter)();
|
|
16
|
+
const providerValue = (0, react_1.useMemo)(() => {
|
|
29
17
|
return {
|
|
30
18
|
loading: loading || pendingPromises > 0,
|
|
31
|
-
registerPersistAsyncPromise: addPendingPromise
|
|
19
|
+
registerPersistAsyncPromise: addPendingPromise,
|
|
32
20
|
};
|
|
33
21
|
}, [loading, pendingPromises, addPendingPromise]);
|
|
34
|
-
return (0, jsx_runtime_1.jsx)(DFContext.Provider,
|
|
22
|
+
return (0, jsx_runtime_1.jsx)(DFContext.Provider, Object.assign({ value: providerValue }, { children: children }));
|
|
35
23
|
};
|
|
36
24
|
exports.DynamicFlowProvider = DynamicFlowProvider;
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
const useDynamicFlow = () => {
|
|
26
|
+
const context = (0, react_1.useContext)(DFContext);
|
|
39
27
|
return context || defaultContextValue;
|
|
40
28
|
};
|
|
41
29
|
exports.useDynamicFlow = useDynamicFlow;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.usePendingPromiseCounter = void 0;
|
|
4
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
5
|
function usePendingPromiseCounter() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
setCount(
|
|
9
|
-
promise
|
|
6
|
+
const [count, setCount] = (0, react_1.useState)(0);
|
|
7
|
+
const addPendingPromise = (0, react_1.useCallback)((promise) => {
|
|
8
|
+
setCount((c) => c + 1);
|
|
9
|
+
promise
|
|
10
|
+
.catch(noop)
|
|
11
|
+
.finally(() => delayUntilNextCycle(() => setCount((c) => Math.max(0, c - 1))));
|
|
10
12
|
}, [setCount]);
|
|
11
|
-
return { addPendingPromise
|
|
13
|
+
return { addPendingPromise, pendingPromises: count };
|
|
12
14
|
}
|
|
13
15
|
exports.usePendingPromiseCounter = usePendingPromiseCounter;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const delayUntilNextCycle = (fn) => setTimeout(() => fn(), 0);
|
|
17
|
+
const noop = () => {
|
|
16
18
|
// no-op
|
|
17
19
|
};
|
|
@@ -1,39 +1,22 @@
|
|
|
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.getEventDispatcher = exports.useEventDispatcher = exports.EventsContextProvider = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
triggerEvent:
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const EventsContext = (0, react_1.createContext)({
|
|
7
|
+
triggerEvent: () => {
|
|
19
8
|
// noop
|
|
20
|
-
}
|
|
9
|
+
},
|
|
21
10
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return (0, jsx_runtime_1.jsx)(EventsContext.Provider, __assign({ value: value }, { children: children }));
|
|
11
|
+
const EventsContextProvider = ({ metadata, children, onEvent }) => {
|
|
12
|
+
const value = (0, react_1.useMemo)(() => ({ triggerEvent: (0, exports.getEventDispatcher)(onEvent, metadata) }), [onEvent, metadata]);
|
|
13
|
+
return (0, jsx_runtime_1.jsx)(EventsContext.Provider, Object.assign({ value: value }, { children: children }));
|
|
26
14
|
};
|
|
27
15
|
exports.EventsContextProvider = EventsContextProvider;
|
|
28
16
|
function useEventDispatcher() {
|
|
29
|
-
|
|
17
|
+
const { triggerEvent } = (0, react_1.useContext)(EventsContext);
|
|
30
18
|
return triggerEvent;
|
|
31
19
|
}
|
|
32
20
|
exports.useEventDispatcher = useEventDispatcher;
|
|
33
|
-
|
|
34
|
-
return function (eventName, properties) {
|
|
35
|
-
if (properties === void 0) { properties = {}; }
|
|
36
|
-
return onEvent(eventName, __assign(__assign({}, metadata), properties));
|
|
37
|
-
};
|
|
38
|
-
};
|
|
21
|
+
const getEventDispatcher = (onEvent, metadata) => (eventName, properties = {}) => onEvent(eventName, Object.assign(Object.assign({}, metadata), properties));
|
|
39
22
|
exports.getEventDispatcher = getEventDispatcher;
|
|
@@ -1,42 +1,29 @@
|
|
|
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.useHasFetcherProvider = exports.useFetcher = exports.FetcherProviderFromBaseUrl = exports.FetcherProvider = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return (0, jsx_runtime_1.jsx)(FetcherContext.Provider, __assign({ value: fetcher }, { children: children }));
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const makeFetcher_1 = require("../../makeFetcher");
|
|
7
|
+
const FetcherContext = (0, react_1.createContext)(undefined);
|
|
8
|
+
const FetcherProvider = ({ fetcher, children }) => {
|
|
9
|
+
return (0, jsx_runtime_1.jsx)(FetcherContext.Provider, Object.assign({ value: fetcher }, { children: children }));
|
|
22
10
|
};
|
|
23
11
|
exports.FetcherProvider = FetcherProvider;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return (0, jsx_runtime_1.jsx)(FetcherContext.Provider, __assign({ value: fetcher }, { children: children }));
|
|
12
|
+
const FetcherProviderFromBaseUrl = ({ baseUrl, children, }) => {
|
|
13
|
+
const fetcher = (0, react_1.useMemo)(() => (0, makeFetcher_1.makeFetcher)(baseUrl), [baseUrl]);
|
|
14
|
+
return (0, jsx_runtime_1.jsx)(FetcherContext.Provider, Object.assign({ value: fetcher }, { children: children }));
|
|
28
15
|
};
|
|
29
16
|
exports.FetcherProviderFromBaseUrl = FetcherProviderFromBaseUrl;
|
|
30
17
|
/**
|
|
31
18
|
* Provides the fetch(er) function for dynamic flows asynchronous operations.
|
|
32
19
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
const useFetcher = () => {
|
|
21
|
+
const contextFetch = (0, react_1.useContext)(FetcherContext);
|
|
35
22
|
return contextFetch || fetch;
|
|
36
23
|
};
|
|
37
24
|
exports.useFetcher = useFetcher;
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
const useHasFetcherProvider = () => {
|
|
26
|
+
const context = (0, react_1.useContext)(FetcherContext);
|
|
40
27
|
return !!context;
|
|
41
28
|
};
|
|
42
29
|
exports.useHasFetcherProvider = useHasFetcherProvider;
|
|
@@ -13,7 +13,7 @@ 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
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./dynamicFlowContexts/DynamicFlowContexts"), exports);
|
|
18
18
|
__exportStar(require("./eventsContext/EventsContext"), exports);
|
|
19
19
|
__exportStar(require("./fetcherContexts/FetcherContexts"), exports);
|
|
@@ -1,42 +1,24 @@
|
|
|
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.useLogger = exports.LogProvider = exports.getLogger = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (flowId === void 0) { flowId = 'UNKNOWN-FLOW-ID'; }
|
|
19
|
-
if (stepId === void 0) { stepId = 'UNKNOWN-FLOW-ID'; }
|
|
20
|
-
return function (title, description, extra) {
|
|
21
|
-
return onLog(level, "Dynamic Flow ".concat(level, " - ").concat(title, " - ").concat(description), __assign({ flowId: flowId, stepId: stepId }, extra));
|
|
22
|
-
};
|
|
23
|
-
};
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const getLogger = (level, onLog, flowId = 'UNKNOWN-FLOW-ID', stepId = 'UNKNOWN-FLOW-ID') => (title, description, extra) => onLog(level, `Dynamic Flow ${level} - ${title} - ${description}`, Object.assign({ flowId, stepId }, extra));
|
|
24
7
|
exports.getLogger = getLogger;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var value = (0, react_1.useMemo)(function () { return ({
|
|
8
|
+
const LogContext = (0, react_1.createContext)(null);
|
|
9
|
+
const LogProvider = ({ flowId, stepId, children, onLog }) => {
|
|
10
|
+
const value = (0, react_1.useMemo)(() => ({
|
|
29
11
|
debug: (0, exports.getLogger)('debug', onLog, flowId, stepId),
|
|
30
12
|
info: (0, exports.getLogger)('info', onLog, flowId, stepId),
|
|
31
13
|
warning: (0, exports.getLogger)('warning', onLog, flowId, stepId),
|
|
32
14
|
error: (0, exports.getLogger)('error', onLog, flowId, stepId),
|
|
33
|
-
critical: (0, exports.getLogger)('critical', onLog, flowId, stepId)
|
|
34
|
-
})
|
|
35
|
-
return (0, jsx_runtime_1.jsx)(LogContext.Provider,
|
|
15
|
+
critical: (0, exports.getLogger)('critical', onLog, flowId, stepId),
|
|
16
|
+
}), [onLog, flowId, stepId]);
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(LogContext.Provider, Object.assign({ value: value }, { children: children }));
|
|
36
18
|
};
|
|
37
19
|
exports.LogProvider = LogProvider;
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
const useLogger = () => {
|
|
21
|
+
const logging = (0, react_1.useContext)(LogContext);
|
|
40
22
|
if (logging == null) {
|
|
41
23
|
throw new Error('Logging context not found. Did you forget to wrap your component in a <LogProvider />?');
|
|
42
24
|
}
|
|
@@ -13,7 +13,7 @@ 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
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./useDebouncedFunction/useDebouncedFunction"), exports);
|
|
18
18
|
__exportStar(require("./useExternal/useExternal"), exports);
|
|
19
19
|
__exportStar(require("./useExternalStepPolling/useExternalStepPolling"), exports);
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
- https://github.com/gnbaron/use-lodash-debounce
|
|
4
4
|
- https://dmitripavlutin.com/react-throttle-debounce/
|
|
5
5
|
*/
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.useDebouncedFunction = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
10
|
function useDebouncedFunction(callback, waitMs) {
|
|
11
11
|
return (0, react_1.useCallback)((0, utils_1.debounce)(callback, waitMs), [callback, waitMs]);
|
|
12
12
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useExternal = void 0;
|
|
4
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
5
|
function useExternal(url) {
|
|
6
6
|
// If we fail to open the window, the user will need to open this on their own
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(0, react_1.useEffect)(
|
|
7
|
+
const [externalWindow, setExternalWindow] = (0, react_1.useState)(null);
|
|
8
|
+
const [hasManuallyTriggered, setHasManuallyTriggered] = (0, react_1.useState)(false);
|
|
9
|
+
const dismissConfirmation = () => setHasManuallyTriggered(true);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
11
|
if (url) {
|
|
12
12
|
setHasManuallyTriggered(false);
|
|
13
13
|
setExternalWindow(window.open(url, '_blank'));
|
|
14
14
|
}
|
|
15
15
|
}, [url]);
|
|
16
|
-
|
|
17
|
-
return { requiresManualTrigger
|
|
16
|
+
const requiresManualTrigger = Boolean(url && !externalWindow && !hasManuallyTriggered);
|
|
17
|
+
return { requiresManualTrigger, dismissConfirmation };
|
|
18
18
|
}
|
|
19
19
|
exports.useExternal = useExternal;
|
|
@@ -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.useExternalStepPolling = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const contexts_1 = require("../../contexts");
|
|
18
7
|
/** @deprecated External step is no longer supported */
|
|
19
8
|
function useExternalStepPolling(polling, onAction) {
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
const fetcher = (0, contexts_1.useFetcher)();
|
|
10
|
+
const asyncFn = (0, react_1.useMemo)(() => {
|
|
22
11
|
if (polling) {
|
|
23
|
-
return
|
|
24
|
-
return fetcher(polling.url).then(
|
|
12
|
+
return () => {
|
|
13
|
+
return fetcher(polling.url).then((response) => {
|
|
25
14
|
if (response.ok) {
|
|
26
15
|
try {
|
|
27
16
|
return response.json();
|
|
@@ -40,34 +29,34 @@ function useExternalStepPolling(polling, onAction) {
|
|
|
40
29
|
return undefined;
|
|
41
30
|
}
|
|
42
31
|
}, [polling, fetcher]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
const onPollingResponse = (0, react_1.useCallback)((pollingResponse) => {
|
|
33
|
+
const responseHandlers = (polling === null || polling === void 0 ? void 0 : polling.responseHandlers) || [];
|
|
34
|
+
const responseHandler = responseHandlers.find((handler) => handler.result === pollingResponse.result);
|
|
46
35
|
if (responseHandler === null || responseHandler === void 0 ? void 0 : responseHandler.action) {
|
|
47
|
-
|
|
36
|
+
const { action } = responseHandler;
|
|
48
37
|
if (action.exit) {
|
|
49
|
-
|
|
50
|
-
onAction(
|
|
38
|
+
const mergedResult = Object.assign(Object.assign({}, (action.result || {})), (pollingResponse.data || {}));
|
|
39
|
+
onAction(Object.assign(Object.assign({}, action), { result: mergedResult }));
|
|
51
40
|
}
|
|
52
41
|
else {
|
|
53
|
-
|
|
54
|
-
onAction(
|
|
42
|
+
const mergedData = Object.assign(Object.assign({}, (action.data || {})), (pollingResponse.data || {}));
|
|
43
|
+
onAction(Object.assign(Object.assign({}, action), { data: mergedData }));
|
|
55
44
|
}
|
|
56
45
|
return false; // stop polling
|
|
57
46
|
}
|
|
58
47
|
return true; // continue polling
|
|
59
48
|
}, [polling === null || polling === void 0 ? void 0 : polling.responseHandlers, onAction]);
|
|
60
49
|
(0, __1.usePolling)({
|
|
61
|
-
asyncFn
|
|
50
|
+
asyncFn,
|
|
62
51
|
interval: (polling === null || polling === void 0 ? void 0 : polling.interval) || 0,
|
|
63
52
|
maxAttempts: (polling === null || polling === void 0 ? void 0 : polling.maxAttempts) || 0,
|
|
64
53
|
maxConsecutiveFails: (polling === null || polling === void 0 ? void 0 : polling.maxConsecutiveFails) || 0,
|
|
65
|
-
onPollingResponse
|
|
66
|
-
onFailure: (0, react_1.useCallback)(
|
|
54
|
+
onPollingResponse,
|
|
55
|
+
onFailure: (0, react_1.useCallback)(() => {
|
|
67
56
|
if (polling) {
|
|
68
57
|
onAction(polling.onError.action);
|
|
69
58
|
}
|
|
70
|
-
}, [onAction, polling])
|
|
59
|
+
}, [onAction, polling]),
|
|
71
60
|
});
|
|
72
61
|
}
|
|
73
62
|
exports.useExternalStepPolling = useExternalStepPolling;
|