import { RefObject } from "react"; export declare type LocationOption = { label: string; value: string; }; export declare type FieldValue = LocationOption | Date | GuestOption[] | string; export declare type FieldType = "location" | "date" | "datetime" | "peopleCount"; export declare type FormSchema = { [key: string]: { type: FieldType; focusOnNext?: string; defaultValue?: FieldValue; options?: { defaultLocationOptions?: LocationOption[]; searchPlace?: (queryString: string) => Promise; [key: string]: any; }; }; }; export declare type GuestOption = { label: string; value: number; totalCount?: number; name: string; min: number; max: number; [key: string]: any; }; export declare type BookingForm = { /** * Form schema provided by the user. */ formSchema: FormSchema; /** * Current form state. */ state: FormState; setState: (state: FormState) => void; /** * Helper that sets the particular field value in the form. */ setFieldValue: (key: string, value: any) => void; /** * Helper that sets the particular field state in the form. */ setFieldState: (key: string, fieldState: any) => void; /** * An array of references to the form fields. * This can be used to focus on a particular field and do other relevant actions. */ refs: RefsType; /** * Helper that allows to focus on a particular field just by passing field key to it. */ focusOn: (key?: string) => void; /** * This is a helper that allows to change a particular option item state. * For example, if you want to increment the number of "adults", you can use this helper as: * ``` * form.setGuestOptionValue(name, option, option.value + 1) * ``` */ setGuestOptionValue: (key: string, option: any, value: any) => void; /** * A callback to pass to the guest minus button click event. */ onMinusClick: (option: GuestOption, name: string) => () => void; /** * A callback to pass to the guest plus button click event. */ onPlusClick: (option: GuestOption, name: string) => () => void; /** * A callback to pass to the guest buttons to determine if the buttons are disabled. */ getIsOptionDisabled: (option: GuestOption, optionType: "plus" | "minus") => boolean; /** * This can be used to swap the location fields. */ swapLocations: (fieldKeys?: [string, string] | undefined) => void; /** * Converts the form state to url query string. * Use convertDate to convert dates to the desired format. */ serializeToURLParams: ({ convertDate, }: { convertDate?: (dateValue: Date) => any; }) => string; }; export declare type RefsType = { [key: string]: RefObject; }; export declare type FormStateItem = { type: FieldType; value: FieldValue; /** * Stores total number of guests in guest selector. */ totalCount?: number; }; export declare type FormState = { [key: string]: FormStateItem; }; export declare const useReactBookingForm: ({ formSchema, }: { formSchema: FormSchema; }) => BookingForm;