Refactor #4433 - Message

pull/4476/head
Tuğçe Küçükoğlu 2023-09-19 14:22:25 +03:00
parent 936ea04d10
commit 69de98e7ef
3 changed files with 16 additions and 1 deletions

View File

@ -57,6 +57,10 @@ const MessageSlots = [
{
name: 'closeicon',
description: 'Custom close icon template.'
},
{
name: 'container',
description: 'Custom container template.'
}
];

View File

@ -188,6 +188,16 @@ export interface MessageSlots {
*/
class: any;
}): VNode[];
/**
* Custom container slot.
* @param {Object} scope - container slot's params.
*/
container(scope: {
/**
* Close message function.
*/
onClose: () => void;
}): VNode[];
}
/**

View File

@ -1,7 +1,8 @@
<template>
<transition name="p-message" appear v-bind="ptm('transition')">
<div v-show="visible" :class="cx('root')" role="alert" aria-live="assertive" aria-atomic="true" v-bind="ptm('root')" data-pc-name="message">
<div :class="cx('wrapper')" v-bind="ptm('wrapper')">
<slot v-if="$slots.container" name="container" :onClose="close"></slot>
<div v-else :class="cx('wrapper')" v-bind="ptm('wrapper')">
<slot name="messageicon" class="p-message-icon">
<component :is="icon ? 'span' : iconComponent" :class="[cx('icon'), icon]" v-bind="ptm('icon')"></component>
</slot>