{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "user-avatar",
  "type": "registry:ui",
  "title": "<ui-user-avatar>",
  "description": "Carbon for IBM Products `UserAvatar` (`c4p-user-avatar`): a round avatar of a person — their photo (`image`), a custom icon (`slot=\"icon\"`), their initials from `name` (\"thomas j. watson\" → \"TW\"), or the user icon, in that order. Sizes sm 24px (label-01), md 32px (body-compact-01), lg 48px (heading-03), xl 64px (heading-04); text-inverse on one of Carbon's 12 avatar colours (`background-color` `order-1-cyan` … `order-12-teal`, a lighter grade on g90 / g100). With `tooltip-text` the avatar becomes a button named by that text, which shows it in a tooltip (`tooltip-alignment`, default bottom) and takes a 2px focus ring. Start the text with the initials (\"TW, Thomas J. Watson\", as Carbon's story) so the name holds what is seen (WCAG 2.5.3). Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [
    "lit@^3.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/core-position",
    "@kanok-ui/core-user-avatar",
    "@kanok-ui/shared-element",
    "@kanok-ui/tooltip",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/user-avatar/user-avatar.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/user-avatar/user-avatar.ts",
      "content": "import { html, css, svg } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { avatarColorToken, avatarInitials, USER_AVATAR_ICON_SIZE, USER_AVATAR_PX, type UserAvatarColor, type UserAvatarSize } from '../../core/user-avatar.ts';\nimport type { Placement } from '../../core/position.ts';\nimport { UiElement } from '../shared/element.ts';\nimport '../tooltip/tooltip.ts';\n\n// Carbon `user` icon: its own 16px drawing, the 32px one scaled for 20 / 24 / 32\nconst userIcon16 = svg`<path d=\"M8,2c1.4,0,2.5,1.1,2.5,2.5S9.4,7,8,7S5.5,5.9,5.5,4.5S6.6,2,8,2 M8,1C6.1,1,4.5,2.6,4.5,4.5S6.1,8,8,8s3.5-1.6,3.5-3.5S9.9,1,8,1z\" /><path d=\"M13,15h-1v-2.5c0-1.4-1.1-2.5-2.5-2.5h-3C5.1,10,4,11.1,4,12.5V15H3v-2.5C3,10.6,4.6,9,6.5,9h3c1.9,0,3.5,1.6,3.5,3.5V15z\" />`;\nconst userIcon32 = svg`<path d=\"M16,4a5,5,0,1,1-5,5,5,5,0,0,1,5-5m0-2a7,7,0,1,0,7,7A7,7,0,0,0,16,2Z\" /><path d=\"M26,30H24V25a5,5,0,0,0-5-5H13a5,5,0,0,0-5,5v5H6V25a7,7,0,0,1,7-7h6a7,7,0,0,1,7,7Z\" />`;\n\n/**\n * Carbon for IBM Products `UserAvatar` (`c4p-user-avatar`): a round avatar of a person — their photo (`image`), a\n * custom icon (`slot=\"icon\"`), their initials from `name` (\"thomas j. watson\" → \"TW\"), or the user icon, in that\n * order. Sizes sm 24px (label-01), md 32px (body-compact-01), lg 48px (heading-03), xl 64px (heading-04); text-inverse\n * on one of Carbon's 12 avatar colours (`background-color` `order-1-cyan` … `order-12-teal`, a lighter grade on g90 /\n * g100). With `tooltip-text` the avatar becomes a button named by that text, which shows it in a tooltip\n * (`tooltip-alignment`, default bottom) and takes a 2px focus ring. Start the text with the initials (\"TW, Thomas J.\n * Watson\", as Carbon's story) so the name holds what is seen (WCAG 2.5.3).\n *\n * @slot icon - A custom icon in place of the initials / user icon (sized 16 / 20 / 24 / 32px)\n * @csspart avatar - The circle\n * @csspart image - The photo\n * @csspart trigger - The button around the avatar when it has a tooltip\n */\n@customElement('ui-user-avatar')\nexport class UiUserAvatar extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: inline-block;\n            vertical-align: middle;\n        }\n\n        .avatar {\n            position: relative;\n            display: flex;\n            box-sizing: border-box;\n            align-items: center;\n            justify-content: center;\n            inline-size: var(--_size);\n            block-size: var(--_size);\n            border: 0.5px solid transparent;\n            border-radius: 100%;\n            background-color: var(--_bg);\n            color: var(--ui-inverse-ink);\n            font: var(--ui-font-body-sm);\n            letter-spacing: var(--ui-tracking-body);\n            outline-offset: 3px;\n        }\n\n        :host([size='sm']) .avatar {\n            font: var(--ui-font-caption);\n            letter-spacing: var(--ui-tracking-caption);\n        }\n\n        :host([size='lg']) .avatar {\n            font: var(--ui-font-heading-03);\n            letter-spacing: normal;\n        }\n\n        :host([size='xl']) .avatar {\n            font: var(--ui-font-heading-04);\n            letter-spacing: normal;\n        }\n\n        svg,\n        ::slotted([slot='icon']) {\n            flex: none;\n            inline-size: var(--_icon);\n            block-size: var(--_icon);\n            color: var(--ui-icon-inverse);\n            fill: currentColor;\n        }\n\n        img {\n            flex: none;\n            inline-size: var(--_size);\n            block-size: var(--_size);\n            border-radius: 100%;\n            object-fit: fill;\n        }\n\n        .trigger {\n            display: flex;\n            padding: 0;\n            border: 0;\n            background: none;\n            color: inherit;\n            cursor: default;\n            font: inherit;\n            letter-spacing: inherit;\n            outline: none;\n        }\n\n        .trigger:focus-visible .avatar {\n            outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n            outline-offset: 1px;\n        }\n\n        @media (forced-colors: active) {\n            .avatar {\n                border-color: CanvasText;\n            }\n        }\n    `;\n\n    /** The person's name or initials; the avatar shows the initials. */\n    @property() name = '';\n\n    /** A photo's URL, shown instead of the initials. */\n    @property() image = '';\n\n    /** The photo's alt text. */\n    @property({ attribute: 'image-description' }) imageDescription = '';\n\n    @property({ reflect: true }) size: UserAvatarSize = 'md';\n\n    /** One of Carbon's 12 avatar colours, `order-1-cyan` … `order-12-teal`. */\n    @property({ attribute: 'background-color' }) backgroundColor: UserAvatarColor = 'order-1-cyan';\n\n    /** Shown in a tooltip and names the avatar, which becomes a button (e.g. \"Thomas J. Watson\"). */\n    @property({ attribute: 'tooltip-text' }) tooltipText = '';\n\n    @property({ attribute: 'tooltip-alignment' }) tooltipAlignment: Placement = 'bottom';\n\n    private renderContent() {\n        if (this.image) return html`<img part=\"image\" src=${this.image} alt=${this.imageDescription} />`;\n        const px = USER_AVATAR_ICON_SIZE[this.size] ?? 20;\n        const icon =\n            px === 16\n                ? html`<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\">${userIcon16}</svg>`\n                : html`<svg viewBox=\"0 0 32 32\" aria-hidden=\"true\">${userIcon32}</svg>`;\n        return html`<slot name=\"icon\">${this.name ? avatarInitials(this.name) : icon}</slot>`;\n    }\n\n    override render() {\n        const px = USER_AVATAR_ICON_SIZE[this.size] ?? 20;\n        const size = USER_AVATAR_PX[this.size] ?? 32;\n        const vars = { '--_size': `${size}px`, '--_icon': `${px}px`, '--_bg': `var(${avatarColorToken(this.backgroundColor)})` };\n        const avatar = html`<div class=\"avatar\" part=\"avatar\" style=${styleMap(vars)}>${this.renderContent()}</div>`;\n        if (!this.tooltipText) return avatar;\n        return html`<ui-tooltip text=${this.tooltipText} as-label placement=${this.tooltipAlignment}><button type=\"button\" class=\"trigger\" part=\"trigger\">${avatar}</button></ui-tooltip>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-user-avatar': UiUserAvatar;\n    }\n}\n"
    }
  ]
}
