From 639d662ed0bd3f6d2a31c9e0ec32a2c6ef06227d 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: Tue, 25 Apr 2023 12:58:01 +0300 Subject: [PATCH] Refactor #3885 - For ConfirmDialog --- api-generator/components/confirmdialog.js | 6 ++ .../lib/confirmdialog/ConfirmDialog.d.ts | 96 +++++++++++++++++++ .../lib/confirmdialog/ConfirmDialog.vue | 15 +-- 3 files changed, 111 insertions(+), 6 deletions(-) diff --git a/api-generator/components/confirmdialog.js b/api-generator/components/confirmdialog.js index 43da51ff6..130dc6444 100644 --- a/api-generator/components/confirmdialog.js +++ b/api-generator/components/confirmdialog.js @@ -16,6 +16,12 @@ const ConfirmDialogProps = [ type: 'boolean', default: 'true', description: 'Whether the dialog can be relocated by dragging.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/confirmdialog/ConfirmDialog.d.ts b/components/lib/confirmdialog/ConfirmDialog.d.ts index faf86690e..71516e6f2 100644 --- a/components/lib/confirmdialog/ConfirmDialog.d.ts +++ b/components/lib/confirmdialog/ConfirmDialog.d.ts @@ -11,6 +11,97 @@ import { VNode } from 'vue'; import { ConfirmationOptions } from '../confirmationoptions'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type ConfirmDialogPassThroughOptionType = ConfirmDialogPassThroughAttributes | ((options: ConfirmDialogPassThroughMethodOptions) => ConfirmDialogPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface ConfirmDialogPassThroughMethodOptions { + props: ConfirmDialogProps; + state: ConfirmDialogState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link ConfirmDialogProps.pt} + */ +export interface ConfirmDialogPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the header's DOM element. + */ + header?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the header title's DOM element. + */ + headerTitle?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the close button's DOM element. + */ + closeButton?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the close icon's DOM element. + */ + closeIcon?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the content's DOM element. + */ + content?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the footer's DOM element. + */ + footer?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the message's DOM element. + */ + message?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the reject button's DOM element. + */ + rejectButton?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the reject icon's DOM element. + */ + rejectIcon?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the accept button's DOM element. + */ + acceptButton?: ConfirmDialogPassThroughOptionType; + /** + * Uses to pass attributes to the accept icon's DOM element. + */ + acceptIcon?: ConfirmDialogPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface ConfirmDialogPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in ConfirmDialog component. + */ +export interface ConfirmDialogState { + /** + * Current visible state as a boolean. + * @defaultValue false + */ + visible: boolean; + /** + * Current confirmation message. + */ + confirmation: any; +} + /** * Breakpoint metadata. */ @@ -51,6 +142,11 @@ export interface ConfirmDialogProps { * @defaultValue true */ draggable?: boolean | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {ConfirmDialogPassThroughOptions} + */ + pt?: ConfirmDialogPassThroughOptions; } /** diff --git a/components/lib/confirmdialog/ConfirmDialog.vue b/components/lib/confirmdialog/ConfirmDialog.vue index 60c0d29bb..f47557435 100644 --- a/components/lib/confirmdialog/ConfirmDialog.vue +++ b/components/lib/confirmdialog/ConfirmDialog.vue @@ -11,27 +11,28 @@ :closeOnEscape="closeOnEscape" :draggable="draggable" @update:visible="onHide" + :pt="{ root: ptm('root'), header: ptm('header'), headerTitle: ptm('headerTitle'), closeButton: ptm('closeButton'), closeIcon: ptm('closeIcon'), content: ptm('content'), footer: ptm('footer') }" >