From bd48603c398f10303df4140dbebdd0d6e72ad69b 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 15:00:20 +0300 Subject: [PATCH] Refactor #3889 - For Button --- api-generator/components/button.js | 6 ++++ components/lib/button/Button.d.ts | 48 ++++++++++++++++++++++++++++++ components/lib/button/Button.vue | 14 +++++---- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/api-generator/components/button.js b/api-generator/components/button.js index cc17ea7d34..5653509387 100644 --- a/api-generator/components/button.js +++ b/api-generator/components/button.js @@ -94,6 +94,12 @@ const ButtonProps = [ 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/button/Button.d.ts b/components/lib/button/Button.d.ts index 7d85f2b53b..f6955bb85e 100755 --- a/components/lib/button/Button.d.ts +++ b/components/lib/button/Button.d.ts @@ -10,6 +10,49 @@ import { ButtonHTMLAttributes, VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type ButtonPassThroughOptionType = ButtonPassThroughAttributes | ((options: ButtonPassThroughMethodOptions) => ButtonPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface ButtonPassThroughMethodOptions { + props: ButtonProps; +} + +/** + * Custom passthrough(pt) options. + * @see {@link ButtonProps.pt} + */ +export interface ButtonPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the loading icon's DOM element. + */ + loadingIcon?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the label's DOM element. + */ + label?: ButtonPassThroughOptionType; + /** + * Uses to pass attributes to the badge's DOM element. + */ + badge?: ButtonPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface ButtonPassThroughAttributes { + [key: string]: any; +} + /** * Defines valid properties in Button component. */ @@ -94,6 +137,11 @@ export interface ButtonProps extends ButtonHTMLAttributes { * @defaultValue false */ plain?: boolean | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {ButtonPassThroughOptions} + */ + pt?: ButtonPassThroughOptions; } /** diff --git a/components/lib/button/Button.vue b/components/lib/button/Button.vue index 027b91ab07..03f69a80f4 100755 --- a/components/lib/button/Button.vue +++ b/components/lib/button/Button.vue @@ -1,26 +1,28 @@