@octanejs/base-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.
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,421 @@
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 useAnchorPositioning_exports = {};
20
+ __export(useAnchorPositioning_exports, {
21
+ useAnchorPositioning: () => useAnchorPositioning
22
+ });
23
+ module.exports = __toCommonJS(useAnchorPositioning_exports);
24
+ var import_octane = require("octane");
25
+ var import_utils = require("@floating-ui/utils");
26
+ var import_floating_ui = require("@octanejs/floating-ui");
27
+ var import_internal = require("../internal.cjs");
28
+ var import_owner = require("./owner.cjs");
29
+ var import_useValueAsRef = require("./useValueAsRef.cjs");
30
+ var import_useStableCallback = require("./useStableCallback.cjs");
31
+ var import_DirectionContext = require("./DirectionContext.cjs");
32
+ var import_useFloating = require("./floating/useFloating.cjs");
33
+ var import_hideMiddleware = require("./hideMiddleware.cjs");
34
+ var import_adaptiveOriginMiddleware = require("./adaptiveOriginMiddleware.cjs");
35
+ function getLogicalSide(sideParam, renderedSide, isRtl) {
36
+ const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
37
+ const logicalRight = isRtl ? "inline-start" : "inline-end";
38
+ const logicalLeft = isRtl ? "inline-end" : "inline-start";
39
+ return {
40
+ top: "top",
41
+ right: isLogicalSideParam ? logicalRight : "right",
42
+ bottom: "bottom",
43
+ left: isLogicalSideParam ? logicalLeft : "left"
44
+ }[renderedSide];
45
+ }
46
+ function getOffsetData(state, sideParam, isRtl) {
47
+ const { rects, placement } = state;
48
+ const data = {
49
+ side: getLogicalSide(sideParam, (0, import_utils.getSide)(placement), isRtl),
50
+ align: (0, import_utils.getAlignment)(placement) || "center",
51
+ anchor: { width: rects.reference.width, height: rects.reference.height },
52
+ positioner: { width: rects.floating.width, height: rects.floating.height }
53
+ };
54
+ return data;
55
+ }
56
+ function useAnchorPositioning(params, slotArg) {
57
+ const slot = slotArg ?? (0, import_internal.S)("useAnchorPositioning");
58
+ const {
59
+ // Public parameters
60
+ anchor,
61
+ positionMethod = "absolute",
62
+ side: sideParam = "bottom",
63
+ sideOffset = 0,
64
+ align = "center",
65
+ alignOffset = 0,
66
+ collisionBoundary,
67
+ collisionPadding: collisionPaddingParam = 5,
68
+ sticky = false,
69
+ arrowPadding = 5,
70
+ disableAnchorTracking = false,
71
+ inline: inlineMiddleware,
72
+ // Private parameters
73
+ keepMounted = false,
74
+ floatingRootContext,
75
+ mounted,
76
+ collisionAvoidance,
77
+ shiftCrossAxis = false,
78
+ nodeId,
79
+ adaptiveOrigin,
80
+ lazyFlip = false,
81
+ externalTree
82
+ } = params;
83
+ const [mountSide, setMountSide] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "mountSide"));
84
+ if (!mounted && mountSide !== null) {
85
+ setMountSide(null);
86
+ }
87
+ const collisionAvoidanceSide = collisionAvoidance.side || "flip";
88
+ const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
89
+ const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
90
+ const anchorFn = typeof anchor === "function" ? anchor : void 0;
91
+ const anchorFnCallback = (0, import_useStableCallback.useStableCallback)(anchorFn, (0, import_internal.subSlot)(slot, "anchorFn"));
92
+ const anchorDep = anchorFn ? anchorFnCallback : anchor;
93
+ const anchorValueRef = (0, import_useValueAsRef.useValueAsRef)(anchor, (0, import_internal.subSlot)(slot, "anchorRef"));
94
+ const mountedRef = (0, import_useValueAsRef.useValueAsRef)(mounted, (0, import_internal.subSlot)(slot, "mountedRef"));
95
+ const direction = (0, import_DirectionContext.useDirection)();
96
+ const isRtl = direction === "rtl";
97
+ const side = mountSide || {
98
+ top: "top",
99
+ right: "right",
100
+ bottom: "bottom",
101
+ left: "left",
102
+ "inline-end": isRtl ? "left" : "right",
103
+ "inline-start": isRtl ? "right" : "left"
104
+ }[sideParam];
105
+ const placement = align === "center" ? side : `${side}-${align}`;
106
+ let collisionPadding = collisionPaddingParam;
107
+ const bias = 1;
108
+ const biasTop = sideParam === "bottom" ? bias : 0;
109
+ const biasBottom = sideParam === "top" ? bias : 0;
110
+ const biasLeft = sideParam === "right" ? bias : 0;
111
+ const biasRight = sideParam === "left" ? bias : 0;
112
+ if (typeof collisionPadding === "number") {
113
+ collisionPadding = {
114
+ top: collisionPadding + biasTop,
115
+ right: collisionPadding + biasRight,
116
+ bottom: collisionPadding + biasBottom,
117
+ left: collisionPadding + biasLeft
118
+ };
119
+ } else if (collisionPadding) {
120
+ collisionPadding = {
121
+ top: (collisionPadding.top || 0) + biasTop,
122
+ right: (collisionPadding.right || 0) + biasRight,
123
+ bottom: (collisionPadding.bottom || 0) + biasBottom,
124
+ left: (collisionPadding.left || 0) + biasLeft
125
+ };
126
+ }
127
+ const commonCollisionProps = {
128
+ boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
129
+ padding: collisionPadding
130
+ };
131
+ const arrowRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "arrowRef"));
132
+ const sideOffsetRef = (0, import_useValueAsRef.useValueAsRef)(sideOffset, (0, import_internal.subSlot)(slot, "sideOffsetRef"));
133
+ const alignOffsetRef = (0, import_useValueAsRef.useValueAsRef)(alignOffset, (0, import_internal.subSlot)(slot, "alignOffsetRef"));
134
+ const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
135
+ const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
136
+ const middleware = [];
137
+ if (inlineMiddleware) {
138
+ middleware.push(inlineMiddleware);
139
+ }
140
+ void sideOffsetDep;
141
+ void alignOffsetDep;
142
+ middleware.push(
143
+ (0, import_floating_ui.offset)((state) => {
144
+ const data = getOffsetData(state, sideParam, isRtl);
145
+ const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
146
+ const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
147
+ return {
148
+ mainAxis: sideAxis,
149
+ crossAxis: alignAxis,
150
+ alignmentAxis: alignAxis
151
+ };
152
+ })
153
+ );
154
+ const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
155
+ const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
156
+ const flipMiddleware = collisionAvoidanceSide === "none" ? null : (0, import_floating_ui.flip)({
157
+ ...commonCollisionProps,
158
+ padding: {
159
+ top: collisionPadding.top + bias,
160
+ right: collisionPadding.right + bias,
161
+ bottom: collisionPadding.bottom + bias,
162
+ left: collisionPadding.left + bias
163
+ },
164
+ mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
165
+ crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
166
+ fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
167
+ });
168
+ const shiftMiddleware = shiftDisabled ? null : (0, import_floating_ui.shift)((data) => {
169
+ const html = (0, import_owner.ownerDocument)(data.elements.floating).documentElement;
170
+ return {
171
+ ...commonCollisionProps,
172
+ rootBoundary: shiftCrossAxis ? { x: 0, y: 0, width: html.clientWidth, height: html.clientHeight } : void 0,
173
+ mainAxis: collisionAvoidanceAlign !== "none",
174
+ crossAxis: crossAxisShiftEnabled,
175
+ limiter: sticky || shiftCrossAxis ? void 0 : (0, import_floating_ui.limitShift)((limitData) => {
176
+ if (!arrowRef.current) {
177
+ return {};
178
+ }
179
+ const { width, height } = arrowRef.current.getBoundingClientRect();
180
+ const sideAxis = (0, import_utils.getSideAxis)((0, import_utils.getSide)(limitData.placement));
181
+ const arrowSize = sideAxis === "y" ? width : height;
182
+ const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
183
+ return {
184
+ offset: arrowSize / 2 + offsetAmount / 2
185
+ };
186
+ })
187
+ };
188
+ });
189
+ if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
190
+ middleware.push(shiftMiddleware, flipMiddleware);
191
+ } else {
192
+ middleware.push(flipMiddleware, shiftMiddleware);
193
+ }
194
+ middleware.push(
195
+ (0, import_floating_ui.size)({
196
+ ...commonCollisionProps,
197
+ apply({ elements: { floating }, availableWidth, availableHeight, rects }) {
198
+ if (!mountedRef.current) {
199
+ return;
200
+ }
201
+ const floatingStyle = floating.style;
202
+ floatingStyle.setProperty("--available-width", `${availableWidth}px`);
203
+ floatingStyle.setProperty("--available-height", `${availableHeight}px`);
204
+ const dpr = (0, import_owner.ownerWindow)(floating).devicePixelRatio || 1;
205
+ const { x: x2, y: y2, width, height } = rects.reference;
206
+ const anchorWidth = (Math.round((x2 + width) * dpr) - Math.round(x2 * dpr)) / dpr;
207
+ const anchorHeight = (Math.round((y2 + height) * dpr) - Math.round(y2 * dpr)) / dpr;
208
+ floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
209
+ floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
210
+ }
211
+ }),
212
+ (0, import_floating_ui.arrow)((state) => ({
213
+ element: arrowRef.current || (0, import_owner.ownerDocument)(state.elements.floating).createElement("div"),
214
+ padding: arrowPadding,
215
+ offsetParent: "floating"
216
+ })),
217
+ {
218
+ name: "transformOrigin",
219
+ fn(state) {
220
+ const { elements: elements2, middlewareData: middlewareData2, placement: renderedPlacement2, rects, y: y2 } = state;
221
+ const currentRenderedSide = (0, import_utils.getSide)(renderedPlacement2);
222
+ const currentRenderedAxis = (0, import_utils.getSideAxis)(currentRenderedSide);
223
+ const arrowEl = arrowRef.current;
224
+ const arrowX = middlewareData2.arrow?.x || 0;
225
+ const arrowY = middlewareData2.arrow?.y || 0;
226
+ const arrowWidth = arrowEl?.clientWidth || 0;
227
+ const arrowHeight = arrowEl?.clientHeight || 0;
228
+ const transformX = arrowX + arrowWidth / 2;
229
+ const transformY = arrowY + arrowHeight / 2;
230
+ const shiftY = Math.abs(middlewareData2.shift?.y || 0);
231
+ const halfAnchorHeight = rects.reference.height / 2;
232
+ const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
233
+ const isOverlappingAnchor = shiftY > sideOffsetValue;
234
+ const adjacentTransformOrigin = {
235
+ top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
236
+ bottom: `${transformX}px ${-sideOffsetValue}px`,
237
+ left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
238
+ right: `${-sideOffsetValue}px ${transformY}px`
239
+ }[currentRenderedSide];
240
+ const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y2}px`;
241
+ elements2.floating.style.setProperty(
242
+ "--transform-origin",
243
+ crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin
244
+ );
245
+ return {};
246
+ }
247
+ },
248
+ import_hideMiddleware.hide,
249
+ adaptiveOrigin
250
+ );
251
+ (0, import_octane.useLayoutEffect)(
252
+ () => {
253
+ if (!mounted && floatingRootContext) {
254
+ floatingRootContext.update({
255
+ referenceElement: null,
256
+ floatingElement: null,
257
+ domReferenceElement: null,
258
+ positionReference: null
259
+ });
260
+ }
261
+ },
262
+ [mounted, floatingRootContext],
263
+ (0, import_internal.subSlot)(slot, "e:reset")
264
+ );
265
+ const autoUpdateOptions = (0, import_octane.useMemo)(
266
+ () => ({
267
+ elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
268
+ layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
269
+ }),
270
+ [disableAnchorTracking],
271
+ (0, import_internal.subSlot)(slot, "m:auto")
272
+ );
273
+ const {
274
+ refs,
275
+ elements,
276
+ x,
277
+ y,
278
+ middlewareData,
279
+ update,
280
+ placement: renderedPlacement,
281
+ context,
282
+ isPositioned,
283
+ floatingStyles: originalFloatingStyles
284
+ } = (0, import_useFloating.useFloating)(
285
+ {
286
+ rootContext: floatingRootContext,
287
+ open: keepMounted ? mounted : void 0,
288
+ placement,
289
+ middleware,
290
+ strategy: positionMethod,
291
+ whileElementsMounted: keepMounted ? void 0 : (...args) => (0, import_floating_ui.autoUpdate)(...args, autoUpdateOptions),
292
+ nodeId,
293
+ externalTree
294
+ },
295
+ (0, import_internal.subSlot)(slot, "floating")
296
+ );
297
+ const { sideX, sideY } = middlewareData.adaptiveOrigin || import_adaptiveOriginMiddleware.DEFAULT_SIDES;
298
+ const resolvedPosition = isPositioned ? positionMethod : "fixed";
299
+ const floatingStyles = (0, import_octane.useMemo)(
300
+ () => {
301
+ const base = adaptiveOrigin ? { position: resolvedPosition, [sideX]: x, [sideY]: y } : { position: resolvedPosition, ...originalFloatingStyles };
302
+ if (!isPositioned) {
303
+ base.opacity = 0;
304
+ }
305
+ return base;
306
+ },
307
+ [adaptiveOrigin, resolvedPosition, sideX, x, sideY, y, originalFloatingStyles, isPositioned],
308
+ (0, import_internal.subSlot)(slot, "m:fs")
309
+ );
310
+ const registeredPositionReferenceRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "regPosRef"));
311
+ (0, import_octane.useLayoutEffect)(
312
+ () => {
313
+ if (!mounted) {
314
+ return;
315
+ }
316
+ const anchorValue = anchorValueRef.current;
317
+ const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
318
+ const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
319
+ const finalAnchor = unwrappedElement || null;
320
+ if (finalAnchor !== registeredPositionReferenceRef.current) {
321
+ refs.setPositionReference(finalAnchor);
322
+ registeredPositionReferenceRef.current = finalAnchor;
323
+ }
324
+ },
325
+ [mounted, refs, anchorDep, anchorValueRef],
326
+ (0, import_internal.subSlot)(slot, "e:posref1")
327
+ );
328
+ (0, import_octane.useEffect)(
329
+ () => {
330
+ if (!mounted) {
331
+ return;
332
+ }
333
+ const anchorValue = anchorValueRef.current;
334
+ if (typeof anchorValue === "function") {
335
+ return;
336
+ }
337
+ if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
338
+ refs.setPositionReference(anchorValue.current);
339
+ registeredPositionReferenceRef.current = anchorValue.current;
340
+ }
341
+ },
342
+ [mounted, refs, anchorDep, anchorValueRef],
343
+ (0, import_internal.subSlot)(slot, "e:posref2")
344
+ );
345
+ (0, import_octane.useEffect)(
346
+ () => {
347
+ if (keepMounted && mounted && elements.reference && elements.floating) {
348
+ return (0, import_floating_ui.autoUpdate)(
349
+ elements.reference,
350
+ elements.floating,
351
+ update,
352
+ autoUpdateOptions
353
+ );
354
+ }
355
+ return void 0;
356
+ },
357
+ [keepMounted, mounted, elements, update, autoUpdateOptions],
358
+ (0, import_internal.subSlot)(slot, "e:auto")
359
+ );
360
+ const renderedSide = (0, import_utils.getSide)(renderedPlacement);
361
+ const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
362
+ const renderedAlign = (0, import_utils.getAlignment)(renderedPlacement) || "center";
363
+ const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
364
+ (0, import_octane.useLayoutEffect)(
365
+ () => {
366
+ if (lazyFlip && mounted && isPositioned) {
367
+ setMountSide(renderedSide);
368
+ }
369
+ },
370
+ [lazyFlip, mounted, isPositioned, renderedSide],
371
+ (0, import_internal.subSlot)(slot, "e:lazyflip")
372
+ );
373
+ const arrowStyles = (0, import_octane.useMemo)(
374
+ () => ({
375
+ position: "absolute",
376
+ top: middlewareData.arrow?.y,
377
+ left: middlewareData.arrow?.x
378
+ }),
379
+ [middlewareData.arrow],
380
+ (0, import_internal.subSlot)(slot, "m:arrow")
381
+ );
382
+ const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
383
+ return (0, import_octane.useMemo)(
384
+ () => ({
385
+ positionerStyles: floatingStyles,
386
+ arrowStyles,
387
+ arrowRef,
388
+ arrowUncentered,
389
+ side: logicalRenderedSide,
390
+ align: renderedAlign,
391
+ physicalSide: renderedSide,
392
+ anchorHidden,
393
+ refs,
394
+ context,
395
+ isPositioned,
396
+ update
397
+ }),
398
+ [
399
+ floatingStyles,
400
+ arrowStyles,
401
+ arrowRef,
402
+ arrowUncentered,
403
+ logicalRenderedSide,
404
+ renderedAlign,
405
+ renderedSide,
406
+ anchorHidden,
407
+ refs,
408
+ context,
409
+ isPositioned,
410
+ update
411
+ ],
412
+ (0, import_internal.subSlot)(slot, "m:ret")
413
+ );
414
+ }
415
+ function isRef(param) {
416
+ return param != null && "current" in param;
417
+ }
418
+ // Annotate the CommonJS export names for ESM import in node:
419
+ 0 && (module.exports = {
420
+ useAnchorPositioning
421
+ });
@@ -0,0 +1,59 @@
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 useAnchoredPopupScrollLock_exports = {};
20
+ __export(useAnchoredPopupScrollLock_exports, {
21
+ useAnchoredPopupScrollLock: () => useAnchoredPopupScrollLock
22
+ });
23
+ module.exports = __toCommonJS(useAnchoredPopupScrollLock_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_owner = require("./owner.cjs");
27
+ var import_useScrollLock = require("./useScrollLock.cjs");
28
+ const VIEWPORT_WIDTH_TOLERANCE_PX = 20;
29
+ function useAnchoredPopupScrollLock(enabled, touchOpen, positionerElement, referenceElement) {
30
+ const slot = (0, import_internal.S)("useAnchoredPopupScrollLock");
31
+ const [touchOpenShouldLockScroll, setTouchOpenShouldLockScroll] = (0, import_octane.useState)(
32
+ false,
33
+ (0, import_internal.subSlot)(slot, "lock")
34
+ );
35
+ (0, import_octane.useLayoutEffect)(
36
+ () => {
37
+ if (!enabled || !touchOpen || positionerElement == null) {
38
+ setTouchOpenShouldLockScroll(false);
39
+ return;
40
+ }
41
+ const viewportWidth = (0, import_owner.ownerDocument)(positionerElement).documentElement.clientWidth;
42
+ const popupWidth = positionerElement.offsetWidth;
43
+ setTouchOpenShouldLockScroll(
44
+ viewportWidth > 0 && popupWidth > 0 && popupWidth >= viewportWidth - VIEWPORT_WIDTH_TOLERANCE_PX
45
+ );
46
+ },
47
+ [enabled, touchOpen, positionerElement],
48
+ (0, import_internal.subSlot)(slot, "eff")
49
+ );
50
+ (0, import_useScrollLock.useScrollLock)(
51
+ enabled && (!touchOpen || touchOpenShouldLockScroll),
52
+ referenceElement,
53
+ (0, import_internal.subSlot)(slot, "scroll")
54
+ );
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ useAnchoredPopupScrollLock
59
+ });
@@ -0,0 +1,93 @@
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 useAnimationFrame_exports = {};
20
+ __export(useAnimationFrame_exports, {
21
+ AnimationFrame: () => AnimationFrame,
22
+ useAnimationFrame: () => useAnimationFrame
23
+ });
24
+ module.exports = __toCommonJS(useAnimationFrame_exports);
25
+ var import_octane = require("octane");
26
+ var import_internal = require("../internal.cjs");
27
+ const AnimationFrame = {
28
+ request(fn) {
29
+ return requestAnimationFrame(fn);
30
+ },
31
+ cancel(id) {
32
+ if (id != null) {
33
+ cancelAnimationFrame(id);
34
+ }
35
+ },
36
+ // A per-instance frame that supersedes its own pending callback (like `useAnimationFrame`'s
37
+ // return, but usable outside a component — e.g. useScrollLock's resize handler).
38
+ create() {
39
+ let id = null;
40
+ return {
41
+ request(fn) {
42
+ if (id != null) {
43
+ cancelAnimationFrame(id);
44
+ }
45
+ id = requestAnimationFrame((ts) => {
46
+ id = null;
47
+ fn(ts);
48
+ });
49
+ return id;
50
+ },
51
+ cancel() {
52
+ if (id != null) {
53
+ cancelAnimationFrame(id);
54
+ id = null;
55
+ }
56
+ }
57
+ };
58
+ }
59
+ };
60
+ function useAnimationFrame(...args) {
61
+ const [, slotArg] = (0, import_internal.splitSlot)(["_", ...args]);
62
+ const slot = slotArg ?? (0, import_internal.S)("useAnimationFrame");
63
+ const idRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "id"));
64
+ const frame = (0, import_octane.useMemo)(
65
+ () => ({
66
+ request(fn) {
67
+ if (idRef.current != null) {
68
+ cancelAnimationFrame(idRef.current);
69
+ }
70
+ idRef.current = requestAnimationFrame((ts) => {
71
+ idRef.current = null;
72
+ fn(ts);
73
+ });
74
+ return idRef.current;
75
+ },
76
+ cancel() {
77
+ if (idRef.current != null) {
78
+ cancelAnimationFrame(idRef.current);
79
+ idRef.current = null;
80
+ }
81
+ }
82
+ }),
83
+ [],
84
+ (0, import_internal.subSlot)(slot, "frame")
85
+ );
86
+ (0, import_octane.useLayoutEffect)(() => () => frame.cancel(), [], (0, import_internal.subSlot)(slot, "e:clean"));
87
+ return frame;
88
+ }
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ AnimationFrame,
92
+ useAnimationFrame
93
+ });
@@ -0,0 +1,98 @@
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 useAnimationsFinished_exports = {};
20
+ __export(useAnimationsFinished_exports, {
21
+ useAnimationsFinished: () => useAnimationsFinished
22
+ });
23
+ module.exports = __toCommonJS(useAnimationsFinished_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_useAnimationFrame = require("./useAnimationFrame.cjs");
27
+ var import_useStableCallback = require("./useStableCallback.cjs");
28
+ var import_resolveRef = require("./resolveRef.cjs");
29
+ const STARTING_STYLE_ATTRIBUTE = "data-starting-style";
30
+ function useAnimationsFinished(...args) {
31
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
32
+ const slot = slotArg ?? (0, import_internal.S)("useAnimationsFinished");
33
+ const elementOrRef = user[0];
34
+ const waitForStartingStyleRemoved = user[1] ?? false;
35
+ const treatAbortedAsFinished = user[2] ?? true;
36
+ const frame = (0, import_useAnimationFrame.useAnimationFrame)((0, import_internal.subSlot)(slot, "frame"));
37
+ return (0, import_useStableCallback.useStableCallback)(
38
+ (fnToExecute, signal = null) => {
39
+ frame.cancel();
40
+ const element = (0, import_resolveRef.resolveRef)(elementOrRef);
41
+ if (element == null) {
42
+ return;
43
+ }
44
+ const resolvedElement = element;
45
+ const done = () => {
46
+ (0, import_octane.flushSync)(fnToExecute);
47
+ };
48
+ if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
49
+ fnToExecute();
50
+ return;
51
+ }
52
+ function exec() {
53
+ Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
54
+ if (!signal?.aborted) {
55
+ done();
56
+ }
57
+ }).catch(() => {
58
+ if (treatAbortedAsFinished) {
59
+ if (!signal?.aborted) {
60
+ done();
61
+ }
62
+ return;
63
+ }
64
+ const currentAnimations = resolvedElement.getAnimations();
65
+ if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some(
66
+ (animation) => animation.pending || animation.playState !== "finished"
67
+ )) {
68
+ exec();
69
+ }
70
+ });
71
+ }
72
+ if (waitForStartingStyleRemoved) {
73
+ if (!resolvedElement.hasAttribute(STARTING_STYLE_ATTRIBUTE)) {
74
+ frame.request(exec);
75
+ return;
76
+ }
77
+ const attributeObserver = new MutationObserver(() => {
78
+ if (!resolvedElement.hasAttribute(STARTING_STYLE_ATTRIBUTE)) {
79
+ attributeObserver.disconnect();
80
+ exec();
81
+ }
82
+ });
83
+ attributeObserver.observe(resolvedElement, {
84
+ attributes: true,
85
+ attributeFilter: [STARTING_STYLE_ATTRIBUTE]
86
+ });
87
+ signal?.addEventListener("abort", () => attributeObserver.disconnect(), { once: true });
88
+ return;
89
+ }
90
+ frame.request(exec);
91
+ },
92
+ (0, import_internal.subSlot)(slot, "cb")
93
+ );
94
+ }
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ useAnimationsFinished
98
+ });