2024-05-16 18:18:42 +02:00
|
|
|
<script lang="ts">
|
2024-05-17 15:02:45 +02:00
|
|
|
import { GPXFile, Track, Waypoint, type AnyGPXTreeElement, type GPXTreeElement } from 'gpx';
|
|
|
|
import { CollapsibleTreeNode } from '$lib/components/collapsible-tree/index';
|
|
|
|
import type { GPXFileWithStatistics } from '$lib/db';
|
|
|
|
import type { Readable } from 'svelte/store';
|
|
|
|
import FileListNodeContent from './FileListNodeContent.svelte';
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
2024-05-16 18:18:42 +02:00
|
|
|
|
2024-05-17 15:02:45 +02:00
|
|
|
export let node:
|
|
|
|
| Map<string, Readable<GPXFileWithStatistics | undefined>>
|
|
|
|
| GPXTreeElement<AnyGPXTreeElement>
|
|
|
|
| ReadonlyArray<Readonly<Waypoint>>;
|
2024-05-16 18:18:42 +02:00
|
|
|
export let id: string;
|
|
|
|
export let index: number = 0;
|
2024-05-17 15:02:45 +02:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
function forwardId() {
|
|
|
|
dispatch('click', { id });
|
|
|
|
}
|
2024-05-16 18:18:42 +02:00
|
|
|
</script>
|
|
|
|
|
2024-05-17 15:02:45 +02:00
|
|
|
{#if node instanceof Map}
|
|
|
|
<FileListNodeContent {node} {id} />
|
|
|
|
{:else}
|
|
|
|
<CollapsibleTreeNode {id} on:click={forwardId}>
|
|
|
|
<span slot="trigger" class="truncate">
|
|
|
|
{#if node instanceof GPXFile}
|
|
|
|
{node.metadata.name}
|
|
|
|
{:else if node instanceof Track}
|
|
|
|
{node.name ?? `Track ${index + 1}`}
|
|
|
|
{:else if Array.isArray(node) && node.length > 0 && node[0] instanceof Waypoint}
|
|
|
|
Waypoints
|
2024-05-16 19:10:26 +02:00
|
|
|
{/if}
|
2024-05-17 15:02:45 +02:00
|
|
|
</span>
|
|
|
|
<div slot="content">
|
|
|
|
<FileListNodeContent {node} {id} />
|
2024-05-16 18:18:42 +02:00
|
|
|
</div>
|
|
|
|
</CollapsibleTreeNode>
|
|
|
|
{/if}
|