2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
|
|
|
<span :class="badgeClass">
|
2022-09-14 11:26:01 +00:00
|
|
|
<slot>{{ value }}</slot>
|
2022-09-06 12:03:37 +00:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-03-07 07:32:19 +00:00
|
|
|
import { ObjectUtils } from 'primevue/utils';
|
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'Badge',
|
|
|
|
props: {
|
2023-03-07 07:32:19 +00:00
|
|
|
value: {
|
|
|
|
type: [String, Number],
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
severity: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
containerClass() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return this.$slots.default ? 'p-overlay-badge' : this.badgeClass;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
badgeClass() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return [
|
|
|
|
'p-badge p-component',
|
|
|
|
{
|
2023-03-07 07:32:19 +00:00
|
|
|
'p-badge-no-gutter': ObjectUtils.isNotEmpty(this.value) && String(this.value).length === 1,
|
|
|
|
'p-badge-dot': ObjectUtils.isEmpty(this.value) && !this.$slots.default,
|
2022-09-14 11:26:01 +00:00
|
|
|
'p-badge-lg': this.size === 'large',
|
|
|
|
'p-badge-xl': this.size === 'xlarge',
|
|
|
|
'p-badge-info': this.severity === 'info',
|
|
|
|
'p-badge-success': this.severity === 'success',
|
|
|
|
'p-badge-warning': this.severity === 'warning',
|
|
|
|
'p-badge-danger': this.severity === 'danger'
|
|
|
|
}
|
|
|
|
];
|
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>
|