{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-03",
  "title": "Invite with a link and a QR code",
  "description": "A link to copy with its expiry and approval, an illustrative QR code and a join code that change together when the link is reset",
  "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/input.json",
    "https://ui.ndekocode.dev/r/select.json",
    "https://ui.ndekocode.dev/r/switch.json",
    "https://ui.ndekocode.dev/r/theme.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-03.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId, useMemo, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { RefreshCwIcon } from '@/registry/ndeko/lib/icons';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n} from '@/registry/ndeko/ui/select';\nimport { Switch } from '@/registry/ndeko/ui/switch';\n\nimport { ActionButton, useTimedAction } from './_parts/action-button';\nimport { CopyButton } from './_parts/copy-button';\nimport {\n  ModalDescription,\n  ModalHeader,\n  ModalPreview,\n  ModalTitle,\n} from './_parts/modal-frame';\nimport { SWAP_TRANSITION, swapVariantsOf } from './_parts/motion';\nimport { TEAM_NAME } from './_parts/people';\nimport { Swap } from './_parts/swap';\n\ntype ExpiryValue = '1' | '7' | '30' | 'never';\n\ntype ExpiryOption = { value: ExpiryValue; label: string; line: string };\n\ntype InviteLink = { token: string; code: string[] };\n\nconst LINK_BASE = 'https://lattice.example/join/';\n\nconst LINKS: InviteLink[] = [\n  { token: '7q4m-92kd-h3xa', code: ['7Q4M', '92KD'] },\n  { token: 'p5zr-wb81-c6tn', code: ['P5ZR', 'WB81'] },\n  { token: 'k2vf-ye47-m9qd', code: ['K2VF', 'YE47'] },\n];\n\nconst EXPIRY_OPTIONS: ExpiryOption[] = [\n  { value: '1', label: '1 day', line: 'The link stops working tomorrow' },\n  { value: '7', label: '7 days', line: 'The link stops working on Nov 12' },\n  { value: '30', label: '30 days', line: 'The link stops working on Dec 5' },\n  { value: 'never', label: 'Never', line: 'The link works until you reset it' },\n];\n\nconst QR_MODULES = 25;\n\nconst QR_QUIET_ZONE = 2;\n\nconst FINDER_SIZE = 7;\n\nconst QR_VIEWBOX_SIZE = QR_MODULES + QR_QUIET_ZONE * 2;\n\nfunction hashOf(text: string) {\n  let hash = 2166136261;\n  for (const character of text) {\n    const code = character.charCodeAt(0);\n    hash ^= code;\n    hash = Math.imul(hash, 16777619);\n  }\n  return hash >>> 0;\n}\n\nfunction randomStreamOf(seed: number) {\n  let state = seed || 1;\n  return function next() {\n    state ^= state << 13;\n    state ^= state >>> 17;\n    state ^= state << 5;\n    const unsigned = state >>> 0;\n    return unsigned / 4294967296;\n  };\n}\n\nfunction finderOriginOf(row: number, column: number) {\n  const far = QR_MODULES - FINDER_SIZE;\n  const isTop = row < FINDER_SIZE + 1;\n  const isLeft = column < FINDER_SIZE + 1;\n  const isBottom = row >= far - 1;\n  const isRight = column >= far - 1;\n  const isTopLeft = isTop && isLeft;\n  const isTopRight = isTop && isRight;\n  const isBottomLeft = isBottom && isLeft;\n  if (isTopLeft) {\n    return { row: 0, column: 0 };\n  }\n  if (isTopRight) {\n    return { row: 0, column: far };\n  }\n  if (isBottomLeft) {\n    return { row: far, column: 0 };\n  }\n  return null;\n}\n\nfunction isFinderDark(localRow: number, localColumn: number) {\n  const isInside = localRow >= 0 && localRow < FINDER_SIZE;\n  const isInsideColumn = localColumn >= 0 && localColumn < FINDER_SIZE;\n  if (!isInside || !isInsideColumn) {\n    return false;\n  }\n  const isEdgeRow = localRow === 0 || localRow === FINDER_SIZE - 1;\n  const isEdgeColumn = localColumn === 0 || localColumn === FINDER_SIZE - 1;\n  const isCoreRow = localRow >= 2 && localRow <= 4;\n  const isCoreColumn = localColumn >= 2 && localColumn <= 4;\n  const isEdge = isEdgeRow || isEdgeColumn;\n  const isCore = isCoreRow && isCoreColumn;\n  return isEdge || isCore;\n}\n\n/**\n * Draws a code with the look of a QR code, derived from the link so it changes when the link does. It is not a\n * scannable QR encoding: plug a QR encoder in to make it one.\n */\nfunction qrPathOf(text: string) {\n  const random = randomStreamOf(hashOf(text));\n  const segments: string[] = [];\n  for (let row = 0; row < QR_MODULES; row += 1) {\n    for (let column = 0; column < QR_MODULES; column += 1) {\n      const origin = finderOriginOf(row, column);\n      let isDark = random() > 0.52;\n      if (origin) {\n        const localRow = row - origin.row;\n        const localColumn = column - origin.column;\n        isDark = isFinderDark(localRow, localColumn);\n      }\n      if (!isDark) {\n        continue;\n      }\n      const x = column + QR_QUIET_ZONE;\n      const y = row + QR_QUIET_ZONE;\n      segments.push(`M${x} ${y}h1v1h-1z`);\n    }\n  }\n  return segments.join('');\n}\n\nfunction isExpiryValue(value: unknown): value is ExpiryValue {\n  return EXPIRY_OPTIONS.some((option) => option.value === value);\n}\n\nfunction approvalLineOf(needsApproval: boolean) {\n  if (needsApproval) {\n    return 'They wait in Requests until a manager lets them in';\n  }\n  return `They join the ${TEAM_NAME} team as members right away`;\n}\n\nfunction QrCode({ url }: { url: string }) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion, 'label');\n  const path = useMemo(() => qrPathOf(url), [url]);\n  const viewBox = `0 0 ${QR_VIEWBOX_SIZE} ${QR_VIEWBOX_SIZE}`;\n\n  return (\n    <div className='bg-card hairline-ring ring-border relative size-40 overflow-hidden rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n      <AnimatePresence initial={false}>\n        <motion.svg\n          key={url}\n          viewBox={viewBox}\n          role='img'\n          aria-label='Illustrative code of the invite link'\n          shapeRendering='crispEdges'\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          transition={SWAP_TRANSITION}\n          className='text-foreground absolute inset-0 size-full'\n        >\n          <path d={path} fill='currentColor' />\n        </motion.svg>\n      </AnimatePresence>\n    </div>\n  );\n}\n\nfunction InviteLinkContent() {\n  const [linkIndex, setLinkIndex] = useState(0);\n  const [expiry, setExpiry] = useState<ExpiryValue>('7');\n  const [needsApproval, setNeedsApproval] = useState(false);\n  const resetAction = useTimedAction();\n  const linkFieldId = useId();\n  const expiryLabelId = useId();\n  const approvalId = useId();\n  const link = LINKS[linkIndex];\n  const url = `${LINK_BASE}${link.token}`;\n  const codeText = link.code.join('-');\n  const codeKey = link.code.join('');\n  const expiryOption = EXPIRY_OPTIONS.find((option) => option.value === expiry);\n  const expiryLine = expiryOption?.line ?? '';\n  const approvalLine = approvalLineOf(needsApproval);\n\n  function changeExpiry(value: unknown) {\n    if (isExpiryValue(value)) {\n      setExpiry(value);\n    }\n  }\n\n  function commitReset() {\n    setLinkIndex((previous) => {\n      const next = previous + 1;\n      return next % LINKS.length;\n    });\n  }\n\n  function resetLink() {\n    resetAction.run(commitReset);\n  }\n\n  return (\n    <div className='grid gap-6 sm:grid-cols-[minmax(0,1fr)_13rem]'>\n      <div className='flex min-w-0 flex-col gap-5'>\n        <ModalHeader>\n          <ModalTitle>Invite with a link</ModalTitle>\n          <ModalDescription>\n            {`Anyone with this link can join the ${TEAM_NAME} team`}\n          </ModalDescription>\n        </ModalHeader>\n        <div className='flex flex-col gap-1.5'>\n          <label htmlFor={linkFieldId} className='text-[13px] font-medium'>\n            Invite link\n          </label>\n          <div className='flex items-center gap-2'>\n            <Input\n              id={linkFieldId}\n              readOnly\n              value={url}\n              className='text-muted-foreground min-w-0 flex-1 truncate'\n            />\n            <CopyButton\n              text={url}\n              label='Copy'\n              size='default'\n              announcement='Invite link copied'\n            />\n          </div>\n        </div>\n        <div className='flex flex-col gap-1.5'>\n          <div className='flex items-center justify-between gap-3'>\n            <span id={expiryLabelId} className='text-[13px] font-medium'>\n              Link expires after\n            </span>\n            <Select\n              items={EXPIRY_OPTIONS}\n              value={expiry}\n              onValueChange={changeExpiry}\n            >\n              <SelectTrigger aria-labelledby={expiryLabelId} className='w-32'>\n                <SelectValue />\n              </SelectTrigger>\n              <SelectContent align='end'>\n                {EXPIRY_OPTIONS.map((option) => (\n                  <SelectItem key={option.value} value={option.value}>\n                    {option.label}\n                  </SelectItem>\n                ))}\n              </SelectContent>\n            </Select>\n          </div>\n          <Swap\n            swapKey={expiryLine}\n            kind='label'\n            className='text-muted-foreground flex text-xs'\n          >\n            {expiryLine}\n          </Swap>\n        </div>\n        <div className='flex items-start justify-between gap-3'>\n          <div className='flex min-w-0 flex-col gap-0.5'>\n            <label htmlFor={approvalId} className='text-[13px] font-medium'>\n              Approve people who join\n            </label>\n            <Swap\n              swapKey={approvalLine}\n              kind='label'\n              className='text-muted-foreground flex min-w-0 text-xs'\n              contentClassName='max-w-full min-w-0 whitespace-normal'\n            >\n              {approvalLine}\n            </Swap>\n          </div>\n          <Switch\n            id={approvalId}\n            checked={needsApproval}\n            onCheckedChange={setNeedsApproval}\n          />\n        </div>\n        <div className='flex items-center gap-2'>\n          <ActionButton\n            variant='outline'\n            size='sm'\n            state={resetAction.state}\n            onClick={resetLink}\n            idleIcon={<RefreshCwIcon />}\n            labels={{\n              idle: 'Reset link',\n              working: 'Resetting',\n              done: 'New link ready',\n            }}\n          />\n          <p className='text-muted-foreground text-xs'>\n            The old link and code stop working\n          </p>\n        </div>\n      </div>\n      <div className='bg-foreground/[0.03] flex flex-col items-center gap-4 rounded-xl px-4 py-5 text-center'>\n        <div className='flex flex-col gap-0.5'>\n          <p className='text-[13px] font-medium'>Scan to join</p>\n          <p className='text-muted-foreground text-xs'>\n            Opens the invite on a phone\n          </p>\n        </div>\n        <QrCode url={url} />\n        <p className='text-muted-foreground text-xs'>or enter the code</p>\n        <div className='flex items-center gap-1.5'>\n          <Swap swapKey={codeKey} kind='label' className='gap-1'>\n            {link.code.map((part) => (\n              <span\n                key={part}\n                className='keycap-3d rounded-md px-2 py-1 font-mono text-[13px] font-medium tabular-nums'\n              >\n                {part}\n              </span>\n            ))}\n          </Swap>\n          <CopyButton\n            text={codeText}\n            variant='ghost'\n            size='icon-sm'\n            aria-label='Copy the invite code'\n            announcement='Invite code copied'\n            className='text-muted-foreground'\n          />\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default function Modal03() {\n  return (\n    <ModalPreview triggerLabel='Open the invite link dialog' size='xl'>\n      <InviteLinkContent />\n    </ModalPreview>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/modal-03.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/copy-button.tsx",
      "content": "'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport { CheckIcon, CopyIcon, LinkIcon } 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\nconst COPIED_RESET_MS = 1600;\n\n/** Copies a text and says so for a moment. */\nexport function useCopy(text: string) {\n  const [isCopied, setIsCopied] = useState(false);\n\n  useEffect(() => {\n    if (!isCopied) {\n      return;\n    }\n    const timeout = window.setTimeout(() => {\n      setIsCopied(false);\n    }, COPIED_RESET_MS);\n    return () => window.clearTimeout(timeout);\n  }, [isCopied]);\n\n  async function copy() {\n    try {\n      await navigator.clipboard.writeText(text);\n      setIsCopied(true);\n    } catch {\n      setIsCopied(false);\n    }\n  }\n\n  return { isCopied, copy };\n}\n\ntype CopyGlyph = 'copy' | 'link';\n\nfunction glyphOf(isCopied: boolean, glyph: CopyGlyph) {\n  if (isCopied) {\n    return <CheckIcon className='text-success-foreground' />;\n  }\n  if (glyph === 'link') {\n    return <LinkIcon />;\n  }\n  return <CopyIcon />;\n}\n\nfunction labelOf(isCopied: boolean, label: string, copiedLabel: string) {\n  if (isCopied) {\n    return copiedLabel;\n  }\n  return label;\n}\n\ntype CopyButtonProps = Omit<ButtonProps, 'children' | 'onClick'> & {\n  text: string;\n  /** Visible label. Leave it out for an icon button, and give `aria-label` instead. */\n  label?: string;\n  copiedLabel?: string;\n  /** Announced once the text is on the clipboard. */\n  announcement: string;\n  glyph?: CopyGlyph;\n};\n\n/** A copy action whose icon becomes a check and whose label becomes Copied, then returns. */\nexport function CopyButton({\n  text,\n  label,\n  copiedLabel = 'Copied',\n  announcement,\n  glyph = 'copy',\n  variant = 'outline',\n  size = 'sm',\n  ...props\n}: CopyButtonProps) {\n  const { isCopied, copy } = useCopy(text);\n  const icon = glyphOf(isCopied, glyph);\n  const iconKey = String(isCopied);\n  const hasLabel = Boolean(label);\n  const shownLabel = labelOf(isCopied, label ?? '', copiedLabel);\n\n  return (\n    <>\n      <Button variant={variant} size={size} onClick={copy} {...props}>\n        <Swap swapKey={iconKey}>{icon}</Swap>\n        {hasLabel && (\n          <AnimatedSize axis='width' as='span'>\n            <Swap swapKey={shownLabel} kind='label'>\n              {shownLabel}\n            </Swap>\n          </AnimatedSize>\n        )}\n      </Button>\n      <span className='sr-only' role='status'>\n        {isCopied && announcement}\n      </span>\n    </>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/copy-button.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"
}