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