import { defineComponent, inject, ref, unref, toRef, openBlock, createBlock, normalizeClass, withCtx, renderSlot } from 'vue'; import '../../popper/index.mjs'; import '../../../utils/index.mjs'; import '../../../hooks/index.mjs'; import { TOOLTIP_INJECTION_KEY } from './constants.mjs'; import { useTooltipTriggerProps } from './trigger.mjs'; import { whenTrigger } from './utils.mjs'; import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs'; import { useNamespace } from '../../../hooks/use-namespace/index.mjs'; import { composeEventHandlers } from '../../../utils/dom/event.mjs'; import ElPopperTrigger from '../../popper/src/trigger2.mjs'; const __default__ = defineComponent({ name: "ElTooltipTrigger" }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: useTooltipTriggerProps, setup(__props, { expose }) { const props = __props; const ns = useNamespace("tooltip"); const { controlled, id, open, onOpen, onClose, onToggle } = inject(TOOLTIP_INJECTION_KEY, void 0); const triggerRef = ref(null); const stopWhenControlledOrDisabled = () => { if (unref(controlled) || props.disabled) { return true; } }; const trigger = toRef(props, "trigger"); const onMouseenter = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "hover", onOpen)); const onMouseleave = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "hover", onClose)); const onClick = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "click", (e) => { if (e.button === 0) { onToggle(e); } })); const onFocus = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "focus", onOpen)); const onBlur = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "focus", onClose)); const onContextMenu = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "contextmenu", (e) => { e.preventDefault(); onToggle(e); })); const onKeydown = composeEventHandlers(stopWhenControlledOrDisabled, (e) => { const { code } = e; if (props.triggerKeys.includes(code)) { e.preventDefault(); onToggle(e); } }); expose({ triggerRef }); return (_ctx, _cache) => { return openBlock(), createBlock(unref(ElPopperTrigger), { id: unref(id), "virtual-ref": _ctx.virtualRef, open: unref(open), "virtual-triggering": _ctx.virtualTriggering, class: normalizeClass(unref(ns).e("trigger")), onBlur: unref(onBlur), onClick: unref(onClick), onContextmenu: unref(onContextMenu), onFocus: unref(onFocus), onMouseenter: unref(onMouseenter), onMouseleave: unref(onMouseleave), onKeydown: unref(onKeydown) }, { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 8, ["id", "virtual-ref", "open", "virtual-triggering", "class", "onBlur", "onClick", "onContextmenu", "onFocus", "onMouseenter", "onMouseleave", "onKeydown"]); }; } }); var ElTooltipTrigger = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "trigger.vue"]]); export { ElTooltipTrigger as default }; //# sourceMappingURL=trigger2.mjs.map