diff --git a/src/design-system/Button.tsx b/src/design-system/Button.tsx index 56697059..6b19e27f 100644 --- a/src/design-system/Button.tsx +++ b/src/design-system/Button.tsx @@ -1,5 +1,5 @@ import { VariantProps, cva } from 'cva'; -import { ElementType, ReactNode, forwardRef } from 'react'; +import { ElementType, ReactNode, RefObject } from 'react'; const styles = cva({ base: 'inline-flex items-center justify-center gap-2 leading-none whitespace-nowrap focus-visible:outline-2 outline-offset-2', @@ -68,44 +68,36 @@ export interface ButtonProps extends VariantProps { href?: string; external?: boolean; className?: string; + ref?: RefObject; } -export const Button = forwardRef< - HTMLButtonElement | HTMLAnchorElement, - ButtonProps ->( - ( - { - children, - as, - variant = 'contained', - color = 'primary', - size = 'medium', - type = 'button', - onClick, - disabled, - href, - external, - className, - }, - ref, - ) => { - const Element = as ? as : href ? 'a' : 'button'; - return ( - - {children} - - ); - }, -); - -Button.displayName = 'Button'; +export const Button = ({ + children, + as, + variant = 'contained', + color = 'primary', + size = 'medium', + type = 'button', + onClick, + disabled, + href, + external, + className, + ref, +}: ButtonProps) => { + const Element = as ? as : href ? 'a' : 'button'; + return ( + + {children} + + ); +}; diff --git a/src/design-system/Dialog.tsx b/src/design-system/Dialog.tsx index 822f115c..b29a8b5a 100644 --- a/src/design-system/Dialog.tsx +++ b/src/design-system/Dialog.tsx @@ -3,50 +3,51 @@ import * as DialogPrimitive from '@radix-ui/react-dialog'; import { cx } from 'cva'; import { X } from 'lucide-react'; -import { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react'; +import { ComponentProps } from 'react'; export const Dialog = DialogPrimitive.Root; export const DialogTrigger = DialogPrimitive.Trigger; export const DialogPortal = DialogPrimitive.Portal; -export const DialogOverlay = forwardRef< - ElementRef, - ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +export const DialogOverlay = ({ + className, + ref, + ...props +}: ComponentProps) => ( -)); -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; +); -export const DialogContent = forwardRef< - ElementRef, - ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( +export const DialogContent = ({ + className, + children, + ref, + ...props +}: ComponentProps) => ( {children} - + Close -)); -DialogContent.displayName = DialogPrimitive.Content.displayName; +); export const DialogClose = DialogPrimitive.Close; export const DialogTitle = DialogPrimitive.Title; diff --git a/src/design-system/Select.tsx b/src/design-system/Select.tsx index 8cd8e1bf..23294635 100644 --- a/src/design-system/Select.tsx +++ b/src/design-system/Select.tsx @@ -12,13 +12,7 @@ import { Loader2, XCircle, } from 'lucide-react'; -import { - ComponentProps, - ComponentPropsWithoutRef, - ElementRef, - forwardRef, - useId, -} from 'react'; +import { ComponentProps, useId } from 'react'; export const Select = ({ ...props @@ -26,24 +20,27 @@ export const Select = ({ ); -Select.FilterTrigger = forwardRef< - ElementRef, - ComponentPropsWithoutRef & { - label: string; - isLoading?: boolean; - isResettable?: boolean; - onReset?: () => void; - } ->(function SelectFilterTrigger( - { className, disabled, label, isLoading, isResettable, onReset, ...props }, +Select.FilterTrigger = function SelectFilterTrigger({ + className, + disabled, + label, + isLoading, + isResettable, + onReset, ref, -) { + ...props +}: ComponentProps & { + label: string; + isLoading?: boolean; + isResettable?: boolean; + onReset?: () => void; +}) { const id = useId(); return (
@@ -51,7 +48,7 @@ Select.FilterTrigger = forwardRef< id={id} disabled={disabled} className={cx( - 'border-ghost-main-dark-bg focus-visible:border-text-secondary flex w-full items-center justify-between rounded-full border-2 px-2 py-2 text-left text-lg font-bold leading-none outline-none disabled:opacity-50 sm:gap-1 sm:px-6 [&>span]:truncate [&>span]:whitespace-nowrap', + 'flex w-full items-center justify-between rounded-full border-2 border-ghost-main-dark-bg px-2 py-2 text-left text-lg font-bold leading-none outline-none focus-visible:border-text-secondary disabled:opacity-50 sm:gap-1 sm:px-6 [&>span]:truncate [&>span]:whitespace-nowrap', className, )} {...props} @@ -68,7 +65,7 @@ Select.FilterTrigger = forwardRef< {!isLoading && ( @@ -80,7 +77,7 @@ Select.FilterTrigger = forwardRef< {/* Reset Button */} {isResettable && !isLoading && (
); -}); +}; -Select.SortTrigger = forwardRef< - ElementRef, - ComponentPropsWithoutRef & { - isLoading?: boolean; - } ->(function SelectSortTrigger({ className, isLoading, ...props }, ref) { +Select.SortTrigger = function SelectSortTrigger({ + className, + isLoading, + ref, + ...props +}: ComponentProps & { + isLoading?: boolean; +}) { const id = useId(); return (
@@ -117,24 +116,26 @@ Select.SortTrigger = forwardRef< {isLoading ? ( ) : ( - + )}
); -}); +}; -Select.Content = forwardRef< - ElementRef, - ComponentPropsWithoutRef ->(function SelectContent({ children, className, ...props }, ref) { +Select.Content = function SelectContent({ + children, + className, + ref, + ...props +}: ComponentProps) { return ( ); -}); +}; -Select.Item = forwardRef< - ElementRef, - ComponentPropsWithoutRef ->(function SelectItem({ children, className, ...props }, ref) { +Select.Item = function SelectItem({ + children, + className, + ref, + ...props +}: ComponentProps) { return ( ); -}); +}; diff --git a/src/ui/alert-dialog.tsx b/src/ui/alert-dialog.tsx index 078d0b35..7d9bc27a 100644 --- a/src/ui/alert-dialog.tsx +++ b/src/ui/alert-dialog.tsx @@ -1,49 +1,49 @@ -"use client" +'use client'; -import * as React from "react" -import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" +import * as React from 'react'; +import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'; -import { cn } from "@/lib/utils/utils" -import { buttonVariants } from "@/ui/button" +import { cn } from '@/lib/utils/utils'; +import { buttonVariants } from '@/ui/button'; -const AlertDialog = AlertDialogPrimitive.Root +const AlertDialog = AlertDialogPrimitive.Root; -const AlertDialogTrigger = AlertDialogPrimitive.Trigger +const AlertDialogTrigger = AlertDialogPrimitive.Trigger; -const AlertDialogPortal = AlertDialogPrimitive.Portal +const AlertDialogPortal = AlertDialogPrimitive.Portal; -const AlertDialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const AlertDialogOverlay = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName +); -const AlertDialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const AlertDialogContent = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName +); const AlertDialogHeader = ({ className, @@ -51,13 +51,12 @@ const AlertDialogHeader = ({ }: React.HTMLAttributes) => (
-) -AlertDialogHeader.displayName = "AlertDialogHeader" +); const AlertDialogFooter = ({ className, @@ -65,66 +64,64 @@ const AlertDialogFooter = ({ }: React.HTMLAttributes) => (
-) -AlertDialogFooter.displayName = "AlertDialogFooter" +); -const AlertDialogTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const AlertDialogTitle = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName +); -const AlertDialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const AlertDialogDescription = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -AlertDialogDescription.displayName = - AlertDialogPrimitive.Description.displayName +); -const AlertDialogAction = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const AlertDialogAction = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName +); -const AlertDialogCancel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const AlertDialogCancel = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName +); export { AlertDialog, @@ -138,4 +135,4 @@ export { AlertDialogDescription, AlertDialogAction, AlertDialogCancel, -} +}; diff --git a/src/ui/button.tsx b/src/ui/button.tsx index a062a7f3..105cf7b6 100644 --- a/src/ui/button.tsx +++ b/src/ui/button.tsx @@ -34,20 +34,25 @@ export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { asChild?: boolean; + ref?: React.RefObject; } -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : 'button'; - return ( - - ); - }, -); -Button.displayName = 'Button'; +const Button = ({ + className, + variant, + size, + asChild = false, + ref, + ...props +}: ButtonProps) => { + const Comp = asChild ? Slot : 'button'; + return ( + + ); +}; export { Button, buttonVariants }; diff --git a/src/ui/checkbox.tsx b/src/ui/checkbox.tsx index 54a0523f..af891e00 100644 --- a/src/ui/checkbox.tsx +++ b/src/ui/checkbox.tsx @@ -1,30 +1,30 @@ -"use client" +'use client'; -import * as React from "react" -import * as CheckboxPrimitive from "@radix-ui/react-checkbox" -import { Check } from "lucide-react" +import * as React from 'react'; +import * as CheckboxPrimitive from '@radix-ui/react-checkbox'; +import { Check } from 'lucide-react'; -import { cn } from "@/lib/utils/utils" +import { cn } from '@/lib/utils/utils'; -const Checkbox = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const Checkbox = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -Checkbox.displayName = CheckboxPrimitive.Root.displayName +); -export { Checkbox } +export { Checkbox }; diff --git a/src/ui/command.tsx b/src/ui/command.tsx index f9590e9c..601f2546 100644 --- a/src/ui/command.tsx +++ b/src/ui/command.tsx @@ -8,10 +8,11 @@ import { Search } from 'lucide-react'; import { cn } from '@/lib/utils/utils'; import { Dialog, DialogContent } from '@/ui/dialog'; -const Command = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const Command = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); -Command.displayName = CommandPrimitive.displayName; +); interface CommandDialogProps extends DialogProps {} @@ -37,10 +37,11 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => { ); }; -const CommandInput = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const CommandInput = ({ + className, + ref, + ...props +}: React.ComponentProps) => (
-)); - -CommandInput.displayName = CommandPrimitive.Input.displayName; +); -const CommandList = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const CommandList = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); +); -CommandList.displayName = CommandPrimitive.List.displayName; - -const CommandEmpty = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->((props, ref) => ( +const CommandEmpty = ( + props: React.ComponentProps, +) => ( -)); +); -CommandEmpty.displayName = CommandPrimitive.Empty.displayName; - -const CommandGroup = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const CommandGroup = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); +); -CommandGroup.displayName = CommandPrimitive.Group.displayName; - -const CommandSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const CommandSeparator = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); -CommandSeparator.displayName = CommandPrimitive.Separator.displayName; +); -const CommandItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const CommandItem = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); - -CommandItem.displayName = CommandPrimitive.Item.displayName; +); const CommandShortcut = ({ className, diff --git a/src/ui/dialog.tsx b/src/ui/dialog.tsx index 3c48dd27..4fd8844f 100644 --- a/src/ui/dialog.tsx +++ b/src/ui/dialog.tsx @@ -1,45 +1,47 @@ -"use client" +'use client'; -import * as React from "react" -import * as DialogPrimitive from "@radix-ui/react-dialog" -import { X } from "lucide-react" +import * as React from 'react'; +import * as DialogPrimitive from '@radix-ui/react-dialog'; +import { X } from 'lucide-react'; -import { cn } from "@/lib/utils/utils" +import { cn } from '@/lib/utils/utils'; -const Dialog = DialogPrimitive.Root +const Dialog = DialogPrimitive.Root; -const DialogTrigger = DialogPrimitive.Trigger +const DialogTrigger = DialogPrimitive.Trigger; -const DialogPortal = DialogPrimitive.Portal +const DialogPortal = DialogPrimitive.Portal; -const DialogClose = DialogPrimitive.Close +const DialogClose = DialogPrimitive.Close; -const DialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const DialogOverlay = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName +); -const DialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( +const DialogContent = ({ + className, + children, + ref, + ...props +}: React.ComponentProps) => ( @@ -50,8 +52,7 @@ const DialogContent = React.forwardRef< -)) -DialogContent.displayName = DialogPrimitive.Content.displayName +); const DialogHeader = ({ className, @@ -59,13 +60,13 @@ const DialogHeader = ({ }: React.HTMLAttributes) => (
-) -DialogHeader.displayName = "DialogHeader" +); +DialogHeader.displayName = 'DialogHeader'; const DialogFooter = ({ className, @@ -73,40 +74,40 @@ const DialogFooter = ({ }: React.HTMLAttributes) => (
-) -DialogFooter.displayName = "DialogFooter" +); +DialogFooter.displayName = 'DialogFooter'; -const DialogTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const DialogTitle = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -DialogTitle.displayName = DialogPrimitive.Title.displayName +); -const DialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const DialogDescription = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -DialogDescription.displayName = DialogPrimitive.Description.displayName +); export { Dialog, @@ -119,4 +120,4 @@ export { DialogFooter, DialogTitle, DialogDescription, -} +}; diff --git a/src/ui/input.tsx b/src/ui/input.tsx index 09c4c8ab..962cee5d 100644 --- a/src/ui/input.tsx +++ b/src/ui/input.tsx @@ -3,25 +3,23 @@ import * as React from 'react'; import { cn } from '@/lib/utils/utils'; export interface InputProps - extends React.InputHTMLAttributes {} - -const Input = React.forwardRef( - ({ className, type, ...props }, ref) => { - return ( - - ); - }, -); -Input.displayName = 'Input'; + extends React.InputHTMLAttributes { + ref?: React.RefObject; +} +const Input = ({ className, type, ref, ...props }: InputProps) => { + return ( + + ); +}; interface InputErrorProps { children: React.ReactNode; } diff --git a/src/ui/label.tsx b/src/ui/label.tsx index 82a2670b..e1884f74 100644 --- a/src/ui/label.tsx +++ b/src/ui/label.tsx @@ -10,17 +10,17 @@ const labelVariants = cva({ base: 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', }); -const Label = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & - VariantProps ->(({ className, ...props }, ref) => ( +const Label = ({ + className, + ref, + ...props +}: React.ComponentProps & + VariantProps) => ( -)); -Label.displayName = LabelPrimitive.Root.displayName; +); export { Label }; diff --git a/src/ui/multiselect.tsx b/src/ui/multiselect.tsx index da3339c3..0a56a452 100644 --- a/src/ui/multiselect.tsx +++ b/src/ui/multiselect.tsx @@ -57,235 +57,228 @@ interface MultiSelectProps animation?: number; value: string[]; onValueChange: (value: string[]) => void; + ref?: React.RefObject; } -const MultiSelect = React.forwardRef( - ( - { - className, - variant, - asChild = false, - options, - defaultValue, - value, - onValueChange, - disabled, - placeholder, - animation = 0, - ...props - }, - ref, - ) => { - const selectedValuesSet = React.useRef(new Set(value)); - const [isPopoverOpen, setIsPopoverOpen] = React.useState(false); - const [isAnimating, setIsAnimating] = React.useState(animation > 0); +const MultiSelect = ({ + className, + variant, + asChild = false, + options, + defaultValue, + value, + onValueChange, + disabled, + placeholder, + animation = 0, + ref, + ...props +}: MultiSelectProps) => { + const selectedValuesSet = React.useRef(new Set(value)); + const [isPopoverOpen, setIsPopoverOpen] = React.useState(false); + const [isAnimating, setIsAnimating] = React.useState(animation > 0); - React.useEffect(() => { - selectedValuesSet.current = new Set(value); - }, [value]); + React.useEffect(() => { + selectedValuesSet.current = new Set(value); + }, [value]); - const handleInputKeyDown = (event: any) => { - if (event.key === 'Enter') { - setIsPopoverOpen(true); - } else if (event.key === 'Backspace' && !event.target.value) { - value.pop(); - onValueChange([...value]); - selectedValuesSet.current.delete(value[value.length - 1]); - onValueChange([...value]); - } - }; + const handleInputKeyDown = (event: any) => { + if (event.key === 'Enter') { + setIsPopoverOpen(true); + } else if (event.key === 'Backspace' && !event.target.value) { + value.pop(); + onValueChange([...value]); + selectedValuesSet.current.delete(value[value.length - 1]); + onValueChange([...value]); + } + }; - const toggleOption = (valueItem: string) => { - if (selectedValuesSet.current.has(valueItem)) { - selectedValuesSet.current.delete(valueItem); - onValueChange(value.filter((v) => v !== valueItem)); - } else { - selectedValuesSet.current.add(valueItem); - onValueChange([...value, valueItem]); - } - onValueChange(Array.from(selectedValuesSet.current)); - }; + const toggleOption = (valueItem: string) => { + if (selectedValuesSet.current.has(valueItem)) { + selectedValuesSet.current.delete(valueItem); + onValueChange(value.filter((v) => v !== valueItem)); + } else { + selectedValuesSet.current.add(valueItem); + onValueChange([...value, valueItem]); + } + onValueChange(Array.from(selectedValuesSet.current)); + }; - return ( - - - - , - ) => { - onValueChange([]); - selectedValuesSet.current.clear(); - onValueChange([]); - event.stopPropagation(); - }} - /> - - -
-
- ) : ( -
- {placeholder} - -
- )} - - - setIsPopoverOpen(false)} - onInteractOutside={(event) => { - if (!event.defaultPrevented) { - setIsPopoverOpen(false); - } + return ( + + + + , + ) => { + onValueChange([]); + selectedValuesSet.current.clear(); + onValueChange([]); + event.stopPropagation(); + }} + /> + + +
+
+ ) : ( +
+ {placeholder} + +
+ )} + + + setIsPopoverOpen(false)} + onInteractOutside={(event) => { + if (!event.defaultPrevented) { + setIsPopoverOpen(false); + } + }} + > + + + + No results found. + + {options.map((option) => { + const isSelected = selectedValuesSet.current.has(option.value); + return ( setIsPopoverOpen(false)} + key={option.value} + onSelect={() => toggleOption(option.value)} style={{ pointerEvents: 'auto', opacity: 1, }} - className="flex-1 cursor-pointer justify-center" + className="cursor-pointer" > - Close +
+ +
+ {option.icon && ( + + )} + {option.label}
- -
-
-
-
- {animation > 0 && value.length > 0 && ( - setIsAnimating(!isAnimating)} - /> - )} - - ); - }, -); - -MultiSelect.displayName = 'MultiSelect'; + ); + })} + + + +
+ {value.length > 0 && ( + <> + { + onValueChange([]); + selectedValuesSet.current.clear(); + onValueChange([]); + }} + style={{ + pointerEvents: 'auto', + opacity: 1, + }} + className="flex-1 cursor-pointer justify-center" + > + Clear + + + + )} + + setIsPopoverOpen(false)} + style={{ + pointerEvents: 'auto', + opacity: 1, + }} + className="flex-1 cursor-pointer justify-center" + > + Close + +
+
+ + + + {animation > 0 && value.length > 0 && ( + setIsAnimating(!isAnimating)} + /> + )} + + ); +}; export default MultiSelect; diff --git a/src/ui/popover.tsx b/src/ui/popover.tsx index b77c40b3..8c9b10dd 100644 --- a/src/ui/popover.tsx +++ b/src/ui/popover.tsx @@ -9,10 +9,13 @@ const Popover = PopoverPrimitive.Root; const PopoverTrigger = PopoverPrimitive.Trigger; -const PopoverContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, align = 'center', sideOffset = 4, ...props }, ref) => ( +const PopoverContent = ({ + className, + align = 'center', + sideOffset = 4, + ref, + ...props +}: React.ComponentProps) => ( -)); -PopoverContent.displayName = PopoverPrimitive.Content.displayName; +); export { Popover, PopoverTrigger, PopoverContent }; diff --git a/src/ui/select.tsx b/src/ui/select.tsx index 1b2d7a3e..89ce0946 100644 --- a/src/ui/select.tsx +++ b/src/ui/select.tsx @@ -1,26 +1,28 @@ -"use client" +'use client'; -import * as React from "react" -import * as SelectPrimitive from "@radix-ui/react-select" -import { Check, ChevronDown, ChevronUp } from "lucide-react" +import * as React from 'react'; +import * as SelectPrimitive from '@radix-ui/react-select'; +import { Check, ChevronDown, ChevronUp } from 'lucide-react'; -import { cn } from "@/lib/utils/utils" +import { cn } from '@/lib/utils/utils'; -const Select = SelectPrimitive.Root +const Select = SelectPrimitive.Root; -const SelectGroup = SelectPrimitive.Group +const SelectGroup = SelectPrimitive.Group; -const SelectValue = SelectPrimitive.Value +const SelectValue = SelectPrimitive.Value; -const SelectTrigger = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( +const SelectTrigger = ({ + className, + children, + ref, + ...props +}: React.ComponentProps) => ( span]:line-clamp-1", - className + 'flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1', + className, )} {...props} > @@ -29,56 +31,57 @@ const SelectTrigger = React.forwardRef< -)) -SelectTrigger.displayName = SelectPrimitive.Trigger.displayName +); -const SelectScrollUpButton = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const SelectScrollUpButton = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName +); -const SelectScrollDownButton = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const SelectScrollDownButton = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -SelectScrollDownButton.displayName = - SelectPrimitive.ScrollDownButton.displayName +); -const SelectContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, position = "popper", ...props }, ref) => ( +const SelectContent = ({ + className, + children, + position = 'popper', + ref, + ...props +}: React.ComponentProps) => ( {children} @@ -96,30 +99,31 @@ const SelectContent = React.forwardRef< -)) -SelectContent.displayName = SelectPrimitive.Content.displayName +); -const SelectLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const SelectLabel = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -SelectLabel.displayName = SelectPrimitive.Label.displayName +); -const SelectItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( +const SelectItem = ({ + className, + children, + ref, + ...props +}: React.ComponentProps) => ( @@ -131,20 +135,19 @@ const SelectItem = React.forwardRef< {children} -)) -SelectItem.displayName = SelectPrimitive.Item.displayName +); -const SelectSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const SelectSeparator = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)) -SelectSeparator.displayName = SelectPrimitive.Separator.displayName +); export { Select, @@ -157,4 +160,4 @@ export { SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, -} +}; diff --git a/src/ui/separator.tsx b/src/ui/separator.tsx index 22ca2556..0990a805 100644 --- a/src/ui/separator.tsx +++ b/src/ui/separator.tsx @@ -1,31 +1,28 @@ -"use client" +'use client'; -import * as React from "react" -import * as SeparatorPrimitive from "@radix-ui/react-separator" +import * as React from 'react'; +import * as SeparatorPrimitive from '@radix-ui/react-separator'; -import { cn } from "@/lib/utils/utils" +import { cn } from '@/lib/utils/utils'; -const Separator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->( - ( - { className, orientation = "horizontal", decorative = true, ...props }, - ref - ) => ( - - ) -) -Separator.displayName = SeparatorPrimitive.Root.displayName +const Separator = ({ + className, + orientation = 'horizontal', + decorative = true, + ref, + ...props +}: React.ComponentProps) => ( + +); -export { Separator } +export { Separator }; diff --git a/src/ui/sheet.tsx b/src/ui/sheet.tsx index 2e955333..b907ba23 100644 --- a/src/ui/sheet.tsx +++ b/src/ui/sheet.tsx @@ -15,10 +15,11 @@ const SheetClose = SheetPrimitive.Close; const SheetPortal = SheetPrimitive.Portal; -const SheetOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const SheetOverlay = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); -SheetOverlay.displayName = SheetPrimitive.Overlay.displayName; +); const sheetVariants = cva({ base: 'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500 overflow-y-auto', @@ -48,13 +48,16 @@ const sheetVariants = cva({ }); interface SheetContentProps - extends React.ComponentPropsWithoutRef, + extends React.ComponentProps, VariantProps {} -const SheetContent = React.forwardRef< - React.ElementRef, - SheetContentProps ->(({ side = 'right', className, children, ...props }, ref) => ( +const SheetContent = ({ + side = 'right', + className, + children, + ref, + ...props +}: SheetContentProps) => ( -)); -SheetContent.displayName = SheetPrimitive.Content.displayName; +); const SheetHeader = ({ className, @@ -100,29 +102,29 @@ const SheetFooter = ({ ); SheetFooter.displayName = 'SheetFooter'; -const SheetTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const SheetTitle = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); -SheetTitle.displayName = SheetPrimitive.Title.displayName; +); -const SheetDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( +const SheetDescription = ({ + className, + ref, + ...props +}: React.ComponentProps) => ( -)); -SheetDescription.displayName = SheetPrimitive.Description.displayName; +); export { Sheet, diff --git a/src/ui/textarea.tsx b/src/ui/textarea.tsx index 2b8771f5..4f27bdb3 100644 --- a/src/ui/textarea.tsx +++ b/src/ui/textarea.tsx @@ -1,24 +1,23 @@ -import * as React from "react" +import * as React from 'react'; -import { cn } from "@/lib/utils/utils" +import { cn } from '@/lib/utils/utils'; export interface TextareaProps - extends React.TextareaHTMLAttributes {} + extends React.TextareaHTMLAttributes { + ref?: React.RefObject; +} -const Textarea = React.forwardRef( - ({ className, ...props }, ref) => { - return ( -