import { ReactElement } from 'react'; import PropTypes from 'prop-types'; import { InputProps, SortPayload, PaginationPayload, Translate } from '../../features/core'; import { FieldInputProps, FieldMetaState } from 'react-final-form'; export interface ReferenceArrayInputProps extends InputProps { allowEmpty?: boolean; basePath?: string; children: ReactElement; classes?: any; className?: string; label?: string; reference: string; resource?: string; [key: string]: any; } /** * An Input component for fields containing a list of references to another resource. * Useful for 'hasMany' relationship. * * @example * The post object has many tags, so the post resource looks like: * { * id: 1234, * tag_ids: [ "1", "23", "4" ] * } * * ReferenceArrayInput component fetches the current resources (using * `dataProvider.getMany()`) as well as possible resources (using * `dataProvider.getList()`) in the reference endpoint. It 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 PostEdit = (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. ReferenceArrayInput 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 * ({ name: searchText })}> * * */ declare const ReferenceArrayInput: { ({ children, id: idOverride, onBlur, onChange, onFocus, validate, parse, format, ...props }: ReferenceArrayInputProps): JSX.Element; propTypes: { allowEmpty: PropTypes.Requireable; basePath: PropTypes.Requireable; children: PropTypes.Validator; className: PropTypes.Requireable; filter: PropTypes.Requireable; filterToQuery: PropTypes.Validator<(...args: any[]) => any>; label: PropTypes.Requireable; perPage: 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 ReferenceArrayInputViewProps { allowEmpty?: boolean; basePath?: string; children: ReactElement; choices: any[]; classes?: object; className?: string; error?: string; helperText?: string | boolean; id: string; input: FieldInputProps; isRequired: boolean; label?: string; loaded: boolean; loading: boolean; meta: FieldMetaState; onChange: any; options?: any; reference: string; resource?: string; setFilter: (v: string) => void; setPagination: (pagination: PaginationPayload) => void; setSort: (sort: SortPayload, order?: string) => void; source: string; translate: Translate; warning?: string; } export declare const ReferenceArrayInputView: { ({ allowEmpty, basePath, children, choices, className, error, input, loaded, loading, isRequired, label, meta, onChange, options, reference, resource, setFilter, setPagination, setSort, source, translate, warning, ...rest }: ReferenceArrayInputViewProps): JSX.Element; propTypes: { allowEmpty: PropTypes.Requireable; basePath: PropTypes.Requireable; children: PropTypes.Requireable; choices: PropTypes.Requireable; className: PropTypes.Requireable; error: PropTypes.Requireable; loading: PropTypes.Requireable; input: PropTypes.Validator; label: PropTypes.Requireable; meta: PropTypes.Requireable; onChange: PropTypes.Requireable<(...args: any[]) => any>; options: PropTypes.Requireable; resource: PropTypes.Requireable; setFilter: PropTypes.Requireable<(...args: any[]) => any>; setPagination: PropTypes.Requireable<(...args: any[]) => any>; setSort: PropTypes.Requireable<(...args: any[]) => any>; source: PropTypes.Requireable; translate: PropTypes.Validator<(...args: any[]) => any>; warning: PropTypes.Requireable; }; }; export default ReferenceArrayInput;