{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-04",
  "title": "Invite into a project",
  "description": "Teammates searched and added to the project with an access level, each one changeable or removable in the list",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/combobox.json",
    "https://ui.ndekocode.dev/r/dialog.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/kbd.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/select.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-04.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId, useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { LayersIcon, SearchIcon, XIcon } from '@/registry/ndeko/lib/icons';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Combobox,\n  ComboboxContent,\n  ComboboxEmpty,\n  ComboboxInput,\n  ComboboxInputGroup,\n  ComboboxItem,\n  ComboboxList,\n} from '@/registry/ndeko/ui/combobox';\nimport { Kbd } from '@/registry/ndeko/ui/kbd';\n\nimport { CopyButton } from './_parts/copy-button';\nimport {\n  ModalCloseButton,\n  ModalDescription,\n  ModalFooter,\n  ModalHeader,\n  ModalPreview,\n  ModalTitle,\n} from './_parts/modal-frame';\nimport { rowVariantsOf } from './_parts/motion';\nimport { CURRENT_USER, PEOPLE, type Person } from './_parts/people';\nimport { PersonAvatar } from './_parts/person-avatar';\nimport {\n  ACCESS_LEVELS,\n  RoleSelect,\n  type AccessLevel,\n} from './_parts/role-select';\n\ntype ProjectMember = { personId: string; access: AccessLevel };\n\ntype Candidate = { value: string; label: string; person: Person };\n\nconst PROJECT_NAME = 'Atlas redesign';\n\nconst PROJECT_LINK = 'https://lattice.example/projects/atlas-redesign';\n\nconst INITIAL_MEMBERS: ProjectMember[] = [\n  { personId: 'lucas', access: 'manage' },\n  { personId: 'priya', access: 'edit' },\n  { personId: 'zola', access: 'view' },\n];\n\nfunction personOf(personId: string) {\n  return PEOPLE.find((person) => person.id === personId);\n}\n\nfunction candidateOf(person: Person): Candidate {\n  return { value: person.id, label: person.name, person };\n}\n\nfunction isCandidate(value: unknown): value is Candidate {\n  const isObject = typeof value === 'object' && value !== null;\n  return isObject && 'person' in value;\n}\n\nfunction MemberRow({\n  member,\n  onAccessChange,\n  onRemove,\n}: {\n  member: ProjectMember;\n  onAccessChange: (personId: string, access: AccessLevel) => void;\n  onRemove: (personId: string) => void;\n}) {\n  const person = personOf(member.personId);\n  if (!person) {\n    return null;\n  }\n\n  function changeAccess(access: AccessLevel) {\n    onAccessChange(member.personId, access);\n  }\n\n  function remove() {\n    onRemove(member.personId);\n  }\n\n  return (\n    <div className='flex min-h-13 items-center gap-3 py-2 pr-1.5 pl-3'>\n      <PersonAvatar person={person} presence={person.presence} />\n      <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n        <p className='truncate text-[13px] leading-tight font-medium'>\n          {person.name}\n        </p>\n        <p className='text-muted-foreground truncate text-xs leading-tight'>\n          {person.email}\n        </p>\n      </div>\n      <RoleSelect\n        label={`Access of ${person.name}`}\n        value={member.access}\n        options={ACCESS_LEVELS}\n        onValueChange={changeAccess}\n      />\n      <Button\n        variant='ghost'\n        size='icon-sm'\n        aria-label={`Remove ${person.name} from the project`}\n        onClick={remove}\n        className='text-muted-foreground'\n      >\n        <XIcon />\n      </Button>\n    </div>\n  );\n}\n\nfunction OwnerRow() {\n  return (\n    <div className='flex min-h-13 items-center gap-3 py-2 pr-3 pl-3'>\n      <PersonAvatar person={CURRENT_USER} presence={CURRENT_USER.presence} />\n      <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n        <p className='flex items-center gap-1.5 text-[13px] leading-tight font-medium'>\n          <span className='truncate'>{CURRENT_USER.name}</span>\n          <Badge variant='secondary' className='text-muted-foreground'>\n            You\n          </Badge>\n        </p>\n        <p className='text-muted-foreground truncate text-xs leading-tight'>\n          {CURRENT_USER.email}\n        </p>\n      </div>\n      <span className='text-muted-foreground text-xs'>Owner</span>\n    </div>\n  );\n}\n\nfunction InviteToProject() {\n  const [members, setMembers] = useState<ProjectMember[]>(INITIAL_MEMBERS);\n  const [query, setQuery] = useState('');\n  const [defaultAccess, setDefaultAccess] = useState<AccessLevel>('edit');\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowVariants = rowVariantsOf(shouldReduceMotion);\n  const headingId = useId();\n  const memberIds = members.map((member) => member.personId);\n  const outsiders = PEOPLE.filter((person) => {\n    const isOwner = person.id === CURRENT_USER.id;\n    const isMember = memberIds.includes(person.id);\n    return !isOwner && !isMember;\n  });\n  const candidates = outsiders.map(candidateOf);\n  const memberCount = members.length + 1;\n  const trimmedQuery = query.trim();\n\n  function changeQuery(nextQuery: string) {\n    setQuery(nextQuery);\n  }\n\n  function addCandidate(value: unknown) {\n    if (!isCandidate(value)) {\n      return;\n    }\n    const added: ProjectMember = {\n      personId: value.person.id,\n      access: defaultAccess,\n    };\n    setMembers((previous) => [added, ...previous]);\n    setQuery('');\n  }\n\n  function changeAccess(personId: string, access: AccessLevel) {\n    setMembers((previous) =>\n      previous.map((member) => {\n        if (member.personId !== personId) {\n          return member;\n        }\n        return { ...member, access };\n      })\n    );\n  }\n\n  function removeMember(personId: string) {\n    setMembers((previous) =>\n      previous.filter((member) => member.personId !== personId)\n    );\n  }\n\n  return (\n    <>\n      <div className='flex items-start gap-3 pr-8'>\n        <span className='gem-plate flex size-9 shrink-0 items-center justify-center rounded-lg [--gem:var(--info)]'>\n          <LayersIcon className='size-4' strokeWidth={2.25} />\n        </span>\n        <ModalHeader className='pr-0'>\n          <ModalTitle>{`Invite to ${PROJECT_NAME}`}</ModalTitle>\n          <ModalDescription>\n            Teammates get the tasks, files and discussions of the project\n          </ModalDescription>\n        </ModalHeader>\n      </div>\n      <Combobox\n        items={candidates}\n        value={null}\n        onValueChange={addCandidate}\n        inputValue={query}\n        onInputValueChange={changeQuery}\n      >\n        <ComboboxInputGroup className='min-h-9 flex-nowrap gap-1.5 py-1 pr-1 pl-2.5'>\n          <SearchIcon className='text-muted-foreground size-4 shrink-0' />\n          <ComboboxInput\n            aria-label='Add teammates by name or e-mail'\n            placeholder='Add teammates by name or e-mail'\n            className='h-7'\n          />\n          <RoleSelect\n            label='Access of the people you add'\n            value={defaultAccess}\n            options={ACCESS_LEVELS}\n            onValueChange={setDefaultAccess}\n          />\n        </ComboboxInputGroup>\n        <ComboboxContent className='p-1'>\n          <ComboboxEmpty>\n            {`Nobody else in Lattice matches “${trimmedQuery}”`}\n          </ComboboxEmpty>\n          <ComboboxList className='max-h-64 overflow-y-auto empty:hidden'>\n            {(candidate: Candidate) => (\n              <ComboboxItem\n                key={candidate.value}\n                value={candidate}\n                className='h-auto py-1.5'\n              >\n                <PersonAvatar\n                  person={candidate.person}\n                  size='sm'\n                  presence={candidate.person.presence}\n                />\n                <span className='flex min-w-0 flex-col'>\n                  <span className='truncate text-[13px]'>\n                    {candidate.person.name}\n                  </span>\n                  <span className='text-muted-foreground truncate text-xs'>\n                    {candidate.person.email}\n                  </span>\n                </span>\n              </ComboboxItem>\n            )}\n          </ComboboxList>\n        </ComboboxContent>\n      </Combobox>\n      <section aria-labelledby={headingId} className='flex flex-col gap-2'>\n        <div className='flex items-center gap-2'>\n          <h3\n            id={headingId}\n            className='text-muted-foreground text-xs font-medium'\n          >\n            In this project\n          </h3>\n          <Kbd>\n            <MotionNumber value={memberCount} />\n          </Kbd>\n        </div>\n        <ul className='bg-card hairline-ring ring-border flex flex-col overflow-hidden rounded-xl py-1 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n          <li>\n            <OwnerRow />\n          </li>\n          <AnimatePresence initial={false}>\n            {members.map((member) => (\n              <motion.li\n                key={member.personId}\n                variants={rowVariants}\n                initial='hidden'\n                animate='shown'\n                exit='hidden'\n              >\n                <MemberRow\n                  member={member}\n                  onAccessChange={changeAccess}\n                  onRemove={removeMember}\n                />\n              </motion.li>\n            ))}\n          </AnimatePresence>\n        </ul>\n      </section>\n      <ModalFooter className='sm:justify-between'>\n        <CopyButton\n          text={PROJECT_LINK}\n          label='Copy project link'\n          glyph='link'\n          variant='ghost'\n          announcement='Project link copied'\n        />\n        <ModalCloseButton>Done</ModalCloseButton>\n      </ModalFooter>\n    </>\n  );\n}\n\nexport default function Modal04() {\n  return (\n    <ModalPreview triggerLabel='Open the project invite dialog' size='lg'>\n      <InviteToProject />\n    </ModalPreview>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/modal-04.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/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/role-select.tsx",
      "content": "'use client';\n\nimport {\n  EyeIcon,\n  PencilIcon,\n  ShieldCheckIcon,\n  UserIcon,\n  UserPenIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n} from '@/registry/ndeko/ui/select';\n\nexport type RoleOption<Value extends string> = {\n  value: Value;\n  label: string;\n  line: string;\n  color: string;\n  icon: Icon;\n};\n\nexport type TeamRole = 'member' | 'manager' | 'admin';\n\nexport const TEAM_ROLES: RoleOption<TeamRole>[] = [\n  {\n    value: 'member',\n    label: 'Member',\n    line: 'Tracks time and works on tasks',\n    color: 'var(--info)',\n    icon: UserIcon,\n  },\n  {\n    value: 'manager',\n    label: 'Manager',\n    line: 'Manages the team, its members and its tasks',\n    color: 'var(--success)',\n    icon: UserPenIcon,\n  },\n  {\n    value: 'admin',\n    label: 'Admin',\n    line: 'Manages the workspace and its settings',\n    color: 'var(--warning)',\n    icon: ShieldCheckIcon,\n  },\n];\n\nexport type AccessLevel = 'view' | 'edit' | 'manage';\n\nexport const ACCESS_LEVELS: RoleOption<AccessLevel>[] = [\n  {\n    value: 'view',\n    label: 'Can view',\n    line: 'Reads tasks, files and comments',\n    color: 'var(--muted-foreground)',\n    icon: EyeIcon,\n  },\n  {\n    value: 'edit',\n    label: 'Can edit',\n    line: 'Also creates and changes tasks',\n    color: 'var(--info)',\n    icon: PencilIcon,\n  },\n  {\n    value: 'manage',\n    label: 'Can manage',\n    line: 'Also shares the project and changes its settings',\n    color: 'var(--primary)',\n    icon: ShieldCheckIcon,\n  },\n];\n\ntype RoleSelectProps<Value extends string> = {\n  value: Value;\n  options: RoleOption<Value>[];\n  onValueChange: (value: Value) => void;\n  /** Names the select for screen readers, since its trigger shows the value only. */\n  label: string;\n  disabled?: boolean;\n  className?: string;\n};\n\n/** A compact role picker that fits in a field or at the end of a row; its menu says what each role can do. */\nexport function RoleSelect<Value extends string>({\n  value,\n  options,\n  onValueChange,\n  label,\n  disabled,\n  className,\n}: RoleSelectProps<Value>) {\n  function changeValue(nextValue: unknown) {\n    const option = options.find((candidate) => candidate.value === nextValue);\n    if (option) {\n      onValueChange(option.value);\n    }\n  }\n\n  return (\n    <Select\n      items={options}\n      value={value}\n      disabled={disabled}\n      onValueChange={changeValue}\n    >\n      <SelectTrigger\n        size='sm'\n        aria-label={label}\n        className={cn(\n          'text-muted-foreground hover:bg-foreground/5 hover:text-foreground data-popup-open:bg-foreground/5 w-auto min-w-0 shrink-0 gap-1 border-transparent bg-transparent px-2 shadow-none ring-0 dark:bg-transparent',\n          className\n        )}\n      >\n        <SelectValue />\n      </SelectTrigger>\n      <SelectContent align='end' className='w-72'>\n        {options.map((option) => {\n          const RoleGlyph = option.icon;\n          const tileStyle = { '--chip': option.color } as React.CSSProperties;\n\n          return (\n            <SelectItem\n              key={option.value}\n              value={option.value}\n              className='h-auto py-1.5'\n            >\n              <span\n                style={tileStyle}\n                className='chip-3d flex size-7 shrink-0 items-center justify-center rounded-md'\n              >\n                <RoleGlyph className='size-3.5 text-current' />\n              </span>\n              <span className='flex min-w-0 flex-col'>\n                <span className='text-foreground text-[13px] font-medium'>\n                  {option.label}\n                </span>\n                <span className='text-muted-foreground truncate text-xs leading-snug'>\n                  {option.line}\n                </span>\n              </span>\n            </SelectItem>\n          );\n        })}\n      </SelectContent>\n    </Select>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/role-select.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"
}