{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-heading",
  "type": "registry:ui",
  "title": "react-tw/heading.tsx",
  "description": "Carbon `Section` as React: each section one heading level deeper than the one around it (the page is 1), so the 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": [],
  "registryDependencies": [
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/heading.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/heading.tsx",
      "content": "import { createContext, useContext, type ComponentProps, type ElementType } from 'react';\nimport { cn } from './lib/utils.ts';\n\nconst HeadingContext = createContext(1);\n\nexport type SectionProps<T extends ElementType = 'section'> = { as?: T; level?: number } & Omit<ComponentProps<T>, 'as' | 'level'>;\n\n/**\n * Carbon `Section` as React: each section one heading level deeper than the one around it (the page is 1), so the\n * `Heading`s inside get the right `<h2>`…`<h6>` without counting; `level` sets it, `as` the element (`<section>`).\n */\nexport function Section<T extends ElementType = 'section'>({ as, level, ...rest }: Readonly<SectionProps<T>>) {\n    const parent = useContext(HeadingContext);\n    const Element: ElementType = as ?? 'section';\n    return (\n        <HeadingContext.Provider value={Math.min(Math.max(level ?? parent + 1, 1), 6)}>\n            <Element {...rest} />\n        </HeadingContext.Provider>\n    );\n}\n\n/** Carbon's productive type per level: h1 heading-06 (42px light) down to h6 heading-01 (14px semibold). */\nconst TYPE = ['type-heading-06', 'type-heading-05', 'type-heading-04', 'type-heading-03', 'type-heading-02', 'type-heading-01'] as const;\n\n/** Carbon `Heading` as React + Tailwind, the look of `<ui-heading>`: an `<h1>`…`<h6>` at its `Section`'s level, no margins. */\nexport function Heading({ className, ...rest }: Readonly<ComponentProps<'h1'>>) {\n    const level = useContext(HeadingContext);\n    const Tag = `h${level}` as 'h1';\n    return <Tag {...rest} className={cn('m-0 text-ink [unicode-bidi:isolate]', TYPE[level - 1], className)} />;\n}\n"
    }
  ]
}
