MCPcopy Index your code
hub / github.com/adobe/react-spectrum / useGridRow

Function useGridRow

packages/react-aria/src/grid/useGridRow.ts:56–93  ·  view source on GitHub ↗
(
  props: GridRowProps<T>,
  state: S,
  ref: RefObject<FocusableElement | null>
)

Source from the content-addressed store, hash-verified

54 * @param state - State of the parent grid, as returned by `useGridState`.
55 */
56export function useGridRow<T, C extends GridCollection<T>, S extends GridState<T, C>>(
57 props: GridRowProps<T>,
58 state: S,
59 ref: RefObject<FocusableElement | null>
60): GridRowAria {
61 let {node, isVirtualized, shouldSelectOnPressUp, onAction} = props;
62
63 let {actions, shouldSelectOnPressUp: gridShouldSelectOnPressUp} = gridMap.get(state)!;
64 let onRowAction = actions.onRowAction ? () => actions.onRowAction?.(node.key) : onAction;
65 let {itemProps, ...states} = useSelectableItem({
66 selectionManager: state.selectionManager,
67 key: node.key,
68 ref,
69 isVirtualized,
70 shouldSelectOnPressUp: gridShouldSelectOnPressUp || shouldSelectOnPressUp,
71 onAction:
72 onRowAction || node?.props?.onAction ? chain(node?.props?.onAction, onRowAction) : undefined,
73 isDisabled: state.collection.size === 0
74 });
75
76 let isSelected = state.selectionManager.isSelected(node.key);
77
78 let rowProps: DOMAttributes = {
79 role: 'row',
80 'aria-selected': state.selectionManager.selectionMode !== 'none' ? isSelected : undefined,
81 'aria-disabled': states.isDisabled || undefined,
82 ...itemProps
83 };
84
85 if (isVirtualized) {
86 rowProps['aria-rowindex'] = node.index + 1; // aria-rowindex is 1 based
87 }
88
89 return {
90 rowProps,
91 ...states
92 };
93}

Callers 7

useTableRowFunction · 0.90
RowFunction · 0.90
DraggableCollectionItemFunction · 0.90
CollectionItemFunction · 0.90
CollectionItemFunction · 0.90
DraggableCollectionItemFunction · 0.90
InternalCardFunction · 0.90

Calls 3

useSelectableItemFunction · 0.90
chainFunction · 0.90
isSelectedMethod · 0.65

Tested by

no test coverage detected