Refactor #3885 - For ConfirmDialog
parent
b4cf56a714
commit
639d662ed0
|
@ -16,6 +16,12 @@ const ConfirmDialogProps = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: 'true',
|
default: 'true',
|
||||||
description: 'Whether the dialog can be relocated by dragging.'
|
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.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,97 @@ import { VNode } from 'vue';
|
||||||
import { ConfirmationOptions } from '../confirmationoptions';
|
import { ConfirmationOptions } from '../confirmationoptions';
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
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.
|
* Breakpoint metadata.
|
||||||
*/
|
*/
|
||||||
|
@ -51,6 +142,11 @@ export interface ConfirmDialogProps {
|
||||||
* @defaultValue true
|
* @defaultValue true
|
||||||
*/
|
*/
|
||||||
draggable?: boolean | undefined;
|
draggable?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to DOM elements inside the component.
|
||||||
|
* @type {ConfirmDialogPassThroughOptions}
|
||||||
|
*/
|
||||||
|
pt?: ConfirmDialogPassThroughOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,27 +11,28 @@
|
||||||
:closeOnEscape="closeOnEscape"
|
:closeOnEscape="closeOnEscape"
|
||||||
:draggable="draggable"
|
:draggable="draggable"
|
||||||
@update:visible="onHide"
|
@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') }"
|
||||||
>
|
>
|
||||||
<template v-if="!$slots.message">
|
<template v-if="!$slots.message">
|
||||||
<slot name="icon" class="p-confirm-dialog-icon">
|
<slot name="icon" class="p-confirm-dialog-icon">
|
||||||
<component v-if="$slots.icon" :is="$slots.icon" class="p-confirm-dialog-icon" />
|
<component v-if="$slots.icon" :is="$slots.icon" class="p-confirm-dialog-icon" />
|
||||||
<span v-else-if="confirmation.icon" :class="iconClass" />
|
<span v-else-if="confirmation.icon" :class="iconClass" v-bind="ptm('icon')" />
|
||||||
</slot>
|
</slot>
|
||||||
<span class="p-confirm-dialog-message">{{ message }}</span>
|
<span class="p-confirm-dialog-message" v-bind="ptm('message')">{{ message }}</span>
|
||||||
</template>
|
</template>
|
||||||
<component v-else :is="$slots.message" :message="confirmation"></component>
|
<component v-else :is="$slots.message" :message="confirmation"></component>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<CDButton :label="rejectLabel" :class="rejectClass" iconPos="left" @click="reject()" :autofocus="autoFocusReject">
|
<CDButton :label="rejectLabel" :class="rejectClass" iconPos="left" @click="reject()" :autofocus="autoFocusReject" v-bind="ptm('rejectButton')">
|
||||||
<template #icon="iconProps">
|
<template #icon="iconProps">
|
||||||
<slot name="rejecticon">
|
<slot name="rejecticon">
|
||||||
<span :class="[rejectIcon, iconProps.class]" />
|
<span :class="[rejectIcon, iconProps.class]" v-bind="ptm('rejectIcon')" />
|
||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</CDButton>
|
</CDButton>
|
||||||
<CDButton :label="acceptLabel" :class="acceptClass" iconPos="left" @click="accept()" :autofocus="autoFocusAccept">
|
<CDButton :label="acceptLabel" :class="acceptClass" iconPos="left" @click="accept()" :autofocus="autoFocusAccept" v-bind="ptm('acceptButton')">
|
||||||
<template #icon="iconProps">
|
<template #icon="iconProps">
|
||||||
<slot name="accepticon">
|
<slot name="accepticon">
|
||||||
<span :class="[acceptIcon, iconProps.class]" />
|
<span :class="[acceptIcon, iconProps.class]" v-bind="ptm('acceptIcon')" />
|
||||||
</slot>
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
</CDButton>
|
</CDButton>
|
||||||
|
@ -40,12 +41,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
import Button from 'primevue/button';
|
import Button from 'primevue/button';
|
||||||
import ConfirmationEventBus from 'primevue/confirmationeventbus';
|
import ConfirmationEventBus from 'primevue/confirmationeventbus';
|
||||||
import Dialog from 'primevue/dialog';
|
import Dialog from 'primevue/dialog';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ConfirmDialog',
|
name: 'ConfirmDialog',
|
||||||
|
extends: BaseComponent,
|
||||||
props: {
|
props: {
|
||||||
group: String,
|
group: String,
|
||||||
breakpoints: {
|
breakpoints: {
|
||||||
|
|
Loading…
Reference in New Issue