11import React , { cloneElement , Fragment } from 'react' ;
2+ import { View } from 'react-native' ;
23import { Portal } from '@gorhom/portal' ;
34import { AnimatePresence } from 'framer-motion' ;
4- import { StyleSheet , View } from 'react-native' ;
55
66import { useLayout } from './hooks' ;
77
8- import { Wrapper } from './components' ;
98import type { TooltipProps } from './types' ;
9+ import { Wrapper , ChildWrapper } from './components' ;
1010
1111const Tooltip : React . FC < TooltipProps > = ( props ) => {
12- const { children, isVisible, renderContent, childrenStyle, ...restProps } =
13- props ;
12+ const {
13+ children,
14+ isVisible,
15+ renderContent,
16+ withOverlay,
17+ childrenStyle,
18+ ...restProps
19+ } = props ;
1420 const { onLayout, ...layout } = useLayout ( ) ;
1521
1622 return (
@@ -22,19 +28,17 @@ const Tooltip: React.FC<TooltipProps> = (props) => {
2228 < AnimatePresence >
2329 { isVisible && (
2430 < Fragment >
25- < Wrapper { ...restProps } childrenLayout = { layout } >
31+ < Wrapper
32+ { ...restProps }
33+ withOverlay = { withOverlay }
34+ childrenLayout = { layout }
35+ >
2636 { renderContent ( ) }
2737 </ Wrapper >
28- { restProps ?. withOverlay && (
29- < View
30- style = { [
31- styles . absolute ,
32- childrenStyle ,
33- { top : layout . y , left : layout . x } ,
34- ] }
35- >
36- { cloneElement ( children as React . ReactElement ) }
37- </ View >
38+ { withOverlay && (
39+ < ChildWrapper childrenStyle = { childrenStyle } layout = { layout } >
40+ { children }
41+ </ ChildWrapper >
3842 ) }
3943 </ Fragment >
4044 ) }
@@ -45,9 +49,3 @@ const Tooltip: React.FC<TooltipProps> = (props) => {
4549} ;
4650
4751export default Tooltip ;
48-
49- const styles = StyleSheet . create ( {
50- absolute : {
51- position : 'absolute' ,
52- } ,
53- } ) ;
0 commit comments