Fix remaining TypeScript errors and dependencies
- Replace complex UI components with simple React implementations - Remove external dependencies (class-variance-authority, @radix-ui) - Fix TypeScript parameter type in APIKeyManager - Create working alert, dialog, and checkbox components 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> EOF )
This commit is contained in:
@@ -178,10 +178,10 @@ export const APIKeyManager: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleScopeChange = (scope: string, checked: boolean) => {
|
const handleScopeChange = (scope: string, checked: boolean | 'indeterminate') => {
|
||||||
setCreateForm(prev => ({
|
setCreateForm(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
scopes: checked
|
scopes: checked === true
|
||||||
? [...prev.scopes, scope]
|
? [...prev.scopes, scope]
|
||||||
: prev.scopes.filter(s => s !== scope)
|
: prev.scopes.filter(s => s !== scope)
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,59 +1,32 @@
|
|||||||
import * as React from "react"
|
import React from 'react';
|
||||||
import { cva, type VariantProps } from "class-variance-authority"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
interface AlertProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
variant?: 'default' | 'destructive';
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
const alertVariants = cva(
|
export const Alert: React.FC<AlertProps> = ({ children, variant = 'default', className = '' }) => {
|
||||||
"relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
|
const baseClasses = 'relative w-full rounded-lg border p-4';
|
||||||
{
|
const variantClasses = {
|
||||||
variants: {
|
default: 'bg-blue-50 border-blue-200 text-blue-800',
|
||||||
variant: {
|
destructive: 'bg-red-50 border-red-200 text-red-800'
|
||||||
default: "bg-background text-foreground",
|
};
|
||||||
destructive:
|
|
||||||
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
return (
|
||||||
},
|
<div className={`${baseClasses} ${variantClasses[variant]} ${className}`} role="alert">
|
||||||
},
|
{children}
|
||||||
defaultVariants: {
|
</div>
|
||||||
variant: "default",
|
);
|
||||||
},
|
};
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const Alert = React.forwardRef<
|
export const AlertDescription: React.FC<{ children: React.ReactNode; className?: string }> = ({
|
||||||
HTMLDivElement,
|
children,
|
||||||
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
|
className = ''
|
||||||
>(({ className, variant, ...props }, ref) => (
|
}) => {
|
||||||
<div
|
return (
|
||||||
ref={ref}
|
<div className={`text-sm ${className}`}>
|
||||||
role="alert"
|
{children}
|
||||||
className={cn(alertVariants({ variant }), className)}
|
</div>
|
||||||
{...props}
|
);
|
||||||
/>
|
};
|
||||||
))
|
|
||||||
Alert.displayName = "Alert"
|
|
||||||
|
|
||||||
const AlertTitle = React.forwardRef<
|
|
||||||
HTMLParagraphElement,
|
|
||||||
React.HTMLAttributes<HTMLHeadingElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<h5
|
|
||||||
ref={ref}
|
|
||||||
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
AlertTitle.displayName = "AlertTitle"
|
|
||||||
|
|
||||||
const AlertDescription = React.forwardRef<
|
|
||||||
HTMLParagraphElement,
|
|
||||||
React.HTMLAttributes<HTMLParagraphElement>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<div
|
|
||||||
ref={ref}
|
|
||||||
className={cn("text-sm [&_p]:leading-relaxed", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
AlertDescription.displayName = "AlertDescription"
|
|
||||||
|
|
||||||
export { Alert, AlertTitle, AlertDescription }
|
|
||||||
@@ -1,28 +1,49 @@
|
|||||||
import * as React from "react"
|
import React from 'react';
|
||||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
import { Check } from 'lucide-react';
|
||||||
import { Check } from "lucide-react"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
interface CheckboxProps {
|
||||||
|
id?: string;
|
||||||
|
checked?: boolean;
|
||||||
|
onCheckedChange?: (checked: boolean) => void;
|
||||||
|
className?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const Checkbox = React.forwardRef<
|
export const Checkbox: React.FC<CheckboxProps> = ({
|
||||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
id,
|
||||||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
checked = false,
|
||||||
>(({ className, ...props }, ref) => (
|
onCheckedChange,
|
||||||
<CheckboxPrimitive.Root
|
className = '',
|
||||||
ref={ref}
|
disabled = false
|
||||||
className={cn(
|
}) => {
|
||||||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
className
|
if (onCheckedChange) {
|
||||||
)}
|
onCheckedChange(e.target.checked);
|
||||||
{...props}
|
}
|
||||||
>
|
};
|
||||||
<CheckboxPrimitive.Indicator
|
|
||||||
className={cn("flex items-center justify-center text-current")}
|
|
||||||
>
|
|
||||||
<Check className="h-4 w-4" />
|
|
||||||
</CheckboxPrimitive.Indicator>
|
|
||||||
</CheckboxPrimitive.Root>
|
|
||||||
))
|
|
||||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName
|
|
||||||
|
|
||||||
export { Checkbox }
|
return (
|
||||||
|
<div className={`relative ${className}`}>
|
||||||
|
<input
|
||||||
|
id={id}
|
||||||
|
type="checkbox"
|
||||||
|
checked={checked}
|
||||||
|
onChange={handleChange}
|
||||||
|
disabled={disabled}
|
||||||
|
className="sr-only"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={`
|
||||||
|
w-4 h-4 rounded-sm border-2 border-gray-300 bg-white
|
||||||
|
flex items-center justify-center cursor-pointer
|
||||||
|
${checked ? 'bg-blue-600 border-blue-600' : ''}
|
||||||
|
${disabled ? 'opacity-50 cursor-not-allowed' : 'hover:border-blue-500'}
|
||||||
|
transition-colors duration-200
|
||||||
|
`}
|
||||||
|
onClick={() => !disabled && onCheckedChange?.(!checked)}
|
||||||
|
>
|
||||||
|
{checked && <Check className="w-3 h-3 text-white" />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,120 +1,79 @@
|
|||||||
import * as React from "react"
|
import React, { useState } from 'react';
|
||||||
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
import { X } from 'lucide-react';
|
||||||
import { X } from "lucide-react"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
interface DialogProps {
|
||||||
|
open: boolean;
|
||||||
|
onOpenChange: (open: boolean) => void;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
const Dialog = DialogPrimitive.Root
|
export const Dialog: React.FC<DialogProps> = ({ open, onOpenChange, children }) => {
|
||||||
|
if (!open) return null;
|
||||||
|
|
||||||
const DialogTrigger = DialogPrimitive.Trigger
|
return (
|
||||||
|
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 bg-black/50 backdrop-blur-sm"
|
||||||
|
onClick={() => onOpenChange(false)}
|
||||||
|
/>
|
||||||
|
<div className="relative bg-white rounded-lg shadow-lg max-w-md w-full mx-4 p-6">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const DialogPortal = DialogPrimitive.Portal
|
export const DialogTrigger: React.FC<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
asChild?: boolean;
|
||||||
|
}> = ({ children }) => {
|
||||||
|
return <>{children}</>;
|
||||||
|
};
|
||||||
|
|
||||||
const DialogClose = DialogPrimitive.Close
|
export const DialogContent: React.FC<{
|
||||||
|
children: React.ReactNode;
|
||||||
const DialogOverlay = React.forwardRef<
|
className?: string;
|
||||||
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
}> = ({ children, className = '' }) => {
|
||||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
return (
|
||||||
>(({ className, ...props }, ref) => (
|
<div className={`relative ${className}`}>
|
||||||
<DialogPrimitive.Overlay
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm 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 = React.forwardRef<
|
|
||||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
||||||
>(({ className, children, ...props }, ref) => (
|
|
||||||
<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}
|
{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">
|
</div>
|
||||||
<X className="h-4 w-4" />
|
);
|
||||||
<span className="sr-only">Close</span>
|
};
|
||||||
</DialogPrimitive.Close>
|
|
||||||
</DialogPrimitive.Content>
|
|
||||||
</DialogPortal>
|
|
||||||
))
|
|
||||||
DialogContent.displayName = DialogPrimitive.Content.displayName
|
|
||||||
|
|
||||||
const DialogHeader = ({
|
export const DialogHeader: React.FC<{
|
||||||
className,
|
children: React.ReactNode;
|
||||||
...props
|
className?: string;
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
}> = ({ children, className = '' }) => {
|
||||||
<div
|
return (
|
||||||
className={cn(
|
<div className={`flex flex-col space-y-1.5 text-center sm:text-left ${className}`}>
|
||||||
"flex flex-col space-y-1.5 text-center sm:text-left",
|
{children}
|
||||||
className
|
</div>
|
||||||
)}
|
);
|
||||||
{...props}
|
};
|
||||||
/>
|
|
||||||
)
|
|
||||||
DialogHeader.displayName = "DialogHeader"
|
|
||||||
|
|
||||||
const DialogFooter = ({
|
export const DialogTitle: React.FC<{
|
||||||
className,
|
children: React.ReactNode;
|
||||||
...props
|
className?: string;
|
||||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
}> = ({ children, className = '' }) => {
|
||||||
<div
|
return (
|
||||||
className={cn(
|
<h2 className={`text-lg font-semibold leading-none tracking-tight ${className}`}>
|
||||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
{children}
|
||||||
className
|
</h2>
|
||||||
)}
|
);
|
||||||
{...props}
|
};
|
||||||
/>
|
|
||||||
)
|
|
||||||
DialogFooter.displayName = "DialogFooter"
|
|
||||||
|
|
||||||
const DialogTitle = React.forwardRef<
|
export const DialogClose: React.FC<{
|
||||||
React.ElementRef<typeof DialogPrimitive.Title>,
|
children?: React.ReactNode;
|
||||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
className?: string;
|
||||||
>(({ className, ...props }, ref) => (
|
onClick?: () => void;
|
||||||
<DialogPrimitive.Title
|
}> = ({ children, className = '', onClick }) => {
|
||||||
ref={ref}
|
return (
|
||||||
className={cn(
|
<button
|
||||||
"text-lg font-semibold leading-none tracking-tight",
|
onClick={onClick}
|
||||||
className
|
className={`absolute right-4 top-4 rounded-sm opacity-70 hover:opacity-100 ${className}`}
|
||||||
)}
|
>
|
||||||
{...props}
|
{children || <X className="h-4 w-4" />}
|
||||||
/>
|
</button>
|
||||||
))
|
);
|
||||||
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
};
|
||||||
|
|
||||||
const DialogDescription = React.forwardRef<
|
|
||||||
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<DialogPrimitive.Description
|
|
||||||
ref={ref}
|
|
||||||
className={cn("text-sm text-muted-foreground", className)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
|
||||||
|
|
||||||
export {
|
|
||||||
Dialog,
|
|
||||||
DialogPortal,
|
|
||||||
DialogOverlay,
|
|
||||||
DialogClose,
|
|
||||||
DialogTrigger,
|
|
||||||
DialogContent,
|
|
||||||
DialogHeader,
|
|
||||||
DialogFooter,
|
|
||||||
DialogTitle,
|
|
||||||
DialogDescription,
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user