@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.js CHANGED
@@ -1,346 +1,310 @@
1
- var $50Iv9$babelruntimehelpersextends = require("@babel/runtime/helpers/extends");
2
- var $50Iv9$react = require("react");
3
- var $50Iv9$floatinguireactdom = require("@floating-ui/react-dom");
4
- var $50Iv9$radixuireactarrow = require("@radix-ui/react-arrow");
5
- var $50Iv9$radixuireactcomposerefs = require("@radix-ui/react-compose-refs");
6
- var $50Iv9$radixuireactcontext = require("@radix-ui/react-context");
7
- var $50Iv9$radixuireactprimitive = require("@radix-ui/react-primitive");
8
- var $50Iv9$radixuireactusecallbackref = require("@radix-ui/react-use-callback-ref");
9
- var $50Iv9$radixuireactuselayouteffect = require("@radix-ui/react-use-layout-effect");
10
- var $50Iv9$radixuireactusesize = require("@radix-ui/react-use-size");
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
- function $parcel$export(e, n, v, s) {
13
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
14
- }
15
- function $parcel$interopDefault(a) {
16
- return a && a.__esModule ? a.default : a;
17
- }
18
-
19
- $parcel$export(module.exports, "createPopperScope", () => $34310caa050a8d63$export$722aac194ae923);
20
- $parcel$export(module.exports, "Popper", () => $34310caa050a8d63$export$badac9ada3a0bdf9);
21
- $parcel$export(module.exports, "PopperAnchor", () => $34310caa050a8d63$export$ecd4e1ccab6ed6d);
22
- $parcel$export(module.exports, "PopperContent", () => $34310caa050a8d63$export$bc4ae5855d3c4fc);
23
- $parcel$export(module.exports, "PopperArrow", () => $34310caa050a8d63$export$79d62cd4e10a3fd0);
24
- $parcel$export(module.exports, "Root", () => $34310caa050a8d63$export$be92b6f5f03c0fe9);
25
- $parcel$export(module.exports, "Anchor", () => $34310caa050a8d63$export$b688253958b8dfe7);
26
- $parcel$export(module.exports, "Content", () => $34310caa050a8d63$export$7c6e2c02157bb7d2);
27
- $parcel$export(module.exports, "Arrow", () => $34310caa050a8d63$export$21b07c8f274aebd5);
28
- $parcel$export(module.exports, "SIDE_OPTIONS", () => $34310caa050a8d63$export$36f0086da09c4b9f);
29
- $parcel$export(module.exports, "ALIGN_OPTIONS", () => $34310caa050a8d63$export$3671ffab7b302fc9);
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
- const $34310caa050a8d63$export$36f0086da09c4b9f = [
41
- 'top',
42
- 'right',
43
- 'bottom',
44
- 'left'
45
- ];
46
- const $34310caa050a8d63$export$3671ffab7b302fc9 = [
47
- 'start',
48
- 'center',
49
- 'end'
50
- ];
51
- /* -------------------------------------------------------------------------------------------------
52
- * Popper
53
- * -----------------------------------------------------------------------------------------------*/ const $34310caa050a8d63$var$POPPER_NAME = 'Popper';
54
- const [$34310caa050a8d63$var$createPopperContext, $34310caa050a8d63$export$722aac194ae923] = $50Iv9$radixuireactcontext.createContextScope($34310caa050a8d63$var$POPPER_NAME);
55
- const [$34310caa050a8d63$var$PopperProvider, $34310caa050a8d63$var$usePopperContext] = $34310caa050a8d63$var$createPopperContext($34310caa050a8d63$var$POPPER_NAME);
56
- const $34310caa050a8d63$export$badac9ada3a0bdf9 = (props)=>{
57
- const { __scopePopper: __scopePopper , children: children } = props;
58
- const [anchor, setAnchor] = $50Iv9$react.useState(null);
59
- return /*#__PURE__*/ $50Iv9$react.createElement($34310caa050a8d63$var$PopperProvider, {
60
- scope: __scopePopper,
61
- anchor: anchor,
62
- onAnchorChange: setAnchor
63
- }, children);
64
- };
65
- /*#__PURE__*/ Object.assign($34310caa050a8d63$export$badac9ada3a0bdf9, {
66
- displayName: $34310caa050a8d63$var$POPPER_NAME
67
- });
68
- /* -------------------------------------------------------------------------------------------------
69
- * PopperAnchor
70
- * -----------------------------------------------------------------------------------------------*/ const $34310caa050a8d63$var$ANCHOR_NAME = 'PopperAnchor';
71
- const $34310caa050a8d63$export$ecd4e1ccab6ed6d = /*#__PURE__*/ $50Iv9$react.forwardRef((props, forwardedRef)=>{
72
- const { __scopePopper: __scopePopper , virtualRef: virtualRef , ...anchorProps } = props;
73
- const context = $34310caa050a8d63$var$usePopperContext($34310caa050a8d63$var$ANCHOR_NAME, __scopePopper);
74
- const ref = $50Iv9$react.useRef(null);
75
- const composedRefs = $50Iv9$radixuireactcomposerefs.useComposedRefs(forwardedRef, ref);
76
- $50Iv9$react.useEffect(()=>{
77
- // Consumer can anchor the popper to something that isn't
78
- // a DOM node e.g. pointer position, so we override the
79
- // `anchorRef` with their virtual ref in this case.
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($34310caa050a8d63$var$isNotNull),
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
- const { refs: refs , floatingStyles: floatingStyles , placement: placement , isPositioned: isPositioned , middlewareData: middlewareData } = $50Iv9$floatinguireactdom.useFloating({
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: 'fixed',
107
+ strategy: "fixed",
125
108
  placement: desiredPlacement,
126
- whileElementsMounted: (...args)=>{
127
- const cleanup = $50Iv9$floatinguireactdom.autoUpdate(...args, {
128
- animationFrame: updatePositionStrategy === 'always'
129
- });
130
- return cleanup;
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
- reference: context.anchor
116
+ reference: context.anchor
134
117
  },
135
118
  middleware: [
136
- $50Iv9$floatinguireactdom.offset({
137
- mainAxis: sideOffset + arrowHeight,
138
- alignmentAxis: alignOffset
139
- }),
140
- avoidCollisions && $50Iv9$floatinguireactdom.shift({
141
- mainAxis: true,
142
- crossAxis: false,
143
- limiter: sticky === 'partial' ? $50Iv9$floatinguireactdom.limitShift() : undefined,
144
- ...detectOverflowOptions
145
- }),
146
- avoidCollisions && $50Iv9$floatinguireactdom.flip({
147
- ...detectOverflowOptions
148
- }),
149
- $50Iv9$floatinguireactdom.size({
150
- ...detectOverflowOptions,
151
- apply: ({ elements: elements , rects: rects , availableWidth: availableWidth , availableHeight: availableHeight })=>{
152
- const { width: anchorWidth , height: anchorHeight } = rects.reference;
153
- const contentStyle = elements.floating.style;
154
- contentStyle.setProperty('--radix-popper-available-width', `${availableWidth}px`);
155
- contentStyle.setProperty('--radix-popper-available-height', `${availableHeight}px`);
156
- contentStyle.setProperty('--radix-popper-anchor-width', `${anchorWidth}px`);
157
- contentStyle.setProperty('--radix-popper-anchor-height', `${anchorHeight}px`);
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
- const [placedSide, placedAlign] = $34310caa050a8d63$var$getSideAndAlignFromPlacement(placement);
175
- const handlePlaced = $50Iv9$radixuireactusecallbackref.useCallbackRef(onPlaced);
176
- $50Iv9$radixuireactuselayouteffect.useLayoutEffect(()=>{
177
- if (isPositioned) handlePlaced === null || handlePlaced === void 0 || handlePlaced();
178
- }, [
179
- isPositioned,
180
- handlePlaced
181
- ]);
182
- const arrowX = (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x;
183
- const arrowY = (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y;
184
- const cannotCenterArrow = ((_middlewareData$arrow3 = middlewareData.arrow) === null || _middlewareData$arrow3 === void 0 ? void 0 : _middlewareData$arrow3.centerOffset) !== 0;
185
- const [contentZIndex, setContentZIndex] = $50Iv9$react.useState();
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
- content
190
- ]);
191
- return /*#__PURE__*/ $50Iv9$react.createElement("div", {
192
- ref: refs.setFloating,
193
- "data-radix-popper-content-wrapper": "",
194
- style: {
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 : 'translate(0, -200%)',
164
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
197
165
  // keep off the page when measuring
198
- minWidth: 'max-content',
166
+ minWidth: "max-content",
199
167
  zIndex: contentZIndex,
200
- ['--radix-popper-transform-origin']: [
201
- (_middlewareData$trans = middlewareData.transformOrigin) === null || _middlewareData$trans === void 0 ? void 0 : _middlewareData$trans.x,
202
- (_middlewareData$trans2 = middlewareData.transformOrigin) === null || _middlewareData$trans2 === void 0 ? void 0 : _middlewareData$trans2.y
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
- ...((_middlewareData$hide = middlewareData.hide) === null || _middlewareData$hide === void 0 ? void 0 : _middlewareData$hide.referenceHidden) && {
208
- visibility: 'hidden',
209
- pointerEvents: 'none'
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
- } // Floating UI interally calculates logical alignment based the `dir` attribute on
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
- /*#__PURE__*/ Object.assign($34310caa050a8d63$export$bc4ae5855d3c4fc, {
235
- displayName: $34310caa050a8d63$var$CONTENT_NAME
236
- });
237
- /* -------------------------------------------------------------------------------------------------
238
- * PopperArrow
239
- * -----------------------------------------------------------------------------------------------*/ const $34310caa050a8d63$var$ARROW_NAME = 'PopperArrow';
240
- const $34310caa050a8d63$var$OPPOSITE_SIDE = {
241
- top: 'bottom',
242
- right: 'left',
243
- bottom: 'top',
244
- left: 'right'
245
- };
246
- const $34310caa050a8d63$export$79d62cd4e10a3fd0 = /*#__PURE__*/ $50Iv9$react.forwardRef(function $34310caa050a8d63$export$79d62cd4e10a3fd0(props, forwardedRef) {
247
- const { __scopePopper: __scopePopper , ...arrowProps } = props;
248
- const contentContext = $34310caa050a8d63$var$useContentContext($34310caa050a8d63$var$ARROW_NAME, __scopePopper);
249
- const baseSide = $34310caa050a8d63$var$OPPOSITE_SIDE[contentContext.placedSide];
250
- return(/*#__PURE__*/ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
251
- // doesn't report size as we'd expect on SVG elements.
252
- // it reports their bounding box which is effectively the largest path inside the SVG.
253
- $50Iv9$react.createElement("span", {
254
- ref: contentContext.onArrowChange,
255
- style: {
256
- position: 'absolute',
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
- top: '',
262
- right: '0 0',
263
- bottom: 'center 0',
264
- left: '100% 0'
237
+ top: "",
238
+ right: "0 0",
239
+ bottom: "center 0",
240
+ left: "100% 0"
265
241
  }[contentContext.placedSide],
266
242
  transform: {
267
- top: 'translateY(100%)',
268
- right: 'translateY(50%) rotate(90deg) translateX(-50%)',
269
- bottom: `rotate(180deg)`,
270
- left: 'translateY(50%) rotate(-90deg) translateX(50%)'
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 ? 'hidden' : undefined
273
- }
274
- }, /*#__PURE__*/ $50Iv9$react.createElement($50Iv9$radixuireactarrow.Root, ($parcel$interopDefault($50Iv9$babelruntimehelpersextends))({}, arrowProps, {
275
- ref: forwardedRef,
276
- style: {
277
- ...arrowProps.style,
278
- // ensures the element can be measured correctly (mostly for if SVG)
279
- display: 'block'
280
- }
281
- }))));
282
- });
283
- /*#__PURE__*/ Object.assign($34310caa050a8d63$export$79d62cd4e10a3fd0, {
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
- return {
323
- data: {
324
- x: x,
325
- y: y
326
- }
327
- };
261
+ )
328
262
  }
329
- })
330
- ;
331
- function $34310caa050a8d63$var$getSideAndAlignFromPlacement(placement) {
332
- const [side, align = 'center'] = placement.split('-');
333
- return [
334
- side,
335
- align
336
- ];
337
- }
338
- const $34310caa050a8d63$export$be92b6f5f03c0fe9 = $34310caa050a8d63$export$badac9ada3a0bdf9;
339
- const $34310caa050a8d63$export$b688253958b8dfe7 = $34310caa050a8d63$export$ecd4e1ccab6ed6d;
340
- const $34310caa050a8d63$export$7c6e2c02157bb7d2 = $34310caa050a8d63$export$bc4ae5855d3c4fc;
341
- const $34310caa050a8d63$export$21b07c8f274aebd5 = $34310caa050a8d63$export$79d62cd4e10a3fd0;
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