@ledgerhq/lumen-ui-rnative 0.1.61 → 0.1.62

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 (190) hide show
  1. package/dist/module/lib/Components/core/Avatar/Avatar.js +17 -6
  2. package/dist/module/lib/Components/core/Avatar/Avatar.js.map +1 -1
  3. package/dist/module/lib/Components/core/Avatar/Avatar.mdx +10 -6
  4. package/dist/module/lib/Components/core/Avatar/Avatar.stories.js +15 -6
  5. package/dist/module/lib/Components/core/Avatar/Avatar.stories.js.map +1 -1
  6. package/dist/module/lib/Components/core/Avatar/Avatar.test.js +56 -0
  7. package/dist/module/lib/Components/core/Avatar/Avatar.test.js.map +1 -1
  8. package/dist/module/lib/Components/core/Avatar/index.js +1 -1
  9. package/dist/module/lib/Components/core/Avatar/index.js.map +1 -1
  10. package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.js +21 -0
  11. package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.js.map +1 -0
  12. package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.test.js +88 -0
  13. package/dist/module/lib/Components/core/Avatar/useResolveAvatarColor.test.js.map +1 -0
  14. package/dist/module/lib/Components/core/Banner/Banner.js +3 -3
  15. package/dist/module/lib/Components/core/Banner/Banner.js.map +1 -1
  16. package/dist/module/lib/Components/core/Banner/Banner.test.js +3 -3
  17. package/dist/module/lib/Components/core/Banner/Banner.test.js.map +1 -1
  18. package/dist/module/lib/Components/core/DotIcon/getDotIconProps.test.js +1 -4
  19. package/dist/module/lib/Components/core/DotIcon/getDotIconProps.test.js.map +1 -1
  20. package/dist/module/lib/Components/core/DotIcon/index.js +0 -10
  21. package/dist/module/lib/Components/core/DotIcon/index.js.map +1 -1
  22. package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.test.js +1 -4
  23. package/dist/module/lib/Components/core/DotSymbol/getDotSymbolProps.test.js.map +1 -1
  24. package/dist/module/lib/Components/core/DotSymbol/index.js +0 -15
  25. package/dist/module/lib/Components/core/DotSymbol/index.js.map +1 -1
  26. package/dist/module/lib/Components/core/MediaButton/MediaButton.js +2 -2
  27. package/dist/module/lib/Components/core/MediaButton/MediaButton.mdx +2 -2
  28. package/dist/module/lib/Components/core/MenuList/MenuList.figma.js +21 -0
  29. package/dist/module/lib/Components/core/MenuList/MenuList.figma.js.map +1 -0
  30. package/dist/module/lib/Components/core/MenuList/MenuList.js +143 -0
  31. package/dist/module/lib/Components/core/MenuList/MenuList.js.map +1 -0
  32. package/dist/module/lib/Components/core/MenuList/MenuList.mdx +66 -0
  33. package/dist/module/lib/Components/core/MenuList/MenuList.stories.js +139 -0
  34. package/dist/module/lib/Components/core/MenuList/MenuList.stories.js.map +1 -0
  35. package/dist/module/lib/Components/core/MenuList/MenuList.test.js +146 -0
  36. package/dist/module/lib/Components/core/MenuList/MenuList.test.js.map +1 -0
  37. package/dist/module/lib/Components/core/MenuList/index.js +5 -0
  38. package/dist/module/lib/Components/core/MenuList/index.js.map +1 -0
  39. package/dist/module/lib/Components/core/MenuList/types.js.map +1 -0
  40. package/dist/module/lib/Components/core/SelectList/SelectList.figma.js +28 -0
  41. package/dist/module/lib/Components/core/{OptionList/OptionList.figma.js.map → SelectList/SelectList.figma.js.map} +1 -1
  42. package/dist/module/lib/Components/core/{OptionList/OptionList.js → SelectList/SelectList.js} +46 -46
  43. package/dist/module/lib/Components/core/{OptionList/OptionList.js.map → SelectList/SelectList.js.map} +1 -1
  44. package/dist/module/lib/Components/core/{OptionList/OptionList.mdx → SelectList/SelectList.mdx} +81 -81
  45. package/dist/module/lib/Components/core/{OptionList/OptionList.stories.js → SelectList/SelectList.stories.js} +130 -130
  46. package/dist/module/lib/Components/core/{OptionList/OptionList.stories.js.map → SelectList/SelectList.stories.js.map} +1 -1
  47. package/dist/module/lib/Components/core/{OptionList/OptionList.test.js → SelectList/SelectList.test.js} +83 -83
  48. package/dist/module/lib/Components/core/{OptionList/OptionList.test.js.map → SelectList/SelectList.test.js.map} +1 -1
  49. package/dist/module/lib/Components/core/SelectList/index.js +5 -0
  50. package/dist/module/lib/Components/core/{OptionList → SelectList}/index.js.map +1 -1
  51. package/dist/module/lib/Components/core/SelectList/types.js +4 -0
  52. package/dist/module/lib/Components/core/{OptionList → SelectList}/types.js.map +1 -1
  53. package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.js → SelectList/useSelectList/useSelectListItems.js} +2 -2
  54. package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.js.map → SelectList/useSelectList/useSelectListItems.js.map} +1 -1
  55. package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.js → SelectList/useSelectList/useSelectListItems.test.js} +17 -17
  56. package/dist/module/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.js.map → SelectList/useSelectList/useSelectListItems.test.js.map} +1 -1
  57. package/dist/module/lib/Components/core/index.js +2 -1
  58. package/dist/module/lib/Components/core/index.js.map +1 -1
  59. package/dist/module/lib/Components/internal/BaseButton/BaseButton.js +2 -2
  60. package/dist/module/lib/Components/internal/BaseButton/BaseButton.js.map +1 -1
  61. package/dist/module/lib/Components/internal/BaseTag/BaseTag.js +3 -3
  62. package/dist/module/lib/Components/internal/BaseTag/BaseTag.js.map +1 -1
  63. package/dist/module/lib/Components/internal/BaseTag/BaseTag.test.js +1 -1
  64. package/dist/module/lib/Components/internal/BaseTag/BaseTag.test.js.map +1 -1
  65. package/dist/module/lib/Components/symbols/Icon/Icon.test.js +1 -1
  66. package/dist/module/lib/Components/symbols/icons/CloudSync.js +50 -0
  67. package/dist/module/lib/Components/symbols/icons/CloudSync.js.map +1 -0
  68. package/dist/module/lib/Components/symbols/icons/Dollar.js +11 -5
  69. package/dist/module/lib/Components/symbols/icons/Dollar.js.map +1 -1
  70. package/dist/module/lib/Components/symbols/icons/DollarConvert.js +1 -1
  71. package/dist/module/lib/Components/symbols/icons/DollarConvert.js.map +1 -1
  72. package/dist/module/lib/Components/symbols/icons/DollarFill.js +47 -0
  73. package/dist/module/lib/Components/symbols/icons/DollarFill.js.map +1 -0
  74. package/dist/module/lib/Components/symbols/icons/FaceId.js +50 -0
  75. package/dist/module/lib/Components/symbols/icons/FaceId.js.map +1 -0
  76. package/dist/module/lib/Components/symbols/icons/Fingerprint.js +50 -0
  77. package/dist/module/lib/Components/symbols/icons/Fingerprint.js.map +1 -0
  78. package/dist/module/lib/Components/symbols/icons/Pause.js +2 -1
  79. package/dist/module/lib/Components/symbols/icons/Pause.js.map +1 -1
  80. package/dist/module/lib/Components/symbols/icons/Range.js +2 -5
  81. package/dist/module/lib/Components/symbols/icons/Range.js.map +1 -1
  82. package/dist/module/lib/Components/symbols/icons/Telegram.js +20 -9
  83. package/dist/module/lib/Components/symbols/icons/Telegram.js.map +1 -1
  84. package/dist/module/lib/Components/symbols/icons/Usb.js +1 -1
  85. package/dist/module/lib/Components/symbols/index.js +4 -0
  86. package/dist/module/lib/Components/symbols/index.js.map +1 -1
  87. package/dist/typescript/src/lib/Components/core/Avatar/Avatar.d.ts.map +1 -1
  88. package/dist/typescript/src/lib/Components/core/Avatar/index.d.ts +1 -1
  89. package/dist/typescript/src/lib/Components/core/Avatar/index.d.ts.map +1 -1
  90. package/dist/typescript/src/lib/Components/core/Avatar/types.d.ts +1 -1
  91. package/dist/typescript/src/lib/Components/core/Avatar/useResolveAvatarColor.d.ts +10 -0
  92. package/dist/typescript/src/lib/Components/core/Avatar/useResolveAvatarColor.d.ts.map +1 -0
  93. package/dist/typescript/src/lib/Components/core/DotIcon/index.d.ts +0 -7
  94. package/dist/typescript/src/lib/Components/core/DotIcon/index.d.ts.map +1 -1
  95. package/dist/typescript/src/lib/Components/core/DotSymbol/index.d.ts +0 -12
  96. package/dist/typescript/src/lib/Components/core/DotSymbol/index.d.ts.map +1 -1
  97. package/dist/typescript/src/lib/Components/core/MediaButton/MediaButton.d.ts +2 -2
  98. package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts +29 -0
  99. package/dist/typescript/src/lib/Components/core/MenuList/MenuList.d.ts.map +1 -0
  100. package/dist/typescript/src/lib/Components/core/MenuList/index.d.ts +3 -0
  101. package/dist/typescript/src/lib/Components/core/MenuList/index.d.ts.map +1 -0
  102. package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts +42 -0
  103. package/dist/typescript/src/lib/Components/core/MenuList/types.d.ts.map +1 -0
  104. package/dist/typescript/src/lib/Components/core/SelectList/SelectList.d.ts +27 -0
  105. package/dist/typescript/src/lib/Components/core/{OptionList/OptionList.d.ts.map → SelectList/SelectList.d.ts.map} +1 -1
  106. package/dist/typescript/src/lib/Components/core/SelectList/index.d.ts +3 -0
  107. package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/index.d.ts.map +1 -1
  108. package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/types.d.ts +24 -24
  109. package/dist/typescript/src/lib/Components/core/{OptionList → SelectList}/types.d.ts.map +1 -1
  110. package/dist/typescript/src/lib/Components/core/SelectList/useSelectList/useSelectListItems.d.ts +20 -0
  111. package/dist/typescript/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.d.ts.map → SelectList/useSelectList/useSelectListItems.d.ts.map} +1 -1
  112. package/dist/typescript/src/lib/Components/core/index.d.ts +2 -1
  113. package/dist/typescript/src/lib/Components/core/index.d.ts.map +1 -1
  114. package/dist/typescript/src/lib/Components/symbols/icons/CloudSync.d.ts +35 -0
  115. package/dist/typescript/src/lib/Components/symbols/icons/CloudSync.d.ts.map +1 -0
  116. package/dist/typescript/src/lib/Components/symbols/icons/Dollar.d.ts.map +1 -1
  117. package/dist/typescript/src/lib/Components/symbols/icons/DollarFill.d.ts +35 -0
  118. package/dist/typescript/src/lib/Components/symbols/icons/DollarFill.d.ts.map +1 -0
  119. package/dist/typescript/src/lib/Components/symbols/icons/FaceId.d.ts +35 -0
  120. package/dist/typescript/src/lib/Components/symbols/icons/FaceId.d.ts.map +1 -0
  121. package/dist/typescript/src/lib/Components/symbols/icons/Fingerprint.d.ts +35 -0
  122. package/dist/typescript/src/lib/Components/symbols/icons/Fingerprint.d.ts.map +1 -0
  123. package/dist/typescript/src/lib/Components/symbols/icons/Pause.d.ts.map +1 -1
  124. package/dist/typescript/src/lib/Components/symbols/icons/Range.d.ts.map +1 -1
  125. package/dist/typescript/src/lib/Components/symbols/icons/Telegram.d.ts.map +1 -1
  126. package/dist/typescript/src/lib/Components/symbols/index.d.ts +4 -0
  127. package/dist/typescript/src/lib/Components/symbols/index.d.ts.map +1 -1
  128. package/package.json +3 -3
  129. package/src/lib/Components/core/Avatar/Avatar.mdx +10 -6
  130. package/src/lib/Components/core/Avatar/Avatar.stories.tsx +16 -9
  131. package/src/lib/Components/core/Avatar/Avatar.test.tsx +64 -0
  132. package/src/lib/Components/core/Avatar/Avatar.tsx +41 -8
  133. package/src/lib/Components/core/Avatar/index.ts +1 -1
  134. package/src/lib/Components/core/Avatar/types.ts +1 -1
  135. package/src/lib/Components/core/Avatar/useResolveAvatarColor.test.tsx +106 -0
  136. package/src/lib/Components/core/Avatar/useResolveAvatarColor.ts +25 -0
  137. package/src/lib/Components/core/Banner/Banner.test.tsx +3 -3
  138. package/src/lib/Components/core/Banner/Banner.tsx +3 -3
  139. package/src/lib/Components/core/DotIcon/getDotIconProps.test.ts +1 -5
  140. package/src/lib/Components/core/DotIcon/index.ts +0 -10
  141. package/src/lib/Components/core/DotSymbol/getDotSymbolProps.test.ts +1 -5
  142. package/src/lib/Components/core/DotSymbol/index.ts +0 -15
  143. package/src/lib/Components/core/MediaButton/MediaButton.mdx +2 -2
  144. package/src/lib/Components/core/MediaButton/MediaButton.tsx +2 -2
  145. package/src/lib/Components/core/MenuList/MenuList.figma.tsx +23 -0
  146. package/src/lib/Components/core/MenuList/MenuList.mdx +66 -0
  147. package/src/lib/Components/core/MenuList/MenuList.stories.tsx +114 -0
  148. package/src/lib/Components/core/MenuList/MenuList.test.tsx +135 -0
  149. package/src/lib/Components/core/MenuList/MenuList.tsx +162 -0
  150. package/src/lib/Components/core/MenuList/index.ts +2 -0
  151. package/src/lib/Components/core/MenuList/types.ts +49 -0
  152. package/src/lib/Components/core/SelectList/SelectList.figma.tsx +37 -0
  153. package/src/lib/Components/core/{OptionList/OptionList.mdx → SelectList/SelectList.mdx} +81 -81
  154. package/src/lib/Components/core/{OptionList/OptionList.stories.tsx → SelectList/SelectList.stories.tsx} +227 -227
  155. package/src/lib/Components/core/{OptionList/OptionList.test.tsx → SelectList/SelectList.test.tsx} +138 -138
  156. package/src/lib/Components/core/{OptionList/OptionList.tsx → SelectList/SelectList.tsx} +92 -92
  157. package/src/lib/Components/core/SelectList/index.ts +2 -0
  158. package/src/lib/Components/core/{OptionList → SelectList}/types.ts +28 -28
  159. package/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.test.ts → SelectList/useSelectList/useSelectListItems.test.ts} +24 -24
  160. package/src/lib/Components/core/{OptionList/useOptionList/useOptionListItems.ts → SelectList/useSelectList/useSelectListItems.ts} +21 -21
  161. package/src/lib/Components/core/Spot/Spot.tsx +1 -1
  162. package/src/lib/Components/core/index.ts +2 -1
  163. package/src/lib/Components/internal/BaseButton/BaseButton.tsx +2 -2
  164. package/src/lib/Components/internal/BaseTag/BaseTag.test.tsx +3 -3
  165. package/src/lib/Components/internal/BaseTag/BaseTag.tsx +3 -3
  166. package/src/lib/Components/symbols/Icon/Icon.test.tsx +1 -1
  167. package/src/lib/Components/symbols/icons/CloudSync.tsx +45 -0
  168. package/src/lib/Components/symbols/icons/Dollar.tsx +8 -1
  169. package/src/lib/Components/symbols/icons/DollarConvert.tsx +1 -1
  170. package/src/lib/Components/symbols/icons/DollarFill.tsx +42 -0
  171. package/src/lib/Components/symbols/icons/FaceId.tsx +45 -0
  172. package/src/lib/Components/symbols/icons/Fingerprint.tsx +45 -0
  173. package/src/lib/Components/symbols/icons/Pause.tsx +2 -1
  174. package/src/lib/Components/symbols/icons/Range.tsx +2 -5
  175. package/src/lib/Components/symbols/icons/Telegram.tsx +14 -7
  176. package/src/lib/Components/symbols/icons/Usb.tsx +1 -1
  177. package/src/lib/Components/symbols/index.ts +4 -0
  178. package/dist/module/lib/Components/core/Avatar/resolveAvatarColor.js +0 -18
  179. package/dist/module/lib/Components/core/Avatar/resolveAvatarColor.js.map +0 -1
  180. package/dist/module/lib/Components/core/OptionList/OptionList.figma.js +0 -28
  181. package/dist/module/lib/Components/core/OptionList/index.js +0 -5
  182. package/dist/typescript/src/lib/Components/core/Avatar/resolveAvatarColor.d.ts +0 -8
  183. package/dist/typescript/src/lib/Components/core/Avatar/resolveAvatarColor.d.ts.map +0 -1
  184. package/dist/typescript/src/lib/Components/core/OptionList/OptionList.d.ts +0 -27
  185. package/dist/typescript/src/lib/Components/core/OptionList/index.d.ts +0 -3
  186. package/dist/typescript/src/lib/Components/core/OptionList/useOptionList/useOptionListItems.d.ts +0 -20
  187. package/src/lib/Components/core/Avatar/resolveAvatarColor.ts +0 -19
  188. package/src/lib/Components/core/OptionList/OptionList.figma.tsx +0 -37
  189. package/src/lib/Components/core/OptionList/index.ts +0 -2
  190. /package/dist/module/lib/Components/core/{OptionList → MenuList}/types.js +0 -0
@@ -0,0 +1,114 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-native-web-vite';
2
+ import { Box } from '../../primitives';
3
+ import { Settings, Trash, Unlink } from '../../symbols';
4
+ import { MenuList, MenuListItem } from './MenuList';
5
+
6
+ const iconMap = {
7
+ None: undefined,
8
+ Settings,
9
+ Unlink,
10
+ Trash,
11
+ } as const;
12
+
13
+ const meta = {
14
+ id: 'rnative-menulist',
15
+ title: 'Core/MenuList',
16
+ component: MenuList,
17
+ subcomponents: { MenuListItem },
18
+ parameters: {
19
+ docs: {
20
+ source: { language: 'tsx', format: true, type: 'dynamic' },
21
+ },
22
+ },
23
+ } satisfies Meta<typeof MenuList>;
24
+
25
+ export default meta;
26
+ type Story = StoryObj<typeof MenuList>;
27
+
28
+ export const Base: Story = {
29
+ parameters: {
30
+ layout: 'centered',
31
+ backgrounds: { default: 'light' },
32
+ },
33
+ render: () => (
34
+ <Box lx={{ width: 's320' }}>
35
+ <MenuList>
36
+ <MenuListItem label='Unlink device' appearance='base' icon={Unlink} />
37
+ </MenuList>
38
+ </Box>
39
+ ),
40
+ };
41
+
42
+ export const ItemShowcase: StoryObj<typeof MenuListItem> = {
43
+ parameters: {
44
+ layout: 'centered',
45
+ backgrounds: { default: 'light' },
46
+ },
47
+ argTypes: {
48
+ icon: {
49
+ options: Object.keys(iconMap),
50
+ mapping: iconMap,
51
+ control: { type: 'select' },
52
+ },
53
+ onPress: { action: 'pressed' },
54
+ },
55
+ args: {
56
+ label: 'Unlink device',
57
+ appearance: 'base',
58
+ disabled: false,
59
+ icon: Unlink,
60
+ },
61
+ render: (args) => (
62
+ <Box lx={{ width: 's320' }}>
63
+ <MenuList>
64
+ <MenuListItem {...args} />
65
+ </MenuList>
66
+ </Box>
67
+ ),
68
+ };
69
+
70
+ export const AppearanceShowcase: Story = {
71
+ parameters: {
72
+ layout: 'centered',
73
+ backgrounds: { default: 'light' },
74
+ },
75
+ render: () => (
76
+ <Box lx={{ width: 's320' }}>
77
+ <MenuList>
78
+ <MenuListItem label='Unlink device' icon={Unlink} onPress={() => {}} />
79
+ <MenuListItem
80
+ label='Remove device'
81
+ icon={Trash}
82
+ appearance='red'
83
+ onPress={() => {}}
84
+ />
85
+ </MenuList>
86
+ </Box>
87
+ ),
88
+ };
89
+
90
+ export const DisabledShowcase: Story = {
91
+ parameters: {
92
+ layout: 'centered',
93
+ backgrounds: { default: 'light' },
94
+ },
95
+ render: () => (
96
+ <Box lx={{ width: 's320' }}>
97
+ <MenuList>
98
+ <MenuListItem
99
+ label='Unlink device'
100
+ icon={Unlink}
101
+ disabled
102
+ onPress={() => {}}
103
+ />
104
+ <MenuListItem
105
+ label='Remove device'
106
+ icon={Trash}
107
+ appearance='red'
108
+ disabled
109
+ onPress={() => {}}
110
+ />
111
+ </MenuList>
112
+ </Box>
113
+ ),
114
+ };
@@ -0,0 +1,135 @@
1
+ import { describe, it, expect, jest } from '@jest/globals';
2
+ import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
3
+ import { render, fireEvent } from '@testing-library/react-native';
4
+ import { View } from 'react-native';
5
+ import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
6
+ import { MenuList, MenuListItem } from './MenuList';
7
+ import type { IconComponent } from './types';
8
+
9
+ const TestIcon: IconComponent = ({ size, color }) => (
10
+ <View
11
+ testID='icon'
12
+ style={{ width: size, height: size }}
13
+ accessibilityLabel={String(color)}
14
+ />
15
+ );
16
+
17
+ const TestWrapper = ({ children }: { children: React.ReactNode }) => (
18
+ <ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
19
+ {children}
20
+ </ThemeProvider>
21
+ );
22
+
23
+ describe('MenuList', () => {
24
+ it('renders children', () => {
25
+ const { getByText } = render(
26
+ <TestWrapper>
27
+ <MenuList>
28
+ <MenuListItem label='Item A' onPress={jest.fn()} />
29
+ </MenuList>
30
+ </TestWrapper>,
31
+ );
32
+
33
+ expect(getByText('Item A')).toBeTruthy();
34
+ });
35
+ });
36
+
37
+ describe('MenuListItem', () => {
38
+ it('renders the label', () => {
39
+ const { getByText } = render(
40
+ <TestWrapper>
41
+ <MenuListItem label='Settings' onPress={jest.fn()} />
42
+ </TestWrapper>,
43
+ );
44
+
45
+ expect(getByText('Settings')).toBeTruthy();
46
+ });
47
+
48
+ it('calls onPress when pressed', () => {
49
+ const onPress = jest.fn();
50
+ const { getByRole } = render(
51
+ <TestWrapper>
52
+ <MenuListItem label='Action' onPress={onPress} />
53
+ </TestWrapper>,
54
+ );
55
+
56
+ fireEvent.press(getByRole('button'));
57
+
58
+ expect(onPress).toHaveBeenCalledTimes(1);
59
+ });
60
+
61
+ it('does not call onPress when disabled', () => {
62
+ const onPress = jest.fn();
63
+ const { getByRole } = render(
64
+ <TestWrapper>
65
+ <MenuListItem label='Disabled action' onPress={onPress} disabled />
66
+ </TestWrapper>,
67
+ );
68
+
69
+ fireEvent.press(getByRole('button'));
70
+
71
+ expect(onPress).not.toHaveBeenCalled();
72
+ });
73
+
74
+ it('sets accessibilityState disabled when disabled', () => {
75
+ const { getByRole } = render(
76
+ <TestWrapper>
77
+ <MenuListItem label='Disabled' onPress={jest.fn()} disabled />
78
+ </TestWrapper>,
79
+ );
80
+
81
+ expect(getByRole('button').props.accessibilityState?.disabled).toBe(true);
82
+ });
83
+
84
+ it('renders with red appearance', () => {
85
+ const { getByText } = render(
86
+ <TestWrapper>
87
+ <MenuListItem label='Delete' appearance='red' onPress={jest.fn()} />
88
+ </TestWrapper>,
89
+ );
90
+
91
+ expect(getByText('Delete').props.style.color).toBe(
92
+ ledgerLiveThemes.dark.colors.text.error,
93
+ );
94
+ });
95
+
96
+ it('renders the icon with base color by default', () => {
97
+ const { getByTestId } = render(
98
+ <TestWrapper>
99
+ <MenuListItem label='With Icon' icon={TestIcon} onPress={jest.fn()} />
100
+ </TestWrapper>,
101
+ );
102
+
103
+ expect(getByTestId('icon').props.accessibilityLabel).toBe('base');
104
+ });
105
+
106
+ it('renders icon with disabled color when disabled', () => {
107
+ const { getByTestId } = render(
108
+ <TestWrapper>
109
+ <MenuListItem
110
+ label='With Icon'
111
+ icon={TestIcon}
112
+ onPress={jest.fn()}
113
+ disabled
114
+ />
115
+ </TestWrapper>,
116
+ );
117
+
118
+ expect(getByTestId('icon').props.accessibilityLabel).toBe('disabled');
119
+ });
120
+
121
+ it('renders icon with error color when appearance is red', () => {
122
+ const { getByTestId } = render(
123
+ <TestWrapper>
124
+ <MenuListItem
125
+ label='Delete'
126
+ icon={TestIcon}
127
+ appearance='red'
128
+ onPress={jest.fn()}
129
+ />
130
+ </TestWrapper>,
131
+ );
132
+
133
+ expect(getByTestId('icon').props.accessibilityLabel).toBe('error');
134
+ });
135
+ });
@@ -0,0 +1,162 @@
1
+ import { useDisabledContext } from '@ledgerhq/lumen-utils-shared';
2
+ import { StyleSheet } from 'react-native';
3
+ import type { LumenTextStyle } from '../../../../styles';
4
+ import { useStyleSheet } from '../../../../styles';
5
+ import { Box, Pressable, Text } from '../../primitives';
6
+ import type {
7
+ MenuListItemAppearance,
8
+ MenuListItemProps,
9
+ MenuListProps,
10
+ } from './types';
11
+
12
+ const resolveContentColor = (
13
+ disabled: boolean,
14
+ appearance: MenuListItemAppearance,
15
+ ): NonNullable<LumenTextStyle['color']> => {
16
+ if (disabled) {
17
+ return 'disabled';
18
+ }
19
+ if (appearance === 'red') {
20
+ return 'error';
21
+ }
22
+ return 'base';
23
+ };
24
+
25
+ const useItemStyles = ({
26
+ pressed,
27
+ disabled,
28
+ appearance,
29
+ }: {
30
+ pressed: boolean;
31
+ disabled: boolean;
32
+ appearance: MenuListItemAppearance;
33
+ }) =>
34
+ useStyleSheet(
35
+ (t) => ({
36
+ container: StyleSheet.flatten([
37
+ {
38
+ flexDirection: 'row',
39
+ alignItems: 'center',
40
+ paddingVertical: t.spacings.s12,
41
+ paddingHorizontal: t.spacings.s8,
42
+ gap: t.spacings.s12,
43
+ borderRadius: t.borderRadius.sm,
44
+ backgroundColor: t.colors.bg.baseTransparent,
45
+ },
46
+ pressed && { backgroundColor: t.colors.bg.baseTransparentPressed },
47
+ ]),
48
+ label: StyleSheet.flatten([
49
+ t.typographies.body2SemiBold,
50
+ {
51
+ flex: 1,
52
+ color: t.colors.text[resolveContentColor(disabled, appearance)],
53
+ },
54
+ ]),
55
+ }),
56
+ [pressed, disabled, appearance],
57
+ );
58
+
59
+ /**
60
+ * A container for a set of tappable actions, rendered as `MenuListItem`s.
61
+ *
62
+ * `MenuList` is a content primitive: it owns no open/close state, so compose it
63
+ * inside a `BottomSheet` (or any other surface) to build a menu experience.
64
+ *
65
+ * @see {@link https://ldls-react-native.vercel.app/?path=/docs/rnative-menulist--docs Storybook}
66
+ *
67
+ * @example
68
+ * <MenuList>
69
+ * <MenuListItem icon={Unlink} label="Unlink" onPress={handleUnlink} />
70
+ * <MenuListItem icon={Trash} label="Remove" appearance="red" onPress={handleRemove} />
71
+ * </MenuList>
72
+ */
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>
83
+ );
84
+
85
+ /**
86
+ * A single action inside a `MenuList`: a label, an optional leading icon and a
87
+ * press handler.
88
+ *
89
+ * Place destructive (`appearance="red"`) items last, per platform convention.
90
+ *
91
+ * @see {@link https://ldls-react-native.vercel.app/?path=/docs/rnative-menulist--docs Storybook}
92
+ *
93
+ * @example
94
+ * <MenuListItem icon={Trash} label="Remove" appearance="red" onPress={handleRemove} />
95
+ */
96
+ export const MenuListItem = ({
97
+ label,
98
+ icon: Icon,
99
+ appearance = 'base',
100
+ disabled: disabledProp = false,
101
+ onPress,
102
+ accessibilityState,
103
+ lx,
104
+ style,
105
+ ref,
106
+ ...props
107
+ }: MenuListItemProps) => {
108
+ const disabled = useDisabledContext({
109
+ consumerName: 'MenuListItem',
110
+ mergeWith: { disabled: disabledProp },
111
+ });
112
+
113
+ return (
114
+ <Pressable
115
+ ref={ref}
116
+ lx={lx}
117
+ style={style}
118
+ onPress={onPress}
119
+ disabled={disabled}
120
+ accessibilityRole='button'
121
+ accessibilityState={{ ...accessibilityState, disabled }}
122
+ {...props}
123
+ >
124
+ {({ pressed }) => (
125
+ <MenuListItemInner
126
+ label={label}
127
+ icon={Icon}
128
+ appearance={appearance}
129
+ pressed={pressed}
130
+ disabled={disabled}
131
+ />
132
+ )}
133
+ </Pressable>
134
+ );
135
+ };
136
+
137
+ const MenuListItemInner = ({
138
+ label,
139
+ icon: Icon,
140
+ appearance,
141
+ pressed,
142
+ disabled,
143
+ }: {
144
+ label: string;
145
+ icon: MenuListItemProps['icon'];
146
+ appearance: MenuListItemAppearance;
147
+ pressed: boolean;
148
+ disabled: boolean;
149
+ }) => {
150
+ const styles = useItemStyles({ pressed, disabled, appearance });
151
+
152
+ return (
153
+ <Box style={styles.container}>
154
+ {Icon && (
155
+ <Icon size={24} color={resolveContentColor(disabled, appearance)} />
156
+ )}
157
+ <Text style={styles.label} numberOfLines={1}>
158
+ {label}
159
+ </Text>
160
+ </Box>
161
+ );
162
+ };
@@ -0,0 +1,2 @@
1
+ export * from './MenuList';
2
+ export * from './types';
@@ -0,0 +1,49 @@
1
+ import type { ComponentType, ReactNode } from 'react';
2
+ import type {
3
+ LumenTextStyle,
4
+ StyledPressableProps,
5
+ StyledViewProps,
6
+ } from '../../../../styles';
7
+ import type { IconSize } from '../../symbols/Icon';
8
+
9
+ export type IconComponent = ComponentType<{
10
+ size?: IconSize;
11
+ color?: LumenTextStyle['color'];
12
+ }>;
13
+
14
+ export type MenuListItemAppearance = 'base' | 'red';
15
+
16
+ export type MenuListProps = {
17
+ /**
18
+ * The `MenuListItem`s that make up the menu.
19
+ */
20
+ children: ReactNode;
21
+ } & Omit<StyledViewProps, 'children'>;
22
+
23
+ export type MenuListItemProps = {
24
+ /**
25
+ * Text describing the action, truncated to a single line.
26
+ */
27
+ label: string;
28
+ /**
29
+ * Icon rendered before the label.
30
+ */
31
+ icon?: IconComponent;
32
+ /**
33
+ * Visual treatment of the label and icon. Use `red` for irreversible or
34
+ * dangerous actions.
35
+ *
36
+ * @default 'base'
37
+ */
38
+ appearance?: MenuListItemAppearance;
39
+ /**
40
+ * Prevents interaction and dims the content.
41
+ *
42
+ * @default false
43
+ */
44
+ disabled?: boolean;
45
+ /**
46
+ * Action to run when the item is pressed.
47
+ */
48
+ onPress?: StyledPressableProps['onPress'];
49
+ } & Omit<StyledPressableProps, 'children' | 'onPress'>;
@@ -0,0 +1,37 @@
1
+ import figma from '@figma/code-connect';
2
+ import {
3
+ SelectList,
4
+ SelectListContent,
5
+ SelectListEmptyState,
6
+ SelectListItem,
7
+ SelectListItemContent,
8
+ SelectListItemDescription,
9
+ SelectListItemText,
10
+ } from './SelectList';
11
+
12
+ figma.connect(
13
+ SelectList,
14
+ 'https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7?node-id=15941-6709',
15
+ {
16
+ imports: [
17
+ "import { SelectList, SelectListContent, SelectListItem, SelectListItemContent, SelectListItemText, SelectListItemDescription, SelectListEmptyState } from '@ledgerhq/lumen-ui-rnative'",
18
+ ],
19
+ example: () => (
20
+ <SelectList items={[]} value={''} onValueChange={() => {}}>
21
+ <SelectListContent
22
+ renderItem={(item) => (
23
+ <SelectListItem value={item.value}>
24
+ <SelectListItemContent>
25
+ <SelectListItemText>{item.label}</SelectListItemText>
26
+ <SelectListItemDescription>
27
+ {item.description}
28
+ </SelectListItemDescription>
29
+ </SelectListItemContent>
30
+ </SelectListItem>
31
+ )}
32
+ />
33
+ <SelectListEmptyState title='No options available' />
34
+ </SelectList>
35
+ ),
36
+ },
37
+ );