florixui 1.0.0 → 1.1.0

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.
@@ -0,0 +1,58 @@
1
+ import { ChangeEvent, DragEvent, InputHTMLAttributes } from 'react';
2
+ /** A file that already lives on a server (e.g. previously uploaded). */
3
+ export type FileMetadata = {
4
+ name: string;
5
+ size: number;
6
+ type: string;
7
+ url: string;
8
+ id: string;
9
+ };
10
+ /** An entry in the uploader: either a freshly picked `File` or remote metadata. */
11
+ export type FileWithPreview = {
12
+ file: File | FileMetadata;
13
+ id: string;
14
+ preview?: string;
15
+ };
16
+ export type FileUploadOptions = {
17
+ /** Maximum number of files allowed (multiple mode). Defaults to unlimited. */
18
+ maxFiles?: number;
19
+ /** Maximum size per file, in bytes. Defaults to unlimited. */
20
+ maxSize?: number;
21
+ /** `accept` attribute, e.g. `"image/*"` or `".pdf,.docx"`. Defaults to `"*"`. */
22
+ accept?: string;
23
+ /** Allow selecting more than one file. */
24
+ multiple?: boolean;
25
+ /** Files to seed the uploader with (already-uploaded items). */
26
+ initialFiles?: FileMetadata[];
27
+ /** Called whenever the file list changes. */
28
+ onFilesChange?: (files: FileWithPreview[]) => void;
29
+ /** Called with only the files added in the latest action. */
30
+ onFilesAdded?: (addedFiles: FileWithPreview[]) => void;
31
+ };
32
+ export type FileUploadState = {
33
+ files: FileWithPreview[];
34
+ isDragging: boolean;
35
+ errors: string[];
36
+ };
37
+ export type FileUploadActions = {
38
+ addFiles: (files: FileList | File[]) => void;
39
+ removeFile: (id: string) => void;
40
+ clearFiles: () => void;
41
+ clearErrors: () => void;
42
+ handleDragEnter: (e: DragEvent<HTMLElement>) => void;
43
+ handleDragLeave: (e: DragEvent<HTMLElement>) => void;
44
+ handleDragOver: (e: DragEvent<HTMLElement>) => void;
45
+ handleDrop: (e: DragEvent<HTMLElement>) => void;
46
+ handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void;
47
+ openFileDialog: () => void;
48
+ getInputProps: (props?: InputHTMLAttributes<HTMLInputElement>) => InputHTMLAttributes<HTMLInputElement> & {
49
+ ref: React.Ref<HTMLInputElement>;
50
+ };
51
+ };
52
+ /** Human-readable byte size, e.g. `1.46MB`. */
53
+ export declare const formatBytes: (bytes: number, decimals?: number) => string;
54
+ /**
55
+ * Headless file-upload state machine: validation, drag & drop, previews, and
56
+ * input wiring. Pair it with your own markup (see `FileUpload` for a default UI).
57
+ */
58
+ export declare const useFileUpload: (options?: FileUploadOptions) => [FileUploadState, FileUploadActions];