@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,32 @@
|
|
|
1
|
+
import type { FileSystemItem } from '../../types';
|
|
2
|
+
import type { FileFilterType } from '../../utils/fileTypes';
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
13
|
+
};
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
15
|
+
}
|
|
16
|
+
declare const MoveDialog: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
isOpen?: boolean;
|
|
18
|
+
itemName?: string;
|
|
19
|
+
folderStructure?: FileSystemItem[];
|
|
20
|
+
currentFilter?: FileFilterType;
|
|
21
|
+
sourceItems?: FileSystemItem[];
|
|
22
|
+
currentPath?: string[];
|
|
23
|
+
target?: string;
|
|
24
|
+
}, {
|
|
25
|
+
move: CustomEvent<any>;
|
|
26
|
+
navigate: CustomEvent<any>;
|
|
27
|
+
close: CustomEvent<any>;
|
|
28
|
+
} & {
|
|
29
|
+
[evt: string]: CustomEvent<any>;
|
|
30
|
+
}, {}, {}, string>;
|
|
31
|
+
type MoveDialog = InstanceType<typeof MoveDialog>;
|
|
32
|
+
export default MoveDialog;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Svelte imports
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
|
|
6
|
+
// Local utils imports
|
|
7
|
+
import { getAssetUrl } from '../../utils/fileUtils';
|
|
8
|
+
|
|
9
|
+
// Event handlers
|
|
10
|
+
function handleClick() {
|
|
11
|
+
dispatch('click');
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="new-folder-button-container w-full relative">
|
|
16
|
+
<button
|
|
17
|
+
class="new-folder-button flex w-full flex-col items-center gap-1 cursor-pointer focus:outline-none widgetic-colors"
|
|
18
|
+
on:click={handleClick}
|
|
19
|
+
>
|
|
20
|
+
<div class="new-folder-icon-ct w-[62px] h-[54px] flex items-center justify-center shrink-0">
|
|
21
|
+
<img src={getAssetUrl('/icons/new-folder.svg')} alt="New Folder" class="w-full h-full object-contain" />
|
|
22
|
+
</div>
|
|
23
|
+
<h3 class="new-folder-label body-medium text-[hsl(var(--deep-forest-green))] text-sm text-center line-clamp-2 break-words px-1">New folder</h3>
|
|
24
|
+
</button>
|
|
25
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const NewFolderButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
click: CustomEvent<any>;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {}, {}, string>;
|
|
19
|
+
type NewFolderButton = InstanceType<typeof NewFolderButton>;
|
|
20
|
+
export default NewFolderButton;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Modal Components
|
|
2
|
+
|
|
3
|
+
## ActionModal Component
|
|
4
|
+
|
|
5
|
+
The `ActionModal` component is a reusable action dialog that can be used across different parts of the project for confirming deletion actions.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- Independent of any specific store or state management system
|
|
10
|
+
- Customizable title, message, and button labels
|
|
11
|
+
- Works with any type of items to be deleted
|
|
12
|
+
- Dispatches events for both confirmation and cancellation
|
|
13
|
+
- Maintains backwards compatibility with the FileBrowser implementation
|
|
14
|
+
|
|
15
|
+
### Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
|------|------|---------|-------------|
|
|
19
|
+
| `isOpen` | boolean | `false` | Controls the visibility of the modal |
|
|
20
|
+
| `items` | array | `[]` | Array of items to be deleted |
|
|
21
|
+
| `title` | string | `''` | Custom title for the modal (autogenerated if empty) |
|
|
22
|
+
| `message` | string | `''` | Custom message for the modal (autogenerated if empty) |
|
|
23
|
+
| `confirmLabel` | string | `'Confirm'` | Label for the confirm button |
|
|
24
|
+
| `cancelLabel` | string | `'Cancel'` | Label for the cancel button |
|
|
25
|
+
| `width` | string | `'410px'` | Width of the modal |
|
|
26
|
+
| `height` | string | `'168px'` | Height of the modal |
|
|
27
|
+
| `modalId` | string | `'action-modal'` | ID for targeting the modal |
|
|
28
|
+
| `modalType` | string | `'deleteConfirmation'` | Type for the modal (for backwards compatibility) |
|
|
29
|
+
| `modalData` | any | `null` | Data for the modal (for backwards compatibility) |
|
|
30
|
+
|
|
31
|
+
### Events
|
|
32
|
+
|
|
33
|
+
- `delete` - Dispatched when the user confirms deletion, with `items` in the event detail
|
|
34
|
+
- `cancel` - Dispatched when the user cancels deletion
|
|
35
|
+
|
|
36
|
+
### Usage Example
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<script>
|
|
40
|
+
import { ActionModal } from '$lib/components/modals';
|
|
41
|
+
|
|
42
|
+
let showDeleteConfirmation = false;
|
|
43
|
+
let itemsToDelete = [
|
|
44
|
+
{ name: 'Document.pdf', type: 'file' },
|
|
45
|
+
{ name: 'Images', type: 'folder' }
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
function handleDelete(event) {
|
|
49
|
+
const { items } = event.detail;
|
|
50
|
+
console.log('Deleting items:', items);
|
|
51
|
+
// Perform deletion logic here
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<button on:click={() => actionConfirmationOpen = true}>
|
|
56
|
+
Delete Items
|
|
57
|
+
</button>
|
|
58
|
+
|
|
59
|
+
<ActionModal
|
|
60
|
+
bind:isOpen={actionConfirmationOpen}
|
|
61
|
+
items={itemsToDelete}
|
|
62
|
+
on:delete={handleDelete}
|
|
63
|
+
on:cancel={() => console.log('Deletion cancelled')}
|
|
64
|
+
/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### FileBrowser Integration
|
|
68
|
+
|
|
69
|
+
When using the component in the FileBrowser, make sure to:
|
|
70
|
+
|
|
71
|
+
1. Handle clearing selections from the persistentSelectStore in the parent component
|
|
72
|
+
2. Provide the correct target(for Portal) for the FileBrowser context
|
|
73
|
+
|
|
74
|
+
```svelte
|
|
75
|
+
<ActionModal
|
|
76
|
+
bind:isOpen={actionConfirmationOpen}
|
|
77
|
+
items={selectedItems}
|
|
78
|
+
target="file-browser-module"
|
|
79
|
+
on:confirm={handleDelete}
|
|
80
|
+
on:cancel={() => {
|
|
81
|
+
actionConfirmationOpen = false;
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Custom Title and Message Example
|
|
87
|
+
|
|
88
|
+
You can provide custom title and message for specific contexts:
|
|
89
|
+
|
|
90
|
+
```svelte
|
|
91
|
+
<ActionModal
|
|
92
|
+
bind:isOpen={actionConfirmationOpen}
|
|
93
|
+
items={selectedItems}
|
|
94
|
+
title="Delete Assets"
|
|
95
|
+
message="These assets will be permanently deleted. This action cannot be undone."
|
|
96
|
+
confirmLabel="Delete Permanently"
|
|
97
|
+
on:confirm={handleDelete}
|
|
98
|
+
/>
|
|
99
|
+
```
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* SearchModal Component
|
|
4
|
+
* Provides real-time search functionality for files and folders with keyboard navigation
|
|
5
|
+
* Features:
|
|
6
|
+
* - Instant search results as user types
|
|
7
|
+
* - Keyboard navigation (up/down arrows, enter)
|
|
8
|
+
* - Mouse hover interactions
|
|
9
|
+
* - File/folder path navigation
|
|
10
|
+
* - Filter support for different file types
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Svelte imports
|
|
14
|
+
import { onMount } from 'svelte';
|
|
15
|
+
import { createEventDispatcher } from 'svelte';
|
|
16
|
+
const dispatch = createEventDispatcher();
|
|
17
|
+
|
|
18
|
+
// Design system imports
|
|
19
|
+
import { Button, Input, BaseModal, WScrollArea, EmptyState } from '@widgetic/design-system/components';
|
|
20
|
+
|
|
21
|
+
// Local components imports
|
|
22
|
+
import { FileItem } from '../items';
|
|
23
|
+
import { FileIcon } from '../ui';
|
|
24
|
+
import { SearchResults } from '../ui';
|
|
25
|
+
|
|
26
|
+
// Local stores imports
|
|
27
|
+
import { fileStore, currentFolder, fileFilter } from '../../stores/fileStore';
|
|
28
|
+
import { searchTermStore } from '../../stores/searchStore';
|
|
29
|
+
|
|
30
|
+
// Local types imports
|
|
31
|
+
import type { FileSystemItem } from '../../types';
|
|
32
|
+
|
|
33
|
+
// Local utils imports
|
|
34
|
+
import { getFileType, getFileIcon } from '../../utils/fileUtils';
|
|
35
|
+
import { getFolderIcon } from '../../utils/folderUtils';
|
|
36
|
+
import { type FileFilterType } from '../../utils/fileTypes';
|
|
37
|
+
//
|
|
38
|
+
import { getAssetUrl } from '../../utils/fileUtils';
|
|
39
|
+
|
|
40
|
+
// Props for filtering search results
|
|
41
|
+
export let currentFilter: FileFilterType = 'all';
|
|
42
|
+
export let open = true;
|
|
43
|
+
export let target: string = 'search-modal'; // target for Portal
|
|
44
|
+
// Consts
|
|
45
|
+
const scrolledAreaMaxHeight = 400;
|
|
46
|
+
|
|
47
|
+
// State management for search results and navigation
|
|
48
|
+
let searchResults: FileSystemItem[] = [];
|
|
49
|
+
let activeIndex = 0;
|
|
50
|
+
let searchContainer: HTMLDivElement;
|
|
51
|
+
let searchContainerHeight = 0;
|
|
52
|
+
let resultsContainer: HTMLDivElement;
|
|
53
|
+
|
|
54
|
+
// Watch for changes in the open state
|
|
55
|
+
$: if (open && searchContainer) {
|
|
56
|
+
// Use setTimeout to ensure DOM is ready
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
const input = searchContainer.querySelector('input');
|
|
59
|
+
if (input) {
|
|
60
|
+
input.focus();
|
|
61
|
+
}
|
|
62
|
+
}, 0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function handleClose() {
|
|
66
|
+
open = false;
|
|
67
|
+
dispatch('close');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Mouse interaction handlers for result highlighting
|
|
72
|
+
*/
|
|
73
|
+
function handleMouseEnter(index: number) {
|
|
74
|
+
activeIndex = index;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reactive statement to update search results when search term changes
|
|
79
|
+
* Filters results based on current filter type and excludes root folder
|
|
80
|
+
*/
|
|
81
|
+
$: {
|
|
82
|
+
// console.log('Search term changed:', $searchTermStore);
|
|
83
|
+
// console.log('Current filter:', currentFilter);
|
|
84
|
+
if ($searchTermStore) {
|
|
85
|
+
searchResults = searchFileSystem($fileStore.root, $searchTermStore.toLowerCase())
|
|
86
|
+
.filter(item => item.name !== 'Root' && (item.type === 'folder' || matchesFilter(item)));
|
|
87
|
+
console.log('Filtered search results:', searchResults);
|
|
88
|
+
activeIndex = 0;
|
|
89
|
+
} else {
|
|
90
|
+
searchResults = [];
|
|
91
|
+
activeIndex = -1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Keyboard navigation handler
|
|
97
|
+
* Supports up/down arrows for result selection and enter for confirmation
|
|
98
|
+
*/
|
|
99
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
100
|
+
if (!searchResults.length) return;
|
|
101
|
+
|
|
102
|
+
// Prevent default scrolling behavior for arrow keys
|
|
103
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (event.key === 'ArrowDown') {
|
|
108
|
+
activeIndex = (activeIndex + 1) % searchResults.length;
|
|
109
|
+
// Use setTimeout to ensure DOM has updated
|
|
110
|
+
setTimeout(() => scrollActiveItemIntoView(), 0);
|
|
111
|
+
} else if (event.key === 'ArrowUp') {
|
|
112
|
+
activeIndex = activeIndex <= 0 ? searchResults.length - 1 : activeIndex - 1;
|
|
113
|
+
// Use setTimeout to ensure DOM has updated
|
|
114
|
+
setTimeout(() => scrollActiveItemIntoView(), 0);
|
|
115
|
+
} else if (event.key === 'Enter' && activeIndex >= 0) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
handleResultClick(searchResults[activeIndex]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Ensures the active search result is visible in the viewport
|
|
123
|
+
*/
|
|
124
|
+
function scrollActiveItemIntoView() {
|
|
125
|
+
if (!resultsContainer) return;
|
|
126
|
+
|
|
127
|
+
const activeItem = resultsContainer.querySelector(
|
|
128
|
+
`.search-result-item:nth-child(${activeIndex + 1})`
|
|
129
|
+
) as HTMLElement;
|
|
130
|
+
|
|
131
|
+
if (activeItem) {
|
|
132
|
+
const containerRect = resultsContainer.getBoundingClientRect();
|
|
133
|
+
const itemRect = activeItem.getBoundingClientRect();
|
|
134
|
+
|
|
135
|
+
// Always scroll to keep item in view
|
|
136
|
+
activeItem.scrollIntoView({
|
|
137
|
+
behavior: 'smooth',
|
|
138
|
+
block: 'nearest'
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Safely highlights search term matches in result names
|
|
145
|
+
* @param name Original file/folder name
|
|
146
|
+
* @param term Search term to highlight
|
|
147
|
+
* @returns Safely escaped HTML string with highlighted match
|
|
148
|
+
*/
|
|
149
|
+
function highlightMatch(name: string, term: string): string {
|
|
150
|
+
if (!name || !term) return name || '';
|
|
151
|
+
|
|
152
|
+
const escapedName = name.replace(/[&<>"']/g, char => ({
|
|
153
|
+
'&': '&',
|
|
154
|
+
'<': '<',
|
|
155
|
+
'>': '>',
|
|
156
|
+
'"': '"',
|
|
157
|
+
"'": '''
|
|
158
|
+
}[char] || char));
|
|
159
|
+
|
|
160
|
+
const escapedTerm = term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
161
|
+
const regex = new RegExp(`(${escapedTerm})`, 'gi');
|
|
162
|
+
|
|
163
|
+
return escapedName.replace(regex, '<span class="text-[hsl(var(--sage-green))]">$1</span>');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Handles result selection and navigation
|
|
168
|
+
* Updates current path and closes search modal
|
|
169
|
+
*/
|
|
170
|
+
function handleResultClick(item: FileSystemItem) {
|
|
171
|
+
console.log('handleResultClick called with item:', item);
|
|
172
|
+
const idPath = findItemPath($fileStore.root, item);
|
|
173
|
+
console.log('ID Path found:', idPath);
|
|
174
|
+
|
|
175
|
+
if (idPath) {
|
|
176
|
+
// Remove root ID from the beginning of the path
|
|
177
|
+
const folderPath = idPath[0] === $fileStore.root.id ? idPath.slice(1) : idPath;
|
|
178
|
+
|
|
179
|
+
// For files, navigate to containing folder
|
|
180
|
+
if (item.type === 'file') {
|
|
181
|
+
folderPath.pop(); // Remove the file ID
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
dispatch('preview', item);
|
|
184
|
+
}, 100);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
console.log('Dispatching navigate event with ID path:', folderPath);
|
|
188
|
+
dispatch('navigate', { path: folderPath });
|
|
189
|
+
} else {
|
|
190
|
+
console.error('Path not found for item:', item);
|
|
191
|
+
}
|
|
192
|
+
dispatch('close');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Recursively searches through the file system for items matching the search term
|
|
197
|
+
* @param item Current file system item to search
|
|
198
|
+
* @param term Search term to match against
|
|
199
|
+
* @returns Array of matching FileSystemItems
|
|
200
|
+
*/
|
|
201
|
+
function searchFileSystem(item: FileSystemItem, term: string): FileSystemItem[] {
|
|
202
|
+
let results: FileSystemItem[] = [];
|
|
203
|
+
|
|
204
|
+
// Check if current item matches search term (excluding root)
|
|
205
|
+
if (item.name.toLowerCase().includes(term) && item.name !== 'Root') {
|
|
206
|
+
if (item.type === 'folder' || matchesFilter(item)) {
|
|
207
|
+
results.push(item);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Recursively search through folder children
|
|
212
|
+
if (item.type === 'folder' && item.children) {
|
|
213
|
+
results = results.concat(item.children.flatMap(child => searchFileSystem(child, term)));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return results;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Checks if a file matches the current filter criteria
|
|
221
|
+
* @param item File item to check
|
|
222
|
+
* @returns Boolean indicating if item matches current filter
|
|
223
|
+
*/
|
|
224
|
+
function matchesFilter(item: FileSystemItem): boolean {
|
|
225
|
+
// console.log('Checking filter for item:', item.name, 'Type:', item.type, 'Current filter:', currentFilter);
|
|
226
|
+
if (currentFilter === 'all') return true;
|
|
227
|
+
if (item.type === 'folder') return true; // Always include folders in search results
|
|
228
|
+
const fileType = getFileType(item.url || item.name);
|
|
229
|
+
const matches = fileType === currentFilter;
|
|
230
|
+
if (fileType === 'font') {
|
|
231
|
+
console.log('Font file found in search:', item.name, 'URL:', item.url);
|
|
232
|
+
}
|
|
233
|
+
// console.log('Item matches filter:', matches);
|
|
234
|
+
return matches;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Recursively finds the path of IDs to a specific item
|
|
239
|
+
* @param root Root item to start search from
|
|
240
|
+
* @param target Target item to find path to
|
|
241
|
+
* @returns Array of item IDs representing path, or null if not found
|
|
242
|
+
*/
|
|
243
|
+
function findItemPath(root: FileSystemItem, target: FileSystemItem): string[] | null {
|
|
244
|
+
if (root.id === target.id) {
|
|
245
|
+
return [root.id];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (root.type === 'folder' && root.children) {
|
|
249
|
+
for (const child of root.children) {
|
|
250
|
+
const path = findItemPath(child, target);
|
|
251
|
+
if (path) {
|
|
252
|
+
return [root.id, ...path];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Gets the appropriate thumbnail or icon for a file/folder
|
|
262
|
+
* @param file File/folder item to get thumbnail for
|
|
263
|
+
* @returns URL to thumbnail or icon
|
|
264
|
+
*/
|
|
265
|
+
function getThumbnailOrIcon(file: FileSystemItem): string {
|
|
266
|
+
if (file.type === 'folder') {
|
|
267
|
+
return getFolderIcon(file, currentFilter);
|
|
268
|
+
}
|
|
269
|
+
const fileType = getFileType(file.url || file.name);
|
|
270
|
+
if ((fileType === 'image' || fileType === 'video') &&
|
|
271
|
+
!file.name.toLowerCase().endsWith('.svg') &&
|
|
272
|
+
file.thumbnail) {
|
|
273
|
+
return file.thumbnail;
|
|
274
|
+
}
|
|
275
|
+
return getFileIcon(file.name);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Checks if a file is marked as missing
|
|
280
|
+
* @param file File to check
|
|
281
|
+
* @returns Boolean indicating if file is missing
|
|
282
|
+
*/
|
|
283
|
+
function isMissingFile(file: FileSystemItem): boolean {
|
|
284
|
+
return file.isMissing === true;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Handle search input to prevent leading spaces
|
|
288
|
+
function handleSearchInput(event: Event) {
|
|
289
|
+
const input = event.target as HTMLInputElement;
|
|
290
|
+
// Remove leading spaces
|
|
291
|
+
input.value = input.value.replace(/^\s+/, '');
|
|
292
|
+
searchTermStore.set(input.value);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Handle input field key events
|
|
296
|
+
function handleInputKeydown(e: KeyboardEvent) {
|
|
297
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
298
|
+
handleKeydown(e);
|
|
299
|
+
} else if (e.key === 'Enter' && searchResults.length > 0) {
|
|
300
|
+
e.preventDefault();
|
|
301
|
+
handleResultClick(searchResults[activeIndex]);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Move this function up near the other utility functions, before any reactive statements
|
|
306
|
+
function getItemPath(item: FileSystemItem): string {
|
|
307
|
+
const path = findItemPath($fileStore.root, item);
|
|
308
|
+
// console.log('Item path for', item.name, ':', path?.join('/') || '');
|
|
309
|
+
return path ? path.join('/') : item.id; // Fallback to ID if path not found
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Add logging to the search results
|
|
313
|
+
$: {
|
|
314
|
+
if ($searchTermStore) {
|
|
315
|
+
// Make this reactive statement depend on currentFilter as well
|
|
316
|
+
searchResults = searchFileSystem($fileStore.root, $searchTermStore.toLowerCase())
|
|
317
|
+
.filter(item => item.name !== 'Root' && (item.type === 'folder' || matchesFilter(item)));
|
|
318
|
+
console.log(`Search results filtered by '${currentFilter}' type:`, searchResults.length);
|
|
319
|
+
activeIndex = 0;
|
|
320
|
+
} else {
|
|
321
|
+
searchResults = [];
|
|
322
|
+
activeIndex = -1;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Add a new reactive statement specifically for filter changes
|
|
327
|
+
$: if (currentFilter) {
|
|
328
|
+
// console.log('Filter changed to:', currentFilter);
|
|
329
|
+
// If we have an existing search term, re-filter the results
|
|
330
|
+
if ($searchTermStore) {
|
|
331
|
+
searchResults = searchFileSystem($fileStore.root, $searchTermStore.toLowerCase())
|
|
332
|
+
.filter(item => item.name !== 'Root' && (item.type === 'folder' || matchesFilter(item)));
|
|
333
|
+
console.log(`Re-filtered search results by '${currentFilter}' type:`, searchResults.length);
|
|
334
|
+
// Reset the active index when filter changes
|
|
335
|
+
activeIndex = 0;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
</script>
|
|
339
|
+
|
|
340
|
+
<!-- Search Modal Layout -->
|
|
341
|
+
<BaseModal class="search-modal"
|
|
342
|
+
bind:open
|
|
343
|
+
on:close={handleClose}
|
|
344
|
+
{target}
|
|
345
|
+
width="566px"
|
|
346
|
+
height={$searchTermStore ? "auto" : "88px"}
|
|
347
|
+
showScroll={false}
|
|
348
|
+
modalType="search"
|
|
349
|
+
modalData={{ searchTerm: $searchTermStore }}
|
|
350
|
+
on:restore={(event) => {
|
|
351
|
+
if (event.detail?.searchTerm) {
|
|
352
|
+
searchTermStore.set(event.detail.searchTerm);
|
|
353
|
+
}
|
|
354
|
+
}}
|
|
355
|
+
>
|
|
356
|
+
<div class="search-modal-root-container relative w-full flex flex-col px-4">
|
|
357
|
+
<!-- Search Input Header -->
|
|
358
|
+
<div
|
|
359
|
+
class="search-modal-input-container z-50 bg-white flex items-center justify-center h-[48px]"
|
|
360
|
+
bind:this={searchContainer}
|
|
361
|
+
bind:clientHeight={searchContainerHeight}
|
|
362
|
+
>
|
|
363
|
+
<Input
|
|
364
|
+
type="text"
|
|
365
|
+
bind:value={$searchTermStore}
|
|
366
|
+
onkeydown={(e: KeyboardEvent) => {
|
|
367
|
+
if (e.key === 'Escape') {
|
|
368
|
+
handleClose();
|
|
369
|
+
} else {
|
|
370
|
+
e.stopPropagation();
|
|
371
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || (e.key === 'Enter' && searchResults.length > 0)) {
|
|
372
|
+
handleInputKeydown(e);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}}
|
|
376
|
+
placeholder="Search files and folders..."
|
|
377
|
+
class="search-modal-input-el w-full
|
|
378
|
+
!h5 !text-[24px] !text-[hsl(var(--grey7))]
|
|
379
|
+
placeholder:!text-[24px] placeholder:!text-[hsl(var(--grey3))]
|
|
380
|
+
focus:outline-none border-none focus-visible:ring-0 focus-visible:ring-offset-0
|
|
381
|
+
transition-all duration-300"
|
|
382
|
+
/>
|
|
383
|
+
</div>
|
|
384
|
+
|
|
385
|
+
<!-- Scrollable Results Container -->
|
|
386
|
+
{#if searchResults.length > 0}
|
|
387
|
+
<WScrollArea class="search-results-scroll-area" style="height: {scrolledAreaMaxHeight}px;" scrollOutside={true}>
|
|
388
|
+
<div
|
|
389
|
+
class="search-results-container flex flex-col"
|
|
390
|
+
bind:this={resultsContainer}
|
|
391
|
+
style="min-height: {scrolledAreaMaxHeight}px; padding: 0;"
|
|
392
|
+
>
|
|
393
|
+
{#each searchResults as result, index (`${result.id}:${getItemPath(result)}:${index}`)}
|
|
394
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
395
|
+
<div
|
|
396
|
+
class="search-result-item relative w-full mx-auto rounded-large widgetic-radius"
|
|
397
|
+
on:mouseenter={() => handleMouseEnter(index)}
|
|
398
|
+
>
|
|
399
|
+
<!-- Result Highlight Background -->
|
|
400
|
+
<div class="hover-box rounded-large widgetic-radius" class:active={index === activeIndex}></div>
|
|
401
|
+
|
|
402
|
+
<!-- Result Item Button -->
|
|
403
|
+
<button
|
|
404
|
+
class="w-full h-full flex items-center px-2 relative z-10"
|
|
405
|
+
on:click={() => handleResultClick(result)}
|
|
406
|
+
>
|
|
407
|
+
{#if result.type === 'folder'}
|
|
408
|
+
<div class="flex items-center gap-4 min-w-0 pr-12">
|
|
409
|
+
<img src={getFolderIcon(result, currentFilter)} alt="Folder" class="w-[62px] h-[54px] object-contain shrink-0" />
|
|
410
|
+
<span class="body-medium text-[hsl(var(--grey7))] truncate">{@html highlightMatch(result.name, $searchTermStore)}</span>
|
|
411
|
+
</div>
|
|
412
|
+
{:else}
|
|
413
|
+
<div class="flex items-center gap-4 min-w-0 pr-12">
|
|
414
|
+
<div class="w-[62px] shrink-0 flex items-center justify-center">
|
|
415
|
+
<FileItem
|
|
416
|
+
item={result}
|
|
417
|
+
selected={false}
|
|
418
|
+
allowSelecting={false}
|
|
419
|
+
thumbnailOnly={true}
|
|
420
|
+
on:click={() => handleResultClick(result)}
|
|
421
|
+
on:action
|
|
422
|
+
/>
|
|
423
|
+
</div>
|
|
424
|
+
<span class="body-medium text-[hsl(var(--grey7))] truncate {result.isMissing ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{@html highlightMatch(result.name, $searchTermStore)}</span>
|
|
425
|
+
</div>
|
|
426
|
+
{/if}
|
|
427
|
+
</button>
|
|
428
|
+
|
|
429
|
+
<!-- Jump to Folder Icon -->
|
|
430
|
+
<img
|
|
431
|
+
src={getAssetUrl('/icons/jump-to-folder.svg')}
|
|
432
|
+
alt="Jump to folder"
|
|
433
|
+
class="jump-to-folder-icon w-6 h-6 absolute right-6 top-1/2 transform -translate-y-1/2 z-20 pointer-events-none"
|
|
434
|
+
class:active={index === activeIndex}
|
|
435
|
+
/>
|
|
436
|
+
</div>
|
|
437
|
+
{/each}
|
|
438
|
+
</div>
|
|
439
|
+
</WScrollArea>
|
|
440
|
+
<!-- End of Search Results Container -->
|
|
441
|
+
{:else if $searchTermStore}
|
|
442
|
+
<div style="height: {scrolledAreaMaxHeight}px; min-height: 70px;" class="overflow-hidden flex flex-col items-center justify-center">
|
|
443
|
+
<EmptyState class="!relative" message="No files found" />
|
|
444
|
+
</div>
|
|
445
|
+
{/if}
|
|
446
|
+
|
|
447
|
+
</div> <!-- End of Search Modal Root Container -->
|
|
448
|
+
</BaseModal>
|
|
449
|
+
|
|
450
|
+
<style>
|
|
451
|
+
/* Search Result Item Styling */
|
|
452
|
+
.search-result-item {
|
|
453
|
+
position: relative;
|
|
454
|
+
margin: 0;
|
|
455
|
+
height: 70px;
|
|
456
|
+
min-height: 70px;
|
|
457
|
+
flex-shrink: 0;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/* Hover Effect Background */
|
|
461
|
+
.hover-box {
|
|
462
|
+
position: absolute;
|
|
463
|
+
top: 0;
|
|
464
|
+
left: 0;
|
|
465
|
+
right: 0;
|
|
466
|
+
bottom: 0;
|
|
467
|
+
border-radius: var(--radius-large);
|
|
468
|
+
pointer-events: none;
|
|
469
|
+
background-color: transparent;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/* Active State Background */
|
|
473
|
+
.hover-box.active {
|
|
474
|
+
background-color: hsl(var(--grey1));
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/* Jump to Folder Icon States */
|
|
478
|
+
.jump-to-folder-icon {
|
|
479
|
+
opacity: 0;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.jump-to-folder-icon.active {
|
|
483
|
+
opacity: 1;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/* Ensure proper containment for the modal layout */
|
|
487
|
+
:global(.modal-content) {
|
|
488
|
+
height: 100%;
|
|
489
|
+
overflow: hidden;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/* Ensure smooth text color transitions */
|
|
493
|
+
:global(.search-modal-input-el) {
|
|
494
|
+
transition: color 300ms ease, background-color 300ms ease, border-color 300ms ease !important;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
:global(.search-modal-input-el::placeholder) {
|
|
498
|
+
transition: color 300ms ease !important;
|
|
499
|
+
}
|
|
500
|
+
</style>
|