{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "collection-controls",
  "type": "registry:ui",
  "title": "Collection Controls",
  "description": "Native search, filter and sort controls. Search stays visible; options collapse in narrow containers. Collection state belongs to the consuming app.",
  "dependencies": [
    "lucide-react@^1.49.0"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/input.json",
    "https://ui.klarhimmel.com/r/native-select.json",
    "https://ui.klarhimmel.com/r/theme.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/ui/collection-controls.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/ui/collection-controls.tsx",
      "content": "/// <reference path=\"../css.d.ts\" />\nimport { useId, type FormHTMLAttributes, type InputHTMLAttributes, type SelectHTMLAttributes } from 'react';\nimport { ChevronDown, SlidersHorizontal } from 'lucide-react';\nimport { Input } from './input';\nimport { NativeSelect } from './native-select';\nimport { cn } from '../lib/utils';\nimport './collection-controls.css';\n\ntype DataAttributes = { [key: `data-${string}`]: string | undefined };\nexport type CollectionOption = { value: string; label: string; count?: number };\nexport type CollectionSelect = {\n  name: string; label: string; options: CollectionOption[]; defaultValue?: string;\n  selectProps?: SelectHTMLAttributes<HTMLSelectElement> & DataAttributes;\n};\nexport interface CollectionControlsProps extends FormHTMLAttributes<HTMLFormElement> {\n  search: { name: string; label: string; placeholder?: string; inputProps?: InputHTMLAttributes<HTMLInputElement> & DataAttributes };\n  choices?: { name: string; label: string; options: CollectionOption[]; defaultValue: string };\n  filters?: CollectionSelect[];\n  sort?: CollectionSelect;\n  disabled?: boolean;\n  disclosureLabel?: string;\n  resetLabel?: string;\n}\n\n/** Native collection controls. Search stays visible; options collapse below\n * 48rem of the containing layout. Filtering and URL state belong to the app. */\nexport function CollectionControls({ search, choices, filters = [], sort, disabled = false, disclosureLabel = 'Filters & sort', resetLabel = 'Clear filters', className, ...formProps }: CollectionControlsProps) {\n  const id = useId();\n  const selects = [...filters, ...(sort ? [sort] : [])];\n  const hasOptions = Boolean(choices || selects.length || resetLabel);\n  return <form {...formProps} className={cn('kh-collection-controls', className)}>\n    <div className=\"kh-collection-search\">\n      <label htmlFor={`${id}-search`}>{search.label}</label>\n      <Input {...search.inputProps} id={`${id}-search`} type=\"search\" name={search.name} placeholder={search.placeholder} disabled={disabled} />\n    </div>\n    {hasOptions && <details className=\"kh-collection-options\">\n      <summary><SlidersHorizontal aria-hidden className=\"size-4\" /><span>{disclosureLabel}</span><ChevronDown aria-hidden className=\"kh-collection-chevron size-4\" /></summary>\n      <div className=\"kh-collection-fields\">\n        {choices && <fieldset>\n          <legend>{choices.label}</legend>\n          {choices.options.map(option => <label className=\"kh-collection-choice\" key={option.value}>\n            <input type=\"radio\" name={choices.name} value={option.value} defaultChecked={option.value === choices.defaultValue} disabled={disabled} />\n            <span>{option.label}</span>{option.count !== undefined && <span className=\"kh-collection-count\">{option.count}</span>}\n          </label>)}\n        </fieldset>}\n        {selects.map((select, index) => <div className=\"kh-collection-select\" key={select.name}>\n          <label htmlFor={`${id}-select-${index}`}>{select.label}</label>\n          <NativeSelect {...select.selectProps} id={`${id}-select-${index}`} name={select.name} defaultValue={select.defaultValue} disabled={disabled}>\n            {select.options.map(option => <option key={option.value} value={option.value}>{option.label}{option.count !== undefined ? ` (${option.count})` : ''}</option>)}\n          </NativeSelect>\n        </div>)}\n        {resetLabel && <button type=\"reset\" disabled={disabled} className=\"kh-collection-reset\">{resetLabel}</button>}\n      </div>\n    </details>}\n  </form>;\n}\n"
    },
    {
      "path": "src/ui/collection-controls.css",
      "type": "registry:file",
      "target": "components/klarhimmel/ui/collection-controls.css",
      "content": ".kh-collection-controls { display:flex; flex-direction:column; gap:.75rem; min-width:0; }\n.kh-collection-controls[hidden] { display:none; }\n.kh-collection-search, .kh-collection-select { display:flex; flex-direction:column; gap:.5rem; min-width:0; }\n.kh-collection-controls label, .kh-collection-controls legend { font-size:var(--kh-text-small); }\n.kh-collection-controls :is(input,select) { font-family:inherit; }\n.kh-collection-search > label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }\n.kh-collection-options > summary { display:flex; min-height:2.75rem; align-items:center; gap:.5rem; padding:.5rem .75rem; border:1px solid var(--kh-line); border-radius:var(--kh-radius); cursor:pointer; list-style:none; font-size:var(--kh-text-small); }\n.kh-collection-options > summary::-webkit-details-marker { display:none; }\n.kh-collection-chevron { margin-left:auto; transition:transform 160ms ease; }\n.kh-collection-options[open] .kh-collection-chevron { transform:rotate(180deg); }\n.kh-collection-fields { display:flex; flex-direction:column; gap:1rem; padding-block:1rem .25rem; }\n.kh-collection-fields fieldset { min-width:0; }\n.kh-collection-fields legend { font-weight:600; margin-bottom:.5rem; }\n.kh-collection-choice { display:flex; min-height:2.75rem; align-items:center; gap:.5rem; cursor:pointer; }\n.kh-collection-choice input { accent-color:var(--kh-accent); }\n.kh-collection-count { margin-left:auto; color:var(--kh-muted); font-variant-numeric:tabular-nums; }\n.kh-collection-reset { min-height:2.75rem; align-self:flex-start; color:var(--kh-muted); text-align:left; border-radius:var(--kh-radius); }\n.kh-collection-controls :focus-visible { outline:2px solid var(--kh-focus); outline-offset:3px; }\n@container (min-width:48rem) {\n  .kh-collection-search > label { position:static; width:auto; height:auto; overflow:visible; clip-path:none; }\n  .kh-collection-options > summary { display:none; }\n  .kh-collection-options::details-content { display:contents; content-visibility:visible; }\n  .kh-collection-fields { padding-block:.25rem 0; }\n}\n@media (prefers-reduced-motion:reduce) { .kh-collection-chevron { transition:none; } }\n"
    }
  ]
}
