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