@lax-wp/design-system 0.4.9 → 0.4.11

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.
@@ -1,16 +1,4 @@
1
- /**
2
- * File upload result interface
3
- */
4
- export interface FileUploadResult {
5
- filename: string;
6
- content?: string;
7
- fileUrl?: string;
8
- fileName?: string;
9
- }
10
- /**
11
- * Union type for file change callback parameter
12
- */
13
- export type FileChangeValue = File | File[] | FileUploadResult | FileUploadResult[] | string | string[] | null;
1
+ import { type FC } from 'react';
14
2
  /**
15
3
  * File upload service interface
16
4
  */
@@ -22,92 +10,55 @@ export interface FileUploadService {
22
10
  deleteFileFromFileServer: (fileName: string, queryParams: string) => Promise<void>;
23
11
  }
24
12
  /**
25
- * Props for the MultiFileUpload component
13
+ * System messages interface
26
14
  */
27
- export interface MultiFileUploadProps {
28
- /** Unique identifier for the upload component */
29
- id?: string;
30
- /** Callback function called when files are selected/uploaded */
31
- onFileChange: (files: FileChangeValue, fileName?: string) => void;
32
- /** Description text to display in the upload area */
15
+ export interface SystemMessages {
16
+ fileSizeLimit: (size: string, unit: string) => string;
17
+ }
18
+ export type MultiFileUploadProps = {
19
+ /** Callback to receive the uploaded file */
20
+ getFile: (file: any, fileName?: string) => any;
21
+ /** Description text to display */
33
22
  description?: string;
34
23
  /** Error message to display */
35
24
  errorMessage?: string;
36
25
  /** Whether the upload is disabled */
37
26
  disabled?: boolean;
38
27
  /** Default file to display */
39
- defaultFile?: File | null;
40
- /** Accepted file types (e.g., ".pdf,.doc,.docx") */
28
+ defaultFile?: any;
29
+ /** Accepted file types */
41
30
  acceptedFiles?: string;
42
- /** Whether the component is in loading state */
31
+ /** Whether loading state is active */
43
32
  isLoading?: boolean;
44
- /** Whether to convert files to base64 */
33
+ /** Convert file to base64 */
45
34
  asBase64?: boolean;
46
- /** Whether to upload files to server */
35
+ /** Upload to file server */
47
36
  toFileServer?: boolean;
48
- /** Whether files are currently uploading */
37
+ /** Whether file is currently uploading */
49
38
  fileUploading?: boolean;
50
39
  /** Callback to set file uploading state */
51
- setFileUploading?: (fileUploading: boolean | string | null) => void;
52
- /** Whether to upload to document server */
40
+ setFileUploading?: (fileUploading: boolean) => void;
41
+ /** Upload to document server path */
53
42
  uploadToDocServer?: boolean;
54
- /** Whether to allow multiple file selection */
43
+ /** Unique identifier for the upload */
44
+ id?: string;
45
+ /** Allow multiple file uploads */
55
46
  multiple?: boolean;
56
- /** Whether to get real file name */
47
+ /** Get original file name */
57
48
  getRealFileName?: boolean;
58
- /** Maximum file size in bytes (default: 50MB) */
49
+ /** Callback when file is deleted */
50
+ onDelete?: () => void;
51
+ /** Maximum file size in bytes */
59
52
  maxSize?: number;
60
- /** File upload service for server uploads */
53
+ /** File upload service */
61
54
  fileUploadService?: FileUploadService;
62
- /** Custom upload handler function (alternative to fileUploadService) */
63
- onUpload?: (files: File[]) => Promise<FileUploadResult[]>;
64
- /** Custom delete handler function (called after file deletion) */
65
- onDelete?: (fileData?: FileUploadResult) => Promise<void>;
66
- /** Additional CSS classes for the wrapper */
67
- wrapperClassName?: string;
68
- /** Additional CSS classes for the upload area */
69
- uploadClassName?: string;
70
- /** Whether to show file size */
71
- showFileSize?: boolean;
72
- /** Custom file size formatter */
73
- formatFileSize?: (size: number) => string;
74
- /** Custom click to upload text */
75
- clickToUploadText?: string;
76
- /** Custom drag and drop text */
77
- dragAndDropText?: string;
78
- /** Callback when file size exceeds limit */
79
- onFileSizeError?: (maxSizeMB: number) => void;
80
- }
81
- /**
82
- * A highly customizable multi-file upload component with drag-and-drop support.
83
- * Features file validation, base64 conversion, server upload, and comprehensive styling options.
84
- *
85
- * @example
86
- * // Using with fileUploadService (recommended for server uploads)
87
- * ```tsx
88
- * <MultiFileUpload
89
- * id="file-upload"
90
- * description="Upload your documents"
91
- * onFileChange={(files) => console.log(files)}
92
- * toFileServer
93
- * fileUploadService={attachmentServices}
94
- * multiple
95
- * maxSize={10 * 1024 * 1024} // 10MB
96
- * />
97
- * ```
98
- *
99
- * @example
100
- * // Using with custom onUpload handler
101
- * ```tsx
102
- * <MultiFileUpload
103
- * id="file-upload"
104
- * onFileChange={(files) => console.log(files)}
105
- * toFileServer
106
- * onUpload={async (files) => {
107
- * // Custom upload logic
108
- * return files.map(f => ({ filename: f.name, fileUrl: 'url' }));
109
- * }}
110
- * />
111
- * ```
112
- */
113
- export declare const MultiFileUpload: import("react").ForwardRefExoticComponent<MultiFileUploadProps & import("react").RefAttributes<HTMLDivElement>>;
55
+ /** System messages for error handling */
56
+ systemMessages?: SystemMessages;
57
+ /** Toast function for displaying errors */
58
+ toast?: {
59
+ error: (message: string, options?: {
60
+ toastId?: string;
61
+ }) => void;
62
+ };
63
+ };
64
+ export declare const MultiFileUpload: FC<MultiFileUploadProps>;
package/dist/index.d.ts CHANGED
@@ -45,7 +45,7 @@ export type { TToggleDirection } from "./constants/toggle";
45
45
  export { MdInput } from "./components/forms/md-input/MdInput";
46
46
  export type { MdInputProps } from "./components/forms/md-input/MdInput";
47
47
  export { MultiFileUpload } from "./components/forms/multi-file-upload/MultiFileUpload";
48
- export type { MultiFileUploadProps, FileUploadResult, FileChangeValue, } from "./components/forms/multi-file-upload/MultiFileUpload";
48
+ export type { MultiFileUploadProps, FileUploadService as MultiFileUploadService, SystemMessages as MultiFileUploadSystemMessages, } from "./components/forms/multi-file-upload/MultiFileUpload";
49
49
  export { IconPicker, IconRenderer } from "./components/forms/icon-picker/IconPicker";
50
50
  export type { IconPickerContentProps } from "./components/forms/icon-picker/IconPicker";
51
51
  export { StatusColorMapping } from "./components/data-display/status-color-mapping/StatusColorMapping";