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