import { ref, h, reactive, PropType } from 'vue' import { defineVxeComponent } from '../../ui/src/comp' import XEUtils from 'xe-utils' import { VxeUI } from '@vxe-ui/core' import type { MentionReactData, VxeMentionPropTypes, MentionPrivateRef, VxeMentionEmits, VxeMentionPrivateComputed, MentionMethods, MentionPrivateMethods, VxeMentionConstructor, VxeMentionPrivateMethods, ValueOf } from '../../../types' const { getConfig, createEvent } = VxeUI export default /* define-vxe-component start */ defineVxeComponent({ name: 'VxeMention', props: { size: { type: String as PropType, default: () => getConfig().mention.size || getConfig().size } }, emits: [] as VxeMentionEmits, setup(props, context) { const { emit } = context const xID = XEUtils.uniqueId() const refElem = ref() const reactData = reactive({}) const refMaps: MentionPrivateRef = { refElem } const computeMaps: VxeMentionPrivateComputed = {} const $xeMention = { xID, props, context, reactData, getRefMaps: () => refMaps, getComputeMaps: () => computeMaps } as unknown as VxeMentionConstructor & VxeMentionPrivateMethods const dispatchEvent = (type: ValueOf, params: Record, evnt: Event | null) => { emit(type, createEvent(evnt, { $mention: $xeMention }, params)) } const tagMethods: MentionMethods = { dispatchEvent } const tagPrivateMethods: MentionPrivateMethods = {} Object.assign($xeMention, tagMethods, tagPrivateMethods) const renderVN = () => { return h('div', { ref: refElem, class: 'vxe-mention' }) } $xeMention.renderVN = renderVN return $xeMention }, render() { return this.renderVN() } }) /* define-vxe-component end */