@unciatech/file-manager 0.0.1 → 0.0.2

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 CHANGED
@@ -23,12 +23,46 @@ It supports deep folder nesting, drag-and-drop file uploads, metadata management
23
23
 
24
24
  If you want to integrate this File Manager into your own Next.js or React application, follow this step-by-step guide.
25
25
 
26
- ### Step 1: Copy the Core Files
27
- Copy the `components`, `types`, `hooks`, `context`, and `providers` folders related to the file manager into your project's source directory (e.g., `src/`).
26
+ ### Step 1: Install the Package
27
+
28
+ Install the library via NPM:
29
+ ```bash
30
+ npm install @unciatech/file-manager
31
+ ```
32
+
33
+ **(Optional) Quick Start Scaffolding**
34
+ Instead of setting everything up manually, you can run our initialization script to immediately generate a working `FileManagerDemo.tsx` file inside your project!
35
+ ```bash
36
+ npx @unciatech/file-manager init
37
+ ```
38
+
39
+ **(CRITICAL) Configure Tailwind CSS:**
40
+ Because this library uses Tailwind CSS, you MUST tell your Tailwind compiler to scan the library components for utility classes, otherwise it will render with zero styles!
41
+
42
+ **For Tailwind v3 (`tailwind.config.ts`):**
43
+ ```typescript
44
+ import type { Config } from "tailwindcss";
45
+
46
+ const config: Config = {
47
+ content: [
48
+ // Your existing paths...
49
+ "./node_modules/@unciatech/file-manager/dist/**/*.js",
50
+ "./node_modules/@unciatech/file-manager/dist/**/*.mjs",
51
+ ],
52
+ // ...
53
+ };
54
+ export default config;
55
+ ```
56
+
57
+ **For Tailwind v4 (`globals.css`):**
58
+ ```css
59
+ @import "tailwindcss";
60
+ @source "../node_modules/@unciatech/file-manager/dist";
61
+ ```
28
62
 
29
63
  ### Step 2: Create your Custom API Provider
30
64
 
31
- The file manager is completely agnostic to your backend database. You simply need to create a class that implements the `IFileManagerProvider` interface.
65
+ The file manager is completely agnostic to your backend database. You simply need to create a class that implements the `IFileManagerProvider` interface.
32
66
 
33
67
  Here is an example of what your custom provider might look like, making real API calls to your backend using `fetch`:
34
68
 
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var l=Object.create;var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var f=(e,o,r,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of p(o))!g.call(e,n)&&n!==r&&c(e,n,{get:()=>o[n],enumerable:!(s=m(o,n))||s.enumerable});return e};var a=(e,o,r)=>(r=e!=null?l(d(e)):{},f(o||!e||!e.__esModule?c(r,"default",{value:e,enumerable:!0}):r,e));var t=a(require("fs")),i=a(require("path")),u=process.argv.slice(2);if(u[0]==="init"){console.log("\u{1F680} Initializing @unciatech/file-manager...");let e=`"use client";
3
+
4
+ import React from "react";
5
+ import { FileManagerProvider } from "@unciatech/file-manager";
6
+ import { FileManager } from "@unciatech/file-manager";
7
+ import { MockProvider } from "@unciatech/file-manager";
8
+
9
+ export default function FileManagerDemo() {
10
+ // Instantiate the mock provider for demonstration purposes
11
+ const mockProvider = new MockProvider();
12
+
13
+ return (
14
+ <div className="h-screen w-full">
15
+ <FileManagerProvider
16
+ mode="page"
17
+ selectionMode="multiple"
18
+ allowedFileTypes={["images", "videos", "audios", "files"]}
19
+ provider={mockProvider}
20
+ >
21
+ <FileManager />
22
+ </FileManagerProvider>
23
+ </div>
24
+ );
25
+ }
26
+ `,o=process.cwd();t.default.existsSync(i.default.join(process.cwd(),"components"))?o=i.default.join(process.cwd(),"components"):t.default.existsSync(i.default.join(process.cwd(),"src","components"))&&(o=i.default.join(process.cwd(),"src","components"));let r=i.default.join(o,"FileManagerDemo.tsx");t.default.existsSync(r)&&(console.error(`\u274C Error: ${r} already exists.`),process.exit(1));try{t.default.writeFileSync(r,e,"utf-8"),console.log(`\u2705 Success! Created ${r}`),console.log(""),console.log("You can now import and render <FileManagerDemo /> anywhere in your application."),console.log("Don't forget to configure your Tailwind CSS content to scan the library for styles!")}catch(s){console.error("\u274C Failed to create initialization file:",s),process.exit(1)}}else console.log("Usage: npx @unciatech/file-manager init");
package/dist/cli.mjs ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import r from"fs";import e from"path";var s=process.argv.slice(2);if(s[0]==="init"){console.log("\u{1F680} Initializing @unciatech/file-manager...");let n=`"use client";
3
+
4
+ import React from "react";
5
+ import { FileManagerProvider } from "@unciatech/file-manager";
6
+ import { FileManager } from "@unciatech/file-manager";
7
+ import { MockProvider } from "@unciatech/file-manager";
8
+
9
+ export default function FileManagerDemo() {
10
+ // Instantiate the mock provider for demonstration purposes
11
+ const mockProvider = new MockProvider();
12
+
13
+ return (
14
+ <div className="h-screen w-full">
15
+ <FileManagerProvider
16
+ mode="page"
17
+ selectionMode="multiple"
18
+ allowedFileTypes={["images", "videos", "audios", "files"]}
19
+ provider={mockProvider}
20
+ >
21
+ <FileManager />
22
+ </FileManagerProvider>
23
+ </div>
24
+ );
25
+ }
26
+ `,i=process.cwd();r.existsSync(e.join(process.cwd(),"components"))?i=e.join(process.cwd(),"components"):r.existsSync(e.join(process.cwd(),"src","components"))&&(i=e.join(process.cwd(),"src","components"));let o=e.join(i,"FileManagerDemo.tsx");r.existsSync(o)&&(console.error(`\u274C Error: ${o} already exists.`),process.exit(1));try{r.writeFileSync(o,n,"utf-8"),console.log(`\u2705 Success! Created ${o}`),console.log(""),console.log("You can now import and render <FileManagerDemo /> anywhere in your application."),console.log("Don't forget to configure your Tailwind CSS content to scan the library for styles!")}catch(t){console.error("\u274C Failed to create initialization file:",t),process.exit(1)}}else console.log("Usage: npx @unciatech/file-manager init");
package/dist/index.js CHANGED
@@ -113,4 +113,3 @@
113
113
  text-[13px] font-medium leading-[1.3] tracking-tight line-clamp-2 px-2.5 pb-[2px] rounded-[6px] transition-colors duration-100 break-words max-w-full
114
114
  ${t?"bg-[#2563EB] text-white antialiased shadow-sm":"text-[#374151] group-hover:text-black"}
115
115
  `,children:e.name}),(0,me.jsx)("div",{className:`flex items-center justify-center gap-1 mt-1 transition-opacity duration-200 ${t?"opacity-60":"opacity-100"}`,children:(0,me.jsxs)("span",{className:"text-[11px] text-blue-600 font-medium tracking-tight px-1.5 rounded-full",children:[e.fileCount," items"]})})]})]})})}var Ge=require("react/jsx-runtime");function mo(){let{files:e,folders:t,isLoading:a,handleFileClick:o,handleFolderClick:r,bulkDelete:i,mode:l,selectionMode:c,isInSelectionMode:s,selectedFiles:f,selectedFolders:m,currentFolder:b,setSelectedFiles:p,setSelectedFolders:y,setIsRenameFolderModalOpen:w,setIsMoveFileModalOpen:N,setFileDetailsModalFile:M,setFolderToRename:D}=O(),T=(()=>{if(!b)return 18;let h=b.folderCount||0,I=b.fileCount||0,Y=h+I;return Y>0?Y:18})();return a?(0,Ge.jsx)("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:Array.from({length:T}).map((h,I)=>(0,Ge.jsxs)("div",{className:"flex flex-col items-center justify-start w-full gap-2",children:[(0,Ge.jsx)("div",{className:"w-full aspect-square bg-gray-100 rounded-2xl animate-pulse"}),(0,Ge.jsxs)("div",{className:"flex flex-col items-center gap-1 w-full",children:[(0,Ge.jsx)("div",{className:"h-4 w-20 bg-gray-100 rounded animate-pulse"}),(0,Ge.jsx)("div",{className:"h-3 w-12 bg-gray-100 rounded animate-pulse"})]})]},I))}):(0,Ge.jsxs)("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:[t.map(h=>(0,Ge.jsx)(Gn,{folder:h,isSelected:m.some(I=>I.id===h.id),onSelect:r,onDelete:()=>i(),onRename:I=>{D(I),w(!0)},onMove:I=>{y([I]),p([]),N(!0)},selectionMode:c,mode:l,isInSelectionMode:s()},h.id)),e.map(h=>(0,Ge.jsx)(Vn,{file:h,isSelected:f.some(I=>I.id===h.id),onSelect:o,onDelete:()=>i(),onEdit:I=>{M(I)},onMove:I=>{p([I]),y([]),N(!0)},selectionMode:c,mode:l,isInSelectionMode:s()},h.id))]})}var Bn=require("react");var fo=require("lucide-react"),Me=require("react/jsx-runtime"),uo=class extends Bn.Component{constructor(a){super(a);this.handleReset=()=>{window.location.reload()};this.state={hasError:!1,error:null}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,o){console.error("FileManager Error Boundary caught an error:",a,o)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,Me.jsx)("div",{className:"flex items-center justify-center min-h-[400px] p-8 w-full h-full bg-slate-50/50 rounded-lg border border-dashed border-slate-200",children:(0,Me.jsxs)("div",{className:"text-center max-w-md flex flex-col items-center",children:[(0,Me.jsx)("div",{className:"bg-red-100 p-3 rounded-full mb-4",children:(0,Me.jsx)(fo.AlertCircle,{className:"size-8 text-red-600"})}),(0,Me.jsx)("h2",{className:"text-xl font-semibold text-slate-900 mb-2",children:"Something went wrong"}),(0,Me.jsx)("p",{className:"text-sm text-slate-500 mb-6",children:"The file manager encountered an unexpected error. Refreshing the page usually resolves this issue."}),this.state.error&&(0,Me.jsxs)("details",{className:"mb-6 text-left w-full border border-slate-200 rounded-lg overflow-hidden flex-col group",children:[(0,Me.jsx)("summary",{className:"cursor-pointer text-xs font-mono bg-slate-100 p-2 text-slate-600 hover:bg-slate-200 transition-colors",children:"View Technical Details"}),(0,Me.jsx)("div",{className:"p-3 bg-white",children:(0,Me.jsx)("pre",{className:"text-[10px] text-slate-600 font-mono whitespace-pre-wrap word-break-all max-h-40 overflow-auto",children:this.state.error.toString()})})]}),(0,Me.jsxs)(C,{onClick:this.handleReset,radius:"full",className:"gap-2",children:[(0,Me.jsx)(fo.RefreshCw,{className:"size-4"}),"Reload Application"]})]})}):this.props.children}};var Hn=require("react");function Un(){let{handleSelectAllGlobal:e,handleClearSelection:t,getSelectionState:a,isCreateFolderModalOpen:o,setIsCreateFolderModalOpen:r,isUploadModalOpen:i,setIsUploadModalOpen:l,isSearchModalOpen:c,setIsSearchModalOpen:s}=O();return(0,Hn.useEffect)(()=>{let f=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),s(!c)),m.key==="a"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),a()===!0?t():e(!0)),m.key==="f"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),r(!o)),m.key==="u"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),l(!i))};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[e,t,a,o,r,i,l,c,s]),null}var ye=require("react/jsx-runtime");function Zn(e){return(0,ye.jsx)(uo,{children:(0,ye.jsxs)(et.Page,d(n({},e),{children:[(0,ye.jsx)(Un,{}),(0,ye.jsxs)("div",{className:"flex h-full relative pb-12 overflow-hidden",children:[(0,ye.jsxs)("div",{className:"flex-1 flex w-full flex-col",children:[(0,ye.jsx)(et.Header,{children:(0,ye.jsxs)("div",{className:"flex w-full justify-between gap-2",children:[(0,ye.jsx)(no,{}),(0,ye.jsx)(Pn,{})]})}),(0,ye.jsx)(xn,{className:"-mb-1"}),(0,ye.jsx)(mo,{}),(0,ye.jsx)(et.Footer,{className:"pt-6 pb-10"})]}),(0,ye.jsx)(et.Overlays,{})]})]}))})}var Nt=require("react");var Z=require("react/jsx-runtime");function jn(o){var r=o,{open:e,onClose:t}=r,a=g(r,["open","onClose"]);return(0,Z.jsx)(et.Modal,d(n({},a),{onClose:t,children:(0,Z.jsx)(ze,{open:e,onOpenChange:t,children:(0,Z.jsx)(Ui,{onClose:t})})}))}function Ui({onClose:e}){let{updateSearchQuery:t}=O(),[a,o]=(0,Nt.useState)(!1),[r,i]=(0,Nt.useState)(""),l=(0,Nt.useRef)(null),c=so(r,300);return(0,Nt.useEffect)(()=>{t(c)},[c,t]),(0,Nt.useEffect)(()=>{a&&l.current&&l.current.focus()},[a]),(0,Z.jsxs)(Te,{className:"p-0",variant:"fullscreen",showCloseButton:!1,children:[(0,Z.jsxs)(Be,{className:"pt-5 pb-3 m-0 border-b border-border",children:[(0,Z.jsx)(Re,{className:"px-6 text-base",children:(0,Z.jsx)("div",{className:"flex w-full justify-between gap-2",children:a?(0,Z.jsxs)("div",{className:"flex items-center gap-4 flex-1",children:[(0,Z.jsx)(Ae,{className:"size-5 text-gray-500 shrink-0"}),(0,Z.jsx)(ta,{ref:l,type:"text",placeholder:"Search files and folders...",className:"border-none shadow-none focus-visible:ring-0 h-auto p-0 text-base font-semibold",value:r,onChange:s=>i(s.target.value),onKeyDown:s=>{s.key==="Escape"&&(i(""),t(""),o(!1))}}),(0,Z.jsxs)(C,{variant:"outline",size:"icon",radius:"full",onClick:()=>{i(""),t(""),o(!1)},className:"border-gray-200 bg-white shrink-0",children:[(0,Z.jsx)(ve,{className:"size-5"}),(0,Z.jsx)("span",{className:"sr-only",children:"Cancel Search"})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(no,{}),(0,Z.jsx)(kn,{onSearchClick:()=>o(!0)}),(0,Z.jsxs)(C,{variant:"outline",size:"icon",radius:"full",onClick:e,className:"border-gray-200 bg-white",children:[(0,Z.jsx)(ve,{className:"size-5"}),(0,Z.jsx)("span",{className:"hidden",children:"Close"})]})]})})}),(0,Z.jsx)(lt,{className:"sr-only",children:"Browse and select files from your media library"})]}),(0,Z.jsxs)("div",{className:"overflow-y-auto flex-1 pb-4",children:[(0,Z.jsx)(mo,{}),(0,Z.jsx)(et.Footer,{className:"my-4"}),(0,Z.jsx)(et.Overlays,{})]}),(0,Z.jsx)(Zi,{onClose:e})]})}function Zi({onClose:e}){let{selectedFiles:t,onFilesSelected:a,setSelectedFiles:o,setSelectedFolders:r,updateSearchQuery:i,handlePageChange:l}=O();return(0,Z.jsxs)(He,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2",children:[(0,Z.jsx)(vn,{}),(0,Z.jsx)(qe,{asChild:!0,children:(0,Z.jsx)(C,{type:"button",variant:"outline",onClick:e,radius:"full",className:"w-full md:w-auto mr-0",children:"Cancel"})}),(0,Z.jsxs)(C,{type:"button",onClick:()=>{a&&t.length>0&&(a(t),o([]),r([]),i(""),l(1),e())},disabled:t.length===0,radius:"full",className:"w-full md:w-auto",children:["Select ",t.length>0?`(${t.length})`:""]})]})}var Ne=[{id:1,name:"Documents",pathId:1,path:"/1",parentId:null,fileCount:20,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:2,name:"Images",pathId:2,path:"/2",parentId:null,fileCount:10,folderCount:3,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:3,name:"Videos",pathId:3,path:"/3",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:4,name:"Music Some Long Name Streched also so long to fit in the card Music Some Long Name Streched also so long to fit in the card",pathId:4,path:"/4",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:5,name:"Archives",pathId:5,path:"/5",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:6,name:"Album 01",pathId:6,path:"/2/6",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:7,name:"Album 02",pathId:7,path:"/2/7",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:8,name:"Squirrels",pathId:8,path:"/2/8",parentId:2,fileCount:1,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")}],$n=[{id:1,name:"Important",color:"#ef4444"},{id:2,name:"Work",color:"#3b82f6"},{id:3,name:"Personal",color:"#10b981"},{id:4,name:"Project",color:"#8b5cf6"},{id:5,name:"Archive",color:"#6b7280"}],Ie=[{id:101,name:"welcome.pdf",url:"/placeholder.svg?height=400&width=300",size:245e3,createdAt:new Date("2024-05-15T10:00:00Z"),updatedAt:new Date("2024-05-15T10:00:00Z"),folderId:null,tags:["important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:2,author:"Admin"}},{id:102,name:"desktop_wallpaper.jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926",size:42e5,createdAt:new Date("2024-05-14T15:30:00Z"),updatedAt:new Date("2024-05-14T15:30:00Z"),folderId:null,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:5e3,height:3333,formats:{thumbnail:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=156",hash:"thumbnail_desktop_wallpaper_abc123",mime:"image/jpeg",name:"thumbnail_desktop_wallpaper.jpg",path:null,size:5.57,width:156,height:104},small:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=500",hash:"small_desktop_wallpaper_abc123",mime:"image/jpeg",name:"small_desktop_wallpaper.jpg",path:null,size:47.27,width:500,height:333},medium:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=750",hash:"medium_desktop_wallpaper_abc123",mime:"image/jpeg",name:"medium_desktop_wallpaper.jpg",path:null,size:97.89,width:750,height:500},large:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=1000",hash:"large_desktop_wallpaper_abc123",mime:"image/jpeg",name:"large_desktop_wallpaper.jpg",path:null,size:159.48,width:1e3,height:667}},metaData:{}},{id:103,name:"quick_notes.txt",url:"/placeholder.svg?height=400&width=300",size:3500,createdAt:new Date("2024-05-13T09:45:00Z"),updatedAt:new Date("2024-05-13T09:45:00Z"),folderId:null,tags:[],mime:"text/plain",ext:".txt",metaData:{}},{id:104,name:"intro_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:12e6,createdAt:new Date("2024-05-12T14:00:00Z"),updatedAt:new Date("2024-05-12T14:00:00Z"),folderId:null,tags:[],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:90,videoSource:"local"}},{id:105,name:"profile_photo.png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde",size:85e4,createdAt:new Date("2024-05-11T11:20:00Z"),updatedAt:new Date("2024-05-11T11:20:00Z"),folderId:null,tags:["personal"],mime:"image/png",ext:".png",width:2e3,height:2e3,formats:{thumbnail:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=156",hash:"thumbnail_profile_photo_def456",mime:"image/png",name:"thumbnail_profile_photo.png",path:null,size:8.2,width:156,height:156},small:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=500",hash:"small_profile_photo_def456",mime:"image/png",name:"small_profile_photo.png",path:null,size:52.3,width:500,height:500},medium:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=750",hash:"medium_profile_photo_def456",mime:"image/png",name:"medium_profile_photo.png",path:null,size:110.5,width:750,height:750},large:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=1000",hash:"large_profile_photo_def456",mime:"image/png",name:"large_profile_photo.png",path:null,size:185.7,width:1e3,height:1e3}},metaData:{}},{id:106,name:"todo_list.md",url:"/placeholder.svg?height=400&width=300",size:6200,createdAt:new Date("2024-05-10T08:30:00Z"),updatedAt:new Date("2024-05-10T08:30:00Z"),folderId:null,tags:["important"],mime:"text/markdown",ext:".md",metaData:{}},{id:107,name:"app_settings.json",url:"/placeholder.svg?height=400&width=300",size:4800,createdAt:new Date("2024-05-09T16:15:00Z"),updatedAt:new Date("2024-05-09T16:15:00Z"),folderId:null,tags:[],mime:"application/json",ext:".json",metaData:{}},{id:108,name:"mountain_landscape.webp",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:12e5,createdAt:new Date("2024-05-08T13:00:00Z"),updatedAt:new Date("2024-05-08T13:00:00Z"),folderId:null,tags:["personal"],mime:"image/webp",ext:".webp",width:4e3,height:2667,metaData:{}},{id:1,name:"Key-Monastery-img.avif",url:"https://unciatrails.com/wp-content/uploads/2024/07/Key-Monastery-img.avif",size:2621440,createdAt:new Date("2023-10-26T10:30:00Z"),updatedAt:new Date("2023-10-26T10:30:00Z"),folderId:8,tags:["personal","important"],mime:"image/avif",ext:".avif",caption:"A cute squirrel in the park",alternativeText:"Gray squirrel sitting on wooden fence",width:3024,height:4032,metaData:{}},{id:2,name:"project_proposal thoda sa.pdf",url:"/placeholder.svg?height=400&width=300",size:1048576,createdAt:new Date("2024-05-10T14:20:00Z"),updatedAt:new Date("2024-05-10T14:20:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:15,author:"John Doe"}},{id:3,name:"quarterly_report.xlsx",url:"/placeholder.svg?height=400&width=300",size:524288,createdAt:new Date("2024-05-08T09:15:00Z"),updatedAt:new Date("2024-05-08T09:15:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:10}},{id:4,name:"presentation.pptx",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:20}},{id:8,name:"documnet.doc",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/msword",ext:".doc",metaData:{pageCount:20}},{id:5,name:"demo_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:10485760,createdAt:new Date("2024-05-03T11:30:00Z"),updatedAt:new Date("2024-05-03T11:30:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:120,videoSource:"remote"}},{id:6,name:"podcast_episode.mp3",url:"/placeholder.svg?height=400&width=300",size:5242880,createdAt:new Date("2024-05-02T10:00:00Z"),updatedAt:new Date("2024-05-02T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:3600}},{id:7,name:"notes.txt",url:"/placeholder.svg?height=400&width=300",size:1024,createdAt:new Date("2024-05-01T09:00:00Z"),updatedAt:new Date("2024-05-01T09:00:00Z"),folderId:1,tags:["work"],mime:"text/plain",ext:".txt",metaData:{}},{id:9,name:"data.json",url:"/placeholder.svg?height=400&width=300",size:2048,createdAt:new Date("2024-04-30T15:00:00Z"),updatedAt:new Date("2024-04-30T15:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:10,name:"archive.zip",url:"/placeholder.svg?height=400&width=300",size:104857600,createdAt:new Date("2024-04-29T12:00:00Z"),updatedAt:new Date("2024-04-29T12:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Project backup"}},{id:11,name:"setup.exe",url:"/placeholder.svg?height=400&width=300",size:52428800,createdAt:new Date("2024-04-28T11:00:00Z"),updatedAt:new Date("2024-04-28T11:00:00Z"),folderId:5,tags:["software"],mime:"application/x-msdownload",ext:".exe",metaData:{description:"Installer"}},{id:12,name:"old_stuff.rar",url:"/placeholder.svg?height=400&width=300",size:20971520,createdAt:new Date("2024-04-27T10:00:00Z"),updatedAt:new Date("2024-04-27T10:00:00Z"),folderId:5,tags:["archive"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Old files"}},{id:13,name:"meeting_notes_q1.pdf",url:"/placeholder.svg?height=400&width=300",size:856e3,createdAt:new Date("2024-03-15T09:00:00Z"),updatedAt:new Date("2024-03-15T09:00:00Z"),folderId:1,tags:["work"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:8,author:"Sarah Johnson"}},{id:14,name:"budget_2024.xlsx",url:"/placeholder.svg?height=400&width=300",size:425e3,createdAt:new Date("2024-03-10T14:30:00Z"),updatedAt:new Date("2024-03-10T14:30:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:5}},{id:15,name:"team_photo.jpg",url:"https://images.unsplash.com/photo-1522071820081-009f0129c71c",size:32e5,createdAt:new Date("2024-02-28T11:00:00Z"),updatedAt:new Date("2024-02-28T11:00:00Z"),folderId:2,tags:["work"],mime:"image/jpeg",ext:".jpg",width:4e3,height:3e3,metaData:{}},{id:16,name:"logo_design.png",url:"https://images.unsplash.com/photo-1611162617474-5b21e879e113",size:15e5,createdAt:new Date("2024-02-20T10:00:00Z"),updatedAt:new Date("2024-02-20T10:00:00Z"),folderId:2,tags:["project"],mime:"image/png",ext:".png",width:2e3,height:2e3,metaData:{}},{id:17,name:"product_demo.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:15e6,createdAt:new Date("2024-02-15T16:00:00Z"),updatedAt:new Date("2024-02-15T16:00:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:180,videoSource:"local"}},{id:18,name:"training_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:25e6,createdAt:new Date("2024-02-10T09:30:00Z"),updatedAt:new Date("2024-02-10T09:30:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:300,videoSource:"local"}},{id:19,name:"background_music.mp3",url:"/placeholder.svg?height=400&width=300",size:45e5,createdAt:new Date("2024-02-05T14:00:00Z"),updatedAt:new Date("2024-02-05T14:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:240}},{id:20,name:"contract_template.docx",url:"/placeholder.svg?height=400&width=300",size:65e4,createdAt:new Date("2024-01-30T11:00:00Z"),updatedAt:new Date("2024-01-30T11:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:12}},{id:21,name:"invoice_jan.pdf",url:"/placeholder.svg?height=400&width=300",size:32e4,createdAt:new Date("2024-01-25T10:00:00Z"),updatedAt:new Date("2024-01-25T10:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:3}},{id:22,name:"vacation_photo1.jpg",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:28e5,createdAt:new Date("2024-01-20T15:00:00Z"),updatedAt:new Date("2024-01-20T15:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:3500,height:2500,metaData:{}},{id:23,name:"vacation_photo2.jpg",url:"https://images.unsplash.com/photo-1469474968028-56623f02e42e",size:31e5,createdAt:new Date("2024-01-20T15:05:00Z"),updatedAt:new Date("2024-01-20T15:05:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2800,metaData:{}},{id:24,name:"project_backup.zip",url:"/placeholder.svg?height=400&width=300",size:85e6,createdAt:new Date("2024-01-15T12:00:00Z"),updatedAt:new Date("2024-01-15T12:00:00Z"),folderId:5,tags:["archive","project"],mime:"application/zip",ext:".zip",metaData:{description:"Full project backup"}},{id:25,name:"presentation_final.pptx",url:"/placeholder.svg?height=400&width=300",size:35e5,createdAt:new Date("2024-01-10T16:00:00Z"),updatedAt:new Date("2024-01-10T16:00:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:35}},{id:26,name:"screenshot_001.png",url:"https://images.unsplash.com/photo-1517694712202-14dd9538aa97",size:12e5,createdAt:new Date("2024-01-05T09:00:00Z"),updatedAt:new Date("2024-01-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/png",ext:".png",width:1920,height:1080,metaData:{}},{id:27,name:"config.json",url:"/placeholder.svg?height=400&width=300",size:5e3,createdAt:new Date("2023-12-28T14:00:00Z"),updatedAt:new Date("2023-12-28T14:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:28,name:"readme.md",url:"/placeholder.svg?height=400&width=300",size:8500,createdAt:new Date("2023-12-20T10:00:00Z"),updatedAt:new Date("2023-12-20T10:00:00Z"),folderId:1,tags:["project"],mime:"text/markdown",ext:".md",metaData:{}},{id:29,name:"database_backup.sql",url:"/placeholder.svg?height=400&width=300",size:12e6,createdAt:new Date("2023-12-15T11:00:00Z"),updatedAt:new Date("2023-12-15T11:00:00Z"),folderId:5,tags:["archive","important"],mime:"application/sql",ext:".sql",metaData:{description:"Database backup"}},{id:30,name:"tutorial_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:18e6,createdAt:new Date("2023-12-10T13:00:00Z"),updatedAt:new Date("2023-12-10T13:00:00Z"),folderId:3,tags:["personal"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:420,videoSource:"local"}},{id:31,name:"company_logo.svg",url:"/placeholder.svg?height=400&width=300",size:45e3,createdAt:new Date("2023-12-05T09:00:00Z"),updatedAt:new Date("2023-12-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/svg+xml",ext:".svg",metaData:{}},{id:32,name:"report_q4.pdf",url:"/placeholder.svg?height=400&width=300",size:18e5,createdAt:new Date("2023-12-01T15:00:00Z"),updatedAt:new Date("2023-12-01T15:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:25,author:"Finance Team"}},{id:33,name:"nature_photo.webp",url:"https://images.unsplash.com/photo-1441974231531-c6227db76b6e",size:95e4,createdAt:new Date("2023-11-25T12:00:00Z"),updatedAt:new Date("2023-11-25T12:00:00Z"),folderId:2,tags:["personal"],mime:"image/webp",ext:".webp",width:3e3,height:2e3,metaData:{}},{id:34,name:"podcast_intro.mp3",url:"/placeholder.svg?height=400&width=300",size:25e5,createdAt:new Date("2023-11-20T10:00:00Z"),updatedAt:new Date("2023-11-20T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:180}},{id:35,name:"data_export.csv",url:"/placeholder.svg?height=400&width=300",size:85e4,createdAt:new Date("2023-11-15T14:00:00Z"),updatedAt:new Date("2023-11-15T14:00:00Z"),folderId:1,tags:["work"],mime:"text/csv",ext:".csv",metaData:{}},{id:36,name:"wireframes.pdf",url:"/placeholder.svg?height=400&width=300",size:42e5,createdAt:new Date("2023-11-10T11:00:00Z"),updatedAt:new Date("2023-11-10T11:00:00Z"),folderId:1,tags:["project"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:45}},{id:37,name:"cityscape.jpg",url:"https://images.unsplash.com/photo-1449824913935-59a10b8d2000",size:38e5,createdAt:new Date("2023-11-05T16:00:00Z"),updatedAt:new Date("2023-11-05T16:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4500,height:3e3,metaData:{}},{id:38,name:"interview_recording.mp3",url:"/placeholder.svg?height=400&width=300",size:85e5,createdAt:new Date("2023-11-01T09:00:00Z"),updatedAt:new Date("2023-11-01T09:00:00Z"),folderId:4,tags:["work"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:1800}},{id:39,name:"client_files.rar",url:"/placeholder.svg?height=400&width=300",size:45e6,createdAt:new Date("2023-10-25T13:00:00Z"),updatedAt:new Date("2023-10-25T13:00:00Z"),folderId:5,tags:["archive","work"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Client deliverables"}},{id:40,name:"marketing_plan.docx",url:"/placeholder.svg?height=400&width=300",size:12e5,createdAt:new Date("2023-10-20T10:00:00Z"),updatedAt:new Date("2023-10-20T10:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:18}},{id:41,name:"analytics_data.xlsx",url:"/placeholder.svg?height=400&width=300",size:21e5,createdAt:new Date("2023-10-15T15:00:00Z"),updatedAt:new Date("2023-10-15T15:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:8}},{id:42,name:"sunset_beach.jpg",url:"https://images.unsplash.com/photo-1507525428034-b723cf961d3e",size:32e5,createdAt:new Date("2023-10-10T17:00:00Z"),updatedAt:new Date("2023-10-10T17:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2700,metaData:{}},{id:43,name:"webinar_recording.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:35e6,createdAt:new Date("2023-10-05T14:00:00Z"),updatedAt:new Date("2023-10-05T14:00:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:600,videoSource:"local"}},{id:44,name:"sound_effects.wav",url:"/placeholder.svg?height=400&width=300",size:15e6,createdAt:new Date("2023-10-01T11:00:00Z"),updatedAt:new Date("2023-10-01T11:00:00Z"),folderId:4,tags:["project"],mime:"audio/wav",ext:".wav",metaData:{duration:120}},{id:45,name:"legacy_system.zip",url:"/placeholder.svg?height=400&width=300",size:125e6,createdAt:new Date("2023-09-25T09:00:00Z"),updatedAt:new Date("2023-09-25T09:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Old system files"}}];var Na=e=>new Promise(t=>setTimeout(t,e)),go=class{getFolder(t){if(t===null)return Promise.resolve(null);let a=Ne.find(i=>i.id===t);if(!a)return Promise.resolve(null);let o=n({},a),r=o;for(;r.parentId!==null;){let i=Ne.find(l=>l.id===r.parentId);if(i)r.parent=n({},i),r=r.parent;else break}return Promise.resolve(o)}async getFolders(t,a=1,o=20,r=""){await Na(300);let i=t!==null?Ne.filter(p=>p.parentId===t):Ne.filter(p=>p.parentId===null),l=i;if(r&&r.trim()){let p=r.toLowerCase().trim();l=i.filter(y=>y.name.toLowerCase().includes(p))}let c=l.sort((p,y)=>new Date(p.createdAt).getTime()-new Date(y.createdAt).getTime()),s=c.length,f=Math.ceil(s/o),m=(a-1)*o;return{folders:c.slice(m,m+o),pagination:{currentPage:a,totalPages:f,totalFiles:s,filesPerPage:o}}}getTags(){return Promise.resolve($n.map(t=>t.name))}async getFiles(t,a,o,r,i){await Na(500);let l=[...Ie];if(t!==null&&(l=l.filter(w=>w.folderId===t)),a&&a.length>0&&(l=l.filter(w=>{let N=je(w.mime,w.ext);return a.includes(N)})),i){let w=i==null?void 0:i.toLowerCase();l=l.filter(N=>N.name.toLowerCase().includes(w))}let c=l.sort((w,N)=>new Date(w.createdAt).getTime()-new Date(N.createdAt).getTime()),s=o!=null?o:1,f=r!=null?r:10,m=c.length,b=Math.ceil(m/f),p=(s-1)*f,y=c.slice(p,p+f);return Promise.resolve({files:y,pagination:{currentPage:s,totalPages:b,totalFiles:m,filesPerPage:f}})}async getItems(t,a,o=1,r=24,i=""){await Na(300);let l=t!==null?Ne.filter(h=>h.parentId===t):Ne.filter(h=>h.parentId===null),c=t!==null?Ie.filter(h=>h.folderId===t):Ie.filter(h=>h.folderId===null);if(a&&a.length>0&&(c=c.filter(h=>{let I=je(h.mime,h.ext);return a.includes(I)})),i&&i.trim()){let h=i.toLowerCase().trim();l=l.filter(I=>I.name.toLowerCase().includes(h)),c=c.filter(I=>{var Y,te;return I.name.toLowerCase().includes(h)||((te=(Y=I.ext)==null?void 0:Y.toLowerCase().includes(h))!=null?te:!1)})}let s=l.sort((h,I)=>new Date(h.createdAt).getTime()-new Date(I.createdAt).getTime()),f=c.sort((h,I)=>new Date(h.createdAt).getTime()-new Date(I.createdAt).getTime()),m=s.length+f.length,b=Math.ceil(m/r)||1,p=(o-1)*r,y=p+r,w=s.slice(Math.max(0,p),Math.min(s.length,y)),N=w.length,M=r-N,D=Math.min(s.length,p),z=Math.max(0,p-s.length),T=f.slice(z,z+M);return{folders:w,files:T,pagination:{currentPage:o,totalPages:b,totalFiles:m,filesPerPage:r}}}async createFolder(t,a){await Na(300);let o={id:Date.now(),name:t,parentId:a!=null?a:null,pathId:typeof a=="number"?a:0,path:"",fileCount:0,folderCount:0,createdAt:new Date,updatedAt:new Date};return Ne.push(o),o}getMetaDataType(t,a){return t.type.startsWith("image/")?{}:t.type.startsWith("video/")?{duration:0,videoSource:a!=null?a:vo.LOCAL}:t.type.startsWith("audio/")?{duration:0}:{description:""}}getFileType(t){var o;let a="."+((o=t.name.split(".").pop())==null?void 0:o.toLowerCase());return je(t.type,a)}async uploadFiles(t,a){var r;await Na(500);let o=[];for(let{file:i,videoSource:l}of t){let c=this.getFileType(i),s="."+((r=i.name.split(".").pop())==null?void 0:r.toLowerCase()),f={id:Date.now()+Math.random(),name:i.name,folderId:a!=null?a:null,size:i.size,url:URL.createObjectURL(i),mime:i.type||"application/octet-stream",ext:s,metaData:this.getMetaDataType(i,l),createdAt:new Date,updatedAt:new Date,tags:[],width:c===X.IMAGE?800:void 0,height:c===X.IMAGE?600:void 0};Ie.push(f),o.push(f)}return o}renameFolder(t,a){let o=Ne.find(r=>r.id===t);return o?(o.name=a,o.updatedAt=new Date,Promise.resolve(o)):Promise.reject(new Error("Folder not found"))}updateFileMetaData(t,a){let o=Ie.find(c=>c.id===t);if(!o)return Promise.reject(new Error("File not found"));let l=a,{metaData:r}=l,i=g(l,["metaData"]);return Object.assign(o,i),r&&(o.metaData=n(n({},o.metaData),r)),o.updatedAt=new Date,Promise.resolve(o)}deleteFiles(t){for(let a of t){let o=Ie.findIndex(r=>r.id===a);o!==-1&&Ie.splice(o,1)}return Promise.resolve()}deleteFolders(t){for(let a of t){let o=Ne.findIndex(r=>r.id===a);if(o!==-1){Ne.splice(o,1);for(let r=Ie.length-1;r>=0;r--)Ie[r].folderId===a&&Ie.splice(r,1)}}return Promise.resolve()}findFiles(t){let a=t==null?void 0:t.toLowerCase(),o=Ie.filter(r=>{var i;return r.name.toLowerCase().includes(a)||((i=r.tags)==null?void 0:i.some(l=>l.toLowerCase().includes(a)))});return Promise.resolve(o)}findFolders(t){let a=t==null?void 0:t.toLowerCase(),o=Ne.filter(r=>r.name.toLowerCase().includes(a));return Promise.resolve(o)}moveFiles(t,a){let o=[];for(let r of t){let i=Ie.find(l=>l.id===r);i&&(i.folderId=a,i.updatedAt=new Date,o.push(i))}return Promise.resolve(o)}moveFolders(t,a){let o=[];for(let r of t){let i=Ne.find(l=>l.id===r);i&&(i.parentId=a,i.updatedAt=new Date,o.push(i))}return Promise.resolve(o)}};0&&(module.exports={FileManager,FileManagerModal,FileManagerProvider,MockProvider,useFileManager});
116
- //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -113,4 +113,3 @@ var $n=Object.defineProperty,Wn=Object.defineProperties;var Kn=Object.getOwnProp
113
113
  text-[13px] font-medium leading-[1.3] tracking-tight line-clamp-2 px-2.5 pb-[2px] rounded-[6px] transition-colors duration-100 break-words max-w-full
114
114
  ${t?"bg-[#2563EB] text-white antialiased shadow-sm":"text-[#374151] group-hover:text-black"}
115
115
  `,children:e.name}),Oe("div",{className:`flex items-center justify-center gap-1 mt-1 transition-opacity duration-200 ${t?"opacity-60":"opacity-100"}`,children:ja("span",{className:"text-[11px] text-blue-600 font-medium tracking-tight px-1.5 rounded-full",children:[e.fileCount," items"]})})]})]})})}import{jsx as Ht,jsxs as zo}from"react/jsx-runtime";function $a(){let{files:e,folders:t,isLoading:a,handleFileClick:o,handleFolderClick:n,bulkDelete:i,mode:l,selectionMode:c,isInSelectionMode:s,selectedFiles:f,selectedFolders:m,currentFolder:b,setSelectedFiles:p,setSelectedFolders:y,setIsRenameFolderModalOpen:w,setIsMoveFileModalOpen:D,setFileDetailsModalFile:F,setFolderToRename:M}=E(),P=(()=>{if(!b)return 18;let h=b.folderCount||0,N=b.fileCount||0,H=h+N;return H>0?H:18})();return a?Ht("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:Array.from({length:P}).map((h,N)=>zo("div",{className:"flex flex-col items-center justify-start w-full gap-2",children:[Ht("div",{className:"w-full aspect-square bg-gray-100 rounded-2xl animate-pulse"}),zo("div",{className:"flex flex-col items-center gap-1 w-full",children:[Ht("div",{className:"h-4 w-20 bg-gray-100 rounded animate-pulse"}),Ht("div",{className:"h-3 w-12 bg-gray-100 rounded animate-pulse"})]})]},N))}):zo("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:[t.map(h=>Ht(Cn,{folder:h,isSelected:m.some(N=>N.id===h.id),onSelect:n,onDelete:()=>i(),onRename:N=>{M(N),w(!0)},onMove:N=>{y([N]),p([]),D(!0)},selectionMode:c,mode:l,isInSelectionMode:s()},h.id)),e.map(h=>Ht(wn,{file:h,isSelected:f.some(N=>N.id===h.id),onSelect:o,onDelete:()=>i(),onEdit:N=>{F(N)},onMove:N=>{p([N]),y([]),D(!0)},selectionMode:c,mode:l,isInSelectionMode:s()},h.id))]})}import{Component as Jl}from"react";import{AlertCircle as Xl,RefreshCw as es}from"lucide-react";import{jsx as tt,jsxs as To}from"react/jsx-runtime";var Wa=class extends Jl{constructor(a){super(a);this.handleReset=()=>{window.location.reload()};this.state={hasError:!1,error:null}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,o){console.error("FileManager Error Boundary caught an error:",a,o)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:tt("div",{className:"flex items-center justify-center min-h-[400px] p-8 w-full h-full bg-slate-50/50 rounded-lg border border-dashed border-slate-200",children:To("div",{className:"text-center max-w-md flex flex-col items-center",children:[tt("div",{className:"bg-red-100 p-3 rounded-full mb-4",children:tt(Xl,{className:"size-8 text-red-600"})}),tt("h2",{className:"text-xl font-semibold text-slate-900 mb-2",children:"Something went wrong"}),tt("p",{className:"text-sm text-slate-500 mb-6",children:"The file manager encountered an unexpected error. Refreshing the page usually resolves this issue."}),this.state.error&&To("details",{className:"mb-6 text-left w-full border border-slate-200 rounded-lg overflow-hidden flex-col group",children:[tt("summary",{className:"cursor-pointer text-xs font-mono bg-slate-100 p-2 text-slate-600 hover:bg-slate-200 transition-colors",children:"View Technical Details"}),tt("div",{className:"p-3 bg-white",children:tt("pre",{className:"text-[10px] text-slate-600 font-mono whitespace-pre-wrap word-break-all max-h-40 overflow-auto",children:this.state.error.toString()})})]}),To(C,{onClick:this.handleReset,radius:"full",className:"gap-2",children:[tt(es,{className:"size-4"}),"Reload Application"]})]})}):this.props.children}};import{useEffect as ts}from"react";function yn(){let{handleSelectAllGlobal:e,handleClearSelection:t,getSelectionState:a,isCreateFolderModalOpen:o,setIsCreateFolderModalOpen:n,isUploadModalOpen:i,setIsUploadModalOpen:l,isSearchModalOpen:c,setIsSearchModalOpen:s}=E();return ts(()=>{let f=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),s(!c)),m.key==="a"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),a()===!0?t():e(!0)),m.key==="f"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),n(!o)),m.key==="u"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),l(!i))};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[e,t,a,o,n,i,l,c,s]),null}import{jsx as at,jsxs as Ka}from"react/jsx-runtime";function as(e){return at(Wa,{children:Ka(Qe.Page,d(r({},e),{children:[at(yn,{}),Ka("div",{className:"flex h-full relative pb-12 overflow-hidden",children:[Ka("div",{className:"flex-1 flex w-full flex-col",children:[at(Qe.Header,{children:Ka("div",{className:"flex w-full justify-between gap-2",children:[at(Oa,{}),at(cn,{})]})}),at(Xr,{className:"-mb-1"}),at($a,{}),at(Qe.Footer,{className:"pt-6 pb-10"})]}),at(Qe.Overlays,{})]})]}))})}import{useState as Fn,useRef as os,useEffect as Mn}from"react";import{Fragment as ls,jsx as ee,jsxs as ot}from"react/jsx-runtime";function rs(o){var n=o,{open:e,onClose:t}=n,a=g(n,["open","onClose"]);return ee(Qe.Modal,d(r({},a),{onClose:t,children:ee(Ie,{open:e,onOpenChange:t,children:ee(ns,{onClose:t})})}))}function ns({onClose:e}){let{updateSearchQuery:t}=E(),[a,o]=Fn(!1),[n,i]=Fn(""),l=os(null),c=Ba(n,300);return Mn(()=>{t(c)},[c,t]),Mn(()=>{a&&l.current&&l.current.focus()},[a]),ot(Pe,{className:"p-0",variant:"fullscreen",showCloseButton:!1,children:[ot(Ge,{className:"pt-5 pb-3 m-0 border-b border-border",children:[ee(ke,{className:"px-6 text-base",children:ee("div",{className:"flex w-full justify-between gap-2",children:a?ot("div",{className:"flex items-center gap-4 flex-1",children:[ee(ze,{className:"size-5 text-gray-500 shrink-0"}),ee(_t,{ref:l,type:"text",placeholder:"Search files and folders...",className:"border-none shadow-none focus-visible:ring-0 h-auto p-0 text-base font-semibold",value:n,onChange:s=>i(s.target.value),onKeyDown:s=>{s.key==="Escape"&&(i(""),t(""),o(!1))}}),ot(C,{variant:"outline",size:"icon",radius:"full",onClick:()=>{i(""),t(""),o(!1)},className:"border-gray-200 bg-white shrink-0",children:[ee(ce,{className:"size-5"}),ee("span",{className:"sr-only",children:"Cancel Search"})]})]}):ot(ls,{children:[ee(Oa,{}),ee(pn,{onSearchClick:()=>o(!0)}),ot(C,{variant:"outline",size:"icon",radius:"full",onClick:e,className:"border-gray-200 bg-white",children:[ee(ce,{className:"size-5"}),ee("span",{className:"hidden",children:"Close"})]})]})})}),ee(rt,{className:"sr-only",children:"Browse and select files from your media library"})]}),ot("div",{className:"overflow-y-auto flex-1 pb-4",children:[ee($a,{}),ee(Qe.Footer,{className:"my-4"}),ee(Qe.Overlays,{})]}),ee(is,{onClose:e})]})}function is({onClose:e}){let{selectedFiles:t,onFilesSelected:a,setSelectedFiles:o,setSelectedFolders:n,updateSearchQuery:i,handlePageChange:l}=E();return ot(Be,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2",children:[ee(Jr,{}),ee(Ye,{asChild:!0,children:ee(C,{type:"button",variant:"outline",onClick:e,radius:"full",className:"w-full md:w-auto mr-0",children:"Cancel"})}),ot(C,{type:"button",onClick:()=>{a&&t.length>0&&(a(t),o([]),n([]),i(""),l(1),e())},disabled:t.length===0,radius:"full",className:"w-full md:w-auto",children:["Select ",t.length>0?`(${t.length})`:""]})]})}var Fe=[{id:1,name:"Documents",pathId:1,path:"/1",parentId:null,fileCount:20,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:2,name:"Images",pathId:2,path:"/2",parentId:null,fileCount:10,folderCount:3,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:3,name:"Videos",pathId:3,path:"/3",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:4,name:"Music Some Long Name Streched also so long to fit in the card Music Some Long Name Streched also so long to fit in the card",pathId:4,path:"/4",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:5,name:"Archives",pathId:5,path:"/5",parentId:null,fileCount:5,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:6,name:"Album 01",pathId:6,path:"/2/6",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:7,name:"Album 02",pathId:7,path:"/2/7",parentId:2,fileCount:0,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")},{id:8,name:"Squirrels",pathId:8,path:"/2/8",parentId:2,fileCount:1,folderCount:0,createdAt:new Date("2024-01-01"),updatedAt:new Date("2024-01-01")}],Dn=[{id:1,name:"Important",color:"#ef4444"},{id:2,name:"Work",color:"#3b82f6"},{id:3,name:"Personal",color:"#10b981"},{id:4,name:"Project",color:"#8b5cf6"},{id:5,name:"Archive",color:"#6b7280"}],Me=[{id:101,name:"welcome.pdf",url:"/placeholder.svg?height=400&width=300",size:245e3,createdAt:new Date("2024-05-15T10:00:00Z"),updatedAt:new Date("2024-05-15T10:00:00Z"),folderId:null,tags:["important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:2,author:"Admin"}},{id:102,name:"desktop_wallpaper.jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926",size:42e5,createdAt:new Date("2024-05-14T15:30:00Z"),updatedAt:new Date("2024-05-14T15:30:00Z"),folderId:null,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:5e3,height:3333,formats:{thumbnail:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=156",hash:"thumbnail_desktop_wallpaper_abc123",mime:"image/jpeg",name:"thumbnail_desktop_wallpaper.jpg",path:null,size:5.57,width:156,height:104},small:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=500",hash:"small_desktop_wallpaper_abc123",mime:"image/jpeg",name:"small_desktop_wallpaper.jpg",path:null,size:47.27,width:500,height:333},medium:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=750",hash:"medium_desktop_wallpaper_abc123",mime:"image/jpeg",name:"medium_desktop_wallpaper.jpg",path:null,size:97.89,width:750,height:500},large:{ext:".jpg",url:"https://images.unsplash.com/photo-1557683316-973673baf926?w=1000",hash:"large_desktop_wallpaper_abc123",mime:"image/jpeg",name:"large_desktop_wallpaper.jpg",path:null,size:159.48,width:1e3,height:667}},metaData:{}},{id:103,name:"quick_notes.txt",url:"/placeholder.svg?height=400&width=300",size:3500,createdAt:new Date("2024-05-13T09:45:00Z"),updatedAt:new Date("2024-05-13T09:45:00Z"),folderId:null,tags:[],mime:"text/plain",ext:".txt",metaData:{}},{id:104,name:"intro_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:12e6,createdAt:new Date("2024-05-12T14:00:00Z"),updatedAt:new Date("2024-05-12T14:00:00Z"),folderId:null,tags:[],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:90,videoSource:"local"}},{id:105,name:"profile_photo.png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde",size:85e4,createdAt:new Date("2024-05-11T11:20:00Z"),updatedAt:new Date("2024-05-11T11:20:00Z"),folderId:null,tags:["personal"],mime:"image/png",ext:".png",width:2e3,height:2e3,formats:{thumbnail:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=156",hash:"thumbnail_profile_photo_def456",mime:"image/png",name:"thumbnail_profile_photo.png",path:null,size:8.2,width:156,height:156},small:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=500",hash:"small_profile_photo_def456",mime:"image/png",name:"small_profile_photo.png",path:null,size:52.3,width:500,height:500},medium:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=750",hash:"medium_profile_photo_def456",mime:"image/png",name:"medium_profile_photo.png",path:null,size:110.5,width:750,height:750},large:{ext:".png",url:"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=1000",hash:"large_profile_photo_def456",mime:"image/png",name:"large_profile_photo.png",path:null,size:185.7,width:1e3,height:1e3}},metaData:{}},{id:106,name:"todo_list.md",url:"/placeholder.svg?height=400&width=300",size:6200,createdAt:new Date("2024-05-10T08:30:00Z"),updatedAt:new Date("2024-05-10T08:30:00Z"),folderId:null,tags:["important"],mime:"text/markdown",ext:".md",metaData:{}},{id:107,name:"app_settings.json",url:"/placeholder.svg?height=400&width=300",size:4800,createdAt:new Date("2024-05-09T16:15:00Z"),updatedAt:new Date("2024-05-09T16:15:00Z"),folderId:null,tags:[],mime:"application/json",ext:".json",metaData:{}},{id:108,name:"mountain_landscape.webp",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:12e5,createdAt:new Date("2024-05-08T13:00:00Z"),updatedAt:new Date("2024-05-08T13:00:00Z"),folderId:null,tags:["personal"],mime:"image/webp",ext:".webp",width:4e3,height:2667,metaData:{}},{id:1,name:"Key-Monastery-img.avif",url:"https://unciatrails.com/wp-content/uploads/2024/07/Key-Monastery-img.avif",size:2621440,createdAt:new Date("2023-10-26T10:30:00Z"),updatedAt:new Date("2023-10-26T10:30:00Z"),folderId:8,tags:["personal","important"],mime:"image/avif",ext:".avif",caption:"A cute squirrel in the park",alternativeText:"Gray squirrel sitting on wooden fence",width:3024,height:4032,metaData:{}},{id:2,name:"project_proposal thoda sa.pdf",url:"/placeholder.svg?height=400&width=300",size:1048576,createdAt:new Date("2024-05-10T14:20:00Z"),updatedAt:new Date("2024-05-10T14:20:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:15,author:"John Doe"}},{id:3,name:"quarterly_report.xlsx",url:"/placeholder.svg?height=400&width=300",size:524288,createdAt:new Date("2024-05-08T09:15:00Z"),updatedAt:new Date("2024-05-08T09:15:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:10}},{id:4,name:"presentation.pptx",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:20}},{id:8,name:"documnet.doc",url:"/placeholder.svg?height=400&width=300",size:2097152,createdAt:new Date("2024-05-05T16:45:00Z"),updatedAt:new Date("2024-05-05T16:45:00Z"),folderId:1,tags:["work","project"],mime:"application/msword",ext:".doc",metaData:{pageCount:20}},{id:5,name:"demo_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:10485760,createdAt:new Date("2024-05-03T11:30:00Z"),updatedAt:new Date("2024-05-03T11:30:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:120,videoSource:"remote"}},{id:6,name:"podcast_episode.mp3",url:"/placeholder.svg?height=400&width=300",size:5242880,createdAt:new Date("2024-05-02T10:00:00Z"),updatedAt:new Date("2024-05-02T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:3600}},{id:7,name:"notes.txt",url:"/placeholder.svg?height=400&width=300",size:1024,createdAt:new Date("2024-05-01T09:00:00Z"),updatedAt:new Date("2024-05-01T09:00:00Z"),folderId:1,tags:["work"],mime:"text/plain",ext:".txt",metaData:{}},{id:9,name:"data.json",url:"/placeholder.svg?height=400&width=300",size:2048,createdAt:new Date("2024-04-30T15:00:00Z"),updatedAt:new Date("2024-04-30T15:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:10,name:"archive.zip",url:"/placeholder.svg?height=400&width=300",size:104857600,createdAt:new Date("2024-04-29T12:00:00Z"),updatedAt:new Date("2024-04-29T12:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Project backup"}},{id:11,name:"setup.exe",url:"/placeholder.svg?height=400&width=300",size:52428800,createdAt:new Date("2024-04-28T11:00:00Z"),updatedAt:new Date("2024-04-28T11:00:00Z"),folderId:5,tags:["software"],mime:"application/x-msdownload",ext:".exe",metaData:{description:"Installer"}},{id:12,name:"old_stuff.rar",url:"/placeholder.svg?height=400&width=300",size:20971520,createdAt:new Date("2024-04-27T10:00:00Z"),updatedAt:new Date("2024-04-27T10:00:00Z"),folderId:5,tags:["archive"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Old files"}},{id:13,name:"meeting_notes_q1.pdf",url:"/placeholder.svg?height=400&width=300",size:856e3,createdAt:new Date("2024-03-15T09:00:00Z"),updatedAt:new Date("2024-03-15T09:00:00Z"),folderId:1,tags:["work"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:8,author:"Sarah Johnson"}},{id:14,name:"budget_2024.xlsx",url:"/placeholder.svg?height=400&width=300",size:425e3,createdAt:new Date("2024-03-10T14:30:00Z"),updatedAt:new Date("2024-03-10T14:30:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:5}},{id:15,name:"team_photo.jpg",url:"https://images.unsplash.com/photo-1522071820081-009f0129c71c",size:32e5,createdAt:new Date("2024-02-28T11:00:00Z"),updatedAt:new Date("2024-02-28T11:00:00Z"),folderId:2,tags:["work"],mime:"image/jpeg",ext:".jpg",width:4e3,height:3e3,metaData:{}},{id:16,name:"logo_design.png",url:"https://images.unsplash.com/photo-1611162617474-5b21e879e113",size:15e5,createdAt:new Date("2024-02-20T10:00:00Z"),updatedAt:new Date("2024-02-20T10:00:00Z"),folderId:2,tags:["project"],mime:"image/png",ext:".png",width:2e3,height:2e3,metaData:{}},{id:17,name:"product_demo.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:15e6,createdAt:new Date("2024-02-15T16:00:00Z"),updatedAt:new Date("2024-02-15T16:00:00Z"),folderId:3,tags:["project"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:180,videoSource:"local"}},{id:18,name:"training_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:25e6,createdAt:new Date("2024-02-10T09:30:00Z"),updatedAt:new Date("2024-02-10T09:30:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:300,videoSource:"local"}},{id:19,name:"background_music.mp3",url:"/placeholder.svg?height=400&width=300",size:45e5,createdAt:new Date("2024-02-05T14:00:00Z"),updatedAt:new Date("2024-02-05T14:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:240}},{id:20,name:"contract_template.docx",url:"/placeholder.svg?height=400&width=300",size:65e4,createdAt:new Date("2024-01-30T11:00:00Z"),updatedAt:new Date("2024-01-30T11:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:12}},{id:21,name:"invoice_jan.pdf",url:"/placeholder.svg?height=400&width=300",size:32e4,createdAt:new Date("2024-01-25T10:00:00Z"),updatedAt:new Date("2024-01-25T10:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:3}},{id:22,name:"vacation_photo1.jpg",url:"https://images.unsplash.com/photo-1506905925346-21bda4d32df4",size:28e5,createdAt:new Date("2024-01-20T15:00:00Z"),updatedAt:new Date("2024-01-20T15:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:3500,height:2500,metaData:{}},{id:23,name:"vacation_photo2.jpg",url:"https://images.unsplash.com/photo-1469474968028-56623f02e42e",size:31e5,createdAt:new Date("2024-01-20T15:05:00Z"),updatedAt:new Date("2024-01-20T15:05:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2800,metaData:{}},{id:24,name:"project_backup.zip",url:"/placeholder.svg?height=400&width=300",size:85e6,createdAt:new Date("2024-01-15T12:00:00Z"),updatedAt:new Date("2024-01-15T12:00:00Z"),folderId:5,tags:["archive","project"],mime:"application/zip",ext:".zip",metaData:{description:"Full project backup"}},{id:25,name:"presentation_final.pptx",url:"/placeholder.svg?height=400&width=300",size:35e5,createdAt:new Date("2024-01-10T16:00:00Z"),updatedAt:new Date("2024-01-10T16:00:00Z"),folderId:1,tags:["work","important"],mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ext:".pptx",metaData:{pageCount:35}},{id:26,name:"screenshot_001.png",url:"https://images.unsplash.com/photo-1517694712202-14dd9538aa97",size:12e5,createdAt:new Date("2024-01-05T09:00:00Z"),updatedAt:new Date("2024-01-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/png",ext:".png",width:1920,height:1080,metaData:{}},{id:27,name:"config.json",url:"/placeholder.svg?height=400&width=300",size:5e3,createdAt:new Date("2023-12-28T14:00:00Z"),updatedAt:new Date("2023-12-28T14:00:00Z"),folderId:1,tags:["project"],mime:"application/json",ext:".json",metaData:{}},{id:28,name:"readme.md",url:"/placeholder.svg?height=400&width=300",size:8500,createdAt:new Date("2023-12-20T10:00:00Z"),updatedAt:new Date("2023-12-20T10:00:00Z"),folderId:1,tags:["project"],mime:"text/markdown",ext:".md",metaData:{}},{id:29,name:"database_backup.sql",url:"/placeholder.svg?height=400&width=300",size:12e6,createdAt:new Date("2023-12-15T11:00:00Z"),updatedAt:new Date("2023-12-15T11:00:00Z"),folderId:5,tags:["archive","important"],mime:"application/sql",ext:".sql",metaData:{description:"Database backup"}},{id:30,name:"tutorial_video.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:18e6,createdAt:new Date("2023-12-10T13:00:00Z"),updatedAt:new Date("2023-12-10T13:00:00Z"),folderId:3,tags:["personal"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:420,videoSource:"local"}},{id:31,name:"company_logo.svg",url:"/placeholder.svg?height=400&width=300",size:45e3,createdAt:new Date("2023-12-05T09:00:00Z"),updatedAt:new Date("2023-12-05T09:00:00Z"),folderId:2,tags:["work"],mime:"image/svg+xml",ext:".svg",metaData:{}},{id:32,name:"report_q4.pdf",url:"/placeholder.svg?height=400&width=300",size:18e5,createdAt:new Date("2023-12-01T15:00:00Z"),updatedAt:new Date("2023-12-01T15:00:00Z"),folderId:1,tags:["work","important"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:25,author:"Finance Team"}},{id:33,name:"nature_photo.webp",url:"https://images.unsplash.com/photo-1441974231531-c6227db76b6e",size:95e4,createdAt:new Date("2023-11-25T12:00:00Z"),updatedAt:new Date("2023-11-25T12:00:00Z"),folderId:2,tags:["personal"],mime:"image/webp",ext:".webp",width:3e3,height:2e3,metaData:{}},{id:34,name:"podcast_intro.mp3",url:"/placeholder.svg?height=400&width=300",size:25e5,createdAt:new Date("2023-11-20T10:00:00Z"),updatedAt:new Date("2023-11-20T10:00:00Z"),folderId:4,tags:["personal"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:180}},{id:35,name:"data_export.csv",url:"/placeholder.svg?height=400&width=300",size:85e4,createdAt:new Date("2023-11-15T14:00:00Z"),updatedAt:new Date("2023-11-15T14:00:00Z"),folderId:1,tags:["work"],mime:"text/csv",ext:".csv",metaData:{}},{id:36,name:"wireframes.pdf",url:"/placeholder.svg?height=400&width=300",size:42e5,createdAt:new Date("2023-11-10T11:00:00Z"),updatedAt:new Date("2023-11-10T11:00:00Z"),folderId:1,tags:["project"],mime:"application/pdf",ext:".pdf",metaData:{pageCount:45}},{id:37,name:"cityscape.jpg",url:"https://images.unsplash.com/photo-1449824913935-59a10b8d2000",size:38e5,createdAt:new Date("2023-11-05T16:00:00Z"),updatedAt:new Date("2023-11-05T16:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4500,height:3e3,metaData:{}},{id:38,name:"interview_recording.mp3",url:"/placeholder.svg?height=400&width=300",size:85e5,createdAt:new Date("2023-11-01T09:00:00Z"),updatedAt:new Date("2023-11-01T09:00:00Z"),folderId:4,tags:["work"],mime:"audio/mpeg",ext:".mp3",metaData:{duration:1800}},{id:39,name:"client_files.rar",url:"/placeholder.svg?height=400&width=300",size:45e6,createdAt:new Date("2023-10-25T13:00:00Z"),updatedAt:new Date("2023-10-25T13:00:00Z"),folderId:5,tags:["archive","work"],mime:"application/x-rar-compressed",ext:".rar",metaData:{description:"Client deliverables"}},{id:40,name:"marketing_plan.docx",url:"/placeholder.svg?height=400&width=300",size:12e5,createdAt:new Date("2023-10-20T10:00:00Z"),updatedAt:new Date("2023-10-20T10:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ext:".docx",metaData:{pageCount:18}},{id:41,name:"analytics_data.xlsx",url:"/placeholder.svg?height=400&width=300",size:21e5,createdAt:new Date("2023-10-15T15:00:00Z"),updatedAt:new Date("2023-10-15T15:00:00Z"),folderId:1,tags:["work"],mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ext:".xlsx",metaData:{pageCount:8}},{id:42,name:"sunset_beach.jpg",url:"https://images.unsplash.com/photo-1507525428034-b723cf961d3e",size:32e5,createdAt:new Date("2023-10-10T17:00:00Z"),updatedAt:new Date("2023-10-10T17:00:00Z"),folderId:2,tags:["personal"],mime:"image/jpeg",ext:".jpg",width:4e3,height:2700,metaData:{}},{id:43,name:"webinar_recording.mp4",url:"https://docs.material-tailwind.com/demo.mp4",size:35e6,createdAt:new Date("2023-10-05T14:00:00Z"),updatedAt:new Date("2023-10-05T14:00:00Z"),folderId:3,tags:["work"],mime:"video/mp4",ext:".mp4",width:1920,height:1080,metaData:{duration:600,videoSource:"local"}},{id:44,name:"sound_effects.wav",url:"/placeholder.svg?height=400&width=300",size:15e6,createdAt:new Date("2023-10-01T11:00:00Z"),updatedAt:new Date("2023-10-01T11:00:00Z"),folderId:4,tags:["project"],mime:"audio/wav",ext:".wav",metaData:{duration:120}},{id:45,name:"legacy_system.zip",url:"/placeholder.svg?height=400&width=300",size:125e6,createdAt:new Date("2023-09-25T09:00:00Z"),updatedAt:new Date("2023-09-25T09:00:00Z"),folderId:5,tags:["archive"],mime:"application/zip",ext:".zip",metaData:{description:"Old system files"}}];var ia=e=>new Promise(t=>setTimeout(t,e)),Ro=class{getFolder(t){if(t===null)return Promise.resolve(null);let a=Fe.find(i=>i.id===t);if(!a)return Promise.resolve(null);let o=r({},a),n=o;for(;n.parentId!==null;){let i=Fe.find(l=>l.id===n.parentId);if(i)n.parent=r({},i),n=n.parent;else break}return Promise.resolve(o)}async getFolders(t,a=1,o=20,n=""){await ia(300);let i=t!==null?Fe.filter(p=>p.parentId===t):Fe.filter(p=>p.parentId===null),l=i;if(n&&n.trim()){let p=n.toLowerCase().trim();l=i.filter(y=>y.name.toLowerCase().includes(p))}let c=l.sort((p,y)=>new Date(p.createdAt).getTime()-new Date(y.createdAt).getTime()),s=c.length,f=Math.ceil(s/o),m=(a-1)*o;return{folders:c.slice(m,m+o),pagination:{currentPage:a,totalPages:f,totalFiles:s,filesPerPage:o}}}getTags(){return Promise.resolve(Dn.map(t=>t.name))}async getFiles(t,a,o,n,i){await ia(500);let l=[...Me];if(t!==null&&(l=l.filter(w=>w.folderId===t)),a&&a.length>0&&(l=l.filter(w=>{let D=Ue(w.mime,w.ext);return a.includes(D)})),i){let w=i==null?void 0:i.toLowerCase();l=l.filter(D=>D.name.toLowerCase().includes(w))}let c=l.sort((w,D)=>new Date(w.createdAt).getTime()-new Date(D.createdAt).getTime()),s=o!=null?o:1,f=n!=null?n:10,m=c.length,b=Math.ceil(m/f),p=(s-1)*f,y=c.slice(p,p+f);return Promise.resolve({files:y,pagination:{currentPage:s,totalPages:b,totalFiles:m,filesPerPage:f}})}async getItems(t,a,o=1,n=24,i=""){await ia(300);let l=t!==null?Fe.filter(h=>h.parentId===t):Fe.filter(h=>h.parentId===null),c=t!==null?Me.filter(h=>h.folderId===t):Me.filter(h=>h.folderId===null);if(a&&a.length>0&&(c=c.filter(h=>{let N=Ue(h.mime,h.ext);return a.includes(N)})),i&&i.trim()){let h=i.toLowerCase().trim();l=l.filter(N=>N.name.toLowerCase().includes(h)),c=c.filter(N=>{var H,q;return N.name.toLowerCase().includes(h)||((q=(H=N.ext)==null?void 0:H.toLowerCase().includes(h))!=null?q:!1)})}let s=l.sort((h,N)=>new Date(h.createdAt).getTime()-new Date(N.createdAt).getTime()),f=c.sort((h,N)=>new Date(h.createdAt).getTime()-new Date(N.createdAt).getTime()),m=s.length+f.length,b=Math.ceil(m/n)||1,p=(o-1)*n,y=p+n,w=s.slice(Math.max(0,p),Math.min(s.length,y)),D=w.length,F=n-D,M=Math.min(s.length,p),I=Math.max(0,p-s.length),P=f.slice(I,I+F);return{folders:w,files:P,pagination:{currentPage:o,totalPages:b,totalFiles:m,filesPerPage:n}}}async createFolder(t,a){await ia(300);let o={id:Date.now(),name:t,parentId:a!=null?a:null,pathId:typeof a=="number"?a:0,path:"",fileCount:0,folderCount:0,createdAt:new Date,updatedAt:new Date};return Fe.push(o),o}getMetaDataType(t,a){return t.type.startsWith("image/")?{}:t.type.startsWith("video/")?{duration:0,videoSource:a!=null?a:Ya.LOCAL}:t.type.startsWith("audio/")?{duration:0}:{description:""}}getFileType(t){var o;let a="."+((o=t.name.split(".").pop())==null?void 0:o.toLowerCase());return Ue(t.type,a)}async uploadFiles(t,a){var n;await ia(500);let o=[];for(let{file:i,videoSource:l}of t){let c=this.getFileType(i),s="."+((n=i.name.split(".").pop())==null?void 0:n.toLowerCase()),f={id:Date.now()+Math.random(),name:i.name,folderId:a!=null?a:null,size:i.size,url:URL.createObjectURL(i),mime:i.type||"application/octet-stream",ext:s,metaData:this.getMetaDataType(i,l),createdAt:new Date,updatedAt:new Date,tags:[],width:c===K.IMAGE?800:void 0,height:c===K.IMAGE?600:void 0};Me.push(f),o.push(f)}return o}renameFolder(t,a){let o=Fe.find(n=>n.id===t);return o?(o.name=a,o.updatedAt=new Date,Promise.resolve(o)):Promise.reject(new Error("Folder not found"))}updateFileMetaData(t,a){let o=Me.find(c=>c.id===t);if(!o)return Promise.reject(new Error("File not found"));let l=a,{metaData:n}=l,i=g(l,["metaData"]);return Object.assign(o,i),n&&(o.metaData=r(r({},o.metaData),n)),o.updatedAt=new Date,Promise.resolve(o)}deleteFiles(t){for(let a of t){let o=Me.findIndex(n=>n.id===a);o!==-1&&Me.splice(o,1)}return Promise.resolve()}deleteFolders(t){for(let a of t){let o=Fe.findIndex(n=>n.id===a);if(o!==-1){Fe.splice(o,1);for(let n=Me.length-1;n>=0;n--)Me[n].folderId===a&&Me.splice(n,1)}}return Promise.resolve()}findFiles(t){let a=t==null?void 0:t.toLowerCase(),o=Me.filter(n=>{var i;return n.name.toLowerCase().includes(a)||((i=n.tags)==null?void 0:i.some(l=>l.toLowerCase().includes(a)))});return Promise.resolve(o)}findFolders(t){let a=t==null?void 0:t.toLowerCase(),o=Fe.filter(n=>n.name.toLowerCase().includes(a));return Promise.resolve(o)}moveFiles(t,a){let o=[];for(let n of t){let i=Me.find(l=>l.id===n);i&&(i.folderId=a,i.updatedAt=new Date,o.push(i))}return Promise.resolve(o)}moveFolders(t,a){let o=[];for(let n of t){let i=Fe.find(l=>l.id===n);i&&(i.parentId=a,i.updatedAt=new Date,o.push(i))}return Promise.resolve(o)}};export{as as FileManager,rs as FileManagerModal,ca as FileManagerProvider,Ro as MockProvider,E as useFileManager};
116
- //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "name": "@unciatech/file-manager",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
7
+ "bin": {
8
+ "file-manager": "dist/cli.js"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.js",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
7
18
  "files": [
8
19
  "dist",
9
20
  "README.md"
10
21
  ],
11
- "publishConfig": {
12
- "provenance": true
13
- },
14
22
  "author": "Avi",
15
23
  "license": "MIT",
16
24
  "repository": {