@finema/core 1.4.133 → 1.4.134
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
package/dist/module.mjs
CHANGED
|
@@ -170,13 +170,14 @@ import {
|
|
|
170
170
|
useFileAllocate,
|
|
171
171
|
useFileProgress,
|
|
172
172
|
isImageFromPath,
|
|
173
|
-
|
|
173
|
+
useFileSize,
|
|
174
174
|
} from '#core/helpers/componentHelper'
|
|
175
175
|
import FieldWrapper from '#core/components/Form/FieldWrapper.vue'
|
|
176
176
|
import { useFieldHOC } from '#core/composables/useForm'
|
|
177
177
|
import {
|
|
178
178
|
type IUploadRequest,
|
|
179
179
|
ref,
|
|
180
|
+
computed,
|
|
180
181
|
toRef,
|
|
181
182
|
useUI,
|
|
182
183
|
useUiConfig,
|
|
@@ -221,7 +222,7 @@ const isPreviewOpen = ref<boolean>(false)
|
|
|
221
222
|
|
|
222
223
|
const { onUploadProgress, onDownloadProgress, percent } = useFileProgress()
|
|
223
224
|
const fileAllocate = useFileAllocate(selectedFile, props)
|
|
224
|
-
const fileAllocateFromPath =
|
|
225
|
+
const fileAllocateFromPath = computed(() => useFileSize(value.value?.size))
|
|
225
226
|
|
|
226
227
|
const onDrop = (files: File[] | null) => {
|
|
227
228
|
if (props.isDisabled || files?.length === 0 || !files) return
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
|
-
import type { IFileValue } from '#core/components/Form/types';
|
|
3
2
|
export declare const checkMaxSize: (file: File, acceptFileSize?: number) => boolean;
|
|
4
3
|
export declare const checkFileType: (file: File, acceptFileType: string | string[]) => boolean;
|
|
5
4
|
export declare const generateURL: (file: File) => string;
|
|
@@ -17,18 +16,6 @@ export declare const useFileAllocate: (selectedFile: Ref<File | undefined | null
|
|
|
17
16
|
isAcceptFileUseMb: any;
|
|
18
17
|
acceptFile: any;
|
|
19
18
|
};
|
|
20
|
-
export declare const useFileAllocateFromPath: (file: Ref<IFileValue | undefined | null>, props: {
|
|
21
|
-
accept?: string | string[];
|
|
22
|
-
maxSize?: number;
|
|
23
|
-
}) => {
|
|
24
|
-
selectedFileSizeKb: any;
|
|
25
|
-
selectedFileSizeMb: any;
|
|
26
|
-
isSelectedFileUseMb: any;
|
|
27
|
-
acceptFileSizeKb: any;
|
|
28
|
-
acceptFileSizeMb: any;
|
|
29
|
-
isAcceptFileUseMb: any;
|
|
30
|
-
acceptFile: any;
|
|
31
|
-
};
|
|
32
19
|
export declare const useFileSize: (size?: number) => {
|
|
33
20
|
isSelectedFileUseMb: any;
|
|
34
21
|
selectedFileSizeKb: any;
|
|
@@ -65,26 +65,6 @@ export const useFileAllocate = (selectedFile, props) => {
|
|
|
65
65
|
acceptFile
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
|
-
export const useFileAllocateFromPath = (file, props) => {
|
|
69
|
-
const selectedFileSizeKb = computed(() => ((file.value?.size || 0) / 1e3).toFixed(2));
|
|
70
|
-
const selectedFileSizeMb = computed(() => ((file.value?.size || 0) / 1e3 / 1e3).toFixed(2));
|
|
71
|
-
const isSelectedFileUseMb = computed(() => (file.value?.size || 0) / 1e3 > 1024);
|
|
72
|
-
const acceptFileSizeKb = computed(() => props.maxSize || 0);
|
|
73
|
-
const acceptFileSizeMb = computed(() => ((acceptFileSizeKb.value || 0) / 1024).toFixed(2));
|
|
74
|
-
const isAcceptFileUseMb = computed(() => acceptFileSizeKb.value && acceptFileSizeKb.value > 1024);
|
|
75
|
-
const acceptFile = computed(
|
|
76
|
-
() => typeof props.accept === "string" ? props.accept : props.accept?.join(",")
|
|
77
|
-
);
|
|
78
|
-
return {
|
|
79
|
-
selectedFileSizeKb,
|
|
80
|
-
selectedFileSizeMb,
|
|
81
|
-
isSelectedFileUseMb,
|
|
82
|
-
acceptFileSizeKb,
|
|
83
|
-
acceptFileSizeMb,
|
|
84
|
-
isAcceptFileUseMb,
|
|
85
|
-
acceptFile
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
68
|
export const useFileSize = (size = 0) => {
|
|
89
69
|
const isSelectedFileUseMb = computed(() => size / 1e3 > 1024);
|
|
90
70
|
const selectedFileSizeKb = computed(() => (size / 1e3).toFixed(2));
|