From a04d4a470b4ea450ff691310fc5b244769a206e9 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: Wed, 26 Apr 2023 12:57:16 +0300 Subject: [PATCH] Refactor #3907 - For Breadcrumb --- api-generator/components/breadcrumb.js | 6 ++ components/lib/breadcrumb/Breadcrumb.d.ts | 60 ++++++++++++++++++++ components/lib/breadcrumb/Breadcrumb.vue | 14 +++-- components/lib/breadcrumb/BreadcrumbItem.vue | 17 +++--- 4 files changed, 84 insertions(+), 13 deletions(-) diff --git a/api-generator/components/breadcrumb.js b/api-generator/components/breadcrumb.js index 5aa6d7d91..cae78fa05 100644 --- a/api-generator/components/breadcrumb.js +++ b/api-generator/components/breadcrumb.js @@ -16,6 +16,12 @@ const BreadcrumbProps = [ type: 'boolean', default: 'true', description: "Whether to apply 'router-link-active-exact' class if route exactly matches the item path." + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/breadcrumb/Breadcrumb.d.ts b/components/lib/breadcrumb/Breadcrumb.d.ts index 2aaf5299b..114b0030d 100755 --- a/components/lib/breadcrumb/Breadcrumb.d.ts +++ b/components/lib/breadcrumb/Breadcrumb.d.ts @@ -11,6 +11,61 @@ import { VNode } from 'vue'; import { MenuItem } from '../menuitem'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type BreadcrumbPassThroughOptionType = BreadcrumbPassThroughAttributes | ((options: BreadcrumbPassThroughMethodOptions) => BreadcrumbPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface BreadcrumbPassThroughMethodOptions { + props: BreadcrumbProps; +} + +/** + * Custom passthrough(pt) options. + * @see {@link BreadcrumbProps.pt} + */ +export interface BreadcrumbPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: BreadcrumbPassThroughOptionType; + /** + * Uses to pass attributes to the list's DOM element. + */ + menu?: BreadcrumbPassThroughOptionType; + /** + * Uses to pass attributes to the list item's DOM element. + */ + menuitem?: BreadcrumbPassThroughOptionType; + /** + * Uses to pass attributes to the action's DOM element. + */ + action?: BreadcrumbPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: BreadcrumbPassThroughOptionType; + /** + * Uses to pass attributes to the label's DOM element. + */ + label?: BreadcrumbPassThroughOptionType; + /** + * Uses to pass attributes to the separator's DOM element. + */ + separator?: BreadcrumbPassThroughOptionType; + /** + * Uses to pass attributes to the separator icon's DOM element. + */ + separatorIcon?: BreadcrumbPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface BreadcrumbPassThroughAttributes { + [key: string]: any; +} + /** * Defines valid properties in Breadcrumb component. */ @@ -36,6 +91,11 @@ export interface BreadcrumbProps { * Identifier of the underlying menu element. */ 'aria-labelledby'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {BreadcrumbPassThroughOptions} + */ + pt?: BreadcrumbPassThroughOptions; } /** diff --git a/components/lib/breadcrumb/Breadcrumb.vue b/components/lib/breadcrumb/Breadcrumb.vue index 01793bcc4..8a98b9363 100755 --- a/components/lib/breadcrumb/Breadcrumb.vue +++ b/components/lib/breadcrumb/Breadcrumb.vue @@ -1,25 +1,27 @@