From 3d6847aea6bd503ca61474cae71c82548c45a2f8 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: Fri, 21 Apr 2023 16:22:04 +0300 Subject: [PATCH] Refactor #3879 - For Badge --- api-generator/components/badge.js | 6 ++++++ components/lib/badge/Badge.d.ts | 32 +++++++++++++++++++++++++++++++ components/lib/badge/Badge.vue | 4 +++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/api-generator/components/badge.js b/api-generator/components/badge.js index 5c7245dfb..0562aeb0a 100644 --- a/api-generator/components/badge.js +++ b/api-generator/components/badge.js @@ -16,6 +16,12 @@ const BadgeProps = [ type: 'string', default: 'null', description: 'Size of the badge, valid options are "large" and "xlarge".' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/badge/Badge.d.ts b/components/lib/badge/Badge.d.ts index 044eea063..3d7934bd8 100644 --- a/components/lib/badge/Badge.d.ts +++ b/components/lib/badge/Badge.d.ts @@ -10,6 +10,33 @@ import { VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type BadgePassThroughOptionType = BadgePassThroughAttributes | ((options: BadgePassThroughMethodOptions) => BadgePassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface BadgePassThroughMethodOptions { + props: BadgeProps; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface BadgePassThroughAttributes { + [key: string]: any; +} + +/** + * Custom passthrough(pt) options. + * @see {@link BadgeProps.pt} + */ +export interface BadgePassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: BadgePassThroughOptionType; +} + /** * Defines valid properties in Badge component. */ @@ -26,6 +53,11 @@ export interface BadgeProps { * Size of the badge, valid options are 'large' and 'xlarge'. */ size?: 'large' | 'xlarge' | null | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {BadgePassThroughOptions} + */ + pt?: BadgePassThroughOptions; } /** diff --git a/components/lib/badge/Badge.vue b/components/lib/badge/Badge.vue index 4d0ab5c76..43e243306 100644 --- a/components/lib/badge/Badge.vue +++ b/components/lib/badge/Badge.vue @@ -1,14 +1,16 @@