UNPKG

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