2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2024-02-11 23:48:09 +00:00
|
|
|
<transition name="p-message" appear v-bind="ptmi('transition')">
|
2024-01-30 14:35:32 +00:00
|
|
|
<div v-show="visible" :class="cx('root')" role="alert" aria-live="assertive" aria-atomic="true" v-bind="ptm('root')">
|
2023-10-31 12:52:10 +00:00
|
|
|
<slot v-if="$slots.container" name="container" :onClose="close" :closeCallback="close"></slot>
|
2024-04-30 08:15:34 +00:00
|
|
|
<div v-else :class="cx('content')" v-bind="ptm('content')">
|
2023-04-18 10:51:10 +00:00
|
|
|
<slot name="messageicon" class="p-message-icon">
|
2023-12-05 11:06:32 +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-12-05 11:06:32 +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-12-05 11:06:32 +00:00
|
|
|
<button v-if="closable" v-ripple :class="cx('closeButton')" :aria-label="closeAriaLabel" type="button" @click="close($event)" v-bind="{ ...closeButtonProps, ...ptm('button'), ...ptm('closeButton') }">
|
2023-05-25 13:22:28 +00:00
|
|
|
<slot name="closeicon">
|
2023-12-05 11:06:32 +00:00
|
|
|
<i v-if="closeIcon" :class="[cx('closeIcon'), closeIcon]" v-bind="{ ...ptm('buttonIcon'), ...ptm('closeIcon') }" />
|
|
|
|
<TimesIcon v-else :class="[cx('closeIcon'), closeIcon]" v-bind="{ ...ptm('buttonIcon'), ...ptm('closeIcon') }" />
|
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,
|
2024-02-11 23:48:09 +00:00
|
|
|
inheritAttrs: false,
|
2024-01-18 06:44:22 +00:00
|
|
|
emits: ['close', 'life-end'],
|
2022-09-06 12:03:37 +00:00
|
|
|
timeout: null,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
visible: true
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
2023-10-25 10:56:47 +00:00
|
|
|
watch: {
|
|
|
|
sticky(newValue) {
|
|
|
|
if (!newValue) {
|
|
|
|
this.closeAfterDelay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
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;
|
2024-01-18 06:44:22 +00:00
|
|
|
this.$emit('life-end');
|
2022-12-08 14:13:16 +00:00
|
|
|
}, 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>
|