@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
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
|
|
2
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import type { LumenTextStyle } from '../../../../styles';
|
|
4
4
|
import { useStyleSheet } from '../../../../styles';
|
|
5
|
+
import { useControllableState } from '../../../utils';
|
|
5
6
|
import { Box, Pressable, Text } from '../../primitives';
|
|
7
|
+
import { Switch } from '../Switch';
|
|
6
8
|
import type {
|
|
7
9
|
MenuListItemAppearance,
|
|
8
10
|
MenuListItemProps,
|
|
9
11
|
MenuListProps,
|
|
12
|
+
MenuListSwitchItemProps,
|
|
10
13
|
} from './types';
|
|
11
14
|
|
|
12
15
|
const resolveContentColor = (
|
|
@@ -70,16 +73,8 @@ const useItemStyles = ({
|
|
|
70
73
|
* <MenuListItem icon={Trash} label="Remove" appearance="red" onPress={handleRemove} />
|
|
71
74
|
* </MenuList>
|
|
72
75
|
*/
|
|
73
|
-
export const MenuList = ({
|
|
74
|
-
children
|
|
75
|
-
lx,
|
|
76
|
-
style,
|
|
77
|
-
ref,
|
|
78
|
-
...props
|
|
79
|
-
}: MenuListProps) => (
|
|
80
|
-
<Box lx={lx} style={style} ref={ref} {...props}>
|
|
81
|
-
{children}
|
|
82
|
-
</Box>
|
|
76
|
+
export const MenuList = ({ children, ...props }: MenuListProps) => (
|
|
77
|
+
<Box {...props}>{children}</Box>
|
|
83
78
|
);
|
|
84
79
|
|
|
85
80
|
/**
|
|
@@ -160,3 +155,91 @@ const MenuListItemInner = ({
|
|
|
160
155
|
</Box>
|
|
161
156
|
);
|
|
162
157
|
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A toggleable action inside a `MenuList`: a label, an optional leading icon
|
|
161
|
+
* and a trailing `Switch`. Pressing anywhere on the item toggles the switch.
|
|
162
|
+
*
|
|
163
|
+
* @see {@link https://ldls-react-native.vercel.app/?path=/docs/rnative-menulist--docs Storybook}
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* <MenuListSwitchItem label="Notifications" icon={Bell} defaultChecked />
|
|
167
|
+
*/
|
|
168
|
+
export const MenuListSwitchItem = ({
|
|
169
|
+
label,
|
|
170
|
+
icon: Icon,
|
|
171
|
+
disabled: disabledProp = false,
|
|
172
|
+
checked: checkedProp,
|
|
173
|
+
defaultChecked = false,
|
|
174
|
+
onCheckedChange: onCheckedChangeProp,
|
|
175
|
+
accessibilityState,
|
|
176
|
+
lx,
|
|
177
|
+
style,
|
|
178
|
+
ref,
|
|
179
|
+
...props
|
|
180
|
+
}: MenuListSwitchItemProps) => {
|
|
181
|
+
const disabled = useDisabledContext({
|
|
182
|
+
consumerName: 'MenuListSwitchItem',
|
|
183
|
+
mergeWith: { disabled: disabledProp },
|
|
184
|
+
});
|
|
185
|
+
const [checked, onCheckedChange] = useControllableState({
|
|
186
|
+
prop: checkedProp,
|
|
187
|
+
onChange: onCheckedChangeProp,
|
|
188
|
+
defaultProp: defaultChecked,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<Pressable
|
|
193
|
+
ref={ref}
|
|
194
|
+
lx={lx}
|
|
195
|
+
style={style}
|
|
196
|
+
onPress={() => onCheckedChange(!checked)}
|
|
197
|
+
disabled={disabled}
|
|
198
|
+
accessibilityRole='switch'
|
|
199
|
+
accessibilityState={{ ...accessibilityState, disabled, checked }}
|
|
200
|
+
{...props}
|
|
201
|
+
>
|
|
202
|
+
{({ pressed }) => (
|
|
203
|
+
<MenuListSwitchItemInner
|
|
204
|
+
label={label}
|
|
205
|
+
icon={Icon}
|
|
206
|
+
pressed={pressed}
|
|
207
|
+
disabled={disabled}
|
|
208
|
+
checked={!!checked}
|
|
209
|
+
/>
|
|
210
|
+
)}
|
|
211
|
+
</Pressable>
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const MenuListSwitchItemInner = ({
|
|
216
|
+
label,
|
|
217
|
+
icon: Icon,
|
|
218
|
+
pressed,
|
|
219
|
+
disabled,
|
|
220
|
+
checked,
|
|
221
|
+
}: {
|
|
222
|
+
label: string;
|
|
223
|
+
icon: MenuListSwitchItemProps['icon'];
|
|
224
|
+
pressed: boolean;
|
|
225
|
+
disabled: boolean;
|
|
226
|
+
checked: boolean;
|
|
227
|
+
}) => {
|
|
228
|
+
const styles = useItemStyles({ pressed, disabled, appearance: 'base' });
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<Box style={styles.container}>
|
|
232
|
+
{Icon && <Icon size={24} color={resolveContentColor(disabled, 'base')} />}
|
|
233
|
+
<Text style={styles.label} numberOfLines={1}>
|
|
234
|
+
{label}
|
|
235
|
+
</Text>
|
|
236
|
+
<View
|
|
237
|
+
pointerEvents='none'
|
|
238
|
+
accessibilityElementsHidden
|
|
239
|
+
importantForAccessibility='no-hide-descendants'
|
|
240
|
+
>
|
|
241
|
+
<Switch checked={checked} disabled={disabled} />
|
|
242
|
+
</View>
|
|
243
|
+
</Box>
|
|
244
|
+
);
|
|
245
|
+
};
|
|
@@ -20,7 +20,7 @@ export type MenuListProps = {
|
|
|
20
20
|
children: ReactNode;
|
|
21
21
|
} & Omit<StyledViewProps, 'children'>;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
type MenuListItemBaseProps = {
|
|
24
24
|
/**
|
|
25
25
|
* Text describing the action, truncated to a single line.
|
|
26
26
|
*/
|
|
@@ -29,6 +29,15 @@ export type MenuListItemProps = {
|
|
|
29
29
|
* Icon rendered before the label.
|
|
30
30
|
*/
|
|
31
31
|
icon?: IconComponent;
|
|
32
|
+
/**
|
|
33
|
+
* Prevents interaction and dims the content.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type MenuListItemProps = {
|
|
32
41
|
/**
|
|
33
42
|
* Visual treatment of the label and icon. Use `red` for irreversible or
|
|
34
43
|
* dangerous actions.
|
|
@@ -37,13 +46,26 @@ export type MenuListItemProps = {
|
|
|
37
46
|
*/
|
|
38
47
|
appearance?: MenuListItemAppearance;
|
|
39
48
|
/**
|
|
40
|
-
*
|
|
41
|
-
|
|
49
|
+
* Action to run when the item is pressed.
|
|
50
|
+
*/
|
|
51
|
+
onPress?: StyledPressableProps['onPress'];
|
|
52
|
+
} & MenuListItemBaseProps &
|
|
53
|
+
Omit<StyledPressableProps, 'children' | 'onPress'>;
|
|
54
|
+
|
|
55
|
+
export type MenuListSwitchItemProps = {
|
|
56
|
+
/**
|
|
57
|
+
* The controlled checked state of the switch.
|
|
42
58
|
* @default false
|
|
43
59
|
*/
|
|
44
|
-
|
|
60
|
+
checked?: boolean;
|
|
45
61
|
/**
|
|
46
|
-
*
|
|
62
|
+
* Sets the initial checked state for uncontrolled use.
|
|
63
|
+
* @default false
|
|
47
64
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
defaultChecked?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* The callback function called when the checked state changes.
|
|
68
|
+
*/
|
|
69
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
70
|
+
} & MenuListItemBaseProps &
|
|
71
|
+
Omit<StyledPressableProps, 'children' | 'onPress'>;
|
|
@@ -211,7 +211,7 @@ function useRootStyles({
|
|
|
211
211
|
...(tabLayout === 'fixed'
|
|
212
212
|
? { width: '100%' }
|
|
213
213
|
: { alignSelf: 'flex-start' }),
|
|
214
|
-
borderRadius: t.borderRadius.
|
|
214
|
+
borderRadius: t.borderRadius.sm,
|
|
215
215
|
backgroundColor:
|
|
216
216
|
appearance === 'background' ? t.colors.bg.surface : 'transparent',
|
|
217
217
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks';
|
|
1
|
+
import { Meta, Canvas, Controls, Source } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import { CustomTabs, Tab } from '../../../../../.storybook/components';
|
|
3
3
|
import * as StepperStories from './Stepper.stories';
|
|
4
4
|
import { Box } from '../../primitives/Box';
|
|
@@ -25,11 +25,12 @@ The Stepper component provides visual feedback for multi-step processes and work
|
|
|
25
25
|
## 🎯 Anatomy
|
|
26
26
|
|
|
27
27
|
The Stepper consists of:
|
|
28
|
-
|
|
29
|
-
- **
|
|
28
|
+
|
|
29
|
+
- **Track**: One muted segment per step, separated by gaps
|
|
30
|
+
- **Progress**: Completed steps filled with color, sweeping clockwise from the top
|
|
30
31
|
- **Label**: Centered text showing "current/total" steps (e.g., "2/4")
|
|
31
32
|
|
|
32
|
-
The
|
|
33
|
+
The gap between the first and last segments is centered at the top (12 o'clock). At 0 progress, no segment is filled.
|
|
33
34
|
|
|
34
35
|
---
|
|
35
36
|
|
|
@@ -37,22 +38,35 @@ The progress arc starts at the top (12 o'clock position) and fills clockwise. Wh
|
|
|
37
38
|
|
|
38
39
|
**Default label**: The default label is "currentStep/totalSteps" (e.g., "2/4").
|
|
39
40
|
|
|
40
|
-
|
|
41
41
|
### Step Ranges
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
- **`totalSteps`** must be between **2** and **8**
|
|
43
44
|
- **`currentStep`** must be between **0** and **`totalSteps`**
|
|
44
|
-
- Use `currentStep={0}` to show the initial state (minimal dot before starting)
|
|
45
45
|
|
|
46
|
-
> ⚠️ Using more than **
|
|
46
|
+
> ⚠️ Using more than **8** total steps or exceeding the valid range may cause the UI to break and text to be truncated inside the circular indicator.
|
|
47
47
|
|
|
48
48
|
> ⚠️ Values outside valid ranges are automatically clamped: **`currentStep`** is kept between **0** and **`totalSteps`**.
|
|
49
49
|
|
|
50
|
-
## 🎨
|
|
50
|
+
## 🎨 Appearance
|
|
51
51
|
|
|
52
|
-
The Stepper supports
|
|
52
|
+
The Stepper supports two appearances for the progress: `accent` (default) and `success`.
|
|
53
53
|
|
|
54
|
-
<Canvas of={StepperStories.
|
|
54
|
+
<Canvas of={StepperStories.AppearanceShowcase} />
|
|
55
|
+
|
|
56
|
+
## 📐 Sizes
|
|
57
|
+
|
|
58
|
+
The Stepper comes in two sizes:
|
|
59
|
+
|
|
60
|
+
- **`md`** (default): 48×48px
|
|
61
|
+
- **`lg`**: 72×72px
|
|
62
|
+
|
|
63
|
+
<Canvas of={StepperStories.SizeShowcase} />
|
|
64
|
+
|
|
65
|
+
## Disabled State
|
|
55
66
|
|
|
67
|
+
The Stepper supports a disabled state that changes the progress to a muted appearance:
|
|
68
|
+
|
|
69
|
+
<Canvas of={StepperStories.DisabledShowcase} />
|
|
56
70
|
|
|
57
71
|
## Custom Labels
|
|
58
72
|
|
|
@@ -60,7 +74,7 @@ By default, the stepper displays "currentStep/totalSteps" (e.g., "2/4"). You can
|
|
|
60
74
|
|
|
61
75
|
<Canvas of={StepperStories.WithCustomLabel} />
|
|
62
76
|
|
|
63
|
-
> ⚠️ **Note**: The label and step counts are automatically truncated if they overflow the circular indicator. Keep custom labels short to ensure readability within the
|
|
77
|
+
> ⚠️ **Note**: The label and step counts are automatically truncated if they overflow the circular indicator. Keep custom labels short to ensure readability within the circle.
|
|
64
78
|
|
|
65
79
|
---
|
|
66
80
|
|
|
@@ -102,6 +116,14 @@ function OnboardingFlow() {
|
|
|
102
116
|
}
|
|
103
117
|
```
|
|
104
118
|
|
|
119
|
+
### Appearance
|
|
120
|
+
|
|
121
|
+
<Source of={StepperStories.AppearanceShowcase} />
|
|
122
|
+
|
|
123
|
+
### Sizes
|
|
124
|
+
|
|
125
|
+
<Source of={StepperStories.SizeShowcase} />
|
|
126
|
+
|
|
105
127
|
### With Disabled State
|
|
106
128
|
|
|
107
129
|
Control the visual state based on step completion:
|
|
@@ -130,10 +152,10 @@ import { Stepper } from '@ledgerhq/lumen-ui-rnative';
|
|
|
130
152
|
function LocalizedStepper() {
|
|
131
153
|
const currentStep = 3;
|
|
132
154
|
const totalSteps = 5;
|
|
133
|
-
|
|
155
|
+
|
|
134
156
|
return (
|
|
135
|
-
<Stepper
|
|
136
|
-
currentStep={currentStep}
|
|
157
|
+
<Stepper
|
|
158
|
+
currentStep={currentStep}
|
|
137
159
|
totalSteps={totalSteps}
|
|
138
160
|
label={`Étape ${currentStep} sur ${totalSteps}`}
|
|
139
161
|
/>
|
|
@@ -141,6 +163,5 @@ function LocalizedStepper() {
|
|
|
141
163
|
}
|
|
142
164
|
```
|
|
143
165
|
|
|
144
|
-
|
|
145
166
|
</Tab>
|
|
146
167
|
</CustomTabs>
|
|
@@ -13,6 +13,8 @@ const meta = {
|
|
|
13
13
|
argTypes: {
|
|
14
14
|
currentStep: { control: 'number' },
|
|
15
15
|
totalSteps: { control: 'number' },
|
|
16
|
+
appearance: { control: 'select', options: ['accent', 'success'] },
|
|
17
|
+
size: { control: 'select', options: ['md', 'lg'] },
|
|
16
18
|
disabled: { control: 'boolean' },
|
|
17
19
|
},
|
|
18
20
|
} satisfies Meta<typeof Stepper>;
|
|
@@ -28,6 +30,52 @@ export const Base: Story = {
|
|
|
28
30
|
render: (args) => <Stepper {...args} />,
|
|
29
31
|
};
|
|
30
32
|
|
|
33
|
+
export const AppearanceShowcase: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
currentStep: 2,
|
|
36
|
+
totalSteps: 4,
|
|
37
|
+
},
|
|
38
|
+
render: () => (
|
|
39
|
+
<Box lx={{ flexDirection: 'row', gap: 's32', alignItems: 'center' }}>
|
|
40
|
+
<Box lx={{ alignItems: 'center', gap: 's8' }}>
|
|
41
|
+
<Text typography='body3' lx={{ color: 'muted' }}>
|
|
42
|
+
Accent
|
|
43
|
+
</Text>
|
|
44
|
+
<Stepper currentStep={2} totalSteps={4} appearance='accent' />
|
|
45
|
+
</Box>
|
|
46
|
+
<Box lx={{ alignItems: 'center', gap: 's8' }}>
|
|
47
|
+
<Text typography='body3' lx={{ color: 'muted' }}>
|
|
48
|
+
Success
|
|
49
|
+
</Text>
|
|
50
|
+
<Stepper currentStep={4} totalSteps={4} appearance='success' />
|
|
51
|
+
</Box>
|
|
52
|
+
</Box>
|
|
53
|
+
),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const SizeShowcase: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
currentStep: 2,
|
|
59
|
+
totalSteps: 4,
|
|
60
|
+
},
|
|
61
|
+
render: () => (
|
|
62
|
+
<Box lx={{ flexDirection: 'row', gap: 's32', alignItems: 'center' }}>
|
|
63
|
+
<Box lx={{ alignItems: 'center', gap: 's8' }}>
|
|
64
|
+
<Text typography='body3' lx={{ color: 'muted' }}>
|
|
65
|
+
Medium (md)
|
|
66
|
+
</Text>
|
|
67
|
+
<Stepper currentStep={2} totalSteps={4} size='md' />
|
|
68
|
+
</Box>
|
|
69
|
+
<Box lx={{ alignItems: 'center', gap: 's8' }}>
|
|
70
|
+
<Text typography='body3' lx={{ color: 'muted' }}>
|
|
71
|
+
Large (lg)
|
|
72
|
+
</Text>
|
|
73
|
+
<Stepper currentStep={2} totalSteps={4} size='lg' />
|
|
74
|
+
</Box>
|
|
75
|
+
</Box>
|
|
76
|
+
),
|
|
77
|
+
};
|
|
78
|
+
|
|
31
79
|
export const DisabledShowcase: Story = {
|
|
32
80
|
args: {
|
|
33
81
|
currentStep: 2,
|
|
@@ -49,9 +97,9 @@ export const DisabledShowcase: Story = {
|
|
|
49
97
|
</Box>
|
|
50
98
|
<Box lx={{ alignItems: 'center', gap: 's8' }}>
|
|
51
99
|
<Text typography='body3' lx={{ color: 'muted' }}>
|
|
52
|
-
Unstarted (0/
|
|
100
|
+
Unstarted (0/8)
|
|
53
101
|
</Text>
|
|
54
|
-
<Stepper currentStep={0} totalSteps={
|
|
102
|
+
<Stepper currentStep={0} totalSteps={8} />
|
|
55
103
|
</Box>
|
|
56
104
|
</Box>
|
|
57
105
|
),
|
|
@@ -80,7 +80,7 @@ describe('Stepper Component', () => {
|
|
|
80
80
|
expect(stepper).toBeTruthy();
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
it('should handle currentStep <= 0
|
|
83
|
+
it('should handle currentStep <= 0', async () => {
|
|
84
84
|
const { findByLabelText } = render(
|
|
85
85
|
<TestWrapper>
|
|
86
86
|
<Stepper currentStep={0} totalSteps={4} />
|
|
@@ -110,6 +110,34 @@ describe('Stepper Component', () => {
|
|
|
110
110
|
expect(getByText('/4')).toBeTruthy();
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
+
it('should render md size by default', () => {
|
|
114
|
+
const { getByTestId } = render(
|
|
115
|
+
<TestWrapper>
|
|
116
|
+
<Stepper currentStep={2} totalSteps={4} testID='stepper' />
|
|
117
|
+
</TestWrapper>,
|
|
118
|
+
);
|
|
119
|
+
const style = getByTestId('stepper').props.style;
|
|
120
|
+
const flatStyle = Array.isArray(style)
|
|
121
|
+
? Object.assign({}, ...style)
|
|
122
|
+
: style;
|
|
123
|
+
expect(flatStyle.width).toBe(48);
|
|
124
|
+
expect(flatStyle.height).toBe(48);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should render lg size', () => {
|
|
128
|
+
const { getByTestId } = render(
|
|
129
|
+
<TestWrapper>
|
|
130
|
+
<Stepper currentStep={2} totalSteps={4} size='lg' testID='stepper' />
|
|
131
|
+
</TestWrapper>,
|
|
132
|
+
);
|
|
133
|
+
const style = getByTestId('stepper').props.style;
|
|
134
|
+
const flatStyle = Array.isArray(style)
|
|
135
|
+
? Object.assign({}, ...style)
|
|
136
|
+
: style;
|
|
137
|
+
expect(flatStyle.width).toBe(72);
|
|
138
|
+
expect(flatStyle.height).toBe(72);
|
|
139
|
+
});
|
|
140
|
+
|
|
113
141
|
it('should apply custom lx props', () => {
|
|
114
142
|
const { getByTestId } = render(
|
|
115
143
|
<TestWrapper>
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
getStepperCalculations,
|
|
3
3
|
useDisabledContext,
|
|
4
4
|
} from '@ledgerhq/lumen-utils-shared';
|
|
5
|
-
import { useEffect } from 'react';
|
|
5
|
+
import { useEffect, useId } from 'react';
|
|
6
6
|
import Animated, {
|
|
7
7
|
cancelAnimation,
|
|
8
8
|
useAnimatedProps,
|
|
9
9
|
useSharedValue,
|
|
10
10
|
withTiming,
|
|
11
11
|
} from 'react-native-reanimated';
|
|
12
|
-
import Svg, { Circle } from 'react-native-svg';
|
|
12
|
+
import Svg, { Circle, Defs, Mask } from 'react-native-svg';
|
|
13
13
|
import { useCommonTranslation } from '../../../../i18n';
|
|
14
14
|
import { useTheme } from '../../../../styles';
|
|
15
15
|
import { useTimingConfig } from '../../animations/useTimingConfig';
|
|
@@ -17,8 +17,10 @@ import { Box } from '../../primitives/Box';
|
|
|
17
17
|
import { Text } from '../../primitives/Text';
|
|
18
18
|
import type { StepperProps } from './types';
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const SIZES = {
|
|
21
|
+
md: { px: 48, strokeWidth: 4, token: 's48', typography: 'body2' },
|
|
22
|
+
lg: { px: 72, strokeWidth: 6, token: 's72', typography: 'heading4' },
|
|
23
|
+
} as const;
|
|
22
24
|
|
|
23
25
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
24
26
|
|
|
@@ -50,16 +52,19 @@ const useAnimatedProgress = ({
|
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
54
|
* A circular stepper component showing progress as current step out of total steps.
|
|
53
|
-
* Renders a track
|
|
55
|
+
* Renders a segmented track with progress and a center label.
|
|
54
56
|
*
|
|
55
57
|
* @see [Figma – Stepper](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=11977-94&m=dev)
|
|
56
58
|
*
|
|
57
59
|
* @example
|
|
58
60
|
* <Stepper currentStep={1} totalSteps={4} />
|
|
59
|
-
* <Stepper currentStep={0} totalSteps={
|
|
61
|
+
* <Stepper currentStep={0} totalSteps={8} disabled /> // Empty progress, disabled style
|
|
62
|
+
* <Stepper currentStep={2} totalSteps={4} size="lg" />
|
|
60
63
|
*/
|
|
61
64
|
export const Stepper = ({
|
|
62
65
|
lx = {},
|
|
66
|
+
appearance = 'accent',
|
|
67
|
+
size = 'md',
|
|
63
68
|
currentStep,
|
|
64
69
|
totalSteps,
|
|
65
70
|
disabled: disabledProp = false,
|
|
@@ -71,25 +76,42 @@ export const Stepper = ({
|
|
|
71
76
|
consumerName: 'Stepper',
|
|
72
77
|
mergeWith: { disabled: disabledProp },
|
|
73
78
|
});
|
|
79
|
+
const maskId = useId();
|
|
74
80
|
const { t } = useCommonTranslation();
|
|
75
81
|
const { theme } = useTheme();
|
|
82
|
+
const {
|
|
83
|
+
px: diameter,
|
|
84
|
+
strokeWidth,
|
|
85
|
+
token: sizeToken,
|
|
86
|
+
typography,
|
|
87
|
+
} = SIZES[size];
|
|
76
88
|
|
|
77
89
|
const {
|
|
78
90
|
displayLabel,
|
|
79
91
|
r,
|
|
80
92
|
cx,
|
|
81
93
|
cy,
|
|
82
|
-
trackDashArray,
|
|
83
94
|
progressDashArray,
|
|
95
|
+
progressMaskDashArray,
|
|
84
96
|
progressDashOffset,
|
|
97
|
+
dashPatternOffset,
|
|
85
98
|
} = getStepperCalculations({
|
|
86
99
|
currentStep,
|
|
87
100
|
totalSteps,
|
|
88
|
-
size:
|
|
101
|
+
size: diameter,
|
|
89
102
|
label,
|
|
90
|
-
strokeWidth
|
|
103
|
+
strokeWidth,
|
|
91
104
|
});
|
|
92
105
|
|
|
106
|
+
const activeColor =
|
|
107
|
+
appearance === 'success'
|
|
108
|
+
? theme.colors.border.success
|
|
109
|
+
: theme.colors.border.active;
|
|
110
|
+
|
|
111
|
+
const progressColor = disabled
|
|
112
|
+
? theme.colors.border.mutedSubtleHover
|
|
113
|
+
: activeColor;
|
|
114
|
+
|
|
93
115
|
const animatedProgress = useAnimatedProgress({
|
|
94
116
|
progressDashOffset,
|
|
95
117
|
});
|
|
@@ -112,8 +134,8 @@ export const Stepper = ({
|
|
|
112
134
|
})
|
|
113
135
|
}
|
|
114
136
|
lx={{
|
|
115
|
-
width:
|
|
116
|
-
height:
|
|
137
|
+
width: sizeToken,
|
|
138
|
+
height: sizeToken,
|
|
117
139
|
flexShrink: 0,
|
|
118
140
|
alignItems: 'center',
|
|
119
141
|
justifyContent: 'center',
|
|
@@ -123,10 +145,10 @@ export const Stepper = ({
|
|
|
123
145
|
{...props}
|
|
124
146
|
>
|
|
125
147
|
<Svg
|
|
126
|
-
width={
|
|
127
|
-
height={
|
|
128
|
-
viewBox={`0 0 ${
|
|
129
|
-
style={{ transform: [{ rotate: '
|
|
148
|
+
width={diameter}
|
|
149
|
+
height={diameter}
|
|
150
|
+
viewBox={`0 0 ${diameter} ${diameter}`}
|
|
151
|
+
style={{ transform: [{ rotate: '-90deg' }] }}
|
|
130
152
|
>
|
|
131
153
|
<Circle
|
|
132
154
|
cx={cx}
|
|
@@ -135,24 +157,42 @@ export const Stepper = ({
|
|
|
135
157
|
fill='none'
|
|
136
158
|
stroke={theme.colors.border.mutedSubtle}
|
|
137
159
|
strokeLinecap='round'
|
|
138
|
-
strokeWidth={
|
|
139
|
-
strokeDasharray={
|
|
140
|
-
strokeDashoffset={
|
|
160
|
+
strokeWidth={strokeWidth}
|
|
161
|
+
strokeDasharray={progressDashArray}
|
|
162
|
+
strokeDashoffset={dashPatternOffset}
|
|
141
163
|
/>
|
|
142
|
-
<
|
|
164
|
+
<Defs>
|
|
165
|
+
<Mask
|
|
166
|
+
id={maskId}
|
|
167
|
+
maskUnits='userSpaceOnUse'
|
|
168
|
+
x={0}
|
|
169
|
+
y={0}
|
|
170
|
+
width={diameter}
|
|
171
|
+
height={diameter}
|
|
172
|
+
>
|
|
173
|
+
<AnimatedCircle
|
|
174
|
+
cx={cx}
|
|
175
|
+
cy={cy}
|
|
176
|
+
r={r}
|
|
177
|
+
fill='none'
|
|
178
|
+
stroke='white'
|
|
179
|
+
strokeWidth={strokeWidth}
|
|
180
|
+
strokeDasharray={progressMaskDashArray}
|
|
181
|
+
animatedProps={animatedProgress}
|
|
182
|
+
/>
|
|
183
|
+
</Mask>
|
|
184
|
+
</Defs>
|
|
185
|
+
<Circle
|
|
143
186
|
cx={cx}
|
|
144
187
|
cy={cy}
|
|
145
188
|
r={r}
|
|
146
189
|
fill='none'
|
|
147
|
-
stroke={
|
|
148
|
-
disabled
|
|
149
|
-
? theme.colors.border.mutedSubtleHover
|
|
150
|
-
: theme.colors.border.active
|
|
151
|
-
}
|
|
190
|
+
stroke={progressColor}
|
|
152
191
|
strokeLinecap='round'
|
|
153
|
-
strokeWidth={
|
|
192
|
+
strokeWidth={strokeWidth}
|
|
154
193
|
strokeDasharray={progressDashArray}
|
|
155
|
-
|
|
194
|
+
strokeDashoffset={dashPatternOffset}
|
|
195
|
+
mask={`url(#${maskId})`}
|
|
156
196
|
/>
|
|
157
197
|
</Svg>
|
|
158
198
|
<Box
|
|
@@ -169,24 +209,25 @@ export const Stepper = ({
|
|
|
169
209
|
>
|
|
170
210
|
{label ? (
|
|
171
211
|
<Text
|
|
172
|
-
typography=
|
|
173
|
-
lx={{ color: 'base' }}
|
|
212
|
+
typography={typography}
|
|
213
|
+
lx={{ color: disabled ? 'disabled' : 'base' }}
|
|
174
214
|
maxFontSizeMultiplier={1.4}
|
|
215
|
+
numberOfLines={1}
|
|
175
216
|
>
|
|
176
217
|
{label}
|
|
177
218
|
</Text>
|
|
178
219
|
) : (
|
|
179
220
|
<>
|
|
180
221
|
<Text
|
|
181
|
-
typography=
|
|
182
|
-
lx={{ color: 'base' }}
|
|
222
|
+
typography={typography}
|
|
223
|
+
lx={{ color: disabled ? 'disabled' : 'base' }}
|
|
183
224
|
maxFontSizeMultiplier={1.4}
|
|
184
225
|
>
|
|
185
226
|
{Math.min(Math.max(currentStep, 0), totalSteps)}
|
|
186
227
|
</Text>
|
|
187
228
|
<Text
|
|
188
|
-
typography=
|
|
189
|
-
lx={{ color: 'muted' }}
|
|
229
|
+
typography={typography}
|
|
230
|
+
lx={{ color: disabled ? 'disabled' : 'muted' }}
|
|
190
231
|
maxFontSizeMultiplier={1.4}
|
|
191
232
|
>
|
|
192
233
|
/{totalSteps}
|
|
@@ -2,7 +2,17 @@ import type { StyledViewProps } from '../../../../styles';
|
|
|
2
2
|
|
|
3
3
|
export type StepperProps = {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* The visual style of the stepper's segments.
|
|
6
|
+
* @default accent
|
|
7
|
+
*/
|
|
8
|
+
appearance?: 'accent' | 'success';
|
|
9
|
+
/**
|
|
10
|
+
* The overall dimensions of the stepper.
|
|
11
|
+
* @default md
|
|
12
|
+
*/
|
|
13
|
+
size?: 'md' | 'lg';
|
|
14
|
+
/**
|
|
15
|
+
* Current step number (1-based).
|
|
6
16
|
*/
|
|
7
17
|
currentStep: number;
|
|
8
18
|
/**
|
|
@@ -10,7 +20,7 @@ export type StepperProps = {
|
|
|
10
20
|
*/
|
|
11
21
|
totalSteps: number;
|
|
12
22
|
/**
|
|
13
|
-
* Whether the stepper is disabled. Changes the progress
|
|
23
|
+
* Whether the stepper is disabled. Changes the progress to a muted style.
|
|
14
24
|
* @default false
|
|
15
25
|
*/
|
|
16
26
|
disabled?: boolean;
|