@mainframework/dropzone 1.0.28 → 1.1.1

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
@@ -105,7 +105,6 @@ The `FileSelector` from the hook accepts **view-only** props (styling, copy, acc
105
105
  | `ariaLabel` | `string` | "File upload drop zone" | Accessible name for the drop zone. |
106
106
  | `ariaDescribedBy` | `string` | — | ID of element that describes the drop zone. |
107
107
  | `ariaLabelButton` | `string` | "Choose files to upload" | Accessible label for the button. |
108
- | `ariaLabelledBy` | `string` | — | ID of element that labels the button. |
109
108
 
110
109
  ## Default Accepted Types
111
110
 
@@ -172,11 +171,19 @@ export const App = () => {
172
171
 
173
172
  ## Cleanup / memory
174
173
 
175
- - Prefer clearing via the provided methods:
176
- - `clearCache()` / `onCancel()` to clear files and revoke blob URLs
177
- - `onRemoveFile(index)` to remove one file and revoke its blob URL
178
- - `clearBlobs()` to revoke blob URLs without clearing arrays
179
- - When the hook instance unmounts, it clears internal state and revokes any blob URLs it created.
174
+ > **Warning: memory management is the caller's responsibility.** The hook does **not** automatically revoke blob URLs on unmount. You **must** call `clearBlobs()` or `clearCache()` yourself — for example in a `useEffect` cleanup, on cancel, or after a successful upload — to prevent memory leaks.
175
+
176
+ ```tsx
177
+ useEffect(() => {
178
+ return () => {
179
+ clearBlobs(); // revoke all blob URLs when the component unmounts
180
+ };
181
+ }, [clearBlobs]);
182
+ ```
183
+
184
+ - Use `clearCache()` / `onCancel()` to clear files **and** revoke blob URLs.
185
+ - Use `onRemoveFile(index)` to remove one file and revoke its blob URL.
186
+ - Use `clearBlobs()` to revoke blob URLs without clearing the file arrays.
180
187
  - Mutating the `validFiles` array directly (for example `validFiles.length = 0`) is not a supported way to clear files/blobs; use `clearCache()` instead so blob URLs are properly revoked.
181
188
 
182
189
  ## Exported types
package/dist/index.d.ts CHANGED
@@ -1,66 +1,2 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ChangeEvent, DragEvent } from 'react';
3
-
4
- /** Props for styling, copy, and accessibility on the dropzone. Used by the `FileSelector` returned from `useFileSelector`. */
5
- interface FileSelectorViewProps {
6
- inputId?: string;
7
- messageParagraph?: string;
8
- inputClassName?: string;
9
- clickableAreaClassName?: string;
10
- dropZoneWrapperClassName?: string;
11
- messageParagraphClassName?: string;
12
- /** Accessible name for the drop zone region (default: "File upload") */
13
- ariaLabel?: string;
14
- /** ID of element that describes the drop zone (e.g. help text) */
15
- ariaDescribedBy?: string;
16
- /** Accessible label for the file input button when messageParagraph is not sufficient */
17
- ariaLabelButton?: string;
18
- ariaLabelledBy?: string;
19
- }
20
- /** File input and drag-and-drop handlers; supplied internally by `useFileSelector` to the presentational component. */
21
- interface FileSelectorHandlerProps {
22
- onChange: (e: ChangeEvent<HTMLInputElement>) => void;
23
- onDragOver: (e: DragEvent<HTMLButtonElement>) => void;
24
- onDrop: (e: DragEvent<HTMLButtonElement>) => void;
25
- onDragEnter: (e: DragEvent<HTMLButtonElement>) => void;
26
- onDragLeave: (e: DragEvent<HTMLButtonElement>) => void;
27
- }
28
- interface IFileUploaderProps {
29
- acceptTypes?: string;
30
- maximumUploadCount?: number;
31
- maximumFileSize?: number;
32
- acceptedTypes?: Record<string, string>;
33
- }
34
- interface FileData {
35
- id: string;
36
- file: File | Blob;
37
- url: string;
38
- type: string;
39
- }
40
- interface ErrorMessage {
41
- status: boolean;
42
- message: string;
43
- }
44
-
45
- declare const useFileSelector: ({ maximumUploadCount, maximumFileSize, acceptedTypes, }?: IFileUploaderProps) => {
46
- validFiles: FileData[];
47
- invalidFiles: File[];
48
- clearCache: () => void;
49
- getValidFileStreams: () => (File | Blob)[];
50
- onCancel: () => void;
51
- onIdChange: (index: number, id: string, files: FileData[]) => void;
52
- onRemoveFile: (index: number) => void;
53
- clearBlobs: () => void;
54
- clearBlob: (file: File) => void;
55
- maxUploadError: ErrorMessage;
56
- maxFileSizeError: ErrorMessage;
57
- setMaximumFileSizeExceeded: (status?: boolean) => void;
58
- setMaximumUploadsExceeded: (status?: boolean, fileCount?: number, maximumUploads?: number) => void;
59
- FileSelector: {
60
- (props: FileSelectorViewProps): react_jsx_runtime.JSX.Element;
61
- displayName: string;
62
- };
63
- };
64
-
65
- export { useFileSelector };
66
- export type { ErrorMessage, FileData, FileSelectorHandlerProps, FileSelectorViewProps, IFileUploaderProps };
1
+ export { useFileSelector } from "./shared/hooks/useFileSelector";
2
+ export type { FileData, ErrorMessage, IFileUploaderProps, FileSelectorViewProps, FileSelectorHandlerProps, } from "./shared/types/types";