mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 18:47:51 +00:00
These fixes are all auto generated and can be merged directly Fixes the following issues 1. Event used on components should be hypenated 2. Attribute orders in components 3. Use `unmounted` instead of `destroyed` 4. Add explicit `emits` declarations for components, autofixed [using this script](https://gist.github.com/scmmishra/6f549109b96400006bb69bbde392eddf) We ignore the top level v-if for now, we will fix it later
71 lines
1.7 KiB
Vue
71 lines
1.7 KiB
Vue
<script setup>
|
|
import { shallowRef, computed, onMounted } from 'vue';
|
|
import emojiGroups from 'shared/components/emoji/emojisGroup.json';
|
|
import MentionBox from '../mentions/MentionBox.vue';
|
|
|
|
const props = defineProps({
|
|
searchKey: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits(['selectEmoji']);
|
|
|
|
const allEmojis = shallowRef([]);
|
|
|
|
const items = computed(() => {
|
|
if (!props.searchKey) return [];
|
|
const searchTerm = props.searchKey.toLowerCase();
|
|
return allEmojis.value.filter(emoji =>
|
|
emoji.searchString.includes(searchTerm)
|
|
);
|
|
});
|
|
|
|
function loadEmojis() {
|
|
allEmojis.value = emojiGroups.flatMap(({ emojis }) =>
|
|
emojis.map(({ name, slug, ...rest }) => ({
|
|
...rest,
|
|
name,
|
|
slug,
|
|
searchString: `${name.replace(/\s+/g, '')} ${slug}`.toLowerCase(), // Remove all whitespace and convert to lowercase
|
|
}))
|
|
);
|
|
}
|
|
|
|
function handleMentionClick(item = {}) {
|
|
emit('selectEmoji', item.emoji);
|
|
}
|
|
|
|
onMounted(() => {
|
|
loadEmojis();
|
|
});
|
|
</script>
|
|
|
|
<!-- eslint-disable-next-line vue/no-root-v-if -->
|
|
<template>
|
|
<MentionBox
|
|
v-if="items.length"
|
|
type="emoji"
|
|
:items="items"
|
|
@mention-select="handleMentionClick"
|
|
>
|
|
<template #default="{ item, selected }">
|
|
<span
|
|
class="max-w-full inline-flex items-center gap-0.5 min-w-0 mb-0 text-sm font-medium text-slate-900 dark:text-slate-100 group-hover:text-woot-500 dark:group-hover:text-woot-500 truncate"
|
|
>
|
|
{{ item.emoji }}
|
|
<p
|
|
class="relative mb-0 truncate bottom-px"
|
|
:class="{
|
|
'text-woot-500 dark:text-woot-500': selected,
|
|
'font-normal': !selected,
|
|
}"
|
|
>
|
|
:{{ item.name }}
|
|
</p>
|
|
</span>
|
|
</template>
|
|
</MentionBox>
|
|
</template>
|