From e855691fc884b93c15ac3a520a367a25bd546868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cguiherme=E2=80=9D?= <“guilherme@agapesistemas.com.br”> Date: Wed, 19 Nov 2025 14:36:30 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20refatorar=20componentes=20do=20Sheet=20?= =?UTF-8?q?para=20melhorar=20a=20legibilidade=20e=20a=20estrutura=20do=20c?= =?UTF-8?q?=C3=B3digo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/components/ui/sheet.tsx | 241 +++++++++++++++--------------- 1 file changed, 122 insertions(+), 119 deletions(-) diff --git a/src/views/components/ui/sheet.tsx b/src/views/components/ui/sheet.tsx index a4c4a11..43f0993 100644 --- a/src/views/components/ui/sheet.tsx +++ b/src/views/components/ui/sheet.tsx @@ -1,137 +1,140 @@ -import * as React from "react" -import * as SheetPrimitive from "@radix-ui/react-dialog" -import { XIcon } from "lucide-react" +import * as SheetPrimitive from '@radix-ui/react-dialog'; +import { cva, type VariantProps } from 'class-variance-authority'; +import { X } from 'lucide-react'; +import * as React from 'react'; -import { cn } from "@/app/utils" +import { cn } from '@/app/utils/index.ts'; -function Sheet({ ...props }: React.ComponentProps) { - return -} +const Sheet = SheetPrimitive.Root; -function SheetTrigger({ - ...props -}: React.ComponentProps) { - return -} +const SheetTrigger = SheetPrimitive.Trigger; -function SheetClose({ - ...props -}: React.ComponentProps) { - return -} +const SheetClose = SheetPrimitive.Close; -function SheetPortal({ - ...props -}: React.ComponentProps) { - return -} +const SheetPortal = SheetPrimitive.Portal; -function SheetOverlay({ +const SheetOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +SheetOverlay.displayName = SheetPrimitive.Overlay.displayName; + +const sheetVariants = cva( + 'fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500 dark:bg-gray-950', + { + variants: { + side: { + top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top', + bottom: + 'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom', + left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm', + right: + 'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm', + }, + }, + defaultVariants: { + side: 'right', + }, + }, +); + +interface SheetContentProps + extends React.ComponentPropsWithoutRef, + VariantProps {} + +const SheetContent = React.forwardRef< + React.ElementRef, + SheetContentProps +>(({ side = 'right', className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)); +SheetContent.displayName = SheetPrimitive.Content.displayName; + +const SheetHeader = ({ className, ...props -}: React.ComponentProps) { - return ( - - ) -} +}: React.HTMLAttributes) => ( +
+); +SheetHeader.displayName = 'SheetHeader'; -function SheetContent({ - className, - children, - side = "right", - ...props -}: React.ComponentProps & { - side?: "top" | "right" | "bottom" | "left" -}) { - return ( - - - - {children} - - - Close - - - - ) -} - -function SheetHeader({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function SheetFooter({ className, ...props }: React.ComponentProps<"div">) { - return ( -
- ) -} - -function SheetTitle({ +const SheetFooter = ({ className, ...props -}: React.ComponentProps) { - return ( - - ) -} +}: React.HTMLAttributes) => ( +
+); +SheetFooter.displayName = 'SheetFooter'; -function SheetDescription({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} +const SheetTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +SheetTitle.displayName = SheetPrimitive.Title.displayName; + +const SheetDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +SheetDescription.displayName = SheetPrimitive.Description.displayName; export { Sheet, - SheetTrigger, SheetClose, SheetContent, - SheetHeader, - SheetFooter, - SheetTitle, SheetDescription, -} + SheetFooter, + SheetHeader, + SheetOverlay, + SheetPortal, + SheetTitle, + SheetTrigger, +};