@@ -42,6 +42,7 @@ export interface MosaicWindowProps<T> {
4242 additionalControlButtonText ?: string ;
4343 draggable ?: boolean ;
4444 createNode ?: CreateNode < T > ;
45+ renderPreview ?: ( props : MosaicWindowProps < T > ) => JSX . Element ;
4546}
4647
4748interface DragSourceProps {
@@ -102,10 +103,19 @@ const dropTarget = { };
102103} ) ) as ClassDecorator )
103104@PureRenderDecorator
104105class MosaicWindowClass < T > extends React . Component < Props < T > , State > {
105- static defaultProps = {
106+ static defaultProps : Partial < Props < any > > = {
106107 additionalControlButtonText : 'More' ,
107108 draggable : true ,
108- } as any ;
109+ renderPreview : ( { title } ) =>
110+ div ( { className : 'mosaic-preview' } ,
111+ div ( { className : 'mosaic-window-toolbar' } ,
112+ div ( { className : 'mosaic-window-title' } , title ) ) ,
113+ div ( { className : 'mosaic-window-body' } ,
114+ h4 ( { } , title ) ,
115+ span ( { className : 'pt-icon pt-icon-application' } ) ,
116+ ) ,
117+ ) ,
118+ } ;
109119
110120 static contextTypes = MosaicTileContext ;
111121
@@ -130,7 +140,7 @@ class MosaicWindowClass<T> extends React.Component<Props<T>, State> {
130140 }
131141
132142 render ( ) {
133- const { className, isOver, title , additionalControls, connectDropTarget, connectDragPreview, draggedMosaicId } = this . props ;
143+ const { className, isOver, renderPreview , additionalControls, connectDropTarget, connectDragPreview, draggedMosaicId } = this . props ;
134144
135145 return connectDropTarget ( div ( {
136146 className : classNames ( 'mosaic-window mosaic-drop-target' , className , {
@@ -150,16 +160,7 @@ class MosaicWindowClass<T> extends React.Component<Props<T>, State> {
150160 div ( { className : 'mosaic-window-additional-actions-bar' } ,
151161 additionalControls ,
152162 ) ,
153- connectDragPreview (
154- div ( { className : 'mosaic-preview' } ,
155- div ( { className : 'mosaic-window-toolbar' } ,
156- div ( { className : 'mosaic-window-title' } , title ) ) ,
157- div ( { className : 'mosaic-window-body' } ,
158- h4 ( { } , title ) ,
159- span ( { className : 'pt-icon pt-icon-application' } ) ,
160- ) ,
161- ) ,
162- ) ,
163+ connectDragPreview ( renderPreview ! ( this . props ) ) ,
163164 div ( { className : 'drop-target-container' } ,
164165 _ . values < string > ( MosaicDropTargetPosition ) . map ( this . renderDropTarget ) ,
165166 ) ,
0 commit comments