@wise/dynamic-flow-client-internal 5.1.3 → 5.2.0-exp-bits-29346f3
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 +0 -45
- package/build/main.css +4 -0
- package/build/main.js +101 -97
- package/build/main.mjs +103 -99
- package/build/types/dynamicFlow/DynamicFlow.d.ts +4 -24
- package/build/types/dynamicFlow/DynamicFlowProps.d.ts +11 -0
- package/build/types/dynamicFlow/DynamicFlowWithRef.d.ts +22 -0
- package/build/types/dynamicFlow/useDynamicFlowWise.d.ts +3 -0
- package/build/types/dynamicFlow/useOnCopy.d.ts +1 -0
- package/build/types/dynamicFlow/useWiseHttpClient.d.ts +1 -0
- package/build/types/index.d.ts +4 -4
- package/package.json +5 -5
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
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
|
-
|
|
127
|
+
DynamicFlowWithRef: () => DynamicFlowWithRef,
|
|
128
128
|
Header: () => Header11,
|
|
129
129
|
Media: () => Media2,
|
|
130
130
|
findRendererPropsByType: () => import_dynamic_flow_client4.findRendererPropsByType,
|
|
@@ -135,11 +135,6 @@ __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");
|
|
141
|
-
var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
|
|
142
|
-
|
|
143
138
|
// ../renderers/src/AlertRenderer.tsx
|
|
144
139
|
var import_components = require("@transferwise/components");
|
|
145
140
|
|
|
@@ -3731,25 +3726,14 @@ var getWiseRenderers = () => [
|
|
|
3731
3726
|
ReviewLegacyRenderer_default
|
|
3732
3727
|
];
|
|
3733
3728
|
|
|
3734
|
-
// src/dynamicFlow/
|
|
3735
|
-
var
|
|
3736
|
-
var
|
|
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
|
-
});
|
|
3729
|
+
// src/dynamicFlow/useDynamicFlowWise.tsx
|
|
3730
|
+
var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
|
|
3731
|
+
var import_react21 = require("react");
|
|
3748
3732
|
|
|
3749
3733
|
// src/dynamicFlow/telemetry/app-version.ts
|
|
3750
3734
|
var appVersion = (
|
|
3751
3735
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
3752
|
-
typeof process !== "undefined" ? "5.1.
|
|
3736
|
+
typeof process !== "undefined" ? "5.1.2" : "0.0.0"
|
|
3753
3737
|
);
|
|
3754
3738
|
|
|
3755
3739
|
// src/dynamicFlow/telemetry/getLogEvent.ts
|
|
@@ -3782,83 +3766,11 @@ var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
|
|
|
3782
3766
|
}
|
|
3783
3767
|
};
|
|
3784
3768
|
|
|
3785
|
-
// src/dynamicFlow/
|
|
3786
|
-
var
|
|
3787
|
-
var
|
|
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;
|
|
3836
|
-
const { formatMessage } = (0, import_react_intl27.useIntl)();
|
|
3837
|
-
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
|
-
});
|
|
3769
|
+
// src/dynamicFlow/useWiseHttpClient.tsx
|
|
3770
|
+
var import_react19 = require("react");
|
|
3771
|
+
var import_react_intl26 = require("react-intl");
|
|
3860
3772
|
var useWiseHttpClient = (httpClient) => {
|
|
3861
|
-
const { locale } = (0,
|
|
3773
|
+
const { locale } = (0, import_react_intl26.useIntl)();
|
|
3862
3774
|
return (0, import_react19.useCallback)(
|
|
3863
3775
|
async (input, init = {}) => {
|
|
3864
3776
|
const headers = new Headers(init.headers);
|
|
@@ -3879,6 +3791,69 @@ var handleRejection = (error) => {
|
|
|
3879
3791
|
}
|
|
3880
3792
|
throw error;
|
|
3881
3793
|
};
|
|
3794
|
+
|
|
3795
|
+
// src/dynamicFlow/useOnCopy.tsx
|
|
3796
|
+
var import_react20 = require("react");
|
|
3797
|
+
var import_react_intl28 = require("react-intl");
|
|
3798
|
+
|
|
3799
|
+
// src/dynamicFlow/messages.ts
|
|
3800
|
+
var import_react_intl27 = require("react-intl");
|
|
3801
|
+
var messages_default = (0, import_react_intl27.defineMessages)({
|
|
3802
|
+
copied: {
|
|
3803
|
+
id: "df.wise.CopyFeedback.copy",
|
|
3804
|
+
defaultMessage: "Copied to clipboard",
|
|
3805
|
+
description: "Appears in a snackbar when the copy operation succeeds."
|
|
3806
|
+
},
|
|
3807
|
+
copyFailed: {
|
|
3808
|
+
id: "df.wise.CopyFeedback.copyFailed",
|
|
3809
|
+
defaultMessage: "Failed to copy to clipboard",
|
|
3810
|
+
description: "Appears in a snackbar when the copy operation fails."
|
|
3811
|
+
}
|
|
3812
|
+
});
|
|
3813
|
+
|
|
3814
|
+
// src/dynamicFlow/useOnCopy.tsx
|
|
3815
|
+
var useOnCopy = () => {
|
|
3816
|
+
const { formatMessage } = (0, import_react_intl28.useIntl)();
|
|
3817
|
+
const createSnackBar = useSnackBarIfAvailable();
|
|
3818
|
+
return (0, import_react20.useCallback)(
|
|
3819
|
+
(copiedContent) => {
|
|
3820
|
+
if (copiedContent) {
|
|
3821
|
+
createSnackBar({ text: formatMessage(messages_default.copied) });
|
|
3822
|
+
} else {
|
|
3823
|
+
createSnackBar({ text: formatMessage(messages_default.copyFailed) });
|
|
3824
|
+
}
|
|
3825
|
+
},
|
|
3826
|
+
[createSnackBar, formatMessage]
|
|
3827
|
+
);
|
|
3828
|
+
};
|
|
3829
|
+
|
|
3830
|
+
// src/dynamicFlow/useDynamicFlowWise.tsx
|
|
3831
|
+
var useDynamicFlowWise = (props) => {
|
|
3832
|
+
const {
|
|
3833
|
+
customFetch = globalThis.fetch,
|
|
3834
|
+
renderers,
|
|
3835
|
+
displayStepTitle = true,
|
|
3836
|
+
features = {},
|
|
3837
|
+
onAnalytics,
|
|
3838
|
+
onEvent,
|
|
3839
|
+
onLog,
|
|
3840
|
+
onLink = openLinkInNewTab
|
|
3841
|
+
} = props;
|
|
3842
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
3843
|
+
const mergedRenderers = (0, import_react21.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
|
|
3844
|
+
const logEvent = (0, import_react21.useMemo)(() => getLogEvent(onLog), [onLog]);
|
|
3845
|
+
const trackEvent = (0, import_react21.useMemo)(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
|
|
3846
|
+
const onCopy = useOnCopy();
|
|
3847
|
+
return (0, import_dynamic_flow_client.useDynamicFlow)(__spreadProps(__spreadValues({}, props), {
|
|
3848
|
+
features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
|
|
3849
|
+
httpClient,
|
|
3850
|
+
renderers: mergedRenderers,
|
|
3851
|
+
onEvent: trackEvent,
|
|
3852
|
+
onLog: logEvent,
|
|
3853
|
+
onLink,
|
|
3854
|
+
onCopy
|
|
3855
|
+
}));
|
|
3856
|
+
};
|
|
3882
3857
|
var openLinkInNewTab = (url) => {
|
|
3883
3858
|
var _a;
|
|
3884
3859
|
try {
|
|
@@ -3889,6 +3864,35 @@ var openLinkInNewTab = (url) => {
|
|
|
3889
3864
|
}
|
|
3890
3865
|
};
|
|
3891
3866
|
|
|
3867
|
+
// src/dynamicFlow/DynamicFlow.tsx
|
|
3868
|
+
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
3869
|
+
var wiseRenderers = getWiseRenderers();
|
|
3870
|
+
function DynamicFlow(props) {
|
|
3871
|
+
const { className = "" } = props;
|
|
3872
|
+
const df = useDynamicFlowWise(props);
|
|
3873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: df.component });
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
// src/dynamicFlow/DynamicFlowWithRef.tsx
|
|
3877
|
+
var import_react22 = require("react");
|
|
3878
|
+
var import_jsx_runtime83 = require("react/jsx-runtime");
|
|
3879
|
+
var DynamicFlowWithRef = (0, import_react22.forwardRef)(function DynamicFlowWithRef2(props, ref) {
|
|
3880
|
+
const { className = "" } = props;
|
|
3881
|
+
const df = useDynamicFlowWise(props);
|
|
3882
|
+
(0, import_react22.useImperativeHandle)(
|
|
3883
|
+
ref,
|
|
3884
|
+
() => ({
|
|
3885
|
+
getValue: async () => {
|
|
3886
|
+
var _a;
|
|
3887
|
+
return (_a = await df.getSubmittableValue()) != null ? _a : null;
|
|
3888
|
+
},
|
|
3889
|
+
validate: () => df.validate()
|
|
3890
|
+
}),
|
|
3891
|
+
[]
|
|
3892
|
+
);
|
|
3893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className, children: df.component });
|
|
3894
|
+
});
|
|
3895
|
+
|
|
3892
3896
|
// src/index.ts
|
|
3893
3897
|
var import_dynamic_flow_client4 = require("@wise/dynamic-flow-client");
|
|
3894
3898
|
|
package/build/main.mjs
CHANGED
|
@@ -117,14 +117,6 @@ 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";
|
|
127
|
-
|
|
128
120
|
// ../renderers/src/AlertRenderer.tsx
|
|
129
121
|
import { Alert } from "@transferwise/components";
|
|
130
122
|
|
|
@@ -3725,25 +3717,14 @@ var getWiseRenderers = () => [
|
|
|
3725
3717
|
ReviewLegacyRenderer_default
|
|
3726
3718
|
];
|
|
3727
3719
|
|
|
3728
|
-
// src/dynamicFlow/
|
|
3729
|
-
import {
|
|
3730
|
-
|
|
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
|
-
});
|
|
3720
|
+
// src/dynamicFlow/useDynamicFlowWise.tsx
|
|
3721
|
+
import { useDynamicFlow } from "@wise/dynamic-flow-client";
|
|
3722
|
+
import { useMemo as useMemo2 } from "react";
|
|
3742
3723
|
|
|
3743
3724
|
// src/dynamicFlow/telemetry/app-version.ts
|
|
3744
3725
|
var appVersion = (
|
|
3745
3726
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
3746
|
-
typeof process !== "undefined" ? "5.1.
|
|
3727
|
+
typeof process !== "undefined" ? "5.1.2" : "0.0.0"
|
|
3747
3728
|
);
|
|
3748
3729
|
|
|
3749
3730
|
// src/dynamicFlow/telemetry/getLogEvent.ts
|
|
@@ -3776,81 +3757,9 @@ var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
|
|
|
3776
3757
|
}
|
|
3777
3758
|
};
|
|
3778
3759
|
|
|
3779
|
-
// src/dynamicFlow/
|
|
3780
|
-
import {
|
|
3781
|
-
|
|
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;
|
|
3794
|
-
const { formatMessage } = useIntl15();
|
|
3795
|
-
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) {
|
|
3819
|
-
const {
|
|
3820
|
-
className = "",
|
|
3821
|
-
customFetch = globalThis.fetch,
|
|
3822
|
-
renderers,
|
|
3823
|
-
displayStepTitle = true,
|
|
3824
|
-
features = {},
|
|
3825
|
-
onAnalytics,
|
|
3826
|
-
onEvent,
|
|
3827
|
-
onLog,
|
|
3828
|
-
onLink = openLinkInNewTab
|
|
3829
|
-
} = props;
|
|
3830
|
-
const { formatMessage } = useIntl15();
|
|
3831
|
-
const createSnackBar = useSnackBarIfAvailable();
|
|
3832
|
-
const httpClient = useWiseHttpClient(customFetch);
|
|
3833
|
-
const mergedRenderers = useMemo2(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
|
|
3834
|
-
const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
|
|
3835
|
-
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), {
|
|
3844
|
-
httpClient,
|
|
3845
|
-
renderers: mergedRenderers,
|
|
3846
|
-
features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
|
|
3847
|
-
onEvent: trackEvent,
|
|
3848
|
-
onLog: logEvent,
|
|
3849
|
-
onLink,
|
|
3850
|
-
onCopy
|
|
3851
|
-
});
|
|
3852
|
-
return /* @__PURE__ */ jsx82("div", { className, children: /* @__PURE__ */ jsx82(DynamicFormCore, __spreadProps(__spreadValues({}, coreProps), { ref })) });
|
|
3853
|
-
});
|
|
3760
|
+
// src/dynamicFlow/useWiseHttpClient.tsx
|
|
3761
|
+
import { useCallback } from "react";
|
|
3762
|
+
import { useIntl as useIntl15 } from "react-intl";
|
|
3854
3763
|
var useWiseHttpClient = (httpClient) => {
|
|
3855
3764
|
const { locale } = useIntl15();
|
|
3856
3765
|
return useCallback(
|
|
@@ -3873,6 +3782,69 @@ var handleRejection = (error) => {
|
|
|
3873
3782
|
}
|
|
3874
3783
|
throw error;
|
|
3875
3784
|
};
|
|
3785
|
+
|
|
3786
|
+
// src/dynamicFlow/useOnCopy.tsx
|
|
3787
|
+
import { useCallback as useCallback2 } from "react";
|
|
3788
|
+
import { useIntl as useIntl16 } from "react-intl";
|
|
3789
|
+
|
|
3790
|
+
// src/dynamicFlow/messages.ts
|
|
3791
|
+
import { defineMessages as defineMessages12 } from "react-intl";
|
|
3792
|
+
var messages_default = defineMessages12({
|
|
3793
|
+
copied: {
|
|
3794
|
+
id: "df.wise.CopyFeedback.copy",
|
|
3795
|
+
defaultMessage: "Copied to clipboard",
|
|
3796
|
+
description: "Appears in a snackbar when the copy operation succeeds."
|
|
3797
|
+
},
|
|
3798
|
+
copyFailed: {
|
|
3799
|
+
id: "df.wise.CopyFeedback.copyFailed",
|
|
3800
|
+
defaultMessage: "Failed to copy to clipboard",
|
|
3801
|
+
description: "Appears in a snackbar when the copy operation fails."
|
|
3802
|
+
}
|
|
3803
|
+
});
|
|
3804
|
+
|
|
3805
|
+
// src/dynamicFlow/useOnCopy.tsx
|
|
3806
|
+
var useOnCopy = () => {
|
|
3807
|
+
const { formatMessage } = useIntl16();
|
|
3808
|
+
const createSnackBar = useSnackBarIfAvailable();
|
|
3809
|
+
return useCallback2(
|
|
3810
|
+
(copiedContent) => {
|
|
3811
|
+
if (copiedContent) {
|
|
3812
|
+
createSnackBar({ text: formatMessage(messages_default.copied) });
|
|
3813
|
+
} else {
|
|
3814
|
+
createSnackBar({ text: formatMessage(messages_default.copyFailed) });
|
|
3815
|
+
}
|
|
3816
|
+
},
|
|
3817
|
+
[createSnackBar, formatMessage]
|
|
3818
|
+
);
|
|
3819
|
+
};
|
|
3820
|
+
|
|
3821
|
+
// src/dynamicFlow/useDynamicFlowWise.tsx
|
|
3822
|
+
var useDynamicFlowWise = (props) => {
|
|
3823
|
+
const {
|
|
3824
|
+
customFetch = globalThis.fetch,
|
|
3825
|
+
renderers,
|
|
3826
|
+
displayStepTitle = true,
|
|
3827
|
+
features = {},
|
|
3828
|
+
onAnalytics,
|
|
3829
|
+
onEvent,
|
|
3830
|
+
onLog,
|
|
3831
|
+
onLink = openLinkInNewTab
|
|
3832
|
+
} = props;
|
|
3833
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
3834
|
+
const mergedRenderers = useMemo2(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
|
|
3835
|
+
const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
|
|
3836
|
+
const trackEvent = useMemo2(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
|
|
3837
|
+
const onCopy = useOnCopy();
|
|
3838
|
+
return useDynamicFlow(__spreadProps(__spreadValues({}, props), {
|
|
3839
|
+
features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
|
|
3840
|
+
httpClient,
|
|
3841
|
+
renderers: mergedRenderers,
|
|
3842
|
+
onEvent: trackEvent,
|
|
3843
|
+
onLog: logEvent,
|
|
3844
|
+
onLink,
|
|
3845
|
+
onCopy
|
|
3846
|
+
}));
|
|
3847
|
+
};
|
|
3876
3848
|
var openLinkInNewTab = (url) => {
|
|
3877
3849
|
var _a;
|
|
3878
3850
|
try {
|
|
@@ -3883,6 +3855,38 @@ var openLinkInNewTab = (url) => {
|
|
|
3883
3855
|
}
|
|
3884
3856
|
};
|
|
3885
3857
|
|
|
3858
|
+
// src/dynamicFlow/DynamicFlow.tsx
|
|
3859
|
+
import { jsx as jsx82 } from "react/jsx-runtime";
|
|
3860
|
+
var wiseRenderers = getWiseRenderers();
|
|
3861
|
+
function DynamicFlow(props) {
|
|
3862
|
+
const { className = "" } = props;
|
|
3863
|
+
const df = useDynamicFlowWise(props);
|
|
3864
|
+
return /* @__PURE__ */ jsx82("div", { className, children: df.component });
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
// src/dynamicFlow/DynamicFlowWithRef.tsx
|
|
3868
|
+
import {
|
|
3869
|
+
forwardRef,
|
|
3870
|
+
useImperativeHandle
|
|
3871
|
+
} from "react";
|
|
3872
|
+
import { jsx as jsx83 } from "react/jsx-runtime";
|
|
3873
|
+
var DynamicFlowWithRef = forwardRef(function DynamicFlowWithRef2(props, ref) {
|
|
3874
|
+
const { className = "" } = props;
|
|
3875
|
+
const df = useDynamicFlowWise(props);
|
|
3876
|
+
useImperativeHandle(
|
|
3877
|
+
ref,
|
|
3878
|
+
() => ({
|
|
3879
|
+
getValue: async () => {
|
|
3880
|
+
var _a;
|
|
3881
|
+
return (_a = await df.getSubmittableValue()) != null ? _a : null;
|
|
3882
|
+
},
|
|
3883
|
+
validate: () => df.validate()
|
|
3884
|
+
}),
|
|
3885
|
+
[]
|
|
3886
|
+
);
|
|
3887
|
+
return /* @__PURE__ */ jsx83("div", { className, children: df.component });
|
|
3888
|
+
});
|
|
3889
|
+
|
|
3886
3890
|
// src/index.ts
|
|
3887
3891
|
import { findRendererPropsByType } from "@wise/dynamic-flow-client";
|
|
3888
3892
|
|
|
@@ -4754,7 +4758,7 @@ var translations = languages.reduce(
|
|
|
4754
4758
|
var i18n_default = translations;
|
|
4755
4759
|
export {
|
|
4756
4760
|
DynamicFlow,
|
|
4757
|
-
|
|
4761
|
+
DynamicFlowWithRef,
|
|
4758
4762
|
Header11 as Header,
|
|
4759
4763
|
Media2 as Media,
|
|
4760
4764
|
findRendererPropsByType,
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
type
|
|
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
|
|
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
|
-
}>;
|
|
6
|
+
export declare const wiseRenderers: import("@wise/dynamic-flow-types/renderers").Renderers;
|
|
16
7
|
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 DynamicFormController 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 @@
|
|
|
1
|
+
export declare const useOnCopy: () => (copiedContent: string | null) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useWiseHttpClient: (httpClient: typeof globalThis.fetch) => typeof globalThis.fetch;
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { makeHttpClient as makeCustomFetch } from '@wise/dynamic-flow-client';
|
|
2
|
-
export type {
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
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
|
|
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.
|
|
3
|
+
"version": "5.2.0-exp-bits-29346f3",
|
|
4
4
|
"description": "Dynamic Flow web client for Wise",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.js",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"typescript": "5.9.3",
|
|
70
70
|
"vitest": "4.0.16",
|
|
71
71
|
"vitest-fetch-mock": "0.4.5",
|
|
72
|
-
"@wise/dynamic-flow-
|
|
72
|
+
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
73
73
|
"@wise/dynamic-flow-renderers": "0.0.0",
|
|
74
|
-
"@wise/dynamic-flow-
|
|
74
|
+
"@wise/dynamic-flow-types": "4.2.0-exp-bits-29346f3"
|
|
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.
|
|
89
|
-
"@wise/dynamic-flow-types": "4.2.0"
|
|
88
|
+
"@wise/dynamic-flow-client": "5.2.0-exp-bits-29346f3",
|
|
89
|
+
"@wise/dynamic-flow-types": "4.2.0-exp-bits-29346f3"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"dev": "pnpm build:visual-tests && storybook dev -p 3005",
|