@tamagui/popper 2.7.7 → 3.0.0-beta.1093.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.
Files changed (53) hide show
  1. package/dist/cjs/Popper.cjs +473 -607
  2. package/dist/cjs/Popper.native.cjs +498 -0
  3. package/dist/cjs/Popper.native.js +454 -611
  4. package/dist/cjs/Popper.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +9 -11
  6. package/dist/cjs/index.native.cjs +20 -0
  7. package/dist/cjs/index.native.js +9 -10
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/useRepositionOnNative.cjs +24 -0
  10. package/dist/cjs/useRepositionOnNative.native.cjs +63 -0
  11. package/dist/cjs/useRepositionOnNative.native.js +65 -0
  12. package/dist/cjs/useRepositionOnNative.native.js.map +1 -0
  13. package/dist/esm/Popper.mjs +443 -559
  14. package/dist/esm/Popper.mjs.map +1 -1
  15. package/dist/esm/Popper.native.js +423 -559
  16. package/dist/esm/Popper.native.js.map +1 -1
  17. package/dist/esm/index.js +1 -2
  18. package/dist/esm/index.mjs +1 -2
  19. package/dist/esm/index.native.js +1 -2
  20. package/dist/esm/useRepositionOnNative.mjs +4 -0
  21. package/dist/esm/useRepositionOnNative.mjs.map +1 -0
  22. package/dist/esm/useRepositionOnNative.native.js +36 -0
  23. package/dist/esm/useRepositionOnNative.native.js.map +1 -0
  24. package/dist/jsx/Popper.mjs +443 -559
  25. package/dist/jsx/Popper.mjs.map +1 -1
  26. package/dist/jsx/Popper.native.cjs +498 -0
  27. package/dist/jsx/Popper.native.js +454 -611
  28. package/dist/jsx/Popper.native.js.map +1 -1
  29. package/dist/jsx/index.js +1 -2
  30. package/dist/jsx/index.mjs +1 -2
  31. package/dist/jsx/index.native.cjs +20 -0
  32. package/dist/jsx/index.native.js +9 -10
  33. package/dist/jsx/index.native.js.map +1 -1
  34. package/dist/jsx/useRepositionOnNative.mjs +4 -0
  35. package/dist/jsx/useRepositionOnNative.mjs.map +1 -0
  36. package/dist/jsx/useRepositionOnNative.native.cjs +63 -0
  37. package/dist/jsx/useRepositionOnNative.native.js +65 -0
  38. package/dist/jsx/useRepositionOnNative.native.js.map +1 -0
  39. package/package.json +15 -13
  40. package/src/Popper.tsx +44 -129
  41. package/src/useRepositionOnNative.native.ts +40 -0
  42. package/src/useRepositionOnNative.ts +8 -0
  43. package/types/Popper.d.ts +42 -74
  44. package/types/Popper.d.ts.map +1 -1
  45. package/types/useRepositionOnNative.d.ts +6 -0
  46. package/types/useRepositionOnNative.d.ts.map +1 -0
  47. package/types/useRepositionOnNative.native.d.ts +7 -0
  48. package/types/useRepositionOnNative.native.d.ts.map +1 -0
  49. package/dist/esm/index.js.map +0 -1
  50. package/dist/esm/index.mjs.map +0 -1
  51. package/dist/esm/index.native.js.map +0 -1
  52. package/dist/jsx/index.js.map +0 -1
  53. package/dist/jsx/index.mjs.map +0 -1
@@ -5,49 +5,42 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
12
  };
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
21
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
30
25
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
27
  var Popper_exports = {};
35
28
  __export(Popper_exports, {
36
- Popper: () => Popper,
37
- PopperAnchor: () => PopperAnchor,
38
- PopperArrow: () => PopperArrow,
39
- PopperArrowFrame: () => PopperArrowFrame,
40
- PopperContent: () => PopperContent,
41
- PopperContentFrame: () => PopperContentFrame,
42
- PopperContextFast: () => PopperContextFast,
43
- PopperContextSlow: () => PopperContextSlow,
44
- PopperPositionContext: () => PopperPositionContext,
45
- PopperProvider: () => PopperProvider,
46
- PopperProviderFast: () => PopperProviderFast,
47
- PopperProviderSlow: () => PopperProviderSlow,
48
- setupPopper: () => setupPopper,
49
- usePopperContext: () => usePopperContext,
50
- usePopperContextSlow: () => usePopperContextSlow
29
+ Popper: () => Popper,
30
+ PopperAnchor: () => PopperAnchor,
31
+ PopperArrow: () => PopperArrow,
32
+ PopperArrowFrame: () => PopperArrowFrame,
33
+ PopperContent: () => PopperContent,
34
+ PopperContentFrame: () => PopperContentFrame,
35
+ PopperContextFast: () => PopperContextFast,
36
+ PopperContextSlow: () => PopperContextSlow,
37
+ PopperPositionContext: () => PopperPositionContext,
38
+ PopperProvider: () => PopperProvider,
39
+ PopperProviderFast: () => PopperProviderFast,
40
+ PopperProviderSlow: () => PopperProviderSlow,
41
+ setupPopper: () => setupPopper,
42
+ usePopperContext: () => usePopperContext,
43
+ usePopperContextSlow: () => usePopperContextSlow
51
44
  });
52
45
  module.exports = __toCommonJS(Popper_exports);
53
46
  var import_react_dom = require("react-dom");
@@ -57,595 +50,468 @@ var import_core = require("@tamagui/core");
57
50
  var import_floating = require("@tamagui/floating");
58
51
  var import_floating2 = require("@tamagui/floating");
59
52
  var import_get_token = require("@tamagui/get-token");
60
- var import_stacks = require("@tamagui/stacks");
61
53
  var import_start_transition = require("@tamagui/start-transition");
62
54
  var React = __toESM(require("react"), 1);
63
- require("react-native-web");
55
+ var import_useRepositionOnNative = require("./useRepositionOnNative.cjs");
64
56
  var import_jsx_runtime = require("react/jsx-runtime");
65
- const PopperContextFast = (0, import_core.createStyledContext)(
66
- // since we always provide this we can avoid setting here
67
- {}, "Popper__");
57
+ const PopperContextFast = (0, import_core.createStyledContext)({}, "Popper__");
68
58
  const PopperPositionContext = import_core.createStyledContext;
69
- const {
70
- useStyledContext: usePopperContext,
71
- Provider: PopperProviderFast
72
- } = PopperContextFast;
73
- const PopperContextSlow = (0, import_core.createStyledContext)(
74
- // since we always provide this we can avoid setting here
75
- {}, "PopperSlow__");
76
- const {
77
- useStyledContext: usePopperContextSlow,
78
- Provider: PopperProviderSlow
79
- } = PopperContextSlow;
80
- const PopperProvider = ({
81
- scope,
82
- children,
83
- ...context
84
- }) => {
85
- const fns = React.useRef(context);
86
- fns.current = context;
87
- const [slowContext] = React.useState(() => ({
88
- refs: context.refs,
89
- triggerElements: context.triggerElements,
90
- update(...a) {
91
- fns.current.update(...a);
92
- },
93
- getReferenceProps(p) {
94
- return fns.current.getReferenceProps?.(p);
95
- },
96
- onHoverReference(e) {
97
- fns.current.onHoverReference?.(e);
98
- },
99
- onLeaveReference() {
100
- fns.current.onLeaveReference?.();
101
- }
102
- }));
103
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperProviderFast, {
104
- scope,
105
- ...context,
106
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperProviderSlow, {
107
- scope,
108
- ...slowContext,
109
- children
110
- })
111
- });
59
+ const { useStyledContext: usePopperContext, Provider: PopperProviderFast } = PopperContextFast;
60
+ const PopperContextSlow = (0, import_core.createStyledContext)({}, "PopperSlow__");
61
+ const { useStyledContext: usePopperContextSlow, Provider: PopperProviderSlow } = PopperContextSlow;
62
+ const PopperProvider = ({ scope, children, ...context }) => {
63
+ const fns = React.useRef(context);
64
+ fns.current = context;
65
+ const [slowContext] = React.useState(() => ({
66
+ refs: context.refs,
67
+ triggerElements: context.triggerElements,
68
+ update(...a) {
69
+ fns.current.update(...a);
70
+ },
71
+ getReferenceProps(p) {
72
+ return fns.current.getReferenceProps?.(p);
73
+ },
74
+ onHoverReference(e) {
75
+ fns.current.onHoverReference?.(e);
76
+ },
77
+ onLeaveReference() {
78
+ fns.current.onLeaveReference?.();
79
+ }
80
+ }));
81
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperProviderFast, {
82
+ scope,
83
+ ...context,
84
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperProviderSlow, {
85
+ scope,
86
+ ...slowContext,
87
+ children
88
+ })
89
+ });
112
90
  };
113
91
  const checkFloating = void 0;
114
92
  const setupOptions = {};
115
93
  function setupPopper(options) {
116
- Object.assign(setupOptions, options);
94
+ Object.assign(setupOptions, options);
117
95
  }
118
96
  function getSideAndAlignFromPlacement(placement) {
119
- const [side, align = "center"] = placement.split("-");
120
- return [side, align];
97
+ const [side, align = "center"] = placement.split("-");
98
+ return [side, align];
121
99
  }
122
- const transformOriginMiddleware = options => ({
123
- name: "transformOrigin",
124
- options,
125
- fn(data) {
126
- const {
127
- placement,
128
- rects,
129
- middlewareData
130
- } = data;
131
- const isArrowHidden = middlewareData.arrow?.centerOffset !== 0;
132
- const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
133
- const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
134
- const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
135
- const noArrowAlign = {
136
- start: "0%",
137
- center: "50%",
138
- end: "100%"
139
- }[placedAlign];
140
- const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
141
- const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
142
- let x = "";
143
- let y = "";
144
- if (placedSide === "bottom") {
145
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
146
- y = `${-arrowHeight}px`;
147
- } else if (placedSide === "top") {
148
- x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
149
- y = `${rects.floating.height + arrowHeight}px`;
150
- } else if (placedSide === "right") {
151
- x = `${-arrowHeight}px`;
152
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
153
- } else if (placedSide === "left") {
154
- x = `${rects.floating.width + arrowHeight}px`;
155
- y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
156
- }
157
- return {
158
- data: {
159
- x,
160
- y
161
- }
162
- };
163
- }
100
+ const transformOriginMiddleware = (options) => ({
101
+ name: "transformOrigin",
102
+ options,
103
+ fn(data) {
104
+ const { placement, rects, middlewareData } = data;
105
+ const isArrowHidden = middlewareData.arrow?.centerOffset !== 0;
106
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
107
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
108
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
109
+ const noArrowAlign = {
110
+ start: "0%",
111
+ center: "50%",
112
+ end: "100%"
113
+ }[placedAlign];
114
+ const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
115
+ const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
116
+ let x = "";
117
+ let y = "";
118
+ if (placedSide === "bottom") {
119
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
120
+ y = `${-arrowHeight}px`;
121
+ } else if (placedSide === "top") {
122
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
123
+ y = `${rects.floating.height + arrowHeight}px`;
124
+ } else if (placedSide === "right") {
125
+ x = `${-arrowHeight}px`;
126
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
127
+ } else if (placedSide === "left") {
128
+ x = `${rects.floating.width + arrowHeight}px`;
129
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
130
+ }
131
+ return { data: {
132
+ x,
133
+ y
134
+ } };
135
+ }
164
136
  });
165
137
  function tamaguiAutoUpdate(reference, floating, update) {
166
- update();
167
- let rafId = requestAnimationFrame(() => {
168
- update();
169
- rafId = 0;
170
- });
171
- const cleanups = [() => {
172
- if (rafId) cancelAnimationFrame(rafId);
173
- }];
174
- if (reference instanceof HTMLElement) cleanups.push((0, import_core.registerLayoutNode)(reference, update));
175
- if (typeof ResizeObserver !== "undefined") {
176
- let lastWidth = -1;
177
- let lastHeight = -1;
178
- const ro = new ResizeObserver(entries => {
179
- const entry = entries[entries.length - 1];
180
- if (!entry) return;
181
- const {
182
- width,
183
- height
184
- } = entry.contentRect;
185
- if (lastWidth === -1) {
186
- lastWidth = width;
187
- lastHeight = height;
188
- return;
189
- }
190
- if (width !== lastWidth || height !== lastHeight) {
191
- lastWidth = width;
192
- lastHeight = height;
193
- update();
194
- }
195
- });
196
- ro.observe(floating);
197
- cleanups.push(() => ro.disconnect());
198
- }
199
- const ancestors = [...(reference instanceof Element ? (0, import_floating2.getOverflowAncestors)(reference) : []), ...(0, import_floating2.getOverflowAncestors)(floating)];
200
- const uniqueAncestors = [...new Set(ancestors)];
201
- for (const ancestor of uniqueAncestors) ancestor.addEventListener("scroll", update, {
202
- passive: true
203
- });
204
- window.addEventListener("resize", update);
205
- cleanups.push(() => {
206
- for (const ancestor of uniqueAncestors) ancestor.removeEventListener("scroll", update);
207
- window.removeEventListener("resize", update);
208
- });
209
- return () => cleanups.forEach(fn => fn());
138
+ update();
139
+ let rafId = requestAnimationFrame(() => {
140
+ update();
141
+ rafId = 0;
142
+ });
143
+ const cleanups = [() => {
144
+ if (rafId) cancelAnimationFrame(rafId);
145
+ }];
146
+ if (reference instanceof HTMLElement) cleanups.push((0, import_core.registerLayoutNode)(reference, update));
147
+ if (typeof ResizeObserver !== "undefined") {
148
+ let lastWidth = -1;
149
+ let lastHeight = -1;
150
+ const ro = new ResizeObserver((entries) => {
151
+ const entry = entries[entries.length - 1];
152
+ if (!entry) return;
153
+ const { width, height } = entry.contentRect;
154
+ if (lastWidth === -1) {
155
+ lastWidth = width;
156
+ lastHeight = height;
157
+ return;
158
+ }
159
+ if (width !== lastWidth || height !== lastHeight) {
160
+ lastWidth = width;
161
+ lastHeight = height;
162
+ update();
163
+ }
164
+ });
165
+ ro.observe(floating);
166
+ cleanups.push(() => ro.disconnect());
167
+ }
168
+ const ancestors = [...reference instanceof Element ? (0, import_floating2.getOverflowAncestors)(reference) : [], ...(0, import_floating2.getOverflowAncestors)(floating)];
169
+ const uniqueAncestors = [...new Set(ancestors)];
170
+ for (const ancestor of uniqueAncestors) ancestor.addEventListener("scroll", update, { passive: true });
171
+ window.addEventListener("resize", update);
172
+ cleanups.push(() => {
173
+ for (const ancestor of uniqueAncestors) ancestor.removeEventListener("scroll", update);
174
+ window.removeEventListener("resize", update);
175
+ });
176
+ return () => cleanups.forEach((fn) => fn());
210
177
  }
211
178
  function Popper(props) {
212
- const {
213
- children,
214
- size,
215
- strategy = "absolute",
216
- placement = "bottom",
217
- stayInFrame,
218
- allowFlip,
219
- offset,
220
- disableRTL,
221
- resize,
222
- passThrough,
223
- open,
224
- scope
225
- } = props;
226
- const [arrowEl, setArrow] = React.useState(null);
227
- const [arrowSize, setArrowSize] = React.useState(0);
228
- const offsetOptions = offset ?? arrowSize;
229
- const floatingStyle = React.useRef({});
230
- const isOpen = passThrough ? false : open ?? true;
231
- const middlewareRef = React.useRef([]);
232
- if (isOpen) middlewareRef.current = [typeof offsetOptions !== "undefined" ? (0, import_floating2.offset)(offsetOptions) : null, allowFlip ? (0, import_floating2.flip)(typeof allowFlip === "boolean" ? {} : allowFlip) : null, stayInFrame ? (0, import_floating2.shift)({
233
- padding: 10,
234
- mainAxis: true,
235
- crossAxis: false,
236
- ...(typeof stayInFrame === "object" ? stayInFrame : null)
237
- }) : null, arrowEl ? (0, import_floating2.arrow)({
238
- element: arrowEl
239
- }) : null, checkFloating, resize ? (0, import_floating2.size)({
240
- padding: typeof stayInFrame === "object" ? stayInFrame.padding : 10,
241
- apply({
242
- availableHeight,
243
- availableWidth
244
- }) {
245
- if (passThrough) return;
246
- Object.assign(floatingStyle.current, {
247
- maxHeight: `${availableHeight}px`,
248
- maxWidth: `${availableWidth}px`
249
- });
250
- const floatingChild = floating.refs.floating.current?.firstChild;
251
- if (floatingChild && floatingChild instanceof HTMLElement) Object.assign(floatingChild.style, floatingStyle.current);
252
- },
253
- ...(typeof resize === "object" && resize)
254
- }) : null, (0, import_floating2.size)({
255
- apply({
256
- elements,
257
- rects,
258
- availableWidth,
259
- availableHeight
260
- }) {
261
- const {
262
- width: anchorWidth,
263
- height: anchorHeight
264
- } = rects.reference;
265
- const contentStyle = elements.floating.style;
266
- contentStyle.setProperty("--tamagui-popper-available-width", `${availableWidth}px`);
267
- contentStyle.setProperty("--tamagui-popper-available-height", `${availableHeight}px`);
268
- contentStyle.setProperty("--tamagui-popper-anchor-width", `${anchorWidth}px`);
269
- contentStyle.setProperty("--tamagui-popper-anchor-height", `${anchorHeight}px`);
270
- }
271
- }), transformOriginMiddleware({
272
- arrowHeight: arrowSize,
273
- arrowWidth: arrowSize
274
- })].filter(Boolean);
275
- let floating = (0, import_floating2.useFloating)({
276
- open: isOpen,
277
- strategy,
278
- placement,
279
- sameScrollView: false,
280
- whileElementsMounted: !isOpen ? void 0 : tamaguiAutoUpdate,
281
- platform: disableRTL ?? setupOptions.disableRTL ? {
282
- ...import_floating2.platform,
283
- isRTL(element) {
284
- return false;
285
- }
286
- } : import_floating2.platform,
287
- middleware: middlewareRef.current
288
- });
289
- floating = React.useMemo(() => {
290
- const og = floating.getFloatingProps;
291
- if (resize && og) floating.getFloatingProps = props2 => {
292
- return og({
293
- ...props2,
294
- style: {
295
- ...props2.style,
296
- ...floatingStyle.current
297
- }
298
- });
299
- };
300
- return floating;
301
- }, [floating, resize ? JSON.stringify(resize) : null]);
302
- const {
303
- middlewareData
304
- } = floating;
305
- const popperContext = React.useMemo(() => {
306
- return {
307
- size,
308
- arrowRef: setArrow,
309
- arrowStyle: middlewareData.arrow,
310
- onArrowSize: setArrowSize,
311
- hasFloating: middlewareData.checkFloating?.hasFloating,
312
- transformOrigin: middlewareData.transformOrigin,
313
- open: !!open,
314
- ...floating
315
- };
316
- }, [open, size, floating, JSON.stringify(middlewareData.arrow || null), JSON.stringify(middlewareData.transformOrigin || null)]);
317
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperProvider, {
318
- scope,
319
- ...popperContext,
320
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, {
321
- value: null,
322
- children
323
- })
324
- });
179
+ const { children, size, strategy = "absolute", placement = "bottom", stayInFrame, allowFlip, offset, disableRTL, resize, passThrough, open, scope } = props;
180
+ const [arrowEl, setArrow] = React.useState(null);
181
+ const [arrowSize, setArrowSize] = React.useState(0);
182
+ const offsetOptions = offset ?? arrowSize;
183
+ const floatingStyle = React.useRef({});
184
+ const isOpen = passThrough ? false : open ?? true;
185
+ const middlewareRef = React.useRef([]);
186
+ if (isOpen) middlewareRef.current = [
187
+ typeof offsetOptions !== "undefined" ? (0, import_floating2.offset)(offsetOptions) : null,
188
+ allowFlip ? (0, import_floating2.flip)(typeof allowFlip === "boolean" ? {} : allowFlip) : null,
189
+ stayInFrame ? (0, import_floating2.shift)({
190
+ padding: 10,
191
+ mainAxis: true,
192
+ crossAxis: false,
193
+ ...typeof stayInFrame === "object" ? stayInFrame : null
194
+ }) : null,
195
+ arrowEl ? (0, import_floating2.arrow)({ element: arrowEl }) : null,
196
+ checkFloating,
197
+ resize ? (0, import_floating2.size)({
198
+ padding: typeof stayInFrame === "object" ? stayInFrame.padding : 10,
199
+ apply({ availableHeight, availableWidth }) {
200
+ if (passThrough) return;
201
+ Object.assign(floatingStyle.current, {
202
+ maxHeight: `${availableHeight}px`,
203
+ maxWidth: `${availableWidth}px`
204
+ });
205
+ const floatingChild = floating.refs.floating.current?.firstChild;
206
+ if (floatingChild && floatingChild instanceof HTMLElement) Object.assign(floatingChild.style, floatingStyle.current);
207
+ },
208
+ ...typeof resize === "object" && resize
209
+ }) : null,
210
+ (0, import_floating2.size)({ apply({ elements, rects, availableWidth, availableHeight }) {
211
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
212
+ const contentStyle = elements.floating.style;
213
+ contentStyle.setProperty("--tamagui-popper-available-width", `${availableWidth}px`);
214
+ contentStyle.setProperty("--tamagui-popper-available-height", `${availableHeight}px`);
215
+ contentStyle.setProperty("--tamagui-popper-anchor-width", `${anchorWidth}px`);
216
+ contentStyle.setProperty("--tamagui-popper-anchor-height", `${anchorHeight}px`);
217
+ } }),
218
+ transformOriginMiddleware({
219
+ arrowHeight: arrowSize,
220
+ arrowWidth: arrowSize
221
+ })
222
+ ].filter(Boolean);
223
+ let floating = (0, import_floating2.useFloating)({
224
+ open: isOpen,
225
+ strategy,
226
+ placement,
227
+ sameScrollView: false,
228
+ whileElementsMounted: !isOpen ? void 0 : tamaguiAutoUpdate,
229
+ platform: disableRTL ?? setupOptions.disableRTL ? {
230
+ ...import_floating2.platform,
231
+ isRTL(element) {
232
+ return false;
233
+ }
234
+ } : import_floating2.platform,
235
+ middleware: middlewareRef.current
236
+ });
237
+ floating = React.useMemo(() => {
238
+ const og = floating.getFloatingProps;
239
+ if (resize && og) floating.getFloatingProps = (props2) => {
240
+ return og({
241
+ ...props2,
242
+ style: {
243
+ ...props2.style,
244
+ ...floatingStyle.current
245
+ }
246
+ });
247
+ };
248
+ return floating;
249
+ }, [floating, resize ? JSON.stringify(resize) : null]);
250
+ const { middlewareData } = floating;
251
+ (0, import_useRepositionOnNative.useRepositionOnNative)(floating.update, passThrough);
252
+ const popperContext = React.useMemo(() => {
253
+ return {
254
+ size,
255
+ arrowRef: setArrow,
256
+ arrowStyle: middlewareData.arrow,
257
+ onArrowSize: setArrowSize,
258
+ hasFloating: middlewareData.checkFloating?.hasFloating,
259
+ transformOrigin: middlewareData.transformOrigin,
260
+ open: !!open,
261
+ ...floating
262
+ };
263
+ }, [
264
+ open,
265
+ size,
266
+ floating,
267
+ JSON.stringify(middlewareData.arrow || null),
268
+ JSON.stringify(middlewareData.transformOrigin || null)
269
+ ]);
270
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperProvider, {
271
+ scope,
272
+ ...popperContext,
273
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, {
274
+ value: null,
275
+ children
276
+ })
277
+ });
325
278
  }
326
- const PopperAnchor = import_stacks.YStack.styleable(function PopperAnchor2(props, forwardedRef) {
327
- const {
328
- virtualRef,
329
- scope,
330
- ...rest
331
- } = props;
332
- const context = usePopperContextSlow(scope);
333
- const {
334
- getReferenceProps,
335
- refs,
336
- update
337
- } = context;
338
- const ref = React.useRef(null);
339
- const triggerId = React.useId();
340
- React.useEffect(() => {
341
- if (!scope || !context.triggerElements || !ref.current) return;
342
- if (!(ref.current instanceof Element)) return;
343
- const el = ref.current;
344
- context.triggerElements.add(triggerId, el);
345
- return () => {
346
- context.triggerElements?.delete(triggerId);
347
- };
348
- }, [scope, triggerId, context.triggerElements]);
349
- React.useEffect(() => {
350
- if (virtualRef) {
351
- refs.setReference(virtualRef.current);
352
- update();
353
- }
354
- }, [virtualRef]);
355
- const refProps = getReferenceProps?.({
356
- ...rest,
357
- ref
358
- }) || null;
359
- const safeSetReference = React.useCallback(node => {
360
- (0, import_start_transition.startTransition)(() => {
361
- refs.setReference(node);
362
- });
363
- },
364
- // it was refs.setRefernce but its stable and refs is undefined on server
365
- [refs]);
366
- const shouldHandleInHover = import_constants.isWeb && scope;
367
- const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref,
368
- // web handles this onMouseEnter below so it can support multiple targets + hovering
369
- shouldHandleInHover ? void 0 : safeSetReference);
370
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
371
- ...rest,
372
- ...refProps,
373
- ref: composedRefs,
374
- ...(shouldHandleInHover && {
375
- onMouseEnter: e => {
376
- const el = e.currentTarget ?? ref.current;
377
- if (el instanceof HTMLElement) {
378
- (0, import_react_dom.flushSync)(() => refs.setReference(el));
379
- update();
380
- if (!refProps) return;
381
- refProps.onPointerEnter?.(e);
382
- context.onHoverReference?.(e.nativeEvent);
383
- }
384
- },
385
- onMouseLeave: e => {
386
- context.onLeaveReference?.();
387
- refProps?.onMouseLeave?.(e);
388
- }
389
- })
390
- });
279
+ const PopperAnchor = (0, import_core.createStyledHOC)(import_core.View, function PopperAnchor2(props, forwardedRef) {
280
+ const { virtualRef, scope, ...rest } = props;
281
+ const context = usePopperContextSlow(scope);
282
+ const { getReferenceProps, refs, update } = context;
283
+ const ref = React.useRef(null);
284
+ const triggerId = React.useId();
285
+ React.useEffect(() => {
286
+ if (!scope || !context.triggerElements || !ref.current) return;
287
+ if (!(ref.current instanceof Element)) return;
288
+ const el = ref.current;
289
+ context.triggerElements.add(triggerId, el);
290
+ return () => {
291
+ context.triggerElements?.delete(triggerId);
292
+ };
293
+ }, [
294
+ scope,
295
+ triggerId,
296
+ context.triggerElements
297
+ ]);
298
+ React.useEffect(() => {
299
+ if (virtualRef) {
300
+ refs.setReference(virtualRef.current);
301
+ update();
302
+ }
303
+ }, [virtualRef]);
304
+ const refProps = getReferenceProps?.({
305
+ ...rest,
306
+ ref
307
+ }) || null;
308
+ const safeSetReference = React.useCallback((node) => {
309
+ (0, import_start_transition.startTransition)(() => {
310
+ refs.setReference(node);
311
+ });
312
+ }, [refs]);
313
+ const shouldHandleInHover = import_constants.isWeb && scope;
314
+ const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, shouldHandleInHover ? void 0 : safeSetReference);
315
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.View, {
316
+ ...rest,
317
+ ...refProps,
318
+ ref: composedRefs,
319
+ ...shouldHandleInHover && {
320
+ onMouseEnter: (e) => {
321
+ const el = e.currentTarget ?? ref.current;
322
+ if (el instanceof HTMLElement) {
323
+ (0, import_react_dom.flushSync)(() => refs.setReference(el));
324
+ update();
325
+ if (!refProps) return;
326
+ refProps.onPointerEnter?.(e);
327
+ context.onHoverReference?.(e.nativeEvent);
328
+ }
329
+ },
330
+ onMouseLeave: (e) => {
331
+ context.onLeaveReference?.();
332
+ refProps?.onMouseLeave?.(e);
333
+ }
334
+ }
335
+ });
391
336
  });
392
- const PopperContentFrame = (0, import_core.styled)(import_stacks.YStack, {
393
- name: "PopperContent",
394
- variants: {
395
- unstyled: {
396
- true: {}
397
- },
398
- size: {
399
- "...size": (val, {
400
- tokens
401
- }) => {
402
- return {
403
- padding: tokens.space[val],
404
- borderRadius: tokens.radius[val]
405
- };
406
- }
407
- }
408
- }
337
+ const PopperContentFrame = (0, import_core.styled)(import_core.View, { displayName: "PopperContent" });
338
+ const PopperContent = (0, import_core.createRefComponent)(function PopperContent2(props, forwardedRef) {
339
+ const isAnimatePosControlled = "animatePosition" in props;
340
+ const { scope, animatePosition, children, passThrough, ...rest } = props;
341
+ const animatePos = animatePosition;
342
+ const context = usePopperContext(scope);
343
+ const { strategy, placement, refs, x, y, getFloatingProps, isPositioned, transformOrigin, update } = context;
344
+ const updateRef = React.useRef(update);
345
+ updateRef.current = update;
346
+ const lastNodeRef = React.useRef(null);
347
+ const safeSetFloating = React.useCallback((node) => {
348
+ const isNewNode = node !== lastNodeRef.current;
349
+ if (node) {
350
+ lastNodeRef.current = node;
351
+ refs.setFloating(node);
352
+ if (!isNewNode) updateRef.current?.();
353
+ }
354
+ }, [refs.setFloating]);
355
+ React.useEffect(() => {
356
+ return () => {
357
+ const ourNode = lastNodeRef.current;
358
+ if (ourNode && refs.floating.current === ourNode) refs.setFloating(null);
359
+ lastNodeRef.current = null;
360
+ };
361
+ }, []);
362
+ const contentRefs = (0, import_compose_refs.useComposedRefs)(safeSetFloating, forwardedRef);
363
+ const [needsMeasure, setNeedsMeasure] = React.useState(animatePos);
364
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
365
+ if (needsMeasure && x && y) setNeedsMeasure(false);
366
+ }, [
367
+ needsMeasure,
368
+ animatePos,
369
+ x,
370
+ y
371
+ ]);
372
+ const hasBeenPositioned = React.useRef(false);
373
+ const lastGoodPosition = React.useRef({
374
+ x: 0,
375
+ y: 0
376
+ });
377
+ if (x !== 0 || y !== 0) {
378
+ lastGoodPosition.current = {
379
+ x,
380
+ y
381
+ };
382
+ if (isPositioned) hasBeenPositioned.current = true;
383
+ }
384
+ const brieflyZero = hasBeenPositioned.current && x === 0 && y === 0;
385
+ const effectiveX = brieflyZero ? lastGoodPosition.current.x : x;
386
+ const effectiveY = brieflyZero ? lastGoodPosition.current.y : y;
387
+ const hide = !hasBeenPositioned.current && effectiveX === 0 && effectiveY === 0;
388
+ const disableAnimationProp = animatePos === "even-when-repositioning" ? needsMeasure : !hasBeenPositioned.current && !isPositioned || needsMeasure;
389
+ const [disableAnimation, setDisableAnimation] = React.useState(disableAnimationProp);
390
+ React.useEffect(() => {
391
+ setDisableAnimation(disableAnimationProp);
392
+ }, [disableAnimationProp]);
393
+ const frameProps = {
394
+ ref: contentRefs,
395
+ ...hide ? {} : {
396
+ x: effectiveX || 0,
397
+ y: effectiveY || 0
398
+ },
399
+ top: 0,
400
+ left: 0,
401
+ position: strategy,
402
+ opacity: hide ? 0 : 1,
403
+ ...isAnimatePosControlled && {
404
+ transition: animatePos && !disableAnimation ? rest.transition : "none",
405
+ animatePresence: false
406
+ }
407
+ };
408
+ const { style, ...floatingProps } = getFloatingProps ? getFloatingProps(frameProps) : frameProps;
409
+ const transformOriginStyle = import_constants.isWeb && transformOrigin ? { transformOrigin: `${transformOrigin.x} ${transformOrigin.y}` } : void 0;
410
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
411
+ disable: !context.open,
412
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.View, {
413
+ passThrough,
414
+ ref: contentRefs,
415
+ direction: rest.direction,
416
+ ...passThrough ? null : floatingProps,
417
+ ...!passThrough && animatePos && { "data-popper-animate-position": "true" },
418
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperContentFrame, {
419
+ passThrough,
420
+ ...!passThrough && {
421
+ "data-placement": placement,
422
+ "data-strategy": strategy,
423
+ ...style,
424
+ ...transformOriginStyle,
425
+ ...rest
426
+ },
427
+ children
428
+ }, "popper-content-frame")
429
+ })
430
+ });
409
431
  });
410
- const PopperContent = React.forwardRef(function PopperContent2(props, forwardedRef) {
411
- const isAnimatePosControlled = "animatePosition" in props || "enableAnimationForPositionChange" in props;
412
- const {
413
- scope,
414
- animatePosition,
415
- enableAnimationForPositionChange,
416
- children,
417
- passThrough,
418
- unstyled,
419
- ...rest
420
- } = props;
421
- const animatePos = animatePosition ?? enableAnimationForPositionChange;
422
- const context = usePopperContext(scope);
423
- const {
424
- strategy,
425
- placement,
426
- refs,
427
- x,
428
- y,
429
- getFloatingProps,
430
- size,
431
- isPositioned,
432
- transformOrigin,
433
- update
434
- } = context;
435
- const updateRef = React.useRef(update);
436
- updateRef.current = update;
437
- const lastNodeRef = React.useRef(null);
438
- const safeSetFloating = React.useCallback(node => {
439
- const isNewNode = node !== lastNodeRef.current;
440
- if (node) {
441
- lastNodeRef.current = node;
442
- refs.setFloating(node);
443
- if (!isNewNode) updateRef.current?.();
444
- }
445
- }, [refs.setFloating]);
446
- React.useEffect(() => {
447
- return () => {
448
- const ourNode = lastNodeRef.current;
449
- if (ourNode && refs.floating.current === ourNode) refs.setFloating(null);
450
- lastNodeRef.current = null;
451
- };
452
- }, []);
453
- const contentRefs = (0, import_compose_refs.useComposedRefs)(safeSetFloating, forwardedRef);
454
- const [needsMeasure, setNeedsMeasure] = React.useState(animatePos);
455
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
456
- if (needsMeasure && x && y) setNeedsMeasure(false);
457
- }, [needsMeasure, animatePos, x, y]);
458
- const hasBeenPositioned = React.useRef(false);
459
- const lastGoodPosition = React.useRef({
460
- x: 0,
461
- y: 0
462
- });
463
- if (x !== 0 || y !== 0) {
464
- lastGoodPosition.current = {
465
- x,
466
- y
467
- };
468
- if (isPositioned) hasBeenPositioned.current = true;
469
- }
470
- const brieflyZero = hasBeenPositioned.current && x === 0 && y === 0;
471
- const effectiveX = brieflyZero ? lastGoodPosition.current.x : x;
472
- const effectiveY = brieflyZero ? lastGoodPosition.current.y : y;
473
- const hide = !hasBeenPositioned.current && effectiveX === 0 && effectiveY === 0;
474
- const disableAnimationProp = animatePos === "even-when-repositioning" ? needsMeasure : !hasBeenPositioned.current && !isPositioned || needsMeasure;
475
- const [disableAnimation, setDisableAnimation] = React.useState(disableAnimationProp);
476
- React.useEffect(() => {
477
- setDisableAnimation(disableAnimationProp);
478
- }, [disableAnimationProp]);
479
- const frameProps = {
480
- ref: contentRefs,
481
- ...(hide ? {} : {
482
- x: effectiveX || 0,
483
- y: effectiveY || 0
484
- }),
485
- top: 0,
486
- left: 0,
487
- position: strategy,
488
- opacity: hide ? 0 : 1,
489
- ...(isAnimatePosControlled && {
490
- transition: animatePos ? rest.transition : void 0,
491
- animateOnly: animatePos && !disableAnimation ? rest.animateOnly : [],
492
- animatePresence: false
493
- })
494
- };
495
- const {
496
- style,
497
- ...floatingProps
498
- } = getFloatingProps ? getFloatingProps(frameProps) : frameProps;
499
- const transformOriginStyle = import_constants.isWeb && transformOrigin ? {
500
- transformOrigin: `${transformOrigin.x} ${transformOrigin.y}`
501
- } : void 0;
502
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
503
- disable: !context.open,
504
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
505
- passThrough,
506
- ref: contentRefs,
507
- direction: rest.direction,
508
- ...(passThrough ? null : floatingProps),
509
- ...(!passThrough && animatePos && {
510
- "data-popper-animate-position": "true"
511
- }),
512
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperContentFrame, {
513
- passThrough,
514
- unstyled,
515
- ...(!passThrough && {
516
- "data-placement": placement,
517
- "data-strategy": strategy,
518
- size,
519
- ...style,
520
- ...transformOriginStyle,
521
- ...rest
522
- }),
523
- children
524
- }, "popper-content-frame")
525
- })
526
- });
432
+ const PopperArrowFrame = (0, import_core.styled)(import_core.View, {
433
+ displayName: "PopperArrow",
434
+ position: "relative"
527
435
  });
528
- const PopperArrowFrame = (0, import_core.styled)(import_stacks.YStack, {
529
- name: "PopperArrow",
530
- variants: {
531
- unstyled: {
532
- false: {
533
- borderColor: "$borderColor",
534
- backgroundColor: "$background",
535
- position: "relative"
536
- }
537
- }
538
- },
539
- defaultVariants: {
540
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
541
- }
542
- });
543
- const PopperArrowOuterFrame = (0, import_core.styled)(import_stacks.YStack, {
544
- name: "PopperArrowOuter",
545
- variants: {
546
- unstyled: {
547
- false: {
548
- position: "absolute",
549
- zIndex: 1e6,
550
- pointerEvents: "none",
551
- overflow: "hidden",
552
- alignItems: "center",
553
- justifyContent: "center"
554
- }
555
- }
556
- },
557
- defaultVariants: {
558
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
559
- }
436
+ const PopperArrowOuterFrame = (0, import_core.styled)(import_core.View, {
437
+ displayName: "PopperArrowOuter",
438
+ position: "absolute",
439
+ zIndex: 1e6,
440
+ pointerEvents: "none",
441
+ overflow: "hidden",
442
+ alignItems: "center",
443
+ justifyContent: "center"
560
444
  });
561
445
  const opposites = {
562
- top: "bottom",
563
- right: "left",
564
- bottom: "top",
565
- left: "right"
446
+ top: "bottom",
447
+ right: "left",
448
+ bottom: "top",
449
+ left: "right"
566
450
  };
567
- const PopperArrow = React.forwardRef(function PopperArrow2(propsIn, forwardedRef) {
568
- const isAnimatePosControlled = "animatePosition" in propsIn;
569
- const {
570
- scope,
571
- animatePosition,
572
- transition,
573
- ...rest
574
- } = propsIn;
575
- const {
576
- offset,
577
- size: sizeProp,
578
- borderWidth = 0,
579
- ...arrowProps
580
- } = rest;
581
- const context = usePopperContext(scope);
582
- const sizeVal = typeof sizeProp === "number" ? sizeProp : (0, import_core.getVariableValue)((0, import_get_token.getSpace)(sizeProp ?? context.size, {
583
- shift: -2,
584
- bounds: [2]
585
- }));
586
- const size = Math.max(0, +sizeVal);
587
- const {
588
- placement
589
- } = context;
590
- const refs = (0, import_compose_refs.useComposedRefs)(context.arrowRef, forwardedRef);
591
- const x = context.arrowStyle?.x || 0;
592
- const y = context.arrowStyle?.y || 0;
593
- const arrowPositioned = context.arrowStyle != null;
594
- const primaryPlacement = placement ? placement.split("-")[0] : "top";
595
- const arrowStyle = {
596
- x,
597
- y,
598
- width: size,
599
- height: size
600
- };
601
- const innerArrowStyle = {};
602
- const isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
603
- if (primaryPlacement) {
604
- arrowStyle[isVertical ? "width" : "height"] = size * 2;
605
- const oppSide = opposites[primaryPlacement];
606
- if (oppSide) {
607
- arrowStyle[oppSide] = -size;
608
- innerArrowStyle[oppSide] = size / 2;
609
- }
610
- if (oppSide === "top" || oppSide === "bottom") arrowStyle.left = 0;
611
- if (oppSide === "left" || oppSide === "right") arrowStyle.top = 0;
612
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
613
- context.onArrowSize?.(size);
614
- }, [size, context.onArrowSize]);
615
- }
616
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperArrowOuterFrame, {
617
- ref: refs,
618
- ...arrowStyle,
619
- ...(!arrowPositioned && {
620
- opacity: 0
621
- }),
622
- ...(isAnimatePosControlled && {
623
- transition: animatePosition ? transition : void 0,
624
- animateOnly: animatePosition ? ["transform"] : [],
625
- animatePresence: false
626
- }),
627
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperArrowFrame, {
628
- width: size,
629
- height: size,
630
- ...arrowProps,
631
- ...innerArrowStyle,
632
- rotate: "45deg",
633
- ...(primaryPlacement === "bottom" && {
634
- borderLeftWidth: borderWidth,
635
- borderTopWidth: borderWidth
636
- }),
637
- ...(primaryPlacement === "top" && {
638
- borderBottomWidth: borderWidth,
639
- borderRightWidth: borderWidth
640
- }),
641
- ...(primaryPlacement === "right" && {
642
- borderLeftWidth: borderWidth,
643
- borderBottomWidth: borderWidth
644
- }),
645
- ...(primaryPlacement === "left" && {
646
- borderTopWidth: borderWidth,
647
- borderRightWidth: borderWidth
648
- })
649
- })
650
- });
651
- });
451
+ const PopperArrow = (0, import_core.createRefComponent)(function PopperArrow2(propsIn, forwardedRef) {
452
+ const isAnimatePosControlled = "animatePosition" in propsIn;
453
+ const { scope, animatePosition, transition, ...rest } = propsIn;
454
+ const { offset, size: sizeProp, borderWidth = 0, ...arrowProps } = rest;
455
+ const context = usePopperContext(scope);
456
+ const sizeVal = typeof sizeProp === "number" ? sizeProp : (0, import_core.getVariableValue)((0, import_get_token.getSize)(sizeProp ?? context.size ?? true)) * .52 - 11.5;
457
+ const size = Math.max(0, +sizeVal);
458
+ const { placement } = context;
459
+ const refs = (0, import_compose_refs.useComposedRefs)(context.arrowRef, forwardedRef);
460
+ const x = context.arrowStyle?.x || 0;
461
+ const y = context.arrowStyle?.y || 0;
462
+ const arrowPositioned = context.arrowStyle != null;
463
+ const primaryPlacement = placement ? placement.split("-")[0] : "top";
464
+ const arrowStyle = {
465
+ x,
466
+ y,
467
+ width: size,
468
+ height: size
469
+ };
470
+ const innerArrowStyle = {};
471
+ const isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
472
+ if (primaryPlacement) {
473
+ arrowStyle[isVertical ? "width" : "height"] = size * 2;
474
+ const oppSide = opposites[primaryPlacement];
475
+ if (oppSide) {
476
+ arrowStyle[oppSide] = -size;
477
+ innerArrowStyle[oppSide] = size / 2;
478
+ }
479
+ if (oppSide === "top" || oppSide === "bottom") arrowStyle.left = 0;
480
+ if (oppSide === "left" || oppSide === "right") arrowStyle.top = 0;
481
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
482
+ context.onArrowSize?.(size);
483
+ }, [size, context.onArrowSize]);
484
+ }
485
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperArrowOuterFrame, {
486
+ ref: refs,
487
+ ...arrowStyle,
488
+ ...!arrowPositioned && { opacity: 0 },
489
+ ...isAnimatePosControlled && {
490
+ transition: animatePosition ? { transform: transition } : "none",
491
+ animatePresence: false
492
+ },
493
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperArrowFrame, {
494
+ width: size,
495
+ height: size,
496
+ ...arrowProps,
497
+ ...innerArrowStyle,
498
+ rotate: "45deg",
499
+ ...primaryPlacement === "bottom" && {
500
+ borderLeftWidth: borderWidth,
501
+ borderTopWidth: borderWidth
502
+ },
503
+ ...primaryPlacement === "top" && {
504
+ borderBottomWidth: borderWidth,
505
+ borderRightWidth: borderWidth
506
+ },
507
+ ...primaryPlacement === "right" && {
508
+ borderLeftWidth: borderWidth,
509
+ borderBottomWidth: borderWidth
510
+ },
511
+ ...primaryPlacement === "left" && {
512
+ borderTopWidth: borderWidth,
513
+ borderRightWidth: borderWidth
514
+ }
515
+ })
516
+ });
517
+ });