2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-06-22 12:24:07 +00:00
|
|
|
<button v-ripple :class="cx('root')" type="button" :aria-label="defaultAriaLabel" :disabled="disabled" v-bind="ptm('root', { disabled })" data-pc-name="button" :data-pc-severity="severity">
|
2023-04-27 12:18:17 +00:00
|
|
|
<slot>
|
2023-05-30 14:05:57 +00:00
|
|
|
<slot v-if="loading" name="loadingicon" :class="[cx('loadingIcon'), cx('icon')]">
|
|
|
|
<span v-if="loadingIcon" :class="[cx('loadingIcon'), cx('icon'), loadingIcon]" v-bind="ptm('loadingIcon')" />
|
|
|
|
<SpinnerIcon v-else :class="[cx('loadingIcon'), cx('icon')]" spin v-bind="ptm('loadingIcon')" />
|
2023-04-13 09:19:28 +00:00
|
|
|
</slot>
|
2023-05-30 14:05:57 +00:00
|
|
|
<slot v-else name="icon" :class="cx('icon')">
|
|
|
|
<span v-if="icon" :class="[cx('icon'), icon]" v-bind="ptm('icon')"></span>
|
2023-04-13 09:19:28 +00:00
|
|
|
</slot>
|
2023-05-30 14:05:57 +00:00
|
|
|
<span :class="cx('label')" v-bind="ptm('label')">{{ label || ' ' }}</span>
|
|
|
|
<span v-if="badge" :class="[cx('badge'), badgeClass]" v-bind="ptm('badge')">{{ badge }}</span>
|
2023-04-27 12:18:17 +00:00
|
|
|
</slot>
|
2022-09-06 12:03:37 +00:00
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-04-18 12:53:43 +00:00
|
|
|
import SpinnerIcon from 'primevue/icons/spinner';
|
2022-09-06 12:03:37 +00:00
|
|
|
import Ripple from 'primevue/ripple';
|
2023-05-30 14:05:57 +00:00
|
|
|
import BaseButton from './BaseButton.vue';
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Button',
|
2023-05-30 14:05:57 +00:00
|
|
|
extends: BaseButton,
|
2022-09-06 12:03:37 +00:00
|
|
|
computed: {
|
|
|
|
disabled() {
|
2023-06-22 14:16:55 +00:00
|
|
|
return this.$attrs.disabled || this.$attrs.disabled === '' || this.loading;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
defaultAriaLabel() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return this.label ? this.label + (this.badge ? ' ' + this.badge : '') : this.$attrs['aria-label'];
|
2023-04-13 09:19:28 +00:00
|
|
|
},
|
|
|
|
hasIcon() {
|
|
|
|
return this.icon || this.$slots.icon;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
2023-04-13 09:19:28 +00:00
|
|
|
components: {
|
|
|
|
SpinnerIcon
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
directives: {
|
2022-09-14 11:26:01 +00:00
|
|
|
ripple: Ripple
|
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>
|