@unciatech/file-manager 0.0.32 → 0.0.33
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 +125 -32
- package/dist/cli.cjs +120 -92
- package/dist/cli.js +115 -87
- package/dist/index.cjs +257 -170
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +243 -156
- package/dist/{mock-provider-nCBvw7nl.d.cts → mock-provider-DrtiUc3h.d.cts} +32 -4
- package/dist/{mock-provider-nCBvw7nl.d.ts → mock-provider-DrtiUc3h.d.ts} +32 -4
- package/dist/mock.d.cts +1 -1
- package/dist/mock.d.ts +1 -1
- package/dist/styles.css +75 -56
- package/dist/styles.d.ts +1 -0
- package/package.json +8 -5
- package/styles.css +75 -56
package/dist/index.js
CHANGED
|
@@ -62,8 +62,89 @@ var VIDEO_SOURCE = {
|
|
|
62
62
|
var VIDEO_SOURCES = Object.values(VIDEO_SOURCE);
|
|
63
63
|
|
|
64
64
|
// hooks/use-file-handlers.ts
|
|
65
|
-
import { useCallback } from "react";
|
|
66
|
-
|
|
65
|
+
import { useCallback as useCallback2 } from "react";
|
|
66
|
+
|
|
67
|
+
// hooks/use-browser-router.ts
|
|
68
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
69
|
+
var LOCATION_CHANGE_EVENT = "locationchange";
|
|
70
|
+
if (typeof window !== "undefined" && !window.__navigationPatched) {
|
|
71
|
+
window.__navigationPatched = true;
|
|
72
|
+
const originalPushState = window.history.pushState;
|
|
73
|
+
const originalReplaceState = window.history.replaceState;
|
|
74
|
+
window.history.pushState = function(...args) {
|
|
75
|
+
const result = originalPushState.apply(this, args);
|
|
76
|
+
setTimeout(() => window.dispatchEvent(new Event(LOCATION_CHANGE_EVENT)), 0);
|
|
77
|
+
return result;
|
|
78
|
+
};
|
|
79
|
+
window.history.replaceState = function(...args) {
|
|
80
|
+
const result = originalReplaceState.apply(this, args);
|
|
81
|
+
setTimeout(() => window.dispatchEvent(new Event(LOCATION_CHANGE_EVENT)), 0);
|
|
82
|
+
return result;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function useBrowserRouter({ basePath, onNavigate } = {}) {
|
|
86
|
+
const [pathname, setPathname] = useState(
|
|
87
|
+
() => typeof window !== "undefined" ? window.location.pathname : "/"
|
|
88
|
+
);
|
|
89
|
+
const [search, setSearch] = useState(
|
|
90
|
+
() => typeof window !== "undefined" ? window.location.search : ""
|
|
91
|
+
);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const onUpdate = () => {
|
|
94
|
+
setPathname(window.location.pathname);
|
|
95
|
+
setSearch(window.location.search);
|
|
96
|
+
};
|
|
97
|
+
window.addEventListener("popstate", onUpdate);
|
|
98
|
+
window.addEventListener(LOCATION_CHANGE_EVENT, onUpdate);
|
|
99
|
+
return () => {
|
|
100
|
+
window.removeEventListener("popstate", onUpdate);
|
|
101
|
+
window.removeEventListener(LOCATION_CHANGE_EVENT, onUpdate);
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
104
|
+
const push = useCallback(
|
|
105
|
+
(url, options) => {
|
|
106
|
+
if (onNavigate) {
|
|
107
|
+
onNavigate(url, options);
|
|
108
|
+
} else {
|
|
109
|
+
history.pushState(null, "", url);
|
|
110
|
+
if ((options == null ? void 0 : options.scroll) !== false) {
|
|
111
|
+
window.scrollTo(0, 0);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
[onNavigate]
|
|
116
|
+
);
|
|
117
|
+
const replace = useCallback(
|
|
118
|
+
(url) => {
|
|
119
|
+
if (onNavigate) {
|
|
120
|
+
onNavigate(url, { replace: true });
|
|
121
|
+
} else {
|
|
122
|
+
history.replaceState(null, "", url);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
[onNavigate]
|
|
126
|
+
);
|
|
127
|
+
const back = useCallback(() => {
|
|
128
|
+
history.back();
|
|
129
|
+
}, []);
|
|
130
|
+
const searchParams = useMemo(
|
|
131
|
+
() => new URLSearchParams(search),
|
|
132
|
+
[search]
|
|
133
|
+
);
|
|
134
|
+
const params = useMemo(() => {
|
|
135
|
+
if (!basePath) return {};
|
|
136
|
+
const base = basePath.replace(/\/$/, "");
|
|
137
|
+
const normalizedBase = base.startsWith("/") ? base : `/${base}`;
|
|
138
|
+
if (!pathname.startsWith(normalizedBase)) return {};
|
|
139
|
+
const rest = pathname.slice(normalizedBase.length).replace(/^\//, "");
|
|
140
|
+
if (!rest) return {};
|
|
141
|
+
const segments = rest.split("/").filter(Boolean);
|
|
142
|
+
return { path: segments[0] };
|
|
143
|
+
}, [pathname, basePath]);
|
|
144
|
+
return { push, replace, back, pathname, searchParams, params };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// hooks/use-file-handlers.ts
|
|
67
148
|
import { toast } from "sonner";
|
|
68
149
|
var toggleFilesInSelection = (prev, filesToToggle) => {
|
|
69
150
|
let updated = [...prev];
|
|
@@ -113,8 +194,8 @@ function useFileHandlers(state) {
|
|
|
113
194
|
setIsLoading,
|
|
114
195
|
setFileDetailsModalFile
|
|
115
196
|
} = state;
|
|
116
|
-
const
|
|
117
|
-
const handleFileClick =
|
|
197
|
+
const { push } = useBrowserRouter({ basePath: state.basePath, onNavigate: state.onNavigate });
|
|
198
|
+
const handleFileClick = useCallback2(
|
|
118
199
|
(file, event, isCheckboxClick = false) => {
|
|
119
200
|
const fileArray = [file];
|
|
120
201
|
const isExplicitSelection = isCheckboxClick || event && (event.metaKey || event.ctrlKey);
|
|
@@ -140,7 +221,7 @@ function useFileHandlers(state) {
|
|
|
140
221
|
},
|
|
141
222
|
[mode, selectionMode, isInSelectionMode, setSelectedFiles, onFilesSelected, onClose, setFileDetailsModalFile]
|
|
142
223
|
);
|
|
143
|
-
const handleFolderClick =
|
|
224
|
+
const handleFolderClick = useCallback2(
|
|
144
225
|
(folder, event, isCheckboxClick = false) => {
|
|
145
226
|
const folderId = folder ? folder.id : null;
|
|
146
227
|
const isExplicitSelection = isCheckboxClick || event && (event.metaKey || event.ctrlKey);
|
|
@@ -155,8 +236,9 @@ function useFileHandlers(state) {
|
|
|
155
236
|
if (mode === MODE.PAGE) {
|
|
156
237
|
setIsLoading(true);
|
|
157
238
|
const path = basePath != null ? basePath : "/media";
|
|
158
|
-
const
|
|
159
|
-
|
|
239
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
240
|
+
const newUrl = folderId === null ? normalizedPath : `${normalizedPath}/${folderId}`;
|
|
241
|
+
push(newUrl);
|
|
160
242
|
} else {
|
|
161
243
|
setIsLoading(true);
|
|
162
244
|
setSelectedFiles([]);
|
|
@@ -169,16 +251,16 @@ function useFileHandlers(state) {
|
|
|
169
251
|
}
|
|
170
252
|
params.set("page", "1");
|
|
171
253
|
const newUrl = `${globalThis.location.pathname}?${params.toString()}`;
|
|
172
|
-
|
|
254
|
+
push(newUrl, { scroll: false });
|
|
173
255
|
}
|
|
174
256
|
},
|
|
175
|
-
[isInSelectionMode, mode,
|
|
257
|
+
[isInSelectionMode, mode, push, setSelectedFolders, setSelectedFiles, basePath, setIsLoading]
|
|
176
258
|
);
|
|
177
|
-
const handleClearSelection =
|
|
259
|
+
const handleClearSelection = useCallback2(() => {
|
|
178
260
|
setSelectedFiles([]);
|
|
179
261
|
setSelectedFolders([]);
|
|
180
262
|
}, [setSelectedFiles, setSelectedFolders]);
|
|
181
|
-
const handleSelectAllGlobal =
|
|
263
|
+
const handleSelectAllGlobal = useCallback2(
|
|
182
264
|
(checked) => {
|
|
183
265
|
if (checked) {
|
|
184
266
|
setSelectedFiles(files);
|
|
@@ -190,10 +272,10 @@ function useFileHandlers(state) {
|
|
|
190
272
|
},
|
|
191
273
|
[files, folders, mode, setSelectedFiles, setSelectedFolders]
|
|
192
274
|
);
|
|
193
|
-
const refreshData =
|
|
275
|
+
const refreshData = useCallback2(async (silent = false) => {
|
|
194
276
|
await loadData(silent);
|
|
195
277
|
}, [loadData]);
|
|
196
|
-
const uploadFiles =
|
|
278
|
+
const uploadFiles = useCallback2(
|
|
197
279
|
async (fileUploadInput) => {
|
|
198
280
|
var _a;
|
|
199
281
|
try {
|
|
@@ -213,7 +295,7 @@ function useFileHandlers(state) {
|
|
|
213
295
|
},
|
|
214
296
|
[currentFolder, provider, refreshData, setSelectedFiles]
|
|
215
297
|
);
|
|
216
|
-
const createFolder =
|
|
298
|
+
const createFolder = useCallback2(
|
|
217
299
|
async (name) => {
|
|
218
300
|
var _a;
|
|
219
301
|
try {
|
|
@@ -233,7 +315,7 @@ function useFileHandlers(state) {
|
|
|
233
315
|
},
|
|
234
316
|
[currentFolder, provider, refreshData, setSelectedFiles]
|
|
235
317
|
);
|
|
236
|
-
const bulkMove =
|
|
318
|
+
const bulkMove = useCallback2(
|
|
237
319
|
async (targetFolderId) => {
|
|
238
320
|
try {
|
|
239
321
|
if (selectedFiles.length > 0) {
|
|
@@ -272,7 +354,7 @@ function useFileHandlers(state) {
|
|
|
272
354
|
setSelectedFolders
|
|
273
355
|
]
|
|
274
356
|
);
|
|
275
|
-
const renameFolder =
|
|
357
|
+
const renameFolder = useCallback2(
|
|
276
358
|
async (folderId, newName) => {
|
|
277
359
|
try {
|
|
278
360
|
setFolders(
|
|
@@ -293,7 +375,7 @@ function useFileHandlers(state) {
|
|
|
293
375
|
},
|
|
294
376
|
[provider, refreshData, setFolders]
|
|
295
377
|
);
|
|
296
|
-
const updateFileMetadata =
|
|
378
|
+
const updateFileMetadata = useCallback2(
|
|
297
379
|
async (fileId, metadata) => {
|
|
298
380
|
try {
|
|
299
381
|
setFiles(
|
|
@@ -319,7 +401,7 @@ function useFileHandlers(state) {
|
|
|
319
401
|
},
|
|
320
402
|
[provider, refreshData, setFiles]
|
|
321
403
|
);
|
|
322
|
-
const bulkDelete =
|
|
404
|
+
const bulkDelete = useCallback2(async () => {
|
|
323
405
|
try {
|
|
324
406
|
if (selectedFiles.length > 0) {
|
|
325
407
|
await provider.deleteFiles(selectedFiles.map((f) => f.id));
|
|
@@ -367,8 +449,7 @@ function useFileHandlers(state) {
|
|
|
367
449
|
}
|
|
368
450
|
|
|
369
451
|
// hooks/use-file-state.ts
|
|
370
|
-
import {
|
|
371
|
-
import { useCallback as useCallback2, useEffect, useMemo, useRef, useState } from "react";
|
|
452
|
+
import { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
372
453
|
import { toast as toast2 } from "sonner";
|
|
373
454
|
function useFileState(options) {
|
|
374
455
|
const {
|
|
@@ -380,16 +461,14 @@ function useFileState(options) {
|
|
|
380
461
|
provider,
|
|
381
462
|
onFilesSelected,
|
|
382
463
|
onClose,
|
|
383
|
-
basePath
|
|
464
|
+
basePath,
|
|
465
|
+
onNavigate
|
|
384
466
|
} = options;
|
|
385
|
-
const params =
|
|
386
|
-
const searchParams = useSearchParams();
|
|
387
|
-
const router = useRouter2();
|
|
388
|
-
const pathname = usePathname();
|
|
467
|
+
const { params, searchParams, push, replace, pathname } = useBrowserRouter({ basePath, onNavigate });
|
|
389
468
|
const pageFromUrl = Math.max(1, Number.parseInt(searchParams.get("page") || "1", 10));
|
|
390
469
|
const limitFromUrl = Math.max(1, Number.parseInt(searchParams.get("limit") || "24", 10));
|
|
391
470
|
const queryFromUrl = searchParams.get("query") || "";
|
|
392
|
-
const folderId =
|
|
471
|
+
const folderId = useMemo2(() => {
|
|
393
472
|
if (mode === MODE.PAGE && (params == null ? void 0 : params.path)) {
|
|
394
473
|
const path = Array.isArray(params.path) ? params.path[0] : params.path;
|
|
395
474
|
return typeof path === "string" && /^\d+$/.test(path) ? Number(path) : null;
|
|
@@ -402,13 +481,13 @@ function useFileState(options) {
|
|
|
402
481
|
}
|
|
403
482
|
return initialFolderId != null ? initialFolderId : null;
|
|
404
483
|
}, [mode, params, searchParams, initialFolderId]);
|
|
405
|
-
const [files, setFiles] =
|
|
406
|
-
const [folders, setFolders] =
|
|
407
|
-
const [selectedFiles, setSelectedFiles] =
|
|
408
|
-
const [selectedFolders, setSelectedFolders] =
|
|
409
|
-
const [currentFolder, setCurrentFolder] =
|
|
410
|
-
const [isLoading, setIsLoading] =
|
|
411
|
-
const [pagination, setPagination] =
|
|
484
|
+
const [files, setFiles] = useState2([]);
|
|
485
|
+
const [folders, setFolders] = useState2([]);
|
|
486
|
+
const [selectedFiles, setSelectedFiles] = useState2([]);
|
|
487
|
+
const [selectedFolders, setSelectedFolders] = useState2([]);
|
|
488
|
+
const [currentFolder, setCurrentFolder] = useState2(null);
|
|
489
|
+
const [isLoading, setIsLoading] = useState2(true);
|
|
490
|
+
const [pagination, setPagination] = useState2({
|
|
412
491
|
currentPage: pageFromUrl,
|
|
413
492
|
totalPages: 1,
|
|
414
493
|
totalFiles: 0,
|
|
@@ -416,39 +495,45 @@ function useFileState(options) {
|
|
|
416
495
|
});
|
|
417
496
|
const currentFolderRef = useRef(null);
|
|
418
497
|
currentFolderRef.current = currentFolder;
|
|
419
|
-
const [searchQuery, setSearchQuery] =
|
|
420
|
-
const [debouncedSearchQuery, setDebouncedSearchQuery] =
|
|
421
|
-
|
|
498
|
+
const [searchQuery, setSearchQuery] = useState2(queryFromUrl);
|
|
499
|
+
const [debouncedSearchQuery, setDebouncedSearchQuery] = useState2(queryFromUrl);
|
|
500
|
+
useEffect2(() => {
|
|
422
501
|
const handler = setTimeout(() => {
|
|
423
502
|
setDebouncedSearchQuery(searchQuery);
|
|
424
503
|
}, 300);
|
|
425
504
|
return () => clearTimeout(handler);
|
|
426
505
|
}, [searchQuery]);
|
|
427
506
|
const prevFolderIdRef = useRef(folderId);
|
|
428
|
-
const updateUrlParams =
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
507
|
+
const updateUrlParams = useCallback3((page, limit, replaceUrl = false) => {
|
|
508
|
+
const urlParams = new URLSearchParams(searchParams.toString());
|
|
509
|
+
urlParams.set("page", page.toString());
|
|
510
|
+
urlParams.set("limit", limit.toString());
|
|
511
|
+
const qs = urlParams.toString();
|
|
512
|
+
const newUrl = qs ? `${pathname}?${qs}` : pathname;
|
|
513
|
+
if (replaceUrl) {
|
|
514
|
+
replace(newUrl);
|
|
515
|
+
} else {
|
|
516
|
+
push(newUrl, { scroll: false });
|
|
517
|
+
}
|
|
518
|
+
}, [push, replace, pathname, searchParams]);
|
|
519
|
+
useEffect2(() => {
|
|
435
520
|
setPagination((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
436
521
|
currentPage: pageFromUrl,
|
|
437
522
|
filesPerPage: limitFromUrl
|
|
438
523
|
}));
|
|
439
524
|
setSearchQuery(queryFromUrl);
|
|
440
525
|
}, [pageFromUrl, limitFromUrl, queryFromUrl]);
|
|
441
|
-
|
|
526
|
+
useEffect2(() => {
|
|
442
527
|
if (folderId !== prevFolderIdRef.current) {
|
|
443
528
|
if (mode === MODE.PAGE) {
|
|
444
|
-
updateUrlParams(1, limitFromUrl);
|
|
529
|
+
updateUrlParams(1, limitFromUrl, true);
|
|
445
530
|
}
|
|
446
531
|
prevFolderIdRef.current = folderId;
|
|
447
532
|
}
|
|
448
533
|
}, [folderId, limitFromUrl, updateUrlParams, mode]);
|
|
449
534
|
const currentPage = pagination.currentPage;
|
|
450
535
|
const filesPerPage = pagination.filesPerPage;
|
|
451
|
-
|
|
536
|
+
useEffect2(() => {
|
|
452
537
|
let cancelled = false;
|
|
453
538
|
const syncAndLoad = async () => {
|
|
454
539
|
if (folderId && (!currentFolderRef.current || currentFolderRef.current.id !== folderId)) {
|
|
@@ -527,18 +612,18 @@ function useFileState(options) {
|
|
|
527
612
|
filesPerPage,
|
|
528
613
|
debouncedSearchQuery
|
|
529
614
|
]);
|
|
530
|
-
|
|
615
|
+
useEffect2(() => {
|
|
531
616
|
setSelectedFolders([]);
|
|
532
617
|
setSelectedFiles([]);
|
|
533
618
|
}, [currentFolder]);
|
|
534
|
-
const [isUploadModalOpen, setIsUploadModalOpen] =
|
|
535
|
-
const [isCreateFolderModalOpen, setIsCreateFolderModalOpen] =
|
|
536
|
-
const [isSearchModalOpen, setIsSearchModalOpen] =
|
|
537
|
-
const [isMoveFileModalOpen, setIsMoveFileModalOpen] =
|
|
538
|
-
const [isRenameFolderModalOpen, setIsRenameFolderModalOpen] =
|
|
539
|
-
const [folderToRename, setFolderToRename] =
|
|
540
|
-
const [fileDetailsModalFile, setFileDetailsModalFile] =
|
|
541
|
-
const loadData =
|
|
619
|
+
const [isUploadModalOpen, setIsUploadModalOpen] = useState2(false);
|
|
620
|
+
const [isCreateFolderModalOpen, setIsCreateFolderModalOpen] = useState2(false);
|
|
621
|
+
const [isSearchModalOpen, setIsSearchModalOpen] = useState2(false);
|
|
622
|
+
const [isMoveFileModalOpen, setIsMoveFileModalOpen] = useState2(false);
|
|
623
|
+
const [isRenameFolderModalOpen, setIsRenameFolderModalOpen] = useState2(false);
|
|
624
|
+
const [folderToRename, setFolderToRename] = useState2(null);
|
|
625
|
+
const [fileDetailsModalFile, setFileDetailsModalFile] = useState2(null);
|
|
626
|
+
const loadData = useCallback3(async (silent = false) => {
|
|
542
627
|
var _a;
|
|
543
628
|
if (!silent) {
|
|
544
629
|
setIsLoading(true);
|
|
@@ -574,7 +659,7 @@ function useFileState(options) {
|
|
|
574
659
|
}, [currentFolder, mode, acceptedFileTypesForModal, allowedFileTypes, provider, currentPage, filesPerPage, debouncedSearchQuery]);
|
|
575
660
|
const isInSelectionMode = () => selectedFiles.length > 0 || selectedFolders.length > 0;
|
|
576
661
|
const getCurrentFolder = () => currentFolder;
|
|
577
|
-
const getSelectionState =
|
|
662
|
+
const getSelectionState = useMemo2(() => {
|
|
578
663
|
return () => {
|
|
579
664
|
const totalItems = files.length + (mode === MODE.PAGE ? folders.length : 0);
|
|
580
665
|
const selectedItems = selectedFiles.length + selectedFolders.length;
|
|
@@ -583,23 +668,24 @@ function useFileState(options) {
|
|
|
583
668
|
return "indeterminate";
|
|
584
669
|
};
|
|
585
670
|
}, [files.length, folders.length, selectedFiles.length, selectedFolders.length, mode]);
|
|
586
|
-
const handlePageChange =
|
|
671
|
+
const handlePageChange = useCallback3((newPage) => {
|
|
587
672
|
setPagination((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: newPage }));
|
|
588
673
|
if (mode === MODE.PAGE) {
|
|
589
674
|
updateUrlParams(newPage, filesPerPage);
|
|
590
675
|
}
|
|
591
676
|
}, [updateUrlParams, filesPerPage, mode]);
|
|
592
|
-
const updateSearchQuery =
|
|
677
|
+
const updateSearchQuery = useCallback3((newQuery) => {
|
|
593
678
|
setSearchQuery(newQuery);
|
|
594
|
-
const
|
|
679
|
+
const urlParams = new URLSearchParams(searchParams.toString());
|
|
595
680
|
if (newQuery.trim()) {
|
|
596
|
-
|
|
597
|
-
|
|
681
|
+
urlParams.set("query", newQuery);
|
|
682
|
+
urlParams.set("page", "1");
|
|
598
683
|
} else {
|
|
599
|
-
|
|
684
|
+
urlParams.delete("query");
|
|
600
685
|
}
|
|
601
|
-
|
|
602
|
-
|
|
686
|
+
const qs = urlParams.toString();
|
|
687
|
+
replace(qs ? `${pathname}?${qs}` : pathname);
|
|
688
|
+
}, [replace, pathname, searchParams]);
|
|
603
689
|
return {
|
|
604
690
|
// State
|
|
605
691
|
files,
|
|
@@ -650,12 +736,13 @@ function useFileState(options) {
|
|
|
650
736
|
provider,
|
|
651
737
|
onFilesSelected,
|
|
652
738
|
onClose,
|
|
653
|
-
basePath
|
|
739
|
+
basePath,
|
|
740
|
+
onNavigate
|
|
654
741
|
};
|
|
655
742
|
}
|
|
656
743
|
|
|
657
744
|
// context/file-manager-context.tsx
|
|
658
|
-
import { createContext, useContext, useMemo as
|
|
745
|
+
import { createContext, useContext, useMemo as useMemo3 } from "react";
|
|
659
746
|
import { jsx } from "react/jsx-runtime";
|
|
660
747
|
var FileManagerContext = createContext(void 0);
|
|
661
748
|
function FileManagerProvider({
|
|
@@ -670,8 +757,9 @@ function FileManagerProvider({
|
|
|
670
757
|
provider,
|
|
671
758
|
basePath = "/media",
|
|
672
759
|
maxUploadFiles = 50,
|
|
673
|
-
maxUploadSize = 100 * 1024 * 1024
|
|
760
|
+
maxUploadSize = 100 * 1024 * 1024,
|
|
674
761
|
// 100MB
|
|
762
|
+
onNavigate
|
|
675
763
|
}) {
|
|
676
764
|
const state = useFileState({
|
|
677
765
|
mode,
|
|
@@ -682,10 +770,11 @@ function FileManagerProvider({
|
|
|
682
770
|
provider,
|
|
683
771
|
onFilesSelected,
|
|
684
772
|
onClose,
|
|
685
|
-
basePath
|
|
773
|
+
basePath,
|
|
774
|
+
onNavigate
|
|
686
775
|
});
|
|
687
776
|
const handlers = useFileHandlers(state);
|
|
688
|
-
const value =
|
|
777
|
+
const value = useMemo3(() => ({
|
|
689
778
|
// State
|
|
690
779
|
files: state.files,
|
|
691
780
|
folders: state.folders,
|
|
@@ -2228,14 +2317,14 @@ function FileManagerHeader({
|
|
|
2228
2317
|
}
|
|
2229
2318
|
|
|
2230
2319
|
// components/modals/upload-modal.tsx
|
|
2231
|
-
import { useState as
|
|
2320
|
+
import { useState as useState6 } from "react";
|
|
2232
2321
|
|
|
2233
2322
|
// components/ui/dialog.tsx
|
|
2234
2323
|
import { cva as cva2 } from "class-variance-authority";
|
|
2235
2324
|
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
2236
2325
|
import { jsx as jsx45, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
2237
2326
|
var dialogContentVariants = cva2(
|
|
2238
|
-
"flex flex-col fixed outline-0 z-50 border border-border bg-background shadow-lg shadow-black/5 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 rounded-2xl",
|
|
2327
|
+
"flex flex-col fixed outline-0 z-50 border border-border bg-background text-foreground shadow-lg shadow-black/5 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 rounded-2xl",
|
|
2239
2328
|
{
|
|
2240
2329
|
variants: {
|
|
2241
2330
|
variant: {
|
|
@@ -2624,7 +2713,7 @@ function getFileSize(bytes) {
|
|
|
2624
2713
|
}
|
|
2625
2714
|
|
|
2626
2715
|
// hooks/use-file-upload.ts
|
|
2627
|
-
import { useCallback as
|
|
2716
|
+
import { useCallback as useCallback4, useRef as useRef2, useState as useState3, useEffect as useEffect3 } from "react";
|
|
2628
2717
|
var useFileUpload = (options = {}) => {
|
|
2629
2718
|
const {
|
|
2630
2719
|
maxFiles = Number.POSITIVE_INFINITY,
|
|
@@ -2636,7 +2725,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2636
2725
|
onFilesAdded,
|
|
2637
2726
|
onError
|
|
2638
2727
|
} = options;
|
|
2639
|
-
const [state, setState] =
|
|
2728
|
+
const [state, setState] = useState3({
|
|
2640
2729
|
files: initialFiles.map((file) => ({
|
|
2641
2730
|
file,
|
|
2642
2731
|
id: file.id,
|
|
@@ -2646,7 +2735,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2646
2735
|
errors: []
|
|
2647
2736
|
});
|
|
2648
2737
|
const inputRef = useRef2(null);
|
|
2649
|
-
|
|
2738
|
+
useEffect3(() => {
|
|
2650
2739
|
return () => {
|
|
2651
2740
|
state.files.forEach((file) => {
|
|
2652
2741
|
if (file.preview && file.file instanceof File) {
|
|
@@ -2655,7 +2744,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2655
2744
|
});
|
|
2656
2745
|
};
|
|
2657
2746
|
}, [state.files]);
|
|
2658
|
-
const validateFile =
|
|
2747
|
+
const validateFile = useCallback4(
|
|
2659
2748
|
(file) => {
|
|
2660
2749
|
if (file.size > maxSize) {
|
|
2661
2750
|
return `File "${file.name}" exceeds the maximum size of ${getFileSize(maxSize)}.`;
|
|
@@ -2682,19 +2771,19 @@ var useFileUpload = (options = {}) => {
|
|
|
2682
2771
|
},
|
|
2683
2772
|
[accept, maxSize]
|
|
2684
2773
|
);
|
|
2685
|
-
const createPreview =
|
|
2774
|
+
const createPreview = useCallback4((file) => {
|
|
2686
2775
|
if (file instanceof File) {
|
|
2687
2776
|
return URL.createObjectURL(file);
|
|
2688
2777
|
}
|
|
2689
2778
|
return file.url;
|
|
2690
2779
|
}, []);
|
|
2691
|
-
const generateUniqueId =
|
|
2780
|
+
const generateUniqueId = useCallback4((file) => {
|
|
2692
2781
|
if (file instanceof File) {
|
|
2693
2782
|
return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
2694
2783
|
}
|
|
2695
2784
|
return file.id.toString();
|
|
2696
2785
|
}, []);
|
|
2697
|
-
const clearFiles =
|
|
2786
|
+
const clearFiles = useCallback4(() => {
|
|
2698
2787
|
setState((prev) => {
|
|
2699
2788
|
for (const file of prev.files) {
|
|
2700
2789
|
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) {
|
|
@@ -2712,7 +2801,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2712
2801
|
return newState;
|
|
2713
2802
|
});
|
|
2714
2803
|
}, [onFilesChange]);
|
|
2715
|
-
const addFiles =
|
|
2804
|
+
const addFiles = useCallback4(
|
|
2716
2805
|
(newFiles) => {
|
|
2717
2806
|
if (!newFiles || newFiles.length === 0) return;
|
|
2718
2807
|
const newFilesArray = Array.from(newFiles);
|
|
@@ -2787,7 +2876,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2787
2876
|
onError
|
|
2788
2877
|
]
|
|
2789
2878
|
);
|
|
2790
|
-
const removeFile =
|
|
2879
|
+
const removeFile = useCallback4(
|
|
2791
2880
|
(id) => {
|
|
2792
2881
|
setState((prev) => {
|
|
2793
2882
|
const fileToRemove = prev.files.find((file) => file.id === id);
|
|
@@ -2804,17 +2893,17 @@ var useFileUpload = (options = {}) => {
|
|
|
2804
2893
|
},
|
|
2805
2894
|
[onFilesChange]
|
|
2806
2895
|
);
|
|
2807
|
-
const clearErrors =
|
|
2896
|
+
const clearErrors = useCallback4(() => {
|
|
2808
2897
|
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
2809
2898
|
errors: []
|
|
2810
2899
|
}));
|
|
2811
2900
|
}, []);
|
|
2812
|
-
const handleDragEnter =
|
|
2901
|
+
const handleDragEnter = useCallback4((e) => {
|
|
2813
2902
|
e.preventDefault();
|
|
2814
2903
|
e.stopPropagation();
|
|
2815
2904
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { isDragging: true }));
|
|
2816
2905
|
}, []);
|
|
2817
|
-
const handleDragLeave =
|
|
2906
|
+
const handleDragLeave = useCallback4((e) => {
|
|
2818
2907
|
e.preventDefault();
|
|
2819
2908
|
e.stopPropagation();
|
|
2820
2909
|
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
@@ -2822,11 +2911,11 @@ var useFileUpload = (options = {}) => {
|
|
|
2822
2911
|
}
|
|
2823
2912
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { isDragging: false }));
|
|
2824
2913
|
}, []);
|
|
2825
|
-
const handleDragOver =
|
|
2914
|
+
const handleDragOver = useCallback4((e) => {
|
|
2826
2915
|
e.preventDefault();
|
|
2827
2916
|
e.stopPropagation();
|
|
2828
2917
|
}, []);
|
|
2829
|
-
const handleDrop =
|
|
2918
|
+
const handleDrop = useCallback4(
|
|
2830
2919
|
(e) => {
|
|
2831
2920
|
var _a;
|
|
2832
2921
|
e.preventDefault();
|
|
@@ -2846,7 +2935,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2846
2935
|
},
|
|
2847
2936
|
[addFiles, multiple]
|
|
2848
2937
|
);
|
|
2849
|
-
const handleFileChange =
|
|
2938
|
+
const handleFileChange = useCallback4(
|
|
2850
2939
|
(e) => {
|
|
2851
2940
|
if (e.target.files && e.target.files.length > 0) {
|
|
2852
2941
|
addFiles(e.target.files);
|
|
@@ -2854,12 +2943,12 @@ var useFileUpload = (options = {}) => {
|
|
|
2854
2943
|
},
|
|
2855
2944
|
[addFiles]
|
|
2856
2945
|
);
|
|
2857
|
-
const openFileDialog =
|
|
2946
|
+
const openFileDialog = useCallback4(() => {
|
|
2858
2947
|
if (inputRef.current) {
|
|
2859
2948
|
inputRef.current.click();
|
|
2860
2949
|
}
|
|
2861
2950
|
}, []);
|
|
2862
|
-
const getInputProps =
|
|
2951
|
+
const getInputProps = useCallback4(
|
|
2863
2952
|
(props = {}) => {
|
|
2864
2953
|
var _a;
|
|
2865
2954
|
return __spreadProps(__spreadValues({}, props), {
|
|
@@ -3131,11 +3220,11 @@ var CloseButton = forwardRef(
|
|
|
3131
3220
|
CloseButton.displayName = "CloseButton";
|
|
3132
3221
|
|
|
3133
3222
|
// components/cards/image-card.tsx
|
|
3134
|
-
import { useState as
|
|
3223
|
+
import { useState as useState4 } from "react";
|
|
3135
3224
|
import { jsx as jsx51, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3136
3225
|
function ImageCard({ file }) {
|
|
3137
3226
|
var _a;
|
|
3138
|
-
const [hasError, setHasError] =
|
|
3227
|
+
const [hasError, setHasError] = useState4(false);
|
|
3139
3228
|
const imageSrc = file.previewUrl || file.url;
|
|
3140
3229
|
if (imageSrc && !hasError) {
|
|
3141
3230
|
return /* @__PURE__ */ jsx51(
|
|
@@ -3160,10 +3249,10 @@ function ImageCardMetadata({ file }) {
|
|
|
3160
3249
|
}
|
|
3161
3250
|
|
|
3162
3251
|
// components/cards/video-card.tsx
|
|
3163
|
-
import { useState as
|
|
3252
|
+
import { useState as useState5 } from "react";
|
|
3164
3253
|
import { jsx as jsx52, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
3165
3254
|
function VideoCard({ file, className }) {
|
|
3166
|
-
const [hasError, setHasError] =
|
|
3255
|
+
const [hasError, setHasError] = useState5(false);
|
|
3167
3256
|
if (file.previewUrl && !hasError) {
|
|
3168
3257
|
return /* @__PURE__ */ jsxs36("div", { className: "relative w-full h-full", children: [
|
|
3169
3258
|
/* @__PURE__ */ jsx52(
|
|
@@ -3314,7 +3403,7 @@ function UploadModal() {
|
|
|
3314
3403
|
} = useFileManager();
|
|
3315
3404
|
const acceptString = fileTypesToAccept(allowedFileTypes);
|
|
3316
3405
|
const fileTypesDescription = getFileTypesDescription(allowedFileTypes);
|
|
3317
|
-
const [uploadItems, setUploadItems] =
|
|
3406
|
+
const [uploadItems, setUploadItems] = useState6([]);
|
|
3318
3407
|
const [
|
|
3319
3408
|
{ isDragging, errors },
|
|
3320
3409
|
{
|
|
@@ -3419,7 +3508,7 @@ function UploadModal() {
|
|
|
3419
3508
|
"div",
|
|
3420
3509
|
{
|
|
3421
3510
|
className: cn(
|
|
3422
|
-
"relative rounded-
|
|
3511
|
+
"relative w-full rounded-xl border-2 border-dashed bg-muted border-muted-foreground/25 px-6 py-16 text-center transition-colors mb-4",
|
|
3423
3512
|
isDragging ? "border-primary bg-primary/5" : "border-muted-foreground/25 hover:border-muted-foreground/50"
|
|
3424
3513
|
),
|
|
3425
3514
|
onDragEnter: handleDragEnter,
|
|
@@ -3474,8 +3563,8 @@ function UploadModal() {
|
|
|
3474
3563
|
iconClassName: "size-3"
|
|
3475
3564
|
}
|
|
3476
3565
|
),
|
|
3477
|
-
/* @__PURE__ */ jsxs39("div", { className: "relative overflow-hidden rounded-lg border bg-card transition-colors", children: [
|
|
3478
|
-
/* @__PURE__ */ jsx57("div", { className: "relative aspect-square bg-muted border-
|
|
3566
|
+
/* @__PURE__ */ jsxs39("div", { className: "relative overflow-hidden rounded-lg border border-muted-foreground/25 bg-card transition-colors", children: [
|
|
3567
|
+
/* @__PURE__ */ jsx57("div", { className: "relative aspect-square bg-muted border-muted-foreground/25", children: /* @__PURE__ */ jsx57("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsx57("div", { className: "w-[75%] h-[75%] flex items-center justify-center", children: fileItem.status === "uploading" ? /* @__PURE__ */ jsxs39("div", { className: "relative w-full h-full flex items-center justify-center", children: [
|
|
3479
3568
|
/* @__PURE__ */ jsxs39("svg", { className: "size-12 -rotate-90 absolute", viewBox: "0 0 48 48", children: [
|
|
3480
3569
|
/* @__PURE__ */ jsx57(
|
|
3481
3570
|
"circle",
|
|
@@ -3547,7 +3636,7 @@ function UploadModal() {
|
|
|
3547
3636
|
}
|
|
3548
3637
|
|
|
3549
3638
|
// components/modals/create-folder.tsx
|
|
3550
|
-
import { useState as
|
|
3639
|
+
import { useState as useState7 } from "react";
|
|
3551
3640
|
|
|
3552
3641
|
// components/ui/input.tsx
|
|
3553
3642
|
import { cva as cva4 } from "class-variance-authority";
|
|
@@ -3695,7 +3784,7 @@ function CreateFolderModal() {
|
|
|
3695
3784
|
folderToRename,
|
|
3696
3785
|
setFolderToRename
|
|
3697
3786
|
} = useFileManager();
|
|
3698
|
-
const [editedName, setEditedName] =
|
|
3787
|
+
const [editedName, setEditedName] = useState7(null);
|
|
3699
3788
|
const isRenameMode = isRenameFolderModalOpen;
|
|
3700
3789
|
const isOpen = isCreateFolderModalOpen || isRenameFolderModalOpen;
|
|
3701
3790
|
const defaultFolderName = isRenameMode && folderToRename ? folderToRename.name : "";
|
|
@@ -3774,7 +3863,7 @@ function CreateFolderModal() {
|
|
|
3774
3863
|
}
|
|
3775
3864
|
|
|
3776
3865
|
// components/modals/move-modal.tsx
|
|
3777
|
-
import { useState as
|
|
3866
|
+
import { useState as useState9, useEffect as useEffect5, useCallback as useCallback5, useRef as useRef4 } from "react";
|
|
3778
3867
|
|
|
3779
3868
|
// lib/truncate-name.ts
|
|
3780
3869
|
function middleTruncate(text, maxLength = 30) {
|
|
@@ -3785,16 +3874,16 @@ function middleTruncate(text, maxLength = 30) {
|
|
|
3785
3874
|
}
|
|
3786
3875
|
|
|
3787
3876
|
// hooks/use-intersection-observer.ts
|
|
3788
|
-
import { useEffect as
|
|
3877
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState8 } from "react";
|
|
3789
3878
|
function useIntersectionObserver({
|
|
3790
3879
|
threshold = 0,
|
|
3791
3880
|
root = null,
|
|
3792
3881
|
rootMargin = "0%"
|
|
3793
3882
|
} = {}) {
|
|
3794
|
-
const [entry, setEntry] =
|
|
3795
|
-
const [node, setNode] =
|
|
3883
|
+
const [entry, setEntry] = useState8();
|
|
3884
|
+
const [node, setNode] = useState8(null);
|
|
3796
3885
|
const observer = useRef3(null);
|
|
3797
|
-
|
|
3886
|
+
useEffect4(() => {
|
|
3798
3887
|
if (observer.current) {
|
|
3799
3888
|
observer.current.disconnect();
|
|
3800
3889
|
}
|
|
@@ -3829,7 +3918,7 @@ function FolderTreeItem({
|
|
|
3829
3918
|
treeState
|
|
3830
3919
|
}) {
|
|
3831
3920
|
var _a;
|
|
3832
|
-
const [isOpen, setIsOpen] =
|
|
3921
|
+
const [isOpen, setIsOpen] = useState9(false);
|
|
3833
3922
|
const hasChildren = ((_a = folder.folderCount) != null ? _a : 0) > 0;
|
|
3834
3923
|
const isSelected = selectedFolderId === folder.id;
|
|
3835
3924
|
const isDisabled = disabledFolderIds.includes(folder.id);
|
|
@@ -3842,7 +3931,7 @@ function FolderTreeItem({
|
|
|
3842
3931
|
rootMargin: "100px"
|
|
3843
3932
|
});
|
|
3844
3933
|
const hasMore = pagination && pagination.currentPage < pagination.totalPages;
|
|
3845
|
-
|
|
3934
|
+
useEffect5(() => {
|
|
3846
3935
|
if (isOpen && (entry == null ? void 0 : entry.isIntersecting) && hasMore && !isLoading) {
|
|
3847
3936
|
const nextPage = ((pagination == null ? void 0 : pagination.currentPage) || 1) + 1;
|
|
3848
3937
|
onLoadChildren(folder.id, nextPage);
|
|
@@ -3930,8 +4019,8 @@ function MoveModal() {
|
|
|
3930
4019
|
bulkMove,
|
|
3931
4020
|
provider
|
|
3932
4021
|
} = useFileManager();
|
|
3933
|
-
const [targetFolderId, setTargetFolderId] =
|
|
3934
|
-
const [treeState, setTreeState] =
|
|
4022
|
+
const [targetFolderId, setTargetFolderId] = useState9(void 0);
|
|
4023
|
+
const [treeState, setTreeState] = useState9({
|
|
3935
4024
|
folders: /* @__PURE__ */ new Map(),
|
|
3936
4025
|
loading: /* @__PURE__ */ new Set(),
|
|
3937
4026
|
loaded: /* @__PURE__ */ new Set(),
|
|
@@ -3948,7 +4037,7 @@ function MoveModal() {
|
|
|
3948
4037
|
const isRootLoading = treeState.loading.has(null);
|
|
3949
4038
|
const disabledFolderIds = selectedFolders.map((f) => f.id);
|
|
3950
4039
|
const rootFolders = treeState.folders.get(null) || [];
|
|
3951
|
-
const loadFolders =
|
|
4040
|
+
const loadFolders = useCallback5(async (folderId, page = 1) => {
|
|
3952
4041
|
if (fetchingRef.current.has(folderId)) return;
|
|
3953
4042
|
fetchingRef.current.add(folderId);
|
|
3954
4043
|
setTreeState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
@@ -3988,7 +4077,7 @@ function MoveModal() {
|
|
|
3988
4077
|
fetchingRef.current.delete(folderId);
|
|
3989
4078
|
}
|
|
3990
4079
|
}, [provider]);
|
|
3991
|
-
|
|
4080
|
+
useEffect5(() => {
|
|
3992
4081
|
if (isMoveFileModalOpen) {
|
|
3993
4082
|
if (!hasInitializedRef.current) {
|
|
3994
4083
|
hasInitializedRef.current = true;
|
|
@@ -3998,7 +4087,7 @@ function MoveModal() {
|
|
|
3998
4087
|
hasInitializedRef.current = false;
|
|
3999
4088
|
}
|
|
4000
4089
|
}, [isMoveFileModalOpen, loadFolders]);
|
|
4001
|
-
|
|
4090
|
+
useEffect5(() => {
|
|
4002
4091
|
if (isMoveFileModalOpen && (rootEntry == null ? void 0 : rootEntry.isIntersecting) && rootHasMore && !isRootLoading) {
|
|
4003
4092
|
const nextPage = ((rootPagination == null ? void 0 : rootPagination.currentPage) || 1) + 1;
|
|
4004
4093
|
loadFolders(null, nextPage);
|
|
@@ -4094,7 +4183,7 @@ function MoveModal() {
|
|
|
4094
4183
|
}
|
|
4095
4184
|
|
|
4096
4185
|
// components/modals/image-modal.tsx
|
|
4097
|
-
import { useState as
|
|
4186
|
+
import { useState as useState11 } from "react";
|
|
4098
4187
|
|
|
4099
4188
|
// components/file-details/details-layout.tsx
|
|
4100
4189
|
import { jsx as jsx61, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
@@ -4132,11 +4221,11 @@ function DetailsLayout({
|
|
|
4132
4221
|
|
|
4133
4222
|
// components/file-details/file-action-buttons.tsx
|
|
4134
4223
|
import { toast as toast3 } from "sonner";
|
|
4135
|
-
import { useState as
|
|
4224
|
+
import { useState as useState10 } from "react";
|
|
4136
4225
|
import { jsx as jsx62 } from "react/jsx-runtime";
|
|
4137
4226
|
function FileDeleteButton({ file }) {
|
|
4138
4227
|
const { provider, setFileDetailsModalFile, refreshData } = useFileManager();
|
|
4139
|
-
const [deleting, setDeleting] =
|
|
4228
|
+
const [deleting, setDeleting] = useState10(false);
|
|
4140
4229
|
const handleDelete = async () => {
|
|
4141
4230
|
setDeleting(true);
|
|
4142
4231
|
try {
|
|
@@ -4166,7 +4255,7 @@ function FileDeleteButton({ file }) {
|
|
|
4166
4255
|
);
|
|
4167
4256
|
}
|
|
4168
4257
|
function FileDownloadButton({ file }) {
|
|
4169
|
-
const [downloading, setDownloading] =
|
|
4258
|
+
const [downloading, setDownloading] = useState10(false);
|
|
4170
4259
|
const handleDownload = async () => {
|
|
4171
4260
|
setDownloading(true);
|
|
4172
4261
|
try {
|
|
@@ -4198,7 +4287,7 @@ function FileDownloadButton({ file }) {
|
|
|
4198
4287
|
);
|
|
4199
4288
|
}
|
|
4200
4289
|
function FileCopyLinkButton({ file }) {
|
|
4201
|
-
const [copied, setCopied] =
|
|
4290
|
+
const [copied, setCopied] = useState10(false);
|
|
4202
4291
|
const handleCopyLink = async () => {
|
|
4203
4292
|
try {
|
|
4204
4293
|
await navigator.clipboard.writeText(file.url);
|
|
@@ -4319,7 +4408,7 @@ function formatDuration(seconds) {
|
|
|
4319
4408
|
}
|
|
4320
4409
|
|
|
4321
4410
|
// components/ui/field.tsx
|
|
4322
|
-
import { useMemo as
|
|
4411
|
+
import { useMemo as useMemo4 } from "react";
|
|
4323
4412
|
import { cva as cva7 } from "class-variance-authority";
|
|
4324
4413
|
import { jsx as jsx65, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
4325
4414
|
var fieldVariants = cva7(
|
|
@@ -4501,10 +4590,10 @@ function InputGroupInput(_a) {
|
|
|
4501
4590
|
import { jsx as jsx67, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
4502
4591
|
function ImageModal({ file, onClose, onSave }) {
|
|
4503
4592
|
var _a;
|
|
4504
|
-
const [isSaving, setIsSaving] =
|
|
4505
|
-
const [fileName, setFileName] =
|
|
4506
|
-
const [alternativeText, setAlternativeText] =
|
|
4507
|
-
const [caption, setCaption] =
|
|
4593
|
+
const [isSaving, setIsSaving] = useState11(false);
|
|
4594
|
+
const [fileName, setFileName] = useState11(file.name);
|
|
4595
|
+
const [alternativeText, setAlternativeText] = useState11(file.alternativeText || "");
|
|
4596
|
+
const [caption, setCaption] = useState11(file.caption || "");
|
|
4508
4597
|
const handleSave = async () => {
|
|
4509
4598
|
setIsSaving(true);
|
|
4510
4599
|
try {
|
|
@@ -4627,13 +4716,13 @@ function ImageModal({ file, onClose, onSave }) {
|
|
|
4627
4716
|
}
|
|
4628
4717
|
|
|
4629
4718
|
// components/modals/video-modal.tsx
|
|
4630
|
-
import { useState as
|
|
4719
|
+
import { useState as useState12 } from "react";
|
|
4631
4720
|
import { jsx as jsx68, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
4632
4721
|
function VideoModal({ file, onClose, onSave }) {
|
|
4633
4722
|
var _a, _b, _c;
|
|
4634
|
-
const [isSaving, setIsSaving] =
|
|
4635
|
-
const [fileName, setFileName] =
|
|
4636
|
-
const [caption, setCaption] =
|
|
4723
|
+
const [isSaving, setIsSaving] = useState12(false);
|
|
4724
|
+
const [fileName, setFileName] = useState12(file.name);
|
|
4725
|
+
const [caption, setCaption] = useState12(file.caption || "");
|
|
4637
4726
|
const handleSave = async () => {
|
|
4638
4727
|
setIsSaving(true);
|
|
4639
4728
|
try {
|
|
@@ -4734,13 +4823,13 @@ function VideoModal({ file, onClose, onSave }) {
|
|
|
4734
4823
|
}
|
|
4735
4824
|
|
|
4736
4825
|
// components/modals/audio-modal.tsx
|
|
4737
|
-
import { useState as
|
|
4826
|
+
import { useState as useState13 } from "react";
|
|
4738
4827
|
import { jsx as jsx69, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
4739
4828
|
function AudioModal({ file, onClose, onSave }) {
|
|
4740
4829
|
var _a, _b, _c;
|
|
4741
|
-
const [isSaving, setIsSaving] =
|
|
4742
|
-
const [fileName, setFileName] =
|
|
4743
|
-
const [caption, setCaption] =
|
|
4830
|
+
const [isSaving, setIsSaving] = useState13(false);
|
|
4831
|
+
const [fileName, setFileName] = useState13(file.name);
|
|
4832
|
+
const [caption, setCaption] = useState13(file.caption || "");
|
|
4744
4833
|
const handleSave = async () => {
|
|
4745
4834
|
setIsSaving(true);
|
|
4746
4835
|
try {
|
|
@@ -4842,13 +4931,13 @@ function AudioModal({ file, onClose, onSave }) {
|
|
|
4842
4931
|
}
|
|
4843
4932
|
|
|
4844
4933
|
// components/modals/file-modal.tsx
|
|
4845
|
-
import { useState as
|
|
4934
|
+
import { useState as useState14 } from "react";
|
|
4846
4935
|
import { jsx as jsx70, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
4847
4936
|
function FileModal({ file, onClose, onSave }) {
|
|
4848
4937
|
var _a, _b, _c, _d;
|
|
4849
|
-
const [isSaving, setIsSaving] =
|
|
4850
|
-
const [fileName, setFileName] =
|
|
4851
|
-
const [description, setDescription] =
|
|
4938
|
+
const [isSaving, setIsSaving] = useState14(false);
|
|
4939
|
+
const [fileName, setFileName] = useState14(file.name);
|
|
4940
|
+
const [description, setDescription] = useState14(((_a = file.metaData) == null ? void 0 : _a.description) || "");
|
|
4852
4941
|
const handleSave = async () => {
|
|
4853
4942
|
setIsSaving(true);
|
|
4854
4943
|
try {
|
|
@@ -5162,7 +5251,6 @@ function Skeleton(_a) {
|
|
|
5162
5251
|
}
|
|
5163
5252
|
|
|
5164
5253
|
// components/layout/header-navigation.tsx
|
|
5165
|
-
import { useRouter as useRouter3 } from "next/navigation";
|
|
5166
5254
|
import { Fragment, jsx as jsx75, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
5167
5255
|
function HeaderNavigation() {
|
|
5168
5256
|
const {
|
|
@@ -5170,9 +5258,8 @@ function HeaderNavigation() {
|
|
|
5170
5258
|
handleFolderClick,
|
|
5171
5259
|
isLoading
|
|
5172
5260
|
} = useFileManager();
|
|
5173
|
-
const router = useRouter3();
|
|
5174
5261
|
const handleBackClick = () => {
|
|
5175
|
-
|
|
5262
|
+
history.back();
|
|
5176
5263
|
};
|
|
5177
5264
|
if (isLoading) {
|
|
5178
5265
|
return /* @__PURE__ */ jsxs50("div", { className: "flex item-center w-full", children: [
|
|
@@ -5279,7 +5366,7 @@ function DropdownMenuSeparator(_a) {
|
|
|
5279
5366
|
}
|
|
5280
5367
|
|
|
5281
5368
|
// components/modals/search-modal.tsx
|
|
5282
|
-
import { useCallback as
|
|
5369
|
+
import { useCallback as useCallback6, useEffect as useEffect7, useState as useState16 } from "react";
|
|
5283
5370
|
|
|
5284
5371
|
// components/ui/command.tsx
|
|
5285
5372
|
import { Command as CommandPrimitive } from "cmdk";
|
|
@@ -5368,10 +5455,10 @@ function CommandItem(_a) {
|
|
|
5368
5455
|
}
|
|
5369
5456
|
|
|
5370
5457
|
// hooks/use-debounced-value.ts
|
|
5371
|
-
import { useEffect as
|
|
5458
|
+
import { useEffect as useEffect6, useState as useState15 } from "react";
|
|
5372
5459
|
function useDebouncedValue(value, delay2 = 500) {
|
|
5373
|
-
const [debouncedValue, setDebouncedValue] =
|
|
5374
|
-
|
|
5460
|
+
const [debouncedValue, setDebouncedValue] = useState15(value);
|
|
5461
|
+
useEffect6(() => {
|
|
5375
5462
|
const handler = setTimeout(() => {
|
|
5376
5463
|
setDebouncedValue(value);
|
|
5377
5464
|
}, delay2);
|
|
@@ -5386,13 +5473,13 @@ function useDebouncedValue(value, delay2 = 500) {
|
|
|
5386
5473
|
import { toast as toast4 } from "sonner";
|
|
5387
5474
|
import { Fragment as Fragment2, jsx as jsx78, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
5388
5475
|
function SearchDialog() {
|
|
5389
|
-
const [searchQuery, setSearchQuery] =
|
|
5390
|
-
const [fileResults, setFileResults] =
|
|
5391
|
-
const [folderResults, setFolderResults] =
|
|
5392
|
-
const [loading, setLoading] =
|
|
5476
|
+
const [searchQuery, setSearchQuery] = useState16("");
|
|
5477
|
+
const [fileResults, setFileResults] = useState16([]);
|
|
5478
|
+
const [folderResults, setFolderResults] = useState16([]);
|
|
5479
|
+
const [loading, setLoading] = useState16(false);
|
|
5393
5480
|
const { provider, handleFolderClick, handleClearSelection, isSearchModalOpen, setIsSearchModalOpen, setFileDetailsModalFile } = useFileManager();
|
|
5394
5481
|
const debouncedSearchQuery = useDebouncedValue(searchQuery, 300);
|
|
5395
|
-
const doSearch =
|
|
5482
|
+
const doSearch = useCallback6(async (q) => {
|
|
5396
5483
|
setLoading(true);
|
|
5397
5484
|
try {
|
|
5398
5485
|
const [files, folders] = await Promise.all([
|
|
@@ -5412,7 +5499,7 @@ function SearchDialog() {
|
|
|
5412
5499
|
setLoading(false);
|
|
5413
5500
|
}
|
|
5414
5501
|
}, [provider]);
|
|
5415
|
-
|
|
5502
|
+
useEffect7(() => {
|
|
5416
5503
|
if (isSearchModalOpen && debouncedSearchQuery.length > 0) {
|
|
5417
5504
|
doSearch(debouncedSearchQuery);
|
|
5418
5505
|
} else {
|
|
@@ -5588,7 +5675,7 @@ function CreateFolderAction() {
|
|
|
5588
5675
|
}
|
|
5589
5676
|
|
|
5590
5677
|
// components/layout/theme-toggle.tsx
|
|
5591
|
-
import { useEffect as
|
|
5678
|
+
import { useEffect as useEffect8, useState as useState17 } from "react";
|
|
5592
5679
|
|
|
5593
5680
|
// components/icons/theme.tsx
|
|
5594
5681
|
import { jsx as jsx81, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
@@ -5635,8 +5722,8 @@ function MoonIcon(props) {
|
|
|
5635
5722
|
// components/layout/theme-toggle.tsx
|
|
5636
5723
|
import { jsx as jsx82 } from "react/jsx-runtime";
|
|
5637
5724
|
function ThemeToggle() {
|
|
5638
|
-
const [isDark, setIsDark] =
|
|
5639
|
-
|
|
5725
|
+
const [isDark, setIsDark] = useState17(false);
|
|
5726
|
+
useEffect8(() => {
|
|
5640
5727
|
const saved = localStorage.getItem("theme");
|
|
5641
5728
|
const shouldBeDark = saved === "dark";
|
|
5642
5729
|
setIsDark(shouldBeDark);
|
|
@@ -6274,7 +6361,7 @@ var FileManagerErrorBoundary = class extends Component {
|
|
|
6274
6361
|
};
|
|
6275
6362
|
|
|
6276
6363
|
// components/keyboard-shortcuts.tsx
|
|
6277
|
-
import { useEffect as
|
|
6364
|
+
import { useEffect as useEffect9 } from "react";
|
|
6278
6365
|
function KeyboardShortcuts() {
|
|
6279
6366
|
const {
|
|
6280
6367
|
handleSelectAllGlobal,
|
|
@@ -6287,7 +6374,7 @@ function KeyboardShortcuts() {
|
|
|
6287
6374
|
isSearchModalOpen,
|
|
6288
6375
|
setIsSearchModalOpen
|
|
6289
6376
|
} = useFileManager();
|
|
6290
|
-
|
|
6377
|
+
useEffect9(() => {
|
|
6291
6378
|
const handleKeyDown = (e) => {
|
|
6292
6379
|
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
|
|
6293
6380
|
e.preventDefault();
|
|
@@ -6323,7 +6410,7 @@ function FileManager(props) {
|
|
|
6323
6410
|
return /* @__PURE__ */ jsx90(FileManagerErrorBoundary, { children: /* @__PURE__ */ jsxs64(FileManagerComposition.Page, __spreadProps(__spreadValues({}, props), { children: [
|
|
6324
6411
|
/* @__PURE__ */ jsx90(KeyboardShortcuts, {}),
|
|
6325
6412
|
/* @__PURE__ */ jsxs64("div", { className: "flex h-full relative pb-12 overflow-hidden bg-background text-foreground", children: [
|
|
6326
|
-
/* @__PURE__ */ jsxs64("div", { className: "flex-1 flex w-full flex-col", children: [
|
|
6413
|
+
/* @__PURE__ */ jsxs64("div", { className: "flex-1 flex w-full flex-col overflow-y-auto", children: [
|
|
6327
6414
|
/* @__PURE__ */ jsx90(FileManagerComposition.Header, { children: /* @__PURE__ */ jsxs64("div", { className: "flex w-full justify-between gap-2", children: [
|
|
6328
6415
|
/* @__PURE__ */ jsx90(HeaderNavigation, {}),
|
|
6329
6416
|
/* @__PURE__ */ jsx90(ResponsiveHeaderActions, {})
|
|
@@ -6338,7 +6425,7 @@ function FileManager(props) {
|
|
|
6338
6425
|
}
|
|
6339
6426
|
|
|
6340
6427
|
// components/file-manager-modal.tsx
|
|
6341
|
-
import { useState as
|
|
6428
|
+
import { useState as useState18, useRef as useRef5, useEffect as useEffect10 } from "react";
|
|
6342
6429
|
import { Fragment as Fragment4, jsx as jsx91, jsxs as jsxs65 } from "react/jsx-runtime";
|
|
6343
6430
|
function FileManagerModal(_a) {
|
|
6344
6431
|
var _b = _a, {
|
|
@@ -6352,14 +6439,14 @@ function FileManagerModal(_a) {
|
|
|
6352
6439
|
}
|
|
6353
6440
|
function ModalContent({ onClose }) {
|
|
6354
6441
|
const { updateSearchQuery } = useFileManager();
|
|
6355
|
-
const [isSearchActive, setIsSearchActive] =
|
|
6356
|
-
const [searchInput, setSearchInput] =
|
|
6442
|
+
const [isSearchActive, setIsSearchActive] = useState18(false);
|
|
6443
|
+
const [searchInput, setSearchInput] = useState18("");
|
|
6357
6444
|
const searchInputRef = useRef5(null);
|
|
6358
6445
|
const debouncedSearch = useDebouncedValue(searchInput, 300);
|
|
6359
|
-
|
|
6446
|
+
useEffect10(() => {
|
|
6360
6447
|
updateSearchQuery(debouncedSearch);
|
|
6361
6448
|
}, [debouncedSearch, updateSearchQuery]);
|
|
6362
|
-
|
|
6449
|
+
useEffect10(() => {
|
|
6363
6450
|
if (isSearchActive && searchInputRef.current) {
|
|
6364
6451
|
searchInputRef.current.focus();
|
|
6365
6452
|
}
|