@widgetic/file-browser 0.5.35 → 0.5.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/components/FolderTree.svelte +46 -97
- package/dist/components/FolderTree.svelte.d.ts +5 -1
- package/dist/components/core/Dropzone.svelte +127 -0
- package/dist/components/core/Dropzone.svelte.d.ts +15 -0
- package/dist/components/core/FileBrowser.css +11 -79
- package/dist/components/core/FileBrowser.svelte +277 -149
- package/dist/components/core/FileBrowser.svelte.d.ts +0 -1
- package/dist/components/core/FileUploader.svelte +204 -418
- package/dist/components/core/FileUploader.svelte.d.ts +1 -0
- package/dist/components/core/Header.svelte +51 -68
- package/dist/components/core/Header.svelte.d.ts +1 -0
- package/dist/components/core/RecentFiles.svelte +135 -562
- package/dist/components/core/RecentFiles.svelte.d.ts +2 -4
- package/dist/components/core/UploadPanel.svelte +169 -0
- package/dist/components/core/UploadPanel.svelte.d.ts +40 -0
- package/dist/components/core/UploadRow.svelte +90 -0
- package/dist/components/core/UploadRow.svelte.d.ts +21 -0
- package/dist/components/core/UploadStatus.svelte +34 -128
- package/dist/components/core/UploadStatus.svelte.d.ts +0 -1
- package/dist/components/core/UploadStatusList.svelte +61 -77
- package/dist/components/items/FileItem.svelte +190 -532
- package/dist/components/items/FileItem.svelte.d.ts +1 -1
- package/dist/components/items/FolderItem.svelte +46 -36
- package/dist/components/items/FolderItem.svelte.d.ts +1 -1
- package/dist/components/modals/MoveDialog.svelte +142 -281
- package/dist/components/modals/NewFolderButton.svelte +13 -14
- package/dist/components/modals/SearchModal.svelte +112 -264
- package/dist/components/modals/SearchModal.svelte.d.ts +0 -1
- package/dist/components/modals/SelectedFilesModal.svelte +91 -167
- package/dist/components/previews/AudioPlayer.svelte +75 -58
- package/dist/components/previews/ErrorPreview.svelte +9 -6
- package/dist/components/previews/FilePreview.svelte +173 -53
- package/dist/components/previews/FontPreview.svelte +37 -54
- package/dist/components/previews/ImagePreview.svelte +9 -2
- package/dist/components/previews/ImagePreview.svelte.d.ts +1 -0
- package/dist/components/previews/PreviewHeaderBar.svelte +70 -0
- package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +32 -0
- package/dist/components/previews/TextPreview.svelte +32 -40
- package/dist/components/previews/VideoPlayer.svelte +124 -149
- package/dist/components/previews/WaveformVisualizer.svelte +42 -222
- package/dist/components/previews/WaveformVisualizer.svelte.d.ts +1 -1
- package/dist/components/ui/ControlToolbar.svelte +113 -288
- package/dist/components/ui/ControlToolbar.svelte.d.ts +2 -3
- package/dist/components/ui/DragSelect.svelte +41 -248
- package/dist/components/ui/DropdownMenu.svelte +56 -55
- package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -1
- package/dist/components/ui/FileIcon.svelte +168 -51
- package/dist/components/ui/FileIcon.svelte.d.ts +13 -20
- package/dist/components/ui/FileMetadata.svelte +20 -9
- package/dist/components/ui/LoadingSkeleton.svelte +5 -20
- package/dist/components/ui/SearchResults.svelte +50 -26
- package/dist/components/ui/SearchResults.svelte.d.ts +4 -0
- package/dist/components/ui/SelectedBadge.svelte +25 -0
- package/dist/components/ui/SelectedBadge.svelte.d.ts +9 -0
- package/dist/components/ui/TileSkeleton.svelte +15 -0
- package/dist/components/ui/TileSkeleton.svelte.d.ts +18 -0
- package/dist/components/ui/VirtualList.svelte +3 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/i18n/messages.d.ts +38 -25
- package/dist/i18n/messages.js +39 -26
- package/dist/utils/gridLayout.d.ts +2 -0
- package/dist/utils/gridLayout.js +10 -0
- package/package.json +3 -4
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Displays
|
|
4
|
-
* Supports file selection, preview, and dropdown actions
|
|
2
|
+
* Recent files grid — Figma "Recent Card" (267:179).
|
|
3
|
+
* Displays recently accessed files with thumbnails, preview, and selection.
|
|
5
4
|
*/
|
|
6
5
|
import type { FileSystemItem } from '../../types';
|
|
7
6
|
import { type FileFilterType } from '../../utils/fileTypes';
|
|
@@ -29,7 +28,6 @@ declare const RecentFiles: $$__sveltets_2_IsomorphicComponent<{
|
|
|
29
28
|
}, {
|
|
30
29
|
fileClick: CustomEvent<any>;
|
|
31
30
|
select: CustomEvent<any>;
|
|
32
|
-
action: CustomEvent<any>;
|
|
33
31
|
} & {
|
|
34
32
|
[evt: string]: CustomEvent<any>;
|
|
35
33
|
}, {}, {}, string>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Figma: Upload Panel (component set 270:987, page File Browser)
|
|
3
|
+
-->
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import UploadRow, { type UploadRowScope, type UploadRowState } from './UploadRow.svelte';
|
|
6
|
+
import { IconButton, Progress, Tooltip } from '@widgetic/design-system/components';
|
|
7
|
+
import { IconChevronDown, IconChevronUp } from '@widgetic/design-system/icons';
|
|
8
|
+
import { useI18n } from '../../i18n/context';
|
|
9
|
+
|
|
10
|
+
export type UploadPanelItem = {
|
|
11
|
+
id: string;
|
|
12
|
+
fileName: string;
|
|
13
|
+
file: { name: string; url?: string; thumbnail?: string; mimeType?: string };
|
|
14
|
+
progress: number;
|
|
15
|
+
status: UploadRowState;
|
|
16
|
+
statusText: string;
|
|
17
|
+
errorMessage?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
items: UploadPanelItem[];
|
|
22
|
+
summaryScope: UploadRowScope;
|
|
23
|
+
summaryState: UploadRowState;
|
|
24
|
+
summaryName: string;
|
|
25
|
+
summaryStatus: string;
|
|
26
|
+
progressValue: number;
|
|
27
|
+
progressTone: 'default' | 'destructive';
|
|
28
|
+
progressDone?: boolean;
|
|
29
|
+
footerText: string;
|
|
30
|
+
footerDestructive?: boolean;
|
|
31
|
+
expanded?: boolean;
|
|
32
|
+
onToggleExpand?: () => void;
|
|
33
|
+
onSummaryCancel?: () => void;
|
|
34
|
+
onSummaryRetry?: () => void;
|
|
35
|
+
onItemCancel?: (id: string) => void;
|
|
36
|
+
onItemRetry?: (id: string) => void;
|
|
37
|
+
onFooterAction?: () => void;
|
|
38
|
+
footerAction?: boolean;
|
|
39
|
+
showClearCompleted?: boolean;
|
|
40
|
+
onClearCompleted?: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let {
|
|
44
|
+
items,
|
|
45
|
+
summaryScope,
|
|
46
|
+
summaryState,
|
|
47
|
+
summaryName,
|
|
48
|
+
summaryStatus,
|
|
49
|
+
progressValue,
|
|
50
|
+
progressTone = 'default',
|
|
51
|
+
progressDone = false,
|
|
52
|
+
footerText,
|
|
53
|
+
footerDestructive = false,
|
|
54
|
+
expanded = false,
|
|
55
|
+
onToggleExpand,
|
|
56
|
+
onSummaryCancel,
|
|
57
|
+
onSummaryRetry,
|
|
58
|
+
onItemCancel,
|
|
59
|
+
onItemRetry,
|
|
60
|
+
onFooterAction,
|
|
61
|
+
footerAction = false,
|
|
62
|
+
showClearCompleted = false,
|
|
63
|
+
onClearCompleted
|
|
64
|
+
}: Props = $props();
|
|
65
|
+
|
|
66
|
+
const { t } = useI18n();
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<div
|
|
70
|
+
class="upload-panel flex w-[376px] max-w-[calc(100vw-2rem)] flex-col gap-2 rounded-xl border border-border bg-background p-3 shadow-floating"
|
|
71
|
+
role="region"
|
|
72
|
+
aria-label={$t('upload.panelTitle')}
|
|
73
|
+
>
|
|
74
|
+
<!-- Figma Upload Panel: one row (its own buttons cancel, retry or remove), the bar, one line of text.
|
|
75
|
+
A batch also gets a control that opens the list of its files (the list is not in Figma: it keeps the
|
|
76
|
+
per-file status and retry that the old drawer had). -->
|
|
77
|
+
<div class="flex items-start gap-2">
|
|
78
|
+
<div class="min-w-0 flex-1">
|
|
79
|
+
<UploadRow
|
|
80
|
+
scope={summaryScope}
|
|
81
|
+
state={summaryState}
|
|
82
|
+
fileName={summaryName}
|
|
83
|
+
file={items[0]?.file}
|
|
84
|
+
statusText={summaryStatus}
|
|
85
|
+
batchCount={items.length}
|
|
86
|
+
onCancel={onSummaryCancel}
|
|
87
|
+
onRetry={onSummaryRetry}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
{#if items.length > 1}
|
|
91
|
+
<div class="flex shrink-0 items-center">
|
|
92
|
+
<Tooltip.Provider delayDuration={200}>
|
|
93
|
+
<Tooltip.Root>
|
|
94
|
+
<Tooltip.Trigger class="inline-flex">
|
|
95
|
+
{#snippet child({ props }: { props: Record<string, unknown> })}
|
|
96
|
+
<IconButton
|
|
97
|
+
{...props}
|
|
98
|
+
variant="ghost"
|
|
99
|
+
size="default"
|
|
100
|
+
label={expanded ? $t('upload.collapsePanel') : $t('upload.expandPanel')}
|
|
101
|
+
onclick={onToggleExpand}
|
|
102
|
+
>
|
|
103
|
+
{#if expanded}
|
|
104
|
+
<IconChevronDown class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
105
|
+
{:else}
|
|
106
|
+
<IconChevronUp class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
107
|
+
{/if}
|
|
108
|
+
</IconButton>
|
|
109
|
+
{/snippet}
|
|
110
|
+
</Tooltip.Trigger>
|
|
111
|
+
<Tooltip.Portal>
|
|
112
|
+
<Tooltip.Content side="top" sideOffset={6} class="z-[99999]">
|
|
113
|
+
<p class="text-caption">{expanded ? $t('upload.collapseUploader') : $t('upload.expandUploader')}</p>
|
|
114
|
+
</Tooltip.Content>
|
|
115
|
+
</Tooltip.Portal>
|
|
116
|
+
</Tooltip.Root>
|
|
117
|
+
</Tooltip.Provider>
|
|
118
|
+
</div>
|
|
119
|
+
{/if}
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<Progress
|
|
123
|
+
value={progressDone ? 100 : progressValue}
|
|
124
|
+
max={100}
|
|
125
|
+
tone={progressTone}
|
|
126
|
+
class="h-1"
|
|
127
|
+
/>
|
|
128
|
+
|
|
129
|
+
<div class="flex flex-col items-center gap-1">
|
|
130
|
+
{#if footerAction}
|
|
131
|
+
<button
|
|
132
|
+
type="button"
|
|
133
|
+
class="text-center text-caption-medium text-destructive underline-offset-2 hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
134
|
+
onclick={onFooterAction}
|
|
135
|
+
>
|
|
136
|
+
{footerText}
|
|
137
|
+
</button>
|
|
138
|
+
{:else}
|
|
139
|
+
<p class="text-center text-caption-medium {footerDestructive ? 'text-destructive' : 'text-muted-foreground'}">
|
|
140
|
+
{footerText}
|
|
141
|
+
</p>
|
|
142
|
+
{/if}
|
|
143
|
+
{#if showClearCompleted && expanded && items.length > 1}
|
|
144
|
+
<button
|
|
145
|
+
type="button"
|
|
146
|
+
class="text-caption-medium text-muted-foreground underline-offset-2 hover:text-foreground hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
147
|
+
onclick={onClearCompleted}
|
|
148
|
+
>
|
|
149
|
+
{$t('upload.clearCompleted')}
|
|
150
|
+
</button>
|
|
151
|
+
{/if}
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
{#if expanded && items.length > 1}
|
|
155
|
+
<div class="flex max-h-48 flex-col gap-2 overflow-y-auto border-t border-border pt-2">
|
|
156
|
+
{#each items as item (item.id)}
|
|
157
|
+
<UploadRow
|
|
158
|
+
scope="single"
|
|
159
|
+
state={item.status}
|
|
160
|
+
fileName={item.fileName}
|
|
161
|
+
file={item.file}
|
|
162
|
+
statusText={item.status === 'failed' ? item.errorMessage || item.statusText : item.statusText}
|
|
163
|
+
onCancel={() => onItemCancel?.(item.id)}
|
|
164
|
+
onRetry={() => onItemRetry?.(item.id)}
|
|
165
|
+
/>
|
|
166
|
+
{/each}
|
|
167
|
+
</div>
|
|
168
|
+
{/if}
|
|
169
|
+
</div>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type UploadRowScope, type UploadRowState } from './UploadRow.svelte';
|
|
2
|
+
export type UploadPanelItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
file: {
|
|
6
|
+
name: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
thumbnail?: string;
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
};
|
|
11
|
+
progress: number;
|
|
12
|
+
status: UploadRowState;
|
|
13
|
+
statusText: string;
|
|
14
|
+
errorMessage?: string;
|
|
15
|
+
};
|
|
16
|
+
interface Props {
|
|
17
|
+
items: UploadPanelItem[];
|
|
18
|
+
summaryScope: UploadRowScope;
|
|
19
|
+
summaryState: UploadRowState;
|
|
20
|
+
summaryName: string;
|
|
21
|
+
summaryStatus: string;
|
|
22
|
+
progressValue: number;
|
|
23
|
+
progressTone: 'default' | 'destructive';
|
|
24
|
+
progressDone?: boolean;
|
|
25
|
+
footerText: string;
|
|
26
|
+
footerDestructive?: boolean;
|
|
27
|
+
expanded?: boolean;
|
|
28
|
+
onToggleExpand?: () => void;
|
|
29
|
+
onSummaryCancel?: () => void;
|
|
30
|
+
onSummaryRetry?: () => void;
|
|
31
|
+
onItemCancel?: (id: string) => void;
|
|
32
|
+
onItemRetry?: (id: string) => void;
|
|
33
|
+
onFooterAction?: () => void;
|
|
34
|
+
footerAction?: boolean;
|
|
35
|
+
showClearCompleted?: boolean;
|
|
36
|
+
onClearCompleted?: () => void;
|
|
37
|
+
}
|
|
38
|
+
declare const UploadPanel: import("svelte").Component<Props, {}, "">;
|
|
39
|
+
type UploadPanel = ReturnType<typeof UploadPanel>;
|
|
40
|
+
export default UploadPanel;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Figma: Upload Row (component set 270:827, page File Browser)
|
|
3
|
+
-->
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import FileIcon from '../ui/FileIcon.svelte';
|
|
6
|
+
import { IconButton } from '@widgetic/design-system/components';
|
|
7
|
+
import { IconCheck, IconFiles, IconRefresh, IconX } from '@widgetic/design-system/icons';
|
|
8
|
+
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
9
|
+
import { useI18n } from '../../i18n/context';
|
|
10
|
+
|
|
11
|
+
export type UploadRowScope = 'single' | 'batch';
|
|
12
|
+
export type UploadRowState = 'uploading' | 'failed' | 'complete';
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
scope?: UploadRowScope;
|
|
16
|
+
state?: UploadRowState;
|
|
17
|
+
fileName?: string;
|
|
18
|
+
/** File for single-scope thumb; batch scope ignores this. */
|
|
19
|
+
file?: { name: string; url?: string; thumbnail?: string; mimeType?: string };
|
|
20
|
+
statusText?: string;
|
|
21
|
+
batchCount?: number;
|
|
22
|
+
onCancel?: () => void;
|
|
23
|
+
onRetry?: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let {
|
|
27
|
+
scope = 'single',
|
|
28
|
+
state = 'uploading',
|
|
29
|
+
fileName = '',
|
|
30
|
+
file,
|
|
31
|
+
statusText = '',
|
|
32
|
+
batchCount = 0,
|
|
33
|
+
onCancel,
|
|
34
|
+
onRetry
|
|
35
|
+
}: Props = $props();
|
|
36
|
+
|
|
37
|
+
const { t } = useI18n();
|
|
38
|
+
const textDirection = useTextDirection();
|
|
39
|
+
const nameDirection = $derived(dirForUserText($textDirection));
|
|
40
|
+
|
|
41
|
+
const failed = $derived(state === 'failed');
|
|
42
|
+
const done = $derived(state === 'complete');
|
|
43
|
+
const textTone = $derived(failed ? 'text-destructive' : 'text-foreground');
|
|
44
|
+
const statusTone = $derived(failed ? 'text-destructive' : 'text-muted-foreground');
|
|
45
|
+
|
|
46
|
+
const displayName = $derived(
|
|
47
|
+
scope === 'batch' ? $t('upload.filesTotal', { count: batchCount }) : fileName
|
|
48
|
+
);
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<div class="flex h-9 w-full min-w-0 items-center gap-3">
|
|
52
|
+
{#if scope === 'batch'}
|
|
53
|
+
<div class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted">
|
|
54
|
+
<IconFiles class="size-4 stroke-[1.333] text-muted-foreground" aria-hidden="true" />
|
|
55
|
+
</div>
|
|
56
|
+
{:else if file}
|
|
57
|
+
<FileIcon {file} size="sm" class="shrink-0" />
|
|
58
|
+
{:else}
|
|
59
|
+
<FileIcon kind="file" size="sm" class="shrink-0" />
|
|
60
|
+
{/if}
|
|
61
|
+
|
|
62
|
+
<div class="min-w-0 flex-1">
|
|
63
|
+
<p dir={nameDirection} class="truncate text-body-medium {textTone}">{displayName}</p>
|
|
64
|
+
{#if statusText}
|
|
65
|
+
<p class="truncate text-caption {statusTone}">{statusText}</p>
|
|
66
|
+
{/if}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<div class="flex shrink-0 items-center gap-1">
|
|
70
|
+
{#if state === 'uploading'}
|
|
71
|
+
<IconButton variant="ghost" size="default" label={$t('upload.cancel')} onclick={() => onCancel?.()}>
|
|
72
|
+
<IconX class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
73
|
+
</IconButton>
|
|
74
|
+
{:else if state === 'failed'}
|
|
75
|
+
<IconButton variant="ghost" size="default" label={$t('upload.retry')} onclick={() => onRetry?.()}>
|
|
76
|
+
<IconRefresh class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
77
|
+
</IconButton>
|
|
78
|
+
<IconButton variant="ghost" size="default" label={$t('upload.removeFile')} onclick={() => onCancel?.()}>
|
|
79
|
+
<IconX class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
80
|
+
</IconButton>
|
|
81
|
+
{:else if done}
|
|
82
|
+
<span
|
|
83
|
+
class="inline-flex size-8 items-center justify-center rounded-lg bg-brand-subtle text-brand"
|
|
84
|
+
aria-label={$t('upload.completedAlt')}
|
|
85
|
+
>
|
|
86
|
+
<IconCheck class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
87
|
+
</span>
|
|
88
|
+
{/if}
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type UploadRowScope = 'single' | 'batch';
|
|
2
|
+
export type UploadRowState = 'uploading' | 'failed' | 'complete';
|
|
3
|
+
interface Props {
|
|
4
|
+
scope?: UploadRowScope;
|
|
5
|
+
state?: UploadRowState;
|
|
6
|
+
fileName?: string;
|
|
7
|
+
/** File for single-scope thumb; batch scope ignores this. */
|
|
8
|
+
file?: {
|
|
9
|
+
name: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
thumbnail?: string;
|
|
12
|
+
mimeType?: string;
|
|
13
|
+
};
|
|
14
|
+
statusText?: string;
|
|
15
|
+
batchCount?: number;
|
|
16
|
+
onCancel?: () => void;
|
|
17
|
+
onRetry?: () => void;
|
|
18
|
+
}
|
|
19
|
+
declare const UploadRow: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type UploadRow = ReturnType<typeof UploadRow>;
|
|
21
|
+
export default UploadRow;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import { IconTrash, IconRefresh } from '@widgetic/design-system/icons';
|
|
2
|
+
import UploadRow from './UploadRow.svelte';
|
|
4
3
|
import { useI18n } from '../../i18n';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const { t } = useI18n();
|
|
8
|
-
|
|
9
|
-
const textDirection = useTextDirection();
|
|
10
|
-
$: nameDirection = dirForUserText($textDirection);
|
|
11
|
-
|
|
12
|
-
// Component props
|
|
4
|
+
import { formatFileSize } from '../../utils/fileUtils';
|
|
5
|
+
|
|
6
|
+
const { t, locale } = useI18n();
|
|
7
|
+
|
|
13
8
|
export let file: File;
|
|
14
|
-
export let progress: number = 0; // 0-100
|
|
15
9
|
export let status: 'uploading' | 'complete' | 'failed' = 'uploading';
|
|
16
10
|
export let fileSize: string;
|
|
17
11
|
export let timeRemaining: string = '';
|
|
@@ -19,122 +13,34 @@
|
|
|
19
13
|
export let previewUrl: string = '';
|
|
20
14
|
export let onCancel: () => void;
|
|
21
15
|
export let onRetry: () => void;
|
|
22
|
-
|
|
23
|
-
// Computed properties
|
|
24
|
-
$: isImage = file.type.startsWith('image/');
|
|
25
|
-
$: isAudio = file.type.startsWith('audio/');
|
|
26
|
-
$: isVideo = file.type.startsWith('video/');
|
|
27
|
-
$: fileIcon = getFileIcon(file.type);
|
|
28
|
-
|
|
29
|
-
// Helper function to get appropriate icon based on file type
|
|
30
|
-
function getFileIcon(fileType: string): string {
|
|
31
|
-
if (isImage) return '🖼️';
|
|
32
|
-
if (isAudio) return '🔊';
|
|
33
|
-
if (isVideo) return '🎬';
|
|
34
|
-
|
|
35
|
-
// Default icon based on extension
|
|
36
|
-
const extension = file.name.split('.').pop()?.toLowerCase();
|
|
37
|
-
switch(extension) {
|
|
38
|
-
case 'pdf': return '📄';
|
|
39
|
-
case 'doc':
|
|
40
|
-
case 'docx': return '📝';
|
|
41
|
-
case 'xls':
|
|
42
|
-
case 'xlsx': return '📊';
|
|
43
|
-
case 'zip':
|
|
44
|
-
case 'rar': return '🗜️';
|
|
45
|
-
default: return '📁';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
</script>
|
|
49
16
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
17
|
+
$: thumbFile = {
|
|
18
|
+
name: file.name,
|
|
19
|
+
url: previewUrl || undefined,
|
|
20
|
+
mimeType: file.type
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
$: statusText =
|
|
24
|
+
status === 'complete'
|
|
25
|
+
? $t('upload.complete')
|
|
54
26
|
: status === 'failed'
|
|
55
|
-
?
|
|
56
|
-
:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{#if timeRemaining}
|
|
76
|
-
<span class="mx-1">•</span>
|
|
77
|
-
<span>{$t('upload.timeLeft', { time: timeRemaining })}</span>
|
|
78
|
-
{/if}
|
|
79
|
-
{:else if status === 'failed'}
|
|
80
|
-
<span class="text-[hsl(var(--error))]">{fileSize}</span>
|
|
81
|
-
{:else}
|
|
82
|
-
<span class="text-[hsl(var(--sage-green))]">{$t('upload.complete')}</span>
|
|
83
|
-
{/if}
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
|
|
87
|
-
<!-- Action buttons -->
|
|
88
|
-
<div class="flex-shrink-0 flex items-center">
|
|
89
|
-
{#if status === 'uploading'}
|
|
90
|
-
<button
|
|
91
|
-
class="p-2 text-[hsl(var(--grey3))] hover:text-[hsl(var(--error))] transition-colors"
|
|
92
|
-
onclick={onCancel}
|
|
93
|
-
aria-label={$t('upload.cancel')}
|
|
94
|
-
>
|
|
95
|
-
<IconTrash class="w-5 h-5" />
|
|
96
|
-
</button>
|
|
97
|
-
{:else if status === 'failed'}
|
|
98
|
-
<div class="flex gap-2">
|
|
99
|
-
<button
|
|
100
|
-
class="p-2 text-[hsl(var(--grey3))] hover:text-[hsl(var(--error))] transition-colors"
|
|
101
|
-
onclick={onCancel}
|
|
102
|
-
aria-label={$t('upload.removeFile')}
|
|
103
|
-
>
|
|
104
|
-
<IconTrash class="w-5 h-5" />
|
|
105
|
-
</button>
|
|
106
|
-
<button
|
|
107
|
-
class="p-2 text-[hsl(var(--grey3))] hover:text-[hsl(var(--deep-forest-green))] transition-colors"
|
|
108
|
-
onclick={onRetry}
|
|
109
|
-
aria-label={$t('upload.retry')}
|
|
110
|
-
>
|
|
111
|
-
<IconRefresh class="w-5 h-5" />
|
|
112
|
-
</button>
|
|
113
|
-
</div>
|
|
114
|
-
{:else}
|
|
115
|
-
<div class="w-6 h-6 rounded-full bg-[hsl(var(--sage-green))] flex items-center justify-center text-white">
|
|
116
|
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor">
|
|
117
|
-
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
|
118
|
-
</svg>
|
|
119
|
-
</div>
|
|
120
|
-
{/if}
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
123
|
-
|
|
124
|
-
<!-- Progress bar -->
|
|
125
|
-
{#if status === 'uploading' || status === 'failed'}
|
|
126
|
-
<div class="w-full h-2 bg-[hsl(var(--grey1))] rounded-full mt-2 overflow-hidden">
|
|
127
|
-
<div
|
|
128
|
-
class="h-full rounded-full {status === 'failed' ? 'bg-[hsl(var(--error))]' : 'bg-[hsl(var(--sage-green))]'}"
|
|
129
|
-
style="width: {progress}%"
|
|
130
|
-
></div>
|
|
131
|
-
</div>
|
|
132
|
-
{/if}
|
|
133
|
-
|
|
134
|
-
<!-- Error message -->
|
|
135
|
-
{#if status === 'failed' && errorMessage}
|
|
136
|
-
<p class="text-sm text-[hsl(var(--error))] mt-1">{errorMessage}</p>
|
|
137
|
-
{/if}
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
27
|
+
? errorMessage || $t('upload.failed')
|
|
28
|
+
: timeRemaining
|
|
29
|
+
? $t('upload.rowMeta', {
|
|
30
|
+
size: fileSize,
|
|
31
|
+
detail: $t('upload.timeLeft', { time: timeRemaining })
|
|
32
|
+
})
|
|
33
|
+
: fileSize;
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div class="w-full shrink-0">
|
|
37
|
+
<UploadRow
|
|
38
|
+
scope="single"
|
|
39
|
+
state={status}
|
|
40
|
+
fileName={file.name}
|
|
41
|
+
file={thumbFile}
|
|
42
|
+
{statusText}
|
|
43
|
+
onCancel={onCancel}
|
|
44
|
+
onRetry={onRetry}
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
@@ -13,7 +13,6 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
13
13
|
}
|
|
14
14
|
declare const UploadStatus: $$__sveltets_2_IsomorphicComponent<{
|
|
15
15
|
file: File;
|
|
16
|
-
progress?: number;
|
|
17
16
|
status?: "uploading" | "complete" | "failed";
|
|
18
17
|
fileSize: string;
|
|
19
18
|
timeRemaining?: string;
|