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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');
var isFunction = require('lodash/isFunction');
var components_upload_hooks_useDrag = require('../hooks/use-drag.js');
var components_upload_const = require('../const.js');
var utils_renderNode = require('../../../utils/render-node.js');
require('vue');
require('lodash');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);

var CustomFile = VueCompositionAPI.defineComponent({
  name: "UploadCustomFile",
  props: {
    ...components_upload_const.commonProps,
    dragEvents: Object,
    draggable: Boolean,
    dragContent: Function,
    trigger: Function,
    triggerUpload: Function,
    childrenNode: Function
  },
  setup(props) {
    const drag = components_upload_hooks_useDrag["default"](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`
      }, [utils_renderNode.renderContent(this, "dragContent", "trigger", {
        params
      }) || isFunction__default["default"](this.childrenNode) && this.childrenNode(params)])]);
    };
    return this.draggable ? renderDragContent() : h("div", {
      "class": `${this.classPrefix}-upload__trigger`,
      "on": {
        "click": this.triggerUpload
      }
    }, [isFunction__default["default"](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))]);
  }
});

exports["default"] = CustomFile;
//# sourceMappingURL=custom-file.js.map
