import { ref, h, PropType } from 'vue' import { defineVxeComponent } from '../../ui/src/comp' import XEUtils from 'xe-utils' import { VxeUI } from '@vxe-ui/core' import type { VxeDividerEmits, VxeDividerPropTypes, DividerMethods, DividerPrivateMethods, ValueOf, DividerPrivateRef, VxeDividerPrivateComputed, VxeDividerConstructor, VxeDividerPrivateMethods } from '../../../types' const { getConfig, createEvent, useFns } = VxeUI export default /* define-vxe-component start */ defineVxeComponent({ name: 'VxeDivider', props: { vertical: { type: Boolean as PropType, default: () => getConfig().divider.vertical }, titleContent: { type: String as PropType, default: () => getConfig().divider.titleContent }, titleAlign: { type: String as PropType, default: () => getConfig().divider.titleAlign }, size: { type: String as PropType, default: () => getConfig().divider.size || getConfig().size } }, emits: [] as VxeDividerEmits, setup(props, context) { const { emit, slots } = context const xID = XEUtils.uniqueId() const refElem = ref() const { computeSize } = useFns.useSize(props) const refMaps: DividerPrivateRef = { refElem } const computeMaps: VxeDividerPrivateComputed = {} const $xeDivider = { xID, props, context, getRefMaps: () => refMaps, getComputeMaps: () => computeMaps } as unknown as VxeDividerConstructor & VxeDividerPrivateMethods const dispatchEvent = (type: ValueOf, params: Record, evnt: Event | null) => { emit(type, createEvent(evnt, { $divider: $xeDivider }, params)) } const dividerMethods: DividerMethods = { dispatchEvent } const dividerPrivateMethods: DividerPrivateMethods = {} Object.assign($xeDivider, dividerMethods, dividerPrivateMethods) const renderVN = () => { const { vertical, titleContent, titleAlign } = props const vSize = computeSize.value const titleSlot = slots.title return h( 'div', { ref: refElem, class: [ 'vxe-divider', vertical ? 'is--vertical' : 'is--horizontal', `t--align-${titleAlign || 'center'}`, { [`size--${vSize}`]: vSize } ] }, (titleContent || titleSlot) && !vertical ? [ h( 'span', { class: 'vxe-divider--content' }, titleSlot ? titleSlot({}) : titleContent ) ] : [] ) } $xeDivider.renderVN = renderVN return $xeDivider }, render() { return this.renderVN() } }) /* define-vxe-component end */