stream-chat-angular 5.4.3 → 5.5.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.
@@ -1,17 +1,19 @@
1
- import { EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
1
+ import { EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
2
2
  import { Action, Attachment } from 'stream-chat';
3
- import { ModalContext, DefaultStreamChatGenerics, AttachmentConfigration, VideoAttachmentConfiguration, ImageAttachmentConfiguration, AttachmentContext } from '../types';
3
+ import { ModalContext, DefaultStreamChatGenerics, AttachmentConfigration, VideoAttachmentConfiguration, ImageAttachmentConfiguration, AttachmentContext, CustomAttachmentListContext } from '../types';
4
4
  import { ChannelService } from '../channel.service';
5
5
  import { CustomTemplatesService } from '../custom-templates.service';
6
6
  import { AttachmentConfigurationService } from '../attachment-configuration.service';
7
+ import { MessageService } from '../message.service';
7
8
  import * as i0 from "@angular/core";
8
9
  /**
9
10
  * The `AttachmentList` component displays the attachments of a message
10
11
  */
11
- export declare class AttachmentListComponent implements OnChanges {
12
+ export declare class AttachmentListComponent implements OnChanges, OnInit, OnDestroy {
12
13
  readonly customTemplatesService: CustomTemplatesService;
13
14
  private channelService;
14
15
  private attachmentConfigurationService;
16
+ private messageService;
15
17
  /**
16
18
  * The id of the message the attachments belong to
17
19
  */
@@ -30,12 +32,17 @@ export declare class AttachmentListComponent implements OnChanges {
30
32
  readonly imageModalStateChange: EventEmitter<"closed" | "opened">;
31
33
  class: string;
32
34
  orderedAttachments: Attachment<DefaultStreamChatGenerics>[];
35
+ customAttachments: Attachment<DefaultStreamChatGenerics>[];
33
36
  imagesToView: Attachment<DefaultStreamChatGenerics>[];
34
37
  imagesToViewCurrentIndex: number;
38
+ customAttachmentsTemplate?: TemplateRef<CustomAttachmentListContext>;
35
39
  private modalContent;
36
40
  private attachmentConfigurations;
37
- constructor(customTemplatesService: CustomTemplatesService, channelService: ChannelService, attachmentConfigurationService: AttachmentConfigurationService);
41
+ private subscriptions;
42
+ constructor(customTemplatesService: CustomTemplatesService, channelService: ChannelService, attachmentConfigurationService: AttachmentConfigurationService, messageService: MessageService);
43
+ ngOnInit(): void;
38
44
  ngOnChanges(changes: SimpleChanges): void;
45
+ ngOnDestroy(): void;
39
46
  trackByUrl(_: number, attachment: Attachment): {} | undefined;
40
47
  isImage(attachment: Attachment): boolean;
41
48
  isSvg(attachment: Attachment): boolean;
@@ -1,11 +1,16 @@
1
- import { EventEmitter } from '@angular/core';
1
+ import { EventEmitter, OnDestroy, OnInit, TemplateRef } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
- import { AttachmentUpload } from '../types';
3
+ import { AttachmentUpload, CustomAttachmentPreviewListContext } from '../types';
4
+ import { CustomTemplatesService } from '../custom-templates.service';
5
+ import { AttachmentService } from '../attachment.service';
6
+ import { Attachment } from 'stream-chat';
4
7
  import * as i0 from "@angular/core";
5
8
  /**
6
9
  * The `AttachmentPreviewList` component displays a preview of the attachments uploaded to a message. Users can delete attachments using the preview component, or retry upload if it failed previously.
7
10
  */
8
- export declare class AttachmentPreviewListComponent {
11
+ export declare class AttachmentPreviewListComponent implements OnInit, OnDestroy {
12
+ private customTemplateService;
13
+ readonly attachmentService: AttachmentService;
9
14
  /**
10
15
  * A stream that emits the current file uploads and their states
11
16
  */
@@ -18,7 +23,12 @@ export declare class AttachmentPreviewListComponent {
18
23
  * An output to notify the parent component if the user wants to delete a file
19
24
  */
20
25
  readonly deleteAttachment: EventEmitter<AttachmentUpload<import("../types").DefaultStreamChatGenerics>>;
21
- constructor();
26
+ customAttachments: Attachment[];
27
+ customAttachmentsPreview?: TemplateRef<CustomAttachmentPreviewListContext>;
28
+ private subscriptions;
29
+ constructor(customTemplateService: CustomTemplatesService, attachmentService: AttachmentService);
30
+ ngOnInit(): void;
31
+ ngOnDestroy(): void;
22
32
  attachmentUploadRetried(file: File): void;
23
33
  attachmentDeleted(upload: AttachmentUpload): void;
24
34
  trackByFile(_: number, item: AttachmentUpload): File;
@@ -1,9 +1,10 @@
1
- import { Observable } from 'rxjs';
1
+ import { BehaviorSubject, Observable } from 'rxjs';
2
2
  import { Attachment } from 'stream-chat';
3
3
  import { ChannelService } from './channel.service';
4
4
  import { NotificationService } from './notification.service';
5
5
  import { AttachmentUpload, AudioRecording, DefaultStreamChatGenerics } from './types';
6
6
  import { ChatClientService } from './chat-client.service';
7
+ import { MessageService } from './message.service';
7
8
  import * as i0 from "@angular/core";
8
9
  /**
9
10
  * The `AttachmentService` manages the uploads of a message input.
@@ -14,18 +15,28 @@ export declare class AttachmentService<T extends DefaultStreamChatGenerics = Def
14
15
  private channelService;
15
16
  private notificationService;
16
17
  private chatClientService;
18
+ private messageService;
17
19
  /**
18
20
  * Emits the number of uploads in progress.
21
+ *
22
+ * You can increment and decrement this counter if you're using custom attachments and want to disable message sending until all attachments are uploaded.
23
+ *
24
+ * The SDK will handle updating this counter for built-in attachments, but for custom attachments you should take care of this.
19
25
  */
20
- attachmentUploadInProgressCounter$: Observable<number>;
26
+ attachmentUploadInProgressCounter$: BehaviorSubject<number>;
21
27
  /**
22
28
  * Emits the state of the uploads ([`AttachmentUpload[]`](https://github.com/GetStream/stream-chat-angular/blob/master/projects/stream-chat-angular/src/lib/types.ts)), it adds a state (`success`, `error` or `uploading`) to each file the user selects for upload. It is used by the [`AttachmentPreviewList`](../components/AttachmentPreviewListComponent.mdx) to display the attachment previews.
23
29
  */
24
30
  attachmentUploads$: Observable<AttachmentUpload[]>;
25
- private attachmentUploadInProgressCounterSubject;
31
+ /**
32
+ * You can get and set the list if uploaded custom attachments
33
+ *
34
+ * By default the SDK components won't display these, but you can provide your own `customAttachmentPreviewListTemplate$` and `customAttachmentListTemplate$` for the [`CustomTemplatesService`](../../services/CustomTemplatesService).
35
+ */
36
+ customAttachments$: BehaviorSubject<Attachment<T>[]>;
26
37
  private attachmentUploadsSubject;
27
38
  private appSettings;
28
- constructor(channelService: ChannelService, notificationService: NotificationService, chatClientService: ChatClientService);
39
+ constructor(channelService: ChannelService, notificationService: NotificationService, chatClientService: ChatClientService, messageService: MessageService);
29
40
  /**
30
41
  * Resets the attachments uploads (for example after the message with the attachments sent successfully)
31
42
  */
@@ -1,6 +1,6 @@
1
1
  import { TemplateRef } from '@angular/core';
2
2
  import { BehaviorSubject } from 'rxjs';
3
- import { AttachmentContext, AttachmentListContext, AttachmentPreviewListContext, AvatarContext, ChannelActionsContext, ChannelHeaderInfoContext, ChannelPreviewContext, ChannelPreviewInfoContext, CommandAutocompleteListItemContext, CustomAttachmentUploadContext, CustomMetadataContext, DateSeparatorContext, DefaultStreamChatGenerics, DeliveredStatusContext, EmojiPickerContext, IconContext, MentionAutcompleteListItemContext, MentionTemplateContext, MessageActionBoxItemContext, MessageActionsBoxContext, MessageContext, MessageReactionsContext, MessageReactionsSelectorContext, ModalContext, NotificationContext, ReadStatusContext, SendingStatusContext, SystemMessageContext, ThreadHeaderContext, TypingIndicatorContext, UnreadMessagesIndicatorContext, UnreadMessagesNotificationContext } from './types';
3
+ import { AttachmentContext, AttachmentListContext, AttachmentPreviewListContext, AvatarContext, ChannelActionsContext, ChannelHeaderInfoContext, ChannelPreviewContext, ChannelPreviewInfoContext, CommandAutocompleteListItemContext, CustomAttachmentListContext, CustomAttachmentPreviewListContext, CustomAttachmentUploadContext, CustomMetadataContext, DateSeparatorContext, DefaultStreamChatGenerics, DeliveredStatusContext, EmojiPickerContext, IconContext, MentionAutcompleteListItemContext, MentionTemplateContext, MessageActionBoxItemContext, MessageActionsBoxContext, MessageContext, MessageReactionsContext, MessageReactionsSelectorContext, ModalContext, NotificationContext, ReadStatusContext, SendingStatusContext, SystemMessageContext, ThreadHeaderContext, TypingIndicatorContext, UnreadMessagesIndicatorContext, UnreadMessagesNotificationContext } from './types';
4
4
  import * as i0 from "@angular/core";
5
5
  /**
6
6
  * A central location for registering your custom templates to override parts of the chat application.
@@ -209,6 +209,14 @@ export declare class CustomTemplatesService<T extends DefaultStreamChatGenerics
209
209
  *
210
210
  */
211
211
  channelPreviewInfoTemplate$: BehaviorSubject<TemplateRef<ChannelPreviewInfoContext<DefaultStreamChatGenerics>> | undefined>;
212
+ /**
213
+ * The template used to display custom attachment previews in the [message input component](../../components/MessageInputComponent.mdx)
214
+ */
215
+ customAttachmentPreviewListTemplate$: BehaviorSubject<TemplateRef<CustomAttachmentPreviewListContext<DefaultStreamChatGenerics>> | undefined>;
216
+ /**
217
+ * The template used to display custom attachments in the [message component](../../components/MessageComponent.mdx)
218
+ */
219
+ customAttachmentListTemplate$: BehaviorSubject<TemplateRef<CustomAttachmentListContext<DefaultStreamChatGenerics>> | undefined>;
212
220
  constructor();
213
221
  static ɵfac: i0.ɵɵFactoryDeclaration<CustomTemplatesService<any>, never>;
214
222
  static ɵprov: i0.ɵɵInjectableDeclaration<CustomTemplatesService<any>>;
@@ -1,6 +1,6 @@
1
1
  import { AfterViewInit, ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef, Type } from '@angular/core';
2
2
  import { Observable, Subject } from 'rxjs';
3
- import { UserResponse } from 'stream-chat';
3
+ import { Attachment, UserResponse } from 'stream-chat';
4
4
  import { AttachmentService } from '../attachment.service';
5
5
  import { ChannelService } from '../channel.service';
6
6
  import { NotificationService } from '../notification.service';
@@ -94,6 +94,7 @@ export declare class MessageInputComponent implements OnInit, OnChanges, OnDestr
94
94
  canSendLinks: boolean | undefined;
95
95
  canSendMessages: boolean | undefined;
96
96
  attachmentUploads$: Observable<AttachmentUpload[]>;
97
+ customAttachments$: Observable<Attachment[]>;
97
98
  attachmentUploadInProgressCounter$: Observable<number>;
98
99
  textareaValue: string;
99
100
  textareaRef: ComponentRef<TextareaInterface & Partial<OnChanges>> | undefined;
@@ -124,11 +125,11 @@ export declare class MessageInputComponent implements OnInit, OnChanges, OnDestr
124
125
  ngOnDestroy(): void;
125
126
  messageSent(): Promise<void>;
126
127
  get containsLinks(): boolean;
127
- get quotedMessageAttachments(): import("stream-chat").Attachment<{
128
+ get quotedMessageAttachments(): Attachment<{
128
129
  attachmentType: import("stream-chat").UR & import("../types").UnknownType & {
129
130
  asset_url?: string | undefined;
130
131
  id?: string | undefined;
131
- images?: import("stream-chat").Attachment<DefaultStreamChatGenerics>[] | undefined;
132
+ images?: Attachment<DefaultStreamChatGenerics>[] | undefined;
132
133
  mime_type?: string | undefined;
133
134
  isCustomAttachment?: boolean | undefined;
134
135
  };
@@ -1,8 +1,10 @@
1
+ import { Attachment } from 'stream-chat';
2
+ import { DefaultStreamChatGenerics } from './types';
1
3
  import * as i0 from "@angular/core";
2
4
  /**
3
5
  * The message service contains configuration options related to displaying the message content
4
6
  */
5
- export declare class MessageService {
7
+ export declare class MessageService<T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> {
6
8
  /**
7
9
  * Decides if the message content should be formatted as text or HTML
8
10
  *
@@ -17,7 +19,21 @@ export declare class MessageService {
17
19
  * @returns the HTML markup as a string for the link
18
20
  */
19
21
  customLinkRenderer?: (url: string) => string;
22
+ /**
23
+ * The SDK supports the following attachment types: `image`, `file`, `giphy`, `video` and `voiceRecording` attachments.
24
+ *
25
+ * All other types are treated as custom attachments, however it's possible to override this logic, and provide a custom filtering method which can be used to treat some built-in attachments as custom.
26
+ *
27
+ * Provide a method which retruns `true` if an attachment should be considered as custom.
28
+ */
29
+ filterCustomAttachment?: (attachment: Attachment<T>) => boolean;
20
30
  constructor();
21
- static ɵfac: i0.ɵɵFactoryDeclaration<MessageService, never>;
22
- static ɵprov: i0.ɵɵInjectableDeclaration<MessageService>;
31
+ /**
32
+ * Tells if an attachment is custom (you need to provide your own template to display them) or built-in (the SDK supports it out-of-the-box)
33
+ * @param attachment
34
+ * @returns `true` if the attachment is custom
35
+ */
36
+ isCustomAttachment(attachment: Attachment<T>): boolean;
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<MessageService<any>, never>;
38
+ static ɵprov: i0.ɵɵInjectableDeclaration<MessageService<any>>;
23
39
  }
package/lib/types.d.ts CHANGED
@@ -132,10 +132,12 @@ export declare type MessageContext = {
132
132
  export declare type ChannelActionsContext<T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
133
133
  channel: Channel<T>;
134
134
  };
135
- export declare type AttachmentListContext = {
135
+ export declare type CustomAttachmentListContext<T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
136
136
  messageId: string;
137
- attachments: Attachment<DefaultStreamChatGenerics>[];
137
+ attachments: Attachment<T>[];
138
138
  parentMessageId?: string;
139
+ };
140
+ export declare type AttachmentListContext = CustomAttachmentListContext & {
139
141
  imageModalStateChangeHandler?: (state: 'opened' | 'closed') => void;
140
142
  };
141
143
  export declare type AvatarType = 'channel' | 'user';
@@ -158,6 +160,7 @@ export declare type AttachmentPreviewListContext = {
158
160
  attachmentUploads$: Observable<AttachmentUpload[]> | undefined;
159
161
  retryUploadHandler: (f: File) => void;
160
162
  deleteUploadHandler: (u: AttachmentUpload) => void;
163
+ service: AttachmentService;
161
164
  };
162
165
  export declare type IconContext = {
163
166
  icon: Icon | undefined;
@@ -329,4 +332,7 @@ export declare type MediaRecording = {
329
332
  mime_type: string;
330
333
  asset_url: string | ArrayBuffer | undefined;
331
334
  };
335
+ export declare type CustomAttachmentPreviewListContext<T extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
336
+ attachmentService: AttachmentService<T>;
337
+ };
332
338
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat-angular",
3
- "version": "5.4.3",
3
+ "version": "5.5.0",
4
4
  "description": "Angular components to create chat conversations or livestream style chat",
5
5
  "author": "GetStream",
6
6
  "homepage": "https://getstream.io/chat/",
@@ -1 +1 @@
1
- export const version = '5.4.3';
1
+ export const version = '5.5.0';