@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.cjs
CHANGED
|
@@ -109,8 +109,89 @@ var VIDEO_SOURCE = {
|
|
|
109
109
|
var VIDEO_SOURCES = Object.values(VIDEO_SOURCE);
|
|
110
110
|
|
|
111
111
|
// hooks/use-file-handlers.ts
|
|
112
|
+
var import_react2 = require("react");
|
|
113
|
+
|
|
114
|
+
// hooks/use-browser-router.ts
|
|
112
115
|
var import_react = require("react");
|
|
113
|
-
var
|
|
116
|
+
var LOCATION_CHANGE_EVENT = "locationchange";
|
|
117
|
+
if (typeof window !== "undefined" && !window.__navigationPatched) {
|
|
118
|
+
window.__navigationPatched = true;
|
|
119
|
+
const originalPushState = window.history.pushState;
|
|
120
|
+
const originalReplaceState = window.history.replaceState;
|
|
121
|
+
window.history.pushState = function(...args) {
|
|
122
|
+
const result = originalPushState.apply(this, args);
|
|
123
|
+
setTimeout(() => window.dispatchEvent(new Event(LOCATION_CHANGE_EVENT)), 0);
|
|
124
|
+
return result;
|
|
125
|
+
};
|
|
126
|
+
window.history.replaceState = function(...args) {
|
|
127
|
+
const result = originalReplaceState.apply(this, args);
|
|
128
|
+
setTimeout(() => window.dispatchEvent(new Event(LOCATION_CHANGE_EVENT)), 0);
|
|
129
|
+
return result;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function useBrowserRouter({ basePath, onNavigate } = {}) {
|
|
133
|
+
const [pathname, setPathname] = (0, import_react.useState)(
|
|
134
|
+
() => typeof window !== "undefined" ? window.location.pathname : "/"
|
|
135
|
+
);
|
|
136
|
+
const [search, setSearch] = (0, import_react.useState)(
|
|
137
|
+
() => typeof window !== "undefined" ? window.location.search : ""
|
|
138
|
+
);
|
|
139
|
+
(0, import_react.useEffect)(() => {
|
|
140
|
+
const onUpdate = () => {
|
|
141
|
+
setPathname(window.location.pathname);
|
|
142
|
+
setSearch(window.location.search);
|
|
143
|
+
};
|
|
144
|
+
window.addEventListener("popstate", onUpdate);
|
|
145
|
+
window.addEventListener(LOCATION_CHANGE_EVENT, onUpdate);
|
|
146
|
+
return () => {
|
|
147
|
+
window.removeEventListener("popstate", onUpdate);
|
|
148
|
+
window.removeEventListener(LOCATION_CHANGE_EVENT, onUpdate);
|
|
149
|
+
};
|
|
150
|
+
}, []);
|
|
151
|
+
const push = (0, import_react.useCallback)(
|
|
152
|
+
(url, options) => {
|
|
153
|
+
if (onNavigate) {
|
|
154
|
+
onNavigate(url, options);
|
|
155
|
+
} else {
|
|
156
|
+
history.pushState(null, "", url);
|
|
157
|
+
if ((options == null ? void 0 : options.scroll) !== false) {
|
|
158
|
+
window.scrollTo(0, 0);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
[onNavigate]
|
|
163
|
+
);
|
|
164
|
+
const replace = (0, import_react.useCallback)(
|
|
165
|
+
(url) => {
|
|
166
|
+
if (onNavigate) {
|
|
167
|
+
onNavigate(url, { replace: true });
|
|
168
|
+
} else {
|
|
169
|
+
history.replaceState(null, "", url);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
[onNavigate]
|
|
173
|
+
);
|
|
174
|
+
const back = (0, import_react.useCallback)(() => {
|
|
175
|
+
history.back();
|
|
176
|
+
}, []);
|
|
177
|
+
const searchParams = (0, import_react.useMemo)(
|
|
178
|
+
() => new URLSearchParams(search),
|
|
179
|
+
[search]
|
|
180
|
+
);
|
|
181
|
+
const params = (0, import_react.useMemo)(() => {
|
|
182
|
+
if (!basePath) return {};
|
|
183
|
+
const base = basePath.replace(/\/$/, "");
|
|
184
|
+
const normalizedBase = base.startsWith("/") ? base : `/${base}`;
|
|
185
|
+
if (!pathname.startsWith(normalizedBase)) return {};
|
|
186
|
+
const rest = pathname.slice(normalizedBase.length).replace(/^\//, "");
|
|
187
|
+
if (!rest) return {};
|
|
188
|
+
const segments = rest.split("/").filter(Boolean);
|
|
189
|
+
return { path: segments[0] };
|
|
190
|
+
}, [pathname, basePath]);
|
|
191
|
+
return { push, replace, back, pathname, searchParams, params };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// hooks/use-file-handlers.ts
|
|
114
195
|
var import_sonner = require("sonner");
|
|
115
196
|
var toggleFilesInSelection = (prev, filesToToggle) => {
|
|
116
197
|
let updated = [...prev];
|
|
@@ -160,8 +241,8 @@ function useFileHandlers(state) {
|
|
|
160
241
|
setIsLoading,
|
|
161
242
|
setFileDetailsModalFile
|
|
162
243
|
} = state;
|
|
163
|
-
const
|
|
164
|
-
const handleFileClick = (0,
|
|
244
|
+
const { push } = useBrowserRouter({ basePath: state.basePath, onNavigate: state.onNavigate });
|
|
245
|
+
const handleFileClick = (0, import_react2.useCallback)(
|
|
165
246
|
(file, event, isCheckboxClick = false) => {
|
|
166
247
|
const fileArray = [file];
|
|
167
248
|
const isExplicitSelection = isCheckboxClick || event && (event.metaKey || event.ctrlKey);
|
|
@@ -187,7 +268,7 @@ function useFileHandlers(state) {
|
|
|
187
268
|
},
|
|
188
269
|
[mode, selectionMode, isInSelectionMode, setSelectedFiles, onFilesSelected, onClose, setFileDetailsModalFile]
|
|
189
270
|
);
|
|
190
|
-
const handleFolderClick = (0,
|
|
271
|
+
const handleFolderClick = (0, import_react2.useCallback)(
|
|
191
272
|
(folder, event, isCheckboxClick = false) => {
|
|
192
273
|
const folderId = folder ? folder.id : null;
|
|
193
274
|
const isExplicitSelection = isCheckboxClick || event && (event.metaKey || event.ctrlKey);
|
|
@@ -202,8 +283,9 @@ function useFileHandlers(state) {
|
|
|
202
283
|
if (mode === MODE.PAGE) {
|
|
203
284
|
setIsLoading(true);
|
|
204
285
|
const path = basePath != null ? basePath : "/media";
|
|
205
|
-
const
|
|
206
|
-
|
|
286
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
287
|
+
const newUrl = folderId === null ? normalizedPath : `${normalizedPath}/${folderId}`;
|
|
288
|
+
push(newUrl);
|
|
207
289
|
} else {
|
|
208
290
|
setIsLoading(true);
|
|
209
291
|
setSelectedFiles([]);
|
|
@@ -216,16 +298,16 @@ function useFileHandlers(state) {
|
|
|
216
298
|
}
|
|
217
299
|
params.set("page", "1");
|
|
218
300
|
const newUrl = `${globalThis.location.pathname}?${params.toString()}`;
|
|
219
|
-
|
|
301
|
+
push(newUrl, { scroll: false });
|
|
220
302
|
}
|
|
221
303
|
},
|
|
222
|
-
[isInSelectionMode, mode,
|
|
304
|
+
[isInSelectionMode, mode, push, setSelectedFolders, setSelectedFiles, basePath, setIsLoading]
|
|
223
305
|
);
|
|
224
|
-
const handleClearSelection = (0,
|
|
306
|
+
const handleClearSelection = (0, import_react2.useCallback)(() => {
|
|
225
307
|
setSelectedFiles([]);
|
|
226
308
|
setSelectedFolders([]);
|
|
227
309
|
}, [setSelectedFiles, setSelectedFolders]);
|
|
228
|
-
const handleSelectAllGlobal = (0,
|
|
310
|
+
const handleSelectAllGlobal = (0, import_react2.useCallback)(
|
|
229
311
|
(checked) => {
|
|
230
312
|
if (checked) {
|
|
231
313
|
setSelectedFiles(files);
|
|
@@ -237,10 +319,10 @@ function useFileHandlers(state) {
|
|
|
237
319
|
},
|
|
238
320
|
[files, folders, mode, setSelectedFiles, setSelectedFolders]
|
|
239
321
|
);
|
|
240
|
-
const refreshData = (0,
|
|
322
|
+
const refreshData = (0, import_react2.useCallback)(async (silent = false) => {
|
|
241
323
|
await loadData(silent);
|
|
242
324
|
}, [loadData]);
|
|
243
|
-
const uploadFiles = (0,
|
|
325
|
+
const uploadFiles = (0, import_react2.useCallback)(
|
|
244
326
|
async (fileUploadInput) => {
|
|
245
327
|
var _a;
|
|
246
328
|
try {
|
|
@@ -260,7 +342,7 @@ function useFileHandlers(state) {
|
|
|
260
342
|
},
|
|
261
343
|
[currentFolder, provider, refreshData, setSelectedFiles]
|
|
262
344
|
);
|
|
263
|
-
const createFolder = (0,
|
|
345
|
+
const createFolder = (0, import_react2.useCallback)(
|
|
264
346
|
async (name) => {
|
|
265
347
|
var _a;
|
|
266
348
|
try {
|
|
@@ -280,7 +362,7 @@ function useFileHandlers(state) {
|
|
|
280
362
|
},
|
|
281
363
|
[currentFolder, provider, refreshData, setSelectedFiles]
|
|
282
364
|
);
|
|
283
|
-
const bulkMove = (0,
|
|
365
|
+
const bulkMove = (0, import_react2.useCallback)(
|
|
284
366
|
async (targetFolderId) => {
|
|
285
367
|
try {
|
|
286
368
|
if (selectedFiles.length > 0) {
|
|
@@ -319,7 +401,7 @@ function useFileHandlers(state) {
|
|
|
319
401
|
setSelectedFolders
|
|
320
402
|
]
|
|
321
403
|
);
|
|
322
|
-
const renameFolder = (0,
|
|
404
|
+
const renameFolder = (0, import_react2.useCallback)(
|
|
323
405
|
async (folderId, newName) => {
|
|
324
406
|
try {
|
|
325
407
|
setFolders(
|
|
@@ -340,7 +422,7 @@ function useFileHandlers(state) {
|
|
|
340
422
|
},
|
|
341
423
|
[provider, refreshData, setFolders]
|
|
342
424
|
);
|
|
343
|
-
const updateFileMetadata = (0,
|
|
425
|
+
const updateFileMetadata = (0, import_react2.useCallback)(
|
|
344
426
|
async (fileId, metadata) => {
|
|
345
427
|
try {
|
|
346
428
|
setFiles(
|
|
@@ -366,7 +448,7 @@ function useFileHandlers(state) {
|
|
|
366
448
|
},
|
|
367
449
|
[provider, refreshData, setFiles]
|
|
368
450
|
);
|
|
369
|
-
const bulkDelete = (0,
|
|
451
|
+
const bulkDelete = (0, import_react2.useCallback)(async () => {
|
|
370
452
|
try {
|
|
371
453
|
if (selectedFiles.length > 0) {
|
|
372
454
|
await provider.deleteFiles(selectedFiles.map((f) => f.id));
|
|
@@ -414,8 +496,7 @@ function useFileHandlers(state) {
|
|
|
414
496
|
}
|
|
415
497
|
|
|
416
498
|
// hooks/use-file-state.ts
|
|
417
|
-
var
|
|
418
|
-
var import_react2 = require("react");
|
|
499
|
+
var import_react3 = require("react");
|
|
419
500
|
var import_sonner2 = require("sonner");
|
|
420
501
|
function useFileState(options) {
|
|
421
502
|
const {
|
|
@@ -427,16 +508,14 @@ function useFileState(options) {
|
|
|
427
508
|
provider,
|
|
428
509
|
onFilesSelected,
|
|
429
510
|
onClose,
|
|
430
|
-
basePath
|
|
511
|
+
basePath,
|
|
512
|
+
onNavigate
|
|
431
513
|
} = options;
|
|
432
|
-
const params = (
|
|
433
|
-
const searchParams = (0, import_navigation2.useSearchParams)();
|
|
434
|
-
const router = (0, import_navigation2.useRouter)();
|
|
435
|
-
const pathname = (0, import_navigation2.usePathname)();
|
|
514
|
+
const { params, searchParams, push, replace, pathname } = useBrowserRouter({ basePath, onNavigate });
|
|
436
515
|
const pageFromUrl = Math.max(1, Number.parseInt(searchParams.get("page") || "1", 10));
|
|
437
516
|
const limitFromUrl = Math.max(1, Number.parseInt(searchParams.get("limit") || "24", 10));
|
|
438
517
|
const queryFromUrl = searchParams.get("query") || "";
|
|
439
|
-
const folderId = (0,
|
|
518
|
+
const folderId = (0, import_react3.useMemo)(() => {
|
|
440
519
|
if (mode === MODE.PAGE && (params == null ? void 0 : params.path)) {
|
|
441
520
|
const path = Array.isArray(params.path) ? params.path[0] : params.path;
|
|
442
521
|
return typeof path === "string" && /^\d+$/.test(path) ? Number(path) : null;
|
|
@@ -449,53 +528,59 @@ function useFileState(options) {
|
|
|
449
528
|
}
|
|
450
529
|
return initialFolderId != null ? initialFolderId : null;
|
|
451
530
|
}, [mode, params, searchParams, initialFolderId]);
|
|
452
|
-
const [files, setFiles] = (0,
|
|
453
|
-
const [folders, setFolders] = (0,
|
|
454
|
-
const [selectedFiles, setSelectedFiles] = (0,
|
|
455
|
-
const [selectedFolders, setSelectedFolders] = (0,
|
|
456
|
-
const [currentFolder, setCurrentFolder] = (0,
|
|
457
|
-
const [isLoading, setIsLoading] = (0,
|
|
458
|
-
const [pagination, setPagination] = (0,
|
|
531
|
+
const [files, setFiles] = (0, import_react3.useState)([]);
|
|
532
|
+
const [folders, setFolders] = (0, import_react3.useState)([]);
|
|
533
|
+
const [selectedFiles, setSelectedFiles] = (0, import_react3.useState)([]);
|
|
534
|
+
const [selectedFolders, setSelectedFolders] = (0, import_react3.useState)([]);
|
|
535
|
+
const [currentFolder, setCurrentFolder] = (0, import_react3.useState)(null);
|
|
536
|
+
const [isLoading, setIsLoading] = (0, import_react3.useState)(true);
|
|
537
|
+
const [pagination, setPagination] = (0, import_react3.useState)({
|
|
459
538
|
currentPage: pageFromUrl,
|
|
460
539
|
totalPages: 1,
|
|
461
540
|
totalFiles: 0,
|
|
462
541
|
filesPerPage: limitFromUrl
|
|
463
542
|
});
|
|
464
|
-
const currentFolderRef = (0,
|
|
543
|
+
const currentFolderRef = (0, import_react3.useRef)(null);
|
|
465
544
|
currentFolderRef.current = currentFolder;
|
|
466
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
467
|
-
const [debouncedSearchQuery, setDebouncedSearchQuery] = (0,
|
|
468
|
-
(0,
|
|
545
|
+
const [searchQuery, setSearchQuery] = (0, import_react3.useState)(queryFromUrl);
|
|
546
|
+
const [debouncedSearchQuery, setDebouncedSearchQuery] = (0, import_react3.useState)(queryFromUrl);
|
|
547
|
+
(0, import_react3.useEffect)(() => {
|
|
469
548
|
const handler = setTimeout(() => {
|
|
470
549
|
setDebouncedSearchQuery(searchQuery);
|
|
471
550
|
}, 300);
|
|
472
551
|
return () => clearTimeout(handler);
|
|
473
552
|
}, [searchQuery]);
|
|
474
|
-
const prevFolderIdRef = (0,
|
|
475
|
-
const updateUrlParams = (0,
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
553
|
+
const prevFolderIdRef = (0, import_react3.useRef)(folderId);
|
|
554
|
+
const updateUrlParams = (0, import_react3.useCallback)((page, limit, replaceUrl = false) => {
|
|
555
|
+
const urlParams = new URLSearchParams(searchParams.toString());
|
|
556
|
+
urlParams.set("page", page.toString());
|
|
557
|
+
urlParams.set("limit", limit.toString());
|
|
558
|
+
const qs = urlParams.toString();
|
|
559
|
+
const newUrl = qs ? `${pathname}?${qs}` : pathname;
|
|
560
|
+
if (replaceUrl) {
|
|
561
|
+
replace(newUrl);
|
|
562
|
+
} else {
|
|
563
|
+
push(newUrl, { scroll: false });
|
|
564
|
+
}
|
|
565
|
+
}, [push, replace, pathname, searchParams]);
|
|
566
|
+
(0, import_react3.useEffect)(() => {
|
|
482
567
|
setPagination((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
483
568
|
currentPage: pageFromUrl,
|
|
484
569
|
filesPerPage: limitFromUrl
|
|
485
570
|
}));
|
|
486
571
|
setSearchQuery(queryFromUrl);
|
|
487
572
|
}, [pageFromUrl, limitFromUrl, queryFromUrl]);
|
|
488
|
-
(0,
|
|
573
|
+
(0, import_react3.useEffect)(() => {
|
|
489
574
|
if (folderId !== prevFolderIdRef.current) {
|
|
490
575
|
if (mode === MODE.PAGE) {
|
|
491
|
-
updateUrlParams(1, limitFromUrl);
|
|
576
|
+
updateUrlParams(1, limitFromUrl, true);
|
|
492
577
|
}
|
|
493
578
|
prevFolderIdRef.current = folderId;
|
|
494
579
|
}
|
|
495
580
|
}, [folderId, limitFromUrl, updateUrlParams, mode]);
|
|
496
581
|
const currentPage = pagination.currentPage;
|
|
497
582
|
const filesPerPage = pagination.filesPerPage;
|
|
498
|
-
(0,
|
|
583
|
+
(0, import_react3.useEffect)(() => {
|
|
499
584
|
let cancelled = false;
|
|
500
585
|
const syncAndLoad = async () => {
|
|
501
586
|
if (folderId && (!currentFolderRef.current || currentFolderRef.current.id !== folderId)) {
|
|
@@ -574,18 +659,18 @@ function useFileState(options) {
|
|
|
574
659
|
filesPerPage,
|
|
575
660
|
debouncedSearchQuery
|
|
576
661
|
]);
|
|
577
|
-
(0,
|
|
662
|
+
(0, import_react3.useEffect)(() => {
|
|
578
663
|
setSelectedFolders([]);
|
|
579
664
|
setSelectedFiles([]);
|
|
580
665
|
}, [currentFolder]);
|
|
581
|
-
const [isUploadModalOpen, setIsUploadModalOpen] = (0,
|
|
582
|
-
const [isCreateFolderModalOpen, setIsCreateFolderModalOpen] = (0,
|
|
583
|
-
const [isSearchModalOpen, setIsSearchModalOpen] = (0,
|
|
584
|
-
const [isMoveFileModalOpen, setIsMoveFileModalOpen] = (0,
|
|
585
|
-
const [isRenameFolderModalOpen, setIsRenameFolderModalOpen] = (0,
|
|
586
|
-
const [folderToRename, setFolderToRename] = (0,
|
|
587
|
-
const [fileDetailsModalFile, setFileDetailsModalFile] = (0,
|
|
588
|
-
const loadData = (0,
|
|
666
|
+
const [isUploadModalOpen, setIsUploadModalOpen] = (0, import_react3.useState)(false);
|
|
667
|
+
const [isCreateFolderModalOpen, setIsCreateFolderModalOpen] = (0, import_react3.useState)(false);
|
|
668
|
+
const [isSearchModalOpen, setIsSearchModalOpen] = (0, import_react3.useState)(false);
|
|
669
|
+
const [isMoveFileModalOpen, setIsMoveFileModalOpen] = (0, import_react3.useState)(false);
|
|
670
|
+
const [isRenameFolderModalOpen, setIsRenameFolderModalOpen] = (0, import_react3.useState)(false);
|
|
671
|
+
const [folderToRename, setFolderToRename] = (0, import_react3.useState)(null);
|
|
672
|
+
const [fileDetailsModalFile, setFileDetailsModalFile] = (0, import_react3.useState)(null);
|
|
673
|
+
const loadData = (0, import_react3.useCallback)(async (silent = false) => {
|
|
589
674
|
var _a;
|
|
590
675
|
if (!silent) {
|
|
591
676
|
setIsLoading(true);
|
|
@@ -621,7 +706,7 @@ function useFileState(options) {
|
|
|
621
706
|
}, [currentFolder, mode, acceptedFileTypesForModal, allowedFileTypes, provider, currentPage, filesPerPage, debouncedSearchQuery]);
|
|
622
707
|
const isInSelectionMode = () => selectedFiles.length > 0 || selectedFolders.length > 0;
|
|
623
708
|
const getCurrentFolder = () => currentFolder;
|
|
624
|
-
const getSelectionState = (0,
|
|
709
|
+
const getSelectionState = (0, import_react3.useMemo)(() => {
|
|
625
710
|
return () => {
|
|
626
711
|
const totalItems = files.length + (mode === MODE.PAGE ? folders.length : 0);
|
|
627
712
|
const selectedItems = selectedFiles.length + selectedFolders.length;
|
|
@@ -630,23 +715,24 @@ function useFileState(options) {
|
|
|
630
715
|
return "indeterminate";
|
|
631
716
|
};
|
|
632
717
|
}, [files.length, folders.length, selectedFiles.length, selectedFolders.length, mode]);
|
|
633
|
-
const handlePageChange = (0,
|
|
718
|
+
const handlePageChange = (0, import_react3.useCallback)((newPage) => {
|
|
634
719
|
setPagination((prev) => __spreadProps(__spreadValues({}, prev), { currentPage: newPage }));
|
|
635
720
|
if (mode === MODE.PAGE) {
|
|
636
721
|
updateUrlParams(newPage, filesPerPage);
|
|
637
722
|
}
|
|
638
723
|
}, [updateUrlParams, filesPerPage, mode]);
|
|
639
|
-
const updateSearchQuery = (0,
|
|
724
|
+
const updateSearchQuery = (0, import_react3.useCallback)((newQuery) => {
|
|
640
725
|
setSearchQuery(newQuery);
|
|
641
|
-
const
|
|
726
|
+
const urlParams = new URLSearchParams(searchParams.toString());
|
|
642
727
|
if (newQuery.trim()) {
|
|
643
|
-
|
|
644
|
-
|
|
728
|
+
urlParams.set("query", newQuery);
|
|
729
|
+
urlParams.set("page", "1");
|
|
645
730
|
} else {
|
|
646
|
-
|
|
731
|
+
urlParams.delete("query");
|
|
647
732
|
}
|
|
648
|
-
|
|
649
|
-
|
|
733
|
+
const qs = urlParams.toString();
|
|
734
|
+
replace(qs ? `${pathname}?${qs}` : pathname);
|
|
735
|
+
}, [replace, pathname, searchParams]);
|
|
650
736
|
return {
|
|
651
737
|
// State
|
|
652
738
|
files,
|
|
@@ -697,14 +783,15 @@ function useFileState(options) {
|
|
|
697
783
|
provider,
|
|
698
784
|
onFilesSelected,
|
|
699
785
|
onClose,
|
|
700
|
-
basePath
|
|
786
|
+
basePath,
|
|
787
|
+
onNavigate
|
|
701
788
|
};
|
|
702
789
|
}
|
|
703
790
|
|
|
704
791
|
// context/file-manager-context.tsx
|
|
705
|
-
var
|
|
792
|
+
var import_react4 = require("react");
|
|
706
793
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
707
|
-
var FileManagerContext = (0,
|
|
794
|
+
var FileManagerContext = (0, import_react4.createContext)(void 0);
|
|
708
795
|
function FileManagerProvider({
|
|
709
796
|
children,
|
|
710
797
|
mode = MODE.PAGE,
|
|
@@ -717,8 +804,9 @@ function FileManagerProvider({
|
|
|
717
804
|
provider,
|
|
718
805
|
basePath = "/media",
|
|
719
806
|
maxUploadFiles = 50,
|
|
720
|
-
maxUploadSize = 100 * 1024 * 1024
|
|
807
|
+
maxUploadSize = 100 * 1024 * 1024,
|
|
721
808
|
// 100MB
|
|
809
|
+
onNavigate
|
|
722
810
|
}) {
|
|
723
811
|
const state = useFileState({
|
|
724
812
|
mode,
|
|
@@ -729,10 +817,11 @@ function FileManagerProvider({
|
|
|
729
817
|
provider,
|
|
730
818
|
onFilesSelected,
|
|
731
819
|
onClose,
|
|
732
|
-
basePath
|
|
820
|
+
basePath,
|
|
821
|
+
onNavigate
|
|
733
822
|
});
|
|
734
823
|
const handlers = useFileHandlers(state);
|
|
735
|
-
const value = (0,
|
|
824
|
+
const value = (0, import_react4.useMemo)(() => ({
|
|
736
825
|
// State
|
|
737
826
|
files: state.files,
|
|
738
827
|
folders: state.folders,
|
|
@@ -794,7 +883,7 @@ function FileManagerProvider({
|
|
|
794
883
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileManagerContext.Provider, { value, children });
|
|
795
884
|
}
|
|
796
885
|
function useFileManager() {
|
|
797
|
-
const context = (0,
|
|
886
|
+
const context = (0, import_react4.useContext)(FileManagerContext);
|
|
798
887
|
if (context === void 0) {
|
|
799
888
|
throw new Error("useFileManager must be used within a FileManagerProvider");
|
|
800
889
|
}
|
|
@@ -2275,14 +2364,14 @@ function FileManagerHeader({
|
|
|
2275
2364
|
}
|
|
2276
2365
|
|
|
2277
2366
|
// components/modals/upload-modal.tsx
|
|
2278
|
-
var
|
|
2367
|
+
var import_react9 = require("react");
|
|
2279
2368
|
|
|
2280
2369
|
// components/ui/dialog.tsx
|
|
2281
2370
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
2282
2371
|
var import_radix_ui2 = require("radix-ui");
|
|
2283
2372
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
2284
2373
|
var dialogContentVariants = (0, import_class_variance_authority2.cva)(
|
|
2285
|
-
"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",
|
|
2374
|
+
"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",
|
|
2286
2375
|
{
|
|
2287
2376
|
variants: {
|
|
2288
2377
|
variant: {
|
|
@@ -2671,7 +2760,7 @@ function getFileSize(bytes) {
|
|
|
2671
2760
|
}
|
|
2672
2761
|
|
|
2673
2762
|
// hooks/use-file-upload.ts
|
|
2674
|
-
var
|
|
2763
|
+
var import_react5 = require("react");
|
|
2675
2764
|
var useFileUpload = (options = {}) => {
|
|
2676
2765
|
const {
|
|
2677
2766
|
maxFiles = Number.POSITIVE_INFINITY,
|
|
@@ -2683,7 +2772,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2683
2772
|
onFilesAdded,
|
|
2684
2773
|
onError
|
|
2685
2774
|
} = options;
|
|
2686
|
-
const [state, setState] = (0,
|
|
2775
|
+
const [state, setState] = (0, import_react5.useState)({
|
|
2687
2776
|
files: initialFiles.map((file) => ({
|
|
2688
2777
|
file,
|
|
2689
2778
|
id: file.id,
|
|
@@ -2692,8 +2781,8 @@ var useFileUpload = (options = {}) => {
|
|
|
2692
2781
|
isDragging: false,
|
|
2693
2782
|
errors: []
|
|
2694
2783
|
});
|
|
2695
|
-
const inputRef = (0,
|
|
2696
|
-
(0,
|
|
2784
|
+
const inputRef = (0, import_react5.useRef)(null);
|
|
2785
|
+
(0, import_react5.useEffect)(() => {
|
|
2697
2786
|
return () => {
|
|
2698
2787
|
state.files.forEach((file) => {
|
|
2699
2788
|
if (file.preview && file.file instanceof File) {
|
|
@@ -2702,7 +2791,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2702
2791
|
});
|
|
2703
2792
|
};
|
|
2704
2793
|
}, [state.files]);
|
|
2705
|
-
const validateFile = (0,
|
|
2794
|
+
const validateFile = (0, import_react5.useCallback)(
|
|
2706
2795
|
(file) => {
|
|
2707
2796
|
if (file.size > maxSize) {
|
|
2708
2797
|
return `File "${file.name}" exceeds the maximum size of ${getFileSize(maxSize)}.`;
|
|
@@ -2729,19 +2818,19 @@ var useFileUpload = (options = {}) => {
|
|
|
2729
2818
|
},
|
|
2730
2819
|
[accept, maxSize]
|
|
2731
2820
|
);
|
|
2732
|
-
const createPreview = (0,
|
|
2821
|
+
const createPreview = (0, import_react5.useCallback)((file) => {
|
|
2733
2822
|
if (file instanceof File) {
|
|
2734
2823
|
return URL.createObjectURL(file);
|
|
2735
2824
|
}
|
|
2736
2825
|
return file.url;
|
|
2737
2826
|
}, []);
|
|
2738
|
-
const generateUniqueId = (0,
|
|
2827
|
+
const generateUniqueId = (0, import_react5.useCallback)((file) => {
|
|
2739
2828
|
if (file instanceof File) {
|
|
2740
2829
|
return `${file.name}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
2741
2830
|
}
|
|
2742
2831
|
return file.id.toString();
|
|
2743
2832
|
}, []);
|
|
2744
|
-
const clearFiles = (0,
|
|
2833
|
+
const clearFiles = (0, import_react5.useCallback)(() => {
|
|
2745
2834
|
setState((prev) => {
|
|
2746
2835
|
for (const file of prev.files) {
|
|
2747
2836
|
if (file.preview && file.file instanceof File && file.file.type.startsWith("image/")) {
|
|
@@ -2759,7 +2848,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2759
2848
|
return newState;
|
|
2760
2849
|
});
|
|
2761
2850
|
}, [onFilesChange]);
|
|
2762
|
-
const addFiles = (0,
|
|
2851
|
+
const addFiles = (0, import_react5.useCallback)(
|
|
2763
2852
|
(newFiles) => {
|
|
2764
2853
|
if (!newFiles || newFiles.length === 0) return;
|
|
2765
2854
|
const newFilesArray = Array.from(newFiles);
|
|
@@ -2834,7 +2923,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2834
2923
|
onError
|
|
2835
2924
|
]
|
|
2836
2925
|
);
|
|
2837
|
-
const removeFile = (0,
|
|
2926
|
+
const removeFile = (0, import_react5.useCallback)(
|
|
2838
2927
|
(id) => {
|
|
2839
2928
|
setState((prev) => {
|
|
2840
2929
|
const fileToRemove = prev.files.find((file) => file.id === id);
|
|
@@ -2851,17 +2940,17 @@ var useFileUpload = (options = {}) => {
|
|
|
2851
2940
|
},
|
|
2852
2941
|
[onFilesChange]
|
|
2853
2942
|
);
|
|
2854
|
-
const clearErrors = (0,
|
|
2943
|
+
const clearErrors = (0, import_react5.useCallback)(() => {
|
|
2855
2944
|
setState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
2856
2945
|
errors: []
|
|
2857
2946
|
}));
|
|
2858
2947
|
}, []);
|
|
2859
|
-
const handleDragEnter = (0,
|
|
2948
|
+
const handleDragEnter = (0, import_react5.useCallback)((e) => {
|
|
2860
2949
|
e.preventDefault();
|
|
2861
2950
|
e.stopPropagation();
|
|
2862
2951
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { isDragging: true }));
|
|
2863
2952
|
}, []);
|
|
2864
|
-
const handleDragLeave = (0,
|
|
2953
|
+
const handleDragLeave = (0, import_react5.useCallback)((e) => {
|
|
2865
2954
|
e.preventDefault();
|
|
2866
2955
|
e.stopPropagation();
|
|
2867
2956
|
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
@@ -2869,11 +2958,11 @@ var useFileUpload = (options = {}) => {
|
|
|
2869
2958
|
}
|
|
2870
2959
|
setState((prev) => __spreadProps(__spreadValues({}, prev), { isDragging: false }));
|
|
2871
2960
|
}, []);
|
|
2872
|
-
const handleDragOver = (0,
|
|
2961
|
+
const handleDragOver = (0, import_react5.useCallback)((e) => {
|
|
2873
2962
|
e.preventDefault();
|
|
2874
2963
|
e.stopPropagation();
|
|
2875
2964
|
}, []);
|
|
2876
|
-
const handleDrop = (0,
|
|
2965
|
+
const handleDrop = (0, import_react5.useCallback)(
|
|
2877
2966
|
(e) => {
|
|
2878
2967
|
var _a;
|
|
2879
2968
|
e.preventDefault();
|
|
@@ -2893,7 +2982,7 @@ var useFileUpload = (options = {}) => {
|
|
|
2893
2982
|
},
|
|
2894
2983
|
[addFiles, multiple]
|
|
2895
2984
|
);
|
|
2896
|
-
const handleFileChange = (0,
|
|
2985
|
+
const handleFileChange = (0, import_react5.useCallback)(
|
|
2897
2986
|
(e) => {
|
|
2898
2987
|
if (e.target.files && e.target.files.length > 0) {
|
|
2899
2988
|
addFiles(e.target.files);
|
|
@@ -2901,12 +2990,12 @@ var useFileUpload = (options = {}) => {
|
|
|
2901
2990
|
},
|
|
2902
2991
|
[addFiles]
|
|
2903
2992
|
);
|
|
2904
|
-
const openFileDialog = (0,
|
|
2993
|
+
const openFileDialog = (0, import_react5.useCallback)(() => {
|
|
2905
2994
|
if (inputRef.current) {
|
|
2906
2995
|
inputRef.current.click();
|
|
2907
2996
|
}
|
|
2908
2997
|
}, []);
|
|
2909
|
-
const getInputProps = (0,
|
|
2998
|
+
const getInputProps = (0, import_react5.useCallback)(
|
|
2910
2999
|
(props = {}) => {
|
|
2911
3000
|
var _a;
|
|
2912
3001
|
return __spreadProps(__spreadValues({}, props), {
|
|
@@ -3146,9 +3235,9 @@ function UploadCloudIcon(props) {
|
|
|
3146
3235
|
}
|
|
3147
3236
|
|
|
3148
3237
|
// components/ui/close-button.tsx
|
|
3149
|
-
var
|
|
3238
|
+
var import_react6 = require("react");
|
|
3150
3239
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
3151
|
-
var CloseButton = (0,
|
|
3240
|
+
var CloseButton = (0, import_react6.forwardRef)(
|
|
3152
3241
|
(_a, ref) => {
|
|
3153
3242
|
var _b = _a, { className, iconClassName, label = "Close" } = _b, props = __objRest(_b, ["className", "iconClassName", "label"]);
|
|
3154
3243
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
@@ -3178,11 +3267,11 @@ var CloseButton = (0, import_react5.forwardRef)(
|
|
|
3178
3267
|
CloseButton.displayName = "CloseButton";
|
|
3179
3268
|
|
|
3180
3269
|
// components/cards/image-card.tsx
|
|
3181
|
-
var
|
|
3270
|
+
var import_react7 = require("react");
|
|
3182
3271
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
3183
3272
|
function ImageCard({ file }) {
|
|
3184
3273
|
var _a;
|
|
3185
|
-
const [hasError, setHasError] = (0,
|
|
3274
|
+
const [hasError, setHasError] = (0, import_react7.useState)(false);
|
|
3186
3275
|
const imageSrc = file.previewUrl || file.url;
|
|
3187
3276
|
if (imageSrc && !hasError) {
|
|
3188
3277
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
@@ -3207,10 +3296,10 @@ function ImageCardMetadata({ file }) {
|
|
|
3207
3296
|
}
|
|
3208
3297
|
|
|
3209
3298
|
// components/cards/video-card.tsx
|
|
3210
|
-
var
|
|
3299
|
+
var import_react8 = require("react");
|
|
3211
3300
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
3212
3301
|
function VideoCard({ file, className }) {
|
|
3213
|
-
const [hasError, setHasError] = (0,
|
|
3302
|
+
const [hasError, setHasError] = (0, import_react8.useState)(false);
|
|
3214
3303
|
if (file.previewUrl && !hasError) {
|
|
3215
3304
|
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "relative w-full h-full", children: [
|
|
3216
3305
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
@@ -3361,7 +3450,7 @@ function UploadModal() {
|
|
|
3361
3450
|
} = useFileManager();
|
|
3362
3451
|
const acceptString = fileTypesToAccept(allowedFileTypes);
|
|
3363
3452
|
const fileTypesDescription = getFileTypesDescription(allowedFileTypes);
|
|
3364
|
-
const [uploadItems, setUploadItems] = (0,
|
|
3453
|
+
const [uploadItems, setUploadItems] = (0, import_react9.useState)([]);
|
|
3365
3454
|
const [
|
|
3366
3455
|
{ isDragging, errors },
|
|
3367
3456
|
{
|
|
@@ -3466,7 +3555,7 @@ function UploadModal() {
|
|
|
3466
3555
|
"div",
|
|
3467
3556
|
{
|
|
3468
3557
|
className: cn(
|
|
3469
|
-
"relative rounded-
|
|
3558
|
+
"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",
|
|
3470
3559
|
isDragging ? "border-primary bg-primary/5" : "border-muted-foreground/25 hover:border-muted-foreground/50"
|
|
3471
3560
|
),
|
|
3472
3561
|
onDragEnter: handleDragEnter,
|
|
@@ -3521,8 +3610,8 @@ function UploadModal() {
|
|
|
3521
3610
|
iconClassName: "size-3"
|
|
3522
3611
|
}
|
|
3523
3612
|
),
|
|
3524
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "relative overflow-hidden rounded-lg border bg-card transition-colors", children: [
|
|
3525
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "relative aspect-square bg-muted border-
|
|
3613
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "relative overflow-hidden rounded-lg border border-muted-foreground/25 bg-card transition-colors", children: [
|
|
3614
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "relative aspect-square bg-muted border-muted-foreground/25", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "w-[75%] h-[75%] flex items-center justify-center", children: fileItem.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "relative w-full h-full flex items-center justify-center", children: [
|
|
3526
3615
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("svg", { className: "size-12 -rotate-90 absolute", viewBox: "0 0 48 48", children: [
|
|
3527
3616
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
3528
3617
|
"circle",
|
|
@@ -3594,7 +3683,7 @@ function UploadModal() {
|
|
|
3594
3683
|
}
|
|
3595
3684
|
|
|
3596
3685
|
// components/modals/create-folder.tsx
|
|
3597
|
-
var
|
|
3686
|
+
var import_react10 = require("react");
|
|
3598
3687
|
|
|
3599
3688
|
// components/ui/input.tsx
|
|
3600
3689
|
var import_class_variance_authority4 = require("class-variance-authority");
|
|
@@ -3742,7 +3831,7 @@ function CreateFolderModal() {
|
|
|
3742
3831
|
folderToRename,
|
|
3743
3832
|
setFolderToRename
|
|
3744
3833
|
} = useFileManager();
|
|
3745
|
-
const [editedName, setEditedName] = (0,
|
|
3834
|
+
const [editedName, setEditedName] = (0, import_react10.useState)(null);
|
|
3746
3835
|
const isRenameMode = isRenameFolderModalOpen;
|
|
3747
3836
|
const isOpen = isCreateFolderModalOpen || isRenameFolderModalOpen;
|
|
3748
3837
|
const defaultFolderName = isRenameMode && folderToRename ? folderToRename.name : "";
|
|
@@ -3821,7 +3910,7 @@ function CreateFolderModal() {
|
|
|
3821
3910
|
}
|
|
3822
3911
|
|
|
3823
3912
|
// components/modals/move-modal.tsx
|
|
3824
|
-
var
|
|
3913
|
+
var import_react12 = require("react");
|
|
3825
3914
|
|
|
3826
3915
|
// lib/truncate-name.ts
|
|
3827
3916
|
function middleTruncate(text, maxLength = 30) {
|
|
@@ -3832,16 +3921,16 @@ function middleTruncate(text, maxLength = 30) {
|
|
|
3832
3921
|
}
|
|
3833
3922
|
|
|
3834
3923
|
// hooks/use-intersection-observer.ts
|
|
3835
|
-
var
|
|
3924
|
+
var import_react11 = require("react");
|
|
3836
3925
|
function useIntersectionObserver({
|
|
3837
3926
|
threshold = 0,
|
|
3838
3927
|
root = null,
|
|
3839
3928
|
rootMargin = "0%"
|
|
3840
3929
|
} = {}) {
|
|
3841
|
-
const [entry, setEntry] = (0,
|
|
3842
|
-
const [node, setNode] = (0,
|
|
3843
|
-
const observer = (0,
|
|
3844
|
-
(0,
|
|
3930
|
+
const [entry, setEntry] = (0, import_react11.useState)();
|
|
3931
|
+
const [node, setNode] = (0, import_react11.useState)(null);
|
|
3932
|
+
const observer = (0, import_react11.useRef)(null);
|
|
3933
|
+
(0, import_react11.useEffect)(() => {
|
|
3845
3934
|
if (observer.current) {
|
|
3846
3935
|
observer.current.disconnect();
|
|
3847
3936
|
}
|
|
@@ -3876,7 +3965,7 @@ function FolderTreeItem({
|
|
|
3876
3965
|
treeState
|
|
3877
3966
|
}) {
|
|
3878
3967
|
var _a;
|
|
3879
|
-
const [isOpen, setIsOpen] = (0,
|
|
3968
|
+
const [isOpen, setIsOpen] = (0, import_react12.useState)(false);
|
|
3880
3969
|
const hasChildren = ((_a = folder.folderCount) != null ? _a : 0) > 0;
|
|
3881
3970
|
const isSelected = selectedFolderId === folder.id;
|
|
3882
3971
|
const isDisabled = disabledFolderIds.includes(folder.id);
|
|
@@ -3889,7 +3978,7 @@ function FolderTreeItem({
|
|
|
3889
3978
|
rootMargin: "100px"
|
|
3890
3979
|
});
|
|
3891
3980
|
const hasMore = pagination && pagination.currentPage < pagination.totalPages;
|
|
3892
|
-
(0,
|
|
3981
|
+
(0, import_react12.useEffect)(() => {
|
|
3893
3982
|
if (isOpen && (entry == null ? void 0 : entry.isIntersecting) && hasMore && !isLoading) {
|
|
3894
3983
|
const nextPage = ((pagination == null ? void 0 : pagination.currentPage) || 1) + 1;
|
|
3895
3984
|
onLoadChildren(folder.id, nextPage);
|
|
@@ -3977,15 +4066,15 @@ function MoveModal() {
|
|
|
3977
4066
|
bulkMove,
|
|
3978
4067
|
provider
|
|
3979
4068
|
} = useFileManager();
|
|
3980
|
-
const [targetFolderId, setTargetFolderId] = (0,
|
|
3981
|
-
const [treeState, setTreeState] = (0,
|
|
4069
|
+
const [targetFolderId, setTargetFolderId] = (0, import_react12.useState)(void 0);
|
|
4070
|
+
const [treeState, setTreeState] = (0, import_react12.useState)({
|
|
3982
4071
|
folders: /* @__PURE__ */ new Map(),
|
|
3983
4072
|
loading: /* @__PURE__ */ new Set(),
|
|
3984
4073
|
loaded: /* @__PURE__ */ new Set(),
|
|
3985
4074
|
pagination: /* @__PURE__ */ new Map()
|
|
3986
4075
|
});
|
|
3987
|
-
const fetchingRef = (0,
|
|
3988
|
-
const hasInitializedRef = (0,
|
|
4076
|
+
const fetchingRef = (0, import_react12.useRef)(/* @__PURE__ */ new Set());
|
|
4077
|
+
const hasInitializedRef = (0, import_react12.useRef)(false);
|
|
3989
4078
|
const { ref: rootObserverRef, entry: rootEntry } = useIntersectionObserver({
|
|
3990
4079
|
threshold: 0.1,
|
|
3991
4080
|
rootMargin: "100px"
|
|
@@ -3995,7 +4084,7 @@ function MoveModal() {
|
|
|
3995
4084
|
const isRootLoading = treeState.loading.has(null);
|
|
3996
4085
|
const disabledFolderIds = selectedFolders.map((f) => f.id);
|
|
3997
4086
|
const rootFolders = treeState.folders.get(null) || [];
|
|
3998
|
-
const loadFolders = (0,
|
|
4087
|
+
const loadFolders = (0, import_react12.useCallback)(async (folderId, page = 1) => {
|
|
3999
4088
|
if (fetchingRef.current.has(folderId)) return;
|
|
4000
4089
|
fetchingRef.current.add(folderId);
|
|
4001
4090
|
setTreeState((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
@@ -4035,7 +4124,7 @@ function MoveModal() {
|
|
|
4035
4124
|
fetchingRef.current.delete(folderId);
|
|
4036
4125
|
}
|
|
4037
4126
|
}, [provider]);
|
|
4038
|
-
(0,
|
|
4127
|
+
(0, import_react12.useEffect)(() => {
|
|
4039
4128
|
if (isMoveFileModalOpen) {
|
|
4040
4129
|
if (!hasInitializedRef.current) {
|
|
4041
4130
|
hasInitializedRef.current = true;
|
|
@@ -4045,7 +4134,7 @@ function MoveModal() {
|
|
|
4045
4134
|
hasInitializedRef.current = false;
|
|
4046
4135
|
}
|
|
4047
4136
|
}, [isMoveFileModalOpen, loadFolders]);
|
|
4048
|
-
(0,
|
|
4137
|
+
(0, import_react12.useEffect)(() => {
|
|
4049
4138
|
if (isMoveFileModalOpen && (rootEntry == null ? void 0 : rootEntry.isIntersecting) && rootHasMore && !isRootLoading) {
|
|
4050
4139
|
const nextPage = ((rootPagination == null ? void 0 : rootPagination.currentPage) || 1) + 1;
|
|
4051
4140
|
loadFolders(null, nextPage);
|
|
@@ -4141,7 +4230,7 @@ function MoveModal() {
|
|
|
4141
4230
|
}
|
|
4142
4231
|
|
|
4143
4232
|
// components/modals/image-modal.tsx
|
|
4144
|
-
var
|
|
4233
|
+
var import_react15 = require("react");
|
|
4145
4234
|
|
|
4146
4235
|
// components/file-details/details-layout.tsx
|
|
4147
4236
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
@@ -4179,11 +4268,11 @@ function DetailsLayout({
|
|
|
4179
4268
|
|
|
4180
4269
|
// components/file-details/file-action-buttons.tsx
|
|
4181
4270
|
var import_sonner3 = require("sonner");
|
|
4182
|
-
var
|
|
4271
|
+
var import_react13 = require("react");
|
|
4183
4272
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
4184
4273
|
function FileDeleteButton({ file }) {
|
|
4185
4274
|
const { provider, setFileDetailsModalFile, refreshData } = useFileManager();
|
|
4186
|
-
const [deleting, setDeleting] = (0,
|
|
4275
|
+
const [deleting, setDeleting] = (0, import_react13.useState)(false);
|
|
4187
4276
|
const handleDelete = async () => {
|
|
4188
4277
|
setDeleting(true);
|
|
4189
4278
|
try {
|
|
@@ -4213,7 +4302,7 @@ function FileDeleteButton({ file }) {
|
|
|
4213
4302
|
);
|
|
4214
4303
|
}
|
|
4215
4304
|
function FileDownloadButton({ file }) {
|
|
4216
|
-
const [downloading, setDownloading] = (0,
|
|
4305
|
+
const [downloading, setDownloading] = (0, import_react13.useState)(false);
|
|
4217
4306
|
const handleDownload = async () => {
|
|
4218
4307
|
setDownloading(true);
|
|
4219
4308
|
try {
|
|
@@ -4245,7 +4334,7 @@ function FileDownloadButton({ file }) {
|
|
|
4245
4334
|
);
|
|
4246
4335
|
}
|
|
4247
4336
|
function FileCopyLinkButton({ file }) {
|
|
4248
|
-
const [copied, setCopied] = (0,
|
|
4337
|
+
const [copied, setCopied] = (0, import_react13.useState)(false);
|
|
4249
4338
|
const handleCopyLink = async () => {
|
|
4250
4339
|
try {
|
|
4251
4340
|
await navigator.clipboard.writeText(file.url);
|
|
@@ -4366,7 +4455,7 @@ function formatDuration(seconds) {
|
|
|
4366
4455
|
}
|
|
4367
4456
|
|
|
4368
4457
|
// components/ui/field.tsx
|
|
4369
|
-
var
|
|
4458
|
+
var import_react14 = require("react");
|
|
4370
4459
|
var import_class_variance_authority7 = require("class-variance-authority");
|
|
4371
4460
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
4372
4461
|
var fieldVariants = (0, import_class_variance_authority7.cva)(
|
|
@@ -4548,10 +4637,10 @@ function InputGroupInput(_a) {
|
|
|
4548
4637
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
4549
4638
|
function ImageModal({ file, onClose, onSave }) {
|
|
4550
4639
|
var _a;
|
|
4551
|
-
const [isSaving, setIsSaving] = (0,
|
|
4552
|
-
const [fileName, setFileName] = (0,
|
|
4553
|
-
const [alternativeText, setAlternativeText] = (0,
|
|
4554
|
-
const [caption, setCaption] = (0,
|
|
4640
|
+
const [isSaving, setIsSaving] = (0, import_react15.useState)(false);
|
|
4641
|
+
const [fileName, setFileName] = (0, import_react15.useState)(file.name);
|
|
4642
|
+
const [alternativeText, setAlternativeText] = (0, import_react15.useState)(file.alternativeText || "");
|
|
4643
|
+
const [caption, setCaption] = (0, import_react15.useState)(file.caption || "");
|
|
4555
4644
|
const handleSave = async () => {
|
|
4556
4645
|
setIsSaving(true);
|
|
4557
4646
|
try {
|
|
@@ -4674,13 +4763,13 @@ function ImageModal({ file, onClose, onSave }) {
|
|
|
4674
4763
|
}
|
|
4675
4764
|
|
|
4676
4765
|
// components/modals/video-modal.tsx
|
|
4677
|
-
var
|
|
4766
|
+
var import_react16 = require("react");
|
|
4678
4767
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
4679
4768
|
function VideoModal({ file, onClose, onSave }) {
|
|
4680
4769
|
var _a, _b, _c;
|
|
4681
|
-
const [isSaving, setIsSaving] = (0,
|
|
4682
|
-
const [fileName, setFileName] = (0,
|
|
4683
|
-
const [caption, setCaption] = (0,
|
|
4770
|
+
const [isSaving, setIsSaving] = (0, import_react16.useState)(false);
|
|
4771
|
+
const [fileName, setFileName] = (0, import_react16.useState)(file.name);
|
|
4772
|
+
const [caption, setCaption] = (0, import_react16.useState)(file.caption || "");
|
|
4684
4773
|
const handleSave = async () => {
|
|
4685
4774
|
setIsSaving(true);
|
|
4686
4775
|
try {
|
|
@@ -4781,13 +4870,13 @@ function VideoModal({ file, onClose, onSave }) {
|
|
|
4781
4870
|
}
|
|
4782
4871
|
|
|
4783
4872
|
// components/modals/audio-modal.tsx
|
|
4784
|
-
var
|
|
4873
|
+
var import_react17 = require("react");
|
|
4785
4874
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
4786
4875
|
function AudioModal({ file, onClose, onSave }) {
|
|
4787
4876
|
var _a, _b, _c;
|
|
4788
|
-
const [isSaving, setIsSaving] = (0,
|
|
4789
|
-
const [fileName, setFileName] = (0,
|
|
4790
|
-
const [caption, setCaption] = (0,
|
|
4877
|
+
const [isSaving, setIsSaving] = (0, import_react17.useState)(false);
|
|
4878
|
+
const [fileName, setFileName] = (0, import_react17.useState)(file.name);
|
|
4879
|
+
const [caption, setCaption] = (0, import_react17.useState)(file.caption || "");
|
|
4791
4880
|
const handleSave = async () => {
|
|
4792
4881
|
setIsSaving(true);
|
|
4793
4882
|
try {
|
|
@@ -4889,13 +4978,13 @@ function AudioModal({ file, onClose, onSave }) {
|
|
|
4889
4978
|
}
|
|
4890
4979
|
|
|
4891
4980
|
// components/modals/file-modal.tsx
|
|
4892
|
-
var
|
|
4981
|
+
var import_react18 = require("react");
|
|
4893
4982
|
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
4894
4983
|
function FileModal({ file, onClose, onSave }) {
|
|
4895
4984
|
var _a, _b, _c, _d;
|
|
4896
|
-
const [isSaving, setIsSaving] = (0,
|
|
4897
|
-
const [fileName, setFileName] = (0,
|
|
4898
|
-
const [description, setDescription] = (0,
|
|
4985
|
+
const [isSaving, setIsSaving] = (0, import_react18.useState)(false);
|
|
4986
|
+
const [fileName, setFileName] = (0, import_react18.useState)(file.name);
|
|
4987
|
+
const [description, setDescription] = (0, import_react18.useState)(((_a = file.metaData) == null ? void 0 : _a.description) || "");
|
|
4899
4988
|
const handleSave = async () => {
|
|
4900
4989
|
setIsSaving(true);
|
|
4901
4990
|
try {
|
|
@@ -5209,7 +5298,6 @@ function Skeleton(_a) {
|
|
|
5209
5298
|
}
|
|
5210
5299
|
|
|
5211
5300
|
// components/layout/header-navigation.tsx
|
|
5212
|
-
var import_navigation3 = require("next/navigation");
|
|
5213
5301
|
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
5214
5302
|
function HeaderNavigation() {
|
|
5215
5303
|
const {
|
|
@@ -5217,9 +5305,8 @@ function HeaderNavigation() {
|
|
|
5217
5305
|
handleFolderClick,
|
|
5218
5306
|
isLoading
|
|
5219
5307
|
} = useFileManager();
|
|
5220
|
-
const router = (0, import_navigation3.useRouter)();
|
|
5221
5308
|
const handleBackClick = () => {
|
|
5222
|
-
|
|
5309
|
+
history.back();
|
|
5223
5310
|
};
|
|
5224
5311
|
if (isLoading) {
|
|
5225
5312
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex item-center w-full", children: [
|
|
@@ -5326,7 +5413,7 @@ function DropdownMenuSeparator(_a) {
|
|
|
5326
5413
|
}
|
|
5327
5414
|
|
|
5328
5415
|
// components/modals/search-modal.tsx
|
|
5329
|
-
var
|
|
5416
|
+
var import_react20 = require("react");
|
|
5330
5417
|
|
|
5331
5418
|
// components/ui/command.tsx
|
|
5332
5419
|
var import_cmdk = require("cmdk");
|
|
@@ -5415,10 +5502,10 @@ function CommandItem(_a) {
|
|
|
5415
5502
|
}
|
|
5416
5503
|
|
|
5417
5504
|
// hooks/use-debounced-value.ts
|
|
5418
|
-
var
|
|
5505
|
+
var import_react19 = require("react");
|
|
5419
5506
|
function useDebouncedValue(value, delay2 = 500) {
|
|
5420
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
5421
|
-
(0,
|
|
5507
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react19.useState)(value);
|
|
5508
|
+
(0, import_react19.useEffect)(() => {
|
|
5422
5509
|
const handler = setTimeout(() => {
|
|
5423
5510
|
setDebouncedValue(value);
|
|
5424
5511
|
}, delay2);
|
|
@@ -5433,13 +5520,13 @@ function useDebouncedValue(value, delay2 = 500) {
|
|
|
5433
5520
|
var import_sonner4 = require("sonner");
|
|
5434
5521
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
5435
5522
|
function SearchDialog() {
|
|
5436
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
5437
|
-
const [fileResults, setFileResults] = (0,
|
|
5438
|
-
const [folderResults, setFolderResults] = (0,
|
|
5439
|
-
const [loading, setLoading] = (0,
|
|
5523
|
+
const [searchQuery, setSearchQuery] = (0, import_react20.useState)("");
|
|
5524
|
+
const [fileResults, setFileResults] = (0, import_react20.useState)([]);
|
|
5525
|
+
const [folderResults, setFolderResults] = (0, import_react20.useState)([]);
|
|
5526
|
+
const [loading, setLoading] = (0, import_react20.useState)(false);
|
|
5440
5527
|
const { provider, handleFolderClick, handleClearSelection, isSearchModalOpen, setIsSearchModalOpen, setFileDetailsModalFile } = useFileManager();
|
|
5441
5528
|
const debouncedSearchQuery = useDebouncedValue(searchQuery, 300);
|
|
5442
|
-
const doSearch = (0,
|
|
5529
|
+
const doSearch = (0, import_react20.useCallback)(async (q) => {
|
|
5443
5530
|
setLoading(true);
|
|
5444
5531
|
try {
|
|
5445
5532
|
const [files, folders] = await Promise.all([
|
|
@@ -5459,7 +5546,7 @@ function SearchDialog() {
|
|
|
5459
5546
|
setLoading(false);
|
|
5460
5547
|
}
|
|
5461
5548
|
}, [provider]);
|
|
5462
|
-
(0,
|
|
5549
|
+
(0, import_react20.useEffect)(() => {
|
|
5463
5550
|
if (isSearchModalOpen && debouncedSearchQuery.length > 0) {
|
|
5464
5551
|
doSearch(debouncedSearchQuery);
|
|
5465
5552
|
} else {
|
|
@@ -5635,7 +5722,7 @@ function CreateFolderAction() {
|
|
|
5635
5722
|
}
|
|
5636
5723
|
|
|
5637
5724
|
// components/layout/theme-toggle.tsx
|
|
5638
|
-
var
|
|
5725
|
+
var import_react21 = require("react");
|
|
5639
5726
|
|
|
5640
5727
|
// components/icons/theme.tsx
|
|
5641
5728
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
@@ -5682,8 +5769,8 @@ function MoonIcon(props) {
|
|
|
5682
5769
|
// components/layout/theme-toggle.tsx
|
|
5683
5770
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
5684
5771
|
function ThemeToggle() {
|
|
5685
|
-
const [isDark, setIsDark] = (0,
|
|
5686
|
-
(0,
|
|
5772
|
+
const [isDark, setIsDark] = (0, import_react21.useState)(false);
|
|
5773
|
+
(0, import_react21.useEffect)(() => {
|
|
5687
5774
|
const saved = localStorage.getItem("theme");
|
|
5688
5775
|
const shouldBeDark = saved === "dark";
|
|
5689
5776
|
setIsDark(shouldBeDark);
|
|
@@ -5841,7 +5928,7 @@ function ModalResponsiveHeaderActions({ onSearchClick }) {
|
|
|
5841
5928
|
}
|
|
5842
5929
|
|
|
5843
5930
|
// components/cards/card-context-menu.tsx
|
|
5844
|
-
var
|
|
5931
|
+
var import_react22 = __toESM(require("react"), 1);
|
|
5845
5932
|
|
|
5846
5933
|
// components/ui/context-menu.tsx
|
|
5847
5934
|
var ContextMenuPrimitive = __toESM(require("@radix-ui/react-context-menu"), 1);
|
|
@@ -5917,7 +6004,7 @@ function CardContextMenu({
|
|
|
5917
6004
|
const MenuItemComponent = isDropdown ? DropdownMenuItem : ContextMenuItem;
|
|
5918
6005
|
const SeparatorComponent = isDropdown ? DropdownMenuSeparator : ContextMenuSeparator;
|
|
5919
6006
|
const nextItemIsDestructive = index < menuItems.length - 1 && menuItems[index + 1].variant === "destructive";
|
|
5920
|
-
return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
|
|
6007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_react22.default.Fragment, { children: [
|
|
5921
6008
|
/* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(
|
|
5922
6009
|
MenuItemComponent,
|
|
5923
6010
|
{
|
|
@@ -6275,9 +6362,9 @@ function UnifiedGrid() {
|
|
|
6275
6362
|
}
|
|
6276
6363
|
|
|
6277
6364
|
// components/error-boundary.tsx
|
|
6278
|
-
var
|
|
6365
|
+
var import_react23 = require("react");
|
|
6279
6366
|
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
6280
|
-
var FileManagerErrorBoundary = class extends
|
|
6367
|
+
var FileManagerErrorBoundary = class extends import_react23.Component {
|
|
6281
6368
|
constructor(props) {
|
|
6282
6369
|
super(props);
|
|
6283
6370
|
this.handleReset = () => {
|
|
@@ -6321,7 +6408,7 @@ var FileManagerErrorBoundary = class extends import_react22.Component {
|
|
|
6321
6408
|
};
|
|
6322
6409
|
|
|
6323
6410
|
// components/keyboard-shortcuts.tsx
|
|
6324
|
-
var
|
|
6411
|
+
var import_react24 = require("react");
|
|
6325
6412
|
function KeyboardShortcuts() {
|
|
6326
6413
|
const {
|
|
6327
6414
|
handleSelectAllGlobal,
|
|
@@ -6334,7 +6421,7 @@ function KeyboardShortcuts() {
|
|
|
6334
6421
|
isSearchModalOpen,
|
|
6335
6422
|
setIsSearchModalOpen
|
|
6336
6423
|
} = useFileManager();
|
|
6337
|
-
(0,
|
|
6424
|
+
(0, import_react24.useEffect)(() => {
|
|
6338
6425
|
const handleKeyDown = (e) => {
|
|
6339
6426
|
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
|
|
6340
6427
|
e.preventDefault();
|
|
@@ -6370,7 +6457,7 @@ function FileManager(props) {
|
|
|
6370
6457
|
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(FileManagerErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(FileManagerComposition.Page, __spreadProps(__spreadValues({}, props), { children: [
|
|
6371
6458
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(KeyboardShortcuts, {}),
|
|
6372
6459
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "flex h-full relative pb-12 overflow-hidden bg-background text-foreground", children: [
|
|
6373
|
-
/* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "flex-1 flex w-full flex-col", children: [
|
|
6460
|
+
/* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "flex-1 flex w-full flex-col overflow-y-auto", children: [
|
|
6374
6461
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(FileManagerComposition.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)("div", { className: "flex w-full justify-between gap-2", children: [
|
|
6375
6462
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(HeaderNavigation, {}),
|
|
6376
6463
|
/* @__PURE__ */ (0, import_jsx_runtime90.jsx)(ResponsiveHeaderActions, {})
|
|
@@ -6385,7 +6472,7 @@ function FileManager(props) {
|
|
|
6385
6472
|
}
|
|
6386
6473
|
|
|
6387
6474
|
// components/file-manager-modal.tsx
|
|
6388
|
-
var
|
|
6475
|
+
var import_react25 = require("react");
|
|
6389
6476
|
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
6390
6477
|
function FileManagerModal(_a) {
|
|
6391
6478
|
var _b = _a, {
|
|
@@ -6399,14 +6486,14 @@ function FileManagerModal(_a) {
|
|
|
6399
6486
|
}
|
|
6400
6487
|
function ModalContent({ onClose }) {
|
|
6401
6488
|
const { updateSearchQuery } = useFileManager();
|
|
6402
|
-
const [isSearchActive, setIsSearchActive] = (0,
|
|
6403
|
-
const [searchInput, setSearchInput] = (0,
|
|
6404
|
-
const searchInputRef = (0,
|
|
6489
|
+
const [isSearchActive, setIsSearchActive] = (0, import_react25.useState)(false);
|
|
6490
|
+
const [searchInput, setSearchInput] = (0, import_react25.useState)("");
|
|
6491
|
+
const searchInputRef = (0, import_react25.useRef)(null);
|
|
6405
6492
|
const debouncedSearch = useDebouncedValue(searchInput, 300);
|
|
6406
|
-
(0,
|
|
6493
|
+
(0, import_react25.useEffect)(() => {
|
|
6407
6494
|
updateSearchQuery(debouncedSearch);
|
|
6408
6495
|
}, [debouncedSearch, updateSearchQuery]);
|
|
6409
|
-
(0,
|
|
6496
|
+
(0, import_react25.useEffect)(() => {
|
|
6410
6497
|
if (isSearchActive && searchInputRef.current) {
|
|
6411
6498
|
searchInputRef.current.focus();
|
|
6412
6499
|
}
|