@wise/dynamic-flow-client-internal 5.0.0 → 5.0.1-exp-css-28d60ea
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 +24 -44
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ npm install @wise/dynamic-flow-client-internal
|
|
|
19
19
|
pnpm install @wise/dynamic-flow-client-internal
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
2. Install required peer dependencies (if not already installed). Please refer to setup instructions for `@transferwise/components` and `@transferwise/neptune-css` if installing
|
|
22
|
+
2. Install required peer dependencies (if not already installed). Please refer to setup instructions for `@transferwise/components` and `@transferwise/neptune-css` if installing for the first time.
|
|
23
23
|
|
|
24
24
|
```
|
|
25
25
|
# yarn
|
|
@@ -50,15 +50,15 @@ The `DynamicFlow` component must be wraped in a Neptune `Provider` to support lo
|
|
|
50
50
|
import {
|
|
51
51
|
Provider,
|
|
52
52
|
SnackbarProvider,
|
|
53
|
-
translations as
|
|
53
|
+
translations as dsTranslations,
|
|
54
54
|
} from '@transferwise/components';
|
|
55
55
|
import { getLocalisedMessages } from '@transferwise/crab/client';
|
|
56
56
|
import {
|
|
57
57
|
DynamicFlow,
|
|
58
|
-
translations as
|
|
58
|
+
translations as dfTranslations,
|
|
59
59
|
} from '@wise/dynamic-flow-client-internal';
|
|
60
60
|
|
|
61
|
-
const messages = getLocalisedMessages(locale, [
|
|
61
|
+
const messages = getLocalisedMessages(locale, [dsTranslations, dfTranslations]);
|
|
62
62
|
|
|
63
63
|
return (
|
|
64
64
|
<Provider i18n={{ locale, messages }}>
|
|
@@ -91,17 +91,17 @@ You'll need to merge the '@transferwise/components' translations with the '@wise
|
|
|
91
91
|
import {
|
|
92
92
|
Provider,
|
|
93
93
|
SnackbarProvider,
|
|
94
|
-
translations as
|
|
94
|
+
translations as dsTranslations,
|
|
95
95
|
} from '@transferwise/components';
|
|
96
96
|
import {
|
|
97
97
|
DynamicFlow,
|
|
98
|
-
translations as
|
|
98
|
+
translations as dfTranslations,
|
|
99
99
|
} from '@wise/dynamic-flow-client-internal';
|
|
100
100
|
|
|
101
101
|
// create your messages object
|
|
102
102
|
const messages: Record<string, string> = {
|
|
103
|
-
...(
|
|
104
|
-
...(
|
|
103
|
+
...(dsTranslations[lang] || dsTranslations[lang.replace('-', '_')] || dsTranslations[lang.substring(0, 2)] || {}),
|
|
104
|
+
...(dfTranslations[lang] || dfTranslations[lang.replace('-', '_')] || dfTranslations[lang.substring(0, 2)] || {}),
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
return (
|
|
@@ -203,13 +203,13 @@ const mockCustomFetch = (input, init) => Promise.resolve(new Response(JSON.strin
|
|
|
203
203
|
|
|
204
204
|
### Telemetry
|
|
205
205
|
|
|
206
|
-
The `DynamicFlow` component accepts two optional props: `
|
|
206
|
+
The `DynamicFlow` component accepts two optional props: `onAnalytics` and `onLog` which can be used to track and log.
|
|
207
207
|
|
|
208
208
|
In the example below we send tracking events to Mixpanel and logging events to Rollbar.
|
|
209
209
|
|
|
210
210
|
```tsx
|
|
211
211
|
<DynamicFlow
|
|
212
|
-
|
|
212
|
+
onAnalytics={(event, props) => mixpanel.track(event, props)}
|
|
213
213
|
onLog={(level, message, extra) => Rollbar[level](message, extra)}
|
|
214
214
|
/>
|
|
215
215
|
```
|
|
@@ -217,7 +217,7 @@ In the example below we send tracking events to Mixpanel and logging events to R
|
|
|
217
217
|
Alternatively, you can log to the browser console:
|
|
218
218
|
|
|
219
219
|
```ts
|
|
220
|
-
|
|
220
|
+
onAnalytics={(event, props) => console.log(event, props)}
|
|
221
221
|
onLog={(level, message, extra) => {
|
|
222
222
|
const levelToConsole = {
|
|
223
223
|
critical: console.error,
|
|
@@ -230,56 +230,36 @@ onLog={(level, message, extra) => {
|
|
|
230
230
|
}}
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
## DynamicForm Component
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
You can change the defaults by passing a `loaderConfig` prop:
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
type LoaderConfig = {
|
|
241
|
-
size?: `xs | sm | md | lg | xl`;
|
|
242
|
-
initial?: boolean;
|
|
243
|
-
submission?: boolean;
|
|
244
|
-
};
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
| property | type | notes | default |
|
|
248
|
-
| ------------ | ------- | ------------------------------------------------------------------------------ | ------- |
|
|
249
|
-
| `size` | string | The size of the Loader component. | `xl` |
|
|
250
|
-
| `initial` | boolean | Whether or not to display the Loader component while loading the initial step. | true |
|
|
251
|
-
| `submission` | boolean | Whether or not to display the Loader component during form submissions. | false |
|
|
252
|
-
|
|
253
|
-
## DynamicFragment
|
|
254
|
-
|
|
255
|
-
If you need to get the submittable data outside of a submission, you can use the `DynamicFragment` component. This will give you access to two methods: `getValue` and `validate` via a [ref](https://react.dev/reference/react/useRef). For example:
|
|
235
|
+
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:
|
|
256
236
|
|
|
257
237
|
```tsx
|
|
258
|
-
import type {
|
|
259
|
-
import {
|
|
238
|
+
import type { DynamicFormController } from '@wise/dynamic-flow-client-internal';
|
|
239
|
+
import { DynamicForm } from '@wise/dynamic-flow-client-internal';
|
|
260
240
|
import { useRef } from 'react';
|
|
261
241
|
|
|
262
242
|
function DynamicFlowWithRef() {
|
|
263
|
-
const ref = useRef<
|
|
243
|
+
const ref = useRef<DynamicFormController>(null);
|
|
264
244
|
|
|
265
245
|
return (
|
|
266
|
-
|
|
267
|
-
<
|
|
246
|
+
<div>
|
|
247
|
+
<DynamicForm
|
|
268
248
|
ref={ref}
|
|
269
249
|
flowId={"id"}
|
|
270
250
|
customFetch={fetch}
|
|
271
|
-
initialStep={
|
|
272
|
-
onValueChange={async () => {
|
|
273
|
-
const value = (await ref.current?.getValue()) ?? null
|
|
251
|
+
initialStep={myStep}
|
|
252
|
+
onValueChange={ async () => {
|
|
253
|
+
const value = (await ref.current?.getValue()) ?? null;
|
|
274
254
|
console.log('Value changed to', JSON.stringify(value));
|
|
275
255
|
}}
|
|
276
256
|
onCompletion={(error) => console.error(error)}
|
|
277
257
|
onCompletion={() => console.log('Completed')}
|
|
278
258
|
/>
|
|
279
259
|
<Button
|
|
280
|
-
onClick={async () => {
|
|
260
|
+
onClick={ async () => {
|
|
281
261
|
// This will get the value, whether or not the form is valid
|
|
282
|
-
const value = (await ref.current?.getValue()) ?? null
|
|
262
|
+
const value = (await ref.current?.getValue()) ?? null;
|
|
283
263
|
|
|
284
264
|
// This will trigger validation of the form and show any validation messages to the user.
|
|
285
265
|
// The response is a boolean indicating whether or not the form is valid.
|
|
@@ -290,7 +270,7 @@ function DynamicFlowWithRef() {
|
|
|
290
270
|
>
|
|
291
271
|
Log value
|
|
292
272
|
</Button>
|
|
293
|
-
|
|
273
|
+
</div>
|
|
294
274
|
);
|
|
295
275
|
}
|
|
296
276
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client-internal",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1-exp-css-28d60ea",
|
|
4
4
|
"description": "Dynamic Flow web client for Wise",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.js",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"import": "./build/main.mjs",
|
|
17
17
|
"require": "./build/main.js"
|
|
18
18
|
},
|
|
19
|
-
"./build/main.css": "./build/main.css"
|
|
19
|
+
"./build/main.css": "./build/main.css",
|
|
20
|
+
"./main.css": "./build/main.css"
|
|
20
21
|
},
|
|
21
22
|
"sideEffects": [
|
|
22
23
|
"*.css"
|
|
@@ -78,8 +79,8 @@
|
|
|
78
79
|
"stylelint-value-no-unknown-custom-properties": "6.0.1",
|
|
79
80
|
"tsx": "4.20.6",
|
|
80
81
|
"typescript": "5.9.3",
|
|
81
|
-
"@wise/dynamic-flow-types": "4.0.0",
|
|
82
82
|
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
83
|
+
"@wise/dynamic-flow-types": "4.0.0",
|
|
83
84
|
"@wise/dynamic-flow-renderers": "0.0.0"
|
|
84
85
|
},
|
|
85
86
|
"peerDependencies": {
|
|
@@ -94,7 +95,7 @@
|
|
|
94
95
|
"react-intl": "^6"
|
|
95
96
|
},
|
|
96
97
|
"dependencies": {
|
|
97
|
-
"@wise/dynamic-flow-client": "5.0.
|
|
98
|
+
"@wise/dynamic-flow-client": "5.0.1-exp-css-28d60ea",
|
|
98
99
|
"@wise/dynamic-flow-types": "4.0.0"
|
|
99
100
|
},
|
|
100
101
|
"scripts": {
|