From 9672b27cf071eb502371d65314f1cc0897c721df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Wed, 2 Aug 2023 17:32:32 +0300 Subject: [PATCH] Refactor #4211 - For ToggleButton --- components/lib/togglebutton/ToggleButton.d.ts | 24 ++++++++++++++++++- components/lib/togglebutton/ToggleButton.vue | 15 +++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/components/lib/togglebutton/ToggleButton.d.ts b/components/lib/togglebutton/ToggleButton.d.ts index 258dc75ac..325035212 100755 --- a/components/lib/togglebutton/ToggleButton.d.ts +++ b/components/lib/togglebutton/ToggleButton.d.ts @@ -20,6 +20,7 @@ export interface ToggleButtonPassThroughMethodOptions { instance: any; props: ToggleButtonProps; state: ToggleButtonState; + context: ToggleButtonContext; } /** @@ -66,11 +67,32 @@ export interface ToggleButtonPassThroughAttributes { */ export interface ToggleButtonState { /** - * Focused state as a number. + * Focused state as a boolean. */ focused: boolean; } +/** + * 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; +} + /** * Defines valid properties in ToggleButton component. */ diff --git a/components/lib/togglebutton/ToggleButton.vue b/components/lib/togglebutton/ToggleButton.vue index 499afbd31..d79aa9f5e 100755 --- a/components/lib/togglebutton/ToggleButton.vue +++ b/components/lib/togglebutton/ToggleButton.vue @@ -1,5 +1,5 @@ @@ -87,6 +87,15 @@ export default { }, label() { return this.hasLabel ? (this.modelValue ? this.onLabel : this.offLabel) : ' '; + }, + ptOptions() { + return { + context: { + focused: this.focused, + disabled: this.disabled, + highlighted: this.modelValue === true + } + }; } }, directives: {