From 7a26836c60ed13ae7812831043fa4e9efab9ff05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Sofuo=C4=9Flu?= Date: Sun, 7 May 2023 14:38:47 +0300 Subject: [PATCH] Refactor #3922 - For ToggleButton --- components/lib/togglebutton/ToggleButton.d.ts | 59 +++++++++++++++++++ components/lib/togglebutton/ToggleButton.vue | 12 ++-- doc/togglebutton/pt/PTDoc.vue | 49 +++++++++++++++ doc/togglebutton/pt/PTImage.vue | 8 +++ doc/togglebutton/pt/index.vue | 41 +++++++++++++ doc/tristatecheckbox/pt/index.vue | 4 +- pages/togglebutton/index.vue | 6 +- 7 files changed, 170 insertions(+), 9 deletions(-) create mode 100644 doc/togglebutton/pt/PTDoc.vue create mode 100644 doc/togglebutton/pt/PTImage.vue create mode 100644 doc/togglebutton/pt/index.vue diff --git a/components/lib/togglebutton/ToggleButton.d.ts b/components/lib/togglebutton/ToggleButton.d.ts index 57b997061..e2c8df251 100755 --- a/components/lib/togglebutton/ToggleButton.d.ts +++ b/components/lib/togglebutton/ToggleButton.d.ts @@ -10,6 +10,60 @@ import { InputHTMLAttributes, VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type ToggleButtonPassThroughOptionType = ToggleButtonPassThroughAttributes | ((options: ToggleButtonPassThroughMethodOptions) => ToggleButtonPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface ToggleButtonPassThroughMethodOptions { + props: ToggleButtonProps; + state: ToggleButtonState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link ToggleButtonProps.pt} + */ +export interface ToggleButtonPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: ToggleButtonPassThroughOptionType; + /** + * Uses to pass attributes to the input aria's DOM element. + */ + inputAria?: ToggleButtonPassThroughOptionType; + /** + * Uses to pass attributes to the input's DOM element. + */ + input?: ToggleButtonPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: ToggleButtonPassThroughOptionType; + /** + * Uses to pass attributes to the label's DOM element. + */ + label?: ToggleButtonPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface ToggleButtonPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in ToggleButton component. + */ +export interface ToggleButtonState { + /** + * Focused state as a number. + */ + focused: boolean; +} + /** * Defines valid properties in ToggleButton component. */ @@ -77,6 +131,11 @@ export interface ToggleButtonProps { * Establishes a string value that labels the component. */ 'aria-label'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {ToggleButtonPassThroughOptions} + */ + pt?: ToggleButtonPassThroughOptions; } /** diff --git a/components/lib/togglebutton/ToggleButton.vue b/components/lib/togglebutton/ToggleButton.vue index 5954950ec..a5b68e52b 100755 --- a/components/lib/togglebutton/ToggleButton.vue +++ b/components/lib/togglebutton/ToggleButton.vue @@ -1,6 +1,6 @@ diff --git a/doc/togglebutton/pt/PTImage.vue b/doc/togglebutton/pt/PTImage.vue new file mode 100644 index 000000000..9ac50d6b4 --- /dev/null +++ b/doc/togglebutton/pt/PTImage.vue @@ -0,0 +1,8 @@ + diff --git a/doc/togglebutton/pt/index.vue b/doc/togglebutton/pt/index.vue new file mode 100644 index 000000000..33c500bb2 --- /dev/null +++ b/doc/togglebutton/pt/index.vue @@ -0,0 +1,41 @@ + + + diff --git a/doc/tristatecheckbox/pt/index.vue b/doc/tristatecheckbox/pt/index.vue index 3272c69b2..597bf4d49 100644 --- a/doc/tristatecheckbox/pt/index.vue +++ b/doc/tristatecheckbox/pt/index.vue @@ -1,7 +1,7 @@