@@ -2,7 +2,7 @@ import React, { useState, useRef, useEffect, useLayoutEffect } from 'react';
22// Fix: Correctly import the DocumentOrFolder type.
33import type { DocumentOrFolder , DraggedNodeTransfer } from '../types' ;
44import IconButton from './IconButton' ;
5- import { FileIcon , FolderIcon , FolderOpenIcon , TrashIcon , ChevronRightIcon , ChevronDownIcon , CopyIcon , ArrowUpIcon , ArrowDownIcon , CodeIcon , SaveIcon , LockClosedIcon , LockOpenIcon } from './Icons' ;
5+ import { FileIcon , FolderIcon , FolderOpenIcon , ChevronRightIcon , ChevronDownIcon , CopyIcon , ArrowUpIcon , ArrowDownIcon , CodeIcon , LockClosedIcon , LockOpenIcon } from './Icons' ;
66import Tooltip from './Tooltip' ;
77
88export interface DocumentNode extends DocumentOrFolder {
@@ -30,11 +30,7 @@ interface DocumentTreeItemProps {
3030 onDropFiles : ( files : FileList , parentId : string | null ) => void ;
3131 onToggleExpand : ( id : string ) => void ;
3232 onCopyNodeContent : ( id : string ) => void ;
33- copyContentTooltip : string ;
34- onSaveNodeToFile : ( id : string ) => void ;
35- saveToFileTooltip : string ;
3633 onToggleLock : ( id : string , locked : boolean ) => void | Promise < void > ;
37- getToggleLockTooltip : ( locked : boolean ) => string ;
3834 isKnownNodeId : ( id : string ) => boolean ;
3935 searchTerm : string ;
4036 onMoveUp : ( id : string ) => void ;
@@ -103,6 +99,12 @@ const DocumentTreeItem: React.FC<DocumentTreeItemProps> = (props) => {
10399 const {
104100 node,
105101 level,
102+ canMoveUp,
103+ canMoveDown,
104+ ...baseChildProps
105+ } = props ;
106+
107+ const {
106108 selectedIds,
107109 focusedItemId,
108110 expandedIds,
@@ -117,23 +119,17 @@ const DocumentTreeItem: React.FC<DocumentTreeItemProps> = (props) => {
117119 onDropFiles,
118120 onToggleExpand,
119121 onCopyNodeContent,
120- copyContentTooltip,
121- onSaveNodeToFile,
122- saveToFileTooltip,
123122 onToggleLock,
124- getToggleLockTooltip,
125123 onMoveUp,
126124 onMoveDown,
127- canMoveUp,
128- canMoveDown,
129125 onContextMenu,
130126 renamingNodeId,
131127 onRenameComplete,
132128 indentPerLevel,
133129 verticalSpacing,
134130 searchTerm,
135131 isKnownNodeId,
136- } = props ;
132+ } = baseChildProps ;
137133
138134 const [ isRenaming , setIsRenaming ] = useState ( false ) ;
139135 const [ renameValue , setRenameValue ] = useState ( node . title ) ;
@@ -155,6 +151,7 @@ const DocumentTreeItem: React.FC<DocumentTreeItemProps> = (props) => {
155151 const isOpenInTab = ! isFolder && openDocumentIds . has ( node . id ) ;
156152 const areActionsVisible = isSelected || isFocused || isHovered ;
157153 const emojiForNode = ! isFolder ? extractEmoji ( node . title ) : null ;
154+ const lockAriaLabel = node . locked ? 'Unlock Document' : 'Lock Document' ;
158155 const displayTitle = React . useMemo ( ( ) => {
159156 if ( ! emojiForNode || isFolder ) {
160157 return node . title ;
@@ -463,23 +460,40 @@ const DocumentTreeItem: React.FC<DocumentTreeItemProps> = (props) => {
463460 overflow : areActionsVisible ? undefined : 'hidden' ,
464461 } }
465462 >
466- < IconButton onClick = { ( e ) => { e . stopPropagation ( ) ; onMoveUp ( node . id ) ; } } tooltip = "Move Up" size = "xs" variant = "ghost" disabled = { ! canMoveUp } >
463+ < IconButton
464+ aria-label = "Move Up"
465+ onClick = { ( e ) => { e . stopPropagation ( ) ; onMoveUp ( node . id ) ; } }
466+ size = "xs"
467+ variant = "ghost"
468+ disabled = { ! canMoveUp }
469+ >
467470 < ArrowUpIcon className = "w-3.5 h-3.5" />
468471 </ IconButton >
469- < IconButton onClick = { ( e ) => { e . stopPropagation ( ) ; onMoveDown ( node . id ) ; } } tooltip = "Move Down" size = "xs" variant = "ghost" disabled = { ! canMoveDown } >
472+ < IconButton
473+ aria-label = "Move Down"
474+ onClick = { ( e ) => { e . stopPropagation ( ) ; onMoveDown ( node . id ) ; } }
475+ size = "xs"
476+ variant = "ghost"
477+ disabled = { ! canMoveDown }
478+ >
470479 < ArrowDownIcon className = "w-3.5 h-3.5" />
471480 </ IconButton >
472481 { ! isFolder && (
473482 < >
474- < IconButton onClick = { ( e ) => { e . stopPropagation ( ) ; onCopyNodeContent ( node . id ) ; } } tooltip = { copyContentTooltip } size = "xs" variant = "ghost" >
483+ < IconButton
484+ aria-label = "Copy Content"
485+ onClick = { ( e ) => { e . stopPropagation ( ) ; onCopyNodeContent ( node . id ) ; } }
486+ size = "xs"
487+ variant = "ghost"
488+ >
475489 < CopyIcon className = "w-3.5 h-3.5" />
476490 </ IconButton >
477491 < IconButton
492+ aria-label = { lockAriaLabel }
478493 onClick = { ( e ) => {
479494 e . stopPropagation ( ) ;
480495 void onToggleLock ( node . id , ! node . locked ) ;
481496 } }
482- tooltip = { getToggleLockTooltip ( node . locked ) }
483497 size = "xs"
484498 variant = "ghost"
485499 className = { node . locked ? 'text-primary' : '' }
@@ -490,14 +504,8 @@ const DocumentTreeItem: React.FC<DocumentTreeItemProps> = (props) => {
490504 < LockOpenIcon className = "w-3.5 h-3.5" />
491505 ) }
492506 </ IconButton >
493- < IconButton onClick = { ( e ) => { e . stopPropagation ( ) ; onSaveNodeToFile ( node . id ) ; } } tooltip = { saveToFileTooltip } size = "xs" variant = "ghost" >
494- < SaveIcon className = "w-3.5 h-3.5" />
495- </ IconButton >
496507 </ >
497508 ) }
498- < IconButton onClick = { ( e ) => { e . stopPropagation ( ) ; onDeleteNode ( node . id , e . shiftKey ) ; } } tooltip = "Delete" size = "xs" variant = "destructive" >
499- < TrashIcon className = "w-3.5 h-3.5" />
500- </ IconButton >
501509 </ div >
502510 ) }
503511 </ div >
@@ -523,16 +531,11 @@ const DocumentTreeItem: React.FC<DocumentTreeItemProps> = (props) => {
523531 { node . children . map ( ( childNode , index ) => (
524532 < DocumentTreeItem
525533 key = { childNode . id }
526- { ...props }
534+ { ...baseChildProps }
527535 node = { childNode }
528536 level = { level + 1 }
529- indentPerLevel = { indentPerLevel }
530- verticalSpacing = { verticalSpacing }
531- openDocumentIds = { openDocumentIds }
532- activeDocumentId = { activeDocumentId }
533537 canMoveUp = { index > 0 }
534538 canMoveDown = { index < node . children . length - 1 }
535- copyContentTooltip = { copyContentTooltip }
536539 />
537540 ) ) }
538541 </ ul >
@@ -541,4 +544,4 @@ const DocumentTreeItem: React.FC<DocumentTreeItemProps> = (props) => {
541544 ) ;
542545} ;
543546
544- export default DocumentTreeItem ;
547+ export default DocumentTreeItem ;
0 commit comments