@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,13 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  import { useComposedRefs } from "@tamagui/compose-refs";
4
2
  import {
5
3
  getTokens,
6
4
  getVariableValue,
5
+ stepTokenUpOrDown,
7
6
  styled,
8
7
  useIsomorphicLayoutEffect
9
8
  } from "@tamagui/core";
10
9
  import { createContextScope } from "@tamagui/create-context";
11
- import { SizableStack, YStack } from "@tamagui/stacks";
10
+ import { ThemeableStack, YStack } from "@tamagui/stacks";
12
11
  import * as React from "react";
13
12
  import { arrow, autoUpdate, flip, offset, shift } from "./floating";
14
13
  import { useFloating } from "./useFloating";
@@ -16,8 +15,16 @@ const POPPER_NAME = "Popper";
16
15
  const [createPopperContext, createScope] = createContextScope(POPPER_NAME);
17
16
  const createPopperScope = createScope;
18
17
  const [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
19
- const Popper = /* @__PURE__ */ __name((props) => {
20
- const { __scopePopper, children, size, placement = "bottom", stayInFrame, allowFlip } = props;
18
+ const Popper = (props) => {
19
+ const {
20
+ __scopePopper,
21
+ children,
22
+ size,
23
+ strategy = "absolute",
24
+ placement = "bottom",
25
+ stayInFrame,
26
+ allowFlip
27
+ } = props;
21
28
  const [isMounted, setIsMounted] = React.useState(false);
22
29
  useIsomorphicLayoutEffect(() => {
23
30
  setIsMounted(true);
@@ -27,10 +34,11 @@ const Popper = /* @__PURE__ */ __name((props) => {
27
34
  const [arrowSize, setArrowSize] = React.useState(0);
28
35
  const arrowRef = React.useRef();
29
36
  const floating = useFloating({
37
+ strategy,
30
38
  placement,
31
39
  middleware: [
32
- stayInFrame ? shift(stayInFrame) : null,
33
- allowFlip ? flip(allowFlip) : null,
40
+ stayInFrame ? shift(typeof stayInFrame === "boolean" ? {} : stayInFrame) : null,
41
+ allowFlip ? flip(typeof allowFlip === "boolean" ? {} : allowFlip) : null,
34
42
  arrowEl ? arrow({ element: arrowEl }) : null,
35
43
  arrowSize ? offset(arrowSize) : null
36
44
  ].filter(Boolean)
@@ -45,65 +53,89 @@ const Popper = /* @__PURE__ */ __name((props) => {
45
53
  return;
46
54
  }
47
55
  return autoUpdate(refs.reference.current, refs.floating.current, floating.update);
48
- }, [refs.floating.current, refs.reference.current]);
56
+ }, [floating.update, refs.floating, refs.reference]);
49
57
  const arrowStyle = React.useMemo(() => {
50
58
  return middlewareData.arrow;
51
59
  }, [JSON.stringify(middlewareData.arrow || {})]);
52
60
  return <PopperProvider scope={__scopePopper} anchorRef={anchorRef} size={size} arrowRef={composedArrowRefs} arrowStyle={arrowStyle} onArrowSize={setArrowSize} isMounted={isMounted} {...floating}>{children}</PopperProvider>;
53
- }, "Popper");
61
+ };
54
62
  Popper.displayName = POPPER_NAME;
55
63
  const ANCHOR_NAME = "PopperAnchor";
56
- const PopperAnchor = React.forwardRef((props, forwardedRef) => {
57
- const { __scopePopper, virtualRef, ...anchorProps } = props;
58
- const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper);
59
- const ref = React.useRef(null);
60
- const composedRefs = useComposedRefs(forwardedRef, ref, anchorRef);
61
- if (virtualRef) {
62
- return null;
64
+ const PopperAnchor = React.forwardRef(
65
+ (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;
72
+ }
73
+ const stackProps = {
74
+ ref: composedRefs,
75
+ ...anchorProps
76
+ };
77
+ return <YStack {...getReferenceProps ? getReferenceProps(stackProps) : stackProps} />;
63
78
  }
64
- const stackProps = {
65
- ref: composedRefs,
66
- ...anchorProps
67
- };
68
- return <YStack {...getReferenceProps ? getReferenceProps(stackProps) : stackProps} />;
69
- });
79
+ );
70
80
  PopperAnchor.displayName = ANCHOR_NAME;
71
81
  const CONTENT_NAME = "PopperContent";
72
- const PopperContentFrame = styled(SizableStack, {
82
+ const PopperContentFrame = styled(ThemeableStack, {
73
83
  name: "PopperContent",
74
84
  backgroundColor: "$background",
75
85
  alignItems: "center",
86
+ radiused: true,
87
+ variants: {
88
+ size: {
89
+ "...size": (val, { tokens }) => {
90
+ return {
91
+ padding: tokens.space[val],
92
+ borderRadius: tokens.radius[val]
93
+ };
94
+ }
95
+ }
96
+ },
76
97
  defaultVariants: {
77
98
  size: "$4"
78
99
  }
79
100
  });
80
- const PopperContent = React.forwardRef((props, forwardedRef) => {
81
- const { __scopePopper, ...contentProps } = props;
82
- const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
83
- const contentRefs = useComposedRefs(floating, forwardedRef);
84
- const contents = React.useMemo(() => {
85
- var _a;
86
- return <PopperContentFrame key="popper-content-frame" data-placement={placement} data-strategy={strategy} {...contentProps} size={(_a = contentProps.size) != null ? _a : size} />;
87
- }, [placement, strategy, props]);
88
- if (!isMounted) {
89
- return null;
90
- }
91
- const frameProps = {
92
- ref: contentRefs,
93
- x: x || 0,
94
- y: y || 0,
95
- position: "absolute"
96
- };
97
- return <YStack {...getFloatingProps ? getFloatingProps(frameProps) : frameProps}>{contents}</YStack>;
98
- });
101
+ const PopperContent = PopperContentFrame.extractable(
102
+ React.forwardRef(
103
+ (props, forwardedRef) => {
104
+ const { __scopePopper, ...contentProps } = props;
105
+ const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
106
+ const contentRefs = useComposedRefs(floating, forwardedRef);
107
+ const contents = React.useMemo(() => {
108
+ return <PopperContentFrame key="popper-content-frame" data-placement={placement} data-strategy={strategy} size={contentProps.size || size} {...contentProps} />;
109
+ }, [placement, strategy, props]);
110
+ if (!isMounted) {
111
+ return null;
112
+ }
113
+ const frameProps = {
114
+ ref: contentRefs,
115
+ x: x || 0,
116
+ y: y || 0,
117
+ position: strategy
118
+ };
119
+ return <YStack {...getFloatingProps ? getFloatingProps(frameProps) : frameProps}>{contents}</YStack>;
120
+ }
121
+ )
122
+ );
99
123
  PopperContent.displayName = CONTENT_NAME;
100
124
  const ARROW_NAME = "PopperArrow";
101
125
  const PopperArrowFrame = styled(YStack, {
102
126
  name: "PopperArrow",
103
127
  borderColor: "$borderColor",
104
128
  backgroundColor: "$background",
129
+ position: "relative"
130
+ });
131
+ const PopperArrowOuterFrame = styled(YStack, {
132
+ name: "PopperArrowOuter",
105
133
  position: "absolute",
106
- zIndex: 1
134
+ zIndex: -1,
135
+ pointerEvents: "none",
136
+ overflow: "hidden",
137
+ alignItems: "center",
138
+ justifyContent: "center"
107
139
  });
108
140
  const opposites = {
109
141
  top: "bottom",
@@ -111,54 +143,60 @@ const opposites = {
111
143
  bottom: "top",
112
144
  left: "right"
113
145
  };
114
- const PopperArrow = React.forwardRef(/* @__PURE__ */ __name(function PopperArrow2(props, forwardedRef) {
115
- var _a, _b;
116
- const { __scopePopper, offset: offset2, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
117
- const context = usePopperContext(ARROW_NAME, __scopePopper);
118
- const tokens = getTokens();
119
- const sizeVal = sizeProp != null ? sizeProp : context.size;
120
- const sizeValResolved = getVariableValue((_b = (_a = tokens.size[sizeVal]) != null ? _a : sizeVal) != null ? _b : 12);
121
- const size = +sizeValResolved;
122
- const { placement } = context;
123
- const { x, y } = context.arrowStyle || { x: 0, y: 0 };
124
- const refs = useComposedRefs(context.arrowRef, forwardedRef);
125
- const primaryPlacement = placement ? placement.split("-")[0] : "top";
126
- let arrowStyle = { x, y, width: size, height: size };
127
- if (primaryPlacement) {
128
- const oppSide = opposites[primaryPlacement];
129
- if (oppSide) {
130
- arrowStyle[oppSide] = -size / 2;
131
- }
132
- if (oppSide === "top" || oppSide === "bottom") {
133
- arrowStyle.left = 0;
146
+ const PopperArrow = PopperArrowFrame.extractable(
147
+ React.forwardRef(function PopperArrow2(props, forwardedRef) {
148
+ const { __scopePopper, offset: offset2, size: sizeProp, borderWidth = 0, ...arrowProps } = props;
149
+ const context = usePopperContext(ARROW_NAME, __scopePopper);
150
+ const tokens = getTokens();
151
+ const sizeVal = sizeProp ?? context.size;
152
+ const sizeValResolved = getVariableValue(stepTokenUpOrDown(tokens.space, sizeVal, -2, [2]));
153
+ const size = +sizeValResolved;
154
+ const { placement } = context;
155
+ const { x, y } = context.arrowStyle || { x: 0, y: 0 };
156
+ const refs = useComposedRefs(context.arrowRef, forwardedRef);
157
+ const primaryPlacement = placement ? placement.split("-")[0] : "top";
158
+ const arrowStyle = { x, y, width: size, height: size };
159
+ const innerArrowStyle = {};
160
+ const isVertical = primaryPlacement === "bottom" || primaryPlacement === "top";
161
+ if (primaryPlacement) {
162
+ arrowStyle[isVertical ? "width" : "height"] = size * 2;
163
+ const oppSide = opposites[primaryPlacement];
164
+ if (oppSide) {
165
+ arrowStyle[oppSide] = -size;
166
+ innerArrowStyle[oppSide] = size / 2;
167
+ }
168
+ if (oppSide === "top" || oppSide === "bottom") {
169
+ arrowStyle.left = 0;
170
+ }
171
+ if (oppSide === "left" || oppSide === "right") {
172
+ arrowStyle.top = 0;
173
+ }
134
174
  }
135
- if (oppSide === "left" || oppSide === "right") {
136
- arrowStyle.top = 0;
137
- }
138
- }
139
- useIsomorphicLayoutEffect(() => {
140
- var _a2;
141
- (_a2 = context.onArrowSize) == null ? void 0 : _a2.call(context, size);
142
- }, [size, context.onArrowSize]);
143
- return <PopperArrowFrame {...arrowProps} ref={refs} {...arrowStyle} rotate="45deg" {...primaryPlacement === "top" && {
144
- borderBottomWidth: borderWidth,
145
- borderRightWidth: borderWidth
146
- }} {...primaryPlacement === "bottom" && {
147
- borderTopWidth: borderWidth,
148
- borderLeftWidth: borderWidth
149
- }} {...primaryPlacement === "left" && {
150
- borderTopWidth: borderWidth,
151
- borderRightWidth: borderWidth
152
- }} {...primaryPlacement === "right" && {
153
- borderBottomWidth: borderWidth,
154
- borderLeftWidth: borderWidth
155
- }} />;
156
- }, "PopperArrow"));
175
+ useIsomorphicLayoutEffect(() => {
176
+ context.onArrowSize?.(size);
177
+ }, [size, context.onArrowSize]);
178
+ return <PopperArrowOuterFrame ref={refs} {...arrowStyle}><PopperArrowFrame width={size} height={size} {...arrowProps} {...innerArrowStyle} rotate="45deg" {...primaryPlacement === "bottom" && {
179
+ borderBottomWidth: borderWidth,
180
+ borderRightWidth: borderWidth
181
+ }} {...primaryPlacement === "top" && {
182
+ borderTopWidth: borderWidth,
183
+ borderLeftWidth: borderWidth
184
+ }} {...primaryPlacement === "right" && {
185
+ borderTopWidth: borderWidth,
186
+ borderRightWidth: borderWidth
187
+ }} {...primaryPlacement === "left" && {
188
+ borderBottomWidth: borderWidth,
189
+ borderLeftWidth: borderWidth
190
+ }} /></PopperArrowOuterFrame>;
191
+ })
192
+ );
157
193
  PopperArrow.displayName = ARROW_NAME;
158
194
  export {
159
195
  Popper,
160
196
  PopperAnchor,
161
197
  PopperArrow,
162
198
  PopperContent,
163
- createPopperScope
199
+ createPopperScope,
200
+ usePopperContext
164
201
  };
202
+ //# sourceMappingURL=Popper.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 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": "AAEA,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,SAAS,CAAC;AAClD,QAAM,WAAW,MAAM,OAAO;AAE9B,QAAM,WAAW,YAAY;AAAA,IAC3B;AAAA,IACA;AAAA,IACA,YA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I,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;AAC9B,cAAQ,cAAc,IAAI;AAAA,IAC5B,GAAG,CAAC,MAAM,QAAQ,WAAW,CAAC;AAG9B,WACE,CAAC,sBAAsB,KAAK,UAAU,YACpC,CAAC,iBACC,OAAO,MACP,QAAQ,UACJ,gBACA,iBACJ,OAAO,YACF,qBAAqB,YAAY;AAAA,MACpC,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,IACpB,OACK,qBAAqB,SAAS;AAAA,MACjC,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACnB,OACK,qBAAqB,WAAW;AAAA,MACnC,gBAAgB;AAAA,MAChB,kBAAkB;AAAA,IACpB,OACK,qBAAqB,UAAU;AAAA,MAClC,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,IACnB,GACF,EACF,EAxBC;AAAA,EA0BL,CAAC;AACH;AAEA,YAAY,cAAc;",
6
+ "names": ["PopperArrow", "offset"]
7
+ }
@@ -1 +1,2 @@
1
1
  export * from "@floating-ui/react-dom";
2
+ //# sourceMappingURL=floating.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/floating.tsx"],
4
+ "sourcesContent": ["export * from '@floating-ui/react-dom'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -1 +1,2 @@
1
1
  export * from "@floating-ui/react-native";
2
+ //# sourceMappingURL=floating.native.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/floating.native.tsx"],
4
+ "sourcesContent": ["export * from '@floating-ui/react-native'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
package/dist/jsx/index.js CHANGED
@@ -3,3 +3,4 @@ export * from "./Popper";
3
3
  export {
4
4
  FloatingOverrideContext
5
5
  };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "sourcesContent": ["export { FloatingOverrideContext, type UseFloatingFn } from './useFloating'\nexport * from './Popper'\n"],
5
+ "mappings": "AAAA,SAAS,+BAAmD;AAC5D,cAAc;",
6
+ "names": []
7
+ }
@@ -1,14 +1,12 @@
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) => {
7
- var _a;
4
+ const useFloating = (props) => {
8
5
  const context = useContext(FloatingOverrideContext);
9
- return (_a = context || Floating.useFloating) == null ? void 0 : _a(props);
10
- }, "useFloating");
6
+ return (context || Floating.useFloating)?.(props);
7
+ };
11
8
  export {
12
9
  FloatingOverrideContext,
13
10
  useFloating
14
11
  };
12
+ //# sourceMappingURL=useFloating.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 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;AACzE,QAAM,UAAU,WAAW,uBAAuB;AAClD,UAAQ,WAAW,SAAS,eAAe,KAAK;AAClD;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,30 +1,35 @@
1
1
  {
2
2
  "name": "@tamagui/popper",
3
- "version": "1.0.1-beta.21",
4
- "sideEffects": true,
3
+ "version": "1.0.1-beta.210",
4
+ "sideEffects": [
5
+ "*.css"
6
+ ],
5
7
  "source": "src/index.ts",
6
- "typings": "types",
8
+ "types": "./types/index.d.ts",
7
9
  "main": "dist/cjs",
8
10
  "module": "dist/esm",
9
11
  "module:jsx": "dist/jsx",
10
12
  "files": [
13
+ "src",
11
14
  "types",
12
15
  "dist"
13
16
  ],
14
17
  "scripts": {
15
18
  "build": "tamagui-build",
16
19
  "watch": "tamagui-build --watch",
20
+ "lint": "eslint",
21
+ "lint:fix": "yarn lint --fix",
17
22
  "clean": "tamagui-build clean",
18
23
  "clean:build": "tamagui-build clean:build"
19
24
  },
20
25
  "dependencies": {
21
- "@floating-ui/react-dom": "0.7.0",
22
- "@floating-ui/react-native": "^0.7.0",
23
- "@tamagui/compose-refs": "^1.0.1-beta.21",
24
- "@tamagui/core": "^1.0.1-beta.21",
25
- "@tamagui/create-context": "^1.0.1-beta.21",
26
- "@tamagui/stacks": "^1.0.1-beta.21",
27
- "@tamagui/use-controllable-state": "^1.0.1-beta.21"
26
+ "@floating-ui/react-dom": "^1.0.0",
27
+ "@floating-ui/react-native": "^0.8.0",
28
+ "@tamagui/compose-refs": "^1.0.1-beta.210",
29
+ "@tamagui/core": "^1.0.1-beta.210",
30
+ "@tamagui/create-context": "^1.0.1-beta.210",
31
+ "@tamagui/stacks": "^1.0.1-beta.210",
32
+ "@tamagui/use-controllable-state": "^1.0.1-beta.210"
28
33
  },
29
34
  "peerDependencies": {
30
35
  "react": "*",
@@ -32,8 +37,8 @@
32
37
  "react-native": "*"
33
38
  },
34
39
  "devDependencies": {
35
- "@tamagui/build": "^1.0.1-beta.21",
36
- "@types/react-native": "^0.67.3",
40
+ "@tamagui/build": "^1.0.1-beta.210",
41
+ "@types/react-native": "^0.69.2",
37
42
  "react": "*",
38
43
  "react-dom": "*",
39
44
  "react-native": "*"