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