@cdx-ui/components 0.0.1-beta.3 → 0.0.1-beta.30
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/README.md +18 -11
- package/lib/commonjs/components/Button/styles.js +2 -2
- package/lib/commonjs/components/Button/styles.js.map +1 -1
- package/lib/commonjs/components/Card/index.js +22 -4
- package/lib/commonjs/components/Card/index.js.map +1 -1
- package/lib/commonjs/components/Card/styles.js +27 -5
- package/lib/commonjs/components/Card/styles.js.map +1 -1
- package/lib/commonjs/components/Checkbox/index.js +5 -29
- package/lib/commonjs/components/Checkbox/index.js.map +1 -1
- package/lib/commonjs/components/Checkbox/styles.js +39 -47
- package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
- package/lib/commonjs/components/Field/index.js +8 -2
- package/lib/commonjs/components/Field/index.js.map +1 -1
- package/lib/commonjs/components/Field/styles.js +4 -4
- package/lib/commonjs/components/Field/styles.js.map +1 -1
- package/lib/commonjs/components/Heading/styles.js +1 -1
- package/lib/commonjs/components/Heading/styles.js.map +1 -1
- package/lib/commonjs/components/Icon/index.js +1 -2
- package/lib/commonjs/components/Icon/index.js.map +1 -1
- package/lib/commonjs/components/IconButton/index.js +6 -1
- package/lib/commonjs/components/IconButton/index.js.map +1 -1
- package/lib/commonjs/components/IconButton/styles.js +135 -10
- package/lib/commonjs/components/IconButton/styles.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +7 -6
- package/lib/commonjs/components/Input/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js +283 -0
- package/lib/commonjs/components/ListItem/index.js.map +1 -0
- package/lib/commonjs/components/ListItem/styles.js +130 -0
- package/lib/commonjs/components/ListItem/styles.js.map +1 -0
- package/lib/commonjs/components/ProgressSegmented/index.js +22 -10
- package/lib/commonjs/components/ProgressSegmented/index.js.map +1 -1
- package/lib/commonjs/components/Radio/index.js +167 -0
- package/lib/commonjs/components/Radio/index.js.map +1 -0
- package/lib/commonjs/components/Radio/styles.js +31 -0
- package/lib/commonjs/components/Radio/styles.js.map +1 -0
- package/lib/commonjs/components/Text/styles.js +2 -2
- package/lib/commonjs/components/Text/styles.js.map +1 -1
- package/lib/commonjs/components/Tile/index.js +251 -0
- package/lib/commonjs/components/Tile/index.js.map +1 -0
- package/lib/commonjs/components/Tile/styles.js +52 -0
- package/lib/commonjs/components/Tile/styles.js.map +1 -0
- package/lib/commonjs/components/index.js +36 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/figma/Button.figma.js +70 -0
- package/lib/commonjs/figma/Button.figma.js.map +1 -0
- package/lib/commonjs/figma/Card.Header.figma.js +28 -0
- package/lib/commonjs/figma/Card.Header.figma.js.map +1 -0
- package/lib/commonjs/figma/Card.figma.js +42 -0
- package/lib/commonjs/figma/Card.figma.js.map +1 -0
- package/lib/commonjs/figma/Checkbox.figma.js +55 -0
- package/lib/commonjs/figma/Checkbox.figma.js.map +1 -0
- package/lib/commonjs/figma/Field.Input.figma.js +57 -0
- package/lib/commonjs/figma/Field.Input.figma.js.map +1 -0
- package/lib/commonjs/figma/Field.Select.figma.js +57 -0
- package/lib/commonjs/figma/Field.Select.figma.js.map +1 -0
- package/lib/commonjs/figma/Heading.figma.js +30 -0
- package/lib/commonjs/figma/Heading.figma.js.map +1 -0
- package/lib/commonjs/figma/Icon.figma.js +20 -0
- package/lib/commonjs/figma/Icon.figma.js.map +1 -0
- package/lib/commonjs/figma/IconButton.figma.js +47 -0
- package/lib/commonjs/figma/IconButton.figma.js.map +1 -0
- package/lib/commonjs/figma/Input.figma.js +52 -0
- package/lib/commonjs/figma/Input.figma.js.map +1 -0
- package/lib/commonjs/figma/ProgressSegmented.figma.js +39 -0
- package/lib/commonjs/figma/ProgressSegmented.figma.js.map +1 -0
- package/lib/commonjs/figma/Radio.figma.js +38 -0
- package/lib/commonjs/figma/Radio.figma.js.map +1 -0
- package/lib/commonjs/figma/Select.figma.js +53 -0
- package/lib/commonjs/figma/Select.figma.js.map +1 -0
- package/lib/commonjs/figma/Text.figma.js +29 -0
- package/lib/commonjs/figma/Text.figma.js.map +1 -0
- package/lib/commonjs/figma/icons.figma.batch.js +27 -0
- package/lib/commonjs/figma/icons.figma.batch.js.map +1 -0
- package/lib/commonjs/figma/icons.figma.batch.json +17705 -0
- package/lib/commonjs/styles/primitives.js +36 -2
- package/lib/commonjs/styles/primitives.js.map +1 -1
- package/lib/module/components/Button/styles.js +2 -2
- package/lib/module/components/Button/styles.js.map +1 -1
- package/lib/module/components/Card/index.js +23 -4
- package/lib/module/components/Card/index.js.map +1 -1
- package/lib/module/components/Card/styles.js +27 -5
- package/lib/module/components/Card/styles.js.map +1 -1
- package/lib/module/components/Checkbox/index.js +6 -30
- package/lib/module/components/Checkbox/index.js.map +1 -1
- package/lib/module/components/Checkbox/styles.js +40 -48
- package/lib/module/components/Checkbox/styles.js.map +1 -1
- package/lib/module/components/Field/index.js +9 -3
- package/lib/module/components/Field/index.js.map +1 -1
- package/lib/module/components/Field/styles.js +4 -4
- package/lib/module/components/Field/styles.js.map +1 -1
- package/lib/module/components/Heading/styles.js +1 -1
- package/lib/module/components/Heading/styles.js.map +1 -1
- package/lib/module/components/Icon/index.js +1 -2
- package/lib/module/components/Icon/index.js.map +1 -1
- package/lib/module/components/IconButton/index.js +6 -1
- package/lib/module/components/IconButton/index.js.map +1 -1
- package/lib/module/components/IconButton/styles.js +135 -10
- package/lib/module/components/IconButton/styles.js.map +1 -1
- package/lib/module/components/Input/styles.js +7 -6
- package/lib/module/components/Input/styles.js.map +1 -1
- package/lib/module/components/ListItem/index.js +226 -0
- package/lib/module/components/ListItem/index.js.map +1 -0
- package/lib/module/components/ListItem/styles.js +127 -0
- package/lib/module/components/ListItem/styles.js.map +1 -0
- package/lib/module/components/ProgressSegmented/index.js +23 -11
- package/lib/module/components/ProgressSegmented/index.js.map +1 -1
- package/lib/module/components/Radio/index.js +164 -0
- package/lib/module/components/Radio/index.js.map +1 -0
- package/lib/module/components/Radio/styles.js +27 -0
- package/lib/module/components/Radio/styles.js.map +1 -0
- package/lib/module/components/Text/styles.js +2 -2
- package/lib/module/components/Text/styles.js.map +1 -1
- package/lib/module/components/Tile/index.js +243 -0
- package/lib/module/components/Tile/index.js.map +1 -0
- package/lib/module/components/Tile/styles.js +48 -0
- package/lib/module/components/Tile/styles.js.map +1 -0
- package/lib/module/components/index.js +3 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/figma/Button.figma.js +64 -0
- package/lib/module/figma/Button.figma.js.map +1 -0
- package/lib/module/figma/Card.Header.figma.js +22 -0
- package/lib/module/figma/Card.Header.figma.js.map +1 -0
- package/lib/module/figma/Card.figma.js +36 -0
- package/lib/module/figma/Card.figma.js.map +1 -0
- package/lib/module/figma/Checkbox.figma.js +49 -0
- package/lib/module/figma/Checkbox.figma.js.map +1 -0
- package/lib/module/figma/Field.Input.figma.js +51 -0
- package/lib/module/figma/Field.Input.figma.js.map +1 -0
- package/lib/module/figma/Field.Select.figma.js +51 -0
- package/lib/module/figma/Field.Select.figma.js.map +1 -0
- package/lib/module/figma/Heading.figma.js +24 -0
- package/lib/module/figma/Heading.figma.js.map +1 -0
- package/lib/module/figma/Icon.figma.js +14 -0
- package/lib/module/figma/Icon.figma.js.map +1 -0
- package/lib/module/figma/IconButton.figma.js +41 -0
- package/lib/module/figma/IconButton.figma.js.map +1 -0
- package/lib/module/figma/Input.figma.js +46 -0
- package/lib/module/figma/Input.figma.js.map +1 -0
- package/lib/module/figma/ProgressSegmented.figma.js +33 -0
- package/lib/module/figma/ProgressSegmented.figma.js.map +1 -0
- package/lib/module/figma/Radio.figma.js +32 -0
- package/lib/module/figma/Radio.figma.js.map +1 -0
- package/lib/module/figma/Select.figma.js +47 -0
- package/lib/module/figma/Select.figma.js.map +1 -0
- package/lib/module/figma/Text.figma.js +23 -0
- package/lib/module/figma/Text.figma.js.map +1 -0
- package/lib/module/figma/icons.figma.batch.js +22 -0
- package/lib/module/figma/icons.figma.batch.js.map +1 -0
- package/lib/module/figma/icons.figma.batch.json +17705 -0
- package/lib/module/styles/primitives.js +36 -2
- package/lib/module/styles/primitives.js.map +1 -1
- package/lib/typescript/components/Card/index.d.ts +4 -3
- package/lib/typescript/components/Card/index.d.ts.map +1 -1
- package/lib/typescript/components/Card/styles.d.ts +13 -3
- package/lib/typescript/components/Card/styles.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/index.d.ts +1 -2
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/styles.d.ts +4 -14
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -1
- package/lib/typescript/components/Field/FieldLabel.web.d.ts +2 -2
- package/lib/typescript/components/Field/FieldLabel.web.d.ts.map +1 -1
- package/lib/typescript/components/Field/index.d.ts.map +1 -1
- package/lib/typescript/components/Field/styles.d.ts.map +1 -1
- package/lib/typescript/components/Heading/styles.d.ts.map +1 -1
- package/lib/typescript/components/Icon/index.d.ts.map +1 -1
- package/lib/typescript/components/IconButton/index.d.ts.map +1 -1
- package/lib/typescript/components/IconButton/styles.d.ts +6 -2
- package/lib/typescript/components/IconButton/styles.d.ts.map +1 -1
- package/lib/typescript/components/Input/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +49 -0
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -0
- package/lib/typescript/components/ListItem/styles.d.ts +30 -0
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -0
- package/lib/typescript/components/ProgressSegmented/index.d.ts +14 -3
- package/lib/typescript/components/ProgressSegmented/index.d.ts.map +1 -1
- package/lib/typescript/components/Radio/index.d.ts +40 -0
- package/lib/typescript/components/Radio/index.d.ts.map +1 -0
- package/lib/typescript/components/Radio/styles.d.ts +8 -0
- package/lib/typescript/components/Radio/styles.d.ts.map +1 -0
- package/lib/typescript/components/Text/styles.d.ts.map +1 -1
- package/lib/typescript/components/Tile/index.d.ts +70 -0
- package/lib/typescript/components/Tile/index.d.ts.map +1 -0
- package/lib/typescript/components/Tile/styles.d.ts +18 -0
- package/lib/typescript/components/Tile/styles.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +3 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/figma/Button.figma.d.ts +8 -0
- package/lib/typescript/figma/Button.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Card.Header.figma.d.ts +8 -0
- package/lib/typescript/figma/Card.Header.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Card.figma.d.ts +8 -0
- package/lib/typescript/figma/Card.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Checkbox.figma.d.ts +8 -0
- package/lib/typescript/figma/Checkbox.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Field.Input.figma.d.ts +8 -0
- package/lib/typescript/figma/Field.Input.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Field.Select.figma.d.ts +8 -0
- package/lib/typescript/figma/Field.Select.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Heading.figma.d.ts +8 -0
- package/lib/typescript/figma/Heading.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Icon.figma.d.ts +8 -0
- package/lib/typescript/figma/Icon.figma.d.ts.map +1 -0
- package/lib/typescript/figma/IconButton.figma.d.ts +8 -0
- package/lib/typescript/figma/IconButton.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Input.figma.d.ts +8 -0
- package/lib/typescript/figma/Input.figma.d.ts.map +1 -0
- package/lib/typescript/figma/ProgressSegmented.figma.d.ts +8 -0
- package/lib/typescript/figma/ProgressSegmented.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Radio.figma.d.ts +8 -0
- package/lib/typescript/figma/Radio.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Select.figma.d.ts +8 -0
- package/lib/typescript/figma/Select.figma.d.ts.map +1 -0
- package/lib/typescript/figma/Text.figma.d.ts +8 -0
- package/lib/typescript/figma/Text.figma.d.ts.map +1 -0
- package/lib/typescript/figma/icons.figma.batch.d.ts +14 -0
- package/lib/typescript/figma/icons.figma.batch.d.ts.map +1 -0
- package/lib/typescript/styles/primitives.d.ts +35 -0
- package/lib/typescript/styles/primitives.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/Button/styles.ts +2 -2
- package/src/components/Card/index.tsx +41 -16
- package/src/components/Card/styles.ts +43 -23
- package/src/components/Checkbox/index.tsx +8 -19
- package/src/components/Checkbox/styles.ts +82 -86
- package/src/components/Field/FieldLabel.web.tsx +1 -1
- package/src/components/Field/index.tsx +10 -3
- package/src/components/Field/styles.ts +5 -4
- package/src/components/Heading/{styles.tsx → styles.ts} +1 -1
- package/src/components/Icon/index.tsx +1 -2
- package/src/components/IconButton/index.tsx +3 -2
- package/src/components/IconButton/styles.ts +136 -10
- package/src/components/Input/styles.ts +13 -8
- package/src/components/ListItem/index.tsx +285 -0
- package/src/components/ListItem/styles.ts +153 -0
- package/src/components/ProgressSegmented/index.tsx +49 -14
- package/src/components/Radio/index.tsx +192 -0
- package/src/components/Radio/styles.ts +59 -0
- package/src/components/Text/{styles.tsx → styles.ts} +2 -2
- package/src/components/Tile/index.tsx +296 -0
- package/src/components/Tile/styles.ts +82 -0
- package/src/components/index.ts +3 -0
- package/src/styles/primitives.ts +36 -2
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { Pressable, Text, View, type TextProps, type ViewProps } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
createListItem,
|
|
5
|
+
type IListItemLeadingSlotProps,
|
|
6
|
+
type IListItemProps,
|
|
7
|
+
type IListItemSectionHeaderProps,
|
|
8
|
+
type ListItemCrossAlign,
|
|
9
|
+
} from '@cdx-ui/primitives';
|
|
10
|
+
import { cn, useStyleContext, withStyleContext, type WithStyleContextProps } from '@cdx-ui/utils';
|
|
11
|
+
import {
|
|
12
|
+
listItemContentVariants,
|
|
13
|
+
listItemDescriptionVariants,
|
|
14
|
+
listItemLeadingSlotVariants,
|
|
15
|
+
listItemMetaVariants,
|
|
16
|
+
listItemRootVariants,
|
|
17
|
+
listItemSectionHeaderLabelVariants,
|
|
18
|
+
listItemSectionHeaderVariants,
|
|
19
|
+
listItemTitleVariants,
|
|
20
|
+
listItemTrailingSlotVariants,
|
|
21
|
+
type ListItemVariantProps,
|
|
22
|
+
} from './styles';
|
|
23
|
+
|
|
24
|
+
const SCOPE = 'LIST_ITEM';
|
|
25
|
+
|
|
26
|
+
const RootView = withStyleContext(View, SCOPE);
|
|
27
|
+
const RootPressable = withStyleContext(Pressable, SCOPE);
|
|
28
|
+
|
|
29
|
+
const ListItemPrimitive = createListItem({
|
|
30
|
+
View: RootView,
|
|
31
|
+
Pressable: RootPressable,
|
|
32
|
+
LeadingSlot: View,
|
|
33
|
+
Content: View,
|
|
34
|
+
Title: Text,
|
|
35
|
+
Description: Text,
|
|
36
|
+
Meta: Text,
|
|
37
|
+
TrailingSlot: View,
|
|
38
|
+
SectionHeader: View,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const useListItemStyleContext = (): Pick<ListItemVariantProps, 'size' | 'crossAlign'> => {
|
|
42
|
+
const ctx = useStyleContext(SCOPE) as ListItemVariantProps | undefined;
|
|
43
|
+
return { size: ctx?.size ?? 'default', crossAlign: ctx?.crossAlign ?? 'center' };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// ROOT
|
|
48
|
+
// =============================================================================
|
|
49
|
+
|
|
50
|
+
export interface ListItemProps extends IListItemProps, WithStyleContextProps {
|
|
51
|
+
className?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const ListItemRoot = forwardRef<View, ListItemProps>(
|
|
55
|
+
(
|
|
56
|
+
{
|
|
57
|
+
size = 'default',
|
|
58
|
+
surface = 'default',
|
|
59
|
+
showSeparator = true,
|
|
60
|
+
crossAlign = 'center',
|
|
61
|
+
className,
|
|
62
|
+
style,
|
|
63
|
+
...props
|
|
64
|
+
},
|
|
65
|
+
ref,
|
|
66
|
+
) => {
|
|
67
|
+
const computedClassName = cn(
|
|
68
|
+
listItemRootVariants({ size, surface, showSeparator, crossAlign }),
|
|
69
|
+
className,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<ListItemPrimitive
|
|
74
|
+
ref={ref as never}
|
|
75
|
+
className={computedClassName}
|
|
76
|
+
context={{ size, surface, showSeparator, crossAlign }}
|
|
77
|
+
crossAlign={crossAlign}
|
|
78
|
+
showSeparator={showSeparator}
|
|
79
|
+
size={size}
|
|
80
|
+
style={style}
|
|
81
|
+
surface={surface}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
ListItemRoot.displayName = 'ListItem';
|
|
89
|
+
|
|
90
|
+
// =============================================================================
|
|
91
|
+
// SLOTS & TEXT
|
|
92
|
+
// =============================================================================
|
|
93
|
+
|
|
94
|
+
export interface ListItemLeadingSlotProps extends IListItemLeadingSlotProps {
|
|
95
|
+
className?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const ListItemLeadingSlot = forwardRef<View, ListItemLeadingSlotProps>(
|
|
99
|
+
({ className, style, ...props }, ref) => (
|
|
100
|
+
<ListItemPrimitive.LeadingSlot
|
|
101
|
+
ref={ref as never}
|
|
102
|
+
className={cn(listItemLeadingSlotVariants(), className)}
|
|
103
|
+
style={style}
|
|
104
|
+
{...props}
|
|
105
|
+
/>
|
|
106
|
+
),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
ListItemLeadingSlot.displayName = 'ListItem.LeadingSlot';
|
|
110
|
+
|
|
111
|
+
export interface ListItemContentProps extends ViewProps {
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const ListItemContent = forwardRef<View, ListItemContentProps>(
|
|
116
|
+
({ className, style, ...props }, ref) => {
|
|
117
|
+
const { crossAlign } = useListItemStyleContext();
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<ListItemPrimitive.Content
|
|
121
|
+
ref={ref as never}
|
|
122
|
+
className={cn(listItemContentVariants({ crossAlign }), className)}
|
|
123
|
+
style={style}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
ListItemContent.displayName = 'ListItem.Content';
|
|
131
|
+
|
|
132
|
+
export interface ListItemTitleProps extends TextProps {
|
|
133
|
+
className?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const ListItemTitle = forwardRef<Text, ListItemTitleProps>(
|
|
137
|
+
({ className, numberOfLines = 1, style, ...props }, ref) => {
|
|
138
|
+
const { size } = useListItemStyleContext();
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<ListItemPrimitive.Title
|
|
142
|
+
ref={ref as never}
|
|
143
|
+
className={cn(listItemTitleVariants({ size }), className)}
|
|
144
|
+
numberOfLines={numberOfLines}
|
|
145
|
+
style={style}
|
|
146
|
+
{...props}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
ListItemTitle.displayName = 'ListItem.Title';
|
|
153
|
+
|
|
154
|
+
export interface ListItemDescriptionProps extends TextProps {
|
|
155
|
+
className?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const ListItemDescription = forwardRef<Text, ListItemDescriptionProps>(
|
|
159
|
+
({ className, style, ...props }, ref) => {
|
|
160
|
+
const { size } = useListItemStyleContext();
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<ListItemPrimitive.Description
|
|
164
|
+
ref={ref as never}
|
|
165
|
+
className={cn(listItemDescriptionVariants({ size }), className)}
|
|
166
|
+
style={style}
|
|
167
|
+
{...props}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
ListItemDescription.displayName = 'ListItem.Description';
|
|
174
|
+
|
|
175
|
+
export interface ListItemMetaProps extends TextProps {
|
|
176
|
+
className?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const ListItemMeta = forwardRef<Text, ListItemMetaProps>(
|
|
180
|
+
({ className, numberOfLines = 1, style, ...props }, ref) => {
|
|
181
|
+
const { size } = useListItemStyleContext();
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<ListItemPrimitive.Meta
|
|
185
|
+
ref={ref as never}
|
|
186
|
+
className={cn(listItemMetaVariants({ size }), className)}
|
|
187
|
+
numberOfLines={numberOfLines}
|
|
188
|
+
style={style}
|
|
189
|
+
{...props}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
192
|
+
},
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
ListItemMeta.displayName = 'ListItem.Meta';
|
|
196
|
+
|
|
197
|
+
export interface ListItemTrailingSlotProps extends ViewProps {
|
|
198
|
+
className?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const ListItemTrailingSlot = forwardRef<View, ListItemTrailingSlotProps>(
|
|
202
|
+
({ className, style, ...props }, ref) => {
|
|
203
|
+
const { crossAlign } = useListItemStyleContext();
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<ListItemPrimitive.TrailingSlot
|
|
207
|
+
ref={ref as never}
|
|
208
|
+
className={cn(listItemTrailingSlotVariants({ crossAlign }), className)}
|
|
209
|
+
style={style}
|
|
210
|
+
{...props}
|
|
211
|
+
/>
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
ListItemTrailingSlot.displayName = 'ListItem.TrailingSlot';
|
|
217
|
+
|
|
218
|
+
const wrapSectionHeaderLabel = (children: ReactNode): ReactNode => {
|
|
219
|
+
if (typeof children === 'string' || typeof children === 'number') {
|
|
220
|
+
return <Text className={cn(listItemSectionHeaderLabelVariants())}>{children}</Text>;
|
|
221
|
+
}
|
|
222
|
+
return children;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// =============================================================================
|
|
226
|
+
// SECTION HEADER
|
|
227
|
+
// =============================================================================
|
|
228
|
+
|
|
229
|
+
export interface ListItemSectionHeaderComponentProps extends IListItemSectionHeaderProps {
|
|
230
|
+
className?: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const ListItemSectionHeader = forwardRef<View, ListItemSectionHeaderComponentProps>(
|
|
234
|
+
({ children, className, showDivider = true, style, trailing, ...props }, ref) => (
|
|
235
|
+
<ListItemPrimitive.SectionHeader
|
|
236
|
+
ref={ref as never}
|
|
237
|
+
className={cn(listItemSectionHeaderVariants({ showDivider }), className)}
|
|
238
|
+
showDivider={showDivider}
|
|
239
|
+
style={style}
|
|
240
|
+
trailing={trailing}
|
|
241
|
+
{...props}
|
|
242
|
+
>
|
|
243
|
+
{wrapSectionHeaderLabel(children)}
|
|
244
|
+
</ListItemPrimitive.SectionHeader>
|
|
245
|
+
),
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
ListItemSectionHeader.displayName = 'ListItem.SectionHeader';
|
|
249
|
+
|
|
250
|
+
// =============================================================================
|
|
251
|
+
// COMPOUND EXPORT
|
|
252
|
+
// =============================================================================
|
|
253
|
+
|
|
254
|
+
type ListItemCompound = typeof ListItemRoot & {
|
|
255
|
+
LeadingSlot: typeof ListItemLeadingSlot;
|
|
256
|
+
Content: typeof ListItemContent;
|
|
257
|
+
Title: typeof ListItemTitle;
|
|
258
|
+
Description: typeof ListItemDescription;
|
|
259
|
+
Meta: typeof ListItemMeta;
|
|
260
|
+
TrailingSlot: typeof ListItemTrailingSlot;
|
|
261
|
+
SectionHeader: typeof ListItemSectionHeader;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const ListItem = Object.assign(ListItemRoot, {
|
|
265
|
+
LeadingSlot: ListItemLeadingSlot,
|
|
266
|
+
Content: ListItemContent,
|
|
267
|
+
Title: ListItemTitle,
|
|
268
|
+
Description: ListItemDescription,
|
|
269
|
+
Meta: ListItemMeta,
|
|
270
|
+
TrailingSlot: ListItemTrailingSlot,
|
|
271
|
+
SectionHeader: ListItemSectionHeader,
|
|
272
|
+
}) as ListItemCompound;
|
|
273
|
+
|
|
274
|
+
export type { ListItemCrossAlign, ListItemVariantProps };
|
|
275
|
+
export {
|
|
276
|
+
listItemContentVariants,
|
|
277
|
+
listItemDescriptionVariants,
|
|
278
|
+
listItemLeadingSlotVariants,
|
|
279
|
+
listItemMetaVariants,
|
|
280
|
+
listItemRootVariants,
|
|
281
|
+
listItemSectionHeaderLabelVariants,
|
|
282
|
+
listItemSectionHeaderVariants,
|
|
283
|
+
listItemTitleVariants,
|
|
284
|
+
listItemTrailingSlotVariants,
|
|
285
|
+
} from './styles';
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { TRANSITION_COLORS } from '../../styles/primitives';
|
|
4
|
+
|
|
5
|
+
// ── Root (row): density, surface, separator, interactive feedback ──────────
|
|
6
|
+
|
|
7
|
+
export const listItemRootVariants = cva(
|
|
8
|
+
[
|
|
9
|
+
'flex-row self-stretch w-full px-4',
|
|
10
|
+
'data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none',
|
|
11
|
+
'data-[active=true]:opacity-70',
|
|
12
|
+
TRANSITION_COLORS,
|
|
13
|
+
Platform.select({
|
|
14
|
+
web: [
|
|
15
|
+
'outline-none',
|
|
16
|
+
'web:data-[hover=true]:bg-slate-50',
|
|
17
|
+
'web:focus-visible:data-[disabled=false]:bg-slate-50',
|
|
18
|
+
'web:focus-visible:data-[disabled=false]:ring-2 web:focus-visible:data-[disabled=false]:ring-slate-400/40 web:focus-visible:data-[disabled=false]:ring-offset-2',
|
|
19
|
+
].join(' '),
|
|
20
|
+
default: '',
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
{
|
|
24
|
+
variants: {
|
|
25
|
+
size: {
|
|
26
|
+
default: 'gap-3 py-4',
|
|
27
|
+
compact: 'gap-2 py-3',
|
|
28
|
+
},
|
|
29
|
+
surface: {
|
|
30
|
+
default: 'bg-white',
|
|
31
|
+
negative: 'bg-red-50',
|
|
32
|
+
},
|
|
33
|
+
showSeparator: {
|
|
34
|
+
true: 'border-b border-solid border-stroke-secondary',
|
|
35
|
+
false: 'border-b-0',
|
|
36
|
+
},
|
|
37
|
+
crossAlign: {
|
|
38
|
+
center: 'items-center',
|
|
39
|
+
start: 'items-start',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
compoundVariants: [
|
|
43
|
+
{
|
|
44
|
+
surface: 'negative',
|
|
45
|
+
className: Platform.select({
|
|
46
|
+
web: 'web:data-[hover=true]:bg-red-100/90',
|
|
47
|
+
default: '',
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
defaultVariants: {
|
|
52
|
+
size: 'default',
|
|
53
|
+
surface: 'default',
|
|
54
|
+
showSeparator: true,
|
|
55
|
+
crossAlign: 'center',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// ── Leading / trailing slots ─────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
export const listItemLeadingSlotVariants = cva(['flex shrink-0 items-center justify-center']);
|
|
63
|
+
|
|
64
|
+
export const listItemTrailingSlotVariants = cva(['flex shrink-0 flex-row justify-end gap-2'], {
|
|
65
|
+
variants: {
|
|
66
|
+
crossAlign: {
|
|
67
|
+
center: 'items-center',
|
|
68
|
+
start: 'items-start self-start',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
defaultVariants: {
|
|
72
|
+
crossAlign: 'center',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ── Content stack (title / description / meta) ───────────────────────────────
|
|
77
|
+
|
|
78
|
+
export const listItemContentVariants = cva('flex min-w-0 flex-1 flex-col gap-1', {
|
|
79
|
+
variants: {
|
|
80
|
+
crossAlign: {
|
|
81
|
+
center: 'justify-center',
|
|
82
|
+
start: 'justify-start',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
defaultVariants: {
|
|
86
|
+
crossAlign: 'center',
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// ── Typography ───────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
export const listItemTitleVariants = cva('text-content-primary font-medium', {
|
|
93
|
+
variants: {
|
|
94
|
+
size: {
|
|
95
|
+
default: 'text-base leading-snug',
|
|
96
|
+
compact: 'text-sm leading-snug',
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
defaultVariants: {
|
|
100
|
+
size: 'default',
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const listItemDescriptionVariants = cva('text-content-secondary', {
|
|
105
|
+
variants: {
|
|
106
|
+
size: {
|
|
107
|
+
default: 'text-sm leading-normal',
|
|
108
|
+
compact: 'text-xs leading-normal',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
defaultVariants: {
|
|
112
|
+
size: 'default',
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
export const listItemMetaVariants = cva('text-content-tertiary', {
|
|
117
|
+
variants: {
|
|
118
|
+
size: {
|
|
119
|
+
default: 'text-xs leading-normal',
|
|
120
|
+
compact: 'text-[11px] leading-normal',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
defaultVariants: {
|
|
124
|
+
size: 'default',
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// ── Section header (group label row inside lists / cards) ───────────────────
|
|
129
|
+
|
|
130
|
+
export const listItemSectionHeaderVariants = cva(
|
|
131
|
+
[
|
|
132
|
+
'flex-row items-center justify-between gap-2 border-b border-solid px-4 py-3',
|
|
133
|
+
'border-stroke-secondary',
|
|
134
|
+
],
|
|
135
|
+
{
|
|
136
|
+
variants: {
|
|
137
|
+
showDivider: {
|
|
138
|
+
true: ['border-t-4 border-solid border-t-surface-brand-strong/40', 'border-x-0'],
|
|
139
|
+
false: 'border-t-0',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
defaultVariants: {
|
|
143
|
+
showDivider: true,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
/** Default section-title typography; applied by `ListItem.SectionHeader` for string/number children. Exported for rare custom composition. */
|
|
149
|
+
export const listItemSectionHeaderLabelVariants = cva(
|
|
150
|
+
'text-xs font-semibold uppercase tracking-wide text-content-secondary',
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
export type ListItemVariantProps = VariantProps<typeof listItemRootVariants>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useMemo } from 'react';
|
|
1
|
+
import { forwardRef, useEffect, useMemo } from 'react';
|
|
2
2
|
import { View, type ViewProps } from 'react-native';
|
|
3
3
|
import { cn } from '@cdx-ui/utils';
|
|
4
4
|
import {
|
|
@@ -7,15 +7,32 @@ import {
|
|
|
7
7
|
type ProgressSegmentedVariants,
|
|
8
8
|
} from './styles';
|
|
9
9
|
|
|
10
|
+
/* `ProgressSegmentedProps.total` remains in the public API until the next major release. */
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
10
12
|
export interface ProgressSegmentedProps extends ViewProps, ProgressSegmentedVariants {
|
|
11
13
|
/** Current step (1-based index into the segment count) */
|
|
12
14
|
readonly step: number;
|
|
13
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Number of segments in the bar. Matches the Figma `segments` variant (2–6 in the design
|
|
17
|
+
* system file); the prop accepts any positive integer for backward compatibility.
|
|
18
|
+
*/
|
|
19
|
+
readonly segments?: number;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use {@link ProgressSegmentedProps.segments} instead. This alias will be removed
|
|
22
|
+
* in a future major release.
|
|
23
|
+
*/
|
|
14
24
|
readonly total?: number;
|
|
15
25
|
/** When true, the current step segment is marked as complete rather than in-progress */
|
|
16
26
|
readonly isStepComplete?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Returns the accessibility value text announced by screen readers. Receives the clamped
|
|
29
|
+
* step, segment count, and whether the step is complete.
|
|
30
|
+
*/
|
|
31
|
+
readonly getAccessibilityText?: (
|
|
32
|
+
step: number,
|
|
33
|
+
segmentCount: number,
|
|
34
|
+
isStepComplete: boolean,
|
|
35
|
+
) => string;
|
|
19
36
|
readonly className?: string;
|
|
20
37
|
}
|
|
21
38
|
|
|
@@ -23,7 +40,8 @@ export const ProgressSegmented = forwardRef<View, ProgressSegmentedProps>(
|
|
|
23
40
|
(
|
|
24
41
|
{
|
|
25
42
|
step,
|
|
26
|
-
|
|
43
|
+
segments,
|
|
44
|
+
total,
|
|
27
45
|
isStepComplete = false,
|
|
28
46
|
getAccessibilityText,
|
|
29
47
|
className,
|
|
@@ -32,10 +50,25 @@ export const ProgressSegmented = forwardRef<View, ProgressSegmentedProps>(
|
|
|
32
50
|
},
|
|
33
51
|
ref,
|
|
34
52
|
) => {
|
|
35
|
-
const
|
|
53
|
+
const segmentCount = segments ?? total ?? 5;
|
|
36
54
|
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (
|
|
57
|
+
typeof process !== 'undefined' &&
|
|
58
|
+
process.env.NODE_ENV !== 'production' &&
|
|
59
|
+
total !== undefined &&
|
|
60
|
+
segments === undefined
|
|
61
|
+
) {
|
|
62
|
+
console.warn(
|
|
63
|
+
'[ProgressSegmented] The `total` prop is deprecated and will be removed in a future major release. Use `segments` instead.',
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}, [total, segments]);
|
|
67
|
+
|
|
68
|
+
const clampedStep = Math.max(0, Math.min(step, segmentCount));
|
|
69
|
+
|
|
70
|
+
const segmentStates = useMemo(() => {
|
|
71
|
+
return Array.from({ length: segmentCount }, (_, index) => {
|
|
39
72
|
const segmentIndex = index + 1;
|
|
40
73
|
let state: 'complete' | 'incomplete' | 'inprogress' = 'incomplete';
|
|
41
74
|
|
|
@@ -47,13 +80,13 @@ export const ProgressSegmented = forwardRef<View, ProgressSegmentedProps>(
|
|
|
47
80
|
|
|
48
81
|
return state;
|
|
49
82
|
});
|
|
50
|
-
}, [
|
|
83
|
+
}, [segmentCount, clampedStep, isStepComplete]);
|
|
51
84
|
|
|
52
|
-
let accessibilityText = `Step ${String(clampedStep)} of ${String(
|
|
85
|
+
let accessibilityText = `Step ${String(clampedStep)} of ${String(segmentCount)}`;
|
|
53
86
|
if (getAccessibilityText) {
|
|
54
|
-
accessibilityText = getAccessibilityText(clampedStep,
|
|
87
|
+
accessibilityText = getAccessibilityText(clampedStep, segmentCount, isStepComplete);
|
|
55
88
|
} else if (isStepComplete) {
|
|
56
|
-
accessibilityText = `Step ${String(clampedStep)} of ${String(
|
|
89
|
+
accessibilityText = `Step ${String(clampedStep)} of ${String(segmentCount)}, completed`;
|
|
57
90
|
}
|
|
58
91
|
|
|
59
92
|
return (
|
|
@@ -63,14 +96,14 @@ export const ProgressSegmented = forwardRef<View, ProgressSegmentedProps>(
|
|
|
63
96
|
accessibilityLabel={accessibilityLabel}
|
|
64
97
|
accessibilityValue={{
|
|
65
98
|
min: 0,
|
|
66
|
-
max:
|
|
99
|
+
max: segmentCount,
|
|
67
100
|
now: clampedStep,
|
|
68
101
|
text: accessibilityText,
|
|
69
102
|
}}
|
|
70
103
|
className={cn(progressSegmentedVariants(), className)}
|
|
71
104
|
{...props}
|
|
72
105
|
>
|
|
73
|
-
{
|
|
106
|
+
{segmentStates.map((state, index) => (
|
|
74
107
|
<View key={index} className={cn(segmentVariants({ state }))} />
|
|
75
108
|
))}
|
|
76
109
|
</View>
|
|
@@ -79,3 +112,5 @@ export const ProgressSegmented = forwardRef<View, ProgressSegmentedProps>(
|
|
|
79
112
|
);
|
|
80
113
|
|
|
81
114
|
ProgressSegmented.displayName = 'ProgressSegmented';
|
|
115
|
+
|
|
116
|
+
/* eslint-enable @typescript-eslint/no-deprecated */
|