@tamagui/popper 1.114.4 → 1.115.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.
@@ -0,0 +1,334 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var Popper_exports = {};
33
+ __export(Popper_exports, {
34
+ Popper: () => Popper,
35
+ PopperAnchor: () => PopperAnchor,
36
+ PopperArrow: () => PopperArrow,
37
+ PopperContent: () => PopperContent,
38
+ PopperContentFrame: () => PopperContentFrame,
39
+ PopperContext: () => PopperContext,
40
+ PopperProvider: () => PopperProvider,
41
+ setupPopper: () => setupPopper,
42
+ usePopperContext: () => usePopperContext
43
+ });
44
+ module.exports = __toCommonJS(Popper_exports);
45
+ var import_compose_refs = require("@tamagui/compose-refs"),
46
+ import_constants = require("@tamagui/constants"),
47
+ import_core = require("@tamagui/core"),
48
+ import_floating = require("@tamagui/floating"),
49
+ import_get_token = require("@tamagui/get-token"),
50
+ import_stacks = require("@tamagui/stacks"),
51
+ import_start_transition = require("@tamagui/start-transition"),
52
+ React = __toESM(require("react")),
53
+ import_react_native = require("react-native-web"),
54
+ import_jsx_runtime = require("react/jsx-runtime");
55
+ const PopperContext = (0, import_core.createStyledContext)({}),
56
+ {
57
+ useStyledContext: usePopperContext,
58
+ Provider: PopperProvider
59
+ } = PopperContext,
60
+ checkFloating = void 0,
61
+ setupOptions = {};
62
+ function setupPopper(options) {
63
+ Object.assign(setupOptions, options);
64
+ }
65
+ function Popper(props) {
66
+ const {
67
+ children,
68
+ size,
69
+ strategy = "absolute",
70
+ placement = "bottom",
71
+ stayInFrame,
72
+ allowFlip,
73
+ offset,
74
+ disableRTL,
75
+ __scopePopper
76
+ } = props,
77
+ [arrowEl, setArrow] = React.useState(null),
78
+ [arrowSize, setArrowSize] = React.useState(0),
79
+ offsetOptions = offset ?? arrowSize,
80
+ floating = (0, import_floating.useFloating)({
81
+ strategy,
82
+ placement,
83
+ sameScrollView: !1,
84
+ // this only takes effect on native
85
+ platform: disableRTL ?? setupOptions.disableRTL ? {
86
+ ...import_floating.platform,
87
+ isRTL(element) {
88
+ return !1;
89
+ }
90
+ } : import_floating.platform,
91
+ middleware: [stayInFrame ? (0, import_floating.shift)(typeof stayInFrame == "boolean" ? {} : stayInFrame) : null, allowFlip ? (0, import_floating.flip)(typeof allowFlip == "boolean" ? {} : allowFlip) : null, arrowEl ? (0, import_floating.arrow)({
92
+ element: arrowEl
93
+ }) : null, typeof offsetOptions < "u" ? (0, import_floating.offset)(offsetOptions) : null, checkFloating].filter(Boolean)
94
+ }),
95
+ {
96
+ refs,
97
+ middlewareData,
98
+ // @ts-expect-error this comes from Tooltip for example
99
+ open
100
+ } = floating;
101
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
102
+ if (open && refs.reference.current && refs.floating.current) return floating.update(), (0, import_floating.autoUpdate)(refs.reference.current, refs.floating.current, floating.update);
103
+ }, [open, floating.update, refs.floating, refs.reference]);
104
+ const popperContext = {
105
+ size,
106
+ arrowRef: setArrow,
107
+ arrowStyle: middlewareData.arrow,
108
+ onArrowSize: setArrowSize,
109
+ scope: __scopePopper,
110
+ hasFloating: middlewareData.checkFloating?.hasFloating,
111
+ ...floating
112
+ };
113
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperProvider, {
114
+ ...popperContext,
115
+ children
116
+ });
117
+ }
118
+ const PopperAnchor = import_stacks.YStack.extractable(React.forwardRef(function (props, forwardedRef) {
119
+ const {
120
+ virtualRef,
121
+ __scopePopper,
122
+ ...anchorProps
123
+ } = props,
124
+ {
125
+ getReferenceProps,
126
+ refs
127
+ } = usePopperContext(__scopePopper),
128
+ ref = React.useRef(null),
129
+ composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, refs.setReference);
130
+ React.useEffect(() => {
131
+ virtualRef && refs.setReference(virtualRef.current);
132
+ }, [virtualRef]);
133
+ const stackProps = {
134
+ ref: composedRefs,
135
+ ...anchorProps
136
+ };
137
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
138
+ ...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)
139
+ });
140
+ })),
141
+ PopperContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
142
+ name: "PopperContent",
143
+ variants: {
144
+ unstyled: {
145
+ false: {
146
+ size: "$true",
147
+ backgroundColor: "$background",
148
+ alignItems: "center",
149
+ radiused: !0
150
+ }
151
+ },
152
+ size: {
153
+ "...size": (val, {
154
+ tokens
155
+ }) => ({
156
+ padding: tokens.space[val],
157
+ borderRadius: tokens.radius[val]
158
+ })
159
+ }
160
+ },
161
+ defaultVariants: {
162
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
163
+ }
164
+ }),
165
+ PopperContent = React.forwardRef(function (props, forwardedRef) {
166
+ const {
167
+ __scopePopper,
168
+ enableAnimationForPositionChange,
169
+ ...rest
170
+ } = props,
171
+ {
172
+ strategy,
173
+ placement,
174
+ refs,
175
+ x,
176
+ y,
177
+ getFloatingProps,
178
+ size,
179
+ update,
180
+ floatingStyles,
181
+ hasFloating
182
+ } = usePopperContext(__scopePopper),
183
+ contentRefs = (0, import_compose_refs.useComposedRefs)(refs.setFloating, forwardedRef);
184
+ let finalHasFloatingValue = !1;
185
+ if (import_constants.isAndroid) {
186
+ const initialRender = React.useRef(!0),
187
+ finalHasFloating = React.useRef(!1);
188
+ hasFloating === !1 && (initialRender.current = !1), initialRender.current || (finalHasFloating.current = hasFloating), finalHasFloatingValue = finalHasFloating.current;
189
+ }
190
+ const contents = React.useMemo(() => /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperContentFrame, {
191
+ "data-placement": placement,
192
+ "data-strategy": strategy,
193
+ contain: "layout",
194
+ size,
195
+ ...rest
196
+ }, "popper-content-frame"), [placement, strategy, props]),
197
+ [needsMeasure, setNeedsMeasure] = React.useState(!0);
198
+ React.useEffect(() => {
199
+ enableAnimationForPositionChange && (x || y) && setNeedsMeasure(!1);
200
+ }, [enableAnimationForPositionChange, x, y]);
201
+ let show = !0;
202
+ if (import_constants.isAndroid) {
203
+ const [show_, setShow] = React.useState(!1);
204
+ show = show_, React.useEffect(() => {
205
+ finalHasFloatingValue && setShow(!0);
206
+ }, [finalHasFloatingValue, x, y]);
207
+ }
208
+ const frameProps = {
209
+ ref: contentRefs,
210
+ x: x || 0,
211
+ y: y || 0,
212
+ top: 0,
213
+ left: 0,
214
+ position: strategy,
215
+ opacity: show ? 1 : 0,
216
+ ...(enableAnimationForPositionChange && {
217
+ // apply animation but disable it on initial render to avoid animating from 0 to the first position
218
+ animation: rest.animation,
219
+ animateOnly: needsMeasure ? ["none"] : rest.animateOnly,
220
+ animatePresence: !1
221
+ })
222
+ };
223
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Stack, {
224
+ ...(getFloatingProps ? getFloatingProps(frameProps) : frameProps),
225
+ children: contents
226
+ });
227
+ }),
228
+ PopperArrowFrame = (0, import_core.styled)(import_stacks.YStack, {
229
+ name: "PopperArrow",
230
+ variants: {
231
+ unstyled: {
232
+ false: {
233
+ borderColor: "$borderColor",
234
+ backgroundColor: "$background",
235
+ position: "relative"
236
+ }
237
+ }
238
+ },
239
+ defaultVariants: {
240
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
241
+ }
242
+ }),
243
+ PopperArrowOuterFrame = (0, import_core.styled)(import_stacks.YStack, {
244
+ name: "PopperArrowOuter",
245
+ variants: {
246
+ unstyled: {
247
+ false: {
248
+ position: "absolute",
249
+ zIndex: 1e6,
250
+ pointerEvents: "none",
251
+ overflow: "hidden",
252
+ alignItems: "center",
253
+ justifyContent: "center"
254
+ }
255
+ }
256
+ },
257
+ defaultVariants: {
258
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
259
+ }
260
+ }),
261
+ opposites = {
262
+ top: "bottom",
263
+ right: "left",
264
+ bottom: "top",
265
+ left: "right"
266
+ },
267
+ PopperArrow = PopperArrowFrame.styleable(function (propsIn, forwardedRef) {
268
+ const {
269
+ __scopePopper,
270
+ ...rest
271
+ } = propsIn,
272
+ props = (0, import_core.useProps)(rest),
273
+ {
274
+ offset,
275
+ size: sizeProp,
276
+ borderWidth = 0,
277
+ ...arrowProps
278
+ } = props,
279
+ context = usePopperContext(__scopePopper),
280
+ sizeVal = typeof sizeProp == "number" ? sizeProp : (0, import_core.getVariableValue)((0, import_get_token.getSpace)(sizeProp ?? context.size, {
281
+ shift: -2,
282
+ bounds: [2]
283
+ })),
284
+ size = Math.max(0, +sizeVal),
285
+ {
286
+ placement
287
+ } = context,
288
+ refs = (0, import_compose_refs.useComposedRefs)(context.arrowRef, forwardedRef),
289
+ x = context.arrowStyle?.x || 0,
290
+ y = context.arrowStyle?.y || 0,
291
+ primaryPlacement = placement ? placement.split("-")[0] : "top",
292
+ arrowStyle = {
293
+ x,
294
+ y,
295
+ width: size,
296
+ height: size
297
+ },
298
+ innerArrowStyle = {},
299
+ isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
300
+ if (primaryPlacement) {
301
+ arrowStyle[isVertical ? "width" : "height"] = size * 2;
302
+ const oppSide = opposites[primaryPlacement];
303
+ oppSide && (arrowStyle[oppSide] = -size, innerArrowStyle[oppSide] = size / 2), (oppSide === "top" || oppSide === "bottom") && (arrowStyle.left = 0), (oppSide === "left" || oppSide === "right") && (arrowStyle.top = 0), (0, import_constants.useIsomorphicLayoutEffect)(() => {
304
+ context.onArrowSize?.(size);
305
+ }, [size, context.onArrowSize]);
306
+ }
307
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperArrowOuterFrame, {
308
+ ref: refs,
309
+ ...arrowStyle,
310
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopperArrowFrame, {
311
+ width: size,
312
+ height: size,
313
+ ...arrowProps,
314
+ ...innerArrowStyle,
315
+ rotate: "45deg",
316
+ ...(primaryPlacement === "bottom" && {
317
+ borderLeftWidth: borderWidth,
318
+ borderTopWidth: borderWidth
319
+ }),
320
+ ...(primaryPlacement === "top" && {
321
+ borderBottomWidth: borderWidth,
322
+ borderRightWidth: borderWidth
323
+ }),
324
+ ...(primaryPlacement === "right" && {
325
+ borderLeftWidth: borderWidth,
326
+ borderBottomWidth: borderWidth
327
+ }),
328
+ ...(primaryPlacement === "left" && {
329
+ borderTopWidth: borderWidth,
330
+ borderRightWidth: borderWidth
331
+ })
332
+ })
333
+ });
334
+ });
@@ -0,0 +1,18 @@
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") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./Popper.cjs"), module.exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/popper",
3
- "version": "1.114.4",
3
+ "version": "1.115.1",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -29,24 +29,25 @@
29
29
  "react-native": "./dist/cjs/index.native.js",
30
30
  "types": "./types/index.d.ts",
31
31
  "import": "./dist/esm/index.mjs",
32
- "require": "./dist/cjs/index.js"
32
+ "require": "./dist/cjs/index.cjs",
33
+ "default": "./dist/cjs/index.native.js"
33
34
  }
34
35
  },
35
36
  "dependencies": {
36
- "@tamagui/compose-refs": "1.114.4",
37
- "@tamagui/constants": "1.114.4",
38
- "@tamagui/core": "1.114.4",
39
- "@tamagui/floating": "1.114.4",
40
- "@tamagui/get-token": "1.114.4",
41
- "@tamagui/stacks": "1.114.4",
42
- "@tamagui/start-transition": "1.114.4",
43
- "@tamagui/use-controllable-state": "1.114.4"
37
+ "@tamagui/compose-refs": "1.115.1",
38
+ "@tamagui/constants": "1.115.1",
39
+ "@tamagui/core": "1.115.1",
40
+ "@tamagui/floating": "1.115.1",
41
+ "@tamagui/get-token": "1.115.1",
42
+ "@tamagui/stacks": "1.115.1",
43
+ "@tamagui/start-transition": "1.115.1",
44
+ "@tamagui/use-controllable-state": "1.115.1"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "react": "*"
47
48
  },
48
49
  "devDependencies": {
49
- "@tamagui/build": "1.114.4",
50
+ "@tamagui/build": "1.115.1",
50
51
  "react": "^18.2.0 || ^19.0.0",
51
52
  "react-native": "0.74.1"
52
53
  },
@@ -1,265 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var Popper_exports = {};
24
- __export(Popper_exports, {
25
- Popper: () => Popper,
26
- PopperAnchor: () => PopperAnchor,
27
- PopperArrow: () => PopperArrow,
28
- PopperContent: () => PopperContent,
29
- PopperContentFrame: () => PopperContentFrame,
30
- PopperContext: () => PopperContext,
31
- PopperProvider: () => PopperProvider,
32
- setupPopper: () => setupPopper,
33
- usePopperContext: () => usePopperContext
34
- });
35
- module.exports = __toCommonJS(Popper_exports);
36
- var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_floating = require("@tamagui/floating"), import_get_token = require("@tamagui/get-token"), import_stacks = require("@tamagui/stacks"), import_start_transition = require("@tamagui/start-transition"), React = __toESM(require("react")), import_react_native = require("react-native-web"), import_jsx_runtime = require("react/jsx-runtime");
37
- const PopperContext = (0, import_core.createStyledContext)({}), { useStyledContext: usePopperContext, Provider: PopperProvider } = PopperContext, checkFloating = void 0, setupOptions = {};
38
- function setupPopper(options) {
39
- Object.assign(setupOptions, options);
40
- }
41
- function Popper(props) {
42
- const {
43
- children,
44
- size,
45
- strategy = "absolute",
46
- placement = "bottom",
47
- stayInFrame,
48
- allowFlip,
49
- offset,
50
- disableRTL,
51
- __scopePopper
52
- } = props, [arrowEl, setArrow] = React.useState(null), [arrowSize, setArrowSize] = React.useState(0), offsetOptions = offset ?? arrowSize, floating = (0, import_floating.useFloating)({
53
- strategy,
54
- placement,
55
- sameScrollView: !1,
56
- // this only takes effect on native
57
- platform: disableRTL ?? setupOptions.disableRTL ? {
58
- ...import_floating.platform,
59
- isRTL(element) {
60
- return !1;
61
- }
62
- } : import_floating.platform,
63
- middleware: [
64
- stayInFrame ? (0, import_floating.shift)(typeof stayInFrame == "boolean" ? {} : stayInFrame) : null,
65
- allowFlip ? (0, import_floating.flip)(typeof allowFlip == "boolean" ? {} : allowFlip) : null,
66
- arrowEl ? (0, import_floating.arrow)({ element: arrowEl }) : null,
67
- typeof offsetOptions < "u" ? (0, import_floating.offset)(offsetOptions) : null,
68
- checkFloating
69
- ].filter(Boolean)
70
- }), {
71
- refs,
72
- middlewareData,
73
- // @ts-expect-error this comes from Tooltip for example
74
- open
75
- } = floating;
76
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
77
- if (open && refs.reference.current && refs.floating.current)
78
- return floating.update(), (0, import_floating.autoUpdate)(refs.reference.current, refs.floating.current, floating.update);
79
- }, [open, floating.update, refs.floating, refs.reference]);
80
- const popperContext = {
81
- size,
82
- arrowRef: setArrow,
83
- arrowStyle: middlewareData.arrow,
84
- onArrowSize: setArrowSize,
85
- scope: __scopePopper,
86
- hasFloating: middlewareData.checkFloating?.hasFloating,
87
- ...floating
88
- };
89
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperProvider, { ...popperContext, children });
90
- }
91
- const PopperAnchor = import_stacks.YStack.extractable(
92
- React.forwardRef(
93
- function(props, forwardedRef) {
94
- const { virtualRef, __scopePopper, ...anchorProps } = props, { getReferenceProps, refs } = usePopperContext(__scopePopper), ref = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref, refs.setReference);
95
- React.useEffect(() => {
96
- virtualRef && refs.setReference(virtualRef.current);
97
- }, [virtualRef]);
98
- const stackProps = {
99
- ref: composedRefs,
100
- ...anchorProps
101
- };
102
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
103
- import_core.View,
104
- {
105
- ...getReferenceProps ? getReferenceProps(stackProps) : stackProps
106
- }
107
- );
108
- }
109
- )
110
- ), PopperContentFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
111
- name: "PopperContent",
112
- variants: {
113
- unstyled: {
114
- false: {
115
- size: "$true",
116
- backgroundColor: "$background",
117
- alignItems: "center",
118
- radiused: !0
119
- }
120
- },
121
- size: {
122
- "...size": (val, { tokens }) => ({
123
- padding: tokens.space[val],
124
- borderRadius: tokens.radius[val]
125
- })
126
- }
127
- },
128
- defaultVariants: {
129
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
130
- }
131
- }), PopperContent = React.forwardRef(function(props, forwardedRef) {
132
- const { __scopePopper, enableAnimationForPositionChange, ...rest } = props, {
133
- strategy,
134
- placement,
135
- refs,
136
- x,
137
- y,
138
- getFloatingProps,
139
- size,
140
- update,
141
- floatingStyles,
142
- hasFloating
143
- } = usePopperContext(__scopePopper), contentRefs = (0, import_compose_refs.useComposedRefs)(refs.setFloating, forwardedRef);
144
- let finalHasFloatingValue = !1;
145
- if (import_constants.isAndroid) {
146
- const initialRender = React.useRef(!0), finalHasFloating = React.useRef(!1);
147
- hasFloating === !1 && (initialRender.current = !1), initialRender.current || (finalHasFloating.current = hasFloating), finalHasFloatingValue = finalHasFloating.current;
148
- }
149
- const contents = React.useMemo(() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
- PopperContentFrame,
151
- {
152
- "data-placement": placement,
153
- "data-strategy": strategy,
154
- contain: "layout",
155
- size,
156
- ...rest
157
- },
158
- "popper-content-frame"
159
- ), [placement, strategy, props]), [needsMeasure, setNeedsMeasure] = React.useState(!0);
160
- React.useEffect(() => {
161
- enableAnimationForPositionChange && (x || y) && setNeedsMeasure(!1);
162
- }, [enableAnimationForPositionChange, x, y]);
163
- let show = !0;
164
- if (import_constants.isAndroid) {
165
- const [show_, setShow] = React.useState(!1);
166
- show = show_, React.useEffect(() => {
167
- finalHasFloatingValue && setShow(!0);
168
- }, [finalHasFloatingValue, x, y]);
169
- }
170
- const frameProps = {
171
- ref: contentRefs,
172
- x: x || 0,
173
- y: y || 0,
174
- top: 0,
175
- left: 0,
176
- position: strategy,
177
- opacity: show ? 1 : 0,
178
- ...enableAnimationForPositionChange && {
179
- // apply animation but disable it on initial render to avoid animating from 0 to the first position
180
- animation: rest.animation,
181
- animateOnly: needsMeasure ? ["none"] : rest.animateOnly,
182
- animatePresence: !1
183
- }
184
- };
185
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Stack, { ...getFloatingProps ? getFloatingProps(frameProps) : frameProps, children: contents });
186
- }), PopperArrowFrame = (0, import_core.styled)(import_stacks.YStack, {
187
- name: "PopperArrow",
188
- variants: {
189
- unstyled: {
190
- false: {
191
- borderColor: "$borderColor",
192
- backgroundColor: "$background",
193
- position: "relative"
194
- }
195
- }
196
- },
197
- defaultVariants: {
198
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
199
- }
200
- }), PopperArrowOuterFrame = (0, import_core.styled)(import_stacks.YStack, {
201
- name: "PopperArrowOuter",
202
- variants: {
203
- unstyled: {
204
- false: {
205
- position: "absolute",
206
- zIndex: 1e6,
207
- pointerEvents: "none",
208
- overflow: "hidden",
209
- alignItems: "center",
210
- justifyContent: "center"
211
- }
212
- }
213
- },
214
- defaultVariants: {
215
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
216
- }
217
- }), opposites = {
218
- top: "bottom",
219
- right: "left",
220
- bottom: "top",
221
- left: "right"
222
- }, PopperArrow = PopperArrowFrame.styleable(
223
- function(propsIn, forwardedRef) {
224
- const { __scopePopper, ...rest } = propsIn, props = (0, import_core.useProps)(rest), { offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props, context = usePopperContext(__scopePopper), sizeVal = typeof sizeProp == "number" ? sizeProp : (0, import_core.getVariableValue)(
225
- (0, import_get_token.getSpace)(sizeProp ?? context.size, {
226
- shift: -2,
227
- bounds: [2]
228
- })
229
- ), size = Math.max(0, +sizeVal), { placement } = context, refs = (0, import_compose_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";
230
- if (primaryPlacement) {
231
- arrowStyle[isVertical ? "width" : "height"] = size * 2;
232
- const oppSide = opposites[primaryPlacement];
233
- oppSide && (arrowStyle[oppSide] = -size, innerArrowStyle[oppSide] = size / 2), (oppSide === "top" || oppSide === "bottom") && (arrowStyle.left = 0), (oppSide === "left" || oppSide === "right") && (arrowStyle.top = 0), (0, import_constants.useIsomorphicLayoutEffect)(() => {
234
- context.onArrowSize?.(size);
235
- }, [size, context.onArrowSize]);
236
- }
237
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperArrowOuterFrame, { ref: refs, ...arrowStyle, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
238
- PopperArrowFrame,
239
- {
240
- width: size,
241
- height: size,
242
- ...arrowProps,
243
- ...innerArrowStyle,
244
- rotate: "45deg",
245
- ...primaryPlacement === "bottom" && {
246
- borderLeftWidth: borderWidth,
247
- borderTopWidth: borderWidth
248
- },
249
- ...primaryPlacement === "top" && {
250
- borderBottomWidth: borderWidth,
251
- borderRightWidth: borderWidth
252
- },
253
- ...primaryPlacement === "right" && {
254
- borderLeftWidth: borderWidth,
255
- borderBottomWidth: borderWidth
256
- },
257
- ...primaryPlacement === "left" && {
258
- borderTopWidth: borderWidth,
259
- borderRightWidth: borderWidth
260
- }
261
- }
262
- ) });
263
- }
264
- );
265
- //# sourceMappingURL=Popper.js.map
package/dist/cjs/index.js DELETED
@@ -1,15 +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))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./Popper"), module.exports);
15
- //# sourceMappingURL=index.js.map
File without changes
File without changes