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

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var upload_hooks_useDrag = require('../hooks/useDrag.js');
var upload_constants = require('../constants.js');
var hooks_tnode = require('../../hooks/tnode.js');
require('lodash/isFunction');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isString');
require('lodash/isObject');

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

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

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 = vue.defineComponent({
  name: "UploadCustomFile",
  props: _objectSpread(_objectSpread({}, upload_constants.commonProps), {}, {
    dragEvents: Object,
    draggable: Boolean,
    dragContent: Function,
    trigger: Function,
    triggerUpload: Function,
    childrenNode: [String, Function]
  }),
  setup: function setup(props, _ref) {
    var slots = _ref.slots;
    var _toRefs = vue.toRefs(props),
      classPrefix = _toRefs.classPrefix,
      displayFiles = _toRefs.displayFiles;
    var drag = upload_hooks_useDrag["default"](props.dragEvents);
    var dragActive = drag.dragActive;
    var renderContent = hooks_tnode.useContent();
    var renderDragContent = function renderDragContent() {
      var _props$childrenNode;
      var params = {
        dragActive: dragActive.value || false,
        files: displayFiles.value
      };
      return vue.createVNode("div", {
        "class": "".concat(classPrefix.value, "-upload__dragger ").concat(classPrefix.value, "-upload__dragger-center"),
        "onDrop": drag.handleDrop,
        "onDragenter": drag.handleDragenter,
        "onDragover": drag.handleDragover,
        "onDragleave": drag.handleDragleave,
        "onClick": props.triggerUpload
      }, [vue.createVNode("div", {
        "class": "".concat(classPrefix.value, "-upload__trigger")
      }, [renderContent("dragContent", "trigger", {
        params: params
      }) || ((_props$childrenNode = props.childrenNode) === null || _props$childrenNode === void 0 ? void 0 : _props$childrenNode.call(props, params))])]);
    };
    return function () {
      var _props$childrenNode2, _slots$default;
      return vue.createVNode(vue.Fragment, null, [props.draggable ? renderDragContent() : vue.createVNode("div", {
        "class": "".concat(classPrefix.value, "-upload__trigger"),
        "onClick": props.triggerUpload
      }, [((_props$childrenNode2 = props.childrenNode) === null || _props$childrenNode2 === void 0 ? void 0 : _props$childrenNode2.call(props, {
        files: displayFiles.value
      })) || ((_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots))])]);
    };
  }
});

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