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

Function useGrid

packages/react-aria/src/grid/useGrid.ts:101–233  ·  view source on GitHub ↗
(
  props: GridProps,
  state: GridState<T, GridCollection<T>>,
  ref: RefObject<HTMLElement | null>
)

Source from the content-addressed store, hash-verified

99 * @param ref - The ref attached to the grid element.
100 */
101export function useGrid<T>(
102 props: GridProps,
103 state: GridState<T, GridCollection<T>>,
104 ref: RefObject<HTMLElement | null>
105): GridAria {
106 let {
107 isVirtualized,
108 disallowTypeAhead,
109 keyboardDelegate,
110 focusMode,
111 scrollRef,
112 getRowText,
113 onRowAction,
114 onCellAction,
115 escapeKeyBehavior = 'clearSelection',
116 shouldSelectOnPressUp
117 } = props;
118 let {selectionManager: manager} = state;
119
120 if (!props['aria-label'] && !props['aria-labelledby']) {
121 console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
122 }
123
124 // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
125 // When virtualized, the layout object will be passed in as a prop and override this.
126 let collator = useCollator({usage: 'search', sensitivity: 'base'});
127 let {direction} = useLocale();
128 let disabledBehavior = state.selectionManager.disabledBehavior;
129 let delegate = useMemo(
130 () =>
131 keyboardDelegate ||
132 new GridKeyboardDelegate({
133 collection: state.collection,
134 disabledKeys: state.disabledKeys,
135 disabledBehavior,
136 ref,
137 direction,
138 collator,
139 focusMode
140 }),
141 [
142 keyboardDelegate,
143 state.collection,
144 state.disabledKeys,
145 disabledBehavior,
146 ref,
147 direction,
148 collator,
149 focusMode
150 ]
151 );
152
153 let {collectionProps} = useSelectableCollection({
154 ref,
155 selectionManager: manager,
156 keyboardDelegate: delegate,
157 isVirtualized,
158 scrollRef,

Callers 7

useTableFunction · 0.90
GridFunction · 0.90
DraggableCollectionFunction · 0.90
ReorderableGridFunction · 0.90
DroppableGrid.tsxFile · 0.90
DraggableCollectionFunction · 0.90
CardView.tsxFile · 0.90

Calls 13

useCollatorFunction · 0.90
useLocaleFunction · 0.90
useSelectableCollectionFunction · 0.90
useIdFunction · 0.90
filterDOMPropsFunction · 0.90
nodeContainsFunction · 0.90
getEventTargetFunction · 0.90
useHasTabbableChildFunction · 0.90
mergePropsFunction · 0.90
setFocusedMethod · 0.65

Tested by

no test coverage detected