{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-09",
  "title": "Give feedback",
  "description": "A kind, a five-step scale, a follow-up question that follows the rating, a screenshot slot and a thank-you state",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/dialog.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/radio-group.json",
    "https://ui.ndekocode.dev/r/status-orb.json",
    "https://ui.ndekocode.dev/r/textarea.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/toggle-group.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/modal/modal-09.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useId, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  ImageIcon,\n  PaperclipIcon,\n  SendIcon,\n  ThumbsUpIcon,\n  TriangleAlertIcon,\n  XIcon,\n  LightbulbIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { RadioGroup, RadioGroupItem } from '@/registry/ndeko/ui/radio-group';\nimport { StatusOrb } from '@/registry/ndeko/ui/status-orb';\nimport { Textarea } from '@/registry/ndeko/ui/textarea';\n\nimport {\n  ActionButton,\n  useTimedAction,\n  type ActionLabels,\n} from './_parts/action-button';\nimport { ChoiceSegments, type SegmentOption } from './_parts/choice-segments';\nimport {\n  ModalCloseButton,\n  ModalDescription,\n  ModalFooter,\n  ModalHeader,\n  ModalPreview,\n  ModalTitle,\n} from './_parts/modal-frame';\nimport { chipVariantsOf, morphOf } from './_parts/motion';\nimport { CURRENT_USER, WORKSPACE_NAME, firstNameOf } from './_parts/people';\nimport { Swap } from './_parts/swap';\n\ntype FeedbackKind = 'idea' | 'problem' | 'praise';\n\ntype Attachment = { name: string; size: string };\n\nconst KINDS: SegmentOption<FeedbackKind>[] = [\n  { value: 'idea', label: 'Idea', icon: LightbulbIcon },\n  { value: 'problem', label: 'Problem', icon: TriangleAlertIcon },\n  { value: 'praise', label: 'Praise', icon: ThumbsUpIcon },\n];\n\nconst PLACEHOLDER: Record<FeedbackKind, string> = {\n  idea: 'Describe the idea and the problem it would solve',\n  problem: 'What you did, what happened and what you expected',\n  praise: 'What worked well, and where',\n};\n\nconst THANKS_LINE: Record<FeedbackKind, string> = {\n  idea: 'The product team reads every idea and links it to the roadmap once it is planned',\n  problem: `We reply by e-mail within two working days, at ${CURRENT_USER.email}`,\n  praise: 'It goes straight to the people who built that part',\n};\n\nconst SCALE = [1, 2, 3, 4, 5];\n\nconst FIRST_RATING = 4;\n\nconst MESSAGE_LIMIT = 500;\n\nconst KILOBYTE = 1024;\n\nconst MEGABYTE = KILOBYTE * KILOBYTE;\n\nconst SEND_LABELS: ActionLabels = {\n  idle: 'Send feedback',\n  working: 'Sending',\n  done: 'Sent',\n};\n\nconst STEP_TRANSITION: Transition = {\n  duration: 0.2,\n  ease: [0.23, 1, 0.32, 1],\n};\n\nconst STEP_VARIANTS: Variants = {\n  hidden: { opacity: 0, filter: 'blur(2px)', transition: STEP_TRANSITION },\n  shown: { opacity: 1, filter: 'blur(0px)', transition: STEP_TRANSITION },\n};\n\nconst STEP_FADE: Variants = {\n  hidden: { opacity: 0, transition: STEP_TRANSITION },\n  shown: { opacity: 1, transition: STEP_TRANSITION },\n};\n\nconst SCALE_SEGMENT = [\n  'relative isolate flex h-7 flex-1 cursor-pointer items-center justify-center rounded-full text-[13px] font-medium tabular-nums text-muted-foreground',\n  'transition-colors duration-150 hover:text-foreground has-data-checked:text-foreground',\n  'has-focus-visible:ring-[3px] has-focus-visible:ring-ring/25',\n].join(' ');\n\nconst SCALE_THUMB =\n  'absolute inset-0 -z-10 rounded-full bg-card shadow-[0_1px_2px_rgb(0_0_0/0.08)] hairline-ring ring-foreground/10 dark:bg-foreground/[0.09] dark:ring-foreground/15';\n\nfunction stepVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return STEP_FADE;\n  }\n  return STEP_VARIANTS;\n}\n\nfunction questionOf(rating: number) {\n  if (rating <= 2) {\n    return 'What got in your way';\n  }\n  if (rating === 3) {\n    return 'What would make it work better for you';\n  }\n  return 'What do you rely on most';\n}\n\nfunction sizeLabelOf(bytes: number) {\n  if (bytes < MEGABYTE) {\n    const kilobytes = Math.max(1, Math.round(bytes / KILOBYTE));\n    return `${kilobytes} KB`;\n  }\n  const megabytes = (bytes / MEGABYTE).toFixed(1);\n  return `${megabytes} MB`;\n}\n\nfunction RatingScale({\n  rating,\n  labelId,\n  onChange,\n}: {\n  rating: number;\n  labelId: string;\n  onChange: (rating: number) => void;\n}) {\n  const thumbId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const thumbTransition = morphOf(shouldReduceMotion);\n\n  function changeRating(value: unknown) {\n    const nextRating = Number(value);\n    const isOnScale = SCALE.includes(nextRating);\n    if (isOnScale) {\n      onChange(nextRating);\n    }\n  }\n\n  return (\n    <div className='flex items-center gap-3'>\n      <span className='text-muted-foreground shrink-0 text-xs'>Not well</span>\n      <RadioGroup\n        aria-labelledby={labelId}\n        value={String(rating)}\n        onValueChange={changeRating}\n        className='bg-foreground/[0.05] flex flex-1 gap-0.5 rounded-full p-0.5'\n      >\n        {SCALE.map((step) => {\n          const isPicked = step === rating;\n\n          return (\n            <label key={step} className={SCALE_SEGMENT}>\n              <RadioGroupItem value={String(step)} className='sr-only' />\n              {isPicked && (\n                <motion.span\n                  layoutId={thumbId}\n                  transition={thumbTransition}\n                  aria-hidden='true'\n                  className={SCALE_THUMB}\n                />\n              )}\n              {step}\n            </label>\n          );\n        })}\n      </RadioGroup>\n      <span className='text-muted-foreground shrink-0 text-xs'>Very well</span>\n    </div>\n  );\n}\n\nfunction AttachSlot({\n  attachment,\n  onAttach,\n  onRemove,\n}: {\n  attachment: Attachment | null;\n  onAttach: (attachment: Attachment) => void;\n  onRemove: () => void;\n}) {\n  const inputId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = chipVariantsOf(shouldReduceMotion);\n\n  function pickFile(event: React.ChangeEvent<HTMLInputElement>) {\n    const file = event.target.files?.[0];\n    event.target.value = '';\n    if (!file) {\n      return;\n    }\n    onAttach({ name: file.name, size: sizeLabelOf(file.size) });\n  }\n\n  return (\n    <div className='relative h-11'>\n      <AnimatePresence initial={false} mode='popLayout'>\n        {attachment && (\n          <motion.div\n            key='file'\n            variants={variants}\n            initial='hidden'\n            animate='shown'\n            exit='hidden'\n            className='bg-card hairline-ring ring-border flex h-11 items-center gap-2.5 rounded-lg pr-1.5 pl-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n          >\n            <span className='keycap-3d text-muted-foreground flex size-7 shrink-0 items-center justify-center rounded-md'>\n              <ImageIcon className='size-3.5' />\n            </span>\n            <span className='flex min-w-0 flex-1 flex-col'>\n              <span className='truncate text-[13px] font-medium'>\n                {attachment.name}\n              </span>\n              <span className='text-muted-foreground text-xs tabular-nums'>\n                {attachment.size}\n              </span>\n            </span>\n            <Button\n              variant='ghost'\n              size='icon-sm'\n              aria-label={`Remove ${attachment.name}`}\n              onClick={onRemove}\n              className='text-muted-foreground'\n            >\n              <XIcon />\n            </Button>\n          </motion.div>\n        )}\n        {!attachment && (\n          <motion.label\n            key='slot'\n            htmlFor={inputId}\n            variants={variants}\n            initial='hidden'\n            animate='shown'\n            exit='hidden'\n            className='hairline-border border-foreground/20 text-muted-foreground hover:bg-foreground/[0.02] hover:text-foreground has-focus-visible:ring-ring/25 flex h-11 cursor-pointer items-center justify-center gap-2 rounded-lg border-dashed text-[13px] transition-colors duration-150 has-focus-visible:ring-[3px]'\n          >\n            <PaperclipIcon className='size-4' />\n            Attach a screenshot\n            <span className='text-muted-foreground/80'>(optional)</span>\n            <input\n              id={inputId}\n              type='file'\n              accept='image/png,image/jpeg'\n              onChange={pickFile}\n              className='sr-only'\n            />\n          </motion.label>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nfunction FeedbackForm({\n  kind,\n  onKindChange,\n  onSent,\n}: {\n  kind: FeedbackKind;\n  onKindChange: (kind: FeedbackKind) => void;\n  onSent: () => void;\n}) {\n  const [rating, setRating] = useState(FIRST_RATING);\n  const [message, setMessage] = useState('');\n  const [attachment, setAttachment] = useState<Attachment | null>({\n    name: 'timesheet-export.png',\n    size: '284 KB',\n  });\n  const { state, run } = useTimedAction();\n  const scaleLabelId = useId();\n  const messageId = useId();\n  const countId = useId();\n  const question = questionOf(rating);\n  const hasMessage = message.trim().length > 0;\n  const isIdle = state === 'idle';\n  const isSendDisabled = isIdle && !hasMessage;\n\n  function changeMessage(event: React.ChangeEvent<HTMLTextAreaElement>) {\n    setMessage(event.target.value);\n  }\n\n  function removeAttachment() {\n    setAttachment(null);\n  }\n\n  function send(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (!hasMessage) {\n      return;\n    }\n    run(onSent);\n  }\n\n  return (\n    <form onSubmit={send} className='flex flex-col gap-5'>\n      <ModalHeader>\n        <ModalTitle>Send feedback</ModalTitle>\n        <ModalDescription>\n          {`It goes to the people who build ${WORKSPACE_NAME}; they read every message`}\n        </ModalDescription>\n      </ModalHeader>\n      <ChoiceSegments\n        label='Kind of feedback'\n        value={kind}\n        options={KINDS}\n        onValueChange={onKindChange}\n      />\n      <div className='flex flex-col gap-2'>\n        <span id={scaleLabelId} className='text-[13px] font-medium'>\n          {`How well does ${WORKSPACE_NAME} work for you`}\n        </span>\n        <RatingScale\n          rating={rating}\n          labelId={scaleLabelId}\n          onChange={setRating}\n        />\n      </div>\n      <div className='flex flex-col gap-1.5'>\n        <div className='flex items-baseline justify-between gap-3'>\n          <label htmlFor={messageId} className='text-[13px] font-medium'>\n            <Swap swapKey={question} kind='label'>\n              {question}\n            </Swap>\n          </label>\n          <span className='text-muted-foreground text-xs'>Required</span>\n        </div>\n        <Textarea\n          id={messageId}\n          required\n          value={message}\n          maxLength={MESSAGE_LIMIT}\n          aria-describedby={countId}\n          placeholder={PLACEHOLDER[kind]}\n          onChange={changeMessage}\n          className='min-h-24'\n        />\n        <p\n          id={countId}\n          className='text-muted-foreground self-end text-xs tabular-nums'\n        >\n          {`${message.length} of ${MESSAGE_LIMIT} characters`}\n        </p>\n      </div>\n      <AttachSlot\n        attachment={attachment}\n        onAttach={setAttachment}\n        onRemove={removeAttachment}\n      />\n      <ModalFooter>\n        <ModalCloseButton type='button' variant='ghost'>\n          Cancel\n        </ModalCloseButton>\n        <ActionButton\n          type='submit'\n          state={state}\n          labels={SEND_LABELS}\n          idleIcon={<SendIcon />}\n          disabled={isSendDisabled}\n        />\n      </ModalFooter>\n    </form>\n  );\n}\n\nfunction ThanksStep({\n  kind,\n  onSendMore,\n}: {\n  kind: FeedbackKind;\n  onSendMore: () => void;\n}) {\n  return (\n    <div className='flex flex-col gap-5'>\n      <ModalHeader className='items-start gap-3'>\n        <StatusOrb tone='success' />\n        <ModalTitle>{`Thanks, ${firstNameOf(CURRENT_USER)}`}</ModalTitle>\n        <ModalDescription>{THANKS_LINE[kind]}</ModalDescription>\n      </ModalHeader>\n      <ModalFooter>\n        <Button variant='ghost' onClick={onSendMore}>\n          Send more feedback\n        </Button>\n        <ModalCloseButton variant='outline'>Close</ModalCloseButton>\n      </ModalFooter>\n    </div>\n  );\n}\n\nfunction FeedbackContent() {\n  const [kind, setKind] = useState<FeedbackKind>('idea');\n  const [isSent, setIsSent] = useState(false);\n  const [formKey, setFormKey] = useState(0);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const stepVariants = stepVariantsOf(shouldReduceMotion);\n\n  function markSent() {\n    setIsSent(true);\n  }\n\n  function sendMore() {\n    setFormKey((previous) => previous + 1);\n    setIsSent(false);\n  }\n\n  return (\n    <div className='relative'>\n      <AnimatePresence initial={false} mode='popLayout'>\n        {!isSent && (\n          <motion.div\n            key={`form-${formKey}`}\n            variants={stepVariants}\n            initial='hidden'\n            animate='shown'\n            exit='hidden'\n          >\n            <FeedbackForm\n              kind={kind}\n              onKindChange={setKind}\n              onSent={markSent}\n            />\n          </motion.div>\n        )}\n        {isSent && (\n          <motion.div\n            key='thanks'\n            variants={stepVariants}\n            initial='hidden'\n            animate='shown'\n            exit='hidden'\n          >\n            <ThanksStep kind={kind} onSendMore={sendMore} />\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport default function Modal09() {\n  return (\n    <ModalPreview triggerLabel='Open send feedback' size='md'>\n      <FeedbackContent />\n    </ModalPreview>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/modal-09.tsx"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/action-button.tsx",
      "content": "'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { CheckIcon, LoaderCircleIcon } from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button, type ButtonProps } from '@/registry/ndeko/ui/button';\n\nimport { Swap } from './swap';\n\nexport type ActionState = 'idle' | 'working' | 'done';\n\nexport type ActionLabels = Record<ActionState, string>;\n\nconst WORKING_MS = 800;\n\nconst DONE_MS = 1600;\n\n/** The life of an action that takes a moment: working, then done for a beat, then ready again. The change is committed when the work ends. */\nexport function useTimedAction() {\n  const [state, setState] = useState<ActionState>('idle');\n  const commitRef = useRef<(() => void) | null>(null);\n\n  useEffect(() => {\n    if (state === 'working') {\n      const timeout = window.setTimeout(() => {\n        const commit = commitRef.current;\n        commitRef.current = null;\n        if (commit) {\n          commit();\n        }\n        setState('done');\n      }, WORKING_MS);\n      return () => window.clearTimeout(timeout);\n    }\n    if (state === 'done') {\n      const timeout = window.setTimeout(() => {\n        setState('idle');\n      }, DONE_MS);\n      return () => window.clearTimeout(timeout);\n    }\n  }, [state]);\n\n  function run(commit: () => void) {\n    if (state !== 'idle') {\n      return;\n    }\n    commitRef.current = commit;\n    setState('working');\n  }\n\n  const isBusy = state !== 'idle';\n\n  return { state, run, isBusy };\n}\n\nfunction iconOf(state: ActionState, idleIcon: React.ReactNode) {\n  if (state === 'working') {\n    return <LoaderCircleIcon className='animate-spin' />;\n  }\n  if (state === 'done') {\n    return <CheckIcon />;\n  }\n  return idleIcon;\n}\n\ntype ActionButtonProps = Omit<ButtonProps, 'children'> & {\n  state: ActionState;\n  labels: ActionLabels;\n  idleIcon?: React.ReactNode;\n};\n\n/** One button that becomes its next state: its icon swaps, its label crossfades and its width follows the new label. */\nexport function ActionButton({\n  state,\n  labels,\n  idleIcon,\n  ...props\n}: ActionButtonProps) {\n  const icon = iconOf(state, idleIcon);\n  const hasIcon = Boolean(icon);\n  const label = labels[state];\n  const isWorking = state === 'working';\n  const isDone = state === 'done';\n\n  return (\n    <>\n      <Button aria-busy={isWorking} {...props}>\n        {hasIcon && <Swap swapKey={state}>{icon}</Swap>}\n        <AnimatedSize axis='width' as='span'>\n          <Swap swapKey={label} kind='label'>\n            {label}\n          </Swap>\n        </AnimatedSize>\n      </Button>\n      <span className='sr-only' role='status'>\n        {isDone && labels.done}\n      </span>\n    </>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/action-button.tsx"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/choice-segments.tsx",
      "content": "'use client';\n\nimport type { Icon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { ToggleGroup, ToggleGroupItem } from '@/registry/ndeko/ui/toggle-group';\n\nexport type SegmentOption<Value extends string> = {\n  value: Value;\n  label: string;\n  icon?: Icon;\n};\n\nconst THUMB =\n  'bg-card shadow-[0_1px_2px_rgb(0_0_0/0.08)] hairline-ring ring-foreground/10 dark:bg-foreground/[0.09] dark:ring-foreground/15';\n\ntype ChoiceSegmentsProps<Value extends string> = {\n  value: Value;\n  options: SegmentOption<Value>[];\n  onValueChange: (value: Value) => void;\n  /** Names the group for screen readers when no visible label points at it. */\n  label: string;\n  className?: string;\n};\n\n/** One choice out of a few on a segmented track: a raised thumb travels to the picked segment. */\nexport function ChoiceSegments<Value extends string>({\n  value,\n  options,\n  onValueChange,\n  label,\n  className,\n}: ChoiceSegmentsProps<Value>) {\n  const pressedValues = [value];\n\n  function changeValue(nextValues: unknown[]) {\n    const [nextValue] = nextValues;\n    const option = options.find((candidate) => candidate.value === nextValue);\n    if (option) {\n      onValueChange(option.value);\n    }\n  }\n\n  return (\n    <ToggleGroup\n      aria-label={label}\n      value={pressedValues}\n      onValueChange={changeValue}\n      travel\n      size='sm'\n      indicatorClassName={THUMB}\n      className={cn('bg-foreground/[0.05] w-full rounded-lg p-0.5', className)}\n    >\n      {options.map((option) => {\n        const OptionGlyph = option.icon;\n\n        return (\n          <ToggleGroupItem\n            key={option.value}\n            value={option.value}\n            className='flex-1 rounded-md'\n          >\n            {OptionGlyph && <OptionGlyph />}\n            {option.label}\n          </ToggleGroupItem>\n        );\n      })}\n    </ToggleGroup>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/choice-segments.tsx"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/modal-frame.tsx",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport { SquareArrowOutUpRightIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button, type ButtonProps } from '@/registry/ndeko/ui/button';\nimport {\n  Dialog,\n  DialogClose,\n  DialogContent,\n  DialogDescription,\n  DialogTitle,\n  DialogTrigger,\n} from '@/registry/ndeko/ui/dialog';\n\n/** Where a modal's content is drawn: open in the page as a preview, or inside the real dialog. */\nexport type ModalHost = 'preview' | 'dialog';\n\nconst ModalHostContext = createContext<ModalHost>('preview');\n\nexport function useModalHost() {\n  return useContext(ModalHostContext);\n}\n\nexport type ModalSize = 'sm' | 'md' | 'lg' | 'xl';\n\nconst SIZE_CLASS: Record<ModalSize, string> = {\n  sm: 'max-w-sm',\n  md: 'max-w-md',\n  lg: 'max-w-lg',\n  xl: 'max-w-[44rem]',\n};\n\nconst TITLE = 'text-lg leading-tight font-semibold text-balance';\n\nconst DESCRIPTION = 'text-muted-foreground text-[13px]';\n\nconst BODY = 'flex flex-col gap-4';\n\ntype ModalTextProps = { className?: string; children: React.ReactNode };\n\nexport function ModalTitle({ className, children }: ModalTextProps) {\n  const host = useModalHost();\n  if (host === 'dialog') {\n    return <DialogTitle className={className}>{children}</DialogTitle>;\n  }\n  return <h2 className={cn(TITLE, className)}>{children}</h2>;\n}\n\nexport function ModalDescription({ className, children }: ModalTextProps) {\n  const host = useModalHost();\n  if (host === 'dialog') {\n    return (\n      <DialogDescription className={className}>{children}</DialogDescription>\n    );\n  }\n  return <p className={cn(DESCRIPTION, className)}>{children}</p>;\n}\n\n/** Leaves room for the dialog's close button, so the preview and the dialog lay out the same. */\nexport function ModalHeader({\n  className,\n  ...props\n}: React.ComponentProps<'div'>) {\n  return (\n    <div className={cn('flex flex-col gap-1.5 pr-8', className)} {...props} />\n  );\n}\n\nexport function ModalFooter({\n  className,\n  ...props\n}: React.ComponentProps<'div'>) {\n  return (\n    <div\n      className={cn(\n        'flex flex-col-reverse gap-2 sm:flex-row sm:items-center sm:justify-end',\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\n/** Closes the dialog. In the preview it stays a plain button that runs its own action, if any. */\nexport function ModalCloseButton({ children, ...props }: ButtonProps) {\n  const host = useModalHost();\n  if (host === 'dialog') {\n    return <DialogClose render={<Button {...props} />}>{children}</DialogClose>;\n  }\n  return <Button {...props}>{children}</Button>;\n}\n\ntype ModalPreviewProps = {\n  /** The content, drawn twice: open in the page, and inside the dialog the trigger opens. */\n  children: React.ReactNode;\n  triggerLabel: string;\n  size?: ModalSize;\n  className?: string;\n};\n\n/** Shows a modal open and whole on the page, with a small trigger that opens the same content in the real dialog. */\nexport function ModalPreview({\n  children,\n  triggerLabel,\n  size = 'md',\n  className,\n}: ModalPreviewProps) {\n  const sizeClass = SIZE_CLASS[size];\n\n  return (\n    <div className='flex w-full flex-col items-center gap-4'>\n      <ModalHostContext.Provider value='preview'>\n        <div\n          className={cn(\n            'surface-raised w-full rounded-2xl p-6 text-left',\n            sizeClass,\n            className\n          )}\n        >\n          <AnimatedSize contentClassName={BODY}>{children}</AnimatedSize>\n        </div>\n      </ModalHostContext.Provider>\n      <Dialog>\n        <DialogTrigger render={<Button variant='outline' size='sm' />}>\n          <SquareArrowOutUpRightIcon />\n          {triggerLabel}\n        </DialogTrigger>\n        <DialogContent className={cn(sizeClass, className)}>\n          <ModalHostContext.Provider value='dialog'>\n            {children}\n          </ModalHostContext.Provider>\n        </DialogContent>\n      </Dialog>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/modal-frame.tsx"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/motion.ts",
      "content": "import type { Transition, Variants } from 'motion/react';\n\nexport const SWAP_TRANSITION: Transition = {\n  duration: 0.15,\n  ease: [0.2, 0, 0, 1],\n};\n\nconst MORPH_SPRING: Transition = { type: 'spring', bounce: 0, duration: 0.3 };\n\nconst INSTANT: Transition = { duration: 0 };\n\nconst PRESENCE_IN: Transition = { duration: 0.2, ease: [0.23, 1, 0.32, 1] };\n\nconst PRESENCE_OUT: Transition = { duration: 0.14, ease: [0.23, 1, 0.32, 1] };\n\nconst ICON_SWAP: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst LABEL_SWAP: 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_SWAP: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nconst ROW_PRESENCE: Variants = {\n  hidden: {\n    height: 0,\n    opacity: 0,\n    overflow: 'hidden',\n    transition: PRESENCE_OUT,\n  },\n  shown: {\n    height: 'auto',\n    opacity: 1,\n    transition: PRESENCE_IN,\n    transitionEnd: { overflow: 'visible' },\n  },\n};\n\nconst ROW_FADE: Variants = {\n  hidden: { opacity: 0, transition: PRESENCE_OUT },\n  shown: { opacity: 1, transition: PRESENCE_IN },\n};\n\nconst CHIP_PRESENCE: Variants = {\n  hidden: { opacity: 0, scale: 0.9, transition: PRESENCE_OUT },\n  shown: { opacity: 1, scale: 1, transition: PRESENCE_IN },\n};\n\nexport type SwapKind = 'icon' | 'label';\n\nexport function swapVariantsOf(\n  shouldReduceMotion: boolean | null,\n  kind: SwapKind = 'icon'\n) {\n  if (shouldReduceMotion) {\n    return FADE_SWAP;\n  }\n  if (kind === 'label') {\n    return LABEL_SWAP;\n  }\n  return ICON_SWAP;\n}\n\n/** A row added to or removed from a list: its height opens or collapses, so the rows after it slide. */\nexport function rowVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return ROW_FADE;\n  }\n  return ROW_PRESENCE;\n}\n\nexport function chipVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return ROW_FADE;\n  }\n  return CHIP_PRESENCE;\n}\n\nexport function morphOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return MORPH_SPRING;\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/motion.ts"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/people.ts",
      "content": "export type Presence = 'tracking' | 'online' | 'away' | 'offline';\n\nexport type Person = {\n  id: string;\n  name: string;\n  email: string;\n  title: string;\n  presence: Presence;\n};\n\nexport const WORKSPACE_NAME = 'Lattice';\n\nexport const TEAM_NAME = 'Product';\n\nexport const PEOPLE: Person[] = [\n  {\n    id: 'amara',\n    name: 'Amara Okafor',\n    email: 'amara@lattice.example',\n    title: 'Product designer',\n    presence: 'tracking',\n  },\n  {\n    id: 'lucas',\n    name: 'Lucas Moreau',\n    email: 'lucas@lattice.example',\n    title: 'Engineering lead',\n    presence: 'online',\n  },\n  {\n    id: 'priya',\n    name: 'Priya Raman',\n    email: 'priya@lattice.example',\n    title: 'Frontend engineer',\n    presence: 'online',\n  },\n  {\n    id: 'mateo',\n    name: 'Mateo Silva',\n    email: 'mateo@lattice.example',\n    title: 'Backend engineer',\n    presence: 'away',\n  },\n  {\n    id: 'hana',\n    name: 'Hana Kobayashi',\n    email: 'hana@lattice.example',\n    title: 'Product manager',\n    presence: 'tracking',\n  },\n  {\n    id: 'jonas',\n    name: 'Jonas Weber',\n    email: 'jonas@lattice.example',\n    title: 'QA engineer',\n    presence: 'offline',\n  },\n  {\n    id: 'zola',\n    name: 'Zola Mbeki',\n    email: 'zola@lattice.example',\n    title: 'Content designer',\n    presence: 'online',\n  },\n  {\n    id: 'theo',\n    name: 'Théo Laurent',\n    email: 'theo@lattice.example',\n    title: 'Data analyst',\n    presence: 'away',\n  },\n  {\n    id: 'sana',\n    name: 'Sana Iqbal',\n    email: 'sana@lattice.example',\n    title: 'Support lead',\n    presence: 'offline',\n  },\n];\n\n/** The person a preview is seen by. */\nexport const CURRENT_USER: Person = PEOPLE[0];\n\nexport function personById(id: string) {\n  return PEOPLE.find((person) => person.id === id);\n}\n\nexport function firstNameOf(person: Person) {\n  const [firstName] = person.name.split(' ');\n  return firstName;\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/people.ts"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/swap.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport { SWAP_TRANSITION, swapVariantsOf, type SwapKind } from './motion';\n\ntype SwapProps = {\n  /** Changes when the content becomes another: the old one leaves while the new one arrives in its place. */\n  swapKey: string;\n  kind?: SwapKind;\n  className?: string;\n  /** Classes of the moving content, for example `min-w-0 max-w-full` so a long text can truncate inside. */\n  contentClassName?: string;\n  children: React.ReactNode;\n};\n\nexport function Swap({\n  swapKey,\n  kind = 'icon',\n  className,\n  contentClassName,\n  children,\n}: SwapProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion, kind);\n\n  return (\n    <span className={cn('relative inline-flex items-center', className)}>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={swapKey}\n          className={cn(\n            'inline-flex items-center gap-[inherit] whitespace-nowrap',\n            contentClassName\n          )}\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          transition={SWAP_TRANSITION}\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/swap.tsx"
    }
  ],
  "categories": [
    "components",
    "modal"
  ],
  "type": "registry:component"
}