@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,48 +1,30 @@
|
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
var CopyableDynamicParagraph = function (_a) {
|
|
32
|
-
var component = _a.component;
|
|
33
|
-
var formatMessage = (0, react_intl_1.useIntl)().formatMessage;
|
|
34
|
-
var createSnackbar = (0, useSnackBarIfAvailable_1.useSnackBarIfAvailable)();
|
|
35
|
-
var text = component.text;
|
|
36
|
-
var copy = function () {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const components_1 = require("@transferwise/components");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const DynamicParagraph_messages_1 = __importDefault(require("./DynamicParagraph.messages"));
|
|
11
|
+
const useSnackBarIfAvailable_1 = require("./useSnackBarIfAvailable");
|
|
12
|
+
const DynamicParagraph = ({ component }) => component.control === 'copyable' ? ((0, jsx_runtime_1.jsx)(CopyableDynamicParagraph, { component: component })) : ((0, jsx_runtime_1.jsx)(BasicDynamicParagraph, { component: component }));
|
|
13
|
+
const BasicDynamicParagraph = ({ component }) => ((0, jsx_runtime_1.jsxs)("p", Object.assign({ className: (0, utils_1.getTextAlignmentAndMargin)(component) }, { children: [" ", component.text, " "] })));
|
|
14
|
+
const CopyableDynamicParagraph = ({ component }) => {
|
|
15
|
+
const { formatMessage } = (0, react_intl_1.useIntl)();
|
|
16
|
+
const createSnackbar = (0, useSnackBarIfAvailable_1.useSnackBarIfAvailable)();
|
|
17
|
+
const { text } = component;
|
|
18
|
+
const copy = () => {
|
|
37
19
|
var _a;
|
|
38
|
-
(_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(text).then(
|
|
20
|
+
(_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_1.default.copied) })).catch(noop);
|
|
39
21
|
};
|
|
40
|
-
|
|
41
|
-
return ((0, jsx_runtime_1.jsxs)("div",
|
|
22
|
+
const classNames = (0, utils_1.getTextAlignmentAndMargin)({ align: component.align, margin: 'sm' }) + ' form-control';
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, utils_1.getTextAlignmentAndMargin)(component) }, { children: [(0, jsx_runtime_1.jsx)("input", { type: "text", className: classNames, value: text, readOnly: true,
|
|
42
24
|
// eslint-disable-next-line react/forbid-dom-props
|
|
43
|
-
style: { textOverflow: 'ellipsis' } }), (0, jsx_runtime_1.jsx)(components_1.Button,
|
|
25
|
+
style: { textOverflow: 'ellipsis' } }), (0, jsx_runtime_1.jsx)(components_1.Button, Object.assign({ block: true, onClick: copy }, { children: formatMessage(DynamicParagraph_messages_1.default.copy) }))] })));
|
|
44
26
|
};
|
|
45
27
|
function noop() {
|
|
46
28
|
//
|
|
47
29
|
}
|
|
48
|
-
exports
|
|
30
|
+
exports.default = DynamicParagraph;
|
|
@@ -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
|
copy: {
|
|
6
6
|
id: 'dynamicFlows.DynamicParagraph.copy',
|
|
7
7
|
defaultMessage: 'Copy',
|
|
8
|
-
description: 'Copy to clipboard button label.'
|
|
8
|
+
description: 'Copy to clipboard button label.',
|
|
9
9
|
},
|
|
10
10
|
copied: {
|
|
11
11
|
id: 'dynamicFlows.DynamicParagraph.copied',
|
|
12
12
|
defaultMessage: 'Copied to clipboard',
|
|
13
|
-
description: 'Appears in a snackbar when the copy operation succeeds.'
|
|
14
|
-
}
|
|
13
|
+
description: 'Appears in a snackbar when the copy operation succeeds.',
|
|
14
|
+
},
|
|
15
15
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSnackBarIfAvailable = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const components_1 = require("@transferwise/components");
|
|
5
|
+
const react_1 = require("react");
|
|
6
6
|
function useSnackBarIfAvailable() {
|
|
7
|
-
|
|
7
|
+
const context = (0, react_1.useContext)(components_1.SnackbarContext);
|
|
8
8
|
return context ? context.createSnackbar : noop;
|
|
9
9
|
}
|
|
10
10
|
exports.useSnackBarIfAvailable = useSnackBarIfAvailable;
|
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
-
var components_1 = require("@transferwise/components");
|
|
16
|
-
var utils_1 = require("../utils");
|
|
17
|
-
var mapFieldsToDefinitions = function (_a, index) {
|
|
18
|
-
var label = _a.label, value = _a.value;
|
|
19
|
-
return { key: String(index), title: label, value: value };
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const components_1 = require("@transferwise/components");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const mapFieldsToDefinitions = ({ label, value }, index) => {
|
|
7
|
+
return { key: String(index), title: label, value };
|
|
20
8
|
};
|
|
21
|
-
|
|
9
|
+
const getReviewLayout = (orientation) => {
|
|
22
10
|
return orientation === 'horizontal' ? 'HORIZONTAL_RIGHT_ALIGNED' : 'VERTICAL_ONE_COLUMN';
|
|
23
11
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return ((0, jsx_runtime_1.jsx)("a",
|
|
12
|
+
const DynamicReview = (props) => {
|
|
13
|
+
const review = props.component;
|
|
14
|
+
const margin = (0, utils_1.getMarginBottom)(review.margin || 'xs');
|
|
15
|
+
const getReviewAction = (action) => {
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: action.url, className: "pull-right", role: "button", onClick: (event) => {
|
|
29
17
|
event.preventDefault();
|
|
30
18
|
props.onAction(action);
|
|
31
19
|
} }, { children: action.title })));
|
|
32
20
|
};
|
|
33
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [review.title && ((0, jsx_runtime_1.jsxs)("h6",
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [review.title && ((0, jsx_runtime_1.jsxs)("h6", Object.assign({ className: "m-b-2" }, { children: [review.title, review.action && getReviewAction(review.action)] }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: margin }, { children: (0, jsx_runtime_1.jsx)(components_1.DefinitionList, { layout: getReviewLayout(review.orientation), definitions: review.fields.map(mapFieldsToDefinitions) }) }))] }));
|
|
34
22
|
};
|
|
35
|
-
exports
|
|
23
|
+
exports.default = DynamicReview;
|
package/build/layout/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTextAlignmentAndMargin = exports.getMarginBottom = void 0;
|
|
4
|
-
|
|
4
|
+
const getMarginBottom = (size) => {
|
|
5
5
|
switch (size) {
|
|
6
6
|
case 'xs':
|
|
7
7
|
return 'm-b-0';
|
|
@@ -18,7 +18,7 @@ var getMarginBottom = function (size) {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
exports.getMarginBottom = getMarginBottom;
|
|
21
|
-
|
|
21
|
+
const getTextAlignment = (align) => {
|
|
22
22
|
switch (align) {
|
|
23
23
|
case 'right':
|
|
24
24
|
return 'text-xs-right';
|
|
@@ -29,7 +29,5 @@ var getTextAlignment = function (align) {
|
|
|
29
29
|
return '';
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
return "".concat(getTextAlignment(component.align), " ").concat(getMarginBottom(component.margin));
|
|
34
|
-
};
|
|
32
|
+
const getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${getMarginBottom(component.margin)}`;
|
|
35
33
|
exports.getTextAlignmentAndMargin = getTextAlignmentAndMargin;
|
|
@@ -1,118 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
|
-
exports
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const contexts_1 = require("../../common/contexts");
|
|
9
|
+
const utils_1 = require("../../common/utils");
|
|
10
|
+
const types_1 = require("../../types");
|
|
11
|
+
const cameraCapture_1 = __importDefault(require("./cameraCapture"));
|
|
48
12
|
function blobToBase64(blob) {
|
|
49
|
-
return new Promise(
|
|
13
|
+
return new Promise((resolve, _) => {
|
|
50
14
|
// we can safely assume the type of reader.result is string
|
|
51
15
|
// because we're calling reader.readAsDataURL
|
|
52
16
|
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
|
|
53
|
-
|
|
17
|
+
const reader = new FileReader();
|
|
54
18
|
// eslint-disable-next-line fp/no-mutation
|
|
55
|
-
reader.onloadend =
|
|
19
|
+
reader.onloadend = () => resolve(reader.result);
|
|
56
20
|
reader.readAsDataURL(blob);
|
|
57
21
|
});
|
|
58
22
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
23
|
+
const CameraStep = (props) => {
|
|
24
|
+
const { step, model, onModelChange, onAction } = props;
|
|
25
|
+
const onEvent = (0, contexts_1.useEventDispatcher)();
|
|
26
|
+
const objectSchema = getObjectSchema(step);
|
|
27
|
+
const cameraSchema = getCameraSchema(step);
|
|
28
|
+
const action = getFirstAction(step);
|
|
29
|
+
const { title, image, cameraConfig } = cameraSchema;
|
|
30
|
+
const { assets, direction, instructions } = cameraConfig || {};
|
|
31
|
+
const { overlay, outline } = assets || {};
|
|
32
|
+
const { url: imageUrl } = image || {};
|
|
33
|
+
const [captureClicked, setCaptureClicked] = (0, react_1.useState)(false);
|
|
70
34
|
// We need to wait for model to update before we call onAction()
|
|
71
|
-
(0, react_1.useEffect)(
|
|
35
|
+
(0, react_1.useEffect)(() => {
|
|
72
36
|
if (captureClicked) {
|
|
73
37
|
onAction(action);
|
|
74
38
|
}
|
|
75
39
|
}, [model]);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
formSchema: objectSchema,
|
|
92
|
-
triggerModel: newValue,
|
|
93
|
-
triggerSchema: cameraSchema
|
|
94
|
-
});
|
|
95
|
-
_b.label = 2;
|
|
96
|
-
case 2: return [2 /*return*/];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}); };
|
|
100
|
-
return ((0, jsx_runtime_1.jsx)(cameraCapture_1["default"], { overlay: overlay, outline: outline, title: title, imageUrl: imageUrl, instructions: instructions, direction: direction, onEvent: onEvent, onCapture: function (blob) {
|
|
40
|
+
const handleCapture = async (blob) => {
|
|
41
|
+
const { $id } = cameraSchema;
|
|
42
|
+
if (blob) {
|
|
43
|
+
const newValue = await blobToBase64(blob);
|
|
44
|
+
const newModel = { [$id || '']: newValue };
|
|
45
|
+
setCaptureClicked(true);
|
|
46
|
+
onModelChange({
|
|
47
|
+
model: newModel,
|
|
48
|
+
formSchema: objectSchema,
|
|
49
|
+
triggerModel: newValue,
|
|
50
|
+
triggerSchema: cameraSchema,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(cameraCapture_1.default, { overlay: overlay, outline: outline, title: title, imageUrl: imageUrl, instructions: instructions, direction: direction, onEvent: onEvent, onCapture: (blob) => {
|
|
101
55
|
void handleCapture(blob);
|
|
102
56
|
} }));
|
|
103
57
|
};
|
|
104
|
-
exports
|
|
58
|
+
exports.default = CameraStep;
|
|
105
59
|
function getObjectSchema(step) {
|
|
106
|
-
|
|
107
|
-
|
|
60
|
+
const nonHiddenSchemas = (0, utils_1.filterHiddenSchemas)(step.schemas || []);
|
|
61
|
+
const objectSchema = nonHiddenSchemas[0];
|
|
108
62
|
if (!objectSchema || !(0, types_1.isObjectSchema)(objectSchema)) {
|
|
109
63
|
throw new Error('The first schema in a camera step is expected to be of type object and have at least one property with a schema...');
|
|
110
64
|
}
|
|
111
65
|
return objectSchema;
|
|
112
66
|
}
|
|
113
67
|
function getCameraSchema(step) {
|
|
114
|
-
|
|
115
|
-
|
|
68
|
+
const objectSchema = getObjectSchema(step);
|
|
69
|
+
const firstProperty = Object.values(objectSchema.properties)[0];
|
|
116
70
|
if (!firstProperty) {
|
|
117
71
|
throw new Error('The first schema in a camera step is expected to be of type object and have at least one property with a schema...');
|
|
118
72
|
}
|
|
@@ -1,104 +1,47 @@
|
|
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
4
|
};
|
|
52
|
-
exports
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var handleCapture = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
-
var canvas;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const react_webcam_1 = __importDefault(require("react-webcam"));
|
|
10
|
+
const CameraCapture_messages_1 = __importDefault(require("./CameraCapture.messages"));
|
|
11
|
+
const components_1 = require("./components");
|
|
12
|
+
const hooks_1 = require("./hooks");
|
|
13
|
+
const Overlay_1 = __importDefault(require("./overlay/Overlay"));
|
|
14
|
+
const screens_1 = require("./screens");
|
|
15
|
+
const tracking_1 = require("./tracking");
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
const CameraCapture = ({ direction = 'back', overlay = '', outline = '', imageUrl = '', title = '', instructions = '', showReview = false, onCapture, onEvent, }) => {
|
|
18
|
+
const [mode, setMode] = (0, react_1.useState)('CAPTURE');
|
|
19
|
+
const [isVideoMirrored, setIsVideoMirrored] = (0, react_1.useState)(false);
|
|
20
|
+
const [ready, setReady] = (0, react_1.useState)(false);
|
|
21
|
+
const [reviewImage, setReviewImage] = (0, react_1.useState)();
|
|
22
|
+
const webcamReference = (0, react_1.useRef)(null);
|
|
23
|
+
const { videoConstraints } = (0, hooks_1.useVideoConstraints)(direction);
|
|
24
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
25
|
+
const handleCapture = (0, react_1.useCallback)(async () => {
|
|
75
26
|
var _a, _b, _c, _d, _e, _f;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
}, 'image/jpeg', 0.92);
|
|
96
|
-
_g.label = 2;
|
|
97
|
-
case 2: return [2 /*return*/];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}); }, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
|
|
101
|
-
var handleUserMediaError = (0, react_1.useCallback)(function (error) {
|
|
27
|
+
if (((_a = webcamReference === null || webcamReference === void 0 ? void 0 : webcamReference.current) === null || _a === void 0 ? void 0 : _a.video) && ((_c = (_b = webcamReference === null || webcamReference === void 0 ? void 0 : webcamReference.current) === null || _b === void 0 ? void 0 : _b.video) === null || _c === void 0 ? void 0 : _c.readyState) >= 3) {
|
|
28
|
+
(_e = (_d = webcamReference === null || webcamReference === void 0 ? void 0 : webcamReference.current) === null || _d === void 0 ? void 0 : _d.video) === null || _e === void 0 ? void 0 : _e.pause();
|
|
29
|
+
const canvas = await (0, utils_1.generateCanvasFromVideo)((_f = webcamReference === null || webcamReference === void 0 ? void 0 : webcamReference.current) === null || _f === void 0 ? void 0 : _f.video);
|
|
30
|
+
canvas === null || canvas === void 0 ? void 0 : canvas.toBlob((blob) => {
|
|
31
|
+
if (blob) {
|
|
32
|
+
if (showReview) {
|
|
33
|
+
const source = window.URL.createObjectURL(blob);
|
|
34
|
+
setReviewImage({ source, blob });
|
|
35
|
+
setMode('REVIEW');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
onCapture(blob);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}, 'image/jpeg', 0.92);
|
|
42
|
+
}
|
|
43
|
+
}, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
|
|
44
|
+
const handleUserMediaError = (0, react_1.useCallback)((error) => {
|
|
102
45
|
if (error instanceof DOMException && (error === null || error === void 0 ? void 0 : error.name) === 'NotAllowedError') {
|
|
103
46
|
setMode('NO_CAMERA_ACCESS');
|
|
104
47
|
(0, tracking_1.trackCameraPermissionDenied)(onEvent);
|
|
@@ -107,21 +50,21 @@ var CameraCapture = function (_a) {
|
|
|
107
50
|
setMode('CAMERA_NOT_SUPPORTED');
|
|
108
51
|
(0, tracking_1.trackCameraNotSupported)(onEvent, error);
|
|
109
52
|
}, [setMode, onEvent]);
|
|
110
|
-
|
|
53
|
+
const handleUserMedia = (0, react_1.useCallback)((stream) => {
|
|
111
54
|
setReady(true);
|
|
112
55
|
setIsVideoMirrored((0, utils_1.isSelfieCamera)(stream));
|
|
113
|
-
void (0, tracking_1.trackCameraFeedStarted)(onEvent, { direction
|
|
56
|
+
void (0, tracking_1.trackCameraFeedStarted)(onEvent, { direction }, stream);
|
|
114
57
|
}, [setIsVideoMirrored, onEvent, direction]);
|
|
115
|
-
|
|
58
|
+
const handleReviewSubmit = () => {
|
|
116
59
|
onCapture((reviewImage === null || reviewImage === void 0 ? void 0 : reviewImage.blob) || null);
|
|
117
60
|
};
|
|
118
|
-
|
|
61
|
+
const handleReviewRetry = () => {
|
|
119
62
|
setMode('CAPTURE');
|
|
120
63
|
setReviewImage(undefined);
|
|
121
64
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return ((0, jsx_runtime_1.jsxs)("section",
|
|
65
|
+
const handleRetryCameraAccess = () => setMode('CAPTURE');
|
|
66
|
+
const captureScreen = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [videoConstraints && ((0, jsx_runtime_1.jsx)(react_webcam_1.default, { ref: webcamReference, audio: false, videoConstraints: videoConstraints, mirrored: isVideoMirrored, onUserMediaError: handleUserMediaError, onUserMedia: handleUserMedia })), (0, jsx_runtime_1.jsx)(Overlay_1.default, { overlay: overlay, outline: outline, imageUrl: imageUrl, title: title, instructions: instructions }), ready && (0, jsx_runtime_1.jsx)(components_1.CaptureBottomBar, { onCapture: () => void handleCapture() })] }));
|
|
67
|
+
const reviewScreen = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { className: "review-image", src: reviewImage === null || reviewImage === void 0 ? void 0 : reviewImage.source, alt: "" }), (0, jsx_runtime_1.jsx)(Overlay_1.default, { overlay: overlay, imageUrl: imageUrl, title: title, instructions: instructions, reviewInstructions: intl.formatMessage(CameraCapture_messages_1.default.reviewInstructions) }), (0, jsx_runtime_1.jsx)(components_1.ReviewBottomBar, { onSubmit: handleReviewSubmit, onRetry: handleReviewRetry })] }));
|
|
68
|
+
return ((0, jsx_runtime_1.jsxs)("section", Object.assign({ className: "camera-capture" }, { children: [mode === 'CAPTURE' && captureScreen, mode === 'REVIEW' && reviewScreen, mode === 'NO_CAMERA_ACCESS' && (0, jsx_runtime_1.jsx)(screens_1.NoCameraAccess, { onAction: handleRetryCameraAccess }), mode === 'CAMERA_NOT_SUPPORTED' && (0, jsx_runtime_1.jsx)(screens_1.CameraNotSupported, {})] })));
|
|
126
69
|
};
|
|
127
|
-
exports
|
|
70
|
+
exports.default = CameraCapture;
|
|
@@ -1,20 +1,20 @@
|
|
|
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
|
reviewSubmit: {
|
|
6
6
|
id: 'dynamicFlows.CameraCapture.reviewSubmit',
|
|
7
7
|
defaultMessage: 'Yes, submit',
|
|
8
|
-
description: 'Accept and submit the image taken with the camera'
|
|
8
|
+
description: 'Accept and submit the image taken with the camera',
|
|
9
9
|
},
|
|
10
10
|
reviewRetry: {
|
|
11
11
|
id: 'dynamicFlows.CameraCapture.reviewRetry',
|
|
12
12
|
defaultMessage: 'No, try again',
|
|
13
|
-
description: "Image taken with camera is not good, don't submit, and retake the image"
|
|
13
|
+
description: "Image taken with camera is not good, don't submit, and retake the image",
|
|
14
14
|
},
|
|
15
15
|
reviewInstructions: {
|
|
16
16
|
id: 'dynamicFlows.CameraCapture.reviewInstructions',
|
|
17
17
|
defaultMessage: 'Is your picture clear, readable and complete?',
|
|
18
|
-
description: 'After taking an image with the camera, prompt user to review the image'
|
|
19
|
-
}
|
|
18
|
+
description: 'After taking an image with the camera, prompt user to review the image',
|
|
19
|
+
},
|
|
20
20
|
});
|
|
@@ -1,36 +1,18 @@
|
|
|
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
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
6
|
exports.ReviewBottomBar = exports.CaptureBottomBar = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var onCapture = _a.onCapture;
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)("div", __assign({ className: "bottom-bar" }, { children: (0, jsx_runtime_1.jsx)(CaptureButton, { onClick: onCapture }) })));
|
|
25
|
-
};
|
|
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 CameraCapture_messages_1 = __importDefault(require("../CameraCapture.messages"));
|
|
11
|
+
const CaptureBottomBar = ({ onCapture }) => ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "bottom-bar" }, { children: (0, jsx_runtime_1.jsx)(CaptureButton, { onClick: onCapture }) })));
|
|
26
12
|
exports.CaptureBottomBar = CaptureBottomBar;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return ((0, jsx_runtime_1.jsx)("div", __assign({ className: "bottom-bar p-x-2" }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ className: "row" }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ className: "col-xs-12 col-md-6 col-md-offset-3" }, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, __assign({ className: "m-b-1", block: true, size: components_1.Size.MEDIUM, type: components_1.ControlType.ACCENT, onClick: onSubmit }, { children: intl.formatMessage(CameraCapture_messages_1["default"].reviewSubmit) })), (0, jsx_runtime_1.jsx)(components_1.Button, __assign({ className: "m-b-2", block: true, size: components_1.Size.MEDIUM, type: components_1.ControlType.ACCENT, priority: components_1.Priority.SECONDARY, onClick: onRetry }, { children: intl.formatMessage(CameraCapture_messages_1["default"].reviewRetry) }))] })) })) })));
|
|
13
|
+
const ReviewBottomBar = ({ onSubmit, onRetry, }) => {
|
|
14
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "bottom-bar p-x-2" }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "row" }, { children: (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "col-xs-12 col-md-6 col-md-offset-3" }, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, Object.assign({ className: "m-b-1", block: true, size: components_1.Size.MEDIUM, type: components_1.ControlType.ACCENT, onClick: onSubmit }, { children: intl.formatMessage(CameraCapture_messages_1.default.reviewSubmit) })), (0, jsx_runtime_1.jsx)(components_1.Button, Object.assign({ className: "m-b-2", block: true, size: components_1.Size.MEDIUM, type: components_1.ControlType.ACCENT, priority: components_1.Priority.SECONDARY, onClick: onRetry }, { children: intl.formatMessage(CameraCapture_messages_1.default.reviewRetry) }))] })) })) })));
|
|
31
16
|
};
|
|
32
17
|
exports.ReviewBottomBar = ReviewBottomBar;
|
|
33
|
-
|
|
34
|
-
var onClick = _a.onClick;
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)("button", __assign({ type: "button", className: "camera-capture-btn m-b-2", "data-testid": "camera-capture-button", onClick: onClick }, { children: (0, jsx_runtime_1.jsx)("span", { className: "camera-capture-btn-inner" }) })));
|
|
36
|
-
};
|
|
18
|
+
const CaptureButton = ({ onClick }) => ((0, jsx_runtime_1.jsx)("button", Object.assign({ type: "button", className: "camera-capture-btn m-b-2", "data-testid": "camera-capture-button", onClick: onClick }, { children: (0, jsx_runtime_1.jsx)("span", { className: "camera-capture-btn-inner" }) })));
|