MCPcopy Create free account
hub / github.com/adobe/react-spectrum / TableCell

Function TableCell

packages/react-aria/stories/table/example-resizing.tsx:335–374  ·  view source on GitHub ↗
({
  cell,
  state,
  layout
}: {
  cell: any;
  state: any;
  layout: any;
})

Source from the content-addressed store, hash-verified

333}
334
335export function TableCell({
336 cell,
337 state,
338 layout
339}: {
340 cell: any;
341 state: any;
342 layout: any;
343}): JSX.Element {
344 let ref = useRef<HTMLTableCellElement | null>(null);
345 let {gridCellProps} = useTableCell({node: cell}, state, ref);
346 let {isFocusVisible, focusProps} = useFocusRing();
347 let column = cell.column;
348 let isSelected = state.selectionManager.isSelected(cell.parentKey);
349
350 return (
351 <td
352 {...mergeProps(gridCellProps, focusProps)}
353 style={{
354 width: layout.getColumnWidth(column.key),
355 padding: '5px 10px',
356 outline: isFocusVisible ? '2px solid orange inset' : 'none',
357 cursor: 'default',
358 overflow: 'hidden',
359 whiteSpace: 'nowrap',
360 textOverflow: 'ellipsis',
361 display: 'block',
362 flex: '0 0 auto',
363 // eslint-disable-next-line no-nested-ternary
364 background: isSelected
365 ? 'blueviolet'
366 : cell.parentKey % 2
367 ? 'var(--spectrum-gray-75)'
368 : 'var(--spectrum-gray-100)'
369 }}
370 ref={ref}>
371 {cell.rendered}
372 </td>
373 );
374}
375
376export function TableCheckboxCell({
377 cell,

Callers

nothing calls this directly

Calls 5

useTableCellFunction · 0.90
useFocusRingFunction · 0.90
mergePropsFunction · 0.90
getColumnWidthMethod · 0.80
isSelectedMethod · 0.65

Tested by

no test coverage detected