(props: {
path: string
class?: string
nodeClass?: string
active?: string
level?: number
allowed?: readonly string[]
modified?: readonly string[]
kinds?: ReadonlyMap<string, Kind>
draggable?: boolean
onFileClick?: (file: FileNode) => void
_filter?: Filter
_marks?: Set<string>
_deeps?: Map<string, number>
_kinds?: ReadonlyMap<string, Kind>
_chain?: readonly string[]
})
| 191 | } |
| 192 | |
| 193 | export default function FileTree(props: { |
| 194 | path: string |
| 195 | class?: string |
| 196 | nodeClass?: string |
| 197 | active?: string |
| 198 | level?: number |
| 199 | allowed?: readonly string[] |
| 200 | modified?: readonly string[] |
| 201 | kinds?: ReadonlyMap<string, Kind> |
| 202 | draggable?: boolean |
| 203 | onFileClick?: (file: FileNode) => void |
| 204 | |
| 205 | _filter?: Filter |
| 206 | _marks?: Set<string> |
| 207 | _deeps?: Map<string, number> |
| 208 | _kinds?: ReadonlyMap<string, Kind> |
| 209 | _chain?: readonly string[] |
| 210 | }) { |
| 211 | const file = useFile() |
| 212 | const level = props.level ?? 0 |
| 213 | const draggable = () => props.draggable ?? true |
| 214 | |
| 215 | const key = (p: string) => |
| 216 | file |
| 217 | .normalize(p) |
| 218 | .replace(/[\\/]+$/, "") |
| 219 | .replaceAll("\\", "/") |
| 220 | const chain = props._chain ? [...props._chain, key(props.path)] : [key(props.path)] |
| 221 | |
| 222 | const filter = createMemo(() => { |
| 223 | if (props._filter) return props._filter |
| 224 | |
| 225 | const allowed = props.allowed |
| 226 | if (!allowed) return |
| 227 | |
| 228 | const files = new Set(allowed) |
| 229 | const dirs = new Set<string>() |
| 230 | |
| 231 | for (const item of allowed) { |
| 232 | const parts = item.split("/") |
| 233 | const parents = parts.slice(0, -1) |
| 234 | for (const [idx] of parents.entries()) { |
| 235 | const dir = parents.slice(0, idx + 1).join("/") |
| 236 | if (dir) dirs.add(dir) |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | return { files, dirs } |
| 241 | }) |
| 242 | |
| 243 | const marks = createMemo(() => { |
| 244 | if (props._marks) return props._marks |
| 245 | |
| 246 | const out = new Set<string>() |
| 247 | for (const item of props.modified ?? []) out.add(item) |
| 248 | for (const item of props.kinds?.keys() ?? []) out.add(item) |
| 249 | if (out.size === 0) return |
| 250 | return out |
nothing calls this directly
no test coverage detected