@radix-ui/react-popper 1.1.4-rc.9 → 1.2.0-rc.2

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.
package/dist/index.mjs CHANGED
@@ -1,329 +1,303 @@
1
- import $kY93V$babelruntimehelpersesmextends from "@babel/runtime/helpers/esm/extends";
2
- import {useState as $kY93V$useState, createElement as $kY93V$createElement, forwardRef as $kY93V$forwardRef, useRef as $kY93V$useRef, useEffect as $kY93V$useEffect} from "react";
3
- import {useFloating as $kY93V$useFloating, autoUpdate as $kY93V$autoUpdate, offset as $kY93V$offset, shift as $kY93V$shift, limitShift as $kY93V$limitShift, flip as $kY93V$flip, size as $kY93V$size, arrow as $kY93V$arrow, hide as $kY93V$hide} from "@floating-ui/react-dom";
4
- import {Root as $kY93V$Root} from "@radix-ui/react-arrow";
5
- import {useComposedRefs as $kY93V$useComposedRefs} from "@radix-ui/react-compose-refs";
6
- import {createContextScope as $kY93V$createContextScope} from "@radix-ui/react-context";
7
- import {Primitive as $kY93V$Primitive} from "@radix-ui/react-primitive";
8
- import {useCallbackRef as $kY93V$useCallbackRef} from "@radix-ui/react-use-callback-ref";
9
- import {useLayoutEffect as $kY93V$useLayoutEffect} from "@radix-ui/react-use-layout-effect";
10
- import {useSize as $kY93V$useSize} from "@radix-ui/react-use-size";
1
+ "use client";
11
2
 
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
- const $cf1ac5d9fe0e8206$export$36f0086da09c4b9f = [
23
- 'top',
24
- 'right',
25
- 'bottom',
26
- 'left'
27
- ];
28
- const $cf1ac5d9fe0e8206$export$3671ffab7b302fc9 = [
29
- 'start',
30
- 'center',
31
- 'end'
32
- ];
33
- /* -------------------------------------------------------------------------------------------------
34
- * Popper
35
- * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$POPPER_NAME = 'Popper';
36
- const [$cf1ac5d9fe0e8206$var$createPopperContext, $cf1ac5d9fe0e8206$export$722aac194ae923] = $kY93V$createContextScope($cf1ac5d9fe0e8206$var$POPPER_NAME);
37
- const [$cf1ac5d9fe0e8206$var$PopperProvider, $cf1ac5d9fe0e8206$var$usePopperContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$POPPER_NAME);
38
- const $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9 = (props)=>{
39
- const { __scopePopper: __scopePopper , children: children } = props;
40
- const [anchor, setAnchor] = $kY93V$useState(null);
41
- return /*#__PURE__*/ $kY93V$createElement($cf1ac5d9fe0e8206$var$PopperProvider, {
42
- scope: __scopePopper,
43
- anchor: anchor,
44
- onAnchorChange: setAnchor
45
- }, children);
3
+ // packages/react/popper/src/Popper.tsx
4
+ import * as React from "react";
5
+ import {
6
+ useFloating,
7
+ autoUpdate,
8
+ offset,
9
+ shift,
10
+ limitShift,
11
+ hide,
12
+ arrow as floatingUIarrow,
13
+ flip,
14
+ size
15
+ } from "@floating-ui/react-dom";
16
+ import * as ArrowPrimitive from "@radix-ui/react-arrow";
17
+ import { useComposedRefs } from "@radix-ui/react-compose-refs";
18
+ import { createContextScope } from "@radix-ui/react-context";
19
+ import { Primitive } from "@radix-ui/react-primitive";
20
+ import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
21
+ import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
22
+ import { useSize } from "@radix-ui/react-use-size";
23
+ import { jsx } from "react/jsx-runtime";
24
+ var SIDE_OPTIONS = ["top", "right", "bottom", "left"];
25
+ var ALIGN_OPTIONS = ["start", "center", "end"];
26
+ var POPPER_NAME = "Popper";
27
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
28
+ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
29
+ var Popper = (props) => {
30
+ const { __scopePopper, children } = props;
31
+ const [anchor, setAnchor] = React.useState(null);
32
+ return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
46
33
  };
47
- /*#__PURE__*/ Object.assign($cf1ac5d9fe0e8206$export$badac9ada3a0bdf9, {
48
- displayName: $cf1ac5d9fe0e8206$var$POPPER_NAME
49
- });
50
- /* -------------------------------------------------------------------------------------------------
51
- * PopperAnchor
52
- * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$ANCHOR_NAME = 'PopperAnchor';
53
- const $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d = /*#__PURE__*/ $kY93V$forwardRef((props, forwardedRef)=>{
54
- const { __scopePopper: __scopePopper , virtualRef: virtualRef , ...anchorProps } = props;
55
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$ANCHOR_NAME, __scopePopper);
56
- const ref = $kY93V$useRef(null);
57
- const composedRefs = $kY93V$useComposedRefs(forwardedRef, ref);
58
- $kY93V$useEffect(()=>{
59
- // Consumer can anchor the popper to something that isn't
60
- // a DOM node e.g. pointer position, so we override the
61
- // `anchorRef` with their virtual ref in this case.
62
- context.onAnchorChange((virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current);
34
+ Popper.displayName = POPPER_NAME;
35
+ var ANCHOR_NAME = "PopperAnchor";
36
+ var PopperAnchor = React.forwardRef(
37
+ (props, forwardedRef) => {
38
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
39
+ const context = usePopperContext(ANCHOR_NAME, __scopePopper);
40
+ const ref = React.useRef(null);
41
+ const composedRefs = useComposedRefs(forwardedRef, ref);
42
+ React.useEffect(() => {
43
+ context.onAnchorChange(virtualRef?.current || ref.current);
63
44
  });
64
- return virtualRef ? null : /*#__PURE__*/ $kY93V$createElement($kY93V$Primitive.div, $kY93V$babelruntimehelpersesmextends({}, anchorProps, {
65
- ref: composedRefs
66
- }));
67
- });
68
- /*#__PURE__*/ Object.assign($cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d, {
69
- displayName: $cf1ac5d9fe0e8206$var$ANCHOR_NAME
70
- });
71
- /* -------------------------------------------------------------------------------------------------
72
- * PopperContent
73
- * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$CONTENT_NAME = 'PopperContent';
74
- const [$cf1ac5d9fe0e8206$var$PopperContentProvider, $cf1ac5d9fe0e8206$var$useContentContext] = $cf1ac5d9fe0e8206$var$createPopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME);
75
- const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /*#__PURE__*/ $kY93V$forwardRef((props, forwardedRef)=>{
76
- var _arrowSize$width, _arrowSize$height, _middlewareData$arrow, _middlewareData$arrow2, _middlewareData$arrow3, _middlewareData$trans, _middlewareData$trans2, _middlewareData$hide;
77
- const { __scopePopper: __scopePopper , side: side = 'bottom' , sideOffset: sideOffset = 0 , align: align = 'center' , alignOffset: alignOffset = 0 , arrowPadding: arrowPadding = 0 , avoidCollisions: avoidCollisions = true , collisionBoundary: collisionBoundary = [] , collisionPadding: collisionPaddingProp = 0 , sticky: sticky = 'partial' , hideWhenDetached: hideWhenDetached = false , updatePositionStrategy: updatePositionStrategy = 'optimized' , onPlaced: onPlaced , ...contentProps } = props;
78
- const context = $cf1ac5d9fe0e8206$var$usePopperContext($cf1ac5d9fe0e8206$var$CONTENT_NAME, __scopePopper);
79
- const [content, setContent] = $kY93V$useState(null);
80
- const composedRefs = $kY93V$useComposedRefs(forwardedRef, (node)=>setContent(node)
81
- );
82
- const [arrow, setArrow] = $kY93V$useState(null);
83
- const arrowSize = $kY93V$useSize(arrow);
84
- const arrowWidth = (_arrowSize$width = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.width) !== null && _arrowSize$width !== void 0 ? _arrowSize$width : 0;
85
- const arrowHeight = (_arrowSize$height = arrowSize === null || arrowSize === void 0 ? void 0 : arrowSize.height) !== null && _arrowSize$height !== void 0 ? _arrowSize$height : 0;
86
- const desiredPlacement = side + (align !== 'center' ? '-' + align : '');
87
- const collisionPadding = typeof collisionPaddingProp === 'number' ? collisionPaddingProp : {
88
- top: 0,
89
- right: 0,
90
- bottom: 0,
91
- left: 0,
92
- ...collisionPaddingProp
93
- };
94
- const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [
95
- collisionBoundary
96
- ];
45
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
46
+ }
47
+ );
48
+ PopperAnchor.displayName = ANCHOR_NAME;
49
+ var CONTENT_NAME = "PopperContent";
50
+ var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
51
+ var PopperContent = React.forwardRef(
52
+ (props, forwardedRef) => {
53
+ const {
54
+ __scopePopper,
55
+ side = "bottom",
56
+ sideOffset = 0,
57
+ align = "center",
58
+ alignOffset = 0,
59
+ arrowPadding = 0,
60
+ avoidCollisions = true,
61
+ collisionBoundary = [],
62
+ collisionPadding: collisionPaddingProp = 0,
63
+ sticky = "partial",
64
+ hideWhenDetached = false,
65
+ updatePositionStrategy = "optimized",
66
+ onPlaced,
67
+ ...contentProps
68
+ } = props;
69
+ const context = usePopperContext(CONTENT_NAME, __scopePopper);
70
+ const [content, setContent] = React.useState(null);
71
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
72
+ const [arrow, setArrow] = React.useState(null);
73
+ const arrowSize = useSize(arrow);
74
+ const arrowWidth = arrowSize?.width ?? 0;
75
+ const arrowHeight = arrowSize?.height ?? 0;
76
+ const desiredPlacement = side + (align !== "center" ? "-" + align : "");
77
+ const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
78
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
97
79
  const hasExplicitBoundaries = boundary.length > 0;
98
80
  const detectOverflowOptions = {
99
- padding: collisionPadding,
100
- boundary: boundary.filter($cf1ac5d9fe0e8206$var$isNotNull),
101
- // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
102
- altBoundary: hasExplicitBoundaries
81
+ padding: collisionPadding,
82
+ boundary: boundary.filter(isNotNull),
83
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
84
+ altBoundary: hasExplicitBoundaries
103
85
  };
104
- const { refs: refs , floatingStyles: floatingStyles , placement: placement , isPositioned: isPositioned , middlewareData: middlewareData } = $kY93V$useFloating({
105
- // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
106
- strategy: 'fixed',
107
- placement: desiredPlacement,
108
- whileElementsMounted: (...args)=>{
109
- const cleanup = $kY93V$autoUpdate(...args, {
110
- animationFrame: updatePositionStrategy === 'always'
111
- });
112
- return cleanup;
113
- },
114
- elements: {
115
- reference: context.anchor
116
- },
117
- middleware: [
118
- $kY93V$offset({
119
- mainAxis: sideOffset + arrowHeight,
120
- alignmentAxis: alignOffset
121
- }),
122
- avoidCollisions && $kY93V$shift({
123
- mainAxis: true,
124
- crossAxis: false,
125
- limiter: sticky === 'partial' ? $kY93V$limitShift() : undefined,
126
- ...detectOverflowOptions
127
- }),
128
- avoidCollisions && $kY93V$flip({
129
- ...detectOverflowOptions
130
- }),
131
- $kY93V$size({
132
- ...detectOverflowOptions,
133
- apply: ({ elements: elements , rects: rects , availableWidth: availableWidth , availableHeight: availableHeight })=>{
134
- const { width: anchorWidth , height: anchorHeight } = rects.reference;
135
- const contentStyle = elements.floating.style;
136
- contentStyle.setProperty('--radix-popper-available-width', `${availableWidth}px`);
137
- contentStyle.setProperty('--radix-popper-available-height', `${availableHeight}px`);
138
- contentStyle.setProperty('--radix-popper-anchor-width', `${anchorWidth}px`);
139
- contentStyle.setProperty('--radix-popper-anchor-height', `${anchorHeight}px`);
140
- }
141
- }),
142
- arrow && $kY93V$arrow({
143
- element: arrow,
144
- padding: arrowPadding
145
- }),
146
- $cf1ac5d9fe0e8206$var$transformOrigin({
147
- arrowWidth: arrowWidth,
148
- arrowHeight: arrowHeight
149
- }),
150
- hideWhenDetached && $kY93V$hide({
151
- strategy: 'referenceHidden',
152
- ...detectOverflowOptions
153
- })
154
- ]
86
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
87
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
88
+ strategy: "fixed",
89
+ placement: desiredPlacement,
90
+ whileElementsMounted: (...args) => {
91
+ const cleanup = autoUpdate(...args, {
92
+ animationFrame: updatePositionStrategy === "always"
93
+ });
94
+ return cleanup;
95
+ },
96
+ elements: {
97
+ reference: context.anchor
98
+ },
99
+ middleware: [
100
+ offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
101
+ avoidCollisions && shift({
102
+ mainAxis: true,
103
+ crossAxis: false,
104
+ limiter: sticky === "partial" ? limitShift() : void 0,
105
+ ...detectOverflowOptions
106
+ }),
107
+ avoidCollisions && flip({ ...detectOverflowOptions }),
108
+ size({
109
+ ...detectOverflowOptions,
110
+ apply: ({ elements, rects, availableWidth, availableHeight }) => {
111
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
112
+ const contentStyle = elements.floating.style;
113
+ contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
114
+ contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
115
+ contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
116
+ contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
117
+ }
118
+ }),
119
+ arrow && floatingUIarrow({ element: arrow, padding: arrowPadding }),
120
+ transformOrigin({ arrowWidth, arrowHeight }),
121
+ hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
122
+ ]
155
123
  });
156
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
157
- const handlePlaced = $kY93V$useCallbackRef(onPlaced);
158
- $kY93V$useLayoutEffect(()=>{
159
- if (isPositioned) handlePlaced === null || handlePlaced === void 0 || handlePlaced();
160
- }, [
161
- isPositioned,
162
- handlePlaced
163
- ]);
164
- const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
165
- const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
166
- const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
167
- const [contentZIndex, setContentZIndex] = $kY93V$useState();
168
- $kY93V$useLayoutEffect(()=>{
169
- if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
170
- }, [
171
- content
172
- ]);
173
- return /*#__PURE__*/ $kY93V$createElement("div", {
124
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
125
+ const handlePlaced = useCallbackRef(onPlaced);
126
+ useLayoutEffect(() => {
127
+ if (isPositioned) {
128
+ handlePlaced?.();
129
+ }
130
+ }, [isPositioned, handlePlaced]);
131
+ const arrowX = middlewareData.arrow?.x;
132
+ const arrowY = middlewareData.arrow?.y;
133
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
134
+ const [contentZIndex, setContentZIndex] = React.useState();
135
+ useLayoutEffect(() => {
136
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
137
+ }, [content]);
138
+ return /* @__PURE__ */ jsx(
139
+ "div",
140
+ {
174
141
  ref: refs.setFloating,
175
142
  "data-radix-popper-content-wrapper": "",
176
143
  style: {
177
- ...floatingStyles,
178
- transform: isPositioned ? floatingStyles.transform : 'translate(0, -200%)',
179
- // keep off the page when measuring
180
- minWidth: 'max-content',
181
- zIndex: contentZIndex,
182
- ['--radix-popper-transform-origin']: [
183
- (_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x,
184
- (_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y
185
- ].join(' '),
186
- // hide the content if using the hide middleware and should be hidden
187
- // set visibility to hidden and disable pointer events so the UI behaves
188
- // as if the PopperContent isn't there at all
189
- ...((_middlewareData$hide = middlewareData.hide) === null || _middlewareData$hide === void 0 ? void 0 : _middlewareData$hide.referenceHidden) && {
190
- visibility: 'hidden',
191
- pointerEvents: 'none'
192
- }
193
- } // Floating UI interally calculates logical alignment based the `dir` attribute on
194
- ,
195
- dir: props.dir
196
- }, /*#__PURE__*/ $kY93V$createElement($cf1ac5d9fe0e8206$var$PopperContentProvider, {
197
- scope: __scopePopper,
198
- placedSide: placedSide,
199
- onArrowChange: setArrow,
200
- arrowX: arrowX,
201
- arrowY: arrowY,
202
- shouldHideArrow: cannotCenterArrow
203
- }, /*#__PURE__*/ $kY93V$createElement($kY93V$Primitive.div, $kY93V$babelruntimehelpersesmextends({
204
- "data-side": placedSide,
205
- "data-align": placedAlign
206
- }, contentProps, {
207
- ref: composedRefs,
208
- style: {
209
- ...contentProps.style,
210
- // if the PopperContent hasn't been placed yet (not all measurements done)
211
- // we prevent animations so that users's animation don't kick in too early referring wrong sides
212
- animation: !isPositioned ? 'none' : undefined
213
- }
214
- }))));
215
- });
216
- /*#__PURE__*/ Object.assign($cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc, {
217
- displayName: $cf1ac5d9fe0e8206$var$CONTENT_NAME
218
- });
219
- /* -------------------------------------------------------------------------------------------------
220
- * PopperArrow
221
- * -----------------------------------------------------------------------------------------------*/ const $cf1ac5d9fe0e8206$var$ARROW_NAME = 'PopperArrow';
222
- const $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE = {
223
- top: 'bottom',
224
- right: 'left',
225
- bottom: 'top',
226
- left: 'right'
144
+ ...floatingStyles,
145
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
146
+ // keep off the page when measuring
147
+ minWidth: "max-content",
148
+ zIndex: contentZIndex,
149
+ ["--radix-popper-transform-origin"]: [
150
+ middlewareData.transformOrigin?.x,
151
+ middlewareData.transformOrigin?.y
152
+ ].join(" "),
153
+ // hide the content if using the hide middleware and should be hidden
154
+ // set visibility to hidden and disable pointer events so the UI behaves
155
+ // as if the PopperContent isn't there at all
156
+ ...middlewareData.hide?.referenceHidden && {
157
+ visibility: "hidden",
158
+ pointerEvents: "none"
159
+ }
160
+ },
161
+ dir: props.dir,
162
+ children: /* @__PURE__ */ jsx(
163
+ PopperContentProvider,
164
+ {
165
+ scope: __scopePopper,
166
+ placedSide,
167
+ onArrowChange: setArrow,
168
+ arrowX,
169
+ arrowY,
170
+ shouldHideArrow: cannotCenterArrow,
171
+ children: /* @__PURE__ */ jsx(
172
+ Primitive.div,
173
+ {
174
+ "data-side": placedSide,
175
+ "data-align": placedAlign,
176
+ ...contentProps,
177
+ ref: composedRefs,
178
+ style: {
179
+ ...contentProps.style,
180
+ // if the PopperContent hasn't been placed yet (not all measurements done)
181
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
182
+ animation: !isPositioned ? "none" : void 0
183
+ }
184
+ }
185
+ )
186
+ }
187
+ )
188
+ }
189
+ );
190
+ }
191
+ );
192
+ PopperContent.displayName = CONTENT_NAME;
193
+ var ARROW_NAME = "PopperArrow";
194
+ var OPPOSITE_SIDE = {
195
+ top: "bottom",
196
+ right: "left",
197
+ bottom: "top",
198
+ left: "right"
227
199
  };
228
- const $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0 = /*#__PURE__*/ $kY93V$forwardRef(function $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0(props, forwardedRef) {
229
- const { __scopePopper: __scopePopper , ...arrowProps } = props;
230
- const contentContext = $cf1ac5d9fe0e8206$var$useContentContext($cf1ac5d9fe0e8206$var$ARROW_NAME, __scopePopper);
231
- const baseSide = $cf1ac5d9fe0e8206$var$OPPOSITE_SIDE[contentContext.placedSide];
232
- return(/*#__PURE__*/ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
200
+ var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
201
+ const { __scopePopper, ...arrowProps } = props;
202
+ const contentContext = useContentContext(ARROW_NAME, __scopePopper);
203
+ const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
204
+ return (
205
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
233
206
  // doesn't report size as we'd expect on SVG elements.
234
207
  // it reports their bounding box which is effectively the largest path inside the SVG.
235
- $kY93V$createElement("span", {
208
+ /* @__PURE__ */ jsx(
209
+ "span",
210
+ {
236
211
  ref: contentContext.onArrowChange,
237
212
  style: {
238
- position: 'absolute',
239
- left: contentContext.arrowX,
240
- top: contentContext.arrowY,
241
- [baseSide]: 0,
242
- transformOrigin: {
243
- top: '',
244
- right: '0 0',
245
- bottom: 'center 0',
246
- left: '100% 0'
247
- }[contentContext.placedSide],
248
- transform: {
249
- top: 'translateY(100%)',
250
- right: 'translateY(50%) rotate(90deg) translateX(-50%)',
251
- bottom: `rotate(180deg)`,
252
- left: 'translateY(50%) rotate(-90deg) translateX(50%)'
253
- }[contentContext.placedSide],
254
- visibility: contentContext.shouldHideArrow ? 'hidden' : undefined
255
- }
256
- }, /*#__PURE__*/ $kY93V$createElement($kY93V$Root, $kY93V$babelruntimehelpersesmextends({}, arrowProps, {
257
- ref: forwardedRef,
258
- style: {
259
- ...arrowProps.style,
260
- // ensures the element can be measured correctly (mostly for if SVG)
261
- display: 'block'
262
- }
263
- }))));
264
- });
265
- /*#__PURE__*/ Object.assign($cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0, {
266
- displayName: $cf1ac5d9fe0e8206$var$ARROW_NAME
213
+ position: "absolute",
214
+ left: contentContext.arrowX,
215
+ top: contentContext.arrowY,
216
+ [baseSide]: 0,
217
+ transformOrigin: {
218
+ top: "",
219
+ right: "0 0",
220
+ bottom: "center 0",
221
+ left: "100% 0"
222
+ }[contentContext.placedSide],
223
+ transform: {
224
+ top: "translateY(100%)",
225
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
226
+ bottom: `rotate(180deg)`,
227
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
228
+ }[contentContext.placedSide],
229
+ visibility: contentContext.shouldHideArrow ? "hidden" : void 0
230
+ },
231
+ children: /* @__PURE__ */ jsx(
232
+ ArrowPrimitive.Root,
233
+ {
234
+ ...arrowProps,
235
+ ref: forwardedRef,
236
+ style: {
237
+ ...arrowProps.style,
238
+ // ensures the element can be measured correctly (mostly for if SVG)
239
+ display: "block"
240
+ }
241
+ }
242
+ )
243
+ }
244
+ )
245
+ );
267
246
  });
268
- /* -----------------------------------------------------------------------------------------------*/ function $cf1ac5d9fe0e8206$var$isNotNull(value) {
269
- return value !== null;
247
+ PopperArrow.displayName = ARROW_NAME;
248
+ function isNotNull(value) {
249
+ return value !== null;
270
250
  }
271
- const $cf1ac5d9fe0e8206$var$transformOrigin = (options)=>({
272
- name: 'transformOrigin',
273
- options: options,
274
- fn (data) {
275
- var _middlewareData$arrow4, _middlewareData$arrow5, _middlewareData$arrow6, _middlewareData$arrow7, _middlewareData$arrow8;
276
- const { placement: placement , rects: rects , middlewareData: middlewareData } = data;
277
- const cannotCenterArrow = ((_middlewareData$arrow4 = middlewareData.arrow) === null || _middlewareData$arrow4 === void 0 ? void 0 : _middlewareData$arrow4.centerOffset) !== 0;
278
- const isArrowHidden = cannotCenterArrow;
279
- const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
280
- const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
281
- const [placedSide, placedAlign] = $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement);
282
- const noArrowAlign = {
283
- start: '0%',
284
- center: '50%',
285
- end: '100%'
286
- }[placedAlign];
287
- const arrowXCenter = ((_middlewareData$arrow5 = (_middlewareData$arrow6 = middlewareData.arrow) === null || _middlewareData$arrow6 === void 0 ? void 0 : _middlewareData$arrow6.x) !== null && _middlewareData$arrow5 !== void 0 ? _middlewareData$arrow5 : 0) + arrowWidth / 2;
288
- const arrowYCenter = ((_middlewareData$arrow7 = (_middlewareData$arrow8 = middlewareData.arrow) === null || _middlewareData$arrow8 === void 0 ? void 0 : _middlewareData$arrow8.y) !== null && _middlewareData$arrow7 !== void 0 ? _middlewareData$arrow7 : 0) + arrowHeight / 2;
289
- let x = '';
290
- let y = '';
291
- if (placedSide === 'bottom') {
292
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
293
- y = `${-arrowHeight}px`;
294
- } else if (placedSide === 'top') {
295
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
296
- y = `${rects.floating.height + arrowHeight}px`;
297
- } else if (placedSide === 'right') {
298
- x = `${-arrowHeight}px`;
299
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
300
- } else if (placedSide === 'left') {
301
- x = `${rects.floating.width + arrowHeight}px`;
302
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
303
- }
304
- return {
305
- data: {
306
- x: x,
307
- y: y
308
- }
309
- };
310
- }
311
- })
312
- ;
313
- function $cf1ac5d9fe0e8206$var$getSideAndAlignFromPlacement(placement) {
314
- const [side, align = 'center'] = placement.split('-');
315
- return [
316
- side,
317
- align
318
- ];
251
+ var transformOrigin = (options) => ({
252
+ name: "transformOrigin",
253
+ options,
254
+ fn(data) {
255
+ const { placement, rects, middlewareData } = data;
256
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
257
+ const isArrowHidden = cannotCenterArrow;
258
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
259
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
260
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
261
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
262
+ const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
263
+ const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
264
+ let x = "";
265
+ let y = "";
266
+ if (placedSide === "bottom") {
267
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
268
+ y = `${-arrowHeight}px`;
269
+ } else if (placedSide === "top") {
270
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
271
+ y = `${rects.floating.height + arrowHeight}px`;
272
+ } else if (placedSide === "right") {
273
+ x = `${-arrowHeight}px`;
274
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
275
+ } else if (placedSide === "left") {
276
+ x = `${rects.floating.width + arrowHeight}px`;
277
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
278
+ }
279
+ return { data: { x, y } };
280
+ }
281
+ });
282
+ function getSideAndAlignFromPlacement(placement) {
283
+ const [side, align = "center"] = placement.split("-");
284
+ return [side, align];
319
285
  }
320
- const $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9 = $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9;
321
- const $cf1ac5d9fe0e8206$export$b688253958b8dfe7 = $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d;
322
- const $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 = $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc;
323
- const $cf1ac5d9fe0e8206$export$21b07c8f274aebd5 = $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0;
324
-
325
-
326
-
327
-
328
- export {$cf1ac5d9fe0e8206$export$722aac194ae923 as createPopperScope, $cf1ac5d9fe0e8206$export$badac9ada3a0bdf9 as Popper, $cf1ac5d9fe0e8206$export$ecd4e1ccab6ed6d as PopperAnchor, $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc as PopperContent, $cf1ac5d9fe0e8206$export$79d62cd4e10a3fd0 as PopperArrow, $cf1ac5d9fe0e8206$export$be92b6f5f03c0fe9 as Root, $cf1ac5d9fe0e8206$export$b688253958b8dfe7 as Anchor, $cf1ac5d9fe0e8206$export$7c6e2c02157bb7d2 as Content, $cf1ac5d9fe0e8206$export$21b07c8f274aebd5 as Arrow, $cf1ac5d9fe0e8206$export$36f0086da09c4b9f as SIDE_OPTIONS, $cf1ac5d9fe0e8206$export$3671ffab7b302fc9 as ALIGN_OPTIONS};
286
+ var Root2 = Popper;
287
+ var Anchor = PopperAnchor;
288
+ var Content = PopperContent;
289
+ var Arrow = PopperArrow;
290
+ export {
291
+ ALIGN_OPTIONS,
292
+ Anchor,
293
+ Arrow,
294
+ Content,
295
+ Popper,
296
+ PopperAnchor,
297
+ PopperArrow,
298
+ PopperContent,
299
+ Root2 as Root,
300
+ SIDE_OPTIONS,
301
+ createPopperScope
302
+ };
329
303
  //# sourceMappingURL=index.mjs.map