@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
42 lines (41 loc) • 1.24 kB
JavaScript
import * as React from 'react';
import { TreeViewContext } from "./TreeViewContext.js";
import { TreeViewStyleContext } from "./TreeViewStyleContext.js";
import { jsx as _jsx } from "react/jsx-runtime";
const EMPTY_OBJECT = {};
/**
* Sets up the contexts for the underlying Tree Item components.
*
* @ignore - do not document.
*/
export function TreeViewProvider(props) {
const {
contextValue,
classes = EMPTY_OBJECT,
slots = EMPTY_OBJECT,
slotProps = EMPTY_OBJECT,
children
} = props;
const styleContextValue = React.useMemo(() => ({
classes,
slots: {
collapseIcon: slots.collapseIcon,
expandIcon: slots.expandIcon,
endIcon: slots.endIcon
},
slotProps: {
collapseIcon: slotProps.collapseIcon,
expandIcon: slotProps.expandIcon,
endIcon: slotProps.endIcon
}
}), [classes, slots.collapseIcon, slots.expandIcon, slots.endIcon, slotProps.collapseIcon, slotProps.expandIcon, slotProps.endIcon]);
return /*#__PURE__*/_jsx(TreeViewContext.Provider, {
value: contextValue,
children: /*#__PURE__*/_jsx(TreeViewStyleContext.Provider, {
value: styleContextValue,
children: contextValue.wrapRoot({
children
})
})
});
}