FactuGES_ERP/packages/shadcn-ui/src/components/empty.tsx

102 lines
2.3 KiB
TypeScript
Raw Normal View History

2025-10-14 13:49:25 +00:00
import { cva, type VariantProps } from "class-variance-authority"
2025-10-12 11:03:24 +00:00
2025-10-14 13:49:25 +00:00
import { cn } from "@repo/shadcn-ui/lib/utils"
2025-10-12 11:03:24 +00:00
function Empty({ className, ...props }: React.ComponentProps<"div">) {
2025-10-14 13:49:25 +00:00
return (
<div
data-slot="empty"
className={cn(
2026-03-17 17:49:54 +00:00
"flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",
2025-10-14 13:49:25 +00:00
className
)}
{...props}
/>
)
2025-10-12 11:03:24 +00:00
}
function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) {
2025-10-14 13:49:25 +00:00
return (
<div
data-slot="empty-header"
2026-03-17 17:49:54 +00:00
className={cn("flex max-w-sm flex-col items-center gap-2", className)}
2025-10-14 13:49:25 +00:00
{...props}
/>
)
2025-10-12 11:03:24 +00:00
}
const emptyMediaVariants = cva(
2026-03-17 17:49:54 +00:00
"mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
2025-10-14 13:49:25 +00:00
{
variants: {
variant: {
default: "bg-transparent",
2026-03-17 17:49:54 +00:00
icon: "flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4",
2025-10-14 13:49:25 +00:00
},
},
defaultVariants: {
variant: "default",
},
}
2025-10-12 11:03:24 +00:00
)
function EmptyMedia({
2025-10-14 13:49:25 +00:00
className,
variant = "default",
...props
2025-10-12 11:03:24 +00:00
}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {
2025-10-14 13:49:25 +00:00
return (
<div
data-slot="empty-icon"
data-variant={variant}
className={cn(emptyMediaVariants({ variant, className }))}
{...props}
/>
)
2025-10-12 11:03:24 +00:00
}
function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {
2025-10-14 13:49:25 +00:00
return (
<div
data-slot="empty-title"
2026-03-17 17:49:54 +00:00
className={cn("text-sm font-medium tracking-tight", className)}
2025-10-14 13:49:25 +00:00
{...props}
/>
)
2025-10-12 11:03:24 +00:00
}
function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {
2025-10-14 13:49:25 +00:00
return (
<div
data-slot="empty-description"
className={cn(
2026-03-17 17:49:54 +00:00
"text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
2025-10-14 13:49:25 +00:00
className
)}
{...props}
/>
)
2025-10-12 11:03:24 +00:00
}
function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {
2025-10-14 13:49:25 +00:00
return (
<div
data-slot="empty-content"
className={cn(
2026-03-17 17:49:54 +00:00
"flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",
2025-10-14 13:49:25 +00:00
className
)}
{...props}
/>
)
2025-10-12 11:03:24 +00:00
}
export {
2025-10-14 13:49:25 +00:00
Empty,
EmptyHeader,
EmptyTitle,
EmptyDescription,
EmptyContent,
EmptyMedia,
2025-10-12 11:03:24 +00:00
}