codemod update components

This commit is contained in:
ppc
2025-12-30 12:20:36 +00:00
parent 8021ee3a7a
commit 6c692b71fa
21 changed files with 730 additions and 572 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ export function AMCard(props: AMCardActionProps & { title: string, titlePerforms
</div> </div>
</div> </div>
{props.actionClicked && ( {props.actionClicked && (
<Button className="flex-shrink-0" variant="ghost" size="icon" disabled={props.actionDisabled} onClick={props.actionClicked}> <Button className="shrink-0" variant="ghost" size="icon" disabled={props.actionDisabled} onClick={props.actionClicked}>
{props.actionIcon ?? <ChevronRight className="h-4 w-4"/>} {props.actionIcon ?? <ChevronRight className="h-4 w-4"/>}
</Button> </Button>
)} )}
+1 -1
View File
@@ -5,7 +5,7 @@ export function AMHeader(props: { title: string, children?: Readonly<React.React
return ( return (
<> <>
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<h2 className="text-4xl font-bold select-none flex-grow">{props.title}</h2> <h2 className="text-4xl font-bold select-none grow">{props.title}</h2>
{props.children} {props.children}
</div> </div>
<Separator/> <Separator/>
@@ -2,7 +2,7 @@ import {Loader} from "lucide-react";
export function LoadingIndicator() { export function LoadingIndicator() {
return ( return (
<div className="flex flex-grow gap-2 justify-center items-center text-gray-500 py-5"> <div className="flex grow gap-2 justify-center items-center text-gray-500 py-5">
<Loader className="h-8 w-8"/> <Loader className="h-8 w-8"/>
<span className="text-center">Loading...</span> <span className="text-center">Loading...</span>
</div> </div>
+88 -70
View File
@@ -10,37 +10,43 @@ const AlertDialogTrigger = AlertDialogPrimitive.Trigger
const AlertDialogPortal = AlertDialogPrimitive.Portal const AlertDialogPortal = AlertDialogPrimitive.Portal
const AlertDialogOverlay = React.forwardRef< const AlertDialogOverlay = (
React.ElementRef<typeof AlertDialogPrimitive.Overlay>, {
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay> ref,
>(({ className, ...props }, ref) => ( className,
<AlertDialogPrimitive.Overlay ...props
}: React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay> & {
ref: React.RefObject<React.ElementRef<typeof AlertDialogPrimitive.Overlay>>;
}
) => (<AlertDialogPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
ref={ref}
/>)
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
const AlertDialogContent = (
{
ref,
className,
...props
}: React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> & {
ref: React.RefObject<React.ElementRef<typeof AlertDialogPrimitive.Content>>;
}
) => (<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
className={cn( className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className className
)} )}
{...props} {...props}
ref={ref}
/> />
)) </AlertDialogPortal>)
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
>(({ className, ...props }, ref) => (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
/>
</AlertDialogPortal>
))
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
const AlertDialogHeader = ({ const AlertDialogHeader = ({
@@ -71,57 +77,69 @@ const AlertDialogFooter = ({
) )
AlertDialogFooter.displayName = "AlertDialogFooter" AlertDialogFooter.displayName = "AlertDialogFooter"
const AlertDialogTitle = React.forwardRef< const AlertDialogTitle = (
React.ElementRef<typeof AlertDialogPrimitive.Title>, {
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title> ref,
>(({ className, ...props }, ref) => ( className,
<AlertDialogPrimitive.Title ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title> & {
className={cn("text-lg font-semibold", className)} ref: React.RefObject<React.ElementRef<typeof AlertDialogPrimitive.Title>>;
{...props} }
/> ) => (<AlertDialogPrimitive.Title
)) ref={ref}
className={cn("text-lg font-semibold", className)}
{...props}
/>)
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
const AlertDialogDescription = React.forwardRef< const AlertDialogDescription = (
React.ElementRef<typeof AlertDialogPrimitive.Description>, {
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description> ref,
>(({ className, ...props }, ref) => ( className,
<AlertDialogPrimitive.Description ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description> & {
className={cn("text-sm text-muted-foreground", className)} ref: React.RefObject<React.ElementRef<typeof AlertDialogPrimitive.Description>>;
{...props} }
/> ) => (<AlertDialogPrimitive.Description
)) ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>)
AlertDialogDescription.displayName = AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName AlertDialogPrimitive.Description.displayName
const AlertDialogAction = React.forwardRef< const AlertDialogAction = (
React.ElementRef<typeof AlertDialogPrimitive.Action>, {
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> ref,
>(({ className, ...props }, ref) => ( className,
<AlertDialogPrimitive.Action ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> & {
className={cn(buttonVariants(), className)} ref: React.RefObject<React.ElementRef<typeof AlertDialogPrimitive.Action>>;
{...props} }
/> ) => (<AlertDialogPrimitive.Action
)) ref={ref}
className={cn(buttonVariants(), className)}
{...props}
/>)
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
const AlertDialogCancel = React.forwardRef< const AlertDialogCancel = (
React.ElementRef<typeof AlertDialogPrimitive.Cancel>, {
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel> ref,
>(({ className, ...props }, ref) => ( className,
<AlertDialogPrimitive.Cancel ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof AlertDialogPrimitive.Cancel>>;
buttonVariants({ variant: "outline" }), }
"mt-2 sm:mt-0", ) => (<AlertDialogPrimitive.Cancel
className ref={ref}
)} className={cn(
{...props} buttonVariants({ variant: "outline" }),
/> "mt-2 sm:mt-0",
)) className
)}
{...props}
/>)
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
export { export {
+39 -31
View File
@@ -19,41 +19,49 @@ const alertVariants = cva(
} }
) )
const Alert = React.forwardRef< const Alert = (
HTMLDivElement, {
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants> ref,
>(({ className, variant, ...props }, ref) => ( className,
<div variant,
ref={ref} ...props
role="alert" }
className={cn(alertVariants({ variant }), className)} ) => (<div
{...props} ref={ref}
/> role="alert"
)) className={cn(alertVariants({ variant }), className)}
{...props}
/>)
Alert.displayName = "Alert" Alert.displayName = "Alert"
const AlertTitle = React.forwardRef< const AlertTitle = (
HTMLParagraphElement, {
React.HTMLAttributes<HTMLHeadingElement> ref,
>(({ className, ...props }, ref) => ( className,
<h5 ...props
ref={ref} }: React.HTMLAttributes<HTMLHeadingElement> & {
className={cn("mb-1 font-medium leading-none tracking-tight", className)} ref?: React.RefObject<HTMLParagraphElement>;
{...props} }
/> ) => (<h5
)) ref={ref}
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
{...props}
/>)
AlertTitle.displayName = "AlertTitle" AlertTitle.displayName = "AlertTitle"
const AlertDescription = React.forwardRef< const AlertDescription = (
HTMLParagraphElement, {
React.HTMLAttributes<HTMLParagraphElement> ref,
>(({ className, ...props }, ref) => ( className,
<div ...props
ref={ref} }: React.HTMLAttributes<HTMLParagraphElement> & {
className={cn("text-sm [&_p]:leading-relaxed", className)} ref?: React.RefObject<HTMLParagraphElement>;
{...props} }
/> ) => (<div
)) ref={ref}
className={cn("text-sm [&_p]:leading-relaxed", className)}
{...props}
/>)
AlertDescription.displayName = "AlertDescription" AlertDescription.displayName = "AlertDescription"
export { Alert, AlertTitle, AlertDescription } export { Alert, AlertTitle, AlertDescription }
+21 -12
View File
@@ -5,7 +5,7 @@ import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
const buttonVariants = cva( const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
{ {
variants: { variants: {
variant: { variant: {
@@ -39,18 +39,27 @@ export interface ButtonProps
asChild?: boolean asChild?: boolean
} }
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( const Button = (
({ className, variant, size, asChild = false, ...props }, ref) => { {
const Comp = asChild ? Slot : "button" ref,
return ( className,
<Comp variant,
className={cn(buttonVariants({ variant, size, className }))} size,
ref={ref} asChild = false,
{...props} ...props
/> }: ButtonProps & {
) ref?: React.RefObject<HTMLButtonElement>;
} }
) ) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
}
Button.displayName = "Button" Button.displayName = "Button"
export { Button, buttonVariants } export { Button, buttonVariants }
+80 -62
View File
@@ -2,78 +2,96 @@ import * as React from "react"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
const Card = React.forwardRef< const Card = (
HTMLDivElement, {
React.HTMLAttributes<HTMLDivElement> ref,
>(({ className, ...props }, ref) => ( className,
<div ...props
ref={ref} }: React.HTMLAttributes<HTMLDivElement> & {
className={cn( ref: React.RefObject<HTMLDivElement>;
"rounded-lg border bg-card text-card-foreground shadow-sm", }
className ) => (<div
)} ref={ref}
{...props} className={cn(
/> "rounded-lg border bg-card text-card-foreground shadow-xs",
)) className
)}
{...props}
/>)
Card.displayName = "Card" Card.displayName = "Card"
const CardHeader = React.forwardRef< const CardHeader = (
HTMLDivElement, {
React.HTMLAttributes<HTMLDivElement> ref,
>(({ className, ...props }, ref) => ( className,
<div ...props
ref={ref} }: React.HTMLAttributes<HTMLDivElement> & {
className={cn("flex flex-col space-y-1.5 p-6", className)} ref: React.RefObject<HTMLDivElement>;
{...props} }
/> ) => (<div
)) ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>)
CardHeader.displayName = "CardHeader" CardHeader.displayName = "CardHeader"
const CardTitle = React.forwardRef< const CardTitle = (
HTMLParagraphElement, {
React.HTMLAttributes<HTMLHeadingElement> ref,
>(({ className, ...props }, ref) => ( className,
<h3 ...props
ref={ref} }: React.HTMLAttributes<HTMLHeadingElement> & {
className={cn( ref?: React.RefObject<HTMLParagraphElement>;
"text-2xl font-semibold leading-none tracking-tight", }
className ) => (<h3
)} ref={ref}
{...props} className={cn(
/> "text-2xl font-semibold leading-none tracking-tight",
)) className
)}
{...props}
/>)
CardTitle.displayName = "CardTitle" CardTitle.displayName = "CardTitle"
const CardDescription = React.forwardRef< const CardDescription = (
HTMLParagraphElement, {
React.HTMLAttributes<HTMLParagraphElement> ref,
>(({ className, ...props }, ref) => ( className,
<p ...props
ref={ref} }: React.HTMLAttributes<HTMLParagraphElement> & {
className={cn("text-sm text-muted-foreground", className)} ref?: React.RefObject<HTMLParagraphElement>;
{...props} }
/> ) => (<p
)) ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>)
CardDescription.displayName = "CardDescription" CardDescription.displayName = "CardDescription"
const CardContent = React.forwardRef< const CardContent = (
HTMLDivElement, {
React.HTMLAttributes<HTMLDivElement> ref,
>(({ className, ...props }, ref) => ( className,
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> ...props
)) }: React.HTMLAttributes<HTMLDivElement> & {
ref: React.RefObject<HTMLDivElement>;
}
) => (<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />)
CardContent.displayName = "CardContent" CardContent.displayName = "CardContent"
const CardFooter = React.forwardRef< const CardFooter = (
HTMLDivElement, {
React.HTMLAttributes<HTMLDivElement> ref,
>(({ className, ...props }, ref) => ( className,
<div ...props
ref={ref} }: React.HTMLAttributes<HTMLDivElement> & {
className={cn("flex items-center p-6 pt-0", className)} ref: React.RefObject<HTMLDivElement>;
{...props} }
/> ) => (<div
)) ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>)
CardFooter.displayName = "CardFooter" CardFooter.displayName = "CardFooter"
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
+142 -123
View File
@@ -16,151 +16,170 @@ const ContextMenuSub = ContextMenuPrimitive.Sub
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup
const ContextMenuSubTrigger = React.forwardRef< const ContextMenuSubTrigger = (
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>, {
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & { ref,
inset?: boolean className,
inset,
children,
...props
} }
>(({ className, inset, children, ...props }, ref) => ( ) => (<ContextMenuPrimitive.SubTrigger
<ContextMenuPrimitive.SubTrigger ref={ref}
ref={ref} className={cn(
className={cn( "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground", inset && "pl-8",
inset && "pl-8", className
className )}
)} {...props}
{...props} >
> {children}
{children} <ChevronRight className="ml-auto h-4 w-4" />
<ChevronRight className="ml-auto h-4 w-4" /> </ContextMenuPrimitive.SubTrigger>)
</ContextMenuPrimitive.SubTrigger>
))
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
const ContextMenuSubContent = React.forwardRef< const ContextMenuSubContent = (
React.ElementRef<typeof ContextMenuPrimitive.SubContent>, {
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent> ref,
>(({ className, ...props }, ref) => ( className,
<ContextMenuPrimitive.SubContent ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof ContextMenuPrimitive.SubContent>>;
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", }
className ) => (<ContextMenuPrimitive.SubContent
)} ref={ref}
{...props} className={cn(
/> "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
)) className
)}
{...props}
/>)
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
const ContextMenuContent = React.forwardRef< const ContextMenuContent = (
React.ElementRef<typeof ContextMenuPrimitive.Content>, {
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> ref,
>(({ className, ...props }, ref) => ( className,
<ContextMenuPrimitive.Portal> ...props
<ContextMenuPrimitive.Content }: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> & {
ref={ref} ref: React.RefObject<React.ElementRef<typeof ContextMenuPrimitive.Content>>;
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
</ContextMenuPrimitive.Portal>
))
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
const ContextMenuItem = React.forwardRef<
React.ElementRef<typeof ContextMenuPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
inset?: boolean
} }
>(({ className, inset, ...props }, ref) => ( ) => (<ContextMenuPrimitive.Portal>
<ContextMenuPrimitive.Item <ContextMenuPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
inset && "pl-8",
className className
)} )}
{...props} {...props}
/> />
)) </ContextMenuPrimitive.Portal>)
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
const ContextMenuItem = (
{
ref,
className,
inset,
...props
}
) => (<ContextMenuPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
inset && "pl-8",
className
)}
{...props}
/>)
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName
const ContextMenuCheckboxItem = React.forwardRef< const ContextMenuCheckboxItem = (
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>, {
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem> ref,
>(({ className, children, checked, ...props }, ref) => ( className,
<ContextMenuPrimitive.CheckboxItem children,
ref={ref} checked,
className={cn( ...props
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", }: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem> & {
className ref: React.RefObject<React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>>;
)} }
checked={checked} ) => (<ContextMenuPrimitive.CheckboxItem
{...props} ref={ref}
> className={cn(
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
<ContextMenuPrimitive.ItemIndicator> className
<Check className="h-4 w-4" /> )}
</ContextMenuPrimitive.ItemIndicator> checked={checked}
</span> {...props}
{children} >
</ContextMenuPrimitive.CheckboxItem> <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
)) <ContextMenuPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
</ContextMenuPrimitive.ItemIndicator>
</span>
{children}
</ContextMenuPrimitive.CheckboxItem>)
ContextMenuCheckboxItem.displayName = ContextMenuCheckboxItem.displayName =
ContextMenuPrimitive.CheckboxItem.displayName ContextMenuPrimitive.CheckboxItem.displayName
const ContextMenuRadioItem = React.forwardRef< const ContextMenuRadioItem = (
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>, {
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem> ref,
>(({ className, children, ...props }, ref) => ( className,
<ContextMenuPrimitive.RadioItem children,
ref={ref} ...props
className={cn( }: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem> & {
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", ref: React.RefObject<React.ElementRef<typeof ContextMenuPrimitive.RadioItem>>;
className }
)} ) => (<ContextMenuPrimitive.RadioItem
{...props} ref={ref}
> className={cn(
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
<ContextMenuPrimitive.ItemIndicator> className
<Circle className="h-2 w-2 fill-current" /> )}
</ContextMenuPrimitive.ItemIndicator> {...props}
</span> >
{children} <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
</ContextMenuPrimitive.RadioItem> <ContextMenuPrimitive.ItemIndicator>
)) <Circle className="h-2 w-2 fill-current" />
</ContextMenuPrimitive.ItemIndicator>
</span>
{children}
</ContextMenuPrimitive.RadioItem>)
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName
const ContextMenuLabel = React.forwardRef< const ContextMenuLabel = (
React.ElementRef<typeof ContextMenuPrimitive.Label>, {
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & { ref,
inset?: boolean className,
inset,
...props
} }
>(({ className, inset, ...props }, ref) => ( ) => (<ContextMenuPrimitive.Label
<ContextMenuPrimitive.Label ref={ref}
ref={ref} className={cn(
className={cn( "px-2 py-1.5 text-sm font-semibold text-foreground",
"px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8",
inset && "pl-8", className
className )}
)} {...props}
{...props} />)
/>
))
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName
const ContextMenuSeparator = React.forwardRef< const ContextMenuSeparator = (
React.ElementRef<typeof ContextMenuPrimitive.Separator>, {
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator> ref,
>(({ className, ...props }, ref) => ( className,
<ContextMenuPrimitive.Separator ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator> & {
className={cn("-mx-1 my-1 h-px bg-border", className)} ref: React.RefObject<React.ElementRef<typeof ContextMenuPrimitive.Separator>>;
{...props} }
/> ) => (<ContextMenuPrimitive.Separator
)) ref={ref}
className={cn("-mx-1 my-1 h-px bg-border", className)}
{...props}
/>)
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName
const ContextMenuShortcut = ({ const ContextMenuShortcut = ({
+68 -55
View File
@@ -12,43 +12,50 @@ const DialogPortal = DialogPrimitive.Portal
const DialogClose = DialogPrimitive.Close const DialogClose = DialogPrimitive.Close
const DialogOverlay = React.forwardRef< const DialogOverlay = (
React.ElementRef<typeof DialogPrimitive.Overlay>, {
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> ref,
>(({ className, ...props }, ref) => ( className,
<DialogPrimitive.Overlay ...props
}: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> & {
ref: React.RefObject<React.ElementRef<typeof DialogPrimitive.Overlay>>;
}
) => (<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
/>)
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
const DialogContent = (
{
ref,
className,
children,
...props
}: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
ref: React.RefObject<React.ElementRef<typeof DialogPrimitive.Content>>;
}
) => (<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref} ref={ref}
className={cn( className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className className
)} )}
{...props} {...props}
/> >
)) {children}
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
const DialogContent = React.forwardRef< <span className="sr-only">Close</span>
React.ElementRef<typeof DialogPrimitive.Content>, </DialogPrimitive.Close>
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> </DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => ( </DialogPortal>)
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
))
DialogContent.displayName = DialogPrimitive.Content.displayName DialogContent.displayName = DialogPrimitive.Content.displayName
const DialogHeader = ({ const DialogHeader = ({
@@ -79,31 +86,37 @@ const DialogFooter = ({
) )
DialogFooter.displayName = "DialogFooter" DialogFooter.displayName = "DialogFooter"
const DialogTitle = React.forwardRef< const DialogTitle = (
React.ElementRef<typeof DialogPrimitive.Title>, {
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> ref,
>(({ className, ...props }, ref) => ( className,
<DialogPrimitive.Title ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof DialogPrimitive.Title>>;
"text-lg font-semibold leading-none tracking-tight", }
className ) => (<DialogPrimitive.Title
)} ref={ref}
{...props} className={cn(
/> "text-lg font-semibold leading-none tracking-tight",
)) className
)}
{...props}
/>)
DialogTitle.displayName = DialogPrimitive.Title.displayName DialogTitle.displayName = DialogPrimitive.Title.displayName
const DialogDescription = React.forwardRef< const DialogDescription = (
React.ElementRef<typeof DialogPrimitive.Description>, {
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> ref,
>(({ className, ...props }, ref) => ( className,
<DialogPrimitive.Description ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description> & {
className={cn("text-sm text-muted-foreground", className)} ref: React.RefObject<React.ElementRef<typeof DialogPrimitive.Description>>;
{...props} }
/> ) => (<DialogPrimitive.Description
)) ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>)
DialogDescription.displayName = DialogPrimitive.Description.displayName DialogDescription.displayName = DialogPrimitive.Description.displayName
export { export {
+65 -52
View File
@@ -20,37 +20,44 @@ const DrawerPortal = DrawerPrimitive.Portal
const DrawerClose = DrawerPrimitive.Close const DrawerClose = DrawerPrimitive.Close
const DrawerOverlay = React.forwardRef< const DrawerOverlay = (
React.ElementRef<typeof DrawerPrimitive.Overlay>, {
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay> ref,
>(({ className, ...props }, ref) => ( className,
<DrawerPrimitive.Overlay ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay> & {
className={cn("fixed inset-0 z-50 bg-black/80", className)} ref: React.RefObject<React.ElementRef<typeof DrawerPrimitive.Overlay>>;
{...props} }
/> ) => (<DrawerPrimitive.Overlay
)) ref={ref}
className={cn("fixed inset-0 z-50 bg-black/80", className)}
{...props}
/>)
DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName
const DrawerContent = React.forwardRef< const DrawerContent = (
React.ElementRef<typeof DrawerPrimitive.Content>, {
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content> ref,
>(({ className, children, ...props }, ref) => ( className,
<DrawerPortal> children,
<DrawerOverlay /> ...props
<DrawerPrimitive.Content }: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content> & {
ref={ref} ref: React.RefObject<React.ElementRef<typeof DrawerPrimitive.Content>>;
className={cn( }
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background", ) => (<DrawerPortal>
className <DrawerOverlay />
)} <DrawerPrimitive.Content
{...props} ref={ref}
> className={cn(
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" /> "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
{children} className
</DrawerPrimitive.Content> )}
</DrawerPortal> {...props}
)) >
<div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
{children}
</DrawerPrimitive.Content>
</DrawerPortal>)
DrawerContent.displayName = "DrawerContent" DrawerContent.displayName = "DrawerContent"
const DrawerHeader = ({ const DrawerHeader = ({
@@ -75,31 +82,37 @@ const DrawerFooter = ({
) )
DrawerFooter.displayName = "DrawerFooter" DrawerFooter.displayName = "DrawerFooter"
const DrawerTitle = React.forwardRef< const DrawerTitle = (
React.ElementRef<typeof DrawerPrimitive.Title>, {
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title> ref,
>(({ className, ...props }, ref) => ( className,
<DrawerPrimitive.Title ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof DrawerPrimitive.Title>>;
"text-lg font-semibold leading-none tracking-tight", }
className ) => (<DrawerPrimitive.Title
)} ref={ref}
{...props} className={cn(
/> "text-lg font-semibold leading-none tracking-tight",
)) className
)}
{...props}
/>)
DrawerTitle.displayName = DrawerPrimitive.Title.displayName DrawerTitle.displayName = DrawerPrimitive.Title.displayName
const DrawerDescription = React.forwardRef< const DrawerDescription = (
React.ElementRef<typeof DrawerPrimitive.Description>, {
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description> ref,
>(({ className, ...props }, ref) => ( className,
<DrawerPrimitive.Description ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description> & {
className={cn("text-sm text-muted-foreground", className)} ref: React.RefObject<React.ElementRef<typeof DrawerPrimitive.Description>>;
{...props} }
/> ) => (<DrawerPrimitive.Description
)) ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>)
DrawerDescription.displayName = DrawerPrimitive.Description.displayName DrawerDescription.displayName = DrawerPrimitive.Description.displayName
export { export {
+50 -25
View File
@@ -70,10 +70,15 @@ const FormItemContext = React.createContext<FormItemContextValue>(
{} as FormItemContextValue {} as FormItemContextValue
) )
const FormItem = React.forwardRef< const FormItem = (
HTMLDivElement, {
React.HTMLAttributes<HTMLDivElement> ref,
>(({ className, ...props }, ref) => { className,
...props
}: React.HTMLAttributes<HTMLDivElement> & {
ref: React.RefObject<HTMLDivElement>;
}
) => {
const id = React.useId() const id = React.useId()
return ( return (
@@ -81,13 +86,18 @@ const FormItem = React.forwardRef<
<div ref={ref} className={cn("space-y-2", className)} {...props} /> <div ref={ref} className={cn("space-y-2", className)} {...props} />
</FormItemContext.Provider> </FormItemContext.Provider>
) )
}) }
FormItem.displayName = "FormItem" FormItem.displayName = "FormItem"
const FormLabel = React.forwardRef< const FormLabel = (
React.ElementRef<typeof LabelPrimitive.Root>, {
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> ref,
>(({ className, ...props }, ref) => { className,
...props
}: React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & {
ref: React.RefObject<React.ElementRef<typeof LabelPrimitive.Root>>;
}
) => {
const { error, formItemId } = useFormField() const { error, formItemId } = useFormField()
return ( return (
@@ -98,13 +108,17 @@ const FormLabel = React.forwardRef<
{...props} {...props}
/> />
) )
}) }
FormLabel.displayName = "FormLabel" FormLabel.displayName = "FormLabel"
const FormControl = React.forwardRef< const FormControl = (
React.ElementRef<typeof Slot>, {
React.ComponentPropsWithoutRef<typeof Slot> ref,
>(({ ...props }, ref) => { ...props
}: React.ComponentPropsWithoutRef<typeof Slot> & {
ref: React.RefObject<React.ElementRef<typeof Slot>>;
}
) => {
const { error, formItemId, formDescriptionId, formMessageId } = useFormField() const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
return ( return (
@@ -120,13 +134,18 @@ const FormControl = React.forwardRef<
{...props} {...props}
/> />
) )
}) }
FormControl.displayName = "FormControl" FormControl.displayName = "FormControl"
const FormDescription = React.forwardRef< const FormDescription = (
HTMLParagraphElement, {
React.HTMLAttributes<HTMLParagraphElement> ref,
>(({ className, ...props }, ref) => { className,
...props
}: React.HTMLAttributes<HTMLParagraphElement> & {
ref?: React.RefObject<HTMLParagraphElement>;
}
) => {
const { formDescriptionId } = useFormField() const { formDescriptionId } = useFormField()
return ( return (
@@ -137,13 +156,19 @@ const FormDescription = React.forwardRef<
{...props} {...props}
/> />
) )
}) }
FormDescription.displayName = "FormDescription" FormDescription.displayName = "FormDescription"
const FormMessage = React.forwardRef< const FormMessage = (
HTMLParagraphElement, {
React.HTMLAttributes<HTMLParagraphElement> ref,
>(({ className, children, ...props }, ref) => { className,
children,
...props
}: React.HTMLAttributes<HTMLParagraphElement> & {
ref?: React.RefObject<HTMLParagraphElement>;
}
) => {
const { error, formMessageId } = useFormField() const { error, formMessageId } = useFormField()
const body = error ? String(error?.message) : children const body = error ? String(error?.message) : children
@@ -161,7 +186,7 @@ const FormMessage = React.forwardRef<
{body} {body}
</p> </p>
) )
}) }
FormMessage.displayName = "FormMessage" FormMessage.displayName = "FormMessage"
export { export {
+21 -14
View File
@@ -5,21 +5,28 @@ import { cn } from "@/lib/utils"
export interface InputProps export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {} extends React.InputHTMLAttributes<HTMLInputElement> {}
const Input = React.forwardRef<HTMLInputElement, InputProps>( const Input = (
({ className, type, ...props }, ref) => { {
return ( ref,
<input className,
type={type} type,
className={cn( ...props
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", }: InputProps & {
className ref: React.RefObject<HTMLInputElement>;
)}
ref={ref}
{...props}
/>
)
} }
) ) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
{...props}
/>
)
}
Input.displayName = "Input" Input.displayName = "Input"
export { Input } export { Input }
+11 -11
View File
@@ -8,17 +8,17 @@ const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
) )
const Label = React.forwardRef< const Label = (
React.ElementRef<typeof LabelPrimitive.Root>, {
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & ref,
VariantProps<typeof labelVariants> className,
>(({ className, ...props }, ref) => ( ...props
<LabelPrimitive.Root }
ref={ref} ) => (<LabelPrimitive.Root
className={cn(labelVariants(), className)} ref={ref}
{...props} className={cn(labelVariants(), className)}
/> {...props}
)) />)
Label.displayName = LabelPrimitive.Root.displayName Label.displayName = LabelPrimitive.Root.displayName
export { Label } export { Label }
+21 -21
View File
@@ -3,27 +3,27 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
const Separator = React.forwardRef< const Separator = (
React.ElementRef<typeof SeparatorPrimitive.Root>, {
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> ref,
>( className,
( orientation = "horizontal",
{ className, orientation = "horizontal", decorative = true, ...props }, decorative = true,
ref ...props
) => ( }: React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> & {
<SeparatorPrimitive.Root ref: React.RefObject<React.ElementRef<typeof SeparatorPrimitive.Root>>;
ref={ref} }
decorative={decorative} ) => (<SeparatorPrimitive.Root
orientation={orientation} ref={ref}
className={cn( decorative={decorative}
"shrink-0 bg-border", orientation={orientation}
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]", className={cn(
className "shrink-0 bg-border",
)} orientation === "horizontal" ? "h-px w-full" : "h-full w-px",
{...props} className
/> )}
) {...props}
) />)
Separator.displayName = SeparatorPrimitive.Root.displayName Separator.displayName = SeparatorPrimitive.Root.displayName
export { Separator } export { Separator }
+87 -69
View File
@@ -7,23 +7,26 @@ import { cn } from "@/lib/utils"
const ToastProvider = ToastPrimitives.Provider const ToastProvider = ToastPrimitives.Provider
const ToastViewport = React.forwardRef< const ToastViewport = (
React.ElementRef<typeof ToastPrimitives.Viewport>, {
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport> ref,
>(({ className, ...props }, ref) => ( className,
<ToastPrimitives.Viewport ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof ToastPrimitives.Viewport>>;
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]", }
className ) => (<ToastPrimitives.Viewport
)} ref={ref}
{...props} className={cn(
/> "fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
)) className
)}
{...props}
/>)
ToastViewport.displayName = ToastPrimitives.Viewport.displayName ToastViewport.displayName = ToastPrimitives.Viewport.displayName
const toastVariants = cva( const toastVariants = cva(
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full", "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
{ {
variants: { variants: {
variant: { variant: {
@@ -38,11 +41,14 @@ const toastVariants = cva(
} }
) )
const Toast = React.forwardRef< const Toast = (
React.ElementRef<typeof ToastPrimitives.Root>, {
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> & ref,
VariantProps<typeof toastVariants> className,
>(({ className, variant, ...props }, ref) => { variant,
...props
}
) => {
return ( return (
<ToastPrimitives.Root <ToastPrimitives.Root
ref={ref} ref={ref}
@@ -50,64 +56,76 @@ const Toast = React.forwardRef<
{...props} {...props}
/> />
) )
}) }
Toast.displayName = ToastPrimitives.Root.displayName Toast.displayName = ToastPrimitives.Root.displayName
const ToastAction = React.forwardRef< const ToastAction = (
React.ElementRef<typeof ToastPrimitives.Action>, {
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action> ref,
>(({ className, ...props }, ref) => ( className,
<ToastPrimitives.Action ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof ToastPrimitives.Action>>;
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive", }
className ) => (<ToastPrimitives.Action
)} ref={ref}
{...props} className={cn(
/> "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive",
)) className
)}
{...props}
/>)
ToastAction.displayName = ToastPrimitives.Action.displayName ToastAction.displayName = ToastPrimitives.Action.displayName
const ToastClose = React.forwardRef< const ToastClose = (
React.ElementRef<typeof ToastPrimitives.Close>, {
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close> ref,
>(({ className, ...props }, ref) => ( className,
<ToastPrimitives.Close ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof ToastPrimitives.Close>>;
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600", }
className ) => (<ToastPrimitives.Close
)} ref={ref}
toast-close="" className={cn(
{...props} "absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-50 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",
> className
<X className="h-4 w-4" /> )}
</ToastPrimitives.Close> toast-close=""
)) {...props}
>
<X className="h-4 w-4" />
</ToastPrimitives.Close>)
ToastClose.displayName = ToastPrimitives.Close.displayName ToastClose.displayName = ToastPrimitives.Close.displayName
const ToastTitle = React.forwardRef< const ToastTitle = (
React.ElementRef<typeof ToastPrimitives.Title>, {
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title> ref,
>(({ className, ...props }, ref) => ( className,
<ToastPrimitives.Title ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title> & {
className={cn("text-sm font-semibold", className)} ref: React.RefObject<React.ElementRef<typeof ToastPrimitives.Title>>;
{...props} }
/> ) => (<ToastPrimitives.Title
)) ref={ref}
className={cn("text-sm font-semibold", className)}
{...props}
/>)
ToastTitle.displayName = ToastPrimitives.Title.displayName ToastTitle.displayName = ToastPrimitives.Title.displayName
const ToastDescription = React.forwardRef< const ToastDescription = (
React.ElementRef<typeof ToastPrimitives.Description>, {
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description> ref,
>(({ className, ...props }, ref) => ( className,
<ToastPrimitives.Description ...props
ref={ref} }: React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description> & {
className={cn("text-sm opacity-90", className)} ref: React.RefObject<React.ElementRef<typeof ToastPrimitives.Description>>;
{...props} }
/> ) => (<ToastPrimitives.Description
)) ref={ref}
className={cn("text-sm opacity-90", className)}
{...props}
/>)
ToastDescription.displayName = ToastPrimitives.Description.displayName ToastDescription.displayName = ToastPrimitives.Description.displayName
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast> type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>
+18 -14
View File
@@ -9,20 +9,24 @@ const Tooltip = TooltipPrimitive.Root
const TooltipTrigger = TooltipPrimitive.Trigger const TooltipTrigger = TooltipPrimitive.Trigger
const TooltipContent = React.forwardRef< const TooltipContent = (
React.ElementRef<typeof TooltipPrimitive.Content>, {
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> ref,
>(({ className, sideOffset = 4, ...props }, ref) => ( className,
<TooltipPrimitive.Content sideOffset = 4,
ref={ref} ...props
sideOffset={sideOffset} }: React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {
className={cn( ref: React.RefObject<React.ElementRef<typeof TooltipPrimitive.Content>>;
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", }
className ) => (<TooltipPrimitive.Content
)} ref={ref}
{...props} sideOffset={sideOffset}
/> className={cn(
)) "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>)
TooltipContent.displayName = TooltipPrimitive.Content.displayName TooltipContent.displayName = TooltipPrimitive.Content.displayName
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
+8 -2
View File
@@ -46,11 +46,17 @@ const router = createHashRouter([
} }
]) ])
createRoot(document.getElementById('root')!).render( function App() {
<StrictMode> return (
<ThemeProvider defaultTheme="system" storageKey="vite-ui-theme"> <ThemeProvider defaultTheme="system" storageKey="vite-ui-theme">
<RouterProvider router={router}/> <RouterProvider router={router}/>
<Toaster/> <Toaster/>
</ThemeProvider> </ThemeProvider>
)
}
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App/>
</StrictMode>, </StrictMode>,
) )
+3 -3
View File
@@ -66,7 +66,7 @@ function CardList(props: { cards: ReadonlyArray<AimeCard> | null, cardSelected:
return (<> return (<>
<h4 className="text-2xl font-bold">{props.cards?.length ? "Cards" : "Additional Cards"}</h4> <h4 className="text-2xl font-bold">{props.cards?.length ? "Cards" : "Additional Cards"}</h4>
<div className="flex gap-2"> <div className="flex gap-2">
<CardCreationDialog className="flex-grow"/> <CardCreationDialog className="grow"/>
<Button onClick={() => navigate('/cards')} variant="outline" size="icon"> <Button onClick={() => navigate('/cards')} variant="outline" size="icon">
<Wallet className="h-4 w-4"/> <Wallet className="h-4 w-4"/>
</Button> </Button>
@@ -187,7 +187,7 @@ function ServerCardInPage() {
<AlertPanel server={server} connectionError={connectionError} onReloadRequested={() => setServerReloadCounter(serverReloadCounter + 1)}/> <AlertPanel server={server} connectionError={connectionError} onReloadRequested={() => setServerReloadCounter(serverReloadCounter + 1)}/>
{server && ( {server && (
<div className="flex flex-col gap-4 w-full flex-grow"> <div className="flex flex-col gap-4 w-full grow">
{selectedCard && (<> {selectedCard && (<>
<h4 className="text-2xl font-bold">{gameName ? `Play ${gameName}` : "Selected Card"}</h4> <h4 className="text-2xl font-bold">{gameName ? `Play ${gameName}` : "Selected Card"}</h4>
@@ -197,7 +197,7 @@ function ServerCardInPage() {
</Button> </Button>
</AimeCardEntry> </AimeCardEntry>
<Button className="flex-grow-0 bg-green-600 mb-5" <Button className="grow-0 bg-green-600 mb-5"
disabled={(cardInStatus || connectionError || !server)} disabled={(cardInStatus || connectionError || !server)}
onClick={() => performCardInAction(selectedCard, server as AimeServer, setCardInStatus, toast)}> onClick={() => performCardInAction(selectedCard, server as AimeServer, setCardInStatus, toast)}>
{cardInStatus ? "Carding in..." : <>Card In <Nfc className="ml-2 h-4 w-4"/></>} {cardInStatus ? "Carding in..." : <>Card In <Nfc className="ml-2 h-4 w-4"/></>}
+1 -1
View File
@@ -53,7 +53,7 @@ function CardManagerPage() {
</Button> </Button>
</AMHeader> </AMHeader>
<div className="flex flex-col gap-4 w-full flex-grow"> <div className="flex flex-col gap-4 w-full grow">
{cards ? <CardList cards={cards}/> : <LoadingIndicator/>} {cards ? <CardList cards={cards}/> : <LoadingIndicator/>}
</div> </div>
+1 -1
View File
@@ -19,7 +19,7 @@ function PrivacyPolicy() {
</Button> </Button>
</AMHeader> </AMHeader>
<div className="flex flex-col gap-4 w-full flex-grow"> <div className="flex flex-col gap-4 w-full grow">
<h4 className="font-semibold text-2xl">Privacy</h4> <h4 className="font-semibold text-2xl">Privacy</h4>
<p>The AMNet card switcher collects and stores the following information locally (on-device):</p> <p>The AMNet card switcher collects and stores the following information locally (on-device):</p>
<ul className="list-disc"> <ul className="list-disc">
+3 -3
View File
@@ -43,7 +43,7 @@ function ServerListing() {
</Button> </Button>
</AMHeader> </AMHeader>
<div className="flex flex-col gap-4 w-full flex-grow"> <div className="flex flex-col gap-4 w-full grow">
<ServerList servers={servers}/> <ServerList servers={servers}/>
</div> </div>
@@ -172,7 +172,7 @@ function ServerAddForm() {
control={form.control} control={form.control}
name="address" name="address"
render={({field}) => ( render={({field}) => (
<FormItem className="flex-grow"> <FormItem className="grow">
<FormControl> <FormControl>
<Input {...field} <Input {...field}
placeholder="Server Address (http://192.168.1.1:6070)" placeholder="Server Address (http://192.168.1.1:6070)"
@@ -183,7 +183,7 @@ function ServerAddForm() {
)} )}
/> />
<Button type="submit" disabled={blockSubmit} variant="outline" size="icon" <Button type="submit" disabled={blockSubmit} variant="outline" size="icon"
className="flex-shrink-0"> className="shrink-0">
<Plus className="h-4 w-4"/> <Plus className="h-4 w-4"/>
</Button> </Button>
</form> </form>