@finema/core 1.4.37 → 1.4.39
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/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/Form/Fields.vue +0 -1
- package/dist/runtime/components/Form/InputUploadFileClassicAuto/index.vue +10 -5
- package/dist/runtime/plugin.mjs +4 -4
- package/dist/runtime/utils/FileHelper.d.ts +3 -0
- package/dist/runtime/utils/FileHelper.mjs +29 -0
- package/package.json +87 -86
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -73,14 +73,15 @@ const fileInput = ref<HTMLInputElement>()
|
|
|
73
73
|
const selectedFile = ref<File | undefined>()
|
|
74
74
|
const percent = ref<number>(0)
|
|
75
75
|
|
|
76
|
+
const acceptFileSizeKb = computed(() => props.maxSize)
|
|
77
|
+
const acceptFileSizeMb = computed(() => ((acceptFileSizeKb.value ?? 0) / 1024).toFixed(2))
|
|
76
78
|
const selectedFileSizeKb = computed(() => ((selectedFile.value?.size || 0) / 1000).toFixed(2))
|
|
77
79
|
const selectedFileSizeMb = computed(() =>
|
|
78
80
|
((selectedFile.value?.size || 0) / 1000 / 1000).toFixed(2)
|
|
79
81
|
)
|
|
80
82
|
|
|
81
83
|
const isSelectedFileUseMb = computed(() => (selectedFile.value?.size || 0) / 1000 > 1024)
|
|
82
|
-
const
|
|
83
|
-
const acceptFileSizeMb = computed(() => ((acceptFileSize.value || 0) / 1024).toFixed(2))
|
|
84
|
+
const isAcceptFileUseMb = computed(() => acceptFileSizeKb.value && acceptFileSizeKb.value > 1024)
|
|
84
85
|
|
|
85
86
|
const acceptFile = computed(() =>
|
|
86
87
|
typeof props.accept === 'string' ? props.accept : props.accept?.join(',')
|
|
@@ -111,7 +112,11 @@ const handleCheckFileCondition = (file: File | undefined): boolean => {
|
|
|
111
112
|
const maxSize = checkMaxSize(file)
|
|
112
113
|
|
|
113
114
|
if (!maxSize) {
|
|
114
|
-
|
|
115
|
+
if (isAcceptFileUseMb.value) {
|
|
116
|
+
setErrors(i18next.t('custom:invalid_file_size_mb', { size: acceptFileSizeMb.value }))
|
|
117
|
+
} else {
|
|
118
|
+
setErrors(i18next.t('custom:invalid_file_size_kb', { size: acceptFileSizeKb.value }))
|
|
119
|
+
}
|
|
115
120
|
|
|
116
121
|
return false
|
|
117
122
|
}
|
|
@@ -122,8 +127,8 @@ const handleCheckFileCondition = (file: File | undefined): boolean => {
|
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
const checkMaxSize = (file: File): boolean => {
|
|
125
|
-
if (
|
|
126
|
-
return file.size / 1000 <=
|
|
130
|
+
if (acceptFileSizeKb.value) {
|
|
131
|
+
return file.size / 1000 <= acceptFileSizeKb.value
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
return true
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -123,8 +123,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
123
123
|
},
|
|
124
124
|
custom: {
|
|
125
125
|
invalid_file_type: "\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E44\u0E1F\u0E25\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07",
|
|
126
|
-
invalid_file_size_kb: "\u0E02\u0E19\u0E32\u0E14\u0E44\u0E1F\u0E25\u0E4C\u0E40\u0E01\u0E34\u0E19\u0E01\u0E27\u0E48\u0E32\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 {{size}}
|
|
127
|
-
invalid_file_size_mb: "\u0E02\u0E19\u0E32\u0E14\u0E44\u0E1F\u0E25\u0E4C\u0E40\u0E01\u0E34\u0E19\u0E01\u0E27\u0E48\u0E32\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 {{size}}
|
|
126
|
+
invalid_file_size_kb: "\u0E02\u0E19\u0E32\u0E14\u0E44\u0E1F\u0E25\u0E4C\u0E40\u0E01\u0E34\u0E19\u0E01\u0E27\u0E48\u0E32\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 {{size}} KB",
|
|
127
|
+
invalid_file_size_mb: "\u0E02\u0E19\u0E32\u0E14\u0E44\u0E1F\u0E25\u0E4C\u0E40\u0E01\u0E34\u0E19\u0E01\u0E27\u0E48\u0E32\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 {{size}} MB"
|
|
128
128
|
},
|
|
129
129
|
en
|
|
130
130
|
},
|
|
@@ -134,8 +134,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
134
134
|
},
|
|
135
135
|
custom: {
|
|
136
136
|
invalid_file_type: "Invalid file type",
|
|
137
|
-
invalid_file_size_kb: "Invalid exceed of file size {{size}}
|
|
138
|
-
invalid_file_size_mb: "Invalid exceed of file size {{size}}
|
|
137
|
+
invalid_file_size_kb: "Invalid exceed of file size {{size}} KB",
|
|
138
|
+
invalid_file_size_mb: "Invalid exceed of file size {{size}} MB"
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { type OptionalParams } from 'js-file-downloader';
|
|
1
2
|
export declare class FileHelper {
|
|
2
3
|
static toBase64: (file: File) => Promise<string>;
|
|
3
4
|
static readFileAsync: (file: File) => Promise<string>;
|
|
4
5
|
static dataURLtoFile: (dataUrl: string, filename: string) => Promise<File>;
|
|
6
|
+
static downloadURL: (url: string, filename?: string, params?: OptionalParams) => Promise<any>;
|
|
7
|
+
static downloadFromURL: (url: string, filename?: string, params?: OptionalParams) => Promise<any>;
|
|
5
8
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import JsFileDownloader from "js-file-downloader";
|
|
1
2
|
export class FileHelper {
|
|
2
3
|
static toBase64 = async (file) => {
|
|
3
4
|
return new Promise((resolve, reject) => {
|
|
@@ -26,4 +27,32 @@ export class FileHelper {
|
|
|
26
27
|
const blob = await res.blob();
|
|
27
28
|
return new File([blob], filename, { type: "image/png" });
|
|
28
29
|
};
|
|
30
|
+
static downloadURL = async (url, filename = "", params = {}) => {
|
|
31
|
+
const getExtension = () => {
|
|
32
|
+
return url.split("?")[0].split(".").pop();
|
|
33
|
+
};
|
|
34
|
+
let finalFilename = filename && `${filename.trim().toLowerCase().replaceAll(" ", "-")}`;
|
|
35
|
+
if (getExtension()) {
|
|
36
|
+
finalFilename = `${finalFilename}.${getExtension()}`;
|
|
37
|
+
}
|
|
38
|
+
return new JsFileDownloader({
|
|
39
|
+
url,
|
|
40
|
+
filename: finalFilename,
|
|
41
|
+
...params
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
static downloadFromURL = async (url, filename = "", params = {}) => {
|
|
45
|
+
const getExtension = () => {
|
|
46
|
+
return url.split("?")[0].split(".").pop();
|
|
47
|
+
};
|
|
48
|
+
let finalFilename = filename && `${filename.trim().toLowerCase().replaceAll(" ", "-")}`;
|
|
49
|
+
if (getExtension()) {
|
|
50
|
+
finalFilename = `${finalFilename}.${getExtension()}`;
|
|
51
|
+
}
|
|
52
|
+
return new JsFileDownloader({
|
|
53
|
+
url,
|
|
54
|
+
filename: finalFilename,
|
|
55
|
+
...params
|
|
56
|
+
});
|
|
57
|
+
};
|
|
29
58
|
}
|
package/package.json
CHANGED
|
@@ -1,86 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@finema/core",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Finema Dev Core Team",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/types.d.ts",
|
|
11
|
-
"import": "./dist/module.mjs",
|
|
12
|
-
"require": "./dist/module.cjs"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"main": "./dist/module.cjs",
|
|
16
|
-
"types": "./dist/types.d.ts",
|
|
17
|
-
"files": [
|
|
18
|
-
"dist"
|
|
19
|
-
],
|
|
20
|
-
"engines": {
|
|
21
|
-
"node": ">=18.0.0"
|
|
22
|
-
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"prepack": "nuxt-module-build build",
|
|
25
|
-
"dev": "nuxi dev playground",
|
|
26
|
-
"dev:build": "nuxi build playground",
|
|
27
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
28
|
-
"lint": "eslint . --cache",
|
|
29
|
-
"lint:fix": "eslint . --fix --cache",
|
|
30
|
-
"test": "vitest run",
|
|
31
|
-
"test:watch": "vitest watch",
|
|
32
|
-
"release": "release-it --ci",
|
|
33
|
-
"prepare": "husky install"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@nuxt/kit": "^3.7.4",
|
|
37
|
-
"@nuxt/ui": "^2.13.0",
|
|
38
|
-
"@pinia/nuxt": "^0.5.1",
|
|
39
|
-
"@vee-validate/nuxt": "^4.12.4",
|
|
40
|
-
"@vee-validate/zod": "^4.12.4",
|
|
41
|
-
"@vuepic/vue-datepicker": "^7.4.1",
|
|
42
|
-
"axios": "^1.6.5",
|
|
43
|
-
"date-fns": "^3.2.0",
|
|
44
|
-
"i18next": "^23.7.16",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"zod
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"@
|
|
56
|
-
"@nuxt/
|
|
57
|
-
"@nuxt/
|
|
58
|
-
"@nuxt/
|
|
59
|
-
"@nuxt/
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@types/
|
|
63
|
-
"@
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"stylelint
|
|
76
|
-
"stylelint-config-
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"*.{
|
|
85
|
-
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@finema/core",
|
|
3
|
+
"version": "1.4.39",
|
|
4
|
+
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Finema Dev Core Team",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types.d.ts",
|
|
11
|
+
"import": "./dist/module.mjs",
|
|
12
|
+
"require": "./dist/module.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/module.cjs",
|
|
16
|
+
"types": "./dist/types.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prepack": "nuxt-module-build build",
|
|
25
|
+
"dev": "nuxi dev playground",
|
|
26
|
+
"dev:build": "nuxi build playground",
|
|
27
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
28
|
+
"lint": "eslint . --cache",
|
|
29
|
+
"lint:fix": "eslint . --fix --cache",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest watch",
|
|
32
|
+
"release": "release-it --ci",
|
|
33
|
+
"prepare": "husky install"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@nuxt/kit": "^3.7.4",
|
|
37
|
+
"@nuxt/ui": "^2.13.0",
|
|
38
|
+
"@pinia/nuxt": "^0.5.1",
|
|
39
|
+
"@vee-validate/nuxt": "^4.12.4",
|
|
40
|
+
"@vee-validate/zod": "^4.12.4",
|
|
41
|
+
"@vuepic/vue-datepicker": "^7.4.1",
|
|
42
|
+
"axios": "^1.6.5",
|
|
43
|
+
"date-fns": "^3.2.0",
|
|
44
|
+
"i18next": "^23.7.16",
|
|
45
|
+
"js-file-downloader": "^1.1.25",
|
|
46
|
+
"lodash-es": "^4.17.21",
|
|
47
|
+
"nuxt-security": "^1.0.0",
|
|
48
|
+
"pinia": "^2.1.7",
|
|
49
|
+
"qrcode.vue": "^3.4.1",
|
|
50
|
+
"url-join": "^5.0.0",
|
|
51
|
+
"zod": "^3.22.4",
|
|
52
|
+
"zod-i18n-map": "^2.25.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@finema/eslint-config": "^1.2.0",
|
|
56
|
+
"@nuxt/devtools": "latest",
|
|
57
|
+
"@nuxt/eslint-config": "^0.2.0",
|
|
58
|
+
"@nuxt/module-builder": "^0.5.4",
|
|
59
|
+
"@nuxt/schema": "^3.7.4",
|
|
60
|
+
"@nuxt/test-utils": "^3.9.0",
|
|
61
|
+
"@release-it/conventional-changelog": "^8.0.1",
|
|
62
|
+
"@types/lodash-es": "^4.17.12",
|
|
63
|
+
"@types/node": "^20.10.8",
|
|
64
|
+
"@vue/test-utils": "^2.4.3",
|
|
65
|
+
"changelogen": "^0.5.5",
|
|
66
|
+
"eslint": "^8.56.0",
|
|
67
|
+
"happy-dom": "^13.0.0",
|
|
68
|
+
"husky": "^8.0.3",
|
|
69
|
+
"lint-staged": "^15.2.0",
|
|
70
|
+
"nuxt": "^3.9.1",
|
|
71
|
+
"playwright-core": "^1.40.1",
|
|
72
|
+
"prettier": "^3.1.1",
|
|
73
|
+
"release-it": "^17.0.1",
|
|
74
|
+
"sass": "^1.69.5",
|
|
75
|
+
"stylelint": "^16.1.0",
|
|
76
|
+
"stylelint-config-prettier-scss": "^1.0.0",
|
|
77
|
+
"stylelint-config-standard-scss": "^13.0.0",
|
|
78
|
+
"vitest": "^1.1.3"
|
|
79
|
+
},
|
|
80
|
+
"resolutions": {
|
|
81
|
+
"vue": "3.3.13"
|
|
82
|
+
},
|
|
83
|
+
"lint-staged": {
|
|
84
|
+
"*.{ts,vue,tsx,js}": "eslint --fix --cache",
|
|
85
|
+
"*.{html,json}": "prettier --write"
|
|
86
|
+
}
|
|
87
|
+
}
|