@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.
Files changed (165) hide show
  1. package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js +19 -11
  2. package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.js.map +1 -1
  3. package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.test.js +113 -4
  4. package/dist/module/lib/Components/core/AmountDisplay/AmountDisplay.test.js.map +1 -1
  5. package/dist/module/lib/Components/core/BottomSheet/BottomSheet.stories.js +51 -0
  6. package/dist/module/lib/Components/core/BottomSheet/BottomSheet.stories.js.map +1 -1
  7. package/dist/module/lib/Components/core/CardButton/CardButton.js +2 -0
  8. package/dist/module/lib/Components/core/CardButton/CardButton.js.map +1 -1
  9. package/dist/module/lib/Components/core/CardButton/CardButton.mdx +4 -0
  10. package/dist/module/lib/Components/core/CardButton/CardButton.stories.js +1 -0
  11. package/dist/module/lib/Components/core/CardButton/CardButton.stories.js.map +1 -1
  12. package/dist/module/lib/Components/core/Link/Link.figma.js +2 -1
  13. package/dist/module/lib/Components/core/Link/Link.figma.js.map +1 -1
  14. package/dist/module/lib/Components/core/Link/Link.js +5 -3
  15. package/dist/module/lib/Components/core/Link/Link.js.map +1 -1
  16. package/dist/module/lib/Components/core/Link/Link.mdx +3 -2
  17. package/dist/module/lib/Components/core/Link/Link.stories.js +4 -1
  18. package/dist/module/lib/Components/core/Link/Link.stories.js.map +1 -1
  19. package/dist/module/lib/Components/core/Link/Link.test.js +2 -2
  20. package/dist/module/lib/Components/core/Link/Link.test.js.map +1 -1
  21. package/dist/module/lib/Components/core/MenuList/MenuList.js +93 -7
  22. package/dist/module/lib/Components/core/MenuList/MenuList.js.map +1 -1
  23. package/dist/module/lib/Components/core/MenuList/MenuList.mdx +14 -1
  24. package/dist/module/lib/Components/core/MenuList/MenuList.stories.js +39 -2
  25. package/dist/module/lib/Components/core/MenuList/MenuList.stories.js.map +1 -1
  26. package/dist/module/lib/Components/core/MenuList/MenuList.test.js +60 -2
  27. package/dist/module/lib/Components/core/MenuList/MenuList.test.js.map +1 -1
  28. package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.js +1 -1
  29. package/dist/module/lib/Components/core/SegmentedControl/SegmentedControl.js.map +1 -1
  30. package/dist/module/lib/Components/core/Stepper/Stepper.js +76 -30
  31. package/dist/module/lib/Components/core/Stepper/Stepper.js.map +1 -1
  32. package/dist/module/lib/Components/core/Stepper/Stepper.mdx +37 -16
  33. package/dist/module/lib/Components/core/Stepper/Stepper.stories.js +102 -2
  34. package/dist/module/lib/Components/core/Stepper/Stepper.stories.js.map +1 -1
  35. package/dist/module/lib/Components/core/Stepper/Stepper.test.js +32 -1
  36. package/dist/module/lib/Components/core/Stepper/Stepper.test.js.map +1 -1
  37. package/dist/module/lib/Components/core/Timeline/Timeline.figma.js +83 -0
  38. package/dist/module/lib/Components/core/Timeline/Timeline.figma.js.map +1 -0
  39. package/dist/module/lib/Components/core/Timeline/Timeline.js +464 -0
  40. package/dist/module/lib/Components/core/Timeline/Timeline.js.map +1 -0
  41. package/dist/module/lib/Components/core/Timeline/Timeline.mdx +49 -0
  42. package/dist/module/lib/Components/core/Timeline/Timeline.stories.js +289 -0
  43. package/dist/module/lib/Components/core/Timeline/Timeline.stories.js.map +1 -0
  44. package/dist/module/lib/Components/core/Timeline/Timeline.test.js +234 -0
  45. package/dist/module/lib/Components/core/Timeline/Timeline.test.js.map +1 -0
  46. package/dist/module/lib/Components/core/Timeline/index.js +5 -0
  47. package/dist/module/lib/Components/core/Timeline/index.js.map +1 -0
  48. package/dist/module/lib/Components/core/Timeline/types.js +4 -0
  49. package/dist/module/lib/Components/core/Timeline/types.js.map +1 -0
  50. package/dist/module/lib/Components/core/Toast/Toast.figma.js +39 -0
  51. package/dist/module/lib/Components/core/Toast/Toast.figma.js.map +1 -0
  52. package/dist/module/lib/Components/core/Toast/Toast.js +138 -0
  53. package/dist/module/lib/Components/core/Toast/Toast.js.map +1 -0
  54. package/dist/module/lib/Components/core/Toast/Toast.mdx +203 -0
  55. package/dist/module/lib/Components/core/Toast/Toast.stories.js +238 -0
  56. package/dist/module/lib/Components/core/Toast/Toast.stories.js.map +1 -0
  57. package/dist/module/lib/Components/core/Toast/Toast.test.js +203 -0
  58. package/dist/module/lib/Components/core/Toast/Toast.test.js.map +1 -0
  59. package/dist/module/lib/Components/core/Toast/Toaster.js +147 -0
  60. package/dist/module/lib/Components/core/Toast/Toaster.js.map +1 -0
  61. package/dist/module/lib/Components/core/Toast/Toaster.test.js +732 -0
  62. package/dist/module/lib/Components/core/Toast/Toaster.test.js.map +1 -0
  63. package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js +70 -0
  64. package/dist/module/lib/Components/core/Toast/hooks/useToastAccessibility.js.map +1 -0
  65. package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js +33 -0
  66. package/dist/module/lib/Components/core/Toast/hooks/useToastCollapse.js.map +1 -0
  67. package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js +224 -0
  68. package/dist/module/lib/Components/core/Toast/hooks/useToastGesture.js.map +1 -0
  69. package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js +82 -0
  70. package/dist/module/lib/Components/core/Toast/hooks/useToastMotion.js.map +1 -0
  71. package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js +21 -0
  72. package/dist/module/lib/Components/core/Toast/hooks/useToastViewportStyles.js.map +1 -0
  73. package/dist/module/lib/Components/core/Toast/index.js +7 -0
  74. package/dist/module/lib/Components/core/Toast/index.js.map +1 -0
  75. package/dist/module/lib/Components/core/Toast/types.js +4 -0
  76. package/dist/module/lib/Components/core/Toast/types.js.map +1 -0
  77. package/dist/module/lib/Components/core/index.js +2 -0
  78. package/dist/module/lib/Components/core/index.js.map +1 -1
  79. package/dist/typescript/src/lib/Components/core/AmountDisplay/AmountDisplay.d.ts.map +1 -1
  80. package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts +2 -0
  81. package/dist/typescript/src/lib/Components/core/CardButton/CardButton.d.ts.map +1 -1
  82. package/dist/typescript/src/lib/Components/core/Link/Link.d.ts +1 -1
  83. package/dist/typescript/src/lib/Components/core/Link/Link.d.ts.map +1 -1
  84. package/dist/typescript/src/lib/Components/core/Link/types.d.ts +1 -1
  85. package/dist/typescript/src/lib/Components/core/Link/types.d.ts.map +1 -1
  86. package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts +12 -2
  87. package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts.map +1 -1
  88. package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts +26 -7
  89. package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts.map +1 -1
  90. package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts +4 -3
  91. package/dist/typescript/src/lib/Components/core/Stepper/Stepper.d.ts.map +1 -1
  92. package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts +12 -2
  93. package/dist/typescript/src/lib/Components/core/Stepper/types.d.ts.map +1 -1
  94. package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts +56 -0
  95. package/dist/typescript/src/lib/Components/core/Timeline/Timeline.d.ts.map +1 -0
  96. package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts +3 -0
  97. package/dist/typescript/src/lib/Components/core/Timeline/index.d.ts.map +1 -0
  98. package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts +109 -0
  99. package/dist/typescript/src/lib/Components/core/Timeline/types.d.ts.map +1 -0
  100. package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts +24 -0
  101. package/dist/typescript/src/lib/Components/core/Toast/Toast.d.ts.map +1 -0
  102. package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts +35 -0
  103. package/dist/typescript/src/lib/Components/core/Toast/Toaster.d.ts.map +1 -0
  104. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts +17 -0
  105. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastAccessibility.d.ts.map +1 -0
  106. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts +19 -0
  107. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastCollapse.d.ts.map +1 -0
  108. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts +14 -0
  109. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastGesture.d.ts.map +1 -0
  110. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts +15 -0
  111. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastMotion.d.ts.map +1 -0
  112. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts +21 -0
  113. package/dist/typescript/src/lib/Components/core/Toast/hooks/useToastViewportStyles.d.ts.map +1 -0
  114. package/dist/typescript/src/lib/Components/core/Toast/index.d.ts +5 -0
  115. package/dist/typescript/src/lib/Components/core/Toast/index.d.ts.map +1 -0
  116. package/dist/typescript/src/lib/Components/core/Toast/types.d.ts +75 -0
  117. package/dist/typescript/src/lib/Components/core/Toast/types.d.ts.map +1 -0
  118. package/dist/typescript/src/lib/Components/core/index.d.ts +2 -0
  119. package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
  120. package/package.json +3 -3
  121. package/src/lib/Components/core/AmountDisplay/AmountDisplay.test.tsx +138 -4
  122. package/src/lib/Components/core/AmountDisplay/AmountDisplay.tsx +13 -6
  123. package/src/lib/Components/core/BottomSheet/BottomSheet.stories.tsx +51 -0
  124. package/src/lib/Components/core/CardButton/CardButton.mdx +4 -0
  125. package/src/lib/Components/core/CardButton/CardButton.stories.tsx +1 -0
  126. package/src/lib/Components/core/CardButton/CardButton.tsx +2 -0
  127. package/src/lib/Components/core/Link/Link.figma.tsx +1 -0
  128. package/src/lib/Components/core/Link/Link.mdx +3 -2
  129. package/src/lib/Components/core/Link/Link.stories.tsx +3 -2
  130. package/src/lib/Components/core/Link/Link.test.tsx +2 -0
  131. package/src/lib/Components/core/Link/Link.tsx +3 -1
  132. package/src/lib/Components/core/Link/types.ts +1 -1
  133. package/src/lib/Components/core/MenuList/MenuList.mdx +14 -1
  134. package/src/lib/Components/core/MenuList/MenuList.stories.tsx +30 -2
  135. package/src/lib/Components/core/MenuList/MenuList.test.tsx +72 -2
  136. package/src/lib/Components/core/MenuList/MenuList.tsx +94 -11
  137. package/src/lib/Components/core/MenuList/types.ts +29 -7
  138. package/src/lib/Components/core/SegmentedControl/SegmentedControl.tsx +1 -1
  139. package/src/lib/Components/core/Stepper/Stepper.mdx +37 -16
  140. package/src/lib/Components/core/Stepper/Stepper.stories.tsx +50 -2
  141. package/src/lib/Components/core/Stepper/Stepper.test.tsx +29 -1
  142. package/src/lib/Components/core/Stepper/Stepper.tsx +73 -32
  143. package/src/lib/Components/core/Stepper/types.ts +12 -2
  144. package/src/lib/Components/core/Timeline/Timeline.figma.tsx +79 -0
  145. package/src/lib/Components/core/Timeline/Timeline.mdx +49 -0
  146. package/src/lib/Components/core/Timeline/Timeline.stories.tsx +250 -0
  147. package/src/lib/Components/core/Timeline/Timeline.test.tsx +275 -0
  148. package/src/lib/Components/core/Timeline/Timeline.tsx +576 -0
  149. package/src/lib/Components/core/Timeline/index.ts +2 -0
  150. package/src/lib/Components/core/Timeline/types.ts +124 -0
  151. package/src/lib/Components/core/Toast/Toast.figma.tsx +36 -0
  152. package/src/lib/Components/core/Toast/Toast.mdx +203 -0
  153. package/src/lib/Components/core/Toast/Toast.stories.tsx +260 -0
  154. package/src/lib/Components/core/Toast/Toast.test.tsx +181 -0
  155. package/src/lib/Components/core/Toast/Toast.tsx +163 -0
  156. package/src/lib/Components/core/Toast/Toaster.test.tsx +687 -0
  157. package/src/lib/Components/core/Toast/Toaster.tsx +157 -0
  158. package/src/lib/Components/core/Toast/hooks/useToastAccessibility.ts +82 -0
  159. package/src/lib/Components/core/Toast/hooks/useToastCollapse.ts +38 -0
  160. package/src/lib/Components/core/Toast/hooks/useToastGesture.ts +83 -0
  161. package/src/lib/Components/core/Toast/hooks/useToastMotion.ts +71 -0
  162. package/src/lib/Components/core/Toast/hooks/useToastViewportStyles.ts +45 -0
  163. package/src/lib/Components/core/Toast/index.ts +4 -0
  164. package/src/lib/Components/core/Toast/types.ts +94 -0
  165. 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
+ };