import { Component, ReactNode, ComponentType } from 'react'; import { WrappedFieldInputProps } from 'redux-form'; import { crudGetManyAccumulate as crudGetManyAccumulateAction, crudGetMatchingAccumulate as crudGetMatchingAccumulateAction } from '../../actions/accumulateActions'; import { Sort, Translate, Record, Pagination, Dispatch } from '../../types'; import { MatchingReferencesError } from './types'; declare const defaultReferenceSource: (resource: string, source: string) => string; interface ChildrenFuncParams { choices: Record[]; error?: string; filter?: any; isLoading: boolean; onChange: (value: any) => void; pagination: Pagination; setFilter: (filter: any) => void; setPagination: (pagination: Pagination) => void; setSort: (sort: Sort) => void; sort: Sort; warning?: string; } interface Props { allowEmpty?: boolean; basePath: string; children: (params: ChildrenFuncParams) => ReactNode; filter?: object; filterToQuery: (filter: {}) => any; input?: WrappedFieldInputProps; perPage: number; record?: Record; reference: string; referenceSource: typeof defaultReferenceSource; resource: string; sort?: Sort; source: string; } interface EnhancedProps { crudGetMatchingAccumulate: Dispatch; crudGetManyAccumulate: Dispatch; matchingReferences?: Record[] | MatchingReferencesError; onChange: () => void; referenceRecord?: Record; translate: Translate; } interface State { pagination: Pagination; sort: Sort; filter: any; } /** * An Input component for choosing a reference record. Useful for foreign keys. * * This component fetches the possible values in the reference resource * (using the `CRUD_GET_MATCHING` REST method), 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 })}> * * */ export declare class UnconnectedReferenceInputController extends Component { static defaultProps: { allowEmpty: boolean; filter: {}; filterToQuery: (searchText: any) => { q: any; }; matchingReferences: any; perPage: number; sort: { field: string; order: string; }; referenceRecord: any; referenceSource: (resource: string, source: string) => string; }; state: State; private debouncedSetFilter; constructor(props: any); componentDidMount(): void; componentWillReceiveProps(nextProps: Props & EnhancedProps): void; setFilter: (filter: any) => void; setPagination: (pagination: Pagination) => void; setSort: (sort: Sort) => void; fetchReference: (props?: Readonly<{ children?: ReactNode; }> & Readonly) => void; fetchOptions: (props?: Readonly<{ children?: ReactNode; }> & Readonly) => void; fetchReferenceAndOptions(props: any): void; render(): ReactNode; } declare const _default: ComponentType; export default _default;