import { HistoryPayload } from "@flyde/core"; import * as React from "react"; import { cn } from "../../lib/utils"; import { formatTimeAgo } from "../../lib/format-time"; import { HotkeyIndication } from "../../ui"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faChevronDown, faChevronUp, faSpinner } from "@fortawesome/free-solid-svg-icons"; interface PinTooltipContentProps { displayName: string; typeLabel: string; description?: string; history?: HistoryPayload; queuedValues?: number; className?: string; isLoading?: boolean; onInspect?: () => void; isExpanded?: boolean; onToggleExpand?: () => void; } export const PinTooltipContent = ({ displayName, typeLabel: type, description, history, className, isLoading = false, onInspect, isExpanded = false, onToggleExpand, }: PinTooltipContentProps) => { const indication = const renderHistoryContent = () => { if (isLoading) { return (
Last value: Type: -
Loading data...
Last: - Total: -
{indication}
); } if (!history) { return (
Last value: Type: -
No session data available
Last: - Total: -
{indication}
); } const { lastSamples } = history; if (lastSamples.length === 0) { return (
Last value: Type: -
No values received
Last: - Total: 0
{indication}
); } const lastValue = lastSamples[0]?.val; const lastTime = lastSamples[0]?.time; const valueType = typeof lastValue === "object" ? "object" : typeof lastValue; const formattedValue = typeof lastValue === "object" ? JSON.stringify(lastValue, null, 2) : String(lastValue); return (
Last value: Type: {valueType}
            {formattedValue}
          
Last: {formatTimeAgo(lastTime ?? 0)} Total: {lastSamples.length}
{indication}
); }; return (
{displayName}{" "} {type}
{onToggleExpand && ( )}
{description && (
{description}
)} {renderHistoryContent()}
); };