{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-layer",
  "type": "registry:ui",
  "title": "react-tw/layer.tsx",
  "description": "Carbon `Layer` as a React + Tailwind component, the rules of `<ui-layer>`: a zone one level deeper 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/layer.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/layer.tsx",
      "content": "import { createContext, useContext, type ReactNode, type ComponentProps } from 'react';\nimport { cn } from './lib/utils.ts';\n\nconst MAX_LEVEL = 2;\nconst LayerLevel = createContext(-1);\n\n/** Literal class names, so Tailwind generates them. */\nconst LEVEL_CLASSES = ['layer-0', 'layer-1', 'layer-2'] as const;\n\n/** The level of the closest `<Layer>` (-1 outside any). */\nexport const useLayerLevel = () => useContext(LayerLevel);\n\nexport interface LayerProps extends Omit<ComponentProps<'div'>, 'level' | 'withBackground' | 'className' | 'children'> {\n    /** 0, 1 or 2; when left out, one deeper than the enclosing layer, and 1 outside any (Carbon React). */\n    level?: 0 | 1 | 2;\n    /** Paint the layer with Carbon's `layer-background` (`withBackground`): the colour its content sits on (white theme, level 1: #f4f4f4 under #ffffff fields). */\n    withBackground?: boolean;\n    className?: string;\n    children?: ReactNode;\n}\n\n/**\n * Carbon `Layer` as a React + Tailwind component, the rules of `<ui-layer>`: a zone one level deeper\n * in the layering model — fields, menus, borders and hover fills inside it use the next layer set of\n * the theme (white: #f4f4f4 → #ffffff → #f4f4f4), so a field on a tile stays distinct from the tile.\n * Level 0 is the page's own set. As Carbon React's `<Layer>` (unlike `<ui-layer>`, which follows\n * Carbon's `cds-layer`), a layer outside any other is level 1 and a nested one goes one deeper (at most 2).\n */\nexport function Layer({ level, withBackground = false, className, children, ...rest }: Readonly<LayerProps>) {\n    const parent = useLayerLevel();\n    const own = level ?? Math.min(Math.max(parent + 1, 1), MAX_LEVEL);\n    return (\n        <LayerLevel.Provider value={own}>\n            <div {...rest} className={cn('block', LEVEL_CLASSES[own], withBackground && 'bg-layer-background [border:var(--ui-layer-border,none)] rounded-[var(--ui-layer-radius,0)]', className)}>{children}</div>\n        </LayerLevel.Provider>\n    );\n}\n"
    }
  ]
}
