11"use client"
2+ export { ExplicitTypes } from "devextreme/ui/chat" ;
23import * as React from "react" ;
34import { memo , forwardRef , useImperativeHandle , useRef , useMemo , ForwardedRef , Ref , ReactElement } from "react" ;
45import dxChat , {
@@ -18,22 +19,23 @@ type ReplaceFieldTypes<TSource, TReplacement> = {
1819 [ P in keyof TSource ] : P extends keyof TReplacement ? TReplacement [ P ] : TSource [ P ] ;
1920}
2021
21- type IChatOptionsNarrowedEvents = {
22- onAttachmentDownload ?: ( ( e : AttachmentDownloadEvent ) => void ) | undefined ;
23- onDisposing ?: ( ( e : DisposingEvent ) => void ) ;
24- onInitialized ?: ( ( e : InitializedEvent ) => void ) ;
25- onMessageDeleted ?: ( ( e : MessageDeletedEvent ) => void ) | undefined ;
26- onMessageDeleting ?: ( ( e : MessageDeletingEvent ) => void ) | undefined ;
27- onMessageEditCanceled ?: ( ( e : MessageEditCanceledEvent ) => void ) | undefined ;
28- onMessageEditingStart ?: ( ( e : MessageEditingStartEvent ) => void ) | undefined ;
29- onMessageEntered ?: ( ( e : MessageEnteredEvent ) => void ) | undefined ;
30- onMessageUpdated ?: ( ( e : MessageUpdatedEvent ) => void ) | undefined ;
31- onMessageUpdating ?: ( ( e : MessageUpdatingEvent ) => void ) | undefined ;
32- onTypingEnd ?: ( ( e : TypingEndEvent ) => void ) | undefined ;
33- onTypingStart ?: ( ( e : TypingStartEvent ) => void ) | undefined ;
22+ type IChatOptionsNarrowedEvents < TAttachment = any > = {
23+ onAttachmentDownload ?: ( ( e : AttachmentDownloadEvent < TAttachment > ) => void ) | undefined ;
24+ onDisposing ?: ( ( e : DisposingEvent < TAttachment > ) => void ) ;
25+ onInitialized ?: ( ( e : InitializedEvent < TAttachment > ) => void ) ;
26+ onMessageDeleted ?: ( ( e : MessageDeletedEvent < TAttachment > ) => void ) | undefined ;
27+ onMessageDeleting ?: ( ( e : MessageDeletingEvent < TAttachment > ) => void ) | undefined ;
28+ onMessageEditCanceled ?: ( ( e : MessageEditCanceledEvent < TAttachment > ) => void ) | undefined ;
29+ onMessageEditingStart ?: ( ( e : MessageEditingStartEvent < TAttachment > ) => void ) | undefined ;
30+ onMessageEntered ?: ( ( e : MessageEnteredEvent < TAttachment > ) => void ) | undefined ;
31+ onMessageUpdated ?: ( ( e : MessageUpdatedEvent < TAttachment > ) => void ) | undefined ;
32+ onMessageUpdating ?: ( ( e : MessageUpdatingEvent < TAttachment > ) => void ) | undefined ;
33+ onTypingEnd ?: ( ( e : TypingEndEvent < TAttachment > ) => void ) | undefined ;
34+ onTypingStart ?: ( ( e : TypingStartEvent < TAttachment > ) => void ) | undefined ;
3435}
3536
36- type IChatOptions = React . PropsWithChildren < ReplaceFieldTypes < Properties , IChatOptionsNarrowedEvents > & IHtmlOptions & {
37+ type IChatOptions < TAttachment = any > = React . PropsWithChildren < ReplaceFieldTypes < Properties < TAttachment > , IChatOptionsNarrowedEvents < TAttachment > > & IHtmlOptions & {
38+ dataSource ?: Properties < TAttachment > [ "dataSource" ] ;
3739 emptyViewRender ?: ( ...params : any ) => React . ReactNode ;
3840 emptyViewComponent ?: React . ComponentType < any > ;
3941 messageRender ?: ( ...params : any ) => React . ReactNode ;
@@ -42,13 +44,13 @@ type IChatOptions = React.PropsWithChildren<ReplaceFieldTypes<Properties, IChatO
4244 onItemsChange ?: ( value : Array < Message > ) => void ;
4345} >
4446
45- interface ChatRef {
46- instance : ( ) => dxChat ;
47+ interface ChatRef < TAttachment = any > {
48+ instance : ( ) => dxChat < TAttachment > ;
4749}
4850
4951const Chat = memo (
5052 forwardRef (
51- ( props : React . PropsWithChildren < IChatOptions > , ref : ForwardedRef < ChatRef > ) => {
53+ < TAttachment = any > ( props : React . PropsWithChildren < IChatOptions < TAttachment > > , ref : ForwardedRef < ChatRef < TAttachment > > ) => {
5254 const baseRef = useRef < ComponentRef > ( null ) ;
5355
5456 useImperativeHandle ( ref , ( ) => (
@@ -91,7 +93,7 @@ const Chat = memo(
9193 ] ) , [ ] ) ;
9294
9395 return (
94- React . createElement ( BaseComponent < React . PropsWithChildren < IChatOptions > > , {
96+ React . createElement ( BaseComponent < React . PropsWithChildren < IChatOptions < TAttachment > > > , {
9597 WidgetClass : dxChat ,
9698 ref : baseRef ,
9799 subscribableOptions,
@@ -104,7 +106,7 @@ const Chat = memo(
104106 ) ;
105107 } ,
106108 ) ,
107- ) as ( props : React . PropsWithChildren < IChatOptions > & { ref ?: Ref < ChatRef > } ) => ReactElement | null ;
109+ ) as < TAttachment = any > ( props : React . PropsWithChildren < IChatOptions < TAttachment > > & { ref ?: Ref < ChatRef < TAttachment > > } ) => ReactElement | null ;
108110
109111
110112// owners:
0 commit comments