@progress/kendo-angular-conversational-ui 4.0.0 → 5.0.0-next.202202241517

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.
Files changed (148) hide show
  1. package/{dist/es2015/api → api}/action.interface.d.ts +0 -0
  2. package/{dist/es2015/api → api}/attachment.interface.d.ts +0 -0
  3. package/{dist/es2015/api → api}/execute-action-event.d.ts +1 -1
  4. package/{dist/es/api/user.interface.js → api/index.d.ts} +6 -0
  5. package/{dist/es2015/api → api}/message.interface.d.ts +0 -0
  6. package/{dist/es2015/api → api}/post-message-event.d.ts +0 -0
  7. package/{dist/es2015/api → api}/preventable-event.d.ts +0 -0
  8. package/{dist/es2015/api → api}/user.interface.d.ts +0 -0
  9. package/bundles/kendo-angular-conversational-ui.umd.js +5 -0
  10. package/{dist/es2015/cards → cards}/hero-card.component.d.ts +3 -0
  11. package/{dist/es2015/chat → chat}/attachment-template.directive.d.ts +3 -0
  12. package/{dist/es2015/chat → chat}/attachment.component.d.ts +9 -5
  13. package/{dist/es2015/chat → chat}/builtin-actions.d.ts +0 -0
  14. package/{dist/es2015/chat → chat}/chat-item.d.ts +0 -0
  15. package/{dist/es2015/chat → chat}/chat-view.d.ts +1 -1
  16. package/{dist/es2015/chat → chat}/chat.component.d.ts +6 -6
  17. package/{dist/es2015/chat → chat}/chat.directives.d.ts +0 -0
  18. package/chat/chat.module.d.ts +47 -0
  19. package/{dist/es2015/chat → chat}/l10n/custom-messages.component.d.ts +4 -1
  20. package/{dist/es2015/chat → chat}/l10n/localized-messages.directive.d.ts +3 -0
  21. package/{dist/es2015/chat → chat}/l10n/messages.d.ts +3 -0
  22. package/{dist/es2015/chat → chat}/message-attachments.component.d.ts +5 -2
  23. package/{dist/es2015/chat → chat}/message-list.component.d.ts +8 -7
  24. package/{dist/es2015/chat → chat}/message-template.directive.d.ts +3 -0
  25. package/{dist/es2015/chat → chat}/message.component.d.ts +4 -1
  26. package/{dist/es2015/chat → chat}/suggested-actions.component.d.ts +4 -1
  27. package/common/focused-state.directive.d.ts +15 -0
  28. package/{dist/es2015/common → common}/keys.enum.d.ts +0 -0
  29. package/{dist/es2015/common → common}/scroll-anchor.directive.d.ts +3 -0
  30. package/{dist/es2015/common → common}/utils.d.ts +0 -0
  31. package/{dist/es2015 → esm2015}/api/action.interface.js +2 -1
  32. package/{dist/es2015 → esm2015}/api/attachment.interface.js +1 -0
  33. package/{dist/es2015 → esm2015}/api/execute-action-event.js +0 -0
  34. package/{dist/es/api/attachment.interface.js → esm2015/api/index.js} +6 -0
  35. package/{dist/es → esm2015}/api/message.interface.js +1 -0
  36. package/{dist/es2015 → esm2015}/api/post-message-event.js +0 -0
  37. package/{dist/es2015 → esm2015}/api/preventable-event.js +0 -0
  38. package/{dist/es2015 → esm2015}/api/user.interface.js +1 -0
  39. package/esm2015/cards/hero-card.component.js +88 -0
  40. package/{dist/es2015 → esm2015}/chat/attachment-template.directive.js +14 -12
  41. package/esm2015/chat/attachment.component.js +83 -0
  42. package/{dist/es2015 → esm2015}/chat/builtin-actions.js +13 -16
  43. package/{dist/es2015 → esm2015}/chat/chat-item.js +0 -0
  44. package/{dist/es2015 → esm2015}/chat/chat-view.js +0 -6
  45. package/esm2015/chat/chat.component.js +226 -0
  46. package/{dist/es → esm2015}/chat/chat.directives.js +0 -0
  47. package/{dist/es2015 → esm2015}/chat/chat.module.js +40 -15
  48. package/esm2015/chat/l10n/custom-messages.component.js +42 -0
  49. package/esm2015/chat/l10n/localized-messages.directive.js +37 -0
  50. package/esm2015/chat/l10n/messages.js +24 -0
  51. package/{dist/es2015 → esm2015}/chat/message-attachments.component.js +71 -48
  52. package/esm2015/chat/message-list.component.js +279 -0
  53. package/{dist/es2015 → esm2015}/chat/message-template.directive.js +14 -12
  54. package/esm2015/chat/message.component.js +140 -0
  55. package/esm2015/chat/suggested-actions.component.js +111 -0
  56. package/esm2015/common/focused-state.directive.js +37 -0
  57. package/{dist/es2015 → esm2015}/common/keys.enum.js +1 -0
  58. package/{dist/es2015 → esm2015}/common/scroll-anchor.directive.js +20 -26
  59. package/{dist/es2015 → esm2015}/common/utils.js +0 -0
  60. package/{dist/es/api/action.interface.js → esm2015/kendo-angular-conversational-ui.js} +4 -1
  61. package/{dist/npm/chat/chat-item.js → esm2015/main.js} +5 -11
  62. package/{dist/es2015 → esm2015}/package-metadata.js +1 -1
  63. package/fesm2015/kendo-angular-conversational-ui.js +1576 -0
  64. package/{dist/es2015/common/focused-state.directive.d.ts → kendo-angular-conversational-ui.d.ts} +3 -6
  65. package/main.d.ts +9 -0
  66. package/{dist/es2015/package-metadata.d.ts → package-metadata.d.ts} +0 -0
  67. package/package.json +34 -101
  68. package/schematics/ngAdd/index.js +5 -2
  69. package/schematics/ngAdd/index.js.map +1 -1
  70. package/dist/cdn/js/kendo-angular-conversational-ui.js +0 -20
  71. package/dist/cdn/main.js +0 -5
  72. package/dist/es/api/execute-action-event.js +0 -24
  73. package/dist/es/api/post-message-event.js +0 -18
  74. package/dist/es/api/preventable-event.js +0 -32
  75. package/dist/es/cards/hero-card.component.js +0 -54
  76. package/dist/es/chat/attachment-template.directive.js +0 -32
  77. package/dist/es/chat/attachment.component.js +0 -65
  78. package/dist/es/chat/builtin-actions.js +0 -28
  79. package/dist/es/chat/chat-item.js +0 -13
  80. package/dist/es/chat/chat-view.js +0 -92
  81. package/dist/es/chat/chat.component.js +0 -193
  82. package/dist/es/chat/chat.module.js +0 -76
  83. package/dist/es/chat/l10n/custom-messages.component.js +0 -45
  84. package/dist/es/chat/l10n/localized-messages.directive.js +0 -36
  85. package/dist/es/chat/l10n/messages.js +0 -26
  86. package/dist/es/chat/message-attachments.component.js +0 -148
  87. package/dist/es/chat/message-list.component.js +0 -165
  88. package/dist/es/chat/message-template.directive.js +0 -32
  89. package/dist/es/chat/message.component.js +0 -77
  90. package/dist/es/chat/suggested-actions.component.js +0 -91
  91. package/dist/es/common/focused-state.directive.js +0 -43
  92. package/dist/es/common/keys.enum.js +0 -4
  93. package/dist/es/common/scroll-anchor.directive.js +0 -87
  94. package/dist/es/common/utils.js +0 -13
  95. package/dist/es/index.js +0 -21
  96. package/dist/es/main.js +0 -8
  97. package/dist/es/package-metadata.js +0 -15
  98. package/dist/es2015/api/message.interface.js +0 -4
  99. package/dist/es2015/cards/hero-card.component.js +0 -78
  100. package/dist/es2015/chat/attachment.component.js +0 -66
  101. package/dist/es2015/chat/chat.component.js +0 -230
  102. package/dist/es2015/chat/chat.directives.js +0 -7
  103. package/dist/es2015/chat/chat.module.d.ts +0 -27
  104. package/dist/es2015/chat/l10n/custom-messages.component.js +0 -37
  105. package/dist/es2015/chat/l10n/localized-messages.directive.js +0 -32
  106. package/dist/es2015/chat/l10n/messages.js +0 -20
  107. package/dist/es2015/chat/message-list.component.js +0 -227
  108. package/dist/es2015/chat/message.component.js +0 -107
  109. package/dist/es2015/chat/suggested-actions.component.js +0 -104
  110. package/dist/es2015/common/focused-state.directive.js +0 -45
  111. package/dist/es2015/index.d.ts +0 -21
  112. package/dist/es2015/index.js +0 -21
  113. package/dist/es2015/index.metadata.json +0 -1
  114. package/dist/es2015/main.d.ts +0 -12
  115. package/dist/es2015/main.js +0 -8
  116. package/dist/fesm2015/index.js +0 -1403
  117. package/dist/fesm5/index.js +0 -1253
  118. package/dist/npm/api/action.interface.js +0 -7
  119. package/dist/npm/api/attachment.interface.js +0 -6
  120. package/dist/npm/api/execute-action-event.js +0 -26
  121. package/dist/npm/api/message.interface.js +0 -6
  122. package/dist/npm/api/post-message-event.js +0 -20
  123. package/dist/npm/api/preventable-event.js +0 -34
  124. package/dist/npm/api/user.interface.js +0 -6
  125. package/dist/npm/cards/hero-card.component.js +0 -56
  126. package/dist/npm/chat/attachment-template.directive.js +0 -34
  127. package/dist/npm/chat/attachment.component.js +0 -67
  128. package/dist/npm/chat/builtin-actions.js +0 -33
  129. package/dist/npm/chat/chat-view.js +0 -98
  130. package/dist/npm/chat/chat.component.js +0 -195
  131. package/dist/npm/chat/chat.directives.js +0 -12
  132. package/dist/npm/chat/chat.module.js +0 -78
  133. package/dist/npm/chat/l10n/custom-messages.component.js +0 -47
  134. package/dist/npm/chat/l10n/localized-messages.directive.js +0 -38
  135. package/dist/npm/chat/l10n/messages.js +0 -28
  136. package/dist/npm/chat/message-attachments.component.js +0 -150
  137. package/dist/npm/chat/message-list.component.js +0 -167
  138. package/dist/npm/chat/message-template.directive.js +0 -34
  139. package/dist/npm/chat/message.component.js +0 -79
  140. package/dist/npm/chat/suggested-actions.component.js +0 -93
  141. package/dist/npm/common/focused-state.directive.js +0 -45
  142. package/dist/npm/common/keys.enum.js +0 -6
  143. package/dist/npm/common/scroll-anchor.directive.js +0 -89
  144. package/dist/npm/common/utils.js +0 -15
  145. package/dist/npm/index.js +0 -37
  146. package/dist/npm/main.js +0 -11
  147. package/dist/npm/package-metadata.js +0 -17
  148. package/dist/systemjs/kendo-angular-conversational-ui.js +0 -5
@@ -1,1403 +0,0 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the project root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import { __decorate, __param, __metadata } from 'tslib';
6
- import { Directive, Optional, TemplateRef, EventEmitter, isDevMode, Input, Output, HostBinding, ContentChild, ViewChild, ElementRef, Component, NgZone, forwardRef, HostListener, ViewChildren, QueryList, Renderer2, NgModule } from '@angular/core';
7
- import { LocalizationService, L10N_PREFIX, ComponentMessages } from '@progress/kendo-angular-l10n';
8
- import { validatePackage } from '@progress/kendo-licensing';
9
- import { ButtonModule } from '@progress/kendo-angular-buttons';
10
- import { CommonModule } from '@angular/common';
11
- import { ResizeSensorModule } from '@progress/kendo-angular-common';
12
- import { fromEvent } from 'rxjs';
13
- import { debounceTime } from 'rxjs/operators';
14
- import { IntlService } from '@progress/kendo-angular-intl';
15
-
16
- /**
17
- * Defines a template that will be used for displaying message attachments. To define an attachment
18
- * template, nest an `<ng-template>` tag with the `kendoChatAttachmentTemplate` attribute inside the
19
- * `<kendo-chat>` component. The template context is set to the attachment instance. For more information,
20
- * refer to the article on [message attachments]({% slug attachments_chat %}).
21
- *
22
- * {% meta height:700 %}
23
- * {% embed_file attachments/templates/app.component.ts preview %}
24
- * {% embed_file shared/app.module.ts preview %}
25
- * {% embed_file shared/main.ts hidden %}
26
- * {% endmeta %}
27
- */
28
- let AttachmentTemplateDirective = class AttachmentTemplateDirective {
29
- constructor(templateRef) {
30
- this.templateRef = templateRef;
31
- }
32
- };
33
- AttachmentTemplateDirective = __decorate([
34
- Directive({
35
- selector: '[kendoChatAttachmentTemplate]'
36
- }),
37
- __param(0, Optional()),
38
- __metadata("design:paramtypes", [TemplateRef])
39
- ], AttachmentTemplateDirective);
40
-
41
- /**
42
- * Arguments for the `SendMessage` event.
43
- *
44
- */
45
- class SendMessageEvent {
46
- /**
47
- * @hidden
48
- */
49
- constructor(message) {
50
- this.message = message;
51
- }
52
- }
53
-
54
- const noop = () => { };
55
- const ɵ1 = (action, sender) => {
56
- sender.sendMessage.emit(new SendMessageEvent({
57
- author: sender.user,
58
- text: action.value,
59
- timestamp: new Date()
60
- }));
61
- }, ɵ2 = (action) => {
62
- window.open('tel:' + action.value);
63
- }, ɵ3 = (action) => {
64
- window.open(action.value);
65
- };
66
- const handlers = {
67
- 'reply': ɵ1,
68
- 'call': ɵ2,
69
- 'openUrl': ɵ3
70
- };
71
- /**
72
- * @hidden
73
- */
74
- const makeHandler = (action) => handlers[action.type] || noop;
75
-
76
- /**
77
- * Defines a template that will be used for displaying Chat messages. To define an attachment
78
- * template, nest an `<ng-template>` tag with the `kendoChatMessageTemplate` attribute inside the
79
- * `<kendo-chat>` component. The template context is set to the message instance. For more information,
80
- * refer to the article on [message templates]({% slug message_templates_chat %}).
81
- *
82
- * {% meta height:700 %}
83
- * {% embed_file messages/templates/app.component.ts preview %}
84
- * {% embed_file shared/app.module.ts preview %}
85
- * {% embed_file shared/main.ts hidden %}
86
- * {% endmeta %}
87
- */
88
- let MessageTemplateDirective = class MessageTemplateDirective {
89
- constructor(templateRef) {
90
- this.templateRef = templateRef;
91
- }
92
- };
93
- MessageTemplateDirective = __decorate([
94
- Directive({
95
- selector: '[kendoChatMessageTemplate]'
96
- }),
97
- __param(0, Optional()),
98
- __metadata("design:paramtypes", [TemplateRef])
99
- ], MessageTemplateDirective);
100
-
101
- /**
102
- * @hidden
103
- */
104
- const packageMetadata = {
105
- name: '@progress/kendo-angular-conversational-ui',
106
- productName: 'Kendo UI for Angular',
107
- productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
108
- publishDate: 1642589598,
109
- version: '',
110
- licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
111
- };
112
-
113
- // tslint:disable-next-line:max-line-length
114
- const sendIcon = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 16 16"><path d="M0,14.3c-0.1,0.6,0.3,0.8,0.8,0.6l14.8-6.5c0.5-0.2,0.5-0.6,0-0.8L0.8,1.1C0.3,0.9-0.1,1.1,0,1.7l0.7,4.2C0.8,6.5,1.4,7,1.9,7.1l8.8,0.8c0.6,0.1,0.6,0.1,0,0.2L1.9,8.9C1.4,9,0.8,9.5,0.7,10.1L0,14.3z"/></svg>';
115
- /**
116
- * Represents the Kendo UI Chat component for Angular.
117
- *
118
- * {% meta height:700 %}
119
- * {% embed_file echo/app.component.ts preview %}
120
- * {% embed_file shared/app.module.ts %}
121
- * {% embed_file shared/main.ts hidden %}
122
- * {% endmeta %}
123
- *
124
- */
125
- let ChatComponent = class ChatComponent {
126
- constructor(localization, zone) {
127
- this.localization = localization;
128
- this.zone = zone;
129
- /**
130
- * Fires when the user types a message and clicks the **Send** button or presses **Enter**.
131
- * Emits the [`SendMessageEvent`]({% slug api_conversational-ui_sendmessageevent %}).
132
- *
133
- * > The message is not automatically appended to the `messages` array.
134
- */
135
- this.sendMessage = new EventEmitter();
136
- /**
137
- * Fires when the user clicks a quick action button.
138
- * The Chat internally handles the `reply`, `openUrl`, and `call` [known actions]({% slug api_conversational-ui_actiontype %}).
139
- *
140
- * Emits the [`ExecuteActionEvent`]({% slug api_conversational-ui_executeactionevent %}).
141
- * The event is preventable. If `preventDefault` is called, the built-in action will be suppressed.
142
- */
143
- this.executeAction = new EventEmitter();
144
- /**
145
- * @hidden
146
- */
147
- this.autoScroll = true;
148
- validatePackage(packageMetadata);
149
- this.direction = localization.rtl ? 'rtl' : 'ltr';
150
- this.localizationChangeSubscription = localization.changes.subscribe(({ rtl }) => {
151
- this.direction = rtl ? 'rtl' : 'ltr';
152
- });
153
- }
154
- get className() {
155
- return 'k-widget k-chat';
156
- }
157
- get dirAttr() {
158
- return this.direction;
159
- }
160
- ngOnChanges() {
161
- this.zone.runOutsideAngular(() => setTimeout(() => {
162
- this.messageList.nativeElement.style.flex = '1 1 auto';
163
- }));
164
- }
165
- ngAfterViewInit() {
166
- if (!isDevMode()) {
167
- return;
168
- }
169
- if (!this.user) {
170
- throw new Error('User must be set and have a valid id.');
171
- }
172
- }
173
- ngOnDestroy() {
174
- if (this.localizationChangeSubscription) {
175
- this.localizationChangeSubscription.unsubscribe();
176
- }
177
- }
178
- /**
179
- * @hidden
180
- */
181
- sendClick() {
182
- const input = this.messageInput.nativeElement;
183
- const value = input.value;
184
- if (!value) {
185
- return;
186
- }
187
- const message = {
188
- author: this.user,
189
- text: value,
190
- timestamp: new Date()
191
- };
192
- this.sendMessage.emit(new SendMessageEvent(message));
193
- input.value = null;
194
- input.focus();
195
- this.autoScroll = true;
196
- }
197
- /**
198
- * @hidden
199
- */
200
- inputKeydown(e) {
201
- if (e.keyCode === 13 /* enter */) {
202
- this.sendClick();
203
- }
204
- }
205
- /**
206
- * @hidden
207
- */
208
- dispatchAction(e) {
209
- this.executeAction.emit(e);
210
- if (!e.isDefaultPrevented()) {
211
- const handler = makeHandler(e.action);
212
- handler(e.action, this);
213
- this.messageInput.nativeElement.focus();
214
- }
215
- }
216
- /**
217
- * @hidden
218
- */
219
- textFor(key) {
220
- return this.localization.get(key);
221
- }
222
- };
223
- __decorate([
224
- Input(),
225
- __metadata("design:type", Array)
226
- ], ChatComponent.prototype, "messages", void 0);
227
- __decorate([
228
- Input(),
229
- __metadata("design:type", Object)
230
- ], ChatComponent.prototype, "user", void 0);
231
- __decorate([
232
- Output(),
233
- __metadata("design:type", EventEmitter)
234
- ], ChatComponent.prototype, "sendMessage", void 0);
235
- __decorate([
236
- Output(),
237
- __metadata("design:type", EventEmitter)
238
- ], ChatComponent.prototype, "executeAction", void 0);
239
- __decorate([
240
- HostBinding('class'),
241
- __metadata("design:type", String),
242
- __metadata("design:paramtypes", [])
243
- ], ChatComponent.prototype, "className", null);
244
- __decorate([
245
- HostBinding('attr.dir'),
246
- __metadata("design:type", String),
247
- __metadata("design:paramtypes", [])
248
- ], ChatComponent.prototype, "dirAttr", null);
249
- __decorate([
250
- ContentChild(AttachmentTemplateDirective, { static: false }),
251
- __metadata("design:type", AttachmentTemplateDirective)
252
- ], ChatComponent.prototype, "attachmentTemplate", void 0);
253
- __decorate([
254
- ContentChild(MessageTemplateDirective, { static: false }),
255
- __metadata("design:type", MessageTemplateDirective)
256
- ], ChatComponent.prototype, "messageTemplate", void 0);
257
- __decorate([
258
- ViewChild('messageInput', { static: true }),
259
- __metadata("design:type", ElementRef)
260
- ], ChatComponent.prototype, "messageInput", void 0);
261
- __decorate([
262
- ViewChild('messageList', { static: true }),
263
- __metadata("design:type", ElementRef)
264
- ], ChatComponent.prototype, "messageList", void 0);
265
- ChatComponent = __decorate([
266
- Component({
267
- providers: [
268
- LocalizationService,
269
- {
270
- provide: L10N_PREFIX,
271
- useValue: 'kendo.chat'
272
- }
273
- ],
274
- selector: 'kendo-chat',
275
- template: `
276
- <ng-container
277
- kendoChatLocalizedMessages
278
- i18n-messagePlaceholder="kendo.chat.messagePlaceholder|The placholder text of the message text input"
279
- messagePlaceholder="Type a message..."
280
-
281
- i18n-send="kendo.chat.send|The text for the Send button"
282
- send="Send..."
283
- >
284
- </ng-container>
285
-
286
- <div
287
- #messageList
288
- class="k-message-list k-avatars"
289
- aria-live="polite" role="log"
290
- kendoChatScrollAnchor
291
- #anchor="scrollAnchor"
292
- [(autoScroll)]="autoScroll"
293
- >
294
- <kendo-chat-message-list
295
- [messages]="messages"
296
- [messageTemplate]="messageTemplate"
297
- [attachmentTemplate]="attachmentTemplate"
298
- [user]="user"
299
- (executeAction)="dispatchAction($event)"
300
- (resize)="anchor.scrollToBottom()"
301
- (navigate)="this.autoScroll = false"
302
- >
303
- </kendo-chat-message-list>
304
- </div>
305
-
306
- <div class="k-message-box">
307
- <input
308
- #messageInput
309
- kendoChatFocusedState
310
- type="text"
311
- class="k-input"
312
- [placeholder]="textFor('messagePlaceholder')"
313
- (keydown)="inputKeydown($event)"
314
- >
315
- <button
316
- kendoButton
317
- fillMode="flat"
318
- class="k-button-send"
319
- tabindex="-1"
320
- [attr.title]="textFor('send')"
321
- (click)="sendClick()"
322
- >${sendIcon}</button>
323
- </div>
324
- `
325
- }),
326
- __metadata("design:paramtypes", [LocalizationService,
327
- NgZone])
328
- ], ChatComponent);
329
-
330
- /**
331
- * @hidden
332
- */
333
- let AttachmentComponent = class AttachmentComponent {
334
- set attachment(value) {
335
- this._attachment = value;
336
- this.context = {
337
- $implicit: this.attachment
338
- };
339
- }
340
- get attachment() {
341
- return this._attachment;
342
- }
343
- get image() {
344
- return this.contentType.indexOf('image/') === 0;
345
- }
346
- get unknown() {
347
- return !this.image;
348
- }
349
- get contentType() {
350
- return this.attachment.contentType || '';
351
- }
352
- };
353
- __decorate([
354
- Input(),
355
- __metadata("design:type", Object),
356
- __metadata("design:paramtypes", [Object])
357
- ], AttachmentComponent.prototype, "attachment", null);
358
- __decorate([
359
- Input(),
360
- __metadata("design:type", AttachmentTemplateDirective)
361
- ], AttachmentComponent.prototype, "template", void 0);
362
- AttachmentComponent = __decorate([
363
- Component({
364
- selector: 'kendo-chat-attachment',
365
- template: `
366
- <ng-container *ngIf="template">
367
- <ng-container *ngTemplateOutlet="template.templateRef; context: context;">
368
- </ng-container>
369
- </ng-container>
370
-
371
- <div *ngIf="!template" class="k-card">
372
- <div class="k-card-body">
373
- <h5 class="k-card-title" *ngIf="attachment.title">
374
- {{ attachment.title }}
375
- </h5>
376
- <h6 class="k-card-subtitle" *ngIf="attachment.subtitle">
377
- {{ attachment.subtitle }}
378
- </h6>
379
- <img *ngIf="image" [attr.src]="attachment.content" />
380
- <ng-container *ngIf="unknown">
381
- {{ attachment.content }}
382
- </ng-container>
383
- </div>
384
- </div>
385
- `
386
- })
387
- ], AttachmentComponent);
388
-
389
- /**
390
- * @hidden
391
- */
392
- class Messages extends ComponentMessages {
393
- }
394
- __decorate([
395
- Input(),
396
- __metadata("design:type", String)
397
- ], Messages.prototype, "messagePlaceholder", void 0);
398
- __decorate([
399
- Input(),
400
- __metadata("design:type", String)
401
- ], Messages.prototype, "send", void 0);
402
-
403
- var CustomMessagesComponent_1;
404
- // tslint:disable:no-forward-ref
405
- /**
406
- * Custom component messages override default component messages
407
- * ([see example]({% slug globalization_chat %}#toc-custom-messages)).
408
- */
409
- let CustomMessagesComponent = CustomMessagesComponent_1 = class CustomMessagesComponent extends Messages {
410
- constructor(service) {
411
- super();
412
- this.service = service;
413
- }
414
- get override() {
415
- return true;
416
- }
417
- };
418
- CustomMessagesComponent = CustomMessagesComponent_1 = __decorate([
419
- Component({
420
- providers: [
421
- {
422
- provide: Messages,
423
- useExisting: forwardRef(() => CustomMessagesComponent_1)
424
- }
425
- ],
426
- selector: 'kendo-chat-messages',
427
- template: ``
428
- }),
429
- __metadata("design:paramtypes", [LocalizationService])
430
- ], CustomMessagesComponent);
431
-
432
- /**
433
- * @hidden
434
- */
435
- let FocusedStateDirective = class FocusedStateDirective {
436
- /**
437
- * @hidden
438
- */
439
- constructor() {
440
- this.focused = false;
441
- }
442
- onFocus() {
443
- this.focused = true;
444
- }
445
- onBlur() {
446
- this.focused = false;
447
- }
448
- };
449
- __decorate([
450
- HostBinding('class.k-state-focused'),
451
- __metadata("design:type", Boolean)
452
- ], FocusedStateDirective.prototype, "focused", void 0);
453
- __decorate([
454
- HostListener('focusin'),
455
- __metadata("design:type", Function),
456
- __metadata("design:paramtypes", []),
457
- __metadata("design:returntype", void 0)
458
- ], FocusedStateDirective.prototype, "onFocus", null);
459
- __decorate([
460
- HostListener('focusout'),
461
- __metadata("design:type", Function),
462
- __metadata("design:paramtypes", []),
463
- __metadata("design:returntype", void 0)
464
- ], FocusedStateDirective.prototype, "onBlur", null);
465
- FocusedStateDirective = __decorate([
466
- Directive({
467
- selector: '[kendoChatFocusedState]'
468
- })
469
- ], FocusedStateDirective);
470
-
471
- /**
472
- * Represents a Hero Card component ([see example]({% slug dialogflow_chat %})).
473
- * Hero cards host a single large image and action buttons with text content.
474
- */
475
- let HeroCardComponent = class HeroCardComponent {
476
- /**
477
- * Represents a Hero Card component ([see example]({% slug dialogflow_chat %})).
478
- * Hero cards host a single large image and action buttons with text content.
479
- */
480
- constructor() {
481
- this.cssClass = true;
482
- /**
483
- * Fires when the user clicks a button.
484
- */
485
- this.executeAction = new EventEmitter();
486
- }
487
- onClick(action) {
488
- this.executeAction.next(action);
489
- }
490
- };
491
- __decorate([
492
- Input(),
493
- __metadata("design:type", String)
494
- ], HeroCardComponent.prototype, "imageUrl", void 0);
495
- __decorate([
496
- Input(),
497
- __metadata("design:type", String)
498
- ], HeroCardComponent.prototype, "title", void 0);
499
- __decorate([
500
- Input(),
501
- __metadata("design:type", String)
502
- ], HeroCardComponent.prototype, "subtitle", void 0);
503
- __decorate([
504
- Input(),
505
- __metadata("design:type", Array)
506
- ], HeroCardComponent.prototype, "actions", void 0);
507
- __decorate([
508
- HostBinding('class.k-card'),
509
- __metadata("design:type", Boolean)
510
- ], HeroCardComponent.prototype, "cssClass", void 0);
511
- __decorate([
512
- Output(),
513
- __metadata("design:type", EventEmitter)
514
- ], HeroCardComponent.prototype, "executeAction", void 0);
515
- HeroCardComponent = __decorate([
516
- Component({
517
- selector: 'kendo-chat-hero-card',
518
- template: `
519
- <img class="k-card-image" [src]="imageUrl" *ngIf="imageUrl" />
520
- <div class="k-card-body">
521
- <h5 class="k-card-title" *ngIf="title">
522
- {{ title }}
523
- </h5>
524
- <h6 class="k-card-subtitle" *ngIf="subtitle">
525
- {{ subtitle }}
526
- </h6>
527
- </div>
528
- <div class="k-card-actions k-card-actions-vertical">
529
- <span class="k-card-action"
530
- *ngFor="let act of actions"
531
- >
532
- <button
533
- kendoButton fillMode="flat"
534
- (click)="onClick(act)">
535
- {{ act.title }}
536
- </button>
537
- </span>
538
- </div>
539
- `
540
- })
541
- ], HeroCardComponent);
542
-
543
- var LocalizedMessagesDirective_1;
544
- // tslint:disable:no-forward-ref
545
- /**
546
- * @hidden
547
- */
548
- let LocalizedMessagesDirective = LocalizedMessagesDirective_1 = class LocalizedMessagesDirective extends Messages {
549
- constructor(service) {
550
- super();
551
- this.service = service;
552
- }
553
- };
554
- LocalizedMessagesDirective = LocalizedMessagesDirective_1 = __decorate([
555
- Directive({
556
- providers: [
557
- {
558
- provide: Messages,
559
- useExisting: forwardRef(() => LocalizedMessagesDirective_1)
560
- }
561
- ],
562
- selector: '[kendoChatLocalizedMessages]'
563
- }),
564
- __metadata("design:paramtypes", [LocalizationService])
565
- ], LocalizedMessagesDirective);
566
-
567
- /**
568
- * @hidden
569
- */
570
- class ChatItem {
571
- }
572
-
573
- var MessageAttachmentsComponent_1;
574
- // tslint:disable:no-forward-ref
575
- /**
576
- * @hidden
577
- */
578
- let MessageAttachmentsComponent = MessageAttachmentsComponent_1 = class MessageAttachmentsComponent extends ChatItem {
579
- constructor(zone) {
580
- super();
581
- this.zone = zone;
582
- this.scrollPosition = 0;
583
- this.selectedIndex = 0;
584
- this.carouselKeyHandlers = {
585
- [37 /* left */]: (e) => this.navigateTo(e, -1),
586
- [39 /* right */]: (e) => this.navigateTo(e, 1)
587
- };
588
- this.listKeyHandlers = {
589
- [38 /* up */]: (e) => this.navigateTo(e, -1),
590
- [40 /* down */]: (e) => this.navigateTo(e, 1)
591
- };
592
- }
593
- get carousel() {
594
- return this.layout !== 'list';
595
- }
596
- ngAfterViewInit() {
597
- this.zone.runOutsideAngular(() => {
598
- const scrollDebounceTime = 100;
599
- this.scrollSubscription = fromEvent(this.deck.nativeElement, 'scroll')
600
- .pipe(debounceTime(scrollDebounceTime))
601
- .subscribe(() => this.onScroll());
602
- });
603
- }
604
- ngOnDestroy() {
605
- this.scrollSubscription.unsubscribe();
606
- }
607
- isSelected(index) {
608
- return this.selectedIndex === index;
609
- }
610
- itemKeydown(e, attachment) {
611
- const keyHandlers = this.layout === 'list' ?
612
- this.listKeyHandlers : this.carouselKeyHandlers;
613
- const handler = keyHandlers[e.keyCode];
614
- if (handler) {
615
- handler(e, attachment);
616
- }
617
- }
618
- itemClick(index) {
619
- this.select(index);
620
- }
621
- focus() {
622
- this.select(this.selectedIndex);
623
- }
624
- scrollTo(dir) {
625
- const el = this.deck.nativeElement;
626
- const scrollStep = el.scrollWidth / this.items.length;
627
- const max = el.scrollWidth - el.offsetWidth;
628
- const pos = el.scrollLeft + scrollStep * dir;
629
- el.scrollLeft = Math.max(0, Math.min(max, pos));
630
- }
631
- select(index) {
632
- this.selectedIndex = index;
633
- const item = this.items.toArray()[index];
634
- if (item) {
635
- item.nativeElement.focus();
636
- }
637
- }
638
- navigateTo(e, offset) {
639
- const prevIndex = this.selectedIndex;
640
- const nextIndex = Math.max(0, Math.min(prevIndex + offset, this.items.length - 1));
641
- if (nextIndex !== prevIndex) {
642
- this.select(nextIndex);
643
- e.preventDefault();
644
- }
645
- }
646
- onScroll() {
647
- const el = this.deck.nativeElement;
648
- if (el.scrollWidth === 0) {
649
- return;
650
- }
651
- const pos = el.scrollLeft / (el.scrollWidth - el.offsetWidth);
652
- if (pos !== this.scrollPosition) {
653
- this.zone.run(() => {
654
- this.scrollPosition = pos;
655
- });
656
- }
657
- }
658
- };
659
- __decorate([
660
- Input(),
661
- __metadata("design:type", Array)
662
- ], MessageAttachmentsComponent.prototype, "attachments", void 0);
663
- __decorate([
664
- Input(),
665
- __metadata("design:type", String)
666
- ], MessageAttachmentsComponent.prototype, "layout", void 0);
667
- __decorate([
668
- Input(),
669
- __metadata("design:type", Boolean)
670
- ], MessageAttachmentsComponent.prototype, "tabbable", void 0);
671
- __decorate([
672
- Input(),
673
- __metadata("design:type", AttachmentTemplateDirective)
674
- ], MessageAttachmentsComponent.prototype, "template", void 0);
675
- __decorate([
676
- HostBinding('class.k-card-deck-scrollwrap'),
677
- __metadata("design:type", Boolean),
678
- __metadata("design:paramtypes", [])
679
- ], MessageAttachmentsComponent.prototype, "carousel", null);
680
- __decorate([
681
- ViewChild('deck', { read: ElementRef, static: true }),
682
- __metadata("design:type", ElementRef)
683
- ], MessageAttachmentsComponent.prototype, "deck", void 0);
684
- __decorate([
685
- ViewChildren('item', { read: ElementRef }),
686
- __metadata("design:type", QueryList)
687
- ], MessageAttachmentsComponent.prototype, "items", void 0);
688
- MessageAttachmentsComponent = MessageAttachmentsComponent_1 = __decorate([
689
- Component({
690
- providers: [{
691
- provide: ChatItem,
692
- useExisting: forwardRef(() => MessageAttachmentsComponent_1)
693
- }],
694
- selector: 'kendo-chat-message-attachments',
695
- template: `
696
- <button
697
- *ngIf="carousel && scrollPosition > 0"
698
- (click)="scrollTo(-1)"
699
- class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
700
- tabindex="-1">
701
- <span class="k-icon k-button-icon k-i-arrow-chevron-left"></span>
702
- </button>
703
- <div #deck [class.k-card-deck]="carousel">
704
- <kendo-chat-attachment #item
705
- *ngFor="let att of attachments; index as index; first as first; last as last"
706
- [attachment]="att"
707
- [template]="template"
708
- [class.k-state-selected]="isSelected(index)"
709
- [class.k-state-focused]="isSelected(index)"
710
- [class.k-card-wrap]="true"
711
- [class.k-first]="first"
712
- [class.k-last]="last"
713
- [attr.tabindex]="tabbable && isSelected(index) ? '0' : '-1'"
714
- (click)="itemClick(index)"
715
- (keydown)="itemKeydown($event, att)"
716
- >
717
- </kendo-chat-attachment>
718
- </div>
719
- <button
720
- *ngIf="carousel && scrollPosition < 1"
721
- (click)="scrollTo(1)"
722
- class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
723
- tabindex="-1">
724
- <span class="k-icon k-button-icon k-i-arrow-chevron-right"></span>
725
- </button>
726
- `
727
- }),
728
- __metadata("design:paramtypes", [NgZone])
729
- ], MessageAttachmentsComponent);
730
-
731
- var MessageComponent_1;
732
- // tslint:disable:no-forward-ref
733
- /**
734
- * @hidden
735
- */
736
- let MessageComponent = MessageComponent_1 = class MessageComponent extends ChatItem {
737
- constructor(element, intl) {
738
- super();
739
- this.element = element;
740
- this.intl = intl;
741
- this.cssClass = true;
742
- }
743
- get tabIndex() {
744
- return this.tabbable ? '0' : '-1';
745
- }
746
- formatTimeStamp(date) {
747
- return this.intl.formatDate(date, { datetime: 'short' });
748
- }
749
- focus() {
750
- this.element.nativeElement.focus();
751
- }
752
- };
753
- __decorate([
754
- Input(),
755
- __metadata("design:type", Object)
756
- ], MessageComponent.prototype, "message", void 0);
757
- __decorate([
758
- Input(),
759
- __metadata("design:type", Boolean)
760
- ], MessageComponent.prototype, "tabbable", void 0);
761
- __decorate([
762
- Input(),
763
- __metadata("design:type", MessageTemplateDirective)
764
- ], MessageComponent.prototype, "template", void 0);
765
- __decorate([
766
- HostBinding('class.k-message'),
767
- __metadata("design:type", Boolean)
768
- ], MessageComponent.prototype, "cssClass", void 0);
769
- __decorate([
770
- HostBinding('class.k-state-selected'),
771
- HostBinding('class.k-state-focused'),
772
- __metadata("design:type", Boolean)
773
- ], MessageComponent.prototype, "selected", void 0);
774
- __decorate([
775
- HostBinding('attr.tabIndex'),
776
- __metadata("design:type", String),
777
- __metadata("design:paramtypes", [])
778
- ], MessageComponent.prototype, "tabIndex", null);
779
- MessageComponent = MessageComponent_1 = __decorate([
780
- Component({
781
- selector: 'kendo-chat-message',
782
- providers: [{
783
- provide: ChatItem,
784
- useExisting: forwardRef(() => MessageComponent_1)
785
- }],
786
- template: `
787
- <time
788
- [attr.aria-hidden]="!selected"
789
- class="k-message-time"
790
- *ngIf="message.timestamp"
791
- >
792
- {{ formatTimeStamp(message.timestamp) }}
793
- </time>
794
-
795
- <ng-container *ngIf="!message.typing; else typing">
796
- <div class="k-bubble" *ngIf="template">
797
- <ng-container
798
- *ngTemplateOutlet="template.templateRef; context: { $implicit: message };"
799
- >
800
- </ng-container>
801
- </div>
802
-
803
- <div class="k-bubble" *ngIf="!template && message.text">
804
- {{message.text}}
805
- </div>
806
- </ng-container>
807
-
808
- <span
809
- class="k-message-status"
810
- *ngIf="message.status"
811
- >
812
- {{ message.status }}
813
- </span>
814
-
815
- <ng-template #typing>
816
- <div class="k-bubble">
817
- <div class="k-typing-indicator">
818
- <span></span>
819
- <span></span>
820
- <span></span>
821
- </div>
822
- </div>
823
- </ng-template>
824
- `
825
- }),
826
- __metadata("design:paramtypes", [ElementRef, IntlService])
827
- ], MessageComponent);
828
-
829
- /**
830
- * @hidden
831
- */
832
- class PreventableEvent {
833
- constructor() {
834
- this.prevented = false;
835
- }
836
- /**
837
- * Prevents the default action for a specified event.
838
- * In this way, the source component suppresses
839
- * the built-in behavior that follows the event.
840
- */
841
- preventDefault() {
842
- this.prevented = true;
843
- }
844
- /**
845
- * Returns `true` if the event was prevented
846
- * by any of its subscribers.
847
- *
848
- * @returns `true` if the default action was prevented.
849
- * Otherwise, returns `false`.
850
- */
851
- isDefaultPrevented() {
852
- return this.prevented;
853
- }
854
- }
855
-
856
- /**
857
- * Arguments for the `executeAction` event. The `executeAction` event fires when the user clicks
858
- * a quick action button. Calling `preventDefault()` suppresses the built-in action handler.
859
- */
860
- class ExecuteActionEvent extends PreventableEvent {
861
- /**
862
- * @hidden
863
- */
864
- constructor(action, message) {
865
- super();
866
- this.action = action;
867
- this.message = message;
868
- }
869
- }
870
-
871
- /**
872
- * @hidden
873
- */
874
- const closest = (node, predicate) => {
875
- while (node && !predicate(node)) {
876
- node = node.parentNode;
877
- }
878
- return node;
879
- };
880
-
881
- /**
882
- * @hidden
883
- */
884
- const isAuthor = (user, msg) => user && msg.author && user.id === msg.author.id;
885
- const last = (arr) => arr[arr.length - 1];
886
- const dateChanged = (curr, prev) => (curr && prev) && (prev.getDate() !== curr.getDate() ||
887
- prev.getMonth() !== curr.getMonth() ||
888
- prev.getFullYear() !== curr.getFullYear());
889
- const addDateMarker = (acc, msg) => {
890
- const timestamp = msg.timestamp;
891
- const lastItem = last(acc);
892
- if (!timestamp) {
893
- return;
894
- }
895
- if (!lastItem || dateChanged(timestamp, lastItem.timestamp)) {
896
- const dateMarker = {
897
- type: 'date-marker',
898
- timestamp: timestamp,
899
- trackBy: timestamp.getTime()
900
- };
901
- acc.push(dateMarker);
902
- }
903
- };
904
- const groupMessages = (acc, msg, isLastMessage) => {
905
- const lastItem = last(acc);
906
- let messages;
907
- if (isDevMode() && !msg.author) {
908
- throw new Error('Author must be set for message: ' + JSON.stringify(msg));
909
- }
910
- if (msg.typing && !isLastMessage) {
911
- return;
912
- }
913
- if (lastItem && lastItem.type === 'message-group') {
914
- messages = lastItem.messages;
915
- }
916
- if (messages && isAuthor(msg.author, last(messages))) {
917
- messages.push(msg);
918
- }
919
- else {
920
- acc.push({
921
- type: 'message-group',
922
- messages: [msg],
923
- author: msg.author,
924
- timestamp: msg.timestamp,
925
- trackBy: msg
926
- });
927
- }
928
- };
929
- const groupItems = (total) => (acc, msg, index) => {
930
- const isLastMessage = index === total - 1;
931
- addDateMarker(acc, msg);
932
- groupMessages(acc, msg, isLastMessage);
933
- if (msg.attachments && msg.attachments.length > 1) {
934
- acc.push({
935
- type: 'attachment-group',
936
- attachments: msg.attachments,
937
- attachmentLayout: msg.attachmentLayout,
938
- timestamp: msg.timestamp,
939
- trackBy: msg
940
- });
941
- }
942
- if (msg.suggestedActions && isLastMessage) {
943
- acc.push({
944
- type: 'action-group',
945
- actions: msg.suggestedActions,
946
- timestamp: msg.timestamp,
947
- trackBy: msg
948
- });
949
- }
950
- return acc;
951
- };
952
- /**
953
- * @hidden
954
- */
955
- const chatView = (messages) => messages.reduce(groupItems(messages.length), []);
956
-
957
- /**
958
- * @hidden
959
- */
960
- let MessageListComponent = class MessageListComponent {
961
- constructor(element, intl) {
962
- this.element = element;
963
- this.intl = intl;
964
- this.executeAction = new EventEmitter();
965
- this.navigate = new EventEmitter();
966
- this.resize = new EventEmitter();
967
- this.cssClass = true;
968
- this.view = [];
969
- this.keyActions = {
970
- [38 /* up */]: (e) => this.navigateTo(e, -1),
971
- [40 /* down */]: (e) => this.navigateTo(e, 1)
972
- };
973
- }
974
- set messages(value) {
975
- const data = value || [];
976
- this.view = chatView(data);
977
- this._messages = data;
978
- }
979
- get messages() {
980
- return this._messages;
981
- }
982
- ngAfterViewInit() {
983
- this.selectedItem = this.items.last;
984
- }
985
- onResize() {
986
- this.resize.emit();
987
- }
988
- formatTimeStamp(date) {
989
- return this.intl.formatDate(date, { date: 'full' });
990
- }
991
- onKeydown(e) {
992
- const action = this.keyActions[e.keyCode];
993
- if (action) {
994
- action(e);
995
- }
996
- }
997
- onBlur(args) {
998
- const next = args.relatedTarget || document.activeElement;
999
- const outside = !closest(next, (node) => node === this.element.nativeElement);
1000
- if (outside) {
1001
- this.select(null);
1002
- }
1003
- }
1004
- isOwnMessage(msg) {
1005
- return isAuthor(this.user, msg);
1006
- }
1007
- dispatchAction(action, message) {
1008
- const args = new ExecuteActionEvent(action, message);
1009
- this.executeAction.emit(args);
1010
- }
1011
- trackGroup(_index, item) {
1012
- return item.trackBy;
1013
- }
1014
- select(item) {
1015
- const prevItem = this.selectedItem;
1016
- if (prevItem) {
1017
- prevItem.selected = false;
1018
- }
1019
- if (item) {
1020
- item.selected = true;
1021
- this.selectedItem = item;
1022
- }
1023
- }
1024
- last(items) {
1025
- if (!items || items.length === 0) {
1026
- return;
1027
- }
1028
- return items[items.length - 1];
1029
- }
1030
- navigateTo(e, offset) {
1031
- const items = this.items.toArray();
1032
- const prevItem = this.selectedItem;
1033
- const prevIndex = items.indexOf(prevItem);
1034
- const nextIndex = Math.max(0, Math.min(prevIndex + offset, this.items.length - 1));
1035
- const nextItem = items[nextIndex];
1036
- if (nextItem !== prevItem) {
1037
- this.select(nextItem);
1038
- nextItem.focus();
1039
- this.navigate.emit();
1040
- e.preventDefault();
1041
- }
1042
- }
1043
- };
1044
- __decorate([
1045
- Input(),
1046
- __metadata("design:type", Array),
1047
- __metadata("design:paramtypes", [Array])
1048
- ], MessageListComponent.prototype, "messages", null);
1049
- __decorate([
1050
- Input(),
1051
- __metadata("design:type", AttachmentTemplateDirective)
1052
- ], MessageListComponent.prototype, "attachmentTemplate", void 0);
1053
- __decorate([
1054
- Input(),
1055
- __metadata("design:type", MessageTemplateDirective)
1056
- ], MessageListComponent.prototype, "messageTemplate", void 0);
1057
- __decorate([
1058
- Input(),
1059
- __metadata("design:type", Object)
1060
- ], MessageListComponent.prototype, "user", void 0);
1061
- __decorate([
1062
- Output(),
1063
- __metadata("design:type", EventEmitter)
1064
- ], MessageListComponent.prototype, "executeAction", void 0);
1065
- __decorate([
1066
- Output(),
1067
- __metadata("design:type", EventEmitter)
1068
- ], MessageListComponent.prototype, "navigate", void 0);
1069
- __decorate([
1070
- Output(),
1071
- __metadata("design:type", EventEmitter)
1072
- ], MessageListComponent.prototype, "resize", void 0);
1073
- __decorate([
1074
- ViewChildren(ChatItem),
1075
- __metadata("design:type", QueryList)
1076
- ], MessageListComponent.prototype, "items", void 0);
1077
- __decorate([
1078
- HostBinding('class.k-message-list-content'),
1079
- __metadata("design:type", Boolean)
1080
- ], MessageListComponent.prototype, "cssClass", void 0);
1081
- __decorate([
1082
- HostListener('keydown', ['$event']),
1083
- __metadata("design:type", Function),
1084
- __metadata("design:paramtypes", [Object]),
1085
- __metadata("design:returntype", void 0)
1086
- ], MessageListComponent.prototype, "onKeydown", null);
1087
- __decorate([
1088
- HostListener('focusout', ['$event']),
1089
- __metadata("design:type", Function),
1090
- __metadata("design:paramtypes", [FocusEvent]),
1091
- __metadata("design:returntype", void 0)
1092
- ], MessageListComponent.prototype, "onBlur", null);
1093
- MessageListComponent = __decorate([
1094
- Component({
1095
- selector: 'kendo-chat-message-list',
1096
- template: `
1097
- <ng-container *ngFor="let group of view; last as lastGroup; trackBy: trackGroup">
1098
- <ng-container [ngSwitch]="group.type">
1099
- <div
1100
- *ngSwitchCase="'date-marker'"
1101
- class="k-timestamp"
1102
- >
1103
- {{ formatTimeStamp(group.timestamp) }}
1104
- </div>
1105
- <div
1106
- *ngSwitchCase="'message-group'"
1107
- class="k-message-group"
1108
- [class.k-alt]="isOwnMessage(group.messages[0])"
1109
- [class.k-no-avatar]="!group.author.avatarUrl"
1110
- >
1111
- <img
1112
- *ngIf="group.author.avatarUrl"
1113
- [attr.src]="group.author.avatarUrl"
1114
- class="k-avatar"
1115
- />
1116
- <p *ngIf="group.author.name" class="k-author">{{ group.author.name }}</p>
1117
- <ng-container
1118
- *ngFor="let msg of group.messages; first as firstMessage; last as lastMessage"
1119
- >
1120
- <img *ngIf="msg.user?.avatarUrl" [src]="msg.user?.avatarUrl" class="k-avatar">
1121
- <kendo-chat-message #message
1122
- [message]="msg"
1123
- [tabbable]="lastGroup && lastMessage"
1124
- [template]="messageTemplate"
1125
- (click)="select(message)"
1126
- (focus)="select(message)"
1127
- [class.k-only]="group.messages.length === 1"
1128
- [class.k-first]="group.messages.length > 1 && firstMessage"
1129
- [class.k-last]="group.messages.length > 1 && lastMessage"
1130
- >
1131
- </kendo-chat-message>
1132
-
1133
- <kendo-chat-attachment
1134
- *ngIf="msg.attachments && msg.attachments.length === 1"
1135
- [attachment]="msg.attachments[0]"
1136
- [template]="attachmentTemplate"
1137
- >
1138
- </kendo-chat-attachment>
1139
- </ng-container>
1140
- </div>
1141
-
1142
- <kendo-chat-message-attachments #attachments
1143
- *ngSwitchCase="'attachment-group'"
1144
- [attachments]="group.attachments"
1145
- [layout]="group.attachmentLayout"
1146
- [tabbable]="lastGroup"
1147
- [template]="attachmentTemplate"
1148
- (click)="select(attachments)"
1149
- (focus)="select(attachments)"
1150
- >
1151
- </kendo-chat-message-attachments>
1152
-
1153
- <kendo-chat-suggested-actions #actions
1154
- *ngSwitchCase="'action-group'"
1155
- [actions]="group.actions"
1156
- [tabbable]="lastGroup"
1157
- (dispatch)="dispatchAction($event, last(group.messages))"
1158
- (click)="select(actions)"
1159
- (focus)="select(actions)"
1160
- >
1161
- </kendo-chat-suggested-actions>
1162
- </ng-container>
1163
- </ng-container>
1164
- <kendo-resize-sensor (resize)="onResize()">
1165
- </kendo-resize-sensor>
1166
- `
1167
- }),
1168
- __metadata("design:paramtypes", [ElementRef, IntlService])
1169
- ], MessageListComponent);
1170
-
1171
- // Consider scroll to be at the bottom when within this number of pixels from the container height.
1172
- const maxDelta = 2;
1173
- /**
1174
- * @hidden
1175
- */
1176
- let ScrollAnchorDirective = class ScrollAnchorDirective {
1177
- constructor(element, zone, renderer) {
1178
- this.element = element;
1179
- this.zone = zone;
1180
- this.renderer = renderer;
1181
- this.autoScroll = true;
1182
- this.autoScrollChange = new EventEmitter();
1183
- this.overflowAnchor = 'none';
1184
- this.scrolling = false;
1185
- }
1186
- ngOnInit() {
1187
- this.zone.runOutsideAngular(() => {
1188
- this.unsubscribe = this.renderer.listen(this.element.nativeElement, 'scroll', () => this.onScroll());
1189
- });
1190
- }
1191
- ngAfterViewInit() {
1192
- this.scrollToBottom();
1193
- }
1194
- ngOnDestroy() {
1195
- if (this.unsubscribe) {
1196
- this.unsubscribe();
1197
- }
1198
- }
1199
- onScroll() {
1200
- if (this.scrolling) {
1201
- return;
1202
- }
1203
- const el = this.element.nativeElement;
1204
- const bottom = el.scrollTop + el.offsetHeight;
1205
- const height = el.scrollHeight;
1206
- const atBottom = height - bottom < maxDelta;
1207
- if (this.autoScroll !== atBottom) {
1208
- this.zone.run(() => {
1209
- this.autoScroll = atBottom;
1210
- this.autoScrollChange.emit(this.autoScroll);
1211
- });
1212
- }
1213
- }
1214
- scrollToBottom() {
1215
- if (!this.autoScroll) {
1216
- return;
1217
- }
1218
- const el = this.element.nativeElement;
1219
- el.scrollTop = el.scrollHeight - el.clientHeight;
1220
- this.scrolling = true;
1221
- this.zone.runOutsideAngular(() => setTimeout(() => this.scrolling = false, 1000));
1222
- }
1223
- };
1224
- __decorate([
1225
- Input(),
1226
- __metadata("design:type", Boolean)
1227
- ], ScrollAnchorDirective.prototype, "autoScroll", void 0);
1228
- __decorate([
1229
- Output(),
1230
- __metadata("design:type", EventEmitter)
1231
- ], ScrollAnchorDirective.prototype, "autoScrollChange", void 0);
1232
- __decorate([
1233
- HostBinding('style.overflow-anchor'),
1234
- __metadata("design:type", String)
1235
- ], ScrollAnchorDirective.prototype, "overflowAnchor", void 0);
1236
- ScrollAnchorDirective = __decorate([
1237
- Directive({
1238
- selector: '[kendoChatScrollAnchor]',
1239
- exportAs: 'scrollAnchor'
1240
- }),
1241
- __metadata("design:paramtypes", [ElementRef,
1242
- NgZone,
1243
- Renderer2])
1244
- ], ScrollAnchorDirective);
1245
-
1246
- var SuggestedActionsComponent_1;
1247
- // tslint:disable:no-forward-ref
1248
- /**
1249
- * @hidden
1250
- */
1251
- let SuggestedActionsComponent = SuggestedActionsComponent_1 = class SuggestedActionsComponent extends ChatItem {
1252
- // tslint:disable:no-forward-ref
1253
- /**
1254
- * @hidden
1255
- */
1256
- constructor() {
1257
- super(...arguments);
1258
- this.dispatch = new EventEmitter();
1259
- this.defaultClass = true;
1260
- this.selectedIndex = 0;
1261
- this.keyHandlers = {
1262
- [37 /* left */]: (e) => this.navigateTo(e, -1),
1263
- [39 /* right */]: (e) => this.navigateTo(e, 1),
1264
- [13 /* enter */]: (_, action) => this.actionClick(action)
1265
- };
1266
- }
1267
- isSelected(index) {
1268
- return this.selected && this.selectedIndex === index;
1269
- }
1270
- actionClick(action) {
1271
- this.dispatch.next(action);
1272
- }
1273
- actionKeydown(e, action) {
1274
- const handler = this.keyHandlers[e.keyCode];
1275
- if (handler) {
1276
- handler(e, action);
1277
- }
1278
- }
1279
- focus() {
1280
- this.select(this.selectedIndex);
1281
- }
1282
- select(index) {
1283
- this.selectedIndex = index;
1284
- const item = this.items.toArray()[index];
1285
- if (item) {
1286
- item.nativeElement.focus();
1287
- }
1288
- }
1289
- navigateTo(e, offset) {
1290
- const prevIndex = this.selectedIndex;
1291
- const nextIndex = Math.max(0, Math.min(prevIndex + offset, this.items.length - 1));
1292
- if (nextIndex !== prevIndex) {
1293
- this.select(nextIndex);
1294
- e.preventDefault();
1295
- }
1296
- }
1297
- };
1298
- __decorate([
1299
- Input(),
1300
- __metadata("design:type", Array)
1301
- ], SuggestedActionsComponent.prototype, "actions", void 0);
1302
- __decorate([
1303
- Input(),
1304
- __metadata("design:type", Boolean)
1305
- ], SuggestedActionsComponent.prototype, "tabbable", void 0);
1306
- __decorate([
1307
- Output(),
1308
- __metadata("design:type", EventEmitter)
1309
- ], SuggestedActionsComponent.prototype, "dispatch", void 0);
1310
- __decorate([
1311
- HostBinding('class.k-quick-replies'),
1312
- __metadata("design:type", Boolean)
1313
- ], SuggestedActionsComponent.prototype, "defaultClass", void 0);
1314
- __decorate([
1315
- ViewChildren('item'),
1316
- __metadata("design:type", QueryList)
1317
- ], SuggestedActionsComponent.prototype, "items", void 0);
1318
- SuggestedActionsComponent = SuggestedActionsComponent_1 = __decorate([
1319
- Component({
1320
- selector: 'kendo-chat-suggested-actions',
1321
- providers: [{
1322
- provide: ChatItem,
1323
- useExisting: forwardRef(() => SuggestedActionsComponent_1)
1324
- }],
1325
- template: `
1326
- <span #item
1327
- *ngFor="let action of actions; index as index; first as first; last as last"
1328
- class="k-quick-reply"
1329
- [class.k-state-selected]="isSelected(index)"
1330
- [class.k-state-focused]="isSelected(index)"
1331
- [class.k-first]="first"
1332
- [class.k-last]="last"
1333
- [attr.tabindex]="tabbable && selectedIndex === index ? '0' : '-1'"
1334
- (click)="actionClick(action)"
1335
- (keydown)="actionKeydown($event, action)"
1336
- >
1337
- {{ action.title || action.value }}
1338
- </span>
1339
- `
1340
- })
1341
- ], SuggestedActionsComponent);
1342
-
1343
- const PUBLIC_DIRECTIVES = [
1344
- ChatComponent,
1345
- CustomMessagesComponent,
1346
- AttachmentTemplateDirective,
1347
- MessageTemplateDirective,
1348
- HeroCardComponent
1349
- ];
1350
- const PRIVATE_DIRECTIVES = [
1351
- AttachmentComponent,
1352
- FocusedStateDirective,
1353
- LocalizedMessagesDirective,
1354
- MessageAttachmentsComponent,
1355
- MessageComponent,
1356
- MessageListComponent,
1357
- MessageTemplateDirective,
1358
- ScrollAnchorDirective,
1359
- SuggestedActionsComponent
1360
- ];
1361
- /**
1362
- * The [NgModule]({{ site.data.urls.angular['ngmodules'] }}) for the Chat component.
1363
- *
1364
- * @example
1365
- * ```ts-no-run
1366
- * import { NgModule } from '@angular/core';
1367
- * import { Component } from '@angular/core';
1368
- * import { BrowserModule } from '@angular/platform-browser';
1369
- *
1370
- * import { ChatModule } from '@progress/kendo-angular-conversational-ui';
1371
- * import { AppComponent } from './app.component';
1372
- *
1373
- * _@NgModule({
1374
- * imports: [ BrowserModule, ChatModule ],
1375
- * declarations: [ AppComponent ],
1376
- * bootstrap: [ AppComponent ]
1377
- * })
1378
- *
1379
- * export class AppModule { }
1380
- * ```
1381
- */
1382
- let ChatModule = class ChatModule {
1383
- };
1384
- ChatModule = __decorate([
1385
- NgModule({
1386
- declarations: [
1387
- ...PUBLIC_DIRECTIVES,
1388
- ...PRIVATE_DIRECTIVES
1389
- ],
1390
- exports: [PUBLIC_DIRECTIVES],
1391
- imports: [
1392
- ButtonModule,
1393
- CommonModule,
1394
- ResizeSensorModule
1395
- ]
1396
- })
1397
- ], ChatModule);
1398
-
1399
- /**
1400
- * Generated bundle index. Do not edit.
1401
- */
1402
-
1403
- export { PreventableEvent, HeroCardComponent, AttachmentComponent, ChatItem, CustomMessagesComponent, LocalizedMessagesDirective, Messages, MessageAttachmentsComponent, MessageListComponent, MessageComponent, SuggestedActionsComponent, FocusedStateDirective, ScrollAnchorDirective, ChatComponent, AttachmentTemplateDirective, MessageTemplateDirective, ChatModule, ExecuteActionEvent, SendMessageEvent };