{#each content as { type, name, valid }, i}
{@const is_selected = (
type === "file" ? selected_files : selected_folders
).some((x) => x[0] === name && x.length === 1)}
-
{
if (selectable) {
handle_select([...index_path, i], [...path, name], type);
}
}}
on:keydown={({ key }) => {
if (selectable && (key === " " || key === "Enter")) {
handle_select([...index_path, i], [...path, name], type);
}
}}
>
{#if interactive}
{#if type === "folder" && file_count === "single"}
{:else}
{
let checked = e.detail;
dispatch("check", {
path: [...path, name],
checked,
type
});
if (selectable) {
handle_select([...index_path, i], [...path, name], type);
}
if (type === "folder" && checked) {
open_folder(i);
}
}}
/>
{/if}
{/if}
{#if type === "folder"}
toggle_open_folder(i)}
role="button"
aria-label="expand directory"
tabindex="0"
on:keydown={({ key }) => {
if (key === " " || key === "Enter") {
toggle_open_folder(i);
}
}}>
{:else}
{/if}
{name}
{#if type === "folder" && opened_folders.includes(i)}
x[0] === name)
.map((x) => x.slice(1))}
selected_folders={selected_folders
.filter((x) => x[0] === name)
.map((x) => x.slice(1))}
is_selected_entirely={selected_folders.some(
(x) => x[0] === name && x.length === 1
)}
{interactive}
{selectable}
{ls_fn}
{file_count}
valid_for_selection={valid}
on:check
on:select
/>
{/if}
{/each}