import { ReactNode } from 'react'; import DatapointTrend from './Trend'; import AccessibilityPause from '../accessibility/AccessibilityPause'; import Badge from '../Badge'; import Box from '../Box'; import Flex from '../Flex'; import Icon from '../Icon'; import TapArea from '../TapArea'; import Text from '../Text'; import Tooltip from '../Tooltip'; import { Indexable } from '../zIndex'; type BadgeObject = { text: string; type?: | 'info' | 'error' | 'warning' | 'success' | 'neutral' | 'recommendation' | 'darkWash' | 'lightWash'; }; type TrendObject = { accessibilityLabel: string; value: number; }; type Props = { badge?: BadgeObject; /** * Changes the color of the text and internal items to be disabled */ disabled?: boolean; /** * Number of lines to truncate the title value */ lineClamp?: number; /** * Min width length for the title */ minTitleWidth?: number; /** * Max width for the title */ maxTitleWidth?: number; /** * number of lines to have the row height for the title */ numTitleRows?: number; size?: 'md' | 'lg'; title: string; tooltipText?: string; trend?: TrendObject; trendSentiment?: 'good' | 'bad' | 'neutral' | 'auto'; tooltipZIndex?: Indexable; value: string; }; function MaybeMinWidth({ minWidth, maxWidth, numTitleRows, children, }: { minWidth?: number; maxWidth?: number; numTitleRows?: number; children: ReactNode; }) { return minWidth ? ( {children} ) : ( children ); } export default function InternalDatapoint({ badge, disabled = false, lineClamp, minTitleWidth, maxTitleWidth, numTitleRows, size = 'md', title, tooltipText, tooltipZIndex, trend, trendSentiment = 'auto', value, }: Props) { const textColor = disabled ? 'subtle' : 'default'; return ( {title} {tooltipText && ( {/* Interactive elements require an a11yLabel on them or their children. That's why we set`accessibilityLabel` on `TapArea` instead of `Tooltip` */} )} {badge && } {value} {trend && ( )} ); }