{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-team-pending",
  "type": "registry:block",
  "title": "App, pending invites",
  "description": "Invites not yet accepted: address, role and when it was sent, with Resend and Revoke that name their invite. Revoke asks first and keeps focus in the list; both actions are shown and announced with the address; the count follows; empty state.",
  "categories": [
    "app"
  ],
  "dependencies": [
    "lucide-react@^1.49.0",
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/badge.json",
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/empty-state.json",
    "https://ui.klarhimmel.com/r/kit-app.json"
  ],
  "files": [
    {
      "path": "src/blocks/app-team-pending/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-team-pending/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, t, req } from '../_shared/schema';\n\nconst schema = z.object({\n  eyebrow: t(60).optional(),\n  title: t(120),\n  description: t(300).optional(),\n  invites: z.array(z.object({ email: t(60), role: t(20), sent: t(30) })).min(1).max(6),\n  actions: z.object({ resend: req(20), revoke: req(20), question: req(40), yes: req(24), no: req(24) }),\n  /** Said after an action, followed by the address: \"Invite sent again to sofia@...\". Shown and announced. */\n  notices: z.object({ resent: t(40), revoked: t(40) }),\n  /** Follows the number of invites: \"3 pending\". */\n  countWord: t(20),\n  state: z.enum(['filled', 'empty']),\n  messages: z.object({ emptyTitle: req(80), emptyBody: t(160) }),\n});\n\nexport const spec = defineSpec({\n  type: 'app-team-pending',\n  aliases: ['app/team-pending'],\n  name: 'App, pending invites',\n  category: 'app',\n  role: 'body',\n  description: 'Invites not yet accepted: address, role and when it was sent, with Resend and Revoke that name their invite. Revoke asks first and keeps focus in the list; both actions are shown and announced with the address; the count follows; empty state.',\n  schema,\n  defaults: {\n    \"eyebrow\": \"Team\",\n    \"title\": \"Pending invites\",\n    \"description\": \"Say who is on this list and why.\",\n    \"invites\": [\n      {\n        \"email\": \"first@example.com\",\n        \"role\": \"Member\",\n        \"sent\": \"Sent 0 days ago\"\n      },\n      {\n        \"email\": \"second@example.com\",\n        \"role\": \"Viewer\",\n        \"sent\": \"Sent 0 days ago\"\n      },\n      {\n        \"email\": \"third@example.com\",\n        \"role\": \"Admin\",\n        \"sent\": \"Sent just now\"\n      }\n    ],\n    \"actions\": {\n      \"resend\": \"Resend\",\n      \"revoke\": \"Revoke\",\n      \"question\": \"Revoke the invite to\",\n      \"yes\": \"Yes, revoke\",\n      \"no\": \"Keep\"\n    },\n    \"notices\": {\n      \"resent\": \"Say it was sent again to\",\n      \"revoked\": \"Say it was cancelled for\"\n    },\n    \"countWord\": \"pending\",\n    \"state\": \"filled\",\n    \"messages\": {\n      \"emptyTitle\": \"Say none are waiting\",\n      \"emptyBody\": \"Say what makes an invite appear here and for how long.\"\n    }\n  },\n});\n"
    },
    {
      "path": "src/blocks/app-team-pending/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-team-pending/index.tsx",
      "content": "import { useEffect, useId, useRef } from 'react';\nimport { MailCheck } from 'lucide-react';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Badge } from '../../ui/badge';\nimport { Button } from '../../ui/button';\nimport { EmptyState } from '../../ui/empty-state';\nimport { Container, Section, SectionHeader } from '../_shared/kit';\nimport { AppPanel, StateSlot, useSynced } from '../_shared/app-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\nfunction AppTeamPending({ props }: BlockProps<Props>) {\n  const id = useId();\n  const [gone, setGone] = useSynced<number[]>([], props.invites);\n  const [asking, setAsking] = useSynced<number | null>(null, props.invites);\n  const [notice, setNotice] = useSynced<{ text: string; n: number }>({ text: '', n: 0 }, props.invites);\n  const left = props.invites.map((v, i) => ({ v, i })).filter(({ i }) => !gone.includes(i));\n  const refs = useRef<{ revoke: Record<number, HTMLButtonElement | null>; keep: Record<number, HTMLButtonElement | null> }>({ revoke: {}, keep: {} });\n  const heading = useRef<HTMLParagraphElement>(null);\n  const next = useRef<{ kind: 'keep' | 'revoke' | 'after'; i: number } | null>(null);\n  useEffect(() => {\n    const n = next.current;\n    next.current = null;\n    if (!n) return;\n    if (n.kind === 'keep') refs.current.keep[n.i]?.focus();\n    else if (n.kind === 'revoke') refs.current.revoke[n.i]?.focus();\n    else {\n      const rest = props.invites.map((_, k) => k).filter((k) => !gone.includes(k));\n      const target = rest.find((k) => k > n.i && refs.current.revoke[k]) ?? [...rest].reverse().find((k) => k < n.i && refs.current.revoke[k]);\n      (target !== undefined ? refs.current.revoke[target] : heading.current)?.focus();\n    }\n  }, [asking, gone, props.invites]);\n  const say = (text: string) => setNotice((x) => ({ text, n: x.n + 1 }));\n  return (\n    <Section labelledBy={id}>\n      <Container width=\"narrow\">\n        <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        <AppPanel className=\"mt-10\">\n          <div className=\"border-b border-kh-line px-6 py-3 text-kh-small text-kh-muted @xl:px-8\">\n            <p ref={heading} tabIndex={-1} className=\"tabular-nums outline-none\">\n              {left.length} <Text path={['countWord']} value={props.countWord} as=\"span\" />\n            </p>\n            <p role=\"status\" key={notice.n} className=\"min-h-5 text-kh-ink\">\n              {notice.text}\n            </p>\n          </div>\n          <StateSlot show={false}>\n            <Text path={['notices', 'resent']} value={props.notices.resent} as=\"p\" />\n            <Text path={['notices', 'revoked']} value={props.notices.revoked} as=\"p\" />\n          </StateSlot>\n          <StateSlot show={props.state === 'filled' && left.length > 0}>\n            <ul className=\"divide-y divide-kh-line\">\n              {left.map(({ v, i }) => (\n                <li key={i} className=\"flex flex-col gap-3 px-6 py-4 @xl:px-8\">\n                  <div className=\"flex flex-col gap-3 @xl:flex-row @xl:items-center @xl:gap-4\">\n                    <div className=\"min-w-0 flex-1\">\n                      <Text path={['invites', i, 'email']} value={v.email} as=\"p\" className=\"truncate text-kh-body font-medium\" />\n                      <p className=\"flex flex-wrap items-center gap-2 text-kh-small text-kh-muted\">\n                        <Badge tone=\"outline\">\n                          <Text path={['invites', i, 'role']} value={v.role} as=\"span\" />\n                        </Badge>\n                        <Text path={['invites', i, 'sent']} value={v.sent} as=\"span\" />\n                      </p>\n                    </div>\n                    <div className=\"flex flex-wrap gap-2\">\n                      <Button variant=\"secondary\" onClick={() => say(`${props.notices.resent} ${v.email}`)}>\n                        <Text path={['actions', 'resend']} value={props.actions.resend} as=\"span\" /> <span className=\"sr-only\">{v.email}</span>\n                      </Button>\n                      <Button\n                        variant=\"ghost\"\n                        aria-expanded={asking === i}\n                        ref={(el) => {\n                          refs.current.revoke[i] = el;\n                        }}\n                        onClick={() => {\n                          next.current = { kind: 'keep', i };\n                          setAsking(asking === i ? null : i);\n                        }}\n                      >\n                        <Text path={['actions', 'revoke']} value={props.actions.revoke} as=\"span\" /> <span className=\"sr-only\">{v.email}</span>\n                      </Button>\n                    </div>\n                  </div>\n                  <div\n                    role=\"group\"\n                    aria-label={`${props.actions.question} ${v.email}`}\n                    hidden={asking !== i}\n                    onKeyDown={(e) => {\n                      if (e.key !== 'Escape') return;\n                      next.current = { kind: 'revoke', i };\n                      setAsking(null);\n                    }}\n                    className=\"flex flex-wrap items-center gap-3 rounded-kh-lg border border-kh-line bg-kh-surface-2 p-3\"\n                  >\n                    <p className=\"text-kh-small\">\n                      <Text path={['actions', 'question']} value={props.actions.question} as=\"span\" /> <strong>{v.email}</strong>\n                    </p>\n                    <div className=\"flex flex-wrap gap-2\">\n                      <Button\n                        variant=\"secondary\"\n                        ref={(el) => {\n                          refs.current.keep[i] = el;\n                        }}\n                        onClick={() => {\n                          next.current = { kind: 'revoke', i };\n                          setAsking(null);\n                        }}\n                      >\n                        <Text path={['actions', 'no']} value={props.actions.no} as=\"span\" />\n                      </Button>\n                      <Button\n                        onClick={() => {\n                          next.current = { kind: 'after', i };\n                          setAsking(null);\n                          setGone((g) => [...g, i]);\n                          say(`${props.notices.revoked} ${v.email}`);\n                        }}\n                      >\n                        <Text path={['actions', 'yes']} value={props.actions.yes} as=\"span\" />\n                      </Button>\n                    </div>\n                  </div>\n                </li>\n              ))}\n            </ul>\n          </StateSlot>\n          <StateSlot show={props.state === 'empty' || left.length === 0}>\n            <EmptyState icon={<MailCheck />} title={<Text path={['messages', 'emptyTitle']} value={props.messages.emptyTitle} as=\"span\" />} level={3}>\n              <Text path={['messages', 'emptyBody']} value={props.messages.emptyBody} as=\"span\" />\n            </EmptyState>\n          </StateSlot>\n        </AppPanel>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(AppTeamPending);\n"
    }
  ]
}
