{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "feedback-sheet",
  "title": "Feedback sheet",
  "description": "A tall bottom sheet that is almost all text field: write, send with a full-width pill, or follow a quiet link. It slides up over a dimmed page and drags down to dismiss.",
  "dependencies": [
    "motion",
    "radix-ui",
    "lucide-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/items/feedback-sheet/feedback-sheet.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Dialog } from \"radix-ui\";\nimport { AnimatePresence, motion, useDragControls, useReducedMotionConfig, type PanInfo } from \"motion/react\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface FeedbackSheetProps {\n  /** Whether the sheet is up. Ignored when `inline`. */\n  open?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** Receives the trimmed text. While its promise is pending the button reads `pendingLabel`; on success the field clears and the sheet closes. */\n  onSubmit?: (text: string) => void | Promise<void>;\n  /** A visible heading. Without one the sheet is just the field, as in the app, and \"Give feedback\" names it for screen readers. */\n  title?: string;\n  /** A line under the heading. */\n  description?: string;\n  placeholder?: string;\n  submitLabel?: string;\n  pendingLabel?: string;\n  maxLength?: number;\n  /** A quiet underlined link under the button, e.g. to a public ideas board. Shown when set. */\n  linkLabel?: string;\n  onLinkClick?: () => void;\n  /** Renders the panel in place, without the portal, backdrop or slide: for previews and docs. */\n  inline?: boolean;\n  defaultValue?: string;\n  className?: string;\n}\n\n/** How far down (fraction of the sheet's height) or how fast (px/s) a drag must go to dismiss. */\nconst DISMISS_FRACTION = 0.25;\nconst DISMISS_VELOCITY = 500;\nconst SLIDE = { type: \"spring\", damping: 40, stiffness: 420, mass: 1 } as const;\n\n/**\n * Steeze's quick-feedback sheet: a tall, dark bottom sheet that is almost all\n * text field, a cream pill to send, and an optional link underneath. It slides\n * up over a dimmed page; drag the handle down, press Escape or tap outside to\n * put it away. Reduced motion fades it instead of sliding.\n */\nexport function FeedbackSheet({\n  open = false,\n  onOpenChange,\n  onSubmit,\n  title,\n  description,\n  placeholder = \"Share your thoughts…\",\n  submitLabel = \"Submit Feedback\",\n  pendingLabel = \"Submitting...\",\n  maxLength = 1000,\n  linkLabel,\n  onLinkClick,\n  inline = false,\n  defaultValue = \"\",\n  className,\n}: FeedbackSheetProps) {\n  const reduceMotion = useReducedMotionConfig();\n  const dragControls = useDragControls();\n  const sheetRef = React.useRef<HTMLDivElement>(null);\n  const fieldRef = React.useRef<HTMLTextAreaElement>(null);\n  const [text, setText] = React.useState(defaultValue);\n  const [pending, setPending] = React.useState(false);\n  const empty = text.trim().length === 0;\n\n  async function submit() {\n    const trimmed = text.trim();\n    if (!trimmed || pending) return;\n    setPending(true);\n    try {\n      await onSubmit?.(trimmed);\n      setText(\"\");\n      if (!inline) onOpenChange?.(false);\n    } catch {\n      // Keep what they wrote so they can try again; the caller reports the error.\n    } finally {\n      setPending(false);\n    }\n  }\n\n  function onDragEnd(_: PointerEvent | MouseEvent | TouchEvent, info: PanInfo) {\n    const height = sheetRef.current?.offsetHeight ?? 1;\n    if (info.offset.y > height * DISMISS_FRACTION || info.velocity.y > DISMISS_VELOCITY) onOpenChange?.(false);\n  }\n\n  const TitleTag = inline ? \"h2\" : Dialog.Title;\n  const DescriptionTag = inline ? \"p\" : Dialog.Description;\n\n  const panel = (\n    <>\n      {/* The grab handle: drag it down to dismiss. */}\n      <div\n        aria-hidden=\"true\"\n        onPointerDown={inline ? undefined : (event) => dragControls.start(event)}\n        className={cn(\"flex shrink-0 justify-center p-2.5\", !inline && \"cursor-grab touch-none active:cursor-grabbing\")}\n      >\n        <span className=\"h-1 w-[30px] rounded-full bg-ink\" />\n      </div>\n\n      <div className=\"relative flex min-h-0 flex-1 flex-col px-6 pt-4 pb-[max(1.5rem,env(safe-area-inset-bottom))]\">\n        <button\n          type=\"button\"\n          aria-label=\"Close\"\n          onClick={() => onOpenChange?.(false)}\n          className=\"absolute top-4 right-4 z-10 rounded-full bg-ground/70 p-2.5 text-ink shadow-md transition-opacity hover:opacity-85 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n        >\n          <X className=\"size-[22px]\" aria-hidden=\"true\" />\n        </button>\n\n        {title ? (\n          <TitleTag className=\"mb-1 pr-14 font-body text-xl font-medium text-popover-foreground\">{title}</TitleTag>\n        ) : (\n          <TitleTag className=\"sr-only\">Give feedback</TitleTag>\n        )}\n        {description ? (\n          <DescriptionTag className=\"mb-3 pr-14 font-body text-sm text-dim\">{description}</DescriptionTag>\n        ) : null}\n\n        <textarea\n          ref={fieldRef}\n          value={text}\n          onChange={(event) => setText(event.target.value)}\n          onKeyDown={(event) => {\n            if (event.key === \"Enter\" && (event.metaKey || event.ctrlKey)) {\n              event.preventDefault();\n              void submit();\n            }\n          }}\n          placeholder={placeholder}\n          maxLength={maxLength}\n          aria-label={title ? undefined : \"Your feedback\"}\n          className=\"max-h-[220px] min-h-[120px] w-full resize-none rounded-xl bg-transparent py-3 pr-14 pl-4 font-body text-2xl font-medium text-popover-foreground caret-ink outline-none placeholder:text-dim\"\n        />\n\n        <div className=\"mt-auto pt-4\">\n          <button\n            type=\"button\"\n            onClick={() => void submit()}\n            disabled={pending || empty}\n            aria-busy={pending || undefined}\n            className=\"flex w-full items-center justify-center rounded-[24px] bg-primary py-3 font-body text-base font-semibold text-primary-foreground transition-colors duration-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:bg-primary/10 disabled:text-primary/40\"\n          >\n            {pending ? pendingLabel : submitLabel}\n          </button>\n          {linkLabel ? (\n            <div className=\"flex justify-center pt-3\">\n              <button\n                type=\"button\"\n                onClick={onLinkClick}\n                className=\"font-body text-base text-popover-foreground underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n              >\n                {linkLabel}\n              </button>\n            </div>\n          ) : null}\n        </div>\n      </div>\n    </>\n  );\n\n  if (inline) {\n    return (\n      <div\n        role=\"group\"\n        aria-label={title ?? \"Give feedback\"}\n        className={cn(\"flex h-[460px] w-full max-w-[400px] flex-col overflow-hidden rounded-[24px] bg-popover font-body\", className)}\n      >\n        {panel}\n      </div>\n    );\n  }\n\n  return (\n    <Dialog.Root open={open} onOpenChange={onOpenChange}>\n      <AnimatePresence>\n        {open ? (\n          <Dialog.Portal forceMount>\n            <Dialog.Overlay {...{ asChild: true }} forceMount>\n              <motion.div\n                className=\"fixed inset-0 z-50 bg-ground/60\"\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                exit={{ opacity: 0 }}\n                transition={{ duration: 0.25 }}\n              />\n            </Dialog.Overlay>\n            <Dialog.Content\n              {...{ asChild: true }}\n              forceMount\n              // No description: tell Radix the field speaks for itself.\n              {...(description ? {} : { \"aria-describedby\": undefined })}\n              onOpenAutoFocus={(event) => {\n                event.preventDefault();\n                fieldRef.current?.focus();\n              }}\n            >\n              <motion.div\n                ref={sheetRef}\n                drag={reduceMotion ? false : \"y\"}\n                dragControls={dragControls}\n                dragListener={false}\n                dragConstraints={{ top: 0, bottom: 0 }}\n                dragElastic={{ top: 0, bottom: 1 }}\n                onDragEnd={onDragEnd}\n                initial={reduceMotion ? { opacity: 0 } : { y: \"100%\" }}\n                animate={reduceMotion ? { opacity: 1 } : { y: 0 }}\n                exit={reduceMotion ? { opacity: 0 } : { y: \"100%\" }}\n                transition={reduceMotion ? { duration: 0.2 } : SLIDE}\n                className={cn(\n                  \"fixed inset-x-0 bottom-0 z-50 mx-auto flex h-[70dvh] w-full max-w-[520px] flex-col rounded-t-[24px] bg-popover font-body shadow-lg outline-none\",\n                  className,\n                )}\n              >\n                {panel}\n              </motion.div>\n            </Dialog.Content>\n          </Dialog.Portal>\n        ) : null}\n      </AnimatePresence>\n    </Dialog.Root>\n  );\n}\n\nexport default FeedbackSheet;\n",
      "type": "registry:block"
    }
  ],
  "meta": {
    "kind": "pattern",
    "whenToUse": "Use for open-ended feedback or a quick note from anywhere in an app, where a full page would be too much. Not for structured surveys or ratings; use a form or the feedback card for those.",
    "origin": {
      "project": "Steeze",
      "path": "app/(root)/(tabs)/settings.tsx (Quick Feedback BottomSheetModal) + components/FilterSortModals.tsx (app_steeze)"
    },
    "credits": [
      {
        "name": "@gorhom/bottom-sheet: the app's sheet behaviour (handle, pan-down to close, backdrop) re-created here with motion and Radix Dialog",
        "url": "https://github.com/gorhom/react-native-bottom-sheet",
        "license": "MIT"
      }
    ]
  },
  "type": "registry:block"
}
