/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import { defineComponent } from '@vue/composition-api';
import isFunction from 'lodash/isFunction';
import useDrag from '../hooks/use-drag.js';
import { commonProps } from '../const.js';
import { renderContent } from '../../../utils/render-node.js';
import 'vue';
import 'lodash';

var CustomFile = defineComponent({
  name: "UploadCustomFile",
  props: {
    ...commonProps,
    dragEvents: Object,
    draggable: Boolean,
    dragContent: Function,
    trigger: Function,
    triggerUpload: Function,
    childrenNode: Function
  },
  setup(props) {
    const drag = useDrag(props.dragEvents);
    const {
      dragActive
    } = drag;
    return {
      dragActive,
      ...drag
    };
  },
  render() {
    var _this$$scopedSlots$de, _this$$scopedSlots;
    const h = arguments[0];
    const renderDragContent = () => {
      const params = {
        dragActive: this.dragActive,
        files: this.displayFiles
      };
      return h("div", {
        "class": `${this.classPrefix}-upload__dragger ${this.classPrefix}-upload__dragger-center`,
        "on": {
          "drop": this.handleDrop,
          "dragenter": this.handleDragenter,
          "dragover": this.handleDragover,
          "dragleave": this.handleDragleave,
          "click": this.triggerUpload
        }
      }, [h("div", {
        "class": `${this.classPrefix}-upload__trigger`
      }, [renderContent(this, "dragContent", "trigger", {
        params
      }) || isFunction(this.childrenNode) && this.childrenNode(params)])]);
    };
    return this.draggable ? renderDragContent() : h("div", {
      "class": `${this.classPrefix}-upload__trigger`,
      "on": {
        "click": this.triggerUpload
      }
    }, [isFunction(this.childrenNode) && this.childrenNode({
      files: this.displayFiles
    }) || ((_this$$scopedSlots$de = (_this$$scopedSlots = this.$scopedSlots).default) === null || _this$$scopedSlots$de === void 0 ? void 0 : _this$$scopedSlots$de.call(_this$$scopedSlots, null))]);
  }
});

export { CustomFile as default };
//# sourceMappingURL=custom-file.js.map
