UNPKG

tdesign-vue-next

Version:
150 lines (146 loc) 4.83 kB
/** * tdesign v1.13.2 * (c) 2025 tdesign * @license MIT */ import { DragPosition } from './useDraggable.js'; import { emitEvent } from '../util.js'; import 'lodash-es'; import 'vue'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/typeof'; import '../../config-provider/hooks/useConfig.js'; import '../../config-provider/utils/context.js'; import '../../_chunks/dep-78c14980.js'; import '../../_chunks/dep-09955460.js'; import 'dayjs'; import '@babel/runtime/helpers/slicedToArray'; import '../../_chunks/dep-17e50b35.js'; import '@babel/runtime/helpers/createClass'; import '@babel/runtime/helpers/classCallCheck'; import '@babel/runtime/helpers/defineProperty'; import '../../_chunks/dep-cedcb3d0.js'; import 'tdesign-icons-vue-next'; import '../../checkbox/index.js'; import '../../checkbox/checkbox.js'; import '../../checkbox/props.js'; import '../../_chunks/dep-2b7081ce.js'; import '../../utils/render-tnode.js'; import '../../_chunks/dep-ce96cd30.js'; import '../../_chunks/dep-8da4c7ba.js'; import '../../_chunks/dep-8d697283.js'; import '../../_chunks/dep-d5d1b50b.js'; import '../../_chunks/dep-0593311f.js'; import '../../_chunks/dep-1f560187.js'; import '../../_chunks/dep-02840c31.js'; import '../../checkbox/consts/index.js'; import '../../checkbox/hooks/useCheckboxLazyLoad.js'; import '../../_chunks/dep-02bb42d0.js'; import '../../checkbox/hooks/useKeyboardEvent.js'; import '../../_chunks/dep-7c41ebd1.js'; import '../../checkbox/group.js'; import '../../checkbox/checkbox-group-props.js'; import '../../_chunks/dep-a018f4a7.js'; import '../../utils/withInstall.js'; import 'tdesign-vue-next/esm/common/style/web/components/checkbox/_index.less'; import '../../loading/index.js'; import '../../loading/directive.js'; import '../../loading/plugin.js'; import '../../_chunks/dep-a916af84.js'; import '../../loading/icon/gradient.js'; import '../../_chunks/dep-2c03cc07.js'; import '@babel/runtime/helpers/objectWithoutProperties'; import '../../utils/dom.js'; import '../../loading/props.js'; import 'tdesign-vue-next/esm/common/style/web/components/loading/_index.less'; import '@babel/runtime/helpers/asyncToGenerator'; import '@babel/runtime/regenerator'; 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.js.map