1 | import * as React from 'react';
|
2 | import { ListContext } from '../useList/ListContext';
|
3 | import { CompoundComponentContext } from '../utils/useCompound';
|
4 | import { jsx as _jsx } from "react/jsx-runtime";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export default function MenuProvider(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 _jsx(CompoundComponentContext.Provider, {
|
37 | value: compoundComponentContextValue,
|
38 | children: _jsx(ListContext.Provider, {
|
39 | value: listContextValue,
|
40 | children: children
|
41 | })
|
42 | });
|
43 | } |
\ | No newline at end of file |