2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
|
|
|
<transition name="p-message" appear>
|
2023-05-29 09:19:55 +00:00
|
|
|
<div v-show="visible" :class="cx('root')" role="alert" aria-live="assertive" aria-atomic="true" v-bind="ptm('root')" data-pc-name="message">
|
2023-05-25 13:22:28 +00:00
|
|
|
<div :class="cx('wrapper')" v-bind="ptm('wrapper')">
|
2023-04-18 10:51:10 +00:00
|
|
|
<slot name="messageicon" class="p-message-icon">
|
2023-07-06 12:13:28 +00:00
|
|
|
<component :is="icon ? 'span' : iconComponent" :class="[cx('icon'), icon]" v-bind="ptm('icon')"></component>
|
2023-04-07 14:15:21 +00:00
|
|
|
</slot>
|
2023-05-25 13:36:24 +00:00
|
|
|
<div class="p-message-text" :class="cx('text')" v-bind="ptm('text')">
|
2022-09-06 12:03:37 +00:00
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2023-05-25 13:22:28 +00:00
|
|
|
<button v-if="closable" v-ripple :class="cx('button')" :aria-label="closeAriaLabel" type="button" @click="close($event)" v-bind="{ ...closeButtonProps, ...ptm('button') }">
|
|
|
|
<slot name="closeicon">
|
2023-07-06 12:13:28 +00:00
|
|
|
<i v-if="closeIcon" :class="[cx('buttonIcon'), closeIcon]" v-bind="ptm('buttonIcon')" />
|
|
|
|
<TimesIcon v-else :class="[cx('buttonIcon'), closeIcon]" v-bind="ptm('buttonIcon')" />
|
2023-04-07 14:15:21 +00:00
|
|
|
</slot>
|
2022-09-06 12:03:37 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-04-18 12:53:43 +00:00
|
|
|
import CheckIcon from 'primevue/icons/check';
|
|
|
|
import ExclamationTriangleIcon from 'primevue/icons/exclamationtriangle';
|
|
|
|
import InfoCircleIcon from 'primevue/icons/infocircle';
|
|
|
|
import TimesIcon from 'primevue/icons/times';
|
|
|
|
import TimesCircleIcon from 'primevue/icons/timescircle';
|
2023-04-14 08:03:50 +00:00
|
|
|
import Ripple from 'primevue/ripple';
|
2023-05-29 09:19:55 +00:00
|
|
|
import BaseMessage from './BaseMessage.vue';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Message',
|
2023-05-25 13:22:28 +00:00
|
|
|
extends: BaseMessage,
|
2022-09-06 12:03:37 +00:00
|
|
|
emits: ['close'],
|
|
|
|
timeout: null,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
visible: true
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (!this.sticky) {
|
2023-04-07 14:15:21 +00:00
|
|
|
this.closeAfterDelay();
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
close(event) {
|
|
|
|
this.visible = false;
|
|
|
|
this.$emit('close', event);
|
2022-12-08 14:13:16 +00:00
|
|
|
},
|
2023-04-07 14:15:21 +00:00
|
|
|
closeAfterDelay() {
|
2022-12-08 14:13:16 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
this.visible = false;
|
|
|
|
}, this.life);
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2023-04-07 14:15:21 +00:00
|
|
|
iconComponent() {
|
|
|
|
return {
|
|
|
|
info: InfoCircleIcon,
|
|
|
|
success: CheckIcon,
|
|
|
|
warn: ExclamationTriangleIcon,
|
|
|
|
error: TimesCircleIcon
|
|
|
|
}[this.severity];
|
2022-12-08 11:04:25 +00:00
|
|
|
},
|
|
|
|
closeAriaLabel() {
|
|
|
|
return this.$primevue.config.locale.aria ? this.$primevue.config.locale.aria.close : undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
directives: {
|
2022-09-14 11:26:01 +00:00
|
|
|
ripple: Ripple
|
2023-04-07 14:15:21 +00:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
TimesIcon,
|
|
|
|
InfoCircleIcon,
|
|
|
|
CheckIcon,
|
|
|
|
ExclamationTriangleIcon,
|
|
|
|
TimesCircleIcon
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|