Skip to content

Commit 449850b

Browse files
Ruslan FarkhutdinovRuslan Farkhutdinov
andauthored
Chat: Add speechToTextEnabled property (#32549)
Co-authored-by: Ruslan Farkhutdinov <ruslan.farkhutdinov@devexpress.com>
1 parent 24b2ab7 commit 449850b

5 files changed

Lines changed: 38 additions & 10 deletions

File tree

packages/devextreme-angular/src/ui/chat/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,19 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
422422
}
423423

424424

425+
/**
426+
* [descr:dxChatOptions.speechToTextEnabled]
427+
428+
*/
429+
@Input()
430+
get speechToTextEnabled(): boolean {
431+
return this._getOption('speechToTextEnabled');
432+
}
433+
set speechToTextEnabled(value: boolean) {
434+
this._setOption('speechToTextEnabled', value);
435+
}
436+
437+
425438

426439
@Input()
427440
get speechToTextOptions(): dxSpeechToTextOptions {
@@ -755,6 +768,13 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
755768
*/
756769
@Output() showUserNameChange: EventEmitter<boolean>;
757770

771+
/**
772+
773+
* This member supports the internal infrastructure and is not intended to be used directly from your code.
774+
775+
*/
776+
@Output() speechToTextEnabledChange: EventEmitter<boolean>;
777+
758778
/**
759779
760780
* This member supports the internal infrastructure and is not intended to be used directly from your code.
@@ -840,6 +860,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
840860
{ emit: 'showDayHeadersChange' },
841861
{ emit: 'showMessageTimestampChange' },
842862
{ emit: 'showUserNameChange' },
863+
{ emit: 'speechToTextEnabledChange' },
843864
{ emit: 'speechToTextOptionsChange' },
844865
{ emit: 'typingUsersChange' },
845866
{ emit: 'userChange' },

packages/devextreme-vue/src/chat.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ type AccessibleOptions = Pick<Properties,
112112
"showDayHeaders" |
113113
"showMessageTimestamp" |
114114
"showUserName" |
115+
"speechToTextEnabled" |
115116
"speechToTextOptions" |
116117
"typingUsers" |
117118
"user" |
@@ -162,6 +163,7 @@ const componentConfig = {
162163
showDayHeaders: Boolean,
163164
showMessageTimestamp: Boolean,
164165
showUserName: Boolean,
166+
speechToTextEnabled: Boolean,
165167
speechToTextOptions: Object as PropType<dxSpeechToTextOptions | Record<string, any>>,
166168
typingUsers: Array as PropType<Array<User>>,
167169
user: Object as PropType<User | Record<string, any>>,
@@ -208,6 +210,7 @@ const componentConfig = {
208210
"update:showDayHeaders": null,
209211
"update:showMessageTimestamp": null,
210212
"update:showUserName": null,
213+
"update:speechToTextEnabled": null,
211214
"update:speechToTextOptions": null,
212215
"update:typingUsers": null,
213216
"update:user": null,

packages/devextreme/js/__internal/ui/chat/chat.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import type {
2020
TypingEndEvent,
2121
TypingStartEvent,
2222
} from '@js/ui/chat';
23-
import type { Properties as SpeechToTextProperties } from '@js/ui/speech_to_text';
2423
import { invokeConditionally } from '@ts/core/utils/conditional_invoke';
2524
import type { OptionChanged } from '@ts/core/widget/types';
2625
import Widget from '@ts/core/widget/widget';
@@ -41,15 +40,10 @@ import type {
4140
import MessageList from '@ts/ui/chat/messagelist';
4241
import type { DataChange } from '@ts/ui/collection/collection_widget.base';
4342

44-
type Properties = ChatProperties & {
45-
speechToTextEnabled?: boolean;
46-
speechToTextOptions?: SpeechToTextProperties;
47-
};
48-
4943
const CHAT_CLASS = 'dx-chat';
5044
const TEXTEDITOR_INPUT_CLASS = 'dx-texteditor-input';
5145

52-
class Chat extends Widget<Properties> {
46+
class Chat extends Widget<ChatProperties> {
5347
_messageBox!: MessageBox;
5448

5549
_messageList!: MessageList;
@@ -82,7 +76,7 @@ class Chat extends Widget<Properties> {
8276

8377
_attachmentDownloadAction?: (e: Partial<AttachmentDownloadClickEvent>) => void;
8478

85-
_getDefaultOptions(): Properties {
79+
_getDefaultOptions(): ChatProperties {
8680
return {
8781
...super._getDefaultOptions(),
8882
activeStateEnabled: true,
@@ -645,7 +639,7 @@ class Chat extends Widget<Properties> {
645639
return $input;
646640
}
647641

648-
_optionChanged(args: OptionChanged<Properties>): void {
642+
_optionChanged(args: OptionChanged<ChatProperties>): void {
649643
const { name, fullName, value } = args;
650644

651645
switch (name) {
@@ -660,7 +654,7 @@ class Chat extends Widget<Properties> {
660654
this._messageBox.option(fullName, value);
661655
break;
662656
case 'user': {
663-
const author = value as Properties[typeof name];
657+
const author = value as ChatProperties[typeof name];
664658

665659
this._messageList.option('currentUserId', author?.id);
666660
break;

packages/devextreme/js/ui/chat.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,12 @@ export interface dxChatOptions extends WidgetOptions<dxChat> {
481481
* @public
482482
*/
483483
showMessageTimestamp?: boolean;
484+
/**
485+
* @docid
486+
* @default false
487+
* @public
488+
*/
489+
speechToTextEnabled?: boolean;
484490
/**
485491
* @docid
486492
* @type dxSpeechToTextOptions

packages/devextreme/ts/dx.all.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11457,6 +11457,10 @@ declare module DevExpress.ui {
1145711457
* [descr:dxChatOptions.showMessageTimestamp]
1145811458
*/
1145911459
showMessageTimestamp?: boolean;
11460+
/**
11461+
* [descr:dxChatOptions.speechToTextEnabled]
11462+
*/
11463+
speechToTextEnabled?: boolean;
1146011464
/**
1146111465
* [descr:dxChatOptions.speechToTextOptions]
1146211466
*/

0 commit comments

Comments
 (0)