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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var isFunction = require('lodash/isFunction');
var upload_hooks_useDrag = require('../hooks/useDrag.js');
var upload_constants = require('../constants.js');
var utils_renderTnode = require('../../utils/render-tnode.js');
require('@babel/runtime/helpers/typeof');
require('vue');
require('lodash/camelCase');
require('lodash/kebabCase');

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

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

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__default["default"](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 = VueCompositionAPI.defineComponent({
  name: "UploadCustomFile",
  props: _objectSpread(_objectSpread({}, upload_constants.commonProps), {}, {
    dragEvents: Object,
    draggable: Boolean,
    dragContent: Function,
    trigger: Function,
    triggerUpload: Function,
    childrenNode: Function
  }),
  setup: function setup(props) {
    var drag = upload_hooks_useDrag["default"](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")
      }, [utils_renderTnode.renderContent(_this, "dragContent", "trigger", {
        params: params
      }) || isFunction__default["default"](_this.childrenNode) && _this.childrenNode(params)])]);
    };
    return this.draggable ? renderDragContent() : h("div", {
      "class": "".concat(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
