{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "heading",
  "type": "registry:ui",
  "title": "<ui-heading>",
  "description": "Carbon `Heading` (`cds-heading`): an `<h1>`…`<h6>` at the level of the `<ui-section>` it sits in (`<h1>` outside any), in Carbon's productive type for that level — h1 heading-06 (42px light) down to h6 heading-01 (14px semibold), no margins. 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/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/heading/heading-shared.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/heading/heading-shared.ts",
      "content": "\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n"
    },
    {
      "path": "src/primitives/heading/heading.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/heading/heading.ts",
      "content": "// Its child elements are one per file beside it; this module re-exports them (one entry point).\nimport { css } from 'lit';\nimport { unsafeStatic, html } from 'lit/static-html.js';\nimport { customElement, state } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport type { HeadingLevel } from './heading-shared.ts';\nexport * from './section.ts';\nexport type { HeadingLevel } from './heading-shared.ts';\n\n/**\n * Carbon `Heading` (`cds-heading`): an `<h1>`…`<h6>` at the level of the `<ui-section>` it sits in (`<h1>` outside\n * any), in Carbon's productive type for that level — h1 heading-06 (42px light) down to h6 heading-01 (14px\n * semibold), no margins.\n *\n * @slot - The heading text\n * @csspart heading - The `<h1>`…`<h6>`\n */\n@customElement('ui-heading')\nexport class UiHeading extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: block;\n        }\n\n        .heading {\n            margin: 0;\n            color: var(--ui-ink);\n            unicode-bidi: isolate;\n        }\n\n        h1 {\n            font: var(--ui-font-heading-06);\n        }\n\n        h2 {\n            font: var(--ui-font-heading-05);\n        }\n\n        h3 {\n            font: var(--ui-font-heading-04);\n        }\n\n        h4 {\n            font: var(--ui-font-heading-03);\n        }\n\n        h5 {\n            font: var(--ui-font-heading-02);\n        }\n\n        h6 {\n            font: var(--ui-font-heading-01);\n            letter-spacing: var(--ui-tracking-body);\n        }\n    `;\n\n    /** The level from the `<ui-section>` around it (1 outside any). */\n    @state() level: HeadingLevel = 1;\n\n    /** Takes the level of the section around it (also called by a section whose level changed). */\n    syncLevel() {\n        this.level = this.closest('ui-section')?.getCurrentLevel() ?? 1;\n    }\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.syncLevel();\n    }\n\n    override render() {\n        const tag = unsafeStatic(`h${this.level}`);\n        return html`<${tag} class=\"heading\" part=\"heading\"><slot></slot></${tag}>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-heading': UiHeading;\n    }\n}\n"
    },
    {
      "path": "src/primitives/heading/section.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/heading/section.ts",
      "content": "import { css, type PropertyValues } from 'lit';\nimport { html } from 'lit/static-html.js';\nimport { customElement, property } from 'lit/decorators.js';\nimport { UiElement } from '../shared/element.ts';\nimport type { HeadingLevel } from './heading-shared.ts';\nimport type { UiHeading } from './heading.ts';\n\nconst clampLevel = (level: number) => Math.min(Math.max(Math.round(level), 1), 6) as HeadingLevel;\n\n/**\n * Carbon `Section` (`cds-section`): each section one heading level deeper than the section it sits in (the page\n * itself is level 1), so `<ui-heading>`s inside get the right `<h2>`…`<h6>` without counting. `level` sets it; a\n * later change reaches the sections and headings inside (as Carbon React's context).\n *\n * @slot - The section's content\n */\n@customElement('ui-section')\nexport class UiSection extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: block;\n        }\n    `;\n\n    /** The heading level inside, instead of one more than the section around it. */\n    @property({ type: Number }) level?: number;\n\n    private currentLevel: HeadingLevel = 2;\n\n    /** The level its headings use (Carbon `getCurrentLevel`). */\n    getCurrentLevel(): HeadingLevel {\n        return this.currentLevel;\n    }\n\n    /** Takes its level from `level`, else from the section around it (also called by an ancestor whose level changed). */\n    syncLevel() {\n        const parent = this.parentElement?.closest('ui-section');\n        this.currentLevel = clampLevel(this.level ?? (parent ? parent.getCurrentLevel() : 1) + 1);\n    }\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.syncLevel();\n    }\n\n    protected override updated(changed: PropertyValues<this>) {\n        super.updated(changed);\n        if (!changed.has('level')) return;\n        // a new level: this section, then everything inside in document order (each reads the one around it)\n        this.syncLevel();\n        for (const el of this.querySelectorAll<UiSection | UiHeading>('ui-section, ui-heading')) el.syncLevel();\n    }\n\n    override render() {\n        return html`<slot></slot>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-section': UiSection;\n    }\n}\n"
    }
  ]
}
