import React from 'react'; import { cn } from '../../lib/utils'; interface AdaptiveTextProps extends React.HTMLAttributes { text: string; isUpperCase: boolean; as?: keyof JSX.IntrinsicElements; preserveWhitespace?: boolean; } export const AdaptiveText = React.memo(({ text, isUpperCase, as: Component = 'span', preserveWhitespace = false, className, ...props }: AdaptiveTextProps) => { // Transformar o texto mantendo espaços em branco se necessário const transformedText = React.useMemo(() => { const transformed = isUpperCase ? text.toUpperCase() : text; return preserveWhitespace ? transformed : transformed.trim(); }, [text, isUpperCase, preserveWhitespace]); return React.createElement( Component, { className: cn( 'transition-colors duration-200', className ), ...props }, transformedText ); }); AdaptiveText.displayName = 'AdaptiveText'; // Variantes específicas para diferentes contextos export const AdaptiveTitle = ({ className, ...props }: AdaptiveTextProps) => ( ); export const AdaptiveParagraph = ({ className, ...props }: AdaptiveTextProps) => ( ); export const AdaptiveLabel = ({ className, ...props }: AdaptiveTextProps) => ( ); // Hook para memoização de textos longos export function useAdaptiveText(text: string, isUpperCase: boolean) { return React.useMemo( () => isUpperCase ? text.toUpperCase() : text, [text, isUpperCase] ); }