From d9dd436c367ac879547090dadc31f4cac9375f44 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 12:59:20 +0300 Subject: [PATCH] Refactor #3885 - For Dialog --- api-generator/components/dialog.js | 6 ++ components/lib/dialog/Dialog.d.ts | 89 ++++++++++++++++++++++++++++++ components/lib/dialog/Dialog.vue | 34 ++++++++---- 3 files changed, 118 insertions(+), 11 deletions(-) diff --git a/api-generator/components/dialog.js b/api-generator/components/dialog.js index 970eff2ad..e08bfa3c2 100644 --- a/api-generator/components/dialog.js +++ b/api-generator/components/dialog.js @@ -130,6 +130,12 @@ const DialogProps = [ type: 'string', default: 'body', description: 'A valid query selector or an HTMLElement to specify where the dialog gets attached. Special keywords are "body" for document body and "self" for the element itself.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/dialog/Dialog.d.ts b/components/lib/dialog/Dialog.d.ts index 5623c3cbe..d3d4154ee 100755 --- a/components/lib/dialog/Dialog.d.ts +++ b/components/lib/dialog/Dialog.d.ts @@ -10,6 +10,90 @@ import { HTMLAttributes, VNode } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type DialogPassThroughOptionType = DialogPassThroughAttributes | ((options: DialogPassThroughMethodOptions) => DialogPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface DialogPassThroughMethodOptions { + props: DialogProps; + state: DialogState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link DialogProps.pt} + */ +export interface DialogPassThroughOptions { + /** + * Uses to pass attributes to the mask's DOM element. + */ + mask?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the header's DOM element. + */ + header?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the header title's DOM element. + */ + headerTitle?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the header icons' DOM element. + */ + headerIcons?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the maximizable button's DOM element. + */ + maximizableButton?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the maximizable icon's DOM element. + */ + maximizableIcon?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the close button's DOM element. + */ + closeButton?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the close icon's DOM element. + */ + closeIcon?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the content's DOM element. + */ + content?: DialogPassThroughOptionType; + /** + * Uses to pass attributes to the footer's DOM element. + */ + footer?: DialogPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface DialogPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in Dialog component. + */ +export interface DialogState { + /** + * Current visible state of the container as a boolean. + * @defaultValue false + */ + containerVisible: boolean; + /** + * Current maximized state as a boolean. + * @defaultValue false + */ + maximized: boolean; +} + /** * Custom breakpoint metadata. */ @@ -159,6 +243,11 @@ export interface DialogProps { * @deprecated since v3.27.0. Use 'minimizeicon' slot. */ minimizeIcon?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {DialogPassThroughOptions} + */ + pt?: DialogPassThroughOptions; } /** diff --git a/components/lib/dialog/Dialog.vue b/components/lib/dialog/Dialog.vue index 5137a5de8..356b21098 100755 --- a/components/lib/dialog/Dialog.vue +++ b/components/lib/dialog/Dialog.vue @@ -1,16 +1,26 @@