11import * as React from 'react' ;
2- import TreeView from '@mui/lab/TreeView ' ;
2+ import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView ' ;
33import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown' ;
44import ArrowRightIcon from '@mui/icons-material/ArrowRight' ;
55import { If , Then , Else } from 'react-if' ;
66import { DocumentItem , DOCUMENT_TYPE } from 'models/document' ;
77import { StyledTreeItem } from './StyledTreeItem' ;
8- import { TreeItemProps } from '@mui/lab /TreeItem' ;
8+ import { TreeItemProps } from '@mui/x-tree-view /TreeItem' ;
99import FolderOutlinedIcon from '@mui/icons-material/FolderOutlined' ;
1010import DescriptionOutlinedIcon from '@mui/icons-material/DescriptionOutlined' ;
1111
@@ -15,26 +15,29 @@ type DocumentTreeProps = TreeItemProps & {
1515
1616export default function DocumentTree ( { documentItem } : DocumentTreeProps ) {
1717 return (
18- < TreeView
18+ < SimpleTreeView
1919 aria-label = "documentTree"
20- defaultExpanded = { [ '3' ] }
21- defaultCollapseIcon = { < ArrowDropDownIcon sx = { { height : '35px' , width : '35px' } } /> }
22- defaultExpandIcon = { < ArrowRightIcon sx = { { height : '35px' , width : '35px' } } /> }
23- defaultEndIcon = { < div style = { { width : 24 } } /> }
20+ defaultExpandedItems = { [ '3' ] }
21+ slots = { {
22+ collapseIcon : ( ) => < ArrowDropDownIcon sx = { { height : '35px' , width : '35px' } } /> ,
23+ expandIcon : ( ) => < ArrowRightIcon sx = { { height : '35px' , width : '35px' } } /> ,
24+ endIcon : ( ) => < div style = { { width : 24 } } /> ,
25+ } }
2426 sx = { { flexGrow : 1 , maxWidth : 1000 , overflowY : 'auto' } }
2527 >
2628 < If condition = { documentItem . type === 'folder' } >
2729 < Then >
2830 < StyledTreeItem
2931 labelUrl = { documentItem . url }
30- nodeId = { `${ documentItem . id } ` }
32+ itemId = { `${ documentItem . id } ` }
3133 labelText = { documentItem . title }
3234 labelIcon = { FolderOutlinedIcon }
3335 >
3436 { documentItem . children ?. map ( ( document : DocumentItem ) => {
3537 return (
3638 < StyledTreeItem
37- nodeId = { `${ document . id } ` }
39+ key = { document . id }
40+ itemId = { `${ document . id } ` }
3841 innerDocument
3942 labelText = { document . title }
4043 labelIcon = {
@@ -50,13 +53,13 @@ export default function DocumentTree({ documentItem }: DocumentTreeProps) {
5053 </ Then >
5154 < Else >
5255 < StyledTreeItem
53- nodeId = { `${ documentItem . id } ` }
56+ itemId = { `${ documentItem . id } ` }
5457 labelText = { documentItem . title }
5558 labelIcon = { DescriptionOutlinedIcon }
5659 labelUrl = { documentItem . url }
5760 />
5861 </ Else >
5962 </ If >
60- </ TreeView >
63+ </ SimpleTreeView >
6164 ) ;
6265}
0 commit comments