@ledgerhq/lumen-ui-rnative 0.0.47 → 0.0.49

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 (54) hide show
  1. package/dist/package.json +3 -3
  2. package/dist/src/lib/Components/Divider/Divider.d.ts +25 -0
  3. package/dist/src/lib/Components/Divider/Divider.d.ts.map +1 -0
  4. package/dist/src/lib/Components/Divider/Divider.js +40 -0
  5. package/dist/src/lib/Components/Divider/Divider.stories.d.ts +9 -0
  6. package/dist/src/lib/Components/Divider/Divider.stories.d.ts.map +1 -0
  7. package/dist/src/lib/Components/Divider/Divider.stories.js +51 -0
  8. package/dist/src/lib/Components/Divider/index.d.ts +3 -0
  9. package/dist/src/lib/Components/Divider/index.d.ts.map +1 -0
  10. package/dist/src/lib/Components/Divider/index.js +1 -0
  11. package/dist/src/lib/Components/Divider/types.d.ts +9 -0
  12. package/dist/src/lib/Components/Divider/types.d.ts.map +1 -0
  13. package/dist/src/lib/Components/Divider/types.js +1 -0
  14. package/dist/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
  15. package/dist/src/lib/Components/ListItem/ListItem.js +9 -3
  16. package/dist/src/lib/Components/Select/GlobalSelectBottomSheet.d.ts.map +1 -1
  17. package/dist/src/lib/Components/Select/GlobalSelectBottomSheet.js +2 -7
  18. package/dist/src/lib/Components/Select/Select.d.ts.map +1 -1
  19. package/dist/src/lib/Components/Select/Select.js +4 -10
  20. package/dist/src/lib/Components/Select/types.d.ts.map +1 -1
  21. package/dist/src/lib/Components/Tile/Tile.d.ts +84 -19
  22. package/dist/src/lib/Components/Tile/Tile.d.ts.map +1 -1
  23. package/dist/src/lib/Components/Tile/Tile.figma.js +8 -18
  24. package/dist/src/lib/Components/Tile/Tile.js +160 -59
  25. package/dist/src/lib/Components/Tile/Tile.stories.d.ts +2 -2
  26. package/dist/src/lib/Components/Tile/Tile.stories.d.ts.map +1 -1
  27. package/dist/src/lib/Components/Tile/Tile.stories.js +36 -81
  28. package/dist/src/lib/Components/Tile/index.d.ts +1 -1
  29. package/dist/src/lib/Components/Tile/index.d.ts.map +1 -1
  30. package/dist/src/lib/Components/Tile/index.js +1 -1
  31. package/dist/src/lib/Components/Tile/types.d.ts +29 -19
  32. package/dist/src/lib/Components/Tile/types.d.ts.map +1 -1
  33. package/dist/src/lib/Components/index.d.ts +1 -0
  34. package/dist/src/lib/Components/index.d.ts.map +1 -1
  35. package/dist/src/lib/Components/index.js +1 -0
  36. package/package.json +3 -3
  37. package/src/lib/Components/Divider/Divider.mdx +151 -0
  38. package/src/lib/Components/Divider/Divider.stories.tsx +140 -0
  39. package/src/lib/Components/Divider/Divider.test.tsx +92 -0
  40. package/src/lib/Components/Divider/Divider.tsx +52 -0
  41. package/src/lib/Components/Divider/index.ts +2 -0
  42. package/src/lib/Components/Divider/types.ts +9 -0
  43. package/src/lib/Components/ListItem/ListItem.tsx +10 -3
  44. package/src/lib/Components/Select/GlobalSelectBottomSheet.tsx +5 -7
  45. package/src/lib/Components/Select/Select.tsx +4 -18
  46. package/src/lib/Components/Select/types.ts +1 -3
  47. package/src/lib/Components/Tile/Tile.figma.tsx +24 -23
  48. package/src/lib/Components/Tile/Tile.mdx +128 -35
  49. package/src/lib/Components/Tile/Tile.stories.tsx +173 -146
  50. package/src/lib/Components/Tile/Tile.test.tsx +193 -221
  51. package/src/lib/Components/Tile/Tile.tsx +270 -123
  52. package/src/lib/Components/Tile/index.ts +7 -1
  53. package/src/lib/Components/Tile/types.ts +38 -19
  54. package/src/lib/Components/index.ts +1 -0
@@ -2,13 +2,17 @@ import { describe, it, expect, jest } from '@jest/globals';
2
2
  import { ledgerLiveThemes } from '@ledgerhq/lumen-design-core';
3
3
  import { render, fireEvent } from '@testing-library/react-native';
4
4
  import React from 'react';
5
- import { Text } from 'react-native';
6
5
 
7
6
  import { Settings } from '../../Symbols';
8
- import { Spot } from '../Spot';
9
7
  import { Tag } from '../Tag';
10
8
  import { ThemeProvider } from '../ThemeProvider/ThemeProvider';
11
- import { Tile } from './Tile';
9
+ import {
10
+ Tile,
11
+ TileSpot,
12
+ TileContent,
13
+ TileTitle,
14
+ TileDescription,
15
+ } from './Tile';
12
16
 
13
17
  const TestWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => (
14
18
  <ThemeProvider themes={ledgerLiveThemes} colorScheme='dark' locale='en'>
@@ -17,236 +21,204 @@ const TestWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => (
17
21
  );
18
22
 
19
23
  describe('Tile Component', () => {
20
- const mockSpot = <Spot appearance='icon' icon={Settings} />;
21
- const mockTitle = 'Test Item';
22
-
23
- it('should render correctly with required props', () => {
24
- const { getByText, getByTestId } = render(
25
- <TestWrapper>
26
- <Tile leadingContent={mockSpot} title={mockTitle} testID='tile' />
27
- </TestWrapper>,
28
- );
29
-
30
- expect(getByTestId('tile')).toBeTruthy();
31
- expect(getByText(mockTitle)).toBeTruthy();
24
+ describe('Basic Rendering', () => {
25
+ it('should render correctly with composite API', () => {
26
+ const { getByText, getByTestId } = render(
27
+ <TestWrapper>
28
+ <Tile testID='tile'>
29
+ <TileSpot appearance='icon' icon={Settings} />
30
+ <TileContent>
31
+ <TileTitle>Test Title</TileTitle>
32
+ </TileContent>
33
+ </Tile>
34
+ </TestWrapper>,
35
+ );
36
+
37
+ expect(getByTestId('tile')).toBeTruthy();
38
+ expect(getByText('Test Title')).toBeTruthy();
39
+ });
40
+
41
+ it('should render custom content', () => {
42
+ const tagText = 'Test Tag';
43
+ const { getByText } = render(
44
+ <TestWrapper>
45
+ <Tile testID='tile'>
46
+ <TileSpot appearance='icon' icon={Settings} />
47
+ <TileContent>
48
+ <TileTitle>Test Title</TileTitle>
49
+ </TileContent>
50
+ <Tag label={tagText} />
51
+ </Tile>
52
+ </TestWrapper>,
53
+ );
54
+
55
+ expect(getByText('Test Title')).toBeTruthy();
56
+ expect(getByText(tagText)).toBeTruthy();
57
+ });
32
58
  });
33
59
 
34
- it('should render description when provided', () => {
35
- const description = 'Test description';
36
- const { getByText } = render(
37
- <TestWrapper>
38
- <Tile
39
- leadingContent={mockSpot}
40
- title={mockTitle}
41
- description={description}
42
- testID='tile'
43
- />
44
- </TestWrapper>,
45
- );
46
-
47
- expect(getByText(mockTitle)).toBeTruthy();
48
- expect(getByText(description)).toBeTruthy();
49
- });
50
-
51
- it('should render without description when not provided', () => {
52
- const { getByText, queryByText } = render(
53
- <TestWrapper>
54
- <Tile leadingContent={mockSpot} title={mockTitle} testID='tile' />
55
- </TestWrapper>,
56
- );
57
-
58
- expect(getByText(mockTitle)).toBeTruthy();
59
- // Description should not exist
60
- expect(queryByText('Test description')).toBeNull();
61
- });
62
-
63
- it('should render trailingContent when provided', () => {
64
- const tagText = 'Test Tag';
65
- const mockTag = <Tag label={tagText} />;
66
- const { getByText } = render(
67
- <TestWrapper>
68
- <Tile
69
- leadingContent={mockSpot}
70
- title={mockTitle}
71
- trailingContent={mockTag}
72
- testID='tile'
73
- />
74
- </TestWrapper>,
75
- );
76
-
77
- expect(getByText(mockTitle)).toBeTruthy();
78
- expect(getByText(tagText)).toBeTruthy();
79
- });
80
-
81
- it('should render custom trailingContent with testID', () => {
82
- const trailingText = 'Custom Trailing';
83
- const mockTrailing = <Text testID='custom-trailing'>{trailingText}</Text>;
84
- const { getByTestId } = render(
85
- <TestWrapper>
86
- <Tile
87
- leadingContent={mockSpot}
88
- title={mockTitle}
89
- trailingContent={mockTrailing}
90
- testID='tile'
91
- />
92
- </TestWrapper>,
93
- );
94
-
95
- expect(getByTestId('custom-trailing')).toBeTruthy();
96
- });
97
-
98
- it('should call onPress handler when pressed', () => {
99
- const handlePress = jest.fn();
100
- const { getByTestId } = render(
101
- <TestWrapper>
102
- <Tile
103
- leadingContent={mockSpot}
104
- title={mockTitle}
105
- onPress={handlePress}
106
- testID='tile'
107
- />
108
- </TestWrapper>,
109
- );
110
-
111
- fireEvent.press(getByTestId('tile'));
112
-
113
- expect(handlePress).toHaveBeenCalledTimes(1);
114
- });
115
-
116
- it('should not call onPress when not provided', () => {
117
- const { getByTestId } = render(
118
- <TestWrapper>
119
- <Tile leadingContent={mockSpot} title={mockTitle} testID='tile' />
120
- </TestWrapper>,
121
- );
60
+ describe('Press Handlers', () => {
61
+ it('should call onPress handler when pressed', () => {
62
+ const handlePress = jest.fn();
63
+ const { getByTestId } = render(
64
+ <TestWrapper>
65
+ <Tile onPress={handlePress} testID='tile'>
66
+ <TileSpot appearance='icon' icon={Settings} />
67
+ <TileContent>
68
+ <TileTitle>Test Title</TileTitle>
69
+ </TileContent>
70
+ </Tile>
71
+ </TestWrapper>,
72
+ );
122
73
 
123
- // Should not throw error when pressing without onPress handler
124
- expect(() => {
125
74
  fireEvent.press(getByTestId('tile'));
126
- }).not.toThrow();
127
- });
128
75
 
129
- it('should call onLongPress handler when long pressed', () => {
130
- const handleLongPress = jest.fn();
131
- const { getByTestId } = render(
132
- <TestWrapper>
133
- <Tile
134
- leadingContent={mockSpot}
135
- title={mockTitle}
136
- onLongPress={handleLongPress}
137
- testID='tile'
138
- />
139
- </TestWrapper>,
140
- );
141
-
142
- fireEvent(getByTestId('tile'), 'onLongPress');
143
-
144
- expect(handleLongPress).toHaveBeenCalledTimes(1);
145
- });
76
+ expect(handlePress).toHaveBeenCalledTimes(1);
77
+ });
78
+
79
+ it('should call onLongPress handler when long pressed', () => {
80
+ const handleLongPress = jest.fn();
81
+ const { getByTestId } = render(
82
+ <TestWrapper>
83
+ <Tile onLongPress={handleLongPress} testID='tile'>
84
+ <TileSpot appearance='icon' icon={Settings} />
85
+ <TileContent>
86
+ <TileTitle>Test Title</TileTitle>
87
+ </TileContent>
88
+ </Tile>
89
+ </TestWrapper>,
90
+ );
91
+
92
+ fireEvent(getByTestId('tile'), 'onLongPress');
93
+
94
+ expect(handleLongPress).toHaveBeenCalledTimes(1);
95
+ });
96
+
97
+ it('should support both onPress and onLongPress', () => {
98
+ const handlePress = jest.fn();
99
+ const handleLongPress = jest.fn();
100
+ const { getByTestId } = render(
101
+ <TestWrapper>
102
+ <Tile
103
+ onPress={handlePress}
104
+ onLongPress={handleLongPress}
105
+ testID='tile'
106
+ >
107
+ <TileSpot appearance='icon' icon={Settings} />
108
+ <TileContent>
109
+ <TileTitle>Test Title</TileTitle>
110
+ </TileContent>
111
+ </Tile>
112
+ </TestWrapper>,
113
+ );
146
114
 
147
- it('should support both onPress and onLongPress', () => {
148
- const handlePress = jest.fn();
149
- const handleLongPress = jest.fn();
150
- const { getByTestId } = render(
151
- <TestWrapper>
152
- <Tile
153
- leadingContent={mockSpot}
154
- title={mockTitle}
155
- onPress={handlePress}
156
- onLongPress={handleLongPress}
157
- testID='tile'
158
- />
159
- </TestWrapper>,
160
- );
161
-
162
- fireEvent.press(getByTestId('tile'));
163
- expect(handlePress).toHaveBeenCalledTimes(1);
164
- expect(handleLongPress).not.toHaveBeenCalled();
165
-
166
- fireEvent(getByTestId('tile'), 'onLongPress');
167
- expect(handleLongPress).toHaveBeenCalledTimes(1);
168
- expect(handlePress).toHaveBeenCalledTimes(1); // Should still be 1
169
- });
170
-
171
- it('should forward testID prop to Pressable', () => {
172
- const testId = 'custom-tile-id';
173
- const { getByTestId } = render(
174
- <TestWrapper>
175
- <Tile leadingContent={mockSpot} title={mockTitle} testID={testId} />
176
- </TestWrapper>,
177
- );
178
-
179
- expect(getByTestId(testId)).toBeTruthy();
180
- });
115
+ fireEvent.press(getByTestId('tile'));
116
+ expect(handlePress).toHaveBeenCalledTimes(1);
117
+ expect(handleLongPress).not.toHaveBeenCalled();
181
118
 
182
- it('should forward additional Pressable props', () => {
183
- const { getByTestId } = render(
184
- <TestWrapper>
185
- <Tile
186
- leadingContent={mockSpot}
187
- title={mockTitle}
188
- testID='tile'
189
- disabled={true}
190
- />
191
- </TestWrapper>,
192
- );
193
-
194
- const pressable = getByTestId('tile');
195
- expect(pressable.props.accessibilityState?.disabled).toBe(true);
119
+ fireEvent(getByTestId('tile'), 'onLongPress');
120
+ expect(handleLongPress).toHaveBeenCalledTimes(1);
121
+ expect(handlePress).toHaveBeenCalledTimes(1);
122
+ });
196
123
  });
197
124
 
198
- it('should support custom accessibility label', () => {
199
- const customLabel = 'Custom accessibility label';
200
- const { getByTestId } = render(
201
- <TestWrapper>
202
- <Tile
203
- leadingContent={mockSpot}
204
- title={mockTitle}
205
- testID='tile'
206
- accessibilityLabel={customLabel}
207
- />
208
- </TestWrapper>,
209
- );
210
-
211
- const pressable = getByTestId('tile');
212
- expect(pressable.props.accessibilityLabel).toBe(customLabel);
125
+ describe('Context Propagation', () => {
126
+ it('should propagate disabled state to TileSpot', () => {
127
+ const { getByTestId } = render(
128
+ <TestWrapper>
129
+ <Tile disabled testID='tile'>
130
+ <TileSpot appearance='icon' icon={Settings} />
131
+ <TileContent>
132
+ <TileTitle>Test Title</TileTitle>
133
+ </TileContent>
134
+ </Tile>
135
+ </TestWrapper>,
136
+ );
137
+
138
+ const pressable = getByTestId('tile');
139
+ expect(pressable.props.accessibilityState?.disabled).toBe(true);
140
+ });
141
+
142
+ it('should propagate disabled state to text components', () => {
143
+ const { getByText } = render(
144
+ <TestWrapper>
145
+ <Tile disabled testID='tile'>
146
+ <TileSpot appearance='icon' icon={Settings} />
147
+ <TileContent>
148
+ <TileTitle>Test Title</TileTitle>
149
+ <TileDescription>Test Description</TileDescription>
150
+ </TileContent>
151
+ </Tile>
152
+ </TestWrapper>,
153
+ );
154
+
155
+ expect(getByText('Test Title')).toBeTruthy();
156
+ expect(getByText('Test Description')).toBeTruthy();
157
+ });
213
158
  });
214
159
 
215
- it('should render complex leadingContent', () => {
216
- const customLeading = (
217
- <Text testID='custom-leading'>Custom Leading Content</Text>
218
- );
219
- const { getByTestId } = render(
220
- <TestWrapper>
221
- <Tile leadingContent={customLeading} title={mockTitle} testID='tile' />
222
- </TestWrapper>,
223
- );
224
-
225
- expect(getByTestId('custom-leading')).toBeTruthy();
160
+ describe('Accessibility', () => {
161
+ it('should support custom accessibility label', () => {
162
+ const customLabel = 'Custom accessibility label';
163
+ const { getByTestId } = render(
164
+ <TestWrapper>
165
+ <Tile testID='tile' accessibilityLabel={customLabel}>
166
+ <TileSpot appearance='icon' icon={Settings} />
167
+ <TileContent>
168
+ <TileTitle>Test Title</TileTitle>
169
+ </TileContent>
170
+ </Tile>
171
+ </TestWrapper>,
172
+ );
173
+
174
+ const pressable = getByTestId('tile');
175
+ expect(pressable.props.accessibilityLabel).toBe(customLabel);
176
+ });
177
+
178
+ it('should set accessibility role to button', () => {
179
+ const { getByTestId } = render(
180
+ <TestWrapper>
181
+ <Tile testID='tile'>
182
+ <TileSpot appearance='icon' icon={Settings} />
183
+ <TileContent>
184
+ <TileTitle>Test Title</TileTitle>
185
+ </TileContent>
186
+ </Tile>
187
+ </TestWrapper>,
188
+ );
189
+
190
+ const pressable = getByTestId('tile');
191
+ expect(pressable.props.accessibilityRole).toBe('button');
192
+ });
226
193
  });
227
194
 
228
- it('should render with all optional props provided', () => {
229
- const description = 'Full description';
230
- const tagText = 'Tag Label';
231
- const mockTag = <Tag label={tagText} />;
232
-
233
- const { getByText, getByTestId } = render(
234
- <TestWrapper>
235
- <Tile
236
- leadingContent={mockSpot}
237
- title={mockTitle}
238
- description={description}
239
- trailingContent={mockTag}
240
- onPress={jest.fn()}
241
- onLongPress={jest.fn()}
242
- testID='tile'
243
- />
244
- </TestWrapper>,
245
- );
246
-
247
- expect(getByTestId('tile')).toBeTruthy();
248
- expect(getByText(mockTitle)).toBeTruthy();
249
- expect(getByText(description)).toBeTruthy();
250
- expect(getByText(tagText)).toBeTruthy();
195
+ describe('Complex Scenarios', () => {
196
+ it('should render with all features combined', () => {
197
+ const description = 'Full description';
198
+ const tagText = 'Tag Label';
199
+
200
+ const { getByText, getByTestId } = render(
201
+ <TestWrapper>
202
+ <Tile
203
+ appearance='card'
204
+ onPress={jest.fn()}
205
+ onLongPress={jest.fn()}
206
+ testID='tile'
207
+ >
208
+ <TileSpot appearance='icon' icon={Settings} />
209
+ <TileContent>
210
+ <TileTitle>Test Title</TileTitle>
211
+ <TileDescription>{description}</TileDescription>
212
+ </TileContent>
213
+ <Tag label={tagText} />
214
+ </Tile>
215
+ </TestWrapper>,
216
+ );
217
+
218
+ expect(getByTestId('tile')).toBeTruthy();
219
+ expect(getByText('Test Title')).toBeTruthy();
220
+ expect(getByText(description)).toBeTruthy();
221
+ expect(getByText(tagText)).toBeTruthy();
222
+ });
251
223
  });
252
224
  });