@ledgerhq/lumen-ui-rnative 0.1.49 → 0.1.50

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 (118) hide show
  1. package/dist/module/lib/Components/BaseInput/BaseInput.js +84 -25
  2. package/dist/module/lib/Components/BaseInput/BaseInput.js.map +1 -1
  3. package/dist/module/lib/Components/Button/ButtonGroup.figma.js +19 -0
  4. package/dist/module/lib/Components/Button/ButtonGroup.figma.js.map +1 -0
  5. package/dist/module/lib/Components/DescriptionItem/DescriptionItem.js +31 -9
  6. package/dist/module/lib/Components/DescriptionItem/DescriptionItem.js.map +1 -1
  7. package/dist/module/lib/Components/DescriptionItem/DescriptionItem.mdx +10 -7
  8. package/dist/module/lib/Components/DescriptionItem/DescriptionItem.stories.js +29 -40
  9. package/dist/module/lib/Components/DescriptionItem/DescriptionItem.stories.js.map +1 -1
  10. package/dist/module/lib/Components/DescriptionItem/DescriptionItem.test.js +22 -0
  11. package/dist/module/lib/Components/DescriptionItem/DescriptionItem.test.js.map +1 -1
  12. package/dist/module/lib/Components/ListItem/ListItem.figma.js +11 -0
  13. package/dist/module/lib/Components/ListItem/ListItem.figma.js.map +1 -1
  14. package/dist/module/lib/Components/ListItem/ListItem.js +78 -20
  15. package/dist/module/lib/Components/ListItem/ListItem.js.map +1 -1
  16. package/dist/module/lib/Components/ListItem/ListItem.mdx +17 -0
  17. package/dist/module/lib/Components/ListItem/ListItem.stories.js +132 -0
  18. package/dist/module/lib/Components/ListItem/ListItem.stories.js.map +1 -1
  19. package/dist/module/lib/Components/ListItem/ListItem.test.js +80 -0
  20. package/dist/module/lib/Components/ListItem/ListItem.test.js.map +1 -1
  21. package/dist/module/lib/Components/SectionHeader/SectionHeader.figma.js +22 -0
  22. package/dist/module/lib/Components/SectionHeader/SectionHeader.figma.js.map +1 -0
  23. package/dist/module/lib/Components/SectionHeader/SectionHeader.js +99 -0
  24. package/dist/module/lib/Components/SectionHeader/SectionHeader.js.map +1 -0
  25. package/dist/module/lib/Components/SectionHeader/SectionHeader.mdx +79 -0
  26. package/dist/module/lib/Components/SectionHeader/SectionHeader.stories.js +104 -0
  27. package/dist/module/lib/Components/SectionHeader/SectionHeader.stories.js.map +1 -0
  28. package/dist/module/lib/Components/SectionHeader/SectionHeader.test.js +108 -0
  29. package/dist/module/lib/Components/SectionHeader/SectionHeader.test.js.map +1 -0
  30. package/dist/module/lib/Components/SectionHeader/index.js +5 -0
  31. package/dist/module/lib/Components/SectionHeader/index.js.map +1 -0
  32. package/dist/module/lib/Components/SectionHeader/types.js +4 -0
  33. package/dist/module/lib/Components/SectionHeader/types.js.map +1 -0
  34. package/dist/module/lib/Components/TextInput/TextInput.figma.js +5 -0
  35. package/dist/module/lib/Components/TextInput/TextInput.figma.js.map +1 -1
  36. package/dist/module/lib/Components/TextInput/TextInput.mdx +43 -73
  37. package/dist/module/lib/Components/TextInput/TextInput.stories.js +58 -1
  38. package/dist/module/lib/Components/TextInput/TextInput.stories.js.map +1 -1
  39. package/dist/module/lib/Components/TextInput/TextInput.test.js +45 -1
  40. package/dist/module/lib/Components/TextInput/TextInput.test.js.map +1 -1
  41. package/dist/module/lib/Components/TileButton/TileButton.figma.js +5 -0
  42. package/dist/module/lib/Components/TileButton/TileButton.figma.js.map +1 -1
  43. package/dist/module/lib/Components/TileButton/TileButton.js +39 -27
  44. package/dist/module/lib/Components/TileButton/TileButton.js.map +1 -1
  45. package/dist/module/lib/Components/TileButton/TileButton.mdx +10 -1
  46. package/dist/module/lib/Components/TileButton/TileButton.stories.js +33 -2
  47. package/dist/module/lib/Components/TileButton/TileButton.stories.js.map +1 -1
  48. package/dist/module/lib/Components/TileButton/TileButton.test.js +26 -0
  49. package/dist/module/lib/Components/TileButton/TileButton.test.js.map +1 -1
  50. package/dist/module/lib/Components/index.js +1 -0
  51. package/dist/module/lib/Components/index.js.map +1 -1
  52. package/dist/module/lib/Symbols/Icons/Upload.js +50 -0
  53. package/dist/module/lib/Symbols/Icons/Upload.js.map +1 -0
  54. package/dist/module/lib/Symbols/index.js +1 -0
  55. package/dist/module/lib/Symbols/index.js.map +1 -1
  56. package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts +1 -1
  57. package/dist/typescript/src/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
  58. package/dist/typescript/src/lib/Components/BaseInput/types.d.ts +16 -0
  59. package/dist/typescript/src/lib/Components/BaseInput/types.d.ts.map +1 -1
  60. package/dist/typescript/src/lib/Components/DescriptionItem/DescriptionItem.d.ts +1 -1
  61. package/dist/typescript/src/lib/Components/DescriptionItem/DescriptionItem.d.ts.map +1 -1
  62. package/dist/typescript/src/lib/Components/DescriptionItem/types.d.ts +6 -0
  63. package/dist/typescript/src/lib/Components/DescriptionItem/types.d.ts.map +1 -1
  64. package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts +1 -1
  65. package/dist/typescript/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
  66. package/dist/typescript/src/lib/Components/ListItem/types.d.ts +11 -1
  67. package/dist/typescript/src/lib/Components/ListItem/types.d.ts.map +1 -1
  68. package/dist/typescript/src/lib/Components/SectionHeader/SectionHeader.d.ts +20 -0
  69. package/dist/typescript/src/lib/Components/SectionHeader/SectionHeader.d.ts.map +1 -0
  70. package/dist/typescript/src/lib/Components/SectionHeader/index.d.ts +3 -0
  71. package/dist/typescript/src/lib/Components/SectionHeader/index.d.ts.map +1 -0
  72. package/dist/typescript/src/lib/Components/SectionHeader/types.d.ts +27 -0
  73. package/dist/typescript/src/lib/Components/SectionHeader/types.d.ts.map +1 -0
  74. package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts +1 -1
  75. package/dist/typescript/src/lib/Components/TileButton/TileButton.d.ts.map +1 -1
  76. package/dist/typescript/src/lib/Components/TileButton/types.d.ts +5 -0
  77. package/dist/typescript/src/lib/Components/TileButton/types.d.ts.map +1 -1
  78. package/dist/typescript/src/lib/Components/index.d.ts +1 -0
  79. package/dist/typescript/src/lib/Components/index.d.ts.map +1 -1
  80. package/dist/typescript/src/lib/Symbols/Icons/Upload.d.ts +35 -0
  81. package/dist/typescript/src/lib/Symbols/Icons/Upload.d.ts.map +1 -0
  82. package/dist/typescript/src/lib/Symbols/index.d.ts +1 -0
  83. package/dist/typescript/src/lib/Symbols/index.d.ts.map +1 -1
  84. package/package.json +3 -3
  85. package/src/lib/Components/BaseInput/BaseInput.tsx +93 -22
  86. package/src/lib/Components/BaseInput/types.ts +18 -0
  87. package/src/lib/Components/Button/ButtonGroup.figma.tsx +15 -0
  88. package/src/lib/Components/DescriptionItem/DescriptionItem.mdx +10 -7
  89. package/src/lib/Components/DescriptionItem/DescriptionItem.stories.tsx +21 -41
  90. package/src/lib/Components/DescriptionItem/DescriptionItem.test.tsx +24 -0
  91. package/src/lib/Components/DescriptionItem/DescriptionItem.tsx +31 -8
  92. package/src/lib/Components/DescriptionItem/types.ts +6 -0
  93. package/src/lib/Components/ListItem/ListItem.figma.tsx +43 -8
  94. package/src/lib/Components/ListItem/ListItem.mdx +17 -0
  95. package/src/lib/Components/ListItem/ListItem.stories.tsx +92 -0
  96. package/src/lib/Components/ListItem/ListItem.test.tsx +78 -0
  97. package/src/lib/Components/ListItem/ListItem.tsx +64 -19
  98. package/src/lib/Components/ListItem/types.ts +11 -1
  99. package/src/lib/Components/SectionHeader/SectionHeader.figma.tsx +24 -0
  100. package/src/lib/Components/SectionHeader/SectionHeader.mdx +79 -0
  101. package/src/lib/Components/SectionHeader/SectionHeader.stories.tsx +95 -0
  102. package/src/lib/Components/SectionHeader/SectionHeader.test.tsx +103 -0
  103. package/src/lib/Components/SectionHeader/SectionHeader.tsx +125 -0
  104. package/src/lib/Components/SectionHeader/index.ts +6 -0
  105. package/src/lib/Components/SectionHeader/types.ts +30 -0
  106. package/src/lib/Components/TextInput/TextInput.figma.tsx +6 -1
  107. package/src/lib/Components/TextInput/TextInput.mdx +43 -73
  108. package/src/lib/Components/TextInput/TextInput.stories.tsx +57 -1
  109. package/src/lib/Components/TextInput/TextInput.test.tsx +60 -1
  110. package/src/lib/Components/TileButton/TileButton.figma.tsx +5 -0
  111. package/src/lib/Components/TileButton/TileButton.mdx +10 -1
  112. package/src/lib/Components/TileButton/TileButton.stories.tsx +28 -4
  113. package/src/lib/Components/TileButton/TileButton.test.tsx +35 -1
  114. package/src/lib/Components/TileButton/TileButton.tsx +47 -28
  115. package/src/lib/Components/TileButton/types.ts +5 -0
  116. package/src/lib/Components/index.ts +1 -0
  117. package/src/lib/Symbols/Icons/Upload.tsx +45 -0
  118. package/src/lib/Symbols/index.ts +1 -0
@@ -1,4 +1,4 @@
1
- import { createSafeContext } from '@ledgerhq/lumen-utils-shared';
1
+ import { createSafeContext, type Priority } from '@ledgerhq/lumen-utils-shared';
2
2
  import { StyleSheet } from 'react-native';
3
3
  import { useStyleSheet } from '../../../styles';
4
4
  import { Box, Text } from '../Utility';
@@ -20,6 +20,11 @@ const [DescriptionItemSizeProvider, useDescriptionItemSizeContext] =
20
20
  size: 'md',
21
21
  });
22
22
 
23
+ const [DescriptionItemPriorityProvider, useDescriptionItemPriorityContext] =
24
+ createSafeContext<{ priority?: Priority }>('DescriptionItemPriority', {
25
+ priority: undefined,
26
+ });
27
+
23
28
  /**
24
29
  * A compound component for displaying a key-value description row.
25
30
  * Composed with DescriptionItemLeading / DescriptionItemLabel (key side)
@@ -42,6 +47,7 @@ export const DescriptionItem = ({
42
47
  lx = {},
43
48
  style,
44
49
  size = 'md',
50
+ priority = 'end',
45
51
  ...props
46
52
  }: DescriptionItemProps) => {
47
53
  const styles = useStyleSheet(
@@ -58,9 +64,15 @@ export const DescriptionItem = ({
58
64
 
59
65
  return (
60
66
  <DescriptionItemSizeProvider value={{ size }}>
61
- <Box lx={lx} style={StyleSheet.flatten([styles.root, style])} {...props}>
62
- {children}
63
- </Box>
67
+ <DescriptionItemPriorityProvider value={{ priority }}>
68
+ <Box
69
+ lx={lx}
70
+ style={StyleSheet.flatten([styles.root, style])}
71
+ {...props}
72
+ >
73
+ {children}
74
+ </Box>
75
+ </DescriptionItemPriorityProvider>
64
76
  </DescriptionItemSizeProvider>
65
77
  );
66
78
  };
@@ -75,17 +87,23 @@ export const DescriptionItemLeading = ({
75
87
  style,
76
88
  ...props
77
89
  }: DescriptionItemLeadingProps) => {
90
+ const { priority } = useDescriptionItemPriorityContext({
91
+ consumerName: 'DescriptionItemLeading',
92
+ contextRequired: false,
93
+ });
94
+
78
95
  const styles = useStyleSheet(
79
96
  (t) => ({
80
97
  leading: {
81
- flex: 1,
98
+ flexGrow: 1,
99
+ flexShrink: priority === 'end' ? 1 : 0,
82
100
  minWidth: 0,
83
101
  flexDirection: 'row',
84
102
  alignItems: 'center',
85
103
  gap: t.spacings.s4,
86
104
  },
87
105
  }),
88
- [],
106
+ [priority],
89
107
  );
90
108
 
91
109
  return (
@@ -151,17 +169,22 @@ export const DescriptionItemTrailing = ({
151
169
  style,
152
170
  ...props
153
171
  }: DescriptionItemTrailingProps) => {
172
+ const { priority } = useDescriptionItemPriorityContext({
173
+ consumerName: 'DescriptionItemTrailing',
174
+ contextRequired: false,
175
+ });
176
+
154
177
  const styles = useStyleSheet(
155
178
  (t) => ({
156
179
  trailing: {
157
- flexShrink: 0,
180
+ flexShrink: priority === 'start' ? 1 : 0,
158
181
  maxWidth: '80%',
159
182
  flexDirection: 'row',
160
183
  alignItems: 'center',
161
184
  gap: t.spacings.s4,
162
185
  },
163
186
  }),
164
- [],
187
+ [priority],
165
188
  );
166
189
 
167
190
  return (
@@ -1,3 +1,4 @@
1
+ import type { Priority } from '@ledgerhq/lumen-utils-shared';
1
2
  import type { ReactNode } from 'react';
2
3
  import type { StyledTextProps, StyledViewProps } from '../../../styles';
3
4
 
@@ -13,6 +14,11 @@ export type DescriptionItemProps = {
13
14
  * @default 'md'
14
15
  */
15
16
  size?: DescriptionItemSize;
17
+ /**
18
+ * The parts which are protected from shrinking and truncation when horizontal space is limited.
19
+ * @default 'end'
20
+ */
21
+ priority?: Priority;
16
22
  } & Omit<StyledViewProps, 'children'>;
17
23
 
18
24
  export type DescriptionItemLeadingProps = {
@@ -97,6 +97,9 @@ const commonProps = {
97
97
  disabled: figma.enum('state', {
98
98
  disabled: true,
99
99
  }),
100
+ active: figma.enum('state', {
101
+ active: true,
102
+ }),
100
103
  density: figma.enum('density', {
101
104
  compact: 'compact',
102
105
  expanded: 'expanded',
@@ -129,7 +132,11 @@ figma.connect(
129
132
  }),
130
133
  },
131
134
  example: (props) => (
132
- <ListItem disabled={props.disabled} density={props.density}>
135
+ <ListItem
136
+ disabled={props.disabled}
137
+ active={props.active}
138
+ density={props.density}
139
+ >
133
140
  <ListItemLeading>
134
141
  {props.checkbox}
135
142
  {props.leadingContent}
@@ -167,7 +174,11 @@ figma.connect(
167
174
  }),
168
175
  },
169
176
  example: (props) => (
170
- <ListItem disabled={props.disabled} density={props.density}>
177
+ <ListItem
178
+ disabled={props.disabled}
179
+ active={props.active}
180
+ density={props.density}
181
+ >
171
182
  <ListItemLeading>
172
183
  {props.checkbox}
173
184
  {props.leadingContent}
@@ -209,7 +220,11 @@ figma.connect(
209
220
  }),
210
221
  },
211
222
  example: (props) => (
212
- <ListItem disabled={props.disabled} density={props.density}>
223
+ <ListItem
224
+ disabled={props.disabled}
225
+ active={props.active}
226
+ density={props.density}
227
+ >
213
228
  <ListItemLeading>
214
229
  {props.checkbox}
215
230
  {props.leadingContent}
@@ -252,7 +267,11 @@ figma.connect(
252
267
  }),
253
268
  },
254
269
  example: (props) => (
255
- <ListItem disabled={props.disabled} density={props.density}>
270
+ <ListItem
271
+ disabled={props.disabled}
272
+ active={props.active}
273
+ density={props.density}
274
+ >
256
275
  <ListItemLeading>
257
276
  {props.checkbox}
258
277
  {props.leadingContent}
@@ -292,7 +311,11 @@ figma.connect(
292
311
  }),
293
312
  },
294
313
  example: (props) => (
295
- <ListItem disabled={props.disabled} density={props.density}>
314
+ <ListItem
315
+ disabled={props.disabled}
316
+ active={props.active}
317
+ density={props.density}
318
+ >
296
319
  <ListItemLeading>
297
320
  {props.checkbox}
298
321
  {props.leadingContent}
@@ -329,7 +352,11 @@ figma.connect(
329
352
  ...commonProps,
330
353
  },
331
354
  example: (props) => (
332
- <ListItem disabled={props.disabled} density={props.density}>
355
+ <ListItem
356
+ disabled={props.disabled}
357
+ active={props.active}
358
+ density={props.density}
359
+ >
333
360
  <ListItemLeading>
334
361
  {props.checkbox}
335
362
  {props.leadingContent}
@@ -369,7 +396,11 @@ figma.connect(
369
396
  }),
370
397
  },
371
398
  example: (props) => (
372
- <ListItem disabled={props.disabled} density={props.density}>
399
+ <ListItem
400
+ disabled={props.disabled}
401
+ active={props.active}
402
+ density={props.density}
403
+ >
373
404
  <ListItemLeading>
374
405
  {props.checkbox}
375
406
  {props.leadingContent}
@@ -411,7 +442,11 @@ figma.connect(
411
442
  ...commonProps,
412
443
  },
413
444
  example: (props) => (
414
- <ListItem disabled={props.disabled} density={props.density}>
445
+ <ListItem
446
+ disabled={props.disabled}
447
+ active={props.active}
448
+ density={props.density}
449
+ >
415
450
  <ListItemLeading>
416
451
  {props.checkbox}
417
452
  {props.leadingContent}
@@ -49,6 +49,17 @@ ListItems are flexible interactive elements designed for lists. They use a compo
49
49
 
50
50
  <Canvas of={ListItemStories.DensityShowcase} />
51
51
 
52
+ ### Priority
53
+
54
+ When horizontal space is constrained and both the leading and trailing sides have long content, the `priority` prop controls which side is protected from shrinking and truncation.
55
+
56
+ - `priority='end'` (default): the leading side (title/description) shrinks and truncates, while the trailing content keeps its natural size.
57
+ - `priority='start'`: the trailing content shrinks and truncates, while the leading side is protected.
58
+
59
+ > **Platform note:** On native, the protected side truncates with an ellipsis. On web (react-native-web), CSS flexbox will not shrink a protected item below its content width, so it is clipped by the container instead of showing an ellipsis. This is a rendering difference only - the behavior is correct on device.
60
+
61
+ <Canvas of={ListItemStories.PriorityShowcase} />
62
+
52
63
  ### Interactivity
53
64
 
54
65
  The ListItem can be interactive or non-interactive. By default, the ListItem is non-interactive. To make it interactive, you need to pass an `onPress` prop.
@@ -61,6 +72,12 @@ When disabled, the ListItem becomes non-interactive. The disabled state is autom
61
72
 
62
73
  <Canvas of={ListItemStories.DisabledState} />
63
74
 
75
+ ### Active State
76
+
77
+ When `active` is `true`, the background uses the muted token to indicate a selected or highlighted item.
78
+
79
+ <Canvas of={ListItemStories.ActiveState} />
80
+
64
81
  ### Responsive Layout
65
82
 
66
83
  ListItems adapt to their container width, truncating long titles and descriptions as needed.
@@ -323,6 +323,50 @@ export const DisabledState: Story = {
323
323
  },
324
324
  };
325
325
 
326
+ export const ActiveState: Story = {
327
+ args: {
328
+ active: true,
329
+ },
330
+ render: (args) => (
331
+ <Box lx={{ flexDirection: 'column', width: 's320', gap: 's8' }}>
332
+ <ListItem {...args}>
333
+ <ListItemLeading>
334
+ <Spot size={48} appearance='icon' icon={Settings} />
335
+ <ListItemContent>
336
+ <ListItemTitle>Active Item</ListItemTitle>
337
+ <ListItemDescription>
338
+ Static with muted background
339
+ </ListItemDescription>
340
+ </ListItemContent>
341
+ </ListItemLeading>
342
+ </ListItem>
343
+
344
+ <ListItem {...args} onPress={() => {}}>
345
+ <ListItemLeading>
346
+ <Spot size={48} appearance='icon' icon={Settings} />
347
+ <ListItemContent>
348
+ <ListItemTitle>Active Interactive</ListItemTitle>
349
+ <ListItemDescription>Press for muted-pressed</ListItemDescription>
350
+ </ListItemContent>
351
+ </ListItemLeading>
352
+ <ListItemTrailing>
353
+ <ChevronRight size={24} />
354
+ </ListItemTrailing>
355
+ </ListItem>
356
+
357
+ <ListItem {...args} disabled>
358
+ <ListItemLeading>
359
+ <Spot size={48} appearance='icon' icon={Wallet} />
360
+ <ListItemContent>
361
+ <ListItemTitle>Active Disabled</ListItemTitle>
362
+ <ListItemDescription>Uses disabled background</ListItemDescription>
363
+ </ListItemContent>
364
+ </ListItemLeading>
365
+ </ListItem>
366
+ </Box>
367
+ ),
368
+ };
369
+
326
370
  export const ResponsiveLayout: Story = {
327
371
  render: () => (
328
372
  <Box lx={{ flexDirection: 'column', width: 's480', gap: 's32' }}>
@@ -402,6 +446,54 @@ export const ResponsiveLayout: Story = {
402
446
  ),
403
447
  };
404
448
 
449
+ export const PriorityShowcase: Story = {
450
+ render: () => (
451
+ <Box lx={{ flexDirection: 'column', width: 's320', gap: 's8' }}>
452
+ <Text typography='body4SemiBold' lx={{ color: 'muted' }}>
453
+ priority="end" (default)
454
+ </Text>
455
+ <ListItem priority='end'>
456
+ <ListItemLeading>
457
+ <Spot size={48} appearance='icon' icon={Wallet} />
458
+ <ListItemContent>
459
+ <ListItemTitle>
460
+ Long title competing with trailing value content
461
+ </ListItemTitle>
462
+ <ListItemDescription>priority="end"</ListItemDescription>
463
+ </ListItemContent>
464
+ </ListItemLeading>
465
+ <ListItemTrailing>
466
+ <ListItemContent>
467
+ <ListItemTitle>1,234,567,891,234.56</ListItemTitle>
468
+ <ListItemDescription>USD</ListItemDescription>
469
+ </ListItemContent>
470
+ </ListItemTrailing>
471
+ </ListItem>
472
+
473
+ <Text typography='body4SemiBold' lx={{ color: 'muted' }}>
474
+ priority="start"
475
+ </Text>
476
+ <ListItem priority='start'>
477
+ <ListItemLeading>
478
+ <Spot size={48} appearance='icon' icon={Wallet} />
479
+ <ListItemContent>
480
+ <ListItemTitle>
481
+ Long title competing with trailing value content
482
+ </ListItemTitle>
483
+ <ListItemDescription>priority="start"</ListItemDescription>
484
+ </ListItemContent>
485
+ </ListItemLeading>
486
+ <ListItemTrailing>
487
+ <ListItemContent>
488
+ <ListItemTitle>1,234,567,891,234.56</ListItemTitle>
489
+ <ListItemDescription>USD</ListItemDescription>
490
+ </ListItemContent>
491
+ </ListItemTrailing>
492
+ </ListItem>
493
+ </Box>
494
+ ),
495
+ };
496
+
405
497
  export const CompositionShowcase: Story = {
406
498
  render: () => (
407
499
  <Box lx={{ flexDirection: 'column', maxWidth: 's320', gap: 's8' }}>
@@ -109,6 +109,38 @@ describe('ListItem', () => {
109
109
  });
110
110
  });
111
111
 
112
+ describe('active', () => {
113
+ it('applies muted background when active', () => {
114
+ renderListItem({ active: true });
115
+ const inner = screen.getByTestId('list-item-content');
116
+ expect(inner.props.style.backgroundColor).not.toBe('transparent');
117
+ });
118
+
119
+ it('applies disabled background when active and disabled', () => {
120
+ renderListItem({ active: true, disabled: true });
121
+ const inner = screen.getByTestId('list-item-content');
122
+ expect(inner.props.style.backgroundColor).not.toBe('transparent');
123
+ });
124
+
125
+ it('uses transparent background when not active', () => {
126
+ renderListItem();
127
+ const inner = screen.getByTestId('list-item-content');
128
+ expect(inner.props.style.backgroundColor).toBe('transparent');
129
+ });
130
+
131
+ it('sets selected accessibility state when active', () => {
132
+ renderListItem({ active: true });
133
+ const item = screen.getByTestId('list-item');
134
+ expect(item.props.accessibilityState?.selected).toBe(true);
135
+ });
136
+
137
+ it('does not set selected accessibility state when not active', () => {
138
+ renderListItem();
139
+ const item = screen.getByTestId('list-item');
140
+ expect(item.props.accessibilityState?.selected).toBeFalsy();
141
+ });
142
+ });
143
+
112
144
  describe('disabled', () => {
113
145
  it('sets disabled accessibility state', () => {
114
146
  renderListItem({ disabled: true });
@@ -125,6 +157,52 @@ describe('ListItem', () => {
125
157
  });
126
158
  });
127
159
 
160
+ describe('priority', () => {
161
+ const renderWithPriority = (priority?: ListItemProps['priority']) =>
162
+ render(
163
+ <TestWrapper>
164
+ <ListItem priority={priority}>
165
+ <ListItemLeading testID='leading'>
166
+ <ListItemContent testID='content'>
167
+ <ListItemTitle>Title</ListItemTitle>
168
+ </ListItemContent>
169
+ </ListItemLeading>
170
+ <ListItemTrailing testID='trailing'>
171
+ <RNText>Trailing</RNText>
172
+ </ListItemTrailing>
173
+ </ListItem>
174
+ </TestWrapper>,
175
+ );
176
+
177
+ it('in "end" priority, leading shrinks, trailing shows', () => {
178
+ renderWithPriority();
179
+
180
+ expect(screen.getByTestId('leading').props.style).toEqual(
181
+ expect.objectContaining({ flexShrink: 1 }),
182
+ );
183
+ expect(screen.getByTestId('content').props.style).toEqual(
184
+ expect.objectContaining({ flex: 1 }),
185
+ );
186
+ expect(screen.getByTestId('trailing').props.style).not.toEqual(
187
+ expect.objectContaining({ flexShrink: 1 }),
188
+ );
189
+ });
190
+
191
+ it('in "start" priority, trailing shrinks, leading shows', () => {
192
+ renderWithPriority('start');
193
+
194
+ expect(screen.getByTestId('leading').props.style).not.toEqual(
195
+ expect.objectContaining({ flexShrink: 1 }),
196
+ );
197
+ expect(screen.getByTestId('content').props.style).toEqual(
198
+ expect.objectContaining({ flex: 0, flexShrink: 1 }),
199
+ );
200
+ expect(screen.getByTestId('trailing').props.style).toEqual(
201
+ expect.objectContaining({ flexShrink: 1 }),
202
+ );
203
+ });
204
+ });
205
+
128
206
  describe('ListItemContentRow', () => {
129
207
  it('renders title alongside additional content in a row', () => {
130
208
  render(
@@ -2,6 +2,7 @@ import {
2
2
  createSafeContext,
3
3
  type Density,
4
4
  DisabledProvider,
5
+ type Priority,
5
6
  useDisabledContext,
6
7
  } from '@ledgerhq/lumen-utils-shared';
7
8
  import type { ComponentRef, ReactNode, Ref } from 'react';
@@ -24,12 +25,21 @@ const [ListItemTrailingProvider, useListItemTrailingContext] =
24
25
  isInTrailing: false,
25
26
  });
26
27
 
28
+ const [ListItemPriorityProvider, useListItemPriorityContext] =
29
+ createSafeContext<{ priority?: Priority }>('ListItemPriority', {
30
+ priority: undefined,
31
+ });
32
+
27
33
  const useRootStyles = ({
28
34
  pressed,
29
35
  density,
36
+ active,
37
+ disabled,
30
38
  }: {
31
39
  pressed: boolean;
32
40
  density: Density;
41
+ active: boolean;
42
+ disabled: boolean;
33
43
  }) => {
34
44
  return useStyleSheet(
35
45
  (t) => ({
@@ -43,13 +53,15 @@ const useRootStyles = ({
43
53
  borderRadius: t.borderRadius.md,
44
54
  backgroundColor: 'transparent',
45
55
  paddingHorizontal: t.spacings.s8,
56
+ overflow: 'hidden',
46
57
  },
47
- pressed && {
48
- backgroundColor: t.colors.bg.baseTransparentPressed,
49
- },
58
+ pressed && { backgroundColor: t.colors.bg.baseTransparentPressed },
59
+ active && { backgroundColor: t.colors.bg.muted },
60
+ active && pressed && { backgroundColor: t.colors.bg.mutedPressed },
61
+ active && disabled && { backgroundColor: t.colors.bg.disabled },
50
62
  ]),
51
63
  }),
52
- [pressed, density],
64
+ [pressed, density, active, disabled],
53
65
  );
54
66
  };
55
67
 
@@ -93,6 +105,8 @@ export const ListItem = ({
93
105
  style,
94
106
  disabled: disabledProp = false,
95
107
  density = 'expanded',
108
+ priority = 'end',
109
+ active = false,
96
110
  onPress,
97
111
  onLongPress,
98
112
  ref,
@@ -116,13 +130,19 @@ export const ListItem = ({
116
130
  onPress={onPress}
117
131
  onLongPress={onLongPress}
118
132
  accessibilityRole='button'
119
- accessibilityState={{ disabled }}
133
+ accessibilityState={{ disabled, selected: active }}
120
134
  {...props}
121
135
  >
122
136
  {({ pressed }) => (
123
- <ListItemInner pressed={pressed} density={density}>
124
- {children}
125
- </ListItemInner>
137
+ <ListItemPriorityProvider value={{ priority }}>
138
+ <ListItemInner
139
+ pressed={pressed}
140
+ density={density}
141
+ active={active}
142
+ >
143
+ {children}
144
+ </ListItemInner>
145
+ </ListItemPriorityProvider>
126
146
  )}
127
147
  </Pressable>
128
148
  </DisabledProvider>
@@ -135,12 +155,14 @@ export const ListItem = ({
135
155
  ref={ref}
136
156
  lx={lx}
137
157
  style={style}
138
- accessibilityState={{ disabled }}
158
+ accessibilityState={{ disabled, selected: active }}
139
159
  {...props}
140
160
  >
141
- <ListItemInner pressed={false} density={density}>
142
- {children}
143
- </ListItemInner>
161
+ <ListItemPriorityProvider value={{ priority }}>
162
+ <ListItemInner pressed={false} density={density} active={active}>
163
+ {children}
164
+ </ListItemInner>
165
+ </ListItemPriorityProvider>
144
166
  </Box>
145
167
  </DisabledProvider>
146
168
  );
@@ -152,13 +174,19 @@ export const ListItem = ({
152
174
  const ListItemInner = ({
153
175
  pressed,
154
176
  density,
177
+ active,
155
178
  children,
156
179
  }: {
157
180
  pressed: boolean;
158
181
  density: Density;
182
+ active: boolean;
159
183
  children: ReactNode;
160
184
  }) => {
161
- const styles = useRootStyles({ pressed, density });
185
+ const disabled = useDisabledContext({
186
+ consumerName: 'ListItemInner',
187
+ contextRequired: false,
188
+ });
189
+ const styles = useRootStyles({ pressed, density, active, disabled });
162
190
  return (
163
191
  <View style={styles.container} testID='list-item-content'>
164
192
  {children}
@@ -177,17 +205,23 @@ export const ListItemLeading = ({
177
205
  ref,
178
206
  ...props
179
207
  }: ListItemLeadingProps & { ref?: Ref<View> }) => {
208
+ const { priority } = useListItemPriorityContext({
209
+ consumerName: 'ListItemLeading',
210
+ contextRequired: false,
211
+ });
212
+
180
213
  const styles = useStyleSheet(
181
214
  (t) => ({
182
215
  leading: {
183
- flex: 1,
216
+ flexGrow: 1,
217
+ flexShrink: priority === 'end' ? 1 : 0,
184
218
  minWidth: 0,
185
219
  flexDirection: 'row',
186
220
  alignItems: 'center',
187
221
  gap: t.spacings.s12,
188
222
  },
189
223
  }),
190
- [],
224
+ [priority],
191
225
  );
192
226
 
193
227
  return (
@@ -217,16 +251,22 @@ export const ListItemContent = ({
217
251
  contextRequired: false,
218
252
  });
219
253
 
254
+ const { priority } = useListItemPriorityContext({
255
+ consumerName: 'ListItemContent',
256
+ contextRequired: false,
257
+ });
258
+
220
259
  const styles = useStyleSheet(
221
260
  (t) => ({
222
261
  content: {
223
- flex: isInTrailing ? 0 : 1,
262
+ flex: isInTrailing || priority === 'start' ? 0 : 1,
263
+ ...(priority === 'start' && { flexShrink: 1, flexBasis: 'auto' }),
224
264
  minWidth: 0,
225
265
  gap: t.spacings.s4,
226
266
  alignItems: isInTrailing ? 'flex-end' : 'stretch',
227
267
  },
228
268
  }),
229
- [isInTrailing],
269
+ [priority, isInTrailing],
230
270
  );
231
271
 
232
272
  return (
@@ -386,14 +426,19 @@ export const ListItemTrailing = ({
386
426
  ref,
387
427
  ...props
388
428
  }: ListItemTrailingProps & { ref?: Ref<View> }) => {
429
+ const { priority } = useListItemPriorityContext({
430
+ consumerName: 'ListItemTrailing',
431
+ contextRequired: false,
432
+ });
433
+
389
434
  const styles = useStyleSheet(
390
435
  () => ({
391
436
  trailing: {
392
- flexShrink: 0,
437
+ flexShrink: priority === 'start' ? 1 : 0,
393
438
  alignItems: 'center',
394
439
  },
395
440
  }),
396
- [],
441
+ [priority],
397
442
  );
398
443
 
399
444
  return (
@@ -1,4 +1,4 @@
1
- import type { Density } from '@ledgerhq/lumen-utils-shared';
1
+ import type { Density, Priority } from '@ledgerhq/lumen-utils-shared';
2
2
  import type {
3
3
  StyledPressableProps,
4
4
  StyledTextProps,
@@ -18,10 +18,20 @@ export type ListItemProps = {
18
18
  * @default 'expanded'
19
19
  */
20
20
  density?: Density;
21
+ /**
22
+ * The parts which are protected from shrinking and truncation when horizontal space is limited.
23
+ * @default 'end'
24
+ */
25
+ priority?: Priority;
21
26
  /**
22
27
  * Whether the list item is disabled.
23
28
  */
24
29
  disabled?: boolean;
30
+ /**
31
+ * Whether the list item is in an active/selected state.
32
+ * @default false
33
+ */
34
+ active?: boolean;
25
35
  /**
26
36
  * Callback function when the list item is pressed.
27
37
  */
@@ -0,0 +1,24 @@
1
+ import figma from '@figma/code-connect';
2
+ import { SectionHeader, SectionHeaderTitle } from './SectionHeader';
3
+
4
+ figma.connect(
5
+ SectionHeader,
6
+ 'https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7?node-id=18640-48457',
7
+ {
8
+ imports: [
9
+ "import { SectionHeader, SectionHeaderTitle } from '@ledgerhq/lumen-ui-rnative'",
10
+ ],
11
+ props: {
12
+ appearance: figma.enum('appearance', {
13
+ 'no-background': 'no-background',
14
+ plain: 'plain',
15
+ }),
16
+ title: figma.string('label'),
17
+ },
18
+ example: (props) => (
19
+ <SectionHeader appearance={props.appearance}>
20
+ <SectionHeaderTitle>{props.title}</SectionHeaderTitle>
21
+ </SectionHeader>
22
+ ),
23
+ },
24
+ );