@octanejs/base-ui 0.1.31 → 0.1.32

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.
Files changed (201) hide show
  1. package/dist/cjs/accordion.cjs +497 -0
  2. package/dist/cjs/alert-dialog.cjs +65 -0
  3. package/dist/cjs/avatar.cjs +234 -0
  4. package/dist/cjs/button.cjs +54 -0
  5. package/dist/cjs/checkbox-group.cjs +165 -0
  6. package/dist/cjs/checkbox.cjs +475 -0
  7. package/dist/cjs/collapsible.cjs +700 -0
  8. package/dist/cjs/context-menu.cjs +257 -0
  9. package/dist/cjs/csp-provider.cjs +40 -0
  10. package/dist/cjs/dialog.cjs +741 -0
  11. package/dist/cjs/direction-provider.cjs +35 -0
  12. package/dist/cjs/field.cjs +559 -0
  13. package/dist/cjs/fieldset.cjs +101 -0
  14. package/dist/cjs/form.cjs +177 -0
  15. package/dist/cjs/index.cjs +133 -0
  16. package/dist/cjs/input.cjs +32 -0
  17. package/dist/cjs/internal.cjs +51 -0
  18. package/dist/cjs/menu.cjs +2420 -0
  19. package/dist/cjs/menubar.cjs +132 -0
  20. package/dist/cjs/merge-props.cjs +34 -0
  21. package/dist/cjs/meter.cjs +169 -0
  22. package/dist/cjs/number-field.cjs +812 -0
  23. package/dist/cjs/popover.cjs +966 -0
  24. package/dist/cjs/preview-card.cjs +632 -0
  25. package/dist/cjs/progress.cjs +206 -0
  26. package/dist/cjs/radio-group.cjs +264 -0
  27. package/dist/cjs/radio.cjs +327 -0
  28. package/dist/cjs/separator.cjs +44 -0
  29. package/dist/cjs/slider.cjs +1384 -0
  30. package/dist/cjs/switch.cjs +306 -0
  31. package/dist/cjs/tabs.cjs +727 -0
  32. package/dist/cjs/toast.cjs +1766 -0
  33. package/dist/cjs/toggle-group.cjs +118 -0
  34. package/dist/cjs/toggle.cjs +121 -0
  35. package/dist/cjs/tooltip.cjs +835 -0
  36. package/dist/cjs/unstable-use-media-query.cjs +79 -0
  37. package/dist/cjs/use-render.cjs +40 -0
  38. package/dist/cjs/utils/CSPContext.cjs +38 -0
  39. package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
  40. package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
  41. package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
  42. package/dist/cjs/utils/DirectionContext.cjs +34 -0
  43. package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
  44. package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
  45. package/dist/cjs/utils/MenubarContext.cjs +40 -0
  46. package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
  47. package/dist/cjs/utils/RequestQueue.cjs +111 -0
  48. package/dist/cjs/utils/TimeoutManager.cjs +50 -0
  49. package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
  50. package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
  51. package/dist/cjs/utils/addEventListener.cjs +33 -0
  52. package/dist/cjs/utils/areArraysEqual.cjs +30 -0
  53. package/dist/cjs/utils/clamp.cjs +30 -0
  54. package/dist/cjs/utils/closePart.cjs +70 -0
  55. package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
  56. package/dist/cjs/utils/composeRefs.cjs +68 -0
  57. package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
  58. package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
  59. package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
  60. package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
  61. package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
  62. package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
  63. package/dist/cjs/utils/composite/keys.cjs +174 -0
  64. package/dist/cjs/utils/composite/list-utils.cjs +90 -0
  65. package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
  66. package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
  67. package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
  68. package/dist/cjs/utils/constants.cjs +56 -0
  69. package/dist/cjs/utils/contains.cjs +46 -0
  70. package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
  71. package/dist/cjs/utils/dom.cjs +35 -0
  72. package/dist/cjs/utils/empty.cjs +34 -0
  73. package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
  74. package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
  75. package/dist/cjs/utils/field/FormContext.cjs +41 -0
  76. package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
  77. package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
  78. package/dist/cjs/utils/field/constants.cjs +68 -0
  79. package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
  80. package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
  81. package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
  82. package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
  83. package/dist/cjs/utils/field/useLabel.cjs +99 -0
  84. package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
  85. package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
  86. package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
  87. package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
  88. package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
  89. package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
  90. package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
  91. package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
  92. package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
  93. package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
  94. package/dist/cjs/utils/floating/composite.cjs +42 -0
  95. package/dist/cjs/utils/floating/constants.cjs +34 -0
  96. package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
  97. package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
  98. package/dist/cjs/utils/floating/element.cjs +103 -0
  99. package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
  100. package/dist/cjs/utils/floating/event.cjs +65 -0
  101. package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
  102. package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
  103. package/dist/cjs/utils/floating/markOthers.cjs +181 -0
  104. package/dist/cjs/utils/floating/nodes.cjs +48 -0
  105. package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
  106. package/dist/cjs/utils/floating/tabbable.cjs +242 -0
  107. package/dist/cjs/utils/floating/types.cjs +16 -0
  108. package/dist/cjs/utils/floating/useClick.cjs +153 -0
  109. package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
  110. package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
  111. package/dist/cjs/utils/floating/useFloating.cjs +186 -0
  112. package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
  113. package/dist/cjs/utils/floating/useFocus.cjs +184 -0
  114. package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
  115. package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
  116. package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
  117. package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
  118. package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
  119. package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
  120. package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
  121. package/dist/cjs/utils/formatNumber.cjs +60 -0
  122. package/dist/cjs/utils/generateId.cjs +32 -0
  123. package/dist/cjs/utils/getCssDimensions.cjs +42 -0
  124. package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
  125. package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
  126. package/dist/cjs/utils/getElementRef.cjs +35 -0
  127. package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
  128. package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
  129. package/dist/cjs/utils/hideMiddleware.cjs +42 -0
  130. package/dist/cjs/utils/inertValue.cjs +30 -0
  131. package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
  132. package/dist/cjs/utils/mergeCleanups.cjs +37 -0
  133. package/dist/cjs/utils/mergeObjects.cjs +39 -0
  134. package/dist/cjs/utils/mergeProps.cjs +182 -0
  135. package/dist/cjs/utils/noop.cjs +29 -0
  136. package/dist/cjs/utils/number/constants.cjs +34 -0
  137. package/dist/cjs/utils/number/parse.cjs +258 -0
  138. package/dist/cjs/utils/number/types.cjs +16 -0
  139. package/dist/cjs/utils/number/validate.cjs +104 -0
  140. package/dist/cjs/utils/owner.cjs +35 -0
  141. package/dist/cjs/utils/platform.cjs +83 -0
  142. package/dist/cjs/utils/popupStateMapping.cjs +74 -0
  143. package/dist/cjs/utils/popups/index.cjs +39 -0
  144. package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
  145. package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
  146. package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
  147. package/dist/cjs/utils/popups/store.cjs +118 -0
  148. package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
  149. package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
  150. package/dist/cjs/utils/resolveClassName.cjs +30 -0
  151. package/dist/cjs/utils/resolveRef.cjs +33 -0
  152. package/dist/cjs/utils/resolveStyle.cjs +30 -0
  153. package/dist/cjs/utils/serializeValue.cjs +40 -0
  154. package/dist/cjs/utils/slider/asc.cjs +30 -0
  155. package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
  156. package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
  157. package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
  158. package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
  159. package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
  160. package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
  161. package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
  162. package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
  163. package/dist/cjs/utils/store/ReactStore.cjs +135 -0
  164. package/dist/cjs/utils/store/Store.cjs +83 -0
  165. package/dist/cjs/utils/store/createSelector.cjs +74 -0
  166. package/dist/cjs/utils/store/useStore.cjs +51 -0
  167. package/dist/cjs/utils/stringifyLocale.cjs +36 -0
  168. package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
  169. package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
  170. package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
  171. package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
  172. package/dist/cjs/utils/useBaseUiId.cjs +36 -0
  173. package/dist/cjs/utils/useButton.cjs +177 -0
  174. package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
  175. package/dist/cjs/utils/useControlled.cjs +47 -0
  176. package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
  177. package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
  178. package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
  179. package/dist/cjs/utils/useIsHydrating.cjs +44 -0
  180. package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
  181. package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
  182. package/dist/cjs/utils/useOnMount.cjs +36 -0
  183. package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
  184. package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
  185. package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
  186. package/dist/cjs/utils/usePopupViewport.cjs +283 -0
  187. package/dist/cjs/utils/usePositioner.cjs +53 -0
  188. package/dist/cjs/utils/usePressAndHold.cjs +51 -0
  189. package/dist/cjs/utils/usePreviousValue.cjs +47 -0
  190. package/dist/cjs/utils/useRefWithInit.cjs +41 -0
  191. package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
  192. package/dist/cjs/utils/useRenderElement.cjs +106 -0
  193. package/dist/cjs/utils/useScrollLock.cjs +232 -0
  194. package/dist/cjs/utils/useStableCallback.cjs +41 -0
  195. package/dist/cjs/utils/useTimeout.cjs +66 -0
  196. package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
  197. package/dist/cjs/utils/useValueAsRef.cjs +43 -0
  198. package/dist/cjs/utils/useValueChanged.cjs +55 -0
  199. package/dist/cjs/utils/valueToPercent.cjs +30 -0
  200. package/dist/cjs/utils/visuallyHidden.cjs +49 -0
  201. package/package.json +20 -8
@@ -0,0 +1,153 @@
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_octane = require("octane");
25
+ var import_internal = require("../../internal.cjs");
26
+ var import_useAnimationFrame = require("../useAnimationFrame.cjs");
27
+ var import_useTimeout = require("../useTimeout.cjs");
28
+ var import_empty = require("../empty.cjs");
29
+ var import_element = require("./element.cjs");
30
+ var import_event = require("./event.cjs");
31
+ var import_createChangeEventDetails = require("../createChangeEventDetails.cjs");
32
+ function useClick(context, props, slot) {
33
+ const {
34
+ enabled = true,
35
+ event: eventOption = "click",
36
+ toggle = true,
37
+ ignoreMouse = false,
38
+ stickIfOpen = true,
39
+ touchOpenDelay = 0,
40
+ reason = import_createChangeEventDetails.REASONS.triggerPress
41
+ } = props;
42
+ const store = context && "rootStore" in context ? context.rootStore : context;
43
+ const dataRef = store.context.dataRef;
44
+ const pointerTypeRef = (0, import_octane.useRef)(
45
+ void 0,
46
+ (0, import_internal.subSlot)(slot, "pt")
47
+ );
48
+ const frame = (0, import_useAnimationFrame.useAnimationFrame)((0, import_internal.subSlot)(slot, "frame"));
49
+ const touchOpenTimeout = (0, import_useTimeout.useTimeout)((0, import_internal.subSlot)(slot, "to"));
50
+ const reference = (0, import_octane.useMemo)(
51
+ () => {
52
+ function setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType) {
53
+ const details = (0, import_createChangeEventDetails.createChangeEventDetails)(reason, nativeEvent, target);
54
+ if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) {
55
+ touchOpenTimeout.start(touchOpenDelay, () => {
56
+ store.setOpen(true, details);
57
+ });
58
+ } else {
59
+ store.setOpen(nextOpen, details);
60
+ }
61
+ }
62
+ function getNextOpen(open, currentTarget, isClickLikeOpenEvent) {
63
+ const openEvent = dataRef.current.openEvent;
64
+ const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== currentTarget;
65
+ if (open && hasClickedOnInactiveTrigger) {
66
+ return true;
67
+ }
68
+ if (!open) {
69
+ return true;
70
+ }
71
+ if (!toggle) {
72
+ return true;
73
+ }
74
+ if (openEvent && stickIfOpen) {
75
+ return !isClickLikeOpenEvent(openEvent.type);
76
+ }
77
+ return false;
78
+ }
79
+ return {
80
+ onPointerDown(event) {
81
+ pointerTypeRef.current = event.pointerType;
82
+ },
83
+ onMouseDown(event) {
84
+ const pointerType = pointerTypeRef.current;
85
+ const nativeEvent = event;
86
+ const open = store.select("open");
87
+ if (event.button !== 0 || eventOption === "click" || (0, import_event.isMouseLikePointerType)(pointerType, true) && ignoreMouse) {
88
+ return;
89
+ }
90
+ const nextOpen = getNextOpen(
91
+ open,
92
+ event.currentTarget,
93
+ (openEventType) => openEventType === "click" || openEventType === "mousedown"
94
+ );
95
+ const target = (0, import_element.getTarget)(nativeEvent);
96
+ if ((0, import_element.isTypeableElement)(target)) {
97
+ setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType);
98
+ return;
99
+ }
100
+ const eventCurrentTarget = event.currentTarget;
101
+ frame.request(() => {
102
+ setOpenWithTouchDelay(nextOpen, nativeEvent, eventCurrentTarget, pointerType);
103
+ });
104
+ },
105
+ onClick(event) {
106
+ if (eventOption === "mousedown-only") {
107
+ return;
108
+ }
109
+ const pointerType = pointerTypeRef.current;
110
+ if (eventOption === "mousedown" && pointerType) {
111
+ pointerTypeRef.current = void 0;
112
+ return;
113
+ }
114
+ if ((0, import_event.isMouseLikePointerType)(pointerType, true) && ignoreMouse) {
115
+ return;
116
+ }
117
+ const open = store.select("open");
118
+ const nextOpen = getNextOpen(
119
+ open,
120
+ event.currentTarget,
121
+ (openEventType) => openEventType === "click" || openEventType === "mousedown" || openEventType === "keydown" || openEventType === "keyup"
122
+ );
123
+ setOpenWithTouchDelay(nextOpen, event, event.currentTarget, pointerType);
124
+ },
125
+ onKeyDown() {
126
+ pointerTypeRef.current = void 0;
127
+ }
128
+ };
129
+ },
130
+ [
131
+ dataRef,
132
+ eventOption,
133
+ ignoreMouse,
134
+ reason,
135
+ store,
136
+ stickIfOpen,
137
+ toggle,
138
+ frame,
139
+ touchOpenTimeout,
140
+ touchOpenDelay
141
+ ],
142
+ (0, import_internal.subSlot)(slot, "ref")
143
+ );
144
+ return (0, import_octane.useMemo)(
145
+ () => enabled ? { reference } : import_empty.EMPTY_OBJECT,
146
+ [enabled, reference],
147
+ (0, import_internal.subSlot)(slot, "out")
148
+ );
149
+ }
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ useClick
153
+ });
@@ -0,0 +1,225 @@
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_octane = require("octane");
25
+ var import_internal = require("../../internal.cjs");
26
+ var import_addEventListener = require("../addEventListener.cjs");
27
+ var import_owner = require("../owner.cjs");
28
+ var import_useStableCallback = require("../useStableCallback.cjs");
29
+ var import_element = require("./element.cjs");
30
+ var import_event = require("./event.cjs");
31
+ function createVirtualElement(domElement, data) {
32
+ let offsetX = null;
33
+ let offsetY = null;
34
+ let isAutoUpdateEvent = false;
35
+ return {
36
+ contextElement: domElement || void 0,
37
+ getBoundingClientRect() {
38
+ const domRect = domElement?.getBoundingClientRect() || { width: 0, height: 0, x: 0, y: 0 };
39
+ const isXAxis = data.axis === "x" || data.axis === "both";
40
+ const isYAxis = data.axis === "y" || data.axis === "both";
41
+ const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
42
+ let width = domRect.width;
43
+ let height = domRect.height;
44
+ let x = domRect.x;
45
+ let y = domRect.y;
46
+ if (offsetX == null && data.x && isXAxis) {
47
+ offsetX = domRect.x - data.x;
48
+ }
49
+ if (offsetY == null && data.y && isYAxis) {
50
+ offsetY = domRect.y - data.y;
51
+ }
52
+ x -= offsetX || 0;
53
+ y -= offsetY || 0;
54
+ width = 0;
55
+ height = 0;
56
+ if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
57
+ width = data.axis === "y" ? domRect.width : 0;
58
+ height = data.axis === "x" ? domRect.height : 0;
59
+ x = isXAxis && data.x != null ? data.x : x;
60
+ y = isYAxis && data.y != null ? data.y : y;
61
+ } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
62
+ height = data.axis === "x" ? domRect.height : height;
63
+ width = data.axis === "y" ? domRect.width : width;
64
+ }
65
+ isAutoUpdateEvent = true;
66
+ return { width, height, x, y, top: y, right: x + width, bottom: y + height, left: x };
67
+ }
68
+ };
69
+ }
70
+ function isMouseBasedEvent(event) {
71
+ return event != null && event.clientX != null;
72
+ }
73
+ function useClientPoint(...args) {
74
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
75
+ const slot = slotArg ?? (0, import_internal.S)("useClientPoint");
76
+ const context = user[0];
77
+ const props = user[1] ?? {};
78
+ const { enabled = true, axis = "both" } = props;
79
+ const store = context != null && "rootStore" in context ? context.rootStore : context;
80
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "s:open"));
81
+ const floating = store.useState("floatingElement", (0, import_internal.subSlot)(slot, "s:floating"));
82
+ const domReference = store.useState("domReferenceElement", (0, import_internal.subSlot)(slot, "s:ref"));
83
+ const dataRef = store.context.dataRef;
84
+ const initialRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "initial"));
85
+ const cleanupListenerRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "cleanup"));
86
+ const [pointerType, setPointerType] = (0, import_octane.useState)(
87
+ void 0,
88
+ (0, import_internal.subSlot)(slot, "ptype")
89
+ );
90
+ const [reactive, setReactive] = (0, import_octane.useState)([], (0, import_internal.subSlot)(slot, "reactive"));
91
+ const resetReference = (0, import_useStableCallback.useStableCallback)(
92
+ (reference2) => {
93
+ store.set("positionReference", reference2);
94
+ },
95
+ (0, import_internal.subSlot)(slot, "reset")
96
+ );
97
+ const setReference = (0, import_useStableCallback.useStableCallback)(
98
+ (newX, newY, referenceElement) => {
99
+ if (initialRef.current) {
100
+ return;
101
+ }
102
+ if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
103
+ return;
104
+ }
105
+ store.set(
106
+ "positionReference",
107
+ createVirtualElement(referenceElement ?? domReference, {
108
+ x: newX,
109
+ y: newY,
110
+ axis,
111
+ dataRef,
112
+ pointerType
113
+ })
114
+ );
115
+ },
116
+ (0, import_internal.subSlot)(slot, "setRef")
117
+ );
118
+ const handleReferenceEnterOrMove = (0, import_useStableCallback.useStableCallback)(
119
+ (event) => {
120
+ if (!open) {
121
+ setReference(event.clientX, event.clientY, event.currentTarget);
122
+ } else if (!cleanupListenerRef.current) {
123
+ setReference(event.clientX, event.clientY, event.currentTarget);
124
+ setReactive([]);
125
+ }
126
+ },
127
+ (0, import_internal.subSlot)(slot, "enterMove")
128
+ );
129
+ const openCheck = (0, import_event.isMouseLikePointerType)(pointerType) ? floating : open;
130
+ (0, import_octane.useEffect)(
131
+ () => {
132
+ if (!enabled) {
133
+ resetReference(domReference);
134
+ return void 0;
135
+ }
136
+ if (!openCheck) {
137
+ return void 0;
138
+ }
139
+ function cleanupListener() {
140
+ cleanupListenerRef.current?.();
141
+ cleanupListenerRef.current = null;
142
+ }
143
+ const win = (0, import_owner.ownerWindow)(floating);
144
+ function handleMouseMove(event) {
145
+ const target = (0, import_element.getTarget)(event);
146
+ if (!(0, import_element.contains)(floating, target)) {
147
+ setReference(event.clientX, event.clientY);
148
+ } else {
149
+ cleanupListener();
150
+ }
151
+ }
152
+ if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
153
+ cleanupListenerRef.current = (0, import_addEventListener.addEventListener)(
154
+ win,
155
+ "mousemove",
156
+ handleMouseMove
157
+ );
158
+ } else {
159
+ resetReference(domReference);
160
+ }
161
+ return cleanupListener;
162
+ },
163
+ [
164
+ openCheck,
165
+ enabled,
166
+ floating,
167
+ dataRef,
168
+ domReference,
169
+ store,
170
+ setReference,
171
+ resetReference,
172
+ reactive
173
+ ],
174
+ (0, import_internal.subSlot)(slot, "e:track")
175
+ );
176
+ (0, import_octane.useEffect)(
177
+ () => () => {
178
+ store.set("positionReference", null);
179
+ },
180
+ [store],
181
+ (0, import_internal.subSlot)(slot, "e:unmount")
182
+ );
183
+ (0, import_octane.useEffect)(
184
+ () => {
185
+ if (enabled && !floating) {
186
+ initialRef.current = false;
187
+ }
188
+ },
189
+ [enabled, floating],
190
+ (0, import_internal.subSlot)(slot, "e:reset")
191
+ );
192
+ (0, import_octane.useEffect)(
193
+ () => {
194
+ if (!enabled && open) {
195
+ initialRef.current = true;
196
+ }
197
+ },
198
+ [enabled, open],
199
+ (0, import_internal.subSlot)(slot, "e:freeze")
200
+ );
201
+ const reference = (0, import_octane.useMemo)(
202
+ () => {
203
+ function setPointerTypeRef(event) {
204
+ setPointerType(event.pointerType);
205
+ }
206
+ return {
207
+ onPointerDown: setPointerTypeRef,
208
+ onPointerEnter: setPointerTypeRef,
209
+ onMouseMove: handleReferenceEnterOrMove,
210
+ onMouseEnter: handleReferenceEnterOrMove
211
+ };
212
+ },
213
+ [handleReferenceEnterOrMove],
214
+ (0, import_internal.subSlot)(slot, "ref")
215
+ );
216
+ return (0, import_octane.useMemo)(
217
+ () => enabled ? { reference, trigger: reference } : {},
218
+ [enabled, reference],
219
+ (0, import_internal.subSlot)(slot, "out")
220
+ );
221
+ }
222
+ // Annotate the CommonJS export names for ESM import in node:
223
+ 0 && (module.exports = {
224
+ useClientPoint
225
+ });