{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "use-controllable-state",
  "title": "useControllableState",
  "description": "Controlled or uncontrolled state with a single API.",
  "files": [
    {
      "path": "src/registry/kinematic/hooks/use-controllable-state.ts",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\ntype ControllableStateOptions<T> = {\n  value?: T\n  defaultValue: T\n  onChange?: (value: T) => void\n}\n\nexport function useControllableState<T>({ value, defaultValue, onChange }: ControllableStateOptions<T>) {\n  const [inner, setInner] = React.useState(defaultValue)\n  const isControlled = value !== undefined\n  const current = isControlled ? value : inner\n\n  const setValue = React.useCallback(\n    (next: T) => {\n      if (!isControlled) setInner(next)\n      onChange?.(next)\n    },\n    [isControlled, onChange]\n  )\n\n  return [current, setValue] as const\n}\n",
      "type": "registry:hook"
    }
  ],
  "type": "registry:hook"
}