@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.
Files changed (233) hide show
  1. package/build/common/constants/DateMode.js +2 -2
  2. package/build/common/constants/FormControlType.js +2 -2
  3. package/build/common/constants/MonthFormat.js +2 -2
  4. package/build/common/constants/SchemaType.js +2 -2
  5. package/build/common/constants/Size.js +2 -2
  6. package/build/common/constants/index.js +1 -1
  7. package/build/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +15 -27
  8. package/build/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +11 -9
  9. package/build/common/contexts/eventsContext/EventsContext.js +11 -28
  10. package/build/common/contexts/fetcherContexts/FetcherContexts.js +14 -27
  11. package/build/common/contexts/index.js +1 -1
  12. package/build/common/contexts/logContext/LogContext.js +12 -30
  13. package/build/common/hooks/index.js +1 -1
  14. package/build/common/hooks/useDebouncedFunction/useDebouncedFunction.js +3 -3
  15. package/build/common/hooks/useExternal/useExternal.js +8 -8
  16. package/build/common/hooks/useExternalStepPolling/useExternalStepPolling.js +20 -31
  17. package/build/common/hooks/usePersistAsync/usePersistAsync.js +60 -139
  18. package/build/common/hooks/usePolling/usePolling.js +20 -21
  19. package/build/common/hooks/usePrevious/usePrevious.js +5 -5
  20. package/build/common/hooks/useStepPolling/useStepPolling.js +15 -14
  21. package/build/common/makeFetcher/index.js +1 -1
  22. package/build/common/makeFetcher/makeFetcher.js +10 -24
  23. package/build/common/messages.js +5 -5
  24. package/build/common/utils/api-utils.js +3 -4
  25. package/build/common/utils/date-utils.js +11 -11
  26. package/build/common/utils/debounce.js +11 -15
  27. package/build/common/utils/file-utils.js +12 -25
  28. package/build/common/utils/id-utils.js +4 -5
  29. package/build/common/utils/index.js +1 -1
  30. package/build/common/utils/is-equal.js +8 -8
  31. package/build/common/utils/schema-utils.js +6 -6
  32. package/build/common/utils/step-utils.js +14 -14
  33. package/build/common/validators/index.js +7 -7
  34. package/build/common/validators/models/model-validators.js +8 -8
  35. package/build/common/validators/models/models.utils.js +29 -42
  36. package/build/common/validators/schemas/schema-validators.js +11 -13
  37. package/build/common/validators/types/type-validators.js +9 -13
  38. package/build/common/validators/validationFailures/validation-failures.js +14 -14
  39. package/build/common/validators/validationFailures/validation-failures.utils.js +5 -7
  40. package/build/common/validators/values/value-validators.js +4 -6
  41. package/build/dynamicFlow/DynamicFlow.js +185 -307
  42. package/build/dynamicFlow/DynamicFlowStep.js +12 -23
  43. package/build/dynamicFlow/DynamicFlowTypes.js +1 -1
  44. package/build/dynamicFlow/index.js +6 -14
  45. package/build/dynamicFlow/stories/DynamicFlow.story.js +20 -20
  46. package/build/dynamicFlow/stories/EditableDynamicFlow.js +20 -33
  47. package/build/dynamicFlow/stories/fixtureFetcher.js +46 -104
  48. package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.js +22 -40
  49. package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.js +6 -6
  50. package/build/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.js +10 -11
  51. package/build/dynamicFlow/utils/index.js +5 -2
  52. package/build/dynamicFlow/utils/responseParsers/response-parsers.js +53 -118
  53. package/build/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +9 -9
  54. package/build/dynamicFlow/utils/useDynamicFlowState.js +51 -74
  55. package/build/dynamicFlow/utils/useLoader.js +9 -20
  56. package/build/fixtures/components/alert.js +8 -8
  57. package/build/fixtures/components/box.js +7 -7
  58. package/build/fixtures/components/button.js +25 -36
  59. package/build/fixtures/components/columns.js +10 -10
  60. package/build/fixtures/components/copyable.js +6 -6
  61. package/build/fixtures/components/decision.js +15 -15
  62. package/build/fixtures/components/heading.js +7 -7
  63. package/build/fixtures/components/image.js +10 -10
  64. package/build/fixtures/components/index.js +17 -25
  65. package/build/fixtures/components/info.js +22 -6
  66. package/build/fixtures/components/list.js +8 -8
  67. package/build/fixtures/components/loading-indicator.js +5 -5
  68. package/build/fixtures/components/paragraph.js +9 -9
  69. package/build/fixtures/components/review.js +11 -11
  70. package/build/fixtures/examples/camera-capture.js +29 -29
  71. package/build/fixtures/examples/index.js +9 -17
  72. package/build/fixtures/examples/recipient-update.js +69 -69
  73. package/build/fixtures/examples/recipient.js +63 -63
  74. package/build/fixtures/examples/single-file-upload.js +21 -21
  75. package/build/fixtures/examples/step-validation-errors.js +21 -21
  76. package/build/fixtures/features/action-response.js +8 -8
  77. package/build/fixtures/features/external.js +8 -8
  78. package/build/fixtures/features/index.js +9 -17
  79. package/build/fixtures/features/persist-async.js +11 -11
  80. package/build/fixtures/features/polling.js +9 -9
  81. package/build/fixtures/features/validation-async.js +10 -10
  82. package/build/fixtures/index.js +11 -22
  83. package/build/fixtures/jsonSchemaForm/allOf.js +30 -30
  84. package/build/fixtures/jsonSchemaForm/audRecipient.js +271 -271
  85. package/build/fixtures/jsonSchemaForm/currency.js +12 -12
  86. package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.js +11 -11
  87. package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.js +11 -11
  88. package/build/fixtures/jsonSchemaForm/oneOf.js +27 -27
  89. package/build/fixtures/jsonSchemaForm/oneOfTabs.js +16 -16
  90. package/build/fixtures/jsonSchemaForm/promotedOneOf.js +17 -17
  91. package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.js +30 -30
  92. package/build/fixtures/jsonSchemaForm/simple.js +16 -16
  93. package/build/fixtures/jsonSchemaForm/uploadPersistAsync.js +19 -19
  94. package/build/fixtures/jsonSchemaForm/validationAsync.js +8 -8
  95. package/build/fixtures/layouts/all.js +37 -37
  96. package/build/fixtures/layouts/final-step-layout.js +9 -9
  97. package/build/fixtures/layouts/index.js +10 -18
  98. package/build/fixtures/layouts/list.js +10 -10
  99. package/build/fixtures/layouts/pay-in.js +23 -23
  100. package/build/fixtures/layouts/review.js +38 -38
  101. package/build/fixtures/layouts/success.js +15 -15
  102. package/build/fixtures/responses/action-response-final.js +8 -8
  103. package/build/fixtures/responses/action.js +3 -3
  104. package/build/fixtures/responses/exit.js +3 -3
  105. package/build/fixtures/responses/index.js +8 -16
  106. package/build/fixtures/responses/recipient-update-final.js +8 -8
  107. package/build/fixtures/schemas/basic-form.js +11 -11
  108. package/build/fixtures/schemas/index.js +8 -16
  109. package/build/fixtures/schemas/number-and-integer.js +11 -11
  110. package/build/fixtures/schemas/one-of.js +43 -46
  111. package/build/fixtures/schemas/string-formats.js +15 -15
  112. package/build/fixtures/utils/image-util.js +8 -8
  113. package/build/formControl/FormControl.js +118 -148
  114. package/build/formControl/index.js +6 -14
  115. package/build/formControl/utils/index.js +1 -1
  116. package/build/formControl/utils/value-utils.js +18 -23
  117. package/build/i18n/index.js +31 -31
  118. package/build/index.js +13 -10
  119. package/build/jsonSchemaForm/JsonSchemaForm.js +12 -24
  120. package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +24 -37
  121. package/build/jsonSchemaForm/allOfSchema/index.js +6 -14
  122. package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +9 -20
  123. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +9 -20
  124. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +6 -14
  125. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +56 -115
  126. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +7 -7
  127. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +6 -14
  128. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +1 -1
  129. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +19 -71
  130. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +10 -11
  131. package/build/jsonSchemaForm/arrayTypeSchema/index.js +6 -14
  132. package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +45 -62
  133. package/build/jsonSchemaForm/basicTypeSchema/index.js +6 -14
  134. package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +39 -50
  135. package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +18 -18
  136. package/build/jsonSchemaForm/controlFeedback/index.js +6 -14
  137. package/build/jsonSchemaForm/genericSchema/GenericSchema.js +52 -61
  138. package/build/jsonSchemaForm/genericSchema/index.js +6 -14
  139. package/build/jsonSchemaForm/help/Help.js +9 -9
  140. package/build/jsonSchemaForm/help/Help.messages.js +5 -5
  141. package/build/jsonSchemaForm/help/index.js +6 -14
  142. package/build/jsonSchemaForm/index.js +6 -14
  143. package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +28 -49
  144. package/build/jsonSchemaForm/objectSchema/index.js +6 -14
  145. package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +54 -74
  146. package/build/jsonSchemaForm/oneOfSchema/index.js +6 -14
  147. package/build/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.js +3 -3
  148. package/build/jsonSchemaForm/oneOfSchema/utils/index.js +1 -1
  149. package/build/jsonSchemaForm/oneOfSchema/utils/one-of-utils.js +19 -20
  150. package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +11 -22
  151. package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +5 -5
  152. package/build/jsonSchemaForm/persistAsyncSchema/index.js +6 -14
  153. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +73 -127
  154. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +6 -14
  155. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +45 -110
  156. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +17 -17
  157. package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +6 -14
  158. package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +28 -47
  159. package/build/jsonSchemaForm/promotedOneOfSchema/index.js +6 -14
  160. package/build/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +4 -4
  161. package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +13 -24
  162. package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +11 -22
  163. package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +12 -23
  164. package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +24 -26
  165. package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +6 -6
  166. package/build/jsonSchemaForm/readOnlySchema/index.js +6 -14
  167. package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +26 -39
  168. package/build/jsonSchemaForm/schemaFormControl/index.js +6 -14
  169. package/build/jsonSchemaForm/schemaFormControl/utils/currency-utils.js +5 -5
  170. package/build/jsonSchemaForm/schemaFormControl/utils/index.js +1 -1
  171. package/build/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +30 -47
  172. package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +57 -119
  173. package/build/jsonSchemaForm/validationAsyncSchema/index.js +6 -14
  174. package/build/layout/DynamicLayout.js +10 -21
  175. package/build/layout/alert/DynamicAlert.js +9 -9
  176. package/build/layout/box/DynamicBox.js +12 -23
  177. package/build/layout/button/DynamicButton.js +16 -27
  178. package/build/layout/columns/DynamicColumns.js +13 -24
  179. package/build/layout/decision/DynamicDecision.js +16 -27
  180. package/build/layout/divider/DynamicDivider.js +7 -8
  181. package/build/layout/external/DynamicExternal.js +16 -28
  182. package/build/layout/external/DynamicExternal.messages.js +5 -5
  183. package/build/layout/form/DynamicForm.js +10 -21
  184. package/build/layout/heading/DynamicHeading.js +12 -23
  185. package/build/layout/icon/DynamicIcon.js +9 -10
  186. package/build/layout/image/DynamicImage.js +43 -93
  187. package/build/layout/index.js +21 -29
  188. package/build/layout/info/DynamicInfo.js +7 -19
  189. package/build/layout/list/DynamicList.js +14 -26
  190. package/build/layout/loadingIndicator/DynamicLoadingIndicator.js +8 -9
  191. package/build/layout/paragraph/DynamicParagraph.js +19 -37
  192. package/build/layout/paragraph/DynamicParagraph.messages.js +6 -6
  193. package/build/layout/paragraph/useSnackBarIfAvailable.js +4 -4
  194. package/build/layout/review/DynamicReview.js +14 -26
  195. package/build/layout/utils.js +4 -6
  196. package/build/step/cameraStep/CameraStep.js +42 -88
  197. package/build/step/cameraStep/cameraCapture/CameraCapture.js +48 -105
  198. package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +7 -7
  199. package/build/step/cameraStep/cameraCapture/components/index.js +10 -28
  200. package/build/step/cameraStep/cameraCapture/hooks/index.js +17 -72
  201. package/build/step/cameraStep/cameraCapture/index.js +6 -14
  202. package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +33 -45
  203. package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +8 -19
  204. package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +6 -6
  205. package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +9 -21
  206. package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +7 -7
  207. package/build/step/cameraStep/cameraCapture/screens/index.js +6 -14
  208. package/build/step/cameraStep/cameraCapture/tracking/index.js +17 -99
  209. package/build/step/cameraStep/cameraCapture/utils/index.js +33 -96
  210. package/build/step/cameraStep/index.js +6 -14
  211. package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +20 -21
  212. package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +8 -8
  213. package/build/step/externalConfirmationStep/index.js +6 -14
  214. package/build/step/index.js +7 -15
  215. package/build/step/layoutStep/LayoutStep.js +19 -19
  216. package/build/step/layoutStep/index.js +6 -14
  217. package/build/step/layoutStep/utils/index.js +3 -14
  218. package/build/step/layoutStep/utils/inline-reference-utils.js +29 -46
  219. package/build/step/layoutStep/utils/layout-utils.js +34 -53
  220. package/build/types/common/FormControl.js +1 -1
  221. package/build/types/index.js +13 -13
  222. package/build/types/specification/Action.js +1 -1
  223. package/build/types/specification/FileUploadSchema.js +1 -1
  224. package/build/types/specification/LayoutComponent.js +1 -1
  225. package/build/types/specification/Model.js +9 -17
  226. package/build/types/specification/PersistAsync.js +1 -1
  227. package/build/types/specification/Polling.js +1 -1
  228. package/build/types/specification/Promotion.js +1 -1
  229. package/build/types/specification/Schema.js +8 -8
  230. package/build/types/specification/Step.js +3 -5
  231. package/build/types/specification/ValidationAsync.js +1 -1
  232. package/build/types/specification/core.js +1 -1
  233. 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.__esModule = true;
17
- var jsx_runtime_1 = require("react/jsx-runtime");
18
- var components_1 = require("@transferwise/components");
19
- var react_intl_1 = require("react-intl");
20
- var utils_1 = require("../utils");
21
- var DynamicParagraph_messages_1 = __importDefault(require("./DynamicParagraph.messages"));
22
- var useSnackBarIfAvailable_1 = require("./useSnackBarIfAvailable");
23
- var DynamicParagraph = function (_a) {
24
- var component = _a.component;
25
- return component.control === 'copyable' ? ((0, jsx_runtime_1.jsx)(CopyableDynamicParagraph, { component: component })) : ((0, jsx_runtime_1.jsx)(BasicDynamicParagraph, { component: component }));
26
- };
27
- var BasicDynamicParagraph = function (_a) {
28
- var component = _a.component;
29
- return ((0, jsx_runtime_1.jsxs)("p", __assign({ className: (0, utils_1.getTextAlignmentAndMargin)(component) }, { children: [" ", component.text, " "] })));
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(function () { return createSnackbar({ text: formatMessage(DynamicParagraph_messages_1["default"].copied) }); })["catch"](noop);
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
- var classNames = (0, utils_1.getTextAlignmentAndMargin)({ align: component.align, margin: 'sm' }) + ' form-control';
41
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: (0, utils_1.getTextAlignmentAndMargin)(component) }, { children: [(0, jsx_runtime_1.jsx)("input", { type: "text", className: classNames, value: text, readOnly: true,
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, __assign({ block: true, onClick: copy }, { children: formatMessage(DynamicParagraph_messages_1["default"].copy) }))] })));
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["default"] = DynamicParagraph;
30
+ exports.default = DynamicParagraph;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var react_intl_1 = require("react-intl");
4
- exports["default"] = (0, react_intl_1.defineMessages)({
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.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSnackBarIfAvailable = void 0;
4
- var components_1 = require("@transferwise/components");
5
- var react_1 = require("react");
4
+ const components_1 = require("@transferwise/components");
5
+ const react_1 = require("react");
6
6
  function useSnackBarIfAvailable() {
7
- var context = (0, react_1.useContext)(components_1.SnackbarContext);
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
- 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
- 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
- var getReviewLayout = function (orientation) {
9
+ const getReviewLayout = (orientation) => {
22
10
  return orientation === 'horizontal' ? 'HORIZONTAL_RIGHT_ALIGNED' : 'VERTICAL_ONE_COLUMN';
23
11
  };
24
- var DynamicReview = function (props) {
25
- var review = props.component;
26
- var margin = (0, utils_1.getMarginBottom)(review.margin || 'xs');
27
- var getReviewAction = function (action) {
28
- return ((0, jsx_runtime_1.jsx)("a", __assign({ href: action.url, className: "pull-right", role: "button", onClick: function (event) {
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", __assign({ className: "m-b-2" }, { children: [review.title, review.action && getReviewAction(review.action)] }))), (0, jsx_runtime_1.jsx)("div", __assign({ className: margin }, { children: (0, jsx_runtime_1.jsx)(components_1.DefinitionList, { layout: getReviewLayout(review.orientation), definitions: review.fields.map(mapFieldsToDefinitions) }) }))] }));
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["default"] = DynamicReview;
23
+ exports.default = DynamicReview;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTextAlignmentAndMargin = exports.getMarginBottom = void 0;
4
- var getMarginBottom = function (size) {
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
- var getTextAlignment = function (align) {
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
- var getTextAlignmentAndMargin = function (component) {
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.__esModule = true;
42
- var jsx_runtime_1 = require("react/jsx-runtime");
43
- var react_1 = require("react");
44
- var contexts_1 = require("../../common/contexts");
45
- var utils_1 = require("../../common/utils");
46
- var types_1 = require("../../types");
47
- var cameraCapture_1 = __importDefault(require("./cameraCapture"));
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(function (resolve, _) {
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
- var reader = new FileReader();
17
+ const reader = new FileReader();
54
18
  // eslint-disable-next-line fp/no-mutation
55
- reader.onloadend = function () { return resolve(reader.result); };
19
+ reader.onloadend = () => resolve(reader.result);
56
20
  reader.readAsDataURL(blob);
57
21
  });
58
22
  }
59
- var CameraStep = function (props) {
60
- var step = props.step, model = props.model, onModelChange = props.onModelChange, onAction = props.onAction;
61
- var onEvent = (0, contexts_1.useEventDispatcher)();
62
- var objectSchema = getObjectSchema(step);
63
- var cameraSchema = getCameraSchema(step);
64
- var action = getFirstAction(step);
65
- var title = cameraSchema.title, image = cameraSchema.image, cameraConfig = cameraSchema.cameraConfig;
66
- var _a = cameraConfig || {}, assets = _a.assets, direction = _a.direction, instructions = _a.instructions;
67
- var _b = assets || {}, overlay = _b.overlay, outline = _b.outline;
68
- var imageUrl = (image || {}).url;
69
- var _c = (0, react_1.useState)(false), captureClicked = _c[0], setCaptureClicked = _c[1];
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)(function () {
35
+ (0, react_1.useEffect)(() => {
72
36
  if (captureClicked) {
73
37
  onAction(action);
74
38
  }
75
39
  }, [model]);
76
- var handleCapture = function (blob) { return __awaiter(void 0, void 0, void 0, function () {
77
- var $id, newValue, newModel;
78
- var _a;
79
- return __generator(this, function (_b) {
80
- switch (_b.label) {
81
- case 0:
82
- $id = cameraSchema.$id;
83
- if (!blob) return [3 /*break*/, 2];
84
- return [4 /*yield*/, blobToBase64(blob)];
85
- case 1:
86
- newValue = _b.sent();
87
- newModel = (_a = {}, _a[$id || ''] = newValue, _a);
88
- setCaptureClicked(true);
89
- onModelChange({
90
- model: newModel,
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["default"] = CameraStep;
58
+ exports.default = CameraStep;
105
59
  function getObjectSchema(step) {
106
- var nonHiddenSchemas = (0, utils_1.filterHiddenSchemas)(step.schemas || []);
107
- var objectSchema = nonHiddenSchemas[0];
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
- var objectSchema = getObjectSchema(step);
115
- var firstProperty = Object.values(objectSchema.properties)[0];
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.__esModule = true;
53
- var jsx_runtime_1 = require("react/jsx-runtime");
54
- var react_1 = require("react");
55
- var react_intl_1 = require("react-intl");
56
- var react_webcam_1 = __importDefault(require("react-webcam"));
57
- var CameraCapture_messages_1 = __importDefault(require("./CameraCapture.messages"));
58
- var components_1 = require("./components");
59
- var hooks_1 = require("./hooks");
60
- var Overlay_1 = __importDefault(require("./overlay/Overlay"));
61
- var screens_1 = require("./screens");
62
- var tracking_1 = require("./tracking");
63
- var utils_1 = require("./utils");
64
- var CameraCapture = function (_a) {
65
- 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;
66
- var _j = (0, react_1.useState)('CAPTURE'), mode = _j[0], setMode = _j[1];
67
- var _k = (0, react_1.useState)(false), isVideoMirrored = _k[0], setIsVideoMirrored = _k[1];
68
- var _l = (0, react_1.useState)(false), ready = _l[0], setReady = _l[1];
69
- var _m = (0, react_1.useState)(), reviewImage = _m[0], setReviewImage = _m[1];
70
- var webcamReference = (0, react_1.useRef)(null);
71
- var videoConstraints = (0, hooks_1.useVideoConstraints)(direction).videoConstraints;
72
- var intl = (0, react_intl_1.useIntl)();
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
- return __generator(this, function (_g) {
77
- switch (_g.label) {
78
- case 0:
79
- 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)) return [3 /*break*/, 2];
80
- (_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();
81
- return [4 /*yield*/, (0, utils_1.generateCanvasFromVideo)((_f = webcamReference === null || webcamReference === void 0 ? void 0 : webcamReference.current) === null || _f === void 0 ? void 0 : _f.video)];
82
- case 1:
83
- canvas = _g.sent();
84
- canvas === null || canvas === void 0 ? void 0 : canvas.toBlob(function (blob) {
85
- if (blob) {
86
- if (showReview) {
87
- var source = window.URL.createObjectURL(blob);
88
- setReviewImage({ source: source, blob: blob });
89
- setMode('REVIEW');
90
- }
91
- else {
92
- onCapture(blob);
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
- var handleUserMedia = (0, react_1.useCallback)(function (stream) {
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: direction }, stream);
56
+ void (0, tracking_1.trackCameraFeedStarted)(onEvent, { direction }, stream);
114
57
  }, [setIsVideoMirrored, onEvent, direction]);
115
- var handleReviewSubmit = function () {
58
+ const handleReviewSubmit = () => {
116
59
  onCapture((reviewImage === null || reviewImage === void 0 ? void 0 : reviewImage.blob) || null);
117
60
  };
118
- var handleReviewRetry = function () {
61
+ const handleReviewRetry = () => {
119
62
  setMode('CAPTURE');
120
63
  setReviewImage(undefined);
121
64
  };
122
- var handleRetryCameraAccess = function () { return setMode('CAPTURE'); };
123
- var 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: function () { return void handleCapture(); } })] }));
124
- var 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 })] }));
125
- return ((0, jsx_runtime_1.jsxs)("section", __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, {})] })));
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["default"] = CameraCapture;
70
+ exports.default = CameraCapture;
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var react_intl_1 = require("react-intl");
4
- exports["default"] = (0, react_intl_1.defineMessages)({
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.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
17
6
  exports.ReviewBottomBar = exports.CaptureBottomBar = void 0;
18
- var jsx_runtime_1 = require("react/jsx-runtime");
19
- var components_1 = require("@transferwise/components");
20
- var react_intl_1 = require("react-intl");
21
- var CameraCapture_messages_1 = __importDefault(require("../CameraCapture.messages"));
22
- var CaptureBottomBar = function (_a) {
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
- var ReviewBottomBar = function (_a) {
28
- var onSubmit = _a.onSubmit, onRetry = _a.onRetry;
29
- var intl = (0, react_intl_1.useIntl)();
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
- var CaptureButton = function (_a) {
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" }) })));