@octanejs/floating-ui 0.1.31 → 0.1.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var transitions_exports = {};
20
+ __export(transitions_exports, {
21
+ useTransitionStatus: () => useTransitionStatus,
22
+ useTransitionStyles: () => useTransitionStyles
23
+ });
24
+ module.exports = __toCommonJS(transitions_exports);
25
+ var import_octane = require("octane");
26
+ var import_internal = require("./internal.cjs");
27
+ var import_utils = require("./utils/index.cjs");
28
+ function useDelayUnmount(open, durationMs, slot) {
29
+ const [isMounted, setIsMounted] = (0, import_octane.useState)(open, (0, import_internal.subSlot)(slot, "mounted"));
30
+ if (open && !isMounted) {
31
+ setIsMounted(true);
32
+ }
33
+ (0, import_octane.useEffect)(
34
+ () => {
35
+ if (!open && isMounted) {
36
+ const timeout = setTimeout(() => setIsMounted(false), durationMs);
37
+ return () => clearTimeout(timeout);
38
+ }
39
+ },
40
+ [open, isMounted, durationMs],
41
+ (0, import_internal.subSlot)(slot, "eff")
42
+ );
43
+ return isMounted;
44
+ }
45
+ function useTransitionStatus(...args) {
46
+ const [user, slot] = (0, import_internal.splitSlot)(args);
47
+ const context = user[0];
48
+ const props = user[1] ?? {};
49
+ const open = context.open;
50
+ const floating = context.elements.floating;
51
+ const duration = props.duration ?? 250;
52
+ const isNumberDuration = typeof duration === "number";
53
+ const closeDuration = (isNumberDuration ? duration : duration.close) || 0;
54
+ const [status, setStatus] = (0, import_octane.useState)("unmounted", (0, import_internal.subSlot)(slot, "status"));
55
+ const isMounted = useDelayUnmount(open, closeDuration, (0, import_internal.subSlot)(slot, "unmount"));
56
+ if (!isMounted && status === "close") {
57
+ setStatus("unmounted");
58
+ }
59
+ (0, import_utils.useModernLayoutEffect)(
60
+ () => {
61
+ if (!floating) return;
62
+ if (open) {
63
+ setStatus("initial");
64
+ const frame = requestAnimationFrame(() => {
65
+ (0, import_octane.flushSync)(() => {
66
+ setStatus("open");
67
+ });
68
+ });
69
+ return () => {
70
+ cancelAnimationFrame(frame);
71
+ };
72
+ }
73
+ setStatus("close");
74
+ },
75
+ [open, floating],
76
+ (0, import_internal.subSlot)(slot, "eff")
77
+ );
78
+ return { isMounted, status };
79
+ }
80
+ function useTransitionStyles(...args) {
81
+ const [user, slot] = (0, import_internal.splitSlot)(args);
82
+ const context = user[0];
83
+ const props = user[1] ?? {};
84
+ const unstableInitial = props.initial ?? { opacity: 0 };
85
+ const unstableOpen = props.open;
86
+ const unstableClose = props.close;
87
+ const unstableCommon = props.common;
88
+ const duration = props.duration ?? 250;
89
+ const placement = context.placement;
90
+ const side = placement.split("-")[0];
91
+ const fnArgs = (0, import_octane.useMemo)(() => ({ side, placement }), [side, placement], (0, import_internal.subSlot)(slot, "args"));
92
+ const isNumberDuration = typeof duration === "number";
93
+ const openDuration = (isNumberDuration ? duration : duration.open) || 0;
94
+ const closeDuration = (isNumberDuration ? duration : duration.close) || 0;
95
+ const [styles, setStyles] = (0, import_octane.useState)(
96
+ () => ({
97
+ ...(0, import_utils.execWithArgsOrReturn)(unstableCommon, fnArgs),
98
+ ...(0, import_utils.execWithArgsOrReturn)(unstableInitial, fnArgs)
99
+ }),
100
+ (0, import_internal.subSlot)(slot, "styles")
101
+ );
102
+ const { isMounted, status } = useTransitionStatus(context, { duration }, (0, import_internal.subSlot)(slot, "status"));
103
+ const initialRef = (0, import_utils.useLatestRef)(unstableInitial, (0, import_internal.subSlot)(slot, "initialRef"));
104
+ const openRef = (0, import_utils.useLatestRef)(unstableOpen, (0, import_internal.subSlot)(slot, "openRef"));
105
+ const closeRef = (0, import_utils.useLatestRef)(unstableClose, (0, import_internal.subSlot)(slot, "closeRef"));
106
+ const commonRef = (0, import_utils.useLatestRef)(unstableCommon, (0, import_internal.subSlot)(slot, "commonRef"));
107
+ (0, import_utils.useModernLayoutEffect)(
108
+ () => {
109
+ const initialStyles = (0, import_utils.execWithArgsOrReturn)(initialRef.current, fnArgs);
110
+ const closeStyles = (0, import_utils.execWithArgsOrReturn)(closeRef.current, fnArgs);
111
+ const commonStyles = (0, import_utils.execWithArgsOrReturn)(commonRef.current, fnArgs);
112
+ const openStyles = (0, import_utils.execWithArgsOrReturn)(openRef.current, fnArgs) || Object.keys(initialStyles).reduce((acc, key) => {
113
+ acc[key] = "";
114
+ return acc;
115
+ }, {});
116
+ if (status === "initial") {
117
+ setStyles((s) => ({
118
+ transitionProperty: s.transitionProperty,
119
+ ...commonStyles,
120
+ ...initialStyles
121
+ }));
122
+ }
123
+ if (status === "open") {
124
+ setStyles({
125
+ transitionProperty: Object.keys(openStyles).map(import_utils.camelCaseToKebabCase).join(","),
126
+ transitionDuration: openDuration + "ms",
127
+ ...commonStyles,
128
+ ...openStyles
129
+ });
130
+ }
131
+ if (status === "close") {
132
+ const s = closeStyles || initialStyles;
133
+ setStyles({
134
+ transitionProperty: Object.keys(s).map(import_utils.camelCaseToKebabCase).join(","),
135
+ transitionDuration: closeDuration + "ms",
136
+ ...commonStyles,
137
+ ...s
138
+ });
139
+ }
140
+ },
141
+ [closeDuration, closeRef, initialRef, openRef, commonRef, openDuration, status, fnArgs],
142
+ (0, import_internal.subSlot)(slot, "eff")
143
+ );
144
+ return { isMounted, styles };
145
+ }
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ useTransitionStatus,
149
+ useTransitionStyles
150
+ });
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var tree_exports = {};
20
+ __export(tree_exports, {
21
+ FloatingNode: () => FloatingNode,
22
+ FloatingNodeContext: () => FloatingNodeContext,
23
+ FloatingTree: () => FloatingTree,
24
+ FloatingTreeContext: () => FloatingTreeContext,
25
+ useFloatingNodeId: () => useFloatingNodeId,
26
+ useFloatingParentNodeId: () => useFloatingParentNodeId,
27
+ useFloatingTree: () => useFloatingTree
28
+ });
29
+ module.exports = __toCommonJS(tree_exports);
30
+ var import_octane = require("octane");
31
+ var import_pubsub = require("./pubsub.cjs");
32
+ var import_internal = require("./internal.cjs");
33
+ var import_useId = require("./useId.cjs");
34
+ var import_utils = require("./utils/index.cjs");
35
+ const FloatingNodeContext = (0, import_octane.createContext)(null);
36
+ const FloatingTreeContext = (0, import_octane.createContext)(null);
37
+ const useFloatingParentNodeId = () => {
38
+ const context = (0, import_octane.useContext)(FloatingNodeContext);
39
+ return context ? context.id ?? null : null;
40
+ };
41
+ const useFloatingTree = () => (0, import_octane.useContext)(FloatingTreeContext);
42
+ function useFloatingNodeId(...args) {
43
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
44
+ const slot = slotArg ?? (0, import_internal.S)("useFloatingNodeId");
45
+ const customParentId = user[0];
46
+ const id = (0, import_useId.useId)((0, import_internal.subSlot)(slot, "id"));
47
+ const tree = useFloatingTree();
48
+ const reactParentId = useFloatingParentNodeId();
49
+ const parentId = customParentId || reactParentId;
50
+ (0, import_utils.useModernLayoutEffect)(
51
+ () => {
52
+ if (!id) return;
53
+ const node = { id, parentId };
54
+ tree?.addNode(node);
55
+ return () => {
56
+ tree?.removeNode(node);
57
+ };
58
+ },
59
+ [tree, id, parentId],
60
+ (0, import_internal.subSlot)(slot, "eff")
61
+ );
62
+ return id;
63
+ }
64
+ function FloatingNode(props) {
65
+ const children = props.children;
66
+ const id = props.id;
67
+ const parentId = useFloatingParentNodeId();
68
+ const value = (0, import_octane.useMemo)(() => ({ id, parentId }), [id, parentId], (0, import_internal.S)("FloatingNode:value"));
69
+ return (0, import_octane.createElement)(FloatingNodeContext.Provider, { value, children });
70
+ }
71
+ function FloatingTree(props) {
72
+ const children = props.children;
73
+ const nodesRef = (0, import_octane.useRef)([], (0, import_internal.S)("FloatingTree:nodes"));
74
+ const addNode = (0, import_octane.useCallback)(
75
+ (node) => {
76
+ nodesRef.current = [...nodesRef.current, node];
77
+ },
78
+ [],
79
+ (0, import_internal.S)("FloatingTree:add")
80
+ );
81
+ const removeNode = (0, import_octane.useCallback)(
82
+ (node) => {
83
+ nodesRef.current = nodesRef.current.filter((n) => n !== node);
84
+ },
85
+ [],
86
+ (0, import_internal.S)("FloatingTree:remove")
87
+ );
88
+ const [events] = (0, import_octane.useState)(() => (0, import_pubsub.createPubSub)(), (0, import_internal.S)("FloatingTree:events"));
89
+ const value = (0, import_octane.useMemo)(
90
+ () => ({ nodesRef, addNode, removeNode, events }),
91
+ [addNode, removeNode, events],
92
+ (0, import_internal.S)("FloatingTree:value")
93
+ );
94
+ return (0, import_octane.createElement)(FloatingTreeContext.Provider, { value, children });
95
+ }
96
+ // Annotate the CommonJS export names for ESM import in node:
97
+ 0 && (module.exports = {
98
+ FloatingNode,
99
+ FloatingNodeContext,
100
+ FloatingTree,
101
+ FloatingTreeContext,
102
+ useFloatingNodeId,
103
+ useFloatingParentNodeId,
104
+ useFloatingTree
105
+ });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useClick_exports = {};
20
+ __export(useClick_exports, {
21
+ useClick: () => useClick
22
+ });
23
+ module.exports = __toCommonJS(useClick_exports);
24
+ var import_dom = require("@floating-ui/utils/dom");
25
+ var import_octane = require("octane");
26
+ var import_internal = require("./internal.cjs");
27
+ var import_utils = require("./utils/index.cjs");
28
+ function isButtonTarget(event) {
29
+ return (0, import_dom.isHTMLElement)(event.target) && event.target.tagName === "BUTTON";
30
+ }
31
+ function isAnchorTarget(event) {
32
+ return (0, import_dom.isHTMLElement)(event.target) && event.target.tagName === "A";
33
+ }
34
+ function isSpaceIgnored(element) {
35
+ return (0, import_utils.isTypeableElement)(element);
36
+ }
37
+ function useClick(...args) {
38
+ const [user, slot] = (0, import_internal.splitSlot)(args);
39
+ const context = user[0];
40
+ const props = user[1] ?? {};
41
+ const open = context.open;
42
+ const onOpenChange = context.onOpenChange;
43
+ const dataRef = context.dataRef;
44
+ const domReference = context.elements.domReference;
45
+ const enabled = props.enabled ?? true;
46
+ const eventOption = props.event ?? "click";
47
+ const toggle = props.toggle ?? true;
48
+ const ignoreMouse = props.ignoreMouse ?? false;
49
+ const keyboardHandlers = props.keyboardHandlers ?? true;
50
+ const stickIfOpen = props.stickIfOpen ?? true;
51
+ const pointerTypeRef = (0, import_octane.useRef)(void 0, (0, import_internal.subSlot)(slot, "ptype"));
52
+ const didKeyDownRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "kd"));
53
+ const reference = (0, import_octane.useMemo)(
54
+ () => ({
55
+ onPointerDown(event) {
56
+ pointerTypeRef.current = event.pointerType;
57
+ },
58
+ onMouseDown(event) {
59
+ const pointerType = pointerTypeRef.current;
60
+ if (event.button !== 0) return;
61
+ if (eventOption === "click") return;
62
+ if ((0, import_utils.isMouseLikePointerType)(pointerType, true) && ignoreMouse) return;
63
+ if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === "mousedown" : true)) {
64
+ onOpenChange(false, event, "click");
65
+ } else {
66
+ event.preventDefault();
67
+ onOpenChange(true, event, "click");
68
+ }
69
+ },
70
+ onClick(event) {
71
+ const pointerType = pointerTypeRef.current;
72
+ if (eventOption === "mousedown" && pointerTypeRef.current) {
73
+ pointerTypeRef.current = void 0;
74
+ return;
75
+ }
76
+ if ((0, import_utils.isMouseLikePointerType)(pointerType, true) && ignoreMouse) return;
77
+ if (open && toggle && (dataRef.current.openEvent && stickIfOpen ? dataRef.current.openEvent.type === "click" : true)) {
78
+ onOpenChange(false, event, "click");
79
+ } else {
80
+ onOpenChange(true, event, "click");
81
+ }
82
+ },
83
+ onKeyDown(event) {
84
+ pointerTypeRef.current = void 0;
85
+ if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event)) {
86
+ return;
87
+ }
88
+ if (event.key === " " && !isSpaceIgnored(domReference)) {
89
+ event.preventDefault();
90
+ didKeyDownRef.current = true;
91
+ }
92
+ if (isAnchorTarget(event)) {
93
+ return;
94
+ }
95
+ if (event.key === "Enter") {
96
+ if (open && toggle) {
97
+ onOpenChange(false, event, "click");
98
+ } else {
99
+ onOpenChange(true, event, "click");
100
+ }
101
+ }
102
+ },
103
+ onKeyUp(event) {
104
+ if (event.defaultPrevented || !keyboardHandlers || isButtonTarget(event) || isSpaceIgnored(domReference)) {
105
+ return;
106
+ }
107
+ if (event.key === " " && didKeyDownRef.current) {
108
+ didKeyDownRef.current = false;
109
+ if (open && toggle) {
110
+ onOpenChange(false, event, "click");
111
+ } else {
112
+ onOpenChange(true, event, "click");
113
+ }
114
+ }
115
+ }
116
+ }),
117
+ [
118
+ dataRef,
119
+ domReference,
120
+ eventOption,
121
+ ignoreMouse,
122
+ keyboardHandlers,
123
+ onOpenChange,
124
+ open,
125
+ stickIfOpen,
126
+ toggle
127
+ ],
128
+ (0, import_internal.subSlot)(slot, "m:ref")
129
+ );
130
+ return (0, import_octane.useMemo)(
131
+ () => enabled ? { reference } : {},
132
+ [enabled, reference],
133
+ (0, import_internal.subSlot)(slot, "m:ret")
134
+ );
135
+ }
136
+ // Annotate the CommonJS export names for ESM import in node:
137
+ 0 && (module.exports = {
138
+ useClick
139
+ });
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useClientPoint_exports = {};
20
+ __export(useClientPoint_exports, {
21
+ useClientPoint: () => useClientPoint
22
+ });
23
+ module.exports = __toCommonJS(useClientPoint_exports);
24
+ var import_dom = require("@floating-ui/utils/dom");
25
+ var import_octane = require("octane");
26
+ var import_internal = require("./internal.cjs");
27
+ var import_utils = require("./utils/index.cjs");
28
+ function createVirtualElement(domElement, data) {
29
+ let offsetX = null;
30
+ let offsetY = null;
31
+ let isAutoUpdateEvent = false;
32
+ return {
33
+ contextElement: domElement || void 0,
34
+ getBoundingClientRect() {
35
+ const domRect = domElement?.getBoundingClientRect() || { width: 0, height: 0, x: 0, y: 0 };
36
+ const isXAxis = data.axis === "x" || data.axis === "both";
37
+ const isYAxis = data.axis === "y" || data.axis === "both";
38
+ const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
39
+ let width = domRect.width;
40
+ let height = domRect.height;
41
+ let x = domRect.x;
42
+ let y = domRect.y;
43
+ if (offsetX == null && data.x && isXAxis) {
44
+ offsetX = domRect.x - data.x;
45
+ }
46
+ if (offsetY == null && data.y && isYAxis) {
47
+ offsetY = domRect.y - data.y;
48
+ }
49
+ x -= offsetX || 0;
50
+ y -= offsetY || 0;
51
+ width = 0;
52
+ height = 0;
53
+ if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
54
+ width = data.axis === "y" ? domRect.width : 0;
55
+ height = data.axis === "x" ? domRect.height : 0;
56
+ x = isXAxis && data.x != null ? data.x : x;
57
+ y = isYAxis && data.y != null ? data.y : y;
58
+ } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
59
+ height = data.axis === "x" ? domRect.height : height;
60
+ width = data.axis === "y" ? domRect.width : width;
61
+ }
62
+ isAutoUpdateEvent = true;
63
+ return { width, height, x, y, top: y, right: x + width, bottom: y + height, left: x };
64
+ }
65
+ };
66
+ }
67
+ function isMouseBasedEvent(event) {
68
+ return event != null && event.clientX != null;
69
+ }
70
+ function useClientPoint(...args) {
71
+ const [user, slot] = (0, import_internal.splitSlot)(args);
72
+ const context = user[0];
73
+ const props = user[1] ?? {};
74
+ const open = context.open;
75
+ const dataRef = context.dataRef;
76
+ const floating = context.elements.floating;
77
+ const domReference = context.elements.domReference;
78
+ const refs = context.refs;
79
+ const enabled = props.enabled ?? true;
80
+ const axis = props.axis ?? "both";
81
+ const x = props.x ?? null;
82
+ const y = props.y ?? null;
83
+ const initialRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "init"));
84
+ const cleanupListenerRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "cleanup"));
85
+ const [pointerType, setPointerType] = (0, import_octane.useState)(
86
+ void 0,
87
+ (0, import_internal.subSlot)(slot, "ptype")
88
+ );
89
+ const [reactive, setReactive] = (0, import_octane.useState)([], (0, import_internal.subSlot)(slot, "reactive"));
90
+ const setReference = (0, import_utils.useEffectEvent)(
91
+ (px, py) => {
92
+ if (initialRef.current) return;
93
+ if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
94
+ return;
95
+ }
96
+ refs.setPositionReference(
97
+ createVirtualElement(domReference, { x: px, y: py, axis, dataRef, pointerType })
98
+ );
99
+ },
100
+ (0, import_internal.subSlot)(slot, "setref")
101
+ );
102
+ const handleReferenceEnterOrMove = (0, import_utils.useEffectEvent)(
103
+ (event) => {
104
+ if (x != null || y != null) return;
105
+ if (!open) {
106
+ setReference(event.clientX, event.clientY);
107
+ } else if (!cleanupListenerRef.current) {
108
+ setReactive([]);
109
+ }
110
+ },
111
+ (0, import_internal.subSlot)(slot, "enter")
112
+ );
113
+ const openCheck = (0, import_utils.isMouseLikePointerType)(pointerType) ? floating : open;
114
+ const addListener = (0, import_octane.useCallback)(
115
+ () => {
116
+ if (!openCheck || !enabled || x != null || y != null) return;
117
+ const win = (0, import_dom.getWindow)(floating);
118
+ function handleMouseMove(event) {
119
+ const target = (0, import_utils.getTarget)(event);
120
+ if (!(0, import_utils.contains)(floating, target)) {
121
+ setReference(event.clientX, event.clientY);
122
+ } else {
123
+ win.removeEventListener("mousemove", handleMouseMove);
124
+ cleanupListenerRef.current = null;
125
+ }
126
+ }
127
+ if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
128
+ win.addEventListener("mousemove", handleMouseMove);
129
+ const cleanup = () => {
130
+ win.removeEventListener("mousemove", handleMouseMove);
131
+ cleanupListenerRef.current = null;
132
+ };
133
+ cleanupListenerRef.current = cleanup;
134
+ return cleanup;
135
+ }
136
+ refs.setPositionReference(domReference);
137
+ },
138
+ [openCheck, enabled, x, y, floating, dataRef, refs, domReference, setReference],
139
+ (0, import_internal.subSlot)(slot, "add")
140
+ );
141
+ (0, import_octane.useEffect)(
142
+ () => {
143
+ return addListener();
144
+ },
145
+ [addListener, reactive],
146
+ (0, import_internal.subSlot)(slot, "e:add")
147
+ );
148
+ (0, import_octane.useEffect)(
149
+ () => {
150
+ if (enabled && !floating) {
151
+ initialRef.current = false;
152
+ }
153
+ },
154
+ [enabled, floating],
155
+ (0, import_internal.subSlot)(slot, "e:reset")
156
+ );
157
+ (0, import_octane.useEffect)(
158
+ () => {
159
+ if (!enabled && open) {
160
+ initialRef.current = true;
161
+ }
162
+ },
163
+ [enabled, open],
164
+ (0, import_internal.subSlot)(slot, "e:block")
165
+ );
166
+ (0, import_utils.useModernLayoutEffect)(
167
+ () => {
168
+ if (enabled && (x != null || y != null)) {
169
+ initialRef.current = false;
170
+ setReference(x, y);
171
+ }
172
+ },
173
+ [enabled, x, y, setReference],
174
+ (0, import_internal.subSlot)(slot, "e:explicit")
175
+ );
176
+ const reference = (0, import_octane.useMemo)(
177
+ () => {
178
+ function setPointerTypeRef(_ref) {
179
+ const { pointerType: pt } = _ref;
180
+ setPointerType(pt);
181
+ }
182
+ return {
183
+ onPointerDown: setPointerTypeRef,
184
+ onPointerEnter: setPointerTypeRef,
185
+ onMouseMove: handleReferenceEnterOrMove,
186
+ onMouseEnter: handleReferenceEnterOrMove
187
+ };
188
+ },
189
+ [handleReferenceEnterOrMove],
190
+ (0, import_internal.subSlot)(slot, "m:ref")
191
+ );
192
+ return (0, import_octane.useMemo)(
193
+ () => enabled ? { reference } : {},
194
+ [enabled, reference],
195
+ (0, import_internal.subSlot)(slot, "m:ret")
196
+ );
197
+ }
198
+ // Annotate the CommonJS export names for ESM import in node:
199
+ 0 && (module.exports = {
200
+ useClientPoint
201
+ });