import { defineVxeComponent } from '../../ui/src/comp';
import XEUtils from 'xe-utils';
import { getConfig, createEvent, renderEmptyElement } from '../../ui';
function createReactData() {
    return {};
}
function createInternalData() {
    return {};
}
export default {
    name: 'VxeTransfer',
    props: {
        modelValue: Array,
        options: Array,
        size: {
            type: String,
            default: () => getConfig().transfer.size || getConfig().size
        }
    },
    data() {
        const xID = XEUtils.uniqueId();
        const reactData = createReactData();
        return Object.assign(Object.assign({}, {}), { xID,
            reactData });
    },
    methods: {
        //
        // Method
        //
        dispatchEvent(type, params, evnt) {
            const $xeTransfer = this;
            $xeTransfer.$emit(type, createEvent(evnt, { $transfer: $xeTransfer }, params));
        },
        emitModel(value) {
            const $xeTransfer = this;
            const { _events } = $xeTransfer;
            if (_events && _events.modelValue) {
                $xeTransfer.$emit('modelValue', value);
            }
            else {
                $xeTransfer.$emit('model-value', value);
            }
        },
        //
        // Render
        //
        renderVN(h) {
            const $xeTransfer = this;
            const slots = $xeTransfer.$scopedSlots;
            const headerSlot = slots.header;
            const footerSlot = slots.footer;
            return h('div', {
                ref: 'refElem',
                class: 'vxe-transfer'
            }, [
                headerSlot
                    ? h('div', {
                        class: 'vxe-transfer--header'
                    }, headerSlot({ $transfer: $xeTransfer }))
                    : renderEmptyElement($xeTransfer),
                h('div'),
                h('div'),
                h('div'),
                footerSlot
                    ? h('div', {
                        class: 'vxe-transfer--footer'
                    }, footerSlot({ $transfer: $xeTransfer }))
                    : renderEmptyElement($xeTransfer)
            ]);
        }
    },
    created() {
        const $xeUpload = this;
        $xeUpload.internalData = createInternalData();
    },
    beforeDestroy() {
        const $xeUpload = this;
        const reactData = $xeUpload.reactData;
        const internalData = $xeUpload.internalData;
        XEUtils.assign(reactData, createReactData());
        XEUtils.assign(internalData, createInternalData());
    },
    render(h) {
        return this.renderVN(h);
    }
};
