mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 14:08:47 +00:00
* feat: add base and radix docs * feat: transform code for display * fix * fix * fix * fix * fix * chore: remove claude files * fix * fix * fix * chore: run format:write * fix * feat: add more examples * fix * feat: add aspect-ratio * feat: add avatar * feat: add badge * feat: add breadcrumb * fix * feat: add button * fix * fix * fix * feat: add calendar and card * feat: add carousel * fix: chart * feat: add checkbox * feat: add collapsible * feat: add combobox * feat: add command * feat: add context menu * feat: add data-table dialog and drawer * feat: dropdown-menu * feat: add date-picker * feat: add empty * feat: add field and hover-card * fix: input * feat: add input * feat: add input-group * feat: add input-otp * feat: add item * feat: add kbd and label * feat: add menubar * feat: add native-select * feat: add more components * feat: more components * feat: more components * feat: add skeleton, slider and sonner * feat: add spinner and switch * feat: add more components * fix: tabs * fix: tabs * feat: add docs for sidebar * fix * fix * fi * docs: update * fix: create page * fix * fix * chore: add changelog * fix
187 lines
5.1 KiB
TypeScript
187 lines
5.1 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { cn } from "@/examples/base/lib/utils"
|
|
import { Button } from "@/examples/base/ui/button"
|
|
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog"
|
|
|
|
function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
|
|
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
|
|
}
|
|
|
|
function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {
|
|
return (
|
|
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
|
|
)
|
|
}
|
|
|
|
function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {
|
|
return (
|
|
<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
|
|
)
|
|
}
|
|
|
|
function AlertDialogOverlay({
|
|
className,
|
|
...props
|
|
}: AlertDialogPrimitive.Backdrop.Props) {
|
|
return (
|
|
<AlertDialogPrimitive.Backdrop
|
|
data-slot="alert-dialog-overlay"
|
|
className={cn(
|
|
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function AlertDialogContent({
|
|
className,
|
|
size = "default",
|
|
...props
|
|
}: AlertDialogPrimitive.Popup.Props & {
|
|
size?: "default" | "sm"
|
|
}) {
|
|
return (
|
|
<AlertDialogPortal>
|
|
<AlertDialogOverlay />
|
|
<AlertDialogPrimitive.Popup
|
|
data-slot="alert-dialog-content"
|
|
data-size={size}
|
|
className={cn(
|
|
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/10 group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl p-4 ring-1 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
</AlertDialogPortal>
|
|
)
|
|
}
|
|
|
|
function AlertDialogHeader({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"div">) {
|
|
return (
|
|
<div
|
|
data-slot="alert-dialog-header"
|
|
className={cn(
|
|
"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function AlertDialogFooter({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"div">) {
|
|
return (
|
|
<div
|
|
data-slot="alert-dialog-footer"
|
|
className={cn(
|
|
"bg-muted/50 -mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function AlertDialogMedia({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"div">) {
|
|
return (
|
|
<div
|
|
data-slot="alert-dialog-media"
|
|
className={cn(
|
|
"bg-muted mb-2 inline-flex size-10 items-center justify-center rounded-md sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function AlertDialogTitle({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
|
|
return (
|
|
<AlertDialogPrimitive.Title
|
|
data-slot="alert-dialog-title"
|
|
className={cn(
|
|
"text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function AlertDialogDescription({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
|
|
return (
|
|
<AlertDialogPrimitive.Description
|
|
data-slot="alert-dialog-description"
|
|
className={cn(
|
|
"text-muted-foreground *:[a]:hover:text-foreground text-sm text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function AlertDialogAction({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof Button>) {
|
|
return (
|
|
<Button
|
|
data-slot="alert-dialog-action"
|
|
className={cn(className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function AlertDialogCancel({
|
|
className,
|
|
variant = "outline",
|
|
size = "default",
|
|
...props
|
|
}: AlertDialogPrimitive.Close.Props &
|
|
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
|
|
return (
|
|
<AlertDialogPrimitive.Close
|
|
data-slot="alert-dialog-cancel"
|
|
className={cn(className)}
|
|
render={<Button variant={variant} size={size} />}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogMedia,
|
|
AlertDialogOverlay,
|
|
AlertDialogPortal,
|
|
AlertDialogTitle,
|
|
AlertDialogTrigger,
|
|
}
|