Dropdown d.ts updated

pull/3689/head
Tuğçe Küçükoğlu 2023-03-01 13:43:09 +03:00
parent 6582826b81
commit 22a13a4f2f
1 changed files with 91 additions and 74 deletions

View File

@ -1,19 +1,20 @@
/**
*
* Dropdown also known as Select, is used to choose an item from a collection of options.
*
* [Live Demo](https://www.primereact.org/dropdown/)
*
* @module dropdown
*
*/
import { HTMLAttributes, InputHTMLAttributes, VNode } from 'vue'; import { HTMLAttributes, InputHTMLAttributes, VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
import { VirtualScrollerItemOptions, VirtualScrollerProps } from '../virtualscroller'; import { VirtualScrollerItemOptions, VirtualScrollerProps } from '../virtualscroller';
type DropdownOptionLabelType = string | ((data: any) => string) | undefined; /**
* Custom change event.
type DropdownOptionValueType = string | ((data: any) => any) | undefined; * @see {@link DropdownEmits.change}
*/
type DropdownOptionDisabledType = string | ((data: any) => boolean) | undefined;
type DropdownOptionChildrenType = string | ((data: any) => any[]) | undefined;
type DropdownFilterMatchModeType = 'contains' | 'startsWith' | 'endsWith' | undefined;
type DropdownAppendToType = 'body' | 'self' | string | undefined | HTMLElement;
export interface DropdownChangeEvent { export interface DropdownChangeEvent {
/** /**
* Browser event. * Browser event.
@ -25,6 +26,10 @@ export interface DropdownChangeEvent {
value: any; value: any;
} }
/**
* Custom filetr event.
* @see {@link DropdownEmits.filter}
*/
export interface DropdownFilterEvent { export interface DropdownFilterEvent {
/** /**
* Browser event. * Browser event.
@ -36,6 +41,9 @@ export interface DropdownFilterEvent {
value: any; value: any;
} }
/**
* Defines valid properties in Dropdown component.
*/
export interface DropdownProps { export interface DropdownProps {
/** /**
* Value of the component. * Value of the component.
@ -47,32 +55,27 @@ export interface DropdownProps {
options?: any[]; options?: any[];
/** /**
* Property name or getter function to use as the label of an option. * Property name or getter function to use as the label of an option.
* @see DropdownOptionLabelType
*/ */
optionLabel?: DropdownOptionLabelType; optionLabel?: string | ((data: any) => string) | undefined;
/** /**
* Property name or getter function to use as the value of an option, defaults to the option itself when not defined. * Property name or getter function to use as the value of an option, defaults to the option itself when not defined.
* @see DropdownOptionValueType
*/ */
optionValue?: DropdownOptionValueType; optionValue?: string | ((data: any) => any) | undefined;
/** /**
* Property name or getter function to use as the disabled flag of an option, defaults to false when not defined. * Property name or getter function to use as the disabled flag of an option, defaults to false when not defined.
* @see DropdownOptionDisabledType
*/ */
optionDisabled?: DropdownOptionDisabledType; optionDisabled?: string | ((data: any) => boolean) | undefined;
/** /**
* Property name or getter function to use as the label of an option group. * Property name or getter function to use as the label of an option group.
* @see DropdownOptionLabelType
*/ */
optionGroupLabel?: DropdownOptionLabelType; optionGroupLabel?: string | ((data: any) => string) | undefined;
/** /**
* Property name or getter function that refers to the children options of option group. * Property name or getter function that refers to the children options of option group.
* @see DropdownOptionChildrenType
*/ */
optionGroupChildren?: DropdownOptionChildrenType; optionGroupChildren?: string | ((data: any) => any[]) | undefined;
/** /**
* Height of the viewport, a scrollbar is defined if height of list exceeds this value. * Height of the viewport, a scrollbar is defined if height of list exceeds this value.
* Default value is '200px'. * @defaultValue 200px
*/ */
scrollHeight?: string | undefined; scrollHeight?: string | undefined;
/** /**
@ -89,10 +92,9 @@ export interface DropdownProps {
filterLocale?: string | undefined; filterLocale?: string | undefined;
/** /**
* Defines the filtering algorithm to use when searching the options. * Defines the filtering algorithm to use when searching the options.
* @see DropdownFilterMatchModeType * @defaultValue contains
* Default value is 'contains'.
*/ */
filterMatchMode?: DropdownFilterMatchModeType; filterMatchMode?: 'contains' | 'startsWith' | 'endsWith' | undefined;
/** /**
* Fields used when filtering the options, defaults to optionLabel. * Fields used when filtering the options, defaults to optionLabel.
*/ */
@ -154,33 +156,32 @@ export interface DropdownProps {
*/ */
clearIconProps?: HTMLAttributes | undefined; clearIconProps?: HTMLAttributes | 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. * A valid query selector or an HTMLElement to specify where the overlay gets attached.
* @see DropdownAppendToType * @defaultValue body
* Default value is 'body'.
*/ */
appendTo?: DropdownAppendToType; appendTo?: 'body' | 'self' | string | undefined | HTMLElement;
/** /**
* Whether the dropdown is in loading state. * Whether the dropdown is in loading state.
*/ */
loading?: boolean | undefined; loading?: boolean | undefined;
/** /**
* Icon to display in clear button. * Icon to display in clear button.
* Default value is 'pi pi-times'. * @defaultValue pi pi-times
*/ */
clearIcon?: string | undefined; clearIcon?: string | undefined;
/** /**
* Icon to display in the dropdown. * Icon to display in the dropdown.
* Default value is 'pi pi-chevron-down'. * @defaultValue pi pi-chevron-down
*/ */
dropdownIcon?: string | undefined; dropdownIcon?: string | undefined;
/** /**
* Icon to display in filter input. * Icon to display in filter input.
* Default value is 'pi pi-search'. * @defaultValue pi pi-search
*/ */
filterIcon?: string | undefined; filterIcon?: string | undefined;
/** /**
* Icon to display in loading state. * Icon to display in loading state.
* Default value is 'pi pi-spinner pi-spin'. * @defaultValue pi pi-spinner pi-spin
*/ */
loadingIcon?: string | undefined; loadingIcon?: string | undefined;
/** /**
@ -189,47 +190,46 @@ export interface DropdownProps {
resetFilterOnHide?: boolean; resetFilterOnHide?: boolean;
/** /**
* Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it. * Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it.
* @see VirtualScroller.VirtualScrollerProps
*/ */
virtualScrollerOptions?: VirtualScrollerProps; virtualScrollerOptions?: VirtualScrollerProps;
/** /**
* Whether to focus on the first visible or selected element when the overlay panel is shown. * Whether to focus on the first visible or selected element when the overlay panel is shown.
* Default value is true. * @defaultValue true
*/ */
autoOptionFocus?: boolean | undefined; autoOptionFocus?: boolean | undefined;
/** /**
* Whether to focus on the filter element when the overlay panel is shown. * Whether to focus on the filter element when the overlay panel is shown.
* Default value is false. * @defaultValue false
*/ */
autoFilterFocus?: boolean | undefined; autoFilterFocus?: boolean | undefined;
/** /**
* When enabled, the focused option is selected. * When enabled, the focused option is selected.
* Default value is false. * @defaultValue false
*/ */
selectOnFocus?: boolean | undefined; selectOnFocus?: boolean | undefined;
/** /**
* Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration. * Text to be displayed in hidden accessible field when filtering returns any results. Defaults to value from PrimeVue locale configuration.
* Default value is '{0} results are available'. * @defaultValue \{0} results are available
*/ */
filterMessage?: string | undefined; filterMessage?: string | undefined;
/** /**
* Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration. * Text to be displayed in hidden accessible field when options are selected. Defaults to value from PrimeVue locale configuration.
* Default value is '{0} items selected'. * @defaultValue \{0} items selected
*/ */
selectionMessage?: string | undefined; selectionMessage?: string | undefined;
/** /**
* Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration. * Text to be displayed in hidden accessible field when any option is not selected. Defaults to value from PrimeVue locale configuration.
* Default value is 'No selected item'. * @defaultValue No selected item
*/ */
emptySelectionMessage?: string | undefined; emptySelectionMessage?: string | undefined;
/** /**
* Text to display when filtering does not return any results. Defaults to value from PrimeVue locale configuration. * Text to display when filtering does not return any results. Defaults to value from PrimeVue locale configuration.
* Default value is 'No results found'. * @defaultValue No results found
*/ */
emptyFilterMessage?: string | undefined; emptyFilterMessage?: string | undefined;
/** /**
* Text to display when there are no options available. Defaults to value from PrimeVue locale configuration. * Text to display when there are no options available. Defaults to value from PrimeVue locale configuration.
* Default value is 'No results found'. * @defaultValue No results found
*/ */
emptyMessage?: string | undefined; emptyMessage?: string | undefined;
/** /**
@ -246,12 +246,15 @@ export interface DropdownProps {
'aria-labelledby'?: string | undefined; 'aria-labelledby'?: string | undefined;
} }
/**
* Defines valid slots in Dropdown component.
*/
export interface DropdownSlots { export interface DropdownSlots {
/** /**
* Custom value template. * Custom value template.
* @param {Object} scope - value slot's params. * @param {Object} scope - value slot's params.
*/ */
value: (scope: { value(scope: {
/** /**
* Value of the component * Value of the component
*/ */
@ -260,16 +263,16 @@ export interface DropdownSlots {
* Placeholder prop value * Placeholder prop value
*/ */
placeholder: string; placeholder: string;
}) => VNode[]; }): VNode[];
/** /**
* Custom indicator template. * Custom indicator template.
*/ */
indicator: () => VNode[]; indicator(): VNode[];
/** /**
* Custom header template of panel. * Custom header template of panel.
* @param {Object} scope - header slot's params. * @param {Object} scope - header slot's params.
*/ */
header: (scope: { header(scope: {
/** /**
* Value of the component * Value of the component
*/ */
@ -278,12 +281,12 @@ export interface DropdownSlots {
* Displayed options * Displayed options
*/ */
options: any[]; options: any[];
}) => VNode[]; }): VNode[];
/** /**
* Custom footer template of panel. * Custom footer template of panel.
* @param {Object} scope - footer slot's params. * @param {Object} scope - footer slot's params.
*/ */
footer: (scope: { footer(scope: {
/** /**
* Value of the component * Value of the component
*/ */
@ -292,12 +295,12 @@ export interface DropdownSlots {
* Displayed options * Displayed options
*/ */
options: any[]; options: any[];
}) => VNode[]; }): VNode[];
/** /**
* Custom option template. * Custom option template.
* @param {Object} scope - option slot's params. * @param {Object} scope - option slot's params.
*/ */
option: (scope: { option(scope: {
/** /**
* Option instance * Option instance
*/ */
@ -306,12 +309,12 @@ export interface DropdownSlots {
* Index of the option * Index of the option
*/ */
index: number; index: number;
}) => VNode[]; }): VNode[];
/** /**
* Custom option group template. * Custom option group template.
* @param {Object} scope - option group slot's params. * @param {Object} scope - option group slot's params.
*/ */
optiongroup: (scope: { optiongroup(scope: {
/** /**
* Option instance * Option instance
*/ */
@ -320,20 +323,20 @@ export interface DropdownSlots {
* Index of the option * Index of the option
*/ */
index: number; index: number;
}) => VNode[]; }): VNode[];
/** /**
* Custom empty filter template. * Custom empty filter template.
*/ */
emptyfilter: () => VNode[]; emptyfilter(): VNode[];
/** /**
* Custom empty template. * Custom empty template.
*/ */
empty: () => VNode[]; empty(): VNode[];
/** /**
* Custom content template. * Custom content template.
* @param {Object} scope - content slot's params. * @param {Object} scope - content slot's params.
*/ */
content: (scope: { content(scope: {
/** /**
* An array of objects to display for virtualscroller * An array of objects to display for virtualscroller
*/ */
@ -353,74 +356,88 @@ export interface DropdownSlots {
* @return {@link VirtualScroller.VirtualScrollerItemOptions} * @return {@link VirtualScroller.VirtualScrollerItemOptions}
*/ */
getItemOptions(index: number): VirtualScrollerItemOptions; getItemOptions(index: number): VirtualScrollerItemOptions;
}) => VNode[]; }): VNode[];
/** /**
* Custom loader template. * Custom loader template.
* @param {Object} scope - loader slot's params. * @param {Object} scope - loader slot's params.
*/ */
loader: (scope: { loader(scope: {
/** /**
* Options of the loader items for virtualscroller * Options of the loader items for virtualscroller
*/ */
options: any[]; options: any[];
}) => VNode[]; }): VNode[];
} }
export declare type DropdownEmits = { /**
* Defines valid emits in Dropdown component.
*/
export interface DropdownEmits {
/** /**
* Emitted when the value changes. * Emitted when the value changes.
* @param {*} value - New value. * @param {*} value - New value.
*/ */
'update:modelValue': (value: any) => void; 'update:modelValue'(value: any): void;
/** /**
* Callback to invoke on value change. * Callback to invoke on value change.
* @param {DropdownChangeEvent} event - Custom change event. * @param {DropdownChangeEvent} event - Custom change event.
*/ */
change: (event: DropdownChangeEvent) => void; change(event: DropdownChangeEvent): void;
/** /**
* Callback to invoke when the component receives focus. * Callback to invoke when the component receives focus.
* @param {Event} event - Browser event. * @param {Event} event - Browser event.
*/ */
focus: (event: Event) => void; focus(event: Event): void;
/** /**
* Callback to invoke when the component loses focus. * Callback to invoke when the component loses focus.
* @param {Event} event - Browser event. * @param {Event} event - Browser event.
*/ */
blur: (event: Event) => void; blur(event: Event): void;
/** /**
* Callback to invoke before the overlay is shown. * Callback to invoke before the overlay is shown.
*/ */
'before-show': () => void; 'before-show'(): void;
/** /**
* Callback to invoke before the overlay is hidden. * Callback to invoke before the overlay is hidden.
*/ */
'before-hide': () => void; 'before-hide'(): void;
/** /**
* Callback to invoke when the overlay is shown. * Callback to invoke when the overlay is shown.
*/ */
show: () => void; show(): void;
/** /**
* Callback to invoke when the overlay is hidden. * Callback to invoke when the overlay is hidden.
*/ */
hide: () => void; hide(): void;
/** /**
* Callback to invoke on filter input. * Callback to invoke on filter input.
* @param {DropdownFilterEvent} event - Custom filter event. * @param {DropdownFilterEvent} event - Custom filter event.
*/ */
filter: (event: DropdownFilterEvent) => void; filter(event: DropdownFilterEvent): void;
}; }
declare class Dropdown extends ClassComponent<DropdownProps, DropdownSlots, DropdownEmits> { /**
* **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
*/
export declare class Dropdown extends ClassComponent<DropdownProps, DropdownSlots, DropdownEmits> {
/** /**
* Shows the overlay. * Shows the overlay.
* @param {boolean} [isFocus] - Decides whether to focus on the component. Default value is false. * @param {boolean} [isFocus] - Decides whether to focus on the component. @defaultValue false.
* *
* @memberof Dropdown * @memberof Dropdown
*/ */
show: (isFocus?: boolean) => void; show: (isFocus?: boolean) => void;
/** /**
* Hides the overlay. * Hides the overlay.
* @param {boolean} [isFocus] - Decides whether to focus on the component. Default value is false. * @param {boolean} [isFocus] - Decides whether to focus on the component. @defaultValue false.
* *
* @memberof Dropdown * @memberof Dropdown
*/ */