@solidxai/core-ui 0.1.13-beta.1 → 0.1.13-beta.3
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/SolidFieldTooltip.d.ts.map +1 -1
- package/dist/components/common/SolidFieldTooltip.js +33 -1
- package/dist/components/common/SolidFieldTooltip.js.map +1 -1
- package/dist/components/common/SolidFieldTooltip.tsx +64 -8
- package/dist/components/core/chatter/SolidChatter.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatter.js +4 -2
- package/dist/components/core/chatter/SolidChatter.js.map +1 -1
- package/dist/components/core/chatter/SolidChatter.tsx +4 -1
- package/dist/components/core/chatter/SolidChatterMentionMenu.d.ts +9 -0
- package/dist/components/core/chatter/SolidChatterMentionMenu.d.ts.map +1 -0
- package/dist/components/core/chatter/SolidChatterMentionMenu.js +18 -0
- package/dist/components/core/chatter/SolidChatterMentionMenu.js.map +1 -0
- package/dist/components/core/chatter/SolidChatterMentionMenu.tsx +45 -0
- package/dist/components/core/chatter/SolidChatterMessageBox.d.ts +1 -0
- package/dist/components/core/chatter/SolidChatterMessageBox.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatterMessageBox.js +29 -5
- package/dist/components/core/chatter/SolidChatterMessageBox.js.map +1 -1
- package/dist/components/core/chatter/SolidChatterMessageBox.tsx +57 -4
- package/dist/components/core/chatter/SolidMessageComposer.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidMessageComposer.js +33 -7
- package/dist/components/core/chatter/SolidMessageComposer.js.map +1 -1
- package/dist/components/core/chatter/SolidMessageComposer.tsx +61 -7
- package/dist/components/core/chatter/chatter.module.css +63 -0
- package/dist/components/core/chatter/chatterMentions.d.ts +17 -0
- package/dist/components/core/chatter/chatterMentions.d.ts.map +1 -0
- package/dist/components/core/chatter/chatterMentions.js +50 -0
- package/dist/components/core/chatter/chatterMentions.js.map +1 -0
- package/dist/components/core/chatter/chatterMentions.ts +59 -0
- package/dist/components/core/chatter/useChatterMentions.d.ts +26 -0
- package/dist/components/core/chatter/useChatterMentions.d.ts.map +1 -0
- package/dist/components/core/chatter/useChatterMentions.js +204 -0
- package/dist/components/core/chatter/useChatterMentions.js.map +1 -0
- package/dist/components/core/chatter/useChatterMentions.ts +160 -0
- package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.js +111 -106
- package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.tsx +165 -134
- package/dist/components/core/form/fields/SolidMediaSingleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.js +81 -84
- package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.tsx +97 -86
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +4 -0
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +6 -0
- package/dist/components/core/list/SolidListView.d.ts.map +1 -1
- package/dist/components/core/list/SolidListView.js +4 -3
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/list/SolidListView.tsx +4 -3
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.js +42 -81
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.tsx +90 -120
- package/dist/components/core/list/columns/SolidMediaSingleColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidMediaSingleColumn.js +34 -42
- package/dist/components/core/list/columns/SolidMediaSingleColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidMediaSingleColumn.tsx +51 -46
- package/dist/components/core/model/CreateModel.d.ts.map +1 -1
- package/dist/components/core/model/CreateModel.js +3 -2
- package/dist/components/core/model/CreateModel.js.map +1 -1
- package/dist/components/core/model/CreateModel.tsx +4 -1
- package/dist/components/core/model/FieldMetaData.d.ts +1 -1
- package/dist/components/core/model/FieldMetaData.d.ts.map +1 -1
- package/dist/components/core/model/FieldMetaData.js +17 -17
- package/dist/components/core/model/FieldMetaData.js.map +1 -1
- package/dist/components/core/model/FieldMetaData.tsx +10 -2
- package/dist/components/shad-cn-ui/SolidTextarea.d.ts +1 -1
- package/dist/components/shad-cn-ui/SolidTextarea.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidTextarea.js +4 -3
- package/dist/components/shad-cn-ui/SolidTextarea.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidTextarea.tsx +4 -2
- package/dist/helpers/downloadMediaFile.d.ts.map +1 -1
- package/dist/helpers/downloadMediaFile.js +10 -3
- package/dist/helpers/downloadMediaFile.js.map +1 -1
- package/dist/helpers/downloadMediaFile.tsx +13 -7
- package/dist/helpers/fileTypeIcon.d.ts +3 -2
- package/dist/helpers/fileTypeIcon.d.ts.map +1 -1
- package/dist/helpers/fileTypeIcon.js +11 -7
- package/dist/helpers/fileTypeIcon.js.map +1 -1
- package/dist/helpers/fileTypeIcon.tsx +12 -7
- package/dist/helpers/mediaType.d.ts +7 -0
- package/dist/helpers/mediaType.d.ts.map +1 -1
- package/dist/helpers/mediaType.js +39 -8
- package/dist/helpers/mediaType.js.map +1 -1
- package/dist/helpers/mediaType.ts +46 -7
- package/dist/helpers/mediaUrl.d.ts +2 -0
- package/dist/helpers/mediaUrl.d.ts.map +1 -0
- package/dist/helpers/mediaUrl.js +10 -0
- package/dist/helpers/mediaUrl.js.map +1 -0
- package/dist/helpers/mediaUrl.ts +11 -0
- package/dist/resources/globals.css +14 -0
- package/dist/resources/solid-tailwind-generated.css +1 -1
- package/package.json +1 -1
|
@@ -22,12 +22,15 @@ import { FileReaderExt } from "../../../../components/common/FileReaderExt";
|
|
|
22
22
|
import getAcceptedFileTypes from "../../../../helpers/getAcceptedFileTypes";
|
|
23
23
|
import { downloadMediaFile } from "../../../../helpers/downloadMediaFile";
|
|
24
24
|
import { getExtensionComponent } from "../../../../helpers/registry";
|
|
25
|
+
import { openMediaInNewTab } from "../../../../helpers/mediaUrl";
|
|
26
|
+
import { getMediaPreviewKind, isLightboxMediaKind } from "../../../../helpers/mediaType";
|
|
25
27
|
import { SolidFormFieldWidgetProps, SolidMediaFormFieldWidgetProps } from "../../../../types/solid-core";
|
|
26
28
|
import { SolidFieldTooltip } from "../../../../components/common/SolidFieldTooltip";
|
|
27
29
|
import { ERROR_MESSAGES } from "../../../../constants/error-messages";
|
|
28
30
|
import styles from "./solidFields.module.css";
|
|
29
31
|
import { SolidIcon } from "../../../shad-cn-ui";
|
|
30
32
|
import { buildMediaFieldKey, getPersistedMediaId } from "./mediaFieldUtils";
|
|
33
|
+
|
|
31
34
|
export class SolidMediaMultipleField implements ISolidField {
|
|
32
35
|
|
|
33
36
|
private fieldContext: SolidFieldProps;
|
|
@@ -190,41 +193,47 @@ export const DefaultMediaMultipleFormEditWidget = ({ formik, fieldContext, setLi
|
|
|
190
193
|
const [deleteMedia] = useDeleteMediaMutation();
|
|
191
194
|
useEffect(() => {
|
|
192
195
|
const fieldValue = formik?.values[fieldLayoutInfo.attrs.name];
|
|
193
|
-
|
|
196
|
+
if (!Array.isArray(fieldValue) || fieldValue.length === 0) {
|
|
197
|
+
setFileDetails([]);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
194
200
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
const objectUrls: string[] = [];
|
|
202
|
+
const details = fieldValue
|
|
203
|
+
.map((file: File | any): MediaFileDetail | null => {
|
|
198
204
|
if (file instanceof File) {
|
|
199
205
|
const fileUrl = URL.createObjectURL(file);
|
|
200
206
|
objectUrls.push(fileUrl);
|
|
201
|
-
|
|
202
|
-
details.push({
|
|
207
|
+
return {
|
|
203
208
|
name: file.name,
|
|
204
209
|
type: file.type,
|
|
205
210
|
size: file.size,
|
|
206
211
|
mediaId: null,
|
|
207
212
|
fileKey: buildMediaFieldKey(file),
|
|
208
|
-
fileUrl
|
|
209
|
-
}
|
|
210
|
-
} else if (typeof file === "object" && file._full_url) {
|
|
211
|
-
details.push({
|
|
212
|
-
name: file.originalFileName,
|
|
213
|
-
type: file.mimeType,
|
|
214
|
-
size: file.fileSize,
|
|
215
|
-
mediaId: getPersistedMediaId(file),
|
|
216
|
-
fileKey: buildMediaFieldKey(file),
|
|
217
|
-
fileUrl: file._full_url
|
|
218
|
-
});
|
|
213
|
+
fileUrl,
|
|
214
|
+
};
|
|
219
215
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
216
|
+
|
|
217
|
+
const fileUrl = file?._full_url;
|
|
218
|
+
if (!fileUrl) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
name: file.originalFileName,
|
|
224
|
+
type: file.mimeType,
|
|
225
|
+
size: file.fileSize,
|
|
226
|
+
mediaId: getPersistedMediaId(file),
|
|
227
|
+
fileKey: buildMediaFieldKey(file),
|
|
228
|
+
fileUrl,
|
|
229
|
+
};
|
|
230
|
+
})
|
|
231
|
+
.filter((detail): detail is MediaFileDetail => detail !== null);
|
|
232
|
+
|
|
233
|
+
setFileDetails(details);
|
|
225
234
|
|
|
226
235
|
return () => {
|
|
227
|
-
objectUrls.forEach((
|
|
236
|
+
objectUrls.forEach((fileUrl) => URL.revokeObjectURL(fileUrl));
|
|
228
237
|
};
|
|
229
238
|
}, [formik.values, fieldLayoutInfo.attrs.name]);
|
|
230
239
|
|
|
@@ -332,32 +341,25 @@ export const DefaultMediaMultipleFormEditWidget = ({ formik, fieldContext, setLi
|
|
|
332
341
|
}
|
|
333
342
|
|
|
334
343
|
const handleFileView = (url: any) => {
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
];
|
|
341
|
-
|
|
342
|
-
const fileUrl = url?.fileUrl || "";
|
|
343
|
-
const cleanUrl = fileUrl.split("?")[0];
|
|
344
|
-
const ext = cleanUrl.split(".").pop()?.toLowerCase();
|
|
345
|
-
|
|
346
|
-
if (ext && downloadOnlyExt.includes(ext)) {
|
|
347
|
-
const link = document.createElement('a');
|
|
348
|
-
link.href = url.fileUrl;
|
|
349
|
-
link.download = ''; // or specify a file name like 'file.pdf'
|
|
350
|
-
link.target = '_blank';
|
|
351
|
-
document.body.appendChild(link);
|
|
352
|
-
link.click();
|
|
353
|
-
document.body.removeChild(link);
|
|
344
|
+
const previewKind = getMediaPreviewKind({
|
|
345
|
+
url: url?.fileUrl,
|
|
346
|
+
fileName: url?.name,
|
|
347
|
+
mimeType: url?.type,
|
|
348
|
+
});
|
|
354
349
|
|
|
355
|
-
|
|
350
|
+
if (isLightboxMediaKind(previewKind)) {
|
|
356
351
|
setLightboxUrls?.([
|
|
357
|
-
{
|
|
352
|
+
{
|
|
353
|
+
src: url.fileUrl,
|
|
354
|
+
downloadUrl: url.fileUrl,
|
|
355
|
+
type: previewKind === "video" ? "video" : undefined
|
|
356
|
+
},
|
|
358
357
|
]);
|
|
359
358
|
setOpenLightbox?.(true);
|
|
359
|
+
return;
|
|
360
360
|
}
|
|
361
|
+
|
|
362
|
+
openMediaInNewTab(url?.fileUrl);
|
|
361
363
|
}
|
|
362
364
|
|
|
363
365
|
|
|
@@ -394,34 +396,45 @@ export const DefaultMediaMultipleFormEditWidget = ({ formik, fieldContext, setLi
|
|
|
394
396
|
}
|
|
395
397
|
</div>
|
|
396
398
|
{fileDetails.length > 0 &&
|
|
397
|
-
<div className=
|
|
398
|
-
<div className=
|
|
399
|
+
<div className={`${styles.mediaAttachmentCard} mt-4`}>
|
|
400
|
+
<div className={`${styles.mediaAttachmentRow} flex items-center md:gap-2`}>
|
|
399
401
|
<FileReaderExt fileDetails={fileDetails[0]} />
|
|
400
|
-
<div className=
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
402
|
+
<div className={`${styles.mediaAttachmentMeta} w-full`}>
|
|
403
|
+
<div className="flex items-start justify-between gap-4">
|
|
404
|
+
<button
|
|
405
|
+
type="button"
|
|
406
|
+
className={styles.mediaAttachmentName}
|
|
407
|
+
onClick={() => handleFileView(fileDetails[0])}
|
|
408
|
+
title={fileDetails[0].name}
|
|
409
|
+
>
|
|
410
|
+
{fileDetails[0].name}
|
|
411
|
+
</button>
|
|
412
|
+
<div className={`${styles.mediaAttachmentActions} flex items-center gap-2`}>
|
|
404
413
|
<button
|
|
405
414
|
type="button"
|
|
406
415
|
className="solid-file-icon-btn"
|
|
407
416
|
disabled={isFieldDisabled || isFieldReadonly}
|
|
408
417
|
aria-label="Download file"
|
|
409
|
-
onClick={() =>
|
|
418
|
+
onClick={(event) => {
|
|
419
|
+
event.preventDefault();
|
|
420
|
+
event.stopPropagation();
|
|
421
|
+
downloadMediaFile(fileDetails[0]?.fileUrl, fileDetails[0]?.name);
|
|
422
|
+
}}
|
|
410
423
|
>
|
|
411
424
|
<SolidIcon name="si-download" aria-hidden />
|
|
412
425
|
</button>
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
</div>
|
|
426
|
+
<button
|
|
427
|
+
type="button"
|
|
428
|
+
className="solid-file-icon-btn is-danger"
|
|
429
|
+
disabled={isFieldDisabled || isFieldReadonly}
|
|
430
|
+
aria-label="Remove file"
|
|
431
|
+
onClick={() => confirmDeleteFile(fileDetails[0].fileKey)}
|
|
432
|
+
>
|
|
433
|
+
<SolidIcon name="si-times" aria-hidden />
|
|
434
|
+
</button>
|
|
423
435
|
</div>
|
|
424
|
-
|
|
436
|
+
</div>
|
|
437
|
+
<div className={styles.mediaAttachmentSize}>
|
|
425
438
|
{formatFileSize(fileDetails[0].size)}
|
|
426
439
|
</div>
|
|
427
440
|
</div>
|
|
@@ -456,35 +469,48 @@ export const DefaultMediaMultipleFormEditWidget = ({ formik, fieldContext, setLi
|
|
|
456
469
|
fileDetails.map((file, index) => {
|
|
457
470
|
const fileId = file.fileKey;
|
|
458
471
|
return (
|
|
459
|
-
<div key={fileId} className="
|
|
460
|
-
<div className=
|
|
461
|
-
<
|
|
462
|
-
|
|
463
|
-
<div className=
|
|
464
|
-
<
|
|
465
|
-
<div className="flex items-center gap-2">
|
|
466
|
-
<button
|
|
467
|
-
type="button"
|
|
468
|
-
className="solid-file-icon-btn"
|
|
469
|
-
disabled={isFieldDisabled || isFieldReadonly}
|
|
470
|
-
aria-label="Download file"
|
|
471
|
-
onClick={() => downloadMediaFile(file?.fileUrl, file?.name)}
|
|
472
|
-
>
|
|
473
|
-
<SolidIcon name="si-download" aria-hidden />
|
|
474
|
-
</button>
|
|
472
|
+
<div key={fileId} className={index === fileDetails.length - 1 ? "" : "mb-3"}>
|
|
473
|
+
<div className={styles.mediaAttachmentCard}>
|
|
474
|
+
<div className={`${styles.mediaAttachmentRow} flex items-center md:gap-2`}>
|
|
475
|
+
<FileReaderExt fileDetails={file} />
|
|
476
|
+
<div className={`${styles.mediaAttachmentMeta} w-full`}>
|
|
477
|
+
<div className="flex items-start justify-between gap-4">
|
|
475
478
|
<button
|
|
476
479
|
type="button"
|
|
477
|
-
className=
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
onClick={() => confirmDeleteFile(fileId)}
|
|
480
|
+
className={styles.mediaAttachmentName}
|
|
481
|
+
onClick={() => handleFileView(file)}
|
|
482
|
+
title={file.name}
|
|
481
483
|
>
|
|
482
|
-
|
|
484
|
+
{file.name}
|
|
483
485
|
</button>
|
|
486
|
+
<div className={`${styles.mediaAttachmentActions} flex items-center gap-2`}>
|
|
487
|
+
<button
|
|
488
|
+
type="button"
|
|
489
|
+
className="solid-file-icon-btn"
|
|
490
|
+
disabled={isFieldDisabled || isFieldReadonly}
|
|
491
|
+
aria-label="Download file"
|
|
492
|
+
onClick={(event) => {
|
|
493
|
+
event.preventDefault();
|
|
494
|
+
event.stopPropagation();
|
|
495
|
+
downloadMediaFile(file?.fileUrl, file?.name);
|
|
496
|
+
}}
|
|
497
|
+
>
|
|
498
|
+
<SolidIcon name="si-download" aria-hidden />
|
|
499
|
+
</button>
|
|
500
|
+
<button
|
|
501
|
+
type="button"
|
|
502
|
+
className="solid-file-icon-btn is-danger"
|
|
503
|
+
disabled={isFieldDisabled || isFieldReadonly}
|
|
504
|
+
aria-label="Remove file"
|
|
505
|
+
onClick={() => confirmDeleteFile(fileId)}
|
|
506
|
+
>
|
|
507
|
+
<SolidIcon name="si-times" aria-hidden />
|
|
508
|
+
</button>
|
|
509
|
+
</div>
|
|
510
|
+
</div>
|
|
511
|
+
<div className={styles.mediaAttachmentSize}>
|
|
512
|
+
{formatFileSize(file.size)}
|
|
484
513
|
</div>
|
|
485
|
-
</div>
|
|
486
|
-
<div className="flex items-center gap-2 text-sm">
|
|
487
|
-
{formatFileSize(file.size)}
|
|
488
514
|
</div>
|
|
489
515
|
</div>
|
|
490
516
|
</div>
|
|
@@ -521,7 +547,7 @@ export const DefaultMediaMultipleFormEditWidget = ({ formik, fieldContext, setLi
|
|
|
521
547
|
}
|
|
522
548
|
|
|
523
549
|
export const DefaultMediaMultipleFormViewWidget = ({ formik, fieldContext, setLightboxUrls, setOpenLightbox }: SolidMediaFormFieldWidgetProps) => {
|
|
524
|
-
const [fileDetails, setFileDetails] = useState<{ name: string; type: string; size: number
|
|
550
|
+
const [fileDetails, setFileDetails] = useState<{ name: string; type: string; size: number; id: number | string; fileUrl: string }[]>([]);
|
|
525
551
|
const [isShowAllFiles, setShowAllFiles] = useState(false);
|
|
526
552
|
const fieldMetadata = fieldContext.fieldMetadata;
|
|
527
553
|
const fieldLayoutInfo = fieldContext.field;
|
|
@@ -539,70 +565,71 @@ export const DefaultMediaMultipleFormViewWidget = ({ formik, fieldContext, setLi
|
|
|
539
565
|
|
|
540
566
|
useEffect(() => {
|
|
541
567
|
const fieldValue = formik?.values[fieldLayoutInfo.attrs.name];
|
|
568
|
+
if (!Array.isArray(fieldValue) || fieldValue.length === 0) {
|
|
569
|
+
setFileDetails([]);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
542
572
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const objectUrls: string[] = [];
|
|
547
|
-
fieldValue.forEach((file: File | any) => {
|
|
573
|
+
const objectUrls: string[] = [];
|
|
574
|
+
const details = fieldValue
|
|
575
|
+
.map((file: File | any) => {
|
|
548
576
|
if (file instanceof File) {
|
|
549
|
-
// New file (from local upload)
|
|
550
577
|
const fileUrl = URL.createObjectURL(file);
|
|
551
|
-
objectUrls.push(fileUrl);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
details.push({
|
|
578
|
+
objectUrls.push(fileUrl);
|
|
579
|
+
return {
|
|
555
580
|
name: file.name,
|
|
556
581
|
type: file.type,
|
|
557
582
|
size: file.size,
|
|
558
583
|
id: `${file.name}-${file.size}`,
|
|
559
|
-
fileUrl
|
|
560
|
-
}
|
|
561
|
-
} else if (typeof file === "object" && file._full_url) {
|
|
562
|
-
urls.push(file._full_url);
|
|
563
|
-
details.push({
|
|
564
|
-
name: file.originalFileName,
|
|
565
|
-
type: file.mimeType,
|
|
566
|
-
size: file.fileSize,
|
|
567
|
-
id: file.id,
|
|
568
|
-
fileUrl: file._full_url
|
|
569
|
-
});
|
|
584
|
+
fileUrl,
|
|
585
|
+
};
|
|
570
586
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
587
|
+
|
|
588
|
+
const fileUrl = file?._full_url;
|
|
589
|
+
if (!fileUrl) {
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return {
|
|
594
|
+
name: file.originalFileName,
|
|
595
|
+
type: file.mimeType,
|
|
596
|
+
size: file.fileSize,
|
|
597
|
+
id: file.id,
|
|
598
|
+
fileUrl,
|
|
599
|
+
};
|
|
600
|
+
})
|
|
601
|
+
.filter(Boolean) as { name: string; type: string; size: number; id: number | string; fileUrl: string }[];
|
|
602
|
+
|
|
603
|
+
setFileDetails(details);
|
|
604
|
+
|
|
605
|
+
return () => {
|
|
606
|
+
objectUrls.forEach((fileUrl) => URL.revokeObjectURL(fileUrl));
|
|
607
|
+
};
|
|
574
608
|
}, [formik.values, fieldLayoutInfo.attrs.name]);
|
|
575
609
|
|
|
576
610
|
const handleFileView = (url: any) => {
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
];
|
|
583
|
-
|
|
584
|
-
const fileUrl = url?.fileUrl || "";
|
|
585
|
-
const cleanUrl = fileUrl.split("?")[0];
|
|
586
|
-
const ext = cleanUrl.split(".").pop()?.toLowerCase();
|
|
587
|
-
|
|
588
|
-
if (ext && downloadOnlyExt.includes(ext)) {
|
|
589
|
-
const link = document.createElement('a');
|
|
590
|
-
link.href = url.fileUrl;
|
|
591
|
-
link.download = ''; // or specify a file name like 'file.pdf'
|
|
592
|
-
link.target = '_blank';
|
|
593
|
-
document.body.appendChild(link);
|
|
594
|
-
link.click();
|
|
595
|
-
document.body.removeChild(link);
|
|
611
|
+
const previewKind = getMediaPreviewKind({
|
|
612
|
+
url: url?.fileUrl,
|
|
613
|
+
fileName: url?.name,
|
|
614
|
+
mimeType: url?.type,
|
|
615
|
+
});
|
|
596
616
|
|
|
597
|
-
|
|
617
|
+
if (isLightboxMediaKind(previewKind)) {
|
|
598
618
|
setLightboxUrls?.([
|
|
599
|
-
{
|
|
619
|
+
{
|
|
620
|
+
src: url.fileUrl,
|
|
621
|
+
downloadUrl: url.fileUrl,
|
|
622
|
+
type: previewKind === "video" ? "video" : undefined
|
|
623
|
+
},
|
|
600
624
|
]);
|
|
601
625
|
setOpenLightbox?.(true);
|
|
626
|
+
return;
|
|
602
627
|
}
|
|
628
|
+
|
|
629
|
+
openMediaInNewTab(url?.fileUrl);
|
|
603
630
|
}
|
|
604
631
|
|
|
605
|
-
const renderMediaFileCard = (file: { name: string; type: string; size: number; id: number; fileUrl: string }, className = "") => (
|
|
632
|
+
const renderMediaFileCard = (file: { name: string; type: string; size: number; id: number | string; fileUrl: string }, className = "") => (
|
|
606
633
|
<div className={`${styles.mediaAttachmentCard} ${className}`.trim()}>
|
|
607
634
|
<div className={`${styles.mediaAttachmentRow} flex items-center md:gap-2`}>
|
|
608
635
|
<FileReaderExt fileDetails={file} />
|
|
@@ -621,7 +648,11 @@ export const DefaultMediaMultipleFormViewWidget = ({ formik, fieldContext, setLi
|
|
|
621
648
|
type="button"
|
|
622
649
|
className="solid-file-icon-btn"
|
|
623
650
|
aria-label="Download file"
|
|
624
|
-
onClick={() =>
|
|
651
|
+
onClick={(event) => {
|
|
652
|
+
event.preventDefault();
|
|
653
|
+
event.stopPropagation();
|
|
654
|
+
downloadMediaFile(file?.fileUrl, file?.name);
|
|
655
|
+
}}
|
|
625
656
|
>
|
|
626
657
|
<SolidIcon name="si-download" aria-hidden />
|
|
627
658
|
</button>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolidMediaSingleField.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/form/fields/SolidMediaSingleField.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"SolidMediaSingleField.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/form/fields/SolidMediaSingleField.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAO3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAc9E,qBAAa,qBAAsB,YAAW,WAAW;IAErD,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,eAAe,CAAC,CAAyD;IACjF,OAAO,CAAC,eAAe,CAAC,CAA0B;gBACtC,YAAY,EAAE,eAAe,EAAE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,IAAI,EAC/G,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI;IAM7C,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG;IAOnD,YAAY,IAAI,GAAG;IAKnB,gBAAgB,IAAI,GAAG,CAAC,MAAM;IAyC9B,MAAM,CAAC,MAAM,EAAE,YAAY;IAoC3B,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY;CAcjE;AAMD,eAAO,MAAM,gCAAgC,+DAAgE,8BAA8B,4CA6U1I,CAAA;AAED,eAAO,MAAM,gCAAgC,+DAAgE,8BAA8B,4CAsH1I,CAAA"}
|