@noya-app/noya-file-explorer 0.0.14 → 0.0.15
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/.eslintrc.js +1 -5
- package/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +11 -0
- package/dist/index.css +43 -25
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/MediaCollection.tsx +14 -4
- package/src/formatByteSize.ts +8 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-file-explorer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"dev": "npm run build:main -- --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@noya-app/noya-designsystem": "0.1.
|
|
24
|
-
"@noya-app/noya-icons": "0.1.
|
|
25
|
-
"@noya-app/noya-multiplayer-react": "0.1.
|
|
23
|
+
"@noya-app/noya-designsystem": "0.1.63",
|
|
24
|
+
"@noya-app/noya-icons": "0.1.11",
|
|
25
|
+
"@noya-app/noya-multiplayer-react": "0.1.62",
|
|
26
26
|
"@noya-app/noya-keymap": "0.1.3",
|
|
27
|
-
"@noya-app/react-utils": "0.1.
|
|
27
|
+
"@noya-app/react-utils": "0.1.23",
|
|
28
28
|
"@noya-app/noya-utils": "0.1.5",
|
|
29
29
|
"@noya-app/noya-schemas": "0.1.5",
|
|
30
30
|
"imfs": "^0.1.0",
|
package/src/MediaCollection.tsx
CHANGED
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
|
|
64
64
|
import { path } from "imfs";
|
|
65
65
|
import React from "react";
|
|
66
|
+
import { formatByteSize } from "./formatByteSize";
|
|
66
67
|
import {
|
|
67
68
|
deleteMediaItems,
|
|
68
69
|
ExpandedMap,
|
|
@@ -239,6 +240,7 @@ type MediaCollectionProps = {
|
|
|
239
240
|
| "scrollable"
|
|
240
241
|
| "renderEmptyState"
|
|
241
242
|
| "sharedDragProps"
|
|
243
|
+
| "onClickItem"
|
|
242
244
|
>;
|
|
243
245
|
|
|
244
246
|
export const MediaCollection = memo(
|
|
@@ -269,6 +271,7 @@ export const MediaCollection = memo(
|
|
|
269
271
|
sortable = false,
|
|
270
272
|
renderEmptyState,
|
|
271
273
|
sharedDragProps,
|
|
274
|
+
onClickItem,
|
|
272
275
|
},
|
|
273
276
|
ref
|
|
274
277
|
) {
|
|
@@ -371,8 +374,7 @@ export const MediaCollection = memo(
|
|
|
371
374
|
}
|
|
372
375
|
}, [initialExpanded]);
|
|
373
376
|
|
|
374
|
-
|
|
375
|
-
const handleExpanded = useCallback(
|
|
377
|
+
const getExpanded = useCallback(
|
|
376
378
|
(item: MediaItem) => {
|
|
377
379
|
if (!expandable) return undefined;
|
|
378
380
|
if (item.kind !== "folder") return undefined;
|
|
@@ -477,6 +479,8 @@ export const MediaCollection = memo(
|
|
|
477
479
|
[media, tree, setMedia]
|
|
478
480
|
);
|
|
479
481
|
|
|
482
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
483
|
+
|
|
480
484
|
const handleUpload = useCallback(
|
|
481
485
|
async (selectedId: string) => {
|
|
482
486
|
try {
|
|
@@ -496,6 +500,8 @@ export const MediaCollection = memo(
|
|
|
496
500
|
};
|
|
497
501
|
});
|
|
498
502
|
|
|
503
|
+
setIsUploading(true);
|
|
504
|
+
|
|
499
505
|
const newMediaMap = await Promise.all(uploadPromises);
|
|
500
506
|
|
|
501
507
|
setMedia(
|
|
@@ -509,6 +515,8 @@ export const MediaCollection = memo(
|
|
|
509
515
|
);
|
|
510
516
|
} catch (error) {
|
|
511
517
|
console.error("Failed to upload files:", error);
|
|
518
|
+
} finally {
|
|
519
|
+
setIsUploading(false);
|
|
512
520
|
}
|
|
513
521
|
},
|
|
514
522
|
[tree.idToPathMap, setMedia, media, assetManager]
|
|
@@ -771,6 +779,7 @@ export const MediaCollection = memo(
|
|
|
771
779
|
<FileExplorerUploadButton
|
|
772
780
|
showUploadButton={showUploadButton}
|
|
773
781
|
onUpload={() => handleUpload(rootMediaItem.id)}
|
|
782
|
+
isUploading={isUploading}
|
|
774
783
|
>
|
|
775
784
|
{right}
|
|
776
785
|
</FileExplorerUploadButton>
|
|
@@ -804,7 +813,7 @@ export const MediaCollection = memo(
|
|
|
804
813
|
return "Enter file name";
|
|
805
814
|
}
|
|
806
815
|
}}
|
|
807
|
-
getExpanded={
|
|
816
|
+
getExpanded={getExpanded}
|
|
808
817
|
setExpanded={handleSetExpanded}
|
|
809
818
|
getRenamable={(item) => {
|
|
810
819
|
if (item.id === rootMediaItem.id) return false;
|
|
@@ -814,6 +823,7 @@ export const MediaCollection = memo(
|
|
|
814
823
|
menuItems={assetContextMenuItems}
|
|
815
824
|
onSelectMenuItem={handleMenuAction}
|
|
816
825
|
onSelectionChange={setSelectedIds}
|
|
826
|
+
onClickItem={onClickItem}
|
|
817
827
|
onDoubleClickItem={onDoubleClickItem}
|
|
818
828
|
onRename={onRename}
|
|
819
829
|
renamable={renamable}
|
|
@@ -831,7 +841,7 @@ export const MediaCollection = memo(
|
|
|
831
841
|
if (!asset) return null;
|
|
832
842
|
return (
|
|
833
843
|
<FileExplorerDetail selected={selected} size={size}>
|
|
834
|
-
{(asset.size
|
|
844
|
+
{formatByteSize(asset.size)}
|
|
835
845
|
</FileExplorerDetail>
|
|
836
846
|
);
|
|
837
847
|
}}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const byteSizeUnits = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
2
|
+
|
|
3
|
+
export function formatByteSize(size: number) {
|
|
4
|
+
const unitIndex = Math.floor(Math.log(size) / Math.log(1024));
|
|
5
|
+
const unit = byteSizeUnits[unitIndex];
|
|
6
|
+
const value = size / Math.pow(1024, unitIndex);
|
|
7
|
+
return `${value.toFixed(1)} ${unit}`;
|
|
8
|
+
}
|