@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.
Files changed (25) hide show
  1. package/README.md +15 -30
  2. package/build/main.js +220 -108
  3. package/build/main.mjs +220 -108
  4. package/build/types/domain/components/step/StepDomainComponent.d.ts +4 -2
  5. package/build/types/domain/features/polling/getStepPolling.d.ts +3 -2
  6. package/build/types/domain/mappers/layout/alertLayoutToComponent.d.ts +1 -1
  7. package/build/types/domain/mappers/layout/decisionLayoutToComponent.d.ts +1 -1
  8. package/build/types/domain/mappers/layout/reviewLayoutToComponent.d.ts +1 -1
  9. package/build/types/domain/mappers/layout/statusListLayoutToComponent.d.ts +1 -1
  10. package/build/types/domain/mappers/mapStepToComponent.d.ts +1 -1
  11. package/build/types/domain/mappers/schema/types.d.ts +2 -1
  12. package/build/types/domain/mappers/utils/behavior-utils.d.ts +5 -2
  13. package/build/types/domain/mappers/utils/call-to-action-utils.d.ts +3 -2
  14. package/build/types/domain/mappers/utils/utils.d.ts +3 -2
  15. package/build/types/domain/prefetching/request-cache.d.ts +9 -0
  16. package/build/types/flow/executeSubmission.d.ts +4 -1
  17. package/build/types/flow/makeSafeHttpClient.d.ts +2 -0
  18. package/build/types/flow/makeSubmissionRequest.d.ts +3 -0
  19. package/package.json +28 -37
  20. package/build/types/domain/mappers/schema/tests/test-utils.d.ts +0 -34
  21. package/build/types/test-utils/NeptuneProviders.d.ts +0 -5
  22. package/build/types/test-utils/getRandomId.d.ts +0 -1
  23. package/build/types/test-utils/index.d.ts +0 -2
  24. package/build/types/test-utils/rtl-utils.d.ts +0 -2
  25. 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
- // Should be imported once in your application
41
- import '@wise/dynamic-flow-client/build/main.css';
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 componentTranslations,
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 dynamicFlowsTranslations,
62
+ translations as dfTranslations,
58
63
  } from '@wise/dynamic-flow-client';
59
64
 
60
- const messages = getLocalisedMessages(locale, [componentTranslations, dynamicFlowsTranslations])
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 componentTranslations,
86
+ translations as dsTranslations,
82
87
  } from '@transferwise/components';
83
88
  import {
84
89
  DynamicFlow,
85
- translations as dynamicFlowsTranslations,
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
- ...(componentTranslations[lang] || componentTranslations[lang.replace('-', '_')] || componentTranslations[lang.substring(0, 2)] || {}),
91
- ...(translations[lang] || translations[lang.replace('-', '_')] || translations[lang.substring(0, 2)] || {}),
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={someInitialStepIfoundLayingAroundHere}
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.