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

Function useTabList

packages/react-aria/src/tabs/useTabList.ts:56–93  ·  view source on GitHub ↗
(
  props: AriaTabListOptions<T>,
  state: TabListState<T>,
  ref: RefObject<HTMLElement | null>
)

Source from the content-addressed store, hash-verified

54 * Tabs organize content into multiple sections and allow users to navigate between them.
55 */
56export function useTabList<T>(
57 props: AriaTabListOptions<T>,
58 state: TabListState<T>,
59 ref: RefObject<HTMLElement | null>
60): TabListAria {
61 let {orientation = 'horizontal', keyboardActivation = 'automatic'} = props;
62 let {collection, selectionManager: manager, disabledKeys} = state;
63 let {direction} = useLocale();
64 let delegate = useMemo(
65 () => new TabsKeyboardDelegate(collection, direction, orientation, disabledKeys),
66 [collection, disabledKeys, orientation, direction]
67 );
68
69 let {collectionProps} = useSelectableCollection({
70 ref,
71 selectionManager: manager,
72 keyboardDelegate: delegate,
73 selectOnFocus: keyboardActivation === 'automatic',
74 disallowEmptySelection: true,
75 scrollRef: ref,
76 linkBehavior: 'selection'
77 });
78
79 // Compute base id for all tabs
80 let tabsId = useId();
81 tabsIds.set(state, tabsId);
82
83 let tabListLabelProps = useLabels({...props, id: tabsId});
84
85 return {
86 tabListProps: {
87 ...mergeProps(collectionProps, tabListLabelProps),
88 role: 'tablist',
89 'aria-orientation': orientation,
90 tabIndex: undefined
91 }
92 };
93}

Callers 3

TabsFunction · 0.90
TabListInnerFunction · 0.90
TabListFunction · 0.90

Calls 6

useLocaleFunction · 0.90
useSelectableCollectionFunction · 0.90
useIdFunction · 0.90
useLabelsFunction · 0.90
mergePropsFunction · 0.90
setMethod · 0.45

Tested by

no test coverage detected