(node: TreeNodeData, isExpanded: boolean)
| 177 | } |
| 178 | |
| 179 | function getNodeIcon(node: TreeNodeData, isExpanded: boolean): string { |
| 180 | if (node.notfound || node.staterror) { |
| 181 | return "triangle-exclamation"; |
| 182 | } |
| 183 | if (node.icon) { |
| 184 | return node.icon; |
| 185 | } |
| 186 | if (node.isDirectory) { |
| 187 | return isExpanded ? "folder-open" : "folder"; |
| 188 | } |
| 189 | const mime = node.mimeType ?? ""; |
| 190 | if (mime.startsWith("image/")) { |
| 191 | return "image"; |
| 192 | } |
| 193 | if (mime === "application/pdf") { |
| 194 | return "file-pdf"; |
| 195 | } |
| 196 | const extension = normalizeLabel(node).split(".").pop()?.toLocaleLowerCase(); |
| 197 | if (["js", "jsx", "ts", "tsx", "go", "py", "java", "c", "cpp", "h", "hpp", "json", "yaml", "yml"].includes(extension)) { |
| 198 | return "file-code"; |
| 199 | } |
| 200 | if (["md", "txt", "log"].includes(extension)) { |
| 201 | return "file-lines"; |
| 202 | } |
| 203 | return "file"; |
| 204 | } |
| 205 | |
| 206 | export const TreeView = forwardRef<TreeViewRef, TreeViewProps>((props, ref) => { |
| 207 | const { |
no test coverage detected