( props: AriaTabListOptions<T>, state: TabListState<T>, ref: RefObject<HTMLElement | null> )
| 54 | * Tabs organize content into multiple sections and allow users to navigate between them. |
| 55 | */ |
| 56 | export 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 | } |
no test coverage detected