@widgetic/file-browser 0.5.34 → 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.
- package/README.md +1 -0
- package/dist/components/FolderTree.svelte +46 -97
- package/dist/components/FolderTree.svelte.d.ts +7 -7
- package/dist/components/core/Dropzone.svelte +127 -0
- package/dist/components/core/Dropzone.svelte.d.ts +15 -0
- package/dist/components/core/FileBrowser.css +11 -79
- package/dist/components/core/FileBrowser.svelte +278 -150
- package/dist/components/core/FileBrowser.svelte.d.ts +0 -1
- package/dist/components/core/FileUploader.svelte +204 -418
- package/dist/components/core/FileUploader.svelte.d.ts +1 -0
- package/dist/components/core/Header.svelte +49 -58
- package/dist/components/core/Header.svelte.d.ts +1 -0
- package/dist/components/core/RecentFiles.svelte +135 -562
- package/dist/components/core/RecentFiles.svelte.d.ts +2 -4
- package/dist/components/core/UploadPanel.svelte +169 -0
- package/dist/components/core/UploadPanel.svelte.d.ts +40 -0
- package/dist/components/core/UploadRow.svelte +90 -0
- package/dist/components/core/UploadRow.svelte.d.ts +21 -0
- package/dist/components/core/UploadStatus.svelte +34 -128
- package/dist/components/core/UploadStatus.svelte.d.ts +0 -1
- package/dist/components/core/UploadStatusList.svelte +61 -77
- package/dist/components/items/FileItem.svelte +190 -532
- package/dist/components/items/FileItem.svelte.d.ts +1 -1
- package/dist/components/items/FolderItem.svelte +46 -36
- package/dist/components/items/FolderItem.svelte.d.ts +1 -1
- package/dist/components/modals/MoveDialog.svelte +142 -281
- package/dist/components/modals/NewFolderButton.svelte +13 -14
- package/dist/components/modals/SearchModal.svelte +112 -264
- package/dist/components/modals/SearchModal.svelte.d.ts +0 -1
- package/dist/components/modals/SelectedFilesModal.svelte +91 -167
- package/dist/components/previews/AudioPlayer.svelte +75 -58
- package/dist/components/previews/ErrorPreview.svelte +9 -6
- package/dist/components/previews/FilePreview.svelte +182 -53
- package/dist/components/previews/FontPreview.svelte +37 -54
- package/dist/components/previews/ImagePreview.svelte +9 -2
- package/dist/components/previews/ImagePreview.svelte.d.ts +1 -0
- package/dist/components/previews/PreviewHeaderBar.svelte +70 -0
- package/dist/components/previews/PreviewHeaderBar.svelte.d.ts +32 -0
- package/dist/components/previews/TextPreview.svelte +32 -40
- package/dist/components/previews/VideoPlayer.svelte +124 -149
- package/dist/components/previews/WaveformVisualizer.svelte +42 -222
- package/dist/components/previews/WaveformVisualizer.svelte.d.ts +1 -1
- package/dist/components/ui/ControlToolbar.svelte +113 -288
- package/dist/components/ui/ControlToolbar.svelte.d.ts +2 -3
- package/dist/components/ui/DragSelect.svelte +41 -248
- package/dist/components/ui/DropdownMenu.svelte +56 -55
- package/dist/components/ui/DropdownMenu.svelte.d.ts +1 -1
- package/dist/components/ui/FileIcon.svelte +168 -51
- package/dist/components/ui/FileIcon.svelte.d.ts +13 -20
- package/dist/components/ui/FileMetadata.svelte +20 -9
- package/dist/components/ui/LoadingSkeleton.svelte +5 -20
- package/dist/components/ui/SearchResults.svelte +50 -26
- package/dist/components/ui/SearchResults.svelte.d.ts +4 -0
- package/dist/components/ui/SelectedBadge.svelte +25 -0
- package/dist/components/ui/SelectedBadge.svelte.d.ts +9 -0
- package/dist/components/ui/TileSkeleton.svelte +15 -0
- package/dist/components/ui/TileSkeleton.svelte.d.ts +18 -0
- package/dist/components/ui/VirtualList.svelte +3 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/i18n/messages.d.ts +40 -27
- package/dist/i18n/messages.js +41 -28
- package/dist/stores/fileStore.d.ts +2 -2
- package/dist/stores/navigationStore.d.ts +1 -1
- package/dist/stores/persistentSelectStore.d.ts +1 -1
- package/dist/utils/gridLayout.d.ts +2 -0
- package/dist/utils/gridLayout.js +10 -0
- package/package.json +3 -4
|
@@ -11,15 +11,16 @@
|
|
|
11
11
|
// Local components imports
|
|
12
12
|
import type { FileSystemItem } from '../../types';
|
|
13
13
|
import FolderTree from '../FolderTree.svelte';
|
|
14
|
-
|
|
14
|
+
import { FileIcon } from '../ui';
|
|
15
|
+
|
|
15
16
|
// Local utils imports
|
|
16
17
|
import { getFolderIcon } from '../../utils/folderUtils';
|
|
17
18
|
import type { FileFilterType } from '../../utils/fileTypes';
|
|
18
|
-
import { getFileType } from '../../utils/fileUtils';
|
|
19
19
|
import { moveItem, findItemById } from '../../utils/fileOperations';
|
|
20
|
-
import { ENDPOINTS
|
|
20
|
+
import { ENDPOINTS } from '../../utils/apiConfig';
|
|
21
21
|
import { useI18n, messageForVisitor } from '../../i18n';
|
|
22
22
|
import { MediaLibraryError } from '../../mediaLibrary/errors';
|
|
23
|
+
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
23
24
|
|
|
24
25
|
// Local stores imports
|
|
25
26
|
import { folderCounts, updateFolderCounts } from '../../stores/folderCountStore';
|
|
@@ -40,71 +41,53 @@
|
|
|
40
41
|
export let sourceItems: FileSystemItem[] = [];
|
|
41
42
|
export let currentPath: string[] = [];
|
|
42
43
|
export let target: string = 'move-dialog'; // target for Portal
|
|
43
|
-
// Consts
|
|
44
|
-
const scrolledAreaMaxHeight = 420;
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
let rootContainerHeight = 0;
|
|
48
|
-
let buttonsContainerHeight = 0;
|
|
45
|
+
const treeScrollHeightPx = 348;
|
|
49
46
|
|
|
50
|
-
// Get the navigation store instance
|
|
51
47
|
const navigationStore = getNavigationStore();
|
|
48
|
+
const textDirection = useTextDirection();
|
|
49
|
+
$: nameDirection = dirForUserText($textDirection);
|
|
52
50
|
|
|
53
51
|
let selectedFolder: FileSystemItem | undefined = undefined;
|
|
54
52
|
let counts: Map<string, number> = new Map();
|
|
55
53
|
let folders: FolderWithDisplay[];
|
|
56
|
-
|
|
57
|
-
// Get the immediate parent folder ID of the items being moved
|
|
54
|
+
|
|
58
55
|
$: immediateParentId = currentPath.length > 0 ? currentPath[currentPath.length - 1] : null;
|
|
59
56
|
|
|
60
|
-
// Add a reactive statement to log when the dialog opens
|
|
61
57
|
$: if (isOpen) {
|
|
62
|
-
// console.log('MoveDialog opened with:', {
|
|
63
|
-
// sourceItems: sourceItems.map(item => ({
|
|
64
|
-
// id: item.id,
|
|
65
|
-
// name: item.name,
|
|
66
|
-
// type: item.type
|
|
67
|
-
// })),
|
|
68
|
-
// itemCount: sourceItems.length,
|
|
69
|
-
// hasFolders: sourceItems.some(item => item.type === 'folder')
|
|
70
|
-
// });
|
|
71
|
-
// Reset selection when dialog opens
|
|
72
58
|
selectedFolder = undefined;
|
|
73
59
|
}
|
|
74
60
|
|
|
75
|
-
// Helper function to recursively map folders and their children
|
|
76
61
|
function mapFolderStructure(folder: FileSystemItem): FolderWithDisplay {
|
|
77
62
|
return {
|
|
78
63
|
...folder,
|
|
79
64
|
displayChildren: folder.children
|
|
80
|
-
?.filter(
|
|
81
|
-
item
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
?.filter(
|
|
66
|
+
(item) =>
|
|
67
|
+
item.type === 'folder' &&
|
|
68
|
+
!sourceItems.some(
|
|
69
|
+
(sourceItem) => sourceItem.type === 'folder' && item.id === sourceItem.id
|
|
70
|
+
)
|
|
85
71
|
)
|
|
86
|
-
.map(child => mapFolderStructure(child)),
|
|
72
|
+
.map((child) => mapFolderStructure(child)),
|
|
87
73
|
children: folder.children
|
|
88
74
|
} as FolderWithDisplay;
|
|
89
75
|
}
|
|
90
76
|
|
|
91
|
-
// Filter out files and the source folders
|
|
92
77
|
$: folders = folderStructure
|
|
93
|
-
.filter(
|
|
94
|
-
item
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
78
|
+
.filter(
|
|
79
|
+
(item) =>
|
|
80
|
+
item.type === 'folder' &&
|
|
81
|
+
!sourceItems.some(
|
|
82
|
+
(sourceItem) => sourceItem.type === 'folder' && item.id === sourceItem.id
|
|
83
|
+
)
|
|
99
84
|
)
|
|
100
|
-
.map(folder => mapFolderStructure(folder));
|
|
85
|
+
.map((folder) => mapFolderStructure(folder));
|
|
101
86
|
|
|
102
|
-
// Subscribe to folder counts
|
|
103
87
|
folderCounts.subscribe((value: Map<string, number>) => {
|
|
104
88
|
counts = value;
|
|
105
89
|
});
|
|
106
90
|
|
|
107
|
-
// Update counts when filter changes
|
|
108
91
|
$: if (folderStructure) {
|
|
109
92
|
const rootFolder: FileSystemItem = {
|
|
110
93
|
id: 'root',
|
|
@@ -125,67 +108,48 @@
|
|
|
125
108
|
return getFolderIcon(folderWithCount, currentFilter);
|
|
126
109
|
}
|
|
127
110
|
|
|
128
|
-
/** A name as the dialog's title shows it: cut at 30 characters. */
|
|
129
111
|
function shortNameOf(name: string | undefined): string {
|
|
130
112
|
const text = name ?? '';
|
|
131
|
-
return text.length > 30 ? text.slice(0, 30) + '
|
|
113
|
+
return text.length > 30 ? text.slice(0, 30) + '…' : text;
|
|
132
114
|
}
|
|
133
115
|
|
|
134
|
-
/** The headline of a failed move: about the folder when one folder was being moved, else about the items. */
|
|
135
116
|
function failedMoveTitle(): string {
|
|
136
117
|
return sourceItems.length === 1 && sourceItems[0]?.type === 'folder'
|
|
137
118
|
? $t('moveDialog.failedFolder')
|
|
138
119
|
: $t('moveDialog.failedItems');
|
|
139
120
|
}
|
|
140
121
|
|
|
141
|
-
/**
|
|
142
|
-
* Handles the move operation and triggers animations
|
|
143
|
-
* @param targetFolderId ID of the destination folder
|
|
144
|
-
*/
|
|
145
122
|
async function handleMove(targetFolderId: string) {
|
|
146
|
-
// console.log('handleMove called with:', {
|
|
147
|
-
// targetFolderId,
|
|
148
|
-
// sourceItems,
|
|
149
|
-
// itemCount
|
|
150
|
-
// });
|
|
151
|
-
|
|
152
123
|
if (!targetFolderId) {
|
|
153
|
-
toast.error(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
duration: 2000
|
|
160
|
-
}
|
|
161
|
-
);
|
|
124
|
+
toast.error(failedMoveTitle(), {
|
|
125
|
+
description: $t('moveDialog.noTarget'),
|
|
126
|
+
position: 'bottom-center',
|
|
127
|
+
class: 'file-browser-sonar',
|
|
128
|
+
duration: 2000
|
|
129
|
+
});
|
|
162
130
|
return;
|
|
163
131
|
}
|
|
164
132
|
|
|
165
133
|
if (sourceItems.length === 0) {
|
|
166
|
-
toast.error(
|
|
167
|
-
$t('moveDialog.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
duration: 2000
|
|
173
|
-
}
|
|
174
|
-
);
|
|
134
|
+
toast.error($t('moveDialog.failedItems'), {
|
|
135
|
+
description: $t('moveDialog.noItems'),
|
|
136
|
+
position: 'bottom-center',
|
|
137
|
+
class: 'file-browser-sonar',
|
|
138
|
+
duration: 2000
|
|
139
|
+
});
|
|
175
140
|
return;
|
|
176
141
|
}
|
|
177
142
|
|
|
178
143
|
try {
|
|
179
|
-
const actualTargetId =
|
|
144
|
+
const actualTargetId =
|
|
145
|
+
targetFolderId === 'root' || targetFolderId === $fileStore?.root?.id ? '' : targetFolderId;
|
|
180
146
|
const movedItems: { id: string; name: string }[] = [];
|
|
181
|
-
|
|
182
|
-
// Helper function to find the complete path to a folder
|
|
147
|
+
|
|
183
148
|
const findFolderPath = (root: FileSystemItem, targetId: string): string[] | null => {
|
|
184
149
|
const search = (folder: FileSystemItem, path: string[] = []): string[] | null => {
|
|
185
150
|
if (folder.id === targetId) {
|
|
186
151
|
return path;
|
|
187
152
|
}
|
|
188
|
-
|
|
189
153
|
if (folder.children) {
|
|
190
154
|
for (const child of folder.children) {
|
|
191
155
|
if (child.type === 'folder') {
|
|
@@ -201,51 +165,44 @@
|
|
|
201
165
|
return search(root);
|
|
202
166
|
};
|
|
203
167
|
|
|
204
|
-
// Get the complete path to the target folder
|
|
205
168
|
const targetPath = actualTargetId ? findFolderPath($fileStore.root, actualTargetId) : [];
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
// Move all items at once
|
|
169
|
+
|
|
209
170
|
const results = await Promise.allSettled(
|
|
210
|
-
sourceItems.map(sourceItem =>
|
|
171
|
+
sourceItems.map((sourceItem) =>
|
|
211
172
|
fetch(ENDPOINTS.FILE_MOVE, {
|
|
212
173
|
method: 'POST',
|
|
213
174
|
headers: {
|
|
214
|
-
'Content-Type': 'application/json'
|
|
175
|
+
'Content-Type': 'application/json'
|
|
215
176
|
},
|
|
216
177
|
body: JSON.stringify({
|
|
217
178
|
itemId: sourceItem.id,
|
|
218
179
|
targetFolderId: actualTargetId
|
|
219
180
|
})
|
|
220
|
-
}).then(response => response.json())
|
|
181
|
+
}).then((response) => response.json())
|
|
221
182
|
)
|
|
222
183
|
);
|
|
223
184
|
|
|
224
|
-
// Process results
|
|
225
185
|
results.forEach((result, index) => {
|
|
226
186
|
const sourceItem = sourceItems[index];
|
|
227
187
|
if (result.status === 'fulfilled' && result.value.success) {
|
|
228
188
|
const success = moveItem(sourceItem.id, actualTargetId);
|
|
229
|
-
|
|
189
|
+
|
|
230
190
|
if (success) {
|
|
231
191
|
const movedItem = findItemById(sourceItem.id);
|
|
232
192
|
if (movedItem) {
|
|
233
|
-
// If we moved a folder, update its paths in navigation history
|
|
234
193
|
if (movedItem.type === 'folder') {
|
|
235
194
|
const newParentPath = actualTargetId ? [actualTargetId] : [];
|
|
236
195
|
navigationStore.updateMovedFolderPaths(movedItem.id, newParentPath);
|
|
237
196
|
}
|
|
238
|
-
|
|
197
|
+
|
|
239
198
|
movedItems.push({
|
|
240
199
|
id: sourceItem.id,
|
|
241
200
|
name: sourceItem.name
|
|
242
201
|
});
|
|
243
202
|
|
|
244
|
-
// Clear the item from selections
|
|
245
203
|
persistentSelectStore.removeSelection(sourceItem.id, currentFilter);
|
|
246
204
|
|
|
247
|
-
|
|
248
|
-
dispatch('move', {
|
|
205
|
+
dispatch('move', {
|
|
249
206
|
item: sourceItem,
|
|
250
207
|
targetFolderId: actualTargetId
|
|
251
208
|
});
|
|
@@ -255,10 +212,12 @@
|
|
|
255
212
|
});
|
|
256
213
|
|
|
257
214
|
if (movedItems.length > 0) {
|
|
258
|
-
// Show appropriate toast based on success/partial success
|
|
259
215
|
if (movedItems.length < sourceItems.length) {
|
|
260
216
|
toast.warning($t('moveDialog.partialTitle'), {
|
|
261
|
-
description: $t('moveDialog.partialDetail', {
|
|
217
|
+
description: $t('moveDialog.partialDetail', {
|
|
218
|
+
moved: movedItems.length,
|
|
219
|
+
total: sourceItems.length
|
|
220
|
+
}),
|
|
262
221
|
position: 'bottom-center',
|
|
263
222
|
class: 'file-browser-sonar',
|
|
264
223
|
duration: 2000
|
|
@@ -266,9 +225,13 @@
|
|
|
266
225
|
} else {
|
|
267
226
|
const isFolder = sourceItems.length === 1 && sourceItems[0].type === 'folder';
|
|
268
227
|
toast.success(
|
|
269
|
-
isFolder
|
|
228
|
+
isFolder
|
|
229
|
+
? $t('moveDialog.doneFolder')
|
|
230
|
+
: sourceItems.length === 1
|
|
231
|
+
? $t('moveDialog.doneOne')
|
|
232
|
+
: $t('moveDialog.doneMany'),
|
|
270
233
|
{
|
|
271
|
-
description: isFolder
|
|
234
|
+
description: isFolder
|
|
272
235
|
? $t('moveDialog.doneFolderDetail', { name: sourceItems[0].name })
|
|
273
236
|
: $t('moveDialog.doneItemsDetail', { count: sourceItems.length }),
|
|
274
237
|
position: 'bottom-center',
|
|
@@ -278,30 +241,26 @@
|
|
|
278
241
|
);
|
|
279
242
|
}
|
|
280
243
|
|
|
281
|
-
|
|
282
|
-
dispatch('navigate', {
|
|
244
|
+
dispatch('navigate', {
|
|
283
245
|
targetFolderId: targetPath || [],
|
|
284
246
|
movedItems
|
|
285
247
|
});
|
|
286
248
|
|
|
287
|
-
// Ensure proper cleanup
|
|
288
249
|
selectedFolder = undefined;
|
|
289
250
|
isOpen = false;
|
|
290
251
|
} else {
|
|
291
|
-
|
|
292
|
-
|
|
252
|
+
throw new MediaLibraryError('FAILED', 'No items were moved successfully', {
|
|
253
|
+
messageKey: 'moveDialog.noneMoved'
|
|
254
|
+
});
|
|
293
255
|
}
|
|
294
256
|
} catch (error) {
|
|
295
257
|
console.error('Error moving items:', error);
|
|
296
|
-
toast.error(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
duration: 2000
|
|
303
|
-
}
|
|
304
|
-
);
|
|
258
|
+
toast.error(failedMoveTitle(), {
|
|
259
|
+
description: messageForVisitor(error, $t),
|
|
260
|
+
position: 'bottom-center',
|
|
261
|
+
class: 'file-browser-sonar',
|
|
262
|
+
duration: 2000
|
|
263
|
+
});
|
|
305
264
|
}
|
|
306
265
|
}
|
|
307
266
|
|
|
@@ -309,38 +268,46 @@
|
|
|
309
268
|
if (selectedFolder) {
|
|
310
269
|
handleMove(selectedFolder.id);
|
|
311
270
|
} else {
|
|
312
|
-
toast.error(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
duration: 2000
|
|
319
|
-
}
|
|
320
|
-
);
|
|
271
|
+
toast.error(failedMoveTitle(), {
|
|
272
|
+
description: $t('moveDialog.pickDestination'),
|
|
273
|
+
position: 'bottom-center',
|
|
274
|
+
class: 'file-browser-sonar',
|
|
275
|
+
duration: 2000
|
|
276
|
+
});
|
|
321
277
|
}
|
|
322
278
|
}
|
|
323
279
|
|
|
324
280
|
function handleClose() {
|
|
325
|
-
// console.log('MoveDialog closing');
|
|
326
281
|
selectedFolder = undefined;
|
|
327
282
|
dispatch('close');
|
|
328
283
|
isOpen = false;
|
|
329
284
|
}
|
|
330
285
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
286
|
+
function selectRoot() {
|
|
287
|
+
if (immediateParentId === null) return;
|
|
288
|
+
selectedFolder = {
|
|
289
|
+
id: 'root',
|
|
290
|
+
type: 'folder',
|
|
291
|
+
name: 'root',
|
|
292
|
+
children: folders,
|
|
293
|
+
modified: new Date().toISOString(),
|
|
294
|
+
size: 0
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
$: rootIsCurrent = immediateParentId === null;
|
|
299
|
+
$: rootIsSelected = selectedFolder?.id === 'root';
|
|
300
|
+
$: confirmDisabled = !selectedFolder || selectedFolder.id === immediateParentId;
|
|
334
301
|
</script>
|
|
335
302
|
|
|
336
|
-
<BaseModal
|
|
337
|
-
|
|
303
|
+
<BaseModal
|
|
304
|
+
class="move-modal"
|
|
305
|
+
bind:open={isOpen}
|
|
338
306
|
on:close={handleClose}
|
|
339
307
|
closeLabel={$t('dialog.close')}
|
|
340
308
|
{target}
|
|
341
309
|
width="566px"
|
|
342
310
|
height="496px"
|
|
343
|
-
titlePadding="small"
|
|
344
311
|
showScroll={false}
|
|
345
312
|
title={
|
|
346
313
|
sourceItems.length === 1
|
|
@@ -348,7 +315,7 @@
|
|
|
348
315
|
: $t('moveDialog.titleMany', { count: sourceItems.length })
|
|
349
316
|
}
|
|
350
317
|
modalType="move"
|
|
351
|
-
modalData={{
|
|
318
|
+
modalData={{
|
|
352
319
|
folderStructure,
|
|
353
320
|
currentFilter,
|
|
354
321
|
sourceItems,
|
|
@@ -362,91 +329,48 @@
|
|
|
362
329
|
sourceItems = event.detail.sourceItems;
|
|
363
330
|
currentPath = event.detail.currentPath;
|
|
364
331
|
itemName = event.detail.itemName;
|
|
365
|
-
selectedFolder = undefined;
|
|
332
|
+
selectedFolder = undefined;
|
|
366
333
|
}
|
|
367
334
|
}}
|
|
368
|
-
>
|
|
369
|
-
<div class="
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
<WScrollArea class="
|
|
373
|
-
<div class="
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
modified: new Date().toISOString(),
|
|
389
|
-
size: 0
|
|
390
|
-
};
|
|
391
|
-
}}
|
|
392
|
-
disabled={immediateParentId === null}
|
|
393
|
-
class:cursor-default={immediateParentId === null}
|
|
394
|
-
class:hover:bg-transparent={immediateParentId === null || selectedFolder?.id === 'root'}
|
|
395
|
-
class:hover:bg-[hsl(var(--grey1))]={immediateParentId !== null && selectedFolder?.id !== 'root'}
|
|
396
|
-
class:hover:bg-[hsl(var(--light-green))]={immediateParentId !== null && selectedFolder?.id === 'root'}
|
|
335
|
+
>
|
|
336
|
+
<div class="flex min-h-0 w-full flex-col gap-4">
|
|
337
|
+
<!-- The tree is a fixed 348px window onto the folders (Figma Move Dialog): it scrolls when there are more.
|
|
338
|
+
shrink-0, not flex-1: in a column that is as tall as its content, flex-1 would give the height away. -->
|
|
339
|
+
<WScrollArea class="shrink-0" type="always" scrollbarWidth={12} style="height: {treeScrollHeightPx}px;">
|
|
340
|
+
<div class="flex flex-col" style="min-height: {treeScrollHeightPx}px;">
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
class="flex h-12 w-full min-w-0 items-center gap-3 rounded-xl py-2 ps-2 pe-3 text-start transition-colors duration-fast
|
|
344
|
+
{rootIsSelected ? 'bg-brand-subtle' : 'hover:bg-accent'}
|
|
345
|
+
{rootIsCurrent ? 'cursor-default' : 'cursor-pointer'}
|
|
346
|
+
focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
347
|
+
onclick={selectRoot}
|
|
348
|
+
disabled={rootIsCurrent}
|
|
349
|
+
aria-current={rootIsCurrent ? 'location' : undefined}
|
|
350
|
+
>
|
|
351
|
+
<FileIcon kind="folder" size="sm" class={rootIsCurrent ? 'opacity-50' : ''} />
|
|
352
|
+
<span
|
|
353
|
+
dir={nameDirection}
|
|
354
|
+
class="min-w-0 flex-1 truncate text-body-medium {rootIsCurrent ? 'text-muted-foreground' : 'text-foreground'}"
|
|
397
355
|
>
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
id: 'root',
|
|
407
|
-
type: 'folder',
|
|
408
|
-
name: 'root',
|
|
409
|
-
children: folders,
|
|
410
|
-
modified: new Date().toISOString(),
|
|
411
|
-
size: 0,
|
|
412
|
-
matchingFileCount: counts.get('root') || 0
|
|
413
|
-
}, currentFilter)}
|
|
414
|
-
alt={$t('moveDialog.rootName')}
|
|
415
|
-
width="62"
|
|
416
|
-
height="54"
|
|
417
|
-
style="width: 62px; height: 54px; object-fit: contain;"
|
|
418
|
-
class=""
|
|
419
|
-
/>
|
|
420
|
-
</div>
|
|
421
|
-
</div>
|
|
422
|
-
<span class="body-medium truncate flex-grow text-start {immediateParentId === null ? 'text-[hsl(var(--grey3))]' : 'text-[hsl(var(--grey7))]'} {selectedFolder?.id === 'root' ? 'font-bold' : 'font-normal'}">{$t('moveDialog.rootName')}</span>
|
|
423
|
-
<div class="flex items-center ms-auto">
|
|
424
|
-
{#if immediateParentId === null}
|
|
425
|
-
<span class="h6 text-[hsl(var(--sage-green))] relative z-10 me-6">{$t('folder.currentLocation')}</span>
|
|
426
|
-
{/if}
|
|
427
|
-
{#if selectedFolder?.id === 'root'}
|
|
428
|
-
<IconArrowBounce class="w-6 h-6 text-[hsl(var(--info))] me-6 rtl:-scale-x-100" />
|
|
429
|
-
{/if}
|
|
430
|
-
</div>
|
|
431
|
-
</button>
|
|
432
|
-
</div>
|
|
356
|
+
{$t('moveDialog.rootName')}
|
|
357
|
+
</span>
|
|
358
|
+
{#if rootIsCurrent}
|
|
359
|
+
<span class="shrink-0 text-caption text-muted-foreground">{$t('folder.currentLocation')}</span>
|
|
360
|
+
{:else if rootIsSelected}
|
|
361
|
+
<IconArrowBounce class="size-4 shrink-0 stroke-[1.333] text-foreground rtl:rotate-180" aria-hidden="true" />
|
|
362
|
+
{/if}
|
|
363
|
+
</button>
|
|
433
364
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
{#each folders as folder}
|
|
365
|
+
<div class="flex flex-col border-s-2 border-border ps-8">
|
|
366
|
+
{#each folders as folder (folder.id)}
|
|
437
367
|
{#if folder.type === 'folder'}
|
|
438
|
-
<FolderTree
|
|
368
|
+
<FolderTree
|
|
439
369
|
{folder}
|
|
440
370
|
{selectedFolder}
|
|
441
371
|
{immediateParentId}
|
|
442
|
-
onSelect={(f) => selectedFolder = f}
|
|
372
|
+
onSelect={(f) => (selectedFolder = f)}
|
|
443
373
|
{getFolderIconForItem}
|
|
444
|
-
customClasses="min-h-[70px] px-2"
|
|
445
|
-
iconSize="40"
|
|
446
|
-
textClass="body-medium truncate text-[hsl(var(--grey7))]"
|
|
447
|
-
selectedIconClass="w-6 h-6 text-[hsl(var(--info))]"
|
|
448
|
-
currentLocationClass="text-sm text-[hsl(var(--info))] me-2"
|
|
449
|
-
selectedIcon={IconArrowBounce}
|
|
450
374
|
/>
|
|
451
375
|
{/if}
|
|
452
376
|
{/each}
|
|
@@ -454,97 +378,34 @@
|
|
|
454
378
|
</div>
|
|
455
379
|
</WScrollArea>
|
|
456
380
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
bind:clientHeight={buttonsContainerHeight}>
|
|
460
|
-
|
|
461
|
-
<!-- Results Count -->
|
|
462
|
-
<div class="results-count text-[hsl(var(--grey5))] subtext">
|
|
381
|
+
<div class="flex shrink-0 items-center gap-2">
|
|
382
|
+
<p class="min-w-0 flex-1 truncate text-caption text-muted-foreground">
|
|
463
383
|
{#if selectedFolder && selectedFolder.id !== immediateParentId}
|
|
464
|
-
{$t('moveDialog.movingTo', {
|
|
384
|
+
{$t('moveDialog.movingTo', {
|
|
385
|
+
name: selectedFolder.id === 'root' ? $t('moveDialog.rootName') : selectedFolder.name
|
|
386
|
+
})}
|
|
465
387
|
{/if}
|
|
466
|
-
</
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
<Button
|
|
471
|
-
type="button"
|
|
472
|
-
class="modal-btn-secondary !h-[34px]"
|
|
473
|
-
onclick={handleClose}
|
|
474
|
-
>
|
|
475
|
-
<span>{$t('action.cancel')}</span>
|
|
388
|
+
</p>
|
|
389
|
+
<div class="flex shrink-0 items-center gap-2">
|
|
390
|
+
<Button type="button" variant="outline" class="h-9" onclick={handleClose}>
|
|
391
|
+
{$t('action.cancel')}
|
|
476
392
|
</Button>
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
393
|
+
<Button
|
|
394
|
+
type="button"
|
|
395
|
+
variant="default"
|
|
396
|
+
class="h-9"
|
|
397
|
+
onclick={handleSubmit}
|
|
398
|
+
disabled={confirmDisabled}
|
|
483
399
|
>
|
|
484
400
|
{#if sourceItems.length === 1 && sourceItems[0]?.type === 'folder'}
|
|
485
|
-
|
|
401
|
+
{$t('moveDialog.confirmFolder')}
|
|
486
402
|
{:else if sourceItems.length === 1}
|
|
487
|
-
|
|
403
|
+
{$t('moveDialog.confirmItem')}
|
|
488
404
|
{:else}
|
|
489
|
-
|
|
405
|
+
{$t('moveDialog.confirmMany', { count: sourceItems.length })}
|
|
490
406
|
{/if}
|
|
491
407
|
</Button>
|
|
492
408
|
</div>
|
|
493
409
|
</div>
|
|
494
|
-
|
|
495
|
-
</div> <!-- End of Root Container -->
|
|
410
|
+
</div>
|
|
496
411
|
</BaseModal>
|
|
497
|
-
|
|
498
|
-
<style>
|
|
499
|
-
/* Folder item styling */
|
|
500
|
-
.folder-item {
|
|
501
|
-
position: relative;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
.folder-item::before {
|
|
505
|
-
content: '';
|
|
506
|
-
position: absolute;
|
|
507
|
-
inset-inline-start: 0;
|
|
508
|
-
top: 0;
|
|
509
|
-
bottom: 0;
|
|
510
|
-
width: 2px;
|
|
511
|
-
background-color: hsl(var(--grey1));
|
|
512
|
-
opacity: 0.5;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/* Apply hover effect only to the button itself */
|
|
516
|
-
.folder-button {
|
|
517
|
-
transition: all 150ms ease;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/* Only apply hover effect when not disabled and not selected */
|
|
521
|
-
.folder-button:not(:disabled):not(.light-green-bg):hover {
|
|
522
|
-
background-color: hsl(var(--grey1));
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/* Explicitly handle the selected state to override the default hover */
|
|
526
|
-
.folder-button.light-green-bg:not(:disabled):hover {
|
|
527
|
-
background-color: hsl(var(--light-green)) !important;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/* Thumbnail button styling - no transform effects */
|
|
531
|
-
.thumbnail-button {
|
|
532
|
-
border-radius: var(--radius-large);
|
|
533
|
-
-webkit-font-smoothing: antialiased;
|
|
534
|
-
transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
/* No scaling for selected state, only opacity changes */
|
|
538
|
-
.thumbnail-button.is-selected {
|
|
539
|
-
opacity: 0.9;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
.thumbnail-button.can-hover:hover {
|
|
543
|
-
opacity: 0.8;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/* Remove scaling hover effect - keep opacity only */
|
|
547
|
-
:global(.group:hover:not(.cursor-default):not(.bg-\[hsl\(var\(--light-green\)\)\])) .thumbnail-button.can-hover:not(.is-selected) {
|
|
548
|
-
opacity: 0.8;
|
|
549
|
-
}
|
|
550
|
-
</style>
|