@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.
- package/dist/package.json +5 -1
- package/dist/src/lib/Components/Icon/Icon.d.ts.map +1 -1
- package/dist/src/lib/Components/Icon/Icon.js +3 -4
- package/dist/src/lib/Components/Icon/createIcon.d.ts.map +1 -1
- package/dist/src/lib/Components/Icon/createIcon.js +1 -1
- package/dist/src/lib/Components/ListItem/ListItem.d.ts +88 -34
- package/dist/src/lib/Components/ListItem/ListItem.d.ts.map +1 -1
- package/dist/src/lib/Components/ListItem/ListItem.js +242 -97
- package/dist/src/lib/Components/ListItem/ListItem.stories.d.ts +2 -3
- package/dist/src/lib/Components/ListItem/ListItem.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/ListItem/ListItem.stories.js +63 -73
- package/dist/src/lib/Components/ListItem/index.d.ts +1 -1
- package/dist/src/lib/Components/ListItem/index.d.ts.map +1 -1
- package/dist/src/lib/Components/ListItem/index.js +1 -1
- package/dist/src/lib/Components/ListItem/types.d.ts +106 -0
- package/dist/src/lib/Components/ListItem/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Spot/types.d.ts +1 -1
- package/dist/src/lib/Components/Spot/types.d.ts.map +1 -1
- package/dist/src/lib/utils/index.d.ts +3 -4
- package/dist/src/lib/utils/index.d.ts.map +1 -1
- package/dist/src/lib/utils/index.js +3 -4
- package/dist/src/lib/utils/react/{extract-text-from-children.d.ts → extractTextFromChildren.d.ts} +1 -1
- package/dist/src/lib/utils/react/extractTextFromChildren.d.ts.map +1 -0
- package/dist/src/lib/utils/react/index.d.ts +1 -1
- package/dist/src/lib/utils/react/index.d.ts.map +1 -1
- package/dist/src/lib/utils/react/index.js +1 -1
- package/dist/src/lib/utils/startTransition/index.d.ts +2 -0
- package/dist/src/lib/utils/startTransition/index.d.ts.map +1 -0
- package/dist/src/lib/utils/startTransition/index.js +1 -0
- package/dist/src/lib/utils/{start-transition/start-transition.d.ts → startTransition/startTransition.d.ts} +1 -1
- package/dist/src/lib/utils/startTransition/startTransition.d.ts.map +1 -0
- package/dist/src/lib/utils/useControllableState/index.d.ts +2 -0
- package/dist/src/lib/utils/useControllableState/index.d.ts.map +1 -0
- package/dist/src/lib/utils/useControllableState/index.js +1 -0
- package/dist/src/lib/utils/{use-controllable-state/use-controllable-state.d.ts → useControllableState/useControllableState.d.ts} +1 -1
- package/dist/src/lib/utils/useControllableState/useControllableState.d.ts.map +1 -0
- package/dist/src/lib/utils/{use-controllable-state/use-controllable-state.js → useControllableState/useControllableState.js} +2 -2
- package/dist/src/lib/utils/useEvent/index.d.ts +3 -0
- package/dist/src/lib/utils/useEvent/index.d.ts.map +1 -0
- package/dist/src/lib/utils/useEvent/index.js +2 -0
- package/dist/src/lib/utils/{use-event/use-event.d.ts → useEvent/useEvent.d.ts} +1 -1
- package/dist/src/lib/utils/useEvent/useEvent.d.ts.map +1 -0
- package/dist/src/lib/utils/{use-event/use-event.js → useEvent/useEvent.js} +1 -1
- package/dist/src/lib/utils/{use-event/use-get.d.ts → useEvent/useGet.d.ts} +1 -1
- package/dist/src/lib/utils/useEvent/useGet.d.ts.map +1 -0
- package/dist/src/styles/provider/LumenStyleSheetProvider.d.ts +1 -1
- package/dist/src/styles/provider/LumenStyleSheetProvider.d.ts.map +1 -1
- package/dist/src/styles/provider/LumenStyleSheetProvider.js +1 -2
- package/package.json +6 -2
- package/src/lib/Components/Checkbox/Checkbox.mdx +1 -0
- package/src/lib/Components/Icon/Icon.tsx +3 -5
- package/src/lib/Components/Icon/createIcon.ts +1 -1
- package/src/lib/Components/ListItem/ListItem.mdx +402 -124
- package/src/lib/Components/ListItem/ListItem.stories.tsx +357 -228
- package/src/lib/Components/ListItem/ListItem.tsx +437 -181
- package/src/lib/Components/ListItem/index.ts +1 -1
- package/src/lib/Components/ListItem/types.ts +121 -0
- package/src/lib/Components/Spot/types.ts +5 -1
- package/src/lib/Components/Switch/Switch.mdx +1 -0
- package/src/lib/utils/index.ts +3 -4
- package/src/lib/utils/react/index.ts +1 -1
- package/src/lib/utils/startTransition/index.ts +1 -0
- package/src/lib/utils/useControllableState/index.ts +1 -0
- package/src/lib/utils/{use-controllable-state/use-controllable-state.ts → useControllableState/useControllableState.ts} +2 -2
- package/src/lib/utils/useEvent/index.ts +2 -0
- package/src/lib/utils/{use-event/use-event.ts → useEvent/useEvent.ts} +1 -1
- package/src/styles/provider/LumenStyleSheetProvider.tsx +2 -3
- package/dist/src/lib/Components/ListItem/ListItem.types.d.ts +0 -31
- package/dist/src/lib/Components/ListItem/ListItem.types.d.ts.map +0 -1
- package/dist/src/lib/utils/react/extract-text-from-children.d.ts.map +0 -1
- package/dist/src/lib/utils/start-transition/index.d.ts +0 -2
- package/dist/src/lib/utils/start-transition/index.d.ts.map +0 -1
- package/dist/src/lib/utils/start-transition/index.js +0 -1
- package/dist/src/lib/utils/start-transition/start-transition.d.ts.map +0 -1
- package/dist/src/lib/utils/string-utils.d.ts +0 -6
- package/dist/src/lib/utils/string-utils.d.ts.map +0 -1
- package/dist/src/lib/utils/string-utils.js +0 -12
- package/dist/src/lib/utils/use-controllable-state/index.d.ts +0 -2
- package/dist/src/lib/utils/use-controllable-state/index.d.ts.map +0 -1
- package/dist/src/lib/utils/use-controllable-state/index.js +0 -1
- package/dist/src/lib/utils/use-controllable-state/use-controllable-state.d.ts.map +0 -1
- package/dist/src/lib/utils/use-event/index.d.ts +0 -3
- package/dist/src/lib/utils/use-event/index.d.ts.map +0 -1
- package/dist/src/lib/utils/use-event/index.js +0 -2
- package/dist/src/lib/utils/use-event/use-event.d.ts.map +0 -1
- package/dist/src/lib/utils/use-event/use-get.d.ts.map +0 -1
- package/src/lib/Components/ListItem/ListItem.types.ts +0 -31
- package/src/lib/utils/start-transition/index.ts +0 -1
- package/src/lib/utils/string-utils.test.ts +0 -73
- package/src/lib/utils/string-utils.ts +0 -11
- package/src/lib/utils/use-controllable-state/index.ts +0 -1
- package/src/lib/utils/use-event/index.ts +0 -2
- /package/dist/src/lib/Components/ListItem/{ListItem.types.js → types.js} +0 -0
- /package/dist/src/lib/utils/react/{extract-text-from-children.js → extractTextFromChildren.js} +0 -0
- /package/dist/src/lib/utils/{start-transition/start-transition.js → startTransition/startTransition.js} +0 -0
- /package/dist/src/lib/utils/{use-event/use-get.js → useEvent/useGet.js} +0 -0
- /package/src/lib/utils/react/{extract-text-from-children.ts → extractTextFromChildren.ts} +0 -0
- /package/src/lib/utils/{start-transition/start-transition.ts → startTransition/startTransition.ts} +0 -0
- /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.
|
|
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;
|
|
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:
|
|
25
|
+
color: resolvedStyle.color || theme.colors.text.base,
|
|
27
26
|
};
|
|
28
|
-
}, [size, theme, resolvedStyle
|
|
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":"
|
|
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,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
|
|
5
|
-
*
|
|
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
|
-
*
|
|
15
|
-
*
|
|
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
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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
|
-
|
|
44
|
-
description?: string;
|
|
45
|
-
leadingContent?: React.ReactNode;
|
|
46
|
-
descriptionTag?: React.ReactNode;
|
|
47
|
-
trailingContent?: React.ReactNode;
|
|
40
|
+
children: React.ReactNode;
|
|
48
41
|
disabled?: boolean;
|
|
49
|
-
|
|
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":"
|
|
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
|
|
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,
|
|
4
|
-
import { useStyleSheet } from '../../../styles';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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,
|
|
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
|
-
*
|
|
78
|
-
*
|
|
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
|
|
116
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
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
|
|
8
|
-
export declare const
|
|
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;
|
|
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"}
|