@ledgerhq/lumen-ui-rnative 0.1.63 → 0.1.65
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/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js +19 -11
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js.map +1 -1
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.test.js +113 -4
- package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.test.js.map +1 -1
- package/dist/module/lib/Components/core/BottomSheet/BottomSheet.stories.js +51 -0
- package/dist/module/lib/Components/core/BottomSheet/BottomSheet.stories.js.map +1 -1
- package/dist/module/lib/Components/core/CardButton/CardButton.js +2 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.js.map +1 -1
- package/dist/module/lib/Components/core/CardButton/CardButton.mdx +4 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js +1 -0
- package/dist/module/lib/Components/core/CardButton/CardButton.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.figma.js +2 -1
- package/dist/module/lib/Components/core/Link/Link.figma.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.js +5 -3
- package/dist/module/lib/Components/core/Link/Link.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.mdx +3 -2
- package/dist/module/lib/Components/core/Link/Link.stories.js +4 -1
- package/dist/module/lib/Components/core/Link/Link.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Link/Link.test.js +2 -2
- package/dist/module/lib/Components/core/Link/Link.test.js.map +1 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.js +93 -7
- package/dist/module/lib/Components/core/MenuList/MenuList.js.map +1 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.mdx +14 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js +39 -2
- package/dist/module/lib/Components/core/MenuList/MenuList.stories.js.map +1 -1
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js +60 -2
- package/dist/module/lib/Components/core/MenuList/MenuList.test.js.map +1 -1
- package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.js +76 -30
- package/dist/module/lib/Components/core/Stepper/Stepper.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.mdx +37 -16
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js +102 -2
- package/dist/module/lib/Components/core/Stepper/Stepper.stories.js.map +1 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.test.js +32 -1
- package/dist/module/lib/Components/core/Stepper/Stepper.test.js.map +1 -1
- package/dist/module/lib/Components/core/Timeline/Timeline.figma.js +83 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.figma.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.js +464 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.mdx +49 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js +289 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.stories.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js +234 -0
- package/dist/module/lib/Components/core/Timeline/Timeline.test.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/index.js +5 -0
- package/dist/module/lib/Components/core/Timeline/index.js.map +1 -0
- package/dist/module/lib/Components/core/Timeline/types.js +4 -0
- package/dist/module/lib/Components/core/Timeline/types.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.figma.js +39 -0
- package/dist/module/lib/Components/core/Toast/Toast.figma.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.js +138 -0
- package/dist/module/lib/Components/core/Toast/Toast.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.mdx +203 -0
- package/dist/module/lib/Components/core/Toast/Toast.stories.js +238 -0
- package/dist/module/lib/Components/core/Toast/Toast.stories.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toast.test.js +203 -0
- package/dist/module/lib/Components/core/Toast/Toast.test.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toaster.js +147 -0
- package/dist/module/lib/Components/core/Toast/Toaster.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/Toaster.test.js +732 -0
- package/dist/module/lib/Components/core/Toast/Toaster.test.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js +70 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js +33 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js +224 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js +82 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js +21 -0
- package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/index.js +7 -0
- package/dist/module/lib/Components/core/Toast/index.js.map +1 -0
- package/dist/module/lib/Components/core/Toast/types.js +4 -0
- package/dist/module/lib/Components/core/Toast/types.js.map +1 -0
- package/dist/module/lib/Components/core/index.js +2 -0
- package/dist/module/lib/Components/core/index.js.map +1 -1
- package/dist/typescript/src/lib/Components/core/AmountDisplay/AmountDisplay.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts +2 -0
- package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Link/Link.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts +1 -1
- package/dist/typescript/src/lib/Components/core/Link/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts +12 -2
- package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts +26 -7
- package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts +4 -3
- package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts +12 -2
- package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts.map +1 -1
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts +56 -0
- package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts +3 -0
- package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts +109 -0
- package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts +24 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts +35 -0
- package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts +17 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts +19 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts +14 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts +15 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts +21 -0
- package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/index.d.ts +5 -0
- package/dist/typescript/src/lib/Components/core/Toast/index.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/Toast/types.d.ts +75 -0
- package/dist/typescript/src/lib/Components/core/Toast/types.d.ts.map +1 -0
- package/dist/typescript/src/lib/Components/core/index.d.ts +2 -0
- package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Components/core/AmountDisplay/AmountDisplay.test.tsx +138 -4
- package/src/lib/Components/core/AmountDisplay/AmountDisplay.tsx +13 -6
- package/src/lib/Components/core/BottomSheet/BottomSheet.stories.tsx +51 -0
- package/src/lib/Components/core/CardButton/CardButton.mdx +4 -0
- package/src/lib/Components/core/CardButton/CardButton.stories.tsx +1 -0
- package/src/lib/Components/core/CardButton/CardButton.tsx +2 -0
- package/src/lib/Components/core/Link/Link.figma.tsx +1 -0
- package/src/lib/Components/core/Link/Link.mdx +3 -2
- package/src/lib/Components/core/Link/Link.stories.tsx +3 -2
- package/src/lib/Components/core/Link/Link.test.tsx +2 -0
- package/src/lib/Components/core/Link/Link.tsx +3 -1
- package/src/lib/Components/core/Link/types.ts +1 -1
- package/src/lib/Components/core/MenuList/MenuList.mdx +14 -1
- package/src/lib/Components/core/MenuList/MenuList.stories.tsx +30 -2
- package/src/lib/Components/core/MenuList/MenuList.test.tsx +72 -2
- package/src/lib/Components/core/MenuList/MenuList.tsx +94 -11
- package/src/lib/Components/core/MenuList/types.ts +29 -7
- package/src/lib/Components/core/SegmentedControl/SegmentedControl.tsx +1 -1
- package/src/lib/Components/core/Stepper/Stepper.mdx +37 -16
- package/src/lib/Components/core/Stepper/Stepper.stories.tsx +50 -2
- package/src/lib/Components/core/Stepper/Stepper.test.tsx +29 -1
- package/src/lib/Components/core/Stepper/Stepper.tsx +73 -32
- package/src/lib/Components/core/Stepper/types.ts +12 -2
- package/src/lib/Components/core/Timeline/Timeline.figma.tsx +79 -0
- package/src/lib/Components/core/Timeline/Timeline.mdx +49 -0
- package/src/lib/Components/core/Timeline/Timeline.stories.tsx +250 -0
- package/src/lib/Components/core/Timeline/Timeline.test.tsx +275 -0
- package/src/lib/Components/core/Timeline/Timeline.tsx +576 -0
- package/src/lib/Components/core/Timeline/index.ts +2 -0
- package/src/lib/Components/core/Timeline/types.ts +124 -0
- package/src/lib/Components/core/Toast/Toast.figma.tsx +36 -0
- package/src/lib/Components/core/Toast/Toast.mdx +203 -0
- package/src/lib/Components/core/Toast/Toast.stories.tsx +260 -0
- package/src/lib/Components/core/Toast/Toast.test.tsx +181 -0
- package/src/lib/Components/core/Toast/Toast.tsx +163 -0
- package/src/lib/Components/core/Toast/Toaster.test.tsx +687 -0
- package/src/lib/Components/core/Toast/Toaster.tsx +157 -0
- package/src/lib/Components/core/Toast/hooks/useToastAccessibility.ts +82 -0
- package/src/lib/Components/core/Toast/hooks/useToastCollapse.ts +38 -0
- package/src/lib/Components/core/Toast/hooks/useToastGesture.ts +83 -0
- package/src/lib/Components/core/Toast/hooks/useToastMotion.ts +71 -0
- package/src/lib/Components/core/Toast/hooks/useToastViewportStyles.ts +45 -0
- package/src/lib/Components/core/Toast/index.ts +4 -0
- package/src/lib/Components/core/Toast/types.ts +94 -0
- package/src/lib/Components/core/index.ts +2 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { useStyleSheet } from '../../../../styles';
|
|
4
|
+
import { Box } from '../../primitives';
|
|
5
|
+
import {
|
|
6
|
+
CheckmarkCircleFill,
|
|
7
|
+
DeleteCircleFill,
|
|
8
|
+
WarningFill,
|
|
9
|
+
} from '../../symbols';
|
|
10
|
+
import type { IconProps } from '../../symbols/Icon';
|
|
11
|
+
import { Button } from '../Button';
|
|
12
|
+
import { Spinner } from '../Spinner';
|
|
13
|
+
import type { ToastAppearance, ToastProps } from './types';
|
|
14
|
+
|
|
15
|
+
type NonInfoAppearance = Exclude<ToastAppearance, 'info'>;
|
|
16
|
+
|
|
17
|
+
const TITLE_MAX_LINES = 5;
|
|
18
|
+
|
|
19
|
+
const iconsMap: Record<NonInfoAppearance, ComponentType<IconProps>> = {
|
|
20
|
+
success: CheckmarkCircleFill,
|
|
21
|
+
warning: WarningFill,
|
|
22
|
+
error: DeleteCircleFill,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const iconColorMap: Record<
|
|
26
|
+
NonInfoAppearance,
|
|
27
|
+
'successOnInteractive' | 'warningOnInteractive' | 'errorOnInteractive'
|
|
28
|
+
> = {
|
|
29
|
+
success: 'successOnInteractive',
|
|
30
|
+
warning: 'warningOnInteractive',
|
|
31
|
+
error: 'errorOnInteractive',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const useToastStyles = ({
|
|
35
|
+
hasLeading,
|
|
36
|
+
hasAction,
|
|
37
|
+
}: {
|
|
38
|
+
hasLeading: boolean;
|
|
39
|
+
hasAction: boolean;
|
|
40
|
+
}) =>
|
|
41
|
+
useStyleSheet(
|
|
42
|
+
(t) => ({
|
|
43
|
+
root: {
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
alignItems: 'flex-start',
|
|
46
|
+
gap: t.spacings.s8,
|
|
47
|
+
minHeight: t.sizes.s56,
|
|
48
|
+
width: '100%',
|
|
49
|
+
borderRadius: t.borderRadius.md,
|
|
50
|
+
backgroundColor: t.colors.bg.interactive,
|
|
51
|
+
paddingVertical: t.spacings.s8,
|
|
52
|
+
paddingRight: t.spacings.s20,
|
|
53
|
+
paddingLeft: hasLeading ? t.spacings.s12 : t.spacings.s16,
|
|
54
|
+
},
|
|
55
|
+
iconWrapper: {
|
|
56
|
+
flexShrink: 0,
|
|
57
|
+
paddingTop: t.spacings.s10,
|
|
58
|
+
},
|
|
59
|
+
textAction: {
|
|
60
|
+
flexDirection: 'row',
|
|
61
|
+
flexWrap: 'wrap',
|
|
62
|
+
alignItems: 'flex-start',
|
|
63
|
+
columnGap: t.spacings.s8,
|
|
64
|
+
rowGap: t.spacings.s4,
|
|
65
|
+
flexGrow: 1,
|
|
66
|
+
flexShrink: 1,
|
|
67
|
+
flexBasis: 'auto',
|
|
68
|
+
},
|
|
69
|
+
title: StyleSheet.flatten([
|
|
70
|
+
t.typographies.body2,
|
|
71
|
+
{
|
|
72
|
+
color: t.colors.text.onInteractive,
|
|
73
|
+
flexShrink: 0,
|
|
74
|
+
flexGrow: 1,
|
|
75
|
+
flexBasis: 'auto',
|
|
76
|
+
paddingTop: t.spacings.s10,
|
|
77
|
+
paddingBottom: hasAction ? undefined : t.spacings.s10,
|
|
78
|
+
paddingRight: t.spacings.s16,
|
|
79
|
+
},
|
|
80
|
+
]),
|
|
81
|
+
actionButton: {
|
|
82
|
+
marginLeft: hasLeading ? -t.spacings.s16 : undefined,
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
[hasLeading, hasAction],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A single toast item: an inverted surface with a status icon or spinner, a
|
|
90
|
+
* title that wraps up to five lines, and an optional action inline beside
|
|
91
|
+
* the title. When the two cannot share a row, the action wraps onto its own
|
|
92
|
+
* row, under the title's left edge. Dismissal is a swipe gesture, owned by
|
|
93
|
+
* `Toaster` — this component never dismisses itself.
|
|
94
|
+
*
|
|
95
|
+
* This is the presentational piece. For the queue, timing and imperative API,
|
|
96
|
+
* use `Toaster` + `toast`.
|
|
97
|
+
*
|
|
98
|
+
* @see {@link https://ldls-react-native.vercel.app/?path=/docs/rnative-toast--docs Guidelines}
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* import { Toast } from '@ledgerhq/lumen-ui-rnative';
|
|
102
|
+
*
|
|
103
|
+
* <Toast appearance="success" title="Payment done" />
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Loading with an action
|
|
107
|
+
* <Toast loading title="Uploading…" action={{ label: 'Cancel', onAction: () => {} }} />
|
|
108
|
+
*/
|
|
109
|
+
export const Toast = ({
|
|
110
|
+
appearance = 'info',
|
|
111
|
+
loading = false,
|
|
112
|
+
title,
|
|
113
|
+
action,
|
|
114
|
+
style,
|
|
115
|
+
...props
|
|
116
|
+
}: ToastProps) => {
|
|
117
|
+
const hasLeading = loading || appearance !== 'info';
|
|
118
|
+
const styles = useToastStyles({ hasLeading, hasAction: Boolean(action) });
|
|
119
|
+
const IconComponent = appearance === 'info' ? null : iconsMap[appearance];
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Box
|
|
123
|
+
style={StyleSheet.flatten([styles.root, style])}
|
|
124
|
+
accessibilityLiveRegion={
|
|
125
|
+
appearance === 'warning' || appearance === 'error'
|
|
126
|
+
? 'assertive'
|
|
127
|
+
: 'polite'
|
|
128
|
+
}
|
|
129
|
+
{...props}
|
|
130
|
+
>
|
|
131
|
+
{loading ? (
|
|
132
|
+
<View style={styles.iconWrapper}>
|
|
133
|
+
<Spinner testID='toast-spinner' size={20} color='onInteractive' />
|
|
134
|
+
</View>
|
|
135
|
+
) : (
|
|
136
|
+
IconComponent && (
|
|
137
|
+
<View testID='toast-icon' style={styles.iconWrapper}>
|
|
138
|
+
<IconComponent
|
|
139
|
+
size={20}
|
|
140
|
+
lx={{ color: iconColorMap[appearance as NonInfoAppearance] }}
|
|
141
|
+
/>
|
|
142
|
+
</View>
|
|
143
|
+
)
|
|
144
|
+
)}
|
|
145
|
+
<View testID='toast-text-action' style={styles.textAction}>
|
|
146
|
+
<Text style={styles.title} numberOfLines={TITLE_MAX_LINES}>
|
|
147
|
+
{title}
|
|
148
|
+
</Text>
|
|
149
|
+
{action && (
|
|
150
|
+
<Button
|
|
151
|
+
testID='toast-action'
|
|
152
|
+
appearance='base'
|
|
153
|
+
size='sm'
|
|
154
|
+
onPress={action.onAction}
|
|
155
|
+
style={styles.actionButton}
|
|
156
|
+
>
|
|
157
|
+
{action.label}
|
|
158
|
+
</Button>
|
|
159
|
+
)}
|
|
160
|
+
</View>
|
|
161
|
+
</Box>
|
|
162
|
+
);
|
|
163
|
+
};
|