@wise/dynamic-flow-client 0.2.1 → 0.3.0-beta-ec09e7.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/README.md +47 -25
- package/build/common/contexts/events/EventsContext.d.ts +15 -0
- package/build/common/contexts/events/EventsContext.js +33 -0
- package/build/common/contexts/events/index.d.ts +1 -0
- package/build/common/contexts/events/index.js +1 -0
- package/build/flow/DynamicFlow.d.ts +0 -1
- package/build/flow/DynamicFlow.js +21 -22
- package/build/flow/DynamicFlowStep.d.ts +0 -1
- package/build/flow/errorBoundary/ErrorBoundaryAlert.d.ts +0 -1
- package/build/flow/response-parsers/index.d.ts +2 -2
- package/build/flow/response-parsers/index.js +16 -3
- package/build/flow/stories/DynamicFlow.story.js +1 -1
- package/build/flow/stories/EditableDynamicFlow.d.ts +0 -1
- package/build/flow/stories/EditableDynamicFlow.js +1 -1
- package/build/flow/types.d.ts +6 -31
- package/build/i18n/de.json +5 -1
- package/build/i18n/es.json +7 -3
- package/build/i18n/fr.json +9 -5
- package/build/i18n/hu.json +5 -1
- package/build/i18n/id.json +7 -3
- package/build/i18n/it.json +4 -0
- package/build/i18n/ja.json +15 -11
- package/build/i18n/pl.json +30 -3
- package/build/i18n/pt.json +4 -0
- package/build/i18n/ro.json +5 -1
- package/build/i18n/ru.json +10 -6
- package/build/i18n/th.json +6 -2
- package/build/i18n/tr.json +30 -3
- package/build/i18n/zh-CN.json +8 -4
- package/build/i18n/zh.json +4 -0
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -2
- package/build/jsonSchemaForm/JsonSchemaForm.d.ts +2 -3
- package/build/jsonSchemaForm/JsonSchemaForm.js +4 -4
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.d.ts +0 -1
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.d.ts +0 -1
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +0 -1
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.d.ts +0 -1
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +5 -5
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.d.ts +0 -1
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.d.ts +0 -1
- package/build/jsonSchemaForm/genericSchema/GenericSchema.d.ts +0 -1
- package/build/jsonSchemaForm/help/Help.d.ts +0 -1
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.d.ts +0 -1
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.d.ts +0 -1
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +4 -4
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.d.ts +0 -1
- package/build/jsonSchemaForm/persistAsyncSchema/basic/PersistAsyncBasicSchema.d.ts +0 -1
- package/build/jsonSchemaForm/persistAsyncSchema/basic/PersistAsyncBasicSchema.js +5 -5
- package/build/jsonSchemaForm/persistAsyncSchema/blob/PersistAsyncBlobSchema.d.ts +0 -1
- package/build/jsonSchemaForm/persistAsyncSchema/blob/PersistAsyncBlobSchema.js +4 -4
- package/build/jsonSchemaForm/persistAsyncSchema/blob/UploadInputAdapter.d.ts +0 -1
- package/build/jsonSchemaForm/persistAsyncSchema/blob/UploadInputAdapter.js +3 -3
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.d.ts +0 -1
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfCheckboxControl.d.ts +0 -1
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfRadioControl.d.ts +0 -1
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.d.ts +0 -1
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +0 -1
- package/build/jsonSchemaForm/schemaFormControl/optionMapper.d.ts +0 -1
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.d.ts +0 -1
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +5 -5
- package/build/layout/DynamicLayout.d.ts +0 -1
- package/build/layout/alert/index.d.ts +0 -1
- package/build/layout/box/index.d.ts +0 -1
- package/build/layout/button/index.d.ts +0 -1
- package/build/layout/columns/index.d.ts +0 -1
- package/build/layout/decision/index.d.ts +0 -1
- package/build/layout/divider/index.d.ts +0 -1
- package/build/layout/external/DynamicExternal.d.ts +0 -1
- package/build/layout/form/index.d.ts +0 -1
- package/build/layout/heading/index.d.ts +0 -1
- package/build/layout/icon/index.d.ts +1 -2
- package/build/layout/icon/index.js +3 -2
- package/build/layout/image/index.d.ts +0 -1
- package/build/layout/image/index.js +7 -2
- package/build/layout/info/index.d.ts +0 -1
- package/build/layout/list/index.d.ts +0 -1
- package/build/layout/loading-indicator/index.d.ts +0 -1
- package/build/layout/paragraph/DynamicParagraph.d.ts +0 -1
- package/build/layout/review/index.d.ts +0 -1
- package/build/main.css +3 -6
- package/build/step/cameraStep/CameraStep.d.ts +0 -1
- package/build/step/cameraStep/CameraStep.js +3 -3
- package/build/step/cameraStep/cameraCapture/CameraCapture.d.ts +3 -4
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +6 -6
- package/build/step/cameraStep/cameraCapture/components/index.d.ts +0 -1
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.d.ts +0 -1
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.d.ts +0 -1
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.d.ts +0 -1
- package/build/step/cameraStep/cameraCapture/tracking/index.d.ts +4 -4
- package/build/step/cameraStep/cameraCapture/tracking/index.js +19 -22
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.d.ts +0 -1
- package/build/step/layoutStep/LayoutStep.d.ts +0 -1
- package/build/step/layoutStep/LayoutStep.js +3 -3
- package/package.json +44 -51
- package/build/common/requirements.d.ts +0 -10
- package/build/common/requirements.js +0 -50
- package/build/common/tracking/index.d.ts +0 -15
- package/build/common/tracking/index.js +0 -33
- package/build/field/Field.d.ts +0 -69
- package/build/field/Field.js +0 -311
- package/build/field/index.d.ts +0 -2
- package/build/field/index.js +0 -2
|
@@ -41,9 +41,9 @@ import { useEffect, useState } from 'react';
|
|
|
41
41
|
import { useIntl } from 'react-intl';
|
|
42
42
|
import { FormControlType } from '../../../common';
|
|
43
43
|
import { isStatus2xx, isStatus422 } from '../../../common/api/utils';
|
|
44
|
+
import { useEventDispatcher } from '../../../common/contexts/events';
|
|
44
45
|
import { useFetcher } from '../../../common/contexts/fetcherContext';
|
|
45
46
|
import usePrevious from '../../../common/hooks/usePrevious';
|
|
46
|
-
import { useTracking } from '../../../common/tracking';
|
|
47
47
|
import { isValidSchema } from '../../../common/validation/schema-validators';
|
|
48
48
|
import BasicTypeSchema from '../../basicTypeSchema';
|
|
49
49
|
import { getControlType } from '../../schemaFormControl/SchemaFormControl';
|
|
@@ -67,7 +67,7 @@ var controlTypesWithPersistOnChange = new Set([
|
|
|
67
67
|
var PersistAsyncBasicSchema = function (props) {
|
|
68
68
|
var intl = useIntl();
|
|
69
69
|
var fetcher = useFetcher();
|
|
70
|
-
var
|
|
70
|
+
var onEvent = useEventDispatcher();
|
|
71
71
|
var _a = useState(null), persistAsyncModel = _a[0], setPersistAsyncModel = _a[1];
|
|
72
72
|
var previousPersistAsyncModel = usePrevious(persistAsyncModel);
|
|
73
73
|
var _b = useState(null), persistAsyncError = _b[0], setPersistAsyncError = _b[1];
|
|
@@ -95,7 +95,7 @@ var PersistAsyncBasicSchema = function (props) {
|
|
|
95
95
|
_d.label = 1;
|
|
96
96
|
case 1:
|
|
97
97
|
_d.trys.push([1, 4, , 5]);
|
|
98
|
-
|
|
98
|
+
onEvent('Dynamic Flow - PersistAsync', { status: 'pending', schemaId: schema.$id });
|
|
99
99
|
persistAsyncFetch = fetcher(persistAsyncSpec.url, {
|
|
100
100
|
method: persistAsyncSpec.method,
|
|
101
101
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -126,11 +126,11 @@ var PersistAsyncBasicSchema = function (props) {
|
|
|
126
126
|
else {
|
|
127
127
|
setGenericPersistAsyncError();
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
onEvent('Dynamic Flow - PersistAsync', { status: 'success', schemaId: schema.$id });
|
|
130
130
|
return [3 /*break*/, 5];
|
|
131
131
|
case 4:
|
|
132
132
|
_b = _d.sent();
|
|
133
|
-
|
|
133
|
+
onEvent('Dynamic Flow - PersistAsync', { status: 'failure', schemaId: schema.$id });
|
|
134
134
|
setGenericPersistAsyncError();
|
|
135
135
|
return [3 /*break*/, 5];
|
|
136
136
|
case 5: return [2 /*return*/];
|
|
@@ -49,8 +49,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
49
49
|
import classNames from 'classnames';
|
|
50
50
|
import { useEffect, useState } from 'react';
|
|
51
51
|
import { isStatus422 } from '../../../common/api/utils';
|
|
52
|
+
import { useEventDispatcher } from '../../../common/contexts/events';
|
|
52
53
|
import { useFetcher } from '../../../common/contexts/fetcherContext';
|
|
53
|
-
import { useTracking } from '../../../common/tracking';
|
|
54
54
|
import { getValidationFailures } from '../../../common/validation/validation-failures';
|
|
55
55
|
import ControlFeedback from '../../controlFeedback';
|
|
56
56
|
import { mapSchemaToUploadOptions } from '../../schemaFormControl/optionMapper';
|
|
@@ -62,7 +62,7 @@ var PersistAsyncBlobSchema = function (props) {
|
|
|
62
62
|
var _c = useState([]), validations = _c[0], setValidations = _c[1];
|
|
63
63
|
var _d = useState(false), changed = _d[0], setChanged = _d[1];
|
|
64
64
|
var fetcher = useFetcher();
|
|
65
|
-
var
|
|
65
|
+
var onEvent = useEventDispatcher();
|
|
66
66
|
var refreshValidations = function () {
|
|
67
67
|
if (props.submitted) {
|
|
68
68
|
setValidations(getValidationFailures(props.model, props.schema, !!props.required));
|
|
@@ -79,7 +79,7 @@ var PersistAsyncBlobSchema = function (props) {
|
|
|
79
79
|
id = getIdFromResponse(props.schema.persistAsync.idProperty, jsonResponse);
|
|
80
80
|
props.onChange({ model: id, triggerSchema: props.schema, triggerModel: id });
|
|
81
81
|
setChanged(true);
|
|
82
|
-
|
|
82
|
+
onEvent('Dynamic Flow - PersistAsync', { status: 'success', schemaId: props.schema.$id });
|
|
83
83
|
return [2 /*return*/];
|
|
84
84
|
}
|
|
85
85
|
});
|
|
@@ -99,7 +99,7 @@ var PersistAsyncBlobSchema = function (props) {
|
|
|
99
99
|
case 2:
|
|
100
100
|
props.onChange({ model: null, triggerSchema: props.schema, triggerModel: null });
|
|
101
101
|
setChanged(true);
|
|
102
|
-
|
|
102
|
+
onEvent('Dynamic Flow - PersistAsync', { status: 'failure', schemaId: props.schema.$id });
|
|
103
103
|
return [2 /*return*/];
|
|
104
104
|
}
|
|
105
105
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Status, UploadInput } from '@transferwise/components';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useEventDispatcher } from '../../../common/contexts/events';
|
|
5
5
|
import { toKilobytes } from '../../../common/utils/file-utils';
|
|
6
6
|
export var UploadInputAdapter = function (props) {
|
|
7
7
|
var id = props.id, _a = props.fetcher, fetcher = _a === void 0 ? fetch : _a, httpOptions = props.httpOptions, fileId = props.fileId, idProperty = props.idProperty, usAccept = props.usAccept, maxSize = props.maxSize, usPlaceholder = props.usPlaceholder, onSuccess = props.onSuccess, onFailure = props.onFailure, onCancel = props.onCancel;
|
|
8
|
-
var
|
|
8
|
+
var onEvent = useEventDispatcher();
|
|
9
9
|
var files = useMemo(function () { return (fileId ? [{ id: fileId, status: Status.SUCCEEDED }] : []); }, [fileId]);
|
|
10
10
|
var uploadFile = function (formData) {
|
|
11
|
-
|
|
11
|
+
onEvent('Dynamic Flow - PersistAsync', { status: 'pending', schemaId: id });
|
|
12
12
|
return fetcher("".concat(httpOptions.url), {
|
|
13
13
|
method: httpOptions.method || 'POST',
|
|
14
14
|
body: formData
|
|
@@ -49,9 +49,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
49
49
|
import { isNull, isObject, isString } from '@transferwise/neptune-validation';
|
|
50
50
|
import isEqual from 'lodash.isequal';
|
|
51
51
|
import { useRef, useState } from 'react';
|
|
52
|
+
import { useEventDispatcher } from '../../common/contexts/events';
|
|
52
53
|
import { useFetcher } from '../../common/contexts/fetcherContext';
|
|
53
54
|
import { useLogger } from '../../common/logging';
|
|
54
|
-
import { useTracking } from '../../common/tracking';
|
|
55
55
|
import { isValidSchema } from '../../common/validation/schema-validators';
|
|
56
56
|
import BasicTypeSchema from '../basicTypeSchema';
|
|
57
57
|
var ValidationAsyncSchema = function (props) {
|
|
@@ -62,7 +62,7 @@ var ValidationAsyncSchema = function (props) {
|
|
|
62
62
|
var _d = useState(false), fieldSubmitted = _d[0], setFieldSubmitted = _d[1];
|
|
63
63
|
var _e = useState(null), abortController = _e[0], setAbortController = _e[1];
|
|
64
64
|
var fetcher = useFetcher();
|
|
65
|
-
var
|
|
65
|
+
var onEvent = useEventDispatcher();
|
|
66
66
|
var logger = useLogger();
|
|
67
67
|
var getValidationAsyncResponse = function (currentValidationAsyncModel, validationAsyncSpec) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
68
|
var signal, requestBody, response, jsonResponse, _a;
|
|
@@ -77,7 +77,7 @@ var ValidationAsyncSchema = function (props) {
|
|
|
77
77
|
if (!validationAsyncSpec.method) {
|
|
78
78
|
logger.warning('Invalid schema or model', 'ValidationAsyncSchema without a "method" property would have defaulted to "GET" in previous versions. Now defaults to "POST".', {});
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
onEvent('Dynamic Flow - ValidationAsync', { status: 'pending' });
|
|
81
81
|
return [4 /*yield*/, fetcher(validationAsyncSpec.url, {
|
|
82
82
|
method: validationAsyncSpec.method || 'POST',
|
|
83
83
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -95,7 +95,7 @@ var ValidationAsyncSchema = function (props) {
|
|
|
95
95
|
if (!isObject(jsonResponse)) {
|
|
96
96
|
throw new Error('Response body is not an object');
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
onEvent('Dynamic Flow - ValidationAsync', { status: 'success' });
|
|
99
99
|
if (response.status === 200) {
|
|
100
100
|
setValidationAsyncSuccessMessage(isString(jsonResponse.message) ? jsonResponse.message : null);
|
|
101
101
|
}
|
|
@@ -105,7 +105,7 @@ var ValidationAsyncSchema = function (props) {
|
|
|
105
105
|
return [3 /*break*/, 5];
|
|
106
106
|
case 4:
|
|
107
107
|
_a = _c.sent();
|
|
108
|
-
|
|
108
|
+
onEvent('Dynamic Flow - ValidationAsync', { status: 'failure' });
|
|
109
109
|
return [3 /*break*/, 5];
|
|
110
110
|
case 5: return [2 /*return*/];
|
|
111
111
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
type Props = {
|
|
3
2
|
type: string;
|
|
4
3
|
};
|
|
5
|
-
declare const DynamicIcon: (
|
|
4
|
+
declare const DynamicIcon: ({ type }: Props) => JSX.Element;
|
|
6
5
|
export declare function isValidIconName(name: string): boolean;
|
|
7
6
|
export default DynamicIcon;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as icons from '@transferwise/icons';
|
|
3
|
-
var DynamicIcon = function (
|
|
4
|
-
var
|
|
3
|
+
var DynamicIcon = function (_a) {
|
|
4
|
+
var type = _a.type;
|
|
5
|
+
var iconName = toCapitalisedCamelCase(type);
|
|
5
6
|
if (!Object.keys(icons).includes(iconName)) {
|
|
6
7
|
return _jsx(_Fragment, {});
|
|
7
8
|
}
|
|
@@ -91,8 +91,13 @@ var getImageSource = function (fetcher, imageUrl) { return __awaiter(void 0, voi
|
|
|
91
91
|
headers: { 'Content-Type': 'image/image' },
|
|
92
92
|
credentials: 'same-origin'
|
|
93
93
|
})
|
|
94
|
-
.then(function (response) {
|
|
95
|
-
.
|
|
94
|
+
.then(function (response) {
|
|
95
|
+
if (response.ok) {
|
|
96
|
+
return response.blob();
|
|
97
|
+
}
|
|
98
|
+
throw new Error('Image fetching failed');
|
|
99
|
+
})
|
|
100
|
+
.then(readImageBlobAsDataURL)["catch"](function () { return imageUrl; })];
|
|
96
101
|
}
|
|
97
102
|
return [2 /*return*/, imageUrl];
|
|
98
103
|
}
|
package/build/main.css
CHANGED
|
@@ -41,8 +41,6 @@
|
|
|
41
41
|
touch-action: manipulation;
|
|
42
42
|
transition: all 0.15s ease-in-out;
|
|
43
43
|
user-select: none;
|
|
44
|
-
user-select: none;
|
|
45
|
-
user-select: none;
|
|
46
44
|
vertical-align: middle;
|
|
47
45
|
width: 76px;
|
|
48
46
|
}
|
|
@@ -168,15 +166,15 @@
|
|
|
168
166
|
.df-image.xs img {
|
|
169
167
|
width: 100px;
|
|
170
168
|
}
|
|
171
|
-
|
|
169
|
+
|
|
172
170
|
.df-image.sm img {
|
|
173
171
|
width: 200px;
|
|
174
172
|
}
|
|
175
|
-
|
|
173
|
+
|
|
176
174
|
.df-image.md img {
|
|
177
175
|
width: 300px;
|
|
178
176
|
}
|
|
179
|
-
|
|
177
|
+
|
|
180
178
|
.df-image.lg img {
|
|
181
179
|
width: 500px;
|
|
182
180
|
}
|
|
@@ -184,5 +182,4 @@
|
|
|
184
182
|
.df-image.xl img {
|
|
185
183
|
max-width: 600px;
|
|
186
184
|
}
|
|
187
|
-
|
|
188
185
|
}
|
|
@@ -36,8 +36,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
38
38
|
import { useEffect, useState } from 'react';
|
|
39
|
+
import { useEventDispatcher } from '../../common/contexts/events';
|
|
39
40
|
import { filterHiddenSchemas } from '../../common/stepTypes/stepTypes';
|
|
40
|
-
import { useTracking } from '../../common/tracking';
|
|
41
41
|
import { isObjectSchema } from '../../dynamic-flow-types';
|
|
42
42
|
import CameraCapture from './cameraCapture';
|
|
43
43
|
function blobToBase64(blob) {
|
|
@@ -53,7 +53,7 @@ function blobToBase64(blob) {
|
|
|
53
53
|
}
|
|
54
54
|
var CameraStep = function (props) {
|
|
55
55
|
var step = props.step, model = props.model, onModelChange = props.onModelChange, onAction = props.onAction;
|
|
56
|
-
var
|
|
56
|
+
var onEvent = useEventDispatcher();
|
|
57
57
|
var objectSchema = getObjectSchema(step);
|
|
58
58
|
var cameraSchema = getCameraSchema(step);
|
|
59
59
|
var action = getFirstAction(step);
|
|
@@ -92,7 +92,7 @@ var CameraStep = function (props) {
|
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
}); };
|
|
95
|
-
return (_jsx(CameraCapture, { overlay: overlay, outline: outline, title: title, imageUrl: imageUrl, instructions: instructions, direction: direction,
|
|
95
|
+
return (_jsx(CameraCapture, { overlay: overlay, outline: outline, title: title, imageUrl: imageUrl, instructions: instructions, direction: direction, onEvent: onEvent, onCapture: function (blob) {
|
|
96
96
|
void handleCapture(blob);
|
|
97
97
|
} }));
|
|
98
98
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { TrackableEventHandler } from '../../../common/tracking';
|
|
1
|
+
import { EventHandler } from '../../../common/contexts/events';
|
|
3
2
|
import { CameraDirection } from '../../../dynamic-flow-types/FileUploadSchema';
|
|
4
3
|
type Props = {
|
|
5
4
|
direction?: CameraDirection;
|
|
@@ -10,7 +9,7 @@ type Props = {
|
|
|
10
9
|
instructions?: string;
|
|
11
10
|
showReview?: boolean;
|
|
12
11
|
onCapture: BlobCallback;
|
|
13
|
-
|
|
12
|
+
onEvent?: EventHandler;
|
|
14
13
|
};
|
|
15
|
-
declare const CameraCapture: ({ direction, overlay, outline, imageUrl, title, instructions, showReview, onCapture,
|
|
14
|
+
declare const CameraCapture: ({ direction, overlay, outline, imageUrl, title, instructions, showReview, onCapture, onEvent, }: Props) => JSX.Element;
|
|
16
15
|
export default CameraCapture;
|
|
@@ -57,7 +57,7 @@ import { CameraNotSupported, NoCameraAccess } from './screens';
|
|
|
57
57
|
import { trackCameraFeedStarted, trackCameraNotSupported, trackCameraPermissionDenied, } from './tracking';
|
|
58
58
|
import { generateCanvasFromVideo, isSelfieCamera } from './utils';
|
|
59
59
|
var CameraCapture = function (_a) {
|
|
60
|
-
var _b = _a.direction, direction = _b === void 0 ? 'back' : _b, _c = _a.overlay, overlay = _c === void 0 ? '' : _c, _d = _a.outline, outline = _d === void 0 ? '' : _d, _e = _a.imageUrl, imageUrl = _e === void 0 ? '' : _e, _f = _a.title, title = _f === void 0 ? '' : _f, _g = _a.instructions, instructions = _g === void 0 ? '' : _g, _h = _a.showReview, showReview = _h === void 0 ? false : _h, onCapture = _a.onCapture,
|
|
60
|
+
var _b = _a.direction, direction = _b === void 0 ? 'back' : _b, _c = _a.overlay, overlay = _c === void 0 ? '' : _c, _d = _a.outline, outline = _d === void 0 ? '' : _d, _e = _a.imageUrl, imageUrl = _e === void 0 ? '' : _e, _f = _a.title, title = _f === void 0 ? '' : _f, _g = _a.instructions, instructions = _g === void 0 ? '' : _g, _h = _a.showReview, showReview = _h === void 0 ? false : _h, onCapture = _a.onCapture, onEvent = _a.onEvent;
|
|
61
61
|
var _j = useState('CAPTURE'), mode = _j[0], setMode = _j[1];
|
|
62
62
|
var _k = useState(false), isVideoMirrored = _k[0], setIsVideoMirrored = _k[1];
|
|
63
63
|
var _l = useState(false), ready = _l[0], setReady = _l[1];
|
|
@@ -96,17 +96,17 @@ var CameraCapture = function (_a) {
|
|
|
96
96
|
var handleUserMediaError = useCallback(function (error) {
|
|
97
97
|
if (error instanceof DOMException && (error === null || error === void 0 ? void 0 : error.name) === 'NotAllowedError') {
|
|
98
98
|
setMode('NO_CAMERA_ACCESS');
|
|
99
|
-
trackCameraPermissionDenied(
|
|
99
|
+
trackCameraPermissionDenied(onEvent);
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
setMode('CAMERA_NOT_SUPPORTED');
|
|
103
|
-
trackCameraNotSupported(
|
|
104
|
-
}, [setMode,
|
|
103
|
+
trackCameraNotSupported(onEvent, error);
|
|
104
|
+
}, [setMode, onEvent]);
|
|
105
105
|
var handleUserMedia = useCallback(function (stream) {
|
|
106
106
|
setReady(true);
|
|
107
107
|
setIsVideoMirrored(isSelfieCamera(stream));
|
|
108
|
-
void trackCameraFeedStarted(
|
|
109
|
-
}, [setIsVideoMirrored,
|
|
108
|
+
void trackCameraFeedStarted(onEvent, { direction: direction }, stream);
|
|
109
|
+
}, [setIsVideoMirrored, onEvent, direction]);
|
|
110
110
|
var handleReviewSubmit = function () {
|
|
111
111
|
onCapture((reviewImage === null || reviewImage === void 0 ? void 0 : reviewImage.blob) || null);
|
|
112
112
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventHandler } from '../../../../common/contexts/events';
|
|
2
2
|
import { CameraDirection } from '../../../../dynamic-flow-types/FileUploadSchema';
|
|
3
|
-
export declare const trackCameraPermissionDenied: (
|
|
4
|
-
export declare const trackCameraFeedStarted: (
|
|
3
|
+
export declare const trackCameraPermissionDenied: (onEvent: EventHandler | undefined) => void | undefined;
|
|
4
|
+
export declare const trackCameraFeedStarted: (onEvent: EventHandler | undefined, props: {
|
|
5
5
|
direction?: CameraDirection;
|
|
6
6
|
}, stream: MediaStream) => Promise<void | undefined>;
|
|
7
|
-
export declare const trackCameraNotSupported: (
|
|
7
|
+
export declare const trackCameraNotSupported: (onEvent: EventHandler | undefined, error: string | DOMException) => void | undefined;
|
|
@@ -46,29 +46,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { getActiveVideoDeviceLabel, getAvailableVideoDeviceLabels, getVideoCapabilities, getVideoTrack, } from '../utils';
|
|
49
|
-
export var trackCameraPermissionDenied = function (
|
|
50
|
-
return
|
|
49
|
+
export var trackCameraPermissionDenied = function (onEvent) {
|
|
50
|
+
return onEvent === null || onEvent === void 0 ? void 0 : onEvent('Dynamic Flow - Camera Permission Denied', {});
|
|
51
51
|
};
|
|
52
|
-
export var trackCameraFeedStarted = function (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
}); };
|
|
71
|
-
export var trackCameraNotSupported = function (onTrackableEvent, error) { return onTrackableEvent === null || onTrackableEvent === void 0 ? void 0 : onTrackableEvent('Dynamic Flow - Camera Not Supported', { Error: error }); };
|
|
52
|
+
export var trackCameraFeedStarted = function (onEvent, props, stream) { return __awaiter(void 0, void 0, void 0, function () { var _a, _b, _c; return __generator(this, function (_d) {
|
|
53
|
+
switch (_d.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
if (!(onEvent === null || onEvent === void 0)) return [3 /*break*/, 1];
|
|
56
|
+
_a = void 0;
|
|
57
|
+
return [3 /*break*/, 3];
|
|
58
|
+
case 1:
|
|
59
|
+
_b = onEvent;
|
|
60
|
+
_c = ['Dynamic Flow - Camera Feed Started'];
|
|
61
|
+
return [4 /*yield*/, getCameraStartedProperties(props, stream)];
|
|
62
|
+
case 2:
|
|
63
|
+
_a = _b.apply(void 0, _c.concat([_d.sent()]));
|
|
64
|
+
_d.label = 3;
|
|
65
|
+
case 3: return [2 /*return*/, _a];
|
|
66
|
+
}
|
|
67
|
+
}); }); };
|
|
68
|
+
export var trackCameraNotSupported = function (onEvent, error) { return onEvent === null || onEvent === void 0 ? void 0 : onEvent('Dynamic Flow - Camera Not Supported', { Error: error }); };
|
|
72
69
|
var getCameraStartedProperties = function (props, videoStream) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
70
|
var videoTrack, capabilities, settings, _a, _b, _c, _d;
|
|
74
71
|
var _e;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { isEmpty } from '@transferwise/neptune-validation';
|
|
3
3
|
import { useDynamicFlow } from '../../common/contexts/dynamicFlowContext/dynamicFlowContext';
|
|
4
|
-
import {
|
|
4
|
+
import { useEventDispatcher } from '../../common/contexts/events';
|
|
5
5
|
import DynamicLayout from '../../layout';
|
|
6
6
|
import { useStepPolling } from '../features';
|
|
7
7
|
import { convertStepToLayout, inlineReferences } from './layoutService';
|
|
@@ -22,11 +22,11 @@ var LayoutStep = function (props) {
|
|
|
22
22
|
var stepSpecification = props.stepSpecification, stepLayoutOptions = props.stepLayoutOptions, submitted = props.submitted, model = props.model, formErrors = props.formErrors, onModelChange = props.onModelChange;
|
|
23
23
|
var components = getComponents(stepSpecification, stepLayoutOptions);
|
|
24
24
|
var _a = useDynamicFlow(), loading = _a.loading, registerPersistAsyncPromise = _a.registerPersistAsyncPromise;
|
|
25
|
-
var
|
|
25
|
+
var onEvent = useEventDispatcher();
|
|
26
26
|
var onAction = !loading
|
|
27
27
|
? props.onAction
|
|
28
28
|
: function () {
|
|
29
|
-
|
|
29
|
+
onEvent('Dynamic Flow - onAction supressed', { reason: 'LayoutStep - loading state' });
|
|
30
30
|
};
|
|
31
31
|
useStepPolling(stepSpecification.polling, onAction);
|
|
32
32
|
return (_jsx(DynamicLayout, { components: components, submitted: submitted, model: model, errors: formErrors, onAction: onAction, onModelChange: onModelChange, onPersistAsync: registerPersistAsyncPromise }));
|