@solidstarters/solid-core-ui 1.1.25 → 1.1.27
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/components/common/SolidBreadcrumb.d.ts +1 -2
- package/dist/components/common/SolidBreadcrumb.d.ts.map +1 -1
- package/dist/components/common/SolidBreadcrumb.js +14 -9
- package/dist/components/common/SolidBreadcrumb.js.map +1 -1
- package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormView.js +65 -38
- package/dist/components/core/form/SolidFormView.js.map +1 -1
- package/dist/components/core/form/fields/SolidBooleanField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidBooleanField.js +2 -2
- package/dist/components/core/form/fields/SolidBooleanField.js.map +1 -1
- package/dist/components/core/form/fields/SolidDateField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDateField.js +2 -2
- package/dist/components/core/form/fields/SolidDateField.js.map +1 -1
- package/dist/components/core/form/fields/SolidDateTimeField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDateTimeField.js +2 -2
- package/dist/components/core/form/fields/SolidDateTimeField.js.map +1 -1
- package/dist/components/core/form/fields/SolidDecimalField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidDecimalField.js +2 -2
- package/dist/components/core/form/fields/SolidDecimalField.js.map +1 -1
- package/dist/components/core/form/fields/SolidIntegerField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidIntegerField.js +2 -2
- package/dist/components/core/form/fields/SolidIntegerField.js.map +1 -1
- package/dist/components/core/form/fields/SolidJsonField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidJsonField.js +1 -1
- package/dist/components/core/form/fields/SolidJsonField.js.map +1 -1
- package/dist/components/core/form/fields/SolidLongTextField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidLongTextField.js +1 -1
- package/dist/components/core/form/fields/SolidLongTextField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.js +27 -96
- package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.js +29 -29
- package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidRichTextField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidRichTextField.js +1 -1
- package/dist/components/core/form/fields/SolidRichTextField.js.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionDynamicField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionDynamicField.js +2 -2
- package/dist/components/core/form/fields/SolidSelectionDynamicField.js.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionStaticField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidSelectionStaticField.js +2 -2
- package/dist/components/core/form/fields/SolidSelectionStaticField.js.map +1 -1
- package/dist/components/core/form/fields/SolidShortTextField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidShortTextField.js +3 -3
- package/dist/components/core/form/fields/SolidShortTextField.js.map +1 -1
- package/dist/components/core/form/fields/SolidTimeField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidTimeField.js +2 -2
- package/dist/components/core/form/fields/SolidTimeField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +5 -5
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +3 -3
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
- package/dist/components/core/list/SolidListView.js +1 -1
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/list/SolidTableRowCell.d.ts +6 -0
- package/dist/components/core/list/SolidTableRowCell.d.ts.map +1 -0
- package/dist/components/core/list/SolidTableRowCell.js +7 -0
- package/dist/components/core/list/SolidTableRowCell.js.map +1 -0
- package/dist/components/core/list/columns/SolidDateColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidDateColumn.js +7 -3
- package/dist/components/core/list/columns/SolidDateColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidDatetimeColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidDatetimeColumn.js +7 -3
- package/dist/components/core/list/columns/SolidDatetimeColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidExternalIdColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidExternalIdColumn.js +7 -3
- package/dist/components/core/list/columns/SolidExternalIdColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidIdColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidIdColumn.js +7 -3
- package/dist/components/core/list/columns/SolidIdColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidIntColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidIntColumn.js +7 -3
- package/dist/components/core/list/columns/SolidIntColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionDynamicColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionDynamicColumn.js +7 -3
- package/dist/components/core/list/columns/SolidSelectionDynamicColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.js +7 -3
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidShortTextColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidShortTextColumn.js +7 -5
- package/dist/components/core/list/columns/SolidShortTextColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidTimeColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidTimeColumn.js +7 -3
- package/dist/components/core/list/columns/SolidTimeColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidUuidColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidUuidColumn.js +10 -4
- package/dist/components/core/list/columns/SolidUuidColumn.js.map +1 -1
- package/dist/components/core/model/ModelMetaData.js +5 -5
- package/dist/components/core/model/ModelMetaData.js.map +1 -1
- package/dist/resources/globals.css +2 -1
- package/package.json +1 -1
- package/src/components/common/SolidBreadcrumb.tsx +18 -15
- package/src/components/core/form/SolidFormView.tsx +20 -3
- package/src/components/core/form/fields/SolidBooleanField.tsx +4 -1
- package/src/components/core/form/fields/SolidDateField.tsx +4 -1
- package/src/components/core/form/fields/SolidDateTimeField.tsx +4 -1
- package/src/components/core/form/fields/SolidDecimalField.tsx +6 -3
- package/src/components/core/form/fields/SolidIntegerField.tsx +4 -1
- package/src/components/core/form/fields/SolidJsonField.tsx +5 -3
- package/src/components/core/form/fields/SolidLongTextField.tsx +4 -1
- package/src/components/core/form/fields/SolidMediaMultipleField.tsx +33 -118
- package/src/components/core/form/fields/SolidMediaSingleField.tsx +39 -33
- package/src/components/core/form/fields/SolidRichTextField.tsx +4 -1
- package/src/components/core/form/fields/SolidSelectionDynamicField.tsx +4 -1
- package/src/components/core/form/fields/SolidSelectionStaticField.tsx +4 -1
- package/src/components/core/form/fields/SolidShortTextField.tsx +5 -4
- package/src/components/core/form/fields/SolidTimeField.tsx +5 -3
- package/src/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +32 -24
- package/src/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +30 -25
- package/src/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +4 -3
- package/src/components/core/list/SolidListView.tsx +1 -1
- package/src/components/core/list/SolidTableRowCell.tsx +12 -0
- package/src/components/core/list/columns/SolidDateColumn.tsx +9 -1
- package/src/components/core/list/columns/SolidDatetimeColumn.tsx +9 -1
- package/src/components/core/list/columns/SolidExternalIdColumn.tsx +10 -1
- package/src/components/core/list/columns/SolidIdColumn.tsx +10 -2
- package/src/components/core/list/columns/SolidIntColumn.tsx +9 -1
- package/src/components/core/list/columns/SolidSelectionDynamicColumn.tsx +10 -1
- package/src/components/core/list/columns/SolidSelectionStaticColumn.tsx +10 -1
- package/src/components/core/list/columns/SolidShortTextColumn.tsx +9 -4
- package/src/components/core/list/columns/SolidTimeColumn.tsx +9 -1
- package/src/components/core/list/columns/SolidUuidColumn.tsx +11 -2
- package/src/components/core/model/ModelMetaData.tsx +5 -5
- package/src/resources/globals.css +2 -1
|
@@ -101,13 +101,9 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
101
101
|
|
|
102
102
|
const [isDeleteImageDialogVisible, setDeleteImageDialogVisible] = useState(false);
|
|
103
103
|
const [imageToBeDeletedData, setImageToBeDeletedData] = useState<any>();
|
|
104
|
-
const [uploadCompleted, setUploadCompleted] = useState<Record<string, boolean>>({});
|
|
105
104
|
const [fileDetails, setFileDetails] = useState<{ name: string; type: string; size: number, id: number, fileUrl: string }[]>([]);
|
|
106
|
-
const [uploadedSize, setUploadedSize] = useState<Record<string, string>>({});
|
|
107
|
-
const [totalSize, setTotalSize] = useState<Record<string, string>>({});
|
|
108
105
|
const [selectedFileId, setSelectedFileId] = useState<string | null>(null);
|
|
109
106
|
|
|
110
|
-
|
|
111
107
|
const formatFileSize = (size: number) => {
|
|
112
108
|
return size >= 1024 * 1024
|
|
113
109
|
? `${(size / (1024 * 1024)).toFixed(1)} MB`
|
|
@@ -117,103 +113,56 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
117
113
|
deleteMedia,
|
|
118
114
|
{ isLoading: isMediaDeleted, isSuccess: isDeleteMediaSuceess, isError: isMediaDeleteError, error: mediaDeleteError, data: DeletedMedia },
|
|
119
115
|
] = useDeleteMediaMutation();
|
|
120
|
-
|
|
121
116
|
useEffect(() => {
|
|
122
117
|
const fieldValue = formik?.values[fieldLayoutInfo.attrs.name];
|
|
118
|
+
|
|
123
119
|
if (Array.isArray(fieldValue) && fieldValue.length > 0) {
|
|
124
120
|
const urls: string[] = [];
|
|
125
121
|
const details: { name: string; type: string; size: number, id: any, fileUrl: string }[] = [];
|
|
126
|
-
const
|
|
127
|
-
|
|
122
|
+
const objectUrls: string[] = [];
|
|
128
123
|
fieldValue.forEach((file: File | any) => {
|
|
129
124
|
if (file instanceof File) {
|
|
130
125
|
// New file (from local upload)
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
const fileUrl = URL.createObjectURL(file);
|
|
127
|
+
objectUrls.push(fileUrl); // Store URL for cleanup
|
|
128
|
+
urls.push(fileUrl);
|
|
129
|
+
|
|
130
|
+
details.push({
|
|
131
|
+
name: file.name,
|
|
132
|
+
type: file.type,
|
|
133
|
+
size: file.size,
|
|
134
|
+
id: `${file.name}-${file.size}`,
|
|
135
|
+
fileUrl: fileUrl // ✅ Store the generated object URL
|
|
136
|
+
});
|
|
133
137
|
} else if (typeof file === "object" && file._full_url) {
|
|
134
138
|
urls.push(file._full_url);
|
|
135
139
|
details.push({
|
|
136
|
-
name: file.
|
|
137
|
-
type: file.
|
|
138
|
-
size:
|
|
140
|
+
name: file.originalFileName,
|
|
141
|
+
type: file.mimeType,
|
|
142
|
+
size: file.fileSize,
|
|
139
143
|
id: file.id,
|
|
140
144
|
fileUrl: file._full_url
|
|
141
145
|
});
|
|
142
146
|
}
|
|
143
147
|
});
|
|
144
|
-
details.forEach(file => {
|
|
145
|
-
completed[`${file.name}-${file.size}`] = true;
|
|
146
|
-
});
|
|
147
|
-
setUploadCompleted(completed);
|
|
148
148
|
setFileDetails(details);
|
|
149
149
|
}
|
|
150
150
|
}, [formik.values, fieldLayoutInfo.attrs.name]);
|
|
151
151
|
|
|
152
152
|
const handleDropImages = (acceptedFiles: any[]) => {
|
|
153
153
|
if (!acceptedFiles.length) return;
|
|
154
|
-
|
|
155
154
|
const newFileDetails = [...fileDetails];
|
|
156
|
-
const newUploadedSize = { ...uploadedSize };
|
|
157
|
-
const newTotalSize = { ...totalSize };
|
|
158
|
-
const newUploadCompleted = { ...uploadCompleted };
|
|
159
|
-
|
|
160
155
|
acceptedFiles.forEach((file) => {
|
|
161
|
-
const fileId = `${file.name}-${file.size}`; // Unique identifier for tracking each file
|
|
162
|
-
|
|
163
156
|
newFileDetails.push({ name: file.name, type: file.type, size: file.size, id: file.id, fileUrl: file._full_url });
|
|
164
|
-
newUploadedSize[fileId] = "0 KB";
|
|
165
|
-
newTotalSize[fileId] = formatFileSize(file.size);
|
|
166
|
-
newUploadCompleted[fileId] = false;
|
|
167
|
-
|
|
168
157
|
const reader = new FileReader();
|
|
169
|
-
|
|
170
|
-
reader.onloadstart = () => {
|
|
171
|
-
setUploadedSize((prev) => ({ ...prev, [fileId]: "0 KB" }));
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
reader.onprogress = (event) => {
|
|
175
|
-
if (event.loaded && event.total) {
|
|
176
|
-
setUploadedSize((prev) => ({ ...prev, [fileId]: formatFileSize(event.loaded) }));
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
reader.onloadend = () => {
|
|
181
|
-
setUploadCompleted((prev) => ({ ...prev, [fileId]: true }));
|
|
182
|
-
setUploadedSize((prev) => ({ ...prev, [fileId]: newTotalSize[fileId] }));
|
|
183
|
-
};
|
|
184
|
-
|
|
185
158
|
reader.readAsDataURL(file);
|
|
186
159
|
});
|
|
187
160
|
|
|
188
161
|
setFileDetails(newFileDetails);
|
|
189
|
-
setUploadedSize(newUploadedSize);
|
|
190
|
-
setTotalSize(newTotalSize);
|
|
191
|
-
setUploadCompleted(newUploadCompleted);
|
|
192
162
|
|
|
193
163
|
formik.setFieldValue(fieldLayoutInfo.attrs.name, acceptedFiles);
|
|
194
164
|
};
|
|
195
165
|
|
|
196
|
-
|
|
197
|
-
const handleCancelUpload = (fileId: string) => {
|
|
198
|
-
setFileDetails((prev) => prev.filter((file) => fileId !== `${file.name}-${file.size}`));
|
|
199
|
-
setUploadCompleted((prev) => {
|
|
200
|
-
const newCompleted = { ...prev };
|
|
201
|
-
delete newCompleted[fileId];
|
|
202
|
-
return newCompleted;
|
|
203
|
-
});
|
|
204
|
-
setUploadedSize((prev) => {
|
|
205
|
-
const newSize = { ...prev };
|
|
206
|
-
delete newSize[fileId];
|
|
207
|
-
return newSize;
|
|
208
|
-
});
|
|
209
|
-
setTotalSize((prev) => {
|
|
210
|
-
const newSize = { ...prev };
|
|
211
|
-
delete newSize[fileId];
|
|
212
|
-
return newSize;
|
|
213
|
-
});
|
|
214
|
-
formik.setFieldValue(fieldLayoutInfo.attrs.name, fileDetails.filter((file) => `${file.name}-${file.size}` !== fileId));
|
|
215
|
-
};
|
|
216
|
-
|
|
217
166
|
const confirmDeleteFile = (fileId: any, deleteId: number) => {
|
|
218
167
|
setSelectedFileId(fileId);
|
|
219
168
|
setDeleteImageDialogVisible(true);
|
|
@@ -228,25 +177,6 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
228
177
|
deleteMedia(imageToBeDeletedData)
|
|
229
178
|
.unwrap()
|
|
230
179
|
.then(() => {
|
|
231
|
-
// Ensure UI state updates only after successful deletion
|
|
232
|
-
setUploadCompleted((prev) => {
|
|
233
|
-
const newCompleted = { ...prev };
|
|
234
|
-
delete newCompleted[selectedFileId];
|
|
235
|
-
return newCompleted;
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
setUploadedSize((prev) => {
|
|
239
|
-
const newSize = { ...prev };
|
|
240
|
-
delete newSize[selectedFileId];
|
|
241
|
-
return newSize;
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
setTotalSize((prev) => {
|
|
245
|
-
const newSize = { ...prev };
|
|
246
|
-
delete newSize[selectedFileId];
|
|
247
|
-
return newSize;
|
|
248
|
-
});
|
|
249
|
-
|
|
250
180
|
// Update form state
|
|
251
181
|
formik.setFieldValue(
|
|
252
182
|
fieldLayoutInfo.attrs.name,
|
|
@@ -263,7 +193,6 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
263
193
|
}
|
|
264
194
|
};
|
|
265
195
|
|
|
266
|
-
|
|
267
196
|
const {
|
|
268
197
|
getRootProps,
|
|
269
198
|
getInputProps,
|
|
@@ -282,7 +211,7 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
282
211
|
<div className="flex flex-column gap-2 mt-4">
|
|
283
212
|
{showFieldLabel != false &&
|
|
284
213
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
285
|
-
|
|
214
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
286
215
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
287
216
|
</label>
|
|
288
217
|
}
|
|
@@ -303,7 +232,7 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
303
232
|
<FileReaderExt fileDetails={fileDetails[0]} />
|
|
304
233
|
<div className="w-full flex flex-column gap-1">
|
|
305
234
|
<div className="flex align-items-center justify-content-between">
|
|
306
|
-
<Link className="font-normal w-11" href={
|
|
235
|
+
<Link className="font-normal w-11" href={`${fileDetails[0]?.fileUrl}`} target="_blank">{fileDetails[0].name}</Link>
|
|
307
236
|
<div className="flex align-items-center gap-2">
|
|
308
237
|
<div>
|
|
309
238
|
<Button
|
|
@@ -335,28 +264,21 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
335
264
|
</div>
|
|
336
265
|
</div>
|
|
337
266
|
</div>
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
342
|
-
<path d="M9.16 12.76L13.39 8.53L12.55 7.69L9.16 11.08L7.45 9.37L6.61 10.21L9.16 12.76ZM10 16C9.17 16 8.39 15.8424 7.66 15.5272C6.93 15.2124 6.295 14.785 5.755 14.245C5.215 13.705 4.7876 13.07 4.4728 12.34C4.1576 11.61 4 10.83 4 10C4 9.17 4.1576 8.39 4.4728 7.66C4.7876 6.93 5.215 6.295 5.755 5.755C6.295 5.215 6.93 4.7874 7.66 4.4722C8.39 4.1574 9.17 4 10 4C10.83 4 11.61 4.1574 12.34 4.4722C13.07 4.7874 13.705 5.215 14.245 5.755C14.785 6.295 15.2124 6.93 15.5272 7.66C15.8424 8.39 16 9.17 16 10C16 10.83 15.8424 11.61 15.5272 12.34C15.2124 13.07 14.785 13.705 14.245 14.245C13.705 14.785 13.07 15.2124 12.34 15.5272C11.61 15.8424 10.83 16 10 16Z" fill="#722ED1" />
|
|
343
|
-
</svg>
|
|
344
|
-
Completed
|
|
345
|
-
</div>
|
|
346
|
-
)}
|
|
267
|
+
<div className="flex align-items-center gap-2 text-sm">
|
|
268
|
+
{formatFileSize(fileDetails[0].size)}
|
|
269
|
+
</div>
|
|
347
270
|
</div>
|
|
348
271
|
</div>
|
|
349
272
|
</div>
|
|
350
273
|
}
|
|
351
274
|
|
|
352
|
-
|
|
353
275
|
{fileDetails.length > 1 &&
|
|
354
|
-
<div className="flex align-items-center">
|
|
276
|
+
<div className="flex align-items-center mt-1">
|
|
355
277
|
<p className="m-0">
|
|
356
|
-
{fileDetails.length - 1} items
|
|
278
|
+
{fileDetails.length - 1} items
|
|
357
279
|
</p>
|
|
358
280
|
<div>
|
|
359
|
-
<Button type="button" text label="View" onClick={() => setShowAllFiles(true)} />
|
|
281
|
+
<Button type="button" size="small" text label="View" onClick={() => setShowAllFiles(true)} />
|
|
360
282
|
</div>
|
|
361
283
|
</div>
|
|
362
284
|
}
|
|
@@ -377,7 +299,7 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
377
299
|
<FileReaderExt fileDetails={file} />
|
|
378
300
|
<div className="w-full flex flex-column gap-1">
|
|
379
301
|
<div className="flex align-items-center justify-content-between">
|
|
380
|
-
<Link className="font-normal w-11" href={
|
|
302
|
+
<Link className="font-normal w-11" href={file?.fileUrl} target="_blank">{file.name}</Link>
|
|
381
303
|
<div className="flex align-items-center gap-2">
|
|
382
304
|
<div>
|
|
383
305
|
<Button
|
|
@@ -409,18 +331,9 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
409
331
|
</div>
|
|
410
332
|
</div>
|
|
411
333
|
</div>
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4" fill="none">
|
|
416
|
-
<circle cx="2" cy="2" r="2" fill="#C1C1C1" />
|
|
417
|
-
</svg>
|
|
418
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
419
|
-
<path d="M9.16 12.76L13.39 8.53L12.55 7.69L9.16 11.08L7.45 9.37L6.61 10.21L9.16 12.76ZM10 16C9.17 16 8.39 15.8424 7.66 15.5272C6.93 15.2124 6.295 14.785 5.755 14.245C5.215 13.705 4.7876 13.07 4.4728 12.34C4.1576 11.61 4 10.83 4 10C4 9.17 4.1576 8.39 4.4728 7.66C4.7876 6.93 5.215 6.295 5.755 5.755C6.295 5.215 6.93 4.7874 7.66 4.4722C8.39 4.1574 9.17 4 10 4C10.83 4 11.61 4.1574 12.34 4.4722C13.07 4.7874 13.705 5.215 14.245 5.755C14.785 6.295 15.2124 6.93 15.5272 7.66C15.8424 8.39 16 9.17 16 10C16 10.83 15.8424 11.61 15.5272 12.34C15.2124 13.07 14.785 13.705 14.245 14.245C13.705 14.785 13.07 15.2124 12.34 15.5272C11.61 15.8424 10.83 16 10 16Z" fill="#722ED1" />
|
|
420
|
-
</svg>
|
|
421
|
-
Completed
|
|
422
|
-
</div>
|
|
423
|
-
)}
|
|
334
|
+
<div className="flex align-items-center gap-2 text-sm">
|
|
335
|
+
{formatFileSize(file.size)}
|
|
336
|
+
</div>
|
|
424
337
|
</div>
|
|
425
338
|
</div>
|
|
426
339
|
</div>
|
|
@@ -429,7 +342,9 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
429
342
|
}
|
|
430
343
|
</Dialog>
|
|
431
344
|
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
432
|
-
<
|
|
345
|
+
<div className="absolute mt-1">
|
|
346
|
+
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
347
|
+
</div>
|
|
433
348
|
)}
|
|
434
349
|
<Dialog
|
|
435
350
|
visible={isDeleteImageDialogVisible}
|
|
@@ -437,8 +352,8 @@ export class SolidMediaMultipleField implements ISolidField {
|
|
|
437
352
|
modal
|
|
438
353
|
footer={() => (
|
|
439
354
|
<div className="flex justify-content-center">
|
|
440
|
-
<Button label="Yes" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={deleteFile} />
|
|
441
|
-
<Button label="No" icon="pi pi-times" className='small-button' onClick={() => setDeleteImageDialogVisible(false)} />
|
|
355
|
+
<Button type="button" label="Yes" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={deleteFile} />
|
|
356
|
+
<Button type="button" label="No" icon="pi pi-times" className='small-button' onClick={() => setDeleteImageDialogVisible(false)} />
|
|
442
357
|
</div>
|
|
443
358
|
)}
|
|
444
359
|
onHide={() => setDeleteImageDialogVisible(false)}
|
|
@@ -87,9 +87,7 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
87
87
|
|
|
88
88
|
const [isDeleteImageDialogVisible, setDeleteImageDialogVisible] = useState(false);
|
|
89
89
|
const [imageToBeDeletedData, setImageToBeDeletedData] = useState<any>();
|
|
90
|
-
const [
|
|
91
|
-
const [fileDetails, setFileDetails] = useState<{ name: string; type: string, fileUrl: string } | null>(null);
|
|
92
|
-
const [totalSize, setTotalSize] = useState<string>("0 KB");
|
|
90
|
+
const [fileDetails, setFileDetails] = useState<{ name: string; type: string, fileUrl: string, fileSize: number } | null>(null);
|
|
93
91
|
const [isReplaceImageDialogVisible, setReplaceImageDialogVisible] = useState(false);
|
|
94
92
|
const [newFileToUpload, setNewFileToUpload] = useState<any>(null);
|
|
95
93
|
|
|
@@ -110,7 +108,6 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
110
108
|
deleteMedia(imageToBeDeletedData);
|
|
111
109
|
}
|
|
112
110
|
e.stopPropagation();
|
|
113
|
-
setUploadCompleted(false);
|
|
114
111
|
setFileDetails(null);
|
|
115
112
|
formik.setFieldValue(fieldLayoutInfo.attrs.name, null);
|
|
116
113
|
setDeleteImageDialogVisible(false);
|
|
@@ -129,25 +126,24 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
129
126
|
}
|
|
130
127
|
};
|
|
131
128
|
|
|
132
|
-
const uploadFile = (file:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
const uploadFile = (file: File) => {
|
|
130
|
+
setFileDetails({
|
|
131
|
+
name: file.name,
|
|
132
|
+
type: file.type,
|
|
133
|
+
fileUrl: URL.createObjectURL(file),
|
|
134
|
+
fileSize: file.size
|
|
135
|
+
});
|
|
136
136
|
|
|
137
137
|
const reader = new FileReader();
|
|
138
|
-
reader.onloadend = () => {
|
|
139
|
-
setUploadCompleted(true);
|
|
140
|
-
};
|
|
141
138
|
reader.readAsDataURL(file);
|
|
142
139
|
formik.setFieldValue(fieldLayoutInfo.attrs.name, file);
|
|
143
140
|
};
|
|
141
|
+
|
|
144
142
|
const handleReplaceFile = () => {
|
|
145
143
|
// Delete the existing file first
|
|
146
144
|
if (imageToBeDeletedData) {
|
|
147
145
|
deleteMedia(imageToBeDeletedData);
|
|
148
146
|
}
|
|
149
|
-
|
|
150
|
-
setUploadCompleted(false);
|
|
151
147
|
setFileDetails(null);
|
|
152
148
|
formik.setFieldValue(fieldLayoutInfo.attrs.name, null);
|
|
153
149
|
|
|
@@ -159,28 +155,36 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
159
155
|
|
|
160
156
|
setReplaceImageDialogVisible(false);
|
|
161
157
|
};
|
|
158
|
+
|
|
162
159
|
useEffect(() => {
|
|
163
160
|
const fieldValue = formik?.values[fieldLayoutInfo.attrs.name];
|
|
164
161
|
|
|
165
162
|
if (fieldValue && typeof fieldValue === "object") {
|
|
166
163
|
let fileUrl = "";
|
|
167
164
|
let fileName = "Unknown File";
|
|
165
|
+
let fileSize = 0;
|
|
168
166
|
|
|
169
167
|
if (fieldValue instanceof File) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
fileUrl = URL.createObjectURL(fieldValue);
|
|
169
|
+
fileName = fieldValue.name;
|
|
170
|
+
fileSize = fieldValue.size;
|
|
173
171
|
} else if (fieldValue._full_url) {
|
|
174
|
-
// Handle updated file from backend
|
|
175
172
|
fileUrl = fieldValue._full_url;
|
|
176
|
-
fileName = fieldValue.
|
|
173
|
+
fileName = fieldValue.originalFileName;
|
|
174
|
+
fileSize = fieldValue.fileSize;
|
|
177
175
|
}
|
|
178
176
|
|
|
179
|
-
setFileDetails({
|
|
177
|
+
setFileDetails({
|
|
178
|
+
name: fileName,
|
|
179
|
+
type: fieldValue.mimeType,
|
|
180
|
+
fileUrl,
|
|
181
|
+
fileSize
|
|
182
|
+
});
|
|
180
183
|
|
|
181
|
-
// Set
|
|
182
|
-
setUploadCompleted(true);
|
|
184
|
+
// Set file ID for delete operation
|
|
183
185
|
setImageToBeDeletedData(fieldValue.id);
|
|
186
|
+
|
|
187
|
+
// Ensure formik has the correct value
|
|
184
188
|
formik.setFieldValue(fieldLayoutInfo.attrs.name, fieldValue);
|
|
185
189
|
}
|
|
186
190
|
}, [formik.values, fieldLayoutInfo.attrs.name]);
|
|
@@ -202,6 +206,7 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
202
206
|
<div className="flex flex-column gap-2 mt-4">
|
|
203
207
|
{showFieldLabel != false &&
|
|
204
208
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
209
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
205
210
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
206
211
|
</label>
|
|
207
212
|
}
|
|
@@ -216,7 +221,9 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
216
221
|
/>
|
|
217
222
|
</div>
|
|
218
223
|
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
219
|
-
<
|
|
224
|
+
<div className="absolute mt-1">
|
|
225
|
+
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
226
|
+
</div>
|
|
220
227
|
)}
|
|
221
228
|
{fileDetails && (
|
|
222
229
|
<div className="solid-file-upload-wrapper">
|
|
@@ -224,10 +231,11 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
224
231
|
<FileReaderExt fileDetails={fileDetails} />
|
|
225
232
|
<div className="w-full flex flex-column gap-1">
|
|
226
233
|
<div className="flex align-items-start justify-content-between">
|
|
227
|
-
<Link className="font-normal w-9" href={
|
|
234
|
+
<Link className="font-normal w-9 text-primary" href={fileDetails.fileUrl} target="_blank">{fileDetails.name}</Link>
|
|
228
235
|
<div className="flex align-items-center gap-2">
|
|
229
236
|
<div>
|
|
230
237
|
<Button
|
|
238
|
+
type="button"
|
|
231
239
|
text
|
|
232
240
|
icon={"pi pi-download"}
|
|
233
241
|
size="small"
|
|
@@ -242,6 +250,7 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
242
250
|
</div>
|
|
243
251
|
<div>
|
|
244
252
|
<Button
|
|
253
|
+
type="button"
|
|
245
254
|
text
|
|
246
255
|
icon={"pi pi-times"}
|
|
247
256
|
size="small"
|
|
@@ -256,12 +265,9 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
256
265
|
</div>
|
|
257
266
|
</div>
|
|
258
267
|
</div>
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
{totalSize}
|
|
263
|
-
</div>
|
|
264
|
-
}
|
|
268
|
+
<div className="flex align-items-center gap-2 text-sm">
|
|
269
|
+
{fileDetails && formatFileSize(fileDetails.fileSize)}
|
|
270
|
+
</div>
|
|
265
271
|
</div>
|
|
266
272
|
</div>
|
|
267
273
|
</div>
|
|
@@ -273,8 +279,8 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
273
279
|
modal
|
|
274
280
|
footer={() => (
|
|
275
281
|
<div className="flex justify-content-center">
|
|
276
|
-
<Button label="Yes" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={handleCancelUpload} />
|
|
277
|
-
<Button label="No" icon="pi pi-times" className='small-button' onClick={() => setDeleteImageDialogVisible(false)} />
|
|
282
|
+
<Button type="button" label="Yes" icon="pi pi-check" className='small-button' severity="danger" autoFocus onClick={handleCancelUpload} />
|
|
283
|
+
<Button type="button" label="No" icon="pi pi-times" className='small-button' onClick={() => setDeleteImageDialogVisible(false)} />
|
|
278
284
|
</div>
|
|
279
285
|
)}
|
|
280
286
|
onHide={() => setDeleteImageDialogVisible(false)}
|
|
@@ -287,8 +293,8 @@ export class SolidMediaSingleField implements ISolidField {
|
|
|
287
293
|
modal
|
|
288
294
|
footer={() => (
|
|
289
295
|
<div className="flex justify-content-center">
|
|
290
|
-
<Button label="Yes, Replace" icon="pi pi-check" className='small-button' severity="danger" onClick={handleReplaceFile} />
|
|
291
|
-
<Button label="Cancel" icon="pi pi-times" className='small-button' onClick={() => setReplaceImageDialogVisible(false)} />
|
|
296
|
+
<Button type="button" label="Yes, Replace" icon="pi pi-check" className='small-button' severity="danger" onClick={handleReplaceFile} />
|
|
297
|
+
<Button type="button" label="Cancel" icon="pi pi-times" className='small-button' onClick={() => setReplaceImageDialogVisible(false)} />
|
|
292
298
|
</div>
|
|
293
299
|
)}
|
|
294
300
|
onHide={() => setReplaceImageDialogVisible(false)}
|
|
@@ -79,6 +79,7 @@ export class SolidRichTextField implements ISolidField {
|
|
|
79
79
|
<div className="flex flex-column gap-2 mt-4">
|
|
80
80
|
{showFieldLabel != false &&
|
|
81
81
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
82
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
82
83
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
83
84
|
</label>
|
|
84
85
|
}
|
|
@@ -93,7 +94,9 @@ export class SolidRichTextField implements ISolidField {
|
|
|
93
94
|
/>
|
|
94
95
|
</div>
|
|
95
96
|
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
96
|
-
<
|
|
97
|
+
<div className="absolute mt-1">
|
|
98
|
+
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
99
|
+
</div>
|
|
97
100
|
)}
|
|
98
101
|
</div>
|
|
99
102
|
);
|
|
@@ -98,6 +98,7 @@ export class SolidSelectionDynamicField implements ISolidField {
|
|
|
98
98
|
<div className="flex flex-column gap-2 mt-4">
|
|
99
99
|
{showFieldLabel != false &&
|
|
100
100
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
101
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
101
102
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
102
103
|
</label>
|
|
103
104
|
}
|
|
@@ -117,7 +118,9 @@ export class SolidSelectionDynamicField implements ISolidField {
|
|
|
117
118
|
/>
|
|
118
119
|
</div>
|
|
119
120
|
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
120
|
-
<
|
|
121
|
+
<div className="absolute mt-1">
|
|
122
|
+
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
123
|
+
</div>
|
|
121
124
|
)}
|
|
122
125
|
</div>
|
|
123
126
|
);
|
|
@@ -103,6 +103,7 @@ export class SolidSelectionStaticField implements ISolidField {
|
|
|
103
103
|
<div className="flex flex-column gap-2 mt-4">
|
|
104
104
|
{showFieldLabel != false &&
|
|
105
105
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
106
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
106
107
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
107
108
|
</label>
|
|
108
109
|
}
|
|
@@ -124,7 +125,9 @@ export class SolidSelectionStaticField implements ISolidField {
|
|
|
124
125
|
/>
|
|
125
126
|
</div>
|
|
126
127
|
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
127
|
-
<
|
|
128
|
+
<div className="absolute mt-1">
|
|
129
|
+
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
130
|
+
</div>
|
|
128
131
|
)}
|
|
129
132
|
</div>
|
|
130
133
|
);
|
|
@@ -85,8 +85,8 @@ export class SolidShortTextField implements ISolidField {
|
|
|
85
85
|
<div className="flex flex-column gap-2 mt-4">
|
|
86
86
|
{showFieldLabel != false &&
|
|
87
87
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
88
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
88
89
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
89
|
-
{/* {fieldDescription && <span className="form_field_help_text">`(${fieldDescription})` </span>} */}
|
|
90
90
|
</label>
|
|
91
91
|
}
|
|
92
92
|
<InputText
|
|
@@ -102,16 +102,17 @@ export class SolidShortTextField implements ISolidField {
|
|
|
102
102
|
/>
|
|
103
103
|
</div>
|
|
104
104
|
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
105
|
-
<
|
|
105
|
+
<div className="absolute mt-1">
|
|
106
|
+
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
107
|
+
</div>
|
|
106
108
|
)}
|
|
107
109
|
</div>}
|
|
108
110
|
{includeWrapper === 'no' &&
|
|
109
111
|
<>
|
|
110
112
|
{showFieldLabel != false &&
|
|
111
113
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
114
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
112
115
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
113
|
-
|
|
114
|
-
{/* {fieldDescription && <span className="form_field_help_text">`(${fieldDescription})` </span>} */}
|
|
115
116
|
</label>
|
|
116
117
|
}
|
|
117
118
|
<InputText
|
|
@@ -53,7 +53,7 @@ export class SolidTimeField implements ISolidField {
|
|
|
53
53
|
const solidFormViewMetaData = this.fieldContext.solidFormViewMetaData;
|
|
54
54
|
const showFieldLabel = fieldLayoutInfo?.attrs?.showLabel;
|
|
55
55
|
const readOnlyPermission = this.fieldContext.readOnly;
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
const isFormFieldValid = (formik: any, fieldName: string) => formik.touched[fieldName] && formik.errors[fieldName];
|
|
58
58
|
|
|
59
59
|
const fieldDisabled = fieldLayoutInfo.attrs?.disabled;
|
|
@@ -64,7 +64,7 @@ export class SolidTimeField implements ISolidField {
|
|
|
64
64
|
<div className="flex flex-column gap-2 mt-4">
|
|
65
65
|
{showFieldLabel != false &&
|
|
66
66
|
<label htmlFor={fieldLayoutInfo.attrs.name} className="form-field-label">{fieldLabel}
|
|
67
|
-
|
|
67
|
+
{fieldMetadata.required && <span className="text-red-500"> *</span>}
|
|
68
68
|
{/* {fieldDescription && <span className="form_field_help">({fieldDescription}) </span>} */}
|
|
69
69
|
</label>
|
|
70
70
|
}
|
|
@@ -86,7 +86,9 @@ export class SolidTimeField implements ISolidField {
|
|
|
86
86
|
/>
|
|
87
87
|
</div>
|
|
88
88
|
{isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (
|
|
89
|
-
<
|
|
89
|
+
<div className="absolute mt-1">
|
|
90
|
+
<Message severity="error" text={formik?.errors[fieldLayoutInfo.attrs.name]?.toString()} />
|
|
91
|
+
</div>
|
|
90
92
|
)}
|
|
91
93
|
</div>
|
|
92
94
|
);
|