stream-chat-react 11.11.0 → 11.12.1
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/{Window-194c5448.js → Window-40a618cb.js} +357 -76
- package/dist/browser.full-bundle.js +424 -136
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +4 -4
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Attachment/Attachment.d.ts +6 -1
- package/dist/components/Attachment/Attachment.d.ts.map +1 -1
- package/dist/components/Attachment/Attachment.js +8 -2
- 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 +7 -0
- package/dist/components/Attachment/Audio.d.ts +0 -10
- package/dist/components/Attachment/Audio.d.ts.map +1 -1
- package/dist/components/Attachment/Audio.js +1 -14
- package/dist/components/Attachment/Card.d.ts.map +1 -1
- package/dist/components/Attachment/Card.js +1 -1
- package/dist/components/Attachment/FileAttachment.d.ts.map +1 -1
- package/dist/components/Attachment/FileAttachment.js +1 -2
- package/dist/components/Attachment/VoiceRecording.d.ts +18 -0
- package/dist/components/Attachment/VoiceRecording.d.ts.map +1 -0
- package/dist/components/Attachment/VoiceRecording.js +45 -0
- package/dist/components/Attachment/components/DownloadButton.d.ts.map +1 -0
- package/dist/components/Attachment/{DownloadButton.js → components/DownloadButton.js} +2 -2
- package/dist/components/Attachment/components/FileSizeIndicator.d.ts +13 -0
- package/dist/components/Attachment/components/FileSizeIndicator.d.ts.map +1 -0
- package/dist/components/Attachment/{FileSizeIndicator.js → components/FileSizeIndicator.js} +2 -2
- package/dist/components/Attachment/components/PlayButton.d.ts +8 -0
- package/dist/components/Attachment/components/PlayButton.d.ts.map +1 -0
- package/dist/components/Attachment/components/PlayButton.js +6 -0
- package/dist/components/Attachment/components/PlaybackRateButton.d.ts +4 -0
- package/dist/components/Attachment/components/PlaybackRateButton.d.ts.map +1 -0
- package/dist/components/Attachment/components/PlaybackRateButton.js +5 -0
- package/dist/components/Attachment/components/ProgressBar.d.ts +7 -0
- package/dist/components/Attachment/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/Attachment/components/ProgressBar.js +8 -0
- package/dist/components/Attachment/components/WaveProgressBar.d.ts +22 -0
- package/dist/components/Attachment/components/WaveProgressBar.d.ts.map +1 -0
- package/dist/components/Attachment/components/WaveProgressBar.js +121 -0
- package/dist/components/Attachment/components/index.d.ts +7 -0
- package/dist/components/Attachment/components/index.d.ts.map +1 -0
- package/dist/components/Attachment/components/index.js +6 -0
- package/dist/components/Attachment/hooks/useAudioController.d.ts +12 -2
- package/dist/components/Attachment/hooks/useAudioController.d.ts.map +1 -1
- package/dist/components/Attachment/hooks/useAudioController.js +60 -25
- 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/Attachment/utils.d.ts +4 -2
- package/dist/components/Attachment/utils.d.ts.map +1 -1
- package/dist/components/Attachment/utils.js +14 -0
- package/dist/components/AutoCompleteTextarea/Textarea.d.ts +2 -2
- package/dist/components/AutoCompleteTextarea/Textarea.d.ts.map +1 -1
- package/dist/components/AutoCompleteTextarea/Textarea.js +23 -13
- package/dist/components/Channel/Channel.d.ts +2 -0
- package/dist/components/Channel/Channel.d.ts.map +1 -1
- package/dist/components/Channel/Channel.js +1 -0
- package/dist/components/Emojis/index.cjs.js +3 -3
- package/dist/components/Gallery/BaseImage.js +1 -1
- package/dist/components/Message/MessageEditedTimestamp.d.ts +8 -0
- package/dist/components/Message/MessageEditedTimestamp.d.ts.map +1 -0
- package/dist/components/Message/MessageEditedTimestamp.js +22 -0
- package/dist/components/Message/MessageSimple.d.ts.map +1 -1
- package/dist/components/Message/MessageSimple.js +13 -3
- package/dist/components/Message/MessageTimestamp.d.ts +1 -1
- package/dist/components/Message/MessageTimestamp.d.ts.map +1 -1
- package/dist/components/Message/MessageTimestamp.js +8 -13
- package/dist/components/Message/QuotedMessage.d.ts.map +1 -1
- package/dist/components/Message/QuotedMessage.js +1 -1
- package/dist/components/Message/Timestamp.d.ts +10 -0
- package/dist/components/Message/Timestamp.d.ts.map +1 -0
- package/dist/components/Message/Timestamp.js +24 -0
- package/dist/components/Message/renderText/index.d.ts +1 -1
- package/dist/components/Message/renderText/index.d.ts.map +1 -1
- package/dist/components/Message/utils.d.ts +1 -0
- package/dist/components/Message/utils.d.ts.map +1 -1
- package/dist/components/Message/utils.js +1 -0
- package/dist/components/MessageInput/QuotedMessagePreview.d.ts.map +1 -1
- package/dist/components/MessageInput/QuotedMessagePreview.js +1 -1
- package/dist/components/MessageList/VirtualizedMessageListComponents.d.ts.map +1 -1
- package/dist/components/MessageList/VirtualizedMessageListComponents.js +11 -6
- package/dist/components/MessageList/utils.d.ts.map +1 -1
- package/dist/components/MessageList/utils.js +5 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/context/ComponentContext.d.ts +2 -0
- package/dist/context/ComponentContext.d.ts.map +1 -1
- package/dist/css/index.css +1 -1
- package/dist/css/v2/index.css +1 -1
- package/dist/css/v2/index.layout.css +1 -1
- package/dist/i18n/Streami18n.d.ts +3 -0
- package/dist/i18n/Streami18n.d.ts.map +1 -1
- package/dist/i18n/de.json +3 -0
- package/dist/i18n/en.json +3 -0
- package/dist/i18n/es.json +3 -0
- package/dist/i18n/fr.json +3 -0
- package/dist/i18n/hi.json +3 -0
- package/dist/i18n/it.json +3 -0
- package/dist/i18n/ja.json +3 -0
- package/dist/i18n/ko.json +3 -0
- package/dist/i18n/nl.json +3 -0
- package/dist/i18n/pt.json +3 -0
- package/dist/i18n/ru.json +3 -0
- package/dist/i18n/tr.json +3 -0
- package/dist/index.cjs.js +23 -7
- package/dist/scss/Message.scss +21 -17
- package/dist/scss/MessageActions.scss +0 -9
- package/dist/scss/_base.scss +8 -1
- package/dist/scss/v2/AttachmentList/AttachmentList-layout.scss +84 -0
- package/dist/scss/v2/AttachmentList/AttachmentList-theme.scss +72 -1
- package/dist/scss/v2/EditMessageForm/EditMessageForm-layout.scss +13 -15
- package/dist/scss/v2/Message/Message-layout.scss +48 -4
- package/dist/scss/v2/MessageActionsBox/MessageActionsBox-layout.scss +0 -8
- package/dist/scss/v2/_base.scss +1 -2
- package/dist/scss/v2/_utils.scss +0 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
- package/dist/components/Attachment/DownloadButton.d.ts.map +0 -1
- package/dist/components/Attachment/FileSizeIndicator.d.ts +0 -7
- package/dist/components/Attachment/FileSizeIndicator.d.ts.map +0 -1
- /package/dist/components/Attachment/{DownloadButton.d.ts → components/DownloadButton.d.ts} +0 -0
|
@@ -3,13 +3,14 @@ import type { ReactPlayerProps } from 'react-player';
|
|
|
3
3
|
import type { Attachment as StreamAttachment } from 'stream-chat';
|
|
4
4
|
import type { AttachmentActionsProps } from './AttachmentActions';
|
|
5
5
|
import type { AudioProps } from './Audio';
|
|
6
|
+
import type { VoiceRecordingProps } from './VoiceRecording';
|
|
6
7
|
import type { CardProps } from './Card';
|
|
7
8
|
import type { FileAttachmentProps } from './FileAttachment';
|
|
8
9
|
import type { GalleryProps, ImageProps } from '../Gallery';
|
|
9
10
|
import type { UnsupportedAttachmentProps } from './UnsupportedAttachment';
|
|
10
11
|
import type { ActionHandlerReturnType } from '../Message/hooks/useActionHandler';
|
|
11
12
|
import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
12
|
-
export declare const ATTACHMENT_GROUPS_ORDER: readonly ["card", "gallery", "image", "media", "audio", "file", "unsupported"];
|
|
13
|
+
export declare const ATTACHMENT_GROUPS_ORDER: readonly ["card", "gallery", "image", "media", "audio", "voiceRecording", "file", "unsupported"];
|
|
13
14
|
export type AttachmentProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
|
|
14
15
|
/** The message attachments to render, see [attachment structure](https://getstream.io/chat/docs/javascript/message_format/?language=javascript) **/
|
|
15
16
|
attachments: StreamAttachment<StreamChatGenerics>[];
|
|
@@ -27,10 +28,14 @@ export type AttachmentProps<StreamChatGenerics extends DefaultStreamChatGenerics
|
|
|
27
28
|
Gallery?: React.ComponentType<GalleryProps<StreamChatGenerics>>;
|
|
28
29
|
/** Custom UI component for displaying an image type attachment, defaults to and accepts same props as: [Image](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Gallery/Image.tsx) */
|
|
29
30
|
Image?: React.ComponentType<ImageProps>;
|
|
31
|
+
/** Optional flag to signal that an attachment is a displayed as a part of a quoted message */
|
|
32
|
+
isQuoted?: boolean;
|
|
30
33
|
/** Custom UI component for displaying a media type attachment, defaults to `ReactPlayer` from 'react-player' */
|
|
31
34
|
Media?: React.ComponentType<ReactPlayerProps>;
|
|
32
35
|
/** Custom UI component for displaying unsupported attachment types, defaults to NullComponent */
|
|
33
36
|
UnsupportedAttachment?: React.ComponentType<UnsupportedAttachmentProps>;
|
|
37
|
+
/** Custom UI component for displaying an audio recording attachment, defaults to and accepts same props as: [VoiceRecording](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Attachment/VoiceRecording.tsx) */
|
|
38
|
+
VoiceRecording?: React.ComponentType<VoiceRecordingProps<StreamChatGenerics>>;
|
|
34
39
|
};
|
|
35
40
|
/**
|
|
36
41
|
* 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;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,aAAa,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;AAuBlE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,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;AAWnE,eAAO,MAAM,uBAAuB,kGAS1B,CAAC;AAEX,MAAM,MAAM,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,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,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;IACxE,yOAAyO;IACzO,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC;CAC/E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,qJAkBtB,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { __assign, __rest, __spreadArray } from "tslib";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
|
-
import { isAudioAttachment, isFileAttachment, isMediaAttachment, isScrapedContent, isUploadedImage, } from './utils';
|
|
4
|
-
import { AudioContainer, CardContainer, FileContainer, GalleryContainer, ImageContainer, MediaContainer, UnsupportedAttachmentContainer, } from './AttachmentContainer';
|
|
3
|
+
import { isAudioAttachment, isFileAttachment, isMediaAttachment, isScrapedContent, isUploadedImage, isVoiceRecordingAttachment, } from './utils';
|
|
4
|
+
import { AudioContainer, CardContainer, FileContainer, GalleryContainer, ImageContainer, MediaContainer, UnsupportedAttachmentContainer, VoiceRecordingContainer, } from './AttachmentContainer';
|
|
5
5
|
var CONTAINER_MAP = {
|
|
6
6
|
audio: AudioContainer,
|
|
7
7
|
card: CardContainer,
|
|
8
8
|
file: FileContainer,
|
|
9
9
|
media: MediaContainer,
|
|
10
10
|
unsupported: UnsupportedAttachmentContainer,
|
|
11
|
+
voiceRecording: VoiceRecordingContainer,
|
|
11
12
|
};
|
|
12
13
|
export var ATTACHMENT_GROUPS_ORDER = [
|
|
13
14
|
'card',
|
|
@@ -15,6 +16,7 @@ export var ATTACHMENT_GROUPS_ORDER = [
|
|
|
15
16
|
'image',
|
|
16
17
|
'media',
|
|
17
18
|
'audio',
|
|
19
|
+
'voiceRecording',
|
|
18
20
|
'file',
|
|
19
21
|
'unsupported',
|
|
20
22
|
];
|
|
@@ -50,6 +52,7 @@ var renderGroupedAttachments = function (_a) {
|
|
|
50
52
|
image: [],
|
|
51
53
|
// eslint-disable-next-line sort-keys
|
|
52
54
|
gallery: [],
|
|
55
|
+
voiceRecording: [],
|
|
53
56
|
});
|
|
54
57
|
if (uploadedImages.length > 1) {
|
|
55
58
|
containers['gallery'] = [
|
|
@@ -76,6 +79,9 @@ var getAttachmentType = function (attachment) {
|
|
|
76
79
|
else if (isAudioAttachment(attachment)) {
|
|
77
80
|
return 'audio';
|
|
78
81
|
}
|
|
82
|
+
else if (isVoiceRecordingAttachment(attachment)) {
|
|
83
|
+
return 'voiceRecording';
|
|
84
|
+
}
|
|
79
85
|
else if (isFileAttachment(attachment)) {
|
|
80
86
|
return 'file';
|
|
81
87
|
}
|
|
@@ -8,6 +8,7 @@ export declare const ImageContainer: <StreamChatGenerics extends DefaultStreamCh
|
|
|
8
8
|
export declare const CardContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: RenderAttachmentProps<StreamChatGenerics>) => React.JSX.Element;
|
|
9
9
|
export declare const FileContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, File, }: RenderAttachmentProps<StreamChatGenerics>) => React.JSX.Element | null;
|
|
10
10
|
export declare const AudioContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, Audio, }: RenderAttachmentProps<StreamChatGenerics>) => React.JSX.Element;
|
|
11
|
+
export declare const VoiceRecordingContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, VoiceRecording, isQuoted, }: RenderAttachmentProps<StreamChatGenerics>) => React.JSX.Element;
|
|
11
12
|
export declare const MediaContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: RenderAttachmentProps<StreamChatGenerics>) => React.JSX.Element;
|
|
12
13
|
export declare const UnsupportedAttachmentContainer: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ attachment, UnsupportedAttachment, }: RenderAttachmentProps<StreamChatGenerics>) => React.JSX.Element;
|
|
13
14
|
//# 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;AAapF,OAAO,EACL,wBAAwB,EAGxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAIjB,OAAO,KAAK,EACV,yBAAyB,EAG1B,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,yBAAyB,0NA+BrC,CAAC;AAEF,eAAO,MAAM,0BAA0B,8MAkBtC,CAAC;AAqBF,eAAO,MAAM,gBAAgB,2KAwC5B,CAAC;AAEF,eAAO,MAAM,cAAc,2JA0C1B,CAAC;AAEF,eAAO,MAAM,aAAa,2JAwBzB,CAAC;AAEF,eAAO,MAAM,aAAa,kLAazB,CAAC;AACF,eAAO,MAAM,cAAc,4KAW1B,CAAC;AAEF,eAAO,MAAM,uBAAuB,+LAYnC,CAAC;AAEF,eAAO,MAAM,cAAc,2JAwD1B,CAAC;AAEF,eAAO,MAAM,8BAA8B,4LAS1C,CAAC"}
|
|
@@ -5,6 +5,7 @@ import clsx from 'clsx';
|
|
|
5
5
|
import * as linkify from 'linkifyjs';
|
|
6
6
|
import { AttachmentActions as DefaultAttachmentActions } from './AttachmentActions';
|
|
7
7
|
import { Audio as DefaultAudio } from './Audio';
|
|
8
|
+
import { VoiceRecording as DefaultVoiceRecording } from './VoiceRecording';
|
|
8
9
|
import { Gallery as DefaultGallery, ImageComponent as DefaultImage } from '../Gallery';
|
|
9
10
|
import { Card as DefaultCard } from './Card';
|
|
10
11
|
import { FileAttachment as DefaultFile } from './FileAttachment';
|
|
@@ -128,6 +129,12 @@ export var AudioContainer = function (_a) {
|
|
|
128
129
|
React.createElement("div", { className: 'str-chat__attachment' },
|
|
129
130
|
React.createElement(Audio, { og: attachment }))));
|
|
130
131
|
};
|
|
132
|
+
export var VoiceRecordingContainer = function (_a) {
|
|
133
|
+
var attachment = _a.attachment, _b = _a.VoiceRecording, VoiceRecording = _b === void 0 ? DefaultVoiceRecording : _b, isQuoted = _a.isQuoted;
|
|
134
|
+
return (React.createElement(AttachmentWithinContainer, { attachment: attachment, componentType: 'voiceRecording' },
|
|
135
|
+
React.createElement("div", { className: 'str-chat__attachment' },
|
|
136
|
+
React.createElement(VoiceRecording, { attachment: attachment, isQuoted: isQuoted }))));
|
|
137
|
+
};
|
|
131
138
|
export var MediaContainer = function (props) {
|
|
132
139
|
var _a;
|
|
133
140
|
var attachment = props.attachment, _b = props.Media, Media = _b === void 0 ? ReactPlayer : _b;
|
|
@@ -4,18 +4,8 @@ import type { DefaultStreamChatGenerics } from '../../types/types';
|
|
|
4
4
|
export type AudioProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
|
|
5
5
|
og: Attachment<StreamChatGenerics>;
|
|
6
6
|
};
|
|
7
|
-
type PlayButtonProps = {
|
|
8
|
-
isPlaying: boolean;
|
|
9
|
-
onClick: () => void;
|
|
10
|
-
};
|
|
11
|
-
export declare const PlayButton: ({ isPlaying, onClick }: PlayButtonProps) => React.JSX.Element;
|
|
12
|
-
type ProgressBarProps = {
|
|
13
|
-
progress: number;
|
|
14
|
-
} & Pick<React.ComponentProps<'div'>, 'onClick'>;
|
|
15
|
-
export declare const ProgressBar: ({ onClick, progress }: ProgressBarProps) => React.JSX.Element;
|
|
16
7
|
/**
|
|
17
8
|
* Audio attachment with play/pause button and progress bar
|
|
18
9
|
*/
|
|
19
10
|
export declare const Audio: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(props: AudioProps<StreamChatGenerics>) => React.JSX.Element;
|
|
20
|
-
export {};
|
|
21
11
|
//# sourceMappingURL=Audio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Audio.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/Audio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Audio.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/Audio.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,MAAM,UAAU,CACpB,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,EAAE,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;CACpC,CAAC;AAwGF;;GAEG;AACH,eAAO,MAAM,KAAK,gJAAwD,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { FileSizeIndicator } from './FileSizeIndicator';
|
|
5
|
-
import { DownloadButton } from './DownloadButton';
|
|
3
|
+
import { DownloadButton, FileSizeIndicator, PlayButton, ProgressBar } from './components';
|
|
6
4
|
import { useAudioController } from './hooks/useAudioController';
|
|
7
5
|
import { useChatContext } from '../../context/ChatContext';
|
|
8
6
|
var AudioV1 = function (_a) {
|
|
@@ -27,17 +25,6 @@ var AudioV1 = function (_a) {
|
|
|
27
25
|
React.createElement("div", { className: 'str-chat__audio__content--progress' },
|
|
28
26
|
React.createElement("div", { "data-progress": progress, "data-testid": 'audio-progress', role: 'progressbar', style: { width: "".concat(progress, "%") } }))))));
|
|
29
27
|
};
|
|
30
|
-
export var PlayButton = function (_a) {
|
|
31
|
-
var isPlaying = _a.isPlaying, onClick = _a.onClick;
|
|
32
|
-
return (React.createElement("button", { className: 'str-chat__message-attachment-audio-widget--play-button', "data-testid": isPlaying ? 'pause-audio' : 'play-audio', onClick: onClick }, isPlaying ? React.createElement(PauseIcon, null) : React.createElement(PlayTriangleIcon, null)));
|
|
33
|
-
};
|
|
34
|
-
export var ProgressBar = function (_a) {
|
|
35
|
-
var onClick = _a.onClick, progress = _a.progress;
|
|
36
|
-
return (React.createElement("div", { className: 'str-chat__message-attachment-audio-widget--progress-track', "data-progress": progress, "data-testid": 'audio-progress', onClick: onClick, role: 'progressbar', style: {
|
|
37
|
-
background: "linear-gradient(\n\t\t to right,\n\t\t var(--str-chat__primary-color),\n\t\t var(--str-chat__primary-color) ".concat(progress, "%,\n\t\t var(--str-chat__disabled-color) ").concat(progress, "%,\n\t\t var(--str-chat__disabled-color)\n\t )"),
|
|
38
|
-
} },
|
|
39
|
-
React.createElement("div", { className: 'str-chat__message-attachment-audio-widget--progress-slider', style: { left: "".concat(progress, "px") } })));
|
|
40
|
-
};
|
|
41
28
|
var AudioV2 = function (_a) {
|
|
42
29
|
var og = _a.og;
|
|
43
30
|
var asset_url = og.asset_url, file_size = og.file_size, title = og.title;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAWrC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA2MrD,eAAO,MAAM,SAAS,gFAEnB,UAAU,sBA8BZ,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAQ5D;;GAEG;AACH,eAAO,MAAM,IAAI,UATc,SAAS,sBAS+B,CAAC"}
|
|
@@ -2,9 +2,9 @@ import { __assign } from "tslib";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import ReactPlayer from 'react-player';
|
|
5
|
-
import { PlayButton, ProgressBar } from './Audio';
|
|
6
5
|
import { ImageComponent } from '../Gallery';
|
|
7
6
|
import { SafeAnchor } from '../SafeAnchor';
|
|
7
|
+
import { PlayButton, ProgressBar } from './components';
|
|
8
8
|
import { useAudioController } from './hooks/useAudioController';
|
|
9
9
|
import { useChatContext } from '../../context/ChatContext';
|
|
10
10
|
import { useChannelStateContext } from '../../context/ChannelStateContext';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileAttachment.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/FileAttachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"FileAttachment.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/FileAttachment.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,MAAM,mBAAmB,CAC7B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;CAC5C,CAAC;AAmDF,eAAO,MAAM,cAAc,mKAES,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FileIcon } from '../ReactFileUtilities';
|
|
3
|
-
import { DownloadButton } from './
|
|
4
|
-
import { FileSizeIndicator } from './FileSizeIndicator';
|
|
3
|
+
import { DownloadButton, FileSizeIndicator } from './components';
|
|
5
4
|
import { SafeAnchor } from '../SafeAnchor/SafeAnchor';
|
|
6
5
|
import { useChatContext } from '../../context/ChatContext';
|
|
7
6
|
var UnMemoizedFileAttachmentV1 = function (_a) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Attachment } from 'stream-chat';
|
|
3
|
+
import type { DefaultStreamChatGenerics } from '../../types';
|
|
4
|
+
export type VoiceRecordingPlayerProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<VoiceRecordingProps<StreamChatGenerics>, 'attachment'> & {
|
|
5
|
+
/** An array of fractional numeric values of playback speed to override the defaults (1.0, 1.5, 2.0) */
|
|
6
|
+
playbackRates?: number[];
|
|
7
|
+
};
|
|
8
|
+
export declare const VoiceRecordingPlayer: ({ attachment, playbackRates }: VoiceRecordingPlayerProps) => React.JSX.Element | null;
|
|
9
|
+
export type QuotedVoiceRecordingProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Pick<VoiceRecordingProps<StreamChatGenerics>, 'attachment'>;
|
|
10
|
+
export declare const QuotedVoiceRecording: ({ attachment }: QuotedVoiceRecordingProps) => React.JSX.Element;
|
|
11
|
+
export type VoiceRecordingProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
|
|
12
|
+
/** The attachment object from the message's attachment list. */
|
|
13
|
+
attachment: Attachment<StreamChatGenerics>;
|
|
14
|
+
/** A boolean flag to signal whether the attachment will be rendered inside the quoted reply. */
|
|
15
|
+
isQuoted?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const VoiceRecording: ({ attachment, isQuoted }: VoiceRecordingProps) => React.JSX.Element;
|
|
18
|
+
//# sourceMappingURL=VoiceRecording.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceRecording.d.ts","sourceRoot":"","sources":["../../../src/components/Attachment/VoiceRecording.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQ9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAI7D,MAAM,MAAM,yBAAyB,CACnC,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,YAAY,CAAC,GAAG;IAChE,uGAAuG;IACvG,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,kCAAmC,yBAAyB,6BA8D5F,CAAC;AAEF,MAAM,MAAM,yBAAyB,CACnC,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,YAAY,CAAC,CAAC;AAEhE,eAAO,MAAM,oBAAoB,mBAAoB,yBAAyB,sBA4B7E,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAC7B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,gEAAgE;IAChE,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC3C,gGAAgG;IAChG,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,cAAc,6BAA8B,mBAAmB,sBAKzE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FileSizeIndicator, PlaybackRateButton, PlayButton, WaveProgressBar } from './components';
|
|
3
|
+
import { useAudioController } from './hooks/useAudioController';
|
|
4
|
+
import { displayDuration } from './utils';
|
|
5
|
+
import { FileIcon } from '../ReactFileUtilities';
|
|
6
|
+
import { useTranslationContext } from '../../context';
|
|
7
|
+
var rootClassName = 'str-chat__message-attachment__voice-recording-widget';
|
|
8
|
+
export var VoiceRecordingPlayer = function (_a) {
|
|
9
|
+
var attachment = _a.attachment, playbackRates = _a.playbackRates;
|
|
10
|
+
var t = useTranslationContext('VoiceRecordingPlayer').t;
|
|
11
|
+
var asset_url = attachment.asset_url, duration = attachment.duration, mime_type = attachment.mime_type, _b = attachment.title, title = _b === void 0 ? t('Voice message') : _b, waveform_data = attachment.waveform_data;
|
|
12
|
+
var _c = useAudioController({
|
|
13
|
+
durationSeconds: duration !== null && duration !== void 0 ? duration : 0,
|
|
14
|
+
playbackRates: playbackRates,
|
|
15
|
+
}), audioRef = _c.audioRef, increasePlaybackRate = _c.increasePlaybackRate, isPlaying = _c.isPlaying, playbackRate = _c.playbackRate, progress = _c.progress, secondsElapsed = _c.secondsElapsed, seek = _c.seek, togglePlay = _c.togglePlay;
|
|
16
|
+
if (!asset_url)
|
|
17
|
+
return null;
|
|
18
|
+
return (React.createElement("div", { className: rootClassName, "data-testid": 'voice-recording-widget' },
|
|
19
|
+
React.createElement("audio", { ref: audioRef },
|
|
20
|
+
React.createElement("source", { "data-testid": 'audio-source', src: asset_url, type: mime_type })),
|
|
21
|
+
React.createElement(PlayButton, { isPlaying: isPlaying, onClick: togglePlay }),
|
|
22
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__metadata' },
|
|
23
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__title', "data-testid": 'voice-recording-title', title: title }, title),
|
|
24
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__audio-state' },
|
|
25
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__timer' }, attachment.duration ? (displayDuration(secondsElapsed)) : (React.createElement(FileSizeIndicator, { fileSize: attachment.file_size, maximumFractionDigits: 0 }))),
|
|
26
|
+
React.createElement(WaveProgressBar, { progress: progress, seek: seek, waveformData: waveform_data || [] }))),
|
|
27
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__right-section' }, isPlaying ? (React.createElement(PlaybackRateButton, { disabled: !audioRef.current, onClick: increasePlaybackRate },
|
|
28
|
+
playbackRate.toFixed(1),
|
|
29
|
+
"x")) : (React.createElement(FileIcon, { big: true, mimeType: mime_type, size: 40, version: '2' })))));
|
|
30
|
+
};
|
|
31
|
+
export var QuotedVoiceRecording = function (_a) {
|
|
32
|
+
var attachment = _a.attachment;
|
|
33
|
+
var t = useTranslationContext().t;
|
|
34
|
+
var title = attachment.title || t('Voice message');
|
|
35
|
+
return (React.createElement("div", { className: rootClassName, "data-testid": 'quoted-voice-recording-widget' },
|
|
36
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__metadata' },
|
|
37
|
+
title && (React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__title', "data-testid": 'voice-recording-title', title: title }, title)),
|
|
38
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__audio-state' },
|
|
39
|
+
React.createElement("div", { className: 'str-chat__message-attachment__voice-recording-widget__timer' }, attachment.duration ? (displayDuration(attachment.duration)) : (React.createElement(FileSizeIndicator, { fileSize: attachment.file_size, maximumFractionDigits: 0 }))))),
|
|
40
|
+
React.createElement(FileIcon, { big: true, mimeType: attachment.mime_type, size: 34, version: '2' })));
|
|
41
|
+
};
|
|
42
|
+
export var VoiceRecording = function (_a) {
|
|
43
|
+
var attachment = _a.attachment, isQuoted = _a.isQuoted;
|
|
44
|
+
return isQuoted ? (React.createElement(QuotedVoiceRecording, { attachment: attachment })) : (React.createElement(VoiceRecordingPlayer, { attachment: attachment }));
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/components/DownloadButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,cAAc,iBAAkB,mBAAmB,sBAS/D,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DownloadIcon } from '
|
|
3
|
-
import { SafeAnchor } from '
|
|
2
|
+
import { DownloadIcon } from '../icons';
|
|
3
|
+
import { SafeAnchor } from '../../SafeAnchor';
|
|
4
4
|
export var DownloadButton = function (_a) {
|
|
5
5
|
var assetUrl = _a.assetUrl;
|
|
6
6
|
return (React.createElement(SafeAnchor, { className: 'str-chat__message-attachment-file--item-download', download: true, href: assetUrl, target: '_blank' },
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type FileSizeIndicatorProps = {
|
|
3
|
+
/** file size in byte */
|
|
4
|
+
fileSize?: number;
|
|
5
|
+
/**
|
|
6
|
+
The maximum number of fraction digits to display. If not set, the default behavior is to round to 3 significant digits.
|
|
7
|
+
@default undefined
|
|
8
|
+
*/
|
|
9
|
+
maximumFractionDigits?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const FileSizeIndicator: ({ fileSize, maximumFractionDigits }: FileSizeIndicatorProps) => React.JSX.Element | null;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=FileSizeIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileSizeIndicator.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/components/FileSizeIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,KAAK,sBAAsB,GAAG;IAC5B,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,iBAAiB,wCAAyC,sBAAsB,6BAW5F,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import prettybytes from 'pretty-bytes';
|
|
3
3
|
export var FileSizeIndicator = function (_a) {
|
|
4
|
-
var fileSize = _a.fileSize;
|
|
4
|
+
var fileSize = _a.fileSize, maximumFractionDigits = _a.maximumFractionDigits;
|
|
5
5
|
if (!(fileSize && Number.isFinite(Number(fileSize))))
|
|
6
6
|
return null;
|
|
7
|
-
return (React.createElement("span", { className: 'str-chat__message-attachment-file--item-size' }, prettybytes(fileSize)));
|
|
7
|
+
return (React.createElement("span", { className: 'str-chat__message-attachment-file--item-size', "data-testid": 'file-size-indicator' }, prettybytes(fileSize, { maximumFractionDigits: maximumFractionDigits })));
|
|
8
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlayButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/components/PlayButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,KAAK,eAAe,GAAG;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,UAAU,2BAA4B,eAAe,sBAQjE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PauseIcon, PlayTriangleIcon } from '../icons';
|
|
3
|
+
export var PlayButton = function (_a) {
|
|
4
|
+
var isPlaying = _a.isPlaying, onClick = _a.onClick;
|
|
5
|
+
return (React.createElement("button", { className: 'str-chat__message-attachment-audio-widget--play-button', "data-testid": isPlaying ? 'pause-audio' : 'play-audio', onClick: onClick }, isPlaying ? React.createElement(PauseIcon, null) : React.createElement(PlayTriangleIcon, null)));
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaybackRateButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/components/PlaybackRateButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,uBAAuB,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AAErE,eAAO,MAAM,kBAAkB,0BAA2B,uBAAuB,sBAQhF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var PlaybackRateButton = function (_a) {
|
|
3
|
+
var children = _a.children, onClick = _a.onClick;
|
|
4
|
+
return (React.createElement("button", { className: 'str-chat__message_attachment__playback-rate-button', "data-testid": 'playback-rate-button', onClick: onClick }, children));
|
|
5
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type ProgressBarProps = {
|
|
3
|
+
/** Progress expressed in fractional number value btw 0 and 100. */
|
|
4
|
+
progress: number;
|
|
5
|
+
} & Pick<React.ComponentProps<'div'>, 'onClick'>;
|
|
6
|
+
export declare const ProgressBar: ({ onClick, progress }: ProgressBarProps) => React.JSX.Element;
|
|
7
|
+
//# sourceMappingURL=ProgressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/components/ProgressBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;AAEjD,eAAO,MAAM,WAAW,0BAA2B,gBAAgB,sBAkBlE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var ProgressBar = function (_a) {
|
|
3
|
+
var onClick = _a.onClick, progress = _a.progress;
|
|
4
|
+
return (React.createElement("div", { className: 'str-chat__message-attachment-audio-widget--progress-track', "data-progress": progress, "data-testid": 'audio-progress', onClick: onClick, role: 'progressbar', style: {
|
|
5
|
+
'--str-chat__message-attachment-audio-widget-progress': progress + '%',
|
|
6
|
+
} },
|
|
7
|
+
React.createElement("div", { className: 'str-chat__message-attachment-audio-widget--progress-slider', style: { left: "".concat(progress, "px") } })));
|
|
8
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { MouseEventHandler } from 'react';
|
|
2
|
+
type WaveProgressBarProps = {
|
|
3
|
+
/** Function that allows to change the track progress */
|
|
4
|
+
seek: MouseEventHandler<HTMLDivElement>;
|
|
5
|
+
/** The array of fractional number values between 0 and 1 representing the height of amplitudes */
|
|
6
|
+
waveformData: number[];
|
|
7
|
+
/** Allows to specify the number of bars into which the original waveformData array should be resampled */
|
|
8
|
+
amplitudesCount?: number;
|
|
9
|
+
/** Progress expressed in fractional number value btw 0 and 100. */
|
|
10
|
+
progress?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const WaveProgressBar: ({ amplitudesCount, progress, seek, waveformData, }: WaveProgressBarProps) => React.JSX.Element | null;
|
|
13
|
+
/**
|
|
14
|
+
* The downSample function uses the Largest-Triangle-Three-Buckets (LTTB) algorithm.
|
|
15
|
+
* See the thesis Downsampling Time Series for Visual Representation by Sveinn Steinarsson for more (https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf)
|
|
16
|
+
* @param data
|
|
17
|
+
* @param targetOutputSize
|
|
18
|
+
*/
|
|
19
|
+
export declare function downSample(data: number[], targetOutputSize: number): number[];
|
|
20
|
+
export declare const upSample: (values: number[], targetSize: number) => number[];
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=WaveProgressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaveProgressBar.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/components/WaveProgressBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAI5E,KAAK,oBAAoB,GAAG;IAC1B,wDAAwD;IACxD,IAAI,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACxC,kGAAkG;IAClG,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,0GAA0G;IAC1G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,eAAO,MAAM,eAAe,uDAKzB,oBAAoB,6BAqEtB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,CAoD7E;AAoBD,eAAO,MAAM,QAAQ,WAAY,MAAM,EAAE,cAAc,MAAM,aAsB5D,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { divMod } from '../utils';
|
|
4
|
+
export var WaveProgressBar = function (_a) {
|
|
5
|
+
var _b = _a.amplitudesCount, amplitudesCount = _b === void 0 ? 40 : _b, _c = _a.progress, progress = _c === void 0 ? 0 : _c, seek = _a.seek, waveformData = _a.waveformData;
|
|
6
|
+
var _d = useState(null), progressIndicator = _d[0], setProgressIndicator = _d[1];
|
|
7
|
+
var isDragging = useRef(false);
|
|
8
|
+
var handleMouseDown = function () {
|
|
9
|
+
if (!progressIndicator)
|
|
10
|
+
return;
|
|
11
|
+
isDragging.current = true;
|
|
12
|
+
progressIndicator.style.cursor = 'grabbing';
|
|
13
|
+
};
|
|
14
|
+
var handleMouseMove = function (event) {
|
|
15
|
+
if (!isDragging.current)
|
|
16
|
+
return;
|
|
17
|
+
seek(event);
|
|
18
|
+
};
|
|
19
|
+
var handleMouseUp = function () {
|
|
20
|
+
if (!progressIndicator)
|
|
21
|
+
return;
|
|
22
|
+
isDragging.current = false;
|
|
23
|
+
progressIndicator.style.removeProperty('cursor');
|
|
24
|
+
};
|
|
25
|
+
var resampledWaveformData = useMemo(function () {
|
|
26
|
+
return waveformData.length === amplitudesCount
|
|
27
|
+
? waveformData
|
|
28
|
+
: waveformData.length > amplitudesCount
|
|
29
|
+
? downSample(waveformData, amplitudesCount)
|
|
30
|
+
: upSample(waveformData, amplitudesCount);
|
|
31
|
+
}, [amplitudesCount, waveformData]);
|
|
32
|
+
if (!waveformData.length)
|
|
33
|
+
return null;
|
|
34
|
+
return (React.createElement("div", { className: 'str-chat__wave-progress-bar__track', "data-testid": 'wave-progress-bar-track', onClick: seek, onMouseDown: handleMouseDown, onMouseLeave: handleMouseUp, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, role: 'progressbar' },
|
|
35
|
+
resampledWaveformData.map(function (amplitude, i) {
|
|
36
|
+
var _a;
|
|
37
|
+
return (React.createElement("div", { className: clsx('str-chat__wave-progress-bar__amplitude-bar', (_a = {},
|
|
38
|
+
_a['str-chat__wave-progress-bar__amplitude-bar--active'] = progress > (i / resampledWaveformData.length) * 100,
|
|
39
|
+
_a)), "data-testid": 'amplitude-bar', key: "amplitude-".concat(i), style: {
|
|
40
|
+
'--str-chat__wave-progress-bar__amplitude-bar-height': amplitude
|
|
41
|
+
? amplitude * 100 + '%'
|
|
42
|
+
: '0%',
|
|
43
|
+
} }));
|
|
44
|
+
}),
|
|
45
|
+
React.createElement("div", { className: 'str-chat__wave-progress-bar__progress-indicator', "data-testid": 'wave-progress-bar-progress-indicator', ref: setProgressIndicator, style: { left: "".concat(progress < 0 ? 0 : progress > 100 ? 100 : progress, "%") } })));
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The downSample function uses the Largest-Triangle-Three-Buckets (LTTB) algorithm.
|
|
49
|
+
* See the thesis Downsampling Time Series for Visual Representation by Sveinn Steinarsson for more (https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf)
|
|
50
|
+
* @param data
|
|
51
|
+
* @param targetOutputSize
|
|
52
|
+
*/
|
|
53
|
+
export function downSample(data, targetOutputSize) {
|
|
54
|
+
if (data.length <= targetOutputSize || targetOutputSize === 0) {
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
if (targetOutputSize === 1)
|
|
58
|
+
return [mean(data)];
|
|
59
|
+
var result = [];
|
|
60
|
+
// bucket size adjusted due to the fact that the first and the last item in the original data array is kept in target output
|
|
61
|
+
var bucketSize = (data.length - 2) / (targetOutputSize - 2);
|
|
62
|
+
var lastSelectedPointIndex = 0;
|
|
63
|
+
result.push(data[lastSelectedPointIndex]); // Always add the first point
|
|
64
|
+
var maxAreaPoint, maxArea, triangleArea;
|
|
65
|
+
for (var bucketIndex = 1; bucketIndex < targetOutputSize - 1; bucketIndex++) {
|
|
66
|
+
var previousBucketRefPoint = data[lastSelectedPointIndex];
|
|
67
|
+
var nextBucketMean = getNextBucketMean(data, bucketIndex, bucketSize);
|
|
68
|
+
var currentBucketStartIndex = Math.floor((bucketIndex - 1) * bucketSize) + 1;
|
|
69
|
+
var nextBucketStartIndex = Math.floor(bucketIndex * bucketSize) + 1;
|
|
70
|
+
var countUnitsBetweenAtoC = 1 + nextBucketStartIndex - currentBucketStartIndex;
|
|
71
|
+
maxArea = triangleArea = -1;
|
|
72
|
+
for (var currentPointIndex = currentBucketStartIndex; currentPointIndex < nextBucketStartIndex; currentPointIndex++) {
|
|
73
|
+
var countUnitsBetweenAtoB = Math.abs(currentPointIndex - currentBucketStartIndex) + 1;
|
|
74
|
+
var countUnitsBetweenBtoC = countUnitsBetweenAtoC - countUnitsBetweenAtoB;
|
|
75
|
+
var currentPointValue = data[currentPointIndex];
|
|
76
|
+
triangleArea = triangleAreaHeron(triangleBase(Math.abs(previousBucketRefPoint - currentPointValue), countUnitsBetweenAtoB), triangleBase(Math.abs(currentPointValue - nextBucketMean), countUnitsBetweenBtoC), triangleBase(Math.abs(previousBucketRefPoint - nextBucketMean), countUnitsBetweenAtoC));
|
|
77
|
+
if (triangleArea > maxArea) {
|
|
78
|
+
maxArea = triangleArea;
|
|
79
|
+
maxAreaPoint = data[currentPointIndex];
|
|
80
|
+
lastSelectedPointIndex = currentPointIndex;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (typeof maxAreaPoint !== 'undefined')
|
|
84
|
+
result.push(maxAreaPoint);
|
|
85
|
+
}
|
|
86
|
+
result.push(data[data.length - 1]); // Always add the last point
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
var triangleAreaHeron = function (a, b, c) {
|
|
90
|
+
var s = (a + b + c) / 2;
|
|
91
|
+
return Math.sqrt(s * (s - a) * (s - b) * (s - c));
|
|
92
|
+
};
|
|
93
|
+
var triangleBase = function (a, b) { return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); };
|
|
94
|
+
var mean = function (values) { return values.reduce(function (acc, value) { return acc + value; }, 0) / values.length; };
|
|
95
|
+
var getNextBucketMean = function (data, currentBucketIndex, bucketSize) {
|
|
96
|
+
var nextBucketStartIndex = Math.floor(currentBucketIndex * bucketSize) + 1;
|
|
97
|
+
var nextNextBucketStartIndex = Math.floor((currentBucketIndex + 1) * bucketSize) + 1;
|
|
98
|
+
nextNextBucketStartIndex =
|
|
99
|
+
nextNextBucketStartIndex < data.length ? nextNextBucketStartIndex : data.length;
|
|
100
|
+
return mean(data.slice(nextBucketStartIndex, nextNextBucketStartIndex));
|
|
101
|
+
};
|
|
102
|
+
export var upSample = function (values, targetSize) {
|
|
103
|
+
if (!values.length) {
|
|
104
|
+
console.warn('Cannot extend empty array of amplitudes.');
|
|
105
|
+
return values;
|
|
106
|
+
}
|
|
107
|
+
if (values.length > targetSize) {
|
|
108
|
+
console.warn('Requested to extend the waveformData that is longer than the target list size');
|
|
109
|
+
return values;
|
|
110
|
+
}
|
|
111
|
+
if (targetSize === values.length)
|
|
112
|
+
return values;
|
|
113
|
+
// eslint-disable-next-line prefer-const
|
|
114
|
+
var _a = divMod(targetSize, values.length), bucketSize = _a[0], remainder = _a[1];
|
|
115
|
+
var result = [];
|
|
116
|
+
for (var i = 0; i < values.length; i++) {
|
|
117
|
+
var extra = remainder && remainder-- ? 1 : 0;
|
|
118
|
+
result.push.apply(result, Array(bucketSize + extra).fill(values[i]));
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
1
|
+
export declare const elementIsPlaying: (audioElement: HTMLAudioElement | null) => boolean | null;
|
|
2
|
+
type AudioControllerParams = {
|
|
3
|
+
/** Audio duration in seconds. */
|
|
4
|
+
durationSeconds?: number;
|
|
5
|
+
/** An array of fractional numeric values of playback speed to override the defaults (1.0, 1.5, 2.0) */
|
|
6
|
+
playbackRates?: number[];
|
|
7
|
+
};
|
|
8
|
+
export declare const useAudioController: ({ durationSeconds, playbackRates, }?: AudioControllerParams) => {
|
|
3
9
|
audioRef: import("react").MutableRefObject<HTMLAudioElement | null>;
|
|
10
|
+
increasePlaybackRate: () => void;
|
|
4
11
|
isPlaying: boolean;
|
|
12
|
+
playbackRate: number;
|
|
5
13
|
progress: number;
|
|
14
|
+
secondsElapsed: number;
|
|
6
15
|
seek: import("react").MouseEventHandler<HTMLDivElement>;
|
|
7
16
|
togglePlay: () => void;
|
|
8
17
|
};
|
|
18
|
+
export {};
|
|
9
19
|
//# sourceMappingURL=useAudioController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAudioController.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/hooks/useAudioController.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAudioController.d.ts","sourceRoot":"","sources":["../../../../src/components/Attachment/hooks/useAudioController.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,iBAAkB,gBAAgB,GAAG,IAAI,mBACR,CAAC;AAI/D,KAAK,qBAAqB,GAAG;IAC3B,iCAAiC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uGAAuG;IACvG,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,yCAG5B,qBAAqB;;;;;;;;;CAmFvB,CAAC"}
|