import { Box, Link, Typography } from "@linagora/twake-mui"; import React from "react"; type InfoRowProps = { icon: React.ReactNode; text?: string; error?: boolean; data?: string; // optional link target content?: React.ReactNode; // if provided, overrides text rendering style?: React.CSSProperties; alignItems?: React.CSSProperties["alignItems"]; }; function detectUrls(text: string) { // Simple regex that captures whole URLs without splitting them apart const urlRegex = /(https?:\/\/[^\s]+|www\.[^\s]+)/gi; const parts = []; let lastIndex = 0; text.replace(urlRegex, (match, _, offset) => { // Push the text before the match if (lastIndex < offset) { parts.push( {text.slice(lastIndex, offset)} ); } // Normalize href const href = match.startsWith("http") ? match : `https://${match}`; parts.push( {match} ); lastIndex = offset + match.length; return match; }); // Push remaining text after last URL if (lastIndex < text.length) { parts.push( {text.slice(lastIndex)} ); } return parts; } export function InfoRow({ icon, text, error = false, data, content, style, alignItems = "center", }: InfoRowProps) { return ( {icon} {content ? ( content ) : ( {data ? ( {text} ) : text ? ( detectUrls(text) ) : null} )} ); }