@ -1,9 +1,6 @@
import { cx } from '@emotion/css' ;
import React from 'react' ;
import { useStyles2 } from '../../themes' ;
import { getCellLinks } from '../../utils' ;
import { Button , clearLinkButtonStyles } from '../Button' ;
import { DataLinksContextMenu } from '../DataLinks/DataLinksContextMenu' ;
import { TableCellProps } from './types' ;
@ -16,7 +13,6 @@ export const ImageCell = (props: TableCellProps) => {
const displayValue = field . display ! ( cell . value ) ;
const hasLinks = Boolean ( getCellLinks ( field , row ) ? . length ) ;
const clearButtonStyle = useStyles2 ( clearLinkButtonStyles ) ;
return (
< div { ...cellProps } className = { tableStyles . cellContainer } >
@ -27,12 +23,29 @@ export const ImageCell = (props: TableCellProps) => {
links = { ( ) = > getCellLinks ( field , row ) || [ ] }
>
{ ( api ) = > {
const img = < img src = { displayValue . text } className = { tableStyles . imageCell } alt = "" / > ;
const img = (
< img
style = { { height : tableStyles.cellHeight - DATALINKS_HEIGHT_OFFSET , width : 'auto' } }
src = { displayValue . text }
className = { tableStyles . imageCell }
alt = ""
/ >
) ;
if ( api . openMenu ) {
return (
< Button className = { cx ( clearButtonStyle ) } onClick = { api . openMenu } >
< div
onClick = { api . openMenu }
role = "button"
tabIndex = { 0 }
onKeyDown = { ( e : React.KeyboardEvent ) = > {
if ( e . key === 'Enter' && api . openMenu ) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
api . openMenu ( e as any ) ;
}
} }
>
{ img }
< / Button >
< / div >
) ;
} else {
return img ;