UNPKG

@rjsf/utils

Version:
15 lines (14 loc) 1.1 kB
import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types.js'; /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data. * Deprecated, use `getFirstMatchingOption()` instead. * * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary * @param formData - The current formData, if any, used to figure out a match * @param options - The list of options to find a matching options from * @param rootSchema - The root schema, used to primarily to look up `$ref`s * @param [discriminatorField] - The optional name of the field within the options object whose value is used to * determine which option is selected * @returns - The index of the matched option or 0 if none is available * @deprecated */ export default function getMatchingOption<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, formData: T | undefined, options: S[], rootSchema: S, discriminatorField?: string): number;