jattac.libs.web.zest-file-upload 0.2.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,16 @@
1
+ import React, { Component, ErrorInfo, ReactNode } from "react";
2
+ interface FileUploadErrorBoundaryProps {
3
+ children: ReactNode;
4
+ fallbackMessage?: string;
5
+ }
6
+ interface FileUploadErrorBoundaryState {
7
+ hasError: boolean;
8
+ }
9
+ declare class FileUploadErrorBoundary extends Component<FileUploadErrorBoundaryProps, FileUploadErrorBoundaryState> {
10
+ constructor(props: FileUploadErrorBoundaryProps);
11
+ static getDerivedStateFromError(): FileUploadErrorBoundaryState;
12
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
13
+ handleRetry: () => void;
14
+ render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
15
+ }
16
+ export default FileUploadErrorBoundary;
@@ -0,0 +1,3 @@
1
+ export declare function useBrowser(): {
2
+ isBrowser: boolean;
3
+ };
@@ -0,0 +1,34 @@
1
+ import type { CameraView, CropArea, FileUploadLabels } from "../Types/types";
2
+ interface UseCameraOptions {
3
+ capture?: "user" | "environment";
4
+ onFileSelect: (file: File | null) => Promise<void>;
5
+ setStatus: (status: "idle" | "uploading" | "complete" | "error") => void;
6
+ onError?: (error: string) => void;
7
+ labels: FileUploadLabels;
8
+ }
9
+ export declare function useCamera({ capture, onFileSelect, setStatus, onError, labels, }: UseCameraOptions): {
10
+ stream: MediaStream | null;
11
+ cameraView: CameraView;
12
+ facingMode: "user" | "environment";
13
+ flashEnabled: boolean;
14
+ capturedImage: string | null;
15
+ cameraError: string | null;
16
+ videoReady: boolean;
17
+ cameraLoading: boolean;
18
+ videoRef: import("react").RefObject<HTMLVideoElement>;
19
+ canvasRef: import("react").RefObject<HTMLCanvasElement>;
20
+ cameraInputRef: import("react").RefObject<HTMLInputElement>;
21
+ torchSupported: boolean;
22
+ cropCompleteArea: CropArea | null;
23
+ handleCameraClick: (e: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
24
+ cancelCamera: () => void;
25
+ toggleCamera: () => Promise<void>;
26
+ toggleFlash: () => Promise<void>;
27
+ capturePhoto: () => void;
28
+ retakePhoto: () => Promise<void>;
29
+ confirmPhoto: () => void;
30
+ cancelCrop: () => void;
31
+ applyCrop: () => Promise<void>;
32
+ setCropCompleteArea: import("react").Dispatch<import("react").SetStateAction<CropArea | null>>;
33
+ };
34
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const useFileValidation: (accept: string, maxSize?: number) => {
2
+ validate: (file: File) => {
3
+ isValid: boolean;
4
+ error: string | null;
5
+ };
6
+ };
@@ -0,0 +1,82 @@
1
+ export interface CompressionOptions {
2
+ maxWidth: number;
3
+ maxHeight: number;
4
+ quality: number;
5
+ mimeType: string;
6
+ }
7
+ export type CameraView = "none" | "loading" | "preview" | "captured" | "crop";
8
+ export interface CropArea {
9
+ x: number;
10
+ y: number;
11
+ width: number;
12
+ height: number;
13
+ }
14
+ export type FileUploadStatus = "idle" | "uploading" | "complete" | "error";
15
+ export interface FileUploadLabels {
16
+ browseFiles: string;
17
+ takePhoto: string;
18
+ uploadComplete: string;
19
+ uploadFailed: string;
20
+ uploading: string;
21
+ noFileSelected: string;
22
+ invalidFileType: string;
23
+ cameraError: string;
24
+ retake: string;
25
+ usePhoto: string;
26
+ cancel: string;
27
+ switchCamera: string;
28
+ toggleFlash: string;
29
+ cropTitle: string;
30
+ cropSave: string;
31
+ cropCancel: string;
32
+ }
33
+ export interface FileUploadRef {
34
+ clearFile: () => void;
35
+ clearAll: () => void;
36
+ }
37
+ export type FileEntryId = string;
38
+ export type FileEntryStatus = "pending" | "uploading" | "complete" | "error";
39
+ export interface FileEntry {
40
+ id: FileEntryId;
41
+ file: File;
42
+ status: FileEntryStatus;
43
+ error: string | null;
44
+ }
45
+ export interface MultiFileUploadLabels {
46
+ addMoreFiles: string;
47
+ removeFile: string;
48
+ filesQueued: string;
49
+ clearAll: string;
50
+ pending: string;
51
+ retryFile: string;
52
+ }
53
+ export interface FileUploadIcons {
54
+ camera: React.ReactNode;
55
+ browse: React.ReactNode;
56
+ close: React.ReactNode;
57
+ flashOn: React.ReactNode;
58
+ flashOff: React.ReactNode;
59
+ switchCamera: React.ReactNode;
60
+ retake: React.ReactNode;
61
+ confirm: React.ReactNode;
62
+ }
63
+ export interface FileUploadProps {
64
+ label: string;
65
+ onFileSelect: (file: File | null) => Promise<void>;
66
+ progressPercentage?: number;
67
+ disabled?: boolean;
68
+ accept?: string;
69
+ capture?: "user" | "environment";
70
+ hideCompletionMessage?: boolean;
71
+ onError?: (error: string) => void;
72
+ maxFileSize?: number;
73
+ labels?: Partial<FileUploadLabels>;
74
+ errorBoundary?: boolean;
75
+ successTimeout?: number;
76
+ icons?: Partial<FileUploadIcons>;
77
+ multiple?: boolean;
78
+ onFilesSelect?: (files: File[]) => Promise<void>;
79
+ filesProgress?: Record<FileEntryId, number>;
80
+ maxFiles?: number;
81
+ multiLabels?: Partial<MultiFileUploadLabels>;
82
+ }
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import type { CameraView, CropArea, FileUploadLabels } from "../Types/types";
3
+ interface CameraCaptureProps {
4
+ cameraView: CameraView;
5
+ facingMode: "user" | "environment";
6
+ flashEnabled: boolean;
7
+ capturedImage: string | null;
8
+ cameraError: string | null;
9
+ cameraLoading: boolean;
10
+ videoRef: React.RefObject<HTMLVideoElement>;
11
+ canvasRef: React.RefObject<HTMLCanvasElement>;
12
+ torchSupported: boolean;
13
+ labels: FileUploadLabels;
14
+ icons: {
15
+ close: React.ReactNode;
16
+ flashOn: React.ReactNode;
17
+ flashOff: React.ReactNode;
18
+ switchCamera: React.ReactNode;
19
+ retake: React.ReactNode;
20
+ confirm: React.ReactNode;
21
+ };
22
+ onCancel: () => void;
23
+ onToggleCamera: () => void;
24
+ onToggleFlash: () => void;
25
+ onCapture: () => void;
26
+ onRetake: () => void;
27
+ onConfirm: () => void;
28
+ onCropCancel: () => void;
29
+ onApplyCrop: () => void;
30
+ onCropComplete: (area: CropArea) => void;
31
+ }
32
+ declare const CameraCapture: React.FC<CameraCaptureProps>;
33
+ export default CameraCapture;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { FileUploadProps, FileUploadRef } from "../Types/types";
3
+ declare const FileUpload: React.ForwardRefExoticComponent<FileUploadProps & React.RefAttributes<FileUploadRef>>;
4
+ export default FileUpload;
@@ -0,0 +1,3 @@
1
+ export { default as ZestFileUpload } from "./FileUpload";
2
+ export { default } from "./FileUpload";
3
+ export type { FileUploadProps, FileUploadRef, FileUploadLabels, FileUploadIcons, FileEntryId, FileEntryStatus, FileEntry, MultiFileUploadLabels, } from "../Types/types";