{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "teams-03",
  "title": "Member row",
  "description": "One member with presence on the avatar, the current task and time today, a role menu, and removal that turns into Undo.",
  "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/dropdown-menu.json",
    "https://ui.ndekocode.dev/r/icons.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/teams/teams-03.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  CheckIcon,\n  CircleAlertIcon,\n  CopyIcon,\n  EllipsisIcon,\n  RotateCcwIcon,\n  UserMinusIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuItem,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\n\nimport { memberById, type Role } from './_parts/people';\nimport { PresenceAvatar } from './_parts/presence-avatar';\nimport { RoleMenu } from './_parts/role-menu';\nimport { Swap } from './_parts/swap';\n\nconst MEMBER = memberById('sana');\n\nconst COPIED_RESET_MS = 1600;\n\nconst ARRIVE: Transition = { duration: 0.18, ease: [0.23, 1, 0.32, 1] };\n\nconst LEAVE: Transition = { duration: 0.12, ease: [0.23, 1, 0.32, 1] };\n\nconst BLUR_VARIANTS: Variants = {\n  enter: { opacity: 0, filter: 'blur(2px)' },\n  visible: { opacity: 1, filter: 'blur(0px)', transition: ARRIVE },\n  exit: { opacity: 0, filter: 'blur(2px)', transition: LEAVE },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1, transition: ARRIVE },\n  exit: { opacity: 0, transition: LEAVE },\n};\n\nfunction variantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return BLUR_VARIANTS;\n}\n\nfunction copyLabelOf(isCopied: boolean) {\n  if (isCopied) {\n    return 'Email copied';\n  }\n  return 'Copy email';\n}\n\nfunction CurrentTask() {\n  return (\n    <div className='hidden min-w-0 flex-col items-end gap-0.5 md:flex'>\n      <span className='flex min-w-0 items-center gap-1.5'>\n        <span\n          role='img'\n          aria-label='Bug'\n          className='gem-plate inline-flex size-4 shrink-0 items-center justify-center rounded-[5px] [--gem:var(--destructive)]'\n        >\n          <CircleAlertIcon strokeWidth={2.5} className='size-2.5' />\n        </span>\n        <span className='text-muted-foreground text-xs tabular-nums'>\n          FRN-152\n        </span>\n        <span className='max-w-40 truncate text-[13px]'>\n          Photo sync drops captions\n        </span>\n      </span>\n      <span className='text-muted-foreground text-xs'>\n        Today <span className='text-foreground tabular-nums'>2h 05m</span>\n      </span>\n    </div>\n  );\n}\n\ntype MemberDetailsProps = {\n  role: Role;\n  onRoleChange: (role: Role) => void;\n  onRemove: () => void;\n};\n\nfunction MemberDetails({ role, onRoleChange, onRemove }: MemberDetailsProps) {\n  const [isCopied, setIsCopied] = useState(false);\n  const copyLabel = copyLabelOf(isCopied);\n\n  function copyEmail() {\n    setIsCopied(true);\n    window.setTimeout(() => setIsCopied(false), COPIED_RESET_MS);\n  }\n\n  return (\n    <div className='flex items-center gap-3'>\n      <PresenceAvatar member={MEMBER} />\n      <div className='min-w-0 flex-1'>\n        <p className='truncate text-[13px] leading-5 font-medium'>\n          {MEMBER.name}\n        </p>\n        <p className='text-muted-foreground truncate text-xs'>{MEMBER.title}</p>\n      </div>\n      <CurrentTask />\n      <RoleMenu role={role} memberName={MEMBER.name} onChange={onRoleChange} />\n      <DropdownMenu>\n        <DropdownMenuTrigger\n          render={\n            <Button\n              variant='ghost'\n              size='icon-sm'\n              aria-label={`More actions for ${MEMBER.name}`}\n              className='text-muted-foreground'\n            />\n          }\n        >\n          <EllipsisIcon />\n        </DropdownMenuTrigger>\n        <DropdownMenuContent align='end' className='w-52'>\n          <DropdownMenuItem closeOnClick={false} onClick={copyEmail}>\n            <Swap swapKey={String(isCopied)}>\n              {isCopied && <CheckIcon className='text-success-foreground' />}\n              {!isCopied && <CopyIcon />}\n            </Swap>\n            {copyLabel}\n          </DropdownMenuItem>\n          <DropdownMenuSeparator />\n          <DropdownMenuItem variant='destructive' onClick={onRemove}>\n            <UserMinusIcon />\n            Remove from team\n          </DropdownMenuItem>\n        </DropdownMenuContent>\n      </DropdownMenu>\n    </div>\n  );\n}\n\nfunction RemovedNotice({ onUndo }: { onUndo: () => void }) {\n  return (\n    <div className='flex min-h-9 items-center gap-3'>\n      <p className='text-muted-foreground min-w-0 flex-1 text-[13px]'>\n        <span className='text-foreground font-medium'>{MEMBER.name}</span> was\n        removed from Atlas Redesign. Open tasks stay assigned to Sana\n      </p>\n      <Button size='sm' variant='outline' onClick={onUndo}>\n        <RotateCcwIcon />\n        Undo\n      </Button>\n    </div>\n  );\n}\n\nexport default function Teams03() {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const [role, setRole] = useState<Role>(MEMBER.role);\n  const [isRemoved, setIsRemoved] = useState(false);\n  const variants = variantsOf(shouldReduceMotion);\n\n  function remove() {\n    setIsRemoved(true);\n  }\n\n  function undo() {\n    setIsRemoved(false);\n  }\n\n  return (\n    <div className='bg-card hairline-ring ring-border w-full max-w-[36rem] rounded-xl px-3 py-2.5 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n      <AnimatedSize>\n        <div aria-live='polite' className='relative'>\n          <AnimatePresence mode='popLayout' initial={false}>\n            <motion.div\n              key={String(isRemoved)}\n              variants={variants}\n              initial='enter'\n              animate='visible'\n              exit='exit'\n            >\n              {!isRemoved && (\n                <MemberDetails\n                  role={role}\n                  onRoleChange={setRole}\n                  onRemove={remove}\n                />\n              )}\n              {isRemoved && <RemovedNotice onUndo={undo} />}\n            </motion.div>\n          </AnimatePresence>\n        </div>\n      </AnimatedSize>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/teams/teams-03.tsx"
    },
    {
      "path": "registry/ndeko/components/teams/_parts/morph-label.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\n\nconst ARRIVE: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst LEAVE: Transition = { duration: 0.1, ease: [0.2, 0, 0, 1] };\n\nconst BLUR_VARIANTS: Variants = {\n  enter: { opacity: 0, filter: 'blur(2px)' },\n  visible: { opacity: 1, filter: 'blur(0px)', transition: ARRIVE },\n  exit: { opacity: 0, filter: 'blur(2px)', transition: LEAVE },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1, transition: ARRIVE },\n  exit: { opacity: 0, transition: LEAVE },\n};\n\nfunction variantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return BLUR_VARIANTS;\n}\n\ntype MorphLabelProps = {\n  /** Changes when the label becomes another one. */\n  value: string;\n  className?: string;\n  children: React.ReactNode;\n};\n\n/** A label that becomes another: the text crossfades through a light blur while its width follows. */\nexport function MorphLabel({ value, className, children }: MorphLabelProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <AnimatedSize as='span' axis='width' contentClassName='relative flex'>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={value}\n          variants={variantsOf(shouldReduceMotion)}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          className={cn('flex whitespace-nowrap', className)}\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </AnimatedSize>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/teams/_parts/morph-label.tsx"
    },
    {
      "path": "registry/ndeko/components/teams/_parts/people.ts",
      "content": "import {\n  CheckIcon,\n  ClockIcon,\n  MinusIcon,\n  MoonIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\n\nexport type Presence = 'tracking' | 'online' | 'away' | 'offline';\n\nexport type Role = 'manager' | 'member' | 'viewer';\n\nexport type Member = {\n  id: string;\n  name: string;\n  email: string;\n  title: string;\n  role: Role;\n  presence: Presence;\n  isYou: boolean;\n};\n\ntype PresenceMeta = { label: string; color: string; glyph: Icon };\n\nexport const PRESENCE_META: Record<Presence, PresenceMeta> = {\n  tracking: {\n    label: 'Tracking time',\n    color: 'var(--primary)',\n    glyph: ClockIcon,\n  },\n  online: { label: 'Online', color: 'var(--success)', glyph: CheckIcon },\n  away: { label: 'Away', color: 'var(--warning)', glyph: MoonIcon },\n  offline: {\n    label: 'Offline',\n    color: 'var(--muted-foreground)',\n    glyph: MinusIcon,\n  },\n};\n\ntype RoleMeta = { label: string; description: string; color: string };\n\nexport const ROLE_META: Record<Role, RoleMeta> = {\n  manager: {\n    label: 'Manager',\n    description: 'Edits the team, its members and their plans',\n    color: 'var(--primary)',\n  },\n  member: {\n    label: 'Member',\n    description: 'Works on tasks and tracks time',\n    color: 'var(--info)',\n  },\n  viewer: {\n    label: 'Viewer',\n    description: 'Sees tasks and reports, changes nothing',\n    color: 'var(--muted-foreground)',\n  },\n};\n\nexport const ROLE_ORDER: Role[] = ['manager', 'member', 'viewer'];\n\nexport function isRole(value: unknown): value is Role {\n  return ROLE_ORDER.some((role) => role === value);\n}\n\nexport const MEMBERS: Member[] = [\n  {\n    id: 'amara',\n    name: 'Amara Okafor',\n    email: 'amara@example.com',\n    title: 'Product designer',\n    role: 'manager',\n    presence: 'tracking',\n    isYou: true,\n  },\n  {\n    id: 'leo',\n    name: 'Léo Martin',\n    email: 'leo@example.com',\n    title: 'Frontend engineer',\n    role: 'member',\n    presence: 'online',\n    isYou: false,\n  },\n  {\n    id: 'sana',\n    name: 'Sana Iqbal',\n    email: 'sana@example.com',\n    title: 'Backend engineer',\n    role: 'member',\n    presence: 'tracking',\n    isYou: false,\n  },\n  {\n    id: 'tomas',\n    name: 'Tomás Rivera',\n    email: 'tomas@example.com',\n    title: 'QA engineer',\n    role: 'member',\n    presence: 'away',\n    isYou: false,\n  },\n  {\n    id: 'mei',\n    name: 'Mei Lin',\n    email: 'mei@example.com',\n    title: 'Content designer',\n    role: 'viewer',\n    presence: 'offline',\n    isYou: false,\n  },\n  {\n    id: 'jonas',\n    name: 'Jonas Weber',\n    email: 'jonas@example.com',\n    title: 'Data analyst',\n    role: 'member',\n    presence: 'online',\n    isYou: false,\n  },\n];\n\nexport function memberById(memberId: string) {\n  const found = MEMBERS.find((member) => member.id === memberId);\n  if (found) {\n    return found;\n  }\n  return MEMBERS[0];\n}\n",
      "type": "registry:component",
      "target": "components/teams/_parts/people.ts"
    },
    {
      "path": "registry/ndeko/components/teams/_parts/presence-avatar.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\n\nimport { PRESENCE_META, type Member } from './people';\n\nconst SIZE_CLASS = {\n  sm: { avatar: 'size-7', badge: 'size-3.5', glyph: 'size-2' },\n  md: { avatar: 'size-9', badge: 'size-4', glyph: 'size-2.5' },\n  lg: { avatar: 'size-12', badge: 'size-5', glyph: 'size-3' },\n} as const;\n\ntype PresenceAvatarProps = {\n  member: Member;\n  size?: keyof typeof SIZE_CLASS;\n  /** The colour behind the badge's cut-out: the surface the avatar sits on. */\n  surfaceClassName?: string;\n  className?: string;\n};\n\n/** A person's face with their presence as a small glyph on its corner, read out after the name. */\nexport function PresenceAvatar({\n  member,\n  size = 'md',\n  surfaceClassName = 'bg-card',\n  className,\n}: PresenceAvatarProps) {\n  const presence = PRESENCE_META[member.presence];\n  const Glyph = presence.glyph;\n  const badgeStyle = { '--chip': presence.color } as React.CSSProperties;\n  const sizes = SIZE_CLASS[size];\n\n  return (\n    <span className={cn('relative inline-flex shrink-0', className)}>\n      <Avatar className={sizes.avatar} seed={member.name} />\n      <span\n        aria-hidden='true'\n        className={cn(\n          'absolute -end-0.5 -bottom-0.5 flex rounded-full p-px',\n          surfaceClassName\n        )}\n      >\n        <span\n          style={badgeStyle}\n          className={cn(\n            'chip-3d flex items-center justify-center rounded-full',\n            sizes.badge\n          )}\n        >\n          <Glyph className={sizes.glyph} strokeWidth={2.75} />\n        </span>\n      </span>\n      <span className='sr-only'>{presence.label}</span>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/teams/_parts/presence-avatar.tsx"
    },
    {
      "path": "registry/ndeko/components/teams/_parts/role-menu.tsx",
      "content": "'use client';\n\nimport { ChevronDownIcon, UserMinusIcon } from '@/registry/ndeko/lib/icons';\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuGroupLabel,\n  DropdownMenuItem,\n  DropdownMenuRadioGroup,\n  DropdownMenuRadioItem,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\n\nimport { MorphLabel } from './morph-label';\nimport { ROLE_META, ROLE_ORDER, isRole, type Role } from './people';\n\ntype RoleTrigger = 'chip' | 'text';\n\nconst CHIP_TRIGGER =\n  'chip-3d inline-flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md px-2 text-xs font-medium whitespace-nowrap outline-none focus-visible:ring-[3px] focus-visible:ring-ring/25';\n\nconst TEXT_TRIGGER =\n  'inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 rounded-md px-2 text-[13px] whitespace-nowrap text-muted-foreground outline-none transition-colors duration-150 hover:bg-foreground/5 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/25 data-popup-open:bg-foreground/5 data-popup-open:text-foreground';\n\nfunction triggerClassOf(trigger: RoleTrigger) {\n  if (trigger === 'chip') {\n    return CHIP_TRIGGER;\n  }\n  return TEXT_TRIGGER;\n}\n\nfunction triggerStyleOf(trigger: RoleTrigger, role: Role) {\n  if (trigger === 'chip') {\n    return { '--chip': ROLE_META[role].color } as React.CSSProperties;\n  }\n  return undefined;\n}\n\nfunction isLockedOption(option: Role, isLastManager: boolean) {\n  const leavesManagerRole = option !== 'manager';\n  return isLastManager && leavesManagerRole;\n}\n\ntype RoleMenuProps = {\n  role: Role;\n  memberName: string;\n  onChange: (role: Role) => void;\n  /** The only manager of the team cannot step down: a team keeps one. */\n  isLastManager?: boolean;\n  /** Adds Remove from team at the end of the menu. */\n  onRemove?: () => void;\n  trigger?: RoleTrigger;\n};\n\n/** The role of a member as a menu: the trigger shows it, the rows explain each one. */\nexport function RoleMenu({\n  role,\n  memberName,\n  onChange,\n  isLastManager = false,\n  onRemove,\n  trigger = 'chip',\n}: RoleMenuProps) {\n  const meta = ROLE_META[role];\n  const canRemove = onRemove !== undefined;\n  const triggerLabel = `Role of ${memberName}: ${meta.label}. Change role`;\n\n  function changeRole(value: unknown) {\n    if (isRole(value)) {\n      onChange(value);\n    }\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        aria-label={triggerLabel}\n        style={triggerStyleOf(trigger, role)}\n        className={triggerClassOf(trigger)}\n      >\n        <MorphLabel value={role}>{meta.label}</MorphLabel>\n        <ChevronDownIcon className='size-3.5 opacity-70' />\n      </DropdownMenuTrigger>\n      <DropdownMenuContent align='end' className='w-72'>\n        <DropdownMenuGroup>\n          <DropdownMenuGroupLabel>Role of {memberName}</DropdownMenuGroupLabel>\n          <DropdownMenuRadioGroup value={role} onValueChange={changeRole}>\n            {ROLE_ORDER.map((option) => {\n              const optionMeta = ROLE_META[option];\n              const isLocked = isLockedOption(option, isLastManager);\n              return (\n                <DropdownMenuRadioItem\n                  key={option}\n                  value={option}\n                  disabled={isLocked}\n                  closeOnClick\n                  className='h-auto items-start py-2'\n                >\n                  <span className='flex flex-col gap-0.5'>\n                    <span>{optionMeta.label}</span>\n                    <span className='text-muted-foreground text-xs'>\n                      {optionMeta.description}\n                    </span>\n                  </span>\n                </DropdownMenuRadioItem>\n              );\n            })}\n          </DropdownMenuRadioGroup>\n        </DropdownMenuGroup>\n        {isLastManager && (\n          <p className='text-muted-foreground px-2 pt-1 pb-1.5 text-xs'>\n            A team keeps at least one manager. Make someone else a manager first\n          </p>\n        )}\n        {canRemove && (\n          <>\n            <DropdownMenuSeparator />\n            <DropdownMenuItem variant='destructive' onClick={onRemove}>\n              <UserMinusIcon />\n              Remove from team\n            </DropdownMenuItem>\n          </>\n        )}\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/teams/_parts/role-menu.tsx"
    },
    {
      "path": "registry/ndeko/components/teams/_parts/swap.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst SWAP_VARIANTS: 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 FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nfunction variantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SWAP_VARIANTS;\n}\n\ntype SwapProps = {\n  /** Changes when the content becomes another one. */\n  swapKey: string;\n  className?: string;\n  children: React.ReactNode;\n};\n\n/** An icon that becomes another: the old one shrinks out of focus while the new one settles. */\nexport function Swap({ swapKey, className, children }: SwapProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <AnimatePresence mode='popLayout' initial={false}>\n      <motion.span\n        key={swapKey}\n        variants={variantsOf(shouldReduceMotion)}\n        initial='enter'\n        animate='visible'\n        exit='exit'\n        transition={SWAP_TRANSITION}\n        className={cn('flex', className)}\n      >\n        {children}\n      </motion.span>\n    </AnimatePresence>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/teams/_parts/swap.tsx"
    }
  ],
  "categories": [
    "components",
    "teams"
  ],
  "type": "registry:component"
}