import { observer } from 'mobx-react'; import { useDndDrag } from './useDndDrag'; import { ConnectDragSource, DragObjectWithType, DragOperationWithType, DragSourceSpec, DragSpecOperationType } from './dnd-types'; export interface WithSourceDragProps { sourceDragRef?: ConnectDragSource; } export const withSourceDrag = < DragObject extends DragObjectWithType = DragObjectWithType, DropResult = any, CollectedProps extends {} = {}, Props extends {} = {} >( spec: DragSourceSpec, DropResult, CollectedProps, Props> ) =>

(WrappedComponent: React.ComponentType

) => { const Component: React.FunctionComponent> = (props) => { // TODO fix cast to any const [dndDragProps, dndDragRef] = useDndDrag(spec, props as any); return ; }; Component.displayName = `withSourceDrag(${WrappedComponent.displayName || WrappedComponent.name})`; return observer(Component); }; export interface WithTargetDragProps { targetDragRef?: ConnectDragSource; } export const withTargetDrag = < DragObject extends DragObjectWithType = DragObjectWithType, DropResult = any, CollectedProps extends {} = {}, Props extends {} = {} >( spec: DragSourceSpec, DropResult, CollectedProps, Props> ) =>

(WrappedComponent: React.ComponentType

) => { const Component: React.FunctionComponent> = (props) => { // TODO fix cast to any const [dndDragProps, dndDragRef] = useDndDrag(spec, props as any); return ; }; Component.displayName = `withTargetDrag(${WrappedComponent.displayName || WrappedComponent.name})`; return observer(Component); };