@progress/kendo-angular-conversational-ui 4.0.2-dev.202203091004 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/js/kendo-angular-conversational-ui.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/cards/hero-card.component.js +1 -1
- package/dist/es/chat/attachment.component.js +1 -1
- package/dist/es/chat/chat.component.js +35 -38
- package/dist/es/chat/chat.directives.js +1 -0
- package/dist/es/chat/chat.module.js +6 -2
- package/dist/es/chat/message-attachments.component.js +1 -1
- package/dist/es/chat/message-box.component.js +124 -0
- package/dist/es/chat/message-box.directive.js +24 -0
- package/dist/es/chat/message-list.component.js +1 -1
- package/dist/es/chat/message.component.js +1 -1
- package/dist/es/chat/suggested-actions.component.js +1 -1
- package/dist/es/common/focused-state.directive.js +1 -1
- package/dist/es/common/models/message-box-options.js +4 -0
- package/dist/es/index.js +1 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/es2015/cards/hero-card.component.js +22 -21
- package/dist/es2015/chat/attachment.component.js +19 -19
- package/dist/es2015/chat/chat.component.d.ts +13 -10
- package/dist/es2015/chat/chat.component.js +67 -83
- package/dist/es2015/chat/chat.directives.d.ts +1 -0
- package/dist/es2015/chat/chat.directives.js +1 -0
- package/dist/es2015/chat/chat.module.js +6 -2
- package/dist/es2015/chat/message-attachments.component.js +31 -31
- package/dist/es2015/chat/message-box.component.d.ts +39 -0
- package/dist/es2015/chat/message-box.component.js +157 -0
- package/dist/es2015/chat/message-box.directive.d.ts +14 -0
- package/dist/es2015/chat/message-box.directive.js +23 -0
- package/dist/es2015/chat/message-list.component.js +66 -66
- package/dist/es2015/chat/message.component.js +33 -33
- package/dist/es2015/chat/suggested-actions.component.js +15 -14
- package/dist/es2015/common/focused-state.directive.js +1 -1
- package/dist/es2015/common/models/message-box-options.d.ts +8 -0
- package/dist/es2015/common/models/message-box-options.js +4 -0
- package/dist/es2015/index.d.ts +1 -0
- package/dist/es2015/index.js +1 -0
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/main.d.ts +1 -0
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/fesm2015/index.js +422 -271
- package/dist/fesm5/index.js +178 -48
- package/dist/npm/cards/hero-card.component.js +1 -1
- package/dist/npm/chat/attachment.component.js +1 -1
- package/dist/npm/chat/chat.component.js +35 -38
- package/dist/npm/chat/chat.directives.js +2 -0
- package/dist/npm/chat/chat.module.js +6 -2
- package/dist/npm/chat/message-attachments.component.js +1 -1
- package/dist/npm/chat/message-box.component.js +126 -0
- package/dist/npm/chat/message-box.directive.js +26 -0
- package/dist/npm/chat/message-list.component.js +1 -1
- package/dist/npm/chat/message.component.js +1 -1
- package/dist/npm/chat/suggested-actions.component.js +1 -1
- package/dist/npm/common/focused-state.directive.js +1 -1
- package/dist/npm/common/models/message-box-options.js +6 -0
- package/dist/npm/index.js +2 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/systemjs/kendo-angular-conversational-ui.js +1 -1
- package/package.json +8 -6
|
@@ -8,11 +8,10 @@ import { AttachmentTemplateDirective } from './attachment-template.directive';
|
|
|
8
8
|
import { L10N_PREFIX, LocalizationService } from '@progress/kendo-angular-l10n';
|
|
9
9
|
import { makeHandler } from './builtin-actions';
|
|
10
10
|
import { MessageTemplateDirective } from './message-template.directive';
|
|
11
|
-
import { SendMessageEvent } from '../api/post-message-event';
|
|
12
11
|
import { validatePackage } from '@progress/kendo-licensing';
|
|
13
12
|
import { packageMetadata } from '../package-metadata';
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import { ChatMessageBoxTemplateDirective } from './message-box.directive';
|
|
14
|
+
import { MessageBoxComponent } from './message-box.component';
|
|
16
15
|
/**
|
|
17
16
|
* Represents the Kendo UI Chat component for Angular.
|
|
18
17
|
*
|
|
@@ -27,6 +26,12 @@ let ChatComponent = class ChatComponent {
|
|
|
27
26
|
constructor(localization, zone) {
|
|
28
27
|
this.localization = localization;
|
|
29
28
|
this.zone = zone;
|
|
29
|
+
/**
|
|
30
|
+
* Used to switch between a one-liner input or a textarea.
|
|
31
|
+
* ([see example]({% slug message_box %})#toc-message-box-types).
|
|
32
|
+
* @default input
|
|
33
|
+
*/
|
|
34
|
+
this.messageBoxType = 'textbox';
|
|
30
35
|
/**
|
|
31
36
|
* Fires when the user types a message and clicks the **Send** button or presses **Enter**.
|
|
32
37
|
* Emits the [`SendMessageEvent`]({% slug api_conversational-ui_sendmessageevent %}).
|
|
@@ -53,11 +58,17 @@ let ChatComponent = class ChatComponent {
|
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
60
|
get className() {
|
|
56
|
-
return 'k-
|
|
61
|
+
return 'k-chat';
|
|
57
62
|
}
|
|
58
63
|
get dirAttr() {
|
|
59
64
|
return this.direction;
|
|
60
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
69
|
+
get localizationText() {
|
|
70
|
+
return this.localization;
|
|
71
|
+
}
|
|
61
72
|
ngOnChanges() {
|
|
62
73
|
this.zone.runOutsideAngular(() => setTimeout(() => {
|
|
63
74
|
this.messageList.nativeElement.style.flex = '1 1 auto';
|
|
@@ -76,33 +87,6 @@ let ChatComponent = class ChatComponent {
|
|
|
76
87
|
this.localizationChangeSubscription.unsubscribe();
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
|
-
/**
|
|
80
|
-
* @hidden
|
|
81
|
-
*/
|
|
82
|
-
sendClick() {
|
|
83
|
-
const input = this.messageInput.nativeElement;
|
|
84
|
-
const value = input.value;
|
|
85
|
-
if (!value) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const message = {
|
|
89
|
-
author: this.user,
|
|
90
|
-
text: value,
|
|
91
|
-
timestamp: new Date()
|
|
92
|
-
};
|
|
93
|
-
this.sendMessage.emit(new SendMessageEvent(message));
|
|
94
|
-
input.value = null;
|
|
95
|
-
input.focus();
|
|
96
|
-
this.autoScroll = true;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* @hidden
|
|
100
|
-
*/
|
|
101
|
-
inputKeydown(e) {
|
|
102
|
-
if (e.keyCode === 13 /* enter */) {
|
|
103
|
-
this.sendClick();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
90
|
/**
|
|
107
91
|
* @hidden
|
|
108
92
|
*/
|
|
@@ -111,7 +95,9 @@ let ChatComponent = class ChatComponent {
|
|
|
111
95
|
if (!e.isDefaultPrevented()) {
|
|
112
96
|
const handler = makeHandler(e.action);
|
|
113
97
|
handler(e.action, this);
|
|
114
|
-
this.
|
|
98
|
+
if (!this.messageBoxTemplate) {
|
|
99
|
+
this.messageBox.messageBoxInput.nativeElement.focus();
|
|
100
|
+
}
|
|
115
101
|
}
|
|
116
102
|
}
|
|
117
103
|
/**
|
|
@@ -129,6 +115,10 @@ tslib_1.__decorate([
|
|
|
129
115
|
Input(),
|
|
130
116
|
tslib_1.__metadata("design:type", Object)
|
|
131
117
|
], ChatComponent.prototype, "user", void 0);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
Input(),
|
|
120
|
+
tslib_1.__metadata("design:type", String)
|
|
121
|
+
], ChatComponent.prototype, "messageBoxType", void 0);
|
|
132
122
|
tslib_1.__decorate([
|
|
133
123
|
Output(),
|
|
134
124
|
tslib_1.__metadata("design:type", EventEmitter)
|
|
@@ -156,9 +146,13 @@ tslib_1.__decorate([
|
|
|
156
146
|
tslib_1.__metadata("design:type", MessageTemplateDirective)
|
|
157
147
|
], ChatComponent.prototype, "messageTemplate", void 0);
|
|
158
148
|
tslib_1.__decorate([
|
|
159
|
-
|
|
160
|
-
tslib_1.__metadata("design:type",
|
|
161
|
-
], ChatComponent.prototype, "
|
|
149
|
+
ContentChild(ChatMessageBoxTemplateDirective, { static: false }),
|
|
150
|
+
tslib_1.__metadata("design:type", ChatMessageBoxTemplateDirective)
|
|
151
|
+
], ChatComponent.prototype, "messageBoxTemplate", void 0);
|
|
152
|
+
tslib_1.__decorate([
|
|
153
|
+
ViewChild('messageBox', { static: false }),
|
|
154
|
+
tslib_1.__metadata("design:type", MessageBoxComponent)
|
|
155
|
+
], ChatComponent.prototype, "messageBox", void 0);
|
|
162
156
|
tslib_1.__decorate([
|
|
163
157
|
ViewChild('messageList', { static: true }),
|
|
164
158
|
tslib_1.__metadata("design:type", ElementRef)
|
|
@@ -174,57 +168,47 @@ ChatComponent = tslib_1.__decorate([
|
|
|
174
168
|
],
|
|
175
169
|
selector: 'kendo-chat',
|
|
176
170
|
template: `
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
171
|
+
<ng-container
|
|
172
|
+
kendoChatLocalizedMessages
|
|
173
|
+
i18n-messagePlaceholder="kendo.chat.messagePlaceholder|The placholder text of the message text input"
|
|
174
|
+
messagePlaceholder="Type a message..."
|
|
181
175
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
i18n-send="kendo.chat.send|The text for the Send button"
|
|
177
|
+
send="Send..."
|
|
178
|
+
>
|
|
179
|
+
</ng-container>
|
|
186
180
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
181
|
+
<div
|
|
182
|
+
#messageList
|
|
183
|
+
class="k-message-list k-avatars"
|
|
184
|
+
aria-live="polite" role="log"
|
|
185
|
+
kendoChatScrollAnchor
|
|
186
|
+
#anchor="scrollAnchor"
|
|
187
|
+
[(autoScroll)]="autoScroll"
|
|
188
|
+
>
|
|
189
|
+
<kendo-chat-message-list
|
|
190
|
+
[messages]="messages"
|
|
191
|
+
[messageTemplate]="messageTemplate"
|
|
192
|
+
[attachmentTemplate]="attachmentTemplate"
|
|
193
|
+
[user]="user"
|
|
194
|
+
(executeAction)="dispatchAction($event)"
|
|
195
|
+
(resize)="anchor.scrollToBottom()"
|
|
196
|
+
(navigate)="this.autoScroll = false"
|
|
197
|
+
>
|
|
198
|
+
</kendo-chat-message-list>
|
|
199
|
+
</div>
|
|
200
|
+
<kendo-message-box
|
|
201
|
+
#messageBox
|
|
202
|
+
[messageBoxTemplate]="messageBoxTemplate"
|
|
203
|
+
[type]="messageBoxType"
|
|
199
204
|
[user]="user"
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
<div class="k-message-box">
|
|
208
|
-
<input
|
|
209
|
-
#messageInput
|
|
210
|
-
kendoChatFocusedState
|
|
211
|
-
type="text"
|
|
212
|
-
class="k-input"
|
|
213
|
-
[placeholder]="textFor('messagePlaceholder')"
|
|
214
|
-
(keydown)="inputKeydown($event)"
|
|
215
|
-
>
|
|
216
|
-
<button
|
|
217
|
-
kendoButton
|
|
218
|
-
fillMode="flat"
|
|
219
|
-
class="k-button-send"
|
|
220
|
-
tabindex="-1"
|
|
221
|
-
[attr.title]="textFor('send')"
|
|
222
|
-
(click)="sendClick()"
|
|
223
|
-
>${sendIcon}</button>
|
|
224
|
-
</div>
|
|
225
|
-
`
|
|
205
|
+
[autoScroll]="autoScroll"
|
|
206
|
+
[localization]="localizationText"
|
|
207
|
+
(sendMessage)="sendMessage.emit($event)"
|
|
208
|
+
>
|
|
209
|
+
</kendo-message-box>
|
|
210
|
+
`
|
|
226
211
|
}),
|
|
227
|
-
tslib_1.__metadata("design:paramtypes", [LocalizationService,
|
|
228
|
-
NgZone])
|
|
212
|
+
tslib_1.__metadata("design:paramtypes", [LocalizationService, NgZone])
|
|
229
213
|
], ChatComponent);
|
|
230
214
|
export { ChatComponent };
|
|
@@ -5,3 +5,4 @@
|
|
|
5
5
|
export { ChatComponent } from './chat.component';
|
|
6
6
|
export { AttachmentTemplateDirective } from './attachment-template.directive';
|
|
7
7
|
export { MessageTemplateDirective } from './message-template.directive';
|
|
8
|
+
export { ChatMessageBoxTemplateDirective } from './message-box.directive';
|
|
@@ -5,3 +5,4 @@
|
|
|
5
5
|
export { ChatComponent } from './chat.component';
|
|
6
6
|
export { AttachmentTemplateDirective } from './attachment-template.directive';
|
|
7
7
|
export { MessageTemplateDirective } from './message-template.directive';
|
|
8
|
+
export { ChatMessageBoxTemplateDirective } from './message-box.directive';
|
|
@@ -18,12 +18,15 @@ import { MessageListComponent } from './message-list.component';
|
|
|
18
18
|
import { NgModule } from '@angular/core';
|
|
19
19
|
import { ScrollAnchorDirective } from '../common/scroll-anchor.directive';
|
|
20
20
|
import { SuggestedActionsComponent } from './suggested-actions.component';
|
|
21
|
+
import { MessageBoxComponent } from './message-box.component';
|
|
22
|
+
import { ChatMessageBoxTemplateDirective } from './message-box.directive';
|
|
21
23
|
const PUBLIC_DIRECTIVES = [
|
|
22
24
|
ChatComponent,
|
|
23
25
|
CustomMessagesComponent,
|
|
24
26
|
AttachmentTemplateDirective,
|
|
25
27
|
MessageTemplateDirective,
|
|
26
|
-
HeroCardComponent
|
|
28
|
+
HeroCardComponent,
|
|
29
|
+
ChatMessageBoxTemplateDirective
|
|
27
30
|
];
|
|
28
31
|
const PRIVATE_DIRECTIVES = [
|
|
29
32
|
AttachmentComponent,
|
|
@@ -34,7 +37,8 @@ const PRIVATE_DIRECTIVES = [
|
|
|
34
37
|
MessageListComponent,
|
|
35
38
|
MessageTemplateDirective,
|
|
36
39
|
ScrollAnchorDirective,
|
|
37
|
-
SuggestedActionsComponent
|
|
40
|
+
SuggestedActionsComponent,
|
|
41
|
+
MessageBoxComponent
|
|
38
42
|
];
|
|
39
43
|
/**
|
|
40
44
|
* The [NgModule]({{ site.data.urls.angular['ngmodules'] }}) for the Chat component.
|
|
@@ -131,37 +131,37 @@ MessageAttachmentsComponent = MessageAttachmentsComponent_1 = tslib_1.__decorate
|
|
|
131
131
|
}],
|
|
132
132
|
selector: 'kendo-chat-message-attachments',
|
|
133
133
|
template: `
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
134
|
+
<button
|
|
135
|
+
*ngIf="carousel && scrollPosition > 0"
|
|
136
|
+
(click)="scrollTo(-1)"
|
|
137
|
+
class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
|
|
138
|
+
tabindex="-1">
|
|
139
|
+
<span class="k-icon k-button-icon k-i-arrow-chevron-left"></span>
|
|
140
|
+
</button>
|
|
141
|
+
<div #deck [class.k-card-deck]="carousel">
|
|
142
|
+
<kendo-chat-attachment #item
|
|
143
|
+
*ngFor="let att of attachments; index as index; first as first; last as last"
|
|
144
|
+
[attachment]="att"
|
|
145
|
+
[template]="template"
|
|
146
|
+
[class.k-state-selected]="isSelected(index)"
|
|
147
|
+
[class.k-state-focused]="isSelected(index)"
|
|
148
|
+
[class.k-card-wrap]="true"
|
|
149
|
+
[class.k-first]="first"
|
|
150
|
+
[class.k-last]="last"
|
|
151
|
+
[attr.tabindex]="tabbable && isSelected(index) ? '0' : '-1'"
|
|
152
|
+
(click)="itemClick(index)"
|
|
153
|
+
(keydown)="itemKeydown($event, att)"
|
|
154
|
+
>
|
|
155
|
+
</kendo-chat-attachment>
|
|
156
|
+
</div>
|
|
157
|
+
<button
|
|
158
|
+
*ngIf="carousel && scrollPosition < 1"
|
|
159
|
+
(click)="scrollTo(1)"
|
|
160
|
+
class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
|
|
161
|
+
tabindex="-1">
|
|
162
|
+
<span class="k-icon k-button-icon k-i-arrow-chevron-right"></span>
|
|
163
|
+
</button>
|
|
164
|
+
`
|
|
165
165
|
}),
|
|
166
166
|
tslib_1.__metadata("design:paramtypes", [NgZone])
|
|
167
167
|
], MessageAttachmentsComponent);
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { ElementRef, EventEmitter } from '@angular/core';
|
|
6
|
+
import { User } from '../api/user.interface';
|
|
7
|
+
import { MessageBoxType } from '../common/models/message-box-options';
|
|
8
|
+
import { LocalizationService } from '@progress/kendo-angular-l10n';
|
|
9
|
+
import { ChatMessageBoxTemplateDirective } from './message-box.directive';
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
export declare class MessageBoxComponent {
|
|
14
|
+
hostClasses: string;
|
|
15
|
+
readonly messageBoxValue: boolean;
|
|
16
|
+
messageBoxInput: ElementRef;
|
|
17
|
+
user: User;
|
|
18
|
+
autoScroll: boolean;
|
|
19
|
+
type: MessageBoxType;
|
|
20
|
+
localization: LocalizationService;
|
|
21
|
+
messageBoxTemplate: ChatMessageBoxTemplateDirective;
|
|
22
|
+
sendMessage: EventEmitter<any>;
|
|
23
|
+
/**
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
sendClick(): void;
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
inputKeydown(e: any): void;
|
|
31
|
+
/**
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
textAreaKeydown(e: any): void;
|
|
35
|
+
/**
|
|
36
|
+
* @hidden
|
|
37
|
+
*/
|
|
38
|
+
textFor(key: string): string;
|
|
39
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
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 * as tslib_1 from "tslib";
|
|
6
|
+
import { Component, ElementRef, EventEmitter, HostBinding, Input, Output, ViewChild } from '@angular/core';
|
|
7
|
+
import { SendMessageEvent } from '../api/post-message-event';
|
|
8
|
+
import { LocalizationService } from '@progress/kendo-angular-l10n';
|
|
9
|
+
import { Keys } from '@progress/kendo-angular-common';
|
|
10
|
+
import { ChatMessageBoxTemplateDirective } from './message-box.directive';
|
|
11
|
+
// tslint:disable-next-line:max-line-length
|
|
12
|
+
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>';
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
let MessageBoxComponent = class MessageBoxComponent {
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
constructor() {
|
|
21
|
+
this.hostClasses = 'k-message-box k-input k-input-md k-rounded-md k-input-solid';
|
|
22
|
+
this.sendMessage = new EventEmitter();
|
|
23
|
+
}
|
|
24
|
+
get messageBoxValue() {
|
|
25
|
+
return this.type === 'textarea';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
sendClick() {
|
|
31
|
+
const input = this.messageBoxInput.nativeElement;
|
|
32
|
+
const value = input.value;
|
|
33
|
+
if (!value) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const message = {
|
|
37
|
+
author: this.user,
|
|
38
|
+
text: value,
|
|
39
|
+
timestamp: new Date()
|
|
40
|
+
};
|
|
41
|
+
this.sendMessage.emit(new SendMessageEvent(message));
|
|
42
|
+
input.value = null;
|
|
43
|
+
input.focus();
|
|
44
|
+
this.autoScroll = true;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @hidden
|
|
48
|
+
*/
|
|
49
|
+
inputKeydown(e) {
|
|
50
|
+
if (e.keyCode === Keys.Enter) {
|
|
51
|
+
this.sendClick();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @hidden
|
|
56
|
+
*/
|
|
57
|
+
textAreaKeydown(e) {
|
|
58
|
+
const isEnter = e.keyCode === Keys.Enter;
|
|
59
|
+
if (!isEnter) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const newLine = (e.metaKey || e.ctrlKey);
|
|
63
|
+
const enterOnly = !(e.shiftKey || e.metaKey || e.ctrlKey);
|
|
64
|
+
if (enterOnly) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
this.sendClick();
|
|
67
|
+
}
|
|
68
|
+
if (newLine) {
|
|
69
|
+
this.messageBoxInput.nativeElement.value += `\r\n`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @hidden
|
|
74
|
+
*/
|
|
75
|
+
textFor(key) {
|
|
76
|
+
return this.localization.get(key);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
HostBinding('class'),
|
|
81
|
+
tslib_1.__metadata("design:type", String)
|
|
82
|
+
], MessageBoxComponent.prototype, "hostClasses", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
HostBinding('class.\!k-align-items-end'),
|
|
85
|
+
tslib_1.__metadata("design:type", Boolean),
|
|
86
|
+
tslib_1.__metadata("design:paramtypes", [])
|
|
87
|
+
], MessageBoxComponent.prototype, "messageBoxValue", null);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
ViewChild('messageBoxInput', { static: false }),
|
|
90
|
+
tslib_1.__metadata("design:type", ElementRef)
|
|
91
|
+
], MessageBoxComponent.prototype, "messageBoxInput", void 0);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
Input(),
|
|
94
|
+
tslib_1.__metadata("design:type", Object)
|
|
95
|
+
], MessageBoxComponent.prototype, "user", void 0);
|
|
96
|
+
tslib_1.__decorate([
|
|
97
|
+
Input(),
|
|
98
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
99
|
+
], MessageBoxComponent.prototype, "autoScroll", void 0);
|
|
100
|
+
tslib_1.__decorate([
|
|
101
|
+
Input(),
|
|
102
|
+
tslib_1.__metadata("design:type", String)
|
|
103
|
+
], MessageBoxComponent.prototype, "type", void 0);
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
Input(),
|
|
106
|
+
tslib_1.__metadata("design:type", LocalizationService)
|
|
107
|
+
], MessageBoxComponent.prototype, "localization", void 0);
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
Input(),
|
|
110
|
+
tslib_1.__metadata("design:type", ChatMessageBoxTemplateDirective)
|
|
111
|
+
], MessageBoxComponent.prototype, "messageBoxTemplate", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
Output(),
|
|
114
|
+
tslib_1.__metadata("design:type", EventEmitter)
|
|
115
|
+
], MessageBoxComponent.prototype, "sendMessage", void 0);
|
|
116
|
+
MessageBoxComponent = tslib_1.__decorate([
|
|
117
|
+
Component({
|
|
118
|
+
selector: 'kendo-message-box',
|
|
119
|
+
template: `
|
|
120
|
+
<ng-container *ngIf="!messageBoxTemplate">
|
|
121
|
+
<input
|
|
122
|
+
*ngIf="type === 'textbox'"
|
|
123
|
+
#messageBoxInput
|
|
124
|
+
kendoChatFocusedState
|
|
125
|
+
type="text"
|
|
126
|
+
class="k-textbox k-input k-input-md k-input-solid"
|
|
127
|
+
[placeholder]="textFor('messagePlaceholder')"
|
|
128
|
+
(keydown)="inputKeydown($event)"
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
<textarea
|
|
132
|
+
*ngIf="type === 'textarea'"
|
|
133
|
+
#messageBoxInput
|
|
134
|
+
kendoChatFocusedState
|
|
135
|
+
[rows]="3"
|
|
136
|
+
class="k-textarea k-input k-input-md k-input-solid !k-overflow-y-auto k-resize-none"
|
|
137
|
+
[placeholder]="textFor('messagePlaceholder')"
|
|
138
|
+
(keydown)="textAreaKeydown($event)"
|
|
139
|
+
></textarea>
|
|
140
|
+
|
|
141
|
+
<button
|
|
142
|
+
kendoButton
|
|
143
|
+
fillMode="flat"
|
|
144
|
+
class="k-button-send"
|
|
145
|
+
[tabindex]="0"
|
|
146
|
+
[attr.title]="textFor('send')"
|
|
147
|
+
(click)="sendClick()"
|
|
148
|
+
>
|
|
149
|
+
${sendIcon}
|
|
150
|
+
</button>
|
|
151
|
+
</ng-container>
|
|
152
|
+
|
|
153
|
+
<ng-template *ngIf="messageBoxTemplate" [ngTemplateOutlet]="messageBoxTemplate?.templateRef"></ng-template>
|
|
154
|
+
`
|
|
155
|
+
})
|
|
156
|
+
], MessageBoxComponent);
|
|
157
|
+
export { MessageBoxComponent };
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { TemplateRef } from '@angular/core';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a message box area that overrides the default message box of the Conversational UI Component.
|
|
8
|
+
* To define a message-box template, nest an `<ng-template>` tag with the `kendoChatMessageBoxTemplate` directive inside the `<kendo-chat>` tag
|
|
9
|
+
* [see example]({% slug message_box %}#toc-message-box-template).
|
|
10
|
+
*/
|
|
11
|
+
export declare class ChatMessageBoxTemplateDirective {
|
|
12
|
+
templateRef: TemplateRef<any>;
|
|
13
|
+
constructor(templateRef: TemplateRef<any>);
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 * as tslib_1 from "tslib";
|
|
6
|
+
import { Directive, TemplateRef } from '@angular/core';
|
|
7
|
+
/**
|
|
8
|
+
* Creates a message box area that overrides the default message box of the Conversational UI Component.
|
|
9
|
+
* To define a message-box template, nest an `<ng-template>` tag with the `kendoChatMessageBoxTemplate` directive inside the `<kendo-chat>` tag
|
|
10
|
+
* [see example]({% slug message_box %}#toc-message-box-template).
|
|
11
|
+
*/
|
|
12
|
+
let ChatMessageBoxTemplateDirective = class ChatMessageBoxTemplateDirective {
|
|
13
|
+
constructor(templateRef) {
|
|
14
|
+
this.templateRef = templateRef;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
ChatMessageBoxTemplateDirective = tslib_1.__decorate([
|
|
18
|
+
Directive({
|
|
19
|
+
selector: '[kendoChatMessageBoxTemplate]'
|
|
20
|
+
}),
|
|
21
|
+
tslib_1.__metadata("design:paramtypes", [TemplateRef])
|
|
22
|
+
], ChatMessageBoxTemplateDirective);
|
|
23
|
+
export { ChatMessageBoxTemplateDirective };
|