From 05881f472fb439be19c12d4f69c4fb0a3d6139fe 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: Mon, 24 Apr 2023 17:10:17 +0300 Subject: [PATCH] Refactor #3885 - For SplitButton --- api-generator/components/splitbutton.js | 6 ++ components/lib/splitbutton/SplitButton.d.ts | 64 +++++++++++++++++++++ components/lib/splitbutton/SplitButton.vue | 14 +++-- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/api-generator/components/splitbutton.js b/api-generator/components/splitbutton.js index 5562dba4e..d5b237969 100644 --- a/api-generator/components/splitbutton.js +++ b/api-generator/components/splitbutton.js @@ -100,6 +100,12 @@ const SplitButtonProps = [ type: 'boolean', default: 'false', description: 'Add a plain textual class to the button without a background initially.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/splitbutton/SplitButton.d.ts b/components/lib/splitbutton/SplitButton.d.ts index ed13e8cbd..87ab709d0 100755 --- a/components/lib/splitbutton/SplitButton.d.ts +++ b/components/lib/splitbutton/SplitButton.d.ts @@ -11,6 +11,65 @@ import { ButtonHTMLAttributes, VNode } from 'vue'; import { MenuItem } from '../menuitem'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type SplitButtonPassThroughOptionType = SplitButtonPassThroughAttributes | ((options: SplitButtonPassThroughMethodOptions) => SplitButtonPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface SplitButtonPassThroughMethodOptions { + props: SplitButtonProps; + state: SplitButtonState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link SplitButtonProps.pt} + */ +export interface SplitButtonPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: SplitButtonPassThroughOptionType; + /** + * Uses to pass attributes to the button's DOM element. + */ + button?: SplitButtonPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: SplitButtonPassThroughOptionType; + /** + * Uses to pass attributes to the menu button's DOM element. + */ + menuButton?: SplitButtonPassThroughOptionType; + /** + * Uses to pass attributes to the menu button icon's DOM element. + */ + menuButtonIcon?: SplitButtonPassThroughOptionType; + /** + * Uses to pass attributes to the menu's DOM element. + */ + menu?: SplitButtonPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface SplitButtonPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in SplitButton component. + */ +export interface SplitButtonState { + /** + * Current blocked state as a boolean. + * @defaultValue false + */ + isBlocked: boolean; +} + /** * Defines valid properties in SplitButton component. */ @@ -103,6 +162,11 @@ export interface SplitButtonProps { * @defaultValue false */ plain?: boolean | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {SplitButtonPassThroughOptions} + */ + pt?: SplitButtonPassThroughOptions; } /** diff --git a/components/lib/splitbutton/SplitButton.vue b/components/lib/splitbutton/SplitButton.vue index 0b4cd3f1a..99689c40f 100755 --- a/components/lib/splitbutton/SplitButton.vue +++ b/components/lib/splitbutton/SplitButton.vue @@ -1,10 +1,10 @@