@cdx-ui/components 0.0.1-alpha.17 → 0.0.1-alpha.19
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/lib/commonjs/components/Avatar/index.js +156 -0
- package/lib/commonjs/components/Avatar/index.js.map +1 -0
- package/lib/commonjs/components/Avatar/styles.js +80 -0
- package/lib/commonjs/components/Avatar/styles.js.map +1 -0
- package/lib/commonjs/components/Card/index.js +104 -0
- package/lib/commonjs/components/Card/index.js.map +1 -0
- package/lib/commonjs/components/Card/styles.js +28 -0
- package/lib/commonjs/components/Card/styles.js.map +1 -0
- package/lib/commonjs/components/index.js +24 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/module/components/Avatar/index.js +152 -0
- package/lib/module/components/Avatar/index.js.map +1 -0
- package/lib/module/components/Avatar/styles.js +77 -0
- package/lib/module/components/Avatar/styles.js.map +1 -0
- package/lib/module/components/Card/index.js +100 -0
- package/lib/module/components/Card/index.js.map +1 -0
- package/lib/module/components/Card/styles.js +25 -0
- package/lib/module/components/Card/styles.js.map +1 -0
- package/lib/module/components/index.js +2 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/typescript/components/Avatar/index.d.ts +40 -0
- package/lib/typescript/components/Avatar/index.d.ts.map +1 -0
- package/lib/typescript/components/Avatar/styles.d.ts +16 -0
- package/lib/typescript/components/Avatar/styles.d.ts.map +1 -0
- package/lib/typescript/components/Button/styles.d.ts +3 -3
- package/lib/typescript/components/Card/index.d.ts +30 -0
- package/lib/typescript/components/Card/index.d.ts.map +1 -0
- package/lib/typescript/components/Card/styles.d.ts +6 -0
- package/lib/typescript/components/Card/styles.d.ts.map +1 -0
- package/lib/typescript/components/Checkbox/styles.d.ts +4 -4
- package/lib/typescript/components/Heading/styles.d.ts +1 -1
- package/lib/typescript/components/Input/styles.d.ts +3 -3
- package/lib/typescript/components/Select/styles.d.ts +5 -5
- package/lib/typescript/components/Stack/styles.d.ts +2 -2
- package/lib/typescript/components/Switch/styles.d.ts +2 -2
- package/lib/typescript/components/Text/styles.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +2 -0
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/Avatar/index.tsx +174 -0
- package/src/components/Avatar/styles.ts +83 -0
- package/src/components/Card/index.tsx +115 -0
- package/src/components/Card/styles.ts +41 -0
- package/src/components/index.ts +2 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { Image, Text, View, type ImageProps, type TextProps, type ViewProps } from 'react-native';
|
|
3
|
+
import { createAvatar, type IAvatarImageProps, type IAvatarProps } from '@cdx-ui/primitives';
|
|
4
|
+
import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
|
|
5
|
+
import { Icon as IconComponent, type IconProps } from '../Icon';
|
|
6
|
+
import {
|
|
7
|
+
type AvatarVariantProps,
|
|
8
|
+
avatarBadgeVariants,
|
|
9
|
+
avatarIconVariants,
|
|
10
|
+
avatarTextVariants,
|
|
11
|
+
avatarImageVariants,
|
|
12
|
+
avatarRootVariants,
|
|
13
|
+
} from './styles';
|
|
14
|
+
|
|
15
|
+
const SCOPE = 'AVATAR';
|
|
16
|
+
|
|
17
|
+
const Root = withStyleContext(View, SCOPE);
|
|
18
|
+
|
|
19
|
+
const useAvatarStyleContext = () => useStyleContext(SCOPE) as AvatarVariantProps;
|
|
20
|
+
|
|
21
|
+
const AvatarPrimitive = createAvatar({
|
|
22
|
+
Root,
|
|
23
|
+
Image,
|
|
24
|
+
Text,
|
|
25
|
+
Icon: IconComponent,
|
|
26
|
+
Badge: View,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// =============================================================================
|
|
30
|
+
// AVATAR ROOT
|
|
31
|
+
// =============================================================================
|
|
32
|
+
|
|
33
|
+
export interface AvatarProps extends ViewProps, IAvatarProps, AvatarVariantProps {
|
|
34
|
+
className?: string;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const AvatarRoot = forwardRef<View, AvatarProps>(
|
|
39
|
+
({ size = 'lg', className, children, style, ...props }, ref) => {
|
|
40
|
+
const computedClassName = cn(avatarRootVariants({ size }), className);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<AvatarPrimitive
|
|
44
|
+
ref={ref as never}
|
|
45
|
+
className={computedClassName}
|
|
46
|
+
style={style}
|
|
47
|
+
context={{ size }}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</AvatarPrimitive>
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
AvatarRoot.displayName = 'Avatar';
|
|
57
|
+
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// AVATAR IMAGE
|
|
60
|
+
// =============================================================================
|
|
61
|
+
|
|
62
|
+
export interface AvatarImageProps extends Omit<ImageProps, 'source'>, IAvatarImageProps {
|
|
63
|
+
className?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const AvatarImage = forwardRef<Image, AvatarImageProps>(({ className, style, ...props }, ref) => {
|
|
67
|
+
const computedClassName = cn(avatarImageVariants(), className);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<AvatarPrimitive.Image
|
|
71
|
+
ref={ref as never}
|
|
72
|
+
className={computedClassName}
|
|
73
|
+
style={style}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
AvatarImage.displayName = 'Avatar.Image';
|
|
80
|
+
|
|
81
|
+
// =============================================================================
|
|
82
|
+
// AVATAR TEXT
|
|
83
|
+
// =============================================================================
|
|
84
|
+
|
|
85
|
+
export interface AvatarTextProps extends TextProps {
|
|
86
|
+
className?: string;
|
|
87
|
+
children?: ReactNode;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const AvatarText = forwardRef<Text, AvatarTextProps>(
|
|
91
|
+
({ className, children, style, ...props }, ref) => {
|
|
92
|
+
const { size } = useAvatarStyleContext();
|
|
93
|
+
const computedClassName = cn(avatarTextVariants({ size }), className);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<AvatarPrimitive.Text
|
|
97
|
+
ref={ref as never}
|
|
98
|
+
className={computedClassName}
|
|
99
|
+
style={style}
|
|
100
|
+
{...props}
|
|
101
|
+
>
|
|
102
|
+
{children}
|
|
103
|
+
</AvatarPrimitive.Text>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
AvatarText.displayName = 'Avatar.Text';
|
|
109
|
+
|
|
110
|
+
// =============================================================================
|
|
111
|
+
// AVATAR ICON
|
|
112
|
+
// =============================================================================
|
|
113
|
+
|
|
114
|
+
export interface AvatarIconProps extends Omit<IconProps, 'children'> {
|
|
115
|
+
className?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const AvatarIcon = ({ className, style, ...props }: AvatarIconProps) => {
|
|
119
|
+
const { size } = useAvatarStyleContext();
|
|
120
|
+
const computedClassName = cn(avatarIconVariants({ size }), className);
|
|
121
|
+
|
|
122
|
+
return <AvatarPrimitive.Icon className={computedClassName} style={style} {...props} />;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
AvatarIcon.displayName = 'Avatar.Icon';
|
|
126
|
+
|
|
127
|
+
// =============================================================================
|
|
128
|
+
// AVATAR BADGE
|
|
129
|
+
// =============================================================================
|
|
130
|
+
|
|
131
|
+
export interface AvatarBadgeProps extends ViewProps {
|
|
132
|
+
className?: string;
|
|
133
|
+
children?: ReactNode;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const AvatarBadge = forwardRef<View, AvatarBadgeProps>(
|
|
137
|
+
({ className, children, style, ...props }, ref) => {
|
|
138
|
+
const { size } = useAvatarStyleContext();
|
|
139
|
+
const computedClassName = cn(avatarBadgeVariants({ size }), className);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<AvatarPrimitive.Badge
|
|
143
|
+
ref={ref as never}
|
|
144
|
+
className={computedClassName}
|
|
145
|
+
style={style}
|
|
146
|
+
{...props}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
</AvatarPrimitive.Badge>
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
AvatarBadge.displayName = 'Avatar.Badge';
|
|
155
|
+
|
|
156
|
+
// =============================================================================
|
|
157
|
+
// COMPOUND COMPONENT
|
|
158
|
+
// =============================================================================
|
|
159
|
+
|
|
160
|
+
type AvatarCompoundComponent = typeof AvatarRoot & {
|
|
161
|
+
Image: typeof AvatarImage;
|
|
162
|
+
Text: typeof AvatarText;
|
|
163
|
+
Icon: typeof AvatarIcon;
|
|
164
|
+
Badge: typeof AvatarBadge;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const Avatar = Object.assign(AvatarRoot, {
|
|
168
|
+
Image: AvatarImage,
|
|
169
|
+
Text: AvatarText,
|
|
170
|
+
Icon: AvatarIcon,
|
|
171
|
+
Badge: AvatarBadge,
|
|
172
|
+
}) as AvatarCompoundComponent;
|
|
173
|
+
|
|
174
|
+
export type { AvatarVariantProps };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { COLOR_BG_MUTED, COLOR_TEXT_SECONDARY, RADIUS_FULL } from '../../styles/primitives';
|
|
3
|
+
|
|
4
|
+
// ── Root ─────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export const avatarRootVariants = cva(
|
|
7
|
+
[RADIUS_FULL, 'relative items-center justify-center', COLOR_BG_MUTED],
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
size: {
|
|
11
|
+
sm: 'w-8 h-8',
|
|
12
|
+
md: 'w-10 h-10',
|
|
13
|
+
lg: 'w-12 h-12',
|
|
14
|
+
xl: 'w-16 h-16',
|
|
15
|
+
'2xl': 'w-20 h-20',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: 'lg',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// ── Image ────────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
export const avatarImageVariants = cva([
|
|
27
|
+
'absolute top-0 left-0 w-full h-full',
|
|
28
|
+
RADIUS_FULL,
|
|
29
|
+
'overflow-hidden',
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
// ── Text ─────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
export const avatarTextVariants = cva([COLOR_TEXT_SECONDARY, 'font-semibold'], {
|
|
35
|
+
variants: {
|
|
36
|
+
size: {
|
|
37
|
+
sm: 'text-xs',
|
|
38
|
+
md: 'text-sm',
|
|
39
|
+
lg: 'text-base',
|
|
40
|
+
xl: 'text-xl',
|
|
41
|
+
'2xl': 'text-2xl',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
defaultVariants: {
|
|
45
|
+
size: 'lg',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// ── Icon ─────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
export const avatarIconVariants = cva([COLOR_TEXT_SECONDARY], {
|
|
52
|
+
variants: {
|
|
53
|
+
size: {
|
|
54
|
+
sm: 'size-4',
|
|
55
|
+
md: 'size-5',
|
|
56
|
+
lg: 'size-6',
|
|
57
|
+
xl: 'size-8',
|
|
58
|
+
'2xl': 'size-10',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
size: 'lg',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// ── Badge ────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
export const avatarBadgeVariants = cva(['absolute border-2 border-white', RADIUS_FULL], {
|
|
69
|
+
variants: {
|
|
70
|
+
size: {
|
|
71
|
+
sm: 'w-2.5 h-2.5 bottom-0 right-0',
|
|
72
|
+
md: 'w-3 h-3 bottom-0 right-0',
|
|
73
|
+
lg: 'w-3.5 h-3.5 bottom-0 right-0',
|
|
74
|
+
xl: 'w-4 h-4 bottom-0.5 right-0.5',
|
|
75
|
+
'2xl': 'w-5 h-5 bottom-0.5 right-0.5',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
defaultVariants: {
|
|
79
|
+
size: 'lg',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export type AvatarVariantProps = VariantProps<typeof avatarRootVariants>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { forwardRef, type ReactNode } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { cn } from '@cdx-ui/utils';
|
|
4
|
+
import {
|
|
5
|
+
cardContentVariants,
|
|
6
|
+
cardFooterVariants,
|
|
7
|
+
cardHeaderVariants,
|
|
8
|
+
cardRootVariants,
|
|
9
|
+
} from './styles';
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// STYLED ROOT COMPONENT
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
export interface CardProps extends ViewProps {
|
|
16
|
+
className?: string;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CardRoot = forwardRef<View, CardProps>(({ className, children, style, ...props }, ref) => {
|
|
21
|
+
const computedClassName = cn(cardRootVariants(), className);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<View ref={ref} className={computedClassName} style={style} {...props}>
|
|
25
|
+
{children}
|
|
26
|
+
</View>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
CardRoot.displayName = 'Card';
|
|
31
|
+
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// STYLED HEADER COMPONENT
|
|
34
|
+
// =============================================================================
|
|
35
|
+
|
|
36
|
+
export interface CardHeaderProps extends ViewProps {
|
|
37
|
+
className?: string;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const CardHeader = forwardRef<View, CardHeaderProps>(
|
|
42
|
+
({ className, children, style, ...props }, ref) => {
|
|
43
|
+
const computedClassName = cn(cardHeaderVariants(), className);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<View ref={ref} className={computedClassName} style={style} {...props}>
|
|
47
|
+
{children}
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
CardHeader.displayName = 'Card.Header';
|
|
54
|
+
|
|
55
|
+
// =============================================================================
|
|
56
|
+
// STYLED CONTENT COMPONENT
|
|
57
|
+
// =============================================================================
|
|
58
|
+
|
|
59
|
+
export interface CardContentProps extends ViewProps {
|
|
60
|
+
className?: string;
|
|
61
|
+
children?: ReactNode;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const CardContent = forwardRef<View, CardContentProps>(
|
|
65
|
+
({ className, children, style, ...props }, ref) => {
|
|
66
|
+
const computedClassName = cn(cardContentVariants(), className);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<View ref={ref} className={computedClassName} style={style} {...props}>
|
|
70
|
+
{children}
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
CardContent.displayName = 'Card.Content';
|
|
77
|
+
|
|
78
|
+
// =============================================================================
|
|
79
|
+
// STYLED FOOTER COMPONENT
|
|
80
|
+
// =============================================================================
|
|
81
|
+
|
|
82
|
+
export interface CardFooterProps extends ViewProps {
|
|
83
|
+
className?: string;
|
|
84
|
+
children?: ReactNode;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const CardFooter = forwardRef<View, CardFooterProps>(
|
|
88
|
+
({ className, children, style, ...props }, ref) => {
|
|
89
|
+
const computedClassName = cn(cardFooterVariants(), className);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<View ref={ref} className={computedClassName} style={style} {...props}>
|
|
93
|
+
{children}
|
|
94
|
+
</View>
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
CardFooter.displayName = 'Card.Footer';
|
|
100
|
+
|
|
101
|
+
// =============================================================================
|
|
102
|
+
// COMPOUND COMPONENT
|
|
103
|
+
// =============================================================================
|
|
104
|
+
|
|
105
|
+
type CardCompoundComponent = typeof CardRoot & {
|
|
106
|
+
Header: typeof CardHeader;
|
|
107
|
+
Content: typeof CardContent;
|
|
108
|
+
Footer: typeof CardFooter;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const Card = CardRoot as CardCompoundComponent;
|
|
112
|
+
|
|
113
|
+
Card.Header = CardHeader;
|
|
114
|
+
Card.Content = CardContent;
|
|
115
|
+
Card.Footer = CardFooter;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { cva } from 'class-variance-authority';
|
|
2
|
+
import {
|
|
3
|
+
COLOR_BG_PRIMARY,
|
|
4
|
+
COLOR_BORDER_DEFAULT,
|
|
5
|
+
COLOR_TEXT_PRIMARY,
|
|
6
|
+
RADIUS_SM,
|
|
7
|
+
SHADOW_SM,
|
|
8
|
+
} from '../../styles/primitives';
|
|
9
|
+
|
|
10
|
+
// ── Root ────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export const cardRootVariants = cva([
|
|
13
|
+
COLOR_BG_PRIMARY,
|
|
14
|
+
`border ${COLOR_BORDER_DEFAULT}`,
|
|
15
|
+
RADIUS_SM,
|
|
16
|
+
SHADOW_SM,
|
|
17
|
+
'overflow-hidden',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
// ── Header ──────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
export const cardHeaderVariants = cva([
|
|
23
|
+
'flex-row items-center justify-between p-4 border-b border-t-8',
|
|
24
|
+
COLOR_BORDER_DEFAULT,
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
// ── Title ───────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
export const cardTitleVariants = cva(['flex-1']);
|
|
30
|
+
|
|
31
|
+
// ── Content ─────────────────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
export const cardContentVariants = cva([COLOR_TEXT_PRIMARY, 'p-4']);
|
|
34
|
+
|
|
35
|
+
// ── Footer ──────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
export const cardFooterVariants = cva([
|
|
38
|
+
'p-4 border-t',
|
|
39
|
+
COLOR_BORDER_DEFAULT,
|
|
40
|
+
'flex-row items-center gap-2',
|
|
41
|
+
]);
|