@transferwise/components 0.0.0-experimental-47052c9 → 0.0.0-experimental-b2b287d
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/build/Snackbar/Snackbar.js +178 -102
- package/build/Snackbar/Snackbar.js.map +1 -1
- package/build/Snackbar/Snackbar.messages.js +14 -0
- package/build/Snackbar/Snackbar.messages.js.map +1 -0
- package/build/Snackbar/Snackbar.messages.mjs +10 -0
- package/build/Snackbar/Snackbar.messages.mjs.map +1 -0
- package/build/Snackbar/Snackbar.mjs +180 -101
- package/build/Snackbar/Snackbar.mjs.map +1 -1
- package/build/Snackbar/SnackbarContext.js.map +1 -1
- package/build/Snackbar/SnackbarContext.mjs.map +1 -1
- package/build/Snackbar/SnackbarPortal.js +12 -0
- package/build/Snackbar/SnackbarPortal.js.map +1 -0
- package/build/Snackbar/SnackbarPortal.mjs +8 -0
- package/build/Snackbar/SnackbarPortal.mjs.map +1 -0
- package/build/Snackbar/SnackbarProvider.js +24 -28
- package/build/Snackbar/SnackbarProvider.js.map +1 -1
- package/build/Snackbar/SnackbarProvider.mjs +25 -29
- package/build/Snackbar/SnackbarProvider.mjs.map +1 -1
- package/build/Snackbar/constants.js +17 -0
- package/build/Snackbar/constants.js.map +1 -0
- package/build/Snackbar/constants.mjs +11 -0
- package/build/Snackbar/constants.mjs.map +1 -0
- package/build/Snackbar/useSnackbarAutoDismiss.js +66 -0
- package/build/Snackbar/useSnackbarAutoDismiss.js.map +1 -0
- package/build/Snackbar/useSnackbarAutoDismiss.mjs +62 -0
- package/build/Snackbar/useSnackbarAutoDismiss.mjs.map +1 -0
- package/build/Snackbar/useSnackbarManager.js +153 -0
- package/build/Snackbar/useSnackbarManager.js.map +1 -0
- package/build/Snackbar/useSnackbarManager.mjs +149 -0
- package/build/Snackbar/useSnackbarManager.mjs.map +1 -0
- package/build/Snackbar/useSnackbarSwipeDismiss.js +135 -0
- package/build/Snackbar/useSnackbarSwipeDismiss.js.map +1 -0
- package/build/Snackbar/useSnackbarSwipeDismiss.mjs +131 -0
- package/build/Snackbar/useSnackbarSwipeDismiss.mjs.map +1 -0
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +0 -4
- package/build/index.js.map +1 -1
- package/build/index.mjs +0 -2
- package/build/index.mjs.map +1 -1
- package/build/main.css +116 -245
- package/build/styles/Snackbar/Snackbar.css +117 -54
- package/build/styles/main.css +116 -245
- package/build/types/Snackbar/Snackbar.d.ts +55 -9
- package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
- package/build/types/Snackbar/Snackbar.messages.d.ts +9 -0
- package/build/types/Snackbar/Snackbar.messages.d.ts.map +1 -0
- package/build/types/Snackbar/Snackbar.types.d.ts +12 -0
- package/build/types/Snackbar/Snackbar.types.d.ts.map +1 -0
- package/build/types/Snackbar/SnackbarContext.d.ts +2 -2
- package/build/types/Snackbar/SnackbarContext.d.ts.map +1 -1
- package/build/types/Snackbar/SnackbarPortal.d.ts +4 -0
- package/build/types/Snackbar/SnackbarPortal.d.ts.map +1 -0
- package/build/types/Snackbar/SnackbarProvider.d.ts +7 -0
- package/build/types/Snackbar/SnackbarProvider.d.ts.map +1 -1
- package/build/types/Snackbar/constants.d.ts +9 -0
- package/build/types/Snackbar/constants.d.ts.map +1 -0
- package/build/types/Snackbar/index.d.ts +1 -1
- package/build/types/Snackbar/index.d.ts.map +1 -1
- package/build/types/Snackbar/useSnackbar.d.ts +1 -1
- package/build/types/Snackbar/useSnackbar.d.ts.map +1 -1
- package/build/types/Snackbar/useSnackbarAutoDismiss.d.ts +13 -0
- package/build/types/Snackbar/useSnackbarAutoDismiss.d.ts.map +1 -0
- package/build/types/Snackbar/useSnackbarManager.d.ts +20 -0
- package/build/types/Snackbar/useSnackbarManager.d.ts.map +1 -0
- package/build/types/Snackbar/useSnackbarSwipeDismiss.d.ts +22 -0
- package/build/types/Snackbar/useSnackbarSwipeDismiss.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -5
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/FlowNavigation/_stories/FlowNavigation.CriticalBanner.docs.mdx +66 -0
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.story.tsx +2 -0
- package/src/Snackbar/Snackbar.css +117 -54
- package/src/Snackbar/Snackbar.less +139 -60
- package/src/Snackbar/Snackbar.messages.ts +9 -0
- package/src/Snackbar/Snackbar.test.tsx +989 -119
- package/src/Snackbar/Snackbar.tsx +208 -93
- package/src/Snackbar/Snackbar.types.ts +17 -0
- package/src/Snackbar/SnackbarContext.ts +2 -2
- package/src/Snackbar/SnackbarPortal.tsx +8 -0
- package/src/Snackbar/SnackbarProvider.test.tsx +783 -0
- package/src/Snackbar/SnackbarProvider.tsx +27 -19
- package/src/Snackbar/_stories/Snackbar.accessibility.docs.mdx +58 -0
- package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +16 -8
- package/src/Snackbar/_stories/Snackbar.story.tsx +388 -61
- package/src/Snackbar/_stories/Snackbar.test.story.tsx +171 -47
- package/src/Snackbar/constants.ts +10 -0
- package/src/Snackbar/index.ts +1 -1
- package/src/Snackbar/useSnackbarAutoDismiss.ts +74 -0
- package/src/Snackbar/useSnackbarManager.ts +169 -0
- package/src/Snackbar/useSnackbarSwipeDismiss.ts +169 -0
- package/src/i18n/en.json +1 -0
- package/src/index.ts +1 -14
- package/src/main.css +116 -245
- package/src/main.less +0 -2
- package/build/CardContainer/CardContainer.js +0 -34
- package/build/CardContainer/CardContainer.js.map +0 -1
- package/build/CardContainer/CardContainer.mjs +0 -30
- package/build/CardContainer/CardContainer.mjs.map +0 -1
- package/build/CardWidget/CardWidget.js +0 -98
- package/build/CardWidget/CardWidget.js.map +0 -1
- package/build/CardWidget/CardWidget.mjs +0 -94
- package/build/CardWidget/CardWidget.mjs.map +0 -1
- package/build/CardWidget/CardWidgetAction.js +0 -73
- package/build/CardWidget/CardWidgetAction.js.map +0 -1
- package/build/CardWidget/CardWidgetAction.mjs +0 -68
- package/build/CardWidget/CardWidgetAction.mjs.map +0 -1
- package/build/styles/CardContainer/CardContainer.css +0 -108
- package/build/styles/CardWidget/CardWidget.css +0 -84
- package/build/types/CardContainer/CardContainer.d.ts +0 -8
- package/build/types/CardContainer/CardContainer.d.ts.map +0 -1
- package/build/types/CardContainer/CardContainer.types.d.ts +0 -53
- package/build/types/CardContainer/CardContainer.types.d.ts.map +0 -1
- package/build/types/CardContainer/_stories/helpers.d.ts +0 -3
- package/build/types/CardContainer/_stories/helpers.d.ts.map +0 -1
- package/build/types/CardContainer/index.d.ts +0 -3
- package/build/types/CardContainer/index.d.ts.map +0 -1
- package/build/types/CardWidget/CardWidget.d.ts +0 -10
- package/build/types/CardWidget/CardWidget.d.ts.map +0 -1
- package/build/types/CardWidget/CardWidget.types.d.ts +0 -55
- package/build/types/CardWidget/CardWidget.types.d.ts.map +0 -1
- package/build/types/CardWidget/CardWidgetAction.d.ts +0 -54
- package/build/types/CardWidget/CardWidgetAction.d.ts.map +0 -1
- package/build/types/CardWidget/index.d.ts +0 -4
- package/build/types/CardWidget/index.d.ts.map +0 -1
- package/src/CardContainer/CardContainer.css +0 -108
- package/src/CardContainer/CardContainer.less +0 -171
- package/src/CardContainer/CardContainer.test.tsx +0 -150
- package/src/CardContainer/CardContainer.tsx +0 -51
- package/src/CardContainer/CardContainer.types.ts +0 -60
- package/src/CardContainer/_stories/CardContainer.story.tsx +0 -167
- package/src/CardContainer/_stories/CardContainer.test.story.tsx +0 -103
- package/src/CardContainer/_stories/helpers.tsx +0 -50
- package/src/CardContainer/index.ts +0 -6
- package/src/CardWidget/CardWidget.css +0 -84
- package/src/CardWidget/CardWidget.less +0 -110
- package/src/CardWidget/CardWidget.test.tsx +0 -222
- package/src/CardWidget/CardWidget.tsx +0 -83
- package/src/CardWidget/CardWidget.types.ts +0 -63
- package/src/CardWidget/CardWidgetAction.tsx +0 -128
- package/src/CardWidget/_stories/CardWidget.story.tsx +0 -238
- package/src/CardWidget/_stories/CardWidget.test.story.tsx +0 -350
- package/src/CardWidget/index.ts +0 -3
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.docs.mdx +0 -122
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { Meta, Source } from '@storybook/addon-docs/blocks';
|
|
2
|
-
|
|
3
|
-
<Meta title="Prompts/CriticalBanner/Developer Guide" tags={['new']} />
|
|
4
|
-
|
|
5
|
-
# Developer Guide
|
|
6
|
-
|
|
7
|
-
**Note:** Any usages of `Layout`, `Flow` or `HashRouterFlow` rely on the `global-critical-banner` feature flag being enabled. Whilst this flag is currently disabled in production, it's recommended to test with this flag enabled in staging, to ensure the critical banner behaves as expected for your users.
|
|
8
|
-
|
|
9
|
-
Typically `CriticalBanner` should be used in one of three ways. Pick the one that matches the page or flow you're building and avoid using CriticalBanner as a standalone component.
|
|
10
|
-
|
|
11
|
-
- `Layout` via `@transferwise/navigation-ui` - Fetched automatically from navigation-service (for non-flow layouts)
|
|
12
|
-
- `Flow` / `HashRouterFlow` via `@transferwise/flow` - Fetched automatically from navigation-service (for flows)
|
|
13
|
-
- `FlowNavigation` via `@transferwise/components` - Passed in by you through the `banner` prop (for custom solutions)
|
|
14
|
-
|
|
15
|
-
If your page uses `Layout`, `Flow` or `HashRouterFlow`, you don't need to render `CriticalBanner` yourself. These components fetch the banner, cache it and render it for you automatically.
|
|
16
|
-
|
|
17
|
-
## Layout from @transferwise/navigation-ui
|
|
18
|
-
|
|
19
|
-
`Layout` has no banner prop. It fetches the critical banner from navigation-service on the client and renders it above the page content.
|
|
20
|
-
|
|
21
|
-
Requirements:
|
|
22
|
-
|
|
23
|
-
- `@transferwise/navigation-ui` `4.46.0` or later
|
|
24
|
-
- The page must use the composable layout, and `global-critical-banner` feature flags in navigation-service control this. The legacy layout doesn't render the banner.
|
|
25
|
-
|
|
26
|
-
<Source
|
|
27
|
-
code={`import { Layout, fetchNavigationData, type NavigationData } from '@transferwise/navigation-ui';
|
|
28
|
-
|
|
29
|
-
// Optional: fetch initial navigation data server side, so the banner cache is scoped correctly.
|
|
30
|
-
export const getServerSideProps = async () => {
|
|
31
|
-
const navigationData = await fetchNavigationData({
|
|
32
|
-
httpClient,
|
|
33
|
-
navigationServiceUrl: process.env.NAVIGATION_SERVICE_URL,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return { props: { navigationData } };
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const Page = ({ navigationData }: { navigationData: NavigationData }) => (
|
|
40
|
-
<Layout navigationData={navigationData} onMixpanelEvent={trackEvent}>
|
|
41
|
-
{ /* Page content */ }
|
|
42
|
-
</Layout>
|
|
43
|
-
);
|
|
44
|
-
`}
|
|
45
|
-
language="typescript"
|
|
46
|
-
dark
|
|
47
|
-
/>
|
|
48
|
-
|
|
49
|
-
`Layout` also handles:
|
|
50
|
-
|
|
51
|
-
- saving the collapsed or expanded state when the user toggles the banner
|
|
52
|
-
- caching the banner for the session, so the entry animation only plays for new or changed banners
|
|
53
|
-
- sending Mixpanel events for toggles and action clicks through `onMixpanelEvent`
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Flow / HashRouterFlow from @transferwise/flow
|
|
57
|
-
|
|
58
|
-
`Flow` and `HashRouterFlow`, from `@transferwise/flow` render `FlowNavigationWrapper` from `@transferwise/navigation-ui`. It fetches, caches and renders the critical banner the same way `Layout` does. You don't need to pass a banner, but do require `@transferwise/navigation-ui` as a dependency.
|
|
59
|
-
|
|
60
|
-
Requirements:
|
|
61
|
-
|
|
62
|
-
- `@transferwise/flow` `13.0.0` or later
|
|
63
|
-
- `@transferwise/navigation-ui` `4.51.0` or later, which is a required peer dependency
|
|
64
|
-
|
|
65
|
-
You can pass two optional properties in the `navigation` options:
|
|
66
|
-
|
|
67
|
-
- `navigationData`: initial navigation data, usually fetched server side, so the banner cache is scoped correctly. If you leave it out, the banner is fetched on the client.
|
|
68
|
-
- `onMixpanelEvent`: called when the user toggles the banner or clicks its action.
|
|
69
|
-
|
|
70
|
-
<Source
|
|
71
|
-
code={`import { HashRouterFlow } from '@transferwise/flow';
|
|
72
|
-
import type { NavigationData } from '@transferwise/navigation-ui';
|
|
73
|
-
|
|
74
|
-
const SendFlow = ({ navigationData }: { navigationData?: NavigationData }) => (
|
|
75
|
-
<HashRouterFlow
|
|
76
|
-
steps={steps}
|
|
77
|
-
trackEvent={trackEvent}
|
|
78
|
-
navigation={{
|
|
79
|
-
profile,
|
|
80
|
-
onClose,
|
|
81
|
-
navigationData,
|
|
82
|
-
onMixpanelEvent: trackEvent,
|
|
83
|
-
}}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
`}
|
|
87
|
-
language="typescript"
|
|
88
|
-
dark
|
|
89
|
-
/>
|
|
90
|
-
|
|
91
|
-
## FlowNavigation from @transferwise/components
|
|
92
|
-
|
|
93
|
-
`FlowNavigation` from `@transferwise/components` renders a critical banner above the navigation when you pass a `banner` prop. Use this if you build your flow with `FlowNavigation` directly. You're responsible for getting the banner data.
|
|
94
|
-
|
|
95
|
-
`banner` accepts either:
|
|
96
|
-
|
|
97
|
-
- `CriticalBannerProps`, the same props `CriticalBanner` takes
|
|
98
|
-
- the legacy `CriticalBannerData` shape returned by navigation-service. `FlowNavigation` maps it to `CriticalBannerProps` for you.
|
|
99
|
-
|
|
100
|
-
<Source
|
|
101
|
-
code={`import { FlowNavigation, type CriticalBannerProps } from '@transferwise/components';
|
|
102
|
-
|
|
103
|
-
const banner: CriticalBannerProps = {
|
|
104
|
-
sentiment: 'negative',
|
|
105
|
-
title: 'Action required',
|
|
106
|
-
description: 'Please verify your identity to continue with this transfer.',
|
|
107
|
-
action: { label: 'Verify now', onClick: handleVerify },
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
<FlowNavigation
|
|
111
|
-
banner={banner}
|
|
112
|
-
steps={steps}
|
|
113
|
-
activeStep={activeStep}
|
|
114
|
-
avatar={avatar}
|
|
115
|
-
onClose={onClose}
|
|
116
|
-
/>;
|
|
117
|
-
`}
|
|
118
|
-
language="typescript"
|
|
119
|
-
dark
|
|
120
|
-
/>
|
|
121
|
-
|
|
122
|
-
Requires `@transferwise/components` `46.162.0` or later. Support for the legacy `CriticalBannerData` shape was added in `46.164.0`.
|