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

253 lines
6.4 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
*
*/
2024-01-14 13:38:51 +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 { DefineComponent, DesignToken, EmitFn, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
2022-09-06 12:03:37 +00:00
2024-03-27 13:14:07 +00:00
export declare type ToggleButtonPassThroughOptionType<T = any> = ToggleButtonPassThroughAttributes | ((options: ToggleButtonPassThroughMethodOptions<T>) => ToggleButtonPassThroughAttributes | string) | string | null | undefined;
2023-05-07 11:38:47 +00:00
/**
* Custom passthrough(pt) option method.
*/
2024-03-26 10:25:08 +00:00
export interface ToggleButtonPassThroughMethodOptions<T = any> {
/**
* 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 options.
*/
2023-08-02 14:32:32 +00:00
context: ToggleButtonContext;
/**
* Defines valid attributes.
*/
attrs: any;
/**
* Defines parent options.
*/
2024-03-26 10:25:08 +00:00
parent: T;
2023-09-05 08:50:46 +00:00
/**
* Defines passthrough(pt) options in global config.
*/
global: object | undefined;
2023-05-07 11:38:47 +00:00
}
/**
* Custom passthrough(pt) options.
* @see {@link ToggleButtonProps.pt}
*/
2024-03-27 13:14:07 +00:00
export interface ToggleButtonPassThroughOptions<T = any> {
2023-05-07 11:38:47 +00:00
/**
* Used to pass attributes to the root's DOM element.
2023-05-07 11:38:47 +00:00
*/
2024-03-26 10:25:08 +00:00
root?: ToggleButtonPassThroughOptionType<T>;
2024-05-15 09:20:13 +00:00
/**
* Used to pass attributes to the content's DOM element.
2024-05-15 09:20:13 +00:00
*/
content?: ToggleButtonPassThroughOptionType<T>;
2023-05-07 11:38:47 +00:00
/**
* Used to pass attributes to the icon's DOM element.
2023-05-07 11:38:47 +00:00
*/
2024-03-26 10:25:08 +00:00
icon?: ToggleButtonPassThroughOptionType<T>;
2023-05-07 11:38:47 +00:00
/**
* Used to pass attributes to the label's DOM element.
2023-05-07 11:38:47 +00:00
*/
2024-03-26 10:25:08 +00:00
label?: ToggleButtonPassThroughOptionType<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-07 11:38:47 +00:00
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface ToggleButtonPassThroughAttributes {
[key: string]: any;
}
2023-08-02 14:32:32 +00:00
/**
* Defines current options in ToggleButton component.
*/
export interface ToggleButtonContext {
/**
2024-01-14 13:38:51 +00:00
* Current highlighted state as a boolean.
2023-08-02 14:32:32 +00:00
* @defaultValue false
*/
2024-01-14 13:38:51 +00:00
active: boolean;
2023-08-02 14:32:32 +00:00
/**
* Current disabled state as a boolean.
* @defaultValue false
*/
disabled: 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;
/**
* 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 11:19:19 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
disabled?: boolean | undefined;
2024-01-14 13:38:51 +00:00
/**
* When present, it specifies that an input field is read-only.
* @default false
*/
readonly?: boolean | undefined;
2022-09-06 12:03:37 +00:00
/**
* Index of the element in tabbing order.
*/
tabindex?: string | undefined;
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
*/
2023-11-24 12:21:54 +00:00
ariaLabelledby?: string | undefined;
2022-09-06 12:03:37 +00:00
/**
* Establishes a string value that labels the component.
*/
2023-11-24 12:21:54 +00:00
ariaLabel?: string | undefined;
/**
* It generates scoped CSS variables using design tokens for the component.
*/
dt?: DesignToken<any>;
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?: PassThrough<ToggleButtonPassThroughOptions>;
2023-09-05 08:50:46 +00:00
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
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 {
2024-03-26 10:25:08 +00:00
/**
* Custom content such as icons, images and text can be placed inside the button via the default slot.
*/
default(): VNode[];
/**
* 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.
*/
2024-05-16 14:05:43 +00:00
export interface ToggleButtonEmitsOptions {
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
export declare type ToggleButtonEmits = EmitFn<ToggleButtonEmitsOptions>;
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
*
*/
declare const ToggleButton: DefineComponent<ToggleButtonProps, ToggleButtonSlots, ToggleButtonEmits>;
2022-09-06 12:03:37 +00:00
declare module 'vue' {
export interface GlobalComponents {
ToggleButton: GlobalComponentConstructor<ToggleButtonProps, ToggleButtonSlots, ToggleButtonEmits>;
2022-09-06 12:03:37 +00:00
}
}
export default ToggleButton;