Refactor #4433 - ConfirmDialog

pull/4476/head
Tuğçe Küçükoğlu 2023-09-19 13:51:23 +03:00
parent 44f802dc0f
commit c368c0f8df
3 changed files with 31 additions and 8 deletions

View File

@ -47,6 +47,10 @@ const ConfirmDialogSlots = [
{ {
name: 'rejecticon', name: 'rejecticon',
description: 'Custom reject icon template.' description: 'Custom reject icon template.'
},
{
name: 'container',
description: 'Custom container template.'
} }
]; ];

View File

@ -211,6 +211,20 @@ export interface ConfirmDialogSlots {
* Custom icon template. * Custom icon template.
*/ */
rejecticon(): VNode[]; rejecticon(): VNode[];
/**
* Custom container slot.
* @param {Object} scope - container slot's params.
*/
container(scope: {
/**
* Message of the component
*/
message: any;
/**
* Close dialog function.
*/
onClose: () => void;
}): VNode[];
} }
/** /**

View File

@ -14,6 +14,10 @@
:pt="pt" :pt="pt"
:unstyled="unstyled" :unstyled="unstyled"
> >
<template v-if="$slots.container" #container="slotProps">
<slot name="container" :message="confirmation" :onClose="slotProps.onClose" />
</template>
<template v-if="!$slots.container">
<template v-if="!$slots.message"> <template v-if="!$slots.message">
<slot name="icon"> <slot name="icon">
<component v-if="$slots.icon" :is="$slots.icon" :class="cx('icon')" /> <component v-if="$slots.icon" :is="$slots.icon" :class="cx('icon')" />
@ -22,7 +26,8 @@
<span :class="cx('message')" v-bind="ptm('message')">{{ message }}</span> <span :class="cx('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>
<template v-if="!$slots.container" #footer>
<CDButton :label="rejectLabel" :class="[cx('rejectButton'), confirmation.rejectClass]" @click="reject()" :autofocus="autoFocusReject" :unstyled="unstyled" :pt="ptm('rejectButton')" data-pc-name="rejectbutton"> <CDButton :label="rejectLabel" :class="[cx('rejectButton'), confirmation.rejectClass]" @click="reject()" :autofocus="autoFocusReject" :unstyled="unstyled" :pt="ptm('rejectButton')" data-pc-name="rejectbutton">
<template v-if="rejectIcon || $slots.rejecticon" #icon="iconProps"> <template v-if="rejectIcon || $slots.rejecticon" #icon="iconProps">
<slot name="rejecticon"> <slot name="rejecticon">