import { Field, FieldInstance } from "./Field"; import { BindingInput } from "../../data/Binding"; import { DropdownConfig } from "../overlay/Dropdown"; import { AccessorChain } from "../../data/createAccessorModelProxy"; import type { CxChild, RenderingContext } from "../../ui/RenderingContext"; import type { Instance } from "../../ui/Instance"; import { FieldConfig } from "./Field"; import { Prop, BooleanProp, StringProp, StructuredProp, DataRecord } from "../../ui/Prop"; export interface LookupBinding { local: string | AccessorChain; remote: string | AccessorChain; key?: boolean; } /** Paged query parameters for infinite scrolling mode */ export interface LookupFieldPagedQueryParams { query: string; page: number; pageSize: number; } /** Common LookupField properties shared across all variants */ interface LookupFieldBaseConfig extends FieldConfig { /** The opposite of `disabled`. */ enabled?: BooleanProp; /** Defaults to `false`. Used to make the field read-only. */ readOnly?: BooleanProp; /** Default text displayed when the field is empty. */ placeholder?: StringProp; /** A list of available options. */ options?: Prop; /** Set to `true` to hide the clear button. Default value is `false`. */ hideClear?: boolean; /** Set to `false` to hide the clear button. Default value is `true`. */ showClear?: boolean; /** Set to `true` to display the clear button even if `required` is set. Default is `false`. */ alwaysShowClear?: boolean; /** Base CSS class to be applied to the field. Defaults to `lookupfield`. */ baseClass?: string; /** Name or configuration of the icon to be put on the left side of the input. */ icon?: StringProp | Record; /** Additional config to be applied to all items. */ itemConfig?: any; /** An array of objects describing the mapping of option data to store data. */ bindings?: LookupBinding[]; /** A delay in milliseconds between typing stop and query. Default is `150`. */ queryDelay?: number; /** Minimal number of characters required before query is made. */ minQueryLength?: number; /** Set to `true` to hide the search field. */ hideSearchField?: boolean; /** Number of options required to show search field. Defaults to `7`. */ minOptionsForSearchField?: number; /** Text to display while data is being loaded. */ loadingText?: string; /** Error message displayed if server query throws an exception. */ queryErrorText?: string; /** Message to be displayed if no entries match the user query. */ noResultsText?: string; /** Name of the field which holds the id of the option. Default is `id`. */ optionIdField?: string; /** Name of the field which holds the display text of the option. Default is `text`. */ optionTextField?: string; /** Name of the field to store id of selected value in multiple mode. Default is `id`. */ valueIdField?: string; /** Name of the field to store display text of selected value. Default is `text`. */ valueTextField?: string; /** `onQuery` will be called once to fetch all options; filtering occurs client-side. */ fetchAll?: boolean; /** When set with `fetchAll`, fetched options are cached for widget lifetime. */ cacheAll?: boolean; /** Close the dropdown after selection. Default is `true`. */ closeOnSelect?: boolean; /** Message displayed if the entered search query is too short. */ minQueryLengthMessageText?: string; /** Set to `true` to sort dropdown options. */ sort?: boolean; /** Additional list options, such as grouping configuration, custom sorting, etc. */ listOptions?: Record; /** Show dropdown immediately after component mount; useful for cell editing. */ autoOpen?: BooleanProp; /** Allow enter key events to propagate; useful for forms or grid cell editors. */ submitOnEnterKey?: BooleanProp; /** Allow dropdown enter key events to propagate for form submission. */ submitOnDropdownEnterKey?: BooleanProp; /** Allow quick selection of all displayed items on `Ctrl + A` key combination. */ quickSelectAll?: boolean; /** Parameters that affect filtering. */ filterParams?: StructuredProp; /** Callback to create a filter function for given filter params. */ onCreateVisibleOptionsFilter?: string | ((filterParams: any, instance: Instance) => (option: TOption) => boolean); /** Additional configuration to be passed to the dropdown, such as `style`, `positioning`, etc. */ dropdownOptions?: Partial; /** Custom validation function. */ onValidate?: string | ((value: number | string, instance: Instance, validationParams: Record) => unknown); } /** Props for infinite mode: uses onQueryPage */ interface LookupFieldInfiniteProps { /** Enable infinite scrolling. */ infinite: true; /** Number of items per page. Default is `100`. */ pageSize?: number; /** Query function for infinite mode. */ onQueryPage: string | ((params: LookupFieldPagedQueryParams, instance: Instance) => TOption[] | Promise); } /** Props for standard mode: uses onQuery */ interface LookupFieldStandardProps { /** Standard mode (no infinite scrolling). */ infinite?: false; onQuery?: string | ((query: string, instance: Instance) => TOption[] | Promise); } /** Props for multiple selection mode */ interface LookupFieldMultipleProps { /** Enable multiple selection. */ multiple: true; /** A list of selected ids. */ values?: Prop<(number | string)[]>; /** A list of selected records. */ records?: Prop; /** Custom display text for records. */ onGetRecordDisplayText?: ((record: TRecord, instance: Instance) => string) | null; } /** Props for single selection mode */ interface LookupFieldSingleProps { /** Single selection (default). */ multiple?: false; /** Selected value. */ value?: Prop; /** Text associated with the selection. */ text?: StringProp; } type LookupFieldInfiniteMultipleConfig = LookupFieldBaseConfig & LookupFieldInfiniteProps & LookupFieldMultipleProps; type LookupFieldInfiniteSingleConfig = LookupFieldBaseConfig & LookupFieldInfiniteProps & LookupFieldSingleProps; type LookupFieldStandardMultipleConfig = LookupFieldBaseConfig & LookupFieldStandardProps & LookupFieldMultipleProps; type LookupFieldStandardSingleConfig = LookupFieldBaseConfig & LookupFieldStandardProps & LookupFieldSingleProps; export type LookupFieldConfig = LookupFieldInfiniteMultipleConfig | LookupFieldInfiniteSingleConfig | LookupFieldStandardMultipleConfig | LookupFieldStandardSingleConfig; export interface LookupFieldUniversalConfig extends LookupFieldBaseConfig, Omit, "multiple">, Omit>, "multiple">, Omit>, "infinite">, Omit>, "infinite"> { multiple?: boolean; infinite?: boolean; } export declare class LookupField extends Field> { baseClass: string; multiple: boolean; hideClear?: boolean; showClear: boolean; alwaysShowClear: boolean; hideSearchField: boolean; minOptionsForSearchField: number; loadingText: string; queryErrorText: string; noResultsText: string; optionIdField: string; optionTextField: string; valueIdField: string; valueTextField: string; fetchAll: boolean; cacheAll: boolean; closeOnSelect: boolean; minQueryLengthMessageText: string; sort?: boolean; listOptions?: Record | null; autoOpen?: boolean; submitOnEnterKey?: boolean; submitOnDropdownEnterKey?: boolean; pageSize: number; infinite?: boolean; quickSelectAll?: boolean; queryDelay: number; minQueryLength: number; onGetRecordDisplayText?: ((record: Record, instance: Instance) => string) | null; onQuery?: string | ((query: string, instance: Instance) => Promise[]> | Record[]); onQueryPage?: string | ((params: LookupFieldPagedQueryParams, instance: Instance) => Promise[]> | Record[]); onCreateVisibleOptionsFilter?: string | ((filterParams: unknown, instance: Instance) => (option: Record) => boolean); value?: BindingInput; text?: BindingInput; records?: Record[]; values?: unknown[]; options?: Record[]; enabled?: boolean; placeholder?: string; readOnly?: boolean; dropdownOptions?: Partial; bindings?: BindingConfig[]; keyBindings?: BindingConfig[]; itemConfig?: CxChild; declareData(...args: Record[]): void; init(): void; prepareData(context: RenderingContext, instance: FieldInstance): void; renderInput(context: RenderingContext, instance: FieldInstance, key: string): React.ReactNode; filterOptions(instance: Instance, options: DataRecord[], query?: string): DataRecord[]; isEmpty(data: Record): boolean; getValidationValue(data: Record): unknown; formatValue(context: RenderingContext, instance: Instance): string | React.ReactNode; } interface BindingConfig { local: string; remote: string; key?: boolean; set?: (value: unknown, instance: Instance) => void; } export {}; //# sourceMappingURL=LookupField.d.ts.map