{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "drawer",
  "title": "Drawer",
  "description": "Flexible Base UI drawer primitive for focused tasks, panels, and mobile sheets.",
  "dependencies": [
    "@base-ui/react"
  ],
  "files": [
    {
      "path": "components/drawer/Drawer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Drawer as DrawerPrimitive } from \"@base-ui/react/drawer\";\n\ntype DrawerSide = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DrawerContextValue = {\n  modal: DrawerPrimitive.Root.Props[\"modal\"];\n  side: DrawerSide;\n};\n\nconst DrawerContext = React.createContext<DrawerContextValue | null>(null);\n\nconst swipeDirectionBySide = {\n  top: \"up\",\n  right: \"right\",\n  bottom: \"down\",\n  left: \"left\",\n} as const;\n\nconst sideClasses = {\n  top:\n    \"inset-x-0 top-0 max-h-[80dvh] rounded-b-[var(--radius-2xl,1rem)] border-t-0 \" +\n    \"[transform:translateY(var(--drawer-swipe-movement-y))] \" +\n    \"data-ending-style:[transform:translateY(calc(-100%-2px))] \" +\n    \"data-starting-style:[transform:translateY(calc(-100%-2px))]\",\n  right:\n    \"inset-y-0 right-0 h-full w-full max-w-md rounded-l-[var(--radius-2xl,1rem)] border-r-0 \" +\n    \"[transform:translateX(var(--drawer-swipe-movement-x))] \" +\n    \"data-ending-style:[transform:translateX(calc(100%+2px))] \" +\n    \"data-starting-style:[transform:translateX(calc(100%+2px))]\",\n  bottom:\n    \"inset-x-0 bottom-0 max-h-[80dvh] rounded-t-[var(--radius-2xl,1rem)] border-b-0 \" +\n    \"[transform:translateY(var(--drawer-swipe-movement-y))] \" +\n    \"data-ending-style:[transform:translateY(calc(100%+2px))] \" +\n    \"data-starting-style:[transform:translateY(calc(100%+2px))]\",\n  left:\n    \"inset-y-0 left-0 h-full w-full max-w-md rounded-r-[var(--radius-2xl,1rem)] border-l-0 \" +\n    \"[transform:translateX(var(--drawer-swipe-movement-x))] \" +\n    \"data-ending-style:[transform:translateX(calc(-100%-2px))] \" +\n    \"data-starting-style:[transform:translateX(calc(-100%-2px))]\",\n};\n\nfunction classes(...values: Array<string | undefined>) {\n  return values.filter(Boolean).join(\" \");\n}\n\nfunction mergeClassName(\n  className: string | ((state: any) => string | undefined) | undefined,\n  ...baseClasses: string[]\n) {\n  return typeof className === \"function\"\n    ? (state: any) => classes(...baseClasses, className(state))\n    : classes(...baseClasses, className);\n}\n\nfunction useDrawerContext() {\n  const context = React.useContext(DrawerContext);\n\n  if (!context) {\n    throw new Error(\"DrawerContent must be used within Drawer.\");\n  }\n\n  return context;\n}\n\nfunction Drawer({\n  side = \"bottom\",\n  modal = true,\n  swipeDirection = swipeDirectionBySide[side],\n  ...props\n}: DrawerPrimitive.Root.Props & { side?: DrawerSide }) {\n  return (\n    <DrawerContext.Provider value={{ modal, side }}>\n      <DrawerPrimitive.Root\n        modal={modal}\n        swipeDirection={swipeDirection}\n        {...props}\n      />\n    </DrawerContext.Provider>\n  );\n}\n\nfunction DrawerTrigger(props: DrawerPrimitive.Trigger.Props) {\n  return <DrawerPrimitive.Trigger {...props} />;\n}\n\nfunction DrawerClose(props: DrawerPrimitive.Close.Props) {\n  return <DrawerPrimitive.Close {...props} />;\n}\n\nfunction DrawerContent({\n  className,\n  children,\n  showHandle,\n  ...props\n}: DrawerPrimitive.Popup.Props & { showHandle?: boolean }) {\n  const { modal, side } = useDrawerContext();\n  const shouldShowHandle = showHandle ?? (side === \"top\" || side === \"bottom\");\n\n  return (\n    <DrawerPrimitive.Portal>\n      {modal && (\n        <DrawerPrimitive.Backdrop\n          className={classes(\n            \"fixed inset-0 z-50 bg-black/40\",\n            \"opacity-[calc(0.4*(1-var(--drawer-swipe-progress)))]\",\n            \"transition-opacity duration-300 data-ending-style:opacity-0\",\n            \"data-starting-style:opacity-0 data-swiping:duration-0\",\n          )}\n        />\n      )}\n      <DrawerPrimitive.Viewport className=\"pointer-events-none fixed inset-0 z-50\">\n        <DrawerPrimitive.Popup\n          className={mergeClassName(\n            className,\n            \"pointer-events-auto fixed z-50 flex min-h-0 flex-col overflow-hidden\",\n            \"border border-[color:var(--color-border,#e4e4e7)]\",\n            \"bg-[var(--color-background,#fff)] text-[color:var(--color-foreground,#09090b)]\",\n            \"shadow-2xl outline-none touch-auto transition-transform duration-300 ease-out\",\n            \"data-ending-style:duration-[calc(var(--drawer-swipe-strength)*400ms)]\",\n            \"data-swiping:select-none data-swiping:duration-0\",\n            sideClasses[side],\n          )}\n          {...props}\n        >\n          {shouldShowHandle ? <DrawerHandle /> : null}\n          <DrawerPrimitive.Content className=\"flex min-h-0 flex-1 flex-col overflow-hidden\">\n            {children}\n          </DrawerPrimitive.Content>\n        </DrawerPrimitive.Popup>\n      </DrawerPrimitive.Viewport>\n    </DrawerPrimitive.Portal>\n  );\n}\n\nfunction DrawerHandle({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      aria-hidden=\"true\"\n      className={classes(\n        \"mx-auto mt-3 h-1 w-10 shrink-0 rounded-full bg-[var(--color-muted,#f4f4f5)]\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction DrawerHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      className={classes(\n        \"flex shrink-0 items-start justify-between gap-4 px-5 py-4\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction DrawerFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      className={classes(\"mt-auto flex shrink-0 gap-3 px-5 py-4\", className)}\n      {...props}\n    />\n  );\n}\n\nfunction DrawerTitle({ className, ...props }: DrawerPrimitive.Title.Props) {\n  return (\n    <DrawerPrimitive.Title\n      className={mergeClassName(className, \"text-base font-semibold\")}\n      {...props}\n    />\n  );\n}\n\nfunction DrawerDescription({\n  className,\n  ...props\n}: DrawerPrimitive.Description.Props) {\n  return (\n    <DrawerPrimitive.Description\n      className={mergeClassName(\n        className,\n        \"text-sm text-[color:var(--color-muted-foreground,#71717a)]\",\n      )}\n      {...props}\n    />\n  );\n}\n\nexport {\n  Drawer,\n  DrawerClose,\n  DrawerContent,\n  DrawerDescription,\n  DrawerFooter,\n  DrawerHandle,\n  DrawerHeader,\n  DrawerTitle,\n  DrawerTrigger,\n};\n",
      "type": "registry:component",
      "target": "@components/drawer/Drawer.tsx"
    }
  ],
  "categories": [
    "drawer"
  ],
  "type": "registry:component"
}