@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.mjs CHANGED
@@ -13207,7 +13207,7 @@ function isReference(block) {
13207
13207
 
13208
13208
  // src/legacy/dynamicFlow/DynamicFlow.tsx
13209
13209
  import { useCallback as useCallback11, useEffect as useEffect26, useMemo as useMemo23, useState as useState34 } from "react";
13210
- import { useIntl as useIntl26 } from "react-intl";
13210
+ import { useIntl as useIntl28 } from "react-intl";
13211
13211
 
13212
13212
  // src/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
13213
13213
  import { createContext as createContext4, useContext as useContext5, useMemo as useMemo8 } from "react";
@@ -14128,11 +14128,11 @@ function useExternalStepPolling(polling, onAction) {
14128
14128
 
14129
14129
  // src/legacy/common/hooks/usePersistAsync/usePersistAsync.ts
14130
14130
  import { useState as useState28 } from "react";
14131
- import { useIntl as useIntl20 } from "react-intl";
14131
+ import { useIntl as useIntl22 } from "react-intl";
14132
14132
 
14133
14133
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
14134
14134
  import { useEffect as useEffect18, useState as useState27 } from "react";
14135
- import { useIntl as useIntl19 } from "react-intl";
14135
+ import { useIntl as useIntl21 } from "react-intl";
14136
14136
 
14137
14137
  // src/legacy/common/constants/DateMode.ts
14138
14138
  var DateMode = {
@@ -15703,6 +15703,7 @@ var Help_default2 = Help2;
15703
15703
 
15704
15704
  // src/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
15705
15705
  import { useEffect as useEffect11 } from "react";
15706
+ import { useIntl as useIntl16 } from "react-intl";
15706
15707
 
15707
15708
  // src/legacy/formControl/FormControl.tsx
15708
15709
  import {
@@ -15984,6 +15985,7 @@ var _FormControl = class _FormControl extends PureComponent {
15984
15985
  monthFormat,
15985
15986
  // FIXME pass id to all components that accept it
15986
15987
  id,
15988
+ invalid,
15987
15989
  minDate,
15988
15990
  maxDate,
15989
15991
  value,
@@ -16024,6 +16026,12 @@ var _FormControl = class _FormControl extends PureComponent {
16024
16026
  SelectInput4,
16025
16027
  {
16026
16028
  id,
16029
+ UNSAFE_triggerButtonProps: {
16030
+ id,
16031
+ "aria-invalid": invalid,
16032
+ "aria-labelledby": void 0,
16033
+ "aria-describedby": describedBy
16034
+ },
16027
16035
  items: items.map((value2) => ({
16028
16036
  type: "option",
16029
16037
  value: value2,
@@ -16229,25 +16237,21 @@ var _FormControl = class _FormControl extends PureComponent {
16229
16237
  }
16230
16238
  case FormControlType.FILE:
16231
16239
  case FormControlType.UPLOAD: {
16232
- return (
16233
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
16234
- // @ts-expect-error - TODO: Remove this once Upload is migrated to TypeScript
16235
- /* @__PURE__ */ jsx89(
16236
- Upload2,
16237
- __spreadProps(__spreadValues({}, uploadProps), {
16238
- usAccept: uploadProps.usAccept || "*",
16239
- usDisabled: uploadProps.usDisabled || disabled,
16240
- onSuccess: (base64url, filename) => {
16241
- this.handleOnChange(base64url, { filename });
16242
- },
16243
- onFailure: () => {
16244
- this.handleOnChange(null);
16245
- },
16246
- onCancel: () => {
16247
- this.handleOnChange(null);
16248
- }
16249
- })
16250
- )
16240
+ return /* @__PURE__ */ jsx89(
16241
+ Upload2,
16242
+ __spreadProps(__spreadValues({}, uploadProps), {
16243
+ usAccept: uploadProps.usAccept || "*",
16244
+ usDisabled: uploadProps.usDisabled || disabled,
16245
+ onSuccess: (base64url, filename) => {
16246
+ this.handleOnChange(base64url, { filename });
16247
+ },
16248
+ onFailure: () => {
16249
+ this.handleOnChange(null);
16250
+ },
16251
+ onCancel: () => {
16252
+ this.handleOnChange(null);
16253
+ }
16254
+ })
16251
16255
  );
16252
16256
  }
16253
16257
  case FormControlType.TEXT:
@@ -16300,6 +16304,7 @@ _FormControl.defaultProps = {
16300
16304
  disabled: false,
16301
16305
  displayPattern: null,
16302
16306
  id: null,
16307
+ invalid: false,
16303
16308
  label: "",
16304
16309
  max: null,
16305
16310
  maxDate: null,
@@ -16394,6 +16399,7 @@ function SchemaFormControl(props) {
16394
16399
  schema,
16395
16400
  value,
16396
16401
  disabled,
16402
+ invalid,
16397
16403
  required,
16398
16404
  onChange,
16399
16405
  onFocus,
@@ -16402,6 +16408,7 @@ function SchemaFormControl(props) {
16402
16408
  describedBy
16403
16409
  } = props;
16404
16410
  const log = useLogger();
16411
+ const intl = useIntl16();
16405
16412
  const getSanitisedValue = (value2) => isNativeInput(schema.type) && (isNull3(value2) || isUndefined3(value2)) ? "" : value2;
16406
16413
  const onModelChange = (value2, type, metadata) => {
16407
16414
  onChange(getValidBasicModelOrNull(value2, schema), type, metadata);
@@ -16423,6 +16430,7 @@ function SchemaFormControl(props) {
16423
16430
  name: id,
16424
16431
  label: schema.title,
16425
16432
  description: schema.description,
16433
+ invalid,
16426
16434
  options: options || [],
16427
16435
  placeholder: schema.placeholder,
16428
16436
  autoComplete: !schema.help,
@@ -16430,7 +16438,9 @@ function SchemaFormControl(props) {
16430
16438
  disabled: disabled || schema.disabled,
16431
16439
  displayPattern: schema.displayFormat,
16432
16440
  // TODO: LOW avoid type assertion below
16433
- uploadProps: mapSchemaToUploadOptions(schema),
16441
+ uploadProps: __spreadValues({
16442
+ intl
16443
+ }, mapSchemaToUploadOptions(schema)),
16434
16444
  describedBy,
16435
16445
  required
16436
16446
  };
@@ -16551,6 +16561,7 @@ function OneOfSchema(props) {
16551
16561
  schema: schemaForSelect,
16552
16562
  value: schemaIndex,
16553
16563
  disabled: props.disabled,
16564
+ invalid: !isEmpty(props.errors) || validations.length > 0,
16554
16565
  describedBy: feedbackId,
16555
16566
  required: props.required,
16556
16567
  onChange: onChooseNewSchema,
@@ -16639,6 +16650,7 @@ var OneOfSchema_default = OneOfSchema;
16639
16650
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
16640
16651
  var import_classnames12 = __toESM(require_classnames());
16641
16652
  import { useEffect as useEffect13, useState as useState19 } from "react";
16653
+ import { useIntl as useIntl17 } from "react-intl";
16642
16654
 
16643
16655
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
16644
16656
  import { Status as Status2, UploadInput as UploadInput4 } from "@transferwise/components";
@@ -16666,8 +16678,10 @@ function UploadInputAdapter(props) {
16666
16678
  method: httpOptions.method || "POST",
16667
16679
  body: formData
16668
16680
  }).then((response) => {
16681
+ var _a;
16669
16682
  if (response.ok) {
16670
- onSuccess == null ? void 0 : onSuccess(response.clone());
16683
+ const file = formData.get((_a = httpOptions.fileInputName) != null ? _a : "file");
16684
+ onSuccess == null ? void 0 : onSuccess(response.clone(), file ? file.name : "");
16671
16685
  return response.json().then((responseBody) => ({
16672
16686
  id: responseBody[idProperty]
16673
16687
  }));
@@ -16703,6 +16717,7 @@ function PersistAsyncBlobSchema(props) {
16703
16717
  const [persistAsyncValidations, setPersistAsyncValidations] = useState19(null);
16704
16718
  const [validations, setValidations] = useState19([]);
16705
16719
  const [changed, setChanged] = useState19(false);
16720
+ const intl = useIntl17();
16706
16721
  const httpClient = useHttpClient();
16707
16722
  const onEvent = useEventDispatcher();
16708
16723
  useEffect13(() => {
@@ -16719,7 +16734,8 @@ function PersistAsyncBlobSchema(props) {
16719
16734
  setChanged(true);
16720
16735
  onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: schema.$id });
16721
16736
  };
16722
- const onFailure = async (errorResponse) => {
16737
+ const onFailure = async (error) => {
16738
+ const errorResponse = error;
16723
16739
  if (errorResponse.response && isStatus422(errorResponse.response.status)) {
16724
16740
  const jsonResponse = await errorResponse.response.json();
16725
16741
  setPersistAsyncValidationMessages(jsonResponse.validation || {});
@@ -16747,6 +16763,7 @@ function PersistAsyncBlobSchema(props) {
16747
16763
  UploadInputAdapter,
16748
16764
  __spreadValues({
16749
16765
  id,
16766
+ intl,
16750
16767
  fileId: model,
16751
16768
  idProperty: schema.persistAsync.idProperty,
16752
16769
  animationDelay: 0,
@@ -16946,7 +16963,7 @@ var PromotedOneOfSchema_default = PromotedOneOfSchema;
16946
16963
 
16947
16964
  // src/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.tsx
16948
16965
  import { DefinitionList as DefinitionList2, Layout } from "@transferwise/components";
16949
- import { useIntl as useIntl16 } from "react-intl";
16966
+ import { useIntl as useIntl18 } from "react-intl";
16950
16967
 
16951
16968
  // src/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.ts
16952
16969
  import { defineMessages as defineMessages16 } from "react-intl";
@@ -16967,7 +16984,7 @@ var ReadOnlySchema_messages_default = defineMessages16({
16967
16984
  import { Fragment as Fragment18, jsx as jsx99, jsxs as jsxs35 } from "react/jsx-runtime";
16968
16985
  function ReadOnlySchema({ schema, model }) {
16969
16986
  const { title = "" } = schema;
16970
- const { formatMessage } = useIntl16();
16987
+ const { formatMessage } = useIntl18();
16971
16988
  const value = getValueForSchema({ schema, model, formatMessage });
16972
16989
  return /* @__PURE__ */ jsx99(DefinitionList2, { layout: Layout.VERTICAL_ONE_COLUMN, definitions: [{ title, value, key: "" }] });
16973
16990
  }
@@ -17468,7 +17485,7 @@ var DynamicLoadingIndicator_default = DynamicLoadingIndicator;
17468
17485
 
17469
17486
  // src/legacy/layout/paragraph/DynamicParagraph.tsx
17470
17487
  import { Button as Button8 } from "@transferwise/components";
17471
- import { useIntl as useIntl17 } from "react-intl";
17488
+ import { useIntl as useIntl19 } from "react-intl";
17472
17489
 
17473
17490
  // src/common/messages/paragraph.messages.ts
17474
17491
  import { defineMessages as defineMessages17 } from "react-intl";
@@ -17508,7 +17525,7 @@ function BasicDynamicParagraph({ component }) {
17508
17525
  ] });
17509
17526
  }
17510
17527
  function CopyableDynamicParagraph({ component }) {
17511
- const { formatMessage } = useIntl17();
17528
+ const { formatMessage } = useIntl19();
17512
17529
  const createSnackbar = useSnackBarIfAvailable2();
17513
17530
  const { text } = component;
17514
17531
  const copy = () => {
@@ -17623,7 +17640,7 @@ var SearchInput = ({ title, value, onFocus, onChange }) => {
17623
17640
 
17624
17641
  // src/legacy/layout/search/SearchResults.tsx
17625
17642
  import { NavigationOption as NavigationOption7, NavigationOptionsList as NavigationOptionsList4 } from "@transferwise/components";
17626
- import { useIntl as useIntl18 } from "react-intl";
17643
+ import { useIntl as useIntl20 } from "react-intl";
17627
17644
  import { jsx as jsx113, jsxs as jsxs41 } from "react/jsx-runtime";
17628
17645
  function SearchResults2({ results, emptyMessage, onSelect }) {
17629
17646
  if (results.length === 0) {
@@ -17643,7 +17660,7 @@ function SearchResults2({ results, emptyMessage, onSelect }) {
17643
17660
  )) });
17644
17661
  }
17645
17662
  function ErrorResult2({ onRetrySearch }) {
17646
- const intl = useIntl18();
17663
+ const intl = useIntl20();
17647
17664
  return /* @__PURE__ */ jsxs41("p", { className: "m-t-2", children: [
17648
17665
  intl.formatMessage(generic_error_messages_default.genericError),
17649
17666
  "\xA0",
@@ -18010,7 +18027,7 @@ var controlTypesWithPersistOnChange = /* @__PURE__ */ new Set([
18010
18027
  ]);
18011
18028
  function PersistAsyncBasicSchema(props) {
18012
18029
  const { schema, required, submitted, errors, onChange, onPersistAsync } = props;
18013
- const intl = useIntl19();
18030
+ const intl = useIntl21();
18014
18031
  const httpClient = useHttpClient();
18015
18032
  const onEvent = useEventDispatcher();
18016
18033
  const [persistAsyncModel, setPersistAsyncModel] = useState27(null);
@@ -18108,7 +18125,7 @@ var PersistAsyncBasicSchema_default = PersistAsyncBasicSchema;
18108
18125
  var usePersistAsync = (persistAsync) => {
18109
18126
  const [abortController, setAbortController] = useState28(null);
18110
18127
  const httpClient = useHttpClient();
18111
- const intl = useIntl20();
18128
+ const intl = useIntl22();
18112
18129
  const { schema } = persistAsync;
18113
18130
  async function handlePersistAsync(model) {
18114
18131
  const isInvalidSchema = model instanceof Blob ? !isBlobSchema2(schema) : !isValidSchema(model, schema);
@@ -18339,7 +18356,7 @@ import { useEffect as useEffect25, useState as useState31 } from "react";
18339
18356
 
18340
18357
  // src/common/cameraCapture/CameraCapture.tsx
18341
18358
  import { useCallback as useCallback10, useEffect as useEffect24, useMemo as useMemo21, useRef as useRef8, useState as useState30 } from "react";
18342
- import { useIntl as useIntl23 } from "react-intl";
18359
+ import { useIntl as useIntl25 } from "react-intl";
18343
18360
  import Webcam from "react-webcam";
18344
18361
 
18345
18362
  // src/common/cameraCapture/CameraCapture.messages.ts
@@ -18404,14 +18421,14 @@ var CameraCapture_messages_default = defineMessages18({
18404
18421
 
18405
18422
  // src/common/cameraCapture/components/bottomBar/BottomBar.tsx
18406
18423
  import { Button as Button10, ControlType, Priority, Size as Size3 } from "@transferwise/components";
18407
- import { useIntl as useIntl21 } from "react-intl";
18424
+ import { useIntl as useIntl23 } from "react-intl";
18408
18425
  import { jsx as jsx119, jsxs as jsxs45 } from "react/jsx-runtime";
18409
18426
  var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ jsx119("div", { className: "bottom-bar", children: /* @__PURE__ */ jsx119(CaptureButton, { onClick: onCapture }) });
18410
18427
  var ReviewBottomBar = ({
18411
18428
  onSubmit,
18412
18429
  onRetry
18413
18430
  }) => {
18414
- const intl = useIntl21();
18431
+ const intl = useIntl23();
18415
18432
  return /* @__PURE__ */ jsx119("div", { className: "bottom-bar p-x-2", children: /* @__PURE__ */ jsx119("div", { className: "row", children: /* @__PURE__ */ jsxs45("div", { className: "col-xs-12 col-md-6 col-md-offset-3", children: [
18416
18433
  /* @__PURE__ */ jsx119(
18417
18434
  Button10,
@@ -18450,7 +18467,7 @@ var CaptureButton = ({ onClick }) => /* @__PURE__ */ jsx119(
18450
18467
  );
18451
18468
 
18452
18469
  // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18453
- import { useIntl as useIntl22 } from "react-intl";
18470
+ import { useIntl as useIntl24 } from "react-intl";
18454
18471
 
18455
18472
  // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.ts
18456
18473
  import { defineMessages as defineMessages19 } from "react-intl";
@@ -18465,7 +18482,7 @@ var OrientationLockOverlay_messages_default = defineMessages19({
18465
18482
  // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18466
18483
  import { jsx as jsx120, jsxs as jsxs46 } from "react/jsx-runtime";
18467
18484
  function OrientationLockOverlay() {
18468
- const intl = useIntl22();
18485
+ const intl = useIntl24();
18469
18486
  return /* @__PURE__ */ jsxs46("div", { className: "orientation-lock-overlay", children: [
18470
18487
  /* @__PURE__ */ jsx120(
18471
18488
  "img",
@@ -18755,7 +18772,7 @@ function CameraCapture({
18755
18772
  shouldLockOrientation,
18756
18773
  onEvent
18757
18774
  );
18758
- const intl = useIntl23();
18775
+ const intl = useIntl25();
18759
18776
  const handleCapture = useCallback10(async () => {
18760
18777
  var _a, _b, _c, _d, _e, _f;
18761
18778
  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) {
@@ -18978,7 +18995,7 @@ function getFirstAction(step) {
18978
18995
  }
18979
18996
 
18980
18997
  // src/legacy/step/externalConfirmationStep/ExternalConfirmationStep.tsx
18981
- import { useIntl as useIntl24 } from "react-intl";
18998
+ import { useIntl as useIntl26 } from "react-intl";
18982
18999
 
18983
19000
  // src/common/messages/external-confirmation.messages.ts
18984
19001
  import { defineMessages as defineMessages20 } from "react-intl";
@@ -19010,7 +19027,7 @@ import { jsx as jsx125 } from "react/jsx-runtime";
19010
19027
  var noop6 = () => {
19011
19028
  };
19012
19029
  function ExternalConfirmationStep({ url, onClose }) {
19013
- const { formatMessage } = useIntl24();
19030
+ const { formatMessage } = useIntl26();
19014
19031
  return /* @__PURE__ */ jsx125(
19015
19032
  DynamicLayout_default,
19016
19033
  {
@@ -19383,9 +19400,9 @@ var assertResponseIsValid2 = (response) => {
19383
19400
  var isResponse2 = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
19384
19401
 
19385
19402
  // src/legacy/dynamicFlow/utils/useErrorResponse.tsx
19386
- import { useIntl as useIntl25 } from "react-intl";
19403
+ import { useIntl as useIntl27 } from "react-intl";
19387
19404
  var useErrorResponse = () => {
19388
- const { formatMessage } = useIntl25();
19405
+ const { formatMessage } = useIntl27();
19389
19406
  return async (response, fetchType, isInitialRequest) => {
19390
19407
  try {
19391
19408
  const errorResponse = await parseErrorResponse(response);
@@ -19429,7 +19446,7 @@ var DynamicFlowComponent = ({
19429
19446
  setSchemaModel
19430
19447
  } = useDynamicFlowState(initialStep);
19431
19448
  const [submitted, setSubmitted] = useState34(false);
19432
- const { locale } = useIntl26();
19449
+ const { locale } = useIntl28();
19433
19450
  const { isLoading, loader, setLoadingState } = useLoader(
19434
19451
  loaderConfig,
19435
19452
  initialStep ? "idle" : "initial"
@@ -62,6 +62,7 @@ export default class FormControl extends PureComponent<FormControlProps, FormCon
62
62
  disabled: boolean;
63
63
  displayPattern: null;
64
64
  id: null;
65
+ invalid: boolean;
65
66
  label: string;
66
67
  max: null;
67
68
  maxDate: null;
@@ -113,6 +114,7 @@ type FormControlProps = {
113
114
  disabled?: boolean;
114
115
  displayPattern?: string;
115
116
  id: string;
117
+ invalid?: boolean;
116
118
  label?: string;
117
119
  description?: string;
118
120
  max?: number;
@@ -23,6 +23,7 @@ export type SchemaFormControlProps = {
23
23
  onSearchChange?: (searchValue: string) => void;
24
24
  disabled?: boolean;
25
25
  describedBy?: string | undefined;
26
+ invalid?: boolean;
26
27
  required?: boolean;
27
28
  };
28
29
  export default SchemaFormControl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.14.0",
3
+ "version": "3.14.1",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -52,17 +52,17 @@
52
52
  "@testing-library/react": "14.3.1",
53
53
  "@testing-library/react-hooks": "8.0.1",
54
54
  "@testing-library/user-event": "14.5.2",
55
- "@transferwise/components": "46.37.0",
55
+ "@transferwise/components": "46.51.0",
56
56
  "@transferwise/formatting": "^2.13.0",
57
57
  "@transferwise/icons": "3.13.0",
58
- "@transferwise/neptune-css": "14.10.0",
58
+ "@transferwise/neptune-css": "14.12.1",
59
59
  "@types/enzyme": "^3.10.18",
60
60
  "@types/jest": "29.5.12",
61
61
  "@types/react": "18.3.3",
62
62
  "@types/react-dom": "18.3.0",
63
63
  "@types/react-intl": "3.0.0",
64
64
  "@wise/art": "2.7.0",
65
- "@wise/components-theming": "^1.3.0",
65
+ "@wise/components-theming": "^1.5.0",
66
66
  "babel-jest": "29.7.0",
67
67
  "enzyme": "^3.11.0",
68
68
  "esbuild": "0.20.2",
@@ -71,7 +71,7 @@
71
71
  "jest-fetch-mock": "^3.0.3",
72
72
  "jest-watch-typeahead": "^2.2.2",
73
73
  "nanoid": "5.0.7",
74
- "npm-run-all2": "5.0.2",
74
+ "npm-run-all2": "6.2.2",
75
75
  "postcss": "^8.4.38",
76
76
  "postcss-cli": "^11.0.0",
77
77
  "postcss-import": "^15.1.0",
@@ -86,8 +86,8 @@
86
86
  "tsx": "4.15.6",
87
87
  "typescript": "5.4.5",
88
88
  "webpack": "5.92.0",
89
- "@wise/dynamic-flow-renderers": "0.0.0",
90
- "@wise/dynamic-flow-fixtures": "0.0.1"
89
+ "@wise/dynamic-flow-fixtures": "0.0.1",
90
+ "@wise/dynamic-flow-renderers": "0.0.0"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@transferwise/components": "^46.31",