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

Function useGridList

packages/react-aria/src/gridlist/useGridList.ts:132–216  ·  view source on GitHub ↗
(
  props: AriaGridListOptions<T>,
  state: ListState<T>,
  ref: RefObject<HTMLElement | null>
)

Source from the content-addressed store, hash-verified

130 * @param ref - The ref attached to the list element.
131 */
132export function useGridList<T>(
133 props: AriaGridListOptions<T>,
134 state: ListState<T>,
135 ref: RefObject<HTMLElement | null>
136): GridListAria {
137 let {
138 isVirtualized,
139 keyboardDelegate,
140 layoutDelegate,
141 onAction,
142 disallowTypeAhead,
143 linkBehavior = 'action',
144 keyboardNavigationBehavior = 'arrow',
145 escapeKeyBehavior = 'clearSelection',
146 shouldSelectOnPressUp
147 } = props;
148
149 if (!props['aria-label'] && !props['aria-labelledby']) {
150 console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
151 }
152
153 let {listProps} = useSelectableList({
154 selectionManager: state.selectionManager,
155 collection: state.collection,
156 disabledKeys: state.disabledKeys,
157 ref,
158 keyboardDelegate,
159 layoutDelegate,
160 isVirtualized,
161 selectOnFocus: state.selectionManager.selectionBehavior === 'replace',
162 allowsTabNavigation: state.collection.size === 0,
163 disallowSelectAll: state.collection.size === 0,
164 shouldFocusWrap: props.shouldFocusWrap,
165 linkBehavior,
166 disallowTypeAhead,
167 autoFocus: props.autoFocus,
168 escapeKeyBehavior,
169 UNSTABLE_focusOnEntry: props.UNSTABLE_focusOnEntry
170 });
171
172 let id = useId(props.id);
173 listMap.set(state, {
174 id,
175 onAction,
176 linkBehavior,
177 keyboardNavigationBehavior,
178 shouldSelectOnPressUp
179 });
180
181 let descriptionProps = useHighlightSelectionDescription({
182 selectionManager: state.selectionManager,
183 hasItemActions: !!onAction
184 });
185
186 let hasTabbableChild = useHasTabbableChild(ref, {
187 isDisabled: state.collection.size !== 0
188 });
189

Callers 5

useTagGroupFunction · 0.90
useTreeFunction · 0.90
GridListInnerFunction · 0.90
ListView.tsxFile · 0.90
GridListInnerFunction · 0.90

Calls 8

useSelectableListFunction · 0.90
useIdFunction · 0.90
useHasTabbableChildFunction · 0.90
filterDOMPropsFunction · 0.90
mergePropsFunction · 0.90
setMethod · 0.45

Tested by

no test coverage detected