import { useEffect } from 'react' import { Facets, formatInt } from '../api' import { FiltersBody, FilterValues } from './Filters' import { IconClose } from './Icons' interface Props { open: boolean facets: Facets | null values: FilterValues total: number | null onChange: (patch: Partial) => void onReset: () => void onClose: () => void } /** * Mobile slide-up bottom sheet holding all catalog filters. * Backdrop tap or the close button dismisses it; filters apply live, * the footer button confirms and closes. */ export default function FilterSheet({ open, facets, values, total, onChange, onReset, onClose, }: Props) { // Scroll lock + Escape to close while open. useEffect(() => { if (!open) return document.body.style.overflow = 'hidden' const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() } window.addEventListener('keydown', onKey) return () => { document.body.style.overflow = '' window.removeEventListener('keydown', onKey) } }, [open, onClose]) if (!open) return null return (