primevue-mirror/components/multiselect/MultiSelect.d.ts

507 lines
14 KiB
TypeScript
Raw Normal View History

2023-03-01 10:58:06 +00:00
/**
*
* MultiSelect is used to select multiple items from a collection.
*
* [Live Demo](https://www.primevue.org/multiselect/)
*
* @module multiselect
*
*/
2022-09-06 12:03:37 +00:00
import { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes, VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
2023-03-01 10:58:06 +00:00
import { VirtualScrollerItemOptions, VirtualScrollerProps } from '../virtualscroller';
2022-09-06 12:03:37 +00:00
2023-03-01 10:58:06 +00:00
/**
* Custom change event.
* @see {@link MultiSelectEmits.change}
*/
2022-09-06 12:03:37 +00:00
export interface MultiSelectChangeEvent {
/**
* Browser event
*/
originalEvent: Event;
/**
* Selected option value
*/
value: any;
}
2023-03-01 10:58:06 +00:00
/**
* Custom all change event.
2023-03-01 11:03:53 +00:00
* @see {@link MultiSelectEmits['selectall-change']}
2023-03-01 10:58:06 +00:00
*/
2022-09-06 12:03:37 +00:00
export interface MultiSelectAllChangeEvent {
/**
* Browser event
*/
originalEvent: Event;
/**
* Whether all data is selected.
*/
checked: boolean;
}
2023-03-01 10:58:06 +00:00
/**
* Custom filter event
* @see {@link MultiSelectEmits.filter}
*/
2022-09-06 12:03:37 +00:00
export interface MultiSelectFilterEvent {
/**
* Original event
*/
originalEvent: Event;
/**
* Filter value
*/
value: string;
}
2023-03-01 10:58:06 +00:00
/**
* Defines valid properties in MultiSelect component.
*/
2022-09-06 12:03:37 +00:00
export interface MultiSelectProps {
/**
* Value of the component.
*/
modelValue?: any;
/**
* An array of selectitems to display as the available options.
*/
options?: any[] | undefined;
/**
* Property name or getter function to use as the label of an option.
*/
2023-03-01 10:58:06 +00:00
optionLabel?: string | ((data: any) => string) | undefined;
2022-09-06 12:03:37 +00:00
/**
* Property name or getter function to use as the value of an option, defaults to the option itself when not defined.
*/
2023-03-01 10:58:06 +00:00
optionValue?: string | ((data: any) => any) | undefined;
2022-09-06 12:03:37 +00:00
/**
* Property name or getter function to use as the disabled flag of an option, defaults to false when not defined.
*/
2023-03-01 10:58:06 +00:00
optionDisabled?: string | ((data: any) => boolean) | undefined;
2022-09-06 12:03:37 +00:00
/**
* Property name or getter function to use as the label of an option group.
*/
2023-03-01 10:58:06 +00:00
optionGroupLabel?: string | ((data: any) => string) | undefined;
2022-09-06 12:03:37 +00:00
/**
* Property name or getter function that refers to the children options of option group.
*/
2023-03-01 10:58:06 +00:00
optionGroupChildren?: string | ((data: any) => any[]) | undefined;
2022-09-06 12:03:37 +00:00
/**
* Height of the viewport, a scrollbar is defined if height of list exceeds this value.
2023-03-03 08:18:55 +00:00
* @defaultValue '200px'
2022-09-06 12:03:37 +00:00
*/
scrollHeight?: string | undefined;
/**
* Label to display when there are no selections.
*/
placeholder?: string | undefined;
/**
* When present, it specifies that the component should be disabled.
2023-03-01 10:58:06 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
disabled?: boolean | undefined;
/**
* Identifier of the underlying input element.
*/
inputId?: string | undefined;
/**
* Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component.
*/
inputProps?: InputHTMLAttributes | undefined;
/**
* Inline style of the overlay panel.
*/
panelStyle?: any;
/**
* Style class of the overlay panel.
*/
panelClass?: any;
/**
* Uses to pass all properties of the HTMLDivElement to the overlay panel.
*/
panelProps?: HTMLAttributes | undefined;
/**
* Uses to pass all properties of the HTMLInputElement to the filter input inside the overlay panel.
*/
filterInputProps?: InputHTMLAttributes | undefined;
/**
* Uses to pass all properties of the HTMLButtonElement to the clear button inside the overlay panel.
*/
closeButtonProps?: ButtonHTMLAttributes | undefined;
/**
* A property to uniquely identify an option.
*/
dataKey?: string | undefined;
/**
* When specified, displays a filter input at header.
2023-03-01 10:58:06 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
filter?: boolean | undefined;
/**
* Placeholder text to show when filter input is empty.
*/
filterPlaceholder?: string | undefined;
/**
* Locale to use in filtering. The default locale is the host environment's current locale.
*/
filterLocale?: string | undefined;
/**
* Defines the filtering algorithm to use when searching the options.
2023-03-03 08:18:55 +00:00
* @defaultValue 'contains'
2022-09-06 12:03:37 +00:00
*/
2023-03-01 10:58:06 +00:00
filterMatchMode?: 'contains' | 'startsWith' | 'endsWith' | undefined;
2022-09-06 12:03:37 +00:00
/**
* Fields used when filtering the options, defaults to optionLabel.
*/
filterFields?: string[] | undefined;
/**
* A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are 'body' for document body and 'self' for the element itself.
2023-03-03 08:18:55 +00:00
* @defaultValue 'body'
2022-09-06 12:03:37 +00:00
*/
2023-03-01 10:58:06 +00:00
appendTo?: 'body' | 'self' | string | undefined | HTMLElement;
2022-09-06 12:03:37 +00:00
/**
* Defines how the selected items are displayed.
2023-03-03 08:18:55 +00:00
* @defaultValue 'comma'
2022-09-06 12:03:37 +00:00
*/
2023-03-01 10:58:06 +00:00
display?: 'comma' | 'chip' | undefined;
2022-09-06 12:03:37 +00:00
/**
* Label to display after exceeding max selected labels.
2023-03-03 08:18:55 +00:00
* @defaultValue '{0} items selected'
2022-09-06 12:03:37 +00:00
*/
selectedItemsLabel?: string | undefined;
/**
* Decides how many selected item labels to show at most.
*/
maxSelectedLabels?: number | undefined;
/**
* Maximum number of selectable items.
*/
selectionLimit?: number | undefined;
/**
* Whether to show the header checkbox to toggle the selection of all items at once.
2023-03-01 10:58:06 +00:00
* @defaultValue true
2022-09-06 12:03:37 +00:00
*/
showToggleAll?: boolean | undefined;
/**
* Whether the multiselect is in loading state.
2023-03-01 10:58:06 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
loading?: boolean | undefined;
2022-12-08 11:04:25 +00:00
/**
* Icon to display in the checkboxes.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-check'
2022-12-08 11:04:25 +00:00
*/
checkboxIcon?: string | undefined;
/**
* Icon to display in the dropdown close button.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-times'
2022-12-08 11:04:25 +00:00
*/
closeIcon?: string | undefined;
/**
* Icon to display in the dropdown.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-chevron-down'
2022-12-08 11:04:25 +00:00
*/
dropdownIcon?: string | undefined;
/**
* Icon to display in filter input.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-search'
2022-12-08 11:04:25 +00:00
*/
filterIcon?: string | undefined;
2022-09-06 12:03:37 +00:00
/**
* Icon to display in loading state.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-spinner pi-spin'
2022-09-06 12:03:37 +00:00
*/
loadingIcon?: string | undefined;
2022-12-08 11:04:25 +00:00
/**
* Icon to display in chip remove action.
2023-03-03 08:18:55 +00:00
* @defaultValue 'pi pi-times-circle'
2022-12-08 11:04:25 +00:00
*/
removeTokenIcon?: string | undefined;
2022-09-06 12:03:37 +00:00
/**
* Whether all data is selected.
2023-03-01 10:58:06 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
selectAll?: boolean | undefined;
/**
* Clears the filter value when hiding the dropdown.
2023-03-01 10:58:06 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
2023-03-01 10:58:06 +00:00
resetFilterOnHide?: boolean | undefined;
2022-09-06 12:03:37 +00:00
/**
* Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it.
2023-03-01 10:58:06 +00:00
* @type {VirtualScrollerProps}
2022-09-06 12:03:37 +00:00
*/
virtualScrollerOptions?: VirtualScrollerProps;
/**
* Whether to focus on the first visible or selected element when the overlay panel is shown.
2023-03-01 10:58:06 +00:00
* @defaultValue true
2022-09-06 12:03:37 +00:00
*/
autoOptionFocus?: boolean | undefined;
2022-09-14 11:26:01 +00:00
/**
* Whether to focus on the filter element when the overlay panel is shown.
2023-03-01 10:58:06 +00:00
* @defaultValue false
2022-09-14 11:26:01 +00:00
*/
autoFilterFocus?: boolean | undefined;
2022-09-06 12:03:37 +00:00
/**
* Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration.
2023-03-03 08:18:55 +00:00
* @defaultValue '{0} results are available'
2022-09-06 12:03:37 +00:00
*/
filterMessage?: string | undefined;
/**
* Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration.
2023-03-03 08:18:55 +00:00
* @defaultValue '{0} items selected'
2022-09-06 12:03:37 +00:00
*/
selectionMessage?: string | undefined;
/**
* Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration.
2023-03-03 08:18:55 +00:00
* @defaultValue 'No selected item'
2022-09-06 12:03:37 +00:00
*/
emptySelectionMessage?: string | undefined;
/**
* Text to display when filtering does not return any results. Defaults to value from PrimeVue locale configuration.
2023-03-03 08:18:55 +00:00
* @defaultValue 'No results found'
2022-09-06 12:03:37 +00:00
*/
emptyFilterMessage?: string | undefined;
/**
* Text to display when there are no options available. Defaults to value from PrimeVue locale configuration.
2023-03-03 08:18:55 +00:00
* @defaultValue 'No results found'
2022-09-06 12:03:37 +00:00
*/
emptyMessage?: string | undefined;
/**
* Index of the element in tabbing order.
*/
tabindex?: number | string | undefined;
/**
* Defines a string value that labels an interactive element.
*/
2022-09-14 11:26:01 +00:00
'aria-label'?: string | undefined;
2022-09-06 12:03:37 +00:00
/**
* Identifier of the underlying input element.
*/
2022-09-14 11:26:01 +00:00
'aria-labelledby'?: string | undefined;
2022-09-06 12:03:37 +00:00
}
2023-03-01 10:58:06 +00:00
/**
* Defines valid slots in MultiSelect component.
*/
2022-09-06 12:03:37 +00:00
export interface MultiSelectSlots {
/**
* Custom value template.
* @param {Object} scope - value slot's params.
*/
2023-03-01 10:58:06 +00:00
value(scope: {
2022-09-06 12:03:37 +00:00
/**
* Value of the component
*/
value: any;
/**
* Placeholder prop value
*/
placeholder: string;
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom chip template.
* @param {Object} scope - chip slot's params.
*/
2023-03-01 10:58:06 +00:00
chip(scope: {
2022-09-06 12:03:37 +00:00
/**
* A value in the selection
*/
value: any;
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom indicator template.
*/
2023-03-01 10:58:06 +00:00
indicator(): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom header template.
* @param {Object} scope - header slot's params.
*/
2023-03-01 10:58:06 +00:00
header(scope: {
2022-09-06 12:03:37 +00:00
/**
* Value of the component
*/
value: any;
/**
* Displayed options
*/
options: any[];
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom footer template.
* @param {Object} scope - footer slot's params.
*/
2023-03-01 10:58:06 +00:00
footer(scope: {
2022-09-06 12:03:37 +00:00
/**
* Value of the component
*/
value: any;
/**
* Displayed options
*/
options: any[];
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom option template.
* @param {Object} scope - option slot's params.
*/
2023-03-01 10:58:06 +00:00
option(scope: {
2022-09-06 12:03:37 +00:00
/**
* Option instance
*/
option: any;
/**
* Index of the option
*/
index: number;
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom option group template.
* @param {Object} scope - option group slot's params.
*/
2023-03-01 10:58:06 +00:00
optiongroup(scope: {
2022-09-06 12:03:37 +00:00
/**
* Option instance
*/
option: any;
/**
* Index of the option
*/
index: number;
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom emptyfilter template.
*/
2023-03-01 10:58:06 +00:00
emptyfilter(): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom empty template.
*/
2023-03-01 10:58:06 +00:00
empty(): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom content template.
* @param {Object} scope - content slot's params.
*/
2023-03-01 10:58:06 +00:00
content(scope: {
2022-09-06 12:03:37 +00:00
/**
* An array of objects to display for virtualscroller
*/
items: any;
/**
* Style class of the component
*/
styleClass: string;
/**
* Referance of the content
* @param {HTMLElement} el - Element of 'ref' property
*/
contentRef(el: any): void;
/**
* Options of the items
* @param {number} index - Rendered index
2023-03-01 10:58:06 +00:00
* @return {VirtualScrollerItemOptions}
2022-09-06 12:03:37 +00:00
*/
getItemOptions(index: number): VirtualScrollerItemOptions;
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom loader template.
* @param {Object} scope - loader slot's params.
*/
2023-03-01 10:58:06 +00:00
loader(scope: {
2022-09-06 12:03:37 +00:00
/**
* Options of the loader items for virtualscroller
*/
options: any[];
2023-03-01 10:58:06 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
}
2023-03-01 10:58:06 +00:00
/**
* Defines valid emits in MultiSelect component.
*/
export interface MultiSelectEmits {
2022-09-06 12:03:37 +00:00
/**
* Emitted when the value changes.
* @param {*} value - New value.
*/
2023-03-01 10:58:06 +00:00
'update:modelValue'(value: any): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on value change.
* @param {MultiSelectChangeEvent} event - Custom change event.
*/
2023-03-01 10:58:06 +00:00
change(event: MultiSelectChangeEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when the component receives focus.
* @param {Event} event - Browser event.
*/
2023-03-01 10:58:06 +00:00
focus(event: Event): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when the component loses focus.
* @param {Event} event - Browser event.
*/
2023-03-01 10:58:06 +00:00
blur(event: Event): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke before the overlay is shown.
*/
2023-03-01 10:58:06 +00:00
'before-show'(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke before the overlay is hidden.
*/
2023-03-01 10:58:06 +00:00
'before-hide'(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when the overlay is shown.
*/
2023-03-01 10:58:06 +00:00
show(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when the overlay is hidden.
*/
2023-03-01 10:58:06 +00:00
hide(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on filter input.
* @param {MultiSelectFilterEvent} event - Custom filter event.
*/
2023-03-01 10:58:06 +00:00
filter(event: MultiSelectFilterEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when all data is selected.
* @param {MultiSelectAllChangeEvent} event - Custom select all change event.
*/
2023-03-01 10:58:06 +00:00
'selectall-change'(event: MultiSelectAllChangeEvent): void;
}
2022-09-06 12:03:37 +00:00
2023-03-01 10:58:06 +00:00
/**
* **PrimeVue - MultiSelect**
*
* _MultiSelect is used to select multiple items from a collection._
*
* [Live Demo](https://www.primevue.org/multiselect/)
* --- ---
2023-03-03 10:55:20 +00:00
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
2023-03-01 10:58:06 +00:00
*
* @group Component
*
*/
2022-09-06 12:03:37 +00:00
declare class MultiSelect extends ClassComponent<MultiSelectProps, MultiSelectSlots, MultiSelectEmits> {
/**
* Shows the overlay.
* @param {boolean} [isFocus] - Decides whether to focus on the component. Default value is false.
*
* @memberof MultiSelect
*/
2023-03-01 10:58:06 +00:00
show(isFocus?: boolean): void;
2022-09-06 12:03:37 +00:00
/**
* Hides the overlay.
* @param {boolean} [isFocus] - Decides whether to focus on the component. Default value is false.
*
* @memberof MultiSelect
*/
2023-03-01 10:58:06 +00:00
hide(isFocus?: boolean): void;
2022-09-06 12:03:37 +00:00
}
declare module '@vue/runtime-core' {
interface GlobalComponents {
2022-09-14 11:26:01 +00:00
MultiSelect: GlobalComponentConstructor<MultiSelect>;
2022-09-06 12:03:37 +00:00
}
}
export default MultiSelect;