@finema/core 3.22.0 → 3.23.2

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.
Files changed (125) hide show
  1. package/dist/module.d.mts +2 -0
  2. package/dist/module.json +2 -2
  3. package/dist/module.mjs +16 -2
  4. package/dist/runtime/components/App.vue +1 -1
  5. package/dist/runtime/components/DevToolsWindow/index.vue +1 -1
  6. package/dist/runtime/components/Dialog/index.d.vue.ts +1 -4
  7. package/dist/runtime/components/Dialog/index.vue +9 -10
  8. package/dist/runtime/components/Dialog/index.vue.d.ts +1 -4
  9. package/dist/runtime/components/Empty.d.vue.ts +0 -1
  10. package/dist/runtime/components/Empty.vue +6 -2
  11. package/dist/runtime/components/Empty.vue.d.ts +0 -1
  12. package/dist/runtime/components/FlexDeck/index.vue +86 -81
  13. package/dist/runtime/components/Form/FieldWrapper.vue +14 -14
  14. package/dist/runtime/components/Form/Fields.vue +10 -10
  15. package/dist/runtime/components/Form/InputCheckbox/index.vue +20 -19
  16. package/dist/runtime/components/Form/InputCheckboxGroup/index.vue +2 -1
  17. package/dist/runtime/components/Form/InputComponent/index.vue +2 -1
  18. package/dist/runtime/components/Form/InputCurrency/index.vue +51 -50
  19. package/dist/runtime/components/Form/InputDateTime/date_time_field.types.d.ts +1 -1
  20. package/dist/runtime/components/Form/InputDateTime/index.vue +69 -64
  21. package/dist/runtime/components/Form/InputDateTimeRange/date_range_time_field.types.d.ts +1 -1
  22. package/dist/runtime/components/Form/InputDateTimeRange/index.vue +62 -57
  23. package/dist/runtime/components/Form/InputMonth/index.vue +10 -5
  24. package/dist/runtime/components/Form/InputMonth/types.d.ts +1 -1
  25. package/dist/runtime/components/Form/InputNumber/index.vue +22 -21
  26. package/dist/runtime/components/Form/InputRadio/index.d.vue.ts +1 -1
  27. package/dist/runtime/components/Form/InputRadio/index.vue +2 -1
  28. package/dist/runtime/components/Form/InputRadio/index.vue.d.ts +1 -1
  29. package/dist/runtime/components/Form/InputRating/index.vue +2 -1
  30. package/dist/runtime/components/Form/InputSearch/index.vue +7 -2
  31. package/dist/runtime/components/Form/InputSelect/index.vue +112 -111
  32. package/dist/runtime/components/Form/InputSelectMultiple/index.vue +120 -119
  33. package/dist/runtime/components/Form/InputTags/index.vue +56 -55
  34. package/dist/runtime/components/Form/InputText/index.vue +88 -87
  35. package/dist/runtime/components/Form/InputTextarea/index.vue +20 -19
  36. package/dist/runtime/components/Form/InputTime/index.vue +45 -40
  37. package/dist/runtime/components/Form/InputTime/types.d.ts +1 -1
  38. package/dist/runtime/components/Form/InputToggle/index.vue +19 -18
  39. package/dist/runtime/components/Form/InputUploadDropzone/index.d.vue.ts +1 -4
  40. package/dist/runtime/components/Form/InputUploadDropzone/index.vue +40 -35
  41. package/dist/runtime/components/Form/InputUploadDropzone/index.vue.d.ts +1 -4
  42. package/dist/runtime/components/Form/InputUploadDropzone/types.d.ts +2 -2
  43. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.d.vue.ts +0 -5
  44. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue +63 -58
  45. package/dist/runtime/components/Form/InputUploadDropzoneAuto/index.vue.d.ts +0 -5
  46. package/dist/runtime/components/Form/InputUploadDropzoneAuto/types.d.ts +3 -3
  47. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.d.vue.ts +0 -5
  48. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue +69 -60
  49. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/index.vue.d.ts +0 -5
  50. package/dist/runtime/components/Form/InputUploadDropzoneAutoMultiple/types.d.ts +3 -3
  51. package/dist/runtime/components/Form/InputUploadImageAuto/index.d.vue.ts +1 -6
  52. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue +63 -58
  53. package/dist/runtime/components/Form/InputUploadImageAuto/index.vue.d.ts +1 -6
  54. package/dist/runtime/components/Form/InputUploadImageAuto/types.d.ts +3 -3
  55. package/dist/runtime/components/Form/InputWYSIWYG/EditorImageUploadNode.vue +18 -18
  56. package/dist/runtime/components/Form/InputWYSIWYG/EditorLinkPopover.vue +65 -65
  57. package/dist/runtime/components/Form/InputWYSIWYG/README.md +96 -96
  58. package/dist/runtime/components/Form/InputWYSIWYG/index.vue +43 -42
  59. package/dist/runtime/components/Form/fileState/EmptyState.vue +21 -21
  60. package/dist/runtime/components/Form/fileState/FailedState.vue +37 -33
  61. package/dist/runtime/components/Form/fileState/LoadingState.vue +24 -24
  62. package/dist/runtime/components/Form/fileState/MultipleFilesState.d.vue.ts +4 -4
  63. package/dist/runtime/components/Form/fileState/MultipleFilesState.vue +79 -75
  64. package/dist/runtime/components/Form/fileState/MultipleFilesState.vue.d.ts +4 -4
  65. package/dist/runtime/components/Form/fileState/PreviewModal.vue +23 -23
  66. package/dist/runtime/components/Form/fileState/SuccessState.d.vue.ts +2 -2
  67. package/dist/runtime/components/Form/fileState/SuccessState.vue +8 -4
  68. package/dist/runtime/components/Form/fileState/SuccessState.vue.d.ts +2 -2
  69. package/dist/runtime/components/Form/fileState/useFilePicker.d.ts +34 -0
  70. package/dist/runtime/components/Form/fileState/useFilePicker.js +48 -0
  71. package/dist/runtime/components/Form/fileState/useFileState.d.ts +7 -9
  72. package/dist/runtime/components/Form/fileState/useFileState.js +40 -120
  73. package/dist/runtime/components/Form/fileState/useUploadImageState.d.ts +7 -8
  74. package/dist/runtime/components/Form/fileState/useUploadImageState.js +28 -300
  75. package/dist/runtime/components/Form/fileState/useUploadState.d.ts +11 -7
  76. package/dist/runtime/components/Form/fileState/useUploadState.js +58 -131
  77. package/dist/runtime/components/Form/fileState/useUploadStateMultiple.d.ts +12 -18
  78. package/dist/runtime/components/Form/fileState/useUploadStateMultiple.js +89 -222
  79. package/dist/runtime/components/Form/index.vue +5 -5
  80. package/dist/runtime/components/Form/types.d.ts +2 -0
  81. package/dist/runtime/components/Image.vue +28 -28
  82. package/dist/runtime/components/Loader.d.vue.ts +1 -0
  83. package/dist/runtime/components/Loader.vue.d.ts +1 -0
  84. package/dist/runtime/components/Table/Base.d.vue.ts +15 -1
  85. package/dist/runtime/components/Table/Base.vue +118 -118
  86. package/dist/runtime/components/Table/Base.vue.d.ts +15 -1
  87. package/dist/runtime/components/Table/ColumnDate.vue +1 -1
  88. package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
  89. package/dist/runtime/components/Table/ColumnImage.vue +4 -4
  90. package/dist/runtime/components/Table/ColumnText.d.vue.ts +2 -3
  91. package/dist/runtime/components/Table/ColumnText.vue +11 -11
  92. package/dist/runtime/components/Table/ColumnText.vue.d.ts +2 -3
  93. package/dist/runtime/components/Table/Pagination.vue +70 -67
  94. package/dist/runtime/components/Table/Simple.vue +19 -19
  95. package/dist/runtime/components/Table/index.d.vue.ts +1 -1
  96. package/dist/runtime/components/Table/index.vue +37 -33
  97. package/dist/runtime/components/Table/index.vue.d.ts +1 -1
  98. package/dist/runtime/composables/loaderList.d.ts +2 -1
  99. package/dist/runtime/composables/loaderList.js +2 -1
  100. package/dist/runtime/composables/loaderObject.d.ts +2 -1
  101. package/dist/runtime/composables/loaderObject.js +2 -1
  102. package/dist/runtime/composables/loaderPage.js +194 -344
  103. package/dist/runtime/composables/useConfig.js +4 -3
  104. package/dist/runtime/composables/useDialog.js +5 -1
  105. package/dist/runtime/composables/useForm.d.ts +1 -1
  106. package/dist/runtime/composables/useForm.js +1 -1
  107. package/dist/runtime/composables/useMessages.d.ts +10 -0
  108. package/dist/runtime/composables/useMessages.js +10 -0
  109. package/dist/runtime/helpers/apiPageHelper.d.ts +0 -1
  110. package/dist/runtime/helpers/uploadCore.d.ts +54 -0
  111. package/dist/runtime/helpers/uploadCore.js +84 -0
  112. package/dist/runtime/i18n/valibot.d.ts +5 -68
  113. package/dist/runtime/i18n/valibot.js +33 -29
  114. package/dist/runtime/locale/en.d.ts +2 -0
  115. package/dist/runtime/locale/en.js +42 -0
  116. package/dist/runtime/locale/index.d.ts +7 -0
  117. package/dist/runtime/locale/index.js +8 -0
  118. package/dist/runtime/locale/th.d.ts +43 -0
  119. package/dist/runtime/locale/th.js +42 -0
  120. package/dist/runtime/server/tsconfig.json +3 -3
  121. package/dist/runtime/utils/ParamHelper.js +1 -1
  122. package/dist/runtime/utils/StringHelper.js +1 -4
  123. package/dist/runtime/utils/TimeHelper.js +2 -2
  124. package/dist/runtime/utils/lodash.js +2 -2
  125. package/package.json +20 -12
@@ -1,211 +1,126 @@
1
- import { useDropZone, useFileDialog } from "@vueuse/core";
2
- import PreviewModal from "./PreviewModal.vue";
3
- import { ArrayHelper, computed, ref, useOverlay, watch } from "#imports";
1
+ import { useFilePicker } from "./useFilePicker.js";
2
+ import { toFileValue, toUploadFormData, UploadState, validateFile } from "#core/helpers/uploadCore";
3
+ import { useCoreMessages } from "#core/composables/useMessages";
4
4
  import { useUploadLoader } from "#core/composables/useUpload";
5
- import { useFileAllocate, useFileProgress } from "#core/helpers/componentHelper";
5
+ import { useFileProgress } from "#core/helpers/componentHelper";
6
6
  import { StringHelper } from "#core/utils/StringHelper";
7
- import { _get } from "#core/utils/lodash";
8
- export var UploadState = /* @__PURE__ */ ((UploadState2) => {
9
- UploadState2["EMPTY"] = "empty";
10
- UploadState2["UPLOADING"] = "uploading";
11
- UploadState2["SUCCESS"] = "success";
12
- UploadState2["ERROR"] = "error";
13
- return UploadState2;
14
- })(UploadState || {});
15
- export const useUploadStateMultiple = (props, emits, onChange, setErrors, value, acceptedFileTypes, wrapperProps, dropzoneRef) => {
16
- const overlay = useOverlay();
17
- const previewModal = overlay.create(PreviewModal);
7
+ import { ArrayHelper, computed, ref, watch } from "#imports";
8
+ export { UploadState };
9
+ export const useUploadStateMultiple = (context) => {
10
+ const {
11
+ props,
12
+ emits,
13
+ onChange,
14
+ setErrors,
15
+ value
16
+ } = context;
17
+ const {
18
+ messages,
19
+ format
20
+ } = useCoreMessages();
18
21
  const fileItems = ref([]);
19
- const fileAllocate = useFileAllocate(computed(() => fileItems.value[0]?.file), props);
20
- const validateFile = (file) => {
21
- if (props.accept && fileAllocate.acceptFile.value) {
22
- const acceptedTypes = fileAllocate.acceptFile.value;
23
- const acceptedTypesList = acceptedTypes.split(",").map((type) => type.trim());
24
- const fileExtension = file.name.toLowerCase().split(".").pop();
25
- const isValidFileType = acceptedTypesList.some((acceptedType) => {
26
- if (acceptedType.startsWith(".")) {
27
- return fileExtension === acceptedType.slice(1).toLowerCase();
28
- }
29
- if (!acceptedType.includes("/") && !acceptedType.includes("*")) {
30
- return fileExtension === acceptedType.toLowerCase();
31
- }
32
- if (acceptedType.endsWith("/*")) {
33
- return file.type.startsWith(acceptedType.slice(0, -2) + "/");
34
- }
35
- return file.type === acceptedType;
36
- });
37
- if (!isValidFileType) {
38
- return {
39
- valid: false,
40
- error: `\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E44\u0E1F\u0E25\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07 (\u0E23\u0E2D\u0E07\u0E23\u0E31\u0E1A\u0E40\u0E09\u0E1E\u0E32\u0E30 ${acceptedTypesList.join(", ")})`
41
- };
42
- }
43
- }
44
- if (props.maxSize) {
45
- const maxSizeBytes = (fileAllocate.acceptFileSizeKb.value || 0) * 1024;
46
- if (file.size > maxSizeBytes) {
47
- const sizeLabel = fileAllocate.isAcceptFileUseMb.value ? `${fileAllocate.acceptFileSizeMb.value} MB` : `${fileAllocate.acceptFileSizeKb.value} KB`;
48
- return {
49
- valid: false,
50
- error: `\u0E02\u0E19\u0E32\u0E14\u0E44\u0E1F\u0E25\u0E4C\u0E15\u0E49\u0E2D\u0E07\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19 ${sizeLabel}`
51
- };
52
- }
53
- }
54
- return {
55
- valid: true
56
- };
22
+ let nextId = 0;
23
+ const updateFileItem = (id, updates) => {
24
+ fileItems.value = fileItems.value.map((item) => item.id === id ? {
25
+ ...item,
26
+ ...updates
27
+ } : item);
28
+ };
29
+ const removeFileItem = (id) => {
30
+ fileItems.value = fileItems.value.filter((item) => item.id !== id);
57
31
  };
58
- const updateFileItem = (index, updates) => {
59
- fileItems.value = fileItems.value.map(
60
- (item, i) => i === index ? {
61
- ...item,
62
- ...updates
63
- } : item
64
- );
32
+ const isFull = () => !!props.maxFiles && fileItems.value.length >= props.maxFiles;
33
+ const setMaxFilesError = () => {
34
+ setErrors(format(messages.value.upload.maxFiles, {
35
+ max: props.maxFiles
36
+ }));
65
37
  };
66
- const setupUpload = (fileItem, index) => {
38
+ const uploadFile = async (id, file) => {
67
39
  const {
68
40
  percent,
69
41
  onDownloadProgress,
70
42
  onUploadProgress
71
43
  } = useFileProgress();
72
- const request = {
44
+ const uploadLoader = useUploadLoader({
73
45
  requestOptions: {
74
46
  ...props.requestOptions,
75
47
  onDownloadProgress,
76
48
  onUploadProgress
77
49
  },
78
50
  pathURL: props.uploadPathURL
79
- };
80
- const uploadLoader = useUploadLoader(request);
81
- updateFileItem(index, {
82
- uploadLoader,
83
- percentRef: percent
84
51
  });
85
- const stopProgressWatch = watch(percent, (newProgress) => {
86
- updateFileItem(index, {
87
- progress: newProgress
52
+ const stopProgressWatch = watch(percent, (progress) => updateFileItem(id, {
53
+ progress
54
+ }));
55
+ try {
56
+ await uploadLoader.run({
57
+ data: toUploadFormData(props.bodyKey, file)
88
58
  });
89
- });
90
- updateFileItem(index, {
91
- cleanupWatchers: [stopProgressWatch]
92
- });
93
- return uploadLoader;
94
- };
95
- const processFile = (file) => {
96
- processFileAsync(file).catch((error) => {
97
- console.error("Error processing file:", error);
59
+ } finally {
60
+ stopProgressWatch();
61
+ }
62
+ if (uploadLoader.status.value.isSuccess && uploadLoader.data.value) {
63
+ const fileValue = toFileValue(uploadLoader.data.value, props, file);
64
+ removeFileItem(id);
65
+ onChange([fileValue, ...ArrayHelper.toArray(value.value)]);
66
+ emits("success", fileValue);
67
+ return;
68
+ }
69
+ updateFileItem(id, {
70
+ state: UploadState.ERROR,
71
+ error: format(messages.value.upload.error, {
72
+ message: StringHelper.getError(uploadLoader.status.value.errorData, messages.value.common.somethingWentWrong)
73
+ })
98
74
  });
99
75
  };
100
- const processFileAsync = async (file) => {
101
- const validation = validateFile(file);
102
- if (!validation.valid) {
103
- setErrors(validation.error || "Invalid file");
76
+ const processFile = async (file) => {
77
+ const error = validateFile(file, props, messages.value.upload);
78
+ if (error) {
79
+ setErrors(error);
104
80
  return;
105
81
  }
106
- if (props.maxFiles && fileItems.value.length >= props.maxFiles) {
107
- setErrors(`\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E2D\u0E31\u0E1E\u0E42\u0E2B\u0E25\u0E14\u0E44\u0E14\u0E49\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14 ${props.maxFiles} \u0E44\u0E1F\u0E25\u0E4C`);
82
+ if (isFull()) {
83
+ setMaxFilesError();
108
84
  return;
109
85
  }
110
86
  setErrors("");
111
- const fileItem = {
112
- file,
113
- state: "uploading" /* UPLOADING */,
114
- progress: 0
115
- };
116
- fileItems.value = [...fileItems.value, fileItem];
117
- const newIndex = fileItems.value.length - 1;
118
- const uploadLoader = setupUpload(fileItem, newIndex);
119
- const formData = new FormData();
120
- formData.append(props.bodyKey, file);
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
- });
161
- });
87
+ const id = nextId++;
88
+ fileItems.value = [
89
+ ...fileItems.value,
90
+ {
91
+ id,
92
+ file,
93
+ state: UploadState.UPLOADING,
94
+ progress: 0
95
+ }
96
+ ];
97
+ await uploadFile(id, file);
162
98
  emits("change", fileItems.value.map((item) => item.file));
163
99
  };
164
- const handleFileDrop = async (files) => {
165
- if (wrapperProps.value.disabled || wrapperProps.value.readonly || !files?.length) return;
166
- for (const file of files) {
167
- await processFileAsync(file);
168
- }
169
- };
170
- const fileDialog = useFileDialog({
171
- accept: acceptedFileTypes.value || "",
172
- directory: false,
173
- multiple: true
174
- });
175
- const dropzone = useDropZone(dropzoneRef, {
176
- onDrop: handleFileDrop,
100
+ const picker = useFilePicker(context, {
177
101
  multiple: true,
178
- preventDefaultForUnhandled: false
102
+ onFiles: async (files) => {
103
+ for (const file of files) {
104
+ await processFile(file);
105
+ }
106
+ }
179
107
  });
180
108
  const isEmpty = computed(() => fileItems.value.length === 0);
181
109
  const hasUploading = computed(
182
- () => fileItems.value.some((item) => item.state === "uploading" /* UPLOADING */)
110
+ () => fileItems.value.some((item) => item.state === UploadState.UPLOADING)
183
111
  );
184
112
  const allSuccess = computed(
185
- () => fileItems.value.length > 0 && fileItems.value.every((item) => item.state === "success" /* SUCCESS */)
113
+ () => fileItems.value.length > 0 && fileItems.value.every((item) => item.state === UploadState.SUCCESS)
186
114
  );
187
- fileDialog.onChange(async (files) => {
188
- if (files?.length) {
189
- for (const file of Array.from(files)) {
190
- await processFileAsync(file);
191
- }
192
- fileDialog.reset();
193
- }
194
- });
195
115
  const handleOpenFile = () => {
196
- if (props.maxFiles && fileItems.value.length >= props.maxFiles) {
197
- setErrors(`\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E2D\u0E31\u0E1E\u0E42\u0E2B\u0E25\u0E14\u0E44\u0E14\u0E49\u0E2A\u0E39\u0E07\u0E2A\u0E38\u0E14 ${props.maxFiles} \u0E44\u0E1F\u0E25\u0E4C`);
116
+ if (isFull()) {
117
+ setMaxFilesError();
198
118
  return;
199
119
  }
200
- if (wrapperProps.value.disabled || wrapperProps.value.readonly) return;
201
- fileDialog.open();
120
+ picker.handleOpenFile();
202
121
  };
203
122
  const handleDeleteFile = (index) => {
204
- const fileItem = fileItems.value[index];
205
- if (fileItem?.cleanupWatchers) {
206
- fileItem.cleanupWatchers.forEach((cleanup) => cleanup());
207
- }
208
- fileItems.value.splice(index, 1);
123
+ fileItems.value = fileItems.value.filter((_, itemIndex) => itemIndex !== index);
209
124
  if (fileItems.value.length === 0) {
210
125
  setErrors("");
211
126
  }
@@ -214,60 +129,12 @@ export const useUploadStateMultiple = (props, emits, onChange, setErrors, value,
214
129
  const handleRetryUpload = async (index) => {
215
130
  const fileItem = fileItems.value[index];
216
131
  if (!fileItem) return;
217
- updateFileItem(index, {
218
- state: "uploading" /* UPLOADING */,
132
+ updateFileItem(fileItem.id, {
133
+ state: UploadState.UPLOADING,
219
134
  error: void 0,
220
135
  progress: 0
221
136
  });
222
- const uploadLoader = setupUpload(fileItem, index);
223
- const formData = new FormData();
224
- formData.append(props.bodyKey, fileItem.file);
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
- });
265
- });
266
- };
267
- const handlePreview = (fileValue) => {
268
- previewModal.open({
269
- value: fileValue
270
- });
137
+ await uploadFile(fileItem.id, fileItem.file);
271
138
  };
272
139
  return {
273
140
  // State
@@ -276,11 +143,11 @@ export const useUploadStateMultiple = (props, emits, onChange, setErrors, value,
276
143
  hasUploading,
277
144
  allSuccess,
278
145
  // Upload utilities
279
- dropzone,
146
+ dropzone: picker.dropzone,
280
147
  // Handlers
281
148
  handleOpenFile,
282
149
  handleDeleteFile,
283
150
  handleRetryUpload,
284
- handlePreview
151
+ handlePreview: picker.openPreview
285
152
  };
286
153
  };
@@ -1,5 +1,5 @@
1
- <template>
2
- <form class="form">
3
- <slot />
4
- </form>
5
- </template>
1
+ <template>
2
+ <form class="form">
3
+ <slot />
4
+ </form>
5
+ </template>
@@ -71,6 +71,8 @@ export interface IFieldProps {
71
71
  required?: boolean;
72
72
  help?: string;
73
73
  ui?: object | any;
74
+ /** Classes for the FormField wrapper (label, hint, error); set by FormFields from the field's `ui` */
75
+ containerUi?: object | any;
74
76
  }
75
77
  export interface IFormFieldBase<I extends INPUT_TYPES, P extends IFieldProps, O> {
76
78
  type: I;
@@ -1,32 +1,32 @@
1
1
  <template>
2
- <UseImage v-bind="$props">
3
- <template #loading>
4
- <slot name="loading">
5
- <div
6
- class="flex h-full w-full items-center justify-center"
7
- >
8
- <Loader
9
- :loading="true"
10
- />
11
- </div>
12
- </slot>
13
- </template>
14
-
15
- <template #error>
16
- <slot name="error">
17
- <div
18
- class="flex h-full w-full items-center justify-center"
19
- >
20
- <p class="text-error-400">
21
- <Icon
22
- name="i-heroicons:exclamation-circle-solid"
23
- class="text-error-400 size-8"
24
- />
25
- </p>
26
- </div>
27
- </slot>
28
- </template>
29
- </UseImage>
2
+ <UseImage v-bind="$props">
3
+ <template #loading>
4
+ <slot name="loading">
5
+ <div
6
+ class="flex h-full w-full items-center justify-center"
7
+ >
8
+ <Loader
9
+ :loading="true"
10
+ />
11
+ </div>
12
+ </slot>
13
+ </template>
14
+
15
+ <template #error>
16
+ <slot name="error">
17
+ <div
18
+ class="flex h-full w-full items-center justify-center"
19
+ >
20
+ <p class="text-error-400">
21
+ <Icon
22
+ name="i-heroicons:exclamation-circle-solid"
23
+ class="text-error-400 size-8"
24
+ />
25
+ </p>
26
+ </div>
27
+ </slot>
28
+ </template>
29
+ </UseImage>
30
30
  </template>
31
31
 
32
32
  <script setup>
@@ -7,6 +7,7 @@ type __VLS_Props = {
7
7
  };
8
8
  type __VLS_Slots = {
9
9
  loading: () => any;
10
+ default: () => any;
10
11
  };
11
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
12
13
  loading: boolean;
@@ -7,6 +7,7 @@ type __VLS_Props = {
7
7
  };
8
8
  type __VLS_Slots = {
9
9
  loading: () => any;
10
+ default: () => any;
10
11
  };
11
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
12
13
  loading: boolean;
@@ -7,7 +7,21 @@ type __VLS_Props = {
7
7
  target?: string | ((row: any) => string | undefined);
8
8
  preserveQuery?: boolean;
9
9
  };
10
- declare var __VLS_21: {}, __VLS_28: {}, __VLS_30: {}, __VLS_44: `${string}-cell`, __VLS_45: any, __VLS_64: string, __VLS_65: any;
10
+ declare var __VLS_21: {}, __VLS_28: {}, __VLS_30: {}, __VLS_44: `${string}-cell`, __VLS_45: {
11
+ cell: import("@tanstack/table-core").Cell<any, unknown>;
12
+ column: import("@tanstack/table-core").Column<any, unknown>;
13
+ getValue: import("@tanstack/table-core").Getter<unknown>;
14
+ renderValue: import("@tanstack/table-core").Getter<unknown>;
15
+ row: import("@tanstack/table-core").Row<any>;
16
+ table: import("@tanstack/table-core").Table<any>;
17
+ }, __VLS_64: string, __VLS_65: {
18
+ cell: import("@tanstack/table-core").Cell<any, unknown>;
19
+ column: import("@tanstack/table-core").Column<any, unknown>;
20
+ getValue: import("@tanstack/table-core").Getter<unknown>;
21
+ renderValue: import("@tanstack/table-core").Getter<unknown>;
22
+ row: import("@tanstack/table-core").Row<any>;
23
+ table: import("@tanstack/table-core").Table<any>;
24
+ };
11
25
  type __VLS_Slots = {} & {
12
26
  [K in NonNullable<typeof __VLS_44>]?: (props: typeof __VLS_45) => any;
13
27
  } & {