UNPKG

tdesign-vue-next

Version:
128 lines (124 loc) 4.3 kB
/** * tdesign v1.11.5 * (c) 2025 tdesign * @license MIT */ import { getMark, emitEvent } from '../util.mjs'; import useTreeAction from './useTreeAction.mjs'; import '../../_chunks/dep-da95471f.mjs'; import '../../_chunks/dep-4ed7019e.mjs'; import 'lodash-es'; import '../adapt.mjs'; import 'vue'; import '../../utils/withInstall.mjs'; import '../../hooks/useVModel.mjs'; import '../../hooks/useDefaultValue.mjs'; import 'tdesign-icons-vue-next'; import '../../checkbox/index.mjs'; import '../../checkbox/checkbox.mjs'; import '../../_chunks/dep-6d9c1bfc.mjs'; import '../../_chunks/dep-9f375e51.mjs'; import '../../checkbox/props.mjs'; import '../../hooks/useRipple.mjs'; import '../../hooks/useKeepAnimation.mjs'; import '../../hooks/useConfig.mjs'; import '../../config-provider/hooks/useConfig.mjs'; import '../../config-provider/utils/context.mjs'; import '../../_chunks/dep-a5ae2f3f.mjs'; import '../../_chunks/dep-82d2a14f.mjs'; import '../../_chunks/dep-37fa6ccb.mjs'; import '../../_chunks/dep-7fb24b17.mjs'; import '../../_chunks/dep-6cfc5734.mjs'; import '../../_chunks/dep-46ec3e86.mjs'; import '../../utils/render-tnode.mjs'; import '../../checkbox/consts/index.mjs'; import '../../checkbox/hooks/useCheckboxLazyLoad.mjs'; import '../../_chunks/dep-221379fb.mjs'; import '../../checkbox/hooks/useKeyboardEvent.mjs'; import '../../_chunks/dep-251d5b63.mjs'; import '../../hooks/useDisabled.mjs'; import '../../hooks/useReadonly.mjs'; import '../../checkbox/group.mjs'; import '../../_chunks/dep-03e058e5.mjs'; import '../../checkbox/checkbox-group-props.mjs'; import '../../hooks/slot.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-3d81ac0a.mjs'; import '../../_chunks/dep-6a79c950.mjs'; import '../../utils/dom.mjs'; import '../../hooks/useTeleport.mjs'; import '../../loading/props.mjs'; import '../../hooks/useGlobalIcon.mjs'; import '../../hooks/useLazyLoad.mjs'; import '../../hooks/useVirtualScrollNew.mjs'; import '../../hooks/useResizeObserver.mjs'; import '../../_chunks/dep-3f189a8c.mjs'; import '../../_chunks/dep-3630a49c.mjs'; import '../../_chunks/dep-7dcc7954.mjs'; import '../../_chunks/dep-88187fb2.mjs'; import '../../_chunks/dep-198540b0.mjs'; function useTreeEvents(state) { var treeState = state; var props = treeState.props, context = treeState.context; var _useTreeAction = useTreeAction(state), toggleExpanded = _useTreeAction.toggleExpanded, toggleActived = _useTreeAction.toggleActived, toggleChecked = _useTreeAction.toggleChecked; var handleClick = function handleClick(evtState) { var mouseEvent = evtState.mouseEvent, event = evtState.event, node = evtState.node; if (!node || !mouseEvent) return; treeState.mouseEvent = mouseEvent; var shouldExpand = props.expandOnClickNode; var shouldActive = !props.disabled && !node.disabled && node.isActivable(); ["trigger", "ignore"].forEach(function (markName) { var mark = getMark(markName, event.target, event.currentTarget); var markValue = (mark === null || mark === void 0 ? void 0 : mark.value) || ""; if (markValue.indexOf("expand") >= 0) { if (markName === "trigger") { shouldExpand = true; } else if (markName === "ignore") { shouldExpand = false; } } if (markValue.indexOf("active") >= 0) { if (markName === "ignore") { shouldActive = false; } } }); if (shouldExpand) { toggleExpanded(node); } if (shouldActive) { toggleActived(node); } var evtCtx = { node: node.getModel(), e: mouseEvent }; emitEvent(props, context, "click", evtCtx); treeState.mouseEvent = null; }; var handleChange = function handleChange(evtState, ctx) { var disabled = props.disabled; var node = evtState.node; if (!node || disabled || node.disabled || !node.isCheckable()) { return; } toggleChecked(node, ctx); }; return { handleChange: handleChange, handleClick: handleClick }; } export { useTreeEvents as default }; //# sourceMappingURL=useTreeEvents.mjs.map