@mui/base
Version:
MUI Base is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
47 lines (46 loc) • 1.34 kB
JavaScript
'use client';
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SelectProvider = SelectProvider;
var React = _interopRequireWildcard(require("react"));
var _ListContext = require("../useList/ListContext");
var _useCompound = require("../useCompound");
var _jsxRuntime = require("react/jsx-runtime");
/**
* Sets up the contexts for the underlying Option components.
*
* @ignore - do not document.
*/
function SelectProvider(props) {
const {
value,
children
} = props;
const {
dispatch,
getItemIndex,
getItemState,
registerItem,
totalSubitemCount
} = value;
const listContextValue = React.useMemo(() => ({
dispatch,
getItemState,
getItemIndex
}), [dispatch, getItemIndex, getItemState]);
const compoundComponentContextValue = React.useMemo(() => ({
getItemIndex,
registerItem,
totalSubitemCount
}), [registerItem, getItemIndex, totalSubitemCount]);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_useCompound.CompoundComponentContext.Provider, {
value: compoundComponentContextValue,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListContext.ListContext.Provider, {
value: listContextValue,
children: children
})
});
}
;