Skip to content

Commit 5f8e84b

Browse files
committed
fix(registry): ref types + remove unnecessary react imports
1 parent 27f67fc commit 5f8e84b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+438
-629
lines changed

packages/registry/src/default/components/ui/accordion.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { TextClassContext } from '@/registry/default/components/ui/text';
33
import { cn } from '@/registry/default/lib/utils';
44
import * as AccordionPrimitive from '@rn-primitives/accordion';
55
import { ChevronDown } from 'lucide-react-native';
6-
import * as React from 'react';
76
import { Platform, Pressable, View } from 'react-native';
87
import Animated, {
98
FadeOutUp,
@@ -17,9 +16,8 @@ import Animated, {
1716
function Accordion({
1817
children,
1918
...props
20-
}: Omit<AccordionPrimitive.RootProps, 'asChild'> & {
21-
ref?: React.RefObject<AccordionPrimitive.RootRef | null>;
22-
}) {
19+
}: Omit<AccordionPrimitive.RootProps, 'asChild'> &
20+
React.RefAttributes<AccordionPrimitive.RootRef>) {
2321
return (
2422
<LayoutAnimationConfig skipEntering>
2523
<AccordionPrimitive.Root
@@ -36,9 +34,7 @@ function AccordionItem({
3634
className,
3735
value,
3836
...props
39-
}: AccordionPrimitive.ItemProps & {
40-
ref?: React.RefObject<AccordionPrimitive.ItemRef | null>;
41-
}) {
37+
}: AccordionPrimitive.ItemProps & React.RefAttributes<AccordionPrimitive.ItemRef>) {
4238
return (
4339
<AccordionPrimitive.Item
4440
className={cn('border-border border-b', className)}
@@ -62,8 +58,7 @@ function AccordionTrigger({
6258
...props
6359
}: AccordionPrimitive.TriggerProps & {
6460
children?: React.ReactNode;
65-
ref?: React.RefObject<AccordionPrimitive.TriggerRef | null>;
66-
}) {
61+
} & React.RefAttributes<AccordionPrimitive.TriggerRef>) {
6762
const { isExpanded } = AccordionPrimitive.useItemContext();
6863

6964
const progress = useDerivedValue(
@@ -117,9 +112,7 @@ function AccordionContent({
117112
className,
118113
children,
119114
...props
120-
}: AccordionPrimitive.ContentProps & {
121-
ref?: React.RefObject<AccordionPrimitive.ContentRef | null>;
122-
}) {
115+
}: AccordionPrimitive.ContentProps & React.RefAttributes<AccordionPrimitive.ContentRef>) {
123116
const { isExpanded } = AccordionPrimitive.useItemContext();
124117
return (
125118
<TextClassContext.Provider value="text-sm">

packages/registry/src/default/components/ui/alert-dialog.tsx

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ function AlertDialogOverlay({
2020
className,
2121
children,
2222
...props
23-
}: Omit<AlertDialogPrimitive.OverlayProps, 'asChild'> & {
24-
ref?: React.RefObject<AlertDialogPrimitive.OverlayRef | null>;
25-
}) {
23+
}: Omit<AlertDialogPrimitive.OverlayProps, 'asChild'> &
24+
React.RefAttributes<AlertDialogPrimitive.OverlayRef>) {
2625
return (
2726
<FullWindowOverlay>
2827
<AlertDialogPrimitive.Overlay
@@ -48,10 +47,10 @@ function AlertDialogContent({
4847
className,
4948
portalHost,
5049
...props
51-
}: AlertDialogPrimitive.ContentProps & {
52-
ref?: React.RefObject<AlertDialogPrimitive.ContentRef | null>;
53-
portalHost?: string;
54-
}) {
50+
}: AlertDialogPrimitive.ContentProps &
51+
React.RefAttributes<AlertDialogPrimitive.ContentRef> & {
52+
portalHost?: string;
53+
}) {
5554
return (
5655
<AlertDialogPortal hostName={portalHost}>
5756
<AlertDialogOverlay>
@@ -90,9 +89,7 @@ function AlertDialogFooter({ className, ...props }: ViewProps) {
9089
function AlertDialogTitle({
9190
className,
9291
...props
93-
}: AlertDialogPrimitive.TitleProps & {
94-
ref?: React.RefObject<AlertDialogPrimitive.TitleRef | null>;
95-
}) {
92+
}: AlertDialogPrimitive.TitleProps & React.RefAttributes<AlertDialogPrimitive.TitleRef>) {
9693
return (
9794
<AlertDialogPrimitive.Title
9895
className={cn('text-foreground text-lg font-semibold', className)}
@@ -104,9 +101,8 @@ function AlertDialogTitle({
104101
function AlertDialogDescription({
105102
className,
106103
...props
107-
}: AlertDialogPrimitive.DescriptionProps & {
108-
ref?: React.RefObject<AlertDialogPrimitive.DescriptionRef | null>;
109-
}) {
104+
}: AlertDialogPrimitive.DescriptionProps &
105+
React.RefAttributes<AlertDialogPrimitive.DescriptionRef>) {
110106
return (
111107
<AlertDialogPrimitive.Description
112108
className={cn('text-muted-foreground text-sm', className)}
@@ -118,9 +114,7 @@ function AlertDialogDescription({
118114
function AlertDialogAction({
119115
className,
120116
...props
121-
}: AlertDialogPrimitive.ActionProps & {
122-
ref?: React.RefObject<AlertDialogPrimitive.ActionRef | null>;
123-
}) {
117+
}: AlertDialogPrimitive.ActionProps & React.RefAttributes<AlertDialogPrimitive.ActionRef>) {
124118
return (
125119
<TextClassContext.Provider value={buttonTextVariants({ className })}>
126120
<AlertDialogPrimitive.Action className={cn(buttonVariants(), className)} {...props} />
@@ -131,9 +125,7 @@ function AlertDialogAction({
131125
function AlertDialogCancel({
132126
className,
133127
...props
134-
}: AlertDialogPrimitive.CancelProps & {
135-
ref?: React.RefObject<AlertDialogPrimitive.CancelRef | null>;
136-
}) {
128+
}: AlertDialogPrimitive.CancelProps & React.RefAttributes<AlertDialogPrimitive.CancelRef>) {
137129
return (
138130
<TextClassContext.Provider value={buttonTextVariants({ className, variant: 'outline' })}>
139131
<AlertDialogPrimitive.Cancel

packages/registry/src/default/components/ui/alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function Alert({
2626
iconClassName,
2727
...props
2828
}: ViewProps &
29-
VariantProps<typeof alertVariants> & {
30-
ref?: React.RefObject<View | null>;
29+
VariantProps<typeof alertVariants> &
30+
React.RefAttributes<View> & {
3131
icon: LucideIcon;
3232
iconClassName?: string;
3333
}) {

packages/registry/src/default/components/ui/avatar.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { cn } from '@/registry/default/lib/utils';
22
import * as AvatarPrimitive from '@rn-primitives/avatar';
3-
import * as React from 'react';
43

54
function Avatar({
65
className,
76
...props
8-
}: AvatarPrimitive.RootProps & {
9-
ref?: React.RefObject<AvatarPrimitive.RootRef | null>;
10-
}) {
7+
}: AvatarPrimitive.RootProps & React.RefAttributes<AvatarPrimitive.RootRef>) {
118
return (
129
<AvatarPrimitive.Root
1310
className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
@@ -19,9 +16,7 @@ function Avatar({
1916
function AvatarImage({
2017
className,
2118
...props
22-
}: AvatarPrimitive.ImageProps & {
23-
ref?: React.RefObject<AvatarPrimitive.ImageRef | null>;
24-
}) {
19+
}: AvatarPrimitive.ImageProps & React.RefAttributes<AvatarPrimitive.ImageRef>) {
2520
return (
2621
<AvatarPrimitive.Image className={cn('aspect-square h-full w-full', className)} {...props} />
2722
);
@@ -30,9 +25,7 @@ function AvatarImage({
3025
function AvatarFallback({
3126
className,
3227
...props
33-
}: AvatarPrimitive.FallbackProps & {
34-
ref?: React.RefObject<AvatarPrimitive.FallbackRef | null>;
35-
}) {
28+
}: AvatarPrimitive.FallbackProps & React.RefAttributes<AvatarPrimitive.FallbackRef>) {
3629
return (
3730
<AvatarPrimitive.Fallback
3831
className={cn(

packages/registry/src/default/components/ui/badge.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ const badgeTextVariants = cva('text-xs font-semibold', {
4949
},
5050
});
5151

52-
type BadgeProps = ViewProps & {
53-
asChild?: boolean;
54-
} & VariantProps<typeof badgeVariants>;
52+
type BadgeProps = ViewProps &
53+
React.RefAttributes<View> & {
54+
asChild?: boolean;
55+
} & VariantProps<typeof badgeVariants>;
5556

5657
function Badge({ className, variant, asChild, ...props }: BadgeProps) {
5758
const Component = asChild ? Slot.View : View;

packages/registry/src/default/components/ui/button.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { TextClassContext } from '@/registry/default/components/ui/text';
22
import { cn } from '@/registry/default/lib/utils';
33
import { cva, type VariantProps } from 'class-variance-authority';
4-
import * as React from 'react';
54
import { Platform, Pressable } from 'react-native';
65

76
const buttonVariants = cva(
@@ -89,7 +88,9 @@ const buttonTextVariants = cva(
8988
}
9089
);
9190

92-
type ButtonProps = React.ComponentProps<typeof Pressable> & VariantProps<typeof buttonVariants>;
91+
type ButtonProps = React.ComponentProps<typeof Pressable> &
92+
React.RefAttributes<typeof Pressable> &
93+
VariantProps<typeof buttonVariants>;
9394

9495
function Button({ className, variant, size, ...props }: ButtonProps) {
9596
return (

packages/registry/src/default/components/ui/card.tsx

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { Text, TextClassContext } from '@/registry/new-york/components/ui/text';
22
import { cn } from '@/registry/new-york/lib/utils';
3-
import * as React from 'react';
43
import { View, type ViewProps } from 'react-native';
54

6-
function Card({
7-
className,
8-
...props
9-
}: ViewProps & {
10-
ref?: React.RefObject<View | null>;
11-
}) {
5+
function Card({ className, ...props }: ViewProps & React.RefAttributes<View>) {
126
return (
137
<TextClassContext.Provider value="text-card-foreground">
148
<View
@@ -22,21 +16,14 @@ function Card({
2216
);
2317
}
2418

25-
function CardHeader({
26-
className,
27-
...props
28-
}: ViewProps & {
29-
ref?: React.RefObject<View | null>;
30-
}) {
19+
function CardHeader({ className, ...props }: ViewProps & React.RefAttributes<View>) {
3120
return <View className={cn('flex flex-col gap-1.5 p-6', className)} {...props} />;
3221
}
3322

3423
function CardTitle({
3524
className,
3625
...props
37-
}: React.ComponentProps<typeof Text> & {
38-
ref?: React.RefObject<Text | null>;
39-
}) {
26+
}: React.ComponentProps<typeof Text> & React.RefAttributes<Text>) {
4027
return (
4128
<Text
4229
role="heading"
@@ -50,27 +37,15 @@ function CardTitle({
5037
function CardDescription({
5138
className,
5239
...props
53-
}: React.ComponentProps<typeof Text> & {
54-
ref?: React.RefObject<Text | null>;
55-
}) {
40+
}: React.ComponentProps<typeof Text> & React.RefAttributes<Text>) {
5641
return <Text className={cn('text-muted-foreground text-sm', className)} {...props} />;
5742
}
5843

59-
function CardContent({
60-
className,
61-
...props
62-
}: ViewProps & {
63-
ref?: React.RefObject<View | null>;
64-
}) {
44+
function CardContent({ className, ...props }: ViewProps & React.RefAttributes<View>) {
6545
return <View className={cn('p-6 pt-0', className)} {...props} />;
6646
}
6747

68-
function CardFooter({
69-
className,
70-
...props
71-
}: ViewProps & {
72-
ref?: React.RefObject<View | null>;
73-
}) {
48+
function CardFooter({ className, ...props }: ViewProps & React.RefAttributes<View>) {
7449
return <View className={cn('flex flex-row items-center p-6 pt-0', className)} {...props} />;
7550
}
7651

packages/registry/src/default/components/ui/checkbox.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Icon } from '@/registry/default/components/ui/icon';
22
import { cn } from '@/registry/default/lib/utils';
33
import * as CheckboxPrimitive from '@rn-primitives/checkbox';
44
import { Check } from 'lucide-react-native';
5-
import * as React from 'react';
65
import { Platform } from 'react-native';
76

87
const DEFAULT_HIT_SLOP = 24;
@@ -13,12 +12,12 @@ function Checkbox({
1312
indicatorClassName,
1413
iconClassName,
1514
...props
16-
}: CheckboxPrimitive.RootProps & {
17-
checkedClassName?: string;
18-
indicatorClassName?: string;
19-
iconClassName?: string;
20-
ref?: React.RefObject<CheckboxPrimitive.RootRef | null>;
21-
}) {
15+
}: CheckboxPrimitive.RootProps &
16+
React.RefAttributes<CheckboxPrimitive.RootRef> & {
17+
checkedClassName?: string;
18+
indicatorClassName?: string;
19+
iconClassName?: string;
20+
}) {
2221
return (
2322
<CheckboxPrimitive.Root
2423
className={cn(

0 commit comments

Comments
 (0)