1 | import * as React from 'react';
|
2 | import TabsContext from '../Tabs/TabsContext';
|
3 | import { CompoundComponentContext } from '../utils/useCompound';
|
4 | import { jsx as _jsx } from "react/jsx-runtime";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export default function TabsProvider(props) {
|
11 | const {
|
12 | value: valueProp,
|
13 | children
|
14 | } = props;
|
15 | const {
|
16 | direction,
|
17 | getItemIndex,
|
18 | onSelected,
|
19 | orientation,
|
20 | registerItem,
|
21 | registerTabIdLookup,
|
22 | selectionFollowsFocus,
|
23 | totalSubitemCount,
|
24 | value,
|
25 | getTabId,
|
26 | getTabPanelId
|
27 | } = valueProp;
|
28 | const compoundComponentContextValue = React.useMemo(() => ({
|
29 | getItemIndex,
|
30 | registerItem,
|
31 | totalSubitemCount
|
32 | }), [registerItem, getItemIndex, totalSubitemCount]);
|
33 | const tabsContextValue = React.useMemo(() => ({
|
34 | direction,
|
35 | getTabId,
|
36 | getTabPanelId,
|
37 | onSelected,
|
38 | orientation,
|
39 | registerTabIdLookup,
|
40 | selectionFollowsFocus,
|
41 | value
|
42 | }), [direction, getTabId, getTabPanelId, onSelected, orientation, registerTabIdLookup, selectionFollowsFocus, value]);
|
43 | return _jsx(CompoundComponentContext.Provider, {
|
44 | value: compoundComponentContextValue,
|
45 | children: _jsx(TabsContext.Provider, {
|
46 | value: tabsContextValue,
|
47 | children: children
|
48 | })
|
49 | });
|
50 | } |
\ | No newline at end of file |