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