stream-chat-react 10.6.0 → 10.7.0
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/browser.full-bundle.js +82 -62
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +5 -5
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Attachment/Attachment.d.ts +4 -1
- package/dist/components/Attachment/Attachment.d.ts.map +1 -1
- package/dist/components/Attachment/Attachment.js +20 -18
- package/dist/components/Attachment/AttachmentContainer.d.ts +1 -0
- package/dist/components/Attachment/AttachmentContainer.d.ts.map +1 -1
- package/dist/components/Attachment/AttachmentContainer.js +6 -0
- package/dist/components/Attachment/UnsupportedAttachment.d.ts +8 -0
- package/dist/components/Attachment/UnsupportedAttachment.d.ts.map +1 -0
- package/dist/components/Attachment/UnsupportedAttachment.js +12 -0
- package/dist/components/Attachment/index.d.ts +1 -0
- package/dist/components/Attachment/index.d.ts.map +1 -1
- package/dist/components/Attachment/index.js +1 -0
- package/dist/components/Gallery/Gallery.d.ts.map +1 -1
- package/dist/components/Gallery/Gallery.js +2 -1
- package/dist/components/MessageList/hooks/useMessageListElements.d.ts.map +1 -1
- package/dist/components/MessageList/hooks/useMessageListElements.js +1 -4
- package/dist/index.cjs.js +43 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -6,9 +6,10 @@ import type { AudioProps } from './Audio';
|
|
|
6
6
|
import type { CardProps } from './Card';
|
|
7
7
|
import type { FileAttachmentProps } from './FileAttachment';
|
|
8
8
|
import type { GalleryProps, ImageProps } from '../Gallery';
|
|
9
|
+
import type { UnsupportedAttachmentProps } from './UnsupportedAttachment';
|
|
9
10
|
import type { ActionHandlerReturnType } from '../Message/hooks/useActionHandler';
|
|
10
11
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
11
|
-
export declare const ATTACHMENT_GROUPS_ORDER: readonly ["card", "gallery", "image", "media", "audio", "file"];
|
|
12
|
+
export declare const ATTACHMENT_GROUPS_ORDER: readonly ["card", "gallery", "image", "media", "audio", "file", "unsupported"];
|
|
12
13
|
export declare type AttachmentProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
|
|
13
14
|
/** The message attachments to render, see [attachment structure](https://getstream.io/chat/docs/javascript/message_format/?language=javascript) **/
|
|
14
15
|
attachments: StreamAttachment<StreamChatGenerics>[];
|
|
@@ -28,6 +29,8 @@ export declare type AttachmentProps<StreamChatGenerics extends DefaultStreamChat
|
|
|
28
29
|
Image?: React.ComponentType<ImageProps>;
|
|
29
30
|
/** Custom UI component for displaying a media type attachment, defaults to `ReactPlayer` from 'react-player' */
|
|
30
31
|
Media?: React.ComponentType<ReactPlayerProps>;
|
|
32
|
+
/** Custom UI component for displaying unsupported attachment types, defaults to NullComponent */
|
|
33
|
+
UnsupportedAttachment?: React.ComponentType<UnsupportedAttachmentProps>;
|
|
31
34
|
};
|
|
32
35
|
/**
|
|
33
36
|
* A component used for rendering message attachments. By default, the component supports: AttachmentActions, Audio, Card, File, Gallery, Image, and Video
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Attachment.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/Attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Attachment.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/Attachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAqBlE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAUnE,eAAO,MAAM,uBAAuB,gFAQ1B,CAAC;AAEX,oBAAY,eAAe,CACzB,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,oJAAoJ;IACpJ,WAAW,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACpD,wJAAwJ;IACxJ,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,oOAAoO;IACpO,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpF,kNAAkN;IAClN,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC5D,8MAA8M;IAC9M,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACtC,wNAAwN;IACxN,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpE,8NAA8N;IAC9N,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAChE,+MAA+M;IAC/M,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACxC,gHAAgH;IAChH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC9C,iGAAiG;IACjG,qBAAqB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,0BAA0B,CAAC,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,+IAiBtB,CAAC"}
|
|
@@ -30,14 +30,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
30
30
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
31
|
};
|
|
32
32
|
import React, { useMemo } from 'react';
|
|
33
|
-
import { sanitizeUrl } from '@braintree/sanitize-url';
|
|
34
33
|
import { isAudioAttachment, isFileAttachment, isMediaAttachment, isScrapedContent, isUploadedImage, } from './utils';
|
|
35
|
-
import { AudioContainer, CardContainer, FileContainer, GalleryContainer, ImageContainer, MediaContainer, } from './AttachmentContainer';
|
|
34
|
+
import { AudioContainer, CardContainer, FileContainer, GalleryContainer, ImageContainer, MediaContainer, UnsupportedAttachmentContainer, } from './AttachmentContainer';
|
|
36
35
|
var CONTAINER_MAP = {
|
|
37
36
|
audio: AudioContainer,
|
|
38
37
|
card: CardContainer,
|
|
39
38
|
file: FileContainer,
|
|
40
39
|
media: MediaContainer,
|
|
40
|
+
unsupported: UnsupportedAttachmentContainer,
|
|
41
41
|
};
|
|
42
42
|
export var ATTACHMENT_GROUPS_ORDER = [
|
|
43
43
|
'card',
|
|
@@ -46,6 +46,7 @@ export var ATTACHMENT_GROUPS_ORDER = [
|
|
|
46
46
|
'media',
|
|
47
47
|
'audio',
|
|
48
48
|
'file',
|
|
49
|
+
'unsupported',
|
|
49
50
|
];
|
|
50
51
|
/**
|
|
51
52
|
* A component used for rendering message attachments. By default, the component supports: AttachmentActions, Audio, Card, File, Gallery, Image, and Video
|
|
@@ -57,26 +58,27 @@ export var Attachment = function (props) {
|
|
|
57
58
|
};
|
|
58
59
|
var renderGroupedAttachments = function (_a) {
|
|
59
60
|
var attachments = _a.attachments, rest = __rest(_a, ["attachments"]);
|
|
60
|
-
var uploadedImages =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return acc;
|
|
61
|
+
var uploadedImages = attachments.filter(function (attachment) {
|
|
62
|
+
return isUploadedImage(attachment);
|
|
63
|
+
});
|
|
64
|
+
var containers = attachments
|
|
65
|
+
.filter(function (attachment) { return !isUploadedImage(attachment); })
|
|
66
|
+
.reduce(function (typeMap, attachment) {
|
|
67
|
+
var attachmentType = getAttachmentType(attachment);
|
|
68
|
+
var Container = CONTAINER_MAP[attachmentType];
|
|
69
|
+
typeMap[attachmentType].push(React.createElement(Container, __assign({ key: "".concat(attachmentType, "-").concat(typeMap[attachmentType].length) }, rest, { attachment: attachment })));
|
|
70
|
+
return typeMap;
|
|
73
71
|
}, {
|
|
74
72
|
audio: [],
|
|
75
73
|
card: [],
|
|
76
74
|
file: [],
|
|
77
|
-
gallery: [],
|
|
78
|
-
image: [],
|
|
79
75
|
media: [],
|
|
76
|
+
unsupported: [],
|
|
77
|
+
// not used in reduce
|
|
78
|
+
// eslint-disable-next-line sort-keys
|
|
79
|
+
image: [],
|
|
80
|
+
// eslint-disable-next-line sort-keys
|
|
81
|
+
gallery: [],
|
|
80
82
|
});
|
|
81
83
|
if (uploadedImages.length > 1) {
|
|
82
84
|
containers['gallery'] = [
|
|
@@ -106,5 +108,5 @@ var getAttachmentType = function (attachment) {
|
|
|
106
108
|
else if (isFileAttachment(attachment)) {
|
|
107
109
|
return 'file';
|
|
108
110
|
}
|
|
109
|
-
return
|
|
111
|
+
return 'unsupported';
|
|
110
112
|
};
|
|
@@ -9,4 +9,5 @@ export declare const CardContainer: <StreamChatGenerics extends DefaultStreamCha
|
|
|
9
9
|
export declare const FileContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, File, }: RenderAttachmentProps<StreamChatGenerics>) => JSX.Element | null;
|
|
10
10
|
export declare const AudioContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, Audio, }: RenderAttachmentProps<StreamChatGenerics>) => JSX.Element;
|
|
11
11
|
export declare const MediaContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: RenderAttachmentProps<StreamChatGenerics>) => JSX.Element;
|
|
12
|
+
export declare const UnsupportedAttachmentContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, UnsupportedAttachment, }: RenderAttachmentProps<StreamChatGenerics>) => JSX.Element;
|
|
12
13
|
//# sourceMappingURL=AttachmentContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentContainer.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/AttachmentContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAqC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AttachmentContainer.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/AttachmentContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAqC,MAAM,OAAO,CAAC;AAYpF,OAAO,EACL,wBAAwB,EAGxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,yBAAyB,oNA+BrC,CAAC;AAEF,eAAO,MAAM,0BAA0B,wMAkBtC,CAAC;AAqBF,eAAO,MAAM,gBAAgB,qKAwC5B,CAAC;AAEF,eAAO,MAAM,cAAc,qJA0C1B,CAAC;AAEF,eAAO,MAAM,aAAa,qJAwBzB,CAAC;AAEF,eAAO,MAAM,aAAa,4KAazB,CAAC;AACF,eAAO,MAAM,cAAc,sKAW1B,CAAC;AAEF,eAAO,MAAM,cAAc,qJAuD1B,CAAC;AAEF,eAAO,MAAM,8BAA8B,sLAS1C,CAAC"}
|
|
@@ -18,6 +18,7 @@ import { Audio as DefaultAudio } from './Audio';
|
|
|
18
18
|
import { Gallery as DefaultGallery, ImageComponent as DefaultImage } from '../Gallery';
|
|
19
19
|
import { Card as DefaultCard } from './Card';
|
|
20
20
|
import { FileAttachment as DefaultFile } from './FileAttachment';
|
|
21
|
+
import { NullComponent as DefaultUnsupportedAttachment } from './UnsupportedAttachment';
|
|
21
22
|
import { isGalleryAttachmentType, isSvgAttachment, } from './utils';
|
|
22
23
|
import { useChannelStateContext } from '../../context/ChannelStateContext';
|
|
23
24
|
export var AttachmentWithinContainer = function (_a) {
|
|
@@ -157,3 +158,8 @@ export var MediaContainer = function (props) {
|
|
|
157
158
|
content,
|
|
158
159
|
React.createElement(AttachmentActionsContainer, __assign({}, props))))) : (React.createElement(AttachmentWithinContainer, { attachment: attachment, componentType: componentType }, content));
|
|
159
160
|
};
|
|
161
|
+
export var UnsupportedAttachmentContainer = function (_a) {
|
|
162
|
+
var attachment = _a.attachment, _b = _a.UnsupportedAttachment, UnsupportedAttachment = _b === void 0 ? DefaultUnsupportedAttachment : _b;
|
|
163
|
+
return (React.createElement(React.Fragment, null,
|
|
164
|
+
React.createElement(UnsupportedAttachment, { attachment: attachment })));
|
|
165
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Attachment } from 'stream-chat';
|
|
2
|
+
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
3
|
+
export declare type UnsupportedAttachmentProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
|
|
4
|
+
attachment: Attachment<StreamChatGenerics>;
|
|
5
|
+
};
|
|
6
|
+
export declare const UnsupportedAttachment: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, }: UnsupportedAttachmentProps<StreamChatGenerics>) => JSX.Element;
|
|
7
|
+
export declare const NullComponent: () => null;
|
|
8
|
+
//# sourceMappingURL=UnsupportedAttachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnsupportedAttachment.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/UnsupportedAttachment.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,oBAAY,0BAA0B,CACpC,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,qBAAqB,oKAWjC,CAAC;AAEF,eAAO,MAAM,aAAa,YAAa,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var UnsupportedAttachment = function (_a) {
|
|
3
|
+
var _b;
|
|
4
|
+
var attachment = _a.attachment;
|
|
5
|
+
return (React.createElement("div", null,
|
|
6
|
+
React.createElement("div", null,
|
|
7
|
+
"Unsupported attachment type ",
|
|
8
|
+
React.createElement("strong", null, (_b = attachment.type) !== null && _b !== void 0 ? _b : 'unknown')),
|
|
9
|
+
React.createElement("code", null, JSON.stringify(attachment, null, 4)),
|
|
10
|
+
";"));
|
|
11
|
+
};
|
|
12
|
+
export var NullComponent = function () { return null; };
|
|
@@ -3,6 +3,7 @@ export * from './AttachmentActions';
|
|
|
3
3
|
export * from './AttachmentContainer';
|
|
4
4
|
export * from './Audio';
|
|
5
5
|
export * from './Card';
|
|
6
|
+
export * from './UnsupportedAttachment';
|
|
6
7
|
export * from './FileAttachment';
|
|
7
8
|
export * from './utils';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gallery.d.ts","sourceRoot":"","sources":["../../../src/components/Gallery/Gallery.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,gBAAgB,EAAY,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Gallery.d.ts","sourceRoot":"","sources":["../../../src/components/Gallery/Gallery.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,gBAAgB,EAAY,MAAM,OAAO,CAAC;AAUzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,oBAAY,YAAY,CACtB,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,MAAM,EAAE,CAAC,CACL;QACE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,GACD,UAAU,CAAC,kBAAkB,CAAC,CACjC,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,aAAa,CAAA;KAAE,CAAC,EAAE,CAAC;IACtD,SAAS,CAAC,EAAE,gBAAgB,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;CACtD,CAAC;AAkFF;;GAEG;AACH,eAAO,MAAM,OAAO,4IAA4D,CAAC"}
|
|
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import React, { useState } from 'react';
|
|
13
|
+
import { sanitizeUrl } from '@braintree/sanitize-url';
|
|
13
14
|
import clsx from 'clsx';
|
|
14
15
|
import { Modal } from '../Modal';
|
|
15
16
|
import { ModalGallery as DefaultModalGallery } from './ModalGallery';
|
|
@@ -39,7 +40,7 @@ var UnMemoizedGallery = function (props) {
|
|
|
39
40
|
React.createElement("p", null, t('{{ imageCount }} more', {
|
|
40
41
|
imageCount: images.length - countImagesDisplayedInPreview,
|
|
41
42
|
})))) : (React.createElement("button", { className: 'str-chat__gallery-image', "data-testid": 'gallery-image', key: "gallery-image-".concat(i), onClick: function () { return toggleModal(i); } },
|
|
42
|
-
React.createElement("img", __assign({ alt: 'User uploaded content', src: image.previewUrl || image.image_url || image.thumb_url, style: image.style }, ((innerRefs === null || innerRefs === void 0 ? void 0 : innerRefs.current) && { ref: function (r) { return (innerRefs.current[i] = r); } })))));
|
|
43
|
+
React.createElement("img", __assign({ alt: 'User uploaded content', src: sanitizeUrl(image.previewUrl || image.image_url || image.thumb_url), style: image.style }, ((innerRefs === null || innerRefs === void 0 ? void 0 : innerRefs.current) && { ref: function (r) { return (innerRefs.current[i] = r); } })))));
|
|
43
44
|
});
|
|
44
45
|
var className = clsx('str-chat__gallery', {
|
|
45
46
|
'str-chat__gallery--square': images.length > lastImageIndexInPreview,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessageListElements.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageList/hooks/useMessageListElements.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAmB,UAAU,EAAE,MAAM,UAAU,CAAC;AAWvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,aAAK,kBAAkB,GACnB,SAAS,GACT,aAAa,GACb,gBAAgB,GAChB,gBAAgB,GAChB,SAAS,GACT,QAAQ,GACR,YAAY,CAAC;AAEjB,aAAK,2BAA2B,CAC9B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACtD,oBAAoB,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACjF,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,YAAY,CAAC,kBAAkB,CAAC,CAAA;KAAE,CAAC,CAAC;CACpF,CAAC;AAEF,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useMessageListElements.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageList/hooks/useMessageListElements.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAmB,UAAU,EAAE,MAAM,UAAU,CAAC;AAWvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,aAAK,kBAAkB,GACnB,SAAS,GACT,aAAa,GACb,gBAAgB,GAChB,gBAAgB,GAChB,SAAS,GACT,QAAQ,GACR,YAAY,CAAC;AAEjB,aAAK,2BAA2B,CAC9B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACtD,oBAAoB,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC,CAAC;IACjF,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,YAAY,CAAC,kBAAkB,CAAC,CAAA;KAAE,CAAC,CAAC;CACpF,CAAC;AAEF,eAAO,MAAM,sBAAsB,iKAkGlC,CAAC"}
|
|
@@ -34,7 +34,6 @@ export var useMessageListElements = function (props) {
|
|
|
34
34
|
var lastReceivedId = useMemo(function () { return getLastReceived(enrichedMessages); }, [enrichedMessages]);
|
|
35
35
|
var elements = useMemo(function () {
|
|
36
36
|
return enrichedMessages.map(function (message) {
|
|
37
|
-
var _a;
|
|
38
37
|
if (message.customType === CUSTOM_MESSAGE_TYPE.date &&
|
|
39
38
|
message.date &&
|
|
40
39
|
isDate(message.date)) {
|
|
@@ -46,9 +45,7 @@ export var useMessageListElements = function (props) {
|
|
|
46
45
|
React.createElement(HeaderComponent, null)));
|
|
47
46
|
}
|
|
48
47
|
if (message.type === 'system') {
|
|
49
|
-
return (React.createElement("li", { key:
|
|
50
|
-
message.created_at ||
|
|
51
|
-
'' },
|
|
48
|
+
return (React.createElement("li", { key: message.id || message.created_at },
|
|
52
49
|
React.createElement(MessageSystem, { message: message })));
|
|
53
50
|
}
|
|
54
51
|
var groupStyles = messageGroupStyles[message.id] || '';
|
package/dist/index.cjs.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var sanitizeUrl = require('@braintree/sanitize-url');
|
|
7
6
|
var ReactPlayer = require('react-player');
|
|
8
7
|
var prettybytes = require('pretty-bytes');
|
|
8
|
+
var sanitizeUrl = require('@braintree/sanitize-url');
|
|
9
9
|
var DefaultEmojiIndex = require('emoji-mart/dist/utils/emoji-index/nimble-emoji-index.js');
|
|
10
10
|
var Dayjs = require('dayjs');
|
|
11
11
|
var calendar = require('dayjs/plugin/calendar');
|
|
@@ -1384,7 +1384,7 @@ var UnMemoizedGallery = function (props) {
|
|
|
1384
1384
|
React__default["default"].createElement("p", null, t('{{ imageCount }} more', {
|
|
1385
1385
|
imageCount: images.length - countImagesDisplayedInPreview,
|
|
1386
1386
|
})))) : (React__default["default"].createElement("button", { className: 'str-chat__gallery-image', "data-testid": 'gallery-image', key: "gallery-image-".concat(i), onClick: function () { return toggleModal(i); } },
|
|
1387
|
-
React__default["default"].createElement("img", __assign({ alt: 'User uploaded content', src: image.previewUrl || image.image_url || image.thumb_url, style: image.style }, ((innerRefs === null || innerRefs === void 0 ? void 0 : innerRefs.current) && { ref: function (r) { return (innerRefs.current[i] = r); } })))));
|
|
1387
|
+
React__default["default"].createElement("img", __assign({ alt: 'User uploaded content', src: sanitizeUrl.sanitizeUrl(image.previewUrl || image.image_url || image.thumb_url), style: image.style }, ((innerRefs === null || innerRefs === void 0 ? void 0 : innerRefs.current) && { ref: function (r) { return (innerRefs.current[i] = r); } })))));
|
|
1388
1388
|
});
|
|
1389
1389
|
var className = clsx('str-chat__gallery', {
|
|
1390
1390
|
'str-chat__gallery--square': images.length > lastImageIndexInPreview,
|
|
@@ -1715,6 +1715,18 @@ var renderMedia = function (props) {
|
|
|
1715
1715
|
});
|
|
1716
1716
|
};
|
|
1717
1717
|
|
|
1718
|
+
var UnsupportedAttachment = function (_a) {
|
|
1719
|
+
var _b;
|
|
1720
|
+
var attachment = _a.attachment;
|
|
1721
|
+
return (React__default["default"].createElement("div", null,
|
|
1722
|
+
React__default["default"].createElement("div", null,
|
|
1723
|
+
"Unsupported attachment type ",
|
|
1724
|
+
React__default["default"].createElement("strong", null, (_b = attachment.type) !== null && _b !== void 0 ? _b : 'unknown')),
|
|
1725
|
+
React__default["default"].createElement("code", null, JSON.stringify(attachment, null, 4)),
|
|
1726
|
+
";"));
|
|
1727
|
+
};
|
|
1728
|
+
var NullComponent = function () { return null; };
|
|
1729
|
+
|
|
1718
1730
|
var AttachmentWithinContainer = function (_a) {
|
|
1719
1731
|
var _b;
|
|
1720
1732
|
var _c;
|
|
@@ -1852,12 +1864,18 @@ var MediaContainer = function (props) {
|
|
|
1852
1864
|
content,
|
|
1853
1865
|
React__default["default"].createElement(AttachmentActionsContainer, __assign({}, props))))) : (React__default["default"].createElement(AttachmentWithinContainer, { attachment: attachment, componentType: componentType }, content));
|
|
1854
1866
|
};
|
|
1867
|
+
var UnsupportedAttachmentContainer = function (_a) {
|
|
1868
|
+
var attachment = _a.attachment, _b = _a.UnsupportedAttachment, UnsupportedAttachment = _b === void 0 ? NullComponent : _b;
|
|
1869
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1870
|
+
React__default["default"].createElement(UnsupportedAttachment, { attachment: attachment })));
|
|
1871
|
+
};
|
|
1855
1872
|
|
|
1856
1873
|
var CONTAINER_MAP = {
|
|
1857
1874
|
audio: AudioContainer,
|
|
1858
1875
|
card: CardContainer,
|
|
1859
1876
|
file: FileContainer,
|
|
1860
1877
|
media: MediaContainer,
|
|
1878
|
+
unsupported: UnsupportedAttachmentContainer,
|
|
1861
1879
|
};
|
|
1862
1880
|
var ATTACHMENT_GROUPS_ORDER = [
|
|
1863
1881
|
'card',
|
|
@@ -1866,6 +1884,7 @@ var ATTACHMENT_GROUPS_ORDER = [
|
|
|
1866
1884
|
'media',
|
|
1867
1885
|
'audio',
|
|
1868
1886
|
'file',
|
|
1887
|
+
'unsupported',
|
|
1869
1888
|
];
|
|
1870
1889
|
/**
|
|
1871
1890
|
* A component used for rendering message attachments. By default, the component supports: AttachmentActions, Audio, Card, File, Gallery, Image, and Video
|
|
@@ -1877,26 +1896,27 @@ var Attachment = function (props) {
|
|
|
1877
1896
|
};
|
|
1878
1897
|
var renderGroupedAttachments = function (_a) {
|
|
1879
1898
|
var attachments = _a.attachments, rest = __rest(_a, ["attachments"]);
|
|
1880
|
-
var uploadedImages =
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
return acc;
|
|
1899
|
+
var uploadedImages = attachments.filter(function (attachment) {
|
|
1900
|
+
return isUploadedImage(attachment);
|
|
1901
|
+
});
|
|
1902
|
+
var containers = attachments
|
|
1903
|
+
.filter(function (attachment) { return !isUploadedImage(attachment); })
|
|
1904
|
+
.reduce(function (typeMap, attachment) {
|
|
1905
|
+
var attachmentType = getAttachmentType(attachment);
|
|
1906
|
+
var Container = CONTAINER_MAP[attachmentType];
|
|
1907
|
+
typeMap[attachmentType].push(React__default["default"].createElement(Container, __assign({ key: "".concat(attachmentType, "-").concat(typeMap[attachmentType].length) }, rest, { attachment: attachment })));
|
|
1908
|
+
return typeMap;
|
|
1893
1909
|
}, {
|
|
1894
1910
|
audio: [],
|
|
1895
1911
|
card: [],
|
|
1896
1912
|
file: [],
|
|
1897
|
-
gallery: [],
|
|
1898
|
-
image: [],
|
|
1899
1913
|
media: [],
|
|
1914
|
+
unsupported: [],
|
|
1915
|
+
// not used in reduce
|
|
1916
|
+
// eslint-disable-next-line sort-keys
|
|
1917
|
+
image: [],
|
|
1918
|
+
// eslint-disable-next-line sort-keys
|
|
1919
|
+
gallery: [],
|
|
1900
1920
|
});
|
|
1901
1921
|
if (uploadedImages.length > 1) {
|
|
1902
1922
|
containers['gallery'] = [
|
|
@@ -1926,7 +1946,7 @@ var getAttachmentType = function (attachment) {
|
|
|
1926
1946
|
else if (isFileAttachment(attachment)) {
|
|
1927
1947
|
return 'file';
|
|
1928
1948
|
}
|
|
1929
|
-
return
|
|
1949
|
+
return 'unsupported';
|
|
1930
1950
|
};
|
|
1931
1951
|
|
|
1932
1952
|
var Item = /*#__PURE__*/React__default["default"].forwardRef(function Item(props, innerRef) {
|
|
@@ -33778,7 +33798,7 @@ var UnMemoizedChannelList = function (props) {
|
|
|
33778
33798
|
*/
|
|
33779
33799
|
var ChannelList = React__default["default"].memo(UnMemoizedChannelList);
|
|
33780
33800
|
|
|
33781
|
-
var version = '10.
|
|
33801
|
+
var version = '10.7.0';
|
|
33782
33802
|
|
|
33783
33803
|
var useChat = function (_a) {
|
|
33784
33804
|
var _b, _c;
|
|
@@ -34870,7 +34890,6 @@ var useMessageListElements = function (props) {
|
|
|
34870
34890
|
var lastReceivedId = React.useMemo(function () { return getLastReceived(enrichedMessages); }, [enrichedMessages]);
|
|
34871
34891
|
var elements = React.useMemo(function () {
|
|
34872
34892
|
return enrichedMessages.map(function (message) {
|
|
34873
|
-
var _a;
|
|
34874
34893
|
if (message.customType === CUSTOM_MESSAGE_TYPE.date &&
|
|
34875
34894
|
message.date &&
|
|
34876
34895
|
isDate(message.date)) {
|
|
@@ -34882,9 +34901,7 @@ var useMessageListElements = function (props) {
|
|
|
34882
34901
|
React__default["default"].createElement(HeaderComponent, null)));
|
|
34883
34902
|
}
|
|
34884
34903
|
if (message.type === 'system') {
|
|
34885
|
-
return (React__default["default"].createElement("li", { key:
|
|
34886
|
-
message.created_at ||
|
|
34887
|
-
'' },
|
|
34904
|
+
return (React__default["default"].createElement("li", { key: message.id || message.created_at },
|
|
34888
34905
|
React__default["default"].createElement(MessageSystem, { message: message })));
|
|
34889
34906
|
}
|
|
34890
34907
|
var groupStyles = messageGroupStyles[message.id] || '';
|
|
@@ -35905,6 +35922,7 @@ exports.MessageText = MessageText;
|
|
|
35905
35922
|
exports.MessageTimestamp = MessageTimestamp;
|
|
35906
35923
|
exports.Modal = Modal;
|
|
35907
35924
|
exports.ModalGallery = ModalGallery;
|
|
35925
|
+
exports.NullComponent = NullComponent;
|
|
35908
35926
|
exports.PinIcon = PinIcon;
|
|
35909
35927
|
exports.PinIndicator = PinIndicator;
|
|
35910
35928
|
exports.PlayButton = PlayButton;
|
|
@@ -35940,6 +35958,8 @@ exports.TypingContext = TypingContext;
|
|
|
35940
35958
|
exports.TypingIndicator = TypingIndicator;
|
|
35941
35959
|
exports.TypingProvider = TypingProvider;
|
|
35942
35960
|
exports.UnMemoizedLoadMorePaginator = UnMemoizedLoadMorePaginator;
|
|
35961
|
+
exports.UnsupportedAttachment = UnsupportedAttachment;
|
|
35962
|
+
exports.UnsupportedAttachmentContainer = UnsupportedAttachmentContainer;
|
|
35943
35963
|
exports.UploadIcon = UploadIcon;
|
|
35944
35964
|
exports.UploadsPreview = UploadsPreview;
|
|
35945
35965
|
exports.UserItem = UserItem;
|