@unciatech/file-manager 0.0.39 → 0.0.41
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/dist/cli.cjs +40 -139
- package/dist/cli.js +40 -139
- package/package.json +4 -3
- package/bin/file-manager.js +0 -3
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
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
3
|
|
|
4
4
|
import React, { Suspense } from "react";
|
|
5
5
|
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
@@ -14,27 +14,27 @@ export default function FileManagerDemo() {
|
|
|
14
14
|
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
15
15
|
viewMode="grid"
|
|
16
16
|
provider={mockProvider}
|
|
17
|
-
basePath="${
|
|
17
|
+
basePath="${t}"
|
|
18
18
|
/>
|
|
19
19
|
</Suspense>
|
|
20
20
|
</div>
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
|
-
`;async function w(){if(
|
|
24
|
-
\u{1F680} Initializing a new application: ${
|
|
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
|
|
26
|
-
Select an option (1-3): `),
|
|
27
|
-
\u274C Error: Directory "${
|
|
28
|
-
\u274C Scaffolding failed:`,s),process.exit(1);}process.exit(0);}async function
|
|
29
|
-
\u{1F4E6} Creating Next.js application (this may take a minute)...`),child_process.execSync(`npx create-next-app@latest ${
|
|
30
|
-
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),child_process.execSync("npm install @unciatech/file-manager tailwindcss-animate",{cwd:
|
|
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
31
|
|
|
32
32
|
import { redirect } from "next/navigation";
|
|
33
33
|
|
|
34
34
|
export default function Home() {
|
|
35
35
|
redirect("/media");
|
|
36
36
|
}
|
|
37
|
-
`);let
|
|
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
38
|
|
|
39
39
|
import { Suspense, useState } from "react";
|
|
40
40
|
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
@@ -73,7 +73,7 @@ export default function MediaPage() {
|
|
|
73
73
|
</Suspense>
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
-
`);let
|
|
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
77
|
|
|
78
78
|
import { Suspense, useState } from "react";
|
|
79
79
|
import { FileManagerModal, MockProvider } from "@unciatech/file-manager";
|
|
@@ -156,8 +156,8 @@ export default function ModalDemoPage() {
|
|
|
156
156
|
</Suspense>
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
|
-
`);let r=
|
|
160
|
-
$1`),
|
|
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
161
|
@import "@unciatech/file-manager/styles";
|
|
162
162
|
@import "tw-animate-css";
|
|
163
163
|
|
|
@@ -167,146 +167,47 @@ $1`),t__default.default.writeFileSync(r,n));}let m=i__default.default.join(e,"sr
|
|
|
167
167
|
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
|
|
168
168
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
169
169
|
}
|
|
170
|
-
`),
|
|
171
|
-
\u{1F4E6} Creating Vite React application...`),child_process.execSync(`npm create vite@latest ${
|
|
172
|
-
\u{1F4E6} Installing dependencies
|
|
173
|
-
|
|
174
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
175
|
-
|
|
176
|
-
export default defineConfig({
|
|
177
|
-
plugins: [
|
|
178
|
-
react(),
|
|
179
|
-
tailwindcss(),
|
|
180
|
-
],
|
|
181
|
-
})
|
|
182
|
-
`);let d=i__default.default.join(e,"src","index.css");t__default.default.writeFileSync(d,`@import "tailwindcss";
|
|
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";
|
|
183
174
|
@import "@unciatech/file-manager/styles";
|
|
175
|
+
|
|
184
176
|
@source "../node_modules/@unciatech/file-manager";
|
|
185
|
-
`)
|
|
186
|
-
import ReactDOM from
|
|
187
|
-
import { BrowserRouter } from
|
|
188
|
-
import App from
|
|
189
|
-
import
|
|
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";
|
|
190
182
|
|
|
191
|
-
ReactDOM.createRoot(document.getElementById(
|
|
183
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
192
184
|
<React.StrictMode>
|
|
193
185
|
<BrowserRouter>
|
|
194
186
|
<App />
|
|
195
187
|
</BrowserRouter>
|
|
196
|
-
</React.StrictMode
|
|
197
|
-
)
|
|
198
|
-
`)
|
|
199
|
-
import { useNavigate, Routes, Route, Link } from 'react-router-dom'
|
|
200
|
-
import { FileManager, FileManagerModal, MockProvider } from '@unciatech/file-manager'
|
|
201
|
-
import type { FileMetaData } from '@unciatech/file-manager'
|
|
202
|
-
|
|
203
|
-
const provider = new MockProvider()
|
|
204
|
-
|
|
205
|
-
function FullPage() {
|
|
206
|
-
const navigate = useNavigate()
|
|
207
|
-
|
|
208
|
-
return (
|
|
209
|
-
<div className="h-screen w-full flex flex-col">
|
|
210
|
-
<div className="flex gap-4 p-4 border-b border-border items-center justify-between">
|
|
211
|
-
<h1 className="text-xl font-bold">Full Page View</h1>
|
|
212
|
-
<Link
|
|
213
|
-
to="/"
|
|
214
|
-
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 cursor-pointer text-sm font-medium"
|
|
215
|
-
>
|
|
216
|
-
Back to Modal Demo
|
|
217
|
-
</Link>
|
|
218
|
-
</div>
|
|
219
|
-
|
|
220
|
-
<div className="flex-1 relative overflow-hidden">
|
|
221
|
-
<FileManager
|
|
222
|
-
provider={provider}
|
|
223
|
-
basePath="full"
|
|
224
|
-
allowedFileTypes={["images", "videos", "audios", "files"]}
|
|
225
|
-
viewMode="grid"
|
|
226
|
-
onNavigate={(url, opts) => navigate(url, { replace: opts?.replace })}
|
|
227
|
-
/>
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
|
-
)
|
|
231
|
-
}
|
|
188
|
+
</React.StrictMode>
|
|
189
|
+
);
|
|
190
|
+
`),e__default.default.writeFileSync(o__default.default.join(s,"App.tsx"),`import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
232
191
|
|
|
233
|
-
|
|
234
|
-
const navigate = useNavigate()
|
|
235
|
-
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
236
|
-
const [selectedFiles, setSelectedFiles] = useState<FileMetaData[]>([])
|
|
192
|
+
const provider = new MockProvider();
|
|
237
193
|
|
|
194
|
+
export default function App() {
|
|
238
195
|
return (
|
|
239
|
-
<div className="
|
|
240
|
-
<
|
|
241
|
-
<h1 className="text-3xl font-bold mb-2">File Manager Demo</h1>
|
|
242
|
-
<p className="text-muted-foreground">Select files using the modal or browse the full page view.</p>
|
|
243
|
-
</div>
|
|
244
|
-
|
|
245
|
-
<div className="flex gap-4">
|
|
246
|
-
<button
|
|
247
|
-
onClick={() => setIsModalOpen(true)}
|
|
248
|
-
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"
|
|
249
|
-
>
|
|
250
|
-
Open File Picker Modal
|
|
251
|
-
</button>
|
|
252
|
-
<Link
|
|
253
|
-
to="/full"
|
|
254
|
-
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"
|
|
255
|
-
>
|
|
256
|
-
Go to Full Page View
|
|
257
|
-
</Link>
|
|
258
|
-
</div>
|
|
259
|
-
|
|
260
|
-
{selectedFiles.length > 0 && (
|
|
261
|
-
<div className="w-full mt-8">
|
|
262
|
-
<h2 className="text-xl font-semibold mb-4 border-b pb-2">Selected Files ({selectedFiles.length})</h2>
|
|
263
|
-
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
|
264
|
-
{selectedFiles.map((file, idx) => (
|
|
265
|
-
<div key={idx} className="border border-border rounded-lg p-3 flex flex-col items-center gap-3 bg-card shadow-sm">
|
|
266
|
-
<div className="w-full aspect-square bg-muted rounded-md overflow-hidden flex items-center justify-center relative">
|
|
267
|
-
{file.url && file.mime?.startsWith('image/') ? (
|
|
268
|
-
<img src={file.url} alt={file.name} className="w-full h-full object-cover" />
|
|
269
|
-
) : (
|
|
270
|
-
<span className="text-muted-foreground font-mono text-xs p-2 overflow-hidden text-ellipsis">{file.ext?.toUpperCase() || 'FILE'}</span>
|
|
271
|
-
)}
|
|
272
|
-
</div>
|
|
273
|
-
<div className="w-full text-center">
|
|
274
|
-
<p className="text-sm font-medium truncate w-full" title={file.name}>{file.name}</p>
|
|
275
|
-
<p className="text-xs text-muted-foreground mt-0.5">{(file.size / 1024).toFixed(1)} KB</p>
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
))}
|
|
279
|
-
</div>
|
|
280
|
-
</div>
|
|
281
|
-
)}
|
|
282
|
-
|
|
283
|
-
<FileManagerModal
|
|
284
|
-
open={isModalOpen}
|
|
285
|
-
onClose={() => setIsModalOpen(false)}
|
|
196
|
+
<div className="h-screen w-full">
|
|
197
|
+
<FileManager
|
|
286
198
|
provider={provider}
|
|
287
199
|
basePath="/"
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
setSelectedFiles(files)
|
|
291
|
-
}}
|
|
292
|
-
onNavigate={(url, opts) => navigate(url, { replace: opts?.replace })}
|
|
200
|
+
viewMode="grid"
|
|
201
|
+
allowedFileTypes={["images","videos","audios","files"]}
|
|
293
202
|
/>
|
|
294
203
|
</div>
|
|
295
|
-
)
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function App() {
|
|
299
|
-
return (
|
|
300
|
-
<Routes>
|
|
301
|
-
<Route path="/" element={<ModalDemo />} />
|
|
302
|
-
<Route path="/full/*" element={<FullPage />} />
|
|
303
|
-
</Routes>
|
|
304
|
-
)
|
|
204
|
+
);
|
|
305
205
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
`)
|
|
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(`
|
|
309
210
|
=========================================`),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log(`
|
|
310
|
-
Next steps:`),console.log(` cd ${
|
|
211
|
+
Next steps:`),console.log(` cd ${t}`),console.log(` ${i}`),console.log(`
|
|
311
212
|
Enjoy building! \u{1F5C2}\uFE0F
|
|
312
213
|
`);}w();
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
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
3
|
|
|
4
4
|
import React, { Suspense } from "react";
|
|
5
5
|
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
@@ -14,27 +14,27 @@ export default function FileManagerDemo() {
|
|
|
14
14
|
allowedFileTypes={["audios", "videos", "images", "files"]}
|
|
15
15
|
viewMode="grid"
|
|
16
16
|
provider={mockProvider}
|
|
17
|
-
basePath="${
|
|
17
|
+
basePath="${t}"
|
|
18
18
|
/>
|
|
19
19
|
</Suspense>
|
|
20
20
|
</div>
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
|
-
`;async function w(){if(
|
|
24
|
-
\u{1F680} Initializing a new application: ${
|
|
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
|
|
26
|
-
Select an option (1-3): `),
|
|
27
|
-
\u274C Error: Directory "${
|
|
28
|
-
\u274C Scaffolding failed:`,s),process.exit(1);}process.exit(0);}async function
|
|
29
|
-
\u{1F4E6} Creating Next.js application (this may take a minute)...`),execSync(`npx create-next-app@latest ${
|
|
30
|
-
\u{1F4E6} Installing dependencies (@unciatech/file-manager, tailwindcss-animate)...`),execSync("npm install @unciatech/file-manager tailwindcss-animate",{cwd:
|
|
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
31
|
|
|
32
32
|
import { redirect } from "next/navigation";
|
|
33
33
|
|
|
34
34
|
export default function Home() {
|
|
35
35
|
redirect("/media");
|
|
36
36
|
}
|
|
37
|
-
`);let
|
|
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
38
|
|
|
39
39
|
import { Suspense, useState } from "react";
|
|
40
40
|
import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
@@ -73,7 +73,7 @@ export default function MediaPage() {
|
|
|
73
73
|
</Suspense>
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
|
-
`);let
|
|
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
77
|
|
|
78
78
|
import { Suspense, useState } from "react";
|
|
79
79
|
import { FileManagerModal, MockProvider } from "@unciatech/file-manager";
|
|
@@ -156,8 +156,8 @@ export default function ModalDemoPage() {
|
|
|
156
156
|
</Suspense>
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
|
-
`);let r=
|
|
160
|
-
$1`),
|
|
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
161
|
@import "@unciatech/file-manager/styles";
|
|
162
162
|
@import "tw-animate-css";
|
|
163
163
|
|
|
@@ -167,146 +167,47 @@ $1`),t.writeFileSync(r,n));}let m=i.join(e,"src","app","globals.css");t.writeFil
|
|
|
167
167
|
--font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
|
|
168
168
|
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
169
169
|
}
|
|
170
|
-
`),
|
|
171
|
-
\u{1F4E6} Creating Vite React application...`),execSync(`npm create vite@latest ${
|
|
172
|
-
\u{1F4E6} Installing dependencies
|
|
173
|
-
|
|
174
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
175
|
-
|
|
176
|
-
export default defineConfig({
|
|
177
|
-
plugins: [
|
|
178
|
-
react(),
|
|
179
|
-
tailwindcss(),
|
|
180
|
-
],
|
|
181
|
-
})
|
|
182
|
-
`);let d=i.join(e,"src","index.css");t.writeFileSync(d,`@import "tailwindcss";
|
|
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";
|
|
183
174
|
@import "@unciatech/file-manager/styles";
|
|
175
|
+
|
|
184
176
|
@source "../node_modules/@unciatech/file-manager";
|
|
185
|
-
`)
|
|
186
|
-
import ReactDOM from
|
|
187
|
-
import { BrowserRouter } from
|
|
188
|
-
import App from
|
|
189
|
-
import
|
|
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";
|
|
190
182
|
|
|
191
|
-
ReactDOM.createRoot(document.getElementById(
|
|
183
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
192
184
|
<React.StrictMode>
|
|
193
185
|
<BrowserRouter>
|
|
194
186
|
<App />
|
|
195
187
|
</BrowserRouter>
|
|
196
|
-
</React.StrictMode
|
|
197
|
-
)
|
|
198
|
-
`)
|
|
199
|
-
import { useNavigate, Routes, Route, Link } from 'react-router-dom'
|
|
200
|
-
import { FileManager, FileManagerModal, MockProvider } from '@unciatech/file-manager'
|
|
201
|
-
import type { FileMetaData } from '@unciatech/file-manager'
|
|
202
|
-
|
|
203
|
-
const provider = new MockProvider()
|
|
204
|
-
|
|
205
|
-
function FullPage() {
|
|
206
|
-
const navigate = useNavigate()
|
|
207
|
-
|
|
208
|
-
return (
|
|
209
|
-
<div className="h-screen w-full flex flex-col">
|
|
210
|
-
<div className="flex gap-4 p-4 border-b border-border items-center justify-between">
|
|
211
|
-
<h1 className="text-xl font-bold">Full Page View</h1>
|
|
212
|
-
<Link
|
|
213
|
-
to="/"
|
|
214
|
-
className="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 cursor-pointer text-sm font-medium"
|
|
215
|
-
>
|
|
216
|
-
Back to Modal Demo
|
|
217
|
-
</Link>
|
|
218
|
-
</div>
|
|
219
|
-
|
|
220
|
-
<div className="flex-1 relative overflow-hidden">
|
|
221
|
-
<FileManager
|
|
222
|
-
provider={provider}
|
|
223
|
-
basePath="full"
|
|
224
|
-
allowedFileTypes={["images", "videos", "audios", "files"]}
|
|
225
|
-
viewMode="grid"
|
|
226
|
-
onNavigate={(url, opts) => navigate(url, { replace: opts?.replace })}
|
|
227
|
-
/>
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
|
-
)
|
|
231
|
-
}
|
|
188
|
+
</React.StrictMode>
|
|
189
|
+
);
|
|
190
|
+
`),e.writeFileSync(o.join(s,"App.tsx"),`import { FileManager, MockProvider } from "@unciatech/file-manager";
|
|
232
191
|
|
|
233
|
-
|
|
234
|
-
const navigate = useNavigate()
|
|
235
|
-
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
236
|
-
const [selectedFiles, setSelectedFiles] = useState<FileMetaData[]>([])
|
|
192
|
+
const provider = new MockProvider();
|
|
237
193
|
|
|
194
|
+
export default function App() {
|
|
238
195
|
return (
|
|
239
|
-
<div className="
|
|
240
|
-
<
|
|
241
|
-
<h1 className="text-3xl font-bold mb-2">File Manager Demo</h1>
|
|
242
|
-
<p className="text-muted-foreground">Select files using the modal or browse the full page view.</p>
|
|
243
|
-
</div>
|
|
244
|
-
|
|
245
|
-
<div className="flex gap-4">
|
|
246
|
-
<button
|
|
247
|
-
onClick={() => setIsModalOpen(true)}
|
|
248
|
-
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"
|
|
249
|
-
>
|
|
250
|
-
Open File Picker Modal
|
|
251
|
-
</button>
|
|
252
|
-
<Link
|
|
253
|
-
to="/full"
|
|
254
|
-
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"
|
|
255
|
-
>
|
|
256
|
-
Go to Full Page View
|
|
257
|
-
</Link>
|
|
258
|
-
</div>
|
|
259
|
-
|
|
260
|
-
{selectedFiles.length > 0 && (
|
|
261
|
-
<div className="w-full mt-8">
|
|
262
|
-
<h2 className="text-xl font-semibold mb-4 border-b pb-2">Selected Files ({selectedFiles.length})</h2>
|
|
263
|
-
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
|
264
|
-
{selectedFiles.map((file, idx) => (
|
|
265
|
-
<div key={idx} className="border border-border rounded-lg p-3 flex flex-col items-center gap-3 bg-card shadow-sm">
|
|
266
|
-
<div className="w-full aspect-square bg-muted rounded-md overflow-hidden flex items-center justify-center relative">
|
|
267
|
-
{file.url && file.mime?.startsWith('image/') ? (
|
|
268
|
-
<img src={file.url} alt={file.name} className="w-full h-full object-cover" />
|
|
269
|
-
) : (
|
|
270
|
-
<span className="text-muted-foreground font-mono text-xs p-2 overflow-hidden text-ellipsis">{file.ext?.toUpperCase() || 'FILE'}</span>
|
|
271
|
-
)}
|
|
272
|
-
</div>
|
|
273
|
-
<div className="w-full text-center">
|
|
274
|
-
<p className="text-sm font-medium truncate w-full" title={file.name}>{file.name}</p>
|
|
275
|
-
<p className="text-xs text-muted-foreground mt-0.5">{(file.size / 1024).toFixed(1)} KB</p>
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
))}
|
|
279
|
-
</div>
|
|
280
|
-
</div>
|
|
281
|
-
)}
|
|
282
|
-
|
|
283
|
-
<FileManagerModal
|
|
284
|
-
open={isModalOpen}
|
|
285
|
-
onClose={() => setIsModalOpen(false)}
|
|
196
|
+
<div className="h-screen w-full">
|
|
197
|
+
<FileManager
|
|
286
198
|
provider={provider}
|
|
287
199
|
basePath="/"
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
setSelectedFiles(files)
|
|
291
|
-
}}
|
|
292
|
-
onNavigate={(url, opts) => navigate(url, { replace: opts?.replace })}
|
|
200
|
+
viewMode="grid"
|
|
201
|
+
allowedFileTypes={["images","videos","audios","files"]}
|
|
293
202
|
/>
|
|
294
203
|
</div>
|
|
295
|
-
)
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function App() {
|
|
299
|
-
return (
|
|
300
|
-
<Routes>
|
|
301
|
-
<Route path="/" element={<ModalDemo />} />
|
|
302
|
-
<Route path="/full/*" element={<FullPage />} />
|
|
303
|
-
</Routes>
|
|
304
|
-
)
|
|
204
|
+
);
|
|
305
205
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
`)
|
|
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(`
|
|
309
210
|
=========================================`),console.log("\u{1F389} Your Media Library application is ready!"),console.log("========================================="),console.log(`
|
|
310
|
-
Next steps:`),console.log(` cd ${
|
|
211
|
+
Next steps:`),console.log(` cd ${t}`),console.log(` ${i}`),console.log(`
|
|
311
212
|
Enjoy building! \u{1F5C2}\uFE0F
|
|
312
213
|
`);}w();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unciatech/file-manager",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "Modern file manager component for React applications",
|
|
5
5
|
"author": "Avi",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"main": "./dist/index.cjs",
|
|
22
22
|
"module": "./dist/index.js",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
|
-
"bin":
|
|
24
|
+
"bin": {
|
|
25
|
+
"file-manager": "./dist/cli.cjs"
|
|
26
|
+
},
|
|
25
27
|
"exports": {
|
|
26
28
|
".": {
|
|
27
29
|
"types": "./dist/index.d.ts",
|
|
@@ -41,7 +43,6 @@
|
|
|
41
43
|
},
|
|
42
44
|
"files": [
|
|
43
45
|
"dist",
|
|
44
|
-
"bin",
|
|
45
46
|
"README.md"
|
|
46
47
|
],
|
|
47
48
|
"sideEffects": [
|
package/bin/file-manager.js
DELETED