{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "presets",
  "title": "Presets",
  "description": "named sets of values to jump to · the matching one is pressed and checked",
  "dependencies": [
    "cn@^0.5.2",
    "lucide-react@^1.52.0"
  ],
  "registryDependencies": [
    "@halftone-web/kit-setup",
    "@halftone-web/lib-controls-schema"
  ],
  "files": [
    {
      "path": "components/controls/presets.tsx",
      "content": "'use client';\nimport { cn } from 'cn';\nimport { CheckIcon } from 'lucide-react';\nimport type { Values } from '@/lib/controls/schema';\n\nexport type Preset = { name: string; values: Values };\n\n/** Whether `values` holds everything the preset sets (it may set only some of the controls). */\nexport function matchesPreset(values: Values, preset: Values): boolean {\n  return Object.entries(preset).every(([k, v]) => {\n    const have = values[k];\n    if (v && typeof v === 'object' && !Array.isArray(v) && have && typeof have === 'object' && !Array.isArray(have)) return matchesPreset(have as Values, v as Values);\n    return JSON.stringify(have) === JSON.stringify(v);\n  });\n}\n\n/**\n * Named sets of values a panel can jump to. The one the panel matches now is pressed and carries a check, so it reads\n * without colour. A preset may set only some controls; the rest keep their values.\n */\nexport function Presets({ presets, values, onApply, label = 'Presets', className }: { presets: readonly Preset[]; values: Values; onApply: (preset: Preset) => void; label?: string; className?: string }) {\n  return (\n    <div role=\"group\" aria-label={label} className={cn('flex flex-wrap gap-1.5', className)}>\n      {presets.map((p) => {\n        const on = matchesPreset(values, p.values);\n        return (\n          <button\n            key={p.name}\n            type=\"button\"\n            aria-pressed={on}\n            onClick={() => onApply(p)}\n            className={cn(\n              'focus-visible:ring-ring/50 inline-flex h-7 items-center gap-1 rounded-md border px-2.5 text-xs font-medium outline-none focus-visible:ring-[3px]',\n              on ? 'border-foreground bg-secondary text-foreground' : 'border-border text-muted-foreground hover:bg-accent hover:text-foreground'\n            )}>\n            {on ? <CheckIcon aria-hidden className=\"size-3.5\" /> : null}\n            {p.name}\n          </button>\n        );\n      })}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/controls/presets.tsx"
    }
  ],
  "meta": {
    "exports": [
      "Presets",
      "matchesPreset"
    ],
    "api": "<Presets presets={[{name,values}]} values onApply />"
  },
  "categories": [
    "controls"
  ],
  "type": "registry:component"
}