{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-08",
  "title": "Add members from the directory",
  "description": "Workspace people outside the team, picked with checkboxes into an avatar stack and added in one go",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/checkbox.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/motion-number.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-08.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  CircleCheckIcon,\n  SearchIcon,\n  UserRoundPlusIcon,\n  XIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Checkbox } from '@/registry/ndeko/ui/checkbox';\nimport { Input } from '@/registry/ndeko/ui/input';\n\nimport {\n  ActionButton,\n  useTimedAction,\n  type ActionLabels,\n} from './_parts/action-button';\nimport {\n  ModalCloseButton,\n  ModalDescription,\n  ModalFooter,\n  ModalHeader,\n  ModalPreview,\n  ModalTitle,\n} from './_parts/modal-frame';\nimport { chipVariantsOf, rowVariantsOf } from './_parts/motion';\nimport {\n  PEOPLE,\n  TEAM_NAME,\n  WORKSPACE_NAME,\n  firstNameOf,\n  type Person,\n} from './_parts/people';\nimport { PersonAvatar } from './_parts/person-avatar';\nimport { Swap } from './_parts/swap';\n\nconst TEAM_SIZE = 5;\n\nconst STACK_LIMIT = 4;\n\nconst OUTSIDE_THE_TEAM: Person[] = [\n  {\n    id: 'nia',\n    name: 'Nia Adeyemi',\n    email: 'nia@lattice.example',\n    title: 'Sales engineer',\n    presence: 'online',\n  },\n  {\n    id: 'ravi',\n    name: 'Ravi Menon',\n    email: 'ravi@lattice.example',\n    title: 'Security engineer',\n    presence: 'tracking',\n  },\n  {\n    id: 'elif',\n    name: 'Elif Demir',\n    email: 'elif@lattice.example',\n    title: 'Finance lead',\n    presence: 'away',\n  },\n];\n\nconst DIRECTORY: Person[] = [...PEOPLE.slice(TEAM_SIZE), ...OUTSIDE_THE_TEAM];\n\nconst FIRST_PICKS = ['zola', 'theo'];\n\nfunction matchesQuery(person: Person, query: string) {\n  const searchable = `${person.name} ${person.title}`;\n  return searchable.toLowerCase().includes(query);\n}\n\nfunction addLabelOf(count: number) {\n  if (count === 0) {\n    return 'Add members';\n  }\n  if (count === 1) {\n    return 'Add 1 member';\n  }\n  return `Add ${count} members`;\n}\n\nfunction labelsOf(count: number): ActionLabels {\n  return { idle: addLabelOf(count), working: 'Adding', done: 'Added' };\n}\n\nfunction namesSentenceOf(people: Person[]) {\n  const names = people.map(firstNameOf);\n  if (names.length === 1) {\n    return names[0];\n  }\n  const last = names.at(-1);\n  const others = names.slice(0, -1).join(', ');\n  return `${others} and ${last}`;\n}\n\nfunction availabilityOf(count: number) {\n  if (count === 0) {\n    return `Everyone in ${WORKSPACE_NAME} is in ${TEAM_NAME}`;\n  }\n  if (count === 1) {\n    return `1 person in ${WORKSPACE_NAME} is not in ${TEAM_NAME}`;\n  }\n  return `${count} people in ${WORKSPACE_NAME} are not in ${TEAM_NAME}`;\n}\n\nfunction noteOf(joined: Person[], availableCount: number) {\n  if (joined.length === 0) {\n    return availabilityOf(availableCount);\n  }\n  return `${namesSentenceOf(joined)} joined ${TEAM_NAME}`;\n}\n\nfunction PickedStack({\n  picked,\n  onClear,\n}: {\n  picked: Person[];\n  onClear: () => void;\n}) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = chipVariantsOf(shouldReduceMotion);\n  const allowsLayout = !shouldReduceMotion;\n  const shown = picked.slice(0, STACK_LIMIT);\n  const hiddenCount = picked.length - shown.length;\n  const hasHidden = hiddenCount > 0;\n  const hasPicked = picked.length > 0;\n  const lineKey = String(hasPicked);\n\n  return (\n    <div className='flex h-8 items-center gap-2.5'>\n      <div className='relative flex items-center -space-x-1.5'>\n        <AnimatePresence initial={false} mode='popLayout'>\n          {shown.map((person) => (\n            <motion.span\n              key={person.id}\n              layout={allowsLayout}\n              variants={variants}\n              initial='hidden'\n              animate='shown'\n              exit='hidden'\n              className='ring-popover flex rounded-full ring-2'\n            >\n              <PersonAvatar person={person} size='sm' />\n            </motion.span>\n          ))}\n        </AnimatePresence>\n        {hasHidden && (\n          <span className='keycap-3d ring-popover text-muted-foreground flex size-6 items-center justify-center rounded-full text-[10px] font-medium ring-2'>\n            +\n            <MotionNumber value={hiddenCount} />\n          </span>\n        )}\n      </div>\n      <Swap swapKey={lineKey} kind='label' className='text-xs'>\n        {hasPicked && (\n          <span className='text-foreground flex items-center gap-1 font-medium'>\n            <MotionNumber value={picked.length} />\n            picked\n          </span>\n        )}\n        {!hasPicked && (\n          <span className='text-muted-foreground'>Pick the people to add</span>\n        )}\n      </Swap>\n      {hasPicked && (\n        <Button\n          variant='ghost'\n          size='sm'\n          onClick={onClear}\n          className='text-muted-foreground ml-auto'\n        >\n          Clear\n        </Button>\n      )}\n    </div>\n  );\n}\n\nfunction DirectoryRow({\n  person,\n  isPicked,\n  isHidden,\n  isDisabled,\n  onToggle,\n}: {\n  person: Person;\n  isPicked: boolean;\n  isHidden: boolean;\n  isDisabled: boolean;\n  onToggle: (personId: string) => void;\n}) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = rowVariantsOf(shouldReduceMotion);\n\n  function toggle() {\n    onToggle(person.id);\n  }\n\n  return (\n    <motion.li\n      hidden={isHidden}\n      variants={variants}\n      initial='hidden'\n      animate='shown'\n      exit='hidden'\n    >\n      <label className='hover:bg-foreground/[0.03] has-data-checked:bg-primary/[0.05] flex cursor-pointer items-center gap-3 rounded-lg px-2 py-2 transition-colors duration-150'>\n        <Checkbox\n          checked={isPicked}\n          disabled={isDisabled}\n          onCheckedChange={toggle}\n        />\n        <PersonAvatar person={person} presence={person.presence} />\n        <span className='flex min-w-0 flex-1 flex-col'>\n          <span className='truncate text-[13px] font-medium'>\n            {person.name}\n          </span>\n          <span className='text-muted-foreground truncate text-xs'>\n            {person.title}\n          </span>\n        </span>\n      </label>\n    </motion.li>\n  );\n}\n\nfunction NoMatch({ query, onClear }: { query: string; onClear: () => void }) {\n  return (\n    <div className='flex flex-col items-center gap-3 py-8 text-center'>\n      <div className='flex flex-col gap-1'>\n        <p className='text-sm font-medium'>\n          {`No one in ${WORKSPACE_NAME} matches “${query}”`}\n        </p>\n        <p className='text-muted-foreground text-[13px]'>\n          Search by first name, last name or job title\n        </p>\n      </div>\n      <Button variant='outline' size='sm' onClick={onClear}>\n        <XIcon />\n        Clear search\n      </Button>\n    </div>\n  );\n}\n\nfunction EveryoneIn() {\n  return (\n    <div className='flex flex-col items-center gap-1 py-8 text-center'>\n      <p className='text-sm font-medium'>\n        {`Everyone in ${WORKSPACE_NAME} is in ${TEAM_NAME}`}\n      </p>\n      <p className='text-muted-foreground text-[13px]'>\n        Invite people by e-mail to grow the team\n      </p>\n    </div>\n  );\n}\n\nfunction AddMembersContent() {\n  const [directory, setDirectory] = useState<Person[]>(DIRECTORY);\n  const [pickedIds, setPickedIds] = useState<string[]>(FIRST_PICKS);\n  const [joined, setJoined] = useState<Person[]>([]);\n  const [query, setQuery] = useState('');\n  const { state, run, isBusy } = useTimedAction();\n  const normalizedQuery = query.trim().toLowerCase();\n  const hasQuery = normalizedQuery.length > 0;\n  const matchCount = directory.filter((person) =>\n    matchesQuery(person, normalizedQuery)\n  ).length;\n  const hasNoMatch = hasQuery && matchCount === 0;\n  const isDirectoryEmpty = directory.length === 0;\n  const picked = directory.filter((person) => pickedIds.includes(person.id));\n  const hasPicked = picked.length > 0;\n  const isIdle = state === 'idle';\n  const isAddDisabled = isIdle && !hasPicked;\n  const hasJoined = joined.length > 0;\n  const note = noteOf(joined, directory.length);\n\n  function changeQuery(event: React.ChangeEvent<HTMLInputElement>) {\n    setQuery(event.target.value);\n  }\n\n  function clearQuery() {\n    setQuery('');\n  }\n\n  function clearPicks() {\n    setPickedIds([]);\n  }\n\n  function togglePerson(personId: string) {\n    setPickedIds((previous) => {\n      if (previous.includes(personId)) {\n        return previous.filter((id) => id !== personId);\n      }\n      return [...previous, personId];\n    });\n  }\n\n  function addPicked() {\n    run(() => {\n      setDirectory((previous) =>\n        previous.filter((person) => !pickedIds.includes(person.id))\n      );\n      setJoined(picked);\n      setPickedIds([]);\n    });\n  }\n\n  return (\n    <>\n      <ModalHeader>\n        <ModalTitle>{`Add members to ${TEAM_NAME}`}</ModalTitle>\n        <ModalDescription>\n          {`People already in ${WORKSPACE_NAME} join the team at once, without an e-mail`}\n        </ModalDescription>\n      </ModalHeader>\n      <div className='relative'>\n        <SearchIcon className='text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2' />\n        <Input\n          type='search'\n          value={query}\n          placeholder='Search by name or job title'\n          aria-label={`Search people in ${WORKSPACE_NAME}`}\n          onChange={changeQuery}\n          className='pl-8'\n        />\n      </div>\n      <PickedStack picked={picked} onClear={clearPicks} />\n      {hasNoMatch && <NoMatch query={query.trim()} onClear={clearQuery} />}\n      {isDirectoryEmpty && <EveryoneIn />}\n      <ul\n        aria-label={`People in ${WORKSPACE_NAME} outside ${TEAM_NAME}`}\n        className='-mx-2 -mt-2 flex max-h-64 flex-col overflow-y-auto'\n      >\n        <AnimatePresence initial={false}>\n          {directory.map((person) => {\n            const isPicked = pickedIds.includes(person.id);\n            const isMatch = matchesQuery(person, normalizedQuery);\n\n            return (\n              <DirectoryRow\n                key={person.id}\n                person={person}\n                isPicked={isPicked}\n                isHidden={!isMatch}\n                isDisabled={isBusy}\n                onToggle={togglePerson}\n              />\n            );\n          })}\n        </AnimatePresence>\n      </ul>\n      <ModalFooter>\n        <p className='text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs sm:mr-auto'>\n          {hasJoined && (\n            <CircleCheckIcon className='text-success-foreground size-3.5 shrink-0' />\n          )}\n          <Swap swapKey={note} kind='label' className='min-w-0'>\n            <span className='truncate'>{note}</span>\n          </Swap>\n        </p>\n        <ModalCloseButton variant='ghost'>Done</ModalCloseButton>\n        <ActionButton\n          state={state}\n          labels={labelsOf(picked.length)}\n          idleIcon={<UserRoundPlusIcon />}\n          disabled={isAddDisabled}\n          onClick={addPicked}\n        />\n      </ModalFooter>\n    </>\n  );\n}\n\nexport default function Modal08() {\n  return (\n    <ModalPreview triggerLabel='Open add members' size='md'>\n      <AddMembersContent />\n    </ModalPreview>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/modal-08.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/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/person-avatar.tsx",
      "content": "import {\n  CheckIcon,\n  ClockIcon,\n  type Icon,\n  MailIcon,\n  MinusIcon,\n  MoonIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\n\nimport type { Person, Presence } from './people';\n\ntype PresenceMeta = { label: string; color: string; icon: Icon };\n\nexport const PRESENCE_META: Record<Presence, PresenceMeta> = {\n  tracking: {\n    label: 'Tracking time',\n    color: 'var(--primary)',\n    icon: ClockIcon,\n  },\n  online: { label: 'Online', color: 'var(--success)', icon: CheckIcon },\n  away: { label: 'Away', color: 'var(--warning)', icon: MoonIcon },\n  offline: {\n    label: 'Offline',\n    color: 'var(--muted-foreground)',\n    icon: MinusIcon,\n  },\n};\n\ntype AvatarSize = 'sm' | 'md' | 'lg';\n\nconst AVATAR_SIZE: Record<AvatarSize, string> = {\n  sm: 'size-6',\n  md: 'size-8',\n  lg: 'size-10',\n};\n\nconst BADGE_SIZE: Record<AvatarSize, string> = {\n  sm: 'size-3 [&_svg]:size-2',\n  md: 'size-3.5 [&_svg]:size-2',\n  lg: 'size-4 [&_svg]:size-2.5',\n};\n\ntype PersonAvatarProps = {\n  person: Pick<Person, 'name'>;\n  size?: AvatarSize;\n  /** Drawn as a small glyph on the avatar; its label is read by screen readers. */\n  presence?: Presence;\n  className?: string;\n};\n\nexport function PersonAvatar({\n  person,\n  size = 'md',\n  presence,\n  className,\n}: PersonAvatarProps) {\n  return (\n    <span className={cn('relative inline-flex shrink-0', className)}>\n      <Avatar className={AVATAR_SIZE[size]} seed={person.name} />\n      {presence && <PresenceBadge presence={presence} size={size} />}\n    </span>\n  );\n}\n\nfunction PresenceBadge({\n  presence,\n  size,\n}: {\n  presence: Presence;\n  size: AvatarSize;\n}) {\n  const meta = PRESENCE_META[presence];\n  const PresenceGlyph = meta.icon;\n  const badgeStyle = { '--chip': meta.color } as React.CSSProperties;\n\n  return (\n    <>\n      <span className='bg-popover absolute -right-0.5 -bottom-0.5 flex rounded-full p-px'>\n        <span\n          style={badgeStyle}\n          className={cn(\n            'chip-3d flex items-center justify-center rounded-full',\n            BADGE_SIZE[size]\n          )}\n        >\n          <PresenceGlyph strokeWidth={2.75} />\n        </span>\n      </span>\n      <span className='sr-only'>{meta.label}</span>\n    </>\n  );\n}\n\ntype PendingAvatarProps = {\n  size?: AvatarSize;\n  className?: string;\n};\n\n/** Someone invited who has not joined yet: an empty dashed slot with an envelope and a clock. */\nexport function PendingAvatar({ size = 'md', className }: PendingAvatarProps) {\n  const clockStyle = { '--chip': 'var(--warning)' } as React.CSSProperties;\n\n  return (\n    <span\n      aria-hidden='true'\n      className={cn('relative inline-flex shrink-0', className)}\n    >\n      <span\n        className={cn(\n          'hairline-border border-foreground/25 text-muted-foreground flex items-center justify-center rounded-full border-dashed',\n          AVATAR_SIZE[size]\n        )}\n      >\n        <MailIcon className='size-[45%]' />\n      </span>\n      <span className='bg-popover absolute -right-0.5 -bottom-0.5 flex rounded-full p-px'>\n        <span\n          style={clockStyle}\n          className={cn(\n            'chip-3d flex items-center justify-center rounded-full',\n            BADGE_SIZE[size]\n          )}\n        >\n          <ClockIcon strokeWidth={2.75} />\n        </span>\n      </span>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/person-avatar.tsx"
    },
    {
      "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"
}