import { SyntheticEvent } from 'react'; import { Search } from '../../search'; import { PriceOption, BedroomOption, DistanceOption } from './constants'; import { SearchForm, SectionElement } from '../../state'; export interface UseSearchFormResult { /** The full local search state for the form */ search: Search; /** Submit callback that should be added to the onSubmit handler of the search form */ submitSearch: (e?: SyntheticEvent, s?: Search) => void; /** Boolean value to represent whether a search is running. Useful for rendering a loading state like a spinner. */ searching: boolean; /** Function to set individual search field values directly. This must be passed to the LocationInput as a prop. */ setSearchField: (payload: { [key: string]: string | number | null | undefined; }) => void; setChannel: (channel: string) => void; setMinBedrooms: (value: number | string | null) => void; setMaxBedrooms: (value: number | string | null) => void; setMinPrice: (value: number | string | null) => void; setMaxPrice: (value: number | string | null) => void; setGeolocation: () => void; setStatus: (value: string | null) => void; setDistance: (value: number | string | null) => void; setTags: (tags: string[]) => void; addTag: (tag: string) => void; removeTag: (tag: string) => void; removeTags: (tags: string[]) => void; setPropertyType: (propertyType: string) => void; setActiveSearchType: (searchType: string) => void; minPriceOptions: PriceOption[]; maxPriceOptions: PriceOption[]; minBedroomOptions: BedroomOption[]; maxBedroomOptions: BedroomOption[]; distanceOptions: DistanceOption[]; /** The relevant search form configuration based on the current activeSearchType, if the top-level `configuration` has been passed. */ searchFormConfig: SectionElement | SearchForm | undefined; formMatchingSearchTags: (config: SectionElement | SearchForm, search: Search) => string | undefined; } export interface PropertyTypeOption { label: string; value: string; } /** * The `useSearchForm` hook provides search functionality. It returns a `search` object containing the * current search state and setters for each of the values. This allows flexibility in composing * search forms using whichever form fields are appropriate. * * Here is a simplified example: * * @example * ```tsx * const { * search, * submitSearch, * searching, * setSearchField, * setGeolocate, * setChannel, * setMinPrice, * setMaxPrice, * minPriceOptions, * maxPriceOptions, * setMinBedrooms, * setMaxBedrooms, * minBedroomOptions, * maxBedroomOptions, * setStatus, * setDistance, * distanceOptions, * setPropertyType, * } = useSearchForm(); * *
* setChannel('sales')} * /> * * setChannel('lettings')} * /> * * * * * * * * * * * * * ``` */ export default function useSearchForm({ propertyTypeOptions, distanceOptions, configuration, activeSearchType, includePcw, }?: { propertyTypeOptions?: PropertyTypeOption[]; distanceOptions?: DistanceOption[]; configuration?: SectionElement | SearchForm; activeSearchType?: string; includePcw?: boolean; }): UseSearchFormResult; //# sourceMappingURL=use-search-form.d.ts.map