@cdx-ui/components 0.0.1-alpha.14 → 0.0.1-alpha.16
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 +1 -1
- package/lib/commonjs/components/Box/Box.js +1 -0
- package/lib/commonjs/components/Box/Box.js.map +1 -1
- package/lib/commonjs/components/Button/index.js +28 -13
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/Button/styles.js +324 -140
- package/lib/commonjs/components/Button/styles.js.map +1 -1
- package/lib/commonjs/components/Checkbox/index.js +18 -11
- package/lib/commonjs/components/Checkbox/index.js.map +1 -1
- package/lib/commonjs/components/Checkbox/styles.js +17 -16
- package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
- package/lib/commonjs/components/Heading/index.js.map +1 -1
- package/lib/commonjs/components/Heading/styles.js +3 -2
- package/lib/commonjs/components/Heading/styles.js.map +1 -1
- package/lib/commonjs/components/Icon/index.js +2 -1
- package/lib/commonjs/components/Icon/index.js.map +1 -1
- package/lib/commonjs/components/Input/index.js +10 -16
- package/lib/commonjs/components/Input/index.js.map +1 -1
- package/lib/commonjs/components/Input/styles.js +16 -30
- package/lib/commonjs/components/Input/styles.js.map +1 -1
- package/lib/commonjs/components/Link/styles.js +6 -1
- package/lib/commonjs/components/Link/styles.js.map +1 -1
- package/lib/commonjs/components/Select/index.js +11 -12
- package/lib/commonjs/components/Select/index.js.map +1 -1
- package/lib/commonjs/components/Select/styles.js +29 -53
- package/lib/commonjs/components/Select/styles.js.map +1 -1
- package/lib/commonjs/components/Stack/styles.js +2 -14
- package/lib/commonjs/components/Stack/styles.js.map +1 -1
- package/lib/commonjs/components/Text/index.js.map +1 -1
- package/lib/commonjs/components/Text/styles.js +3 -2
- package/lib/commonjs/components/Text/styles.js.map +1 -1
- package/lib/commonjs/styles/index.js +17 -0
- package/lib/commonjs/styles/index.js.map +1 -0
- package/lib/commonjs/styles/primitives.js +123 -0
- package/lib/commonjs/styles/primitives.js.map +1 -0
- package/lib/module/components/Box/Box.js +1 -0
- package/lib/module/components/Box/Box.js.map +1 -1
- package/lib/module/components/Button/index.js +29 -14
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/Button/styles.js +323 -139
- package/lib/module/components/Button/styles.js.map +1 -1
- package/lib/module/components/Checkbox/index.js +19 -12
- package/lib/module/components/Checkbox/index.js.map +1 -1
- package/lib/module/components/Checkbox/styles.js +17 -16
- package/lib/module/components/Checkbox/styles.js.map +1 -1
- package/lib/module/components/Heading/index.js.map +1 -1
- package/lib/module/components/Heading/styles.js +3 -2
- package/lib/module/components/Heading/styles.js.map +1 -1
- package/lib/module/components/Icon/index.js +2 -1
- package/lib/module/components/Icon/index.js.map +1 -1
- package/lib/module/components/Input/index.js +10 -16
- package/lib/module/components/Input/index.js.map +1 -1
- package/lib/module/components/Input/styles.js +16 -30
- package/lib/module/components/Input/styles.js.map +1 -1
- package/lib/module/components/Link/styles.js +6 -1
- package/lib/module/components/Link/styles.js.map +1 -1
- package/lib/module/components/Select/index.js +12 -13
- package/lib/module/components/Select/index.js.map +1 -1
- package/lib/module/components/Select/styles.js +29 -53
- package/lib/module/components/Select/styles.js.map +1 -1
- package/lib/module/components/Stack/styles.js +2 -14
- package/lib/module/components/Stack/styles.js.map +1 -1
- package/lib/module/components/Text/index.js.map +1 -1
- package/lib/module/components/Text/styles.js +3 -2
- package/lib/module/components/Text/styles.js.map +1 -1
- package/lib/module/styles/index.js +4 -0
- package/lib/module/styles/index.js.map +1 -0
- package/lib/module/styles/primitives.js +119 -0
- package/lib/module/styles/primitives.js.map +1 -0
- package/lib/typescript/components/Box/Box.d.ts +1 -0
- package/lib/typescript/components/Box/Box.d.ts.map +1 -1
- package/lib/typescript/components/Button/index.d.ts +6 -3
- package/lib/typescript/components/Button/index.d.ts.map +1 -1
- package/lib/typescript/components/Button/styles.d.ts +14 -8
- package/lib/typescript/components/Button/styles.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/index.d.ts +6 -4
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
- package/lib/typescript/components/Checkbox/styles.d.ts +4 -4
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -1
- package/lib/typescript/components/Heading/index.d.ts +6 -2
- package/lib/typescript/components/Heading/index.d.ts.map +1 -1
- package/lib/typescript/components/Heading/styles.d.ts.map +1 -1
- package/lib/typescript/components/Icon/index.d.ts +1 -2
- package/lib/typescript/components/Icon/index.d.ts.map +1 -1
- package/lib/typescript/components/Input/index.d.ts +6 -4
- package/lib/typescript/components/Input/index.d.ts.map +1 -1
- package/lib/typescript/components/Input/styles.d.ts +5 -7
- package/lib/typescript/components/Input/styles.d.ts.map +1 -1
- package/lib/typescript/components/Link/styles.d.ts.map +1 -1
- package/lib/typescript/components/Select/index.d.ts +6 -3
- package/lib/typescript/components/Select/index.d.ts.map +1 -1
- package/lib/typescript/components/Select/styles.d.ts +6 -8
- package/lib/typescript/components/Select/styles.d.ts.map +1 -1
- package/lib/typescript/components/Stack/styles.d.ts.map +1 -1
- package/lib/typescript/components/Text/index.d.ts +6 -2
- package/lib/typescript/components/Text/index.d.ts.map +1 -1
- package/lib/typescript/components/Text/styles.d.ts.map +1 -1
- package/lib/typescript/styles/index.d.ts +2 -0
- package/lib/typescript/styles/index.d.ts.map +1 -0
- package/lib/typescript/styles/primitives.d.ts +85 -0
- package/lib/typescript/styles/primitives.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/components/Box/Box.tsx +1 -0
- package/src/components/Button/index.tsx +23 -15
- package/src/components/Button/styles.ts +353 -149
- package/src/components/Checkbox/index.tsx +15 -21
- package/src/components/Checkbox/styles.ts +33 -24
- package/src/components/Heading/index.tsx +4 -1
- package/src/components/Heading/styles.tsx +3 -2
- package/src/components/Icon/index.tsx +7 -2
- package/src/components/Input/index.tsx +9 -20
- package/src/components/Input/styles.ts +42 -37
- package/src/components/Link/styles.ts +10 -1
- package/src/components/Select/index.tsx +12 -11
- package/src/components/Select/styles.ts +63 -74
- package/src/components/Stack/styles.ts +2 -14
- package/src/components/Text/index.tsx +2 -1
- package/src/components/Text/styles.tsx +3 -2
- package/src/styles/index.ts +1 -0
- package/src/styles/primitives.ts +107 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { forwardRef, type ReactNode } from 'react';
|
|
2
2
|
import { Pressable, Text, type TextProps, View, type ViewProps } from 'react-native';
|
|
3
|
+
import { Check, CheckIndeterminateSmall } from '@cdx-ui/icons';
|
|
3
4
|
import { createCheckbox, type ICheckboxProps } from '@cdx-ui/primitives';
|
|
4
5
|
import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
|
|
6
|
+
import { Icon, IconProps } from '../Icon';
|
|
5
7
|
import {
|
|
6
8
|
type CheckboxVariantProps,
|
|
7
9
|
checkboxGroupVariants,
|
|
@@ -35,17 +37,23 @@ export interface CheckboxProps extends ICheckboxProps, CheckboxVariantProps {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
const CheckboxRoot = forwardRef<View, CheckboxProps>(
|
|
38
|
-
({ size = '
|
|
40
|
+
({ size = 'default', className, isIndeterminate, children, style, ...props }, ref) => {
|
|
39
41
|
const computedClassName = cn(checkboxRootVariants({ size }), className);
|
|
40
42
|
|
|
41
43
|
return (
|
|
42
44
|
<CheckboxPrimitive
|
|
43
45
|
ref={ref as any}
|
|
44
46
|
className={computedClassName}
|
|
47
|
+
isIndeterminate={isIndeterminate}
|
|
45
48
|
style={style}
|
|
46
49
|
context={{ size }}
|
|
47
50
|
{...props}
|
|
48
51
|
>
|
|
52
|
+
<CheckboxIndicator>
|
|
53
|
+
<CheckboxPrimitive.Icon>
|
|
54
|
+
<CheckboxIcon as={isIndeterminate ? CheckIndeterminateSmall : Check} />
|
|
55
|
+
</CheckboxPrimitive.Icon>
|
|
56
|
+
</CheckboxIndicator>
|
|
49
57
|
{children}
|
|
50
58
|
</CheckboxPrimitive>
|
|
51
59
|
);
|
|
@@ -87,28 +95,14 @@ CheckboxIndicator.displayName = 'Checkbox.Indicator';
|
|
|
87
95
|
// CHECKBOX ICON
|
|
88
96
|
// =============================================================================
|
|
89
97
|
|
|
90
|
-
export interface CheckboxIconProps extends
|
|
91
|
-
className?: string;
|
|
92
|
-
children?: ReactNode;
|
|
93
|
-
}
|
|
98
|
+
export interface CheckboxIconProps extends Omit<IconProps, 'children'> {}
|
|
94
99
|
|
|
95
|
-
const CheckboxIcon =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const computedClassName = cn(checkboxIconVariants({ size }), className);
|
|
100
|
+
const CheckboxIcon = ({ className, style, ...props }: CheckboxIconProps) => {
|
|
101
|
+
const { size } = useCheckboxStyleContext();
|
|
102
|
+
const computedClassName = cn(checkboxIconVariants({ size }), className);
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
ref={ref as any}
|
|
103
|
-
className={computedClassName}
|
|
104
|
-
style={style}
|
|
105
|
-
{...props}
|
|
106
|
-
>
|
|
107
|
-
{children}
|
|
108
|
-
</CheckboxPrimitive.Icon>
|
|
109
|
-
);
|
|
110
|
-
},
|
|
111
|
-
);
|
|
104
|
+
return <Icon className={computedClassName} style={style} {...props} />;
|
|
105
|
+
};
|
|
112
106
|
|
|
113
107
|
CheckboxIcon.displayName = 'Checkbox.Icon';
|
|
114
108
|
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import {
|
|
4
|
+
COLOR_BG_PRIMARY,
|
|
5
|
+
COLOR_BORDER_STRONG,
|
|
6
|
+
COLOR_TEXT_PRIMARY,
|
|
7
|
+
DISABLED_CURSOR,
|
|
8
|
+
DISABLED_OPACITY,
|
|
9
|
+
TRANSITION_COLORS,
|
|
10
|
+
} from '../../styles/primitives';
|
|
3
11
|
|
|
4
12
|
export const checkboxRootVariants = cva(
|
|
5
|
-
[
|
|
6
|
-
'flex-row items-center',
|
|
7
|
-
'data-[disabled=true]:opacity-60 data-[disabled=true]:cursor-not-allowed',
|
|
8
|
-
],
|
|
13
|
+
['flex-row items-center', DISABLED_OPACITY, DISABLED_CURSOR],
|
|
9
14
|
{
|
|
10
15
|
variants: {
|
|
11
16
|
size: {
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
small: 'gap-2',
|
|
18
|
+
default: 'gap-2.5',
|
|
14
19
|
},
|
|
15
20
|
},
|
|
16
21
|
defaultVariants: {
|
|
17
|
-
size: '
|
|
22
|
+
size: 'default',
|
|
18
23
|
},
|
|
19
24
|
},
|
|
20
25
|
);
|
|
@@ -23,18 +28,22 @@ export const checkboxIndicatorVariants = cva(
|
|
|
23
28
|
[
|
|
24
29
|
'items-center justify-center',
|
|
25
30
|
'rounded',
|
|
26
|
-
'border-2
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
'border-2',
|
|
32
|
+
COLOR_BORDER_STRONG,
|
|
33
|
+
COLOR_BG_PRIMARY,
|
|
34
|
+
'data-[checked=true]:bg-slate-900 data-[checked=true]:border-slate-900',
|
|
35
|
+
'data-[indeterminate=true]:bg-slate-900 data-[indeterminate=true]:border-slate-900',
|
|
36
|
+
'data-[disabled=true]:opacity-50',
|
|
29
37
|
'data-[invalid=true]:border-red-500',
|
|
30
38
|
'data-[checked=true]:data-[invalid=true]:bg-red-500 data-[checked=true]:data-[invalid=true]:border-red-500',
|
|
39
|
+
'data-[indeterminate=true]:data-[invalid=true]:bg-red-500 data-[indeterminate=true]:data-[invalid=true]:border-red-500',
|
|
31
40
|
Platform.select({
|
|
32
41
|
web: [
|
|
33
|
-
|
|
34
|
-
'data-[hover=true]:data-[checked=false]:border-
|
|
35
|
-
'data-[focus-visible=true]:ring-2 data-[focus-visible=true]:ring-
|
|
42
|
+
TRANSITION_COLORS,
|
|
43
|
+
'data-[hover=true]:data-[checked=false]:data-[indeterminate=false]:border-slate-400 data-[hover=true]:data-[checked=false]:data-[indeterminate=false]:bg-slate-50',
|
|
44
|
+
'data-[focus-visible=true]:ring-2 data-[focus-visible=true]:ring-slate-400/50 data-[focus-visible=true]:ring-offset-2',
|
|
36
45
|
'data-[invalid=true]:data-[hover=true]:border-red-400',
|
|
37
|
-
'data-[invalid=true]:data-[focus-visible=true]:ring-red-
|
|
46
|
+
'data-[invalid=true]:data-[focus-visible=true]:ring-red-400/50',
|
|
38
47
|
].join(' '),
|
|
39
48
|
default: '',
|
|
40
49
|
}),
|
|
@@ -42,12 +51,12 @@ export const checkboxIndicatorVariants = cva(
|
|
|
42
51
|
{
|
|
43
52
|
variants: {
|
|
44
53
|
size: {
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
small: 'h-4 w-4',
|
|
55
|
+
default: 'h-5 w-5',
|
|
47
56
|
},
|
|
48
57
|
},
|
|
49
58
|
defaultVariants: {
|
|
50
|
-
size: '
|
|
59
|
+
size: 'default',
|
|
51
60
|
},
|
|
52
61
|
},
|
|
53
62
|
);
|
|
@@ -55,26 +64,26 @@ export const checkboxIndicatorVariants = cva(
|
|
|
55
64
|
export const checkboxIconVariants = cva(['text-white'], {
|
|
56
65
|
variants: {
|
|
57
66
|
size: {
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
small: 'h-3 w-3',
|
|
68
|
+
default: 'h-3.5 w-3.5',
|
|
60
69
|
},
|
|
61
70
|
},
|
|
62
71
|
defaultVariants: {
|
|
63
|
-
size: '
|
|
72
|
+
size: 'default',
|
|
64
73
|
},
|
|
65
74
|
});
|
|
66
75
|
|
|
67
76
|
export const checkboxLabelVariants = cva(
|
|
68
|
-
[
|
|
77
|
+
[COLOR_TEXT_PRIMARY, 'data-[disabled=true]:text-slate-400'],
|
|
69
78
|
{
|
|
70
79
|
variants: {
|
|
71
80
|
size: {
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
small: 'text-sm',
|
|
82
|
+
default: 'text-base',
|
|
74
83
|
},
|
|
75
84
|
},
|
|
76
85
|
defaultVariants: {
|
|
77
|
-
size: '
|
|
86
|
+
size: 'default',
|
|
78
87
|
},
|
|
79
88
|
},
|
|
80
89
|
);
|
|
@@ -11,7 +11,10 @@ const sizeToLevel = {
|
|
|
11
11
|
xs: 5,
|
|
12
12
|
} as const;
|
|
13
13
|
|
|
14
|
-
export type HeadingProps = HeadingVariantProps &
|
|
14
|
+
export type HeadingProps = HeadingVariantProps &
|
|
15
|
+
ComponentPropsWithoutRef<typeof Text> & {
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
15
18
|
|
|
16
19
|
export const Heading = memo(
|
|
17
20
|
forwardRef<ComponentRef<typeof Text>, HeadingProps>(function Heading(
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { COLOR_TEXT_PRIMARY } from '../../styles/primitives';
|
|
3
4
|
|
|
4
5
|
export const headingStyle = cva(
|
|
5
6
|
[
|
|
6
|
-
|
|
7
|
+
`${COLOR_TEXT_PRIMARY} font-semibold tracking-tight my-0`,
|
|
7
8
|
Platform.select({
|
|
8
|
-
web: 'bg-transparent
|
|
9
|
+
web: 'font-sans bg-transparent display-inline no-underline',
|
|
9
10
|
default: '',
|
|
10
11
|
}),
|
|
11
12
|
],
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { withUniwind } from 'uniwind';
|
|
2
2
|
import { cn } from '@cdx-ui/utils';
|
|
3
3
|
import type { CdxIcon, CdxIconProps } from '@cdx-ui/icons';
|
|
4
|
+
import { COLOR_TEXT_PRIMARY } from '../../styles/primitives';
|
|
4
5
|
|
|
5
|
-
type IconProps = CdxIconProps & {
|
|
6
|
+
export type IconProps = CdxIconProps & {
|
|
6
7
|
className?: string; // TODO: Why does this need to specified manually?
|
|
7
8
|
as: CdxIcon;
|
|
8
9
|
};
|
|
@@ -44,6 +45,10 @@ const StyledIcon = withUniwind(IconImpl, {
|
|
|
44
45
|
*/
|
|
45
46
|
export function Icon({ as: IconComponent, className, ...props }: IconProps) {
|
|
46
47
|
return (
|
|
47
|
-
<StyledIcon
|
|
48
|
+
<StyledIcon
|
|
49
|
+
as={IconComponent}
|
|
50
|
+
className={cn(COLOR_TEXT_PRIMARY, 'size-5', className)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
48
53
|
);
|
|
49
54
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type IInputSlotProps,
|
|
8
8
|
} from '@cdx-ui/primitives';
|
|
9
9
|
import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
|
|
10
|
+
import { Icon, IconProps } from '../Icon';
|
|
10
11
|
import { BaseInput } from './BaseInput';
|
|
11
12
|
import {
|
|
12
13
|
type InputVariantProps,
|
|
@@ -25,7 +26,6 @@ const useInputStyleContext = () => useStyleContext(SCOPE) as InputVariantProps;
|
|
|
25
26
|
|
|
26
27
|
const InputPrimitive = createInput({
|
|
27
28
|
Root,
|
|
28
|
-
Icon: View,
|
|
29
29
|
Slot: View,
|
|
30
30
|
Field: BaseInput,
|
|
31
31
|
});
|
|
@@ -40,7 +40,7 @@ export interface InputProps extends ViewProps, IInputFieldProps, InputVariantPro
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const InputRoot = forwardRef<View, InputProps>(
|
|
43
|
-
({ variant = 'outline', size = '
|
|
43
|
+
({ variant = 'outline', size = 'default', className, children, style, ...props }, ref) => {
|
|
44
44
|
const computedClassName = cn(inputRootVariants({ variant, size }), className);
|
|
45
45
|
|
|
46
46
|
return (
|
|
@@ -103,9 +103,7 @@ export interface InputSlotProps extends ViewProps, IInputSlotProps {
|
|
|
103
103
|
|
|
104
104
|
const InputSlot = forwardRef<View, InputSlotProps>(
|
|
105
105
|
({ className, children, style, ...props }, ref) => {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const computedClassName = cn(inputSlotVariants({ size }), className);
|
|
106
|
+
const computedClassName = cn(inputSlotVariants(), className);
|
|
109
107
|
|
|
110
108
|
return (
|
|
111
109
|
<InputPrimitive.Slot ref={ref} className={computedClassName} style={style} {...props}>
|
|
@@ -121,24 +119,15 @@ InputSlot.displayName = 'Input.Slot';
|
|
|
121
119
|
// INPUT ICON
|
|
122
120
|
// =============================================================================
|
|
123
121
|
|
|
124
|
-
export interface InputIconProps extends
|
|
125
|
-
className?: string;
|
|
126
|
-
children?: ReactNode;
|
|
127
|
-
}
|
|
122
|
+
export interface InputIconProps extends Omit<IconProps, 'children'> {}
|
|
128
123
|
|
|
129
|
-
const InputIcon =
|
|
130
|
-
|
|
131
|
-
const { size } = useInputStyleContext();
|
|
124
|
+
const InputIcon = ({ className, style, as, ...props }: InputIconProps) => {
|
|
125
|
+
const { size } = useInputStyleContext();
|
|
132
126
|
|
|
133
|
-
|
|
127
|
+
const computedClassName = cn(inputIconVariants({ size }), className);
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
{children}
|
|
138
|
-
</InputPrimitive.Icon>
|
|
139
|
-
);
|
|
140
|
-
},
|
|
141
|
-
);
|
|
129
|
+
return <Icon as={as} className={computedClassName} style={style} {...props} />;
|
|
130
|
+
};
|
|
142
131
|
|
|
143
132
|
InputIcon.displayName = 'Input.Icon';
|
|
144
133
|
|
|
@@ -1,83 +1,88 @@
|
|
|
1
1
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import {
|
|
3
|
+
COLOR_BG_PRIMARY,
|
|
4
|
+
COLOR_BORDER_DEFAULT,
|
|
5
|
+
COLOR_TEXT_MUTED,
|
|
6
|
+
COLOR_TEXT_PRIMARY,
|
|
7
|
+
DISABLED_CURSOR,
|
|
8
|
+
DISABLED_OPACITY,
|
|
9
|
+
RADIUS_SM,
|
|
10
|
+
SHADOW_SM,
|
|
11
|
+
SIZE_SCALE,
|
|
12
|
+
TRANSITION_COLORS,
|
|
13
|
+
} from '../../styles/primitives';
|
|
2
14
|
|
|
3
15
|
export const inputRootVariants = cva(
|
|
4
16
|
[
|
|
5
|
-
'w-full flex-row items-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
'w-full flex-row items-stretch border',
|
|
18
|
+
COLOR_BG_PRIMARY,
|
|
19
|
+
COLOR_BORDER_DEFAULT,
|
|
20
|
+
RADIUS_SM,
|
|
21
|
+
SHADOW_SM,
|
|
22
|
+
TRANSITION_COLORS,
|
|
23
|
+
DISABLED_OPACITY,
|
|
24
|
+
DISABLED_CURSOR,
|
|
25
|
+
'data-[disabled=true]:bg-slate-50 data-[disabled=true]:border-slate-300',
|
|
26
|
+
'data-[readonly=true]:cursor-default',
|
|
27
|
+
'data-[readonly=true]:bg-slate-50',
|
|
28
|
+
'web:data-[hover=true]:data-[active=false]:border-slate-300',
|
|
29
|
+
'data-[focus=true]:border-slate-900',
|
|
9
30
|
'data-[invalid=true]:border-red-500',
|
|
10
31
|
],
|
|
11
32
|
{
|
|
12
33
|
variants: {
|
|
13
34
|
variant: {
|
|
14
35
|
outline: [
|
|
15
|
-
'
|
|
16
|
-
'web:focus-within:border-
|
|
17
|
-
'web:data-[invalid=true]:focus-within:border-red-500 web:data-[invalid=true]:focus-within:ring-red-300/50',
|
|
36
|
+
'web:focus-within:border-slate-900 web:focus-within:ring-2 web:focus-within:ring-slate-400/50 web:focus-within:ring-offset-0',
|
|
37
|
+
'web:data-[invalid=true]:focus-within:border-red-500 web:data-[invalid=true]:focus-within:ring-2 web:data-[invalid=true]:focus-within:ring-red-400/50',
|
|
18
38
|
],
|
|
19
|
-
underlined:
|
|
20
|
-
'rounded-none border-t-0 border-l-0 border-r-0 border-b-neutral-border data-[focus=true]:border-b-interactive-focus shadow-none',
|
|
21
39
|
},
|
|
22
40
|
size: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
lg: 'h-12 py-2',
|
|
41
|
+
default: `${SIZE_SCALE.default.height} ${SIZE_SCALE.default.px} py-2 ${SIZE_SCALE.default.gap}`,
|
|
42
|
+
small: `${SIZE_SCALE.small.height} ${SIZE_SCALE.small.px} py-1.5 ${SIZE_SCALE.small.gap}`,
|
|
26
43
|
},
|
|
27
44
|
},
|
|
28
45
|
defaultVariants: {
|
|
29
46
|
variant: 'outline',
|
|
30
|
-
size: '
|
|
47
|
+
size: 'default',
|
|
31
48
|
},
|
|
32
49
|
},
|
|
33
50
|
);
|
|
34
51
|
|
|
35
52
|
export const inputFieldVariants = cva(
|
|
36
53
|
[
|
|
37
|
-
'flex-1 bg-transparent
|
|
38
|
-
|
|
54
|
+
'flex-1 justify-center bg-transparent',
|
|
55
|
+
COLOR_TEXT_PRIMARY,
|
|
56
|
+
'placeholder:text-slate-400',
|
|
39
57
|
'web:outline-none',
|
|
40
58
|
],
|
|
41
59
|
{
|
|
42
60
|
variants: {
|
|
43
61
|
size: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
lg: 'text-lg leading-none',
|
|
62
|
+
default: 'text-[1rem]',
|
|
63
|
+
small: 'text-[0.875rem]',
|
|
47
64
|
},
|
|
48
65
|
},
|
|
49
66
|
defaultVariants: {
|
|
50
|
-
size: '
|
|
67
|
+
size: 'default',
|
|
51
68
|
},
|
|
52
69
|
},
|
|
53
70
|
);
|
|
54
71
|
|
|
55
|
-
export const inputSlotVariants = cva(['items-center justify-center']
|
|
56
|
-
variants: {
|
|
57
|
-
size: {
|
|
58
|
-
sm: 'h-4 w-4',
|
|
59
|
-
md: 'h-5 w-5',
|
|
60
|
-
lg: 'h-6 w-6',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
defaultVariants: {
|
|
64
|
-
size: 'sm',
|
|
65
|
-
},
|
|
66
|
-
});
|
|
72
|
+
export const inputSlotVariants = cva(['items-center justify-center self-center']);
|
|
67
73
|
|
|
68
|
-
export const inputIconVariants = cva([
|
|
74
|
+
export const inputIconVariants = cva([COLOR_TEXT_MUTED], {
|
|
69
75
|
variants: {
|
|
70
76
|
size: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
lg: 'h-5 w-5',
|
|
77
|
+
default: 'size-5',
|
|
78
|
+
small: 'size-4',
|
|
74
79
|
},
|
|
75
80
|
},
|
|
76
81
|
defaultVariants: {
|
|
77
|
-
size: '
|
|
82
|
+
size: 'default',
|
|
78
83
|
},
|
|
79
84
|
});
|
|
80
85
|
|
|
81
|
-
export const inputFieldPlaceholderVariants = cva(['accent-
|
|
86
|
+
export const inputFieldPlaceholderVariants = cva(['accent-slate-400']);
|
|
82
87
|
|
|
83
88
|
export type InputVariantProps = VariantProps<typeof inputRootVariants>;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
1
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { COLOR_TEXT_PRIMARY, TRANSITION_COLORS } from '../../styles/primitives';
|
|
2
4
|
|
|
3
5
|
export const linkRootVariants = cva([
|
|
4
6
|
'flex-row items-center',
|
|
5
7
|
'web:outline-none web:focus:outline-none web:focus-visible:outline-none',
|
|
6
|
-
|
|
8
|
+
COLOR_TEXT_PRIMARY,
|
|
9
|
+
'underline decoration-slate-300 underline-offset-4',
|
|
10
|
+
TRANSITION_COLORS,
|
|
11
|
+
Platform.select({
|
|
12
|
+
web: 'data-[hover=true]:decoration-slate-900',
|
|
13
|
+
default: '',
|
|
14
|
+
}),
|
|
15
|
+
'web:data-[focus-visible=true]:ring-2 web:data-[focus-visible=true]:ring-slate-400/50 web:data-[focus-visible=true]:ring-offset-2',
|
|
7
16
|
]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { forwardRef, type ReactNode } from 'react';
|
|
2
2
|
import { Pressable, Text, type TextProps, View, type ViewProps } from 'react-native';
|
|
3
|
+
import { ArrowDropDown } from '@cdx-ui/icons';
|
|
3
4
|
import {
|
|
4
5
|
createSelect,
|
|
5
6
|
type ISelectContentProps,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
type ISelectValueProps,
|
|
11
12
|
} from '@cdx-ui/primitives';
|
|
12
13
|
import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
|
|
14
|
+
import { Icon, IconProps } from '../Icon';
|
|
13
15
|
import {
|
|
14
16
|
type SelectVariantProps,
|
|
15
17
|
selectContentVariants,
|
|
@@ -45,7 +47,7 @@ export interface SelectProps extends ViewProps, ISelectProps, SelectVariantProps
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const SelectRoot = forwardRef<View, SelectProps>(
|
|
48
|
-
({ variant = 'outline', size = '
|
|
50
|
+
({ variant = 'outline', size = 'default', className, children, style, ...props }, ref) => {
|
|
49
51
|
return (
|
|
50
52
|
<SelectPrimitive
|
|
51
53
|
ref={ref}
|
|
@@ -80,6 +82,7 @@ const SelectTrigger = forwardRef<View, SelectTriggerProps>(
|
|
|
80
82
|
return (
|
|
81
83
|
<SelectPrimitive.Trigger ref={ref} className={computedClassName} style={style} {...props}>
|
|
82
84
|
{children}
|
|
85
|
+
<SelectIcon as={ArrowDropDown} />
|
|
83
86
|
</SelectPrimitive.Trigger>
|
|
84
87
|
);
|
|
85
88
|
},
|
|
@@ -96,9 +99,9 @@ export interface SelectValueProps extends TextProps, ISelectValueProps {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
const SelectValue = forwardRef<Text, SelectValueProps>(({ className, style, ...props }, ref) => {
|
|
99
|
-
const {
|
|
102
|
+
const { size } = useSelectStyleContext();
|
|
100
103
|
|
|
101
|
-
const computedClassName = cn(selectValueVariants({
|
|
104
|
+
const computedClassName = cn(selectValueVariants({ size }), className);
|
|
102
105
|
|
|
103
106
|
return <SelectPrimitive.Value ref={ref} className={computedClassName} style={style} {...props} />;
|
|
104
107
|
});
|
|
@@ -109,17 +112,15 @@ SelectValue.displayName = 'Select.Value';
|
|
|
109
112
|
// STYLED ICON COMPONENT
|
|
110
113
|
// =============================================================================
|
|
111
114
|
|
|
112
|
-
export interface SelectIconProps extends
|
|
113
|
-
className?: string;
|
|
114
|
-
}
|
|
115
|
+
export interface SelectIconProps extends Omit<IconProps, 'children'> {}
|
|
115
116
|
|
|
116
|
-
const SelectIcon =
|
|
117
|
-
const {
|
|
117
|
+
const SelectIcon = ({ className, style, ...props }: SelectIconProps) => {
|
|
118
|
+
const { size } = useSelectStyleContext();
|
|
118
119
|
|
|
119
|
-
const computedClassName = cn(selectIconVariants({
|
|
120
|
+
const computedClassName = cn(selectIconVariants({ size }), className);
|
|
120
121
|
|
|
121
|
-
return <
|
|
122
|
-
}
|
|
122
|
+
return <Icon className={computedClassName} style={style} {...props} />;
|
|
123
|
+
};
|
|
123
124
|
|
|
124
125
|
SelectIcon.displayName = 'Select.Icon';
|
|
125
126
|
|