From aecdfd5b4629f8e4d4f6936f14eeb772b4721e46 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan Date: Thu, 19 Feb 2026 19:11:09 +0530 Subject: [PATCH] svelte 5 --- src/lib/components/git/DirectoryItem.svelte | 108 +++++++++--------- src/lib/components/git/DirectoryPicker.svelte | 48 +++++--- src/lib/components/git/selectRootModal.svelte | 58 ++++++++-- src/lib/components/git/types.ts | 14 +++ 4 files changed, 152 insertions(+), 76 deletions(-) create mode 100644 src/lib/components/git/types.ts diff --git a/src/lib/components/git/DirectoryItem.svelte b/src/lib/components/git/DirectoryItem.svelte index 68512940a..baf706601 100644 --- a/src/lib/components/git/DirectoryItem.svelte +++ b/src/lib/components/git/DirectoryItem.svelte @@ -3,33 +3,41 @@ import type { createTreeView } from '@melt-ui/svelte'; import { IconChevronRight } from '@appwrite.io/pink-icons-svelte'; import { Icon, Layout, Selector, Spinner, Typography } from '@appwrite.io/pink-svelte'; + import DirectoryItemSelf from './DirectoryItem.svelte'; - export let directories: Array<{ - title: string; - fileCount?: number; - fullPath: string; - thumbnailUrl?: string; - thumbnailIcon?: typeof Icon; - thumbnailHtml?: string; - children?: typeof directories; - hasChildren?: boolean; - showThumbnail?: boolean; - loading?: boolean; - }>; - export let level = 0; - export let containerWidth: number | undefined; - export let selectedPath: string | undefined; - export let onSelect: - | ((detail: { title: string; fullPath: string; hasChildren: boolean }) => void) - | undefined; + let { + directories, + level = 0, + containerWidth, + selectedPath, + onSelect + }: { + directories: Array<{ + title: string; + fileCount?: number; + fullPath: string; + thumbnailUrl?: string; + thumbnailIcon?: typeof Icon; + thumbnailHtml?: string; + children?: typeof directories; + hasChildren?: boolean; + showThumbnail?: boolean; + loading?: boolean; + }>; + level?: number; + containerWidth?: number; + selectedPath?: string; + onSelect?: (detail: { title: string; fullPath: string; hasChildren: boolean }) => void; + } = $props(); const Radio = Selector.Radio; - let radioInputs: Array = []; - let value: string | undefined; - let thumbnailStates: Array<{ loading: boolean; error: boolean }> = []; + let radioInputs = $state>([]); + let value = $state(undefined); + let thumbnailStates = $state>([]); - $: if (directories) { + $effect(() => { + if (!directories) return; if (thumbnailStates.length < directories.length) { thumbnailStates = [ ...thumbnailStates, @@ -41,7 +49,7 @@ } else if (thumbnailStates.length > directories.length) { thumbnailStates = thumbnailStates.slice(0, directories.length); } - } + }); function handleThumbnailLoad(index: number) { if (!thumbnailStates[index]) return; @@ -62,40 +70,41 @@ const paddingLeftStyle = `padding-left: ${32 * level + 8}px`; - $: if (selectedPath && directories?.length) { - const idx = directories.findIndex((d) => d.fullPath === selectedPath); - if (idx !== -1 && radioInputs[idx]) { - radioInputs[idx].checked = true; + $effect(() => { + if (selectedPath && directories?.length) { + const idx = directories.findIndex((d) => d.fullPath === selectedPath); + if (idx !== -1 && radioInputs[idx]) { + radioInputs[idx].checked = true; + } } - } + }); {#each directories as { title, fileCount, fullPath, thumbnailUrl, thumbnailIcon, thumbnailHtml, children, hasChildren: explicitHasChildren, showThumbnail = true, loading = false }, i} {@const hasChildren = explicitHasChildren ?? !!children?.length} {@const __MELTUI_BUILDER_1__ = $group({ id: fullPath })} {@const __MELTUI_BUILDER_0__ = $item({ - id: fullPath, - hasChildren - })} + id: fullPath, + hasChildren + })}