{
  "name": "drawer",
  "type": "registry:ui",
  "framework": "react",
  "title": "Drawer",
  "description": "A modal panel that slides against an edge of the screen and closes on Escape, overlay click or an explicit close control.",
  "dependencies": [
    "radix-ui"
  ],
  "files": [
    {
      "path": "ui/drawer.tsx",
      "content": "\"use client\"\n\nimport { Dialog as DialogPrimitive } from \"radix-ui\"\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/*\n * A panel that comes in from the edge and keeps the page behind it in view.\n * Radix owns the behaviour: open state, the focus trap, Escape and outside\n * press, scroll lock, hiding the page from screen readers, and giving focus\n * back to the trigger. Only the look is newt/ui's.\n */\nconst Drawer = DialogPrimitive.Root\n\n/*\n * It has no look of its own. Pass `asChild` to put the state on your own\n * button: `<DrawerTrigger asChild><Button>Open</Button></DrawerTrigger>`.\n * Focus returns to the trigger when the drawer closes. A drawer opened from\n * state alone has no trigger, so pass `onCloseAutoFocus` to `DrawerContent`\n * to say where focus goes.\n */\nconst DrawerTrigger = DialogPrimitive.Trigger\n\n/**\n * Closes the drawer when activated. Wrap a Button with `asChild` to keep its styling:\n * `<DrawerClose asChild><Button variant=\"secondary\">Cancel</Button></DrawerClose>`\n */\nconst DrawerClose = DialogPrimitive.Close\n\nconst SIDE = {\n  end: \"inset-y-0 end-0 start-auto h-full w-[380px] max-w-[90vw] border-s\",\n  start: \"inset-y-0 start-0 end-auto h-full w-[380px] max-w-[90vw] border-e\",\n  bottom:\n    \"inset-x-0 bottom-0 top-auto h-auto max-h-[85vh] w-full max-w-none border-t\",\n} as const\n\nconst DrawerContent = React.forwardRef<\n  React.ComponentRef<typeof DialogPrimitive.Content>,\n  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {\n    /** The edge it sits against. `end` is the right in left-to-right text. */\n    side?: keyof typeof SIDE\n    /**\n     * The element the overlay and panel are portalled into. Defaults to\n     * `document.body`. A drawer opened below a `DirectionProvider` or a themed\n     * wrapper passes that element, so it keeps the direction and the palette.\n     */\n    container?: React.ComponentProps<typeof DialogPrimitive.Portal>[\"container\"]\n  }\n>(({ className, children, side = \"end\", container, ...props }, ref) => (\n  <DialogPrimitive.Portal container={container}>\n    <DialogPrimitive.Overlay className=\"fixed inset-0 z-[100] bg-newt-overlay\" />\n    <DialogPrimitive.Content\n      ref={ref}\n      data-side={side}\n      className={cn(\n        \"fixed z-[100] flex flex-col border-newt-border bg-newt-bg-elevated text-newt-text-primary shadow-elevation-high outline-none\",\n        SIDE[side],\n        className\n      )}\n      {...props}\n    >\n      {children}\n    </DialogPrimitive.Content>\n  </DialogPrimitive.Portal>\n))\nDrawerContent.displayName = \"DrawerContent\"\n\nexport interface DrawerHeaderProps extends React.ComponentProps<\"header\"> {\n  /** Accessible name of the close button. */\n  closeLabel?: string\n}\n\n/** The row for `DrawerTitle`, with the button that closes the drawer at its end. */\nconst DrawerHeader = React.forwardRef<HTMLElement, DrawerHeaderProps>(\n  ({ className, closeLabel = \"Close\", children, ...props }, ref) => (\n    <header\n      ref={ref}\n      className={cn(\n        \"flex items-center justify-between gap-3 border-b border-newt-border p-4\",\n        className\n      )}\n      {...props}\n    >\n      <div className=\"flex min-w-0 flex-col gap-1\">{children}</div>\n      <DialogPrimitive.Close\n        aria-label={closeLabel}\n        className=\"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-[var(--newt-radius-sm)] text-newt-text-muted hover:bg-newt-bg-hover hover:text-newt-text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link\"\n      >\n        <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\" className=\"h-4 w-4\">\n          <path\n            fill=\"currentColor\"\n            d=\"M4.3 4.3a1 1 0 0 1 1.4 0L8 6.6l2.3-2.3a1 1 0 1 1 1.4 1.4L9.4 8l2.3 2.3a1 1 0 0 1-1.4 1.4L8 9.4l-2.3 2.3a1 1 0 0 1-1.4-1.4L6.6 8 4.3 5.7a1 1 0 0 1 0-1.4Z\"\n          />\n        </svg>\n      </DialogPrimitive.Close>\n    </header>\n  )\n)\nDrawerHeader.displayName = \"DrawerHeader\"\n\n/** The dialog's accessible name. Give it real text. */\nconst DrawerTitle = React.forwardRef<\n  React.ComponentRef<typeof DialogPrimitive.Title>,\n  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n  <DialogPrimitive.Title\n    ref={ref}\n    className={cn(\"m-0 text-base font-semibold leading-5\", className)}\n    {...props}\n  />\n))\nDrawerTitle.displayName = \"DrawerTitle\"\n\n/**\n * Radix links it to the dialog with `aria-describedby`. A drawer without one\n * passes `aria-describedby={undefined}` to `DrawerContent` to say so.\n */\nconst DrawerDescription = React.forwardRef<\n  React.ComponentRef<typeof DialogPrimitive.Description>,\n  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n  <DialogPrimitive.Description\n    ref={ref}\n    className={cn(\"m-0 text-sm leading-5 text-newt-text-secondary\", className)}\n    {...props}\n  />\n))\nDrawerDescription.displayName = \"DrawerDescription\"\n\nconst DrawerBody = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(({ className, ...props }, ref) => (\n  <div\n    ref={ref}\n    className={cn(\n      \"flex-1 overflow-y-auto p-4 text-sm leading-5 text-newt-text-secondary\",\n      className\n    )}\n    {...props}\n  />\n))\nDrawerBody.displayName = \"DrawerBody\"\n\nconst DrawerFooter = React.forwardRef<\n  HTMLElement,\n  React.ComponentProps<\"footer\">\n>(({ className, ...props }, ref) => (\n  <footer\n    ref={ref}\n    className={cn(\"flex justify-end gap-2 bg-newt-bg-surface p-4\", className)}\n    {...props}\n  />\n))\nDrawerFooter.displayName = \"DrawerFooter\"\n\nexport {\n  Drawer,\n  DrawerTrigger,\n  DrawerContent,\n  DrawerHeader,\n  DrawerTitle,\n  DrawerDescription,\n  DrawerBody,\n  DrawerFooter,\n  DrawerClose,\n}\n",
      "type": "registry:ui"
    }
  ]
}