Fixed #1685 - Templating Support for ConfirmPopup

pull/1722/head
Tuğçe Küçükoğlu 2021-11-02 12:47:22 +03:00
parent 033f46dfb6
commit 87941b29c2
4 changed files with 41 additions and 5 deletions

View File

@ -7,10 +7,18 @@ const ConfirmPopupProps = [
} }
]; ];
const ConfirmPopupSlots = [
{
name: "message",
description: "Custom content for the component."
}
];
module.exports = { module.exports = {
confirmpopup: { confirmpopup: {
name: "ConfirmPopup", name: "ConfirmPopup",
description: "ConfirmPopup displays a confirmation overlay displayed relatively to its target.", description: "ConfirmPopup displays a confirmation overlay displayed relatively to its target.",
props: ConfirmPopupProps props: ConfirmPopupProps,
slots: ConfirmPopupSlots
} }
}; };

View File

@ -2,8 +2,15 @@ interface ConfirmPopupProps {
group?: string; group?: string;
} }
interface ConfirmPopupMessageSlot {
message: any;
}
declare class ConfirmPopup { declare class ConfirmPopup {
$props: ConfirmPopupProps; $props: ConfirmPopupProps;
$slots: {
message: ConfirmPopupMessageSlot
}
} }
export default ConfirmPopup; export default ConfirmPopup;

View File

@ -2,10 +2,13 @@
<Teleport to="body"> <Teleport to="body">
<transition name="p-confirm-popup" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave"> <transition name="p-confirm-popup" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave">
<div :class="containerClass" v-if="visible" :ref="containerRef" v-bind="$attrs" @click="onOverlayClick"> <div :class="containerClass" v-if="visible" :ref="containerRef" v-bind="$attrs" @click="onOverlayClick">
<template v-if="!$slots.message">
<div class="p-confirm-popup-content"> <div class="p-confirm-popup-content">
<i :class="iconClass" /> <i :class="iconClass" />
<span class="p-confirm-popup-message">{{confirmation.message}}</span> <span class="p-confirm-popup-message">{{confirmation.message}}</span>
</div> </div>
</template>
<component v-else :is="$slots.message" :message="confirmation"></component>
<div class="p-confirm-popup-footer"> <div class="p-confirm-popup-footer">
<CPButton :label="rejectLabel" :icon="rejectIcon" :class="rejectClass" @click="reject()"/> <CPButton :label="rejectLabel" :icon="rejectIcon" :class="rejectClass" @click="reject()"/>
<CPButton :label="acceptLabel" :icon="acceptIcon" :class="acceptClass" @click="accept()" autofocus /> <CPButton :label="acceptLabel" :icon="acceptIcon" :class="acceptClass" @click="accept()" autofocus />

View File

@ -209,6 +209,24 @@ export default {
</table> </table>
</div> </div>
<h5>Slots</h5>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
<tr>
<th>Name</th>
<th>Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td>message</td>
<td>-</td>
</tr>
</tbody>
</table>
</div>
<h5>Styling</h5> <h5>Styling</h5>
<p>ConfirmDialog inherits all the classes from the Dialog component, visit <router-link to="/dialog">dialog</router-link> for more information.</p> <p>ConfirmDialog inherits all the classes from the Dialog component, visit <router-link to="/dialog">dialog</router-link> for more information.</p>
<div class="doc-tablewrapper"> <div class="doc-tablewrapper">