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