@wise/dynamic-flow-client 3.14.0 → 3.14.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.
package/build/main.js CHANGED
@@ -13225,7 +13225,7 @@ function isReference(block) {
13225
13225
 
13226
13226
  // src/legacy/dynamicFlow/DynamicFlow.tsx
13227
13227
  var import_react66 = require("react");
13228
- var import_react_intl46 = require("react-intl");
13228
+ var import_react_intl48 = require("react-intl");
13229
13229
 
13230
13230
  // src/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
13231
13231
  var import_react24 = require("react");
@@ -14146,11 +14146,11 @@ function useExternalStepPolling(polling, onAction) {
14146
14146
 
14147
14147
  // src/legacy/common/hooks/usePersistAsync/usePersistAsync.ts
14148
14148
  var import_react54 = require("react");
14149
- var import_react_intl37 = require("react-intl");
14149
+ var import_react_intl39 = require("react-intl");
14150
14150
 
14151
14151
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
14152
14152
  var import_react53 = require("react");
14153
- var import_react_intl36 = require("react-intl");
14153
+ var import_react_intl38 = require("react-intl");
14154
14154
 
14155
14155
  // src/legacy/common/constants/DateMode.ts
14156
14156
  var DateMode = {
@@ -15718,6 +15718,7 @@ var Help_default2 = Help2;
15718
15718
 
15719
15719
  // src/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
15720
15720
  var import_react39 = require("react");
15721
+ var import_react_intl31 = require("react-intl");
15721
15722
 
15722
15723
  // src/legacy/formControl/FormControl.tsx
15723
15724
  var import_components54 = require("@transferwise/components");
@@ -15987,6 +15988,7 @@ var _FormControl = class _FormControl extends import_react38.PureComponent {
15987
15988
  monthFormat,
15988
15989
  // FIXME pass id to all components that accept it
15989
15990
  id,
15991
+ invalid,
15990
15992
  minDate,
15991
15993
  maxDate,
15992
15994
  value,
@@ -16027,6 +16029,12 @@ var _FormControl = class _FormControl extends import_react38.PureComponent {
16027
16029
  import_components54.SelectInput,
16028
16030
  {
16029
16031
  id,
16032
+ UNSAFE_triggerButtonProps: {
16033
+ id,
16034
+ "aria-invalid": invalid,
16035
+ "aria-labelledby": void 0,
16036
+ "aria-describedby": describedBy
16037
+ },
16030
16038
  items: items.map((value2) => ({
16031
16039
  type: "option",
16032
16040
  value: value2,
@@ -16232,25 +16240,21 @@ var _FormControl = class _FormControl extends import_react38.PureComponent {
16232
16240
  }
16233
16241
  case FormControlType.FILE:
16234
16242
  case FormControlType.UPLOAD: {
16235
- return (
16236
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16237
- // @ts-expect-error - TODO: Remove this once Upload is migrated to TypeScript
16238
- /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16239
- import_components54.Upload,
16240
- __spreadProps(__spreadValues({}, uploadProps), {
16241
- usAccept: uploadProps.usAccept || "*",
16242
- usDisabled: uploadProps.usDisabled || disabled,
16243
- onSuccess: (base64url, filename) => {
16244
- this.handleOnChange(base64url, { filename });
16245
- },
16246
- onFailure: () => {
16247
- this.handleOnChange(null);
16248
- },
16249
- onCancel: () => {
16250
- this.handleOnChange(null);
16251
- }
16252
- })
16253
- )
16243
+ return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16244
+ import_components54.Upload,
16245
+ __spreadProps(__spreadValues({}, uploadProps), {
16246
+ usAccept: uploadProps.usAccept || "*",
16247
+ usDisabled: uploadProps.usDisabled || disabled,
16248
+ onSuccess: (base64url, filename) => {
16249
+ this.handleOnChange(base64url, { filename });
16250
+ },
16251
+ onFailure: () => {
16252
+ this.handleOnChange(null);
16253
+ },
16254
+ onCancel: () => {
16255
+ this.handleOnChange(null);
16256
+ }
16257
+ })
16254
16258
  );
16255
16259
  }
16256
16260
  case FormControlType.TEXT:
@@ -16303,6 +16307,7 @@ _FormControl.defaultProps = {
16303
16307
  disabled: false,
16304
16308
  displayPattern: null,
16305
16309
  id: null,
16310
+ invalid: false,
16306
16311
  label: "",
16307
16312
  max: null,
16308
16313
  maxDate: null,
@@ -16397,6 +16402,7 @@ function SchemaFormControl(props) {
16397
16402
  schema,
16398
16403
  value,
16399
16404
  disabled,
16405
+ invalid,
16400
16406
  required,
16401
16407
  onChange,
16402
16408
  onFocus,
@@ -16405,6 +16411,7 @@ function SchemaFormControl(props) {
16405
16411
  describedBy
16406
16412
  } = props;
16407
16413
  const log = useLogger();
16414
+ const intl = (0, import_react_intl31.useIntl)();
16408
16415
  const getSanitisedValue = (value2) => isNativeInput(schema.type) && (isNull3(value2) || isUndefined3(value2)) ? "" : value2;
16409
16416
  const onModelChange = (value2, type, metadata) => {
16410
16417
  onChange(getValidBasicModelOrNull(value2, schema), type, metadata);
@@ -16426,6 +16433,7 @@ function SchemaFormControl(props) {
16426
16433
  name: id,
16427
16434
  label: schema.title,
16428
16435
  description: schema.description,
16436
+ invalid,
16429
16437
  options: options || [],
16430
16438
  placeholder: schema.placeholder,
16431
16439
  autoComplete: !schema.help,
@@ -16433,7 +16441,9 @@ function SchemaFormControl(props) {
16433
16441
  disabled: disabled || schema.disabled,
16434
16442
  displayPattern: schema.displayFormat,
16435
16443
  // TODO: LOW avoid type assertion below
16436
- uploadProps: mapSchemaToUploadOptions(schema),
16444
+ uploadProps: __spreadValues({
16445
+ intl
16446
+ }, mapSchemaToUploadOptions(schema)),
16437
16447
  describedBy,
16438
16448
  required
16439
16449
  };
@@ -16554,6 +16564,7 @@ function OneOfSchema(props) {
16554
16564
  schema: schemaForSelect,
16555
16565
  value: schemaIndex,
16556
16566
  disabled: props.disabled,
16567
+ invalid: !isEmpty(props.errors) || validations.length > 0,
16557
16568
  describedBy: feedbackId,
16558
16569
  required: props.required,
16559
16570
  onChange: onChooseNewSchema,
@@ -16642,6 +16653,7 @@ var OneOfSchema_default = OneOfSchema;
16642
16653
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
16643
16654
  var import_classnames12 = __toESM(require_classnames());
16644
16655
  var import_react42 = require("react");
16656
+ var import_react_intl32 = require("react-intl");
16645
16657
 
16646
16658
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
16647
16659
  var import_components56 = require("@transferwise/components");
@@ -16669,8 +16681,10 @@ function UploadInputAdapter(props) {
16669
16681
  method: httpOptions.method || "POST",
16670
16682
  body: formData
16671
16683
  }).then((response) => {
16684
+ var _a;
16672
16685
  if (response.ok) {
16673
- onSuccess == null ? void 0 : onSuccess(response.clone());
16686
+ const file = formData.get((_a = httpOptions.fileInputName) != null ? _a : "file");
16687
+ onSuccess == null ? void 0 : onSuccess(response.clone(), file ? file.name : "");
16674
16688
  return response.json().then((responseBody) => ({
16675
16689
  id: responseBody[idProperty]
16676
16690
  }));
@@ -16706,6 +16720,7 @@ function PersistAsyncBlobSchema(props) {
16706
16720
  const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react42.useState)(null);
16707
16721
  const [validations, setValidations] = (0, import_react42.useState)([]);
16708
16722
  const [changed, setChanged] = (0, import_react42.useState)(false);
16723
+ const intl = (0, import_react_intl32.useIntl)();
16709
16724
  const httpClient = useHttpClient();
16710
16725
  const onEvent = useEventDispatcher();
16711
16726
  (0, import_react42.useEffect)(() => {
@@ -16722,7 +16737,8 @@ function PersistAsyncBlobSchema(props) {
16722
16737
  setChanged(true);
16723
16738
  onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: schema.$id });
16724
16739
  };
16725
- const onFailure = async (errorResponse) => {
16740
+ const onFailure = async (error) => {
16741
+ const errorResponse = error;
16726
16742
  if (errorResponse.response && isStatus422(errorResponse.response.status)) {
16727
16743
  const jsonResponse = await errorResponse.response.json();
16728
16744
  setPersistAsyncValidationMessages(jsonResponse.validation || {});
@@ -16750,6 +16766,7 @@ function PersistAsyncBlobSchema(props) {
16750
16766
  UploadInputAdapter,
16751
16767
  __spreadValues({
16752
16768
  id,
16769
+ intl,
16753
16770
  fileId: model,
16754
16771
  idProperty: schema.persistAsync.idProperty,
16755
16772
  animationDelay: 0,
@@ -16949,11 +16966,11 @@ var PromotedOneOfSchema_default = PromotedOneOfSchema;
16949
16966
 
16950
16967
  // src/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.tsx
16951
16968
  var import_components59 = require("@transferwise/components");
16952
- var import_react_intl32 = require("react-intl");
16969
+ var import_react_intl34 = require("react-intl");
16953
16970
 
16954
16971
  // src/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.ts
16955
- var import_react_intl31 = require("react-intl");
16956
- var ReadOnlySchema_messages_default = (0, import_react_intl31.defineMessages)({
16972
+ var import_react_intl33 = require("react-intl");
16973
+ var ReadOnlySchema_messages_default = (0, import_react_intl33.defineMessages)({
16957
16974
  yes: {
16958
16975
  id: "dynamicFlows.ReadOnlySchema.yes",
16959
16976
  defaultMessage: "Yes",
@@ -16970,7 +16987,7 @@ var ReadOnlySchema_messages_default = (0, import_react_intl31.defineMessages)({
16970
16987
  var import_jsx_runtime99 = require("react/jsx-runtime");
16971
16988
  function ReadOnlySchema({ schema, model }) {
16972
16989
  const { title = "" } = schema;
16973
- const { formatMessage } = (0, import_react_intl32.useIntl)();
16990
+ const { formatMessage } = (0, import_react_intl34.useIntl)();
16974
16991
  const value = getValueForSchema({ schema, model, formatMessage });
16975
16992
  return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components59.DefinitionList, { layout: import_components59.Layout.VERTICAL_ONE_COLUMN, definitions: [{ title, value, key: "" }] });
16976
16993
  }
@@ -17471,11 +17488,11 @@ var DynamicLoadingIndicator_default = DynamicLoadingIndicator;
17471
17488
 
17472
17489
  // src/legacy/layout/paragraph/DynamicParagraph.tsx
17473
17490
  var import_components67 = require("@transferwise/components");
17474
- var import_react_intl34 = require("react-intl");
17491
+ var import_react_intl36 = require("react-intl");
17475
17492
 
17476
17493
  // src/common/messages/paragraph.messages.ts
17477
- var import_react_intl33 = require("react-intl");
17478
- var paragraph_messages_default2 = (0, import_react_intl33.defineMessages)({
17494
+ var import_react_intl35 = require("react-intl");
17495
+ var paragraph_messages_default2 = (0, import_react_intl35.defineMessages)({
17479
17496
  copy: {
17480
17497
  id: "dynamicFlows.DynamicParagraph.copy",
17481
17498
  defaultMessage: "Copy",
@@ -17511,7 +17528,7 @@ function BasicDynamicParagraph({ component }) {
17511
17528
  ] });
17512
17529
  }
17513
17530
  function CopyableDynamicParagraph({ component }) {
17514
- const { formatMessage } = (0, import_react_intl34.useIntl)();
17531
+ const { formatMessage } = (0, import_react_intl36.useIntl)();
17515
17532
  const createSnackbar = useSnackBarIfAvailable2();
17516
17533
  const { text } = component;
17517
17534
  const copy = () => {
@@ -17626,7 +17643,7 @@ var SearchInput = ({ title, value, onFocus, onChange }) => {
17626
17643
 
17627
17644
  // src/legacy/layout/search/SearchResults.tsx
17628
17645
  var import_components70 = require("@transferwise/components");
17629
- var import_react_intl35 = require("react-intl");
17646
+ var import_react_intl37 = require("react-intl");
17630
17647
  var import_jsx_runtime113 = require("react/jsx-runtime");
17631
17648
  function SearchResults2({ results, emptyMessage, onSelect }) {
17632
17649
  if (results.length === 0) {
@@ -17646,7 +17663,7 @@ function SearchResults2({ results, emptyMessage, onSelect }) {
17646
17663
  )) });
17647
17664
  }
17648
17665
  function ErrorResult2({ onRetrySearch }) {
17649
- const intl = (0, import_react_intl35.useIntl)();
17666
+ const intl = (0, import_react_intl37.useIntl)();
17650
17667
  return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)("p", { className: "m-t-2", children: [
17651
17668
  intl.formatMessage(generic_error_messages_default.genericError),
17652
17669
  "\xA0",
@@ -18013,7 +18030,7 @@ var controlTypesWithPersistOnChange = /* @__PURE__ */ new Set([
18013
18030
  ]);
18014
18031
  function PersistAsyncBasicSchema(props) {
18015
18032
  const { schema, required, submitted, errors, onChange, onPersistAsync } = props;
18016
- const intl = (0, import_react_intl36.useIntl)();
18033
+ const intl = (0, import_react_intl38.useIntl)();
18017
18034
  const httpClient = useHttpClient();
18018
18035
  const onEvent = useEventDispatcher();
18019
18036
  const [persistAsyncModel, setPersistAsyncModel] = (0, import_react53.useState)(null);
@@ -18111,7 +18128,7 @@ var PersistAsyncBasicSchema_default = PersistAsyncBasicSchema;
18111
18128
  var usePersistAsync = (persistAsync) => {
18112
18129
  const [abortController, setAbortController] = (0, import_react54.useState)(null);
18113
18130
  const httpClient = useHttpClient();
18114
- const intl = (0, import_react_intl37.useIntl)();
18131
+ const intl = (0, import_react_intl39.useIntl)();
18115
18132
  const { schema } = persistAsync;
18116
18133
  async function handlePersistAsync(model) {
18117
18134
  const isInvalidSchema = model instanceof Blob ? !isBlobSchema2(schema) : !isValidSchema(model, schema);
@@ -18342,12 +18359,12 @@ var import_react62 = require("react");
18342
18359
 
18343
18360
  // src/common/cameraCapture/CameraCapture.tsx
18344
18361
  var import_react61 = require("react");
18345
- var import_react_intl42 = require("react-intl");
18362
+ var import_react_intl44 = require("react-intl");
18346
18363
  var import_react_webcam = __toESM(require("react-webcam"));
18347
18364
 
18348
18365
  // src/common/cameraCapture/CameraCapture.messages.ts
18349
- var import_react_intl38 = require("react-intl");
18350
- var CameraCapture_messages_default = (0, import_react_intl38.defineMessages)({
18366
+ var import_react_intl40 = require("react-intl");
18367
+ var CameraCapture_messages_default = (0, import_react_intl40.defineMessages)({
18351
18368
  reviewSubmit: {
18352
18369
  id: "dynamicFlows.CameraCapture.reviewSubmit",
18353
18370
  defaultMessage: "Yes, submit",
@@ -18407,14 +18424,14 @@ var CameraCapture_messages_default = (0, import_react_intl38.defineMessages)({
18407
18424
 
18408
18425
  // src/common/cameraCapture/components/bottomBar/BottomBar.tsx
18409
18426
  var import_components73 = require("@transferwise/components");
18410
- var import_react_intl39 = require("react-intl");
18427
+ var import_react_intl41 = require("react-intl");
18411
18428
  var import_jsx_runtime119 = require("react/jsx-runtime");
18412
18429
  var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: "bottom-bar", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(CaptureButton, { onClick: onCapture }) });
18413
18430
  var ReviewBottomBar = ({
18414
18431
  onSubmit,
18415
18432
  onRetry
18416
18433
  }) => {
18417
- const intl = (0, import_react_intl39.useIntl)();
18434
+ const intl = (0, import_react_intl41.useIntl)();
18418
18435
  return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: "bottom-bar p-x-2", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("div", { className: "col-xs-12 col-md-6 col-md-offset-3", children: [
18419
18436
  /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
18420
18437
  import_components73.Button,
@@ -18453,11 +18470,11 @@ var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0, import_jsx_runtime119.j
18453
18470
  );
18454
18471
 
18455
18472
  // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18456
- var import_react_intl41 = require("react-intl");
18473
+ var import_react_intl43 = require("react-intl");
18457
18474
 
18458
18475
  // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.ts
18459
- var import_react_intl40 = require("react-intl");
18460
- var OrientationLockOverlay_messages_default = (0, import_react_intl40.defineMessages)({
18476
+ var import_react_intl42 = require("react-intl");
18477
+ var OrientationLockOverlay_messages_default = (0, import_react_intl42.defineMessages)({
18461
18478
  text: {
18462
18479
  id: "dynamicFlows.CameraCapture.rotatePhone.text",
18463
18480
  defaultMessage: "Rotate your phone to portrait view to take a photo",
@@ -18468,7 +18485,7 @@ var OrientationLockOverlay_messages_default = (0, import_react_intl40.defineMess
18468
18485
  // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18469
18486
  var import_jsx_runtime120 = require("react/jsx-runtime");
18470
18487
  function OrientationLockOverlay() {
18471
- const intl = (0, import_react_intl41.useIntl)();
18488
+ const intl = (0, import_react_intl43.useIntl)();
18472
18489
  return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("div", { className: "orientation-lock-overlay", children: [
18473
18490
  /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
18474
18491
  "img",
@@ -18758,7 +18775,7 @@ function CameraCapture({
18758
18775
  shouldLockOrientation,
18759
18776
  onEvent
18760
18777
  );
18761
- const intl = (0, import_react_intl42.useIntl)();
18778
+ const intl = (0, import_react_intl44.useIntl)();
18762
18779
  const handleCapture = (0, import_react61.useCallback)(async () => {
18763
18780
  var _a, _b, _c, _d, _e, _f;
18764
18781
  if (((_a = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _a.video) && ((_c = (_b = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _b.video) == null ? void 0 : _c.readyState) >= 3) {
@@ -18981,11 +18998,11 @@ function getFirstAction(step) {
18981
18998
  }
18982
18999
 
18983
19000
  // src/legacy/step/externalConfirmationStep/ExternalConfirmationStep.tsx
18984
- var import_react_intl44 = require("react-intl");
19001
+ var import_react_intl46 = require("react-intl");
18985
19002
 
18986
19003
  // src/common/messages/external-confirmation.messages.ts
18987
- var import_react_intl43 = require("react-intl");
18988
- var external_confirmation_messages_default2 = (0, import_react_intl43.defineMessages)({
19004
+ var import_react_intl45 = require("react-intl");
19005
+ var external_confirmation_messages_default2 = (0, import_react_intl45.defineMessages)({
18989
19006
  title: {
18990
19007
  id: "dynamicFlows.ExternalConfirmation.title",
18991
19008
  defaultMessage: "Please confirm",
@@ -19013,7 +19030,7 @@ var import_jsx_runtime125 = require("react/jsx-runtime");
19013
19030
  var noop6 = () => {
19014
19031
  };
19015
19032
  function ExternalConfirmationStep({ url, onClose }) {
19016
- const { formatMessage } = (0, import_react_intl44.useIntl)();
19033
+ const { formatMessage } = (0, import_react_intl46.useIntl)();
19017
19034
  return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
19018
19035
  DynamicLayout_default,
19019
19036
  {
@@ -19386,9 +19403,9 @@ var assertResponseIsValid2 = (response) => {
19386
19403
  var isResponse2 = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
19387
19404
 
19388
19405
  // src/legacy/dynamicFlow/utils/useErrorResponse.tsx
19389
- var import_react_intl45 = require("react-intl");
19406
+ var import_react_intl47 = require("react-intl");
19390
19407
  var useErrorResponse = () => {
19391
- const { formatMessage } = (0, import_react_intl45.useIntl)();
19408
+ const { formatMessage } = (0, import_react_intl47.useIntl)();
19392
19409
  return async (response, fetchType, isInitialRequest) => {
19393
19410
  try {
19394
19411
  const errorResponse = await parseErrorResponse(response);
@@ -19432,7 +19449,7 @@ var DynamicFlowComponent = ({
19432
19449
  setSchemaModel
19433
19450
  } = useDynamicFlowState(initialStep);
19434
19451
  const [submitted, setSubmitted] = (0, import_react66.useState)(false);
19435
- const { locale } = (0, import_react_intl46.useIntl)();
19452
+ const { locale } = (0, import_react_intl48.useIntl)();
19436
19453
  const { isLoading, loader, setLoadingState } = useLoader(
19437
19454
  loaderConfig,
19438
19455
  initialStep ? "idle" : "initial"