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