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