-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathuseNavDrawerBody.ts
More file actions
31 lines (28 loc) · 1.07 KB
/
useNavDrawerBody.ts
File metadata and controls
31 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use client';
import * as React from 'react';
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
import { useDrawerBody_unstable } from '@fluentui/react-drawer';
import { useNavContext_unstable } from '../NavContext';
import type { NavDrawerBodyProps, NavDrawerBodyState } from './NavDrawerBody.types';
/**
* Create the state required to render NavDrawerBody.
*
* The returned state can be modified with hooks such as useNavDrawerBodyStyles_unstable,
* before being passed to renderNavDrawerBody_unstable.
*
* @param props - props from this instance of NavDrawerBody
* @param ref - reference to root HTMLDivElement of NavDrawerBody
*/
export const useNavDrawerBody_unstable = (
props: NavDrawerBodyProps,
ref: React.Ref<HTMLDivElement>,
): NavDrawerBodyState => {
const { tabbable } = useNavContext_unstable();
// cannot use focusgroup here because of the tabbable behavior
const focusAttributes = useArrowNavigationGroup({
axis: 'vertical',
circular: true,
tabbable,
});
return useDrawerBody_unstable({ ...focusAttributes, ...props }, ref);
};