Skip to content

Commit 23dbb08

Browse files
marker-daomarker dao ®
andauthored
Chat: Add sendButtonOptions to .d.ts (#33122)
Co-authored-by: marker dao ® <youdontknow@marker-dao.eth>
1 parent 1710f03 commit 23dbb08

9 files changed

Lines changed: 360 additions & 118 deletions

File tree

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from '@angular/core';
2323

2424

25-
import type { default as dxChat, Alert, Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, InputFieldTextChangedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, OptionChangedEvent, TypingEndEvent, TypingStartEvent, User } from 'devextreme/ui/chat';
25+
import type { default as dxChat, Alert, Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, InputFieldTextChangedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, OptionChangedEvent, TypingEndEvent, TypingStartEvent, SendButtonProperties, User } from 'devextreme/ui/chat';
2626
import type { default as DataSource, DataSourceOptions } from 'devextreme/data/data_source';
2727
import type { Store } from 'devextreme/data/store';
2828
import type { Format } from 'devextreme/common/core/localization';
@@ -61,6 +61,7 @@ import { DxoChatEditingModule } from 'devextreme-angular/ui/chat/nested';
6161
import { DxoChatFileUploaderOptionsModule } from 'devextreme-angular/ui/chat/nested';
6262
import { DxiChatItemModule } from 'devextreme-angular/ui/chat/nested';
6363
import { DxoChatMessageTimestampFormatModule } from 'devextreme-angular/ui/chat/nested';
64+
import { DxoChatSendButtonOptionsModule } from 'devextreme-angular/ui/chat/nested';
6465
import { DxoChatSpeechRecognitionConfigModule } from 'devextreme-angular/ui/chat/nested';
6566
import { DxoChatSpeechToTextOptionsModule } from 'devextreme-angular/ui/chat/nested';
6667
import { DxiChatTypingUserModule } from 'devextreme-angular/ui/chat/nested';
@@ -368,6 +369,16 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
368369
}
369370

370371

372+
373+
@Input()
374+
get sendButtonOptions(): SendButtonProperties {
375+
return this._getOption('sendButtonOptions');
376+
}
377+
set sendButtonOptions(value: SendButtonProperties) {
378+
this._setOption('sendButtonOptions', value);
379+
}
380+
381+
371382
/**
372383
* [descr:dxChatOptions.showAvatar]
373384
@@ -746,6 +757,13 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
746757
*/
747758
@Output() rtlEnabledChange: EventEmitter<boolean>;
748759

760+
/**
761+
762+
* This member supports the internal infrastructure and is not intended to be used directly from your code.
763+
764+
*/
765+
@Output() sendButtonOptionsChange: EventEmitter<SendButtonProperties>;
766+
749767
/**
750768
751769
* This member supports the internal infrastructure and is not intended to be used directly from your code.
@@ -863,6 +881,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
863881
{ emit: 'messageTimestampFormatChange' },
864882
{ emit: 'reloadOnChangeChange' },
865883
{ emit: 'rtlEnabledChange' },
884+
{ emit: 'sendButtonOptionsChange' },
866885
{ emit: 'showAvatarChange' },
867886
{ emit: 'showDayHeadersChange' },
868887
{ emit: 'showMessageTimestampChange' },
@@ -943,6 +962,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
943962
DxoChatFileUploaderOptionsModule,
944963
DxiChatItemModule,
945964
DxoChatMessageTimestampFormatModule,
965+
DxoChatSendButtonOptionsModule,
946966
DxoChatSpeechRecognitionConfigModule,
947967
DxoChatSpeechToTextOptionsModule,
948968
DxiChatTypingUserModule,
@@ -969,6 +989,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges
969989
DxoChatFileUploaderOptionsModule,
970990
DxiChatItemModule,
971991
DxoChatMessageTimestampFormatModule,
992+
DxoChatSendButtonOptionsModule,
972993
DxoChatSpeechRecognitionConfigModule,
973994
DxoChatSpeechToTextOptionsModule,
974995
DxiChatTypingUserModule,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from './editing';
77
export * from './file-uploader-options';
88
export * from './item-dxi';
99
export * from './message-timestamp-format';
10+
export * from './send-button-options';
1011
export * from './speech-recognition-config';
1112
export * from './speech-to-text-options';
1213
export * from './typing-user-dxi';
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* tslint:disable:max-line-length */
2+
3+
4+
import {
5+
Component,
6+
OnInit,
7+
OnDestroy,
8+
NgModule,
9+
Host,
10+
SkipSelf,
11+
Input
12+
} from '@angular/core';
13+
14+
15+
16+
17+
import type { SendButtonAction, SendButtonClickEvent } from 'devextreme/ui/chat';
18+
19+
import {
20+
DxIntegrationModule,
21+
NestedOptionHost,
22+
} from 'devextreme-angular/core';
23+
import { NestedOption } from 'devextreme-angular/core';
24+
25+
26+
@Component({
27+
selector: 'dxo-chat-send-button-options',
28+
standalone: true,
29+
template: '',
30+
styles: [''],
31+
imports: [ DxIntegrationModule ],
32+
providers: [NestedOptionHost]
33+
})
34+
export class DxoChatSendButtonOptionsComponent extends NestedOption implements OnDestroy, OnInit {
35+
@Input()
36+
get action(): SendButtonAction {
37+
return this._getOption('action');
38+
}
39+
set action(value: SendButtonAction) {
40+
this._setOption('action', value);
41+
}
42+
43+
@Input()
44+
get icon(): string {
45+
return this._getOption('icon');
46+
}
47+
set icon(value: string) {
48+
this._setOption('icon', value);
49+
}
50+
51+
@Input()
52+
get onClick(): ((e: SendButtonClickEvent) => void) {
53+
return this._getOption('onClick');
54+
}
55+
set onClick(value: ((e: SendButtonClickEvent) => void)) {
56+
this._setOption('onClick', value);
57+
}
58+
59+
60+
protected get _optionPath() {
61+
return 'sendButtonOptions';
62+
}
63+
64+
65+
constructor(@SkipSelf() @Host() parentOptionHost: NestedOptionHost,
66+
@Host() optionHost: NestedOptionHost) {
67+
super();
68+
parentOptionHost.setNestedOption(this);
69+
optionHost.setHost(this, this._fullOptionPath.bind(this));
70+
}
71+
72+
73+
ngOnInit() {
74+
this._addRecreatedComponent();
75+
}
76+
77+
ngOnDestroy() {
78+
this._addRemovedOption(this._getOptionPath());
79+
}
80+
81+
82+
}
83+
84+
@NgModule({
85+
imports: [
86+
DxoChatSendButtonOptionsComponent
87+
],
88+
exports: [
89+
DxoChatSendButtonOptionsComponent
90+
],
91+
})
92+
export class DxoChatSendButtonOptionsModule { }

packages/devextreme-metadata/make-angular-metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Ng.makeMetadata({
5151
removeMembers(/\/card_view:/),
5252
removeMembers(/\/chat:TextMessage.attachments/),
5353
removeMembers(
54-
/\/chat:dxChatOptions\.(fileUploaderOptions|inputFieldText|onAttachmentDownloadClick|speechToTextOptions)/,
54+
/\/chat:dxChatOptions\.(fileUploaderOptions|inputFieldText|sendButtonOptions|speechToTextOptions|onAttachmentDownloadClick)/,
5555
),
5656
removeMembers(/\/form:dxFormOptions\.(aiIntegration|onSmartPasting|onSmartPasted|smartPaste)/),
5757
removeMembers(/\/form:dxFormSimpleItem\.aiOptions/),

packages/devextreme-react/src/chat.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dxChat, {
88
import { Component as BaseComponent, IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
99
import NestedOption from "./core/nested-option";
1010

11-
import type { Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, TypingEndEvent, TypingStartEvent, Attachment as ChatAttachment, User as ChatUser } from "devextreme/ui/chat";
11+
import type { Message, AttachmentDownloadClickEvent, DisposingEvent, InitializedEvent, MessageDeletedEvent, MessageDeletingEvent, MessageEditCanceledEvent, MessageEditingStartEvent, MessageEnteredEvent, MessageUpdatedEvent, MessageUpdatingEvent, TypingEndEvent, TypingStartEvent, Attachment as ChatAttachment, User as ChatUser, SendButtonAction, SendButtonClickEvent } from "devextreme/ui/chat";
1212
import type { DisposingEvent as FileUploaderDisposingEvent, InitializedEvent as FileUploaderInitializedEvent, BeforeSendEvent, ContentReadyEvent, DropZoneEnterEvent, DropZoneLeaveEvent, FilesUploadedEvent, OptionChangedEvent, ProgressEvent, UploadAbortedEvent, UploadedEvent, UploadErrorEvent, UploadStartedEvent, ValueChangedEvent, UploadHttpMethod, FileUploadMode } from "devextreme/ui/file_uploader";
1313
import type { DisposingEvent as SpeechToTextDisposingEvent, InitializedEvent as SpeechToTextInitializedEvent, ContentReadyEvent as SpeechToTextContentReadyEvent, OptionChangedEvent as SpeechToTextOptionChangedEvent, CustomSpeechRecognizer as SpeechToTextCustomSpeechRecognizer, EndEvent, ErrorEvent, ResultEvent, StartClickEvent, StopClickEvent, SpeechRecognitionConfig as SpeechToTextSpeechRecognitionConfig } from "devextreme/ui/speech_to_text";
1414
import type { Format, ValidationStatus, ButtonStyle, ButtonType } from "devextreme/common";
@@ -74,6 +74,7 @@ const Chat = memo(
7474
fileUploaderOptions: { optionName: "fileUploaderOptions", isCollectionItem: false },
7575
item: { optionName: "items", isCollectionItem: true },
7676
messageTimestampFormat: { optionName: "messageTimestampFormat", isCollectionItem: false },
77+
sendButtonOptions: { optionName: "sendButtonOptions", isCollectionItem: false },
7778
speechToTextOptions: { optionName: "speechToTextOptions", isCollectionItem: false },
7879
typingUser: { optionName: "typingUsers", isCollectionItem: true },
7980
user: { optionName: "user", isCollectionItem: false }
@@ -372,6 +373,26 @@ const MessageTimestampFormat = Object.assign<typeof _componentMessageTimestampFo
372373
componentType: "option",
373374
});
374375

376+
// owners:
377+
// Chat
378+
type ISendButtonOptionsProps = React.PropsWithChildren<{
379+
action?: SendButtonAction;
380+
icon?: string;
381+
onClick?: ((e: SendButtonClickEvent) => void);
382+
}>
383+
const _componentSendButtonOptions = (props: ISendButtonOptionsProps) => {
384+
return React.createElement(NestedOption<ISendButtonOptionsProps>, {
385+
...props,
386+
elementDescriptor: {
387+
OptionName: "sendButtonOptions",
388+
},
389+
});
390+
};
391+
392+
const SendButtonOptions = Object.assign<typeof _componentSendButtonOptions, NestedComponentMeta>(_componentSendButtonOptions, {
393+
componentType: "option",
394+
});
395+
375396
// owners:
376397
// SpeechToTextOptions
377398
type ISpeechRecognitionConfigProps = React.PropsWithChildren<{
@@ -510,6 +531,8 @@ export {
510531
IItemProps,
511532
MessageTimestampFormat,
512533
IMessageTimestampFormatProps,
534+
SendButtonOptions,
535+
ISendButtonOptionsProps,
513536
SpeechRecognitionConfig,
514537
ISpeechRecognitionConfigProps,
515538
SpeechToTextOptions,

packages/devextreme-vue/src/chat.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ import {
2222
OptionChangedEvent,
2323
TypingEndEvent,
2424
TypingStartEvent,
25+
SendButtonProperties,
2526
User,
2627
Attachment,
28+
SendButtonAction,
29+
SendButtonClickEvent,
2730
} from "devextreme/ui/chat";
2831
import {
2932
DataSourceOptions,
@@ -110,6 +113,7 @@ type AccessibleOptions = Pick<Properties,
110113
"onTypingStart" |
111114
"reloadOnChange" |
112115
"rtlEnabled" |
116+
"sendButtonOptions" |
113117
"showAvatar" |
114118
"showDayHeaders" |
115119
"showMessageTimestamp" |
@@ -162,6 +166,7 @@ const componentConfig = {
162166
onTypingStart: Function as PropType<((e: TypingStartEvent) => void)>,
163167
reloadOnChange: Boolean,
164168
rtlEnabled: Boolean,
169+
sendButtonOptions: Object as PropType<SendButtonProperties | Record<string, any>>,
165170
showAvatar: Boolean,
166171
showDayHeaders: Boolean,
167172
showMessageTimestamp: Boolean,
@@ -210,6 +215,7 @@ const componentConfig = {
210215
"update:onTypingStart": null,
211216
"update:reloadOnChange": null,
212217
"update:rtlEnabled": null,
218+
"update:sendButtonOptions": null,
213219
"update:showAvatar": null,
214220
"update:showDayHeaders": null,
215221
"update:showMessageTimestamp": null,
@@ -236,6 +242,7 @@ const componentConfig = {
236242
fileUploaderOptions: { isCollectionItem: false, optionName: "fileUploaderOptions" },
237243
item: { isCollectionItem: true, optionName: "items" },
238244
messageTimestampFormat: { isCollectionItem: false, optionName: "messageTimestampFormat" },
245+
sendButtonOptions: { isCollectionItem: false, optionName: "sendButtonOptions" },
239246
speechToTextOptions: { isCollectionItem: false, optionName: "speechToTextOptions" },
240247
typingUser: { isCollectionItem: true, optionName: "typingUsers" },
241248
user: { isCollectionItem: false, optionName: "user" }
@@ -586,6 +593,27 @@ const DxMessageTimestampFormat = defineComponent(DxMessageTimestampFormatConfig)
586593

587594
(DxMessageTimestampFormat as any).$_optionName = "messageTimestampFormat";
588595

596+
const DxSendButtonOptionsConfig = {
597+
emits: {
598+
"update:isActive": null,
599+
"update:hoveredElement": null,
600+
"update:action": null,
601+
"update:icon": null,
602+
"update:onClick": null,
603+
},
604+
props: {
605+
action: String as PropType<SendButtonAction>,
606+
icon: String,
607+
onClick: Function as PropType<((e: SendButtonClickEvent) => void)>
608+
}
609+
};
610+
611+
prepareConfigurationComponentConfig(DxSendButtonOptionsConfig);
612+
613+
const DxSendButtonOptions = defineComponent(DxSendButtonOptionsConfig);
614+
615+
(DxSendButtonOptions as any).$_optionName = "sendButtonOptions";
616+
589617
const DxSpeechRecognitionConfigConfig = {
590618
emits: {
591619
"update:isActive": null,
@@ -747,6 +775,7 @@ export {
747775
DxFileUploaderOptions,
748776
DxItem,
749777
DxMessageTimestampFormat,
778+
DxSendButtonOptions,
750779
DxSpeechRecognitionConfig,
751780
DxSpeechToTextOptions,
752781
DxTypingUser,

0 commit comments

Comments
 (0)