@tamagui/popper 1.0.1-beta.21 → 1.0.1-beta.210

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.
Files changed (48) hide show
  1. package/dist/cjs/Popper.js +159 -125
  2. package/dist/cjs/Popper.js.map +3 -3
  3. package/dist/cjs/floating.js +1 -0
  4. package/dist/cjs/floating.js.map +1 -1
  5. package/dist/cjs/floating.native.js +1 -0
  6. package/dist/cjs/floating.native.js.map +1 -1
  7. package/dist/cjs/index.js +1 -0
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/useFloating.js +7 -4
  10. package/dist/cjs/useFloating.js.map +2 -2
  11. package/dist/esm/Popper.js +153 -108
  12. package/dist/esm/Popper.js.map +3 -3
  13. package/dist/esm/floating.js +0 -0
  14. package/dist/esm/floating.js.map +1 -1
  15. package/dist/esm/floating.native.js +0 -0
  16. package/dist/esm/floating.native.js.map +1 -1
  17. package/dist/esm/index.js +0 -0
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/useFloating.js +2 -4
  20. package/dist/esm/useFloating.js.map +2 -2
  21. package/dist/jsx/Popper.js +124 -86
  22. package/dist/jsx/Popper.js.map +7 -0
  23. package/dist/jsx/floating.js +1 -0
  24. package/dist/jsx/floating.js.map +7 -0
  25. package/dist/jsx/floating.native.js +1 -0
  26. package/dist/jsx/floating.native.js.map +7 -0
  27. package/dist/jsx/index.js +1 -0
  28. package/dist/jsx/index.js.map +7 -0
  29. package/dist/jsx/useFloating.js +4 -6
  30. package/dist/jsx/useFloating.js.map +7 -0
  31. package/package.json +17 -12
  32. package/src/Popper.tsx +351 -0
  33. package/src/floating.native.tsx +1 -0
  34. package/src/floating.tsx +1 -0
  35. package/src/index.tsx +2 -0
  36. package/src/useFloating.tsx +20 -0
  37. package/types/Popper.d.ts +73 -61
  38. package/types/index.d.ts +1 -1
  39. package/types/useFloating.d.ts +3 -2
  40. package/types/Popper.d.ts.map +0 -1
  41. package/types/floating.d.ts.map +0 -1
  42. package/types/floating.native.d.ts.map +0 -1
  43. package/types/index.d.ts.map +0 -1
  44. package/types/useFloating.d.ts.map +0 -1
  45. package/types/useFloating.native.d.ts +0 -2
  46. package/types/useFloating.native.d.ts.map +0 -1
  47. package/types/useFloating.web.d.ts +0 -2
  48. package/types/useFloating.web.d.ts.map +0 -1
@@ -1,14 +1,14 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
1
+ import { jsx } from "react/jsx-runtime";
3
2
  import { useComposedRefs } from "@tamagui/compose-refs";
4
3
  import {
5
4
  getTokens,
6
5
  getVariableValue,
6
+ stepTokenUpOrDown,
7
7
  styled,
8
8
  useIsomorphicLayoutEffect
9
9
  } from "@tamagui/core";
10
10
  import { createContextScope } from "@tamagui/create-context";
11
- import { SizableStack, YStack } from "@tamagui/stacks";
11
+ import { ThemeableStack, YStack } from "@tamagui/stacks";
12
12
  import * as React from "react";
13
13
  import { arrow, autoUpdate, flip, offset, shift } from "./floating";
14
14
  import { useFloating } from "./useFloating";
@@ -16,8 +16,16 @@ const POPPER_NAME = "Popper";
16
16
  const [createPopperContext, createScope] = createContextScope(POPPER_NAME);
17
17
  const createPopperScope = createScope;
18
18
  const [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
19
- const Popper = /* @__PURE__ */ __name((props) => {
20
- const { __scopePopper, children, size, placement = "bottom", stayInFrame, allowFlip } = props;
19
+ const Popper = (props) => {
20
+ const {
21
+ __scopePopper,
22
+ children,
23
+ size,
24
+ strategy = "absolute",
25
+ placement = "bottom",
26
+ stayInFrame,
27
+ allowFlip
28
+ } = props;
21
29
  const [isMounted, setIsMounted] = React.useState(false);
22
30
  useIsomorphicLayoutEffect(() => {
23
31
  setIsMounted(true);
@@ -27,10 +35,11 @@ const Popper = /* @__PURE__ */ __name((props) => {
27
35
  const [arrowSize, setArrowSize] = React.useState(0);
28
36
  const arrowRef = React.useRef();
29
37
  const floating = useFloating({
38
+ strategy,
30
39
  placement,
31
40
  middleware: [
32
- stayInFrame ? shift(stayInFrame) : null,
33
- allowFlip ? flip(allowFlip) : null,
41
+ stayInFrame ? shift(typeof stayInFrame === "boolean" ? {} : stayInFrame) : null,
42
+ allowFlip ? flip(typeof allowFlip === "boolean" ? {} : allowFlip) : null,
34
43
  arrowEl ? arrow({ element: arrowEl }) : null,
35
44
  arrowSize ? offset(arrowSize) : null
36
45
  ].filter(Boolean)
@@ -45,11 +54,11 @@ const Popper = /* @__PURE__ */ __name((props) => {
45
54
  return;
46
55
  }
47
56
  return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
48
- }, [refs.floating.current, refs.reference.current]);
57
+ }, [floating.update, refs.floating, refs.reference]);
49
58
  const arrowStyle = React.useMemo(() => {
50
59
  return middlewareData.arrow;
51
60
  }, [JSON.stringify(middlewareData.arrow || {})]);
52
- return /* @__PURE__ */ React.createElement(PopperProvider, {
61
+ return /* @__PURE__ */ jsx(PopperProvider, {
53
62
  scope: __scopePopper,
54
63
  anchorRef,
55
64
  size,
@@ -57,72 +66,97 @@ const Popper = /* @__PURE__ */ __name((props) => {
57
66
  arrowStyle,
58
67
  onArrowSize: setArrowSize,
59
68
  isMounted,
60
- ...floating
61
- }, children);
62
- }, "Popper");
69
+ ...floating,
70
+ children
71
+ });
72
+ };
63
73
  Popper.displayName = POPPER_NAME;
64
74
  const ANCHOR_NAME = "PopperAnchor";
65
- const PopperAnchor = React.forwardRef((props, forwardedRef) => {
66
- const { __scopePopper, virtualRef, ...anchorProps } = props;
67
- const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper);
68
- const ref = React.useRef(null);
69
- const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
70
- if (virtualRef) {
71
- return null;
75
+ const PopperAnchor = React.forwardRef(
76
+ (props, forwardedRef) => {
77
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
78
+ const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper);
79
+ const ref = React.useRef(null);
80
+ const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
81
+ if (virtualRef) {
82
+ return null;
83
+ }
84
+ const stackProps = {
85
+ ref: composedRefs,
86
+ ...anchorProps
87
+ };
88
+ return /* @__PURE__ */ jsx(YStack, {
89
+ ...getReferenceProps ? getReferenceProps(stackProps) : stackProps
90
+ });
72
91
  }
73
- const stackProps = {
74
- ref: composedRefs,
75
- ...anchorProps
76
- };
77
- return /* @__PURE__ */ React.createElement(YStack, {
78
- ...getReferenceProps ? getReferenceProps(stackProps) : stackProps
79
- });
80
- });
92
+ );
81
93
  PopperAnchor.displayName = ANCHOR_NAME;
82
94
  const CONTENT_NAME = "PopperContent";
83
- const PopperContentFrame = styled(SizableStack, {
95
+ const PopperContentFrame = styled(ThemeableStack, {
84
96
  name: "PopperContent",
85
97
  backgroundColor: "$background",
86
98
  alignItems: "center",
99
+ radiused: true,
100
+ variants: {
101
+ size: {
102
+ "...size": (val, { tokens }) => {
103
+ return {
104
+ padding: tokens.space[val],
105
+ borderRadius: tokens.radius[val]
106
+ };
107
+ }
108
+ }
109
+ },
87
110
  defaultVariants: {
88
111
  size: "$4"
89
112
  }
90
113
  });
91
- const PopperContent = React.forwardRef((props, forwardedRef) => {
92
- const { __scopePopper, ...contentProps } = props;
93
- const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
94
- const contentRefs = useComposedRefs(floating, forwardedRef);
95
- const contents = React.useMemo(() => {
96
- var _a;
97
- return /* @__PURE__ */ React.createElement(PopperContentFrame, {
98
- key: "popper-content-frame",
99
- "data-placement": placement,
100
- "data-strategy": strategy,
101
- ...contentProps,
102
- size: (_a = contentProps.size) != null ? _a : size
103
- });
104
- }, [placement, strategy, props]);
105
- if (!isMounted) {
106
- return null;
107
- }
108
- const frameProps = {
109
- ref: contentRefs,
110
- x: x || 0,
111
- y: y || 0,
112
- position: "absolute"
113
- };
114
- return /* @__PURE__ */ React.createElement(YStack, {
115
- ...getFloatingProps ? getFloatingProps(frameProps) : frameProps
116
- }, contents);
117
- });
114
+ const PopperContent = PopperContentFrame.extractable(
115
+ React.forwardRef(
116
+ (props, forwardedRef) => {
117
+ const { __scopePopper, ...contentProps } = props;
118
+ const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
119
+ const contentRefs = useComposedRefs(floating, forwardedRef);
120
+ const contents = React.useMemo(() => {
121
+ return /* @__PURE__ */ jsx(PopperContentFrame, {
122
+ "data-placement": placement,
123
+ "data-strategy": strategy,
124
+ size: contentProps.size || size,
125
+ ...contentProps
126
+ }, "popper-content-frame");
127
+ }, [placement, strategy, props]);
128
+ if (!isMounted) {
129
+ return null;
130
+ }
131
+ const frameProps = {
132
+ ref: contentRefs,
133
+ x: x || 0,
134
+ y: y || 0,
135
+ position: strategy
136
+ };
137
+ return /* @__PURE__ */ jsx(YStack, {
138
+ ...getFloatingProps ? getFloatingProps(frameProps) : frameProps,
139
+ children: contents
140
+ });
141
+ }
142
+ )
143
+ );
118
144
  PopperContent.displayName = CONTENT_NAME;
119
145
  const ARROW_NAME = "PopperArrow";
120
146
  const PopperArrowFrame = styled(YStack, {
121
147
  name: "PopperArrow",
122
148
  borderColor: "$borderColor",
123
149
  backgroundColor: "$background",
150
+ position: "relative"
151
+ });
152
+ const PopperArrowOuterFrame = styled(YStack, {
153
+ name: "PopperArrowOuter",
124
154
  position: "absolute",
125
- zIndex: 1
155
+ zIndex: -1,
156
+ pointerEvents: "none",
157
+ overflow: "hidden",
158
+ alignItems: "center",
159
+ justifyContent: "center"
126
160
  });
127
161
  const opposites = {
128
162
  top: "bottom",
@@ -130,64 +164,75 @@ const opposites = {
130
164
  bottom: "top",
131
165
  left: "right"
132
166
  };
133
- const PopperArrow = React.forwardRef(/* @__PURE__ */ __name(function PopperArrow2(props, forwardedRef) {
134
- var _a, _b;
135
- const { __scopePopper, offset: offset2, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
136
- const context = usePopperContext(ARROW_NAME, __scopePopper);
137
- const tokens = getTokens();
138
- const sizeVal = sizeProp != null ? sizeProp : context.size;
139
- const sizeValResolved = getVariableValue((_b = (_a = tokens.size[sizeVal]) != null ? _a : sizeVal) != null ? _b : 12);
140
- const size = +sizeValResolved;
141
- const { placement } = context;
142
- const { x, y } = context.arrowStyle || { x: 0, y: 0 };
143
- const refs = useComposedRefs(context.arrowRef, forwardedRef);
144
- const primaryPlacement = placement ? placement.split("-")[0] : "top";
145
- let arrowStyle = { x, y, width: size, height: size };
146
- if (primaryPlacement) {
147
- const oppSide = opposites[primaryPlacement];
148
- if (oppSide) {
149
- arrowStyle[oppSide] = -size / 2;
150
- }
151
- if (oppSide === "top" || oppSide === "bottom") {
152
- arrowStyle.left = 0;
153
- }
154
- if (oppSide === "left" || oppSide === "right") {
155
- arrowStyle.top = 0;
167
+ const PopperArrow = PopperArrowFrame.extractable(
168
+ React.forwardRef(function PopperArrow2(props, forwardedRef) {
169
+ const { __scopePopper, offset: offset2, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
170
+ const context = usePopperContext(ARROW_NAME, __scopePopper);
171
+ const tokens = getTokens();
172
+ const sizeVal = sizeProp ?? context.size;
173
+ const sizeValResolved = getVariableValue(stepTokenUpOrDown(tokens.space, sizeVal, -2, [2]));
174
+ const size = +sizeValResolved;
175
+ const { placement } = context;
176
+ const { x, y } = context.arrowStyle || { x: 0, y: 0 };
177
+ const refs = useComposedRefs(context.arrowRef, forwardedRef);
178
+ const primaryPlacement = placement ? placement.split("-")[0] : "top";
179
+ const arrowStyle = { x, y, width: size, height: size };
180
+ const innerArrowStyle = {};
181
+ const isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
182
+ if (primaryPlacement) {
183
+ arrowStyle[isVertical ? "width" : "height"] = size * 2;
184
+ const oppSide = opposites[primaryPlacement];
185
+ if (oppSide) {
186
+ arrowStyle[oppSide] = -size;
187
+ innerArrowStyle[oppSide] = size / 2;
188
+ }
189
+ if (oppSide === "top" || oppSide === "bottom") {
190
+ arrowStyle.left = 0;
191
+ }
192
+ if (oppSide === "left" || oppSide === "right") {
193
+ arrowStyle.top = 0;
194
+ }
156
195
  }
157
- }
158
- useIsomorphicLayoutEffect(() => {
159
- var _a2;
160
- (_a2 = context.onArrowSize) == null ? void 0 : _a2.call(context, size);
161
- }, [size, context.onArrowSize]);
162
- return /* @__PURE__ */ React.createElement(PopperArrowFrame, {
163
- ...arrowProps,
164
- ref: refs,
165
- ...arrowStyle,
166
- rotate: "45deg",
167
- ...primaryPlacement === "top" && {
168
- borderBottomWidth: borderWidth,
169
- borderRightWidth: borderWidth
170
- },
171
- ...primaryPlacement === "bottom" && {
172
- borderTopWidth: borderWidth,
173
- borderLeftWidth: borderWidth
174
- },
175
- ...primaryPlacement === "left" && {
176
- borderTopWidth: borderWidth,
177
- borderRightWidth: borderWidth
178
- },
179
- ...primaryPlacement === "right" && {
180
- borderBottomWidth: borderWidth,
181
- borderLeftWidth: borderWidth
182
- }
183
- });
184
- }, "PopperArrow"));
196
+ useIsomorphicLayoutEffect(() => {
197
+ var _a;
198
+ (_a = context.onArrowSize) == null ? void 0 : _a.call(context, size);
199
+ }, [size, context.onArrowSize]);
200
+ return /* @__PURE__ */ jsx(PopperArrowOuterFrame, {
201
+ ref: refs,
202
+ ...arrowStyle,
203
+ children: /* @__PURE__ */ jsx(PopperArrowFrame, {
204
+ width: size,
205
+ height: size,
206
+ ...arrowProps,
207
+ ...innerArrowStyle,
208
+ rotate: "45deg",
209
+ ...primaryPlacement === "bottom" && {
210
+ borderBottomWidth: borderWidth,
211
+ borderRightWidth: borderWidth
212
+ },
213
+ ...primaryPlacement === "top" && {
214
+ borderTopWidth: borderWidth,
215
+ borderLeftWidth: borderWidth
216
+ },
217
+ ...primaryPlacement === "right" && {
218
+ borderTopWidth: borderWidth,
219
+ borderRightWidth: borderWidth
220
+ },
221
+ ...primaryPlacement === "left" && {
222
+ borderBottomWidth: borderWidth,
223
+ borderLeftWidth: borderWidth
224
+ }
225
+ })
226
+ });
227
+ })
228
+ );
185
229
  PopperArrow.displayName = ARROW_NAME;
186
230
  export {
187
231
  Popper,
188
232
  PopperAnchor,
189
233
  PopperArrow,
190
234
  PopperContent,
191
- createPopperScope
235
+ createPopperScope,
236
+ usePopperContext
192
237
  };
193
238
  //# sourceMappingURL=Popper.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Popper.tsx"],
4
- "sourcesContent": ["// adapted from radix-ui popper\n\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n SizeTokens,\n StackProps,\n getTokens,\n getVariableValue,\n styled,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { SizableStack, SizableStackProps, YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nimport { Coords, Placement, arrow, autoUpdate, flip, offset, shift } from './floating'\nimport { UseFloatingResult, useFloating } from './useFloating'\n\ntype ShiftProps = typeof shift extends (options: infer Opts) => void ? Opts : never\ntype FlipProps = typeof flip extends (options: infer Opts) => void ? Opts : never\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper'\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope }\nconst [createPopperContext, createScope] = createContextScope(POPPER_NAME)\n\nexport const createPopperScope = createScope\n\ntype PopperContextValue = UseFloatingResult & {\n isMounted: boolean\n anchorRef: any\n size?: SizeTokens\n placement?: Placement\n arrowRef: any\n onArrowSize?: (val: number) => void\n arrowStyle?: Partial<Coords> & {\n centerOffset: number\n }\n}\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME)\n\nexport type PopperProps = {\n size?: SizeTokens\n children?: React.ReactNode\n placement?: Placement\n stayInFrame?: ShiftProps\n allowFlip?: FlipProps\n}\n\nexport const Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const { __scopePopper, children, size, placement = 'bottom', stayInFrame, allowFlip } = props\n\n const [isMounted, setIsMounted] = React.useState(false)\n useIsomorphicLayoutEffect(() => {\n setIsMounted(true)\n }, [])\n\n const anchorRef = React.useRef<any>()\n const [arrowEl, setArrow] = React.useState<HTMLSpanElement | null>(null)\n const [arrowSize, setArrowSize] = React.useState(0)\n const arrowRef = React.useRef()\n\n const floating = useFloating({\n placement,\n middleware: [\n stayInFrame ? shift(stayInFrame) : (null as any),\n allowFlip ? flip(allowFlip) : (null as any),\n arrowEl ? arrow({ element: arrowEl }) : (null as any),\n arrowSize ? offset(arrowSize) : (null as any),\n ].filter(Boolean),\n })\n\n const { refs, middlewareData } = floating\n\n const composedArrowRefs = useComposedRefs<any>(arrowRef, setArrow)\n\n useIsomorphicLayoutEffect(() => {\n floating.reference(anchorRef.current)\n }, [anchorRef])\n\n React.useEffect(() => {\n if (!refs.reference.current || !refs.floating.current) {\n return\n }\n // Only call this when the floating element is rendered\n return autoUpdate(refs.reference.current, refs.floating.current, floating.update)\n }, [refs.floating.current, refs.reference.current])\n\n const arrowStyle = React.useMemo(() => {\n return middlewareData.arrow\n }, [JSON.stringify(middlewareData.arrow || {})])\n\n return (\n <PopperProvider\n scope={__scopePopper}\n anchorRef={anchorRef}\n size={size}\n arrowRef={composedArrowRefs}\n arrowStyle={arrowStyle}\n onArrowSize={setArrowSize}\n isMounted={isMounted}\n {...floating}\n >\n {children}\n </PopperProvider>\n )\n}\n\nPopper.displayName = POPPER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor'\n\ntype PopperAnchorRef = HTMLElement | View\n\nexport type PopperAnchorProps = YStackProps & {\n virtualRef?: React.RefObject<any>\n}\n\nexport const PopperAnchor = React.forwardRef<PopperAnchorRef, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props\n const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper)\n const ref = React.useRef<PopperAnchorRef>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef)\n if (virtualRef) {\n return null\n }\n const stackProps = {\n ref: composedRefs,\n ...anchorProps,\n }\n return <YStack {...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)} />\n }\n)\n\nPopperAnchor.displayName = ANCHOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent'\n\ntype PopperContentElement = HTMLElement | View\n\nexport type PopperContentProps = SizableStackProps\n\nconst PopperContentFrame = styled(SizableStack, {\n name: 'PopperContent',\n backgroundColor: '$background',\n alignItems: 'center',\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const { __scopePopper, ...contentProps } = props\n const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } =\n usePopperContext(CONTENT_NAME, __scopePopper)\n const contentRefs = useComposedRefs<any>(floating, forwardedRef)\n\n const contents = React.useMemo(() => {\n return (\n <PopperContentFrame\n key=\"popper-content-frame\"\n data-placement={placement}\n data-strategy={strategy}\n {...contentProps}\n size={contentProps.size ?? size}\n />\n )\n }, [placement, strategy, props])\n\n // all poppers hidden on ssr by default\n if (!isMounted) {\n return null\n }\n\n const frameProps = {\n ref: contentRefs,\n x: (x as any) || 0,\n y: (y as any) || 0,\n position: 'absolute',\n }\n\n // outer frame because we explicitly dont want animation to apply to this\n return (\n <YStack {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}>\n {contents}\n </YStack>\n )\n }\n)\n\nPopperContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow'\n\ntype PopperArrowElement = HTMLElement | View\n\nexport type PopperArrowProps = YStackProps & {\n offset?: number\n size?: SizeTokens\n}\n\nconst PopperArrowFrame = styled(YStack, {\n name: 'PopperArrow',\n borderColor: '$borderColor',\n backgroundColor: '$background',\n position: 'absolute',\n zIndex: 1,\n // TODO bug not applying\n // rotate: '45deg',\n})\n\nconst opposites = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n}\n\nexport const PopperArrow = React.forwardRef<PopperArrowElement, PopperArrowProps>(\n function PopperArrow(props: ScopedProps<PopperArrowProps>, forwardedRef) {\n const { __scopePopper, offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props\n const context = usePopperContext(ARROW_NAME, __scopePopper)\n const tokens = getTokens()\n const sizeVal = sizeProp ?? context.size\n const sizeValResolved = getVariableValue(tokens.size[sizeVal as any] ?? sizeVal ?? 12)\n const size = +sizeValResolved\n const { placement } = context\n const { x, y } = context.arrowStyle || { x: 0, y: 0 }\n const refs = useComposedRefs(context.arrowRef, forwardedRef)\n\n const primaryPlacement = placement ? placement.split('-')[0] : 'top'\n\n let arrowStyle: StackProps = { x, y, width: size, height: size }\n if (primaryPlacement) {\n const oppSide = opposites[primaryPlacement]\n if (oppSide) {\n arrowStyle[oppSide] = -size / 2\n }\n if (oppSide === 'top' || oppSide === 'bottom') {\n arrowStyle.left = 0\n }\n if (oppSide === 'left' || oppSide === 'right') {\n arrowStyle.top = 0\n }\n }\n\n // send the Arrow's offset up to Popper\n useIsomorphicLayoutEffect(() => {\n context.onArrowSize?.(size)\n }, [size, context.onArrowSize])\n\n return (\n <PopperArrowFrame\n {...arrowProps}\n ref={refs}\n {...arrowStyle}\n rotate=\"45deg\"\n // left={0}\n // top={0}\n {...(primaryPlacement === 'top' && {\n borderBottomWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'bottom' && {\n borderTopWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n {...(primaryPlacement === 'left' && {\n borderTopWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'right' && {\n borderBottomWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n />\n )\n }\n)\n\nPopperArrow.displayName = ARROW_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n"],
5
- "mappings": ";;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AACA;AACA;AAGA;AACA;AASA,MAAM,cAAc;AAGpB,MAAM,CAAC,qBAAqB,eAAe,mBAAmB,WAAW;AAElE,MAAM,oBAAoB;AAajC,MAAM,CAAC,gBAAgB,oBAAoB,oBAAwC,WAAW;AAUvF,MAAM,SAAgC,wBAAC,UAAoC;AAChF,QAAM,EAAE,eAAe,UAAU,MAAM,YAAY,UAAU,aAAa,cAAc;AAExF,QAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,KAAK;AACtD,4BAA0B,MAAM;AAC9B,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY,MAAM,OAAY;AACpC,QAAM,CAAC,SAAS,YAAY,MAAM,SAAiC,IAAI;AACvE,QAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,CAAC;AAClD,QAAM,WAAW,MAAM,OAAO;AAE9B,QAAM,WAAW,YAAY;AAAA,IAC3B;AAAA,IACA,YAAY;AAAA,MACV,cAAc,MAAM,WAAW,IAAK;AAAA,MACpC,YAAY,KAAK,SAAS,IAAK;AAAA,MAC/B,UAAU,MAAM,EAAE,SAAS,QAAQ,CAAC,IAAK;AAAA,MACzC,YAAY,OAAO,SAAS,IAAK;AAAA,IACnC,EAAE,OAAO,OAAO;AAAA,EAClB,CAAC;AAED,QAAM,EAAE,MAAM,mBAAmB;AAEjC,QAAM,oBAAoB,gBAAqB,UAAU,QAAQ;AAEjE,4BAA0B,MAAM;AAC9B,aAAS,UAAU,UAAU,OAAO;AAAA,EACtC,GAAG,CAAC,SA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,cAAc;AACtB,QAAM,EAAE,GAAG,MAAM,QAAQ,cAAc,EAAE,GAAG,GAAG,GAAG,EAAE;AACpD,QAAM,OAAO,gBAAgB,QAAQ,UAAU,YAAY;AAE3D,QAAM,mBAAmB,YAAY,UAAU,MAAM,GAAG,EAAE,KAAK;AAE/D,MAAI,aAAyB,EAAE,GAAG,GAAG,OAAO,MAAM,QAAQ,KAAK;AAC/D,MAAI,kBAAkB;AACpB,UAAM,UAAU,UAAU;AAC1B,QAAI,SAAS;AACX,iBAAW,WAAW,CAAC,OAAO;AAAA,IAChC;AACA,QAAI,YAAY,SAAS,YAAY,UAAU;AAC7C,iBAAW,OAAO;AAAA,IACpB;AACA,QAAI,YAAY,UAAU,YAAY,SAAS;AAC7C,iBAAW,MAAM;AAAA,IACnB;AAAA,EACF;AAGA,4BAA0B,MAAM;AA3QpC;AA4QM,mBAAQ,gBAAR,kCAAsB;AAAA,EACxB,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAE9B,SACE,oCAAC;AAAA,OACK;AAAA,IACJ,KAAK;AAAA,OACD;AAAA,IACJ,QAAO;AAAA,OAGF,qBAAqB,SAAS;AAAA,MACjC,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,IACpB;AAAA,OACK,qBAAqB,YAAY;AAAA,MACpC,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACnB;AAAA,OACK,qBAAqB,UAAU;AAAA,MAClC,gBAAgB;AAAA,MAChB,kBAAkB;AAAA,IACpB;AAAA,OACK,qBAAqB,WAAW;AAAA,MACnC,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,IACnB;AAAA,GACF;AAEJ,GA1DA,cA2DF;AAEA,YAAY,cAAc;",
6
- "names": []
4
+ "sourcesContent": ["// adapted from radix-ui popper\n\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n SizeTokens,\n StackProps,\n getTokens,\n getVariableValue,\n stepTokenUpOrDown,\n styled,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport { SizableStackProps, ThemeableStack, YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nimport { Coords, Placement, Strategy, arrow, autoUpdate, flip, offset, shift } from './floating'\nimport { UseFloatingReturn, useFloating } from './useFloating'\n\ntype ShiftProps = typeof shift extends (options: infer Opts) => void ? Opts : never\ntype FlipProps = typeof flip extends (options: infer Opts) => void ? Opts : never\n\n/* -------------------------------------------------------------------------------------------------\n * Popper\n * -----------------------------------------------------------------------------------------------*/\n\nconst POPPER_NAME = 'Popper'\n\ntype ScopedProps<P> = P & { __scopePopper?: Scope }\nconst [createPopperContext, createScope] = createContextScope(POPPER_NAME)\n\nexport const createPopperScope = createScope\n\ntype PopperContextValue = UseFloatingReturn & {\n isMounted: boolean\n anchorRef: any\n size?: SizeTokens\n placement?: Placement\n arrowRef: any\n onArrowSize?: (val: number) => void\n arrowStyle?: Partial<Coords> & {\n centerOffset: number\n }\n}\nconst [PopperProvider, usePopperContext] = createPopperContext<PopperContextValue>(POPPER_NAME)\n\nexport type PopperProps = {\n size?: SizeTokens\n children?: React.ReactNode\n placement?: Placement\n stayInFrame?: ShiftProps | boolean\n allowFlip?: FlipProps | boolean\n strategy?: Strategy\n}\n\nexport const Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {\n const {\n __scopePopper,\n children,\n size,\n strategy = 'absolute',\n placement = 'bottom',\n stayInFrame,\n allowFlip,\n } = props\n\n const [isMounted, setIsMounted] = React.useState(false)\n useIsomorphicLayoutEffect(() => {\n setIsMounted(true)\n }, [])\n\n const anchorRef = React.useRef<any>()\n const [arrowEl, setArrow] = React.useState<HTMLSpanElement | null>(null)\n const [arrowSize, setArrowSize] = React.useState(0)\n const arrowRef = React.useRef()\n\n const floating = useFloating({\n strategy,\n placement,\n middleware: [\n stayInFrame ? shift(typeof stayInFrame === 'boolean' ? {} : stayInFrame) : (null as any),\n allowFlip ? flip(typeof allowFlip === 'boolean' ? {} : allowFlip) : (null as any),\n arrowEl ? arrow({ element: arrowEl }) : (null as any),\n arrowSize ? offset(arrowSize) : (null as any),\n ].filter(Boolean),\n })\n\n const { refs, middlewareData } = floating\n\n const composedArrowRefs = useComposedRefs<any>(arrowRef, setArrow)\n\n useIsomorphicLayoutEffect(() => {\n floating.reference(anchorRef.current)\n }, [anchorRef])\n\n React.useEffect(() => {\n if (!refs.reference.current || !refs.floating.current) {\n return\n }\n // Only call this when the floating element is rendered\n return autoUpdate(refs.reference.current, refs.floating.current, floating.update)\n }, [floating.update, refs.floating, refs.reference])\n\n const arrowStyle = React.useMemo(() => {\n return middlewareData.arrow\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(middlewareData.arrow || {})])\n\n return (\n <PopperProvider\n scope={__scopePopper}\n anchorRef={anchorRef}\n size={size}\n arrowRef={composedArrowRefs}\n arrowStyle={arrowStyle}\n onArrowSize={setArrowSize}\n isMounted={isMounted}\n {...floating}\n >\n {children}\n </PopperProvider>\n )\n}\n\nPopper.displayName = POPPER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopperAnchor'\n\ntype PopperAnchorRef = HTMLElement | View\n\nexport type PopperAnchorProps = YStackProps & {\n virtualRef?: React.RefObject<any>\n}\n\nexport const PopperAnchor = React.forwardRef<PopperAnchorRef, PopperAnchorProps>(\n (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {\n const { __scopePopper, virtualRef, ...anchorProps } = props\n const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper)\n const ref = React.useRef<PopperAnchorRef>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef)\n if (virtualRef) {\n return null\n }\n const stackProps = {\n ref: composedRefs,\n ...anchorProps,\n }\n return <YStack {...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)} />\n }\n)\n\nPopperAnchor.displayName = ANCHOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent'\n\ntype PopperContentElement = HTMLElement | View\n\nexport type PopperContentProps = SizableStackProps\n\nconst PopperContentFrame = styled(ThemeableStack, {\n name: 'PopperContent',\n backgroundColor: '$background',\n alignItems: 'center',\n radiused: true,\n\n variants: {\n size: {\n '...size': (val, { tokens }) => {\n return {\n padding: tokens.space[val],\n borderRadius: tokens.radius[val],\n }\n },\n },\n } as const,\n\n defaultVariants: {\n size: '$4',\n },\n})\n\nexport const PopperContent = PopperContentFrame.extractable(\n React.forwardRef<PopperContentElement, PopperContentProps>(\n (props: ScopedProps<PopperContentProps>, forwardedRef) => {\n const { __scopePopper, ...contentProps } = props\n const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } =\n usePopperContext(CONTENT_NAME, __scopePopper)\n const contentRefs = useComposedRefs<any>(floating, forwardedRef)\n\n const contents = React.useMemo(() => {\n return (\n <PopperContentFrame\n key=\"popper-content-frame\"\n data-placement={placement}\n data-strategy={strategy}\n size={contentProps.size || size}\n {...contentProps}\n />\n )\n }, [placement, strategy, props])\n\n // all poppers hidden on ssr by default\n if (!isMounted) {\n return null\n }\n\n const frameProps = {\n ref: contentRefs,\n x: x || 0,\n y: y || 0,\n position: strategy,\n }\n\n // outer frame because we explicitly dont want animation to apply to this\n return (\n <YStack {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}>\n {contents}\n </YStack>\n )\n }\n )\n)\n\nPopperContent.displayName = CONTENT_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopperArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopperArrow'\n\ntype PopperArrowElement = HTMLElement | View\n\nexport type PopperArrowProps = YStackProps & {\n offset?: number\n size?: SizeTokens\n}\n\nconst PopperArrowFrame = styled(YStack, {\n name: 'PopperArrow',\n borderColor: '$borderColor',\n backgroundColor: '$background',\n position: 'relative',\n})\n\nconst PopperArrowOuterFrame = styled(YStack, {\n name: 'PopperArrowOuter',\n position: 'absolute',\n zIndex: -1,\n pointerEvents: 'none',\n overflow: 'hidden',\n alignItems: 'center',\n justifyContent: 'center',\n})\n\nconst opposites = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n} as const\n\ntype Sides = keyof typeof opposites\n\nexport const PopperArrow = PopperArrowFrame.extractable(\n React.forwardRef<PopperArrowElement, PopperArrowProps>(function PopperArrow(\n props: ScopedProps<PopperArrowProps>,\n forwardedRef\n ) {\n const { __scopePopper, offset, size: sizeProp, borderWidth = 0, ...arrowProps } = props\n const context = usePopperContext(ARROW_NAME, __scopePopper)\n const tokens = getTokens()\n const sizeVal = sizeProp ?? context.size\n const sizeValResolved = getVariableValue(stepTokenUpOrDown(tokens.space, sizeVal, -2, [2]))\n const size = +sizeValResolved\n const { placement } = context\n const { x, y } = context.arrowStyle || { x: 0, y: 0 }\n const refs = useComposedRefs(context.arrowRef, forwardedRef)\n\n const primaryPlacement = (placement ? placement.split('-')[0] : 'top') as Sides\n\n const arrowStyle: StackProps = { x, y, width: size, height: size }\n const innerArrowStyle: StackProps = {}\n const isVertical = primaryPlacement === 'bottom' || primaryPlacement === 'top'\n\n if (primaryPlacement) {\n // allows for extra diagonal size\n arrowStyle[isVertical ? 'width' : 'height'] = size * 2\n const oppSide = opposites[primaryPlacement]\n if (oppSide) {\n arrowStyle[oppSide] = -size\n innerArrowStyle[oppSide] = size / 2\n }\n if (oppSide === 'top' || oppSide === 'bottom') {\n arrowStyle.left = 0\n }\n if (oppSide === 'left' || oppSide === 'right') {\n arrowStyle.top = 0\n }\n }\n\n // send the Arrow's offset up to Popper\n useIsomorphicLayoutEffect(() => {\n context.onArrowSize?.(size)\n }, [size, context.onArrowSize])\n\n // outer frame to cut off for ability to have nicer shadows/borders\n return (\n <PopperArrowOuterFrame ref={refs} {...arrowStyle}>\n <PopperArrowFrame\n width={size}\n height={size}\n {...arrowProps}\n {...innerArrowStyle}\n rotate=\"45deg\"\n {...(primaryPlacement === 'bottom' && {\n borderBottomWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'top' && {\n borderTopWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n {...(primaryPlacement === 'right' && {\n borderTopWidth: borderWidth,\n borderRightWidth: borderWidth,\n })}\n {...(primaryPlacement === 'left' && {\n borderBottomWidth: borderWidth,\n borderLeftWidth: borderWidth,\n })}\n />\n </PopperArrowOuterFrame>\n )\n })\n)\n\nPopperArrow.displayName = ARROW_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport { usePopperContext }\n"],
5
+ "mappings": "AA8GI;AA5GJ,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAgB,0BAA0B;AAC1C,SAA4B,gBAAgB,cAA2B;AACvE,YAAY,WAAW;AAGvB,SAAsC,OAAO,YAAY,MAAM,QAAQ,aAAa;AACpF,SAA4B,mBAAmB;AAS/C,MAAM,cAAc;AAGpB,MAAM,CAAC,qBAAqB,WAAW,IAAI,mBAAmB,WAAW;AAElE,MAAM,oBAAoB;AAajC,MAAM,CAAC,gBAAgB,gBAAgB,IAAI,oBAAwC,WAAW;AAWvF,MAAM,SAAgC,CAAC,UAAoC;AAChF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,4BAA0B,MAAM;AAC9B,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,YAAY,MAAM,OAAY;AACpC,QAAM,CAAC,SAAS,QAAQ,IAAI,MAAM,SAAiC,IAAI;AACvE,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,S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AM,aAAyB,EAAE,GAAG,GAAG,OAAO,MAAM,QAAQ,KAAK;AACjE,UAAM,kBAA8B,CAAC;AACrC,UAAM,aAAa,qBAAqB,YAAY,qBAAqB;AAEzE,QAAI,kBAAkB;AAEpB,iBAAW,aAAa,UAAU,YAAY,OAAO;AACrD,YAAM,UAAU,UAAU;AAC1B,UAAI,SAAS;AACX,mBAAW,WAAW,CAAC;AACvB,wBAAgB,WAAW,OAAO;AAAA,MACpC;AACA,UAAI,YAAY,SAAS,YAAY,UAAU;AAC7C,mBAAW,OAAO;AAAA,MACpB;AACA,UAAI,YAAY,UAAU,YAAY,SAAS;AAC7C,mBAAW,MAAM;AAAA,MACnB;AAAA,IACF;AAGA,8BAA0B,MAAM;AAvTpC;AAwTM,oBAAQ,gBAAR,iCAAsB;AAAA,IACxB,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAG9B,WACE,oBAAC;AAAA,MAAsB,KAAK;AAAA,MAAO,GAAG;AAAA,MACpC,8BAAC;AAAA,QACC,OAAO;AAAA,QACP,QAAQ;AAAA,QACP,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,QAAO;AAAA,QACN,GAAI,qBAAqB,YAAY;AAAA,UACpC,mBAAmB;AAAA,UACnB,kBAAkB;AAAA,QACpB;AAAA,QACC,GAAI,qBAAqB,SAAS;AAAA,UACjC,gBAAgB;AAAA,UAChB,iBAAiB;AAAA,QACnB;AAAA,QACC,GAAI,qBAAqB,WAAW;AAAA,UACnC,gBAAgB;AAAA,UAChB,kBAAkB;AAAA,QACpB;AAAA,QACC,GAAI,qBAAqB,UAAU;AAAA,UAClC,mBAAmB;AAAA,UACnB,iBAAiB;AAAA,QACnB;AAAA,OACF;AAAA,KACF;AAAA,EAEJ,CAAC;AACH;AAEA,YAAY,cAAc;",
6
+ "names": ["PopperArrow", "offset"]
7
7
  }
File without changes
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/floating.tsx"],
4
4
  "sourcesContent": ["export * from '@floating-ui/react-dom'\n"],
5
- "mappings": "AAAA;",
5
+ "mappings": "AAAA,cAAc;",
6
6
  "names": []
7
7
  }
File without changes
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/floating.native.tsx"],
4
4
  "sourcesContent": ["export * from '@floating-ui/react-native'\n"],
5
- "mappings": "AAAA;",
5
+ "mappings": "AAAA,cAAc;",
6
6
  "names": []
7
7
  }
package/dist/esm/index.js CHANGED
File without changes
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx"],
4
4
  "sourcesContent": ["export { FloatingOverrideContext, type UseFloatingFn } from './useFloating'\nexport * from './Popper'\n"],
5
- "mappings": "AAAA;AACA;",
5
+ "mappings": "AAAA,SAAS,+BAAmD;AAC5D,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,13 +1,11 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  import { createContext, useContext } from "react";
4
2
  import * as Floating from "./floating";
5
3
  const FloatingOverrideContext = createContext(null);
6
- const useFloating = /* @__PURE__ */ __name((props) => {
4
+ const useFloating = (props) => {
7
5
  var _a;
8
6
  const context = useContext(FloatingOverrideContext);
9
7
  return (_a = context || Floating.useFloating) == null ? void 0 : _a(props);
10
- }, "useFloating");
8
+ };
11
9
  export {
12
10
  FloatingOverrideContext,
13
11
  useFloating
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/useFloating.tsx"],
4
- "sourcesContent": ["import { createContext, useContext } from 'react'\n\nimport * as Floating from './floating'\n\nexport type UseFloatingFn = typeof Floating.useFloating\n\ntype UseFloatingProps = UseFloatingFn extends (props: infer Props) => any ? Props : never\n\nexport type UseFloatingResult = ReturnType<UseFloatingFn> & {\n getFloatingProps?: (props: { ref: any; [key: string]: any }) => any\n getReferenceProps?: (props: { ref: any; [key: string]: any }) => any\n}\n\nexport const FloatingOverrideContext = createContext<UseFloatingFn | null>(null)\n\nexport const useFloating = (props: UseFloatingProps): UseFloatingResult => {\n const context = useContext(FloatingOverrideContext)\n return (context || Floating.useFloating)?.(props)\n}\n"],
5
- "mappings": ";;AAAA;AAEA;AAWO,MAAM,0BAA0B,cAAoC,IAAI;AAExE,MAAM,cAAc,wBAAC,UAA+C;AAf3E;AAgBE,QAAM,UAAU,WAAW,uBAAuB;AAClD,SAAQ,iBAAW,SAAS,gBAApB,mBAAmC;AAC7C,GAH2B;",
4
+ "sourcesContent": ["import { createContext, useContext } from 'react'\n\nimport * as Floating from './floating'\n\nexport type UseFloatingFn = typeof Floating.useFloating\n\ntype UseFloatingProps = UseFloatingFn extends (props: infer Props) => any ? Props : never\n\nexport type UseFloatingReturn = Floating.UseFloatingReturn & {\n context?: any\n getFloatingProps?: (props: { ref: any; [key: string]: any }) => any\n getReferenceProps?: (props: { ref: any; [key: string]: any }) => any\n}\n\nexport const FloatingOverrideContext = createContext<UseFloatingFn | null>(null)\n\nexport const useFloating = (props: UseFloatingProps): UseFloatingReturn => {\n const context = useContext(FloatingOverrideContext)\n return (context || Floating.useFloating)?.(props)\n}\n"],
5
+ "mappings": "AAAA,SAAS,eAAe,kBAAkB;AAE1C,YAAY,cAAc;AAYnB,MAAM,0BAA0B,cAAoC,IAAI;AAExE,MAAM,cAAc,CAAC,UAA+C;AAhB3E;AAiBE,QAAM,UAAU,WAAW,uBAAuB;AAClD,UAAQ,gBAAW,SAAS,gBAApB,mBAAmC;AAC7C;",
6
6
  "names": []
7
7
  }