@wise/dynamic-flow-client 5.0.0 → 5.1.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 +15 -30
- package/build/main.js +220 -108
- package/build/main.mjs +220 -108
- package/build/types/domain/components/step/StepDomainComponent.d.ts +4 -2
- package/build/types/domain/features/polling/getStepPolling.d.ts +3 -2
- package/build/types/domain/mappers/layout/alertLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/decisionLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/reviewLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/layout/statusListLayoutToComponent.d.ts +1 -1
- package/build/types/domain/mappers/mapStepToComponent.d.ts +1 -1
- package/build/types/domain/mappers/schema/types.d.ts +2 -1
- package/build/types/domain/mappers/utils/behavior-utils.d.ts +5 -2
- package/build/types/domain/mappers/utils/call-to-action-utils.d.ts +3 -2
- package/build/types/domain/mappers/utils/utils.d.ts +3 -2
- package/build/types/domain/prefetching/request-cache.d.ts +9 -0
- package/build/types/flow/executeSubmission.d.ts +4 -1
- package/build/types/flow/makeSafeHttpClient.d.ts +2 -0
- package/build/types/flow/makeSubmissionRequest.d.ts +3 -0
- package/package.json +28 -37
- package/build/types/domain/mappers/schema/tests/test-utils.d.ts +0 -34
- package/build/types/test-utils/NeptuneProviders.d.ts +0 -5
- package/build/types/test-utils/getRandomId.d.ts +0 -1
- package/build/types/test-utils/index.d.ts +0 -2
- package/build/types/test-utils/rtl-utils.d.ts +0 -2
- package/build/types/tests/renderers/TextInputRenderer.test.d.ts +0 -1
package/README.md
CHANGED
|
@@ -36,9 +36,14 @@ pnpm install @transferwise/components @transferwise/formatting @transferwise/ico
|
|
|
36
36
|
```
|
|
37
37
|
**Note:** Keep in mind that some of these dependencies have their own peer dependencies. Don't forget to install those, for instance: `@transferwise/components` needs `@wise/art` and `@wise/components-theming`.
|
|
38
38
|
|
|
39
|
+
3. In addition to the design system styles, you need to import the DynamicFlow styles once into your application. You can do this either via JavaScript or CSS.
|
|
40
|
+
|
|
39
41
|
```js
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
import '@wise/dynamic-flow-client/main.css'; // JavaScript
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
@import url('@wise/dynamic-flow-client/build/main.css'); /* CSS */
|
|
42
47
|
```
|
|
43
48
|
|
|
44
49
|
The `DynamicFlow` component must be wraped in a Neptune `Provider` to support localisation, a `ThemeProvider` to provide theming, and a `SnackbarProvider` to ensure snackbars display correctly. Translations should be imported from both components and dynamic flows, merged, and passed to the `Provider` component (as below).
|
|
@@ -49,15 +54,15 @@ The `DynamicFlow` component must be wraped in a Neptune `Provider` to support lo
|
|
|
49
54
|
import {
|
|
50
55
|
Provider,
|
|
51
56
|
SnackbarProvider,
|
|
52
|
-
translations as
|
|
57
|
+
translations as dsTranslations,
|
|
53
58
|
} from '@transferwise/components';
|
|
54
59
|
import { getLocalisedMessages } from '@transferwise/crab/client';
|
|
55
60
|
import {
|
|
56
61
|
DynamicFlow,
|
|
57
|
-
translations as
|
|
62
|
+
translations as dfTranslations,
|
|
58
63
|
} from '@wise/dynamic-flow-client';
|
|
59
64
|
|
|
60
|
-
const messages = getLocalisedMessages(locale, [
|
|
65
|
+
const messages = getLocalisedMessages(locale, [dsTranslations, dfTranslations])
|
|
61
66
|
|
|
62
67
|
return (
|
|
63
68
|
<Provider i18n={{ locale, messages }}>
|
|
@@ -78,17 +83,17 @@ You'll need to merge the '@transferwise/components' translations with the '@wise
|
|
|
78
83
|
import {
|
|
79
84
|
Provider,
|
|
80
85
|
SnackbarProvider,
|
|
81
|
-
translations as
|
|
86
|
+
translations as dsTranslations,
|
|
82
87
|
} from '@transferwise/components';
|
|
83
88
|
import {
|
|
84
89
|
DynamicFlow,
|
|
85
|
-
translations as
|
|
90
|
+
translations as dfTranslations,
|
|
86
91
|
} from '@wise/dynamic-flow-client';
|
|
87
92
|
|
|
88
93
|
// create your messages object
|
|
89
94
|
const messages: Record<string, string> = {
|
|
90
|
-
...(
|
|
91
|
-
...(
|
|
95
|
+
...(dsTranslations[lang] || dsTranslations[lang.replace('-', '_')] || dsTranslations[lang.substring(0, 2)] || {}),
|
|
96
|
+
...(dfTranslations[lang] || dfTranslations[lang.replace('-', '_')] || dfTranslations[lang.substring(0, 2)] || {}),
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
return (
|
|
@@ -125,7 +130,7 @@ In some cases you may want to obtain the initial step yourself, and then pass it
|
|
|
125
130
|
|
|
126
131
|
```tsx
|
|
127
132
|
<DynamicFlow
|
|
128
|
-
initialStep={
|
|
133
|
+
initialStep={myInitialStep}
|
|
129
134
|
httpClient={...}
|
|
130
135
|
onCompletion={...}
|
|
131
136
|
onError={...}
|
|
@@ -211,26 +216,6 @@ onLog={(level, message, extra) => {
|
|
|
211
216
|
}}
|
|
212
217
|
```
|
|
213
218
|
|
|
214
|
-
### Loader configuration
|
|
215
|
-
|
|
216
|
-
By default, DF will display a loading animation (The `Loader` component from Neptune) when the first step is loading. It will not display it during refresh-on-change or while submitting forms.
|
|
217
|
-
|
|
218
|
-
You can change the defaults by passing a `loaderConfig` prop:
|
|
219
|
-
|
|
220
|
-
```ts
|
|
221
|
-
type LoaderConfig = {
|
|
222
|
-
size?: `xs | sm | md | lg | xl`;
|
|
223
|
-
initial?: boolean;
|
|
224
|
-
submission?: boolean;
|
|
225
|
-
};
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
| property | type | notes | default |
|
|
229
|
-
| ------------ | ------- | ------------------------------------------------------------------------------ | ------- |
|
|
230
|
-
| `size` | string | The size of the Loader component. | `xl` |
|
|
231
|
-
| `initial` | boolean | Whether or not to display the Loader component while loading the initial step. | true |
|
|
232
|
-
| `submission` | boolean | Whether or not to display the Loader component during form submissions. | false |
|
|
233
|
-
|
|
234
219
|
## Contributing
|
|
235
220
|
|
|
236
221
|
We love contributions! Check out `CONTRIBUTING.md` for more information.
|