@mui/x-tree-view
Version:
The community edition of the MUI X Tree View components.
30 lines (29 loc) • 1.2 kB
JavaScript
'use client';
import _extends from "@babel/runtime/helpers/esm/extends";
import { useStore } from '@mui/x-internals/store';
import { idSelectors } from "../plugins/id/index.js";
import { selectionSelectors } from "../plugins/selection/index.js";
import { itemsSelectors } from "../plugins/items/index.js";
export function useTreeViewRootProps(store, forwardedProps, ref) {
const treeId = useStore(store, idSelectors.treeId);
const itemChildrenIndentation = useStore(store, itemsSelectors.itemChildrenIndentation);
const isMultiSelectEnabled = useStore(store, selectionSelectors.isMultiSelectEnabled);
return otherHandlers => _extends({
ref,
role: 'tree',
id: treeId,
'aria-multiselectable': isMultiSelectEnabled
}, forwardedProps, otherHandlers, {
style: _extends({}, forwardedProps.style, {
'--TreeView-itemChildrenIndentation': typeof itemChildrenIndentation === 'number' ? `${itemChildrenIndentation}px` : itemChildrenIndentation
}),
onFocus: event => {
otherHandlers.onFocus?.(event);
store.focus.handleRootFocus(event);
},
onBlur: event => {
otherHandlers.onBlur?.(event);
store.focus.handleRootBlur(event);
}
});
}