@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,16 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- exports.__esModule = true;
14
- exports["default"] = void 0;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = void 0;
15
7
  var DynamicFlow_1 = require("./DynamicFlow");
16
- __createBinding(exports, DynamicFlow_1, "default");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(DynamicFlow_1).default; } });
@@ -2,35 +2,35 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getObjectKeys = void 0;
7
- var jsx_runtime_1 = require("react/jsx-runtime");
8
- var addon_actions_1 = require("@storybook/addon-actions");
9
- var react_1 = require("@storybook/react");
10
- var fixtures_1 = require("../../fixtures");
11
- var DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
12
- var EditableDynamicFlow_1 = __importDefault(require("./EditableDynamicFlow"));
13
- var fixtureFetcher_1 = require("./fixtureFetcher");
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const addon_actions_1 = require("@storybook/addon-actions");
9
+ const react_1 = require("@storybook/react");
10
+ const fixtures_1 = require("../../fixtures");
11
+ const DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
12
+ const EditableDynamicFlow_1 = __importDefault(require("./EditableDynamicFlow"));
13
+ const fixtureFetcher_1 = require("./fixtureFetcher");
14
14
  exports.getObjectKeys = Object.keys;
15
- var storyMap = {};
16
- var allStepNames = (0, exports.getObjectKeys)(fixtures_1.fixtures.steps);
17
- allStepNames.forEach(function (stepName) {
15
+ const storyMap = {};
16
+ const allStepNames = (0, exports.getObjectKeys)(fixtures_1.fixtures.steps);
17
+ allStepNames.forEach((stepName) => {
18
18
  var _a;
19
- var label = (_a = fixtures_1.fixtures.steps[stepName].key) !== null && _a !== void 0 ? _a : stepName;
20
- var _b = label.split('/'), group = _b[0], name = _b[1];
19
+ const label = (_a = fixtures_1.fixtures.steps[stepName].key) !== null && _a !== void 0 ? _a : stepName;
20
+ const [group, name] = label.split('/');
21
21
  if (!storyMap[group]) {
22
- storyMap[group] = (0, react_1.storiesOf)("Dynamic Flow/".concat(group), module);
22
+ storyMap[group] = (0, react_1.storiesOf)(`Dynamic Flow/${group}`, module);
23
23
  }
24
- storyMap[group].add(name, function () { return ((0, jsx_runtime_1.jsx)(DynamicFlow_1["default"], { flowId: "storybook", initialAction: { method: 'GET', url: "/steps/".concat(stepName) }, fetcher: fixtureFetcher_1.fixtureFetcher, loaderConfig: { size: 'xl', initial: true, submission: false }, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, stepName)); });
24
+ storyMap[group].add(name, () => ((0, jsx_runtime_1.jsx)(DynamicFlow_1.default, { flowId: "storybook", initialAction: { method: 'GET', url: `/steps/${stepName}` }, fetcher: fixtureFetcher_1.fixtureFetcher, loaderConfig: { size: 'xl', initial: true, submission: false }, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, stepName)));
25
25
  });
26
- var editable = (0, react_1.storiesOf)("Dynamic Flow/Editable", module);
27
- editable.add('Dynamic Flow', EditableDynamicFlow_1["default"], {
26
+ const editable = (0, react_1.storiesOf)(`Dynamic Flow/Editable`, module);
27
+ editable.add('Dynamic Flow', EditableDynamicFlow_1.default, {
28
28
  argTypes: {
29
29
  initialStepName: {
30
30
  label: 'Initial Step',
31
31
  control: 'select',
32
- options: Object.keys(fixtures_1.fixtures.steps)
33
- }
32
+ options: Object.keys(fixtures_1.fixtures.steps),
33
+ },
34
34
  },
35
- args: { initialStepName: Object.keys(fixtures_1.fixtures)[0] }
35
+ args: { initialStepName: Object.keys(fixtures_1.fixtures)[0] },
36
36
  });
@@ -1,39 +1,26 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
- exports.__esModule = true;
17
- var jsx_runtime_1 = require("react/jsx-runtime");
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
18
7
  /* eslint-disable react/forbid-dom-props */
19
- var addon_actions_1 = require("@storybook/addon-actions");
20
- var react_1 = require("react");
21
- var fixtures_1 = require("../../fixtures");
22
- var DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
23
- var fixtureFetcher_1 = require("./fixtureFetcher");
24
- var EditableDynamicFlow = function (_a) {
25
- var _b = _a.initialStepName, initialStepName = _b === void 0 ? '' : _b;
26
- var selectedStep = fixtures_1.fixtures.steps[initialStepName] || {};
27
- var selectedInitialStep = JSON.stringify(selectedStep, null, 2);
8
+ const addon_actions_1 = require("@storybook/addon-actions");
9
+ const react_1 = require("react");
10
+ const fixtures_1 = require("../../fixtures");
11
+ const DynamicFlow_1 = __importDefault(require("../DynamicFlow"));
12
+ const fixtureFetcher_1 = require("./fixtureFetcher");
13
+ const EditableDynamicFlow = ({ initialStepName = '' }) => {
14
+ const selectedStep = fixtures_1.fixtures.steps[initialStepName] || {};
15
+ const selectedInitialStep = JSON.stringify(selectedStep, null, 2);
28
16
  return (0, jsx_runtime_1.jsx)(InteractiveDemo, { selectedInitialStep: selectedInitialStep }, selectedInitialStep);
29
17
  };
30
- var InteractiveDemo = function (_a) {
31
- var selectedInitialStep = _a.selectedInitialStep;
32
- var _b = (0, react_1.useState)(selectedInitialStep), initialStep = _b[0], setInitialStep = _b[1];
33
- var onTextAreaChange = function (event) {
18
+ const InteractiveDemo = ({ selectedInitialStep }) => {
19
+ const [initialStep, setInitialStep] = (0, react_1.useState)(selectedInitialStep);
20
+ const onTextAreaChange = (event) => {
34
21
  setInitialStep(event.target.value);
35
22
  };
36
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: { display: 'flex', gap: '1em' } }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: { flexBasis: '50%' } }, { children: [(0, jsx_runtime_1.jsx)("h3", { children: "Editable Demo" }), (0, jsx_runtime_1.jsxs)("p", { children: ["You can select an initial step from the drop down in the controls panel.", (0, jsx_runtime_1.jsx)("br", {}), "You can edit the JSON below and see the result on the right."] }), (0, jsx_runtime_1.jsx)("textarea", { wrap: "off", rows: 40, style: { fontFamily: 'monospace', fontSize: '0.9em', width: '100%' }, value: initialStep, onChange: onTextAreaChange })] })), (0, jsx_runtime_1.jsx)("div", __assign({ style: { flexBasis: '50%' } }, { children: (0, jsx_runtime_1.jsx)(DynamicFlow_1["default"], { flowId: "the-flow-id", initialStep: safeParseStepJson(initialStep), fetcher: fixtureFetcher_1.fixtureFetcher, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, initialStep) }))] })));
23
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ style: { display: 'flex', gap: '1em' } }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ style: { flexBasis: '50%' } }, { children: [(0, jsx_runtime_1.jsx)("h3", { children: "Editable Demo" }), (0, jsx_runtime_1.jsxs)("p", { children: ["You can select an initial step from the drop down in the controls panel.", (0, jsx_runtime_1.jsx)("br", {}), "You can edit the JSON below and see the result on the right."] }), (0, jsx_runtime_1.jsx)("textarea", { wrap: "off", rows: 40, style: { fontFamily: 'monospace', fontSize: '0.9em', width: '100%' }, value: initialStep, onChange: onTextAreaChange })] })), (0, jsx_runtime_1.jsx)("div", Object.assign({ style: { flexBasis: '50%' } }, { children: (0, jsx_runtime_1.jsx)(DynamicFlow_1.default, { flowId: "the-flow-id", initialStep: safeParseStepJson(initialStep), fetcher: fixtureFetcher_1.fixtureFetcher, onComplete: (0, addon_actions_1.action)('onComplete'), onStepChange: (0, addon_actions_1.action)('onStepChange'), onError: (0, addon_actions_1.action)('onError'), onEvent: (0, addon_actions_1.action)('onEvent'), onLog: (0, addon_actions_1.action)('onLog') }, initialStep) }))] })));
37
24
  };
38
25
  function safeParseStepJson(jsonStep) {
39
26
  try {
@@ -51,17 +38,17 @@ function safeParseStepJson(jsonStep) {
51
38
  components: [
52
39
  {
53
40
  type: 'alert',
54
- markdown: "**Error parsing JSON.**",
55
- context: 'warning'
41
+ markdown: `**Error parsing JSON.**`,
42
+ context: 'warning',
56
43
  },
57
44
  {
58
45
  type: 'paragraph',
59
- text: " Invalid syntax or missing elements are preventing the JSON code you entered from being parsed. Carefully review and edit the code for errors such as missing commas or brackets."
46
+ text: ` Invalid syntax or missing elements are preventing the JSON code you entered from being parsed. Carefully review and edit the code for errors such as missing commas or brackets.`,
60
47
  },
61
- ]
48
+ ],
62
49
  },
63
- ]
50
+ ],
64
51
  };
65
52
  }
66
53
  }
67
- exports["default"] = EditableDynamicFlow;
54
+ exports.default = EditableDynamicFlow;
@@ -1,76 +1,26 @@
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 };
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fixtureFetcher = void 0;
4
+ const addon_actions_1 = require("@storybook/addon-actions");
5
+ const validators_1 = require("../../common/validators");
6
+ const fixtures_1 = require("../../fixtures");
7
+ const DynamicFlow_story_1 = require("./DynamicFlow.story");
8
+ const fixtureFetcher = async (input, init) => {
9
+ (0, addon_actions_1.action)('fixtureFetcher')(input, init);
10
+ const url = getURL(input);
11
+ if (url.pathname.startsWith('/steps/')) {
12
+ return respondWithFixture(fixtures_1.fixtures.steps, url, init);
47
13
  }
14
+ if (url.pathname.startsWith('/responses/')) {
15
+ return respondWithFixture(fixtures_1.fixtures.responses, url, init);
16
+ }
17
+ if (url.pathname.startsWith('/validate')) {
18
+ return new Response(JSON.stringify({ message: 'Validation-async OK' }));
19
+ }
20
+ return new Response(null, { status: 404 });
48
21
  };
49
- exports.__esModule = true;
50
- exports.fixtureFetcher = void 0;
51
- var addon_actions_1 = require("@storybook/addon-actions");
52
- var validators_1 = require("../../common/validators");
53
- var fixtures_1 = require("../../fixtures");
54
- var DynamicFlow_story_1 = require("./DynamicFlow.story");
55
- var fixtureFetcher = function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
56
- var url;
57
- return __generator(this, function (_a) {
58
- (0, addon_actions_1.action)('fixtureFetcher')(input, init);
59
- url = getURL(input);
60
- if (url.pathname.startsWith('/steps/')) {
61
- return [2 /*return*/, respondWithFixture(fixtures_1.fixtures.steps, url, init)];
62
- }
63
- if (url.pathname.startsWith('/responses/')) {
64
- return [2 /*return*/, respondWithFixture(fixtures_1.fixtures.responses, url, init)];
65
- }
66
- if (url.pathname.startsWith('/validate')) {
67
- return [2 /*return*/, new Response(JSON.stringify({ message: 'Validation-async OK' }))];
68
- }
69
- return [2 /*return*/, new Response(null, { status: 404 })];
70
- });
71
- }); };
72
22
  exports.fixtureFetcher = fixtureFetcher;
73
- var getURL = function (input) {
23
+ const getURL = (input) => {
74
24
  if (input instanceof URL) {
75
25
  return input;
76
26
  }
@@ -79,40 +29,32 @@ var getURL = function (input) {
79
29
  }
80
30
  return new URL(input, 'http://foo');
81
31
  };
82
- var respondWithFixture = function (fixtures, url, init) { return __awaiter(void 0, void 0, void 0, function () {
83
- var fixtureNames, name, fixture, body;
32
+ const respondWithFixture = async (fixtures, url, init) => {
84
33
  var _a;
85
- return __generator(this, function (_b) {
86
- switch (_b.label) {
87
- case 0:
88
- fixtureNames = (0, DynamicFlow_story_1.getObjectKeys)(fixtures);
89
- name = url.pathname
90
- .split('/')
91
- .filter(function (part) { return !!part; })
92
- .pop();
93
- if (!fixtureNames.includes(name !== null && name !== void 0 ? name : '')) return [3 /*break*/, 3];
94
- fixture = fixtures[name];
95
- if (!url.searchParams.has('delay')) return [3 /*break*/, 2];
96
- return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, Number(url.searchParams.get('delay'))); })];
97
- case 1:
98
- _b.sent();
99
- _b.label = 2;
100
- case 2:
101
- // by convention if the url contains a "refresh"query parameterm we use the payload as model
102
- if (url.searchParams.has('refresh') &&
103
- (init === null || init === void 0 ? void 0 : init.body) &&
104
- typeof init.body === 'string' &&
105
- (0, validators_1.isObject)(fixture)) {
106
- body = JSON.parse(init.body);
107
- return [2 /*return*/, new Response(JSON.stringify(__assign(__assign({}, fixture), { model: __assign(__assign({}, ((_a = fixture.model) !== null && _a !== void 0 ? _a : {})), body) })))];
108
- }
109
- if (url.pathname.includes('exit')) {
110
- return [2 /*return*/, new Response(JSON.stringify(fixture), { headers: { 'X-DF-Exit': 'true' } })];
111
- }
112
- return [2 /*return*/, new Response(JSON.stringify(fixture))];
113
- case 3:
114
- (0, addon_actions_1.action)('ERROR 404')(url);
115
- return [2 /*return*/, new Response(null, { status: 404 })];
34
+ const fixtureNames = (0, DynamicFlow_story_1.getObjectKeys)(fixtures);
35
+ const name = url.pathname
36
+ .split('/')
37
+ .filter((part) => !!part)
38
+ .pop();
39
+ if (fixtureNames.includes(name !== null && name !== void 0 ? name : '')) {
40
+ const fixture = fixtures[name];
41
+ // by convention if the url contains a "delay" query parameter, we delay the response
42
+ if (url.searchParams.has('delay')) {
43
+ await new Promise((resolve) => setTimeout(resolve, Number(url.searchParams.get('delay'))));
44
+ }
45
+ // by convention if the url contains a "refresh"query parameterm we use the payload as model
46
+ if (url.searchParams.has('refresh') &&
47
+ (init === null || init === void 0 ? void 0 : init.body) &&
48
+ typeof init.body === 'string' &&
49
+ (0, validators_1.isObject)(fixture)) {
50
+ const body = JSON.parse(init.body);
51
+ return new Response(JSON.stringify(Object.assign(Object.assign({}, fixture), { model: Object.assign(Object.assign({}, ((_a = fixture.model) !== null && _a !== void 0 ? _a : {})), body) })));
116
52
  }
117
- });
118
- }); };
53
+ if (url.pathname.includes('exit')) {
54
+ return new Response(JSON.stringify(fixture), { headers: { 'X-DF-Exit': 'true' } });
55
+ }
56
+ return new Response(JSON.stringify(fixture));
57
+ }
58
+ (0, addon_actions_1.action)('ERROR 404')(url);
59
+ return new Response(null, { status: 404 });
60
+ };
@@ -1,47 +1,29 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- exports.__esModule = true;
18
- var jsx_runtime_1 = require("react/jsx-runtime");
19
- var react_1 = require("react");
20
- var ErrorBoundaryAlert_1 = require("./ErrorBoundaryAlert");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const ErrorBoundaryAlert_1 = require("./ErrorBoundaryAlert");
21
6
  // eslint-disable-next-line @typescript-eslint/no-empty-function
22
- var noop = function () { };
23
- var ErrorBoundary = /** @class */ (function (_super) {
24
- __extends(ErrorBoundary, _super);
25
- function ErrorBoundary(props) {
26
- var _this = _super.call(this, props) || this;
27
- _this.handleErrorReset = function () {
28
- _this.setState({ hasError: false, isFatalError: false });
7
+ const noop = () => { };
8
+ class ErrorBoundary extends react_1.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.handleErrorReset = () => {
12
+ this.setState({ hasError: false, isFatalError: false });
29
13
  };
30
- _this.state = { hasError: false, isFatalError: false };
31
- return _this;
14
+ this.state = { hasError: false, isFatalError: false };
32
15
  }
33
- ErrorBoundary.getDerivedStateFromError = function () {
16
+ static getDerivedStateFromError() {
34
17
  return { hasError: true, isFatalError: true };
35
- };
36
- ErrorBoundary.prototype.componentDidCatch = function (error) {
37
- var _a = this.props.onError, onError = _a === void 0 ? noop : _a;
18
+ }
19
+ componentDidCatch(error) {
20
+ const { onError = noop } = this.props;
38
21
  onError(error);
39
- };
40
- ErrorBoundary.prototype.render = function () {
41
- var children = this.props.children;
42
- var _a = this.state, hasError = _a.hasError, isFatalError = _a.isFatalError;
22
+ }
23
+ render() {
24
+ const { children } = this.props;
25
+ const { hasError, isFatalError } = this.state;
43
26
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [hasError && (0, jsx_runtime_1.jsx)(ErrorBoundaryAlert_1.ErrorBoundaryAlert, { onDismiss: this.handleErrorReset }), !isFatalError && children] }));
44
- };
45
- return ErrorBoundary;
46
- }(react_1.Component));
47
- exports["default"] = ErrorBoundary;
27
+ }
28
+ }
29
+ exports.default = ErrorBoundary;
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
- exports.__esModule = true;
3
- var react_intl_1 = require("react-intl");
4
- exports["default"] = (0, react_intl_1.defineMessages)({
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_intl_1 = require("react-intl");
4
+ exports.default = (0, react_intl_1.defineMessages)({
5
5
  errorAlert: {
6
6
  id: 'dynamicFlows.ErrorBoundary.errorAlert',
7
7
  defaultMessage: 'Oops. Something went wrong...',
8
- description: 'Generic error message for when something has gone wrong'
8
+ description: 'Generic error message for when something has gone wrong',
9
9
  },
10
10
  retry: {
11
11
  id: 'dynamicFlows.ErrorBoundary.retry',
12
12
  defaultMessage: 'Retry',
13
- description: 'Retry'
14
- }
13
+ description: 'Retry',
14
+ },
15
15
  });
@@ -2,18 +2,17 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- exports.__esModule = true;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ErrorBoundaryAlert = void 0;
7
- var jsx_runtime_1 = require("react/jsx-runtime");
8
- var components_1 = require("@transferwise/components");
9
- var react_intl_1 = require("react-intl");
10
- var ErrorBoundary_messages_1 = __importDefault(require("./ErrorBoundary.messages"));
11
- var ErrorBoundaryAlert = function (_a) {
12
- var onDismiss = _a.onDismiss;
13
- var formatMessage = (0, react_intl_1.useIntl)().formatMessage;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const components_1 = require("@transferwise/components");
9
+ const react_intl_1 = require("react-intl");
10
+ const ErrorBoundary_messages_1 = __importDefault(require("./ErrorBoundary.messages"));
11
+ const ErrorBoundaryAlert = ({ onDismiss }) => {
12
+ const { formatMessage } = (0, react_intl_1.useIntl)();
14
13
  return ((0, jsx_runtime_1.jsx)(components_1.Alert, { action: {
15
- text: formatMessage(ErrorBoundary_messages_1["default"].retry),
16
- href: window.location.href
17
- }, message: formatMessage(ErrorBoundary_messages_1["default"].errorAlert), type: components_1.Sentiment.NEGATIVE, className: "m-b-3", onDismiss: onDismiss }));
14
+ text: formatMessage(ErrorBoundary_messages_1.default.retry),
15
+ href: window.location.href,
16
+ }, message: formatMessage(ErrorBoundary_messages_1.default.errorAlert), type: components_1.Sentiment.NEGATIVE, className: "m-b-3", onDismiss: onDismiss }));
18
17
  };
19
18
  exports.ErrorBoundaryAlert = ErrorBoundaryAlert;
@@ -13,11 +13,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- exports.__esModule = true;
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
17
20
  exports.ErrorBoundary = void 0;
18
21
  __exportStar(require("./useDebouncedRefresh/useDebouncedRefresh"), exports);
19
22
  __exportStar(require("./useDynamicFlowState"), exports);
20
23
  __exportStar(require("./useLoader"), exports);
21
24
  var ErrorBoundary_1 = require("./errorBoundary/ErrorBoundary");
22
- __createBinding(exports, ErrorBoundary_1, "default", "ErrorBoundary");
25
+ Object.defineProperty(exports, "ErrorBoundary", { enumerable: true, get: function () { return __importDefault(ErrorBoundary_1).default; } });
23
26
  __exportStar(require("./responseParsers/response-parsers"), exports);