{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "badge-indicator",
  "type": "registry:ui",
  "title": "<ui-badge-indicator>",
  "description": "Carbon `BadgeIndicator` (`cds-badge-indicator`): a support-error badge in the top-end corner of a ghost `<ui-icon-button>` — an 8px dot 8px in, or with `count` a 16px pill (helper-text-01) 4px in, \"999+\" past 999 (4px in on a small button either way). Put it inside the icon button (it takes the `badge-indicator` slot); the button reads the count to screen readers as its description, and hides the badge while disabled. `<ui-icon-button badge-count>` makes one for you. 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-badge-indicator",
    "@kanok-ui/shared-element",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/badge-indicator/badge-indicator.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/badge-indicator/badge-indicator.ts",
      "content": "import { html, css, type PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { badgeText } from '../../core/badge-indicator.ts';\nimport { UiElement } from '../shared/element.ts';\n\n/**\n * Carbon `BadgeIndicator` (`cds-badge-indicator`): a support-error badge in the top-end corner of a ghost\n * `<ui-icon-button>` — an 8px dot 8px in, or with `count` a 16px pill (helper-text-01) 4px in, \"999+\" past 999 (4px in\n * on a small button either way). Put it inside the icon button (it takes the `badge-indicator` slot); the button\n * reads the count to screen readers as its description, and hides the badge while disabled. `<ui-icon-button\n * badge-count>` makes one for you.\n */\n@customElement('ui-badge-indicator')\nexport class UiBadgeIndicator extends UiElement {\n    static override readonly styles = css`\n        :host {\n            position: absolute;\n            inset-block-start: 0;\n            inset-inline-end: 0;\n            display: flex;\n            box-sizing: border-box;\n            min-inline-size: 8px;\n            min-block-size: 8px;\n            max-block-size: 16px;\n            margin-block-start: var(--_ui-badge-dot-offset, 8px);\n            margin-inline-end: var(--_ui-badge-dot-offset, 8px);\n            padding: 0 var(--ui-space-xxs) 2px;\n            border-radius: 100px;\n            background: var(--ui-error);\n            color: var(--ui-on-primary);\n            font: var(--ui-font-caption);\n            letter-spacing: var(--ui-tracking-caption);\n            pointer-events: none;\n        }\n\n        :host([data-count]) {\n            margin-block-start: var(--ui-space-xxs);\n            margin-inline-end: var(--ui-space-xxs);\n        }\n\n        @media (forced-colors: active) {\n            :host {\n                border: 1px solid CanvasText;\n            }\n        }\n    `;\n\n    /** The number shown; unset or 0 = a dot. */\n    @property({ type: Number }) count?: number;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.slot = 'badge-indicator';\n        // the icon button reads the count as its description; hidden here, so its visible content stays its name (WCAG 2.5.3)\n        this.setAttribute('aria-hidden', 'true');\n    }\n\n    protected override updated(changed: PropertyValues<this>) {\n        super.updated(changed);\n        this.toggleAttribute('data-count', badgeText(this.count) !== '');\n        // the icon button around reads the count as its description\n        if (changed.has('count')) this.closest('ui-icon-button')?.requestUpdate();\n    }\n\n    override render() {\n        return html`${badgeText(this.count)}`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-badge-indicator': UiBadgeIndicator;\n    }\n}\n"
    }
  ]
}
