primevue-mirror/components/lib/togglebutton/ToggleButton.d.ts

254 lines
6.3 KiB
TypeScript
Raw Normal View History

2023-03-01 11:19:19 +00:00
/**
*
* ToggleButton is used to select a boolean value using a button.
*
* [Live Demo](https://www.primevue.org/togglebutton/)
*
* @module togglebutton
*
*/
import { InputHTMLAttributes, VNode } from 'vue';
2023-07-06 11:17:08 +00:00
import { ComponentHooks } from '../basecomponent';
import { ClassComponent, GlobalComponentConstructor, PTOptions } from '../ts-helpers';
2022-09-06 12:03:37 +00:00
export declare type ToggleButtonPassThroughOptionType = ToggleButtonPassThroughAttributes | ((options: ToggleButtonPassThroughMethodOptions) => ToggleButtonPassThroughAttributes | string) | string | null | undefined;
2023-05-07 11:38:47 +00:00
/**
* Custom passthrough(pt) option method.
*/
export interface ToggleButtonPassThroughMethodOptions {
/**
* Defines instance.
*/
2023-07-06 12:01:33 +00:00
instance: any;
/**
* Defines valid properties.
*/
2023-05-07 11:38:47 +00:00
props: ToggleButtonProps;
/**
* Defines current inline state.
*/
2023-05-07 11:38:47 +00:00
state: ToggleButtonState;
/**
* Defines current options.
*/
2023-08-02 14:32:32 +00:00
context: ToggleButtonContext;
2023-05-07 11:38:47 +00:00
}
/**
* Custom passthrough(pt) options.
* @see {@link ToggleButtonProps.pt}
*/
export interface ToggleButtonPassThroughOptions {
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the root's DOM element.
2023-05-07 11:38:47 +00:00
*/
root?: ToggleButtonPassThroughOptionType;
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the icon's DOM element.
2023-05-07 11:38:47 +00:00
*/
icon?: ToggleButtonPassThroughOptionType;
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the label's DOM element.
2023-05-07 11:38:47 +00:00
*/
label?: ToggleButtonPassThroughOptionType;
2023-05-09 08:57:03 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the hidden input wrapper's DOM element.
2023-05-09 08:57:03 +00:00
*/
hiddenInputWrapper?: ToggleButtonPassThroughOptionType;
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to the hidden input's DOM element.
2023-05-09 08:57:03 +00:00
*/
hiddenInput?: ToggleButtonPassThroughOptionType;
2023-07-06 11:09:01 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to manage all lifecycle hooks
2023-07-06 11:09:01 +00:00
* @see {@link BaseComponent.ComponentHooks}
*/
hooks?: ComponentHooks;
2023-05-07 11:38:47 +00:00
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface ToggleButtonPassThroughAttributes {
[key: string]: any;
}
/**
* Defines current inline state in ToggleButton component.
*/
export interface ToggleButtonState {
/**
2023-08-02 14:32:32 +00:00
* Focused state as a boolean.
2023-05-07 11:38:47 +00:00
*/
focused: boolean;
}
2023-08-02 14:32:32 +00:00
/**
* Defines current options in ToggleButton component.
*/
export interface ToggleButtonContext {
/**
* Current focused state as a boolean.
* @defaultValue false
*/
focused: boolean;
/**
* Current disabled state as a boolean.
* @defaultValue false
*/
disabled: boolean;
/**
* Current highlighted state as a boolean.
* @defaultValue false
*/
highlighted: boolean;
}
2023-03-01 11:19:19 +00:00
/**
* Defines valid properties in ToggleButton component.
*/
2022-09-06 12:03:37 +00:00
export interface ToggleButtonProps {
/**
* Value of the component.
2023-03-01 11:19:19 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
modelValue?: boolean | undefined;
/**
* Icon for the on state.
* @deprecated since v3.27.0. Use 'icon' slot.
2022-09-06 12:03:37 +00:00
*/
onIcon?: string | undefined;
/**
* Icon for the off state.
* @deprecated since v3.27.0. Use 'icon' slot.
2022-09-06 12:03:37 +00:00
*/
offIcon?: string | undefined;
/**
* Label for the on state.
2023-03-01 11:19:19 +00:00
* @defaultValue yes
2022-09-06 12:03:37 +00:00
*/
onLabel?: string | undefined;
/**
* Label for the off state.
2023-03-01 11:19:19 +00:00
* @defaultValue no
2022-09-06 12:03:37 +00:00
*/
offLabel?: string | undefined;
/**
* Position of the icon.
2023-03-08 10:51:52 +00:00
* @defaultValue left
2022-09-06 12:03:37 +00:00
*/
2023-03-01 11:19:19 +00:00
iconPos?: 'left' | 'right' | undefined;
2022-09-06 12:03:37 +00:00
/**
* When present, it specifies that the element should be disabled.
2023-03-01 11:19:19 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
disabled?: boolean | undefined;
/**
* Index of the element in tabbing order.
*/
tabindex?: string | undefined;
/**
* Identifier of the focus input to match a label defined for the chips.
*/
inputId?: string | undefined;
/**
* Style class of the input field.
*/
inputClass?: string | object | undefined;
2022-09-06 12:03:37 +00:00
/**
* Inline style of the input field.
*/
inputStyle?: object | undefined;
2022-09-06 12:03:37 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass all properties of the HTMLInputElement to the focusable input element inside the component.
2022-09-06 12:03:37 +00:00
*/
inputProps?: InputHTMLAttributes | undefined;
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
*/
'aria-labelledby'?: string | undefined;
/**
* Establishes a string value that labels the component.
*/
'aria-label'?: string | undefined;
2023-05-07 11:38:47 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to DOM elements inside the component.
2023-05-07 11:38:47 +00:00
* @type {ToggleButtonPassThroughOptions}
*/
pt?: PTOptions<ToggleButtonPassThroughOptions>;
2023-05-24 14:26:41 +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 11:19:19 +00:00
/**
* Defines valid slots in ToggleButton component.
*/
export interface ToggleButtonSlots {
/**
* Custom icon template.
2023-08-17 07:16:25 +00:00
* @param {Object} scope - icon slot's params.
*/
icon(scope: {
/**
* Current value
*/
value: any;
/**
* Icon style class
*/
class: any;
}): VNode[];
}
2022-09-06 12:03:37 +00:00
2023-03-01 11:19:19 +00:00
/**
* Defines valid emits in ToggleButton component.
*/
export interface ToggleButtonEmits {
2022-09-06 12:03:37 +00:00
/**
* Emitted when the value changes.
* @param {boolean} value - New value.
*/
2023-03-01 11:19:19 +00:00
'update:modelValue'(value: boolean): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on value change.
* @param {Event} event - Browser event.
*/
2023-03-01 11:19:19 +00:00
change(event: Event): 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 11:19:19 +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 11:19:19 +00:00
blur(event: Event): void;
}
2022-09-06 12:03:37 +00:00
2023-03-01 11:19:19 +00:00
/**
* **PrimeVue - ToggleButton**
*
* _ToggleButton is used to select a boolean value using a button._
*
* [Live Demo](https://www.primevue.org/togglebutton/)
* --- ---
2023-03-03 10:55:20 +00:00
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
2023-03-01 11:19:19 +00:00
*
* @group Component
*
*/
2022-09-14 11:26:01 +00:00
declare class ToggleButton extends ClassComponent<ToggleButtonProps, ToggleButtonSlots, ToggleButtonEmits> {}
2022-09-06 12:03:37 +00:00
declare module '@vue/runtime-core' {
interface GlobalComponents {
2022-09-14 11:26:01 +00:00
ToggleButton: GlobalComponentConstructor<ToggleButton>;
2022-09-06 12:03:37 +00:00
}
}
export default ToggleButton;