UNPKG

@tiller-ds/formik-elements

Version:

Formik elements module of Tiller Design System

27 lines (26 loc) 1.5 kB
/// <reference types="react" /> import { AutocompleteProps } from "@tiller-ds/selectors"; import { InputFieldProps } from "./InputField"; declare type AutocompleteOnlyPropsUnion = "value" | "onChange" | "onBlur" | "error"; export declare type AutocompleteFieldProps<T> = { /** * The accessor value for the input field component (for validation, fetching, etc.). */ name: string; /** * Function describing what property of the object the component will treat as a value. Required because * comparison between objects requires a unique value (typically id) to properly compare them. * By default, value(s) determined by this function also serves as value(s) sent on form submit * (if not overridden by 'sendOptionValue' prop). * Ex. (item: Item) => item.id */ getOptionValue?: (item: T) => unknown; /** * Optional prop for overriding the default behaviour of the component which is to send values set by 'getOptionValue' prop on submit. * Turn this prop off if you wish to send whole objects on submit instead of a value/array of values determined by 'getOptionValue'. * On by default. */ sendOptionValue?: boolean; } & Omit<AutocompleteProps<T>, AutocompleteOnlyPropsUnion> & Pick<InputFieldProps, "valueTransform">; export default function AutocompleteField<T>({ name, options, getOptionValue, sendOptionValue, valueTransform, ...props }: AutocompleteFieldProps<T>): JSX.Element; export {};