2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
|
|
|
<div aria-live="polite" :class="containerClass">
|
2023-04-18 09:31:46 +00:00
|
|
|
<slot name="icon">
|
2023-04-14 08:03:50 +00:00
|
|
|
<component :is="icon ? 'span' : iconComponent" :class="['p-inline-message-icon', icon]"></component>
|
2023-04-07 18:49:14 +00:00
|
|
|
</slot>
|
2022-09-06 12:03:37 +00:00
|
|
|
<span class="p-inline-message-text"><slot> </slot></span>
|
|
|
|
</div>
|
|
|
|
</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 TimesCircleIcon from 'primevue/icons/timescircle';
|
2023-04-14 08:03:50 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'InlineMessage',
|
|
|
|
props: {
|
|
|
|
severity: {
|
|
|
|
type: String,
|
|
|
|
default: 'error'
|
2023-04-07 18:49:14 +00:00
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: undefined
|
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
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (!this.sticky) {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.visible = false;
|
|
|
|
}, this.life);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
containerClass() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return ['p-inline-message p-component p-inline-message-' + this.severity, { 'p-inline-message-icon-only': !this.$slots.default }];
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
2023-04-07 18:49:14 +00:00
|
|
|
iconComponent() {
|
|
|
|
return {
|
|
|
|
info: InfoCircleIcon,
|
|
|
|
success: CheckIcon,
|
|
|
|
warn: ExclamationTriangleIcon,
|
|
|
|
error: TimesCircleIcon
|
|
|
|
}[this.severity];
|
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>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.p-inline-message {
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
vertical-align: top;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-inline-message-icon-only .p-inline-message-text {
|
|
|
|
visibility: hidden;
|
|
|
|
width: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-fluid .p-inline-message {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
</style>
|