{"version":3,"file":"AvatarGroup.cjs","names":[],"sources":["../../../src/components/AvatarGroup/AvatarGroup.tsx"],"sourcesContent":["import { cn } from \"@/utils/cn\";\nimport { Avatar } from \"../Avatar\";\nimport type { AvatarSize } from \"../Avatar\";\nimport styles from \"./AvatarGroup.module.css\";\n\n/** One participant of the group. */\nexport interface AvatarGroupItem {\n    /** Image URL. Falls back to initials from `name`. */\n    src?: string;\n    /** Full name — drives the initials and the accessible label. */\n    name: string;\n}\n\nexport interface AvatarGroupProps {\n    items: AvatarGroupItem[];\n    /** How many avatars to show before collapsing into `+N`. Default `4`. */\n    max?: number;\n    size?: AvatarSize;\n    /** Accessible name of the group, e.g. `\"Participantes\"`. */\n    label?: string;\n    /**\n     * Called when the `+N` chip is activated — a natural hook for \"see all\n     * participants\". Without it the chip is plain text and not focusable.\n     */\n    onOverflowClick?: () => void;\n    className?: string;\n}\n\n/**\n * Overlapping row of avatars with a `+N` overflow chip — participants of a\n * meeting, assignees of a task, members of a team.\n *\n * The whole row is one `role=\"group\"` with a single accessible name, and each\n * avatar's name is exposed as its label. That is deliberate: announcing seven\n * separate images with no relation between them is noise, and the overflow chip\n * carries the remaining count so the total is never hidden from a screen reader.\n *\n * @example\n * ```tsx\n * <AvatarGroup\n *   label=\"Participantes\"\n *   max={3}\n *   items={[\n *     { name: \"Ada Lovelace\", src: ada },\n *     { name: \"Grace Hopper\" },\n *     { name: \"Alan Turing\" },\n *     { name: \"Edsger Dijkstra\" },\n *   ]}\n *   onOverflowClick={() => setDrawerOpen(true)}\n * />\n * ```\n */\nexport function AvatarGroup({\n    items,\n    max = 4,\n    size = \"md\",\n    label,\n    onOverflowClick,\n    className,\n}: AvatarGroupProps) {\n    const limit = Math.max(0, max);\n    const visible = items.slice(0, limit);\n    const overflow = items.length - visible.length;\n\n    return (\n        <div role=\"group\" aria-label={label} className={cn(styles.group, styles[size], className)}>\n            {visible.map((item, index) => (\n                <span key={`${item.name}-${index}`} className={styles.slot}>\n                    <Avatar src={item.src} name={item.name} alt={item.name} size={size} />\n                </span>\n            ))}\n\n            {overflow > 0 ? (\n                <span className={styles.slot}>\n                    {onOverflowClick ? (\n                        <button\n                            type=\"button\"\n                            className={cn(styles.overflow, styles.overflowButton)}\n                            aria-label={`${overflow} more`}\n                            onClick={onOverflowClick}\n                        >\n                            +{overflow}\n                        </button>\n                    ) : (\n                        <span className={styles.overflow} aria-label={`${overflow} more`}>\n                            +{overflow}\n                        </span>\n                    )}\n                </span>\n            ) : null}\n        </div>\n    );\n}\n"],"mappings":"iJAoDA,SAAgB,EAAY,CACxB,QACA,MAAM,EACN,OAAO,KACP,QACA,kBACA,aACiB,CACjB,IAAM,EAAQ,KAAK,IAAI,EAAG,CAAG,EACvB,EAAU,EAAM,MAAM,EAAG,CAAK,EAC9B,EAAW,EAAM,OAAS,EAAQ,OAExC,OACI,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,KAAK,QAAQ,aAAY,EAAO,UAAW,EAAA,GAAG,EAAA,QAAO,MAAO,EAAA,QAAO,GAAO,CAAS,EAAxF,SAAA,CACK,EAAQ,KAAK,EAAM,KAChB,EAAA,EAAA,IAAA,CAAC,OAAD,CAAoC,UAAW,EAAA,QAAO,KAClD,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAQ,IAAK,EAAK,IAAK,KAAM,EAAK,KAAM,IAAK,EAAK,KAAY,MAAO,CAAA,CACnE,EAFK,GAAG,EAAK,KAAK,GAAG,GAErB,CACT,EAEA,EAAW,GACR,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,KACnB,SAAA,GACG,EAAA,EAAA,KAAA,CAAC,SAAD,CACI,KAAK,SACL,UAAW,EAAA,GAAG,EAAA,QAAO,SAAU,EAAA,QAAO,cAAc,EACpD,aAAY,GAAG,EAAS,OACxB,QAAS,EAJb,SAAA,CAKC,IACK,CACE,CAER,CAAA,GAAA,EAAA,EAAA,KAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,SAAU,aAAY,GAAG,EAAS,OAA1D,SAAA,CAAkE,IAC5D,CACA,GAER,CAAA,EACN,IACH,GAEb"}