@wise/dynamic-flow-client-internal 5.2.0-exp-bits-29346f3 → 5.2.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 +45 -0
- package/build/i18n/uk.json +3 -3
- package/build/main.css +0 -4
- package/build/main.js +97 -101
- package/build/main.mjs +99 -103
- package/build/types/dynamicFlow/DynamicFlow.d.ts +24 -4
- package/build/types/index.d.ts +4 -4
- package/package.json +4 -4
- package/build/types/dynamicFlow/DynamicFlowProps.d.ts +0 -11
- package/build/types/dynamicFlow/DynamicFlowWithRef.d.ts +0 -22
- package/build/types/dynamicFlow/useDynamicFlowWise.d.ts +0 -3
- package/build/types/dynamicFlow/useOnCopy.d.ts +0 -1
- package/build/types/dynamicFlow/useWiseHttpClient.d.ts +0 -1
package/README.md
CHANGED
|
@@ -235,6 +235,51 @@ 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
|
+
|
|
238
283
|
## Contributing
|
|
239
284
|
|
|
240
285
|
We love contributions! Check out `CONTRIBUTING.md` for more information.
|
package/build/i18n/uk.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"df.wise.ArraySchema.addItem": "Зберегти",
|
|
3
|
-
"df.wise.ArraySchema.addItemTitle": "
|
|
3
|
+
"df.wise.ArraySchema.addItemTitle": "Додати позицію",
|
|
4
4
|
"df.wise.ArraySchema.editItem": "Зберегти",
|
|
5
5
|
"df.wise.ArraySchema.maxItemsError": "Додайте {maxItems} або менше.",
|
|
6
6
|
"df.wise.ArraySchema.minItemsError": "Додайте принаймні {minItems}.",
|
|
7
7
|
"df.wise.ArraySchema.removeItem": "Вилучити",
|
|
8
|
-
"df.wise.ButtonLayout.buttonLoadingMessage": "
|
|
8
|
+
"df.wise.ButtonLayout.buttonLoadingMessage": "Це може зайняти кілька секунд",
|
|
9
9
|
"df.wise.ControlFeedback.maxLength": "Максимальна кількість символів: {maxLength}.",
|
|
10
10
|
"df.wise.ControlFeedback.maximum": "Введіть число, що менше або дорівнює {maximum}.",
|
|
11
11
|
"df.wise.ControlFeedback.maximumDate": "Введіть дату, що припадає на {maximum}, або ранішу.",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"df.wise.SearchLayout.loading": "Завантаження…",
|
|
36
36
|
"df.wise.back.label": "Назад",
|
|
37
37
|
"df.wise.filter.noResults": "Нічого не знайдено",
|
|
38
|
-
"df.wise.filter.placeholder": "
|
|
38
|
+
"df.wise.filter.placeholder": "Почніть вводити текст для пошуку",
|
|
39
39
|
"df.wise.filter.results": "Результати пошуку",
|
|
40
40
|
"df.wise.group.all": "Усе",
|
|
41
41
|
"df.wise.group.currencies-with-account-details": "Валюти з реквізитами рахунків",
|
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
|
+
DynamicForm: () => DynamicForm,
|
|
128
128
|
Header: () => Header11,
|
|
129
129
|
Media: () => Media2,
|
|
130
130
|
findRendererPropsByType: () => import_dynamic_flow_client4.findRendererPropsByType,
|
|
@@ -135,6 +135,11 @@ __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
|
+
|
|
138
143
|
// ../renderers/src/AlertRenderer.tsx
|
|
139
144
|
var import_components = require("@transferwise/components");
|
|
140
145
|
|
|
@@ -3726,14 +3731,25 @@ var getWiseRenderers = () => [
|
|
|
3726
3731
|
ReviewLegacyRenderer_default
|
|
3727
3732
|
];
|
|
3728
3733
|
|
|
3729
|
-
// src/dynamicFlow/
|
|
3730
|
-
var
|
|
3731
|
-
var
|
|
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
3748
|
|
|
3733
3749
|
// src/dynamicFlow/telemetry/app-version.ts
|
|
3734
3750
|
var appVersion = (
|
|
3735
3751
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
3736
|
-
typeof process !== "undefined" ? "5.
|
|
3752
|
+
typeof process !== "undefined" ? "5.2.0" : "0.0.0"
|
|
3737
3753
|
);
|
|
3738
3754
|
|
|
3739
3755
|
// src/dynamicFlow/telemetry/getLogEvent.ts
|
|
@@ -3766,11 +3782,83 @@ var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
|
|
|
3766
3782
|
}
|
|
3767
3783
|
};
|
|
3768
3784
|
|
|
3769
|
-
// src/dynamicFlow/
|
|
3770
|
-
var
|
|
3771
|
-
var
|
|
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;
|
|
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
|
+
});
|
|
3772
3860
|
var useWiseHttpClient = (httpClient) => {
|
|
3773
|
-
const { locale } = (0,
|
|
3861
|
+
const { locale } = (0, import_react_intl27.useIntl)();
|
|
3774
3862
|
return (0, import_react19.useCallback)(
|
|
3775
3863
|
async (input, init = {}) => {
|
|
3776
3864
|
const headers = new Headers(init.headers);
|
|
@@ -3791,69 +3879,6 @@ var handleRejection = (error) => {
|
|
|
3791
3879
|
}
|
|
3792
3880
|
throw error;
|
|
3793
3881
|
};
|
|
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
|
-
};
|
|
3857
3882
|
var openLinkInNewTab = (url) => {
|
|
3858
3883
|
var _a;
|
|
3859
3884
|
try {
|
|
@@ -3864,35 +3889,6 @@ var openLinkInNewTab = (url) => {
|
|
|
3864
3889
|
}
|
|
3865
3890
|
};
|
|
3866
3891
|
|
|
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
|
-
|
|
3896
3892
|
// src/index.ts
|
|
3897
3893
|
var import_dynamic_flow_client4 = require("@wise/dynamic-flow-client");
|
|
3898
3894
|
|
package/build/main.mjs
CHANGED
|
@@ -117,6 +117,14 @@ 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
|
+
|
|
120
128
|
// ../renderers/src/AlertRenderer.tsx
|
|
121
129
|
import { Alert } from "@transferwise/components";
|
|
122
130
|
|
|
@@ -3717,14 +3725,25 @@ var getWiseRenderers = () => [
|
|
|
3717
3725
|
ReviewLegacyRenderer_default
|
|
3718
3726
|
];
|
|
3719
3727
|
|
|
3720
|
-
// src/dynamicFlow/
|
|
3721
|
-
import {
|
|
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
3742
|
|
|
3724
3743
|
// src/dynamicFlow/telemetry/app-version.ts
|
|
3725
3744
|
var appVersion = (
|
|
3726
3745
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
3727
|
-
typeof process !== "undefined" ? "5.
|
|
3746
|
+
typeof process !== "undefined" ? "5.2.0" : "0.0.0"
|
|
3728
3747
|
);
|
|
3729
3748
|
|
|
3730
3749
|
// src/dynamicFlow/telemetry/getLogEvent.ts
|
|
@@ -3757,70 +3776,12 @@ var getTrackEvent = (onEvent, onAnalytics) => (name, properties) => {
|
|
|
3757
3776
|
}
|
|
3758
3777
|
};
|
|
3759
3778
|
|
|
3760
|
-
// src/dynamicFlow/
|
|
3761
|
-
import {
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
const { locale } = useIntl15();
|
|
3765
|
-
return useCallback(
|
|
3766
|
-
async (input, init = {}) => {
|
|
3767
|
-
const headers = new Headers(init.headers);
|
|
3768
|
-
headers.set("accept-language", locale);
|
|
3769
|
-
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || void 0;
|
|
3770
|
-
if (timeZone) {
|
|
3771
|
-
headers.set("time-zone", timeZone);
|
|
3772
|
-
}
|
|
3773
|
-
const requestInit = __spreadProps(__spreadValues({}, init), { credentials: "include", headers });
|
|
3774
|
-
return httpClient(input, requestInit).catch(handleRejection);
|
|
3775
|
-
},
|
|
3776
|
-
[httpClient, locale]
|
|
3777
|
-
);
|
|
3778
|
-
};
|
|
3779
|
-
var handleRejection = (error) => {
|
|
3780
|
-
if (error instanceof Error && error.message === "SCA_MODAL_CLOSED") {
|
|
3781
|
-
return new Response(JSON.stringify({ validation: {} }), { status: 400 });
|
|
3782
|
-
}
|
|
3783
|
-
throw error;
|
|
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) => {
|
|
3779
|
+
// src/dynamicFlow/DynamicFlow.tsx
|
|
3780
|
+
import { jsx as jsx82 } from "react/jsx-runtime";
|
|
3781
|
+
var wiseRenderers = getWiseRenderers();
|
|
3782
|
+
function DynamicFlow(props) {
|
|
3823
3783
|
const {
|
|
3784
|
+
className = "",
|
|
3824
3785
|
customFetch = globalThis.fetch,
|
|
3825
3786
|
renderers,
|
|
3826
3787
|
displayStepTitle = true,
|
|
@@ -3830,12 +3791,20 @@ var useDynamicFlowWise = (props) => {
|
|
|
3830
3791
|
onLog,
|
|
3831
3792
|
onLink = openLinkInNewTab
|
|
3832
3793
|
} = props;
|
|
3794
|
+
const { formatMessage } = useIntl15();
|
|
3795
|
+
const createSnackBar = useSnackBarIfAvailable();
|
|
3833
3796
|
const httpClient = useWiseHttpClient(customFetch);
|
|
3834
3797
|
const mergedRenderers = useMemo2(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
|
|
3835
3798
|
const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
|
|
3836
3799
|
const trackEvent = useMemo2(() => getTrackEvent(onEvent, onAnalytics), [onEvent, onAnalytics]);
|
|
3837
|
-
const onCopy =
|
|
3838
|
-
|
|
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), {
|
|
3839
3808
|
features: __spreadValues({ hideStepTitle: !displayStepTitle }, features),
|
|
3840
3809
|
httpClient,
|
|
3841
3810
|
renderers: mergedRenderers,
|
|
@@ -3843,7 +3812,66 @@ var useDynamicFlowWise = (props) => {
|
|
|
3843
3812
|
onLog: logEvent,
|
|
3844
3813
|
onLink,
|
|
3845
3814
|
onCopy
|
|
3846
|
-
})
|
|
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
|
+
});
|
|
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;
|
|
3847
3875
|
};
|
|
3848
3876
|
var openLinkInNewTab = (url) => {
|
|
3849
3877
|
var _a;
|
|
@@ -3855,38 +3883,6 @@ var openLinkInNewTab = (url) => {
|
|
|
3855
3883
|
}
|
|
3856
3884
|
};
|
|
3857
3885
|
|
|
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
|
-
|
|
3890
3886
|
// src/index.ts
|
|
3891
3887
|
import { findRendererPropsByType } from "@wise/dynamic-flow-client";
|
|
3892
3888
|
|
|
@@ -4758,7 +4754,7 @@ var translations = languages.reduce(
|
|
|
4758
4754
|
var i18n_default = translations;
|
|
4759
4755
|
export {
|
|
4760
4756
|
DynamicFlow,
|
|
4761
|
-
|
|
4757
|
+
DynamicForm,
|
|
4762
4758
|
Header11 as Header,
|
|
4763
4759
|
Media2 as Media,
|
|
4764
4760
|
findRendererPropsByType,
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
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> = {
|
|
4
5
|
[K in keyof T]: T[K];
|
|
5
6
|
} & {};
|
|
6
|
-
export
|
|
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
|
+
}>;
|
|
7
16
|
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 {};
|
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 { DynamicFormController } from '@wise/dynamic-flow-client';
|
|
3
|
+
export type { DynamicFlowProps } from './dynamicFlow/DynamicFlow';
|
|
4
|
+
export { DynamicFlow, DynamicForm } from './dynamicFlow/DynamicFlow';
|
|
5
5
|
export { findRendererPropsByType } from '@wise/dynamic-flow-client';
|
|
6
|
-
export {
|
|
6
|
+
export { Header, Media, getMargin } 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.2.0",
|
|
4
4
|
"description": "Dynamic Flow web client for Wise",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"vitest-fetch-mock": "0.4.5",
|
|
72
72
|
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
73
73
|
"@wise/dynamic-flow-renderers": "0.0.0",
|
|
74
|
-
"@wise/dynamic-flow-types": "4.
|
|
74
|
+
"@wise/dynamic-flow-types": "4.3.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.
|
|
88
|
+
"@wise/dynamic-flow-client": "5.2.0",
|
|
89
|
+
"@wise/dynamic-flow-types": "4.3.0"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"dev": "pnpm build:visual-tests && storybook dev -p 3005",
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}>;
|
|
@@ -1,22 +0,0 @@
|
|
|
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>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useOnCopy: () => (copiedContent: string | null) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useWiseHttpClient: (httpClient: typeof globalThis.fetch) => typeof globalThis.fetch;
|