{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popover-08",
  "title": "Feedback popover",
  "description": "A short form that confirms when the message is sent.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/popover.json",
    "https://ui.ndekocode.dev/r/textarea.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/popover/popover-08.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { CircleCheckIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Popover,\n  PopoverContent,\n  PopoverTitle,\n  PopoverTrigger,\n} from '@/registry/ndeko/ui/popover';\nimport { Textarea } from '@/registry/ndeko/ui/textarea';\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst NOTICE_VARIANTS: Variants = {\n  enter: { opacity: 0, filter: 'blur(2px)' },\n  visible: { opacity: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, filter: 'blur(2px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nfunction noticeVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return NOTICE_VARIANTS;\n}\n\nexport default function Popover08() {\n  const [message, setMessage] = useState('');\n  const [isSent, setIsSent] = useState(false);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const noticeVariants = noticeVariantsOf(shouldReduceMotion);\n  const trimmedMessage = message.trim();\n  const hasMessage = trimmedMessage.length > 0;\n\n  function updateMessage(event: React.ChangeEvent<HTMLTextAreaElement>) {\n    setMessage(event.target.value);\n    setIsSent(false);\n  }\n\n  function sendFeedback(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (!hasMessage) {\n      return;\n    }\n    setMessage('');\n    setIsSent(true);\n  }\n\n  function resetAfterClosing(isOpen: boolean) {\n    if (isOpen) {\n      return;\n    }\n    setMessage('');\n    setIsSent(false);\n  }\n\n  return (\n    <Popover onOpenChangeComplete={resetAfterClosing}>\n      <PopoverTrigger render={<Button variant='outline' />}>\n        Feedback\n      </PopoverTrigger>\n      <PopoverContent className='flex flex-col gap-3'>\n        <PopoverTitle>Send us feedback</PopoverTitle>\n        <form onSubmit={sendFeedback} className='flex flex-col gap-3'>\n          <Textarea\n            value={message}\n            onChange={updateMessage}\n            placeholder='What would make this page better?'\n            aria-label='Feedback'\n          />\n          <div className='flex items-center justify-between gap-3'>\n            <div role='status' className='flex'>\n              <AnimatePresence initial={false}>\n                {isSent && (\n                  <motion.span\n                    key='sent'\n                    className='text-muted-foreground flex items-center gap-1.5 text-xs'\n                    variants={noticeVariants}\n                    initial='enter'\n                    animate='visible'\n                    exit='exit'\n                    transition={SWAP_TRANSITION}\n                  >\n                    <CircleCheckIcon className='text-success-foreground size-3.5' />\n                    Sent. Thank you.\n                  </motion.span>\n                )}\n              </AnimatePresence>\n            </div>\n            <Button\n              type='submit'\n              size='sm'\n              disabled={!hasMessage}\n              focusableWhenDisabled\n              className='ml-auto'\n            >\n              Send feedback\n            </Button>\n          </div>\n        </form>\n      </PopoverContent>\n    </Popover>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "popover"
  ],
  "type": "registry:component"
}