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

Function useGrid

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

Source from the content-addressed store, hash-verified

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

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