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