'use client'; import React from 'react'; import { createTooltip } from '@gluestack-ui/tooltip'; import { View, Text, ViewStyle } from 'react-native'; import type { VariantProps } from '@gluestack-ui/nativewind-utils'; import { tva } from '@gluestack-ui/nativewind-utils/tva'; import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext'; import { Motion, AnimatePresence, MotionComponentProps, } from '@legendapp/motion'; import { cssInterop } from 'nativewind'; type IMotionViewProps = React.ComponentProps & MotionComponentProps; const MotionView = Motion.View as React.ComponentType; export const UITooltip = createTooltip({ Root: withStyleContext(View), Content: MotionView, Text: Text, AnimatePresence: AnimatePresence, }); cssInterop(MotionView, { className: 'style' }); const tooltipStyle = tva({ base: 'w-full h-full web:pointer-events-none', }); const tooltipContentStyle = tva({ base: 'py-1 px-3 rounded-sm bg-background-900 web:pointer-events-auto', }); const tooltipTextStyle = tva({ base: 'font-normal tracking-normal web:select-none text-xs text-typography-50', variants: { isTruncated: { true: { props: 'line-clamp-1 truncate', }, }, bold: { true: 'font-bold', }, underline: { true: 'underline', }, strikeThrough: { true: 'line-through', }, size: { '2xs': 'text-2xs', 'xs': 'text-xs', 'sm': 'text-sm', 'md': 'text-base', 'lg': 'text-lg', 'xl': 'text-xl', '2xl': 'text-2xl', '3xl': 'text-3xl', '4xl': 'text-4xl', '5xl': 'text-5xl', '6xl': 'text-6xl', }, sub: { true: 'text-xs', }, italic: { true: 'italic', }, highlight: { true: 'bg-yellow-500', }, }, }); type ITooltipProps = React.ComponentProps & VariantProps & { className?: string }; type ITooltipContentProps = React.ComponentProps & VariantProps & { className?: string }; type ITooltipTextProps = React.ComponentProps & VariantProps & { className?: string }; const Tooltip = React.forwardRef< React.ComponentRef, ITooltipProps >(function Tooltip({ className, ...props }, ref) { return ( ); }); const TooltipContent = React.forwardRef< React.ComponentRef, ITooltipContentProps & { className?: string } >(function TooltipContent({ className, ...props }, ref) { return ( ); }); const TooltipText = React.forwardRef< React.ComponentRef, ITooltipTextProps & { className?: string } >(function TooltipText({ size, className, ...props }, ref) { return ( ); }); Tooltip.displayName = 'Tooltip'; TooltipContent.displayName = 'TooltipContent'; TooltipText.displayName = 'TooltipText'; export { Tooltip, TooltipContent, TooltipText };