{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "people-list",
  "type": "registry:component",
  "title": "People List",
  "description": "A team directory with initials avatars, presence dots, role badges, a keyboard-friendly row menu and a search field with an animated empty state.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "lists",
    "people",
    "team",
    "directory",
    "members",
    "search",
    "menu"
  ],
  "docs": "https://hyperblur.dev/effects/people-list",
  "files": [
    {
      "path": "registry/hyperblur/people-list.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/people-list.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type PersonStatus = \"online\" | \"away\" | \"offline\";\nexport type PersonAction = \"edit\" | \"invite\" | \"remove\";\n\nexport interface Person {\n  id: string;\n  name: string;\n  email: string;\n  role: string;\n  status?: PersonStatus;\n}\n\nexport const defaultPeople: Person[] = [\n  { id: \"p1\", name: \"Maya Johnson\", email: \"maya@northwind.io\", role: \"Owner\", status: \"online\" },\n  { id: \"p2\", name: \"Daniel Okafor\", email: \"daniel@northwind.io\", role: \"Admin\", status: \"online\" },\n  { id: \"p3\", name: \"Priya Raman\", email: \"priya@northwind.io\", role: \"Member\", status: \"away\" },\n  { id: \"p4\", name: \"Lucas Moreau\", email: \"lucas@northwind.io\", role: \"Member\", status: \"offline\" },\n  { id: \"p5\", name: \"Hannah Weiss\", email: \"hannah@northwind.io\", role: \"Viewer\", status: \"online\" },\n  { id: \"p6\", name: \"Tomas Silva\", email: \"tomas@northwind.io\", role: \"Member\", status: \"away\" },\n  { id: \"p7\", name: \"Aiko Tanaka\", email: \"aiko@northwind.io\", role: \"Admin\", status: \"offline\" },\n];\n\nexport interface PeopleListProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n  people?: Person[];\n  searchable?: boolean;\n  placeholder?: string;\n  accent?: string;\n  onAction?: (action: PersonAction, person: Person) => void;\n}\n\nconst css = `\n.hb-ppl {\n  --hb-ppl-accent: #2f7bff;\n  container-type: inline-size;\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  min-width: 0;\n  box-sizing: border-box;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 1.4;\n  color: #ededed;\n}\n.hb-ppl *, .hb-ppl *::before, .hb-ppl *::after { box-sizing: border-box; font-family: inherit; }\n.hb-ppl-search {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n  height: 34px;\n  padding: 0 10px;\n  margin-bottom: 6px;\n  border: 1px solid #262626;\n  border-radius: 9px;\n  background: #111111;\n  color: #8f8f8f;\n  transition: border-color .15s ease, box-shadow .15s ease;\n}\n.hb-ppl-search:focus-within {\n  border-color: color-mix(in srgb, var(--hb-ppl-accent) 70%, transparent);\n  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-ppl-accent) 18%, transparent);\n}\n.hb-ppl-search svg { width: 14px; height: 14px; flex: none; }\n.hb-ppl-input {\n  flex: 1;\n  min-width: 0;\n  height: 100%;\n  padding: 0;\n  border: 0;\n  outline: 0;\n  background: none;\n  color: #ededed;\n  font-size: 13px;\n}\n.hb-ppl-input::placeholder { color: #6b6b6b; }\n.hb-ppl-input::-webkit-search-cancel-button { display: none; }\n.hb-ppl-count { flex: none; font-size: 11px; color: #6b6b6b; font-variant-numeric: tabular-nums; }\n.hb-ppl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }\n.hb-ppl-row {\n  position: relative;\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  min-width: 0;\n  padding: 7px 8px;\n  border-radius: 10px;\n  animation: hb-ppl-in .32s cubic-bezier(.2, .8, .2, 1) both;\n  animation-delay: calc(var(--hb-ppl-i, 0) * 28ms);\n  transition: background-color .15s ease;\n}\n.hb-ppl-row:hover, .hb-ppl-row:focus-within { background: rgba(255, 255, 255, .045); }\n.hb-ppl-row[data-open=\"true\"] { background: color-mix(in srgb, var(--hb-ppl-accent) 12%, transparent); z-index: 3; }\n.hb-ppl-avatar {\n  position: relative;\n  flex: none;\n  display: grid;\n  place-items: center;\n  width: 32px;\n  height: 32px;\n  border-radius: 50%;\n  background: var(--hb-ppl-bg);\n  color: var(--hb-ppl-fg);\n  font-size: 12px;\n  font-weight: 600;\n  letter-spacing: .02em;\n}\n.hb-ppl-dot {\n  position: absolute;\n  right: -1px;\n  bottom: -1px;\n  width: 10px;\n  height: 10px;\n  border-radius: 50%;\n  border: 2px solid #111111;\n  background: #5a5a5a;\n}\n.hb-ppl-dot[data-status=\"online\"] { background: #3ecf8e; }\n.hb-ppl-dot[data-status=\"away\"] { background: #f5a524; }\n.hb-ppl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }\n.hb-ppl-name {\n  display: flex;\n  align-items: center;\n  gap: 6px;\n  min-width: 0;\n  font-weight: 500;\n  color: #ededed;\n}\n.hb-ppl-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-ppl-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #8f8f8f; }\n.hb-ppl-invited {\n  flex: none;\n  padding: 0 6px;\n  border-radius: 999px;\n  font-size: 10px;\n  font-weight: 500;\n  line-height: 16px;\n  color: #7fb3ff;\n  background: rgba(47, 123, 255, .14);\n  animation: hb-ppl-pop .3s cubic-bezier(.3, 1.4, .5, 1) both;\n}\n.hb-ppl-role {\n  flex: none;\n  padding: 2px 8px;\n  border-radius: 999px;\n  border: 1px solid #262626;\n  background: #171717;\n  font-size: 11px;\n  font-weight: 500;\n  color: #a1a1a1;\n}\n.hb-ppl-role[data-tone=\"blue\"] { color: #7fb3ff; border-color: rgba(47, 123, 255, .35); background: rgba(47, 123, 255, .1); }\n.hb-ppl-role[data-tone=\"violet\"] { color: #c4a8ff; border-color: rgba(150, 110, 255, .32); background: rgba(150, 110, 255, .1); }\n.hb-ppl-actions { position: relative; flex: none; }\n.hb-ppl-more {\n  display: grid;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  padding: 0;\n  border: 0;\n  border-radius: 8px;\n  background: none;\n  color: #8f8f8f;\n  cursor: pointer;\n  transition: background-color .15s ease, color .15s ease;\n}\n.hb-ppl-more:hover, .hb-ppl-more[aria-expanded=\"true\"] { background: rgba(255, 255, 255, .08); color: #ededed; }\n.hb-ppl-more svg { width: 16px; height: 16px; }\n.hb-ppl-menu {\n  position: absolute;\n  right: 0;\n  top: calc(100% + 4px);\n  z-index: 10;\n  min-width: 148px;\n  padding: 4px;\n  border: 1px solid #2a2a2a;\n  border-radius: 11px;\n  background: #171717;\n  box-shadow: 0 14px 34px rgba(0, 0, 0, .55);\n  transform-origin: top right;\n  animation: hb-ppl-menu .16s cubic-bezier(.2, .8, .2, 1) both;\n}\n.hb-ppl-menu[data-above=\"true\"] { top: auto; bottom: calc(100% + 4px); transform-origin: bottom right; }\n.hb-ppl-item {\n  display: flex;\n  align-items: center;\n  gap: 9px;\n  width: 100%;\n  padding: 7px 9px;\n  border: 0;\n  border-radius: 7px;\n  background: none;\n  color: #ededed;\n  font-size: 13px;\n  text-align: left;\n  cursor: pointer;\n}\n.hb-ppl-item svg { width: 14px; height: 14px; flex: none; color: #8f8f8f; }\n.hb-ppl-item:hover, .hb-ppl-item:focus-visible { outline: 0; background: rgba(255, 255, 255, .08); }\n.hb-ppl-item[data-danger=\"true\"] { color: #ff6b6b; }\n.hb-ppl-item[data-danger=\"true\"] svg { color: #ff6b6b; }\n.hb-ppl-item[data-danger=\"true\"]:hover, .hb-ppl-item[data-danger=\"true\"]:focus-visible { background: rgba(255, 90, 90, .12); }\n.hb-ppl-input:focus-visible, .hb-ppl-more:focus-visible, .hb-ppl-clear:focus-visible {\n  outline: 2px solid color-mix(in srgb, var(--hb-ppl-accent) 75%, transparent);\n  outline-offset: 1px;\n}\n.hb-ppl-input:focus-visible { outline: 0; }\n.hb-ppl-empty {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 4px;\n  padding: 22px 12px;\n  text-align: center;\n  color: #8f8f8f;\n  animation: hb-ppl-empty .4s cubic-bezier(.2, .8, .2, 1) both;\n}\n.hb-ppl-empty svg { width: 34px; height: 34px; margin-bottom: 6px; color: #3a3a3a; animation: hb-ppl-float 3s ease-in-out infinite; }\n.hb-ppl-empty strong { font-weight: 500; color: #ededed; }\n.hb-ppl-clear {\n  margin-top: 6px;\n  padding: 4px 11px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #171717;\n  color: #ededed;\n  font-size: 12px;\n  cursor: pointer;\n  transition: border-color .15s ease, background-color .15s ease;\n}\n.hb-ppl-clear:hover { border-color: #3a3a3a; background: #1f1f1f; }\n.hb-ppl-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0 0 0 0);\n  white-space: nowrap;\n}\n@container (max-width: 300px) {\n  .hb-ppl-role { display: none; }\n}\n@keyframes hb-ppl-in {\n  from { opacity: 0; transform: translateY(6px); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes hb-ppl-pop {\n  from { opacity: 0; transform: scale(.7); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes hb-ppl-menu {\n  from { opacity: 0; transform: scale(.94) translateY(-4px); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes hb-ppl-empty {\n  from { opacity: 0; transform: translateY(8px) scale(.97); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes hb-ppl-float {\n  0%, 100% { transform: translateY(0); }\n  50% { transform: translateY(-4px); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-ppl-row, .hb-ppl-invited, .hb-ppl-menu, .hb-ppl-empty, .hb-ppl-empty svg { animation: none !important; }\n  .hb-ppl-row, .hb-ppl-more, .hb-ppl-search, .hb-ppl-clear { transition: none !important; }\n}\n`;\n\nfunction hash(input: string) {\n  let h = 0;\n  for (let i = 0; i < input.length; i++) h = (Math.imul(h, 31) + input.charCodeAt(i)) >>> 0;\n  return h;\n}\n\nfunction initials(name: string) {\n  const words = name.trim().split(/\\s+/).filter(Boolean);\n  if (words.length === 0) return \"?\";\n  const first = words[0][0] ?? \"\";\n  const last = words.length > 1 ? (words[words.length - 1][0] ?? \"\") : \"\";\n  return (first + last).toUpperCase();\n}\n\nfunction roleTone(role: string) {\n  const key = role.toLowerCase();\n  if (key === \"owner\") return \"blue\";\n  if (key === \"admin\") return \"violet\";\n  return \"neutral\";\n}\n\nconst statusLabel: Record<PersonStatus, string> = {\n  online: \"Online\",\n  away: \"Away\",\n  offline: \"Offline\",\n};\n\nconst menuItems: { action: PersonAction; label: string; icon: React.ReactNode }[] = [\n  {\n    action: \"edit\",\n    label: \"Edit\",\n    icon: (\n      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n        <path d=\"M10.5 2.5l3 3L5.5 13.5l-3.5.5.5-3.5z\" />\n      </svg>\n    ),\n  },\n  {\n    action: \"invite\",\n    label: \"Invite\",\n    icon: (\n      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n        <rect x=\"1.8\" y=\"3.5\" width=\"12.4\" height=\"9\" rx=\"1.8\" />\n        <path d=\"M2.4 4.6L8 8.6l5.6-4\" />\n      </svg>\n    ),\n  },\n  {\n    action: \"remove\",\n    label: \"Remove\",\n    icon: (\n      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n        <path d=\"M2.5 4.5h11M6 4.5V3h4v1.5M4 4.5l.6 8.2a1 1 0 0 0 1 .8h4.8a1 1 0 0 0 1-.8l.6-8.2\" />\n      </svg>\n    ),\n  },\n];\n\nexport function PeopleList({\n  people = defaultPeople,\n  searchable = true,\n  placeholder = \"Search people\",\n  accent = \"#2f7bff\",\n  onAction,\n  className = \"\",\n  style,\n  ...rest\n}: PeopleListProps) {\n  const sourceKey = people.map((p) => p.id).join(\"|\");\n  const [seenKey, setSeenKey] = React.useState(sourceKey);\n  const [list, setList] = React.useState<Person[]>(people);\n  const [query, setQuery] = React.useState(\"\");\n  const [openId, setOpenId] = React.useState<string | null>(null);\n  const [above, setAbove] = React.useState(false);\n  const [invited, setInvited] = React.useState<string[]>([]);\n  const [message, setMessage] = React.useState(\"\");\n  const wrapRef = React.useRef<HTMLSpanElement | null>(null);\n  const searchRef = React.useRef<HTMLInputElement | null>(null);\n\n  if (seenKey !== sourceKey) {\n    setSeenKey(sourceKey);\n    setList(people);\n  }\n\n  React.useEffect(() => {\n    if (!openId) return;\n    const first = wrapRef.current?.querySelector<HTMLElement>('[role=\"menuitem\"]');\n    first?.focus();\n    const onDown = (event: PointerEvent) => {\n      const target = event.target as Node | null;\n      if (target && wrapRef.current && wrapRef.current.contains(target)) return;\n      setOpenId(null);\n    };\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => document.removeEventListener(\"pointerdown\", onDown);\n  }, [openId]);\n\n  const needle = query.trim().toLowerCase();\n  const visible = needle\n    ? list.filter((p) => `${p.name} ${p.email} ${p.role}`.toLowerCase().includes(needle))\n    : list;\n\n  const toggleMenu = (event: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>, id: string) => {\n    if (openId === id) {\n      setOpenId(null);\n      return;\n    }\n    const rect = event.currentTarget.getBoundingClientRect();\n    setAbove(window.innerHeight - rect.bottom < 150 && rect.top > 150);\n    setOpenId(id);\n  };\n\n  const run = (action: PersonAction, person: Person) => {\n    setOpenId(null);\n    if (action === \"remove\") {\n      setList((prev) => prev.filter((p) => p.id !== person.id));\n      setMessage(`${person.name} removed`);\n      searchRef.current?.focus();\n    } else if (action === \"invite\") {\n      setInvited((prev) => (prev.includes(person.id) ? prev : [...prev, person.id]));\n      setMessage(`Invite sent to ${person.name}`);\n    }\n    onAction?.(action, person);\n  };\n\n  const onMenuKey = (event: React.KeyboardEvent<HTMLDivElement>) => {\n    const items = Array.from(event.currentTarget.querySelectorAll<HTMLElement>('[role=\"menuitem\"]'));\n    const current = items.indexOf(document.activeElement as HTMLElement);\n    let next = -1;\n    if (event.key === \"ArrowDown\") next = (current + 1) % items.length;\n    else if (event.key === \"ArrowUp\") next = (current - 1 + items.length) % items.length;\n    else if (event.key === \"Home\") next = 0;\n    else if (event.key === \"End\") next = items.length - 1;\n    else if (event.key === \"Escape\") {\n      event.preventDefault();\n      event.stopPropagation();\n      wrapRef.current?.querySelector<HTMLElement>(\"[data-trigger]\")?.focus();\n      setOpenId(null);\n      return;\n    } else if (event.key === \"Tab\") {\n      setOpenId(null);\n      return;\n    }\n    if (next >= 0) {\n      event.preventDefault();\n      items[next]?.focus();\n    }\n  };\n\n  const vars = { \"--hb-ppl-accent\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <div className={`hb-ppl ${className}`} style={vars} {...rest}>\n      <style href=\"hb-people-list\" precedence=\"default\">{css}</style>\n      {searchable && (\n        <div className=\"hb-ppl-search\">\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" aria-hidden=\"true\">\n            <circle cx=\"7\" cy=\"7\" r=\"4.5\" />\n            <path d=\"M10.5 10.5L14 14\" />\n          </svg>\n          <input\n            ref={searchRef}\n            className=\"hb-ppl-input\"\n            type=\"search\"\n            value={query}\n            placeholder={placeholder}\n            aria-label={placeholder}\n            onChange={(event) => setQuery(event.target.value)}\n          />\n          <span className=\"hb-ppl-count\" aria-hidden=\"true\">\n            {visible.length}\n          </span>\n        </div>\n      )}\n      <span className=\"hb-ppl-sr\" role=\"status\" aria-live=\"polite\">\n        {message || `${visible.length} people`}\n      </span>\n      {visible.length > 0 ? (\n        <ul className=\"hb-ppl-list\" aria-label=\"People\">\n          {visible.map((person, i) => {\n            const hue = hash(person.name) % 360;\n            const status = person.status ?? \"offline\";\n            const open = openId === person.id;\n            const colors = {\n              \"--hb-ppl-bg\": `hsl(${hue} 42% 30%)`,\n              \"--hb-ppl-fg\": `hsl(${hue} 70% 88%)`,\n              \"--hb-ppl-i\": i,\n            } as React.CSSProperties;\n            return (\n              <li key={person.id} className=\"hb-ppl-row\" data-open={open} style={colors}>\n                <span className=\"hb-ppl-avatar\" aria-hidden=\"true\">\n                  {initials(person.name)}\n                  <span className=\"hb-ppl-dot\" data-status={status} />\n                </span>\n                <span className=\"hb-ppl-main\">\n                  <span className=\"hb-ppl-name\">\n                    <span className=\"hb-ppl-name-text\">{person.name}</span>\n                    <span className=\"hb-ppl-sr\">{`, ${statusLabel[status]}`}</span>\n                    {invited.includes(person.id) && <span className=\"hb-ppl-invited\">Invited</span>}\n                  </span>\n                  <span className=\"hb-ppl-email\">{person.email}</span>\n                </span>\n                <span className=\"hb-ppl-role\" data-tone={roleTone(person.role)}>\n                  {person.role}\n                </span>\n                <span className=\"hb-ppl-actions\" ref={open ? wrapRef : undefined}>\n                  <button\n                    type=\"button\"\n                    className=\"hb-ppl-more\"\n                    data-trigger=\"\"\n                    aria-label={`Actions for ${person.name}`}\n                    aria-haspopup=\"menu\"\n                    aria-expanded={open}\n                    onClick={(event) => toggleMenu(event, person.id)}\n                    onKeyDown={(event) => {\n                      if (event.key === \"ArrowDown\" && !open) {\n                        event.preventDefault();\n                        toggleMenu(event, person.id);\n                      }\n                    }}\n                  >\n                    <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden=\"true\">\n                      <circle cx=\"3.5\" cy=\"8\" r=\"1.25\" />\n                      <circle cx=\"8\" cy=\"8\" r=\"1.25\" />\n                      <circle cx=\"12.5\" cy=\"8\" r=\"1.25\" />\n                    </svg>\n                  </button>\n                  {open && (\n                    <div className=\"hb-ppl-menu\" role=\"menu\" aria-label={`${person.name} actions`} data-above={above} onKeyDown={onMenuKey}>\n                      {menuItems.map((item) => (\n                        <button\n                          key={item.action}\n                          type=\"button\"\n                          role=\"menuitem\"\n                          className=\"hb-ppl-item\"\n                          data-danger={item.action === \"remove\"}\n                          tabIndex={-1}\n                          onClick={() => run(item.action, person)}\n                        >\n                          {item.icon}\n                          {item.action === \"invite\" && invited.includes(person.id) ? \"Resend invite\" : item.label}\n                        </button>\n                      ))}\n                    </div>\n                  )}\n                </span>\n              </li>\n            );\n          })}\n        </ul>\n      ) : (\n        <div className=\"hb-ppl-empty\">\n          <svg viewBox=\"0 0 32 32\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" aria-hidden=\"true\">\n            <circle cx=\"14\" cy=\"14\" r=\"8\" />\n            <path d=\"M20 20l7 7M10.5 14h7\" />\n          </svg>\n          {needle ? (\n            <>\n              <strong>No one found</strong>\n              <span>{`Nothing matches \"${query.trim()}\"`}</span>\n              <button type=\"button\" className=\"hb-ppl-clear\" onClick={() => setQuery(\"\")}>\n                Clear search\n              </button>\n            </>\n          ) : (\n            <>\n              <strong>No people yet</strong>\n              <span>Invite teammates to see them here.</span>\n            </>\n          )}\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}