2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2023-05-24 07:39:02 +00:00
|
|
|
<div v-if="visible" :class="cx('root')" :aria-label="label" v-bind="ptm('root')">
|
2023-04-27 12:18:17 +00:00
|
|
|
<slot>
|
2023-04-21 13:24:22 +00:00
|
|
|
<img v-if="image" :src="image" v-bind="ptm('image')" />
|
2023-05-24 07:39:02 +00:00
|
|
|
<component v-else-if="$slots.icon" :is="$slots.icon" :class="cx('icon')" v-bind="ptm('icon')" />
|
|
|
|
<span v-else-if="icon" :class="cx('icon')" v-bind="ptm('icon')" />
|
|
|
|
<div v-if="label" :class="cx('label')" v-bind="ptm('label')">{{ label }}</div>
|
2023-04-27 12:18:17 +00:00
|
|
|
</slot>
|
2023-04-18 07:35:20 +00:00
|
|
|
<slot v-if="removable" name="removeicon" :onClick="close" :onKeydown="onKeydown">
|
2023-05-24 07:39:02 +00:00
|
|
|
<component :is="removeIcon ? 'span' : 'TimesCircleIcon'" tabindex="0" :class="cx('removeIcon')" @click="close" @keydown="onKeydown" v-bind="ptm('removeIcon')"></component>
|
2023-04-10 19:42:57 +00:00
|
|
|
</slot>
|
2022-09-06 12:03:37 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-05-24 07:39:02 +00:00
|
|
|
import BaseChip from './BaseChip.vue';
|
2023-04-18 12:53:43 +00:00
|
|
|
import TimesCircleIcon from 'primevue/icons/timescircle';
|
2023-04-14 14:10:51 +00:00
|
|
|
|
2022-09-06 12:03:37 +00:00
|
|
|
export default {
|
|
|
|
name: 'Chip',
|
2023-05-24 07:39:02 +00:00
|
|
|
extends: BaseChip,
|
2022-09-06 12:03:37 +00:00
|
|
|
emits: ['remove'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
visible: true
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2022-12-08 11:04:25 +00:00
|
|
|
onKeydown(event) {
|
|
|
|
if (event.key === 'Enter' || event.key === 'Backspace') {
|
|
|
|
this.close(event);
|
|
|
|
}
|
|
|
|
},
|
2022-09-06 12:03:37 +00:00
|
|
|
close(event) {
|
|
|
|
this.visible = false;
|
|
|
|
this.$emit('remove', event);
|
|
|
|
}
|
|
|
|
},
|
2023-04-10 19:42:57 +00:00
|
|
|
components: {
|
|
|
|
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>
|