171 bug allow passing refs to inputbutton components (#172)
* Refactor UI components to use ComponentPropsWithRef for improved type safety * Updated dependencies and removed duplicate instance of Tslint since it's already provided in the Next.js config
This commit is contained in:
committed by
GitHub
parent
cdf7cc6f00
commit
0808b91e0d
@@ -26,7 +26,7 @@ const alertVariants = cva(
|
||||
);
|
||||
|
||||
const Alert: React.FC<
|
||||
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
|
||||
React.ComponentPropsWithRef<'div'> & VariantProps<typeof alertVariants>
|
||||
> = ({ className, variant, ...props }) => (
|
||||
<div
|
||||
role="alert"
|
||||
@@ -36,7 +36,7 @@ const Alert: React.FC<
|
||||
);
|
||||
Alert.displayName = 'Alert';
|
||||
|
||||
const AlertTitle: React.FC<React.HTMLAttributes<HTMLHeadingElement>> = ({
|
||||
const AlertTitle: React.FC<React.ComponentPropsWithRef<'h5'>> = ({
|
||||
className,
|
||||
...props
|
||||
}) => (
|
||||
@@ -48,7 +48,7 @@ const AlertTitle: React.FC<React.HTMLAttributes<HTMLHeadingElement>> = ({
|
||||
AlertTitle.displayName = 'AlertTitle';
|
||||
|
||||
const AlertDescription: React.FC<
|
||||
React.HTMLAttributes<HTMLParagraphElement>
|
||||
React.ComponentPropsWithRef<'div'>
|
||||
> = ({ className, ...props }) => (
|
||||
<div
|
||||
className={cn('text-sm font-normal [&_p]:leading-relaxed', className)}
|
||||
|
||||
@@ -37,7 +37,7 @@ const buttonVariants = cva(
|
||||
);
|
||||
|
||||
export interface ButtonProps
|
||||
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
||||
extends React.ComponentPropsWithRef<'button'>,
|
||||
VariantProps<typeof buttonVariants> {
|
||||
asChild?: boolean;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ const FormItemContext = React.createContext<FormItemContextValue>(
|
||||
{} as FormItemContextValue,
|
||||
);
|
||||
|
||||
const FormItem: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
||||
const FormItem: React.FC<React.ComponentPropsWithRef<'div'>> = ({
|
||||
className,
|
||||
...props
|
||||
}) => {
|
||||
@@ -118,7 +118,7 @@ const FormControl: React.FC<React.ComponentPropsWithoutRef<typeof Slot>> = ({
|
||||
};
|
||||
FormControl.displayName = 'FormControl';
|
||||
|
||||
const FormDescription: React.FC<React.HTMLAttributes<HTMLParagraphElement>> = ({
|
||||
const FormDescription: React.FC<React.ComponentPropsWithRef<'p'>> = ({
|
||||
className,
|
||||
...props
|
||||
}) => {
|
||||
@@ -134,7 +134,7 @@ const FormDescription: React.FC<React.HTMLAttributes<HTMLParagraphElement>> = ({
|
||||
};
|
||||
FormDescription.displayName = 'FormDescription';
|
||||
|
||||
const FormMessage: React.FC<React.HTMLAttributes<HTMLParagraphElement>> = ({
|
||||
const FormMessage: React.FC<React.ComponentPropsWithRef<'p'>> = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as React from 'react';
|
||||
|
||||
import { cn } from '../lib/utils';
|
||||
|
||||
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
|
||||
export type InputProps = React.ComponentPropsWithRef<'input'>;
|
||||
|
||||
const Input: React.FC<InputProps> = ({
|
||||
className,
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as React from 'react';
|
||||
|
||||
import { cn } from '../lib/utils';
|
||||
|
||||
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
||||
export type TextareaProps = React.ComponentPropsWithRef<'textarea'>;
|
||||
|
||||
const Textarea: React.FC<TextareaProps> = ({ className, ...props }) => {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user