The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(ui): install the shadcn alert primitive
Yuneng Jianga5b6f31585ce
diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.jsonindex a647eedc354..e22812df465 100644--- a/ui/litellm-dashboard/eslint-suppressions.json+++ b/ui/litellm-dashboard/eslint-suppressions.json@@ -2133,6 +2133,11 @@"count": 1}},+ "src/components/ui/alert.tsx": {+ "local/filename-pascal-case": {+ "count": 1+ }+ },"src/components/ui/avatar.tsx": {"local/filename-pascal-case": {"count": 1diff --git a/ui/litellm-dashboard/src/components/shared/Alert.tsx b/ui/litellm-dashboard/src/components/shared/Alert.tsxindex 490fcba6ef5..1a895c204de 100644--- a/ui/litellm-dashboard/src/components/shared/Alert.tsx+++ b/ui/litellm-dashboard/src/components/shared/Alert.tsx@@ -1,75 +1,32 @@-import * as React from "react";--import { cva, type VariantProps } from "class-variance-authority";+import type * as React from "react";+import { Alert as AlertPrimitive, AlertAction, AlertDescription, AlertTitle } from "@/components/ui/alert";import { cn } from "@/lib/cva.config";-const alertVariants = cva(- "group/alert relative grid w-full gap-0.5 rounded-lg border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",- {- variants: {- variant: {- default: "bg-card text-card-foreground",- destructive:- "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",- info: "border-info/20 bg-info/5 text-info *:[svg]:text-current",- success: "border-success/20 bg-success/5 text-success *:[svg]:text-current",- warning: "border-warning/20 bg-warning/5 text-warning *:[svg]:text-current",- error:- "border-destructive/20 bg-destructive/10 text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-destructive",- },- },- defaultVariants: {- variant: "default",- },- },-);+const STATUS_VARIANT_CLASSES = {+ info: "border-info/20 bg-info/5 text-info *:[svg]:text-current",+ success: "border-success/20 bg-success/5 text-success *:[svg]:text-current",+ warning: "border-warning/20 bg-warning/5 text-warning *:[svg]:text-current",+ error:+ "border-destructive/20 bg-destructive/10 text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-destructive",+} as const;-type AlertProps = React.ComponentProps<"div"> & VariantProps<typeof alertVariants>;+type StatusVariant = keyof typeof STATUS_VARIANT_CLASSES;+type AlertVariant = NonNullable<React.ComponentProps<typeof AlertPrimitive>["variant"]> | StatusVariant;-const Alert = React.forwardRef<HTMLDivElement, AlertProps>(({ className, variant = "default", ...props }, ref) => (- <div- ref={ref}- data-slot="alert"- data-variant={variant}- role="alert"- className={cn(alertVariants({ variant }), className)}- {...props}- />-));-Alert.displayName = "Alert";+type AlertProps = Omit<React.ComponentProps<typeof AlertPrimitive>, "variant"> & {+ variant?: AlertVariant;+};-const AlertTitle = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => (- <div- ref={ref}- data-slot="alert-title"- className={cn(- "font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",- className,- )}+const isStatusVariant = (variant: AlertVariant): variant is StatusVariant => variant in STATUS_VARIANT_CLASSES;++const Alert = ({ variant = "default", className, ...props }: AlertProps) => (+ <AlertPrimitive+ data-variant={variant}+ variant={variant === "destructive" ? "destructive" : "default"}+ className={cn(isStatusVariant(variant) ? STATUS_VARIANT_CLASSES[variant] : undefined, className)}{...props}/>-));-AlertTitle.displayName = "AlertTitle";--const AlertDescription = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(- ({ className, ...props }, ref) => (- <div- ref={ref}- data-slot="alert-description"- className={cn(- "text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",- className,- )}- {...props}- />- ),);-AlertDescription.displayName = "AlertDescription";--const AlertAction = React.forwardRef<HTMLDivElement, React.ComponentProps<"div">>(({ className, ...props }, ref) => (- <div ref={ref} data-slot="alert-action" className={cn("absolute top-2.5 right-3", className)} {...props} />-));-AlertAction.displayName = "AlertAction";export { Alert, AlertTitle, AlertDescription, AlertAction };diff --git a/ui/litellm-dashboard/src/components/ui/alert.tsx b/ui/litellm-dashboard/src/components/ui/alert.tsxnew file mode 100644index 00000000000..01d86e0961a--- /dev/null+++ b/ui/litellm-dashboard/src/components/ui/alert.tsx@@ -0,0 +1,56 @@+import * as React from "react";+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "@/lib/cva.config";++const alertVariants = cva(+ "group/alert relative grid w-full gap-0.5 rounded-lg border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",+ {+ variants: {+ variant: {+ default: "bg-card text-card-foreground",+ destructive:+ "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ },+);++function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {+ return <div data-slot="alert" role="alert" className={cn(alertVariants({ variant }), className)} {...props} />;+}++function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="alert-title"+ className={cn(+ "font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",+ className,+ )}+ {...props}+ />+ );+}++function AlertDescription({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="alert-description"+ className={cn(+ "text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",+ className,+ )}+ {...props}+ />+ );+}++function AlertAction({ className, ...props }: React.ComponentProps<"div">) {+ return <div data-slot="alert-action" className={cn("absolute top-2.5 right-3", className)} {...props} />;+}++export { Alert, AlertTitle, AlertDescription, AlertAction };