@tamagui/popper 1.5.19 → 1.5.21

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.
@@ -22,7 +22,7 @@ const POPPER_NAME = "Popper";
22
22
  const [createPopperContext, createScope] = createContextScope(POPPER_NAME);
23
23
  const createPopperScope = createScope;
24
24
  const [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
25
- const Popper = (props) => {
25
+ function Popper(props) {
26
26
  const {
27
27
  __scopePopper,
28
28
  children,
@@ -93,11 +93,10 @@ const Popper = (props) => {
93
93
  isMounted={isMounted}
94
94
  {...floating}
95
95
  >{children}</PopperProvider>;
96
- };
97
- Popper.displayName = POPPER_NAME;
96
+ }
98
97
  const ANCHOR_NAME = "PopperAnchor";
99
- const PopperAnchor = React.forwardRef(
100
- (props, forwardedRef) => {
98
+ const PopperAnchor = YStack.extractable(
99
+ React.forwardRef(function PopperAnchor2(props, forwardedRef) {
101
100
  const { __scopePopper, virtualRef, ...anchorProps } = props;
102
101
  const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper);
103
102
  const ref = React.useRef(null);
@@ -110,16 +109,20 @@ const PopperAnchor = React.forwardRef(
110
109
  ...anchorProps
111
110
  };
112
111
  return <YStack {...getReferenceProps ? getReferenceProps(stackProps) : stackProps} />;
113
- }
112
+ })
114
113
  );
115
- PopperAnchor.displayName = ANCHOR_NAME;
116
114
  const CONTENT_NAME = "PopperContent";
117
115
  const PopperContentFrame = styled(ThemeableStack, {
118
116
  name: "PopperContent",
119
- backgroundColor: "$background",
120
- alignItems: "center",
121
- radiused: true,
122
117
  variants: {
118
+ unstyled: {
119
+ false: {
120
+ size: "$true",
121
+ backgroundColor: "$background",
122
+ alignItems: "center",
123
+ radiused: true
124
+ }
125
+ },
123
126
  size: {
124
127
  "...size": (val, { tokens }) => {
125
128
  return {
@@ -130,56 +133,71 @@ const PopperContentFrame = styled(ThemeableStack, {
130
133
  }
131
134
  },
132
135
  defaultVariants: {
133
- size: "$true"
136
+ unstyled: false
134
137
  }
135
138
  });
136
- const PopperContent = PopperContentFrame.extractable(
137
- React.forwardRef(
138
- (props, forwardedRef) => {
139
- const { __scopePopper, ...contentProps } = props;
140
- const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
141
- const contentRefs = useComposedRefs(floating, forwardedRef);
142
- const contents = React.useMemo(() => {
143
- return <PopperContentFrame
144
- key="popper-content-frame"
145
- data-placement={placement}
146
- data-strategy={strategy}
147
- size={contentProps.size || size}
148
- {...contentProps}
149
- />;
150
- }, [placement, strategy, props]);
151
- if (!isMounted) {
152
- return null;
153
- }
154
- const frameProps = {
155
- ref: contentRefs,
156
- x: x || 0,
157
- y: y || 0,
158
- position: strategy
159
- };
160
- return <YStack
161
- animateOnly={["transform"]}
162
- {...getFloatingProps ? getFloatingProps(frameProps) : frameProps}
163
- >{contents}</YStack>;
139
+ const PopperContent = React.forwardRef(
140
+ function PopperContent2(props, forwardedRef) {
141
+ const { __scopePopper, ...contentProps } = props;
142
+ const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } = usePopperContext(CONTENT_NAME, __scopePopper);
143
+ const contentRefs = useComposedRefs(floating, forwardedRef);
144
+ const contents = React.useMemo(() => {
145
+ return <PopperContentFrame
146
+ key="popper-content-frame"
147
+ data-placement={placement}
148
+ data-strategy={strategy}
149
+ size={contentProps.size || size}
150
+ {...contentProps}
151
+ />;
152
+ }, [placement, strategy, props]);
153
+ if (!isMounted) {
154
+ return null;
164
155
  }
165
- )
156
+ const frameProps = {
157
+ ref: contentRefs,
158
+ x: x || 0,
159
+ y: y || 0,
160
+ position: strategy
161
+ };
162
+ return <YStack
163
+ animateOnly={["transform"]}
164
+ {...getFloatingProps ? getFloatingProps(frameProps) : frameProps}
165
+ >{contents}</YStack>;
166
+ }
166
167
  );
167
- PopperContent.displayName = CONTENT_NAME;
168
168
  const ARROW_NAME = "PopperArrow";
169
169
  const PopperArrowFrame = styled(YStack, {
170
170
  name: "PopperArrow",
171
- borderColor: "$borderColor",
172
- backgroundColor: "$background",
173
- position: "relative"
171
+ variants: {
172
+ unstyled: {
173
+ false: {
174
+ borderColor: "$borderColor",
175
+ backgroundColor: "$background",
176
+ position: "relative"
177
+ }
178
+ }
179
+ },
180
+ defaultVariants: {
181
+ unstyled: false
182
+ }
174
183
  });
175
184
  const PopperArrowOuterFrame = styled(YStack, {
176
185
  name: "PopperArrowOuter",
177
- position: "absolute",
178
- zIndex: -1,
179
- pointerEvents: "none",
180
- overflow: "hidden",
181
- alignItems: "center",
182
- justifyContent: "center"
186
+ variants: {
187
+ unstyled: {
188
+ false: {
189
+ position: "absolute",
190
+ zIndex: -1,
191
+ pointerEvents: "none",
192
+ overflow: "hidden",
193
+ alignItems: "center",
194
+ justifyContent: "center"
195
+ }
196
+ }
197
+ },
198
+ defaultVariants: {
199
+ unstyled: false
200
+ }
183
201
  });
184
202
  const opposites = {
185
203
  top: "bottom",
@@ -250,12 +268,12 @@ const PopperArrow = PopperArrowFrame.extractable(
250
268
  /></PopperArrowOuterFrame>;
251
269
  })
252
270
  );
253
- PopperArrow.displayName = ARROW_NAME;
254
271
  export {
255
272
  Popper,
256
273
  PopperAnchor,
257
274
  PopperArrow,
258
275
  PopperContent,
276
+ PopperContentFrame,
259
277
  PopperProvider,
260
278
  createPopperScope,
261
279
  usePopperContext
@@ -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 getVariableValue,\n isWeb,\n styled,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport {\n Coords,\n Placement,\n Strategy,\n UseFloatingReturn,\n arrow,\n autoUpdate,\n flip,\n offset,\n shift,\n useFloating,\n} from '@tamagui/floating'\nimport { stepTokenUpOrDown } from '@tamagui/get-size'\nimport { SizableStackProps, ThemeableStack, YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { Keyboard, View, useWindowDimensions } from 'react-native'\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}\nexport const [PopperProvider, usePopperContext] =\n 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<any>(null)\n const [arrowSize, setArrowSize] = React.useState(0)\n const arrowRef = React.useRef()\n\n const floating = useFloating({\n strategy,\n placement,\n sameScrollView: false, // this only takes effect on native\n middleware: [\n stayInFrame\n ? shift(typeof stayInFrame === 'boolean' ? {} : stayInFrame)\n : (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 if (isWeb) {\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 } else {\n // On Native there's no autoupdate so we call update() when necessary\n\n // Subscribe to window dimensions (orientation, scale, etc...)\n const dimensions = useWindowDimensions()\n\n // Subscribe to keyboard state\n const [keyboardOpen, setKeyboardOpen] = React.useState(false)\n React.useEffect(() => {\n const showSubscription = Keyboard.addListener('keyboardDidShow', () => {\n setKeyboardOpen(true)\n })\n const hideSubscription = Keyboard.addListener('keyboardDidHide', () => {\n setKeyboardOpen(false)\n })\n\n return () => {\n showSubscription.remove()\n hideSubscription.remove()\n }\n }, [])\n\n useIsomorphicLayoutEffect(() => {\n floating.update()\n }, [dimensions, keyboardOpen])\n }\n\n return (\n <PopperProvider\n scope={__scopePopper}\n anchorRef={anchorRef}\n size={size}\n arrowRef={composedArrowRefs}\n arrowStyle={middlewareData.arrow}\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 (\n <YStack {...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)} />\n )\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: '$true',\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\n animateOnly={['transform']}\n {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}\n >\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 {\n __scopePopper,\n offset,\n size: sizeProp,\n borderWidth = 0,\n ...arrowProps\n } = props\n const context = usePopperContext(ARROW_NAME, __scopePopper)\n const sizeVal = sizeProp ?? context.size\n const sizeValResolved = getVariableValue(stepTokenUpOrDown('space', sizeVal, -2, [2]))\n const size = +sizeValResolved\n const { placement } = context\n const refs = useComposedRefs(context.arrowRef, forwardedRef)\n\n // Sometimes floating-ui can return NaN during orientation or screen size changes on native\n // so we explictly force the x,y position types as a number\n const x = (context.arrowStyle?.x as number) || 0\n const y = (context.arrowStyle?.y as number) || 0\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"],
5
- "mappings": "AAEA,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAgB,0BAA0B;AAC1C;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAA4B,gBAAgB,cAA2B;AACvE,YAAY,WAAW;AACvB,SAAS,UAAgB,2BAA2B;AASpD,MAAM,cAAc;AAGpB,MAAM,CAAC,qBAAqB,WAAW,IAAI,mBAAmB,WAAW;AAElE,MAAM,oBAAoB;AAa1B,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;AAW9C,MAAM,SAAgC,CAAC,UAAoC;AA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AC7C,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;AAAA,MACC,OAAO;AAAA,MACP,QAAQ;AAAA,UACJ;AAAA,UACA;AAAA,MACJ,OAAO;AAAA,UACF,qBAAqB,YAAY;AAAA,QACpC,mBAAmB;AAAA,QACnB,kBAAkB;AAAA,MACpB;AAAA,UACK,qBAAqB,SAAS;AAAA,QACjC,gBAAgB;AAAA,QAChB,iBAAiB;AAAA,MACnB;AAAA,UACK,qBAAqB,WAAW;AAAA,QACnC,gBAAgB;AAAA,QAChB,kBAAkB;AAAA,MACpB;AAAA,UACK,qBAAqB,UAAU;AAAA,QAClC,mBAAmB;AAAA,QACnB,iBAAiB;AAAA,MACnB;AAAA,IACF,EACF,EAxBC;AAAA,EA0BL,CAAC;AACH;AAEA,YAAY,cAAc;",
6
- "names": ["PopperArrow", "offset"]
4
+ "sourcesContent": ["// adapted from radix-ui popper\n\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n SizeTokens,\n StackProps,\n getVariableValue,\n isWeb,\n styled,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { Scope, createContextScope } from '@tamagui/create-context'\nimport {\n Coords,\n Placement,\n Strategy,\n UseFloatingReturn,\n arrow,\n autoUpdate,\n flip,\n offset,\n shift,\n useFloating,\n} from '@tamagui/floating'\nimport { stepTokenUpOrDown } from '@tamagui/get-size'\nimport { SizableStackProps, ThemeableStack, YStack, YStackProps } from '@tamagui/stacks'\nimport * as React from 'react'\nimport { Keyboard, View, useWindowDimensions } from 'react-native'\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}\nexport const [PopperProvider, usePopperContext] =\n 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 function Popper(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<any>(null)\n const [arrowSize, setArrowSize] = React.useState(0)\n const arrowRef = React.useRef()\n\n const floating = useFloating({\n strategy,\n placement,\n sameScrollView: false, // this only takes effect on native\n middleware: [\n stayInFrame\n ? shift(typeof stayInFrame === 'boolean' ? {} : stayInFrame)\n : (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 if (isWeb) {\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 } else {\n // On Native there's no autoupdate so we call update() when necessary\n\n // Subscribe to window dimensions (orientation, scale, etc...)\n const dimensions = useWindowDimensions()\n\n // Subscribe to keyboard state\n const [keyboardOpen, setKeyboardOpen] = React.useState(false)\n React.useEffect(() => {\n const showSubscription = Keyboard.addListener('keyboardDidShow', () => {\n setKeyboardOpen(true)\n })\n const hideSubscription = Keyboard.addListener('keyboardDidHide', () => {\n setKeyboardOpen(false)\n })\n\n return () => {\n showSubscription.remove()\n hideSubscription.remove()\n }\n }, [])\n\n useIsomorphicLayoutEffect(() => {\n floating.update()\n }, [dimensions, keyboardOpen])\n }\n\n return (\n <PopperProvider\n scope={__scopePopper}\n anchorRef={anchorRef}\n size={size}\n arrowRef={composedArrowRefs}\n arrowStyle={middlewareData.arrow}\n onArrowSize={setArrowSize}\n isMounted={isMounted}\n {...floating}\n >\n {children}\n </PopperProvider>\n )\n}\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 = YStack.extractable(\n React.forwardRef<PopperAnchorRef, PopperAnchorProps>(function PopperAnchor(\n props: ScopedProps<PopperAnchorProps>,\n forwardedRef\n ) {\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 (\n <YStack {...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)} />\n )\n })\n)\n\n/* -------------------------------------------------------------------------------------------------\n * PopperContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopperContent'\n\ntype PopperContentElement = HTMLElement | View\n\nexport type PopperContentProps = SizableStackProps\n\nexport const PopperContentFrame = styled(ThemeableStack, {\n name: 'PopperContent',\n\n variants: {\n unstyled: {\n false: {\n size: '$true',\n backgroundColor: '$background',\n alignItems: 'center',\n radiused: true,\n },\n },\n\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 unstyled: false,\n },\n})\n\nexport const PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(\n function PopperContent(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\n animateOnly={['transform']}\n {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}\n >\n {contents}\n </YStack>\n )\n }\n)\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\n variants: {\n unstyled: {\n false: {\n borderColor: '$borderColor',\n backgroundColor: '$background',\n position: 'relative',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\n})\n\nconst PopperArrowOuterFrame = styled(YStack, {\n name: 'PopperArrowOuter',\n\n variants: {\n unstyled: {\n false: {\n position: 'absolute',\n zIndex: -1,\n pointerEvents: 'none',\n overflow: 'hidden',\n alignItems: 'center',\n justifyContent: 'center',\n },\n },\n } as const,\n\n defaultVariants: {\n unstyled: false,\n },\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 {\n __scopePopper,\n offset,\n size: sizeProp,\n borderWidth = 0,\n ...arrowProps\n } = props\n const context = usePopperContext(ARROW_NAME, __scopePopper)\n const sizeVal = sizeProp ?? context.size\n const sizeValResolved = getVariableValue(stepTokenUpOrDown('space', sizeVal, -2, [2]))\n const size = +sizeValResolved\n const { placement } = context\n const refs = useComposedRefs(context.arrowRef, forwardedRef)\n\n // Sometimes floating-ui can return NaN during orientation or screen size changes on native\n // so we explictly force the x,y position types as a number\n const x = (context.arrowStyle?.x as number) || 0\n const y = (context.arrowStyle?.y as number) || 0\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\n/* -----------------------------------------------------------------------------------------------*/\n"],
5
+ "mappings": "AAEA,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAgB,0BAA0B;AAC1C;AAAA,EAKE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAA4B,gBAAgB,cAA2B;AACvE,YAAY,WAAW;AACvB,SAAS,UAAgB,2BAA2B;AASpD,MAAM,cAAc;AAGpB,MAAM,CAAC,qBAAqB,WAAW,IAAI,mBAAmB,WAAW;AAElE,MAAM,oBAAoB;AAa1B,MAAM,CAAC,gBAAgB,gBAAgB,IAC5C,oBAAwC,WAAW;AAW9C,SAAS,OAAO,OAAiC;AACtD,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;AAA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AAW,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;AAAA,MACC,OAAO;AAAA,MACP,QAAQ;AAAA,UACJ;AAAA,UACA;AAAA,MACJ,OAAO;AAAA,UACF,qBAAqB,YAAY;AAAA,QACpC,mBAAmB;AAAA,QACnB,kBAAkB;AAAA,MACpB;AAAA,UACK,qBAAqB,SAAS;AAAA,QACjC,gBAAgB;AAAA,QAChB,iBAAiB;AAAA,MACnB;AAAA,UACK,qBAAqB,WAAW;AAAA,QACnC,gBAAgB;AAAA,QAChB,kBAAkB;AAAA,MACpB;AAAA,UACK,qBAAqB,UAAU;AAAA,QAClC,mBAAmB;AAAA,QACnB,iBAAiB;AAAA,MACnB;AAAA,IACF,EACF,EAxBC;AAAA,EA0BL,CAAC;AACH;",
6
+ "names": ["PopperAnchor", "PopperContent", "PopperArrow", "offset"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/popper",
3
- "version": "1.5.19",
3
+ "version": "1.5.21",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -25,13 +25,13 @@
25
25
  "dependencies": {
26
26
  "@floating-ui/react-dom": "^1.2.2",
27
27
  "@floating-ui/react-native": "^0.9.0",
28
- "@tamagui/compose-refs": "^1.5.19",
29
- "@tamagui/core": "^1.5.19",
30
- "@tamagui/create-context": "^1.5.19",
31
- "@tamagui/floating": "^1.5.19",
32
- "@tamagui/get-size": "^1.5.19",
33
- "@tamagui/stacks": "^1.5.19",
34
- "@tamagui/use-controllable-state": "^1.5.19"
28
+ "@tamagui/compose-refs": "^1.5.21",
29
+ "@tamagui/core": "^1.5.21",
30
+ "@tamagui/create-context": "^1.5.21",
31
+ "@tamagui/floating": "^1.5.21",
32
+ "@tamagui/get-size": "^1.5.21",
33
+ "@tamagui/stacks": "^1.5.21",
34
+ "@tamagui/use-controllable-state": "^1.5.21"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "*",
@@ -39,7 +39,7 @@
39
39
  "react-native": "*"
40
40
  },
41
41
  "devDependencies": {
42
- "@tamagui/build": "^1.5.19",
42
+ "@tamagui/build": "^1.5.21",
43
43
  "react": "^18.2.0",
44
44
  "react-dom": "^18.2.0",
45
45
  "react-native": "*"
package/src/Popper.tsx CHANGED
@@ -64,7 +64,7 @@ export type PopperProps = {
64
64
  strategy?: Strategy
65
65
  }
66
66
 
67
- export const Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) => {
67
+ export function Popper(props: ScopedProps<PopperProps>) {
68
68
  const {
69
69
  __scopePopper,
70
70
  children,
@@ -158,8 +158,6 @@ export const Popper: React.FC<PopperProps> = (props: ScopedProps<PopperProps>) =
158
158
  )
159
159
  }
160
160
 
161
- Popper.displayName = POPPER_NAME
162
-
163
161
  /* -------------------------------------------------------------------------------------------------
164
162
  * PopperAnchor
165
163
  * -----------------------------------------------------------------------------------------------*/
@@ -172,8 +170,11 @@ export type PopperAnchorProps = YStackProps & {
172
170
  virtualRef?: React.RefObject<any>
173
171
  }
174
172
 
175
- export const PopperAnchor = React.forwardRef<PopperAnchorRef, PopperAnchorProps>(
176
- (props: ScopedProps<PopperAnchorProps>, forwardedRef) => {
173
+ export const PopperAnchor = YStack.extractable(
174
+ React.forwardRef<PopperAnchorRef, PopperAnchorProps>(function PopperAnchor(
175
+ props: ScopedProps<PopperAnchorProps>,
176
+ forwardedRef
177
+ ) {
177
178
  const { __scopePopper, virtualRef, ...anchorProps } = props
178
179
  const { anchorRef, getReferenceProps } = usePopperContext(ANCHOR_NAME, __scopePopper)
179
180
  const ref = React.useRef<PopperAnchorRef>(null)
@@ -188,11 +189,9 @@ export const PopperAnchor = React.forwardRef<PopperAnchorRef, PopperAnchorProps>
188
189
  return (
189
190
  <YStack {...(getReferenceProps ? getReferenceProps(stackProps) : stackProps)} />
190
191
  )
191
- }
192
+ })
192
193
  )
193
194
 
194
- PopperAnchor.displayName = ANCHOR_NAME
195
-
196
195
  /* -------------------------------------------------------------------------------------------------
197
196
  * PopperContent
198
197
  * -----------------------------------------------------------------------------------------------*/
@@ -203,13 +202,19 @@ type PopperContentElement = HTMLElement | View
203
202
 
204
203
  export type PopperContentProps = SizableStackProps
205
204
 
206
- const PopperContentFrame = styled(ThemeableStack, {
205
+ export const PopperContentFrame = styled(ThemeableStack, {
207
206
  name: 'PopperContent',
208
- backgroundColor: '$background',
209
- alignItems: 'center',
210
- radiused: true,
211
207
 
212
208
  variants: {
209
+ unstyled: {
210
+ false: {
211
+ size: '$true',
212
+ backgroundColor: '$background',
213
+ alignItems: 'center',
214
+ radiused: true,
215
+ },
216
+ },
217
+
213
218
  size: {
214
219
  '...size': (val, { tokens }) => {
215
220
  return {
@@ -221,56 +226,52 @@ const PopperContentFrame = styled(ThemeableStack, {
221
226
  } as const,
222
227
 
223
228
  defaultVariants: {
224
- size: '$true',
229
+ unstyled: false,
225
230
  },
226
231
  })
227
232
 
228
- export const PopperContent = PopperContentFrame.extractable(
229
- React.forwardRef<PopperContentElement, PopperContentProps>(
230
- (props: ScopedProps<PopperContentProps>, forwardedRef) => {
231
- const { __scopePopper, ...contentProps } = props
232
- const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } =
233
- usePopperContext(CONTENT_NAME, __scopePopper)
234
- const contentRefs = useComposedRefs<any>(floating, forwardedRef)
235
-
236
- const contents = React.useMemo(() => {
237
- return (
238
- <PopperContentFrame
239
- key="popper-content-frame"
240
- data-placement={placement}
241
- data-strategy={strategy}
242
- size={contentProps.size || size}
243
- {...contentProps}
244
- />
245
- )
246
- }, [placement, strategy, props])
247
-
248
- // all poppers hidden on ssr by default
249
- if (!isMounted) {
250
- return null
251
- }
252
-
253
- const frameProps = {
254
- ref: contentRefs,
255
- x: x || 0,
256
- y: y || 0,
257
- position: strategy,
258
- }
233
+ export const PopperContent = React.forwardRef<PopperContentElement, PopperContentProps>(
234
+ function PopperContent(props: ScopedProps<PopperContentProps>, forwardedRef) {
235
+ const { __scopePopper, ...contentProps } = props
236
+ const { strategy, placement, floating, x, y, getFloatingProps, size, isMounted } =
237
+ usePopperContext(CONTENT_NAME, __scopePopper)
238
+ const contentRefs = useComposedRefs<any>(floating, forwardedRef)
259
239
 
260
- // outer frame because we explicitly dont want animation to apply to this
240
+ const contents = React.useMemo(() => {
261
241
  return (
262
- <YStack
263
- animateOnly={['transform']}
264
- {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}
265
- >
266
- {contents}
267
- </YStack>
242
+ <PopperContentFrame
243
+ key="popper-content-frame"
244
+ data-placement={placement}
245
+ data-strategy={strategy}
246
+ size={contentProps.size || size}
247
+ {...contentProps}
248
+ />
268
249
  )
250
+ }, [placement, strategy, props])
251
+
252
+ // all poppers hidden on ssr by default
253
+ if (!isMounted) {
254
+ return null
269
255
  }
270
- )
271
- )
272
256
 
273
- PopperContent.displayName = CONTENT_NAME
257
+ const frameProps = {
258
+ ref: contentRefs,
259
+ x: x || 0,
260
+ y: y || 0,
261
+ position: strategy,
262
+ }
263
+
264
+ // outer frame because we explicitly dont want animation to apply to this
265
+ return (
266
+ <YStack
267
+ animateOnly={['transform']}
268
+ {...(getFloatingProps ? getFloatingProps(frameProps) : frameProps)}
269
+ >
270
+ {contents}
271
+ </YStack>
272
+ )
273
+ }
274
+ )
274
275
 
275
276
  /* -------------------------------------------------------------------------------------------------
276
277
  * PopperArrow
@@ -287,19 +288,41 @@ export type PopperArrowProps = YStackProps & {
287
288
 
288
289
  const PopperArrowFrame = styled(YStack, {
289
290
  name: 'PopperArrow',
290
- borderColor: '$borderColor',
291
- backgroundColor: '$background',
292
- position: 'relative',
291
+
292
+ variants: {
293
+ unstyled: {
294
+ false: {
295
+ borderColor: '$borderColor',
296
+ backgroundColor: '$background',
297
+ position: 'relative',
298
+ },
299
+ },
300
+ } as const,
301
+
302
+ defaultVariants: {
303
+ unstyled: false,
304
+ },
293
305
  })
294
306
 
295
307
  const PopperArrowOuterFrame = styled(YStack, {
296
308
  name: 'PopperArrowOuter',
297
- position: 'absolute',
298
- zIndex: -1,
299
- pointerEvents: 'none',
300
- overflow: 'hidden',
301
- alignItems: 'center',
302
- justifyContent: 'center',
309
+
310
+ variants: {
311
+ unstyled: {
312
+ false: {
313
+ position: 'absolute',
314
+ zIndex: -1,
315
+ pointerEvents: 'none',
316
+ overflow: 'hidden',
317
+ alignItems: 'center',
318
+ justifyContent: 'center',
319
+ },
320
+ },
321
+ } as const,
322
+
323
+ defaultVariants: {
324
+ unstyled: false,
325
+ },
303
326
  })
304
327
 
305
328
  const opposites = {
@@ -393,6 +416,4 @@ export const PopperArrow = PopperArrowFrame.extractable(
393
416
  })
394
417
  )
395
418
 
396
- PopperArrow.displayName = ARROW_NAME
397
-
398
419
  /* -----------------------------------------------------------------------------------------------*/