Replace event dispatcher with a callback in filemanager

This commit is contained in:
Pixeldrain-Server committed 2025-10-13 23:20:42 +02:00
1 parent 6d89c5ddd9
commit 75d9ed3023
41 files changed
+326 -255

No files matched your search

@@ -1,21 +1,20 @@
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { fs_encode_path, fs_node_icon, node_is_shared } from "lib/FilesystemAPI"
import { fs_encode_path, fs_node_icon } from "lib/FilesystemAPI.svelte"
import type { FSNavigator } from "filesystem/FSNavigator";
import { FileAction } from "./FileManagerLib";
let dispatch = createEventDispatcher()
import { FileAction, type FileActionHandler } from "./FileManagerLib";
let {
nav,
file_event,
show_hidden = false,
large_icons = false,
hide_edit = false
}: {
nav: FSNavigator;
show_hidden?: boolean;
large_icons?: boolean;
hide_edit?: boolean;
file_event: FileActionHandler
show_hidden?: boolean
large_icons?: boolean
hide_edit?: boolean
} = $props();
</script>
@@ -23,8 +22,8 @@ let {
{#each $nav.children as child, index (child.path)}
<a
href={"/d"+fs_encode_path(child.path)}
onclick={e => dispatch("file", {index: index, action: FileAction.Click, original: e})}
oncontextmenu={e => dispatch("file", {index: index, action: FileAction.Context, original: e})}
onclick={e => file_event(FileAction.Click, index, e)}
oncontextmenu={e => file_event(FileAction.Context, index, e)}
class="node"
class:node_selected={child.fm_selected}
class:hidden={child.name.startsWith(".") && !show_hidden}
@@ -34,14 +33,14 @@ let {
{child.name}
</div>
{#if node_is_shared(child)}
{#if child.is_shared()}
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
{/if}
{#if !hide_edit}
<button
class="action_button flat"
onclick={e => dispatch("file", {index: index, action: FileAction.Menu, original: e})}
onclick={e => file_event(FileAction.Menu, index, e)}
>
<i class="icon">menu</i>
</button>
@@ -66,8 +65,8 @@ let {
color: var(--body_text-color);
padding: 2px;
align-items: center;
background: var(--shaded_background);
backdrop-filter: blur(4px);
background: var(--body_background);
/* backdrop-filter: blur(4px); */
border-radius: 4px;
gap: 6px;
}