@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,62 +1,15 @@
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
- exports.__esModule = true;
50
- var jsx_runtime_1 = require("react/jsx-runtime");
51
- var react_1 = require("react");
52
- var react_intl_1 = require("react-intl");
53
- var contexts_1 = require("../common/contexts");
54
- var validators_1 = require("../common/validators");
55
- var types_1 = require("../types");
56
- var DynamicFlowStep_1 = require("./DynamicFlowStep");
57
- var utils_1 = require("./utils");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const react_intl_1 = require("react-intl");
6
+ const contexts_1 = require("../common/contexts");
7
+ const validators_1 = require("../common/validators");
8
+ const types_1 = require("../types");
9
+ const DynamicFlowStep_1 = require("./DynamicFlowStep");
10
+ const utils_1 = require("./utils");
58
11
  // eslint-disable-next-line @typescript-eslint/no-empty-function
59
- var noop = function () { };
12
+ const noop = () => { };
60
13
  /**
61
14
  * ## DynamicFlow
62
15
  *
@@ -66,307 +19,232 @@ var noop = function () { };
66
19
  * and reformats it to use a LayoutStep for presentation.
67
20
  *
68
21
  */
69
- var DynamicFlowComponent = function (_a) {
70
- var flowId = _a.flowId, fetcher = _a.fetcher, flowUrl = _a.flowUrl, initialAction = _a.initialAction, initialStep = _a.initialStep, loaderConfig = _a.loaderConfig, _b = _a.displayStepTitle, displayStepTitle = _b === void 0 ? true : _b, onComplete = _a.onComplete, _c = _a.onStepChange, onStepChange = _c === void 0 ? noop : _c, onError = _a.onError, _d = _a.onEvent, onEvent = _d === void 0 ? noop : _d, _e = _a.onLog, onLog = _e === void 0 ? noop : _e;
71
- var locale = (0, react_intl_1.useIntl)().locale;
72
- var _f = (0, utils_1.useDynamicFlowState)(initialStep), formErrors = _f.formErrors, globalError = _f.globalError, step = _f.step, models = _f.models, etag = _f.etag, modelIsValid = _f.modelIsValid, setFormErrors = _f.setFormErrors, setGlobalError = _f.setGlobalError, setStepAndEtag = _f.setStepAndEtag, setSchemaModel = _f.setSchemaModel;
73
- var _g = (0, react_1.useState)(false), submitted = _g[0], setSubmitted = _g[1];
74
- var _h = (0, utils_1.useLoader)(loaderConfig, initialStep ? 'idle' : 'initial'), loadingState = _h.loadingState, setLoadingState = _h.setLoadingState, loader = _h.loader;
75
- var logWarning = (0, contexts_1.getLogger)('warning', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
76
- var logError = (0, contexts_1.getLogger)('error', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
77
- var logCritical = (0, contexts_1.getLogger)('critical', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
78
- var analyticsMetadata = (0, react_1.useMemo)(function () { var _a; return (__assign({ flowId: flowId, stepId: step === null || step === void 0 ? void 0 : step.key }, ((_a = step === null || step === void 0 ? void 0 : step.analytics) !== null && _a !== void 0 ? _a : {}))); }, [flowId, step]);
79
- var dispatchEvent = (0, react_1.useMemo)(function () { return (0, contexts_1.getEventDispatcher)(onEvent, analyticsMetadata); }, [onEvent, analyticsMetadata]);
80
- var triggerActionRequest = (0, react_1.useCallback)(function (_a) {
81
- var action = _a.action, data = _a.data, etag = _a.etag;
82
- var url = action.url, _b = action.method, method = _b === void 0 ? 'POST' : _b;
22
+ const DynamicFlowComponent = ({ flowId, fetcher, flowUrl, initialAction, initialStep, loaderConfig, displayStepTitle = true, onComplete, onStepChange = noop, onError, onEvent = noop, onLog = noop, }) => {
23
+ const { locale } = (0, react_intl_1.useIntl)();
24
+ const { formErrors, globalError, step, models, etag, modelIsValid, setFormErrors, setGlobalError, setStepAndEtag, setSchemaModel, } = (0, utils_1.useDynamicFlowState)(initialStep);
25
+ const [submitted, setSubmitted] = (0, react_1.useState)(false);
26
+ const { loadingState, setLoadingState, loader } = (0, utils_1.useLoader)(loaderConfig, initialStep ? 'idle' : 'initial');
27
+ const logWarning = (0, contexts_1.getLogger)('warning', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
28
+ const logError = (0, contexts_1.getLogger)('error', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
29
+ const logCritical = (0, contexts_1.getLogger)('critical', onLog, flowId, step === null || step === void 0 ? void 0 : step.key);
30
+ const analyticsMetadata = (0, react_1.useMemo)(() => { var _a; return (Object.assign({ flowId, stepId: step === null || step === void 0 ? void 0 : step.key }, ((_a = step === null || step === void 0 ? void 0 : step.analytics) !== null && _a !== void 0 ? _a : {}))); }, [flowId, step]);
31
+ const dispatchEvent = (0, react_1.useMemo)(() => (0, contexts_1.getEventDispatcher)(onEvent, analyticsMetadata), [onEvent, analyticsMetadata]);
32
+ const triggerActionRequest = (0, react_1.useCallback)(({ action, data, etag }) => {
33
+ const { url, method = 'POST' } = action;
83
34
  return fetcher(url !== null && url !== void 0 ? url : '', {
84
- method: method,
85
- headers: __assign({ 'accept-language': locale, 'Content-Type': 'application/json' }, (etag ? { 'If-None-Match': etag } : {})),
35
+ method,
36
+ headers: Object.assign({ 'accept-language': locale, 'Content-Type': 'application/json' }, (etag ? { 'If-None-Match': etag } : {})),
86
37
  credentials: 'include',
87
- body: method === 'GET' ? undefined : JSON.stringify(data)
38
+ body: method === 'GET' ? undefined : JSON.stringify(data),
88
39
  });
89
40
  }, [fetcher, locale]);
90
- var fetchNextStep = function (action, data) {
91
- if (data === void 0) { data = {}; }
92
- return __awaiter(void 0, void 0, void 0, function () {
93
- var response, error_1;
94
- return __generator(this, function (_a) {
95
- switch (_a.label) {
96
- case 0:
97
- setLoadingState(loadingState === 'initial' ? 'initial' : 'submission');
98
- _a.label = 1;
99
- case 1:
100
- _a.trys.push([1, 3, , 4]);
101
- dispatchEvent('Dynamic Flow - Step Submitted', { actionId: action.$id });
102
- return [4 /*yield*/, triggerActionRequest({ action: action, data: data })];
103
- case 2:
104
- response = _a.sent();
105
- return [2 /*return*/, handleFetchResponse(response, 'submission')];
106
- case 3:
107
- error_1 = _a.sent();
108
- handleFetchError(error_1, 'Error fetching next step');
109
- return [3 /*break*/, 4];
110
- case 4: return [2 /*return*/];
111
- }
112
- });
113
- });
41
+ const fetchNextStep = async (action, data = {}) => {
42
+ setLoadingState(loadingState === 'initial' ? 'initial' : 'submission');
43
+ try {
44
+ dispatchEvent('Dynamic Flow - Step Submitted', { actionId: action.$id });
45
+ const response = await triggerActionRequest({ action, data });
46
+ return handleFetchResponse(response, 'submission');
47
+ }
48
+ catch (error) {
49
+ handleFetchError(error, 'Error fetching next step');
50
+ }
114
51
  };
115
- var fetchRefreshStep = function (action, data, etag) { return __awaiter(void 0, void 0, void 0, function () {
116
- var response, error_2;
117
- return __generator(this, function (_a) {
118
- switch (_a.label) {
119
- case 0:
120
- setLoadingState('refresh');
121
- _a.label = 1;
122
- case 1:
123
- _a.trys.push([1, 4, , 5]);
124
- dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'pending' });
125
- return [4 /*yield*/, triggerActionRequest({ action: action, data: data, etag: etag })];
126
- case 2:
127
- response = _a.sent();
128
- return [4 /*yield*/, handleFetchResponse(response, 'refresh')];
129
- case 3:
130
- _a.sent();
131
- setLoadingState('idle');
132
- return [3 /*break*/, 5];
133
- case 4:
134
- error_2 = _a.sent();
135
- handleFetchError(error_2, 'Error fetching refresh step');
136
- return [3 /*break*/, 5];
137
- case 5: return [2 /*return*/];
138
- }
139
- });
140
- }); };
141
- var fetchExitResult = function (action, data) { return __awaiter(void 0, void 0, void 0, function () {
142
- var response, exitResult, error_3;
143
- return __generator(this, function (_a) {
144
- switch (_a.label) {
145
- case 0:
146
- _a.trys.push([0, 3, , 4]);
147
- return [4 /*yield*/, triggerActionRequest({ action: action, data: data })];
148
- case 1:
149
- response = _a.sent();
150
- return [4 /*yield*/, (0, utils_1.parseExitResponse)(response)];
151
- case 2:
152
- exitResult = _a.sent();
153
- onCloseWithEvent(__assign(__assign({}, exitResult), action.result));
154
- return [3 /*break*/, 4];
155
- case 3:
156
- error_3 = _a.sent();
157
- handleFetchError(error_3, 'Error fetching exit result');
158
- return [3 /*break*/, 4];
159
- case 4: return [2 /*return*/];
160
- }
161
- });
162
- }); };
163
- var debouncedFetchRefresh = (0, utils_1.useDebouncedRefresh)(fetchRefreshStep);
164
- var onCloseWithEvent = (0, react_1.useCallback)(function (result) {
52
+ const fetchRefreshStep = async (action, data, etag) => {
53
+ setLoadingState('refresh');
54
+ try {
55
+ dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'pending' });
56
+ const response = await triggerActionRequest({ action, data, etag });
57
+ await handleFetchResponse(response, 'refresh');
58
+ setLoadingState('idle');
59
+ }
60
+ catch (error) {
61
+ handleFetchError(error, 'Error fetching refresh step');
62
+ }
63
+ };
64
+ const fetchExitResult = async (action, data) => {
65
+ try {
66
+ const response = await triggerActionRequest({ action, data });
67
+ const exitResult = await (0, utils_1.parseExitResponse)(response);
68
+ onCloseWithEvent(Object.assign(Object.assign({}, exitResult), action.result));
69
+ }
70
+ catch (error) {
71
+ handleFetchError(error, 'Error fetching exit result');
72
+ }
73
+ };
74
+ const debouncedFetchRefresh = (0, utils_1.useDebouncedRefresh)(fetchRefreshStep);
75
+ const onCloseWithEvent = (0, react_1.useCallback)((result) => {
165
76
  dispatchEvent('Dynamic Flow - Flow Finished', { result: 'success' });
166
77
  onComplete(result);
167
78
  }, [onComplete, dispatchEvent]);
168
- (0, react_1.useEffect)(function () {
79
+ (0, react_1.useEffect)(() => {
169
80
  dispatchEvent('Dynamic Flow - Flow Started', {});
170
81
  }, []);
171
- (0, react_1.useEffect)(function () {
82
+ (0, react_1.useEffect)(() => {
172
83
  if (!initialStep) {
173
- var action = __assign({ $id: '#initial-step-request', method: 'GET' }, initialAction);
84
+ const action = Object.assign({ $id: '#initial-step-request', method: 'GET' }, initialAction);
174
85
  void fetchNextStep(action, action.data);
175
86
  }
176
87
  }, [flowUrl, fetcher, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
177
- var handleFetchResponse = function (response, fetchType) { return __awaiter(void 0, void 0, void 0, function () {
178
- var parsedResponse, step_1, etag_1, error_4;
179
- return __generator(this, function (_a) {
180
- switch (_a.label) {
181
- case 0:
182
- if (!response.ok) return [3 /*break*/, 4];
183
- _a.label = 1;
184
- case 1:
185
- _a.trys.push([1, 3, , 4]);
186
- return [4 /*yield*/, (0, utils_1.parseFetchResponse)(response)];
187
- case 2:
188
- parsedResponse = _a.sent();
189
- switch (parsedResponse.type) {
190
- case 'action':
191
- void fetchNextStep(parsedResponse.action, parsedResponse.action.data);
192
- return [2 /*return*/];
193
- case 'exit':
194
- return [2 /*return*/, onCloseWithEvent(parsedResponse.result)];
195
- case 'step':
196
- default: {
197
- step_1 = parsedResponse.step, etag_1 = parsedResponse.etag;
198
- return [2 /*return*/, fetchType === 'submission'
199
- ? updateStepAfterSubmission(step_1, etag_1)
200
- : updateStepAfterRefresh(step_1, etag_1)];
201
- }
88
+ const handleFetchResponse = async (response, fetchType) => {
89
+ if (response.ok) {
90
+ try {
91
+ const parsedResponse = await (0, utils_1.parseFetchResponse)(response);
92
+ switch (parsedResponse.type) {
93
+ case 'action':
94
+ void fetchNextStep(parsedResponse.action, parsedResponse.action.data);
95
+ return;
96
+ case 'exit':
97
+ return onCloseWithEvent(parsedResponse.result);
98
+ case 'step':
99
+ default: {
100
+ const { step, etag } = parsedResponse;
101
+ return fetchType === 'submission'
102
+ ? updateStepAfterSubmission(step, etag)
103
+ : updateStepAfterRefresh(step, etag);
202
104
  }
203
- return [3 /*break*/, 4];
204
- case 3:
205
- error_4 = _a.sent();
206
- return [2 /*return*/, handleFetchError(error_4, 'Error parsing fetch response')];
207
- case 4: return [2 /*return*/, handleErrorResponse(response, fetchType)];
105
+ }
208
106
  }
209
- });
210
- }); };
211
- var updateStepAfterSubmission = function (newStep, etag) {
212
- var previousStep = step;
107
+ catch (error) {
108
+ return handleFetchError(error, 'Error parsing fetch response');
109
+ }
110
+ }
111
+ return handleErrorResponse(response, fetchType);
112
+ };
113
+ const updateStepAfterSubmission = (newStep, etag) => {
114
+ const previousStep = step;
213
115
  setStepAndEtag(newStep, etag);
214
116
  onStepChange(newStep, previousStep);
215
117
  setSubmitted(false);
216
118
  setLoadingState('idle');
217
- dispatchEvent('Dynamic Flow - Step Started', __assign({ stepId: newStep.key }, newStep === null || newStep === void 0 ? void 0 : newStep.analytics));
119
+ dispatchEvent('Dynamic Flow - Step Started', Object.assign({ stepId: newStep.key }, newStep === null || newStep === void 0 ? void 0 : newStep.analytics));
218
120
  };
219
- var updateStepAfterRefresh = function (step, etag) {
121
+ const updateStepAfterRefresh = (step, etag) => {
220
122
  setStepAndEtag(step, etag);
221
123
  setLoadingState('idle');
222
124
  dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'success' });
223
125
  };
224
- var handleErrorResponse = function (response, fetchType) { return __awaiter(void 0, void 0, void 0, function () {
225
- var errorBody, action, error_5;
226
- return __generator(this, function (_a) {
227
- switch (_a.label) {
228
- case 0:
229
- if (response.status === 304) {
230
- setLoadingState('idle');
231
- return [2 /*return*/];
232
- }
233
- _a.label = 1;
234
- case 1:
235
- _a.trys.push([1, 5, , 6]);
236
- return [4 /*yield*/, (0, utils_1.parseErrorResponse)(response)];
237
- case 2:
238
- errorBody = _a.sent();
239
- if (!errorBody.refreshFormUrl) return [3 /*break*/, 4];
240
- action = { url: errorBody === null || errorBody === void 0 ? void 0 : errorBody.refreshFormUrl, method: 'POST' };
241
- return [4 /*yield*/, fetchRefreshStep(action, combineModels(models), etag)];
242
- case 3:
243
- _a.sent();
244
- _a.label = 4;
245
- case 4:
246
- if (errorBody.validation) {
247
- setFormErrors(errorBody.validation);
248
- }
249
- if (errorBody.error) {
250
- setGlobalError(errorBody.error);
251
- }
252
- if (!errorBody.refreshFormUrl && !errorBody.validation && !errorBody.error) {
253
- logError('Invalid response', 'Response body must contain at least one of the following properties: refreshFormUrl, validation, or error.');
254
- throw errorBody;
255
- }
256
- return [3 /*break*/, 6];
257
- case 5:
258
- error_5 = _a.sent();
259
- if (fetchType === 'refresh') {
260
- dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'failure' });
261
- }
262
- dispatchEvent('Dynamic Flow - Flow Finished', { status: 'failure' });
263
- onError(error_5, response.status);
264
- logError('Invalid response', 'Error response body must be an object.');
265
- return [3 /*break*/, 6];
266
- case 6:
267
- setLoadingState('idle');
268
- return [2 /*return*/];
126
+ const handleErrorResponse = async (response, fetchType) => {
127
+ if (response.status === 304) {
128
+ setLoadingState('idle');
129
+ return;
130
+ }
131
+ try {
132
+ const errorBody = await (0, utils_1.parseErrorResponse)(response);
133
+ if (errorBody.refreshFormUrl) {
134
+ const action = { url: errorBody === null || errorBody === void 0 ? void 0 : errorBody.refreshFormUrl, method: 'POST' };
135
+ await fetchRefreshStep(action, combineModels(models), etag);
269
136
  }
270
- });
271
- }); };
272
- var handleFetchError = function (error, message) {
137
+ if (errorBody.validation) {
138
+ setFormErrors(errorBody.validation);
139
+ }
140
+ if (errorBody.error) {
141
+ setGlobalError(errorBody.error);
142
+ }
143
+ if (!errorBody.refreshFormUrl && !errorBody.validation && !errorBody.error) {
144
+ logError('Invalid response', 'Response body must contain at least one of the following properties: refreshFormUrl, validation, or error.');
145
+ throw errorBody;
146
+ }
147
+ }
148
+ catch (error) {
149
+ if (fetchType === 'refresh') {
150
+ dispatchEvent('Dynamic Flow - Step Refreshed', { status: 'failure' });
151
+ }
152
+ dispatchEvent('Dynamic Flow - Flow Finished', { status: 'failure' });
153
+ onError(error, response.status);
154
+ logError('Invalid response', 'Error response body must be an object.');
155
+ }
156
+ setLoadingState('idle');
157
+ };
158
+ const handleFetchError = (error, message) => {
273
159
  logCritical('Error fetching', message);
274
160
  onError(error);
275
161
  setLoadingState('idle');
276
162
  };
277
- var onModelChange = function (onModelChangeProps) {
278
- var model = onModelChangeProps.model, formSchema = onModelChangeProps.formSchema;
279
- var _a = formSchema.$id, $id = _a === void 0 ? '' : _a;
163
+ const onModelChange = (onModelChangeProps) => {
164
+ const { model, formSchema } = onModelChangeProps;
165
+ const { $id = '' } = formSchema;
280
166
  setGlobalError(null);
281
167
  if (!(0, types_1.isObjectModel)(model)) {
282
168
  // TODO: MC-3224
283
169
  logCritical('Invalid model on change', 'onModelChange was called but the model argument is not an object');
284
170
  }
285
- var objectModel = model;
286
- setSchemaModel($id, objectModel, function (updatedModels) {
171
+ const objectModel = model;
172
+ setSchemaModel($id, objectModel, (updatedModels) => {
287
173
  refreshOnChangeIfNeeded(onModelChangeProps, updatedModels);
288
174
  });
289
175
  };
290
- var refreshOnChangeIfNeeded = function (props, updatedModels) {
291
- var triggerSchema = props.triggerSchema;
176
+ const refreshOnChangeIfNeeded = (props, updatedModels) => {
177
+ const { triggerSchema } = props;
292
178
  if (shouldTriggerRefresh(props)) {
293
- var url = triggerSchema.refreshFormUrl || (step === null || step === void 0 ? void 0 : step.refreshFormUrl);
294
- var action = { url: url, method: 'POST' };
179
+ const url = triggerSchema.refreshFormUrl || (step === null || step === void 0 ? void 0 : step.refreshFormUrl);
180
+ const action = { url, method: 'POST' };
295
181
  debouncedFetchRefresh(action, combineModels(updatedModels), etag, triggerSchema);
296
182
  }
297
183
  };
298
- var onAction = function (action) { return __awaiter(void 0, void 0, void 0, function () {
299
- var data, method, exit, url, result, submissionData, extraLoggingProps;
300
- return __generator(this, function (_a) {
301
- switch (_a.label) {
302
- case 0:
303
- data = action.data, method = action.method, exit = action.exit, url = action.url, result = action.result;
304
- submissionData = __assign(__assign({}, combineModels(models)), data);
305
- extraLoggingProps = {
306
- url: action.url,
307
- method: action.method,
308
- currency: submissionData.currency,
309
- type: submissionData.type
310
- };
311
- if (loadingState !== 'idle' || action.disabled) {
312
- logWarning('Action supressed', loadingState !== 'idle'
313
- ? "onAction was supressed because loadingState is ".concat(loadingState)
314
- : "onAction was supressed because action is disabled", extraLoggingProps);
315
- return [2 /*return*/];
316
- }
317
- if (!exit) return [3 /*break*/, 7];
318
- if (!url) return [3 /*break*/, 6];
319
- if (!isSubmissionMethod(method)) return [3 /*break*/, 3];
184
+ const onAction = async (action) => {
185
+ const { data, method, exit, url, result } = action;
186
+ const submissionData = Object.assign(Object.assign({}, combineModels(models)), data);
187
+ // Temporary tracking properties specific to recipient creation
188
+ // the submissionData object typically contains PII
189
+ // but we're only taking "currency" and "type" which are not PII.
190
+ const extraLoggingProps = {
191
+ url: action.url,
192
+ method: action.method,
193
+ currency: submissionData.currency,
194
+ type: submissionData.type,
195
+ };
196
+ if (loadingState !== 'idle' || action.disabled) {
197
+ logWarning('Action supressed', loadingState !== 'idle'
198
+ ? `onAction was supressed because loadingState is ${loadingState}`
199
+ : `onAction was supressed because action is disabled`, extraLoggingProps);
200
+ return;
201
+ }
202
+ if (exit) {
203
+ if (url) {
204
+ if (isSubmissionMethod(method)) {
320
205
  setFormErrors(null);
321
206
  setSubmitted(true);
322
- if (!modelIsValid) return [3 /*break*/, 2];
323
- return [4 /*yield*/, fetchExitResult(action, submissionData)];
324
- case 1:
325
- _a.sent();
326
- _a.label = 2;
327
- case 2: return [3 /*break*/, 5];
328
- case 3: return [4 /*yield*/, fetchExitResult(action)];
329
- case 4:
330
- _a.sent();
331
- _a.label = 5;
332
- case 5: return [2 /*return*/];
333
- case 6:
334
- onCloseWithEvent(result);
335
- return [2 /*return*/];
336
- case 7:
337
- if (isSubmissionMethod(method)) {
338
- setFormErrors(null);
339
- setSubmitted(true);
340
- if (modelIsValid) {
341
- void fetchNextStep(action, submissionData);
342
- }
343
- else {
344
- dispatchEvent('Dynamic Flow - onAction supressed', __assign({ reason: 'invalid model' }, extraLoggingProps));
345
- }
346
- return [2 /*return*/];
207
+ if (modelIsValid) {
208
+ await fetchExitResult(action, submissionData);
347
209
  }
348
- void fetchNextStep(action);
349
- return [2 /*return*/];
210
+ }
211
+ else {
212
+ await fetchExitResult(action);
213
+ }
214
+ return;
350
215
  }
351
- });
352
- }); };
353
- return ((0, jsx_runtime_1.jsx)(contexts_1.LogProvider, __assign({ flowId: flowId, stepId: step === null || step === void 0 ? void 0 : step.key, onLog: onLog }, { children: (0, jsx_runtime_1.jsx)(contexts_1.EventsContextProvider, __assign({ metadata: analyticsMetadata, onEvent: onEvent }, { children: (0, jsx_runtime_1.jsx)(contexts_1.DynamicFlowProvider, __assign({ loading: loadingState !== 'idle' }, { children: (0, jsx_runtime_1.jsx)(contexts_1.FetcherProvider, __assign({ fetcher: fetcher }, { children: loader !== null ? (loader) : ((0, jsx_runtime_1.jsx)(DynamicFlowStep_1.DynamicFlowStep, { step: step, model: combineModels(models), submitted: submitted, globalError: globalError, formErrors: formErrors, stepLayoutOptions: { displayStepTitle: displayStepTitle }, onAction: function (action) {
216
+ onCloseWithEvent(result);
217
+ return;
218
+ }
219
+ if (isSubmissionMethod(method)) {
220
+ setFormErrors(null);
221
+ setSubmitted(true);
222
+ if (modelIsValid) {
223
+ void fetchNextStep(action, submissionData);
224
+ }
225
+ else {
226
+ dispatchEvent('Dynamic Flow - onAction supressed', Object.assign({ reason: 'invalid model' }, extraLoggingProps));
227
+ }
228
+ return;
229
+ }
230
+ void fetchNextStep(action);
231
+ };
232
+ return ((0, jsx_runtime_1.jsx)(contexts_1.LogProvider, Object.assign({ flowId: flowId, stepId: step === null || step === void 0 ? void 0 : step.key, onLog: onLog }, { children: (0, jsx_runtime_1.jsx)(contexts_1.EventsContextProvider, Object.assign({ metadata: analyticsMetadata, onEvent: onEvent }, { children: (0, jsx_runtime_1.jsx)(contexts_1.DynamicFlowProvider, Object.assign({ loading: loadingState !== 'idle' }, { children: (0, jsx_runtime_1.jsx)(contexts_1.FetcherProvider, Object.assign({ fetcher: fetcher }, { children: loader !== null ? (loader) : ((0, jsx_runtime_1.jsx)(DynamicFlowStep_1.DynamicFlowStep, { step: step, model: combineModels(models), submitted: submitted, globalError: globalError, formErrors: formErrors, stepLayoutOptions: { displayStepTitle }, onAction: (action) => {
354
233
  void onAction(action);
355
234
  }, onModelChange: onModelChange })) })) })) })) })));
356
235
  };
357
- var DynamicFlow = function (props) { return ((0, jsx_runtime_1.jsx)(utils_1.ErrorBoundary, __assign({ onError: props.onError }, { children: (0, jsx_runtime_1.jsx)(DynamicFlowComponent, __assign({}, props)) }))); };
358
- exports["default"] = DynamicFlow;
359
- var combineModels = function (formModels) {
360
- return Object.values(formModels).reduce(function (previous, model) { return (__assign(__assign({}, previous), model)); }, {});
236
+ const DynamicFlow = (props) => ((0, jsx_runtime_1.jsx)(utils_1.ErrorBoundary, Object.assign({ onError: props.onError }, { children: (0, jsx_runtime_1.jsx)(DynamicFlowComponent, Object.assign({}, props)) })));
237
+ exports.default = DynamicFlow;
238
+ const combineModels = (formModels) => {
239
+ return Object.values(formModels).reduce((previous, model) => (Object.assign(Object.assign({}, previous), model)), {});
361
240
  };
362
- var isSubmissionMethod = function (method) {
363
- if (method === void 0) { method = 'POST'; }
364
- var submissionMethods = ['POST', 'PUT', 'PATCH'];
241
+ const isSubmissionMethod = (method = 'POST') => {
242
+ const submissionMethods = ['POST', 'PUT', 'PATCH'];
365
243
  return submissionMethods.includes(method.toUpperCase());
366
244
  };
367
- var shouldTriggerRefresh = function (props) {
368
- var type = props.type, triggerSchema = props.triggerSchema, triggerModel = props.triggerModel, _a = props.lastTriggerModel, lastTriggerModel = _a === void 0 ? null : _a;
369
- var isValid = function () { return (0, validators_1.isValidSchema)(triggerModel, triggerSchema); };
370
- var wasValid = function () { return (0, validators_1.isValidSchema)(lastTriggerModel, triggerSchema); };
245
+ const shouldTriggerRefresh = (props) => {
246
+ const { type, triggerSchema, triggerModel, lastTriggerModel = null } = props;
247
+ const isValid = () => (0, validators_1.isValidSchema)(triggerModel, triggerSchema);
248
+ const wasValid = () => (0, validators_1.isValidSchema)(lastTriggerModel, triggerSchema);
371
249
  return type !== 'init' && (triggerSchema === null || triggerSchema === void 0 ? void 0 : triggerSchema.refreshFormOnChange) && (isValid() || wasValid());
372
250
  };
@@ -1,27 +1,16 @@
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;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.DynamicFlowStep = void 0;
15
- var jsx_runtime_1 = require("react/jsx-runtime");
16
- var hooks_1 = require("../common/hooks");
17
- var utils_1 = require("../common/utils");
18
- var layout_1 = require("../layout");
19
- var step_1 = require("../step");
20
- var DynamicFlowStep = function (props) {
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const hooks_1 = require("../common/hooks");
6
+ const utils_1 = require("../common/utils");
7
+ const layout_1 = require("../layout");
8
+ const step_1 = require("../step");
9
+ const DynamicFlowStep = (props) => {
21
10
  var _a;
22
- var step = props.step, globalError = props.globalError;
23
- var externalUrl = (_a = step === null || step === void 0 ? void 0 : step.external) === null || _a === void 0 ? void 0 : _a.url;
24
- var _b = (0, hooks_1.useExternal)(externalUrl), requiresManualTrigger = _b.requiresManualTrigger, dismissConfirmation = _b.dismissConfirmation;
11
+ const { step, globalError } = props;
12
+ const externalUrl = (_a = step === null || step === void 0 ? void 0 : step.external) === null || _a === void 0 ? void 0 : _a.url;
13
+ const { requiresManualTrigger, dismissConfirmation } = (0, hooks_1.useExternal)(externalUrl);
25
14
  if (step === undefined) {
26
15
  return null;
27
16
  }
@@ -29,8 +18,8 @@ var DynamicFlowStep = function (props) {
29
18
  return (0, jsx_runtime_1.jsx)(step_1.ExternalConfirmationStep, { url: externalUrl, onClose: dismissConfirmation });
30
19
  }
31
20
  if ((0, utils_1.getStepType)(step) === 'camera') {
32
- return (0, jsx_runtime_1.jsx)(step_1.CameraStep, __assign({}, props, { step: step }));
21
+ return (0, jsx_runtime_1.jsx)(step_1.CameraStep, Object.assign({}, props, { step: step }));
33
22
  }
34
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalError ? ((0, jsx_runtime_1.jsx)(layout_1.DynamicAlert, { component: { context: 'negative', markdown: globalError, margin: 'lg' } })) : null, (0, jsx_runtime_1.jsx)(step_1.LayoutStep, __assign({}, props, { stepSpecification: step }))] }));
23
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [globalError ? ((0, jsx_runtime_1.jsx)(layout_1.DynamicAlert, { component: { context: 'negative', markdown: globalError, margin: 'lg' } })) : null, (0, jsx_runtime_1.jsx)(step_1.LayoutStep, Object.assign({}, props, { stepSpecification: step }))] }));
35
24
  };
36
25
  exports.DynamicFlowStep = DynamicFlowStep;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.__esModule = true;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isSchema = void 0;
4
4
  // TODO HD Move this out of types
5
5
  function isSchema(schema) {