2023-03-01 10:20:57 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* ListBox is used to select one or more values from a list of items.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/listbox/)
|
|
|
|
*
|
|
|
|
* @module listbox
|
|
|
|
*
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
import { InputHTMLAttributes, VNode } from 'vue';
|
|
|
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
2023-03-01 10:20:57 +00:00
|
|
|
import { VirtualScrollerItemOptions, VirtualScrollerProps } from '../virtualscroller';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 10:20:57 +00:00
|
|
|
/**
|
|
|
|
* Custom change event.
|
|
|
|
* @see {@link ListboxEmits.change}
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ListboxChangeEvent {
|
|
|
|
/**
|
|
|
|
* Original event
|
|
|
|
*/
|
|
|
|
originalEvent: Event;
|
|
|
|
/**
|
|
|
|
* Selected option value
|
|
|
|
*/
|
|
|
|
value: any;
|
|
|
|
}
|
|
|
|
|
2023-03-01 10:20:57 +00:00
|
|
|
/**
|
|
|
|
* Custom filter event.
|
|
|
|
* @see {@link ListboxEmits.filter}
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ListboxFilterEvent {
|
|
|
|
/**
|
|
|
|
* Original event
|
|
|
|
*/
|
|
|
|
originalEvent: Event;
|
|
|
|
/**
|
|
|
|
* Filter value
|
|
|
|
*/
|
|
|
|
value: string;
|
|
|
|
}
|
|
|
|
|
2023-03-01 10:20:57 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in Listbox component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ListboxProps {
|
|
|
|
/**
|
|
|
|
* 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:20:57 +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:20:57 +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:20:57 +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:20:57 +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:20:57 +00:00
|
|
|
optionGroupChildren?: string | ((data: any) => any[]) | undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Inline style of inner list element.
|
|
|
|
*/
|
|
|
|
listStyle?: string | undefined;
|
|
|
|
/**
|
|
|
|
* When specified, disables the component.
|
2023-03-01 10:20:57 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
disabled?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* A property to uniquely identify an option.
|
|
|
|
*/
|
|
|
|
dataKey?: string | undefined;
|
|
|
|
/**
|
|
|
|
* When specified, allows selecting multiple values.
|
2023-03-01 10:20:57 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
multiple?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually.
|
|
|
|
* On touch enabled devices, metaKeySelection is turned off automatically.
|
2023-04-24 17:19:57 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
metaKeySelection?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* When specified, displays a filter input at header.
|
2023-03-01 10:20:57 +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-08 10:51:52 +00:00
|
|
|
* @defaultValue contains
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
2023-03-27 08:09:36 +00:00
|
|
|
filterMatchMode?: 'contains' | 'startsWith' | 'endsWith' | string | undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Fields used when filtering the options, defaults to optionLabel.
|
|
|
|
*/
|
|
|
|
filterFields?: string[] | undefined;
|
|
|
|
/**
|
|
|
|
* Uses to pass all properties of the HTMLInputElement to the filter input inside the component.
|
|
|
|
*/
|
|
|
|
filterInputProps?: InputHTMLAttributes | undefined;
|
|
|
|
/**
|
|
|
|
* Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it.
|
2023-03-01 10:20:57 +00:00
|
|
|
* @type {VirtualScrollerProps}
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
virtualScrollerOptions?: VirtualScrollerProps;
|
|
|
|
/**
|
|
|
|
* Whether to focus on the first visible or selected element.
|
2023-03-01 10:20:57 +00:00
|
|
|
* @defaultValue true
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
autoOptionFocus?: boolean | undefined;
|
2022-09-14 11:26:01 +00:00
|
|
|
/**
|
|
|
|
* When enabled, the focused option is selected.
|
2023-03-01 10:20:57 +00:00
|
|
|
* @defaultValue false
|
2022-09-14 11:26:01 +00:00
|
|
|
*/
|
|
|
|
selectOnFocus?: 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-08 11:02:08 +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-08 11:02:08 +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-08 10:51:52 +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-08 10:51:52 +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-08 10:51:52 +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;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Icon to display in filter input.
|
2023-04-18 10:51:10 +00:00
|
|
|
* @deprecated since v3.27.0. Use 'filtericon' slot.
|
2022-12-08 11:04:25 +00:00
|
|
|
*/
|
|
|
|
filterIcon?: string | undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* 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:20:57 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in Listbox component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface ListboxSlots {
|
|
|
|
/**
|
|
|
|
* Custom header template.
|
|
|
|
* @param {Object} scope - header slot's params.
|
|
|
|
*/
|
2023-03-01 10:20:57 +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:20:57 +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:20:57 +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:20:57 +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:20:57 +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:20:57 +00:00
|
|
|
}): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Custom optiongroup template.
|
|
|
|
* @param {Object} scope - optiongroup slot's params.
|
|
|
|
*/
|
2023-03-01 10:20:57 +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:20:57 +00:00
|
|
|
}): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Custom emptyfilter template.
|
|
|
|
*/
|
2023-03-01 10:20:57 +00:00
|
|
|
emptyfilter(): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Custom empty template.
|
|
|
|
*/
|
2023-03-01 10:20:57 +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:20:57 +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:20:57 +00:00
|
|
|
* @return {VirtualScrollerItemOptions}
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
getItemOptions(index: number): VirtualScrollerItemOptions;
|
2023-03-01 10:20:57 +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:20:57 +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:20:57 +00:00
|
|
|
}): VNode[];
|
2023-04-04 12:40:49 +00:00
|
|
|
/**
|
|
|
|
* Custom filter icon template.
|
|
|
|
*/
|
|
|
|
filtericon(): VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 10:20:57 +00:00
|
|
|
/**
|
|
|
|
* Defines valid emits in Listbox component.
|
|
|
|
*/
|
|
|
|
export interface ListboxEmits {
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Emitted when the value changes.
|
|
|
|
* @param {*} value - New value.
|
|
|
|
*/
|
2023-03-01 10:20:57 +00:00
|
|
|
'update:modelValue'(value: any): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke on value change.
|
|
|
|
* @param {ListboxChangeEvent} event - Custom change event.
|
|
|
|
*/
|
2023-03-01 10:20:57 +00:00
|
|
|
change(event: ListboxChangeEvent): 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:20:57 +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:20:57 +00:00
|
|
|
blur(event: Event): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke on filter input.
|
|
|
|
* @param {ListboxFilterEvent} event - Custom filter event.
|
|
|
|
*/
|
2023-03-01 10:20:57 +00:00
|
|
|
filter(event: ListboxFilterEvent): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 10:20:57 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - Listbox**
|
|
|
|
*
|
|
|
|
* _ListBox is used to select one or more values from a list of items._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/listbox/)
|
|
|
|
* --- ---
|
2023-03-03 10:55:20 +00:00
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
2023-03-01 10:20:57 +00:00
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*
|
|
|
|
*/
|
2022-09-14 11:26:01 +00:00
|
|
|
declare class Listbox extends ClassComponent<ListboxProps, ListboxSlots, ListboxEmits> {}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
declare module '@vue/runtime-core' {
|
|
|
|
interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
Listbox: GlobalComponentConstructor<Listbox>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Listbox;
|