@unciatech/file-manager 0.0.41 → 0.0.43
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 +303 -288
- package/dist/chunk-NOCFQCIH.js +18 -0
- package/dist/chunk-XOGHUQYC.cjs +18 -0
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{mock-provider-DrtiUc3h.d.cts → mock-provider-D1q21QlM.d.cts} +1 -0
- package/dist/{mock-provider-DrtiUc3h.d.ts → mock-provider-D1q21QlM.d.ts} +1 -0
- package/dist/mock.cjs +1 -1
- package/dist/mock.d.cts +1 -1
- package/dist/mock.d.ts +1 -1
- package/dist/mock.js +1 -1
- package/package.json +1 -4
- package/dist/chunk-DXJH5W7A.js +0 -18
- package/dist/chunk-SV5VFLC2.cjs +0 -18
- package/dist/cli.cjs +0 -213
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -213
package/dist/cli.cjs
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';var e=require('fs'),o=require('path'),child_process=require('child_process'),f=require('readline');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var e__default=/*#__PURE__*/_interopDefault(e);var o__default=/*#__PURE__*/_interopDefault(o);var f__default=/*#__PURE__*/_interopDefault(f);var m=process.argv.slice(2),g=m[0],a=m[1],p=f__default.default.createInterface({input:process.stdin,output:process.stdout}),x=t=>new Promise(i=>p.question(t,i)),v=(t="/media")=>`"use client";
|
|
3
|
-
|
|
4
|
-
import React, { Suspense } from "react";
|
|
5
|
-
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
6
|
-
|
|
7
|
-
export default function FileManagerDemo() {
|
|
8
|
-
const mockProvider = new MockProvider();
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<div className="h-screen w-full">
|
|
12
|
-
<Suspense fallback={<div className="p-4">Loading Media Library...</div>}>
|
|
13
|
-
<FileManager
|
|
14
|
-
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
15
|
-
viewMode="grid"
|
|
16
|
-
provider={mockProvider}
|
|
17
|
-
basePath="${t}"
|
|
18
|
-
/>
|
|
19
|
-
</Suspense>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
`;async function w(){if(g!=="init"&&(console.log("Usage: npx @unciatech/file-manager init [project-name]"),process.exit(0)),!a){console.log("\u{1F680} Generating <FileManagerDemo /> component in the current project...");let s=process.cwd();e__default.default.existsSync(o__default.default.join(process.cwd(),"components"))?s=o__default.default.join(process.cwd(),"components"):e__default.default.existsSync(o__default.default.join(process.cwd(),"src","components"))&&(s=o__default.default.join(process.cwd(),"src","components"));let n=o__default.default.join(s,"FileManagerDemo.tsx");e__default.default.existsSync(n)&&(console.error(`\u274C Error: ${n} already exists.`),process.exit(1)),e__default.default.writeFileSync(n,v("/"),"utf-8"),console.log(`\u2705 Success! Created ${n}`),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!"),process.exit(0);}console.log(`
|
|
24
|
-
\u{1F680} Initializing a new application: ${a}
|
|
25
|
-
`),console.log("Which framework would you like to use?"),console.log(" 1) Next.js (App Router, Tailwind v4)"),console.log(" 2) Vite (React, Tailwind v4)"),console.log(" 3) Cancel");let t=await x(`
|
|
26
|
-
Select an option (1-3): `),i=o__default.default.join(process.cwd(),a);e__default.default.existsSync(i)&&(console.error(`
|
|
27
|
-
\u274C Error: Directory "${a}" already exists in ${process.cwd()}.`),console.error(" Please choose a different project name or delete the existing directory first."),p.close(),process.exit(1));try{t==="1"?await h(a,i):t==="2"?await y(a,i):(console.log("Canceled."),process.exit(0));}catch(s){console.error(`
|
|
28
|
-
\u274C Scaffolding failed:`,s),process.exit(1);}process.exit(0);}async function h(t,i){console.log(`
|
|
29
|
-
\u{1F4E6} Creating Next.js application (this may take a minute)...`),child_process.execSync(`npx create-next-app@latest ${t} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,{stdio:"inherit"}),console.log(`
|
|
30
|
-
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),child_process.execSync("npm install @unciatech/file-manager tailwindcss-animate",{cwd:i,stdio:"inherit"});let s=o__default.default.join(i,"src","app","page.tsx");e__default.default.writeFileSync(s,`"use client";
|
|
31
|
-
|
|
32
|
-
import { redirect } from "next/navigation";
|
|
33
|
-
|
|
34
|
-
export default function Home() {
|
|
35
|
-
redirect("/media");
|
|
36
|
-
}
|
|
37
|
-
`);let n=o__default.default.join(i,"src","app","media","[[...path]]");e__default.default.mkdirSync(n,{recursive:true}),e__default.default.writeFileSync(o__default.default.join(n,"page.tsx"),`"use client";
|
|
38
|
-
|
|
39
|
-
import { Suspense, useState } from "react";
|
|
40
|
-
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
41
|
-
import Link from "next/link";
|
|
42
|
-
|
|
43
|
-
function MediaPageContent() {
|
|
44
|
-
const [provider] = useState(() => new MockProvider());
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div className="h-screen w-full flex flex-col">
|
|
48
|
-
<div className="flex gap-4 p-4 border-b border-border items-center justify-between">
|
|
49
|
-
<h1 className="text-xl font-bold">Full Page View</h1>
|
|
50
|
-
<Link
|
|
51
|
-
href="/modal-demo"
|
|
52
|
-
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 cursor-pointer text-sm font-medium"
|
|
53
|
-
>
|
|
54
|
-
Go to Modal Demo
|
|
55
|
-
</Link>
|
|
56
|
-
</div>
|
|
57
|
-
<div className="flex-1 relative overflow-hidden">
|
|
58
|
-
<FileManager
|
|
59
|
-
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
60
|
-
viewMode="grid"
|
|
61
|
-
provider={provider}
|
|
62
|
-
basePath="/media"
|
|
63
|
-
/>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default function MediaPage() {
|
|
70
|
-
return (
|
|
71
|
-
<Suspense fallback={<div className="p-4">Loading Media Library...</div>}>
|
|
72
|
-
<MediaPageContent />
|
|
73
|
-
</Suspense>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
`);let c=o__default.default.join(i,"src","app","modal-demo");e__default.default.mkdirSync(c,{recursive:true}),e__default.default.writeFileSync(o__default.default.join(c,"page.tsx"),`"use client";
|
|
77
|
-
|
|
78
|
-
import { Suspense, useState } from "react";
|
|
79
|
-
import { FileManagerModal, MockProvider } from "@unciatech/file-manager";
|
|
80
|
-
import type { FileMetaData } from "@unciatech/file-manager";
|
|
81
|
-
import Link from "next/link";
|
|
82
|
-
|
|
83
|
-
function ModalDemoContent() {
|
|
84
|
-
const [provider] = useState(() => new MockProvider());
|
|
85
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
86
|
-
const [selectedFiles, setSelectedFiles] = useState<FileMetaData[]>([]);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<div className="p-10 flex flex-col items-start gap-6 min-h-screen w-full">
|
|
90
|
-
<div>
|
|
91
|
-
<h1 className="text-3xl font-bold mb-2">File Manager Demo</h1>
|
|
92
|
-
<p className="text-gray-500">Select files using the modal or browse the full page view.</p>
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
<div className="flex gap-4">
|
|
96
|
-
<button
|
|
97
|
-
onClick={() => setIsOpen(true)}
|
|
98
|
-
className="px-6 py-2.5 bg-blue-600 text-white rounded-md hover:bg-blue-700 cursor-pointer text-sm font-medium shadow-sm transition-colors"
|
|
99
|
-
>
|
|
100
|
-
Open File Picker Modal
|
|
101
|
-
</button>
|
|
102
|
-
<Link
|
|
103
|
-
href="/media"
|
|
104
|
-
className="px-6 py-2.5 bg-zinc-100 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 cursor-pointer text-sm font-medium transition-colors"
|
|
105
|
-
>
|
|
106
|
-
Go to Full Page View
|
|
107
|
-
</Link>
|
|
108
|
-
</div>
|
|
109
|
-
|
|
110
|
-
{selectedFiles.length > 0 && (
|
|
111
|
-
<div className="w-full mt-8">
|
|
112
|
-
<h2 className="text-xl font-semibold mb-4 border-b pb-2">
|
|
113
|
-
Selected Files ({selectedFiles.length})
|
|
114
|
-
</h2>
|
|
115
|
-
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
|
116
|
-
{selectedFiles.map((file, idx) => (
|
|
117
|
-
<div key={idx} className="border rounded-lg p-3 flex flex-col items-center gap-3 shadow-sm">
|
|
118
|
-
<div className="w-full aspect-square bg-gray-100 dark:bg-gray-800 rounded-md overflow-hidden flex items-center justify-center relative">
|
|
119
|
-
{file.url && file.mime?.startsWith("image/") ? (
|
|
120
|
-
<img src={file.url} alt={file.name} className="w-full h-full object-cover" />
|
|
121
|
-
) : (
|
|
122
|
-
<span className="text-gray-400 font-mono text-xs p-2 overflow-hidden text-ellipsis">
|
|
123
|
-
{file.ext?.toUpperCase() || "FILE"}
|
|
124
|
-
</span>
|
|
125
|
-
)}
|
|
126
|
-
</div>
|
|
127
|
-
<div className="w-full text-center">
|
|
128
|
-
<p className="text-sm font-medium truncate w-full" title={file.name}>{file.name}</p>
|
|
129
|
-
<p className="text-xs text-gray-500 mt-0.5">{(file.size / 1024).toFixed(1)} KB</p>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
))}
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
)}
|
|
136
|
-
|
|
137
|
-
<FileManagerModal
|
|
138
|
-
open={isOpen}
|
|
139
|
-
onClose={() => setIsOpen(false)}
|
|
140
|
-
provider={provider}
|
|
141
|
-
allowedFileTypes={["images", "videos", "audios", "files"]}
|
|
142
|
-
onFilesSelected={(files: FileMetaData[]) => {
|
|
143
|
-
setSelectedFiles(files);
|
|
144
|
-
setIsOpen(false);
|
|
145
|
-
}}
|
|
146
|
-
basePath="/media"
|
|
147
|
-
/>
|
|
148
|
-
</div>
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export default function ModalDemoPage() {
|
|
153
|
-
return (
|
|
154
|
-
<Suspense fallback={<div className="p-10">Loading...</div>}>
|
|
155
|
-
<ModalDemoContent />
|
|
156
|
-
</Suspense>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
`);let r=o__default.default.join(i,"src","app","layout.tsx");if(e__default.default.existsSync(r)){let d=e__default.default.readFileSync(r,"utf8");d.includes("@unciatech/file-manager/styles")||(d=d.replace(/^(import type)/m,`import '@unciatech/file-manager/styles';
|
|
160
|
-
$1`),e__default.default.writeFileSync(r,d));}let u=o__default.default.join(i,"src","app","globals.css");e__default.default.writeFileSync(u,`@import "tailwindcss";
|
|
161
|
-
@import "@unciatech/file-manager/styles";
|
|
162
|
-
@import "tw-animate-css";
|
|
163
|
-
|
|
164
|
-
@source "../../node_modules/@unciatech/file-manager";
|
|
165
|
-
|
|
166
|
-
@theme {
|
|
167
|
-
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
|
|
168
|
-
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
169
|
-
}
|
|
170
|
-
`),S(t);}async function y(t,i){if(console.log(`
|
|
171
|
-
\u{1F4E6} Creating Vite React application...`),child_process.execSync(`npm create vite@latest ${t} -- --template react-ts`,{stdio:"inherit"}),!e__default.default.existsSync(i))throw new Error("Project creation failed");process.chdir(i),console.log(`
|
|
172
|
-
\u{1F4E6} Installing dependencies...`),child_process.execSync("npm install",{stdio:"inherit"}),child_process.execSync("npm install tailwindcss @tailwindcss/vite @vitejs/plugin-react react-router-dom @unciatech/file-manager",{stdio:"inherit"}),console.log(`
|
|
173
|
-
\u2699\uFE0F Configuring Vite project...`);let s=o__default.default.join(i,"src");["App.tsx","App.css"].forEach(c=>{let r=o__default.default.join(s,c);e__default.default.existsSync(r)&&e__default.default.unlinkSync(r);}),e__default.default.writeFileSync(o__default.default.join(s,"index.css"),`@import "tailwindcss";
|
|
174
|
-
@import "@unciatech/file-manager/styles";
|
|
175
|
-
|
|
176
|
-
@source "../node_modules/@unciatech/file-manager";
|
|
177
|
-
`),e__default.default.writeFileSync(o__default.default.join(s,"main.tsx"),`import React from "react";
|
|
178
|
-
import ReactDOM from "react-dom/client";
|
|
179
|
-
import { BrowserRouter } from "react-router-dom";
|
|
180
|
-
import App from "./App";
|
|
181
|
-
import "./index.css";
|
|
182
|
-
|
|
183
|
-
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
184
|
-
<React.StrictMode>
|
|
185
|
-
<BrowserRouter>
|
|
186
|
-
<App />
|
|
187
|
-
</BrowserRouter>
|
|
188
|
-
</React.StrictMode>
|
|
189
|
-
);
|
|
190
|
-
`),e__default.default.writeFileSync(o__default.default.join(s,"App.tsx"),`import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
191
|
-
|
|
192
|
-
const provider = new MockProvider();
|
|
193
|
-
|
|
194
|
-
export default function App() {
|
|
195
|
-
return (
|
|
196
|
-
<div className="h-screen w-full">
|
|
197
|
-
<FileManager
|
|
198
|
-
provider={provider}
|
|
199
|
-
basePath="/"
|
|
200
|
-
viewMode="grid"
|
|
201
|
-
allowedFileTypes={["images","videos","audios","files"]}
|
|
202
|
-
/>
|
|
203
|
-
</div>
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
`),console.log(`
|
|
207
|
-
=================================`),console.log("\u{1F389} Vite File Manager ready!"),console.log(`=================================
|
|
208
|
-
`),console.log(`cd ${t}`),console.log(`npm run dev
|
|
209
|
-
`);}function S(t,i="npm run dev"){console.log(`
|
|
210
|
-
=========================================`),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log(`
|
|
211
|
-
Next steps:`),console.log(` cd ${t}`),console.log(` ${i}`),console.log(`
|
|
212
|
-
Enjoy building! \u{1F5C2}\uFE0F
|
|
213
|
-
`);}w();
|
package/dist/cli.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import e from'fs';import o from'path';import {execSync}from'child_process';import f from'readline';var m=process.argv.slice(2),g=m[0],a=m[1],p=f.createInterface({input:process.stdin,output:process.stdout}),x=t=>new Promise(i=>p.question(t,i)),v=(t="/media")=>`"use client";
|
|
3
|
-
|
|
4
|
-
import React, { Suspense } from "react";
|
|
5
|
-
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
6
|
-
|
|
7
|
-
export default function FileManagerDemo() {
|
|
8
|
-
const mockProvider = new MockProvider();
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<div className="h-screen w-full">
|
|
12
|
-
<Suspense fallback={<div className="p-4">Loading Media Library...</div>}>
|
|
13
|
-
<FileManager
|
|
14
|
-
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
15
|
-
viewMode="grid"
|
|
16
|
-
provider={mockProvider}
|
|
17
|
-
basePath="${t}"
|
|
18
|
-
/>
|
|
19
|
-
</Suspense>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
`;async function w(){if(g!=="init"&&(console.log("Usage: npx @unciatech/file-manager init [project-name]"),process.exit(0)),!a){console.log("\u{1F680} Generating <FileManagerDemo /> component in the current project...");let s=process.cwd();e.existsSync(o.join(process.cwd(),"components"))?s=o.join(process.cwd(),"components"):e.existsSync(o.join(process.cwd(),"src","components"))&&(s=o.join(process.cwd(),"src","components"));let n=o.join(s,"FileManagerDemo.tsx");e.existsSync(n)&&(console.error(`\u274C Error: ${n} already exists.`),process.exit(1)),e.writeFileSync(n,v("/"),"utf-8"),console.log(`\u2705 Success! Created ${n}`),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!"),process.exit(0);}console.log(`
|
|
24
|
-
\u{1F680} Initializing a new application: ${a}
|
|
25
|
-
`),console.log("Which framework would you like to use?"),console.log(" 1) Next.js (App Router, Tailwind v4)"),console.log(" 2) Vite (React, Tailwind v4)"),console.log(" 3) Cancel");let t=await x(`
|
|
26
|
-
Select an option (1-3): `),i=o.join(process.cwd(),a);e.existsSync(i)&&(console.error(`
|
|
27
|
-
\u274C Error: Directory "${a}" already exists in ${process.cwd()}.`),console.error(" Please choose a different project name or delete the existing directory first."),p.close(),process.exit(1));try{t==="1"?await h(a,i):t==="2"?await y(a,i):(console.log("Canceled."),process.exit(0));}catch(s){console.error(`
|
|
28
|
-
\u274C Scaffolding failed:`,s),process.exit(1);}process.exit(0);}async function h(t,i){console.log(`
|
|
29
|
-
\u{1F4E6} Creating Next.js application (this may take a minute)...`),execSync(`npx create-next-app@latest ${t} --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`,{stdio:"inherit"}),console.log(`
|
|
30
|
-
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),execSync("npm install @unciatech/file-manager tailwindcss-animate",{cwd:i,stdio:"inherit"});let s=o.join(i,"src","app","page.tsx");e.writeFileSync(s,`"use client";
|
|
31
|
-
|
|
32
|
-
import { redirect } from "next/navigation";
|
|
33
|
-
|
|
34
|
-
export default function Home() {
|
|
35
|
-
redirect("/media");
|
|
36
|
-
}
|
|
37
|
-
`);let n=o.join(i,"src","app","media","[[...path]]");e.mkdirSync(n,{recursive:true}),e.writeFileSync(o.join(n,"page.tsx"),`"use client";
|
|
38
|
-
|
|
39
|
-
import { Suspense, useState } from "react";
|
|
40
|
-
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
41
|
-
import Link from "next/link";
|
|
42
|
-
|
|
43
|
-
function MediaPageContent() {
|
|
44
|
-
const [provider] = useState(() => new MockProvider());
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div className="h-screen w-full flex flex-col">
|
|
48
|
-
<div className="flex gap-4 p-4 border-b border-border items-center justify-between">
|
|
49
|
-
<h1 className="text-xl font-bold">Full Page View</h1>
|
|
50
|
-
<Link
|
|
51
|
-
href="/modal-demo"
|
|
52
|
-
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 cursor-pointer text-sm font-medium"
|
|
53
|
-
>
|
|
54
|
-
Go to Modal Demo
|
|
55
|
-
</Link>
|
|
56
|
-
</div>
|
|
57
|
-
<div className="flex-1 relative overflow-hidden">
|
|
58
|
-
<FileManager
|
|
59
|
-
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
60
|
-
viewMode="grid"
|
|
61
|
-
provider={provider}
|
|
62
|
-
basePath="/media"
|
|
63
|
-
/>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default function MediaPage() {
|
|
70
|
-
return (
|
|
71
|
-
<Suspense fallback={<div className="p-4">Loading Media Library...</div>}>
|
|
72
|
-
<MediaPageContent />
|
|
73
|
-
</Suspense>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
`);let c=o.join(i,"src","app","modal-demo");e.mkdirSync(c,{recursive:true}),e.writeFileSync(o.join(c,"page.tsx"),`"use client";
|
|
77
|
-
|
|
78
|
-
import { Suspense, useState } from "react";
|
|
79
|
-
import { FileManagerModal, MockProvider } from "@unciatech/file-manager";
|
|
80
|
-
import type { FileMetaData } from "@unciatech/file-manager";
|
|
81
|
-
import Link from "next/link";
|
|
82
|
-
|
|
83
|
-
function ModalDemoContent() {
|
|
84
|
-
const [provider] = useState(() => new MockProvider());
|
|
85
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
86
|
-
const [selectedFiles, setSelectedFiles] = useState<FileMetaData[]>([]);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<div className="p-10 flex flex-col items-start gap-6 min-h-screen w-full">
|
|
90
|
-
<div>
|
|
91
|
-
<h1 className="text-3xl font-bold mb-2">File Manager Demo</h1>
|
|
92
|
-
<p className="text-gray-500">Select files using the modal or browse the full page view.</p>
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
<div className="flex gap-4">
|
|
96
|
-
<button
|
|
97
|
-
onClick={() => setIsOpen(true)}
|
|
98
|
-
className="px-6 py-2.5 bg-blue-600 text-white rounded-md hover:bg-blue-700 cursor-pointer text-sm font-medium shadow-sm transition-colors"
|
|
99
|
-
>
|
|
100
|
-
Open File Picker Modal
|
|
101
|
-
</button>
|
|
102
|
-
<Link
|
|
103
|
-
href="/media"
|
|
104
|
-
className="px-6 py-2.5 bg-zinc-100 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 rounded-md hover:bg-zinc-200 dark:hover:bg-zinc-700 cursor-pointer text-sm font-medium transition-colors"
|
|
105
|
-
>
|
|
106
|
-
Go to Full Page View
|
|
107
|
-
</Link>
|
|
108
|
-
</div>
|
|
109
|
-
|
|
110
|
-
{selectedFiles.length > 0 && (
|
|
111
|
-
<div className="w-full mt-8">
|
|
112
|
-
<h2 className="text-xl font-semibold mb-4 border-b pb-2">
|
|
113
|
-
Selected Files ({selectedFiles.length})
|
|
114
|
-
</h2>
|
|
115
|
-
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
|
116
|
-
{selectedFiles.map((file, idx) => (
|
|
117
|
-
<div key={idx} className="border rounded-lg p-3 flex flex-col items-center gap-3 shadow-sm">
|
|
118
|
-
<div className="w-full aspect-square bg-gray-100 dark:bg-gray-800 rounded-md overflow-hidden flex items-center justify-center relative">
|
|
119
|
-
{file.url && file.mime?.startsWith("image/") ? (
|
|
120
|
-
<img src={file.url} alt={file.name} className="w-full h-full object-cover" />
|
|
121
|
-
) : (
|
|
122
|
-
<span className="text-gray-400 font-mono text-xs p-2 overflow-hidden text-ellipsis">
|
|
123
|
-
{file.ext?.toUpperCase() || "FILE"}
|
|
124
|
-
</span>
|
|
125
|
-
)}
|
|
126
|
-
</div>
|
|
127
|
-
<div className="w-full text-center">
|
|
128
|
-
<p className="text-sm font-medium truncate w-full" title={file.name}>{file.name}</p>
|
|
129
|
-
<p className="text-xs text-gray-500 mt-0.5">{(file.size / 1024).toFixed(1)} KB</p>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
))}
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
)}
|
|
136
|
-
|
|
137
|
-
<FileManagerModal
|
|
138
|
-
open={isOpen}
|
|
139
|
-
onClose={() => setIsOpen(false)}
|
|
140
|
-
provider={provider}
|
|
141
|
-
allowedFileTypes={["images", "videos", "audios", "files"]}
|
|
142
|
-
onFilesSelected={(files: FileMetaData[]) => {
|
|
143
|
-
setSelectedFiles(files);
|
|
144
|
-
setIsOpen(false);
|
|
145
|
-
}}
|
|
146
|
-
basePath="/media"
|
|
147
|
-
/>
|
|
148
|
-
</div>
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export default function ModalDemoPage() {
|
|
153
|
-
return (
|
|
154
|
-
<Suspense fallback={<div className="p-10">Loading...</div>}>
|
|
155
|
-
<ModalDemoContent />
|
|
156
|
-
</Suspense>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
`);let r=o.join(i,"src","app","layout.tsx");if(e.existsSync(r)){let d=e.readFileSync(r,"utf8");d.includes("@unciatech/file-manager/styles")||(d=d.replace(/^(import type)/m,`import '@unciatech/file-manager/styles';
|
|
160
|
-
$1`),e.writeFileSync(r,d));}let u=o.join(i,"src","app","globals.css");e.writeFileSync(u,`@import "tailwindcss";
|
|
161
|
-
@import "@unciatech/file-manager/styles";
|
|
162
|
-
@import "tw-animate-css";
|
|
163
|
-
|
|
164
|
-
@source "../../node_modules/@unciatech/file-manager";
|
|
165
|
-
|
|
166
|
-
@theme {
|
|
167
|
-
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
|
|
168
|
-
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
169
|
-
}
|
|
170
|
-
`),S(t);}async function y(t,i){if(console.log(`
|
|
171
|
-
\u{1F4E6} Creating Vite React application...`),execSync(`npm create vite@latest ${t} -- --template react-ts`,{stdio:"inherit"}),!e.existsSync(i))throw new Error("Project creation failed");process.chdir(i),console.log(`
|
|
172
|
-
\u{1F4E6} Installing dependencies...`),execSync("npm install",{stdio:"inherit"}),execSync("npm install tailwindcss @tailwindcss/vite @vitejs/plugin-react react-router-dom @unciatech/file-manager",{stdio:"inherit"}),console.log(`
|
|
173
|
-
\u2699\uFE0F Configuring Vite project...`);let s=o.join(i,"src");["App.tsx","App.css"].forEach(c=>{let r=o.join(s,c);e.existsSync(r)&&e.unlinkSync(r);}),e.writeFileSync(o.join(s,"index.css"),`@import "tailwindcss";
|
|
174
|
-
@import "@unciatech/file-manager/styles";
|
|
175
|
-
|
|
176
|
-
@source "../node_modules/@unciatech/file-manager";
|
|
177
|
-
`),e.writeFileSync(o.join(s,"main.tsx"),`import React from "react";
|
|
178
|
-
import ReactDOM from "react-dom/client";
|
|
179
|
-
import { BrowserRouter } from "react-router-dom";
|
|
180
|
-
import App from "./App";
|
|
181
|
-
import "./index.css";
|
|
182
|
-
|
|
183
|
-
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
184
|
-
<React.StrictMode>
|
|
185
|
-
<BrowserRouter>
|
|
186
|
-
<App />
|
|
187
|
-
</BrowserRouter>
|
|
188
|
-
</React.StrictMode>
|
|
189
|
-
);
|
|
190
|
-
`),e.writeFileSync(o.join(s,"App.tsx"),`import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
191
|
-
|
|
192
|
-
const provider = new MockProvider();
|
|
193
|
-
|
|
194
|
-
export default function App() {
|
|
195
|
-
return (
|
|
196
|
-
<div className="h-screen w-full">
|
|
197
|
-
<FileManager
|
|
198
|
-
provider={provider}
|
|
199
|
-
basePath="/"
|
|
200
|
-
viewMode="grid"
|
|
201
|
-
allowedFileTypes={["images","videos","audios","files"]}
|
|
202
|
-
/>
|
|
203
|
-
</div>
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
`),console.log(`
|
|
207
|
-
=================================`),console.log("\u{1F389} Vite File Manager ready!"),console.log(`=================================
|
|
208
|
-
`),console.log(`cd ${t}`),console.log(`npm run dev
|
|
209
|
-
`);}function S(t,i="npm run dev"){console.log(`
|
|
210
|
-
=========================================`),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log(`
|
|
211
|
-
Next steps:`),console.log(` cd ${t}`),console.log(` ${i}`),console.log(`
|
|
212
|
-
Enjoy building! \u{1F5C2}\uFE0F
|
|
213
|
-
`);}w();
|