@cubone/react-file-manager 1.26.0 → 1.26.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 +38 -1
- package/dist/react-file-manager.es.js +3087 -3714
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -176,7 +176,7 @@ if not specified.
|
|
|
176
176
|
/>
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
## Custom File Preview
|
|
179
|
+
## </> Custom File Preview
|
|
180
180
|
|
|
181
181
|
The `FileManager` component allows you to provide a custom file preview by passing the
|
|
182
182
|
`filePreviewComponent` prop. This is an optional callback function that receives the selected file
|
|
@@ -195,6 +195,43 @@ const CustomImagePreviewer = ({ file }) => {
|
|
|
195
195
|
/>;
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
+
## 🧭 Handling Current Path
|
|
199
|
+
|
|
200
|
+
By default, the file manager starts in the root directory (`""`). You can override this by passing
|
|
201
|
+
an `initialPath` prop. For example, to start in `/Documents`:
|
|
202
|
+
|
|
203
|
+
```jsx
|
|
204
|
+
<FileManager initialPath="/Documents" />
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Controlled usage with `currentPath`
|
|
208
|
+
|
|
209
|
+
If you want to **track and control** the current folder, you can pair `initialPath` with the
|
|
210
|
+
`onFolderChange` callback. A common pattern is to keep the path in React state:
|
|
211
|
+
|
|
212
|
+
```jsx
|
|
213
|
+
import { useState } from "react";
|
|
214
|
+
|
|
215
|
+
function App() {
|
|
216
|
+
const [currentPath, setCurrentPath] = useState("/Documents");
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<FileManager
|
|
220
|
+
// other props...
|
|
221
|
+
initialPath={currentPath}
|
|
222
|
+
onFolderChange={setCurrentPath}
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Important notes
|
|
229
|
+
|
|
230
|
+
- `initialPath` is applied **only once** when the `files` state is first set.
|
|
231
|
+
- After that, folder changes are driven by `onFolderChange`.
|
|
232
|
+
- If you want to keep the path in sync with user navigation, use a controlled state (as shown
|
|
233
|
+
above).
|
|
234
|
+
|
|
198
235
|
## ©️ License
|
|
199
236
|
|
|
200
237
|
React File Manager is [MIT Licensed](LICENSE).
|