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

'use strict';

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

var vue = require('vue');

function useDrag(props) {
  var target = vue.ref(null);
  var dragActive = vue.ref(false);
  var handleDrop = function handleDrop(event) {
    var _props$onDragFileChan, _props$onDrop;
    event.preventDefault();
    (_props$onDragFileChan = props.onDragFileChange) === null || _props$onDragFileChan === void 0 ? void 0 : _props$onDragFileChan.call(props, event);
    (_props$onDrop = props.onDrop) === null || _props$onDrop === void 0 ? void 0 : _props$onDrop.call(props, {
      e: event
    });
    dragActive.value = false;
  };
  var handleDragenter = function handleDragenter(event) {
    var _props$onDragenter;
    event.preventDefault();
    target.value = event.target;
    (_props$onDragenter = props.onDragenter) === null || _props$onDragenter === void 0 ? void 0 : _props$onDragenter.call(props, {
      e: event
    });
    dragActive.value = true;
  };
  var handleDragleave = function handleDragleave(event) {
    var _props$onDragleave;
    if (event.target !== target.value) return;
    event.preventDefault();
    (_props$onDragleave = props.onDragleave) === null || _props$onDragleave === void 0 ? void 0 : _props$onDragleave.call(props, {
      e: event
    });
    dragActive.value = false;
  };
  var handleDragover = function handleDragover(event) {
    event.preventDefault();
  };
  return {
    target: target,
    dragActive: dragActive,
    handleDrop: handleDrop,
    handleDragenter: handleDragenter,
    handleDragleave: handleDragleave,
    handleDragover: handleDragover
  };
}

exports["default"] = useDrag;
//# sourceMappingURL=useDrag.js.map
