import React from "react"; import { HTMLInputProps as BlueprintHTMLInputProps } from "@blueprintjs/core"; import { MultiSelectProps as BlueprintMultiSelectProps } from "@blueprintjs/select"; import { IntentBlueprint } from "../../common/Intent"; import { TestableComponent } from "../interfaces"; import { ContextOverlayProps } from "./../../index"; export interface MultiSuggestFieldSelectionProps { newlySelected?: T; newlyRemoved?: T; selectedItems: T[]; createdItems: Partial[]; } export interface MultiSuggestFieldCommonProps extends TestableComponent, Pick, "items" | "placeholder" | "openOnKeyDown" | "noResults" | "createNewItemRenderer">, Partial, "itemRenderer">> { /** * Additional class name, space separated. */ className?: string; /** * Returns the unique ID of an item. This will be used for equality of items. */ itemId: (item: T) => string; /** * Returns the label of an item. * this would be used in the item selection list as well as the multi-select input */ itemLabel: (item: T) => string; /** * function handler that would be called anytime an item is selected/deselected or an item is created/removed */ onSelection?: (params: MultiSuggestFieldSelectionProps) => void; /** * Props to spread to `ContextOverlay`. Note that `content` cannot be changed. */ contextOverlayProps?: Partial>; /** * Props to spread to `TagInput`. Use `query` and `onQueryChange` to control the input. */ tagInputProps?: BlueprintMultiSelectProps["tagInputProps"]; /** Additional properties for the (query) input field of the multi-selection. */ inputProps?: BlueprintHTMLInputProps; /** * prop to listen for query changes, when text is entered in the multi-select input */ runOnQueryChange?: (query: string) => Promise | (T[] | undefined); /** * Whether the component should take up the full width of its container. * This overrides `tagInputProps.fill`. */ fullWidth?: boolean; /** * text content to render when filtering items returns zero results. * If omitted, "No results." will be rendered in this case. */ noResultText?: string; /** * text content to render when a new item non-existing in filtered items is about to be created . * If omitted, "No results." will be rendered in this case. */ newItemCreationText?: string; /** * Allows to create new item from a given query. If this is not provided then no new items can be created. */ createNewItemFromQuery?: (query: string) => T; /** Validates if a new item can be created from the current query string. */ isValidNewOption?: (query: string) => boolean; /** * Items that were newly created and not taken from the list will be post-fixed with this string. */ newItemPostfix?: string; /** * Intent state of the multi select. */ intent?: IntentBlueprint | "accent"; /** * Disables the input element */ disabled?: boolean; /** * Delay in ms how long the request for the given query should be delayed. */ requestDelay?: number; /** * Clear query when an option is selected or unselected. * The query is empty then and the user need to enter a new query. */ clearQueryOnSelection?: boolean; /** * If set then a `div` element is used as wrapper. * It uses the attributes given via this property. */ wrapperProps?: React.HTMLAttributes; /** * Function that allows us to filter values from the option list. * * @deprecated (v27) use `searchListPredicate` instead. */ searchPredicate?: (item: T, query: string) => boolean; /** * Returns the filtered the search option list. * By default, a case-insensitive multi-word filtering is applied. * * @param items The options. * @param query The search query. */ searchListPredicate?: (items: T[], query: string) => T[]; /** * Limits the height of the input target plus its dropdown menu when it is opened. * Need to be a `number not greater than 100` (as `vh`, a unit describing a length relative to the viewport height) or `true` (equals 100). * If not set than the dropdown menu cannot be larger that appr. the half of the available viewport hight. */ limitHeightOpened?: boolean | number; } export type MultiSuggestFieldProps = MultiSuggestFieldCommonProps & ({ /** * Predefined selected values. * `prePopulateWithItems` cannot be used then. */ selectedItems?: T[]; prePopulateWithItems?: never; } | { selectedItems?: never; /** * When set to `true` will set the multi-select value with all the items provided. * `selectedItems` cannot be used then. */ prePopulateWithItems?: boolean; }); /** * Element behaves very similar to `SuggestField` but allows multiple selections. * Its value does not represent a string but a stack of objects. * * Example usage: input field for user created tags. * * Attention: there may be another `MultiSelect` component in future but this will be a re-implemented `Select` like element allowing multiple selections. */ export declare function MultiSuggestField({ items, selectedItems: externalSelectedItems, prePopulateWithItems, itemId, itemLabel, onSelection, contextOverlayProps, tagInputProps, inputProps, runOnQueryChange, fullWidth, noResultText, newItemCreationText, newItemPostfix, disabled, createNewItemFromQuery, isValidNewOption, requestDelay, clearQueryOnSelection, className, "data-test-id": dataTestId, "data-testid": dataTestid, wrapperProps, searchPredicate, searchListPredicate, limitHeightOpened, intent, ...otherMultiSelectProps }: MultiSuggestFieldProps): React.JSX.Element;