@finema/core 1.4.31 → 1.4.33

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.31",
3
+ "version": "1.4.33",
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.31";
5
+ const version = "1.4.33";
6
6
 
7
7
  const colors = {
8
8
  black: "#20243E",
@@ -42,16 +42,7 @@
42
42
  </template>
43
43
 
44
44
  <script lang="tsx" setup>
45
- import {
46
- _isEmpty,
47
- computed,
48
- ref,
49
- StringHelper,
50
- toRef,
51
- useUI,
52
- useUiConfig,
53
- useWatchTrue,
54
- } from '#imports'
45
+ import { computed, ref, StringHelper, toRef, useUI, useUiConfig, useWatchTrue } from '#imports'
55
46
  import { type IUploadFileProps } from './types'
56
47
  import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
57
48
  import { useFieldHOC } from '#core/composables/useForm'
@@ -64,9 +55,10 @@ const config = useUiConfig<typeof uploadFileInputClassicAuto>(
64
55
  'uploadFileInputClassicAuto'
65
56
  )
66
57
 
58
+ const emits = defineEmits(['success'])
67
59
  const props = withDefaults(defineProps<IUploadFileProps>(), {})
68
60
 
69
- const { wrapperProps, handleChange: onChange, setErrors, value } = useFieldHOC<string>(props)
61
+ const { wrapperProps, setErrors, value } = useFieldHOC<string>(props)
70
62
 
71
63
  const request: IUploadRequest = {
72
64
  pathURL: props.uploadPathURL,
@@ -100,20 +92,13 @@ const handleChange = (e: Event) => {
100
92
  selectedFile.value = file
101
93
  const formData = new FormData()
102
94
 
103
- formData.append('file', file)
95
+ formData.append(props.bodyKey || 'file', file)
104
96
  upload.run(formData, { data: { onUploadProgress, onDownloadProgress } })
105
97
  }
106
98
  }
107
99
 
108
100
  const handleCheckFileCondition = (file: File | undefined): boolean => {
109
101
  if (!file) return false
110
- const accept = checkAcceptFile(file)
111
-
112
- if (!accept) {
113
- setErrors(i18next.t('custom:invalid_file_type'))
114
-
115
- return false
116
- }
117
102
 
118
103
  const maxSize = checkMaxSize(file)
119
104
 
@@ -128,18 +113,6 @@ const handleCheckFileCondition = (file: File | undefined): boolean => {
128
113
  return true
129
114
  }
130
115
 
131
- const checkAcceptFile = (file: File): boolean => {
132
- let fileType = ''
133
-
134
- if (_isEmpty(file.type)) {
135
- fileType = file.name.split('.').pop() || ''
136
- } else {
137
- fileType = file.type.split('/').pop() || ''
138
- }
139
-
140
- return acceptFile.value ? acceptFile.value.includes(fileType) : true
141
- }
142
-
143
116
  const checkMaxSize = (file: File): boolean => {
144
117
  if (acceptFileSize.value) {
145
118
  return file.size / 1000 <= acceptFileSize.value
@@ -165,10 +138,8 @@ const onDownloadProgress = (progressEvent: ProgressEvent) => {
165
138
  useWatchTrue(
166
139
  () => upload.status.value.isSuccess,
167
140
  () => {
168
- if (upload.data.value?.url) {
169
- value.value = upload.data.value?.url
170
- onChange(upload.data.value?.url)
171
- }
141
+ value.value = upload.data.value[props.responseKey || 'url']
142
+ emits('success', upload.data.value)
172
143
  }
173
144
  )
174
145
 
@@ -7,7 +7,11 @@ export interface IUploadFileProps extends IFieldProps {
7
7
  uploadPathURL?: string;
8
8
  selectFileLabel?: string;
9
9
  accept?: string[] | string;
10
+ bodyKey?: string;
11
+ responseKey?: string;
10
12
  maxSize?: number;
11
13
  imagePreviewURL?: string;
12
14
  }
13
- export type IUploadFileField = IFormFieldBase<INPUT_TYPES.UPLOAD_FILE_CLASSIC_AUTO, IUploadFileProps, never>;
15
+ export type IUploadFileField = IFormFieldBase<INPUT_TYPES.UPLOAD_FILE_CLASSIC_AUTO, IUploadFileProps, {
16
+ success?: (res: any) => void;
17
+ }>;
@@ -1,15 +1,8 @@
1
1
  import { type AxiosRequestConfig } from 'axios';
2
- export interface IUploadData {
3
- name: string;
4
- url: string;
5
- path: string;
6
- size: number;
7
- content_type: string;
8
- }
9
2
  export interface IUploadRequest {
10
3
  requestOptions: Omit<AxiosRequestConfig, 'baseURL'> & {
11
4
  baseURL: string;
12
5
  };
13
6
  pathURL?: string;
14
7
  }
15
- export declare const useUploadLoader: (request: IUploadRequest) => import("../helpers/apiObjectHelper").IUseObjectLoader<IUploadData, any, Record<string, any>>;
8
+ export declare const useUploadLoader: (request: IUploadRequest) => import("../helpers/apiObjectHelper").IUseObjectLoader<any, any, Record<string, any>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.31",
3
+ "version": "1.4.33",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",