UNPKG

@gpa-gemstone/react-forms

Version:
52 lines (51 loc) 1.8 kB
import * as React from 'react'; import { Gemstone } from '@gpa-gemstone/application-typings'; export interface IProps<T> extends Omit<Gemstone.TSX.Interfaces.IBaseFormProps<T>, 'Setter'> { /** * Function to determine the validity of a field * @param field - Field of the record to check * @returns {boolean} */ Valid?: (field: keyof T) => boolean; /** * Feedback message to show when input is invalid * @type {string} * @optional */ Feedback?: string; /** * Flag to allow custom input values * @type {boolean} * @optional */ AllowCustom?: boolean; /** * Function to perform a search and return a promiselike object with a list of IOption and an optional callback * @param search - Search string * @returns {AbortablePromise<T>} */ Search: (search: string) => Gemstone.TSX.Interfaces.AbortablePromise<Gemstone.TSX.Interfaces.ILabelValue<string | number>[]>; /** * CSS styles to apply to the form group * @type {React.CSSProperties} * @optional */ Style?: React.CSSProperties; /** * CSS style to apply to the button holding the selected value * @type {React.CSSProperties} * @optional */ BtnStyle?: React.CSSProperties; GetLabel?: () => Gemstone.TSX.Interfaces.AbortablePromise<string>; /** * Flag to reset search text to an empty string when a user selects an option or when the element loses focus. Defaulting to false */ ResetSearchOnSelect?: boolean; /** * Setter function to update the Record * @param record - Updated Record */ Setter: (record: T, selectedOption: Gemstone.TSX.Interfaces.ILabelValue<string | number>) => void; } export default function SearchableSelect<T>(props: IProps<T>): JSX.Element;