({
value,
className,
style,
tooltip = true,
emptyText = '-'
}: DateTimeTextProps)
| 11 | } |
| 12 | |
| 13 | export function DateTimeText({ |
| 14 | value, |
| 15 | className, |
| 16 | style, |
| 17 | tooltip = true, |
| 18 | emptyText = '-' |
| 19 | }: DateTimeTextProps): React.JSX.Element { |
| 20 | const date = parseDateLike(value) |
| 21 | const mergedStyle = { whiteSpace: 'nowrap', ...style } |
| 22 | |
| 23 | if (!date) { |
| 24 | return ( |
| 25 | <span className={className} style={mergedStyle}> |
| 26 | {emptyText} |
| 27 | </span> |
| 28 | ) |
| 29 | } |
| 30 | |
| 31 | const content = ( |
| 32 | <span className={className} style={mergedStyle}> |
| 33 | {formatSemanticDateTime(date)} |
| 34 | </span> |
| 35 | ) |
| 36 | |
| 37 | if (!tooltip) { |
| 38 | return content |
| 39 | } |
| 40 | |
| 41 | return <Tooltip title={formatLongDateTime(date)}>{content}</Tooltip> |
| 42 | } |
nothing calls this directly
no test coverage detected