UNPKG

1.66 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 Option components.
7 *
8 * @ignore - do not document.
9 */
10export default function SelectProvider(props) {
11 var value = props.value,
12 children = props.children;
13 var dispatch = value.dispatch,
14 getItemIndex = value.getItemIndex,
15 getItemState = value.getItemState,
16 registerHighlightChangeHandler = value.registerHighlightChangeHandler,
17 registerSelectionChangeHandler = value.registerSelectionChangeHandler,
18 registerItem = value.registerItem,
19 totalSubitemCount = value.totalSubitemCount;
20 var listContextValue = React.useMemo(function () {
21 return {
22 dispatch: dispatch,
23 getItemState: getItemState,
24 getItemIndex: getItemIndex,
25 registerHighlightChangeHandler: registerHighlightChangeHandler,
26 registerSelectionChangeHandler: registerSelectionChangeHandler
27 };
28 }, [dispatch, getItemIndex, getItemState, registerHighlightChangeHandler, registerSelectionChangeHandler]);
29 var compoundComponentContextValue = React.useMemo(function () {
30 return {
31 getItemIndex: getItemIndex,
32 registerItem: registerItem,
33 totalSubitemCount: totalSubitemCount
34 };
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