@wise/dynamic-flow-client 0.2.1 → 0.3.0-beta-ec09e7.2

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