@cubone/react-file-manager 1.0.0 → 1.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
@@ -1,83 +1,72 @@
1
- # File Manager Component
1
+ # React File Manager
2
2
 
3
- ## Overview
4
-
5
- The File Manager Component is an open-source React.js package designed to help developers easily integrate a file manager into their applications. This component provides a user-friendly interface along with essential functionalities for managing files and folders, such as viewing, uploading and deleting within a specified directory structure. Ideal for anyone looking to build or enhance a file management system, this package offers both UI and backend integration capabilities.
3
+ An open-source React.js package for easy integration of a file manager into applications. It provides a user-friendly interface for managing files and folders, including viewing, uploading, and deleting, with full UI and backend integration.
6
4
 
7
5
  ## Features
8
6
 
9
7
  - **View Files and Folders**: Display the directory structure with folders and files.
10
8
  - **Upload Files**: Upload new files to a selected directory.
11
9
  - **Delete Files and Folders**: Remove unwanted files or folders.
10
+ - **Toolbar**: Access common file operations such as upload, delete, and refresh with a convenient toolbar.
12
11
  - **Breadcrumb Navigation**: Easily navigate through the directory structure.
13
- - **Responsive Design**: Works seamlessly on both desktop and mobile devices.
12
+ - **Navigation Pane**: Easily switch between folders and directories with a sidebar navigation pane.
13
+ - **Context Menu**: Right-click to open a context menu with options for cutting, copying, pasting, renaming, and deleting files or folders.
14
14
 
15
15
  ## Installation
16
16
 
17
- To get started with the File Manager Component, follow these steps:
18
-
19
- ### Prerequisites
20
-
21
- Ensure you have the following installed on your system:
22
-
23
- - Node.js (v14 or later)
24
- - npm (v6 or later)
25
-
26
- ### Clone the Repository
17
+ To install `React File Manager`, use the following command:
27
18
 
28
19
  ```bash
29
- git clone https://github.com/Saifullah-dev/react-file-manager.git
30
- cd react-file-manager
31
- ```
32
-
33
- ### Install Dependencies
34
-
35
- Using npm:
36
-
37
- ```bash
38
- npm i
39
- ```
40
-
41
- ### Start the Development Server
42
-
43
- To start the development server and see the File Manager in action:
44
-
45
- ```bash
46
- npm run dev
20
+ npm i @cubone/react-file-manager
47
21
  ```
48
22
 
49
- The application should now be running on `http://localhost:5173`.
50
-
51
23
  ## Usage
52
24
 
53
- ### File Structure
54
-
55
- - **src/**: Contains all the source code.
56
- - **components/**: Reusable components like `Button`, `Context Menu`, `Modal`, etc.
57
- - **File Manager/**: The main directory for the File Manager component.
58
- - **hooks/**: Custom hooks for handling various interactions and UI state.
59
- - **Mock APIs/**: Simulated API functions for demonstration purposes.
60
- - **utils/**: Utility functions and helpers.
61
- - **App.js**: Main entry point of the application.
62
- - **index.js**: Application bootstrap and rendering.
63
-
64
- ## Available Scripts
65
-
66
- In the project directory, you can run:
67
-
68
- - `npm run dev`: Runs the app in development mode.
69
- - `npm run build`: Builds the app for production.
70
- - `npm test`: Launches the test runner.
71
-
72
- ## Deployment
73
-
74
- To deploy the app, first build the project:
75
-
76
- ```bash
77
- npm run build
25
+ Here’s a basic example of how to use the File Manager Component in your React application:
26
+
27
+ ```javascript
28
+ import { useState } from "react";
29
+ import { FileManager } from "@cubone/react-file-manager";
30
+ import "@cubone/react-file-manager/dist/style.css";
31
+
32
+ function App() {
33
+ const [files, setFiles] = useState([
34
+ {
35
+ name: "Documents",
36
+ isDirectory: true,
37
+ path: "", // Root directory
38
+ },
39
+ {
40
+ name: "Pictures",
41
+ isDirectory: true,
42
+ path: "", // Root directory
43
+ },
44
+ {
45
+ name: "Pic.png",
46
+ isDirectory: false,
47
+ path: "/Pictures", // Located inside the "Pictures" folder
48
+ },
49
+ ]);
50
+
51
+ return (
52
+ <>
53
+ <FileManager files={files} />
54
+ </>
55
+ );
56
+ }
78
57
  ```
79
-
80
- This will create a `build/` directory containing the production-ready code. You can then deploy the contents of this directory to your preferred hosting service.
58
+ ## Props
59
+
60
+ | Name | Type | Description |
61
+ |-----------------|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
62
+ | `files` | `Array<{ name: string, isDirectory: boolean, path: string }>` | An array of file and folder objects representing the current directory structure. Each object includes `name`, `isDirectory`, and `path` properties. |
63
+ | `isLoading` | `boolean` | A boolean indicating whether the application is currently performing an operation, such as creating, renaming, or deleting a file/folder. Displays a loading state if `true`. |
64
+ | `fileUploadConfig`| `{ url: string; headers?: { [key: string]: string } }` | Configuration object for file uploads. It includes the upload URL (`url`) and an optional `headers` object for setting custom HTTP headers in the upload request. The `headers` object can accept any standard or custom headers required by the server. Example: `{ url: "https://example.com/fileupload", headers: { Authorization: "Bearer" + TOKEN, "X-Custom-Header": "value" } }` |
65
+ | `onCreateFolder`| `(files: { name: string, isDirectory: boolean, path: string }[], folderName: string, folderPath: string) => void` | A callback function triggered when a new folder is created. Update the `files` state to include the new folder in the specified path. |
66
+ | `onRename` | `(files: { name: string, isDirectory: boolean, path: string }[], selectedFile: { name: string, isDirectory: boolean, path: string }, newName: string) => void` | A callback function triggered when a file or folder is renamed. Update the `files` state to reflect the new name for the specified file or folder. |
67
+ | `onDelete` | `(files: { name: string, isDirectory: boolean, path: string }[], file: { name: string, isDirectory: boolean, path: string }) => void` | A callback function triggered when a file or folder is deleted. Update the `files` state to remove the specified file or folder from the structure. |
68
+ | `onPaste` | `(files: { name: string, isDirectory: boolean, path: string }[], pastePath: string, clipBoard: { isMoving: boolean, files: { name: string, isDirectory: boolean, path: string, children?: { name: string, isDirectory: boolean, path: string }[] }[] }) => void` | A callback function triggered when a file or folder is pasted (moved or copied). Update the files state to reflect the new location of the pasted items based on the clipBoard data. |
69
+ | `onRefresh` | `() => void` | A callback function triggered when the file manager is refreshed. Use this to reload or refresh the `files` state to reflect any changes or updates. |
81
70
 
82
71
  ## Contributing
83
72
 
@@ -90,13 +79,16 @@ Contributions are welcome! To contribute:
90
79
  5. Push to the branch (`git push origin feature/branch-name`).
91
80
  6. Open a Pull Request.
92
81
 
93
- ## License
94
-
95
- This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
82
+ Get started by running following commands:
96
83
 
97
- ## Contact
84
+ ```bash
85
+ git clone https://github.com/Saifullah-dev/react-file-manager.git
86
+ cd react-file-manager
87
+ npm i
88
+ npm run dev
89
+ ```
90
+ The application should now be running on `http://localhost:5173`, have fun!
98
91
 
99
- For any questions, feel free to reach out:
92
+ ## License
100
93
 
101
- - **Email**: saifullah.contact@gmail.com
102
- - **GitHub**: [Saifullah-dev](https://github.com/Saifullah-dev)
94
+ React File Manager is [MIT Licensed](LICENSE).