@wise/dynamic-flow-client-internal 5.2.0 → 5.3.0

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/README.md CHANGED
@@ -235,51 +235,6 @@ onLog={(level, message, extra) => {
235
235
  }}
236
236
  ```
237
237
 
238
- ## DynamicForm Component
239
-
240
- If you need to get the submittable data outside of a submission, you can use the `DynamicForm` component. This will give you access to two methods: `getValue` and `validate` via a [ref](https://react.dev/reference/react/useRef). For example:
241
-
242
- ```tsx
243
- import type { DynamicFormController } from '@wise/dynamic-flow-client-internal';
244
- import { DynamicForm } from '@wise/dynamic-flow-client-internal';
245
- import { useRef } from 'react';
246
-
247
- function DynamicFlowWithRef() {
248
- const ref = useRef<DynamicFormController>(null);
249
-
250
- return (
251
- <div>
252
- <DynamicForm
253
- ref={ref}
254
- flowId={"id"}
255
- customFetch={fetch}
256
- initialStep={myStep}
257
- onValueChange={ async () => {
258
- const value = (await ref.current?.getValue()) ?? null;
259
- console.log('Value changed to', JSON.stringify(value));
260
- }}
261
- onCompletion={(error) => console.error(error)}
262
- onCompletion={() => console.log('Completed')}
263
- />
264
- <Button
265
- onClick={ async () => {
266
- // This will get the value, whether or not the form is valid
267
- const value = (await ref.current?.getValue()) ?? null;
268
-
269
- // This will trigger validation of the form and show any validation messages to the user.
270
- // The response is a boolean indicating whether or not the form is valid.
271
- const isValid = ref.current?.validate();
272
-
273
- // Whatever you want to do with value
274
- }}
275
- >
276
- Log value
277
- </Button>
278
- </div>
279
- );
280
- }
281
- ```
282
-
283
238
  ## Contributing
284
239
 
285
240
  We love contributions! Check out `CONTRIBUTING.md` for more information.
package/build/main.css CHANGED
@@ -14,7 +14,11 @@
14
14
  .df-box-renderer-width-lg {
15
15
  width: 100%;
16
16
  }
17
- @media screen and (width >= 768px) {
17
+ @media screen and (width >=768px) {
18
+ .df-box-renderer-border {
19
+ padding: var(--size-24);
20
+ }
21
+
18
22
  .df-box-renderer-width-xs {
19
23
  width: 33.33%;
20
24
  }
@@ -31,7 +35,7 @@
31
35
  width: 83.33%;
32
36
  }
33
37
  }
34
- @media screen and (width >= 990px) {
38
+ @media screen and (width >=990px) {
35
39
  .df-box-renderer-width-xs {
36
40
  width: 25%;
37
41
  }
@@ -176,6 +180,10 @@
176
180
  .tw-modal-body--scrollable .df-step-fixed__footer {
177
181
  bottom: -24px;
178
182
  }
183
+ .df-modal .df-back-button {
184
+ position: fixed;
185
+ top: 24px;
186
+ }
179
187
  .chips-container {
180
188
  overflow-x: auto;
181
189
  }
package/build/main.js CHANGED
@@ -124,7 +124,7 @@ var require_classnames = __commonJS({
124
124
  var index_exports = {};
125
125
  __export(index_exports, {
126
126
  DynamicFlow: () => DynamicFlow,
127
- DynamicForm: () => DynamicForm,
127
+ DynamicFlowWithRef: () => DynamicFlowWithRef,
128
128
  Header: () => Header11,
129
129
  Media: () => Media2,
130
130
  findRendererPropsByType: () => import_dynamic_flow_client4.findRendererPropsByType,
@@ -135,9 +135,7 @@ __export(index_exports, {
135
135
  module.exports = __toCommonJS(index_exports);
136
136
  var import_dynamic_flow_client3 = require("@wise/dynamic-flow-client");
137
137
 
138
- // src/dynamicFlow/DynamicFlow.tsx
139
- var import_react19 = require("react");
140
- var import_react_intl27 = require("react-intl");
138
+ // src/dynamicFlow/useDynamicFlowWise.tsx
141
139
  var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
142
140
 
143
141
  // ../renderers/src/AlertRenderer.tsx
@@ -3731,25 +3729,13 @@ var getWiseRenderers = () => [
3731
3729
  ReviewLegacyRenderer_default
3732
3730
  ];
3733
3731
 
3734
- // src/dynamicFlow/messages.ts
3735
- var import_react_intl26 = require("react-intl");
3736
- var messages_default = (0, import_react_intl26.defineMessages)({
3737
- copied: {
3738
- id: "df.wise.CopyFeedback.copy",
3739
- defaultMessage: "Copied to clipboard",
3740
- description: "Appears in a snackbar when the copy operation succeeds."
3741
- },
3742
- copyFailed: {
3743
- id: "df.wise.CopyFeedback.copyFailed",
3744
- defaultMessage: "Failed to copy to clipboard",
3745
- description: "Appears in a snackbar when the copy operation fails."
3746
- }
3747
- });
3732
+ // src/dynamicFlow/useDynamicFlowWise.tsx
3733
+ var import_react21 = require("react");
3748
3734
 
3749
3735
  // src/dynamicFlow/telemetry/app-version.ts
3750
3736
  var appVersion = (
3751
3737
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
3752
- typeof process !== "undefined" ? "5.2.0" : "0.0.0"
3738
+ typeof process !== "undefined" ? "5.3.0" : "0.0.0"
3753
3739
  );
3754
3740
 
3755
3741
  // src/dynamicFlow/telemetry/getLogEvent.ts
@@ -3782,84 +3768,47 @@ var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
3782
3768
  }
3783
3769
  };
3784
3770
 
3785
- // src/dynamicFlow/DynamicFlow.tsx
3786
- var import_jsx_runtime82 = require("react/jsx-runtime");
3787
- var wiseRenderers = getWiseRenderers();
3788
- function DynamicFlow(props) {
3789
- const {
3790
- className = "",
3791
- customFetch = globalThis.fetch,
3792
- renderers,
3793
- displayStepTitle = true,
3794
- features = {},
3795
- onAnalytics,
3796
- onEvent,
3797
- onLog,
3798
- onLink = openLinkInNewTab
3799
- } = props;
3800
- const { formatMessage } = (0, import_react_intl27.useIntl)();
3801
- const createSnackBar = useSnackBarIfAvailable();
3802
- const httpClient = useWiseHttpClient(customFetch);
3803
- const mergedRenderers = (0, import_react19.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
3804
- const logEvent = (0, import_react19.useMemo)(() => getLogEvent(onLog), [onLog]);
3805
- const trackEvent = (0, import_react19.useMemo)(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
3806
- const onCopy = (copiedContent) => {
3807
- if (copiedContent) {
3808
- createSnackBar({ text: formatMessage(messages_default.copied) });
3809
- } else {
3810
- createSnackBar({ text: formatMessage(messages_default.copyFailed) });
3811
- }
3812
- };
3813
- const coreProps = __spreadProps(__spreadValues({}, props), {
3814
- features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
3815
- httpClient,
3816
- renderers: mergedRenderers,
3817
- onEvent: trackEvent,
3818
- onLog: logEvent,
3819
- onLink,
3820
- onCopy
3821
- });
3822
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client.DynamicFlow, __spreadValues({}, coreProps)) });
3823
- }
3824
- var DynamicForm = (0, import_react19.forwardRef)(function DynamicForm2(props, ref) {
3825
- const {
3826
- className = "",
3827
- customFetch = globalThis.fetch,
3828
- renderers,
3829
- displayStepTitle = true,
3830
- features = {},
3831
- onAnalytics,
3832
- onEvent,
3833
- onLog,
3834
- onLink = openLinkInNewTab
3835
- } = props;
3771
+ // src/dynamicFlow/useOnCopy.tsx
3772
+ var import_react19 = require("react");
3773
+ var import_react_intl27 = require("react-intl");
3774
+
3775
+ // src/dynamicFlow/messages.ts
3776
+ var import_react_intl26 = require("react-intl");
3777
+ var messages_default = (0, import_react_intl26.defineMessages)({
3778
+ copied: {
3779
+ id: "df.wise.CopyFeedback.copy",
3780
+ defaultMessage: "Copied to clipboard",
3781
+ description: "Appears in a snackbar when the copy operation succeeds."
3782
+ },
3783
+ copyFailed: {
3784
+ id: "df.wise.CopyFeedback.copyFailed",
3785
+ defaultMessage: "Failed to copy to clipboard",
3786
+ description: "Appears in a snackbar when the copy operation fails."
3787
+ }
3788
+ });
3789
+
3790
+ // src/dynamicFlow/useOnCopy.tsx
3791
+ var useOnCopy = () => {
3836
3792
  const { formatMessage } = (0, import_react_intl27.useIntl)();
3837
3793
  const createSnackBar = useSnackBarIfAvailable();
3838
- const httpClient = useWiseHttpClient(customFetch);
3839
- const mergedRenderers = (0, import_react19.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
3840
- const logEvent = (0, import_react19.useMemo)(() => getLogEvent(onLog), [onLog]);
3841
- const trackEvent = (0, import_react19.useMemo)(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
3842
- const onCopy = (copiedContent) => {
3843
- if (copiedContent) {
3844
- createSnackBar({ text: formatMessage(messages_default.copied) });
3845
- } else {
3846
- createSnackBar({ text: formatMessage(messages_default.copyFailed) });
3847
- }
3848
- };
3849
- const coreProps = __spreadProps(__spreadValues({}, props), {
3850
- httpClient,
3851
- renderers: mergedRenderers,
3852
- features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
3853
- onEvent: trackEvent,
3854
- onLog: logEvent,
3855
- onLink,
3856
- onCopy
3857
- });
3858
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client.DynamicForm, __spreadProps(__spreadValues({}, coreProps), { ref })) });
3859
- });
3860
- var useWiseHttpClient = (httpClient) => {
3861
- const { locale } = (0, import_react_intl27.useIntl)();
3862
3794
  return (0, import_react19.useCallback)(
3795
+ (copiedContent) => {
3796
+ if (copiedContent) {
3797
+ createSnackBar({ text: formatMessage(messages_default.copied) });
3798
+ } else {
3799
+ createSnackBar({ text: formatMessage(messages_default.copyFailed) });
3800
+ }
3801
+ },
3802
+ [createSnackBar, formatMessage]
3803
+ );
3804
+ };
3805
+
3806
+ // src/dynamicFlow/useWiseHttpClient.tsx
3807
+ var import_react20 = require("react");
3808
+ var import_react_intl28 = require("react-intl");
3809
+ var useWiseHttpClient = (httpClient) => {
3810
+ const { locale } = (0, import_react_intl28.useIntl)();
3811
+ return (0, import_react20.useCallback)(
3863
3812
  async (input, init = {}) => {
3864
3813
  const headers = new Headers(init.headers);
3865
3814
  headers.set("accept-language", locale);
@@ -3879,6 +3828,35 @@ var handleRejection = (error) => {
3879
3828
  }
3880
3829
  throw error;
3881
3830
  };
3831
+
3832
+ // src/dynamicFlow/useDynamicFlowWise.tsx
3833
+ var wiseRenderers = getWiseRenderers();
3834
+ var useDynamicFlowWise = (props) => {
3835
+ const {
3836
+ customFetch = globalThis.fetch,
3837
+ renderers,
3838
+ displayStepTitle = true,
3839
+ features = {},
3840
+ onAnalytics,
3841
+ onEvent,
3842
+ onLog,
3843
+ onLink = openLinkInNewTab
3844
+ } = props;
3845
+ const httpClient = useWiseHttpClient(customFetch);
3846
+ const mergedRenderers = (0, import_react21.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
3847
+ const logEvent = (0, import_react21.useMemo)(() => getLogEvent(onLog), [onLog]);
3848
+ const trackEvent = (0, import_react21.useMemo)(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
3849
+ const onCopy = useOnCopy();
3850
+ return (0, import_dynamic_flow_client.useDynamicFlow)(__spreadProps(__spreadValues({}, props), {
3851
+ features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
3852
+ httpClient,
3853
+ renderers: mergedRenderers,
3854
+ onEvent: trackEvent,
3855
+ onLog: logEvent,
3856
+ onLink,
3857
+ onCopy
3858
+ }));
3859
+ };
3882
3860
  var openLinkInNewTab = (url) => {
3883
3861
  var _a;
3884
3862
  try {
@@ -3889,6 +3867,34 @@ var openLinkInNewTab = (url) => {
3889
3867
  }
3890
3868
  };
3891
3869
 
3870
+ // src/dynamicFlow/DynamicFlow.tsx
3871
+ var import_jsx_runtime82 = require("react/jsx-runtime");
3872
+ function DynamicFlow(props) {
3873
+ const { className = "" } = props;
3874
+ const df = useDynamicFlowWise(props);
3875
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: df.view });
3876
+ }
3877
+
3878
+ // src/dynamicFlow/DynamicFlowWithRef.tsx
3879
+ var import_react22 = require("react");
3880
+ var import_jsx_runtime83 = require("react/jsx-runtime");
3881
+ var DynamicFlowWithRef = (0, import_react22.forwardRef)(function DynamicFlowWithRef2(props, ref) {
3882
+ const { className = "" } = props;
3883
+ const df = useDynamicFlowWise(props);
3884
+ (0, import_react22.useImperativeHandle)(
3885
+ ref,
3886
+ () => ({
3887
+ getValue: async () => {
3888
+ var _a;
3889
+ return (_a = await df.controller.getSubmittableValue()) != null ? _a : null;
3890
+ },
3891
+ validate: () => df.controller.validate()
3892
+ }),
3893
+ [df]
3894
+ );
3895
+ return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className, children: df.view });
3896
+ });
3897
+
3892
3898
  // src/index.ts
3893
3899
  var import_dynamic_flow_client4 = require("@wise/dynamic-flow-client");
3894
3900
 
package/build/main.mjs CHANGED
@@ -117,13 +117,8 @@ var require_classnames = __commonJS({
117
117
  // src/index.ts
118
118
  import { makeHttpClient } from "@wise/dynamic-flow-client";
119
119
 
120
- // src/dynamicFlow/DynamicFlow.tsx
121
- import { forwardRef, useCallback, useMemo as useMemo2 } from "react";
122
- import { useIntl as useIntl15 } from "react-intl";
123
- import {
124
- DynamicFlow as DynamicFlowCore,
125
- DynamicForm as DynamicFormCore
126
- } from "@wise/dynamic-flow-client";
120
+ // src/dynamicFlow/useDynamicFlowWise.tsx
121
+ import { useDynamicFlow } from "@wise/dynamic-flow-client";
127
122
 
128
123
  // ../renderers/src/AlertRenderer.tsx
129
124
  import { Alert } from "@transferwise/components";
@@ -3725,25 +3720,13 @@ var getWiseRenderers = () => [
3725
3720
  ReviewLegacyRenderer_default
3726
3721
  ];
3727
3722
 
3728
- // src/dynamicFlow/messages.ts
3729
- import { defineMessages as defineMessages12 } from "react-intl";
3730
- var messages_default = defineMessages12({
3731
- copied: {
3732
- id: "df.wise.CopyFeedback.copy",
3733
- defaultMessage: "Copied to clipboard",
3734
- description: "Appears in a snackbar when the copy operation succeeds."
3735
- },
3736
- copyFailed: {
3737
- id: "df.wise.CopyFeedback.copyFailed",
3738
- defaultMessage: "Failed to copy to clipboard",
3739
- description: "Appears in a snackbar when the copy operation fails."
3740
- }
3741
- });
3723
+ // src/dynamicFlow/useDynamicFlowWise.tsx
3724
+ import { useMemo as useMemo2 } from "react";
3742
3725
 
3743
3726
  // src/dynamicFlow/telemetry/app-version.ts
3744
3727
  var appVersion = (
3745
3728
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
3746
- typeof process !== "undefined" ? "5.2.0" : "0.0.0"
3729
+ typeof process !== "undefined" ? "5.3.0" : "0.0.0"
3747
3730
  );
3748
3731
 
3749
3732
  // src/dynamicFlow/telemetry/getLogEvent.ts
@@ -3776,48 +3759,71 @@ var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
3776
3759
  }
3777
3760
  };
3778
3761
 
3779
- // src/dynamicFlow/DynamicFlow.tsx
3780
- import { jsx as jsx82 } from "react/jsx-runtime";
3781
- var wiseRenderers = getWiseRenderers();
3782
- function DynamicFlow(props) {
3783
- const {
3784
- className = "",
3785
- customFetch = globalThis.fetch,
3786
- renderers,
3787
- displayStepTitle = true,
3788
- features = {},
3789
- onAnalytics,
3790
- onEvent,
3791
- onLog,
3792
- onLink = openLinkInNewTab
3793
- } = props;
3762
+ // src/dynamicFlow/useOnCopy.tsx
3763
+ import { useCallback } from "react";
3764
+ import { useIntl as useIntl15 } from "react-intl";
3765
+
3766
+ // src/dynamicFlow/messages.ts
3767
+ import { defineMessages as defineMessages12 } from "react-intl";
3768
+ var messages_default = defineMessages12({
3769
+ copied: {
3770
+ id: "df.wise.CopyFeedback.copy",
3771
+ defaultMessage: "Copied to clipboard",
3772
+ description: "Appears in a snackbar when the copy operation succeeds."
3773
+ },
3774
+ copyFailed: {
3775
+ id: "df.wise.CopyFeedback.copyFailed",
3776
+ defaultMessage: "Failed to copy to clipboard",
3777
+ description: "Appears in a snackbar when the copy operation fails."
3778
+ }
3779
+ });
3780
+
3781
+ // src/dynamicFlow/useOnCopy.tsx
3782
+ var useOnCopy = () => {
3794
3783
  const { formatMessage } = useIntl15();
3795
3784
  const createSnackBar = useSnackBarIfAvailable();
3796
- const httpClient = useWiseHttpClient(customFetch);
3797
- const mergedRenderers = useMemo2(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
3798
- const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
3799
- const trackEvent = useMemo2(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
3800
- const onCopy = (copiedContent) => {
3801
- if (copiedContent) {
3802
- createSnackBar({ text: formatMessage(messages_default.copied) });
3803
- } else {
3804
- createSnackBar({ text: formatMessage(messages_default.copyFailed) });
3805
- }
3806
- };
3807
- const coreProps = __spreadProps(__spreadValues({}, props), {
3808
- features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
3809
- httpClient,
3810
- renderers: mergedRenderers,
3811
- onEvent: trackEvent,
3812
- onLog: logEvent,
3813
- onLink,
3814
- onCopy
3815
- });
3816
- return /* @__PURE__ */ jsx82("div", { className, children: /* @__PURE__ */ jsx82(DynamicFlowCore, __spreadValues({}, coreProps)) });
3817
- }
3818
- var DynamicForm = forwardRef(function DynamicForm2(props, ref) {
3785
+ return useCallback(
3786
+ (copiedContent) => {
3787
+ if (copiedContent) {
3788
+ createSnackBar({ text: formatMessage(messages_default.copied) });
3789
+ } else {
3790
+ createSnackBar({ text: formatMessage(messages_default.copyFailed) });
3791
+ }
3792
+ },
3793
+ [createSnackBar, formatMessage]
3794
+ );
3795
+ };
3796
+
3797
+ // src/dynamicFlow/useWiseHttpClient.tsx
3798
+ import { useCallback as useCallback2 } from "react";
3799
+ import { useIntl as useIntl16 } from "react-intl";
3800
+ var useWiseHttpClient = (httpClient) => {
3801
+ const { locale } = useIntl16();
3802
+ return useCallback2(
3803
+ async (input, init = {}) => {
3804
+ const headers = new Headers(init.headers);
3805
+ headers.set("accept-language", locale);
3806
+ const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || void 0;
3807
+ if (timeZone) {
3808
+ headers.set("time-zone", timeZone);
3809
+ }
3810
+ const requestInit = __spreadProps(__spreadValues({}, init), { credentials: "include", headers });
3811
+ return httpClient(input, requestInit).catch(handleRejection);
3812
+ },
3813
+ [httpClient, locale]
3814
+ );
3815
+ };
3816
+ var handleRejection = (error) => {
3817
+ if (error instanceof Error && error.message === "SCA_MODAL_CLOSED") {
3818
+ return new Response(JSON.stringify({ validation: {} }), { status: 400 });
3819
+ }
3820
+ throw error;
3821
+ };
3822
+
3823
+ // src/dynamicFlow/useDynamicFlowWise.tsx
3824
+ var wiseRenderers = getWiseRenderers();
3825
+ var useDynamicFlowWise = (props) => {
3819
3826
  const {
3820
- className = "",
3821
3827
  customFetch = globalThis.fetch,
3822
3828
  renderers,
3823
3829
  displayStepTitle = true,
@@ -3827,51 +3833,20 @@ var DynamicForm = forwardRef(function DynamicForm2(props, ref) {
3827
3833
  onLog,
3828
3834
  onLink = openLinkInNewTab
3829
3835
  } = props;
3830
- const { formatMessage } = useIntl15();
3831
- const createSnackBar = useSnackBarIfAvailable();
3832
3836
  const httpClient = useWiseHttpClient(customFetch);
3833
3837
  const mergedRenderers = useMemo2(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
3834
3838
  const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
3835
3839
  const trackEvent = useMemo2(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
3836
- const onCopy = (copiedContent) => {
3837
- if (copiedContent) {
3838
- createSnackBar({ text: formatMessage(messages_default.copied) });
3839
- } else {
3840
- createSnackBar({ text: formatMessage(messages_default.copyFailed) });
3841
- }
3842
- };
3843
- const coreProps = __spreadProps(__spreadValues({}, props), {
3840
+ const onCopy = useOnCopy();
3841
+ return useDynamicFlow(__spreadProps(__spreadValues({}, props), {
3842
+ features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
3844
3843
  httpClient,
3845
3844
  renderers: mergedRenderers,
3846
- features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
3847
3845
  onEvent: trackEvent,
3848
3846
  onLog: logEvent,
3849
3847
  onLink,
3850
3848
  onCopy
3851
- });
3852
- return /* @__PURE__ */ jsx82("div", { className, children: /* @__PURE__ */ jsx82(DynamicFormCore, __spreadProps(__spreadValues({}, coreProps), { ref })) });
3853
- });
3854
- var useWiseHttpClient = (httpClient) => {
3855
- const { locale } = useIntl15();
3856
- return useCallback(
3857
- async (input, init = {}) => {
3858
- const headers = new Headers(init.headers);
3859
- headers.set("accept-language", locale);
3860
- const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || void 0;
3861
- if (timeZone) {
3862
- headers.set("time-zone", timeZone);
3863
- }
3864
- const requestInit = __spreadProps(__spreadValues({}, init), { credentials: "include", headers });
3865
- return httpClient(input, requestInit).catch(handleRejection);
3866
- },
3867
- [httpClient, locale]
3868
- );
3869
- };
3870
- var handleRejection = (error) => {
3871
- if (error instanceof Error && error.message === "SCA_MODAL_CLOSED") {
3872
- return new Response(JSON.stringify({ validation: {} }), { status: 400 });
3873
- }
3874
- throw error;
3849
+ }));
3875
3850
  };
3876
3851
  var openLinkInNewTab = (url) => {
3877
3852
  var _a;
@@ -3883,6 +3858,37 @@ var openLinkInNewTab = (url) => {
3883
3858
  }
3884
3859
  };
3885
3860
 
3861
+ // src/dynamicFlow/DynamicFlow.tsx
3862
+ import { jsx as jsx82 } from "react/jsx-runtime";
3863
+ function DynamicFlow(props) {
3864
+ const { className = "" } = props;
3865
+ const df = useDynamicFlowWise(props);
3866
+ return /* @__PURE__ */ jsx82("div", { className, children: df.view });
3867
+ }
3868
+
3869
+ // src/dynamicFlow/DynamicFlowWithRef.tsx
3870
+ import {
3871
+ forwardRef,
3872
+ useImperativeHandle
3873
+ } from "react";
3874
+ import { jsx as jsx83 } from "react/jsx-runtime";
3875
+ var DynamicFlowWithRef = forwardRef(function DynamicFlowWithRef2(props, ref) {
3876
+ const { className = "" } = props;
3877
+ const df = useDynamicFlowWise(props);
3878
+ useImperativeHandle(
3879
+ ref,
3880
+ () => ({
3881
+ getValue: async () => {
3882
+ var _a;
3883
+ return (_a = await df.controller.getSubmittableValue()) != null ? _a : null;
3884
+ },
3885
+ validate: () => df.controller.validate()
3886
+ }),
3887
+ [df]
3888
+ );
3889
+ return /* @__PURE__ */ jsx83("div", { className, children: df.view });
3890
+ });
3891
+
3886
3892
  // src/index.ts
3887
3893
  import { findRendererPropsByType } from "@wise/dynamic-flow-client";
3888
3894
 
@@ -4754,7 +4760,7 @@ var translations = languages.reduce(
4754
4760
  var i18n_default = translations;
4755
4761
  export {
4756
4762
  DynamicFlow,
4757
- DynamicForm,
4763
+ DynamicFlowWithRef,
4758
4764
  Header11 as Header,
4759
4765
  Media2 as Media,
4760
4766
  findRendererPropsByType,
@@ -1,27 +1,6 @@
1
- import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
- import type { DynamicFlowProps as DynamicFlowCoreProps, DynamicFormController } from '@wise/dynamic-flow-client';
3
- type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
4
- type Prettify<T> = {
1
+ import type { DynamicFlowProps } from './DynamicFlowProps';
2
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
3
+ export type Prettify<T> = {
5
4
  [K in keyof T]: T[K];
6
5
  } & {};
7
- export type DynamicFlowProps = Prettify<MakeOptional<Omit<DynamicFlowCoreProps, 'httpClient'>, 'renderers' | 'onLink'> & {
8
- className?: string;
9
- /**
10
- * @deprecated Use `features` prop with `hideStepTitle` instead.
11
- */
12
- displayStepTitle?: boolean;
13
- customFetch?: DynamicFlowCoreProps['httpClient'];
14
- onAnalytics?: DynamicFlowCoreProps['onEvent'];
15
- }>;
16
6
  export declare function DynamicFlow(props: DynamicFlowProps): import("react/jsx-runtime").JSX.Element;
17
- export type DynamicFormProps = Omit<DynamicFlowProps, 'onCompletion'> & {
18
- onValueChange?: () => void;
19
- onCompletion?: DynamicFlowProps['onCompletion'];
20
- };
21
- /**
22
- * DynamicForm is like DynamicFlow, but it also accepts a ForwardedRef.
23
- * This ref conforms to the DynamicFormController type, containing two functions: `getValue` and `validate`.
24
- * @experimental This component may be changed in the future without notice.
25
- */
26
- export declare const DynamicForm: ForwardRefExoticComponent<DynamicFormProps & RefAttributes<DynamicFormController>>;
27
- export {};
@@ -0,0 +1,11 @@
1
+ import type { DynamicFlowProps as DynamicFlowCoreProps } from '@wise/dynamic-flow-client';
2
+ import { Prettify, MakeOptional } from './DynamicFlow';
3
+ export type DynamicFlowProps = Prettify<MakeOptional<Omit<DynamicFlowCoreProps, 'httpClient'>, 'renderers' | 'onLink'> & {
4
+ className?: string;
5
+ /**
6
+ * @deprecated Use `features` prop with `hideStepTitle` instead.
7
+ */
8
+ displayStepTitle?: boolean;
9
+ customFetch?: DynamicFlowCoreProps['httpClient'];
10
+ onAnalytics?: DynamicFlowCoreProps['onEvent'];
11
+ }>;
@@ -0,0 +1,22 @@
1
+ import { JsonElement } from '@wise/dynamic-flow-types/spec';
2
+ import { type ForwardRefExoticComponent, type RefAttributes } from 'react';
3
+ import type { DynamicFlowProps } from './DynamicFlowProps';
4
+ export type DynamicFlowWithRefProps = DynamicFlowProps & {
5
+ onValueChange?: () => void;
6
+ };
7
+ export type DynamicFlowRef = {
8
+ /**
9
+ * Returns the current value of the form, even if it doesn't pass validation.
10
+ */
11
+ getValue: () => Promise<JsonElement>;
12
+ /**
13
+ * triggers validation in every UI component and returns whether or not the current value is valid.
14
+ */
15
+ validate: () => boolean;
16
+ };
17
+ /**
18
+ * DynamicFlowWithRef is like DynamicFlow, but it also accepts a ForwardedRef.
19
+ * This ref conforms to the DynamicFlowRef type, containing two functions: `getValue` and `validate`.
20
+ * @experimental This component may be changed in the future without notice.
21
+ */
22
+ export declare const DynamicFlowWithRef: ForwardRefExoticComponent<DynamicFlowWithRefProps & RefAttributes<DynamicFlowRef>>;
@@ -0,0 +1,3 @@
1
+ import { useDynamicFlow } from '@wise/dynamic-flow-client';
2
+ import { DynamicFlowProps } from './DynamicFlowProps';
3
+ export declare const useDynamicFlowWise: (props: DynamicFlowProps) => ReturnType<typeof useDynamicFlow>;
@@ -0,0 +1 @@
1
+ export declare const useOnCopy: () => (copiedContent: string | null) => void;
@@ -0,0 +1 @@
1
+ export declare const useWiseHttpClient: (httpClient: typeof globalThis.fetch) => typeof globalThis.fetch;
@@ -1,7 +1,7 @@
1
1
  export { makeHttpClient as makeCustomFetch } from '@wise/dynamic-flow-client';
2
- export type { DynamicFormController } from '@wise/dynamic-flow-client';
3
- export type { DynamicFlowProps } from './dynamicFlow/DynamicFlow';
4
- export { DynamicFlow, DynamicForm } from './dynamicFlow/DynamicFlow';
2
+ export type { DynamicFlowProps } from './dynamicFlow/DynamicFlowProps';
3
+ export { DynamicFlow } from './dynamicFlow/DynamicFlow';
4
+ export { DynamicFlowWithRef, type DynamicFlowRef } from './dynamicFlow/DynamicFlowWithRef';
5
5
  export { findRendererPropsByType } from '@wise/dynamic-flow-client';
6
- export { Header, Media, getMargin } from './dynamicFlow/renderers';
6
+ export { getMargin, Header, Media } from './dynamicFlow/renderers';
7
7
  export { default as translations } from './i18n';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client-internal",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "Dynamic Flow web client for Wise",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@chromatic-com/storybook": "4.1.3",
35
- "@formatjs/cli": "^6.9.0",
35
+ "@formatjs/cli": "^6.11.0",
36
36
  "@storybook/addon-a11y": "^10.1.11",
37
37
  "@storybook/addon-docs": "^10.1.11",
38
38
  "@storybook/addon-links": "^10.1.11",
@@ -41,18 +41,18 @@
41
41
  "@testing-library/jest-dom": "6.9.1",
42
42
  "@testing-library/react": "16.3.1",
43
43
  "@testing-library/user-event": "14.6.1",
44
- "@transferwise/components": "^46.118.0",
44
+ "@transferwise/components": "^46.121.1",
45
45
  "@transferwise/formatting": "^2.13.4",
46
- "@transferwise/icons": "4.0.1",
47
- "@transferwise/neptune-css": "14.26.0",
46
+ "@transferwise/icons": "4.0.2",
47
+ "@transferwise/neptune-css": "14.26.1",
48
48
  "@types/react": "18.3.27",
49
49
  "@types/react-dom": "18.3.7",
50
- "@wise/art": "2.25.0",
51
- "@wise/components-theming": "^1.9.1",
50
+ "@wise/art": "2.26.0",
51
+ "@wise/components-theming": "^1.10.0",
52
52
  "currency-flags": "4.0.7",
53
53
  "esbuild": "0.27.0",
54
54
  "eslint-plugin-storybook": "10.1.11",
55
- "framer-motion": "^12.23.26",
55
+ "framer-motion": "^12.26.2",
56
56
  "npm-run-all2": "8.0.4",
57
57
  "postcss": "^8.5.6",
58
58
  "postcss-cli": "^11.0.1",
@@ -67,11 +67,11 @@
67
67
  "stylelint-value-no-unknown-custom-properties": "6.1.0",
68
68
  "tsx": "4.21.0",
69
69
  "typescript": "5.9.3",
70
- "vitest": "4.0.16",
70
+ "vitest": "4.0.17",
71
71
  "vitest-fetch-mock": "0.4.5",
72
- "@wise/dynamic-flow-fixtures": "0.0.1",
73
72
  "@wise/dynamic-flow-renderers": "0.0.0",
74
- "@wise/dynamic-flow-types": "4.3.0"
73
+ "@wise/dynamic-flow-fixtures": "0.0.1",
74
+ "@wise/dynamic-flow-types": "4.4.0"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@transferwise/components": "^46.104.0",
@@ -85,8 +85,8 @@
85
85
  "react-intl": "^6"
86
86
  },
87
87
  "dependencies": {
88
- "@wise/dynamic-flow-client": "5.2.0",
89
- "@wise/dynamic-flow-types": "4.3.0"
88
+ "@wise/dynamic-flow-client": "5.3.0",
89
+ "@wise/dynamic-flow-types": "4.4.0"
90
90
  },
91
91
  "scripts": {
92
92
  "dev": "pnpm build:visual-tests && storybook dev -p 3005",