UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

25 lines (24 loc) 1.22 kB
//#region src/base-ui/Popover/hoverOnlyPress.ts /** * Base UI Popover.Trigger always wires useClick. With openOnHover, a press while * the popup is hover-open can re-open with reason `trigger-press` (stickIfOpen), * which disables mouseleave dismiss. Hover-only triggers must cancel press-driven * opens so antd-compatible `trigger="hover"` keeps hover close semantics. */ function shouldCancelHoverOnlyPressOpen(openOnClick, nextOpen, reason) { return !openOnClick && nextOpen && reason === "trigger-press"; } /** * Stamped on a grouped trigger that only opens on hover. The group arbitrates * open changes for every member from one handler, and the event only carries the * trigger element — without this it cannot tell which member the press belongs to * and would judge it by whichever member happens to be active. */ const HOVER_ONLY_TRIGGER_ATTR = "data-hover-only-trigger"; function isHoverOnlyTriggerElement(trigger) { if (typeof Element === "undefined" || !(trigger instanceof Element)) return null; return trigger.hasAttribute(HOVER_ONLY_TRIGGER_ATTR); } //#endregion export { HOVER_ONLY_TRIGGER_ATTR, isHoverOnlyTriggerElement, shouldCancelHoverOnlyPressOpen }; //# sourceMappingURL=hoverOnlyPress.mjs.map