@appquality/unguess-design-system 3.1.103-attachments → 3.1.105-attachments

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/build/index.js CHANGED
@@ -2337,6 +2337,19 @@ const ChatContextProvider = ({ onSave, onFileUpload, onDeleteThumbnail, setMenti
2337
2337
  setEditor,
2338
2338
  thumbnails,
2339
2339
  setThumbnails,
2340
+ afterUploadCallback: (failed) => {
2341
+ setThumbnails(thumbnails.map((file) => {
2342
+ if (failed.includes(file.name)) {
2343
+ file.isLoadingMedia = false;
2344
+ //file.isError = true;
2345
+ }
2346
+ else {
2347
+ file.isLoadingMedia = false;
2348
+ //file.isError = false
2349
+ }
2350
+ return file;
2351
+ }));
2352
+ },
2340
2353
  addThumbnails: ({ files }) => {
2341
2354
  files.forEach((file) => (file.isLoadingMedia = true));
2342
2355
  setThumbnails((prev) => [...prev, ...files]);
@@ -3085,7 +3098,7 @@ const CommentBar = ({ editor, i18n, }) => {
3085
3098
  const mediaFiles = Array.from(files).map((file) => {
3086
3099
  return Object.assign(file, {
3087
3100
  isLoadingMedia: false,
3088
- internalId: uuid.v4(),
3101
+ internal_id: uuid.v4(),
3089
3102
  });
3090
3103
  });
3091
3104
  if (mediaFiles.length === 0)
@@ -3521,31 +3534,34 @@ const Col = (props) => jsxRuntime.jsx(StyledCol$1, Object.assign({}, props));
3521
3534
 
3522
3535
  const ThumbnailContainer = ({ openLightbox }) => {
3523
3536
  const { thumbnails, removeThumbnail, onDeleteThumbnail } = useChatContext();
3524
- const media = React.useMemo(() => (thumbnails.map((file) => ({
3525
- src: URL.createObjectURL(file),
3526
- internalId: file.internalId,
3527
- type: file.type,
3528
- isLoadingMedia: file.isLoadingMedia,
3529
- }))), [thumbnails]);
3530
- if (!media || media.length === 0) {
3537
+ const mediaFiles = React.useMemo(() => {
3538
+ return thumbnails.map((file) => ({
3539
+ fileName: file.name,
3540
+ fileType: file.type,
3541
+ previewUrl: URL.createObjectURL(file),
3542
+ internal_id: file.internal_id,
3543
+ isLoadingMedia: file.isLoadingMedia,
3544
+ }));
3545
+ }, [thumbnails]);
3546
+ if (!mediaFiles || mediaFiles.length === 0) {
3531
3547
  return null;
3532
3548
  }
3533
- return (jsxRuntime.jsx(Grid, { children: jsxRuntime.jsx(Row$1, Object.assign({ className: "responsive-container" }, { children: media.map((file, index) => {
3549
+ return (jsxRuntime.jsx(Grid, { children: jsxRuntime.jsx(Row$1, Object.assign({ className: "responsive-container" }, { children: mediaFiles.map((file, index) => {
3534
3550
  // Check if item is an image or a video
3535
- if (file.type.includes("image"))
3536
- return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, xl: 3, lg: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(ImageThumbnail, { src: file.src, index: index, showX: true, isLoadingMedia: file.isLoadingMedia, removeThumbnail: () => {
3551
+ if (file.fileType.includes("image"))
3552
+ return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, xl: 3, lg: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(ImageThumbnail, { src: file.previewUrl, index: index, showX: true, isLoadingMedia: file.isLoadingMedia, removeThumbnail: () => {
3537
3553
  removeThumbnail(index);
3538
- onDeleteThumbnail(file.internalId);
3554
+ onDeleteThumbnail(file.internal_id);
3539
3555
  }, clickThumbnail: () => {
3540
3556
  openLightbox(thumbnails[index], index);
3541
- } }, file.internalId) })));
3542
- if (file.type.includes("video"))
3543
- return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(VideoThumbnail, { src: file.src, index: index, showX: true, isLoadingMedia: file.isLoadingMedia, removeThumbnail: () => {
3557
+ } }, index) })));
3558
+ if (file.fileType.includes("video"))
3559
+ return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(VideoThumbnail, { src: file.previewUrl, index: index, showX: true, isLoadingMedia: file.isLoadingMedia, removeThumbnail: () => {
3544
3560
  removeThumbnail(index);
3545
- onDeleteThumbnail(file.internalId);
3561
+ onDeleteThumbnail(file.internal_id);
3546
3562
  }, clickThumbnail: () => {
3547
3563
  openLightbox(thumbnails[index], index);
3548
- } }, file.internalId) })));
3564
+ } }, index) })));
3549
3565
  return null;
3550
3566
  }) })) }));
3551
3567
  };
@@ -4796,7 +4812,7 @@ const CommentBox = (_a) => {
4796
4812
  const files = Array.from(event.dataTransfer.files).map((file) => {
4797
4813
  return Object.assign(file, {
4798
4814
  isLoadingMedia: false,
4799
- internalId: uuid.v4(),
4815
+ internal_id: uuid.v4(),
4800
4816
  });
4801
4817
  });
4802
4818
  const wrongFiles = files.filter((file) => !/^(image|video)\//.test(file.type));
@@ -4818,7 +4834,7 @@ const CommentBox = (_a) => {
4818
4834
  const files = Array.from(event.clipboardData.files).map((file) => {
4819
4835
  return Object.assign(file, {
4820
4836
  isLoadingMedia: false,
4821
- internalId: uuid.v4(),
4837
+ internal_id: uuid.v4(),
4822
4838
  });
4823
4839
  });
4824
4840
  const wrongFiles = files.filter((file) => !/^(image|video)\//.test(file.type));
@@ -4917,7 +4933,7 @@ const Comment = ({ author, message, children, date, media = [], header, }) => {
4917
4933
  ref.pause();
4918
4934
  }
4919
4935
  });
4920
- }, [videoRefs, media]);
4936
+ }, [videoRefs]);
4921
4937
  const ed = react.useEditor({
4922
4938
  extensions: ext,
4923
4939
  content: message || "",
@@ -19,7 +19,7 @@ export interface ChatEditorArgs extends Partial<EditorOptions> {
19
19
  bold?: string;
20
20
  italic?: string;
21
21
  mention?: string;
22
- attachment?: React.ReactNode;
22
+ attachment?: string | React.ReactNode;
23
23
  };
24
24
  mention?: {
25
25
  noResults?: string;
@@ -40,10 +40,8 @@ export interface EditorHeaderArgs {
40
40
  }
41
41
  export interface FileItem extends File {
42
42
  isLoadingMedia: boolean;
43
- internalId: string;
44
- type: string;
45
43
  isError?: boolean;
46
- src?: string;
44
+ internal_id: string;
47
45
  }
48
46
  export interface FloatingMenuArgs extends Partial<BubbleMenuProps> {
49
47
  }
@@ -13,6 +13,7 @@ export type ChatContextType = {
13
13
  mentionableUsers: (props: {
14
14
  query: string;
15
15
  }) => SuggestedUser[];
16
+ afterUploadCallback: (failed: string[]) => void;
16
17
  clearInput: () => void;
17
18
  onDeleteThumbnail: (id: string) => void;
18
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "3.1.103-attachments",
3
+ "version": "3.1.105-attachments",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",