UNPKG

1.27 kBJavaScriptView Raw
1import * as React from 'react';
2import { ListContext } from '../useList/ListContext';
3import { CompoundComponentContext } from '../utils/useCompound';
4import { jsx as _jsx } from "react/jsx-runtime";
5/**
6 * Sets up the contexts for the underlying Tab components.
7 *
8 * @ignore - do not document.
9 */
10export default function TabsListProvider(props) {
11 const {
12 value,
13 children
14 } = props;
15 const {
16 dispatch,
17 getItemIndex,
18 getItemState,
19 registerHighlightChangeHandler,
20 registerSelectionChangeHandler,
21 registerItem,
22 totalSubitemCount
23 } = value;
24 const listContextValue = React.useMemo(() => ({
25 dispatch,
26 getItemState,
27 getItemIndex,
28 registerHighlightChangeHandler,
29 registerSelectionChangeHandler
30 }), [dispatch, getItemIndex, getItemState, registerHighlightChangeHandler, registerSelectionChangeHandler]);
31 const compoundComponentContextValue = React.useMemo(() => ({
32 getItemIndex,
33 registerItem,
34 totalSubitemCount
35 }), [registerItem, getItemIndex, totalSubitemCount]);
36 return /*#__PURE__*/_jsx(CompoundComponentContext.Provider, {
37 value: compoundComponentContextValue,
38 children: /*#__PURE__*/_jsx(ListContext.Provider, {
39 value: listContextValue,
40 children: children
41 })
42 });
43}
\No newline at end of file