primevue-mirror/components/lib/selectbutton/SelectButton.d.ts

267 lines
6.6 KiB
TypeScript
Raw Normal View History

2023-03-01 08:50:58 +00:00
/**
*
* SelectButton is used to choose single or multiple items from a list using buttons.
*
* [Live Demo](https://www.primevue.org/selectbutton/)
*
* @module selectbutton
*
*/
2022-09-06 12:03:37 +00:00
import { VNode } from 'vue';
2023-07-06 11:17:08 +00:00
import { ComponentHooks } from '../basecomponent';
2023-09-05 08:50:46 +00:00
import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
2022-09-06 12:03:37 +00:00
export declare type SelectButtonPassThroughOptionType<T = any> = SelectButtonPassThroughAttributes | ((options: SelectButtonPassThroughMethodOptions<T>) => SelectButtonPassThroughAttributes | string) | string | null | undefined;
2023-05-06 19:56:50 +00:00
/**
* Custom passthrough(pt) option method.
*/
export interface SelectButtonPassThroughMethodOptions<T = any> {
/**
* Defines instance.
*/
2023-07-06 12:01:33 +00:00
instance: any;
/**
* Defines valid properties.
*/
2023-05-06 19:56:50 +00:00
props: SelectButtonProps;
/**
* Defines current inline state.
*/
2023-05-06 19:56:50 +00:00
state: SelectButtonState;
/**
* Defines current options.
*/
2023-05-09 08:43:08 +00:00
context: SelectButtonContext;
/**
* Defines valid attributes.
*/
attrs: any;
/**
* Defines parent options.
*/
parent: T;
2023-09-05 08:50:46 +00:00
/**
* Defines passthrough(pt) options in global config.
*/
global: object | undefined;
2023-05-06 19:56:50 +00:00
}
/**
* Custom passthrough(pt) options.
* @see {@link SelectButtonProps.pt}
*/
export interface SelectButtonPassThroughOptions<T = any> {
2023-05-06 19:56:50 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the root's DOM element.
2023-05-06 19:56:50 +00:00
*/
root?: SelectButtonPassThroughOptionType<T>;
2023-05-06 19:56:50 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the button's DOM element.
2023-05-06 19:56:50 +00:00
*/
button?: SelectButtonPassThroughOptionType<T>;
2023-05-06 19:56:50 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the label's DOM element.
2023-05-06 19:56:50 +00:00
*/
label?: SelectButtonPassThroughOptionType<T>;
2023-07-06 11:09:01 +00:00
/**
2023-11-07 06:16:39 +00:00
* Used to manage all lifecycle hooks.
2023-07-06 11:09:01 +00:00
* @see {@link BaseComponent.ComponentHooks}
*/
hooks?: ComponentHooks;
2023-05-06 19:56:50 +00:00
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface SelectButtonPassThroughAttributes {
[key: string]: any;
}
2023-03-01 08:50:58 +00:00
/**
* Custom change event.
2023-03-06 20:35:39 +00:00
* @see {@link SelectButtonEmits.change}
2023-03-01 08:50:58 +00:00
*/
2022-09-06 12:03:37 +00:00
export interface SelectButtonChangeEvent {
/**
* Browser event.
*/
originalEvent: Event;
/**
* Single value or an array of values that are selected.
*/
value: any;
}
2023-05-06 19:56:50 +00:00
/**
* Defines current inline state in SelectButton component.
*/
export interface SelectButtonState {
/**
* FocusedIndex state as a number.
*/
focusedIndex: number;
}
2023-05-09 08:43:08 +00:00
/**
* Defines current options in SelectButton component.
*/
export interface SelectButtonContext {
/**
* Current active state of the item as a boolean.
* @defaultValue false
*/
active: boolean;
/**
* Current disabled state of the item as a boolean.
* @defaultValue false
*/
disabled: boolean;
/**
* Available option.
*/
option: any;
2023-05-09 08:43:08 +00:00
}
2023-03-01 08:50:58 +00:00
/**
* Defines valid properties in SelectButton component.
*/
2022-09-06 12:03:37 +00:00
export interface SelectButtonProps {
/**
* 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 08:50:58 +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 08:50:58 +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 08:50:58 +00:00
optionDisabled?: string | ((data: any) => boolean) | undefined;
2022-09-06 12:03:37 +00:00
/**
* When specified, allows selecting multiple values.
2023-03-01 08:50:58 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
multiple?: boolean | undefined;
/**
* When present, it specifies that the component should have invalid state style.
* @defaultValue false
*/
invalid?: boolean | undefined;
2022-09-06 12:03:37 +00:00
/**
* When present, it specifies that the element should be disabled.
2023-03-01 08:50: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;
/**
* Whether selection can be cleared.
* @defaultValue true
* @deprecated Use 'allowEmpty' property instead.
2022-09-06 12:03:37 +00:00
*/
unselectable?: boolean | undefined;
/**
* Whether selection can be cleared.
* @defaultValue true
*/
allowEmpty?: boolean | undefined;
2022-09-06 12:03:37 +00:00
/**
* Identifier of the underlying element.
*/
2023-11-24 12:21:54 +00:00
ariaLabelledby?: string | undefined;
2023-05-06 19:56:50 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to DOM elements inside the component.
2023-05-06 19:56:50 +00:00
* @type {SelectButtonPassThroughOptions}
*/
pt?: PassThrough<SelectButtonPassThroughOptions>;
2023-09-05 08:50:46 +00:00
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
2023-05-25 14:09:22 +00:00
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
2022-09-06 12:03:37 +00:00
}
2023-03-01 08:50:58 +00:00
/**
* Defines valid slots in SelectButton component.
*/
2022-09-06 12:03:37 +00:00
export interface SelectButtonSlots {
/**
* Custom content for each option.
* @param {Object} scope - option slot's params.
*/
2023-03-01 08:50:58 +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 08:50:58 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
}
2023-03-01 08:50:58 +00:00
/**
* Defines valid emits in SelectButton component.
*/
export interface SelectButtonEmits {
2022-09-06 12:03:37 +00:00
/**
* Emitted when the value changes.
* @param {*} value - New value.
*/
2023-03-01 08:50:58 +00:00
'update:modelValue'(value: any): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on value change.
* @param {SelectButtonChangeEvent} event - Custom change event.
*/
2023-03-01 08:50:58 +00:00
change(event: SelectButtonChangeEvent): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on focus.
*/
2023-03-01 08:50:58 +00:00
focus(event: Event): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on blur.
* @param {Event} event - Browser event.
*/
2023-03-01 08:50:58 +00:00
blur(event: Event): void;
}
2022-09-06 12:03:37 +00:00
2023-03-01 08:50:58 +00:00
/**
* **PrimeVue - SelectButton**
*
* _SelectButton is used to choose single or multiple items from a list using buttons._
*
* [Live Demo](https://www.primevue.org/selectbutton/)
* --- ---
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
*
* @group Component
*/
2023-03-01 14:48:23 +00:00
declare class SelectButton extends ClassComponent<SelectButtonProps, SelectButtonSlots, SelectButtonEmits> {}
2022-09-06 12:03:37 +00:00
declare module 'vue' {
export interface GlobalComponents {
2022-09-14 11:26:01 +00:00
SelectButton: GlobalComponentConstructor<SelectButton>;
2022-09-06 12:03:37 +00:00
}
}
export default SelectButton;