mirror of
https://github.com/cosscom/coss.git
synced 2026-09-14 20:06:50 +08:00
15 lines
5.2 KiB
JSON
15 lines
5.2 KiB
JSON
{
|
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
"name": "sheet",
|
|
"type": "registry:ui",
|
|
"dependencies": ["@base-ui-components/react"],
|
|
"registryDependencies": ["@coss/dialog"],
|
|
"files": [
|
|
{
|
|
"path": "registry/default/ui/sheet.tsx",
|
|
"content": "\"use client\"\n\nimport { Dialog as SheetPrimitive } from \"@base-ui-components/react/dialog\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { XIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst Sheet = SheetPrimitive.Root\n\nfunction SheetTrigger(props: SheetPrimitive.Trigger.Props) {\n return <SheetPrimitive.Trigger data-slot=\"sheet-trigger\" {...props} />\n}\n\nfunction SheetPortal(props: SheetPrimitive.Portal.Props) {\n return <SheetPrimitive.Portal {...props} />\n}\n\nfunction SheetClose(props: SheetPrimitive.Close.Props) {\n return <SheetPrimitive.Close data-slot=\"sheet-close\" {...props} />\n}\n\nconst sheetPopupVariants = cva(\n \"fixed z-50 flex flex-col gap-4 overflow-y-auto bg-popover text-popover-foreground shadow-lg transition-[opacity,translate] duration-300 ease-in-out will-change-transform [--sheet-inset:0px] data-ending-style:opacity-0 data-starting-style:opacity-0\",\n {\n variants: {\n inset: {\n true: \"sm:rounded-xl sm:[--sheet-inset:1rem]\",\n },\n side: {\n right:\n \"inset-y-[var(--sheet-inset)] right-[var(--sheet-inset)] h-dvh w-[calc(100%-(--spacing(12)))] max-w-sm data-ending-style:translate-x-12 data-starting-style:translate-x-12 sm:h-[calc(100dvh-var(--sheet-inset)*2)]\",\n left: \"inset-y-[var(--sheet-inset)] left-[var(--sheet-inset)] h-dvh w-[calc(100%-(--spacing(12)))] max-w-sm data-ending-style:-translate-x-12 data-starting-style:-translate-x-12 sm:h-[calc(100dvh-var(--sheet-inset)*2)]\",\n top: \"inset-x-[var(--sheet-inset)] top-[var(--sheet-inset)] h-auto max-h-[calc(100dvh-var(--sheet-inset)*2)] data-ending-style:-translate-y-12 data-starting-style:-translate-y-12\",\n bottom:\n \"inset-x-[var(--sheet-inset)] bottom-[var(--sheet-inset)] h-auto max-h-[calc(100dvh-var(--sheet-inset)*2)] data-ending-style:translate-y-12 data-starting-style:translate-y-12\",\n },\n },\n defaultVariants: {\n inset: false,\n side: \"right\",\n },\n }\n)\n\nfunction SheetBackdrop({ className, ...props }: SheetPrimitive.Backdrop.Props) {\n return (\n <SheetPrimitive.Backdrop\n data-slot=\"sheet-backdrop\"\n className={cn(\n \"fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction SheetPopup({\n className,\n children,\n showCloseButton = true,\n side = \"right\",\n inset = false,\n ...props\n}: SheetPrimitive.Popup.Props & {\n showCloseButton?: boolean\n} & VariantProps<typeof sheetPopupVariants>) {\n return (\n <SheetPortal>\n <SheetBackdrop />\n <SheetPrimitive.Popup\n data-slot=\"sheet-popup\"\n className={cn(sheetPopupVariants({ inset, side }), className)}\n {...props}\n >\n {children}\n {showCloseButton && (\n <SheetPrimitive.Close className=\"absolute end-2 top-2 inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-72 transition-[color,background-color,box-shadow,opacity] outline-none hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\">\n <XIcon />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>\n )}\n </SheetPrimitive.Popup>\n </SheetPortal>\n )\n}\n\nfunction SheetHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sheet-header\"\n className={cn(\"flex flex-col gap-1.5 p-4\", className)}\n {...props}\n />\n )\n}\n\nfunction SheetFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"sheet-footer\"\n className={cn(\"mt-auto flex flex-col gap-2 p-4\", className)}\n {...props}\n />\n )\n}\n\nfunction SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {\n return (\n <SheetPrimitive.Title\n data-slot=\"sheet-title\"\n className={cn(\"font-semibold\", className)}\n {...props}\n />\n )\n}\n\nfunction SheetDescription({\n className,\n ...props\n}: SheetPrimitive.Description.Props) {\n return (\n <SheetPrimitive.Description\n data-slot=\"sheet-description\"\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n )\n}\n\nexport {\n Sheet,\n SheetTrigger,\n SheetPortal,\n SheetClose,\n SheetBackdrop,\n SheetBackdrop as SheetOverlay,\n SheetPopup,\n SheetPopup as SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n sheetPopupVariants,\n}\n",
|
|
"type": "registry:ui"
|
|
}
|
|
]
|
|
}
|