react-file-upload-ui 0.1.0 → 0.1.3

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
@@ -20,15 +20,45 @@ pnpm add react-file-upload-ui
20
20
 
21
21
  ## Usage
22
22
 
23
+ **Important:** You must import the CSS file for the component to be styled correctly.
24
+
23
25
  ```tsx
24
26
  import React from "react";
25
27
  import ReactFileUploaderUI from "react-file-upload-ui";
28
+ import "react-file-upload-ui/styles.css"; // ← Import the styles
26
29
 
27
30
  export default function App() {
28
- return <ReactFileUploaderUI />;
31
+ const handleFilesSelected = (files) => {
32
+ console.log("Selected files:", files);
33
+ };
34
+
35
+ return (
36
+ <div style={{ padding: "2rem" }}>
37
+ <ReactFileUploaderUI
38
+ accept="image/*"
39
+ maxSize={10 * 1024 * 1024}
40
+ maxFiles={10}
41
+ onFilesSelected={handleFilesSelected}
42
+ />
43
+ </div>
44
+ );
29
45
  }
30
46
  ```
31
47
 
48
+ ## Props
49
+
50
+ | Prop | Type | Default | Description |
51
+ | ----------------- | ------------------------------ | ---------- | ----------------------------------------------- |
52
+ | `accept` | `string` | - | File types to accept (e.g., "image/\*", ".pdf") |
53
+ | `multiple` | `boolean` | `true` | Allow multiple file selection |
54
+ | `maxSize` | `number` | `10485760` | Maximum file size in bytes (default: 10MB) |
55
+ | `maxFiles` | `number` | `10` | Maximum number of files |
56
+ | `onFilesSelected` | `(files: IFileData[]) => void` | - | Callback when files are selected |
57
+ | `onError` | `(error: string) => void` | - | Callback when an error occurs |
58
+ | `disabled` | `boolean` | `false` | Disable the file uploader |
59
+ | `className` | `string` | `""` | Additional CSS classes |
60
+ | `defaultFiles` | `IFileData[]` | - | Pre-populate with default files |
61
+
32
62
  ## Building
33
63
 
34
64
  This package uses `tsup` to build. To build locally run:
package/dist/index.d.mts CHANGED
@@ -1,9 +1,47 @@
1
- import React from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- interface ReactFileUploaderUIProps {
3
+ interface IFileData {
4
+ id: string;
5
+ isDefault: boolean;
6
+ file: File | undefined;
7
+ url?: string;
8
+ name: string;
9
+ }
10
+ interface IReactFileUploaderUIProps {
4
11
  accept?: string;
5
12
  multiple?: boolean;
13
+ maxSize?: number;
14
+ maxFiles?: number;
15
+ onFilesSelected?: (data: IFileData[]) => void;
16
+ onError?: (error: string) => void;
17
+ disabled?: boolean;
18
+ className?: string;
19
+ /**
20
+ * Default files (external URLs) to pre-populate the uploader with.
21
+ * Example: [{ url: 'https://...', name: 'image.jpg' }]
22
+ */
23
+ defaultFiles?: DefaultFile[];
24
+ }
25
+ interface DefaultFile {
26
+ id?: string;
27
+ name?: string;
28
+ url: string;
29
+ type?: string;
30
+ isDefault?: boolean;
6
31
  }
7
- declare const ReactFileUploaderUI: React.FC<ReactFileUploaderUIProps>;
32
+ interface IFileWithPreview {
33
+ id: string;
34
+ name: string;
35
+ size?: number;
36
+ type?: string;
37
+ preview?: string;
38
+ isDefault?: boolean;
39
+ /**
40
+ * Original File if the item was uploaded via input; undefined for external URL defaults.
41
+ */
42
+ rawFile?: File | undefined;
43
+ }
44
+
45
+ declare const ReactFileUploaderUI: ({ accept, multiple, maxSize, maxFiles, onFilesSelected, onError, disabled, className, defaultFiles, }: IReactFileUploaderUIProps) => react_jsx_runtime.JSX.Element;
8
46
 
9
- export { ReactFileUploaderUI, type ReactFileUploaderUIProps, ReactFileUploaderUI as default };
47
+ export { type IFileData, type IFileWithPreview, type IReactFileUploaderUIProps, ReactFileUploaderUI as default };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,47 @@
1
- import React from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
- interface ReactFileUploaderUIProps {
3
+ interface IFileData {
4
+ id: string;
5
+ isDefault: boolean;
6
+ file: File | undefined;
7
+ url?: string;
8
+ name: string;
9
+ }
10
+ interface IReactFileUploaderUIProps {
4
11
  accept?: string;
5
12
  multiple?: boolean;
13
+ maxSize?: number;
14
+ maxFiles?: number;
15
+ onFilesSelected?: (data: IFileData[]) => void;
16
+ onError?: (error: string) => void;
17
+ disabled?: boolean;
18
+ className?: string;
19
+ /**
20
+ * Default files (external URLs) to pre-populate the uploader with.
21
+ * Example: [{ url: 'https://...', name: 'image.jpg' }]
22
+ */
23
+ defaultFiles?: DefaultFile[];
24
+ }
25
+ interface DefaultFile {
26
+ id?: string;
27
+ name?: string;
28
+ url: string;
29
+ type?: string;
30
+ isDefault?: boolean;
6
31
  }
7
- declare const ReactFileUploaderUI: React.FC<ReactFileUploaderUIProps>;
32
+ interface IFileWithPreview {
33
+ id: string;
34
+ name: string;
35
+ size?: number;
36
+ type?: string;
37
+ preview?: string;
38
+ isDefault?: boolean;
39
+ /**
40
+ * Original File if the item was uploaded via input; undefined for external URL defaults.
41
+ */
42
+ rawFile?: File | undefined;
43
+ }
44
+
45
+ declare const ReactFileUploaderUI: ({ accept, multiple, maxSize, maxFiles, onFilesSelected, onError, disabled, className, defaultFiles, }: IReactFileUploaderUIProps) => react_jsx_runtime.JSX.Element;
8
46
 
9
- export { ReactFileUploaderUI, type ReactFileUploaderUIProps, ReactFileUploaderUI as default };
47
+ export { type IFileData, type IFileWithPreview, type IReactFileUploaderUIProps, ReactFileUploaderUI as default };