@tamagui/popper 1.61.3 → 1.62.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.js +67 -141
- package/dist/cjs/Popper.js.map +2 -2
- package/dist/cjs/Popper.native.js +251 -0
- package/dist/cjs/Popper.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +20 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/esm/Popper.js +60 -121
- package/dist/esm/Popper.js.map +2 -2
- package/dist/jsx/Popper.js +55 -114
- package/dist/jsx/Popper.js.map +2 -2
- package/dist/jsx/Popper.native.js +228 -0
- package/dist/jsx/Popper.native.js.map +6 -0
- package/dist/jsx/index.native.js +2 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/package.json +8 -8
package/dist/cjs/index.js.map
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var src_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(src_exports);
|
|
15
|
+
__reExport(src_exports, require("./Popper"), module.exports);
|
|
16
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
17
|
+
0 && (module.exports = {
|
|
18
|
+
...require("./Popper")
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/dist/esm/Popper.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
2
|
import {
|
|
4
3
|
View as TamaguiView,
|
|
@@ -21,8 +20,8 @@ import { getSpace } from "@tamagui/get-token";
|
|
|
21
20
|
import { ThemeableStack, YStack } from "@tamagui/stacks";
|
|
22
21
|
import * as React from "react";
|
|
23
22
|
import { Keyboard, useWindowDimensions } from "react-native";
|
|
24
|
-
|
|
25
|
-
const usePopperContext = () => React.useContext(PopperContext);
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
const PopperContext = createStyledContext({}), usePopperContext = () => React.useContext(PopperContext);
|
|
26
25
|
function Popper(props) {
|
|
27
26
|
const {
|
|
28
27
|
children,
|
|
@@ -32,61 +31,46 @@ function Popper(props) {
|
|
|
32
31
|
stayInFrame,
|
|
33
32
|
allowFlip,
|
|
34
33
|
offset
|
|
35
|
-
} = props;
|
|
36
|
-
const [isMounted, setIsMounted] = React.useState(false);
|
|
34
|
+
} = props, [isMounted, setIsMounted] = React.useState(!1);
|
|
37
35
|
useIsomorphicLayoutEffect(() => {
|
|
38
|
-
setIsMounted(
|
|
36
|
+
setIsMounted(!0);
|
|
39
37
|
}, []);
|
|
40
|
-
const [anchorRef, setAnchorRef] = React.useState()
|
|
41
|
-
const [arrowEl, setArrow] = React.useState(null);
|
|
42
|
-
const [arrowSize, setArrowSize] = React.useState(0);
|
|
43
|
-
const offsetOptions = offset ?? arrowSize;
|
|
44
|
-
const floating = useFloating({
|
|
38
|
+
const [anchorRef, setAnchorRef] = React.useState(), [arrowEl, setArrow] = React.useState(null), [arrowSize, setArrowSize] = React.useState(0), offsetOptions = offset ?? arrowSize, floating = useFloating({
|
|
45
39
|
strategy,
|
|
46
40
|
placement,
|
|
47
|
-
sameScrollView:
|
|
41
|
+
sameScrollView: !1,
|
|
48
42
|
// this only takes effect on native
|
|
49
43
|
middleware: [
|
|
50
|
-
stayInFrame ? shift(typeof stayInFrame
|
|
51
|
-
allowFlip ? flip(typeof allowFlip
|
|
44
|
+
stayInFrame ? shift(typeof stayInFrame == "boolean" ? {} : stayInFrame) : null,
|
|
45
|
+
allowFlip ? flip(typeof allowFlip == "boolean" ? {} : allowFlip) : null,
|
|
52
46
|
arrowEl ? arrow({ element: arrowEl }) : null,
|
|
53
|
-
typeof offsetOptions
|
|
47
|
+
typeof offsetOptions < "u" ? offsetFn(offsetOptions) : null
|
|
54
48
|
].filter(Boolean)
|
|
55
|
-
})
|
|
56
|
-
const {
|
|
49
|
+
}), {
|
|
57
50
|
refs,
|
|
58
51
|
middlewareData,
|
|
59
52
|
// @ts-expect-error this comes from Tooltip for example
|
|
60
53
|
open
|
|
61
54
|
} = floating;
|
|
62
|
-
useIsomorphicLayoutEffect(() => {
|
|
55
|
+
if (useIsomorphicLayoutEffect(() => {
|
|
63
56
|
floating.refs.setReference(anchorRef);
|
|
64
|
-
}, [anchorRef])
|
|
65
|
-
if (isWeb) {
|
|
57
|
+
}, [anchorRef]), isWeb)
|
|
66
58
|
useIsomorphicLayoutEffect(() => {
|
|
67
|
-
if (
|
|
68
|
-
return;
|
|
69
|
-
if (!(refs.reference.current && refs.floating.current)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
|
|
59
|
+
if (open && refs.reference.current && refs.floating.current)
|
|
60
|
+
return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
|
|
73
61
|
}, [open, floating.update, refs.floating, refs.reference]);
|
|
74
|
-
|
|
75
|
-
const dimensions = useWindowDimensions();
|
|
76
|
-
const [keyboardOpen, setKeyboardOpen] = React.useState(false);
|
|
62
|
+
else {
|
|
63
|
+
const dimensions = useWindowDimensions(), [keyboardOpen, setKeyboardOpen] = React.useState(!1);
|
|
77
64
|
React.useEffect(() => {
|
|
78
65
|
const showSubscription = Keyboard.addListener("keyboardDidShow", () => {
|
|
79
|
-
setKeyboardOpen(
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
setKeyboardOpen(false);
|
|
66
|
+
setKeyboardOpen(!0);
|
|
67
|
+
}), hideSubscription = Keyboard.addListener("keyboardDidHide", () => {
|
|
68
|
+
setKeyboardOpen(!1);
|
|
83
69
|
});
|
|
84
70
|
return () => {
|
|
85
|
-
showSubscription.remove();
|
|
86
|
-
hideSubscription.remove();
|
|
71
|
+
showSubscription.remove(), hideSubscription.remove();
|
|
87
72
|
};
|
|
88
|
-
}, [])
|
|
89
|
-
useIsomorphicLayoutEffect(() => {
|
|
73
|
+
}, []), useIsomorphicLayoutEffect(() => {
|
|
90
74
|
floating.update();
|
|
91
75
|
}, [dimensions, keyboardOpen]);
|
|
92
76
|
}
|
|
@@ -102,14 +86,10 @@ function Popper(props) {
|
|
|
102
86
|
return /* @__PURE__ */ jsx(PopperContext.Provider, { ...popperContext, children });
|
|
103
87
|
}
|
|
104
88
|
const PopperAnchor = YStack.extractable(
|
|
105
|
-
React.forwardRef(function
|
|
106
|
-
const { virtualRef, ...anchorProps } = props;
|
|
107
|
-
|
|
108
|
-
const ref = React.useRef(null);
|
|
109
|
-
const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
|
|
110
|
-
if (virtualRef) {
|
|
89
|
+
React.forwardRef(function(props, forwardedRef) {
|
|
90
|
+
const { virtualRef, ...anchorProps } = props, { anchorRef, getReferenceProps } = usePopperContext(), ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
|
|
91
|
+
if (virtualRef)
|
|
111
92
|
return null;
|
|
112
|
-
}
|
|
113
93
|
const stackProps = {
|
|
114
94
|
ref: composedRefs,
|
|
115
95
|
...anchorProps
|
|
@@ -121,8 +101,7 @@ const PopperAnchor = YStack.extractable(
|
|
|
121
101
|
}
|
|
122
102
|
);
|
|
123
103
|
})
|
|
124
|
-
)
|
|
125
|
-
const PopperContentFrame = styled(ThemeableStack, {
|
|
104
|
+
), PopperContentFrame = styled(ThemeableStack, {
|
|
126
105
|
name: "PopperContent",
|
|
127
106
|
variants: {
|
|
128
107
|
unstyled: {
|
|
@@ -130,47 +109,36 @@ const PopperContentFrame = styled(ThemeableStack, {
|
|
|
130
109
|
size: "$true",
|
|
131
110
|
backgroundColor: "$background",
|
|
132
111
|
alignItems: "center",
|
|
133
|
-
radiused:
|
|
112
|
+
radiused: !0
|
|
134
113
|
}
|
|
135
114
|
},
|
|
136
115
|
size: {
|
|
137
|
-
"...size": (val, { tokens }) => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
}
|
|
116
|
+
"...size": (val, { tokens }) => ({
|
|
117
|
+
padding: tokens.space[val],
|
|
118
|
+
borderRadius: tokens.radius[val]
|
|
119
|
+
})
|
|
143
120
|
}
|
|
144
121
|
},
|
|
145
122
|
defaultVariants: {
|
|
146
|
-
unstyled:
|
|
123
|
+
unstyled: !1
|
|
147
124
|
}
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
);
|
|
165
|
-
}, [placement, strategy, props]);
|
|
166
|
-
useIsomorphicLayoutEffect(() => {
|
|
167
|
-
if (isMounted) {
|
|
168
|
-
update();
|
|
169
|
-
}
|
|
170
|
-
}, [isMounted]);
|
|
171
|
-
if (!isMounted) {
|
|
125
|
+
}), PopperContent = React.forwardRef(
|
|
126
|
+
function(props, forwardedRef) {
|
|
127
|
+
const { strategy, placement, refs, x, y, getFloatingProps, size, isMounted, update } = usePopperContext(), contentRefs = useComposedRefs(refs.setFloating, forwardedRef), contents = React.useMemo(() => /* @__PURE__ */ jsx(
|
|
128
|
+
PopperContentFrame,
|
|
129
|
+
{
|
|
130
|
+
"data-placement": placement,
|
|
131
|
+
"data-strategy": strategy,
|
|
132
|
+
contain: "layout",
|
|
133
|
+
size,
|
|
134
|
+
...props
|
|
135
|
+
},
|
|
136
|
+
"popper-content-frame"
|
|
137
|
+
), [placement, strategy, props]);
|
|
138
|
+
if (useIsomorphicLayoutEffect(() => {
|
|
139
|
+
isMounted && update();
|
|
140
|
+
}, [isMounted]), !isMounted)
|
|
172
141
|
return null;
|
|
173
|
-
}
|
|
174
142
|
const frameProps = {
|
|
175
143
|
ref: contentRefs,
|
|
176
144
|
x: x || 0,
|
|
@@ -179,8 +147,7 @@ const PopperContent = React.forwardRef(
|
|
|
179
147
|
};
|
|
180
148
|
return /* @__PURE__ */ jsx(YStack, { ...getFloatingProps ? getFloatingProps(frameProps) : frameProps, children: contents });
|
|
181
149
|
}
|
|
182
|
-
)
|
|
183
|
-
const PopperArrowFrame = styled(YStack, {
|
|
150
|
+
), PopperArrowFrame = styled(YStack, {
|
|
184
151
|
name: "PopperArrow",
|
|
185
152
|
variants: {
|
|
186
153
|
unstyled: {
|
|
@@ -192,10 +159,9 @@ const PopperArrowFrame = styled(YStack, {
|
|
|
192
159
|
}
|
|
193
160
|
},
|
|
194
161
|
defaultVariants: {
|
|
195
|
-
unstyled:
|
|
162
|
+
unstyled: !1
|
|
196
163
|
}
|
|
197
|
-
})
|
|
198
|
-
const PopperArrowOuterFrame = styled(YStack, {
|
|
164
|
+
}), PopperArrowOuterFrame = styled(YStack, {
|
|
199
165
|
name: "PopperArrowOuter",
|
|
200
166
|
variants: {
|
|
201
167
|
unstyled: {
|
|
@@ -210,56 +176,29 @@ const PopperArrowOuterFrame = styled(YStack, {
|
|
|
210
176
|
}
|
|
211
177
|
},
|
|
212
178
|
defaultVariants: {
|
|
213
|
-
unstyled:
|
|
179
|
+
unstyled: !1
|
|
214
180
|
}
|
|
215
|
-
})
|
|
216
|
-
const opposites = {
|
|
181
|
+
}), opposites = {
|
|
217
182
|
top: "bottom",
|
|
218
183
|
right: "left",
|
|
219
184
|
bottom: "top",
|
|
220
185
|
left: "right"
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
var _a, _b;
|
|
225
|
-
const props = useProps(propsIn);
|
|
226
|
-
const { offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
|
|
227
|
-
const context = usePopperContext();
|
|
228
|
-
const sizeVal = sizeProp ?? context.size;
|
|
229
|
-
const sizeValResolved = getVariableValue(
|
|
186
|
+
}, PopperArrow = PopperArrowFrame.styleable(
|
|
187
|
+
function(propsIn, forwardedRef) {
|
|
188
|
+
const props = useProps(propsIn), { offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props, context = usePopperContext(), sizeVal = sizeProp ?? context.size, size = +getVariableValue(
|
|
230
189
|
getSpace(sizeVal, {
|
|
231
190
|
shift: -2,
|
|
232
191
|
bounds: [2]
|
|
233
192
|
})
|
|
234
|
-
);
|
|
235
|
-
const size = +sizeValResolved;
|
|
236
|
-
const { placement } = context;
|
|
237
|
-
const refs = useComposedRefs(context.arrowRef, forwardedRef);
|
|
238
|
-
const x = ((_a = context.arrowStyle) == null ? void 0 : _a.x) || 0;
|
|
239
|
-
const y = ((_b = context.arrowStyle) == null ? void 0 : _b.y) || 0;
|
|
240
|
-
const primaryPlacement = placement ? placement.split("-")[0] : "top";
|
|
241
|
-
const arrowStyle = { x, y, width: size, height: size };
|
|
242
|
-
const innerArrowStyle = {};
|
|
243
|
-
const isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
|
|
193
|
+
), { placement } = context, refs = useComposedRefs(context.arrowRef, forwardedRef), x = context.arrowStyle?.x || 0, y = context.arrowStyle?.y || 0, primaryPlacement = placement ? placement.split("-")[0] : "top", arrowStyle = { x, y, width: size, height: size }, innerArrowStyle = {}, isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
|
|
244
194
|
if (primaryPlacement) {
|
|
245
195
|
arrowStyle[isVertical ? "width" : "height"] = size * 2;
|
|
246
196
|
const oppSide = opposites[primaryPlacement];
|
|
247
|
-
|
|
248
|
-
arrowStyle[oppSide] = -size;
|
|
249
|
-
innerArrowStyle[oppSide] = size / 2;
|
|
250
|
-
}
|
|
251
|
-
if (oppSide === "top" || oppSide === "bottom") {
|
|
252
|
-
arrowStyle.left = 0;
|
|
253
|
-
}
|
|
254
|
-
if (oppSide === "left" || oppSide === "right") {
|
|
255
|
-
arrowStyle.top = 0;
|
|
256
|
-
}
|
|
197
|
+
oppSide && (arrowStyle[oppSide] = -size, innerArrowStyle[oppSide] = size / 2), (oppSide === "top" || oppSide === "bottom") && (arrowStyle.left = 0), (oppSide === "left" || oppSide === "right") && (arrowStyle.top = 0);
|
|
257
198
|
}
|
|
258
|
-
useIsomorphicLayoutEffect(() => {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}, [size, context.onArrowSize]);
|
|
262
|
-
return /* @__PURE__ */ jsx(PopperArrowOuterFrame, { ref: refs, ...arrowStyle, children: /* @__PURE__ */ jsx(
|
|
199
|
+
return useIsomorphicLayoutEffect(() => {
|
|
200
|
+
context.onArrowSize?.(size);
|
|
201
|
+
}, [size, context.onArrowSize]), /* @__PURE__ */ jsx(PopperArrowOuterFrame, { ref: refs, ...arrowStyle, children: /* @__PURE__ */ jsx(
|
|
263
202
|
PopperArrowFrame,
|
|
264
203
|
{
|
|
265
204
|
width: size,
|
package/dist/esm/Popper.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Popper.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": "AAEA,SAAS,uBAAuB;AAChC;AAAA,EAGE,QAAQ;AAAA,EACR;AAA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D,kBAA8B,CAAC,GAC/B,aAAa,qBAAqB,YAAY,qBAAqB;AAEzE,QAAI,kBAAkB;AAEpB,iBAAW,aAAa,UAAU,QAAQ,IAAI,OAAO;AACrD,YAAM,UAAU,UAAU,gBAAgB;AAC1C,MAAI,YACF,WAAW,OAAO,IAAI,CAAC,MACvB,gBAAgB,OAAO,IAAI,OAAO,KAEhC,YAAY,SAAS,YAAY,cACnC,WAAW,OAAO,KAEhB,YAAY,UAAU,YAAY,aACpC,WAAW,MAAM;AAAA,IAErB;AAGA,qCAA0B,MAAM;AAC9B,cAAQ,cAAc,IAAI;AAAA,IAC5B,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC,GAI5B,oBAAC,yBAAsB,KAAK,MAAO,GAAG,YACpC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,QAAQ;AAAA,QACP,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,QAAO;AAAA,QACN,GAAI,qBAAqB,YAAY;AAAA,UACpC,iBAAiB;AAAA,UACjB,gBAAgB;AAAA,QAClB;AAAA,QACC,GAAI,qBAAqB,SAAS;AAAA,UACjC,mBAAmB;AAAA,UACnB,kBAAkB;AAAA,QACpB;AAAA,QACC,GAAI,qBAAqB,WAAW;AAAA,UACnC,iBAAiB;AAAA,UACjB,mBAAmB;AAAA,QACrB;AAAA,QACC,GAAI,qBAAqB,UAAU;AAAA,UAClC,gBAAgB;AAAA,UAChB,kBAAkB;AAAA,QACpB;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;",
|
|
5
|
+
"names": []
|
|
6
6
|
}
|
package/dist/jsx/Popper.js
CHANGED
|
@@ -20,8 +20,7 @@ import { getSpace } from "@tamagui/get-token";
|
|
|
20
20
|
import { ThemeableStack, YStack } from "@tamagui/stacks";
|
|
21
21
|
import * as React from "react";
|
|
22
22
|
import { Keyboard, useWindowDimensions } from "react-native";
|
|
23
|
-
const PopperContext = createStyledContext({});
|
|
24
|
-
const usePopperContext = () => React.useContext(PopperContext);
|
|
23
|
+
const PopperContext = createStyledContext({}), usePopperContext = () => React.useContext(PopperContext);
|
|
25
24
|
function Popper(props) {
|
|
26
25
|
const {
|
|
27
26
|
children,
|
|
@@ -31,61 +30,46 @@ function Popper(props) {
|
|
|
31
30
|
stayInFrame,
|
|
32
31
|
allowFlip,
|
|
33
32
|
offset
|
|
34
|
-
} = props;
|
|
35
|
-
const [isMounted, setIsMounted] = React.useState(false);
|
|
33
|
+
} = props, [isMounted, setIsMounted] = React.useState(!1);
|
|
36
34
|
useIsomorphicLayoutEffect(() => {
|
|
37
|
-
setIsMounted(
|
|
35
|
+
setIsMounted(!0);
|
|
38
36
|
}, []);
|
|
39
|
-
const [anchorRef, setAnchorRef] = React.useState()
|
|
40
|
-
const [arrowEl, setArrow] = React.useState(null);
|
|
41
|
-
const [arrowSize, setArrowSize] = React.useState(0);
|
|
42
|
-
const offsetOptions = offset ?? arrowSize;
|
|
43
|
-
const floating = useFloating({
|
|
37
|
+
const [anchorRef, setAnchorRef] = React.useState(), [arrowEl, setArrow] = React.useState(null), [arrowSize, setArrowSize] = React.useState(0), offsetOptions = offset ?? arrowSize, floating = useFloating({
|
|
44
38
|
strategy,
|
|
45
39
|
placement,
|
|
46
|
-
sameScrollView:
|
|
40
|
+
sameScrollView: !1,
|
|
47
41
|
// this only takes effect on native
|
|
48
42
|
middleware: [
|
|
49
|
-
stayInFrame ? shift(typeof stayInFrame
|
|
50
|
-
allowFlip ? flip(typeof allowFlip
|
|
43
|
+
stayInFrame ? shift(typeof stayInFrame == "boolean" ? {} : stayInFrame) : null,
|
|
44
|
+
allowFlip ? flip(typeof allowFlip == "boolean" ? {} : allowFlip) : null,
|
|
51
45
|
arrowEl ? arrow({ element: arrowEl }) : null,
|
|
52
|
-
typeof offsetOptions
|
|
46
|
+
typeof offsetOptions < "u" ? offsetFn(offsetOptions) : null
|
|
53
47
|
].filter(Boolean)
|
|
54
|
-
})
|
|
55
|
-
const {
|
|
48
|
+
}), {
|
|
56
49
|
refs,
|
|
57
50
|
middlewareData,
|
|
58
51
|
// @ts-expect-error this comes from Tooltip for example
|
|
59
52
|
open
|
|
60
53
|
} = floating;
|
|
61
|
-
useIsomorphicLayoutEffect(() => {
|
|
54
|
+
if (useIsomorphicLayoutEffect(() => {
|
|
62
55
|
floating.refs.setReference(anchorRef);
|
|
63
|
-
}, [anchorRef])
|
|
64
|
-
if (isWeb) {
|
|
56
|
+
}, [anchorRef]), isWeb)
|
|
65
57
|
useIsomorphicLayoutEffect(() => {
|
|
66
|
-
if (
|
|
67
|
-
return;
|
|
68
|
-
if (!(refs.reference.current && refs.floating.current)) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
|
|
58
|
+
if (open && refs.reference.current && refs.floating.current)
|
|
59
|
+
return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
|
|
72
60
|
}, [open, floating.update, refs.floating, refs.reference]);
|
|
73
|
-
|
|
74
|
-
const dimensions = useWindowDimensions();
|
|
75
|
-
const [keyboardOpen, setKeyboardOpen] = React.useState(false);
|
|
61
|
+
else {
|
|
62
|
+
const dimensions = useWindowDimensions(), [keyboardOpen, setKeyboardOpen] = React.useState(!1);
|
|
76
63
|
React.useEffect(() => {
|
|
77
64
|
const showSubscription = Keyboard.addListener("keyboardDidShow", () => {
|
|
78
|
-
setKeyboardOpen(
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
setKeyboardOpen(false);
|
|
65
|
+
setKeyboardOpen(!0);
|
|
66
|
+
}), hideSubscription = Keyboard.addListener("keyboardDidHide", () => {
|
|
67
|
+
setKeyboardOpen(!1);
|
|
82
68
|
});
|
|
83
69
|
return () => {
|
|
84
|
-
showSubscription.remove();
|
|
85
|
-
hideSubscription.remove();
|
|
70
|
+
showSubscription.remove(), hideSubscription.remove();
|
|
86
71
|
};
|
|
87
|
-
}, [])
|
|
88
|
-
useIsomorphicLayoutEffect(() => {
|
|
72
|
+
}, []), useIsomorphicLayoutEffect(() => {
|
|
89
73
|
floating.update();
|
|
90
74
|
}, [dimensions, keyboardOpen]);
|
|
91
75
|
}
|
|
@@ -101,14 +85,10 @@ function Popper(props) {
|
|
|
101
85
|
return <PopperContext.Provider {...popperContext}>{children}</PopperContext.Provider>;
|
|
102
86
|
}
|
|
103
87
|
const PopperAnchor = YStack.extractable(
|
|
104
|
-
React.forwardRef(function
|
|
105
|
-
const { virtualRef, ...anchorProps } = props;
|
|
106
|
-
|
|
107
|
-
const ref = React.useRef(null);
|
|
108
|
-
const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
|
|
109
|
-
if (virtualRef) {
|
|
88
|
+
React.forwardRef(function(props, forwardedRef) {
|
|
89
|
+
const { virtualRef, ...anchorProps } = props, { anchorRef, getReferenceProps } = usePopperContext(), ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
|
|
90
|
+
if (virtualRef)
|
|
110
91
|
return null;
|
|
111
|
-
}
|
|
112
92
|
const stackProps = {
|
|
113
93
|
ref: composedRefs,
|
|
114
94
|
...anchorProps
|
|
@@ -117,8 +97,7 @@ const PopperAnchor = YStack.extractable(
|
|
|
117
97
|
{...getReferenceProps ? getReferenceProps(stackProps) : stackProps}
|
|
118
98
|
/>;
|
|
119
99
|
})
|
|
120
|
-
)
|
|
121
|
-
const PopperContentFrame = styled(ThemeableStack, {
|
|
100
|
+
), PopperContentFrame = styled(ThemeableStack, {
|
|
122
101
|
name: "PopperContent",
|
|
123
102
|
variants: {
|
|
124
103
|
unstyled: {
|
|
@@ -126,44 +105,33 @@ const PopperContentFrame = styled(ThemeableStack, {
|
|
|
126
105
|
size: "$true",
|
|
127
106
|
backgroundColor: "$background",
|
|
128
107
|
alignItems: "center",
|
|
129
|
-
radiused:
|
|
108
|
+
radiused: !0
|
|
130
109
|
}
|
|
131
110
|
},
|
|
132
111
|
size: {
|
|
133
|
-
"...size": (val, { tokens }) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
}
|
|
112
|
+
"...size": (val, { tokens }) => ({
|
|
113
|
+
padding: tokens.space[val],
|
|
114
|
+
borderRadius: tokens.radius[val]
|
|
115
|
+
})
|
|
139
116
|
}
|
|
140
117
|
},
|
|
141
118
|
defaultVariants: {
|
|
142
|
-
unstyled:
|
|
119
|
+
unstyled: !1
|
|
143
120
|
}
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
/>;
|
|
158
|
-
}, [placement, strategy, props]);
|
|
159
|
-
useIsomorphicLayoutEffect(() => {
|
|
160
|
-
if (isMounted) {
|
|
161
|
-
update();
|
|
162
|
-
}
|
|
163
|
-
}, [isMounted]);
|
|
164
|
-
if (!isMounted) {
|
|
121
|
+
}), PopperContent = React.forwardRef(
|
|
122
|
+
function(props, forwardedRef) {
|
|
123
|
+
const { strategy, placement, refs, x, y, getFloatingProps, size, isMounted, update } = usePopperContext(), contentRefs = useComposedRefs(refs.setFloating, forwardedRef), contents = React.useMemo(() => <PopperContentFrame
|
|
124
|
+
key="popper-content-frame"
|
|
125
|
+
data-placement={placement}
|
|
126
|
+
data-strategy={strategy}
|
|
127
|
+
contain="layout"
|
|
128
|
+
size={size}
|
|
129
|
+
{...props}
|
|
130
|
+
/>, [placement, strategy, props]);
|
|
131
|
+
if (useIsomorphicLayoutEffect(() => {
|
|
132
|
+
isMounted && update();
|
|
133
|
+
}, [isMounted]), !isMounted)
|
|
165
134
|
return null;
|
|
166
|
-
}
|
|
167
135
|
const frameProps = {
|
|
168
136
|
ref: contentRefs,
|
|
169
137
|
x: x || 0,
|
|
@@ -172,8 +140,7 @@ const PopperContent = React.forwardRef(
|
|
|
172
140
|
};
|
|
173
141
|
return <YStack {...getFloatingProps ? getFloatingProps(frameProps) : frameProps}>{contents}</YStack>;
|
|
174
142
|
}
|
|
175
|
-
)
|
|
176
|
-
const PopperArrowFrame = styled(YStack, {
|
|
143
|
+
), PopperArrowFrame = styled(YStack, {
|
|
177
144
|
name: "PopperArrow",
|
|
178
145
|
variants: {
|
|
179
146
|
unstyled: {
|
|
@@ -185,10 +152,9 @@ const PopperArrowFrame = styled(YStack, {
|
|
|
185
152
|
}
|
|
186
153
|
},
|
|
187
154
|
defaultVariants: {
|
|
188
|
-
unstyled:
|
|
155
|
+
unstyled: !1
|
|
189
156
|
}
|
|
190
|
-
})
|
|
191
|
-
const PopperArrowOuterFrame = styled(YStack, {
|
|
157
|
+
}), PopperArrowOuterFrame = styled(YStack, {
|
|
192
158
|
name: "PopperArrowOuter",
|
|
193
159
|
variants: {
|
|
194
160
|
unstyled: {
|
|
@@ -203,54 +169,29 @@ const PopperArrowOuterFrame = styled(YStack, {
|
|
|
203
169
|
}
|
|
204
170
|
},
|
|
205
171
|
defaultVariants: {
|
|
206
|
-
unstyled:
|
|
172
|
+
unstyled: !1
|
|
207
173
|
}
|
|
208
|
-
})
|
|
209
|
-
const opposites = {
|
|
174
|
+
}), opposites = {
|
|
210
175
|
top: "bottom",
|
|
211
176
|
right: "left",
|
|
212
177
|
bottom: "top",
|
|
213
178
|
left: "right"
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const props = useProps(propsIn);
|
|
218
|
-
const { offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
|
|
219
|
-
const context = usePopperContext();
|
|
220
|
-
const sizeVal = sizeProp ?? context.size;
|
|
221
|
-
const sizeValResolved = getVariableValue(
|
|
179
|
+
}, PopperArrow = PopperArrowFrame.styleable(
|
|
180
|
+
function(propsIn, forwardedRef) {
|
|
181
|
+
const props = useProps(propsIn), { offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props, context = usePopperContext(), sizeVal = sizeProp ?? context.size, size = +getVariableValue(
|
|
222
182
|
getSpace(sizeVal, {
|
|
223
183
|
shift: -2,
|
|
224
184
|
bounds: [2]
|
|
225
185
|
})
|
|
226
|
-
);
|
|
227
|
-
const size = +sizeValResolved;
|
|
228
|
-
const { placement } = context;
|
|
229
|
-
const refs = useComposedRefs(context.arrowRef, forwardedRef);
|
|
230
|
-
const x = context.arrowStyle?.x || 0;
|
|
231
|
-
const y = context.arrowStyle?.y || 0;
|
|
232
|
-
const primaryPlacement = placement ? placement.split("-")[0] : "top";
|
|
233
|
-
const arrowStyle = { x, y, width: size, height: size };
|
|
234
|
-
const innerArrowStyle = {};
|
|
235
|
-
const isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
|
|
186
|
+
), { placement } = context, refs = useComposedRefs(context.arrowRef, forwardedRef), x = context.arrowStyle?.x || 0, y = context.arrowStyle?.y || 0, primaryPlacement = placement ? placement.split("-")[0] : "top", arrowStyle = { x, y, width: size, height: size }, innerArrowStyle = {}, isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
|
|
236
187
|
if (primaryPlacement) {
|
|
237
188
|
arrowStyle[isVertical ? "width" : "height"] = size * 2;
|
|
238
189
|
const oppSide = opposites[primaryPlacement];
|
|
239
|
-
|
|
240
|
-
arrowStyle[oppSide] = -size;
|
|
241
|
-
innerArrowStyle[oppSide] = size / 2;
|
|
242
|
-
}
|
|
243
|
-
if (oppSide === "top" || oppSide === "bottom") {
|
|
244
|
-
arrowStyle.left = 0;
|
|
245
|
-
}
|
|
246
|
-
if (oppSide === "left" || oppSide === "right") {
|
|
247
|
-
arrowStyle.top = 0;
|
|
248
|
-
}
|
|
190
|
+
oppSide && (arrowStyle[oppSide] = -size, innerArrowStyle[oppSide] = size / 2), (oppSide === "top" || oppSide === "bottom") && (arrowStyle.left = 0), (oppSide === "left" || oppSide === "right") && (arrowStyle.top = 0);
|
|
249
191
|
}
|
|
250
|
-
useIsomorphicLayoutEffect(() => {
|
|
192
|
+
return useIsomorphicLayoutEffect(() => {
|
|
251
193
|
context.onArrowSize?.(size);
|
|
252
|
-
}, [size, context.onArrowSize])
|
|
253
|
-
return <PopperArrowOuterFrame ref={refs} {...arrowStyle}><PopperArrowFrame
|
|
194
|
+
}, [size, context.onArrowSize]), <PopperArrowOuterFrame ref={refs} {...arrowStyle}><PopperArrowFrame
|
|
254
195
|
width={size}
|
|
255
196
|
height={size}
|
|
256
197
|
{...arrowProps}
|