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

Function TableRow

packages/@adobe/react-spectrum/src/table/TableViewBase.tsx:1278–1428  ·  view source on GitHub ↗
({
  item,
  children,
  layoutInfo,
  parent,
  ...otherProps
}: {
  item: GridNode<unknown>;
  children: ReactNode;
  layoutInfo: LayoutInfo;
  parent: LayoutInfo | null;
})

Source from the content-addressed store, hash-verified

1276}
1277
1278function TableRow({
1279 item,
1280 children,
1281 layoutInfo,
1282 parent,
1283 ...otherProps
1284}: {
1285 item: GridNode<unknown>;
1286 children: ReactNode;
1287 layoutInfo: LayoutInfo;
1288 parent: LayoutInfo | null;
1289}) {
1290 let ref = useRef<HTMLDivElement | null>(null);
1291 let {state, layout, dragAndDropHooks, isTableDraggable, isTableDroppable, dragState, dropState} =
1292 useTableContext();
1293 let isSelected = state.selectionManager.isSelected(item.key);
1294 let {rowProps, hasAction, allowsSelection} = useTableRow(
1295 {
1296 node: item,
1297 isVirtualized: true,
1298 shouldSelectOnPressUp: isTableDraggable
1299 },
1300 state,
1301 ref
1302 );
1303
1304 let isDisabled = state.selectionManager.isDisabled(item.key);
1305 let isInteractive = !isDisabled && (hasAction || allowsSelection || isTableDraggable);
1306 let {pressProps, isPressed} = usePress({isDisabled: !isInteractive});
1307
1308 // The row should show the focus background style when any cell inside it is focused.
1309 // If the row itself is focused, then it should have a blue focus indicator on the left.
1310 let {isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps} = useFocusRing({
1311 within: true
1312 });
1313 let {isFocusVisible, focusProps} = useFocusRing();
1314 let {hoverProps, isHovered} = useHover({isDisabled: !isInteractive});
1315 let isFirstRow =
1316 state.collection.rows.find(row => row.type === 'item' && row.level === 0)?.key === item.key;
1317 let isLastRow = item.nextKey == null;
1318 // Figure out if the TableView content is equal or greater in height to the container. If so, we'll need to round the bottom
1319 // border corners of the last row when selected.
1320 let isFlushWithContainerBottom = false;
1321 if (isLastRow) {
1322 if (layout.getContentSize()?.height >= (layout.virtualizer?.visibleRect.height ?? 0)) {
1323 isFlushWithContainerBottom = true;
1324 }
1325 }
1326
1327 let draggableItem: DraggableItemResult | null = null;
1328 if (isTableDraggable && dragAndDropHooks && dragState) {
1329 // oxlint-disable-next-line react/react-compiler
1330 draggableItem = dragAndDropHooks.useDraggableItem!(
1331 {key: item.key, hasDragButton: true},
1332 dragState
1333 );
1334 if (isDisabled) {
1335 draggableItem = null;

Callers

nothing calls this directly

Calls 14

useTableRowFunction · 0.90
usePressFunction · 0.90
useFocusRingFunction · 0.90
useHoverFunction · 0.90
useButtonFunction · 0.90
mergePropsFunction · 0.90
useVisuallyHiddenFunction · 0.90
classNamesFunction · 0.90
useTableContextFunction · 0.85
useStyleFunction · 0.85
isDropTargetMethod · 0.80
isSelectedMethod · 0.65

Tested by

no test coverage detected