@wise/dynamic-flow-client 0.2.0 → 0.2.1

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 (117) hide show
  1. package/build/flow/DynamicFlow.d.ts +1 -0
  2. package/build/flow/DynamicFlow.js +15 -5
  3. package/build/flow/DynamicFlowStep.d.ts +1 -0
  4. package/build/flow/errorBoundary/ErrorBoundaryAlert.d.ts +1 -0
  5. package/build/flow/fixtures/components/alert.d.ts +2 -2
  6. package/build/flow/fixtures/components/box.d.ts +2 -2
  7. package/build/flow/fixtures/components/button.d.ts +2 -2
  8. package/build/flow/fixtures/components/columns.d.ts +2 -2
  9. package/build/flow/fixtures/components/copyable.d.ts +2 -2
  10. package/build/flow/fixtures/components/decision.d.ts +2 -2
  11. package/build/flow/fixtures/components/heading.d.ts +2 -2
  12. package/build/flow/fixtures/components/image.d.ts +3 -2
  13. package/build/flow/fixtures/components/image.js +22 -3
  14. package/build/flow/fixtures/components/info.d.ts +2 -2
  15. package/build/flow/fixtures/components/list.d.ts +2 -2
  16. package/build/flow/fixtures/components/loading-indicator.d.ts +2 -2
  17. package/build/flow/fixtures/components/paragraph.d.ts +2 -2
  18. package/build/flow/fixtures/components/review.d.ts +2 -2
  19. package/build/flow/fixtures/examples/camera-capture.d.ts +2 -2
  20. package/build/flow/fixtures/examples/recipient-update.d.ts +2 -2
  21. package/build/flow/fixtures/examples/recipient-update.js +2 -2
  22. package/build/flow/fixtures/examples/recipient.d.ts +2 -2
  23. package/build/flow/fixtures/examples/single-file-upload.d.ts +2 -2
  24. package/build/flow/fixtures/examples/single-file-upload.js +32 -30
  25. package/build/flow/fixtures/examples/step-validation-errors.d.ts +2 -2
  26. package/build/flow/fixtures/features/action-response.d.ts +2 -2
  27. package/build/flow/fixtures/features/external.d.ts +2 -2
  28. package/build/flow/fixtures/features/persist-async.d.ts +2 -2
  29. package/build/flow/fixtures/features/polling.d.ts +2 -2
  30. package/build/flow/fixtures/features/validation-async.d.ts +3 -0
  31. package/build/flow/fixtures/features/validation-async.js +38 -0
  32. package/build/flow/fixtures/index.d.ts +34 -28
  33. package/build/flow/fixtures/index.js +8 -1
  34. package/build/flow/fixtures/responses/action-response-final.d.ts +2 -2
  35. package/build/flow/fixtures/responses/recipient-update-final.d.ts +2 -2
  36. package/build/flow/fixtures/schemas/basic-form.d.ts +2 -2
  37. package/build/flow/fixtures/schemas/number-and-integer.d.ts +2 -2
  38. package/build/flow/fixtures/schemas/one-of.d.ts +2 -2
  39. package/build/flow/fixtures/schemas/string-formats.d.ts +2 -2
  40. package/build/flow/fixtures/schemas/string-formats.js +6 -2
  41. package/build/flow/stories/DynamicFlow.story.d.ts +1 -0
  42. package/build/flow/stories/DynamicFlow.story.js +30 -0
  43. package/build/flow/stories/EditableDynamicFlow.d.ts +1 -0
  44. package/build/flow/stories/EditableDynamicFlow.js +2 -1
  45. package/build/flow/stories/fixtureFetcher.d.ts +2 -0
  46. package/build/flow/stories/fixtureFetcher.js +114 -0
  47. package/build/jsonSchemaForm/JsonSchemaForm.d.ts +1 -0
  48. package/build/jsonSchemaForm/allOfSchema/AllOfSchema.d.ts +1 -0
  49. package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.d.ts +1 -0
  50. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +1 -0
  51. package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.d.ts +1 -0
  52. package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.d.ts +1 -0
  53. package/build/jsonSchemaForm/controlFeedback/ControlFeedback.d.ts +1 -0
  54. package/build/jsonSchemaForm/genericSchema/GenericSchema.d.ts +1 -0
  55. package/build/jsonSchemaForm/help/Help.d.ts +1 -0
  56. package/build/jsonSchemaForm/objectSchema/ObjectSchema.d.ts +1 -0
  57. package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.d.ts +1 -0
  58. package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.d.ts +1 -0
  59. package/build/jsonSchemaForm/persistAsyncSchema/basic/PersistAsyncBasicSchema.d.ts +1 -0
  60. package/build/jsonSchemaForm/persistAsyncSchema/blob/PersistAsyncBlobSchema.d.ts +1 -0
  61. package/build/jsonSchemaForm/persistAsyncSchema/blob/UploadInputAdapter.d.ts +1 -0
  62. package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.d.ts +1 -0
  63. package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfCheckboxControl.d.ts +1 -0
  64. package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfRadioControl.d.ts +1 -0
  65. package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.d.ts +1 -0
  66. package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +2 -1
  67. package/build/jsonSchemaForm/schemaFormControl/optionMapper.d.ts +7 -11
  68. package/build/jsonSchemaForm/schemaFormControl/optionMapper.js +12 -6
  69. package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.d.ts +1 -0
  70. package/build/layout/DynamicLayout.d.ts +1 -0
  71. package/build/layout/alert/index.d.ts +1 -0
  72. package/build/layout/box/index.d.ts +1 -0
  73. package/build/layout/button/index.d.ts +1 -0
  74. package/build/layout/columns/index.d.ts +1 -0
  75. package/build/layout/decision/index.d.ts +1 -0
  76. package/build/layout/divider/index.d.ts +1 -0
  77. package/build/layout/external/DynamicExternal.d.ts +1 -0
  78. package/build/layout/form/index.d.ts +1 -0
  79. package/build/layout/heading/index.d.ts +1 -0
  80. package/build/layout/icon/index.d.ts +1 -0
  81. package/build/layout/image/index.d.ts +4 -2
  82. package/build/layout/image/index.js +17 -38
  83. package/build/layout/info/index.d.ts +1 -0
  84. package/build/layout/list/index.d.ts +1 -0
  85. package/build/layout/loading-indicator/index.d.ts +1 -0
  86. package/build/layout/paragraph/DynamicParagraph.d.ts +1 -0
  87. package/build/layout/review/index.d.ts +1 -0
  88. package/build/main.css +45 -0
  89. package/build/step/cameraStep/CameraStep.d.ts +1 -0
  90. package/build/step/cameraStep/cameraCapture/CameraCapture.d.ts +1 -0
  91. package/build/step/cameraStep/cameraCapture/components/index.d.ts +1 -0
  92. package/build/step/cameraStep/cameraCapture/overlay/Overlay.d.ts +1 -0
  93. package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.d.ts +1 -0
  94. package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.d.ts +1 -0
  95. package/build/step/externalConfirmationStep/ExternalConfirmationStep.d.ts +1 -0
  96. package/build/step/layoutStep/LayoutStep.d.ts +1 -0
  97. package/package.json +7 -5
  98. package/build/common/hooks/useDebouncedFunction.test.d.ts +0 -1
  99. package/build/common/hooks/useDebouncedFunction.test.js +0 -59
  100. package/build/common/logging/spec.d.ts +0 -1
  101. package/build/common/logging/spec.js +0 -45
  102. package/build/common/tracking/spec.d.ts +0 -1
  103. package/build/common/tracking/spec.js +0 -49
  104. package/build/common/utils/generate-random-id.test.d.ts +0 -1
  105. package/build/common/utils/generate-random-id.test.js +0 -12
  106. package/build/common/validation/rule-validators/spec.d.ts +0 -1
  107. package/build/common/validation/rule-validators/spec.js +0 -145
  108. package/build/common/validation/schema-validators/spec.d.ts +0 -1
  109. package/build/common/validation/schema-validators/spec.js +0 -137
  110. package/build/common/validation/valid-model/spec.d.ts +0 -1
  111. package/build/common/validation/valid-model/spec.js +0 -605
  112. package/build/common/validation/validation-failures/spec.d.ts +0 -1
  113. package/build/common/validation/validation-failures/spec.js +0 -185
  114. package/build/flow/response-parsers/spec.d.ts +0 -1
  115. package/build/flow/response-parsers/spec.js +0 -263
  116. package/build/layout/loading-indicator/spec.d.ts +0 -1
  117. package/build/layout/loading-indicator/spec.js +0 -11
@@ -15,6 +15,7 @@ import { action } from '@storybook/addon-actions';
15
15
  import { useState } from 'react';
16
16
  import DynamicFlow from '../DynamicFlow';
17
17
  import { fixtures } from '../fixtures';
18
+ import { fixtureFetcher } from './fixtureFetcher';
18
19
  var EditableDynamicFlow = function (_a) {
19
20
  var _b = _a.initialStepName, initialStepName = _b === void 0 ? '' : _b;
20
21
  var selectedStep = fixtures.steps[initialStepName] || {};
@@ -27,7 +28,7 @@ var InteractiveDemo = function (_a) {
27
28
  var onTextAreaChange = function (event) {
28
29
  setInitialStep(event.target.value);
29
30
  };
30
- return (_jsxs("div", __assign({ style: { display: 'flex', gap: '1em' } }, { children: [_jsxs("div", __assign({ style: { flexBasis: '50%' } }, { children: [_jsx("h3", { children: "Editable Demo" }), _jsxs("p", { children: ["You can select an initial step from the drop down in the controls panel.", _jsx("br", {}), "You can edit the JSON below and see the result on the right."] }), _jsx("textarea", { wrap: "off", rows: 40, style: { fontFamily: 'monospace', fontSize: '0.9em', width: '100%' }, value: initialStep, onChange: onTextAreaChange })] })), _jsx("div", __assign({ style: { flexBasis: '50%' } }, { children: _jsx(DynamicFlow, { initialStep: safeParseStepJson(initialStep), fetcher: function () { return Promise.resolve(new Response(initialStep)); }, onClose: action('onClose'), onStepChange: action('onStepChange'), onError: action('onError'), onTrackableEvent: action('onTrackableEvent'), onLog: action('onLog') }, initialStep) }))] })));
31
+ return (_jsxs("div", __assign({ style: { display: 'flex', gap: '1em' } }, { children: [_jsxs("div", __assign({ style: { flexBasis: '50%' } }, { children: [_jsx("h3", { children: "Editable Demo" }), _jsxs("p", { children: ["You can select an initial step from the drop down in the controls panel.", _jsx("br", {}), "You can edit the JSON below and see the result on the right."] }), _jsx("textarea", { wrap: "off", rows: 40, style: { fontFamily: 'monospace', fontSize: '0.9em', width: '100%' }, value: initialStep, onChange: onTextAreaChange })] })), _jsx("div", __assign({ style: { flexBasis: '50%' } }, { children: _jsx(DynamicFlow, { initialStep: safeParseStepJson(initialStep), fetcher: fixtureFetcher, onClose: action('onClose'), onStepChange: action('onStepChange'), onError: action('onError'), onTrackableEvent: action('onTrackableEvent'), onLog: action('onLog') }, initialStep) }))] })));
31
32
  };
32
33
  function safeParseStepJson(jsonStep) {
33
34
  try {
@@ -0,0 +1,2 @@
1
+ import { Fetcher } from '../types';
2
+ export declare const fixtureFetcher: Fetcher;
@@ -0,0 +1,114 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { action } from '@storybook/addon-actions';
49
+ import { isObject } from '@transferwise/neptune-validation';
50
+ import { fixtures } from '../fixtures';
51
+ import { getObjectKeys } from './DynamicFlow.story';
52
+ export var fixtureFetcher = function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var url;
54
+ return __generator(this, function (_a) {
55
+ action('fixtureFetcher')(input, init);
56
+ url = getURL(input);
57
+ if (url.pathname.startsWith('/steps/')) {
58
+ return [2 /*return*/, respondWithFixture(fixtures.steps, url, init)];
59
+ }
60
+ if (url.pathname.startsWith('/responses/')) {
61
+ return [2 /*return*/, respondWithFixture(fixtures.responses, url, init)];
62
+ }
63
+ if (url.pathname.startsWith('/validate')) {
64
+ return [2 /*return*/, new Response(JSON.stringify({ message: 'Validation-async OK' }))];
65
+ }
66
+ return [2 /*return*/, new Response(null, { status: 404 })];
67
+ });
68
+ }); };
69
+ var getURL = function (input) {
70
+ if (input instanceof URL) {
71
+ return input;
72
+ }
73
+ if (input instanceof Request) {
74
+ return new URL(input.url, 'http://foo');
75
+ }
76
+ return new URL(input, 'http://foo');
77
+ };
78
+ var respondWithFixture = function (fixtures, url, init) { return __awaiter(void 0, void 0, void 0, function () {
79
+ var fixtureNames, name, fixture, body;
80
+ var _a;
81
+ return __generator(this, function (_b) {
82
+ switch (_b.label) {
83
+ case 0:
84
+ fixtureNames = getObjectKeys(fixtures);
85
+ name = url.pathname
86
+ .split('/')
87
+ .filter(function (part) { return !!part; })
88
+ .pop();
89
+ if (!fixtureNames.includes(name !== null && name !== void 0 ? name : '')) return [3 /*break*/, 3];
90
+ fixture = fixtures[name];
91
+ if (!url.searchParams.has('delay')) return [3 /*break*/, 2];
92
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, Number(url.searchParams.get('delay'))); })];
93
+ case 1:
94
+ _b.sent();
95
+ _b.label = 2;
96
+ case 2:
97
+ // by convention if the url contains a "refresh"query parameterm we use the payload as model
98
+ if (url.searchParams.has('refresh') &&
99
+ (init === null || init === void 0 ? void 0 : init.body) &&
100
+ typeof init.body === 'string' &&
101
+ isObject(fixture)) {
102
+ body = JSON.parse(init.body);
103
+ return [2 /*return*/, new Response(JSON.stringify(__assign(__assign({}, fixture), { model: __assign(__assign({}, ((_a = fixture.model) !== null && _a !== void 0 ? _a : {})), body) })))];
104
+ }
105
+ if (url.pathname.includes('exit')) {
106
+ return [2 /*return*/, new Response(JSON.stringify(fixture), { headers: { 'X-DF-Exit': 'true' } })];
107
+ }
108
+ return [2 /*return*/, new Response(JSON.stringify(fixture))];
109
+ case 3:
110
+ action('ERROR 404')(url);
111
+ return [2 /*return*/, new Response(null, { status: 404 })];
112
+ }
113
+ });
114
+ }); };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { LogEventHandler } from '../common/logging';
2
3
  import { TrackableEventHandler } from '../common/tracking';
3
4
  import { FormErrors, Model, Schema } from '../dynamic-flow-types';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { AllOfSchema as AllOfSchemaType, ObjectModel } from '../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
3
4
  declare const AllOfSchema: {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ArrayModel, ArraySchema as ArraySchemaType } from '../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
3
4
  declare const ArraySchema: {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ArrayModel, ArraySchema as ArraySchemaType } from '../../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../../genericSchema/GenericSchema';
3
4
  declare const ArrayListSchema: {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ArrayModel } from '../../../../dynamic-flow-types';
2
3
  import { MultipleFileUploadSchema as MultipleFileUploadSchemaType } from '../../../../dynamic-flow-types/Schema';
3
4
  import { GenericSchemaProps } from '../../../genericSchema/GenericSchema';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { BasicModel, BasicSchema } from '../../dynamic-flow-types';
2
3
  import { OnChange } from '../JsonSchemaForm';
3
4
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Schema } from '../../dynamic-flow-types';
2
3
  declare const ControlFeedback: {
3
4
  (props: ControlFeedbackProps): JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { FormErrors, Model, Schema } from '../../dynamic-flow-types';
2
3
  import { OnPersistAsync } from '../../schema';
3
4
  import { OnChange } from '../JsonSchemaForm';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type Props = {
2
3
  help: {
3
4
  markdown: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ObjectModel, ObjectSchema as ObjectSchemaType } from '../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
3
4
  declare const ObjectSchema: {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { OneOfSchema as OneOfSchemaType } from '../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
3
4
  declare const OneOfSchema: {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { PersistAsyncSchema as PersistAsyncSchemaType } from '../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
3
4
  declare const PersistAsyncSchema: {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { PersistAsync, Schema } from '../../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../../genericSchema/GenericSchema';
3
4
  export declare const getIdFromResponse: (idProperty: string, response: Record<string, unknown>) => string | number;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { BlobSchema, PersistAsync, Schema } from '../../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../../genericSchema/GenericSchema';
3
4
  declare const PersistAsyncBlobSchema: {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { UploadProps } from '@transferwise/components/build/types/upload/Upload';
2
3
  import { PersistAsync } from '../../../dynamic-flow-types';
3
4
  import { Fetcher } from '../../../schema';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ObjectModel, OneOfObjectSchema } from '../../dynamic-flow-types';
2
3
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
3
4
  declare const PromotedOneOfSchema: (props: PromotedOneOfSchemaProps) => JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { PromotedOneOfControlProps } from './PromotedOneOfControl';
2
3
  declare const PromotedOneOfCheckboxControl: {
3
4
  (props: PromotedOneOfControlProps): JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { PromotedOneOfControlProps } from './PromotedOneOfControl';
2
3
  declare const PromotedOneOfRadioControl: {
3
4
  (props: PromotedOneOfControlProps): JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Model, Schema } from '../../dynamic-flow-types';
2
3
  type ReadOnlySchemaProps = {
3
4
  schema: Schema;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { FormControlType } from '../../common';
2
3
  import { BasicModel, Schema } from '../../dynamic-flow-types';
3
4
  export declare const getControlType: (schema: Schema) => (typeof FormControlType)[keyof typeof FormControlType] | undefined;
@@ -11,7 +12,7 @@ declare const SchemaFormControl: {
11
12
  disabled: boolean;
12
13
  };
13
14
  };
14
- type SchemaFormControlProps = {
15
+ export type SchemaFormControlProps = {
15
16
  id: string;
16
17
  value: BasicModel | null;
17
18
  schema: Schema;
@@ -1,24 +1,20 @@
1
+ /// <reference types="react" />
1
2
  import { Icon, Image, Schema } from '../../dynamic-flow-types';
2
- export declare const mapConstSchemaToOption: (schema: Schema, controlType?: string) => {
3
- searchStrings: string[];
3
+ export declare const mapConstSchemaToOption: (schema: Schema, controlType?: string) => RadioOption | SelectOption;
4
+ export type RadioOption = {
4
5
  disabled?: boolean | undefined;
5
- icon?: JSX.Element | undefined;
6
+ avatar?: JSX.Element | undefined;
6
7
  currency?: string | undefined;
7
8
  label: string;
8
9
  value: string;
9
- } | {
10
- searchStrings?: undefined;
10
+ };
11
+ export type SelectOption = {
12
+ searchStrings?: string[];
11
13
  disabled?: boolean | undefined;
12
14
  icon?: JSX.Element | undefined;
13
15
  currency?: string | undefined;
14
16
  label: string;
15
17
  value: string;
16
- } | {
17
- disabled?: boolean | undefined;
18
- avatar?: JSX.Element | undefined;
19
- currency?: string | undefined;
20
- label: string;
21
- value: string;
22
18
  };
23
19
  export declare const mapImage: (image?: Image) => {
24
20
  icon: JSX.Element;
@@ -17,16 +17,22 @@ import { getCurrencyFlag } from './availableCurrencyFlags';
17
17
  export var mapConstSchemaToOption = function (schema, controlType) {
18
18
  switch (controlType) {
19
19
  case 'select':
20
- return __assign(__assign(__assign(__assign(__assign(__assign({
21
- // TODO: LOW avoid type assertion -- using || '' would fail some tests
22
- label: schema.title, value: schema["const"] }, getOptionDescription(schema.title, schema.description)), mapIcon(schema.icon)), mapCurrency(schema.icon)), mapImage(schema.image)), getDisabled(schema.disabled)), mapKeywordsToSearchStrings(schema.keywords));
20
+ return mapConstSchemaToSelectOption(schema);
23
21
  case 'radio':
24
22
  default:
25
- return __assign(__assign(__assign(__assign(__assign({
26
- // TODO: LOW avoid type assertion -- using || '' would fail some tests
27
- label: schema.title, value: schema["const"] }, getOptionDescription(schema.title, schema.description)), mapIconToAvatar(schema.icon)), mapCurrency(schema.icon)), mapAvatar(schema.image)), getDisabled(schema.disabled));
23
+ return mapConstSchemaToRadioOption(schema);
28
24
  }
29
25
  };
26
+ var mapConstSchemaToRadioOption = function (schema) {
27
+ return __assign(__assign(__assign(__assign(__assign({
28
+ // TODO: LOW avoid type assertion -- using || '' would fail some tests
29
+ label: schema.title, value: schema["const"] }, getOptionDescription(schema.title, schema.description)), mapIconToAvatar(schema.icon)), mapCurrency(schema.icon)), mapAvatar(schema.image)), getDisabled(schema.disabled));
30
+ };
31
+ var mapConstSchemaToSelectOption = function (schema) {
32
+ return __assign(__assign(__assign(__assign(__assign(__assign({
33
+ // TODO: LOW avoid type assertion -- using || '' would fail some tests
34
+ label: schema.title, value: schema["const"] }, getOptionDescription(schema.title, schema.description)), mapIcon(schema.icon)), mapCurrency(schema.icon)), mapImage(schema.image)), getDisabled(schema.disabled)), mapKeywordsToSearchStrings(schema.keywords));
35
+ };
30
36
  // TODO: LOW avoid type assertion below -- icon.name may be undefined
31
37
  var mapCurrency = function (icon) { return (icon ? getCurrencyFlag(icon.name) : null); };
32
38
  var mapKeywordsToSearchStrings = function (searchStrings) {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { BasicModel } from '../../dynamic-flow-types';
2
3
  import { ValidationAsyncSchema as ValidationAsyncSchemaType } from '../../dynamic-flow-types/Schema';
3
4
  import { GenericSchemaProps } from '../genericSchema/GenericSchema';
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { FormErrors, LayoutComponent, Model } from '../dynamic-flow-types';
2
3
  import { OnAction, OnModelChange, OnPersistAsync } from '../schema';
3
4
  export type CommonLayoutProps = {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Alert as AlertType } from '../../dynamic-flow-types';
2
3
  declare const DynamicAlert: (props: {
3
4
  component: AlertType;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { BoxLayout } from '../../dynamic-flow-types';
2
3
  import { CommonLayoutProps } from '../DynamicLayout';
3
4
  type Props = CommonLayoutProps & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ButtonLayout } from '../../dynamic-flow-types';
2
3
  import { CommonLayoutProps } from '../DynamicLayout';
3
4
  type Props = Omit<CommonLayoutProps, 'submitted' | 'onModelChange' | 'onPersistAsync'> & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ColumnsLayout } from '../../dynamic-flow-types';
2
3
  import { CommonLayoutProps } from '../DynamicLayout';
3
4
  type Props = CommonLayoutProps & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { DecisionLayout } from '../../dynamic-flow-types';
2
3
  import { OnAction } from '../../schema';
3
4
  type Props = {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { DividerLayout } from '../../dynamic-flow-types';
2
3
  type Props = {
3
4
  component: DividerLayout;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Action, ExternalLayout } from '../../dynamic-flow-types';
2
3
  type Props = {
3
4
  component: ExternalLayout;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { FormLayout } from '../../dynamic-flow-types';
2
3
  import { CommonLayoutProps } from '../DynamicLayout';
3
4
  type Props = Omit<CommonLayoutProps, 'onAction'> & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { HeadingLayout } from '../../dynamic-flow-types';
2
3
  declare const DynamicHeading: (props: {
3
4
  component: HeadingLayout;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type Props = {
2
3
  type: string;
3
4
  };
@@ -1,5 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { ImageLayout } from '../../dynamic-flow-types';
2
- declare const DynamicImage: (props: {
3
+ type DynamicImageProps = {
3
4
  component: ImageLayout;
4
- }) => JSX.Element | null;
5
+ };
6
+ declare const DynamicImage: ({ component: image }: DynamicImageProps) => JSX.Element | null;
5
7
  export default DynamicImage;
@@ -51,24 +51,24 @@ import { useEffect, useState } from 'react';
51
51
  import { isRelativePath } from '../../common/api/utils';
52
52
  import { useFetcher } from '../../common/contexts/fetcherContext';
53
53
  import { getMarginBottom } from '../utils';
54
- var getWrapperClasses = function (component) {
55
- switch (component.size) {
56
- case 'xs':
57
- return 'col-xs-2 col-xs-offset-5';
58
- case 'sm':
59
- return 'col-xs-4 col-xs-offset-4';
60
- case 'md':
61
- return 'col-xs-6 col-xs-offset-3';
62
- case 'lg':
63
- return 'col-xs-8 col-xs-offset-2';
64
- case 'xl':
65
- default:
66
- return 'col-xs-12';
54
+ var DynamicImage = function (_a) {
55
+ var image = _a.component;
56
+ var url = image.url, size = image.size, text = image.text, margin = image.margin;
57
+ var fetcher = useFetcher();
58
+ var _b = useState(''), imageSource = _b[0], setImageSource = _b[1];
59
+ useEffect(function () {
60
+ void getImageSource(fetcher, url).then(setImageSource);
61
+ }, [url, fetcher]);
62
+ var imageProps = {
63
+ alt: text || '',
64
+ src: imageSource,
65
+ stretch: true,
66
+ shrink: true
67
+ };
68
+ if (!imageSource) {
69
+ return null;
67
70
  }
68
- };
69
- var getImageClasses = function (image) {
70
- var margin = getMarginBottom(image.margin || 'lg');
71
- return "img-responsive ".concat(margin);
71
+ return (_jsx("div", __assign({ className: "df-image ".concat(size || 'xl') }, { children: _jsx(Image, __assign({ className: "img-responsive ".concat(getMarginBottom(margin || 'lg')) }, imageProps)) })));
72
72
  };
73
73
  var readImageBlobAsDataURL = function (imageBlob) {
74
74
  // we can safely assume the type of reader.result is string
@@ -102,25 +102,4 @@ var getImageSource = function (fetcher, imageUrl) { return __awaiter(void 0, voi
102
102
  return [2 /*return*/];
103
103
  });
104
104
  }); };
105
- var DynamicImage = function (props) {
106
- var image = props.component;
107
- var fetcher = useFetcher();
108
- var _a = useState(''), imageSource = _a[0], setImageSource = _a[1];
109
- useEffect(function () {
110
- void getImageSource(fetcher, image.url).then(setImageSource);
111
- }, [image.url, fetcher]);
112
- var imageProps = {
113
- alt: image.text || '',
114
- src: imageSource,
115
- stretch: true,
116
- shrink: true
117
- };
118
- var getImage = function () {
119
- return imageSource ? _jsx(Image, __assign({ className: getImageClasses(image) }, imageProps)) : null;
120
- };
121
- if (!image.size || image.size === 'xl') {
122
- return getImage();
123
- }
124
- return (_jsx("div", __assign({ className: "row m-b-0" }, { children: _jsx("div", __assign({ className: getWrapperClasses(image) }, { children: getImage() })) })));
125
- };
126
105
  export default DynamicImage;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { InfoLayout } from '../../dynamic-flow-types';
2
3
  type Props = {
3
4
  component: InfoLayout;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Action, ListLayout } from '../../dynamic-flow-types';
2
3
  type Props = {
3
4
  component: ListLayout;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { LoadingIndicatorLayout } from '../../dynamic-flow-types';
2
3
  type Props = {
3
4
  component: LoadingIndicatorLayout;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ParagraphLayout } from '../../dynamic-flow-types';
2
3
  type Props = {
3
4
  component: ParagraphLayout;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ReviewLayout } from '../../dynamic-flow-types';
2
3
  import { OnAction } from '../../schema';
3
4
  type Props = {
package/build/main.css CHANGED
@@ -141,3 +141,48 @@
141
141
  width: 100%;
142
142
  z-index: 10000;
143
143
  }
144
+ .df-image {
145
+ display: flex;
146
+ justify-content: center;
147
+ align-items: center;
148
+ }
149
+ .df-image img {
150
+ height: auto;
151
+ width: 100%;
152
+ }
153
+ /* narrow screens */
154
+ .df-image.xs img {
155
+ width: 50px;
156
+ }
157
+ .df-image.sm img {
158
+ width: 100px;
159
+ }
160
+ .df-image.md img {
161
+ width: 200px;
162
+ }
163
+ .df-image.lg img {
164
+ width: 300px;
165
+ }
166
+ /* wide screens */
167
+ @media (min-width: 576px) {
168
+ .df-image.xs img {
169
+ width: 100px;
170
+ }
171
+
172
+ .df-image.sm img {
173
+ width: 200px;
174
+ }
175
+
176
+ .df-image.md img {
177
+ width: 300px;
178
+ }
179
+
180
+ .df-image.lg img {
181
+ width: 500px;
182
+ }
183
+
184
+ .df-image.xl img {
185
+ max-width: 600px;
186
+ }
187
+
188
+ }
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { Step } from '../../dynamic-flow-types';
2
3
  import { CommonLayoutProps } from '../../layout/DynamicLayout';
3
4
  export type CameraStepProps = Omit<CommonLayoutProps, 'onPersistAsync' | 'baseUrl'> & {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { TrackableEventHandler } from '../../../common/tracking';
2
3
  import { CameraDirection } from '../../../dynamic-flow-types/FileUploadSchema';
3
4
  type Props = {
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const CaptureBottomBar: ({ onCapture }: {
2
3
  onCapture: () => void;
3
4
  }) => JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type Props = {
2
3
  overlay?: string;
3
4
  outline?: string;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  declare const CameraNotSupported: () => JSX.Element;
2
3
  export default CameraNotSupported;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type Props = {
2
3
  onAction: () => void;
3
4
  };
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  type Props = {
2
3
  url: string;
3
4
  onClose: () => void;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { FormErrors, Step } from '../../dynamic-flow-types';
2
3
  import { CommonLayoutProps } from '../../layout/DynamicLayout';
3
4
  import { StepLayoutOptions } from './layoutService/convertStepToLayout';