react-native-tooltip-2
Version:
Customizable, easy to use tooltip for React Native
101 lines (100 loc) • 3.54 kB
TypeScript
import React, { Component } from "react";
import { ScaledSize, StyleProp, View, ViewStyle } from "react-native";
import { Point, Rect, Size } from "./geometry";
import TooltipChildrenContext from "./TooltipChildren.context";
import { Placement, PlacementType } from "./Tooltip.type";
export { TooltipChildrenContext };
export type TooltipProps = typeof Tooltip.defaultProps & {
isVisible: boolean;
onClose: () => void;
content?: any;
children?: any;
modalComponent?: any;
accessible?: boolean;
topAdjustment?: number;
disableShadow?: boolean;
backgroundColor?: string;
childContentSpacing?: number;
showChildInTooltip?: boolean;
useReactNativeModal?: boolean;
horizontalAdjustment?: number;
allowChildInteraction?: boolean;
useInteractionManager?: boolean;
supportedOrientations?: string[];
closeOnChildInteraction?: boolean;
closeOnContentInteraction?: boolean;
closeOnBackgroundInteraction?: boolean;
arrowSize?: Size;
placement?: Placement;
displayInsets?: PlacementType;
style?: StyleProp<ViewStyle>;
contentStyle?: StyleProp<ViewStyle>;
backgroundStyle?: StyleProp<ViewStyle>;
parentWrapperStyle?: StyleProp<ViewStyle>;
childrenWrapperStyle?: StyleProp<ViewStyle>;
};
interface TooltipState {
waitingForInteractions: boolean;
contentSize: Size;
adjustedContentSize: Size;
anchorPoint: Point;
tooltipOrigin: Point;
childRect: Rect;
measurementsFinished: boolean | number;
windowDims: ScaledSize;
displayInsets: PlacementType;
placement: Placement;
}
declare class Tooltip extends Component<TooltipProps, TooltipState> {
static defaultProps: {
allowChildInteraction: boolean;
arrowSize: Size;
backgroundColor: string;
childContentSpacing: number;
children: null;
closeOnChildInteraction: boolean;
closeOnContentInteraction: boolean;
closeOnBackgroundInteraction: boolean;
content: JSX.Element;
displayInsets: {};
disableShadow: boolean;
isVisible: boolean;
onClose: () => void;
placement: Placement;
showChildInTooltip: boolean;
supportedOrientations: string[];
useInteractionManager: boolean;
useReactNativeModal: boolean;
topAdjustment: number;
horizontalAdjustment: number;
accessible: boolean;
};
isMeasuringChild: boolean;
interactionPromise: {
then: (onfulfilled?: () => any, onrejected?: () => any) => Promise<any>;
done: (...args: any[]) => any;
cancel: () => void;
} | null;
dimensionsSubscription: any;
childWrapper: React.RefObject<View>;
constructor(props: TooltipProps);
componentDidMount(): void;
componentDidUpdate(prevProps: TooltipProps, prevState: TooltipState): void;
componentWillUnmount(): void;
static getDerivedStateFromProps(nextProps: TooltipProps, prevState: TooltipState): {
placement: Placement;
displayInsets: PlacementType;
measurementsFinished: number | boolean;
adjustedContentSize: Size;
} | null;
updateWindowDims: (dims: any) => void;
doChildlessPlacement: () => void;
measureContent: (e: any) => void;
onChildMeasurementComplete: (rect: Rect) => void;
measureChildRect: () => void;
computeGeometry: () => void;
renderChildInTooltip: () => JSX.Element;
renderContentForTooltip: () => JSX.Element;
render(): JSX.Element;
}
export default Tooltip;