{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "avatar-select",
  "title": "Avatar Select",
  "description": "A ready-to-ship person selector with Blobz avatars in the trigger and option list.",
  "dependencies": ["cn", "lucide-react"],
  "registryDependencies": ["select", "@blobz/avatar", "@blobz/avatar-profile"],
  "files": [
    {
      "path": "apps/web/src/registry/blobz/blocks/avatar-select.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"cn\";\nimport { useMemo } from \"react\";\nimport {\n\tAvatar,\n\tAvatarFallback,\n\tAvatarImage,\n\ttype AvatarSource,\n} from \"@/components/ui/avatar\";\nimport {\n\tSelect,\n\tSelectContent,\n\tSelectGroup,\n\tSelectItem,\n\tSelectTrigger,\n\tSelectValue,\n} from \"@/components/ui/select\";\nimport {\n\tAvatarProfile,\n\tAvatarProfileContent,\n\tAvatarProfileDescription,\n\tAvatarProfileName,\n} from \"@/registry/blobz/components/avatar-profile\";\nexport interface AvatarSelectOption {\n\treadonly avatar: AvatarSource;\n\treadonly description?: string;\n\treadonly id: string;\n\treadonly name: string;\n}\n\nexport interface AvatarSelectProps {\n\treadonly className?: string;\n\treadonly contentClassName?: string;\n\treadonly defaultValue?: string;\n\treadonly disabled?: boolean;\n\treadonly items: readonly AvatarSelectOption[];\n\treadonly name?: string;\n\treadonly onValueChange?: (value: string | null) => void;\n\treadonly placeholder?: string;\n\treadonly triggerLabel?: string;\n\treadonly value?: string | null;\n}\n\nfunction AvatarSelectIdentity({\n\toption,\n}: {\n\treadonly option: AvatarSelectOption;\n}) {\n\treturn (\n\t\t<AvatarProfile className=\"p-0\" density=\"compact\">\n\t\t\t<Avatar frame={option.avatar.frame}>\n\t\t\t\t<AvatarImage alt=\"\" src={option.avatar.src} />\n\t\t\t\t<AvatarFallback\n\t\t\t\t\talt=\"\"\n\t\t\t\t\tchoices={option.avatar.choices}\n\t\t\t\t\tname={option.avatar.name}\n\t\t\t\t\tpalette={option.avatar.palette}\n\t\t\t\t/>\n\t\t\t</Avatar>\n\t\t\t<AvatarProfileContent>\n\t\t\t\t<AvatarProfileName>{option.name}</AvatarProfileName>\n\t\t\t\t{option.description ? (\n\t\t\t\t\t<AvatarProfileDescription>\n\t\t\t\t\t\t{option.description}\n\t\t\t\t\t</AvatarProfileDescription>\n\t\t\t\t) : null}\n\t\t\t</AvatarProfileContent>\n\t\t</AvatarProfile>\n\t);\n}\n\nexport function AvatarSelect({\n\tclassName,\n\tcontentClassName,\n\tdefaultValue,\n\tdisabled,\n\titems,\n\tname,\n\tonValueChange,\n\tplaceholder = \"Select a person\",\n\ttriggerLabel = \"Select a person\",\n\tvalue,\n}: AvatarSelectProps) {\n\tconst itemById = useMemo(\n\t\t() => new Map(items.map((item) => [item.id, item])),\n\t\t[items]\n\t);\n\tconst selectItems = useMemo(\n\t\t() => items.map((item) => ({ label: item.name, value: item.id })),\n\t\t[items]\n\t);\n\n\treturn (\n\t\t<Select\n\t\t\tdefaultValue={defaultValue ?? items.at(0)?.id}\n\t\t\tdisabled={disabled}\n\t\t\titems={selectItems}\n\t\t\tname={name}\n\t\t\tonValueChange={onValueChange}\n\t\t\tvalue={value}\n\t\t>\n\t\t\t<SelectTrigger\n\t\t\t\taria-label={triggerLabel}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"w-full min-w-0 rounded-xl border-border bg-card px-3 shadow-xs data-[size=default]:h-16\",\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t<SelectValue>\n\t\t\t\t\t{(selectedValue: string | null) => {\n\t\t\t\t\t\tconst option = selectedValue\n\t\t\t\t\t\t\t? itemById.get(selectedValue)\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\treturn option ? (\n\t\t\t\t\t\t\t<AvatarSelectIdentity option={option} />\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tplaceholder\n\t\t\t\t\t\t);\n\t\t\t\t\t}}\n\t\t\t\t</SelectValue>\n\t\t\t</SelectTrigger>\n\t\t\t<SelectContent alignItemWithTrigger={false} className={contentClassName}>\n\t\t\t\t<SelectGroup>\n\t\t\t\t\t{items.map((option) => (\n\t\t\t\t\t\t<SelectItem key={option.id} value={option.id}>\n\t\t\t\t\t\t\t<AvatarSelectIdentity option={option} />\n\t\t\t\t\t\t</SelectItem>\n\t\t\t\t\t))}\n\t\t\t\t</SelectGroup>\n\t\t\t</SelectContent>\n\t\t</Select>\n\t);\n}\n",
      "type": "registry:component",
      "target": "@components/blobz/avatar-select.tsx"
    }
  ],
  "type": "registry:block"
}
