UNPKG

tdesign-vue

Version:
121 lines (115 loc) 3.66 kB
/** * tdesign v1.12.1 * (c) 2025 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tree_hooks_useDraggable = require('./useDraggable.js'); var tree_util = require('../util.js'); require('../../_chunks/dep-a283b0cb.js'); require('../../_chunks/dep-965b0138.js'); require('../../_chunks/dep-51fe98f1.js'); require('@babel/runtime/helpers/typeof'); require('../../_chunks/dep-5ea2b00f.js'); require('../../_chunks/dep-cdb9a98c.js'); require('../../_chunks/dep-7b78e8c3.js'); require('../../_chunks/dep-d7270eaf.js'); require('@vue/composition-api'); require('@babel/runtime/helpers/defineProperty'); require('../../_chunks/dep-bf70543d.js'); require('../../_chunks/dep-f895c884.js'); require('../../_chunks/dep-e1cc6f64.js'); require('../../_chunks/dep-9b72cbc5.js'); require('../../_chunks/dep-68f48b50.js'); require('../../_chunks/dep-051ce30d.js'); require('../../_chunks/dep-4b30bfe2.js'); function useDragHandle(state) { var props = state.props, context = state.context, scope = state.scope, store = state.store; var dragNode = null; var handleDragStart = function handleDragStart(state2) { var dragEvent = state2.dragEvent, node = state2.node; dragNode = node; var ctx = { node: node.getModel(), e: dragEvent }; tree_util.emitEvent(props, context, "drag-start", ctx); }; var handleDragEnd = function handleDragEnd(state2) { var dragEvent = state2.dragEvent, node = state2.node; dragNode = node; var ctx = { node: node.getModel(), e: dragEvent }; tree_util.emitEvent(props, context, "drag-end", ctx); }; var handleDragOver = function handleDragOver(state2) { var dragEvent = state2.dragEvent, node = state2.node; var ctx = { node: node.getModel(), e: dragEvent }; tree_util.emitEvent(props, context, "drag-over", ctx); }; var handleDragLeave = function handleDragLeave(state2) { var dragEvent = state2.dragEvent, node = state2.node; var ctx = { node: node.getModel(), e: dragEvent }; tree_util.emitEvent(props, context, "drag-leave", ctx); }; var handleDrop = function handleDrop(state2) { var _props$allowDrop; var dragEvent = state2.dragEvent, node = state2.node, dropPosition = state2.dropPosition; if (node.value === dragNode.value || node.getParents().some(function (_node) { return _node.value === dragNode.value; })) return; var ctx = { dropNode: node.getModel(), dragNode: dragNode.getModel(), dropPosition: dropPosition, e: dragEvent }; if (((_props$allowDrop = props.allowDrop) === null || _props$allowDrop === void 0 ? void 0 : _props$allowDrop.call(props, ctx)) === false) return; var nodes = store.getNodes(); nodes.some(function (_node) { if (_node.value === node.value) { if (dropPosition === tree_hooks_useDraggable.DragPosition.Inside) { dragNode.appendTo(store, _node); } else if (dropPosition === tree_hooks_useDraggable.DragPosition.Before) { node.insertBefore(dragNode); } else { node.insertAfter(dragNode); } return true; } return false; }); tree_util.emitEvent(props, context, "drop", ctx); }; var drag = { handleDragStart: handleDragStart, handleDragEnd: handleDragEnd, handleDragOver: handleDragOver, handleDragLeave: handleDragLeave, handleDrop: handleDrop }; scope.drag = drag; return { drag: drag }; } exports["default"] = useDragHandle; //# sourceMappingURL=useDragHandle.js.map