{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "link",
  "type": "registry:ui",
  "title": "<ui-link>",
  "description": "Carbon-style link (`Link`): `--ui-link` text, underline on hover, Carbon focus ring, sizes sm (helper-text-01) / md (body-compact-01) / lg (body-compact-02), `inline` (always underlined, for links inside running text), `visited` styling opt-in and a `disabled` state that renders plain text with `aria-disabled`. 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/shared-element",
    "@kanok-ui/shared-navigate",
    "@kanok-ui/shared-slots",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/link/link.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/link/link.ts",
      "content": "import { LitElement, html, css, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport { followLink } from '../shared/navigate.ts';\nimport { SlotController } from '../shared/slots.ts';\n\nexport type LinkSize = 'sm' | 'md' | 'lg';\n\n/**\n * Carbon-style link (`Link`): `--ui-link` text, underline on hover, Carbon focus ring, sizes\n * sm (helper-text-01) / md (body-compact-01) / lg (body-compact-02), `inline` (always underlined,\n * for links inside running text), `visited` styling opt-in and a `disabled` state that renders\n * plain text with `aria-disabled`.\n *\n * @slot - Link text\n * @slot icon - A 16px (lg: 20px) icon after the text (Carbon `renderIcon`; not shown when `inline`)\n * @csspart base - The anchor\n * @csspart icon - The icon wrapper\n * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router)\n * @cssprop --ui-link-focus-radius - Corners of the focus ring (default 0; Kanok: 4px)\n */\n@customElement('ui-link')\nexport class UiLink extends UiElement {\n    /** `el.focus()` lands on the control inside. */\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            display: inline;\n            font-family: var(--ui-font-family);\n        }\n\n        a,\n        .disabled {\n            display: inline-flex;\n            align-items: center;\n            color: var(--ui-link);\n            font: var(--ui-font-body-sm);\n            letter-spacing: var(--ui-tracking-body);\n            text-decoration: none;\n            outline: var(--ui-focus-width, 2px) solid transparent;\n            outline-offset: 1px;\n            border-radius: var(--ui-link-focus-radius, 0); /* the ring's corners (Carbon: square; Kanok rounds them) */\n            transition: color var(--ui-duration-fast) var(--ui-easing);\n        }\n\n        :host([size='sm']) a,\n        :host([size='sm']) .disabled {\n            font: var(--ui-font-caption);\n            letter-spacing: var(--ui-tracking-caption);\n        }\n\n        :host([size='lg']) a,\n        :host([size='lg']) .disabled {\n            font: var(--ui-font-body);\n            line-height: 22px; /* body-compact-02 */\n        }\n\n        a:hover {\n            color: var(--ui-link-hover);\n            text-decoration: underline;\n        }\n\n        a:focus-visible {\n            outline-color: var(--ui-focus);\n            text-decoration: underline;\n        }\n\n        a:active,\n        a:active:visited {\n            color: var(--ui-link);\n            text-decoration: underline;\n        }\n\n        :host([visited]) a:visited {\n            color: var(--ui-link-visited);\n        }\n\n        :host([visited]) a:visited:hover {\n            color: var(--ui-link-hover);\n        }\n\n        :host([inline]) a,\n        :host([inline]) .disabled {\n            display: inline;\n            text-decoration: underline;\n        }\n\n        .disabled {\n            color: var(--ui-ink-disabled);\n            cursor: not-allowed;\n        }\n\n        .icon {\n            display: inline-flex;\n            align-items: center;\n            margin-inline-start: var(--ui-space-xs);\n        }\n\n        ::slotted([slot='icon']) {\n            width: 16px;\n            height: 16px;\n            fill: currentColor;\n        }\n\n        :host([size='lg']) ::slotted([slot='icon']) {\n            width: 20px;\n            height: 20px;\n        }\n\n        :host([inline]) .icon {\n            display: none;\n        }\n\n        @media (forced-colors: active) {\n            a {\n                color: LinkText;\n            }\n\n            a:focus-visible {\n                outline: 2px solid Highlight;\n            }\n\n            .disabled {\n                color: GrayText;\n            }\n        }\n\n    `;\n\n    @property() href = '';\n    @property() target = '';\n    @property() rel = '';\n    @property() download = '';\n    @property({ reflect: true }) size: LinkSize = 'md';\n    /** Underlined at rest, for links inside a sentence. */\n    @property({ type: Boolean, reflect: true }) inline = false;\n    /** Opt into Carbon's visited colour (browser `:visited`). */\n    @property({ type: Boolean, reflect: true }) visited = false;\n    /** Renders as inert text with `aria-disabled`. */\n    @property({ type: Boolean, reflect: true }) disabled = false;\n\n    private readonly slots = new SlotController(this);\n\n    override render() {\n        // only with an icon: an empty .icon would still add its 8px margin after the text (Carbon renders none)\n        const icon = this.slots.has('icon') ? html`<span class=\"icon\" part=\"icon\"><slot name=\"icon\"></slot></span>` : nothing;\n        if (this.disabled) {\n            return html`<span class=\"disabled\" part=\"base\" role=\"link\" aria-disabled=\"true\"><slot></slot>${icon}</span>`;\n        }\n        const external = this.target === '_blank';\n        // tabindex=\"0\" as Carbon's cds-link: without it Safari neither focuses the link on click nor stops on it with Tab\n        return html`<a\n            part=\"base\"\n            href=${this.href || nothing}\n            target=${this.target || nothing}\n            rel=${this.rel || (external ? 'noopener noreferrer' : nothing)}\n            download=${this.download || nothing}\n            tabindex=${this.href ? '0' : nothing}\n            @click=${followLink}\n        >\n            <slot></slot>${icon}\n        </a>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-link': UiLink;\n    }\n}\n"
    }
  ]
}
