/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent } from '@vue/composition-api';
import isFunction from 'lodash/isFunction';
import useDrag from '../hooks/useDrag.js';
import { commonProps } from '../constants.js';
import { renderContent } from '../../utils/render-tnode.js';
import '@babel/runtime/helpers/typeof';
import 'vue';
import 'lodash/camelCase';
import 'lodash/kebabCase';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var CustomFile = defineComponent({
  name: "UploadCustomFile",
  props: _objectSpread(_objectSpread({}, commonProps), {}, {
    dragEvents: Object,
    draggable: Boolean,
    dragContent: Function,
    trigger: Function,
    triggerUpload: Function,
    childrenNode: Function
  }),
  setup: function setup(props) {
    var drag = useDrag(props.dragEvents);
    var dragActive = drag.dragActive;
    return _objectSpread({
      dragActive: dragActive
    }, drag);
  },
  render: function render() {
    var _this = this,
      _this$$scopedSlots$de,
      _this$$scopedSlots;
    var h = arguments[0];
    var renderDragContent = function renderDragContent() {
      var params = {
        dragActive: _this.dragActive || false,
        files: _this.displayFiles
      };
      return h("div", {
        "class": "".concat(_this.classPrefix, "-upload__dragger ").concat(_this.classPrefix, "-upload__dragger-center"),
        "on": {
          "drop": _this.handleDrop,
          "dragenter": _this.handleDragenter,
          "dragover": _this.handleDragover,
          "dragleave": _this.handleDragleave,
          "click": _this.triggerUpload
        }
      }, [h("div", {
        "class": "".concat(_this.classPrefix, "-upload__trigger")
      }, [renderContent(_this, "dragContent", "trigger", {
        params: params
      }) || isFunction(_this.childrenNode) && _this.childrenNode(params)])]);
    };
    return this.draggable ? renderDragContent() : h("div", {
      "class": "".concat(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
