All files / src/ahuora-design-system/ui search-dialog.tsx

93.33% Statements 14/15
66.66% Branches 2/3
100% Functions 4/4
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90          37x   37x   37x   37x   37x       278x                 37x                 37x       5030x                             1x                   37x   37x       231x                 37x                    
import * as React from "react";
import * as SearchDialogPrimitive from "@radix-ui/react-dialog";
import { Cross2Icon } from "@radix-ui/react-icons";
import { cn } from "@/lib/utils";
 
const SearchDialog = SearchDialogPrimitive.Root;
 
const SearchDialogTrigger = SearchDialogPrimitive.Trigger;
 
const SearchDialogPortal = SearchDialogPrimitive.Portal;
 
const SearchDialogClose = SearchDialogPrimitive.Close;
 
const SearchDialogOverlay = React.forwardRef<
  React.ElementRef<typeof SearchDialogPrimitive.Overlay>,
  React.ComponentPropsWithoutRef<typeof SearchDialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
  <SearchDialogPrimitive.Overlay
    ref={ref}
    className={cn(
      "fixed inset-0 z-50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
      className,
    )}
    {...props}
  />
));
SearchDialogOverlay.displayName = SearchDialogPrimitive.Overlay.displayName;
 
type SearchDialogContentProps = React.ComponentPropsWithoutRef<
  typeof SearchDialogPrimitive.Content
> & {
  onClose?: () => void;
  preventDefault?: boolean;
};
 
const SearchDialogContent = React.forwardRef<
  React.ElementRef<typeof SearchDialogPrimitive.Content>,
  SearchDialogContentProps
>(({ className, children, onClose, preventDefault, ...props }, ref) => (
  <SearchDialogPortal>
    <SearchDialogOverlay />
    <SearchDialogPrimitive.Content
      ref={ref} 
      className={cn(
        "fixed top-0 origin-top z-50 left-1/2 -translate-x-1/2 grid h-[85%] w-[37.5%] scale-90 overflow-hidden pb-2 gap-2 border rounded-2xl bg-background duration-200 shadow-[0_5px_10px_rgba(0,0,0,0.4)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] 2xl:h-[62%] 2xl:w-1/3 2xl:scale-100",
        className,
      )}
      {...props}
    >
      {children}
      {!preventDefault && (
        <SearchDialogPrimitive.Close
          className="absolute right-5 top-5 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"
          onClick={() => {
            Iif (onClose) onClose();
          }}
        >
          <Cross2Icon className="h-4 w-4" />
          <span className="sr-only">Close</span>
        </SearchDialogPrimitive.Close>
      )}
    </SearchDialogPrimitive.Content>
  </SearchDialogPortal>
));
SearchDialogContent.displayName = SearchDialogPrimitive.Content.displayName;
 
const SearchDialogTitle = React.forwardRef<
  React.ElementRef<typeof SearchDialogPrimitive.Title>,
  React.ComponentPropsWithoutRef<typeof SearchDialogPrimitive.Title>
>(({ className, ...props }, ref) => (
  <SearchDialogPrimitive.Title
    ref={ref}
    className={cn(
      "text-lg font-semibold leading-none tracking-tight",
      className,
    )}
    {...props}
  />
));
SearchDialogTitle.displayName = SearchDialogPrimitive.Title.displayName;
 
export {
  SearchDialog,
  SearchDialogPortal,
  SearchDialogOverlay,
  SearchDialogTrigger,
  SearchDialogClose,
  SearchDialogContent,
  SearchDialogTitle,
};