@cubone/react-file-manager 1.0.1 → 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/LICENSE +21 -21
- package/README.md +94 -93
- package/dist/react-file-manager.es.js +1625 -1561
- package/dist/react-file-manager.umd.js +26 -26
- package/dist/style.css +1 -1
- package/package.json +57 -57
- package/src/index.js +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Saifullah Zubair
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Saifullah Zubair
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,93 +1,94 @@
|
|
|
1
|
-
# React File Manager
|
|
2
|
-
|
|
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.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **View Files and Folders**: Display the directory structure with folders and files.
|
|
8
|
-
- **Upload Files**: Upload new files to a selected directory.
|
|
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.
|
|
11
|
-
- **Breadcrumb Navigation**: Easily navigate through the directory structure.
|
|
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
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
To install `React File Manager`, use the following command:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm i @cubone/react-file-manager
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
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
|
-
}
|
|
57
|
-
```
|
|
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
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
npm
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1
|
+
# React File Manager
|
|
2
|
+
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **View Files and Folders**: Display the directory structure with folders and files.
|
|
8
|
+
- **Upload Files**: Upload new files to a selected directory.
|
|
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.
|
|
11
|
+
- **Breadcrumb Navigation**: Easily navigate through the directory structure.
|
|
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
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
To install `React File Manager`, use the following command:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm i @cubone/react-file-manager
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
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
|
+
}
|
|
57
|
+
```
|
|
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. |
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
|
|
73
|
+
Contributions are welcome! To contribute:
|
|
74
|
+
|
|
75
|
+
1. Fork the repository.
|
|
76
|
+
2. Create a new branch (`git checkout -b feature/branch-name`).
|
|
77
|
+
3. Make your changes.
|
|
78
|
+
4. Commit your changes (`git commit -m 'Add some feature'`).
|
|
79
|
+
5. Push to the branch (`git push origin feature/branch-name`).
|
|
80
|
+
6. Open a Pull Request.
|
|
81
|
+
|
|
82
|
+
Get started by running following commands:
|
|
83
|
+
|
|
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!
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
React File Manager is [MIT Licensed](LICENSE).
|