{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switch",
  "title": "Switch",
  "description": "A switch whose knob lifts into a lens as it slides.",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "https://liquikit.dev/r/core.json",
    "https://liquikit.dev/r/glass.json"
  ],
  "files": [
    {
      "path": "src/switch.tsx",
      "content": "\"use client\";\n\nimport { Switch as BaseSwitch } from \"@base-ui/react/switch\";\nimport { type CSSProperties, useRef, useState } from \"react\";\nimport { GlassSwitchSurface, type UseGlassSwitchResult } from \"./glass\";\nimport { cx, type GlassOptions } from \"./types\";\nimport \"./liquikit.css\";\n\nexport type SwitchProps = Omit<\n\tBaseSwitch.Root.Props,\n\t\"children\" | \"render\" | \"className\" | \"style\" | \"onCheckedChange\"\n> &\n\tGlassOptions & {\n\t\tonCheckedChange?: (\n\t\t\tchecked: boolean,\n\t\t\teventDetails?: BaseSwitch.Root.ChangeEventDetails,\n\t\t) => void;\n\t\twidth?: number;\n\t\theight?: number;\n\t\tclassName?: string;\n\t\tstyle?: CSSProperties;\n\t};\n\nexport function Switch({\n\tchecked,\n\tdefaultChecked = false,\n\tonCheckedChange,\n\twidth,\n\theight,\n\ttheme,\n\tlens,\n\tliquid,\n\tclassName,\n\t...rootProps\n}: SwitchProps) {\n\tconst controls = useRef<UseGlassSwitchResult>(null);\n\tconst [uncontrolled, setUncontrolled] = useState(defaultChecked);\n\tconst current = checked ?? uncontrolled;\n\n\tconst commit = (\n\t\tnext: boolean,\n\t\teventDetails?: BaseSwitch.Root.ChangeEventDetails,\n\t) => {\n\t\tif (checked === undefined) setUncontrolled(next);\n\t\tonCheckedChange?.(next, eventDetails);\n\t};\n\n\treturn (\n\t\t<BaseSwitch.Root\n\t\t\t{...rootProps}\n\t\t\tchecked={current}\n\t\t\tonCheckedChange={(next, eventDetails) => {\n\t\t\t\tif (controls.current?.consumeDragGuard()) {\n\t\t\t\t\teventDetails.cancel();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcommit(next, eventDetails);\n\t\t\t\tcontrols.current?.flash();\n\t\t\t}}\n\t\t\tclassName={cx(\"glass-ui-root glass-ui-switch\", className)}\n\t\t>\n\t\t\t<GlassSwitchSurface\n\t\t\t\tchecked={current}\n\t\t\t\tonCheckedChange={(next) => commit(next)}\n\t\t\t\twidth={width}\n\t\t\t\theight={height}\n\t\t\t\tdisabled={rootProps.disabled}\n\t\t\t\tdraggable={!rootProps.readOnly}\n\t\t\t\tlens={lens}\n\t\t\t\ttheme={theme}\n\t\t\t\tliquid={liquid}\n\t\t\t\tcontrolsRef={controls}\n\t\t\t/>\n\t\t</BaseSwitch.Root>\n\t);\n}\n",
      "type": "registry:ui",
      "target": "@components/liquikit/switch.tsx"
    }
  ],
  "type": "registry:ui"
}