handy-uploader 2.0.0 → 2.0.2
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 +18 -16
- package/dist/components/InsertButton.vue.d.ts +24 -0
- package/dist/components/SelectFileIconType.vue.d.ts +29 -0
- package/dist/components/SimpleUploader.vue.d.ts +60 -0
- package/dist/components/TableUploader.vue.d.ts +62 -0
- package/dist/components/ThumbnailUploader.vue.d.ts +59 -0
- package/dist/components/handyUploader.vue.d.ts +146 -0
- package/dist/composables/useErrorHandler.d.ts +39 -0
- package/dist/composables/useFileUpload.d.ts +33 -0
- package/dist/lib/index.d.ts +713 -0
- package/dist/lib/language.d.ts +39 -0
- package/dist/types/index.d.ts +129 -0
- package/dist/utils/documentation.d.ts +95 -0
- package/dist/utils/fileUtils.d.ts +41 -0
- package/dist/utils/propValidation.d.ts +71 -0
- package/package.json +8 -7
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
interface Translation {
|
|
2
|
+
insertFile: string;
|
|
3
|
+
insertNewFile: string;
|
|
4
|
+
add: string;
|
|
5
|
+
delete: string;
|
|
6
|
+
edit: string;
|
|
7
|
+
deleteDialog: {
|
|
8
|
+
message: string;
|
|
9
|
+
cancel: string;
|
|
10
|
+
};
|
|
11
|
+
table: {
|
|
12
|
+
thumb: string;
|
|
13
|
+
name: string;
|
|
14
|
+
size: string;
|
|
15
|
+
tags?: string;
|
|
16
|
+
action: {
|
|
17
|
+
action: string;
|
|
18
|
+
deleteTooltip: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
size: {
|
|
22
|
+
kb: string;
|
|
23
|
+
mb: string;
|
|
24
|
+
};
|
|
25
|
+
maxFileSizeAlert?: string;
|
|
26
|
+
maxFileCountAlert: string;
|
|
27
|
+
fileName: string;
|
|
28
|
+
fileDescription: string;
|
|
29
|
+
fileTags: string;
|
|
30
|
+
}
|
|
31
|
+
interface Language {
|
|
32
|
+
en: Translation;
|
|
33
|
+
fa: Translation;
|
|
34
|
+
fr: Translation;
|
|
35
|
+
ch: Translation;
|
|
36
|
+
ar: Translation;
|
|
37
|
+
}
|
|
38
|
+
export declare const languages: Language;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export interface FileData {
|
|
2
|
+
name: string;
|
|
3
|
+
format: string;
|
|
4
|
+
base64: string;
|
|
5
|
+
size: number;
|
|
6
|
+
tags: string[];
|
|
7
|
+
description: string | null;
|
|
8
|
+
showDetailState: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DocumentAttachment {
|
|
11
|
+
file: FileData;
|
|
12
|
+
}
|
|
13
|
+
export type FileUploaderType = 'simple' | 'thumbnail' | 'table';
|
|
14
|
+
export type CardType = 'default' | 'outlined' | 'shaped' | 'raised' | 'tile';
|
|
15
|
+
export type LanguageCode = 'en' | 'fa' | 'fr' | 'ch' | 'ar';
|
|
16
|
+
export interface FileSizeResult {
|
|
17
|
+
text: string;
|
|
18
|
+
color: string;
|
|
19
|
+
}
|
|
20
|
+
export interface FileIconProps {
|
|
21
|
+
icon: string;
|
|
22
|
+
color: string;
|
|
23
|
+
}
|
|
24
|
+
export interface Translation {
|
|
25
|
+
insertFile: string;
|
|
26
|
+
insertNewFile: string;
|
|
27
|
+
add: string;
|
|
28
|
+
delete: string;
|
|
29
|
+
edit: string;
|
|
30
|
+
deleteDialog: {
|
|
31
|
+
message: string;
|
|
32
|
+
cancel: string;
|
|
33
|
+
};
|
|
34
|
+
table: {
|
|
35
|
+
thumb: string;
|
|
36
|
+
name: string;
|
|
37
|
+
size: string;
|
|
38
|
+
tags?: string;
|
|
39
|
+
action: {
|
|
40
|
+
action: string;
|
|
41
|
+
deleteTooltip: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
size: {
|
|
45
|
+
kb: string;
|
|
46
|
+
mb: string;
|
|
47
|
+
};
|
|
48
|
+
maxFileSizeAlert?: string;
|
|
49
|
+
maxFileCountAlert: string;
|
|
50
|
+
fileName: string;
|
|
51
|
+
fileDescription: string;
|
|
52
|
+
fileTags: string;
|
|
53
|
+
}
|
|
54
|
+
export interface LanguageCollection {
|
|
55
|
+
[key: string]: Translation;
|
|
56
|
+
}
|
|
57
|
+
export interface BaseUploaderProps {
|
|
58
|
+
documentAttachment: DocumentAttachment[];
|
|
59
|
+
lang?: LanguageCode;
|
|
60
|
+
thumb?: boolean;
|
|
61
|
+
cols?: number;
|
|
62
|
+
editPermission?: boolean;
|
|
63
|
+
deletePermission?: boolean;
|
|
64
|
+
selectedLang: LanguageCollection;
|
|
65
|
+
}
|
|
66
|
+
export interface CardThemeProps {
|
|
67
|
+
cardType?: CardType;
|
|
68
|
+
outlined?: boolean;
|
|
69
|
+
raised?: boolean;
|
|
70
|
+
shaped?: boolean;
|
|
71
|
+
tile?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface HandyUploaderProps extends BaseUploaderProps, CardThemeProps {
|
|
74
|
+
maxFileSize?: number;
|
|
75
|
+
fileUploaderType?: FileUploaderType;
|
|
76
|
+
maxFileCount?: number;
|
|
77
|
+
badgeCounter?: boolean;
|
|
78
|
+
btnColor?: string;
|
|
79
|
+
imageCompressor?: boolean;
|
|
80
|
+
imageCompressLevel?: number;
|
|
81
|
+
fileAccept?: string;
|
|
82
|
+
tableThumbColumn?: boolean;
|
|
83
|
+
tableFixedHeader?: boolean;
|
|
84
|
+
tableHeight?: number;
|
|
85
|
+
rtlSupport?: boolean;
|
|
86
|
+
changeFileName?: boolean;
|
|
87
|
+
addFileDescription?: boolean;
|
|
88
|
+
addFileTag?: boolean;
|
|
89
|
+
tags?: string[];
|
|
90
|
+
customLang?: LanguageCollection | null;
|
|
91
|
+
insertPermission?: boolean;
|
|
92
|
+
}
|
|
93
|
+
export interface UploaderEvents {
|
|
94
|
+
openDeleteDialog: (index: number, deleteId: string) => void;
|
|
95
|
+
openEditDocumentDialog: (item: DocumentAttachment, index: number) => void;
|
|
96
|
+
setCardTheme?: () => void;
|
|
97
|
+
}
|
|
98
|
+
export interface HandyUploaderEvents extends UploaderEvents {
|
|
99
|
+
updateCardType: (value: CardType) => void;
|
|
100
|
+
updateBadgeCounter: (value: boolean) => void;
|
|
101
|
+
updateMaxFileCount: (value: number) => void;
|
|
102
|
+
updateMaxFileSize: (value: number) => void;
|
|
103
|
+
updateImageCompressor: (value: boolean) => void;
|
|
104
|
+
updateImageCompressLevel: (value: number) => void;
|
|
105
|
+
updateFileAccept: (value: string) => void;
|
|
106
|
+
updateThumb: (value: boolean) => void;
|
|
107
|
+
updateChangeFileName: (value: boolean) => void;
|
|
108
|
+
updateAddFileDescription: (value: boolean) => void;
|
|
109
|
+
updateTableThumbColumn: (value: boolean) => void;
|
|
110
|
+
updateTableFixedHeader: (value: boolean) => void;
|
|
111
|
+
updateTableHeight: (value: number) => void;
|
|
112
|
+
updateLang: (value: LanguageCode) => void;
|
|
113
|
+
updateDocumentAttachment: (value: DocumentAttachment[]) => void;
|
|
114
|
+
}
|
|
115
|
+
export type MimeType = 'image/jpeg' | 'image/png' | 'image/tiff' | 'image/bmp' | string;
|
|
116
|
+
export interface ProcessedFile {
|
|
117
|
+
base64: string;
|
|
118
|
+
size: string;
|
|
119
|
+
name: string;
|
|
120
|
+
tags: string[];
|
|
121
|
+
description: string;
|
|
122
|
+
showDetailState: boolean;
|
|
123
|
+
format: string;
|
|
124
|
+
}
|
|
125
|
+
export interface SnackbarConfig {
|
|
126
|
+
show: boolean;
|
|
127
|
+
text: string;
|
|
128
|
+
color: string;
|
|
129
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component documentation and usage examples
|
|
3
|
+
*/
|
|
4
|
+
export interface PropDocumentation {
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
required: boolean;
|
|
8
|
+
default?: any;
|
|
9
|
+
description: string;
|
|
10
|
+
examples?: any[];
|
|
11
|
+
validation?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ComponentDocumentation {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
props: PropDocumentation[];
|
|
17
|
+
events: EventDocumentation[];
|
|
18
|
+
slots: SlotDocumentation[];
|
|
19
|
+
examples: ComponentExample[];
|
|
20
|
+
}
|
|
21
|
+
export interface EventDocumentation {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
payload?: string;
|
|
25
|
+
example?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SlotDocumentation {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
props?: string;
|
|
31
|
+
example?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ComponentExample {
|
|
34
|
+
title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
code: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* HandyUploader component documentation
|
|
40
|
+
*/
|
|
41
|
+
export declare const handyUploaderDocumentation: ComponentDocumentation;
|
|
42
|
+
/**
|
|
43
|
+
* Usage examples for different scenarios
|
|
44
|
+
*/
|
|
45
|
+
export declare const usageExamples: {
|
|
46
|
+
/**
|
|
47
|
+
* Basic file upload
|
|
48
|
+
*/
|
|
49
|
+
basic: string;
|
|
50
|
+
/**
|
|
51
|
+
* Advanced configuration
|
|
52
|
+
*/
|
|
53
|
+
advanced: string;
|
|
54
|
+
/**
|
|
55
|
+
* TypeScript usage
|
|
56
|
+
*/
|
|
57
|
+
typescript: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Best practices and recommendations
|
|
61
|
+
*/
|
|
62
|
+
export declare const bestPractices: {
|
|
63
|
+
performance: string[];
|
|
64
|
+
accessibility: string[];
|
|
65
|
+
userExperience: string[];
|
|
66
|
+
security: string[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Troubleshooting guide
|
|
70
|
+
*/
|
|
71
|
+
export declare const troubleshooting: {
|
|
72
|
+
commonIssues: {
|
|
73
|
+
issue: string;
|
|
74
|
+
solutions: string[];
|
|
75
|
+
}[];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Migration guide for upgrading
|
|
79
|
+
*/
|
|
80
|
+
export declare const migrationGuide: {
|
|
81
|
+
fromV1: string[];
|
|
82
|
+
breakingChanges: string[];
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Get documentation for a specific component
|
|
86
|
+
*/
|
|
87
|
+
export declare function getComponentDocumentation(componentName: string): ComponentDocumentation | null;
|
|
88
|
+
/**
|
|
89
|
+
* Generate prop validation code
|
|
90
|
+
*/
|
|
91
|
+
export declare function generatePropValidation(props: PropDocumentation[]): string;
|
|
92
|
+
/**
|
|
93
|
+
* Generate TypeScript interface from props
|
|
94
|
+
*/
|
|
95
|
+
export declare function generateTypeScriptInterface(componentName: string, props: PropDocumentation[]): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FileSizeResult, FileIconProps, MimeType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Formats file size into human-readable format with appropriate color coding
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatFileSize(size: number): FileSizeResult;
|
|
6
|
+
/**
|
|
7
|
+
* Determines file type based on file extension or MIME type
|
|
8
|
+
*/
|
|
9
|
+
export declare function getFileType(fileName: string, mimeType?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Gets appropriate icon and color for file type
|
|
12
|
+
*/
|
|
13
|
+
export declare function getFileIcon(fileName: string, mimeType?: string): FileIconProps;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if file is an image type
|
|
16
|
+
*/
|
|
17
|
+
export declare function isImageFile(fileName: string, mimeType?: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Validates file size against maximum allowed size
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateFileSize(fileSize: number, maxSize: number): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Validates file count against maximum allowed count
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateFileCount(currentCount: number, maxCount: number): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Gets MIME type from file extension
|
|
28
|
+
*/
|
|
29
|
+
export declare function getMimeTypeFromExtension(fileName: string): MimeType;
|
|
30
|
+
/**
|
|
31
|
+
* Constructs proper data URL for base64 image data
|
|
32
|
+
*/
|
|
33
|
+
export declare function constructImageDataUrl(base64: string, format: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Compresses image using canvas
|
|
36
|
+
*/
|
|
37
|
+
export declare function compressImage(file: File, quality?: number, maxWidth?: number, maxHeight?: number): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Converts file to base64 string
|
|
40
|
+
*/
|
|
41
|
+
export declare function fileToBase64(file: File): Promise<string>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for component props
|
|
3
|
+
*/
|
|
4
|
+
export interface ValidationResult {
|
|
5
|
+
isValid: boolean;
|
|
6
|
+
errors: string[];
|
|
7
|
+
warnings: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validates file uploader type
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateFileUploaderType(value: any): ValidationResult;
|
|
13
|
+
/**
|
|
14
|
+
* Validates card type
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateCardType(value: any): ValidationResult;
|
|
17
|
+
/**
|
|
18
|
+
* Validates language code
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateLanguageCode(value: any): ValidationResult;
|
|
21
|
+
/**
|
|
22
|
+
* Validates file size (in bytes)
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateFileSize(value: any): ValidationResult;
|
|
25
|
+
/**
|
|
26
|
+
* Validates file count
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateFileCount(value: any): ValidationResult;
|
|
29
|
+
/**
|
|
30
|
+
* Validates image compression level
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateCompressionLevel(value: any): ValidationResult;
|
|
33
|
+
/**
|
|
34
|
+
* Validates file accept pattern
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateFileAccept(value: any): ValidationResult;
|
|
37
|
+
/**
|
|
38
|
+
* Validates columns count for grid layout
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateColumns(value: any): ValidationResult;
|
|
41
|
+
/**
|
|
42
|
+
* Validates table height
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateTableHeight(value: any): ValidationResult;
|
|
45
|
+
/**
|
|
46
|
+
* Validates document attachment array
|
|
47
|
+
*/
|
|
48
|
+
export declare function validateDocumentAttachment(value: any): ValidationResult;
|
|
49
|
+
/**
|
|
50
|
+
* Comprehensive prop validation for HandyUploader component
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateHandyUploaderProps(props: Record<string, any>): ValidationResult;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a prop validator function for Vue components
|
|
55
|
+
*/
|
|
56
|
+
export declare function createPropValidator<T>(validator: (value: any) => ValidationResult): (value: T) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Prop validators for Vue components
|
|
59
|
+
*/
|
|
60
|
+
export declare const propValidators: {
|
|
61
|
+
fileUploaderType: (value: unknown) => boolean;
|
|
62
|
+
cardType: (value: unknown) => boolean;
|
|
63
|
+
languageCode: (value: unknown) => boolean;
|
|
64
|
+
fileSize: (value: unknown) => boolean;
|
|
65
|
+
fileCount: (value: unknown) => boolean;
|
|
66
|
+
compressionLevel: (value: unknown) => boolean;
|
|
67
|
+
fileAccept: (value: unknown) => boolean;
|
|
68
|
+
columns: (value: unknown) => boolean;
|
|
69
|
+
tableHeight: (value: unknown) => boolean;
|
|
70
|
+
documentAttachment: (value: unknown) => boolean;
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "handy-uploader",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "A comprehensive Vue 3 file uploader component library with video thumbnail generation and multiple upload styles",
|
|
5
5
|
"main": "dist/handy-uploader.umd.js",
|
|
6
6
|
"module": "dist/handy-uploader.es.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
7
|
+
"types": "dist/lib/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/handy-uploader.es.js",
|
|
11
11
|
"require": "./dist/handy-uploader.umd.js",
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
12
|
+
"types": "./dist/lib/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
@@ -30,16 +30,17 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/
|
|
33
|
+
"url": "https://github.com/alijahanpak/handy-uploader.git"
|
|
34
34
|
},
|
|
35
|
-
"homepage": "https://github.com/
|
|
35
|
+
"homepage": "https://github.com/alijahanpak/handy-uploader#readme",
|
|
36
36
|
"bugs": {
|
|
37
|
-
"url": "https://github.com/
|
|
37
|
+
"url": "https://github.com/alijahanpak/handy-uploader/issues"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"dev": "vite",
|
|
41
|
-
"build": "run-p type-check build-lib",
|
|
41
|
+
"build": "run-p type-check build-lib && npm run build-types",
|
|
42
42
|
"build-lib": "vite build --mode lib",
|
|
43
|
+
"build-types": "vue-tsc --project tsconfig.build.json",
|
|
43
44
|
"preview": "vite preview",
|
|
44
45
|
"build-only": "vite build",
|
|
45
46
|
"type-check": "vue-tsc --noEmit",
|