UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

42 lines 1.39 kB
import { InferredTypeMap } from './types'; /** * Guesses an element based on an array of values * * @example * inferElementFromValues( * 'address', * ['2 Baker Street', '1 Downing street'], * { number: NumberField, string: StringField } * ); * // new InferredElement(<StringField source="address" />) * * Types are optional: if a type isn't provided, the function falls back * to the nearest type. * * @example * inferElementFromValues( * 'content', * ['<h1>Hello</h1>'], * { string: StringField } // no richText type * ); * // new InferredElement(<StringField source="content" />) * * Types can be disabled by passing a falsy value. * * @example * inferElementFromValues( * 'content', * ['<h1>Hello</h1>'], * { string: StringField, richText: false } * ); * // null * * @param {string} name Property name, e.g. 'date_of_birth' * @param {any[]} values an array of values from which to determine the type, e.g. [12, 34.4, 43] * @param {Object} types A set of components indexed by type. The string type is the only required one * * @return InferredElement */ declare const inferElementFromValues: (name: any, values?: never[], types?: InferredTypeMap) => any; export default inferElementFromValues; //# sourceMappingURL=inferElementFromValues.d.ts.map