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 { EmptyReactData, VxeEmptyEmits, VxeEmptyPropTypes, EmptyMethods, EmptyPrivateMethods, ValueOf, EmptyPrivateRef, VxeEmptyPrivateComputed, VxeEmptyConstructor, VxeEmptyPrivateMethods } from '../../../types' const { getConfig, getI18n, getIcon, createEvent } = VxeUI export default /* define-vxe-component start */ defineVxeComponent({ name: 'VxeEmpty', props: { imageUrl: String as PropType, imageStyle: Object as PropType, icon: String as PropType, status: { type: String as PropType, default: () => getConfig().empty.status }, content: [String, Number] as PropType }, emits: [] as VxeEmptyEmits, setup(props, context) { const { emit } = context const xID = XEUtils.uniqueId() const refElem = ref() const reactData = reactive({}) const refMaps: EmptyPrivateRef = { refElem } const computeMaps: VxeEmptyPrivateComputed = {} const $xeEmpty = { xID, props, context, reactData, getRefMaps: () => refMaps, getComputeMaps: () => computeMaps } as unknown as VxeEmptyConstructor & VxeEmptyPrivateMethods const dispatchEvent = (type: ValueOf, params: Record, evnt: Event | null) => { emit(type, createEvent(evnt, { $empty: $xeEmpty }, params)) } const emptyMethods: EmptyMethods = { dispatchEvent } const emptyPrivateMethods: EmptyPrivateMethods = {} Object.assign($xeEmpty, emptyMethods, emptyPrivateMethods) const renderVN = () => { const { imageUrl, imageStyle, icon, status, content } = props return h( 'div', { ref: refElem, class: [ 'vxe-empty', { [`theme--${status}`]: status } ] }, [ h( 'div', { class: 'vxe-empty--inner' }, [ imageUrl ? h( 'div', { class: 'vxe-empty--img-wrapper' }, [ h('img', { src: imageUrl, style: imageStyle }) ] ) : h( 'div', { class: 'vxe-empty--icon-wrapper' }, [ h('i', { class: icon || getIcon().EMPTY_DEFAULT }) ] ), h( 'div', { class: 'vxe-empty--content-wrapper' }, `${content || getI18n('vxe.empty.defText')}` ) ] ) ] ) } $xeEmpty.renderVN = renderVN return $xeEmpty }, render() { return this.renderVN() } }) /* define-vxe-component end */