{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sort-filter-sheet",
  "title": "Sort Filter Sheet",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/sort-filter-sheet/SortFilterSheet.tsx",
      "content": "import { useState } from 'react'\nimport { View } from 'react-native'\nimport { Button } from '@/components/ui/button'\nimport { FilterChip, FilterChipGroup } from '@/components/ui/filter-chip-group'\nimport { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'\nimport { Sheet, SheetClose, SheetContent, SheetTrigger } from '@/components/ui/sheet'\nimport { Text } from '@/components/ui/text'\n\nexport interface SortFilterOption {\n  id: string\n  label: string\n}\n\nexport interface SortFilterValue {\n  sort: string | null\n  filters: readonly string[]\n}\n\nexport interface SortFilterSheetProps {\n  value: SortFilterValue\n  onApply: (value: SortFilterValue) => void\n  /** IDs must be nonempty and unique within each option list. */\n  sorts?: readonly SortFilterOption[]\n  filters?: readonly SortFilterOption[]\n  /** Clear all resets to this sort. Defaults to the first available sort. */\n  defaultSort?: string\n  title?: string\n  closeLabel?: string\n  labels?: Partial<Record<'trigger' | 'sort' | 'filters' | 'apply' | 'clear', string>>\n}\n\nexport function SortFilterSheet({\n  value,\n  onApply,\n  sorts = [],\n  filters = [],\n  defaultSort,\n  title = 'Sort and filter',\n  closeLabel = 'Close filters',\n  labels,\n}: SortFilterSheetProps) {\n  const [draft, setDraft] = useState<SortFilterValue | null>(null)\n  const defaultSortId = sorts.find((option) => option.id === defaultSort)?.id ?? sorts[0]?.id ?? null\n  const sortLabel = labels?.sort ?? 'Sort by'\n  const filtersLabel = labels?.filters ?? 'Filters'\n\n  return (\n    <Sheet\n      open={draft !== null}\n      onOpenChange={(open) =>\n        setDraft(\n          open\n            ? {\n                sort: sorts.some((option) => option.id === value.sort) ? value.sort : defaultSortId,\n                filters: [...value.filters],\n              }\n            : null,\n        )\n      }\n    >\n      <SheetTrigger\n        variant=\"outline\"\n        disabled={sorts.length === 0 && filters.length === 0}\n        accessibilityLabel={labels?.trigger ?? title}\n      >\n        {labels?.trigger ?? title}\n      </SheetTrigger>\n      <SheetContent title={title} closeLabel={closeLabel}>\n        {draft ? (\n          <>\n            {sorts.length > 0 ? (\n              <View className=\"gap-[4px]\">\n                <Text size=\"sm\" className=\"font-semibold\" accessibilityRole=\"header\">\n                  {sortLabel}\n                </Text>\n                <RadioGroup\n                  value={draft.sort ?? ''}\n                  accessibilityLabel={sortLabel}\n                  onValueChange={(sort) => setDraft((current) => current && { ...current, sort })}\n                  className=\"gap-0\"\n                >\n                  {sorts.map(({ id, label }) => (\n                    <RadioGroupItem key={id} value={id} label={label} />\n                  ))}\n                </RadioGroup>\n              </View>\n            ) : null}\n            {filters.length > 0 ? (\n              <View className=\"gap-[8px]\">\n                <Text size=\"sm\" className=\"font-semibold\" accessibilityRole=\"header\">\n                  {filtersLabel}\n                </Text>\n                <FilterChipGroup\n                  value={draft.filters}\n                  onValueChange={(selection) => setDraft((current) => current && { ...current, filters: selection })}\n                >\n                  {filters.map(({ id, label }) => (\n                    <FilterChip key={id} value={id} label={label} />\n                  ))}\n                </FilterChipGroup>\n              </View>\n            ) : null}\n            <View className=\"gap-[8px] border-t border-border pt-[16px]\">\n              <SheetClose\n                accessibilityLabel={labels?.apply ?? 'Apply'}\n                onPress={() =>\n                  onApply({\n                    sort: sorts.some((option) => option.id === draft.sort) ? draft.sort : defaultSortId,\n                    filters: [...new Set(draft.filters.filter((id) => filters.some((option) => option.id === id)))],\n                  })\n                }\n              >\n                {labels?.apply ?? 'Apply'}\n              </SheetClose>\n              <Button\n                variant=\"ghost\"\n                accessibilityLabel={labels?.clear ?? 'Clear all'}\n                onPress={() => setDraft({ sort: defaultSortId, filters: [] })}\n              >\n                {labels?.clear ?? 'Clear all'}\n              </Button>\n            </View>\n          </>\n        ) : null}\n      </SheetContent>\n    </Sheet>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/sort-filter-sheet/SortFilterSheet.tsx"
    },
    {
      "path": "packages/registry-native/blocks/sort-filter-sheet/index.ts",
      "content": "export {\n  SortFilterSheet,\n  type SortFilterOption,\n  type SortFilterSheetProps,\n  type SortFilterValue,\n} from './SortFilterSheet'\n",
      "type": "registry:block",
      "target": "~/components/blocks/sort-filter-sheet/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/filter-chip-group.json",
    "https://native.uipkge.dev/r/native/radio-group.json",
    "https://native.uipkge.dev/r/native/sheet.json",
    "https://native.uipkge.dev/r/native/text.json"
  ],
  "description": "Bottom sheet for drafting sort and filter changes, with explicit clear and apply controls.",
  "categories": [
    "search"
  ]
}