import { ReactElement } from 'react'; import PropTypes from 'prop-types'; import { InputProps, ReferenceInputValue, UseInputValue } from '../../features/core'; /** * An Input component for choosing a reference record. Useful for foreign keys. * * This component fetches the possible values in the reference resource * (using `dataProvider.getList()`), then delegates rendering * to a subcomponent, to which it passes the possible choices * as the `choices` attribute. * * Use it with a selector component as child, like ``, * ``, or ``. * * @example * export const CommentEdit = (props) => ( * * * * * * * * ); * * @example * export const CommentEdit = (props) => ( * * * * * * * * ); * * By default, restricts the possible values to 25. You can extend this limit * by setting the `perPage` prop. * * @example * * * * * By default, orders the possible values by id desc. You can change this order * by setting the `sort` prop (an object with `field` and `order` properties). * * @example * * * * * Also, you can filter the query used to populate the possible values. Use the * `filter` prop for that. * * @example * * * * * The enclosed component may filter results. ReferenceInput passes a `setFilter` * function as prop to its child component. It uses the value to create a filter * for the query - by default { q: [searchText] }. You can customize the mapping * searchText => searchQuery by setting a custom `filterToQuery` function prop: * * @example * ({ title: searchText })}> * * */ declare const ReferenceInput: { (props: ReferenceInputProps): JSX.Element; propTypes: { allowEmpty: PropTypes.Requireable; basePath: PropTypes.Requireable; children: PropTypes.Validator; className: PropTypes.Requireable; classes: PropTypes.Requireable; filter: PropTypes.Requireable; filterToQuery: PropTypes.Validator<(...args: any[]) => any>; label: PropTypes.Requireable; onChange: PropTypes.Requireable<(...args: any[]) => any>; perPage: PropTypes.Requireable; record: PropTypes.Requireable; reference: PropTypes.Validator; resource: PropTypes.Requireable; sort: PropTypes.Requireable; order: PropTypes.Requireable; }>>; source: PropTypes.Requireable; }; defaultProps: { filter: {}; filterToQuery: (searchText: any) => { q: any; } | { q?: undefined; }; perPage: number; sort: { field: string; order: string; }; }; }; export interface ReferenceInputProps extends InputProps { allowEmpty?: boolean; basePath?: string; children: ReactElement; classes?: any; className?: string; filterToQuery?: (filter: string) => any; label?: string; perPage?: number; reference: string; referenceSource?: (resource: string, source: string) => string; resource?: string; [key: string]: any; } export interface ReferenceInputViewProps extends ReferenceInputValue, ReferenceInputProps, Omit { } export declare const ReferenceInputView: (props: ReferenceInputViewProps) => JSX.Element; export default ReferenceInput;