diff --git a/packages/devextreme-angular/src/ui/chat/index.ts b/packages/devextreme-angular/src/ui/chat/index.ts index bc61e4859729..33611204a5e4 100644 --- a/packages/devextreme-angular/src/ui/chat/index.ts +++ b/packages/devextreme-angular/src/ui/chat/index.ts @@ -24,7 +24,7 @@ import { import { Store } from 'devextreme/data'; import DataSource, { Options as DataSourceOptions } from 'devextreme/data/data_source'; -import { DisposingEvent, InitializedEvent, Message, MessageSendEvent, OptionChangedEvent, User } from 'devextreme/ui/chat'; +import { ChatError, DisposingEvent, InitializedEvent, Message, MessageSendEvent, OptionChangedEvent, User } from 'devextreme/ui/chat'; import DxChat from 'devextreme/ui/chat'; @@ -39,16 +39,20 @@ import { WatcherHelper } from 'devextreme-angular/core'; +import { DxiErrorModule } from 'devextreme-angular/ui/nested'; import { DxiItemModule } from 'devextreme-angular/ui/nested'; import { DxoAuthorModule } from 'devextreme-angular/ui/nested'; import { DxoUserModule } from 'devextreme-angular/ui/nested'; +import { DxiChatErrorModule } from 'devextreme-angular/ui/chat/nested'; import { DxiChatItemModule } from 'devextreme-angular/ui/chat/nested'; import { DxoChatAuthorModule } from 'devextreme-angular/ui/chat/nested'; import { DxoChatUserModule } from 'devextreme-angular/ui/chat/nested'; +import { DxiErrorComponent } from 'devextreme-angular/ui/nested'; import { DxiItemComponent } from 'devextreme-angular/ui/nested'; +import { DxiChatErrorComponent } from 'devextreme-angular/ui/chat/nested'; import { DxiChatItemComponent } from 'devextreme-angular/ui/chat/nested'; @@ -134,6 +138,19 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges } + /** + * [descr:dxChatOptions.errors] + + */ + @Input() + get errors(): Array { + return this._getOption('errors'); + } + set errors(value: Array) { + this._setOption('errors', value); + } + + /** * [descr:dxChatOptions.focusStateEnabled] @@ -317,6 +334,13 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges */ @Output() elementAttrChange: EventEmitter; + /** + + * This member supports the internal infrastructure and is not intended to be used directly from your code. + + */ + @Output() errorsChange: EventEmitter>; + /** * This member supports the internal infrastructure and is not intended to be used directly from your code. @@ -383,6 +407,15 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges + @ContentChildren(DxiChatErrorComponent) + get errorsChildren(): QueryList { + return this._getOption('errors'); + } + set errorsChildren(value) { + this.setContentChildren('errors', value, 'DxiChatErrorComponent'); + this.setChildren('errors', value); + } + @ContentChildren(DxiChatItemComponent) get itemsChildren(): QueryList { return this._getOption('items'); @@ -393,6 +426,16 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges } + @ContentChildren(DxiErrorComponent) + get errorsLegacyChildren(): QueryList { + return this._getOption('errors'); + } + set errorsLegacyChildren(value) { + if (this.checkContentChildren('errors', value, 'DxiErrorComponent')) { + this.setChildren('errors', value); + } + } + @ContentChildren(DxiItemComponent) get itemsLegacyChildren(): QueryList { return this._getOption('items'); @@ -425,6 +468,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges { emit: 'dataSourceChange' }, { emit: 'disabledChange' }, { emit: 'elementAttrChange' }, + { emit: 'errorsChange' }, { emit: 'focusStateEnabledChange' }, { emit: 'heightChange' }, { emit: 'hintChange' }, @@ -453,6 +497,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); this.setupChanges('dataSource', changes); + this.setupChanges('errors', changes); this.setupChanges('items', changes); } @@ -464,6 +509,7 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges ngDoCheck() { this._idh.doCheck('dataSource'); + this._idh.doCheck('errors'); this._idh.doCheck('items'); this._watcherHelper.checkWatchers(); super.ngDoCheck(); @@ -482,9 +528,11 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges @NgModule({ imports: [ + DxiErrorModule, DxiItemModule, DxoAuthorModule, DxoUserModule, + DxiChatErrorModule, DxiChatItemModule, DxoChatAuthorModule, DxoChatUserModule, @@ -496,9 +544,11 @@ export class DxChatComponent extends DxComponent implements OnDestroy, OnChanges ], exports: [ DxChatComponent, + DxiErrorModule, DxiItemModule, DxoAuthorModule, DxoUserModule, + DxiChatErrorModule, DxiChatItemModule, DxoChatAuthorModule, DxoChatUserModule, diff --git a/packages/devextreme-angular/src/ui/chat/nested/error-dxi.ts b/packages/devextreme-angular/src/ui/chat/nested/error-dxi.ts new file mode 100644 index 000000000000..d485ad7bd645 --- /dev/null +++ b/packages/devextreme-angular/src/ui/chat/nested/error-dxi.ts @@ -0,0 +1,74 @@ +/* tslint:disable:max-line-length */ + + +import { + Component, + NgModule, + Host, + SkipSelf, + Input +} from '@angular/core'; + + + + + +import { + NestedOptionHost, +} from 'devextreme-angular/core'; +import { CollectionNestedOption } from 'devextreme-angular/core'; + + +@Component({ + selector: 'dxi-chat-error', + template: '', + styles: [''], + providers: [NestedOptionHost] +}) +export class DxiChatErrorComponent extends CollectionNestedOption { + @Input() + get id(): number | string { + return this._getOption('id'); + } + set id(value: number | string) { + this._setOption('id', value); + } + + @Input() + get message(): string { + return this._getOption('message'); + } + set message(value: string) { + this._setOption('message', value); + } + + + protected get _optionPath() { + return 'errors'; + } + + + constructor(@SkipSelf() @Host() parentOptionHost: NestedOptionHost, + @Host() optionHost: NestedOptionHost) { + super(); + parentOptionHost.setNestedOption(this); + optionHost.setHost(this, this._fullOptionPath.bind(this)); + } + + + + ngOnDestroy() { + this._deleteRemovedOptions(this._fullOptionPath()); + } + +} + +@NgModule({ + declarations: [ + DxiChatErrorComponent + ], + exports: [ + DxiChatErrorComponent + ], +}) +export class DxiChatErrorModule { } diff --git a/packages/devextreme-angular/src/ui/chat/nested/index.ts b/packages/devextreme-angular/src/ui/chat/nested/index.ts index 4484a9761ed1..a18fa778c83d 100644 --- a/packages/devextreme-angular/src/ui/chat/nested/index.ts +++ b/packages/devextreme-angular/src/ui/chat/nested/index.ts @@ -1,4 +1,5 @@ export * from './author'; +export * from './error-dxi'; export * from './item-dxi'; export * from './user'; diff --git a/packages/devextreme-angular/src/ui/nested/base/chat-error-dxi.ts b/packages/devextreme-angular/src/ui/nested/base/chat-error-dxi.ts new file mode 100644 index 000000000000..157d04f9ebd2 --- /dev/null +++ b/packages/devextreme-angular/src/ui/nested/base/chat-error-dxi.ts @@ -0,0 +1,26 @@ +/* tslint:disable:max-line-length */ + +import { CollectionNestedOption } from 'devextreme-angular/core'; +import { + Component, +} from '@angular/core'; + + +@Component({ + template: '' +}) +export abstract class DxiChatError extends CollectionNestedOption { + get id(): number | string { + return this._getOption('id'); + } + set id(value: number | string) { + this._setOption('id', value); + } + + get message(): string { + return this._getOption('message'); + } + set message(value: string) { + this._setOption('message', value); + } +} diff --git a/packages/devextreme-angular/src/ui/nested/base/index.ts b/packages/devextreme-angular/src/ui/nested/base/index.ts index 6e9515165ed5..5c8528456155 100644 --- a/packages/devextreme-angular/src/ui/nested/base/index.ts +++ b/packages/devextreme-angular/src/ui/nested/base/index.ts @@ -9,6 +9,7 @@ export * from './chart-common-annotation-config'; export * from './chart-common-series-settings'; export * from './chart-series-dxi'; export * from './charts-color'; +export * from './chat-error-dxi'; export * from './column-chooser-search-config'; export * from './column-chooser-selection-config'; export * from './data-change-dxi'; diff --git a/packages/devextreme-angular/src/ui/nested/error-dxi.ts b/packages/devextreme-angular/src/ui/nested/error-dxi.ts new file mode 100644 index 000000000000..82c3eec068d1 --- /dev/null +++ b/packages/devextreme-angular/src/ui/nested/error-dxi.ts @@ -0,0 +1,62 @@ +/* tslint:disable:max-line-length */ + +/* tslint:disable:use-input-property-decorator */ + +import { + Component, + NgModule, + Host, + SkipSelf +} from '@angular/core'; + + + + + +import { + NestedOptionHost, +} from 'devextreme-angular/core'; +import { DxiChatError } from './base/chat-error-dxi'; + + +@Component({ + selector: 'dxi-error', + template: '', + styles: [''], + providers: [NestedOptionHost], + inputs: [ + 'id', + 'message' + ] +}) +export class DxiErrorComponent extends DxiChatError { + + protected get _optionPath() { + return 'errors'; + } + + + constructor(@SkipSelf() @Host() parentOptionHost: NestedOptionHost, + @Host() optionHost: NestedOptionHost) { + super(); + parentOptionHost.setNestedOption(this); + optionHost.setHost(this, this._fullOptionPath.bind(this)); + } + + + + ngOnDestroy() { + this._deleteRemovedOptions(this._fullOptionPath()); + } + +} + +@NgModule({ + declarations: [ + DxiErrorComponent + ], + exports: [ + DxiErrorComponent + ], +}) +export class DxiErrorModule { } diff --git a/packages/devextreme-angular/src/ui/nested/index.ts b/packages/devextreme-angular/src/ui/nested/index.ts index 645550119a6c..50f02194ad77 100644 --- a/packages/devextreme-angular/src/ui/nested/index.ts +++ b/packages/devextreme-angular/src/ui/nested/index.ts @@ -64,6 +64,7 @@ export * from './drag-box-style'; export * from './drop-down-options'; export * from './edges'; export * from './editing'; +export * from './error-dxi'; export * from './export'; export * from './field-chooser'; export * from './field-dxi'; diff --git a/packages/devextreme-react/src/chat.ts b/packages/devextreme-react/src/chat.ts index 8f06a14ea4c1..7f7e82853840 100644 --- a/packages/devextreme-react/src/chat.ts +++ b/packages/devextreme-react/src/chat.ts @@ -50,6 +50,7 @@ const Chat = memo( }), []); const expectedChildren = useMemo(() => ({ + error: { optionName: "errors", isCollectionItem: true }, item: { optionName: "items", isCollectionItem: true }, user: { optionName: "user", isCollectionItem: false } }), []); @@ -87,6 +88,23 @@ const Author: typeof _componentAuthor & IElementDescriptor = Object.assign(_comp OptionName: "author", }) +// owners: +// Chat +type IErrorProps = React.PropsWithChildren<{ + id?: number | string; + message?: string; +}> +const _componentError = memo( + (props: IErrorProps) => { + return React.createElement(NestedOption, { ...props }); + } +); + +const Error: typeof _componentError & IElementDescriptor = Object.assign(_componentError, { + OptionName: "errors", + IsCollectionItem: true, +}) + // owners: // Chat type IItemProps = React.PropsWithChildren<{ @@ -133,6 +151,8 @@ export { ChatRef, Author, IAuthorProps, + Error, + IErrorProps, Item, IItemProps, User, diff --git a/packages/devextreme-vue/src/chat.ts b/packages/devextreme-vue/src/chat.ts index fb91f13f308e..03d7e8a84f0d 100644 --- a/packages/devextreme-vue/src/chat.ts +++ b/packages/devextreme-vue/src/chat.ts @@ -9,6 +9,7 @@ type AccessibleOptions = Pick { * @public */ dataSource?: DataSourceLike | null; + /** + * @docid + * @default undefined + * @public + */ + errors?: Array; /** * @docid * @default null diff --git a/packages/devextreme/js/ui/chat_types.d.ts b/packages/devextreme/js/ui/chat_types.d.ts index a26813804d5b..4a4fa625a730 100644 --- a/packages/devextreme/js/ui/chat_types.d.ts +++ b/packages/devextreme/js/ui/chat_types.d.ts @@ -4,6 +4,7 @@ export { OptionChangedEvent, MessageSendEvent, User, + ChatError, Message, dxChatOptions, Properties, diff --git a/packages/devextreme/ts/dx.all.d.ts b/packages/devextreme/ts/dx.all.d.ts index 6042d2727cd7..4a10f850db82 100644 --- a/packages/devextreme/ts/dx.all.d.ts +++ b/packages/devextreme/ts/dx.all.d.ts @@ -9557,6 +9557,10 @@ declare module DevExpress.ui { * [descr:dxChatOptions.dataSource] */ dataSource?: DevExpress.data.DataSource.DataSourceLike | null; + /** + * [descr:dxChatOptions.errors] + */ + errors?: Array; /** * [descr:dxChatOptions.onMessageSend] */ @@ -30654,6 +30658,19 @@ declare module DevExpress.ui.dxButtonGroup { export type Item = dxButtonGroupItem; } declare module DevExpress.ui.dxChat { + /** + * [descr:ChatError] + */ + export type ChatError = { + /** + * [descr:ChatError.id] + */ + id?: number | string; + /** + * [descr:ChatError.message] + */ + message?: string; + }; /** * [descr:Message] */