@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.37",
3
+ "version": "1.4.39",
4
4
  "configKey": "core",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.7.4"
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { defineNuxtModule, createResolver, installModule, addPlugin, addComponen
2
2
  import 'lodash-es';
3
3
 
4
4
  const name = "@finema/core";
5
- const version = "1.4.37";
5
+ const version = "1.4.39";
6
6
 
7
7
  const colors = {
8
8
  black: "#20243E",
@@ -97,7 +97,6 @@
97
97
  v-else-if="option.type === INPUT_TYPES.UPLOAD_FILE_CLASSIC_AUTO"
98
98
  :class="option.class"
99
99
  :form="form"
100
- :request-options="option.props.requestOptions"
101
100
  v-bind="getFieldBinding(option)"
102
101
  v-on="option.on ?? {}"
103
102
  />
@@ -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 acceptFileSize = computed(() => props.maxSize)
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
- setErrors(i18next.t('custom:invalid_file_size', { size: acceptFileSizeMb.value }))
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 (acceptFileSize.value) {
126
- return file.size / 1000 <= acceptFileSize.value
130
+ if (acceptFileSizeKb.value) {
131
+ return file.size / 1000 <= acceptFileSizeKb.value
127
132
  }
128
133
 
129
134
  return true
@@ -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}} 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"
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}} Kb",
138
- invalid_file_size_mb: "Invalid exceed of file size {{size}} Mb"
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.37",
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
- "lodash-es": "^4.17.21",
46
- "nuxt-security": "^1.0.0",
47
- "pinia": "^2.1.7",
48
- "qrcode.vue": "^3.4.1",
49
- "url-join": "^5.0.0",
50
- "zod": "^3.22.4",
51
- "zod-i18n-map": "^2.25.0"
52
- },
53
- "devDependencies": {
54
- "@finema/eslint-config": "^1.2.0",
55
- "@nuxt/devtools": "latest",
56
- "@nuxt/eslint-config": "^0.2.0",
57
- "@nuxt/module-builder": "^0.5.4",
58
- "@nuxt/schema": "^3.7.4",
59
- "@nuxt/test-utils": "^3.9.0",
60
- "@release-it/conventional-changelog": "^8.0.1",
61
- "@types/lodash-es": "^4.17.12",
62
- "@types/node": "^20.10.8",
63
- "@vue/test-utils": "^2.4.3",
64
- "changelogen": "^0.5.5",
65
- "eslint": "^8.56.0",
66
- "happy-dom": "^13.0.0",
67
- "husky": "^8.0.3",
68
- "lint-staged": "^15.2.0",
69
- "nuxt": "^3.9.1",
70
- "playwright-core": "^1.40.1",
71
- "prettier": "^3.1.1",
72
- "release-it": "^17.0.1",
73
- "sass": "^1.69.5",
74
- "stylelint": "^16.1.0",
75
- "stylelint-config-prettier-scss": "^1.0.0",
76
- "stylelint-config-standard-scss": "^13.0.0",
77
- "vitest": "^1.1.3"
78
- },
79
- "resolutions": {
80
- "vue": "3.3.13"
81
- },
82
- "lint-staged": {
83
- "*.{ts,vue,tsx,js}": "eslint --fix --cache",
84
- "*.{html,json}": "prettier --write"
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
+ }