@finema/core 3.14.4 → 3.14.6
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/InputSelect/index.vue +2 -0
- package/dist/runtime/components/Form/InputSelect/types.d.ts +1 -0
- package/dist/runtime/components/Form/InputSelectMultiple/index.vue +2 -1
- package/dist/runtime/components/Form/fileState/MultipleFilesState.d.vue.ts +0 -3
- package/dist/runtime/components/Form/fileState/MultipleFilesState.vue.d.ts +0 -3
- package/dist/runtime/components/Form/fileState/useUploadStateMultiple.d.ts +1 -1
- package/dist/runtime/components/Form/fileState/useUploadStateMultiple.js +95 -46
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
label-key="label"
|
|
13
13
|
:icon="icon"
|
|
14
14
|
:ui="ui"
|
|
15
|
+
:ignore-filter="ignoreFilter"
|
|
15
16
|
:leading-icon="options.find((item) => item.value === value)?.icon"
|
|
16
17
|
:avatar="options.find((item) => item.value === value)?.avatar"
|
|
17
18
|
@update:modelValue="onChange"
|
|
@@ -65,6 +66,7 @@ const emits = defineEmits([
|
|
|
65
66
|
]);
|
|
66
67
|
const props = defineProps({
|
|
67
68
|
icon: { type: String, required: false },
|
|
69
|
+
ignoreFilter: { type: Boolean, required: false },
|
|
68
70
|
trailingIcon: { type: String, required: false },
|
|
69
71
|
clearIcon: { type: String, required: false, default: "ph:x-circle-fill" },
|
|
70
72
|
selectedIcon: { type: String, required: false },
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
label-key="label"
|
|
14
14
|
:icon="icon"
|
|
15
15
|
:ui="ui"
|
|
16
|
-
:ignore-filter="
|
|
16
|
+
:ignore-filter="ignoreFilter"
|
|
17
17
|
@update:model-value="onChange"
|
|
18
18
|
@update:searchTerm="onSearch"
|
|
19
19
|
>
|
|
@@ -86,6 +86,7 @@ const emits = defineEmits([
|
|
|
86
86
|
]);
|
|
87
87
|
const props = defineProps({
|
|
88
88
|
icon: { type: String, required: false },
|
|
89
|
+
ignoreFilter: { type: Boolean, required: false },
|
|
89
90
|
trailingIcon: { type: String, required: false },
|
|
90
91
|
clearIcon: { type: String, required: false, default: "ph:x-circle-fill" },
|
|
91
92
|
selectedIcon: { type: String, required: false },
|
|
@@ -107,6 +107,6 @@ export declare const useUploadStateMultiple: (props: IUploadDropzoneAutoMultiple
|
|
|
107
107
|
dropzone: import("@vueuse/core").UseDropZoneReturn;
|
|
108
108
|
handleOpenFile: () => void;
|
|
109
109
|
handleDeleteFile: (index: number) => void;
|
|
110
|
-
handleRetryUpload: (index: number) => void
|
|
110
|
+
handleRetryUpload: (index: number) => Promise<void>;
|
|
111
111
|
handlePreview: (fileValue: IFileValue) => void;
|
|
112
112
|
};
|
|
@@ -87,48 +87,17 @@ export const useUploadStateMultiple = (props, emits, onChange, setErrors, value,
|
|
|
87
87
|
progress: newProgress
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
|
-
const stopSuccessWatch = watch(
|
|
91
|
-
() => uploadLoader.status.value.isSuccess,
|
|
92
|
-
(isSuccess) => {
|
|
93
|
-
if (isSuccess && uploadLoader.data.value) {
|
|
94
|
-
const fileValue = {
|
|
95
|
-
url: _get(uploadLoader.data.value, props.responseURL),
|
|
96
|
-
path: _get(uploadLoader.data.value, props.responsePath),
|
|
97
|
-
name: _get(uploadLoader.data.value, props.responseName) || fileItem.file.name,
|
|
98
|
-
size: Number(_get(uploadLoader.data.value, props.responseSize) || fileItem.file.size),
|
|
99
|
-
id: _get(uploadLoader.data.value, props.responseID)
|
|
100
|
-
};
|
|
101
|
-
fileItems.value = fileItems.value.filter((_, i) => i !== index);
|
|
102
|
-
onChange([fileValue, ...ArrayHelper.toArray(value.value)]);
|
|
103
|
-
emits("success", fileValue);
|
|
104
|
-
stopProgressWatch();
|
|
105
|
-
stopSuccessWatch();
|
|
106
|
-
stopErrorWatch();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
const stopErrorWatch = watch(
|
|
111
|
-
() => uploadLoader.status.value.isError,
|
|
112
|
-
(isError) => {
|
|
113
|
-
if (isError) {
|
|
114
|
-
updateFileItem(index, {
|
|
115
|
-
state: "error" /* ERROR */,
|
|
116
|
-
error: "\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14: " + StringHelper.getError(
|
|
117
|
-
uploadLoader.status.value.errorData
|
|
118
|
-
)
|
|
119
|
-
});
|
|
120
|
-
stopProgressWatch();
|
|
121
|
-
stopSuccessWatch();
|
|
122
|
-
stopErrorWatch();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
90
|
updateFileItem(index, {
|
|
127
|
-
cleanupWatchers: [stopProgressWatch
|
|
91
|
+
cleanupWatchers: [stopProgressWatch]
|
|
128
92
|
});
|
|
129
93
|
return uploadLoader;
|
|
130
94
|
};
|
|
131
95
|
const processFile = (file) => {
|
|
96
|
+
processFileAsync(file).catch((error) => {
|
|
97
|
+
console.error("Error processing file:", error);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const processFileAsync = async (file) => {
|
|
132
101
|
const validation = validateFile(file);
|
|
133
102
|
if (!validation.valid) {
|
|
134
103
|
setErrors(validation.error || "Invalid file");
|
|
@@ -149,14 +118,54 @@ export const useUploadStateMultiple = (props, emits, onChange, setErrors, value,
|
|
|
149
118
|
const uploadLoader = setupUpload(fileItem, newIndex);
|
|
150
119
|
const formData = new FormData();
|
|
151
120
|
formData.append(props.bodyKey, file);
|
|
152
|
-
|
|
153
|
-
|
|
121
|
+
await new Promise((resolve, reject) => {
|
|
122
|
+
const stopSuccessWatch = watch(
|
|
123
|
+
() => uploadLoader.status.value.isSuccess,
|
|
124
|
+
(isSuccess) => {
|
|
125
|
+
if (isSuccess && uploadLoader.data.value) {
|
|
126
|
+
const fileValue = {
|
|
127
|
+
url: _get(uploadLoader.data.value, props.responseURL),
|
|
128
|
+
path: _get(uploadLoader.data.value, props.responsePath),
|
|
129
|
+
name: _get(uploadLoader.data.value, props.responseName) || fileItem.file.name,
|
|
130
|
+
size: Number(_get(uploadLoader.data.value, props.responseSize) || fileItem.file.size),
|
|
131
|
+
id: _get(uploadLoader.data.value, props.responseID)
|
|
132
|
+
};
|
|
133
|
+
fileItems.value = fileItems.value.filter((_, i) => i !== newIndex);
|
|
134
|
+
onChange([fileValue, ...ArrayHelper.toArray(value.value)]);
|
|
135
|
+
emits("success", fileValue);
|
|
136
|
+
stopSuccessWatch();
|
|
137
|
+
stopErrorWatch();
|
|
138
|
+
resolve();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
const stopErrorWatch = watch(
|
|
143
|
+
() => uploadLoader.status.value.isError,
|
|
144
|
+
(isError) => {
|
|
145
|
+
if (isError) {
|
|
146
|
+
updateFileItem(newIndex, {
|
|
147
|
+
state: "error" /* ERROR */,
|
|
148
|
+
error: "\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14: " + StringHelper.getError(
|
|
149
|
+
uploadLoader.status.value.errorData
|
|
150
|
+
)
|
|
151
|
+
});
|
|
152
|
+
stopSuccessWatch();
|
|
153
|
+
stopErrorWatch();
|
|
154
|
+
reject(new Error("Upload failed"));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
uploadLoader.run({
|
|
159
|
+
data: formData
|
|
160
|
+
});
|
|
154
161
|
});
|
|
155
162
|
emits("change", fileItems.value.map((item) => item.file));
|
|
156
163
|
};
|
|
157
|
-
const handleFileDrop = (files) => {
|
|
164
|
+
const handleFileDrop = async (files) => {
|
|
158
165
|
if (wrapperProps.value.disabled || wrapperProps.value.readonly || !files?.length) return;
|
|
159
|
-
|
|
166
|
+
for (const file of files) {
|
|
167
|
+
await processFileAsync(file);
|
|
168
|
+
}
|
|
160
169
|
};
|
|
161
170
|
const fileDialog = useFileDialog({
|
|
162
171
|
accept: acceptedFileTypes.value || "",
|
|
@@ -175,9 +184,11 @@ export const useUploadStateMultiple = (props, emits, onChange, setErrors, value,
|
|
|
175
184
|
const allSuccess = computed(
|
|
176
185
|
() => fileItems.value.length > 0 && fileItems.value.every((item) => item.state === "success" /* SUCCESS */)
|
|
177
186
|
);
|
|
178
|
-
fileDialog.onChange((files) => {
|
|
187
|
+
fileDialog.onChange(async (files) => {
|
|
179
188
|
if (files?.length) {
|
|
180
|
-
Array.from(files)
|
|
189
|
+
for (const file of Array.from(files)) {
|
|
190
|
+
await processFileAsync(file);
|
|
191
|
+
}
|
|
181
192
|
fileDialog.reset();
|
|
182
193
|
}
|
|
183
194
|
});
|
|
@@ -200,7 +211,7 @@ export const useUploadStateMultiple = (props, emits, onChange, setErrors, value,
|
|
|
200
211
|
}
|
|
201
212
|
emits("delete", index);
|
|
202
213
|
};
|
|
203
|
-
const handleRetryUpload = (index) => {
|
|
214
|
+
const handleRetryUpload = async (index) => {
|
|
204
215
|
const fileItem = fileItems.value[index];
|
|
205
216
|
if (!fileItem) return;
|
|
206
217
|
updateFileItem(index, {
|
|
@@ -211,8 +222,46 @@ export const useUploadStateMultiple = (props, emits, onChange, setErrors, value,
|
|
|
211
222
|
const uploadLoader = setupUpload(fileItem, index);
|
|
212
223
|
const formData = new FormData();
|
|
213
224
|
formData.append(props.bodyKey, fileItem.file);
|
|
214
|
-
|
|
215
|
-
|
|
225
|
+
await new Promise((resolve, reject) => {
|
|
226
|
+
const stopSuccessWatch = watch(
|
|
227
|
+
() => uploadLoader.status.value.isSuccess,
|
|
228
|
+
(isSuccess) => {
|
|
229
|
+
if (isSuccess && uploadLoader.data.value) {
|
|
230
|
+
const fileValue = {
|
|
231
|
+
url: _get(uploadLoader.data.value, props.responseURL),
|
|
232
|
+
path: _get(uploadLoader.data.value, props.responsePath),
|
|
233
|
+
name: _get(uploadLoader.data.value, props.responseName) || fileItem.file.name,
|
|
234
|
+
size: Number(_get(uploadLoader.data.value, props.responseSize) || fileItem.file.size),
|
|
235
|
+
id: _get(uploadLoader.data.value, props.responseID)
|
|
236
|
+
};
|
|
237
|
+
fileItems.value = fileItems.value.filter((_, i) => i !== index);
|
|
238
|
+
onChange([fileValue, ...ArrayHelper.toArray(value.value)]);
|
|
239
|
+
emits("success", fileValue);
|
|
240
|
+
stopSuccessWatch();
|
|
241
|
+
stopErrorWatch();
|
|
242
|
+
resolve();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
const stopErrorWatch = watch(
|
|
247
|
+
() => uploadLoader.status.value.isError,
|
|
248
|
+
(isError) => {
|
|
249
|
+
if (isError) {
|
|
250
|
+
updateFileItem(index, {
|
|
251
|
+
state: "error" /* ERROR */,
|
|
252
|
+
error: "\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14: " + StringHelper.getError(
|
|
253
|
+
uploadLoader.status.value.errorData
|
|
254
|
+
)
|
|
255
|
+
});
|
|
256
|
+
stopSuccessWatch();
|
|
257
|
+
stopErrorWatch();
|
|
258
|
+
reject(new Error("Upload failed"));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
uploadLoader.run({
|
|
263
|
+
data: formData
|
|
264
|
+
});
|
|
216
265
|
});
|
|
217
266
|
};
|
|
218
267
|
const handlePreview = (fileValue) => {
|