From 43c3f82ae5af04c4f1bfb2b53b2b13d27b8272ff 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 15:04:27 +0300 Subject: [PATCH] Refactor #3879 - For Avatar & AvatarGroup --- api-generator/components/avatar.js | 6 +++ api-generator/components/avatargroup.js | 42 +++++++++++++++++++- components/lib/avatar/Avatar.d.ts | 44 +++++++++++++++++++++ components/lib/avatar/Avatar.vue | 13 +++--- components/lib/avatargroup/AvatarGroup.d.ts | 28 ++++++++++++- components/lib/avatargroup/AvatarGroup.vue | 7 +++- 6 files changed, 131 insertions(+), 9 deletions(-) diff --git a/api-generator/components/avatar.js b/api-generator/components/avatar.js index d3eff8255..b0c96a8c6 100644 --- a/api-generator/components/avatar.js +++ b/api-generator/components/avatar.js @@ -28,6 +28,12 @@ const AvatarProps = [ type: 'string', default: 'square', description: 'Shape of the element, valid options are "square" and "circle".' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/api-generator/components/avatargroup.js b/api-generator/components/avatargroup.js index 8b570a288..4168b6775 100644 --- a/api-generator/components/avatargroup.js +++ b/api-generator/components/avatargroup.js @@ -1,7 +1,47 @@ +const AvatarGroupProps = [ + { + name: 'label', + type: 'string', + default: 'null', + description: 'Defines the text to display.' + }, + { + name: 'icon', + type: 'string', + default: 'null', + description: 'Defines the icon to display.' + }, + { + name: 'image', + type: 'string', + default: 'null', + description: 'Defines the image to display.' + }, + { + name: 'size', + type: 'string', + default: 'null', + description: 'Size of the element, valid options are "large" and "xlarge".' + }, + { + name: 'shape', + type: 'string', + default: 'square', + description: 'Shape of the element, valid options are "square" and "circle".' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' + } +]; + module.exports = { avatargroup: { name: 'AvatarGroup', 'doc-url': 'avatar', - description: 'A set of Avatars can be displayed together using the AvatarGroup component.' + description: 'A set of Avatars can be displayed together using the AvatarGroup component.', + props: AvatarGroupProps } }; diff --git a/components/lib/avatar/Avatar.d.ts b/components/lib/avatar/Avatar.d.ts index 9e0bef653..09c5b0784 100644 --- a/components/lib/avatar/Avatar.d.ts +++ b/components/lib/avatar/Avatar.d.ts @@ -9,6 +9,45 @@ import { VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type AvatarPassThroughOptionType = AvatarPassThroughAttributes | ((options: AvatarPassThroughMethodOptions) => AvatarPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface AvatarPassThroughMethodOptions { + props: AvatarProps; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface AvatarPassThroughAttributes { + [key: string]: any; +} + +/** + * Custom passthrough(pt) options. + * @see {@link AvatarProps.pt} + */ +export interface AvatarPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: AvatarPassThroughOptionType; + /** + * Uses to pass attributes to the label's DOM element. + */ + label?: AvatarPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: AvatarPassThroughOptionType; + /** + * Uses to pass attributes to the image's DOM element. + */ + image?: AvatarPassThroughOptionType; +} + /** * Defines valid properties in Avatar component. */ @@ -44,6 +83,11 @@ export interface AvatarProps { * Establishes relationships between the component and label(s) where its value should be one or more element IDs. */ 'aria-labelledby'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {AvatarPassThroughOptions} + */ + pt?: AvatarPassThroughOptions; } /** diff --git a/components/lib/avatar/Avatar.vue b/components/lib/avatar/Avatar.vue index 282ebfcce..71cc8291f 100644 --- a/components/lib/avatar/Avatar.vue +++ b/components/lib/avatar/Avatar.vue @@ -1,18 +1,21 @@