@widgetic/file-browser 0.5.17
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 +131 -0
- package/dist/components/FolderTree.svelte +143 -0
- package/dist/components/FolderTree.svelte.d.ts +32 -0
- package/dist/components/core/FileBrowser.css +79 -0
- package/dist/components/core/FileBrowser.svelte +3989 -0
- package/dist/components/core/FileBrowser.svelte.d.ts +55 -0
- package/dist/components/core/FileUploader.svelte +1152 -0
- package/dist/components/core/FileUploader.svelte.d.ts +43 -0
- package/dist/components/core/Header.svelte +143 -0
- package/dist/components/core/Header.svelte.d.ts +36 -0
- package/dist/components/core/RecentFiles.svelte +753 -0
- package/dist/components/core/RecentFiles.svelte.d.ts +37 -0
- package/dist/components/core/UploadStatus.svelte +133 -0
- package/dist/components/core/UploadStatus.svelte.d.ts +28 -0
- package/dist/components/core/UploadStatusList.svelte +138 -0
- package/dist/components/core/UploadStatusList.svelte.d.ts +33 -0
- package/dist/components/core/index.d.ts +4 -0
- package/dist/components/core/index.js +4 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +8 -0
- package/dist/components/items/FileItem.svelte +684 -0
- package/dist/components/items/FileItem.svelte.d.ts +34 -0
- package/dist/components/items/FolderItem.svelte +77 -0
- package/dist/components/items/FolderItem.svelte.d.ts +27 -0
- package/dist/components/items/index.d.ts +2 -0
- package/dist/components/items/index.js +2 -0
- package/dist/components/modals/MoveDialog.svelte +539 -0
- package/dist/components/modals/MoveDialog.svelte.d.ts +32 -0
- package/dist/components/modals/NewFolderButton.svelte +25 -0
- package/dist/components/modals/NewFolderButton.svelte.d.ts +20 -0
- package/dist/components/modals/README.md +99 -0
- package/dist/components/modals/SearchModal.svelte +500 -0
- package/dist/components/modals/SearchModal.svelte.d.ts +28 -0
- package/dist/components/modals/SelectedFilesModal.svelte +291 -0
- package/dist/components/modals/SelectedFilesModal.svelte.d.ts +32 -0
- package/dist/components/modals/index.d.ts +6 -0
- package/dist/components/modals/index.js +9 -0
- package/dist/components/previews/AudioPlayer.svelte +117 -0
- package/dist/components/previews/AudioPlayer.svelte.d.ts +22 -0
- package/dist/components/previews/ErrorPreview.svelte +12 -0
- package/dist/components/previews/ErrorPreview.svelte.d.ts +20 -0
- package/dist/components/previews/FilePreview.svelte +475 -0
- package/dist/components/previews/FilePreview.svelte.d.ts +31 -0
- package/dist/components/previews/FontPreview.svelte +82 -0
- package/dist/components/previews/FontPreview.svelte.d.ts +22 -0
- package/dist/components/previews/ImagePreview.svelte +551 -0
- package/dist/components/previews/ImagePreview.svelte.d.ts +27 -0
- package/dist/components/previews/TextPreview.svelte +92 -0
- package/dist/components/previews/TextPreview.svelte.d.ts +20 -0
- package/dist/components/previews/VideoPlayer.svelte +268 -0
- package/dist/components/previews/VideoPlayer.svelte.d.ts +22 -0
- package/dist/components/previews/WaveformVisualizer.svelte +240 -0
- package/dist/components/previews/WaveformVisualizer.svelte.d.ts +20 -0
- package/dist/components/previews/index.d.ts +8 -0
- package/dist/components/previews/index.js +8 -0
- package/dist/components/ui/ControlToolbar.svelte +342 -0
- package/dist/components/ui/ControlToolbar.svelte.d.ts +36 -0
- package/dist/components/ui/DragSelect.svelte +815 -0
- package/dist/components/ui/DragSelect.svelte.d.ts +31 -0
- package/dist/components/ui/DropdownMenu.svelte +83 -0
- package/dist/components/ui/DropdownMenu.svelte.d.ts +25 -0
- package/dist/components/ui/FileIcon.svelte +65 -0
- package/dist/components/ui/FileIcon.svelte.d.ts +25 -0
- package/dist/components/ui/FileMetadata.svelte +26 -0
- package/dist/components/ui/FileMetadata.svelte.d.ts +21 -0
- package/dist/components/ui/LoadingSkeleton.svelte +26 -0
- package/dist/components/ui/LoadingSkeleton.svelte.d.ts +22 -0
- package/dist/components/ui/SearchResults.svelte +37 -0
- package/dist/components/ui/SearchResults.svelte.d.ts +21 -0
- package/dist/components/ui/VirtualList.svelte +106 -0
- package/dist/components/ui/VirtualList.svelte.d.ts +45 -0
- package/dist/components/ui/index.d.ts +8 -0
- package/dist/components/ui/index.js +8 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +14 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +11 -0
- package/dist/static/favicon.png +0 -0
- package/dist/static/files/audio/audio-file.mp3 +0 -0
- package/dist/static/files/document/-missing-file.txt +1 -0
- package/dist/static/files/document/HeliosDesign Website Project Brief Sample.pdf +0 -0
- package/dist/static/files/document/RFP-NEC_Website-Development_2021-August.pdf +0 -0
- package/dist/static/files/document/The World Before Calculus.pdf +0 -0
- package/dist/static/files/document/specs.txt +15 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Bold.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-BoldItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Book.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-BookItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Heavy.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-HeavyItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Light.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-LightItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Medium.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-MediumItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Semibold.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-SemiboldItalic.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-Thin.otf +0 -0
- package/dist/static/files/font/CooperHewitt/CooperHewitt-ThinItalic.otf +0 -0
- package/dist/static/files/font/Kimpo/Kimpo-Bold.otf +0 -0
- package/dist/static/files/font/Kimpo/Kimpo-Regular.otf +0 -0
- package/dist/static/files/image/image 1.jpg +0 -0
- package/dist/static/files/image/image 10.jpg +0 -0
- package/dist/static/files/image/image 11.jpg +0 -0
- package/dist/static/files/image/image 12.jpg +0 -0
- package/dist/static/files/image/image 13.jpg +0 -0
- package/dist/static/files/image/image 14.jpg +0 -0
- package/dist/static/files/image/image 15.jpg +0 -0
- package/dist/static/files/image/image 16.jpg +0 -0
- package/dist/static/files/image/image 17.jpg +0 -0
- package/dist/static/files/image/image 18.jpg +0 -0
- package/dist/static/files/image/image 19.jpg +0 -0
- package/dist/static/files/image/image 2.jpg +0 -0
- package/dist/static/files/image/image 20.jpg +0 -0
- package/dist/static/files/image/image 21.jpg +0 -0
- package/dist/static/files/image/image 22.jpg +0 -0
- package/dist/static/files/image/image 23.jpg +0 -0
- package/dist/static/files/image/image 24.jpg +0 -0
- package/dist/static/files/image/image 25.jpg +0 -0
- package/dist/static/files/image/image 26.jpg +0 -0
- package/dist/static/files/image/image 27.jpg +0 -0
- package/dist/static/files/image/image 28.jpg +0 -0
- package/dist/static/files/image/image 29.jpg +0 -0
- package/dist/static/files/image/image 3.jpg +0 -0
- package/dist/static/files/image/image 30.jpg +0 -0
- package/dist/static/files/image/image 31.jpg +0 -0
- package/dist/static/files/image/image 32.jpg +0 -0
- package/dist/static/files/image/image 33.jpg +0 -0
- package/dist/static/files/image/image 34.jpg +0 -0
- package/dist/static/files/image/image 35.jpg +0 -0
- package/dist/static/files/image/image 36.jpg +0 -0
- package/dist/static/files/image/image 37.jpg +0 -0
- package/dist/static/files/image/image 38.jpg +0 -0
- package/dist/static/files/image/image 39.jpg +0 -0
- package/dist/static/files/image/image 4.jpg +0 -0
- package/dist/static/files/image/image 40.jpg +0 -0
- package/dist/static/files/image/image 41.jpg +0 -0
- package/dist/static/files/image/image 42.jpg +0 -0
- package/dist/static/files/image/image 43.jpg +0 -0
- package/dist/static/files/image/image 44.jpg +0 -0
- package/dist/static/files/image/image 45.jpg +0 -0
- package/dist/static/files/image/image 46.jpg +0 -0
- package/dist/static/files/image/image 47.jpg +0 -0
- package/dist/static/files/image/image 48.jpg +0 -0
- package/dist/static/files/image/image 49.jpg +0 -0
- package/dist/static/files/image/image 5.jpg +0 -0
- package/dist/static/files/image/image 50.jpg +0 -0
- package/dist/static/files/image/image 51.jpg +0 -0
- package/dist/static/files/image/image 52.jpg +0 -0
- package/dist/static/files/image/image 53.jpg +0 -0
- package/dist/static/files/image/image 54.jpg +0 -0
- package/dist/static/files/image/image 55.jpg +0 -0
- package/dist/static/files/image/image 56.jpg +0 -0
- package/dist/static/files/image/image 57.jpg +0 -0
- package/dist/static/files/image/image 58.jpg +0 -0
- package/dist/static/files/image/image 59.jpg +0 -0
- package/dist/static/files/image/image 6.jpg +0 -0
- package/dist/static/files/image/image 60.jpg +0 -0
- package/dist/static/files/image/image 61.jpg +0 -0
- package/dist/static/files/image/image 62.jpg +0 -0
- package/dist/static/files/image/image 63.jpg +0 -0
- package/dist/static/files/image/image 64.jpg +0 -0
- package/dist/static/files/image/image 65.jpg +0 -0
- package/dist/static/files/image/image 66.jpg +0 -0
- package/dist/static/files/image/image 67.jpg +0 -0
- package/dist/static/files/image/image 68.jpg +0 -0
- package/dist/static/files/image/image 7.jpg +0 -0
- package/dist/static/files/image/image 8.jpg +0 -0
- package/dist/static/files/image/image 9.jpg +0 -0
- package/dist/static/files/svg/astronaut.svg +30 -0
- package/dist/static/files/svg/cook.svg +30 -0
- package/dist/static/files/svg/dj.svg +28 -0
- package/dist/static/files/svg/doctor.svg +29 -0
- package/dist/static/files/svg/farmer.svg +43 -0
- package/dist/static/files/svg/fire fighter.svg +40 -0
- package/dist/static/files/svg/plumber.svg +32 -0
- package/dist/static/files/svg/santa.svg +34 -0
- package/dist/static/files/svg/scientist.svg +31 -0
- package/dist/static/files/svg/student.svg +32 -0
- package/dist/static/files/thumbnail/image 1.jpg +0 -0
- package/dist/static/files/thumbnail/image 10.jpg +0 -0
- package/dist/static/files/thumbnail/image 11.jpg +0 -0
- package/dist/static/files/thumbnail/image 12.jpg +0 -0
- package/dist/static/files/thumbnail/image 13.jpg +0 -0
- package/dist/static/files/thumbnail/image 14.jpg +0 -0
- package/dist/static/files/thumbnail/image 15.jpg +0 -0
- package/dist/static/files/thumbnail/image 16.jpg +0 -0
- package/dist/static/files/thumbnail/image 17.jpg +0 -0
- package/dist/static/files/thumbnail/image 18.jpg +0 -0
- package/dist/static/files/thumbnail/image 19.jpg +0 -0
- package/dist/static/files/thumbnail/image 2.jpg +0 -0
- package/dist/static/files/thumbnail/image 20.jpg +0 -0
- package/dist/static/files/thumbnail/image 21.jpg +0 -0
- package/dist/static/files/thumbnail/image 22.jpg +0 -0
- package/dist/static/files/thumbnail/image 23.jpg +0 -0
- package/dist/static/files/thumbnail/image 24.jpg +0 -0
- package/dist/static/files/thumbnail/image 25.jpg +0 -0
- package/dist/static/files/thumbnail/image 26.jpg +0 -0
- package/dist/static/files/thumbnail/image 27.jpg +0 -0
- package/dist/static/files/thumbnail/image 28.jpg +0 -0
- package/dist/static/files/thumbnail/image 29.jpg +0 -0
- package/dist/static/files/thumbnail/image 3.jpg +0 -0
- package/dist/static/files/thumbnail/image 30.jpg +0 -0
- package/dist/static/files/thumbnail/image 31.jpg +0 -0
- package/dist/static/files/thumbnail/image 32.jpg +0 -0
- package/dist/static/files/thumbnail/image 33.jpg +0 -0
- package/dist/static/files/thumbnail/image 34.jpg +0 -0
- package/dist/static/files/thumbnail/image 35.jpg +0 -0
- package/dist/static/files/thumbnail/image 36.jpg +0 -0
- package/dist/static/files/thumbnail/image 37.jpg +0 -0
- package/dist/static/files/thumbnail/image 38.jpg +0 -0
- package/dist/static/files/thumbnail/image 39.jpg +0 -0
- package/dist/static/files/thumbnail/image 4.jpg +0 -0
- package/dist/static/files/thumbnail/image 40.jpg +0 -0
- package/dist/static/files/thumbnail/image 41.jpg +0 -0
- package/dist/static/files/thumbnail/image 42.jpg +0 -0
- package/dist/static/files/thumbnail/image 43.jpg +0 -0
- package/dist/static/files/thumbnail/image 44.jpg +0 -0
- package/dist/static/files/thumbnail/image 45.jpg +0 -0
- package/dist/static/files/thumbnail/image 46.jpg +0 -0
- package/dist/static/files/thumbnail/image 47.jpg +0 -0
- package/dist/static/files/thumbnail/image 48.jpg +0 -0
- package/dist/static/files/thumbnail/image 49.jpg +0 -0
- package/dist/static/files/thumbnail/image 5.jpg +0 -0
- package/dist/static/files/thumbnail/image 50.jpg +0 -0
- package/dist/static/files/thumbnail/image 51.jpg +0 -0
- package/dist/static/files/thumbnail/image 52.jpg +0 -0
- package/dist/static/files/thumbnail/image 53.jpg +0 -0
- package/dist/static/files/thumbnail/image 54.jpg +0 -0
- package/dist/static/files/thumbnail/image 55.jpg +0 -0
- package/dist/static/files/thumbnail/image 56.jpg +0 -0
- package/dist/static/files/thumbnail/image 57.jpg +0 -0
- package/dist/static/files/thumbnail/image 58.jpg +0 -0
- package/dist/static/files/thumbnail/image 59.jpg +0 -0
- package/dist/static/files/thumbnail/image 6.jpg +0 -0
- package/dist/static/files/thumbnail/image 60.jpg +0 -0
- package/dist/static/files/thumbnail/image 61.jpg +0 -0
- package/dist/static/files/thumbnail/image 62.jpg +0 -0
- package/dist/static/files/thumbnail/image 63.jpg +0 -0
- package/dist/static/files/thumbnail/image 64.jpg +0 -0
- package/dist/static/files/thumbnail/image 65.jpg +0 -0
- package/dist/static/files/thumbnail/image 66.jpg +0 -0
- package/dist/static/files/thumbnail/image 67.jpg +0 -0
- package/dist/static/files/thumbnail/image 68.jpg +0 -0
- package/dist/static/files/thumbnail/image 7.jpg +0 -0
- package/dist/static/files/thumbnail/image 8.jpg +0 -0
- package/dist/static/files/thumbnail/image 9.jpg +0 -0
- package/dist/static/files/video/video-file.mp4 +0 -0
- package/dist/static/files/video/video-file.png +0 -0
- package/dist/static/icons/audio.svg +7 -0
- package/dist/static/icons/check.svg +3 -0
- package/dist/static/icons/checked.svg +4 -0
- package/dist/static/icons/close.svg +11 -0
- package/dist/static/icons/document.svg +11 -0
- package/dist/static/icons/dots.svg +1 -0
- package/dist/static/icons/download.svg +1 -0
- package/dist/static/icons/empty-folder.svg +24 -0
- package/dist/static/icons/error.svg +5 -0
- package/dist/static/icons/file-upload.svg +1 -0
- package/dist/static/icons/folder-plus.svg +1 -0
- package/dist/static/icons/folder.svg +28 -0
- package/dist/static/icons/jump-to-folder.svg +1 -0
- package/dist/static/icons/move.svg +1 -0
- package/dist/static/icons/new-folder.svg +5 -0
- package/dist/static/icons/pdf.svg +6 -0
- package/dist/static/icons/player-pause.svg +1 -0
- package/dist/static/icons/player-play.svg +3 -0
- package/dist/static/icons/plus.svg +1 -0
- package/dist/static/icons/rename.svg +1 -0
- package/dist/static/icons/search.svg +1 -0
- package/dist/static/icons/trash.svg +1 -0
- package/dist/static/icons/unorganized-folder.svg +60 -0
- package/dist/stores/dragStore.d.ts +2 -0
- package/dist/stores/dragStore.js +2 -0
- package/dist/stores/fileStore.d.ts +36 -0
- package/dist/stores/fileStore.js +166 -0
- package/dist/stores/folderCountStore.d.ts +5 -0
- package/dist/stores/folderCountStore.js +49 -0
- package/dist/stores/index.d.ts +7 -0
- package/dist/stores/index.js +8 -0
- package/dist/stores/missingFilesStore.d.ts +3 -0
- package/dist/stores/missingFilesStore.js +14 -0
- package/dist/stores/navigationStore.d.ts +36 -0
- package/dist/stores/navigationStore.js +615 -0
- package/dist/stores/persistentSelectStore.d.ts +17 -0
- package/dist/stores/persistentSelectStore.js +170 -0
- package/dist/stores/searchStore.d.ts +1 -0
- package/dist/stores/searchStore.js +2 -0
- package/dist/stores/uploadApiStore.d.ts +13 -0
- package/dist/stores/uploadApiStore.js +36 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/pdf.d.ts +3 -0
- package/dist/types.d.ts +23 -0
- package/dist/types.js +1 -0
- package/dist/utils/apiConfig.d.ts +9 -0
- package/dist/utils/apiConfig.js +19 -0
- package/dist/utils/dateUtils.d.ts +2 -0
- package/dist/utils/dateUtils.js +38 -0
- package/dist/utils/fileOperations.d.ts +36 -0
- package/dist/utils/fileOperations.js +573 -0
- package/dist/utils/fileTypes.d.ts +17 -0
- package/dist/utils/fileTypes.js +110 -0
- package/dist/utils/fileUtils.d.ts +15 -0
- package/dist/utils/fileUtils.js +112 -0
- package/dist/utils/folderUtils.d.ts +4 -0
- package/dist/utils/folderUtils.js +26 -0
- package/dist/utils/imageTransform.d.ts +22 -0
- package/dist/utils/imageTransform.js +60 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/resolveFileUrl.d.ts +6 -0
- package/dist/utils/resolveFileUrl.js +21 -0
- package/dist/utils/userUploadsStorage.d.ts +27 -0
- package/dist/utils/userUploadsStorage.js +168 -0
- package/dist/utils/widgeticTusUpload.d.ts +18 -0
- package/dist/utils/widgeticTusUpload.js +131 -0
- package/dist/utils/widgeticUpload.d.ts +29 -0
- package/dist/utils/widgeticUpload.js +105 -0
- package/package.json +156 -0
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* RecentFiles Component
|
|
4
|
+
* Displays a grid of recently accessed files with thumbnails and actions
|
|
5
|
+
* Supports file selection, preview, and dropdown actions
|
|
6
|
+
*/
|
|
7
|
+
import type { FileSystemItem } from '../../types';
|
|
8
|
+
import { createEventDispatcher, onMount } from 'svelte';
|
|
9
|
+
import { getFileType, getFileIcon } from '../../utils/fileUtils';
|
|
10
|
+
import { formatRelativeDate } from '../../utils/dateUtils';
|
|
11
|
+
import { DropdownMenu, FileIcon } from '../ui';
|
|
12
|
+
import { type FileFilterType } from '../../utils/fileTypes';
|
|
13
|
+
// import ThumbHashImage from '../previews/ThumbHashImage.svelte';
|
|
14
|
+
import { ThumbHashImage } from "@widgetic/design-system/components";
|
|
15
|
+
import { IconExclamationCircle } from '@widgetic/design-system/icons';
|
|
16
|
+
import { browser } from '$app/environment';
|
|
17
|
+
import { getAssetUrl } from '../../utils/fileUtils';
|
|
18
|
+
|
|
19
|
+
/* COMPONENT PROPS */
|
|
20
|
+
let className = '';
|
|
21
|
+
export { className as class };
|
|
22
|
+
export let style: string = '';
|
|
23
|
+
//
|
|
24
|
+
export let recentFiles: FileSystemItem[] = [];
|
|
25
|
+
export let selectedFiles: FileSystemItem[] = [];
|
|
26
|
+
// svelte-ignore export_let_unused
|
|
27
|
+
export let currentFilter: FileFilterType = 'all';
|
|
28
|
+
export let allowSelecting: boolean = false;
|
|
29
|
+
export let columnWidth: number = 40; // Default value if not provided
|
|
30
|
+
|
|
31
|
+
/* STATE VARS */
|
|
32
|
+
// Responsive breakpoints from global.css
|
|
33
|
+
const DESKTOP_BREAKPOINT = 1156;
|
|
34
|
+
const TABLET_BREAKPOINT = 744;
|
|
35
|
+
const MOBILE_BREAKPOINT = 393;
|
|
36
|
+
|
|
37
|
+
// Responsive vars
|
|
38
|
+
let windowWidth = browser ? window.innerWidth : DESKTOP_BREAKPOINT;
|
|
39
|
+
let gridColumns = 3; // Default number of columns
|
|
40
|
+
let maxRecentFiles = 3; // Default number of recent files to display
|
|
41
|
+
|
|
42
|
+
// Logs
|
|
43
|
+
let showLogs = false;
|
|
44
|
+
|
|
45
|
+
/* METHODS */
|
|
46
|
+
// Update grid columns and max files based on window width
|
|
47
|
+
function updateResponsiveLayout() {
|
|
48
|
+
if (windowWidth > DESKTOP_BREAKPOINT) {
|
|
49
|
+
// For large desktop screens, show more files
|
|
50
|
+
const availableWidth = windowWidth;
|
|
51
|
+
// Calculate how many columns would fit nicely
|
|
52
|
+
gridColumns = Math.min(6, Math.floor(availableWidth / 300));
|
|
53
|
+
// Set max files to fill at least one row
|
|
54
|
+
maxRecentFiles = gridColumns * 2; // Two rows of content
|
|
55
|
+
} else if (windowWidth > TABLET_BREAKPOINT) {
|
|
56
|
+
// Standard desktop
|
|
57
|
+
gridColumns = 3;
|
|
58
|
+
maxRecentFiles = 6; // Two rows
|
|
59
|
+
} else {
|
|
60
|
+
// Tablet and below - we don't show recent files on these sizes
|
|
61
|
+
// but keeping the logic for completeness
|
|
62
|
+
gridColumns = 2;
|
|
63
|
+
maxRecentFiles = 4;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if(showLogs) console.log('Responsive layout updated:', { windowWidth, gridColumns, maxRecentFiles });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Grid setup
|
|
70
|
+
$: gridGap = 20; // Gap between items (px)
|
|
71
|
+
$: numberOfColumns = gridColumns; // Number of columns
|
|
72
|
+
|
|
73
|
+
// Debug log to monitor size calculations
|
|
74
|
+
$: if(showLogs) console.log('RecentFiles sizing:', { columnWidth, numberOfColumns, gridGap, maxRecentFiles });
|
|
75
|
+
|
|
76
|
+
const dispatch = createEventDispatcher();
|
|
77
|
+
|
|
78
|
+
// Remove redundant filtering since files are already filtered by parent
|
|
79
|
+
$: filteredRecentFiles = recentFiles.slice(0, maxRecentFiles);
|
|
80
|
+
|
|
81
|
+
// File states
|
|
82
|
+
let loadingStates = new Map<string, boolean>();
|
|
83
|
+
let errorStates = new Map<string, boolean>();
|
|
84
|
+
let imageLoaded = false;
|
|
85
|
+
let loadedStates = new Map<string, boolean>();
|
|
86
|
+
|
|
87
|
+
// Add a map to track cached fonts
|
|
88
|
+
let cachedFonts = new Map<string, boolean>();
|
|
89
|
+
// Add a map to track cached SVGs
|
|
90
|
+
let cachedSvgs = new Map<string, boolean>();
|
|
91
|
+
|
|
92
|
+
function shouldUseFileIcon(file: FileSystemItem): boolean {
|
|
93
|
+
if (file.isMissing || errorStates.get(file.id)) return false;
|
|
94
|
+
const fileType = getFileType(file.url || file.name);
|
|
95
|
+
return fileType === 'font' && !isFontCached(file);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Initialize loading states for all files
|
|
99
|
+
$: {
|
|
100
|
+
recentFiles.forEach(file => {
|
|
101
|
+
if (!loadingStates.has(file.id)) {
|
|
102
|
+
loadingStates.set(file.id, true);
|
|
103
|
+
errorStates.set(file.id, false);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
loadingStates = loadingStates;
|
|
107
|
+
errorStates = errorStates;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Validates file existence by performing a HEAD request
|
|
112
|
+
* Used to show appropriate UI state for missing files
|
|
113
|
+
* @param url File URL to check
|
|
114
|
+
* @returns Promise resolving to boolean indicating file existence
|
|
115
|
+
*/
|
|
116
|
+
async function checkFileExists(url: string | undefined): Promise<boolean> {
|
|
117
|
+
if (!url) return false;
|
|
118
|
+
try {
|
|
119
|
+
const response = await fetch(url, { method: 'HEAD' });
|
|
120
|
+
return response.ok;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if(showLogs) console.error('Error checking file existence:', error);
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Checks if a font is cached in the browser
|
|
129
|
+
* @param file File to check for font caching
|
|
130
|
+
* @returns Promise resolving to boolean indicating if font is cached
|
|
131
|
+
*/
|
|
132
|
+
async function checkFontCached(file: FileSystemItem): Promise<boolean> {
|
|
133
|
+
const fileType = getFileType(file.url || file.name);
|
|
134
|
+
if (fileType !== 'font') return false;
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
// Try to check if font is in document.fonts
|
|
138
|
+
if (document.fonts) {
|
|
139
|
+
const fontName = file.name.split('.')[0]; // Extract font name without extension
|
|
140
|
+
// Try multiple font checks to ensure accurate detection
|
|
141
|
+
const checks = [
|
|
142
|
+
document.fonts.check(`1em "${fontName}"`),
|
|
143
|
+
document.fonts.check(`1em '${fontName}'`)
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
const results = await Promise.all(checks);
|
|
147
|
+
const isCached = results.some(result => result === true);
|
|
148
|
+
if(showLogs) console.log(`Font ${fontName} cached status:`, isCached);
|
|
149
|
+
return isCached;
|
|
150
|
+
}
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if(showLogs) console.error('Error checking font cache:', error);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Checks if an SVG file is cached in the browser
|
|
160
|
+
* @param file File to check for SVG caching
|
|
161
|
+
* @returns Promise resolving to boolean indicating if SVG is cached
|
|
162
|
+
*/
|
|
163
|
+
async function checkSvgCached(file: FileSystemItem): Promise<boolean> {
|
|
164
|
+
const fileType = getFileType(file.url || file.name);
|
|
165
|
+
if (fileType !== 'svg' || !file.url) return false;
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
// More reliable method to check if an image is cached
|
|
169
|
+
return new Promise((resolve) => {
|
|
170
|
+
const img = new Image();
|
|
171
|
+
|
|
172
|
+
// If image loads immediately (from cache), complete will be true
|
|
173
|
+
if (img.complete) {
|
|
174
|
+
if(showLogs) console.log(`SVG ${file.name} found in cache`);
|
|
175
|
+
resolve(true);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Set up load and error handlers
|
|
180
|
+
img.onload = () => {
|
|
181
|
+
if(showLogs) console.log(`SVG ${file.name} loaded but was not cached`);
|
|
182
|
+
resolve(false);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
img.onerror = () => {
|
|
186
|
+
if(showLogs) console.error(`Error loading SVG ${file.name}`);
|
|
187
|
+
resolve(false);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// Set source to trigger load - ensure URL is a string
|
|
191
|
+
if (file.url) {
|
|
192
|
+
img.src = file.url;
|
|
193
|
+
|
|
194
|
+
// Double check for immediate completion (happens with cached images)
|
|
195
|
+
if (img.complete) {
|
|
196
|
+
if(showLogs) console.log(`SVG ${file.name} found in cache (after src set)`);
|
|
197
|
+
resolve(true);
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
// No URL available, can't check cache
|
|
201
|
+
if(showLogs) console.warn(`No URL available for SVG ${file.name}`);
|
|
202
|
+
resolve(false);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if(showLogs) console.error('Error checking SVG cache:', error);
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Explicitly loads a font file to ensure it's available for display
|
|
213
|
+
* @param file Font file to load
|
|
214
|
+
* @returns Promise resolving when loading is complete
|
|
215
|
+
*/
|
|
216
|
+
async function loadFontForDisplay(file: FileSystemItem): Promise<void> {
|
|
217
|
+
if (!file.url) return;
|
|
218
|
+
|
|
219
|
+
const fontName = file.name.split('.')[0];
|
|
220
|
+
const fontId = `font-${file.id}`;
|
|
221
|
+
|
|
222
|
+
// Skip if we already added this font
|
|
223
|
+
if (document.getElementById(fontId)) return;
|
|
224
|
+
|
|
225
|
+
try {
|
|
226
|
+
// Create a style element with @font-face declaration
|
|
227
|
+
const style = document.createElement('style');
|
|
228
|
+
style.id = fontId;
|
|
229
|
+
style.textContent = `
|
|
230
|
+
@font-face {
|
|
231
|
+
font-family: "${fontName}";
|
|
232
|
+
src: url("${file.url}") format("opentype");
|
|
233
|
+
font-weight: normal;
|
|
234
|
+
font-style: normal;
|
|
235
|
+
font-display: block;
|
|
236
|
+
}
|
|
237
|
+
`;
|
|
238
|
+
document.head.appendChild(style);
|
|
239
|
+
if(showLogs) console.log(`Added @font-face declaration for font ${fontName}`);
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if(showLogs) console.error(`Failed to load font ${fontName}:`, error);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Check existence of all files
|
|
247
|
+
* Updates loading states and missing flags for each file
|
|
248
|
+
*/
|
|
249
|
+
async function checkFiles() {
|
|
250
|
+
const promises = recentFiles.map(async (file) => {
|
|
251
|
+
try {
|
|
252
|
+
const fileType = getFileType(file.url || file.name);
|
|
253
|
+
const isVideo = fileType === 'video';
|
|
254
|
+
const isSvg = fileType === 'svg';
|
|
255
|
+
const isFont = fileType === 'font';
|
|
256
|
+
|
|
257
|
+
// Check if font is cached
|
|
258
|
+
if (isFont) {
|
|
259
|
+
const isCached = await checkFontCached(file);
|
|
260
|
+
cachedFonts.set(file.id, isCached);
|
|
261
|
+
|
|
262
|
+
if (isCached) {
|
|
263
|
+
// For cached fonts, ensure they're loaded for display
|
|
264
|
+
await loadFontForDisplay(file);
|
|
265
|
+
|
|
266
|
+
// Skip loading state for cached fonts
|
|
267
|
+
loadingStates.set(file.id, false);
|
|
268
|
+
errorStates.set(file.id, false);
|
|
269
|
+
file.isMissing = false;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Check if SVG is cached
|
|
275
|
+
if (isSvg) {
|
|
276
|
+
const isCached = await checkSvgCached(file);
|
|
277
|
+
cachedSvgs.set(file.id, isCached);
|
|
278
|
+
|
|
279
|
+
if (isCached) {
|
|
280
|
+
// Skip loading state for cached SVGs
|
|
281
|
+
loadingStates.set(file.id, false);
|
|
282
|
+
errorStates.set(file.id, false);
|
|
283
|
+
file.isMissing = false;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// For video and SVG files, only check the file existence
|
|
289
|
+
if (isVideo || isSvg) {
|
|
290
|
+
const fileExists = await checkFileExists(file.url);
|
|
291
|
+
file.isMissing = !fileExists;
|
|
292
|
+
errorStates.set(file.id, !fileExists);
|
|
293
|
+
loadingStates.set(file.id, false);
|
|
294
|
+
} else {
|
|
295
|
+
// For other files, keep existing logic
|
|
296
|
+
const exists = await checkFileExists(file.url);
|
|
297
|
+
file.isMissing = !exists;
|
|
298
|
+
errorStates.set(file.id, !exists);
|
|
299
|
+
loadingStates.set(file.id, false);
|
|
300
|
+
}
|
|
301
|
+
} catch (error) {
|
|
302
|
+
if(showLogs) console.error('Error checking file:', file.name, error);
|
|
303
|
+
file.isMissing = true;
|
|
304
|
+
errorStates.set(file.id, true);
|
|
305
|
+
loadingStates.set(file.id, false);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
await Promise.all(promises);
|
|
310
|
+
loadingStates = loadingStates;
|
|
311
|
+
errorStates = errorStates;
|
|
312
|
+
cachedFonts = cachedFonts;
|
|
313
|
+
cachedSvgs = cachedSvgs;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Checks if a file is currently loading
|
|
318
|
+
* @param file File to check loading status
|
|
319
|
+
* @returns boolean indicating if file is loading
|
|
320
|
+
*/
|
|
321
|
+
function isLoading(file: FileSystemItem): boolean {
|
|
322
|
+
return loadingStates.get(file.id) || false;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Handles image loading errors
|
|
327
|
+
* @param file File that failed to load
|
|
328
|
+
*/
|
|
329
|
+
function handleImageError(file: FileSystemItem) {
|
|
330
|
+
errorStates.set(file.id, true);
|
|
331
|
+
errorStates = errorStates;
|
|
332
|
+
file.isMissing = true;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Gets thumbnail or appropriate icon for file
|
|
337
|
+
* Returns error icon for missing files
|
|
338
|
+
* @param file File to get thumbnail/icon for
|
|
339
|
+
* @returns URL to thumbnail or icon
|
|
340
|
+
*/
|
|
341
|
+
function getThumbnailOrIcon(file: FileSystemItem): string {
|
|
342
|
+
if (isLoading(file)) return '';
|
|
343
|
+
|
|
344
|
+
const fileType = getFileType(file.url || file.name);
|
|
345
|
+
const isVideo = fileType === 'video';
|
|
346
|
+
const isSvg = fileType === 'svg';
|
|
347
|
+
const isAudio = fileType === 'audio';
|
|
348
|
+
|
|
349
|
+
if (file.isMissing && !isVideo && !isSvg) {
|
|
350
|
+
return getAssetUrl('/icons/error.svg');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (isSvg) {
|
|
354
|
+
return file.url || '';
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (fileType === 'image') {
|
|
358
|
+
return file.url || '';
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (isVideo) {
|
|
362
|
+
return file.thumbnail || '';
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (isAudio) {
|
|
366
|
+
return getAssetUrl(getFileIcon(file.name));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return getAssetUrl(getFileIcon(file.name));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Checks if file is a media type (video/audio)
|
|
374
|
+
* @param file File to check
|
|
375
|
+
* @returns boolean indicating if file is media
|
|
376
|
+
*/
|
|
377
|
+
function isMediaFile(file: FileSystemItem): boolean {
|
|
378
|
+
const fileType = getFileType(file.url || file.name);
|
|
379
|
+
return fileType === 'video' || fileType === 'audio';
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Gets background color based on file type
|
|
384
|
+
* Returns light red for missing files
|
|
385
|
+
* @param file File to get background for
|
|
386
|
+
* @returns CSS color value
|
|
387
|
+
*/
|
|
388
|
+
function getBackgroundColor(file: FileSystemItem): string {
|
|
389
|
+
if (file.isMissing || errorStates.get(file.id)) return '#FFF5F5';
|
|
390
|
+
const fileType = getFileType(file.url || file.name);
|
|
391
|
+
if (fileType === 'audio') return '#A7FF68';
|
|
392
|
+
if (fileType === 'document') return '#FFDC68';
|
|
393
|
+
return 'bg-gray-100';
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Determines if file should use SVG icon display
|
|
398
|
+
* @param file File to check
|
|
399
|
+
* @returns boolean indicating if SVG icon should be used
|
|
400
|
+
*/
|
|
401
|
+
function isSvgIcon(file: FileSystemItem): boolean {
|
|
402
|
+
const fileType = getFileType(file.url || file.name);
|
|
403
|
+
return fileType === 'svg';
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Handles file preview click
|
|
408
|
+
* Only triggers for non-missing files
|
|
409
|
+
* @param file File to preview
|
|
410
|
+
*/
|
|
411
|
+
function handleFileClick(file: FileSystemItem) {
|
|
412
|
+
if (!file.isMissing && !errorStates.get(file.id)) {
|
|
413
|
+
dispatch('fileClick', file);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Handles file selection toggle
|
|
419
|
+
* @param file File to select/deselect
|
|
420
|
+
*/
|
|
421
|
+
function handleFileSelect(file: FileSystemItem) {
|
|
422
|
+
dispatch('select', file);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Checks if a file is currently selected
|
|
427
|
+
* @param file File to check selection status
|
|
428
|
+
* @returns boolean indicating if file is selected
|
|
429
|
+
*/
|
|
430
|
+
function isSelected(file: FileSystemItem): boolean {
|
|
431
|
+
return selectedFiles.some(selectedFile => selectedFile.id === file.id);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Handles dropdown menu actions
|
|
436
|
+
* @param file File to perform action on
|
|
437
|
+
* @param action Action to perform
|
|
438
|
+
*/
|
|
439
|
+
function handleDropdownAction(file: FileSystemItem, action: string) {
|
|
440
|
+
dispatch('action', { action, item: file });
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Formats file modification date
|
|
445
|
+
* @param date Date to format
|
|
446
|
+
* @returns Formatted date string
|
|
447
|
+
*/
|
|
448
|
+
function getFormattedDate(date: string | Date): string {
|
|
449
|
+
return formatRelativeDate(date);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Handle window resize event
|
|
454
|
+
*/
|
|
455
|
+
function handleResize() {
|
|
456
|
+
windowWidth = window.innerWidth;
|
|
457
|
+
updateResponsiveLayout();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Check files on mount
|
|
461
|
+
onMount(() => {
|
|
462
|
+
if (browser) {
|
|
463
|
+
// Set up resize listener
|
|
464
|
+
window.addEventListener('resize', handleResize);
|
|
465
|
+
|
|
466
|
+
// Initial layout update
|
|
467
|
+
updateResponsiveLayout();
|
|
468
|
+
|
|
469
|
+
// Check files
|
|
470
|
+
if (recentFiles.length > 0) {
|
|
471
|
+
checkFiles();
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Cleanup on component destroy
|
|
475
|
+
return () => {
|
|
476
|
+
window.removeEventListener('resize', handleResize);
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// Check files when they change
|
|
482
|
+
$: {
|
|
483
|
+
if (recentFiles.length > 0) {
|
|
484
|
+
checkFiles();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
$: {
|
|
489
|
+
if (recentFiles) {
|
|
490
|
+
recentFiles.forEach(file => {
|
|
491
|
+
if (!loadedStates.has(file.id)) {
|
|
492
|
+
loadedStates.set(file.id, false);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function handleLoad(fileId: string) {
|
|
499
|
+
loadedStates.set(fileId, true);
|
|
500
|
+
loadedStates = loadedStates;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Checks if a font file is cached
|
|
505
|
+
* @param file File to check
|
|
506
|
+
* @returns boolean indicating if font is cached
|
|
507
|
+
*/
|
|
508
|
+
function isFontCached(file: FileSystemItem): boolean {
|
|
509
|
+
return cachedFonts.get(file.id) || false;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Determines if file is a font that should show cached preview
|
|
514
|
+
* @param file File to check
|
|
515
|
+
* @returns boolean indicating if cached font preview should be used
|
|
516
|
+
*/
|
|
517
|
+
function isCachedFontPreview(file: FileSystemItem): boolean {
|
|
518
|
+
if (file.isMissing || errorStates.get(file.id)) return false;
|
|
519
|
+
const fileType = getFileType(file.url || file.name);
|
|
520
|
+
return fileType === 'font' && isFontCached(file);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Checks if an SVG file is cached
|
|
525
|
+
* @param file File to check
|
|
526
|
+
* @returns boolean indicating if SVG is cached
|
|
527
|
+
*/
|
|
528
|
+
function isSvgCached(file: FileSystemItem): boolean {
|
|
529
|
+
return cachedSvgs.get(file.id) || false;
|
|
530
|
+
}
|
|
531
|
+
</script>
|
|
532
|
+
|
|
533
|
+
<!-- Recent Files Container -->
|
|
534
|
+
<div class="{className ? className + ' ' : ''} pt-8 widgetic-colors flex flex-col"
|
|
535
|
+
style="{style ? style + ' ' : ''}display:flex;"
|
|
536
|
+
>
|
|
537
|
+
<!-- Section Header -->
|
|
538
|
+
<h2 class="h5 text-[hsl(var(--grey7))] mb-4">Recent Files</h2>
|
|
539
|
+
|
|
540
|
+
<!-- Files Grid Layout - Using CSS Grid with responsive columns -->
|
|
541
|
+
<div class="grid gap-5 w-full" style="grid-template-columns: repeat({numberOfColumns}, minmax(0, 1fr));">
|
|
542
|
+
{#each filteredRecentFiles as file (file.id)}
|
|
543
|
+
<!-- Individual File Card -->
|
|
544
|
+
<div class="w-full">
|
|
545
|
+
<!-- File Item Container -->
|
|
546
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
547
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
548
|
+
<div
|
|
549
|
+
data-item-id={file.id}
|
|
550
|
+
class="item-container w-full h-full relative overflow-hidden rounded-large widgetic-radius cursor-pointer group transition-all duration-200 {isSelected(file) ? 'p-2' : 'p-0'} {isSelected(file) ? 'bg-[hsl(var(--light-green))]' : 'hover:bg-[hsl(var(--grey1))]'}"
|
|
551
|
+
onclick={(e) => {
|
|
552
|
+
const target = e.target as HTMLElement;
|
|
553
|
+
if (!target.closest('.item-preview')) {
|
|
554
|
+
handleFileSelect(file);
|
|
555
|
+
}
|
|
556
|
+
}}
|
|
557
|
+
>
|
|
558
|
+
<!-- Content Container -->
|
|
559
|
+
<div class="transition-all duration-200 h-full">
|
|
560
|
+
<!-- Thumbnail Container Wrapper -->
|
|
561
|
+
<div class="relative mb-2 transition-transform duration-200">
|
|
562
|
+
<!-- Thumbnail Container -->
|
|
563
|
+
<div
|
|
564
|
+
class="item-preview relative overflow-hidden {isSelected(file) ? 'rounded-medium' : 'rounded-large'} widgetic-radius flex items-center justify-center cursor-pointer hover:opacity-80 transition-opacity duration-150"
|
|
565
|
+
style="width: 100%; aspect-ratio: 16/10;"
|
|
566
|
+
onclick={(e) => {
|
|
567
|
+
e.stopPropagation();
|
|
568
|
+
if (!file.isMissing) {
|
|
569
|
+
handleFileClick(file);
|
|
570
|
+
}
|
|
571
|
+
}}
|
|
572
|
+
role="button"
|
|
573
|
+
tabindex="0"
|
|
574
|
+
onkeydown={(e) => {
|
|
575
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
576
|
+
e.preventDefault();
|
|
577
|
+
e.stopPropagation();
|
|
578
|
+
if (!file.isMissing) {
|
|
579
|
+
handleFileClick(file);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}}
|
|
583
|
+
>
|
|
584
|
+
{#if isLoading(file)}
|
|
585
|
+
<div class="w-full h-full flex items-center justify-center">
|
|
586
|
+
<!-- <span class="text-gray-400">Loading...</span> -->
|
|
587
|
+
</div>
|
|
588
|
+
{:else}
|
|
589
|
+
<!-- File Thumbnail/Icon -->
|
|
590
|
+
{#if shouldUseFileIcon(file)}
|
|
591
|
+
<div class="w-full h-full flex items-center justify-center bg-[hsl(var(--grey1))] rounded-large widgetic-radius preview-fade">
|
|
592
|
+
<div class="transform scale-[3]">
|
|
593
|
+
<FileIcon {file} size="lg" />
|
|
594
|
+
</div>
|
|
595
|
+
</div>
|
|
596
|
+
{:else if isCachedFontPreview(file)}
|
|
597
|
+
<!-- Display cached font with sample text - no fade animation -->
|
|
598
|
+
<div class="w-full h-full flex flex-col items-center justify-center bg-[hsl(var(--grey1))] rounded-large widgetic-radius cached-font-preview">
|
|
599
|
+
<div class="flex flex-col items-center justify-center h-full w-full">
|
|
600
|
+
<!-- Use inline style with !important to force font application -->
|
|
601
|
+
<div style="font-family: {file.name.split('.')[0]} !important;" class="text-8xl mb-4 text-[hsl(var(--grey7))] widgetic-colors">
|
|
602
|
+
aA
|
|
603
|
+
</div>
|
|
604
|
+
<div style="font-family: {file.name.split('.')[0]} !important;" class="text-xl text-[hsl(var(--grey7))] widgetic-colors">
|
|
605
|
+
The quick fox
|
|
606
|
+
</div>
|
|
607
|
+
</div>
|
|
608
|
+
</div>
|
|
609
|
+
{:else if isSvgIcon(file)}
|
|
610
|
+
<div class="w-full h-full flex items-center justify-center bg-[hsl(var(--grey1))] rounded-large widgetic-radius {isSvgCached(file) ? 'cached-preview' : 'preview-fade'}">
|
|
611
|
+
<div class="w-[120px] h-[120px] flex items-center justify-center">
|
|
612
|
+
<img
|
|
613
|
+
src={file.url}
|
|
614
|
+
alt={file.name}
|
|
615
|
+
class="w-full h-full object-contain"
|
|
616
|
+
/>
|
|
617
|
+
</div>
|
|
618
|
+
</div>
|
|
619
|
+
{:else if isMediaFile(file) && file.hash && file.url}
|
|
620
|
+
<div class="absolute inset-0">
|
|
621
|
+
<ThumbHashImage
|
|
622
|
+
src={getFileType(file.url || file.name) === 'video' ? (file.thumbnail || file.url) : file.url}
|
|
623
|
+
alt={file.name}
|
|
624
|
+
thumbhash={file.hash}
|
|
625
|
+
class_="w-full h-full object-cover"
|
|
626
|
+
/>
|
|
627
|
+
</div>
|
|
628
|
+
<img
|
|
629
|
+
src={getFileType(file.url || file.name) === 'video' ? (file.thumbnail || '') : file.url}
|
|
630
|
+
alt={file.name}
|
|
631
|
+
class="w-full h-full absolute inset-0 object-cover fade-in"
|
|
632
|
+
onload={() => imageLoaded = true}
|
|
633
|
+
onerror={() => handleImageError(file)}
|
|
634
|
+
/>
|
|
635
|
+
{:else}
|
|
636
|
+
<img
|
|
637
|
+
src={getThumbnailOrIcon(file)}
|
|
638
|
+
alt={file.name}
|
|
639
|
+
class="w-full h-full object-cover fade-in"
|
|
640
|
+
onload={() => imageLoaded = true}
|
|
641
|
+
onerror={() => handleImageError(file)}
|
|
642
|
+
/>
|
|
643
|
+
{/if}
|
|
644
|
+
|
|
645
|
+
<!-- Play Button Overlay for Media Files -->
|
|
646
|
+
{#if isMediaFile(file) && !file.isMissing && !errorStates.get(file.id)}
|
|
647
|
+
<div class="absolute inset-0 flex items-center justify-center transition-transform duration-200 {isSelected(file) ? 'scale-[0.8]' : ''}">
|
|
648
|
+
<img src={getAssetUrl('/icons/player-play.svg')} alt="Play" class="w-36 h-36" />
|
|
649
|
+
</div>
|
|
650
|
+
{/if}
|
|
651
|
+
{/if}
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
654
|
+
|
|
655
|
+
<!-- File Information Container -->
|
|
656
|
+
<div class="flex flex-col px-4">
|
|
657
|
+
<!-- Title and Checkmark Row -->
|
|
658
|
+
<div class="flex items-start justify-between mb-1">
|
|
659
|
+
<div class="flex-1 min-w-0">
|
|
660
|
+
<!-- File Name -->
|
|
661
|
+
<h3 class="body-medium text-[hsl({file.isMissing ? 'var(--error)' : 'var(--grey7)'})] truncate">
|
|
662
|
+
{file.name}
|
|
663
|
+
</h3>
|
|
664
|
+
|
|
665
|
+
<!-- File Modification Date -->
|
|
666
|
+
<p class="subtext text-[hsl({file.isMissing ? 'var(--error)' : 'var(--grey5)'})] truncate">
|
|
667
|
+
{getFormattedDate(file.modified || new Date())}
|
|
668
|
+
</p>
|
|
669
|
+
</div>
|
|
670
|
+
|
|
671
|
+
<!-- Selection Check Icon -->
|
|
672
|
+
{#if isSelected(file) && allowSelecting}
|
|
673
|
+
<div class="ml-2 mt-1 flex-shrink-0">
|
|
674
|
+
<img src={getAssetUrl('/icons/checked.svg')} alt="Selected" class="w-5 h-5" />
|
|
675
|
+
</div>
|
|
676
|
+
{:else if !file.isMissing && allowSelecting}
|
|
677
|
+
<div class="ml-2 mt-1 opacity-0 group-hover:opacity-20 transition-all duration-200 flex-shrink-0">
|
|
678
|
+
<img src={getAssetUrl('/icons/checked.svg')} alt="Select" class="w-5 h-5" />
|
|
679
|
+
</div>
|
|
680
|
+
{/if}
|
|
681
|
+
</div>
|
|
682
|
+
</div>
|
|
683
|
+
</div>
|
|
684
|
+
</div>
|
|
685
|
+
</div>
|
|
686
|
+
{/each}
|
|
687
|
+
</div>
|
|
688
|
+
|
|
689
|
+
<!-- Empty State Message -->
|
|
690
|
+
{#if filteredRecentFiles.length === 0}
|
|
691
|
+
<div class="flex items-center justify-center h-[197px]">
|
|
692
|
+
<div class="flex items-center gap-2">
|
|
693
|
+
<IconExclamationCircle class="w-6 h-6 text-[hsl(var(--grey3))]" />
|
|
694
|
+
<p class="text-[hsl(var(--grey3))] subtext">No recent files available!</p>
|
|
695
|
+
</div>
|
|
696
|
+
</div>
|
|
697
|
+
{/if}
|
|
698
|
+
</div>
|
|
699
|
+
|
|
700
|
+
<style>
|
|
701
|
+
:global(.item-preview:hover) {
|
|
702
|
+
opacity: 0.8;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
:global(.item-preview) {
|
|
706
|
+
transition: opacity 150ms ease-out;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/* Add hover effect styles for drag select */
|
|
710
|
+
:global(.recent-files-container .hover-effect) {
|
|
711
|
+
background-color: hsl(var(--grey1)) !important;
|
|
712
|
+
border-radius: var(--radius-large) !important;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.preview-fade {
|
|
716
|
+
opacity: 0;
|
|
717
|
+
animation: fadeIn 250ms ease-out forwards;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
@keyframes fadeIn {
|
|
721
|
+
from { opacity: 0; }
|
|
722
|
+
to { opacity: 1; }
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
.fade-in {
|
|
726
|
+
opacity: 0;
|
|
727
|
+
transition: opacity 250ms ease-out;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
img[src].fade-in {
|
|
731
|
+
opacity: 1;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/* Ensure cached font previews appear immediately without fading */
|
|
735
|
+
.cached-font-preview {
|
|
736
|
+
opacity: 1 !important;
|
|
737
|
+
animation: none !important;
|
|
738
|
+
transition: none !important;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/* Ensure all cached content appears immediately without fading */
|
|
742
|
+
.cached-preview {
|
|
743
|
+
opacity: 1 !important;
|
|
744
|
+
animation: none !important;
|
|
745
|
+
transition: none !important;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/* Add specific styling for font preview text */
|
|
749
|
+
.cached-font-preview div {
|
|
750
|
+
font-weight: normal !important;
|
|
751
|
+
font-style: normal !important;
|
|
752
|
+
}
|
|
753
|
+
</style>
|