UNPKG

tdesign-vue-next

Version:
142 lines (138 loc) 4.42 kB
/** * tdesign v1.20.3 * (c) 2026 tdesign * @license MIT */ import { DragPosition } from './useDraggable.mjs'; import { emitEvent } from '../utils/index.mjs'; import 'lodash-es'; import '../utils/adapt.mjs'; import 'vue'; import '../../_chunks/dep-5975d369.mjs'; import '../../_chunks/dep-adf8ce39.mjs'; import '../../_chunks/dep-390963eb.mjs'; import '../../_chunks/dep-d84a2ec7.mjs'; import '../../_chunks/dep-12b4e978.mjs'; import '../../_chunks/dep-0841ee8f.mjs'; import '../../config-provider/hooks/useConfig.mjs'; import '../../config-provider/utils/context.mjs'; import '../../_chunks/dep-cf105282.mjs'; import '../../_chunks/dep-dcbc09c5.mjs'; import '../../_chunks/dep-9fc6972b.mjs'; import '../../_chunks/dep-ff183185.mjs'; import '../../_chunks/dep-a1cbfaae.mjs'; import '../../_chunks/dep-3f53eff0.mjs'; import '../../_chunks/dep-4c65e11b.mjs'; import '../../_chunks/dep-46776e3b.mjs'; import '../../_chunks/dep-07d8f2aa.mjs'; import '../../_chunks/dep-8aebe545.mjs'; import 'tdesign-icons-vue-next'; import '../../checkbox/index.mjs'; import '../../checkbox/checkbox.mjs'; import '../../checkbox/props.mjs'; import '../../checkbox/constants/index.mjs'; import '../../checkbox/hooks/useCheckboxLazyLoad.mjs'; import '../../checkbox/hooks/useKeyboardEvent.mjs'; import '../../checkbox/group.mjs'; import '../../checkbox/checkbox-group-props.mjs'; import './style/css.mjs'; import '../../loading/index.mjs'; import '../../loading/directive.mjs'; import '../../loading/plugin.mjs'; import '../../loading/loading.mjs'; import '../../loading/icon/gradient.mjs'; import '../../_chunks/dep-92b8be55.mjs'; import '../../_chunks/dep-b9c8a688.mjs'; import '../../loading/props.mjs'; import '../../_chunks/dep-abbb1a9d.mjs'; import '../../_chunks/dep-128e8914.mjs'; import '../../_chunks/dep-ad9e539e.mjs'; 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 }; 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 }; 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 }; 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 }; 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 === DragPosition.Inside) { dragNode.appendTo(store, _node); } else if (dropPosition === DragPosition.Before) { node.insertBefore(dragNode); } else { node.insertAfter(dragNode); } return true; } return false; }); emitEvent(props, context, "drop", ctx); }; var drag = { handleDragStart: handleDragStart, handleDragEnd: handleDragEnd, handleDragOver: handleDragOver, handleDragLeave: handleDragLeave, handleDrop: handleDrop }; scope.drag = drag; return { drag: drag }; } export { useDragHandle as default }; //# sourceMappingURL=useDragHandle.mjs.map