From b913aab3c4ad45a0aede0987ab818cdaae9e8fe8 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 14:44:52 +0300 Subject: [PATCH] Refactor #3885 - For Sidebar --- api-generator/components/sidebar.js | 6 +++ components/lib/sidebar/Sidebar.d.ts | 68 +++++++++++++++++++++++++++++ components/lib/sidebar/Sidebar.vue | 16 ++++--- 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/api-generator/components/sidebar.js b/api-generator/components/sidebar.js index 952f6e5d56..c810d30512 100644 --- a/api-generator/components/sidebar.js +++ b/api-generator/components/sidebar.js @@ -58,6 +58,12 @@ const SidebarProps = [ type: 'string', default: 'undefined', description: 'Icon to display in the sidebar close button.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/sidebar/Sidebar.d.ts b/components/lib/sidebar/Sidebar.d.ts index 137dbe0e9f..a571bef48f 100755 --- a/components/lib/sidebar/Sidebar.d.ts +++ b/components/lib/sidebar/Sidebar.d.ts @@ -10,6 +10,69 @@ import { VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type SidebarPassThroughOptionType = SidebarPassThroughAttributes | ((options: SidebarPassThroughMethodOptions) => SidebarPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface SidebarPassThroughMethodOptions { + props: SidebarProps; + state: SidebarState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link SidebarProps.pt} + */ +export interface SidebarPassThroughOptions { + /** + * Uses to pass attributes to the mask's DOM element. + */ + mask?: SidebarPassThroughOptionType; + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: SidebarPassThroughOptionType; + /** + * Uses to pass attributes to the header's DOM element. + */ + header?: SidebarPassThroughOptionType; + /** + * Uses to pass attributes to the header content's DOM element. + */ + headerContent?: SidebarPassThroughOptionType; + /** + * Uses to pass attributes to the close button's DOM element. + */ + closeButton?: SidebarPassThroughOptionType; + /** + * Uses to pass attributes to the close icon's DOM element. + */ + closeIcon?: SidebarPassThroughOptionType; + /** + * Uses to pass attributes to the content's DOM element. + */ + content?: SidebarPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface SidebarPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in Sidebar component. + */ +export interface SidebarState { + /** + * Current container visible state as a boolean. + * @defaultValue false + */ + containerVisible: boolean; +} + /** * Defines valid properties in Sidebar component. */ @@ -59,6 +122,11 @@ export interface SidebarProps { * @defaultValue false */ blockScroll?: boolean | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {SidebarPassThroughOptions} + */ + pt?: SidebarPassThroughOptions; } /** diff --git a/components/lib/sidebar/Sidebar.vue b/components/lib/sidebar/Sidebar.vue index 117ca77087..acde9e6f5e 100755 --- a/components/lib/sidebar/Sidebar.vue +++ b/components/lib/sidebar/Sidebar.vue @@ -1,19 +1,19 @@