@ledgerhq/lumen-ui-rnative 0.0.46 → 0.0.47

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 (99) hide show
  1. package/dist/package.json +5 -1
  2. package/dist/src/lib/Components/Icon/Icon.d.ts.map +1 -1
  3. package/dist/src/lib/Components/Icon/Icon.js +3 -4
  4. package/dist/src/lib/Components/Icon/createIcon.d.ts.map +1 -1
  5. package/dist/src/lib/Components/Icon/createIcon.js +1 -1
  6. package/dist/src/lib/Components/ListItem/ListItem.d.ts +88 -34
  7. package/dist/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
  8. package/dist/src/lib/Components/ListItem/ListItem.js +242 -97
  9. package/dist/src/lib/Components/ListItem/ListItem.stories.d.ts +2 -3
  10. package/dist/src/lib/Components/ListItem/ListItem.stories.d.ts.map +1 -1
  11. package/dist/src/lib/Components/ListItem/ListItem.stories.js +63 -73
  12. package/dist/src/lib/Components/ListItem/index.d.ts +1 -1
  13. package/dist/src/lib/Components/ListItem/index.d.ts.map +1 -1
  14. package/dist/src/lib/Components/ListItem/index.js +1 -1
  15. package/dist/src/lib/Components/ListItem/types.d.ts +106 -0
  16. package/dist/src/lib/Components/ListItem/types.d.ts.map +1 -0
  17. package/dist/src/lib/Components/Spot/types.d.ts +1 -1
  18. package/dist/src/lib/Components/Spot/types.d.ts.map +1 -1
  19. package/dist/src/lib/utils/index.d.ts +3 -4
  20. package/dist/src/lib/utils/index.d.ts.map +1 -1
  21. package/dist/src/lib/utils/index.js +3 -4
  22. package/dist/src/lib/utils/react/{extract-text-from-children.d.ts → extractTextFromChildren.d.ts} +1 -1
  23. package/dist/src/lib/utils/react/extractTextFromChildren.d.ts.map +1 -0
  24. package/dist/src/lib/utils/react/index.d.ts +1 -1
  25. package/dist/src/lib/utils/react/index.d.ts.map +1 -1
  26. package/dist/src/lib/utils/react/index.js +1 -1
  27. package/dist/src/lib/utils/startTransition/index.d.ts +2 -0
  28. package/dist/src/lib/utils/startTransition/index.d.ts.map +1 -0
  29. package/dist/src/lib/utils/startTransition/index.js +1 -0
  30. package/dist/src/lib/utils/{start-transition/start-transition.d.ts → startTransition/startTransition.d.ts} +1 -1
  31. package/dist/src/lib/utils/startTransition/startTransition.d.ts.map +1 -0
  32. package/dist/src/lib/utils/useControllableState/index.d.ts +2 -0
  33. package/dist/src/lib/utils/useControllableState/index.d.ts.map +1 -0
  34. package/dist/src/lib/utils/useControllableState/index.js +1 -0
  35. package/dist/src/lib/utils/{use-controllable-state/use-controllable-state.d.ts → useControllableState/useControllableState.d.ts} +1 -1
  36. package/dist/src/lib/utils/useControllableState/useControllableState.d.ts.map +1 -0
  37. package/dist/src/lib/utils/{use-controllable-state/use-controllable-state.js → useControllableState/useControllableState.js} +2 -2
  38. package/dist/src/lib/utils/useEvent/index.d.ts +3 -0
  39. package/dist/src/lib/utils/useEvent/index.d.ts.map +1 -0
  40. package/dist/src/lib/utils/useEvent/index.js +2 -0
  41. package/dist/src/lib/utils/{use-event/use-event.d.ts → useEvent/useEvent.d.ts} +1 -1
  42. package/dist/src/lib/utils/useEvent/useEvent.d.ts.map +1 -0
  43. package/dist/src/lib/utils/{use-event/use-event.js → useEvent/useEvent.js} +1 -1
  44. package/dist/src/lib/utils/{use-event/use-get.d.ts → useEvent/useGet.d.ts} +1 -1
  45. package/dist/src/lib/utils/useEvent/useGet.d.ts.map +1 -0
  46. package/dist/src/styles/provider/LumenStyleSheetProvider.d.ts +1 -1
  47. package/dist/src/styles/provider/LumenStyleSheetProvider.d.ts.map +1 -1
  48. package/dist/src/styles/provider/LumenStyleSheetProvider.js +1 -2
  49. package/package.json +6 -2
  50. package/src/lib/Components/Checkbox/Checkbox.mdx +1 -0
  51. package/src/lib/Components/Icon/Icon.tsx +3 -5
  52. package/src/lib/Components/Icon/createIcon.ts +1 -1
  53. package/src/lib/Components/ListItem/ListItem.mdx +402 -124
  54. package/src/lib/Components/ListItem/ListItem.stories.tsx +357 -228
  55. package/src/lib/Components/ListItem/ListItem.tsx +437 -181
  56. package/src/lib/Components/ListItem/index.ts +1 -1
  57. package/src/lib/Components/ListItem/types.ts +121 -0
  58. package/src/lib/Components/Spot/types.ts +5 -1
  59. package/src/lib/Components/Switch/Switch.mdx +1 -0
  60. package/src/lib/utils/index.ts +3 -4
  61. package/src/lib/utils/react/index.ts +1 -1
  62. package/src/lib/utils/startTransition/index.ts +1 -0
  63. package/src/lib/utils/useControllableState/index.ts +1 -0
  64. package/src/lib/utils/{use-controllable-state/use-controllable-state.ts → useControllableState/useControllableState.ts} +2 -2
  65. package/src/lib/utils/useEvent/index.ts +2 -0
  66. package/src/lib/utils/{use-event/use-event.ts → useEvent/useEvent.ts} +1 -1
  67. package/src/styles/provider/LumenStyleSheetProvider.tsx +2 -3
  68. package/dist/src/lib/Components/ListItem/ListItem.types.d.ts +0 -31
  69. package/dist/src/lib/Components/ListItem/ListItem.types.d.ts.map +0 -1
  70. package/dist/src/lib/utils/react/extract-text-from-children.d.ts.map +0 -1
  71. package/dist/src/lib/utils/start-transition/index.d.ts +0 -2
  72. package/dist/src/lib/utils/start-transition/index.d.ts.map +0 -1
  73. package/dist/src/lib/utils/start-transition/index.js +0 -1
  74. package/dist/src/lib/utils/start-transition/start-transition.d.ts.map +0 -1
  75. package/dist/src/lib/utils/string-utils.d.ts +0 -6
  76. package/dist/src/lib/utils/string-utils.d.ts.map +0 -1
  77. package/dist/src/lib/utils/string-utils.js +0 -12
  78. package/dist/src/lib/utils/use-controllable-state/index.d.ts +0 -2
  79. package/dist/src/lib/utils/use-controllable-state/index.d.ts.map +0 -1
  80. package/dist/src/lib/utils/use-controllable-state/index.js +0 -1
  81. package/dist/src/lib/utils/use-controllable-state/use-controllable-state.d.ts.map +0 -1
  82. package/dist/src/lib/utils/use-event/index.d.ts +0 -3
  83. package/dist/src/lib/utils/use-event/index.d.ts.map +0 -1
  84. package/dist/src/lib/utils/use-event/index.js +0 -2
  85. package/dist/src/lib/utils/use-event/use-event.d.ts.map +0 -1
  86. package/dist/src/lib/utils/use-event/use-get.d.ts.map +0 -1
  87. package/src/lib/Components/ListItem/ListItem.types.ts +0 -31
  88. package/src/lib/utils/start-transition/index.ts +0 -1
  89. package/src/lib/utils/string-utils.test.ts +0 -73
  90. package/src/lib/utils/string-utils.ts +0 -11
  91. package/src/lib/utils/use-controllable-state/index.ts +0 -1
  92. package/src/lib/utils/use-event/index.ts +0 -2
  93. /package/dist/src/lib/Components/ListItem/{ListItem.types.js → types.js} +0 -0
  94. /package/dist/src/lib/utils/react/{extract-text-from-children.js → extractTextFromChildren.js} +0 -0
  95. /package/dist/src/lib/utils/{start-transition/start-transition.js → startTransition/startTransition.js} +0 -0
  96. /package/dist/src/lib/utils/{use-event/use-get.js → useEvent/useGet.js} +0 -0
  97. /package/src/lib/utils/react/{extract-text-from-children.ts → extractTextFromChildren.ts} +0 -0
  98. /package/src/lib/utils/{start-transition/start-transition.ts → startTransition/startTransition.ts} +0 -0
  99. /package/src/lib/utils/{use-event/use-get.ts → useEvent/useGet.ts} +0 -0
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/lumen-ui-rnative",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "license": "Apache-2.0",
5
5
  "keywords": [
6
6
  "react-native",
@@ -32,8 +32,12 @@
32
32
  "react-i18next": "^14.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
+ "@gorhom/bottom-sheet": "^5.0.0",
36
+ "@ledgerhq/lumen-design-core": "*",
35
37
  "react": "~18.3.1",
36
38
  "react-native": "~0.77.3",
39
+ "react-native-reanimated": "^3.0.0",
40
+ "react-native-safe-area-context": "^4.0.0 || ^5.0.0",
37
41
  "react-native-svg": "^15.0.0"
38
42
  },
39
43
  "nx": {
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Icon/Icon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAmC9C,eAAO,MAAM,IAAI;;;;;;uBAHsB,8DAGxB;+HAoBd,CAAC"}
1
+ {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Icon/Icon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiC9C,eAAO,MAAM,IAAI;;;;;;uBACM,8DAAoC;+HAmB1D,CAAC"}
@@ -13,8 +13,7 @@ const iconSizeMap = {
13
13
  };
14
14
  const useStyles = (lx, size, color) => {
15
15
  const { theme } = useTheme();
16
- const resolvedStyle = useResolveTextStyle(lx || {});
17
- const resolvedColor = useResolveTextStyle({ color });
16
+ const resolvedStyle = useResolveTextStyle({ ...(lx || {}), color });
18
17
  return useMemo(() => {
19
18
  return {
20
19
  container: {
@@ -23,9 +22,9 @@ const useStyles = (lx, size, color) => {
23
22
  height: theme.icon.height[iconSizeMap[size]],
24
23
  strokeWidth: theme.icon.borderWidth[iconSizeMap[size]],
25
24
  },
26
- color: resolvedColor.color || resolvedStyle.color || theme.colors.text.base,
25
+ color: resolvedStyle.color || theme.colors.text.base,
27
26
  };
28
- }, [size, theme, resolvedStyle, resolvedColor.color]);
27
+ }, [size, theme, resolvedStyle]);
29
28
  };
30
29
  export const Icon = forwardRef(({ size = 24, color, lx = {}, children, viewBox, ...props }, ref) => {
31
30
  const styles = useStyles(lx, size, color);
@@ -1 +1 @@
1
- {"version":3,"file":"createIcon.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Icon/createIcon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GACd,UAAU,MAAM,EAChB,SAAS,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,4FAetC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"createIcon.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Icon/createIcon.ts"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GACd,UAAU,MAAM,EAChB,SAAS,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,4FAetC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,5 +1,5 @@
1
+ import { toPascalCase } from '@ledgerhq/lumen-utils-shared';
1
2
  import React, { forwardRef } from 'react';
2
- import { toPascalCase } from '../../utils';
3
3
  import { Icon } from './Icon';
4
4
  /**
5
5
  * Create an Icon component for React Native
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
+ import { ListItemIconProps, ListItemSpotProps } from './types';
3
4
  /**
4
- * A flexible list item component that displays a required title and optional description (with possible tag), leading and trailing content.
5
- * It functions as a clickable button with hover and active states.
5
+ * A flexible list item component that provides a composable structure for displaying
6
+ * interactive list items with leading content, title, description, and trailing content.
6
7
  *
7
8
  * @see {@link https://ldls.vercel.app/?path=/docs/react-native_containment-listitem--docs Storybook}
8
9
  * @see {@link https://ldls.vercel.app/?path=/docs/react-native_containment-listitem--docs#dos-and-donts Guidelines}
@@ -11,40 +12,93 @@ import { View } from 'react-native';
11
12
  * Do not use it to modify the list item's core appearance (colors, padding, etc).
12
13
  *
13
14
  * @example
14
- * // Basic item
15
- * import { ListItem } from '@ledgerhq/lumen-ui-rnative';
15
+ * import {
16
+ * ListItem,
17
+ * ListItemLeading,
18
+ * ListItemSpot,
19
+ * ListItemContent,
20
+ * ListItemTitle,
21
+ * ListItemDescription,
22
+ * ListItemTrailing,
23
+ * } from '@ledgerhq/lumen-ui-rnative';
24
+ * import { Wallet, ChevronRight } from '@ledgerhq/lumen-ui-rnative/symbols';
16
25
  *
17
- * <ListItem
18
- * title="Basic Item"
19
- * description="Optional description"
20
- * onPress={() => console.log('Clicked!')}
21
- * />
22
- *
23
- * // Icon trailing content with leading Spot
24
- * import { ListItem, Spot } from '@ledgerhq/lumen-ui-rnative';
25
- * import { Wallet, Settings } from '@ledgerhq/lumen-ui-rnative/symbols';
26
- *
27
- * <ListItem
28
- * title="Balance"
29
- * leadingContent={<Spot appearance="icon" icon={Wallet} />}
30
- * trailingContent={<Settings />}
31
- * />
32
- *
33
- * // Chevron trailing content
34
- * import { ListItem } from '@ledgerhq/lumen-ui-rnative';
35
- * import { ChevronRight } from '@ledgerhq/lumen-ui-rnative/symbols';
36
- *
37
- * <ListItem
38
- * title="Settings"
39
- * trailingContent={<ChevronRight size={24} />}
40
- * />
26
+ * <ListItem onPress={() => console.log('Clicked!')}>
27
+ * <ListItemLeading>
28
+ * <ListItemSpot appearance="icon" icon={Wallet} />
29
+ * <ListItemContent>
30
+ * <ListItemTitle>Balance</ListItemTitle>
31
+ * <ListItemDescription>Optional description</ListItemDescription>
32
+ * </ListItemContent>
33
+ * </ListItemLeading>
34
+ * <ListItemTrailing>
35
+ * <ChevronRight size={24} />
36
+ * </ListItemTrailing>
37
+ * </ListItem>
41
38
  */
42
39
  export declare const ListItem: React.ForwardRefExoticComponent<{
43
- title: string;
44
- description?: string;
45
- leadingContent?: React.ReactNode;
46
- descriptionTag?: React.ReactNode;
47
- trailingContent?: React.ReactNode;
40
+ children: React.ReactNode;
48
41
  disabled?: boolean;
49
- } & Omit<import("../../../styles").StyledPressableProps, "disabled"> & React.RefAttributes<View>>;
42
+ onPress?: import("../../../styles").StyledPressableProps["onPress"];
43
+ } & Omit<import("../../../styles").StyledPressableProps, "children" | "disabled"> & React.RefAttributes<View>>;
44
+ /**
45
+ * Container for the leading (left) part of the list item.
46
+ * Contains the visual element (ListItemSpot, Avatar, Icon) and the content (title + description).
47
+ */
48
+ export declare const ListItemLeading: React.ForwardRefExoticComponent<{
49
+ children: React.ReactNode;
50
+ } & Omit<import("../../../styles").StyledViewProps, "children"> & React.RefAttributes<View>>;
51
+ /**
52
+ * Container for the text content (title and description) within the leading area.
53
+ */
54
+ export declare const ListItemContent: React.ForwardRefExoticComponent<{
55
+ children: React.ReactNode;
56
+ } & Omit<import("../../../styles").StyledViewProps, "children"> & React.RefAttributes<View>>;
57
+ /**
58
+ * The main title of the list item. Can contain text directly or
59
+ * ListItemTruncate + Tag for more complex layouts.
60
+ */
61
+ export declare const ListItemTitle: React.ForwardRefExoticComponent<{
62
+ children: React.ReactNode;
63
+ } & Omit<import("../../../styles").StyledTextProps, "children"> & React.RefAttributes<View>>;
64
+ /**
65
+ * Optional description below the title. Can contain text directly or
66
+ * ListItemTruncate + Tag for more complex layouts.
67
+ * Automatically applies disabled styling when the parent ListItem is disabled.
68
+ */
69
+ export declare const ListItemDescription: React.ForwardRefExoticComponent<{
70
+ children: React.ReactNode;
71
+ } & Omit<import("../../../styles").StyledTextProps, "children"> & React.RefAttributes<View>>;
72
+ /**
73
+ * Container for the trailing (right) content of the list item.
74
+ * Used for icons, switches, values, tags, chevrons, etc.
75
+ */
76
+ export declare const ListItemTrailing: React.ForwardRefExoticComponent<{
77
+ children: React.ReactNode;
78
+ } & Omit<import("../../../styles").StyledViewProps, "children"> & React.RefAttributes<View>>;
79
+ /**
80
+ * Spot adapter for ListItem. Automatically inherits disabled state from parent ListItem.
81
+ * Fixed at size 48 for consistent list item appearance.
82
+ */
83
+ export declare const ListItemSpot: {
84
+ (props: ListItemSpotProps): import("react/jsx-runtime").JSX.Element;
85
+ displayName: string;
86
+ };
87
+ /**
88
+ * Icon adapter for ListItem. Automatically inherits disabled state from parent ListItem.
89
+ * Fixed at size 24 for consistent list item appearance.
90
+ */
91
+ export declare const ListItemIcon: {
92
+ ({ icon: Icon, color, lx, style, ...viewProps }: ListItemIconProps): import("react/jsx-runtime").JSX.Element;
93
+ displayName: string;
94
+ };
95
+ /**
96
+ * Text wrapper that truncates when space is limited.
97
+ * Use inside ListItemTitle or ListItemDescription when combining text with a Tag.
98
+ * Set variant='title' for title styling or variant='description' (default) for description styling.
99
+ */
100
+ export declare const ListItemTruncate: React.ForwardRefExoticComponent<{
101
+ children: string;
102
+ variant?: "title" | "description";
103
+ } & Omit<import("../../../styles").StyledTextProps, "children"> & React.RefAttributes<import("react-native").Text>>;
50
104
  //# sourceMappingURL=ListItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/ListItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAoB,IAAI,EAAE,MAAM,cAAc,CAAC;AAsFtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,QAAQ;;;;;;;iGA0CpB,CAAC"}
1
+ {"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/ListItem/ListItem.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAc,IAAI,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,EAIL,iBAAiB,EAGjB,iBAAiB,EAIlB,MAAM,SAAS,CAAC;AAkCjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,QAAQ;;;;8GAqBnB,CAAC;AAsBH;;;GAGG;AACH,eAAO,MAAM,eAAe;;4FA0B3B,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,eAAe;;4FAyB3B,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,aAAa;;4FAiEzB,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;4FAkE9B,CAAC;AAIH;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;4FA0B5B,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,YAAY;YAAW,iBAAiB;;CAOpD,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,YAAY;qDAMtB,iBAAiB;;CAqBnB,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;mHA8C5B,CAAC"}
@@ -1,122 +1,267 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createSafeContext, isTextChildren, } from '@ledgerhq/lumen-utils-shared';
2
3
  import React from 'react';
3
- import { StyleSheet, Text, View } from 'react-native';
4
- import { useStyleSheet } from '../../../styles';
5
- import { Pressable } from '../Utility';
6
- const useStyles = ({ disabled, pressed, }) => {
7
- return useStyleSheet((t) => {
8
- return {
9
- container: StyleSheet.flatten([
10
- {
11
- flexDirection: 'row',
12
- alignItems: 'center',
13
- height: t.sizes.s64,
14
- width: t.sizes.full,
15
- gap: t.spacings.s16,
16
- borderRadius: t.borderRadius.md,
17
- backgroundColor: 'transparent',
18
- paddingHorizontal: t.spacings.s8,
19
- paddingVertical: t.spacings.s12,
20
- },
21
- pressed && {
22
- backgroundColor: t.colors.bg.baseTransparentPressed,
23
- },
24
- disabled && {
25
- backgroundColor: 'transparent',
26
- },
27
- ]),
28
- contentWrapper: {
29
- flex: 1,
30
- minWidth: 0,
4
+ import { StyleSheet, View } from 'react-native';
5
+ import { useStyleSheet, useTheme } from '../../../styles';
6
+ import { Spot } from '../Spot';
7
+ import { Box, Pressable, Text } from '../Utility';
8
+ const [ListItemProvider, useListItemContext] = createSafeContext('ListItem', {});
9
+ const [ListItemTrailingProvider, useListItemTrailingContext] = createSafeContext('ListItemTrailing', {
10
+ isInTrailing: false,
11
+ });
12
+ const useRootStyles = ({ pressed }) => {
13
+ return useStyleSheet((t) => ({
14
+ container: StyleSheet.flatten([
15
+ {
31
16
  flexDirection: 'row',
32
17
  alignItems: 'center',
33
- gap: t.spacings.s12,
18
+ height: t.sizes.s64,
19
+ width: t.sizes.full,
20
+ gap: t.spacings.s16,
21
+ borderRadius: t.borderRadius.md,
22
+ backgroundColor: 'transparent',
23
+ paddingHorizontal: t.spacings.s8,
24
+ paddingVertical: t.spacings.s12,
34
25
  },
35
- textWrapper: {
36
- flex: 1,
37
- minWidth: 0,
38
- flexDirection: 'column',
26
+ pressed && {
27
+ backgroundColor: t.colors.bg.baseTransparentPressed,
28
+ },
29
+ ]),
30
+ }), [pressed]);
31
+ };
32
+ /**
33
+ * A flexible list item component that provides a composable structure for displaying
34
+ * interactive list items with leading content, title, description, and trailing content.
35
+ *
36
+ * @see {@link https://ldls.vercel.app/?path=/docs/react-native_containment-listitem--docs Storybook}
37
+ * @see {@link https://ldls.vercel.app/?path=/docs/react-native_containment-listitem--docs#dos-and-donts Guidelines}
38
+ *
39
+ * @warning The `lx` prop should only be used for layout adjustments like margins or positioning.
40
+ * Do not use it to modify the list item's core appearance (colors, padding, etc).
41
+ *
42
+ * @example
43
+ * import {
44
+ * ListItem,
45
+ * ListItemLeading,
46
+ * ListItemSpot,
47
+ * ListItemContent,
48
+ * ListItemTitle,
49
+ * ListItemDescription,
50
+ * ListItemTrailing,
51
+ * } from '@ledgerhq/lumen-ui-rnative';
52
+ * import { Wallet, ChevronRight } from '@ledgerhq/lumen-ui-rnative/symbols';
53
+ *
54
+ * <ListItem onPress={() => console.log('Clicked!')}>
55
+ * <ListItemLeading>
56
+ * <ListItemSpot appearance="icon" icon={Wallet} />
57
+ * <ListItemContent>
58
+ * <ListItemTitle>Balance</ListItemTitle>
59
+ * <ListItemDescription>Optional description</ListItemDescription>
60
+ * </ListItemContent>
61
+ * </ListItemLeading>
62
+ * <ListItemTrailing>
63
+ * <ChevronRight size={24} />
64
+ * </ListItemTrailing>
65
+ * </ListItem>
66
+ */
67
+ export const ListItem = React.forwardRef(({ children, lx = {}, style, disabled = false, ...pressableProps }, ref) => {
68
+ return (_jsx(ListItemProvider, { value: { disabled }, children: _jsx(Pressable, { ref: ref, lx: lx, style: style, disabled: disabled, accessibilityRole: 'button', accessibilityState: { disabled }, ...pressableProps, children: ({ pressed }) => (_jsx(ListItemInner, { pressed: pressed, children: children })) }) }));
69
+ });
70
+ ListItem.displayName = 'ListItem';
71
+ /**
72
+ * Internal component to handle pressed state styling
73
+ */
74
+ const ListItemInner = ({ pressed, children, }) => {
75
+ const styles = useRootStyles({ pressed });
76
+ return (_jsx(View, { style: styles.container, testID: 'list-item-content', children: children }));
77
+ };
78
+ /**
79
+ * Container for the leading (left) part of the list item.
80
+ * Contains the visual element (ListItemSpot, Avatar, Icon) and the content (title + description).
81
+ */
82
+ export const ListItemLeading = React.forwardRef(({ children, lx = {}, style, ...viewProps }, ref) => {
83
+ const styles = useStyleSheet((t) => ({
84
+ leading: {
85
+ flex: 1,
86
+ minWidth: 0,
87
+ flexDirection: 'row',
88
+ alignItems: 'center',
89
+ gap: t.spacings.s12,
90
+ },
91
+ }), []);
92
+ return (_jsx(Box, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.leading, style]), ...viewProps, children: children }));
93
+ });
94
+ ListItemLeading.displayName = 'ListItemLeading';
95
+ /**
96
+ * Container for the text content (title and description) within the leading area.
97
+ */
98
+ export const ListItemContent = React.forwardRef(({ children, lx = {}, style, ...viewProps }, ref) => {
99
+ const styles = useStyleSheet((t) => ({
100
+ content: {
101
+ flex: 1,
102
+ minWidth: 0,
103
+ flexDirection: 'column',
104
+ gap: t.spacings.s4,
105
+ },
106
+ }), []);
107
+ return (_jsx(Box, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.content, style]), ...viewProps, children: children }));
108
+ });
109
+ ListItemContent.displayName = 'ListItemContent';
110
+ /**
111
+ * The main title of the list item. Can contain text directly or
112
+ * ListItemTruncate + Tag for more complex layouts.
113
+ */
114
+ export const ListItemTitle = React.forwardRef(({ children, lx = {}, style, ...viewProps }, ref) => {
115
+ const { disabled } = useListItemContext({
116
+ consumerName: 'ListItemTitle',
117
+ contextRequired: true,
118
+ });
119
+ const { isInTrailing } = useListItemTrailingContext({
120
+ consumerName: 'ListItemTitle',
121
+ contextRequired: false,
122
+ });
123
+ const styles = useStyleSheet((t) => {
124
+ const { boxStyle } = StyleSheet.create({
125
+ boxStyle: {
126
+ flexDirection: 'row',
127
+ alignItems: 'center',
39
128
  gap: t.spacings.s4,
129
+ width: '100%',
130
+ textAlign: isInTrailing ? 'right' : 'left',
131
+ justifyContent: isInTrailing ? 'flex-end' : 'flex-start',
40
132
  },
41
- title: StyleSheet.flatten([
133
+ });
134
+ return {
135
+ asBox: boxStyle,
136
+ asText: StyleSheet.flatten([
42
137
  t.typographies.body2SemiBold,
43
138
  {
139
+ ...boxStyle,
44
140
  color: disabled ? t.colors.text.disabled : t.colors.text.base,
45
141
  },
46
142
  ]),
47
- descriptionRow: {
143
+ };
144
+ }, [disabled]);
145
+ // If children is a string, render it directly as Text with truncation
146
+ if (isTextChildren(children)) {
147
+ return (_jsx(Text, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.asText, style]), numberOfLines: 1, ellipsizeMode: 'tail', children: children }));
148
+ }
149
+ // Otherwise, render as a row container for ListItemTruncate + Tag
150
+ return (_jsx(Box, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.asBox, style]), ...viewProps, children: children }));
151
+ });
152
+ ListItemTitle.displayName = 'ListItemTitle';
153
+ /**
154
+ * Optional description below the title. Can contain text directly or
155
+ * ListItemTruncate + Tag for more complex layouts.
156
+ * Automatically applies disabled styling when the parent ListItem is disabled.
157
+ */
158
+ export const ListItemDescription = React.forwardRef(({ children, lx = {}, style, ...viewProps }, ref) => {
159
+ const { disabled } = useListItemContext({
160
+ consumerName: 'ListItemDescription',
161
+ contextRequired: true,
162
+ });
163
+ const { isInTrailing } = useListItemTrailingContext({
164
+ consumerName: 'ListItemDescription',
165
+ contextRequired: false,
166
+ });
167
+ const styles = useStyleSheet((t) => {
168
+ const { boxStyle } = StyleSheet.create({
169
+ boxStyle: {
48
170
  flexDirection: 'row',
49
171
  alignItems: 'center',
50
172
  gap: t.spacings.s4,
173
+ width: '100%',
174
+ textAlign: isInTrailing ? 'right' : 'left',
175
+ justifyContent: isInTrailing ? 'flex-end' : 'flex-start',
51
176
  },
52
- descriptionTextWrapper: {
53
- minWidth: 0,
54
- flexShrink: 1,
55
- },
56
- description: StyleSheet.flatten([
177
+ });
178
+ return {
179
+ asBox: boxStyle,
180
+ asText: StyleSheet.flatten([
57
181
  t.typographies.body3,
58
182
  {
183
+ ...boxStyle,
59
184
  color: disabled ? t.colors.text.disabled : t.colors.text.muted,
60
- minWidth: 0,
61
- flexShrink: 1,
62
185
  },
63
186
  ]),
64
- descriptionTagWrapper: {
65
- height: t.sizes.s16,
66
- flexShrink: 0,
67
- flexDirection: 'row',
68
- alignItems: 'center',
69
- },
70
- trailingWrapper: {
71
- flexShrink: 0,
72
- },
73
187
  };
74
- }, [disabled, pressed]);
75
- };
188
+ }, [disabled, isInTrailing]);
189
+ // If children is a string, render it directly as Text with truncation
190
+ if (isTextChildren(children)) {
191
+ return (_jsx(Text, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.asText, style]), numberOfLines: 1, ellipsizeMode: 'tail', children: children }));
192
+ }
193
+ // Otherwise, render as a row container for ListItemTruncate + Tag
194
+ return (_jsx(Box, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.asBox, style]), ...viewProps, children: children }));
195
+ });
196
+ ListItemDescription.displayName = 'ListItemDescription';
76
197
  /**
77
- * A flexible list item component that displays a required title and optional description (with possible tag), leading and trailing content.
78
- * It functions as a clickable button with hover and active states.
79
- *
80
- * @see {@link https://ldls.vercel.app/?path=/docs/react-native_containment-listitem--docs Storybook}
81
- * @see {@link https://ldls.vercel.app/?path=/docs/react-native_containment-listitem--docs#dos-and-donts Guidelines}
82
- *
83
- * @warning The `lx` prop should only be used for layout adjustments like margins or positioning.
84
- * Do not use it to modify the list item's core appearance (colors, padding, etc).
85
- *
86
- * @example
87
- * // Basic item
88
- * import { ListItem } from '@ledgerhq/lumen-ui-rnative';
89
- *
90
- * <ListItem
91
- * title="Basic Item"
92
- * description="Optional description"
93
- * onPress={() => console.log('Clicked!')}
94
- * />
95
- *
96
- * // Icon trailing content with leading Spot
97
- * import { ListItem, Spot } from '@ledgerhq/lumen-ui-rnative';
98
- * import { Wallet, Settings } from '@ledgerhq/lumen-ui-rnative/symbols';
99
- *
100
- * <ListItem
101
- * title="Balance"
102
- * leadingContent={<Spot appearance="icon" icon={Wallet} />}
103
- * trailingContent={<Settings />}
104
- * />
105
- *
106
- * // Chevron trailing content
107
- * import { ListItem } from '@ledgerhq/lumen-ui-rnative';
108
- * import { ChevronRight } from '@ledgerhq/lumen-ui-rnative/symbols';
109
- *
110
- * <ListItem
111
- * title="Settings"
112
- * trailingContent={<ChevronRight size={24} />}
113
- * />
198
+ * Container for the trailing (right) content of the list item.
199
+ * Used for icons, switches, values, tags, chevrons, etc.
114
200
  */
115
- export const ListItem = React.forwardRef(({ title, description, leadingContent, descriptionTag, trailingContent, lx = {}, style, disabled = false, ...touchableProps }, ref) => {
116
- return (_jsx(Pressable, { ref: ref, lx: lx, style: style, disabled: disabled, accessibilityRole: 'button', accessibilityState: { disabled }, ...touchableProps, children: ({ pressed }) => (_jsx(ListItemContent, { disabled: disabled, pressed: pressed, title: title, description: description, leadingContent: leadingContent, descriptionTag: descriptionTag, trailingContent: trailingContent })) }));
201
+ export const ListItemTrailing = React.forwardRef(({ children, lx = {}, style, ...viewProps }, ref) => {
202
+ const styles = useStyleSheet(() => ({
203
+ trailing: {
204
+ flexShrink: 0,
205
+ flexDirection: 'row',
206
+ alignItems: 'center',
207
+ },
208
+ }), []);
209
+ return (_jsx(ListItemTrailingProvider, { value: { isInTrailing: true }, children: _jsx(Box, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.trailing, style]), ...viewProps, children: children }) }));
117
210
  });
118
- const ListItemContent = ({ disabled, pressed, title, description, leadingContent, descriptionTag, trailingContent, }) => {
119
- const styles = useStyles({ disabled, pressed });
120
- return (_jsxs(View, { style: styles.container, testID: 'list-item-content', children: [_jsxs(View, { style: styles.contentWrapper, children: [leadingContent, _jsxs(View, { style: styles.textWrapper, children: [_jsx(Text, { style: styles.title, numberOfLines: 1, ellipsizeMode: 'tail', children: title }), description && (_jsxs(View, { style: styles.descriptionRow, children: [_jsx(View, { style: styles.descriptionTextWrapper, children: _jsx(Text, { numberOfLines: 1, ellipsizeMode: 'tail', style: styles.description, children: description }) }), descriptionTag && (_jsx(View, { style: styles.descriptionTagWrapper, children: descriptionTag }))] }))] })] }), trailingContent && (_jsx(View, { style: styles.trailingWrapper, children: trailingContent }))] }));
211
+ ListItemTrailing.displayName = 'ListItemTrailing';
212
+ /**
213
+ * Spot adapter for ListItem. Automatically inherits disabled state from parent ListItem.
214
+ * Fixed at size 48 for consistent list item appearance.
215
+ */
216
+ export const ListItemSpot = (props) => {
217
+ const { disabled } = useListItemContext({
218
+ consumerName: 'ListItemSpot',
219
+ contextRequired: true,
220
+ });
221
+ return _jsx(Spot, { ...props, size: 48, disabled: disabled });
121
222
  };
122
- ListItem.displayName = 'ListItem';
223
+ ListItemSpot.displayName = 'ListItemSpot';
224
+ /**
225
+ * Icon adapter for ListItem. Automatically inherits disabled state from parent ListItem.
226
+ * Fixed at size 24 for consistent list item appearance.
227
+ */
228
+ export const ListItemIcon = ({ icon: Icon, color, lx = {}, style, ...viewProps }) => {
229
+ const { theme } = useTheme();
230
+ const { disabled } = useListItemContext({
231
+ consumerName: 'ListItemIcon',
232
+ contextRequired: true,
233
+ });
234
+ return (_jsx(Box, { lx: lx, style: StyleSheet.flatten([{ flexShrink: 0 }, style]), ...viewProps, children: _jsx(Icon, { size: 24, style: {
235
+ color: disabled ? theme.colors.text.disabled : (color ?? undefined),
236
+ } }) }));
237
+ };
238
+ ListItemIcon.displayName = 'ListItemIcon';
239
+ /**
240
+ * Text wrapper that truncates when space is limited.
241
+ * Use inside ListItemTitle or ListItemDescription when combining text with a Tag.
242
+ * Set variant='title' for title styling or variant='description' (default) for description styling.
243
+ */
244
+ export const ListItemTruncate = React.forwardRef(({ children, variant = 'description', lx = {}, style, ...textProps }, ref) => {
245
+ const { disabled } = useListItemContext({
246
+ consumerName: 'ListItemTruncate',
247
+ contextRequired: true,
248
+ });
249
+ const styles = useStyleSheet((t) => ({
250
+ truncate: StyleSheet.flatten([
251
+ variant === 'title'
252
+ ? t.typographies.body2SemiBold
253
+ : t.typographies.body3,
254
+ {
255
+ color: disabled
256
+ ? t.colors.text.disabled
257
+ : variant === 'title'
258
+ ? t.colors.text.base
259
+ : t.colors.text.muted,
260
+ minWidth: 0,
261
+ flexShrink: 1,
262
+ },
263
+ ]),
264
+ }), [disabled, variant]);
265
+ return (_jsx(Text, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.truncate, style]), numberOfLines: 1, ellipsizeMode: 'tail', ...textProps, children: children }));
266
+ });
267
+ ListItemTruncate.displayName = 'ListItemTruncate';
@@ -4,8 +4,7 @@ declare const meta: Meta<typeof ListItem>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof ListItem>;
6
6
  export declare const Base: Story;
7
- export declare const WithDescriptionTag: Story;
8
- export declare const TrailingContentVariantsShowcase: Story;
9
- export declare const StateShowcase: Story;
7
+ export declare const VariantsShowcase: Story;
8
+ export declare const DisabledState: Story;
10
9
  export declare const ResponsiveLayout: Story;
11
10
  //# sourceMappingURL=ListItem.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListItem.stories.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/ListItem/ListItem.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAevE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBtC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,QAAQ,CAwD/B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEvC,eAAO,MAAM,IAAI,EAAE,KAoBlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAchC,CAAC;AAEF,eAAO,MAAM,+BAA+B,EAAE,KAoC7C,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAqE3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAwC9B,CAAC"}
1
+ {"version":3,"file":"ListItem.stories.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/ListItem/ListItem.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAMvE,OAAO,EACL,QAAQ,EAST,MAAM,YAAY,CAAC;AAEpB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,QAAQ,CAkC/B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEvC,eAAO,MAAM,IAAI,EAAE,KAgClB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAqK9B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KA+E3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAuE9B,CAAC"}