import type { QueryObserverResult, UseQueryOptions } from "@tanstack/react-query"; import type { UseManyReturnType } from "../data/useMany"; import type { BaseKey, BaseOption, BaseRecord, CrudFilter, CrudSort, GetListResponse, GetManyResponse, HttpError, MetaQuery, Pagination, Prettify } from "../../contexts/data/types"; import type { LiveModeProps } from "../../contexts/live/types"; import type { SuccessErrorNotification } from "../../contexts/notification/types"; import type { BaseListProps } from "../data/useList"; import { type UseLoadingOvertimeOptionsProps, type UseLoadingOvertimeReturnType } from "../useLoadingOvertime"; import type { MakeOptional } from "../../definitions/types"; export type SelectedOptionsOrder = "in-place" | "selected-first"; export type UseSelectProps = { /** * Resource name for API data interactions */ resource: string; /** * Set the option's label value * @default `"title"` */ optionLabel?: (keyof TData extends string ? keyof TData : never) | ((item: TData) => string); /** * Set the option's value * @default `"id"` */ optionValue?: (keyof TData extends string ? keyof TData : never) | ((item: TData) => string); /** * Field name to search for. * @description If provided `optionLabel` is a string, uses `optionLabel`'s value. * @default `"title"` * @example * // when optionLabel is string. * useSelect({ optionLabel: "name" }) * // uses `name` field. * @example * // when optionLabel is function. * useSelect({ optionLabel: (field) => field.description }) * // uses `title`, since `optionLabel` is a function. */ searchField?: keyof TData extends string ? keyof TData : never; /** * Allow us to sort the options */ sorters?: CrudSort[]; /** * Resource name for API data interactions */ filters?: CrudFilter[]; /** * Adds extra `options` */ defaultValue?: BaseKey | BaseKey[]; /** * Allow us to sort the selection options * @default `in-place` */ selectedOptionsOrder?: SelectedOptionsOrder; /** * The number of milliseconds to delay * @default `300` */ debounce?: number; /** * react-query [useQuery](https://react-query.tanstack.com/reference/useQuery) options */ queryOptions?: MakeOptional, TError, GetListResponse>, "queryKey" | "queryFn">; /** * Pagination option from [`useList()`](/docs/api-reference/core/hooks/data/useList/) * @type { currentPage?: number; pageSize?: number;} * @default `undefined` */ pagination?: Prettify & { /** * Whether to use server side pagination or not. * @default "off" */ mode?: Pagination["mode"]; }>; /** * react-query [useQuery](https://react-query.tanstack.com/reference/useQuery) options */ defaultValueQueryOptions?: MakeOptional, TError, GetManyResponse>, "queryKey" | "queryFn">; /** * If defined, this callback allows us to override all filters for every search request. * @default `undefined` */ onSearch?: (value: string) => CrudFilter[]; /** * Additional meta data to pass to the `useMany` from the data provider */ meta?: MetaQuery; /** * Additional meta data to pass to the `useMany` from the data provider /** * If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use. * @default `default` */ dataProviderName?: string; } & SuccessErrorNotification, TError, Prettify> & LiveModeProps & UseLoadingOvertimeOptionsProps; export type UseSelectReturnType = { query: QueryObserverResult, TError>; defaultValueQuery: UseManyReturnType; onSearch: (value: string) => void; options: TOption[]; } & UseLoadingOvertimeReturnType; /** * `useSelect` hook is used to fetch data from the dataProvider and return the options for the select box. * * It uses `getList` method as query function from the dataProvider that is * passed to {@link https://refine.dev/docs/api-reference/core/components/refine-config/ ``}. * * @see {@link https://refine.dev/docs/api-reference/core/hooks/useSelect} for more details. * * @typeParam TQueryFnData - Result data returned by the query function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`} * @typeParam TError - Custom error object that extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#httperror `HttpError`} * @typeParam TData - Result data returned by the `select` function. Extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`}. Defaults to `TQueryFnData` * */ export declare const useSelect: (props: UseSelectProps) => UseSelectReturnType; //# sourceMappingURL=index.d.ts.map