{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-01",
  "title": "Invite people",
  "description": "Addresses become chips tinted by what sending does to them, with the role of the batch and the pending invitations to resend or revoke",
  "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/chip.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/recipes.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-01.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useEffect, useId, useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  AlertCircleIcon,\n  CheckIcon,\n  ChevronDownIcon,\n  ClockIcon,\n  InfoIcon,\n  LoaderCircleIcon,\n  SendIcon,\n  TrashIcon,\n  UsersRoundIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Chip } from '@/registry/ndeko/ui/chip';\nimport { Kbd } from '@/registry/ndeko/ui/kbd';\n\nimport {\n  ActionButton,\n  useTimedAction,\n  type ActionState,\n} from './_parts/action-button';\nimport { AddressField, chipsOf } from './_parts/address-field';\nimport {\n  countOf,\n  isSendable,\n  mergeAddresses,\n  splitAddresses,\n  stateOfAddress,\n  type AddressEntry,\n  type AddressState,\n} from './_parts/invite-emails';\nimport {\n  ModalDescription,\n  ModalHeader,\n  ModalPreview,\n  ModalTitle,\n} from './_parts/modal-frame';\nimport { rowVariantsOf } from './_parts/motion';\nimport { PEOPLE, TEAM_NAME } from './_parts/people';\nimport { PendingAvatar } from './_parts/person-avatar';\nimport { RoleSelect, TEAM_ROLES, type TeamRole } from './_parts/role-select';\nimport { Swap } from './_parts/swap';\n\ntype InvitationState = 'pending' | 'expired';\n\ntype Invitation = {\n  id: string;\n  email: string;\n  role: TeamRole;\n  state: InvitationState;\n  line: string;\n};\n\nconst SHOWN_INVITATIONS = 4;\n\nconst REVOKE_ARMED_MS = 4000;\n\nconst FRESH_EXPIRY = 'Expires in 7 days';\n\nconst INVITATIONS: Invitation[] = [\n  {\n    id: 'invite-noor',\n    email: 'noor.haddad@lattice.example',\n    role: 'member',\n    state: 'pending',\n    line: 'Invited Nov 3 · Expires in 5 days',\n  },\n  {\n    id: 'invite-kofi',\n    email: 'kofi.mensah@lattice.example',\n    role: 'manager',\n    state: 'pending',\n    line: 'Invited this morning · Expires in 7 days',\n  },\n  {\n    id: 'invite-ines',\n    email: 'ines.carvalho@northfield.example',\n    role: 'member',\n    state: 'expired',\n    line: 'Expired Nov 2',\n  },\n  {\n    id: 'invite-yuki',\n    email: 'yuki.tanaka@lattice.example',\n    role: 'member',\n    state: 'pending',\n    line: 'Invited Oct 31 · Expires tomorrow',\n  },\n  {\n    id: 'invite-omar',\n    email: 'omar.farouk@lattice.example',\n    role: 'admin',\n    state: 'expired',\n    line: 'Expired Oct 28',\n  },\n];\n\nconst STATE_LOOK: Record<\n  InvitationState,\n  { label: string; color: string; icon: Icon }\n> = {\n  pending: { label: 'Pending', color: 'var(--warning)', icon: ClockIcon },\n  expired: {\n    label: 'Expired',\n    color: 'var(--destructive)',\n    icon: AlertCircleIcon,\n  },\n};\n\nconst SUMMARY_ORDER: AddressState[] = ['invalid', 'member', 'pending'];\n\nconst MEMBER_EMAILS = new Set(PEOPLE.map((person) => person.email));\n\nfunction roleLabelOf(role: TeamRole) {\n  const option = TEAM_ROLES.find((candidate) => candidate.value === role);\n  return option?.label ?? role;\n}\n\nfunction summaryLineOf(state: AddressState, count: number) {\n  const isOne = count === 1;\n  if (state === 'invalid') {\n    if (isOne) {\n      return '1 address is not valid. Fix or remove it';\n    }\n    return `${count} addresses are not valid. Fix or remove them`;\n  }\n  if (state === 'member') {\n    if (isOne) {\n      return '1 person is already in the team and is skipped';\n    }\n    return `${count} people are already in the team and are skipped`;\n  }\n  if (isOne) {\n    return '1 person was already invited and gets the e-mail again';\n  }\n  return `${count} people were already invited and get the e-mail again`;\n}\n\nfunction inviteLabelOf(count: number) {\n  if (count > 1) {\n    return `Invite ${count}`;\n  }\n  return 'Invite';\n}\n\nfunction moreLabelOf(isExpanded: boolean, hiddenCount: number) {\n  if (isExpanded) {\n    return 'Show less';\n  }\n  return `Show ${hiddenCount} more`;\n}\n\nfunction invitationOf(email: string, role: TeamRole): Invitation {\n  return {\n    id: `invite-${email}`,\n    email,\n    role,\n    state: 'pending',\n    line: `Invited just now · ${FRESH_EXPIRY}`,\n  };\n}\n\nfunction resentOf(invitation: Invitation): Invitation {\n  return {\n    ...invitation,\n    state: 'pending',\n    line: `Sent again just now · ${FRESH_EXPIRY}`,\n  };\n}\n\nfunction TeamContext() {\n  return (\n    <span className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n      <span className='gem-plate flex size-4 items-center justify-center rounded-[4px] [--gem:var(--primary)]'>\n        <UsersRoundIcon className='size-2.5' strokeWidth={2.5} />\n      </span>\n      {`${TEAM_NAME} team`}\n    </span>\n  );\n}\n\nfunction StateChip({ state }: { state: InvitationState }) {\n  const look = STATE_LOOK[state];\n  const StateGlyph = look.icon;\n\n  return (\n    <Swap swapKey={state} kind='label'>\n      <Chip color={look.color} className='h-5'>\n        <StateGlyph strokeWidth={2.25} />\n        {look.label}\n      </Chip>\n    </Swap>\n  );\n}\n\nfunction RevokeButton({\n  email,\n  onRevoke,\n}: {\n  email: string;\n  onRevoke: () => void;\n}) {\n  const [isArmed, setIsArmed] = useState(false);\n\n  useEffect(() => {\n    if (!isArmed) {\n      return;\n    }\n    const timeout = window.setTimeout(() => {\n      setIsArmed(false);\n    }, REVOKE_ARMED_MS);\n    return () => window.clearTimeout(timeout);\n  }, [isArmed]);\n\n  function arm() {\n    setIsArmed(true);\n  }\n\n  function disarm() {\n    setIsArmed(false);\n  }\n\n  if (isArmed) {\n    return (\n      <Button\n        variant='ghost'\n        size='sm'\n        autoFocus\n        onClick={onRevoke}\n        onBlur={disarm}\n        className='text-destructive-ink hover:bg-destructive/10 hover:text-destructive-ink'\n      >\n        Revoke\n      </Button>\n    );\n  }\n\n  return (\n    <Button\n      variant='ghost'\n      size='icon-sm'\n      aria-label={`Revoke the invitation sent to ${email}`}\n      onClick={arm}\n      className='text-muted-foreground hover:text-destructive-ink'\n    >\n      <TrashIcon />\n    </Button>\n  );\n}\n\nfunction ResendButton({\n  email,\n  onResend,\n}: {\n  email: string;\n  onResend: () => void;\n}) {\n  const action = useTimedAction();\n  const isDone = action.state === 'done';\n  const isWorking = action.state === 'working';\n\n  function resend() {\n    action.run(onResend);\n  }\n\n  return (\n    <Button\n      variant='ghost'\n      size='icon-sm'\n      aria-label={`Send the invitation to ${email} again`}\n      aria-busy={isWorking}\n      onClick={resend}\n      className={cn(\n        'text-muted-foreground hover:text-foreground',\n        isDone && 'text-success-foreground hover:text-success-foreground'\n      )}\n    >\n      <Swap swapKey={action.state}>\n        <ResendGlyph state={action.state} />\n      </Swap>\n    </Button>\n  );\n}\n\nfunction ResendGlyph({ state }: { state: ActionState }) {\n  if (state === 'working') {\n    return <LoaderCircleIcon className='animate-spin' />;\n  }\n  if (state === 'done') {\n    return <CheckIcon />;\n  }\n  return <SendIcon />;\n}\n\nfunction InvitationRow({\n  invitation,\n  onResend,\n  onRevoke,\n}: {\n  invitation: Invitation;\n  onResend: (invitationId: string) => void;\n  onRevoke: (invitationId: string) => void;\n}) {\n  const roleLabel = roleLabelOf(invitation.role);\n\n  function resend() {\n    onResend(invitation.id);\n  }\n\n  function revoke() {\n    onRevoke(invitation.id);\n  }\n\n  return (\n    <div className='flex min-h-14 items-center gap-3 py-2 pr-1.5 pl-3'>\n      <PendingAvatar />\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          {invitation.email}\n        </p>\n        <Swap\n          swapKey={invitation.line}\n          kind='label'\n          className='text-muted-foreground flex min-w-0 text-xs leading-tight'\n          contentClassName='max-w-full min-w-0'\n        >\n          <span className='truncate'>{`${roleLabel} · ${invitation.line}`}</span>\n        </Swap>\n      </div>\n      <StateChip state={invitation.state} />\n      <div className='flex shrink-0 items-center'>\n        <ResendButton email={invitation.email} onResend={resend} />\n        <RevokeButton email={invitation.email} onRevoke={revoke} />\n      </div>\n    </div>\n  );\n}\n\nfunction PendingList({\n  invitations,\n  onResend,\n  onRevoke,\n}: {\n  invitations: Invitation[];\n  onResend: (invitationId: string) => void;\n  onRevoke: (invitationId: string) => void;\n}) {\n  const [isExpanded, setIsExpanded] = useState(false);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowVariants = rowVariantsOf(shouldReduceMotion);\n  const headingId = useId();\n  const hiddenCount = invitations.length - SHOWN_INVITATIONS;\n  const canExpand = hiddenCount > 0;\n  const hasInvitations = invitations.length > 0;\n  let shownInvitations = invitations.slice(0, SHOWN_INVITATIONS);\n  if (isExpanded) {\n    shownInvitations = invitations;\n  }\n  const moreLabel = moreLabelOf(isExpanded, hiddenCount);\n\n  function toggleExpanded() {\n    setIsExpanded((previous) => !previous);\n  }\n\n  if (!hasInvitations) {\n    return (\n      <p className='text-muted-foreground text-xs'>\n        Nobody is waiting to join the team\n      </p>\n    );\n  }\n\n  return (\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          Pending invitations\n        </h3>\n        <Kbd>\n          <MotionNumber value={invitations.length} />\n        </Kbd>\n      </div>\n      <div className='bg-card hairline-ring ring-border overflow-hidden rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n        <ul className='flex flex-col py-1'>\n          <AnimatePresence initial={false}>\n            {shownInvitations.map((invitation) => (\n              <motion.li\n                key={invitation.id}\n                variants={rowVariants}\n                initial='hidden'\n                animate='shown'\n                exit='hidden'\n              >\n                <InvitationRow\n                  invitation={invitation}\n                  onResend={onResend}\n                  onRevoke={onRevoke}\n                />\n              </motion.li>\n            ))}\n          </AnimatePresence>\n        </ul>\n        {canExpand && (\n          <button\n            type='button'\n            aria-expanded={isExpanded}\n            onClick={toggleExpanded}\n            className='text-muted-foreground hover:bg-foreground/[0.03] hover:text-foreground focus-visible:bg-foreground/[0.03] flex h-9 w-full cursor-pointer items-center gap-2 px-3 text-left text-xs font-medium transition-colors duration-150 outline-none'\n          >\n            <ChevronDownIcon\n              className={cn(\n                'size-3.5 transition-transform duration-200 ease-(--ease-out-strong)',\n                isExpanded && 'rotate-180'\n              )}\n            />\n            <Swap swapKey={moreLabel} kind='label'>\n              {moreLabel}\n            </Swap>\n          </button>\n        )}\n      </div>\n    </section>\n  );\n}\n\nfunction InvitePeople() {\n  const [addresses, setAddresses] = useState<string[]>([\n    'ada.lindqvist@lattice.example',\n    'kofi.mensah@lattice.example',\n    'priya@lattice.example',\n    'bruno@lattice',\n  ]);\n  const [role, setRole] = useState<TeamRole>('member');\n  const [invitations, setInvitations] = useState<Invitation[]>(INVITATIONS);\n  const action = useTimedAction();\n  const summaryId = useId();\n  const pendingEmails = new Set(\n    invitations.map((invitation) => invitation.email)\n  );\n  const context = { memberEmails: MEMBER_EMAILS, pendingEmails };\n  const entries: AddressEntry[] = addresses.map((email) => ({\n    email,\n    state: stateOfAddress(email, context),\n  }));\n  const sendable = entries.filter((entry) => isSendable(entry.state));\n  const sendableCount = sendable.length;\n  const hasInvalid = countOf(entries, 'invalid') > 0;\n  const isSendDisabled = sendableCount === 0;\n  const allSummaryLines = SUMMARY_ORDER.map((state) => ({\n    state,\n    count: countOf(entries, state),\n  }));\n  const summaryLines = allSummaryLines.filter((line) => line.count > 0);\n  const hasSummary = summaryLines.length > 0;\n\n  function addAddresses(text: string) {\n    const added = splitAddresses(text);\n    setAddresses((previous) => mergeAddresses(previous, added));\n  }\n\n  function removeAddress(email: string) {\n    setAddresses((previous) => previous.filter((item) => item !== email));\n  }\n\n  function resendInvitation(invitationId: string) {\n    setInvitations((previous) =>\n      previous.map((invitation) => {\n        if (invitation.id !== invitationId) {\n          return invitation;\n        }\n        return resentOf(invitation);\n      })\n    );\n  }\n\n  function revokeInvitation(invitationId: string) {\n    setInvitations((previous) =>\n      previous.filter((invitation) => invitation.id !== invitationId)\n    );\n  }\n\n  function commitSend() {\n    const newEntries = sendable.filter((entry) => entry.state === 'new');\n    const newEmails = newEntries.map((entry) => entry.email);\n    const resentEntries = sendable.filter((entry) => entry.state === 'pending');\n    const resentEmails = resentEntries.map((entry) => entry.email);\n    const sentEmails = sendable.map((entry) => entry.email);\n    const created = newEmails.map((email) => invitationOf(email, role));\n    setInvitations((previous) => {\n      const refreshed = previous.map((invitation) => {\n        const isResent = resentEmails.includes(invitation.email);\n        if (!isResent) {\n          return invitation;\n        }\n        return resentOf(invitation);\n      });\n      return [...created, ...refreshed];\n    });\n    setAddresses((previous) =>\n      previous.filter((email) => !sentEmails.includes(email))\n    );\n  }\n\n  function send(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (isSendDisabled) {\n      return;\n    }\n    action.run(commitSend);\n  }\n\n  function sendFromShortcut() {\n    if (isSendDisabled) {\n      return;\n    }\n    action.run(commitSend);\n  }\n\n  return (\n    <>\n      <ModalHeader>\n        <TeamContext />\n        <ModalTitle>Invite people</ModalTitle>\n        <ModalDescription>\n          They get an e-mail with a link to join the team\n        </ModalDescription>\n      </ModalHeader>\n      <form onSubmit={send} autoComplete='off' className='flex flex-col gap-2'>\n        <div className='flex items-start gap-2'>\n          <AddressField\n            label='E-mail addresses'\n            chips={chipsOf(entries)}\n            onAdd={addAddresses}\n            onRemove={removeAddress}\n            onSubmitShortcut={sendFromShortcut}\n            describedBy={summaryId}\n            isInvalid={hasInvalid}\n            className='flex-1'\n            trailing={\n              <RoleSelect\n                label='Role of the people invited'\n                value={role}\n                options={TEAM_ROLES}\n                onValueChange={setRole}\n              />\n            }\n          />\n          <ActionButton\n            type='submit'\n            size='lg'\n            state={action.state}\n            disabled={isSendDisabled}\n            idleIcon={<SendIcon />}\n            labels={{\n              idle: inviteLabelOf(sendableCount),\n              working: 'Sending',\n              done: 'Sent',\n            }}\n          />\n        </div>\n        <AnimatedSize>\n          <div id={summaryId} className='flex flex-col gap-1'>\n            <p className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n              <InfoIcon className='size-3.5 shrink-0' />\n              Press Enter or a comma after each address, or paste a list\n            </p>\n            {hasSummary && (\n              <ul className='text-muted-foreground flex flex-col gap-0.5 pl-5 text-xs'>\n                {summaryLines.map((line) => (\n                  <li\n                    key={line.state}\n                    className={cn(\n                      line.state === 'invalid' && 'text-destructive-ink'\n                    )}\n                  >\n                    {summaryLineOf(line.state, line.count)}\n                  </li>\n                ))}\n              </ul>\n            )}\n          </div>\n        </AnimatedSize>\n      </form>\n      <PendingList\n        invitations={invitations}\n        onResend={resendInvitation}\n        onRevoke={revokeInvitation}\n      />\n    </>\n  );\n}\n\nexport default function Modal01() {\n  return (\n    <ModalPreview triggerLabel='Open the invite dialog' size='lg'>\n      <InvitePeople />\n    </ModalPreview>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/modal-01.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/address-field.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { XIcon } from '@/registry/ndeko/lib/icons';\nimport { CONTROL_RECIPE } from '@/registry/ndeko/lib/recipes';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Chip } from '@/registry/ndeko/ui/chip';\n\nimport {\n  ADDRESS_LOOK,\n  type AddressEntry,\n  type AddressLook,\n} from './invite-emails';\nimport { chipVariantsOf } from './motion';\n\nexport type FieldChip = { email: string; look: AddressLook };\n\nexport function chipsOf(entries: AddressEntry[]): FieldChip[] {\n  return entries.map((entry) => ({\n    email: entry.email,\n    look: ADDRESS_LOOK[entry.state],\n  }));\n}\n\nconst COMMIT_KEYS = new Set(['Enter', ',', ';', ' ', 'Tab']);\n\nfunction placeholderOf(hasChips: boolean, empty: string, more: string) {\n  if (hasChips) {\n    return more;\n  }\n  return empty;\n}\n\nfunction AddressChip({\n  chip,\n  allowsLayout,\n  onRemove,\n}: {\n  chip: FieldChip;\n  allowsLayout: boolean;\n  onRemove: (email: string) => void;\n}) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = chipVariantsOf(shouldReduceMotion);\n  const ChipGlyph = chip.look.icon;\n  const hasHint = chip.look.hint.length > 0;\n\n  function remove() {\n    onRemove(chip.email);\n  }\n\n  return (\n    <motion.li\n      layout={allowsLayout}\n      variants={variants}\n      initial='hidden'\n      animate='shown'\n      exit='hidden'\n      title={chip.look.hint}\n      className='flex max-w-full'\n    >\n      <Chip\n        color={chip.look.color}\n        className='h-6 max-w-full gap-1 pr-0.5 pl-1.5 text-xs'\n      >\n        {ChipGlyph && <ChipGlyph strokeWidth={2.25} />}\n        <span className='truncate'>{chip.email}</span>\n        {hasHint && <span className='sr-only'>{chip.look.hint}</span>}\n        <button\n          type='button'\n          aria-label={`Remove ${chip.email}`}\n          onClick={remove}\n          className='hover:bg-foreground/10 focus-visible:ring-ring/25 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-[5px] opacity-70 transition-[opacity,background-color] duration-150 outline-none hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-[3px]'\n        >\n          <XIcon className='size-3' />\n        </button>\n      </Chip>\n    </motion.li>\n  );\n}\n\ntype AddressFieldProps = {\n  label: string;\n  chips: FieldChip[];\n  onAdd: (text: string) => void;\n  onRemove: (email: string) => void;\n  /** Enter on an empty line, or Cmd Enter at any time, sends what the field holds. */\n  onSubmitShortcut?: () => void;\n  /** Sits at the right end of the field, such as the role of the batch. */\n  trailing?: React.ReactNode;\n  placeholder?: string;\n  morePlaceholder?: string;\n  describedBy?: string;\n  isInvalid?: boolean;\n  disabled?: boolean;\n  className?: string;\n};\n\n/**\n * One field for many addresses, like the To line of a mail: each address becomes a chip tinted by what sending\n * will do with it, a pasted list fills it at once, Backspace on an empty line takes the last chip back.\n */\nexport function AddressField({\n  label,\n  chips,\n  onAdd,\n  onRemove,\n  onSubmitShortcut,\n  trailing,\n  placeholder = 'name@company.com, another@company.com',\n  morePlaceholder = 'Add another address',\n  describedBy,\n  isInvalid = false,\n  disabled = false,\n  className,\n}: AddressFieldProps) {\n  const inputId = useId();\n  const inputRef = useRef<HTMLInputElement>(null);\n  const [draft, setDraft] = useState('');\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const allowsLayout = !shouldReduceMotion;\n  const hasChips = chips.length > 0;\n  const hasTrailing = Boolean(trailing);\n  const shownPlaceholder = placeholderOf(\n    hasChips,\n    placeholder,\n    morePlaceholder\n  );\n  const lastChip = chips.at(-1);\n\n  function focusInput() {\n    inputRef.current?.focus();\n  }\n\n  function commitDraft() {\n    const typed = draft.trim();\n    if (typed.length === 0) {\n      return false;\n    }\n    onAdd(typed);\n    setDraft('');\n    return true;\n  }\n\n  function changeDraft(event: React.ChangeEvent<HTMLInputElement>) {\n    setDraft(event.target.value);\n  }\n\n  function removeChip(email: string) {\n    onRemove(email);\n    focusInput();\n  }\n\n  function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n    const isEnter = event.key === 'Enter';\n    const hasModifier = event.metaKey || event.ctrlKey;\n    const isDraftEmpty = draft.trim().length === 0;\n    const isSubmitShortcut = isEnter && hasModifier;\n    const isEnterOnEmptyLine = isEnter && isDraftEmpty;\n    const asksToSend = isSubmitShortcut || isEnterOnEmptyLine;\n    if (asksToSend && onSubmitShortcut) {\n      event.preventDefault();\n      commitDraft();\n      onSubmitShortcut();\n      return;\n    }\n    if (COMMIT_KEYS.has(event.key)) {\n      const hasCommitted = commitDraft();\n      const isTab = event.key === 'Tab';\n      const keepsTabMoving = isTab && !hasCommitted;\n      if (!keepsTabMoving) {\n        event.preventDefault();\n      }\n      return;\n    }\n    const isBackspace = event.key === 'Backspace';\n    const takesLastChip = isBackspace && draft.length === 0;\n    if (takesLastChip && lastChip) {\n      onRemove(lastChip.email);\n    }\n  }\n\n  function handlePaste(event: React.ClipboardEvent<HTMLInputElement>) {\n    const pasted = event.clipboardData.getData('text');\n    event.preventDefault();\n    onAdd(`${draft} ${pasted}`);\n    setDraft('');\n  }\n\n  return (\n    <div\n      role='presentation'\n      onClick={focusInput}\n      data-invalid={isInvalid || undefined}\n      className={cn(\n        CONTROL_RECIPE,\n        'flex min-h-9 cursor-text items-start gap-1 p-1',\n        'focus-within:border-foreground/30 focus-within:ring-ring/25 focus-within:ring-[3px]',\n        className\n      )}\n    >\n      <div className='relative flex max-h-[7rem] min-w-0 flex-1 flex-wrap items-center gap-1 overflow-y-auto overscroll-contain'>\n        {hasChips && (\n          <ul aria-label='Addresses to invite' className='contents'>\n            <AnimatePresence initial={false} mode='popLayout'>\n              {chips.map((chip) => (\n                <AddressChip\n                  key={chip.email}\n                  chip={chip}\n                  allowsLayout={allowsLayout}\n                  onRemove={removeChip}\n                />\n              ))}\n            </AnimatePresence>\n          </ul>\n        )}\n        <label htmlFor={inputId} className='sr-only'>\n          {label}\n        </label>\n        <input\n          ref={inputRef}\n          id={inputId}\n          type='text'\n          inputMode='email'\n          autoComplete='off'\n          spellCheck={false}\n          value={draft}\n          disabled={disabled}\n          aria-describedby={describedBy}\n          aria-invalid={isInvalid || undefined}\n          placeholder={shownPlaceholder}\n          onChange={changeDraft}\n          onKeyDown={handleKeyDown}\n          onPaste={handlePaste}\n          onBlur={commitDraft}\n          className='placeholder:text-muted-foreground/75 h-7 min-w-36 flex-1 bg-transparent px-1.5 text-base outline-none disabled:cursor-not-allowed md:text-[13px]'\n        />\n      </div>\n      {hasTrailing && (\n        <div className='flex h-7 shrink-0 items-center'>{trailing}</div>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/address-field.tsx"
    },
    {
      "path": "registry/ndeko/components/modal/_parts/invite-emails.ts",
      "content": "import {\n  AlertCircleIcon,\n  ClockIcon,\n  UserIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\n\n/** What sending does to an address: a new invitation, the e-mail again for a pending one, nothing for a member or a typo. */\nexport type AddressState = 'new' | 'pending' | 'member' | 'invalid';\n\nexport type AddressEntry = { email: string; state: AddressState };\n\nexport type AddressLook = { color: string; icon: Icon | null; hint: string };\n\nexport const ADDRESS_LOOK: Record<AddressState, AddressLook> = {\n  new: { color: 'var(--muted-foreground)', icon: null, hint: '' },\n  pending: {\n    color: 'var(--warning)',\n    icon: ClockIcon,\n    hint: 'Already invited: they get the e-mail again',\n  },\n  member: {\n    color: 'var(--muted-foreground)',\n    icon: UserIcon,\n    hint: 'Already in the team: not invited again',\n  },\n  invalid: {\n    color: 'var(--destructive)',\n    icon: AlertCircleIcon,\n    hint: 'Not a valid e-mail address',\n  },\n};\n\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst TOKEN_SEPARATORS = /[\\s,;<>\"'()]+/;\n\nexport function isEmail(value: string) {\n  return EMAIL_PATTERN.test(value);\n}\n\nfunction normalizeAddress(value: string) {\n  const trimmed = value.trim();\n  return trimmed.toLowerCase();\n}\n\n/**\n * The addresses in what was typed or pasted, without repeats. When the text holds an address, the words around it\n * are names copied from a mail client and are left out.\n */\nexport function splitAddresses(text: string) {\n  const tokens = text.split(TOKEN_SEPARATORS);\n  const holdsAnAddress = text.includes('@');\n  const addresses: string[] = [];\n  for (const token of tokens) {\n    const address = normalizeAddress(token);\n    const isEmpty = address.length === 0;\n    const isNameAround = holdsAnAddress && !address.includes('@');\n    const isRepeat = addresses.includes(address);\n    if (isEmpty || isNameAround || isRepeat) {\n      continue;\n    }\n    addresses.push(address);\n  }\n  return addresses;\n}\n\nexport function mergeAddresses(current: string[], added: string[]) {\n  const merged = [...current];\n  for (const address of added) {\n    if (!merged.includes(address)) {\n      merged.push(address);\n    }\n  }\n  return merged;\n}\n\nexport type AddressContext = {\n  memberEmails: ReadonlySet<string>;\n  pendingEmails: ReadonlySet<string>;\n};\n\nexport function stateOfAddress(\n  email: string,\n  context: AddressContext\n): AddressState {\n  if (!isEmail(email)) {\n    return 'invalid';\n  }\n  if (context.memberEmails.has(email)) {\n    return 'member';\n  }\n  if (context.pendingEmails.has(email)) {\n    return 'pending';\n  }\n  return 'new';\n}\n\nexport function isSendable(state: AddressState) {\n  const isNew = state === 'new';\n  const isPending = state === 'pending';\n  return isNew || isPending;\n}\n\nexport function countOf(entries: AddressEntry[], state: AddressState) {\n  return entries.filter((entry) => entry.state === state).length;\n}\n",
      "type": "registry:component",
      "target": "components/modal/_parts/invite-emails.ts"
    },
    {
      "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"
}