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

import { ref } from '@vue/composition-api';

function useDrag(props) {
  const target = ref(null);
  const dragActive = ref(false);
  const 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;
  };
  const 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;
  };
  const 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;
  };
  const handleDragover = event => {
    event.preventDefault();
  };
  return {
    target,
    dragActive,
    handleDrop,
    handleDragenter,
    handleDragleave,
    handleDragover
  };
}

export { useDrag as default };
//# sourceMappingURL=use-drag.js.map
