import { CATALOGUE_VIEW_MODES, DIFFICULTIES, MACHINE_CATEGORIES, RELEASE_PHASES, SORT_OPTIONS, type CatalogueViewMode, type Difficulty, type MachineCategory, type ReleasePhase, type SortKey } from '@/types/catalogue'; import type { FacetCounts } from '@/utils/search'; import { Badge } from '@/components/ui/Badge'; import { Button } from '@/components/ui/Button'; import { Input } from '@/components/ui/Input'; import { Panel } from '@/components/ui/Panel'; import { SegmentedControl } from '@/components/ui/SegmentedControl'; import { Select } from '@/components/ui/Select'; import { ToggleSwitch } from '@/components/ui/ToggleSwitch'; import { cn } from '@/utils/classNames'; import { difficultyToTone, phaseLabel } from '@/utils/format'; export interface CatalogueFiltersProps { readonly query: string; readonly onQueryChange: (query: string) => void; readonly selectedCategories: readonly MachineCategory[]; readonly onToggleCategory: (category: MachineCategory) => void; readonly selectedDifficulties: readonly Difficulty[]; readonly onToggleDifficulty: (difficulty: Difficulty) => void; readonly selectedPhases: readonly ReleasePhase[]; readonly onTogglePhase: (phase: ReleasePhase) => void; readonly sortKey: SortKey; readonly onSortChange: (sortKey: SortKey) => void; readonly favouritesOnly: boolean; readonly onFavouritesOnlyChange: (enabled: boolean) => void; readonly viewMode: CatalogueViewMode; readonly onViewModeChange: (viewMode: CatalogueViewMode) => void; readonly counts: FacetCounts; readonly activeFilterCount: number; readonly onClearFilters: () => void; } function SearchIcon() { return ( ); } function FilterSection({ children, title }: { readonly children: React.ReactNode; readonly title: string; }) { return (

{title}

{children}
); } function Chip({ active, children, count, onClick }: { readonly active: boolean; readonly children: React.ReactNode; readonly count?: number; readonly onClick: () => void; }) { return ( ); } export function CatalogueFilters({ activeFilterCount, counts, favouritesOnly, onClearFilters, onFavouritesOnlyChange, onQueryChange, onSortChange, onToggleCategory, onToggleDifficulty, onTogglePhase, onViewModeChange, query, selectedCategories, selectedDifficulties, selectedPhases, sortKey, viewMode }: CatalogueFiltersProps) { const sortOptions = SORT_OPTIONS.map((option) => ({ value: option.value, label: option.label })); return (

Catalogue controls

Refine machines

0 ? 'accent' : 'neutral'}> {activeFilterCount} active
onQueryChange(event.currentTarget.value)} placeholder="Search by mechanism, part, or fact…" leftIcon={} hint="Search scans names, tags, applications, engineering facts, and component descriptions." />
{MACHINE_CATEGORIES.map((category) => ( onToggleCategory(category)} > {category} ))}
{DIFFICULTIES.map((difficulty) => ( onToggleDifficulty(difficulty)} > {difficulty} {difficulty.slice(0, 3)} ))}
{RELEASE_PHASES.map((phase) => ( onTogglePhase(phase)} > {phaseLabel(phase)} ))}