primevue-mirror/components/lib/dropdown/Dropdown.d.ts

456 lines
13 KiB
TypeScript
Raw Normal View History

2023-03-01 10:43:09 +00:00
/**
*
* Dropdown also known as Select, is used to choose an item from a collection of options.
*
2023-03-01 13:05:44 +00:00
* [Live Demo](https://www.primevue.org/dropdown/)
2023-03-01 10:43:09 +00:00
*
* @module dropdown
*
*/
2022-09-06 12:03:37 +00:00
import { HTMLAttributes, InputHTMLAttributes, VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
2022-09-14 11:26:01 +00:00
import { VirtualScrollerItemOptions, VirtualScrollerProps } from '../virtualscroller';
2022-09-06 12:03:37 +00:00
2023-03-01 10:43:09 +00:00
/**
* Custom change event.
2023-03-06 20:35:39 +00:00
* @see {@link DropdownEmits.change}
2023-03-01 10:43:09 +00:00
*/
2022-09-06 12:03:37 +00:00
export interface DropdownChangeEvent {
/**
* Browser event.
*/
originalEvent: Event;
/**
* Selected option value
*/
value: any;
}
2023-03-01 10:43:09 +00:00
/**
2023-03-03 14:17:03 +00:00
* Custom filter event.
2023-03-06 20:35:39 +00:00
* @see {@link DropdownEmits.filter}
2023-03-01 10:43:09 +00:00
*/
2022-09-06 12:03:37 +00:00
export interface DropdownFilterEvent {
/**
* Browser event.
*/
originalEvent: Event;
/**
* Filter value
*/
value: any;
}
2023-03-01 10:43:09 +00:00
/**
* Defines valid properties in Dropdown component.
*/
2022-09-06 12:03:37 +00:00
export interface DropdownProps {
/**
* Value of the component.
*/
modelValue?: any;
/**
* An array of selectitems to display as the available options.
*/
options?: any[];
/**
* Property name or getter function to use as the label of an option.
*/
2023-03-01 10:43:09 +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:43:09 +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:43:09 +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:43:09 +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:43:09 +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-08 10:51:52 +00:00
* @defaultValue 200px
2022-09-06 12:03:37 +00:00
*/
scrollHeight?: string | undefined;
/**
* When specified, displays a filter input at header.
2023-03-10 14:00:58 +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;
/**
* When present, custom value instead of predefined options can be entered using the editable input field.
2023-03-10 14:00:58 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
editable?: boolean | undefined;
/**
* Default text to display when no option is selected.
*/
placeholder?: string | undefined;
/**
* When present, it specifies that the component should be disabled.
2023-03-10 14:00:58 +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 enabled, a clear icon is displayed to clear the value.
2023-03-10 14:00:58 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
showClear?: boolean | undefined;
/**
* Identifier of the underlying input element.
*/
inputId?: string | undefined;
/**
* Inline style of the input field.
*/
inputStyle?: object | undefined;
2022-09-06 12:03:37 +00:00
/**
* Style class of the input field.
*/
inputClass?: string | object | undefined;
2022-09-06 12:03:37 +00:00
/**
* Uses to pass all properties of the HTMLInputElement/HTMLSpanElement to the focusable input element inside the component.
*/
inputProps?: InputHTMLAttributes | HTMLAttributes | undefined;
/**
* Inline style of the overlay panel.
*/
panelStyle?: object | undefined;
2022-09-06 12:03:37 +00:00
/**
* Style class of the overlay panel.
*/
panelClass?: string | object | undefined;
2022-09-06 12:03:37 +00:00
/**
* Uses to pass all properties of the HTMLDivElement to the overlay panel inside the component.
*/
panelProps?: HTMLAttributes | undefined;
/**
* Uses to pass all properties of the HTMLInputElement to the filter input inside the component.
*/
filterInputProps?: InputHTMLAttributes | undefined;
/**
* Uses to pass all properties of the HTMLElement to the clear icon inside the component.
*/
clearIconProps?: HTMLAttributes | undefined;
/**
2023-03-01 10:43:09 +00:00
* A valid query selector or an HTMLElement to specify where the overlay gets attached.
2023-03-08 10:51:52 +00:00
* @defaultValue body
2022-09-06 12:03:37 +00:00
*/
2023-03-01 10:43:09 +00:00
appendTo?: 'body' | 'self' | string | undefined | HTMLElement;
2022-09-06 12:03:37 +00:00
/**
* Whether the dropdown is in loading state.
2023-03-10 14:00:58 +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 clear button.
*/
clearIcon?: string | undefined;
/**
* Icon to display in the dropdown.
*/
dropdownIcon?: string | undefined;
/**
* Icon to display in filter input.
*/
filterIcon?: string | undefined;
2022-09-06 12:03:37 +00:00
/**
* Icon to display in loading state.
*/
loadingIcon?: string | undefined;
2022-09-14 11:26:01 +00:00
/**
* Clears the filter value when hiding the dropdown.
2023-03-10 14:00:58 +00:00
* @defaultValue false
2022-09-14 11:26:01 +00:00
*/
resetFilterOnHide?: boolean;
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.
*/
virtualScrollerOptions?: VirtualScrollerProps;
/**
* Whether to focus on the first visible or selected element when the overlay panel is shown.
2023-03-01 10:43:09 +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:43:09 +00:00
* @defaultValue false
2022-09-14 11:26:01 +00:00
*/
autoFilterFocus?: boolean | undefined;
/**
* When enabled, the focused option is selected.
2023-03-01 10:43:09 +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 foun
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:43:09 +00:00
/**
* Defines valid slots in Dropdown component.
*/
2022-09-06 12:03:37 +00:00
export interface DropdownSlots {
/**
* Custom value template.
* @param {Object} scope - value slot's params.
*/
2023-03-01 10:43:09 +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:43:09 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom indicator template.
*/
2023-03-01 10:43:09 +00:00
indicator(): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom header template of panel.
* @param {Object} scope - header slot's params.
*/
2023-03-01 10:43:09 +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:43:09 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom footer template of panel.
* @param {Object} scope - footer slot's params.
*/
2023-03-01 10:43:09 +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:43:09 +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:43:09 +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:43:09 +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:43:09 +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:43:09 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom empty filter template.
*/
2023-03-01 10:43:09 +00:00
emptyfilter(): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom empty template.
*/
2023-03-01 10:43:09 +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:43:09 +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
* @return {@link VirtualScroller.VirtualScrollerItemOptions}
*/
getItemOptions(index: number): VirtualScrollerItemOptions;
2023-03-01 10:43:09 +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:43:09 +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:43:09 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
}
2023-03-01 10:43:09 +00:00
/**
* Defines valid emits in Dropdown component.
*/
export interface DropdownEmits {
2022-09-06 12:03:37 +00:00
/**
* Emitted when the value changes.
* @param {*} value - New value.
*/
2023-03-01 10:43:09 +00:00
'update:modelValue'(value: any): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on value change.
* @param {DropdownChangeEvent} event - Custom change event.
*/
2023-03-01 10:43:09 +00:00
change(event: DropdownChangeEvent): 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:43:09 +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:43:09 +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:43:09 +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:43:09 +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:43:09 +00:00
show(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when the overlay is hidden.
*/
2023-03-01 10:43:09 +00:00
hide(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on filter input.
* @param {DropdownFilterEvent} event - Custom filter event.
*/
2023-03-01 10:43:09 +00:00
filter(event: DropdownFilterEvent): void;
}
2022-09-06 12:03:37 +00:00
2023-03-01 10:43:09 +00:00
/**
* **PrimeVue - Dropdown**
*
* _Dropdown also known as Select, is used to choose an item from a collection of options._
*
* [Live Demo](https://www.primevue.org/dropdown/)
* --- ---
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
*
* @group Component
*/
2023-03-01 14:48:23 +00:00
declare class Dropdown extends ClassComponent<DropdownProps, DropdownSlots, DropdownEmits> {
2022-09-06 12:03:37 +00:00
/**
* Shows the overlay.
2023-03-01 10:43:09 +00:00
* @param {boolean} [isFocus] - Decides whether to focus on the component. @defaultValue false.
2022-09-06 12:03:37 +00:00
*
* @memberof Dropdown
*/
show: (isFocus?: boolean) => void;
/**
* Hides the overlay.
2023-03-01 10:43:09 +00:00
* @param {boolean} [isFocus] - Decides whether to focus on the component. @defaultValue false.
2022-09-06 12:03:37 +00:00
*
* @memberof Dropdown
*/
hide: (isFocus?: boolean) => void;
}
declare module '@vue/runtime-core' {
interface GlobalComponents {
2022-09-14 11:26:01 +00:00
Dropdown: GlobalComponentConstructor<Dropdown>;
2022-09-06 12:03:37 +00:00
}
}
export default Dropdown;