UNPKG

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