file-tree-doc.tsx 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { useSelectableEntity } from '../contexts/file-tree-selectable'
  2. import FileTreeIcon from './file-tree-icon'
  3. import FileTreeItemInner from './file-tree-item/file-tree-item-inner'
  4. function FileTreeDoc({
  5. name,
  6. id,
  7. isFile,
  8. isLinkedFile,
  9. }: {
  10. name: string
  11. id: string
  12. isFile?: boolean
  13. isLinkedFile?: boolean
  14. }) {
  15. const type = isFile ? 'file' : 'doc'
  16. const { isSelected, props: selectableEntityProps } = useSelectableEntity(
  17. id,
  18. type
  19. )
  20. return (
  21. <li
  22. // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
  23. role="treeitem"
  24. // aria-selected is provided in selectableEntityProps
  25. {...selectableEntityProps}
  26. aria-label={name}
  27. tabIndex={0}
  28. translate="no"
  29. >
  30. <FileTreeItemInner
  31. id={id}
  32. name={name}
  33. type={type}
  34. isSelected={isSelected}
  35. icons={<FileTreeIcon isLinkedFile={isLinkedFile} name={name} />}
  36. />
  37. </li>
  38. )
  39. }
  40. export default FileTreeDoc