file-tree-doc.tsx 963 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. >
  29. <FileTreeItemInner
  30. id={id}
  31. name={name}
  32. type={type}
  33. isSelected={isSelected}
  34. icons={<FileTreeIcon isLinkedFile={isLinkedFile} name={name} />}
  35. />
  36. </li>
  37. )
  38. }
  39. export default FileTreeDoc