@widgetic/file-browser 0.5.35 → 0.5.36

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.
Files changed (68) hide show
  1. package/README.md +1 -0
  2. package/dist/components/FolderTree.svelte +46 -97
  3. package/dist/components/FolderTree.svelte.d.ts +7 -7
  4. package/dist/components/core/Dropzone.svelte +127 -0
  5. package/dist/components/core/Dropzone.svelte.d.ts +15 -0
  6. package/dist/components/core/FileBrowser.css +11 -79
  7. package/dist/components/core/FileBrowser.svelte +277 -150
  8. package/dist/components/core/FileBrowser.svelte.d.ts +0 -1
  9. package/dist/components/core/FileUploader.svelte +204 -418
  10. package/dist/components/core/FileUploader.svelte.d.ts +1 -0
  11. package/dist/components/core/Header.svelte +51 -68
  12. package/dist/components/core/Header.svelte.d.ts +1 -0
  13. package/dist/components/core/RecentFiles.svelte +135 -562
  14. package/dist/components/core/RecentFiles.svelte.d.ts +2 -4
  15. package/dist/components/core/UploadPanel.svelte +169 -0
  16. package/dist/components/core/UploadPanel.svelte.d.ts +40 -0
  17. package/dist/components/core/UploadRow.svelte +90 -0
  18. package/dist/components/core/UploadRow.svelte.d.ts +21 -0
  19. package/dist/components/core/UploadStatus.svelte +34 -128
  20. package/dist/components/core/UploadStatus.svelte.d.ts +0 -1
  21. package/dist/components/core/UploadStatusList.svelte +61 -77
  22. package/dist/components/items/FileItem.svelte +190 -532
  23. package/dist/components/items/FileItem.svelte.d.ts +1 -1
  24. package/dist/components/items/FolderItem.svelte +46 -36
  25. package/dist/components/items/FolderItem.svelte.d.ts +1 -1
  26. package/dist/components/modals/MoveDialog.svelte +142 -281
  27. package/dist/components/modals/NewFolderButton.svelte +13 -14
  28. package/dist/components/modals/SearchModal.svelte +112 -264
  29. package/dist/components/modals/SearchModal.svelte.d.ts +0 -1
  30. package/dist/components/modals/SelectedFilesModal.svelte +91 -167
  31. package/dist/components/previews/AudioPlayer.svelte +75 -58
  32. package/dist/components/previews/ErrorPreview.svelte +9 -6
  33. package/dist/components/previews/FilePreview.svelte +173 -53
  34. package/dist/components/previews/FontPreview.svelte +37 -54
  35. package/dist/components/previews/ImagePreview.svelte +9 -2
  36. package/dist/components/previews/ImagePreview.svelte.d.ts +1 -0
  37. package/dist/components/previews/PreviewHeaderBar.svelte +70 -0
  38. package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +32 -0
  39. package/dist/components/previews/TextPreview.svelte +32 -40
  40. package/dist/components/previews/VideoPlayer.svelte +124 -149
  41. package/dist/components/previews/WaveformVisualizer.svelte +42 -222
  42. package/dist/components/previews/WaveformVisualizer.svelte.d.ts +1 -1
  43. package/dist/components/ui/ControlToolbar.svelte +113 -288
  44. package/dist/components/ui/ControlToolbar.svelte.d.ts +2 -3
  45. package/dist/components/ui/DragSelect.svelte +41 -248
  46. package/dist/components/ui/DropdownMenu.svelte +56 -55
  47. package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -1
  48. package/dist/components/ui/FileIcon.svelte +168 -51
  49. package/dist/components/ui/FileIcon.svelte.d.ts +13 -20
  50. package/dist/components/ui/FileMetadata.svelte +20 -9
  51. package/dist/components/ui/LoadingSkeleton.svelte +5 -20
  52. package/dist/components/ui/SearchResults.svelte +50 -26
  53. package/dist/components/ui/SearchResults.svelte.d.ts +4 -0
  54. package/dist/components/ui/SelectedBadge.svelte +25 -0
  55. package/dist/components/ui/SelectedBadge.svelte.d.ts +9 -0
  56. package/dist/components/ui/TileSkeleton.svelte +15 -0
  57. package/dist/components/ui/TileSkeleton.svelte.d.ts +18 -0
  58. package/dist/components/ui/VirtualList.svelte +3 -0
  59. package/dist/components/ui/index.d.ts +1 -0
  60. package/dist/components/ui/index.js +1 -0
  61. package/dist/i18n/messages.d.ts +38 -25
  62. package/dist/i18n/messages.js +39 -26
  63. package/dist/stores/fileStore.d.ts +2 -2
  64. package/dist/stores/navigationStore.d.ts +1 -1
  65. package/dist/stores/persistentSelectStore.d.ts +1 -1
  66. package/dist/utils/gridLayout.d.ts +2 -0
  67. package/dist/utils/gridLayout.js +10 -0
  68. package/package.json +3 -4
@@ -1,28 +1,27 @@
1
1
  <script lang="ts">
2
- // Svelte imports
2
+ /** Figma File Tile with File Thumb Kind=New — opens the new-folder dialog. */
3
3
  import { createEventDispatcher } from 'svelte';
4
- const dispatch = createEventDispatcher();
5
-
6
- // Local utils imports
7
- import { getAssetUrl } from '../../utils/fileUtils';
4
+ import { FileIcon } from '../ui';
8
5
  import { useI18n } from '../../i18n';
9
6
 
7
+ const dispatch = createEventDispatcher();
10
8
  const { t } = useI18n();
11
9
 
12
- // Event handlers
13
10
  function handleClick() {
14
11
  dispatch('click');
15
12
  }
16
13
  </script>
17
14
 
18
- <div class="new-folder-button-container w-full relative">
19
- <button
20
- class="new-folder-button flex w-full flex-col items-center gap-1 cursor-pointer focus:outline-none widgetic-colors"
15
+ <div class="new-folder-button-container w-full">
16
+ <button
17
+ type="button"
18
+ class="new-folder-button flex h-16 w-full cursor-pointer items-center gap-3 rounded-xl border border-border bg-background p-2 text-start transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
21
19
  on:click={handleClick}
20
+ aria-label={$t('newFolder.label')}
22
21
  >
23
- <div class="new-folder-icon-ct w-[62px] h-[54px] flex items-center justify-center shrink-0">
24
- <img src={getAssetUrl('/icons/new-folder.svg')} alt={$t('newFolder.alt')} class="w-full h-full object-contain" />
25
- </div>
26
- <h3 class="new-folder-label body-medium text-[hsl(var(--deep-forest-green))] text-sm text-center line-clamp-2 break-words px-1">{$t('newFolder.label')}</h3>
22
+ <FileIcon kind="new" size="lg" />
23
+ <span class="new-folder-label text-body-medium min-w-0 flex-1 truncate text-foreground">
24
+ {$t('newFolder.label')}
25
+ </span>
27
26
  </button>
28
- </div>
27
+ </div>
@@ -9,65 +9,53 @@
9
9
  * - File/folder path navigation
10
10
  * - Filter support for different file types
11
11
  */
12
-
12
+
13
13
  // Svelte imports
14
- import { onMount, onDestroy } from 'svelte';
14
+ import { onDestroy } from 'svelte';
15
15
  import { createEventDispatcher } from 'svelte';
16
16
  const dispatch = createEventDispatcher();
17
17
 
18
18
  // Design system imports
19
- import { Button, Input, BaseModal, WScrollArea, EmptyState } from '@widgetic/design-system/components';
19
+ import { BaseModal, WScrollArea, EmptyState, IconButton } from '@widgetic/design-system/components';
20
+ import { IconSearch, IconX, IconCornerUpRight } from '@widgetic/design-system/icons';
20
21
 
21
22
  // Local components imports
22
- import { FileItem } from '../items';
23
23
  import { FileIcon } from '../ui';
24
- import { SearchResults } from '../ui';
25
24
 
26
25
  // Local stores imports
27
- import { fileStore, currentFolder, fileFilter } from '../../stores/fileStore';
26
+ import { fileStore } from '../../stores/fileStore';
28
27
  import { searchTermStore } from '../../stores/searchStore';
29
28
 
30
29
  // Local types imports
31
30
  import type { FileSystemItem } from '../../types';
32
31
 
33
32
  // Local utils imports
34
- import { getFileIcon } from '../../utils/fileUtils';
35
33
  import { getFileTypeOf } from '../../utils/fileKinds';
36
- import { getFolderIcon } from '../../utils/folderUtils';
37
34
  import { type FileFilterType } from '../../utils/fileTypes';
38
- //
39
- import { getAssetUrl } from '../../utils/fileUtils';
40
35
  import { highlightMatchesAsHtml } from '../../utils/safeText';
41
36
  import { useI18n } from '../../i18n';
42
37
  import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
43
38
 
44
39
  const { t } = useI18n();
45
- // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
46
40
  const textDirection = useTextDirection();
47
41
  $: nameDirection = dirForUserText($textDirection);
48
-
49
- // Props for filtering search results
42
+
50
43
  export let currentFilter: FileFilterType = 'all';
51
44
  export let open = true;
52
45
  export let target: string = 'search-modal'; // target for Portal
53
- // Consts
54
- const scrolledAreaMaxHeight = 400;
55
46
 
56
- // State management for search results and navigation
47
+ const resultsScrollMaxHeightPx = 400;
48
+ const matchHighlightClass = 'rounded-sm bg-brand-subtle px-0.5 text-body-medium';
49
+
57
50
  let searchResults: FileSystemItem[] = [];
58
51
  let activeIndex = 0;
59
52
  let searchContainer: HTMLDivElement;
60
- let searchContainerHeight = 0;
61
53
  let resultsContainer: HTMLDivElement;
54
+ let queryInput: HTMLInputElement;
62
55
 
63
- // Watch for changes in the open state
64
56
  $: if (open && searchContainer) {
65
- // Use setTimeout to ensure DOM is ready
66
57
  setTimeout(() => {
67
- const input = searchContainer.querySelector('input');
68
- if (input) {
69
- input.focus();
70
- }
58
+ queryInput?.focus();
71
59
  }, 0);
72
60
  }
73
61
 
@@ -76,9 +64,6 @@
76
64
  dispatch('close');
77
65
  }
78
66
 
79
- /**
80
- * Mouse interaction handlers for result highlighting
81
- */
82
67
  function handleMouseEnter(index: number) {
83
68
  activeIndex = index;
84
69
  }
@@ -91,11 +76,6 @@
91
76
  }
92
77
  });
93
78
 
94
- /**
95
- * Reactive statement to update search results when search term changes
96
- * Filters results based on current filter type and excludes root folder.
97
- * Debounced by 150ms to prevent expensive full-tree traversals on every keystroke.
98
- */
99
79
  $: {
100
80
  const term = $searchTermStore?.trim().toLowerCase();
101
81
  const filter = currentFilter;
@@ -107,8 +87,9 @@
107
87
 
108
88
  if (term) {
109
89
  searchDebounceTimer = setTimeout(() => {
110
- searchResults = searchFileSystem(root, term)
111
- .filter(item => item.name !== 'Root' && (item.type === 'folder' || matchesFilter(item)));
90
+ searchResults = searchFileSystem(root, term).filter(
91
+ (item) => item.name !== 'Root' && (item.type === 'folder' || matchesFilter(item))
92
+ );
112
93
  activeIndex = 0;
113
94
  }, 150);
114
95
  } else {
@@ -117,25 +98,18 @@
117
98
  }
118
99
  }
119
100
 
120
- /**
121
- * Keyboard navigation handler
122
- * Supports up/down arrows for result selection and enter for confirmation
123
- */
124
101
  function handleKeydown(event: KeyboardEvent) {
125
102
  if (!searchResults.length) return;
126
103
 
127
- // Prevent default scrolling behavior for arrow keys
128
104
  if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
129
105
  event.preventDefault();
130
106
  }
131
107
 
132
108
  if (event.key === 'ArrowDown') {
133
109
  activeIndex = (activeIndex + 1) % searchResults.length;
134
- // Use setTimeout to ensure DOM has updated
135
110
  setTimeout(() => scrollActiveItemIntoView(), 0);
136
111
  } else if (event.key === 'ArrowUp') {
137
112
  activeIndex = activeIndex <= 0 ? searchResults.length - 1 : activeIndex - 1;
138
- // Use setTimeout to ensure DOM has updated
139
113
  setTimeout(() => scrollActiveItemIntoView(), 0);
140
114
  } else if (event.key === 'Enter' && activeIndex >= 0) {
141
115
  event.preventDefault();
@@ -143,21 +117,14 @@
143
117
  }
144
118
  }
145
119
 
146
- /**
147
- * Ensures the active search result is visible in the viewport
148
- */
149
120
  function scrollActiveItemIntoView() {
150
121
  if (!resultsContainer) return;
151
-
122
+
152
123
  const activeItem = resultsContainer.querySelector(
153
124
  `.search-result-item:nth-child(${activeIndex + 1})`
154
125
  ) as HTMLElement;
155
-
126
+
156
127
  if (activeItem) {
157
- const containerRect = resultsContainer.getBoundingClientRect();
158
- const itemRect = activeItem.getBoundingClientRect();
159
-
160
- // Always scroll to keep item in view
161
128
  activeItem.scrollIntoView({
162
129
  behavior: 'smooth',
163
130
  block: 'nearest'
@@ -165,40 +132,23 @@
165
132
  }
166
133
  }
167
134
 
168
- /**
169
- * Safely highlights search term matches in result names
170
- * @param name Original file/folder name
171
- * @param term Search term to highlight
172
- * @returns Safely escaped HTML string with highlighted match
173
- */
174
135
  function highlightMatch(name: string, term: string): string {
175
- // The name is escaped on every path, including an empty term: it is written by someone else and is rendered
176
- // with {@html}, so it must never reach the page as markup.
177
- return highlightMatchesAsHtml(name, term, 'text-[hsl(var(--sage-green))]');
136
+ return highlightMatchesAsHtml(name, term, matchHighlightClass);
178
137
  }
179
138
 
180
- /**
181
- * Handles result selection and navigation
182
- * Updates current path and closes search modal
183
- */
184
139
  function handleResultClick(item: FileSystemItem) {
185
- // console.log('handleResultClick called with item:', item);
186
140
  const idPath = findItemPath($fileStore.root, item);
187
- // console.log('ID Path found:', idPath);
188
-
141
+
189
142
  if (idPath) {
190
- // Remove root ID from the beginning of the path
191
143
  const folderPath = idPath[0] === $fileStore.root.id ? idPath.slice(1) : idPath;
192
-
193
- // For files, navigate to containing folder
144
+
194
145
  if (item.type === 'file') {
195
- folderPath.pop(); // Remove the file ID
146
+ folderPath.pop();
196
147
  setTimeout(() => {
197
148
  dispatch('preview', item);
198
149
  }, 100);
199
150
  }
200
-
201
- // console.log('Dispatching navigate event with ID path:', folderPath);
151
+
202
152
  dispatch('navigate', { path: folderPath });
203
153
  } else {
204
154
  console.error('Path not found for item:', item);
@@ -206,54 +156,29 @@
206
156
  dispatch('close');
207
157
  }
208
158
 
209
- /**
210
- * Recursively searches through the file system for items matching the search term
211
- * @param item Current file system item to search
212
- * @param term Search term to match against
213
- * @returns Array of matching FileSystemItems
214
- */
215
159
  function searchFileSystem(item: FileSystemItem, term: string): FileSystemItem[] {
216
160
  let results: FileSystemItem[] = [];
217
161
 
218
- // Check if current item matches search term (excluding root)
219
162
  if (item.name.toLowerCase().includes(term) && item.name !== 'Root') {
220
163
  if (item.type === 'folder' || matchesFilter(item)) {
221
164
  results.push(item);
222
165
  }
223
166
  }
224
167
 
225
- // Recursively search through folder children
226
168
  if (item.type === 'folder' && item.children) {
227
- results = results.concat(item.children.flatMap(child => searchFileSystem(child, term)));
169
+ results = results.concat(item.children.flatMap((child) => searchFileSystem(child, term)));
228
170
  }
229
171
 
230
172
  return results;
231
173
  }
232
174
 
233
- /**
234
- * Checks if a file matches the current filter criteria
235
- * @param item File item to check
236
- * @returns Boolean indicating if item matches current filter
237
- */
238
175
  function matchesFilter(item: FileSystemItem): boolean {
239
- // console.log('Checking filter for item:', item.name, 'Type:', item.type, 'Current filter:', currentFilter);
240
176
  if (currentFilter === 'all') return true;
241
- if (item.type === 'folder') return true; // Always include folders in search results
177
+ if (item.type === 'folder') return true;
242
178
  const fileType = getFileTypeOf(item);
243
- const matches = fileType === currentFilter;
244
- if (fileType === 'font') {
245
- // console.log('Font file found in search:', item.name, 'URL:', item.url);
246
- }
247
- // console.log('Item matches filter:', matches);
248
- return matches;
179
+ return fileType === currentFilter;
249
180
  }
250
181
 
251
- /**
252
- * Recursively finds the path of IDs to a specific item
253
- * @param root Root item to start search from
254
- * @param target Target item to find path to
255
- * @returns Array of item IDs representing path, or null if not found
256
- */
257
182
  function findItemPath(root: FileSystemItem, target: FileSystemItem): string[] | null {
258
183
  if (root.id === target.id) {
259
184
  return [root.id];
@@ -271,42 +196,12 @@
271
196
  return null;
272
197
  }
273
198
 
274
- /**
275
- * Gets the appropriate thumbnail or icon for a file/folder
276
- * @param file File/folder item to get thumbnail for
277
- * @returns URL to thumbnail or icon
278
- */
279
- function getThumbnailOrIcon(file: FileSystemItem): string {
280
- if (file.type === 'folder') {
281
- return getFolderIcon(file, currentFilter);
282
- }
283
- const fileType = getFileTypeOf(file);
284
- if ((fileType === 'image' || fileType === 'video') &&
285
- !file.name.toLowerCase().endsWith('.svg') &&
286
- file.thumbnail) {
287
- return file.thumbnail;
288
- }
289
- return getFileIcon(file.name);
290
- }
291
-
292
- /**
293
- * Checks if a file is marked as missing
294
- * @param file File to check
295
- * @returns Boolean indicating if file is missing
296
- */
297
- function isMissingFile(file: FileSystemItem): boolean {
298
- return file.isMissing === true;
299
- }
300
-
301
- // Handle search input to prevent leading spaces
302
199
  function handleSearchInput(event: Event) {
303
200
  const input = event.target as HTMLInputElement;
304
- // Remove leading spaces
305
201
  input.value = input.value.replace(/^\s+/, '');
306
202
  searchTermStore.set(input.value);
307
203
  }
308
204
 
309
- // Handle input field key events
310
205
  function handleInputKeydown(e: KeyboardEvent) {
311
206
  if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
312
207
  handleKeydown(e);
@@ -316,22 +211,28 @@
316
211
  }
317
212
  }
318
213
 
319
- // Move this function up near the other utility functions, before any reactive statements
320
- function getItemPath(item: FileSystemItem): string {
321
- const path = findItemPath($fileStore.root, item);
322
- // console.log('Item path for', item.name, ':', path?.join('/') || '');
323
- return path ? path.join('/') : item.id; // Fallback to ID if path not found
214
+ function clearQuery() {
215
+ searchTermStore.set('');
216
+ queryInput?.focus();
324
217
  }
218
+
219
+ $: modalHeight =
220
+ !$searchTermStore?.trim()
221
+ ? '64px'
222
+ : searchResults.length > 0
223
+ ? 'auto'
224
+ : '305px';
325
225
  </script>
326
226
 
327
- <!-- Search Modal Layout -->
328
- <BaseModal class="search-modal"
227
+ <BaseModal
228
+ class="search-modal"
329
229
  bind:open
230
+ bare
330
231
  on:close={handleClose}
331
- closeLabel={$t('dialog.close')}
332
232
  {target}
333
233
  width="566px"
334
- height={$searchTermStore ? "auto" : "88px"}
234
+ height={modalHeight}
235
+ animateSize={true}
335
236
  showScroll={false}
336
237
  modalType="search"
337
238
  modalData={{ searchTerm: $searchTermStore }}
@@ -341,148 +242,95 @@
341
242
  }
342
243
  }}
343
244
  >
344
- <div class="search-modal-root-container relative w-full flex flex-col px-4">
345
- <!-- Search Input Header -->
346
- <div
347
- class="search-modal-input-container z-50 bg-white flex items-center justify-center h-[48px]"
245
+ <div class="flex w-full flex-col">
246
+ <div
247
+ class="flex h-16 w-full items-center gap-3 ps-6 pe-4"
348
248
  bind:this={searchContainer}
349
- bind:clientHeight={searchContainerHeight}
350
249
  >
351
- <Input
352
- type="text"
353
- bind:value={$searchTermStore}
354
- onkeydown={(e: KeyboardEvent) => {
250
+ <IconSearch class="size-5 shrink-0 stroke-[1.667] text-foreground" aria-hidden="true" />
251
+ <input
252
+ bind:this={queryInput}
253
+ type="search"
254
+ value={$searchTermStore}
255
+ on:input={handleSearchInput}
256
+ placeholder={$t('searchModal.placeholder')}
257
+ class="min-w-0 flex-1 appearance-none border-0 bg-transparent text-heading-page text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-0 [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden"
258
+ on:keydown={(e) => {
355
259
  if (e.key === 'Escape') {
356
260
  handleClose();
357
261
  } else {
358
262
  e.stopPropagation();
359
- if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || (e.key === 'Enter' && searchResults.length > 0)) {
263
+ if (
264
+ e.key === 'ArrowDown' ||
265
+ e.key === 'ArrowUp' ||
266
+ (e.key === 'Enter' && searchResults.length > 0)
267
+ ) {
360
268
  handleInputKeydown(e);
361
269
  }
362
270
  }
363
271
  }}
364
- placeholder={$t('searchModal.placeholder')}
365
- class="search-modal-input-el w-full
366
- !h5 !text-[24px] !text-[hsl(var(--grey7))]
367
- placeholder:!text-[24px] placeholder:!text-[hsl(var(--grey3))]
368
- focus:outline-none border-none focus-visible:ring-0 focus-visible:ring-offset-0
369
- transition-all duration-300"
272
+ autocomplete="off"
273
+ spellcheck="false"
370
274
  />
275
+ {#if $searchTermStore}
276
+ <IconButton variant="ghost" label={$t('searchModal.clearQuery')} class="size-8 shrink-0" onclick={clearQuery}>
277
+ <IconX class="size-4 stroke-[1.333]" />
278
+ </IconButton>
279
+ {/if}
371
280
  </div>
372
281
 
373
- <!-- Scrollable Results Container -->
374
- {#if searchResults.length > 0}
375
- <WScrollArea class="search-results-scroll-area" style="height: {scrolledAreaMaxHeight}px;" scrollOutside={true}>
376
- <div
377
- class="search-results-container flex flex-col"
378
- bind:this={resultsContainer}
379
- style="min-height: {scrolledAreaMaxHeight}px; padding: 0;"
380
- >
381
- {#each searchResults as result, index (result.id || `${result.type}-${index}`)}
382
- <!-- svelte-ignore a11y_no_static_element_interactions -->
383
- <div
384
- class="search-result-item relative w-full mx-auto rounded-large widgetic-radius"
385
- on:mouseenter={() => handleMouseEnter(index)}
282
+ {#if $searchTermStore?.trim()}
283
+ {#if searchResults.length > 0}
284
+ <div class="border-t border-border" role="separator"></div>
285
+ <WScrollArea
286
+ class="search-results-scroll-area w-full"
287
+ style="max-height: {resultsScrollMaxHeightPx}px;"
288
+ scrollOutside={true}
386
289
  >
387
- <!-- Result Highlight Background -->
388
- <div class="hover-box rounded-large widgetic-radius" class:active={index === activeIndex}></div>
389
-
390
- <!-- Result Item Button -->
391
- <button
392
- class="w-full h-full flex items-center px-2 relative z-10"
393
- on:click={() => handleResultClick(result)}
394
- >
395
- {#if result.type === 'folder'}
396
- <div class="flex items-center gap-4 min-w-0 pe-12">
397
- <img src={getFolderIcon(result, currentFilter)} alt={$t('item.folder')} class="w-[62px] h-[54px] object-contain shrink-0" />
398
- <span dir={nameDirection} class="body-medium text-[hsl(var(--grey7))] truncate">{@html highlightMatch(result.name, $searchTermStore)}</span>
399
- </div>
400
- {:else}
401
- <div class="flex items-center gap-4 min-w-0 pe-12">
402
- <div class="w-[62px] shrink-0 flex items-center justify-center">
403
- <FileItem
404
- item={result}
405
- selected={false}
406
- allowSelecting={false}
407
- thumbnailOnly={true}
408
- on:click={() => handleResultClick(result)}
409
- on:action
290
+ <div class="flex flex-col py-2" bind:this={resultsContainer}>
291
+ {#each searchResults as result, index (result.id || `${result.type}-${index}`)}
292
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
293
+ <div
294
+ class="search-result-item mx-2 flex min-h-12 items-center gap-3 rounded-xl py-2 ps-2 pe-3 transition-colors duration-fast
295
+ {index === activeIndex ? 'bg-accent' : 'hover:bg-accent'}"
296
+ on:mouseenter={() => handleMouseEnter(index)}
297
+ >
298
+ <button
299
+ type="button"
300
+ class="flex min-w-0 flex-1 items-center gap-3 text-start focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
301
+ on:click={() => handleResultClick(result)}
302
+ >
303
+ <FileIcon
304
+ file={result}
305
+ kind={result.isMissing ? 'missing' : result.type === 'folder' ? 'folder' : undefined}
306
+ size="sm"
307
+ class="shrink-0"
410
308
  />
411
- </div>
412
- <span dir={nameDirection} class="body-medium text-[hsl(var(--grey7))] truncate {result.isMissing ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{@html highlightMatch(result.name, $searchTermStore)}</span>
309
+ <div class="min-w-0 flex-1">
310
+ <div dir={nameDirection} class="truncate text-body">
311
+ {@html highlightMatch(result.name, $searchTermStore.trim())}
312
+ </div>
313
+ </div>
314
+ </button>
315
+ {#if index === activeIndex}
316
+ <span class="hidden shrink-0 items-center gap-1 text-caption text-muted-foreground sm:flex">
317
+ {$t('searchModal.jumpToFolder')}
318
+ <IconCornerUpRight class="size-4 stroke-[1.333] rtl:rotate-180" aria-hidden="true" />
319
+ </span>
320
+ {/if}
413
321
  </div>
414
- {/if}
415
- </button>
416
-
417
- <!-- Jump to Folder Icon -->
418
- <img
419
- src={getAssetUrl('/icons/jump-to-folder.svg')}
420
- alt={$t('searchModal.jumpToFolder')}
421
- class="jump-to-folder-icon w-6 h-6 absolute end-6 top-1/2 transform -translate-y-1/2 z-20 pointer-events-none rtl:-scale-x-100"
422
- class:active={index === activeIndex}
423
- />
322
+ {/each}
323
+ </div>
324
+ </WScrollArea>
325
+ {:else}
326
+ <div class="border-t border-border"></div>
327
+ <div
328
+ class="flex flex-col items-center justify-center px-6 py-8"
329
+ style="min-height: 200px;"
330
+ >
331
+ <EmptyState message={$t('searchModal.empty')} />
424
332
  </div>
425
- {/each}
426
- </div>
427
- </WScrollArea>
428
- <!-- End of Search Results Container -->
429
- {:else if $searchTermStore}
430
- <div style="height: {scrolledAreaMaxHeight}px; min-height: 70px;" class="overflow-hidden flex flex-col items-center justify-center">
431
- <EmptyState class="!relative" message={$t('searchModal.empty')} />
432
- </div>
333
+ {/if}
433
334
  {/if}
434
-
435
- </div> <!-- End of Search Modal Root Container -->
335
+ </div>
436
336
  </BaseModal>
437
-
438
- <style>
439
- /* Search Result Item Styling */
440
- .search-result-item {
441
- position: relative;
442
- margin: 0;
443
- height: 70px;
444
- min-height: 70px;
445
- flex-shrink: 0;
446
- }
447
-
448
- /* Hover Effect Background */
449
- .hover-box {
450
- position: absolute;
451
- top: 0;
452
- left: 0;
453
- right: 0;
454
- bottom: 0;
455
- border-radius: var(--radius-large);
456
- pointer-events: none;
457
- background-color: transparent;
458
- }
459
-
460
- /* Active State Background */
461
- .hover-box.active {
462
- background-color: hsl(var(--grey1));
463
- }
464
-
465
- /* Jump to Folder Icon States */
466
- .jump-to-folder-icon {
467
- opacity: 0;
468
- }
469
-
470
- .jump-to-folder-icon.active {
471
- opacity: 1;
472
- }
473
-
474
- /* Ensure proper containment for the modal layout */
475
- :global(.modal-content) {
476
- height: 100%;
477
- overflow: hidden;
478
- }
479
-
480
- /* Ensure smooth text color transitions */
481
- :global(.search-modal-input-el) {
482
- transition: color 300ms ease, background-color 300ms ease, border-color 300ms ease !important;
483
- }
484
-
485
- :global(.search-modal-input-el::placeholder) {
486
- transition: color 300ms ease !important;
487
- }
488
- </style>
@@ -17,7 +17,6 @@ declare const SearchModal: $$__sveltets_2_IsomorphicComponent<{
17
17
  open?: boolean;
18
18
  target?: string;
19
19
  }, {
20
- action: CustomEvent<any>;
21
20
  close: CustomEvent<any>;
22
21
  preview: CustomEvent<any>;
23
22
  navigate: CustomEvent<any>;