| 14 | } |
| 15 | |
| 16 | export class SourceConnector implements Connector { |
| 17 | public hooks = wrapConnectorHooks({ |
| 18 | dragSource: ( |
| 19 | node: Element | ReactElement | Ref<any>, |
| 20 | options?: DragSourceOptions, |
| 21 | ) => { |
| 22 | this.clearDragSource() |
| 23 | this.dragSourceOptions = options || null |
| 24 | if (isRef(node)) { |
| 25 | this.dragSourceRef = node as RefObject<any> |
| 26 | } else { |
| 27 | this.dragSourceNode = node |
| 28 | } |
| 29 | this.reconnectDragSource() |
| 30 | }, |
| 31 | dragPreview: (node: any, options?: DragPreviewOptions) => { |
| 32 | this.clearDragPreview() |
| 33 | this.dragPreviewOptions = options || null |
| 34 | if (isRef(node)) { |
| 35 | this.dragPreviewRef = node |
| 36 | } else { |
| 37 | this.dragPreviewNode = node |
| 38 | } |
| 39 | this.reconnectDragPreview() |
| 40 | }, |
| 41 | }) |
| 42 | private handlerId: Identifier | null = null |
| 43 | |
| 44 | // The drop target may either be attached via ref or connect function |
| 45 | private dragSourceRef: RefObject<any> | null = null |
| 46 | private dragSourceNode: any |
| 47 | private dragSourceOptionsInternal: DragSourceOptions | null = null |
| 48 | private dragSourceUnsubscribe: Unsubscribe | undefined |
| 49 | |
| 50 | // The drag preview may either be attached via ref or connect function |
| 51 | private dragPreviewRef: RefObject<any> | null = null |
| 52 | private dragPreviewNode: any |
| 53 | private dragPreviewOptionsInternal: DragPreviewOptions | null = null |
| 54 | private dragPreviewUnsubscribe: Unsubscribe | undefined |
| 55 | |
| 56 | private lastConnectedHandlerId: Identifier | null = null |
| 57 | private lastConnectedDragSource: any = null |
| 58 | private lastConnectedDragSourceOptions: any = null |
| 59 | private lastConnectedDragPreview: any = null |
| 60 | private lastConnectedDragPreviewOptions: any = null |
| 61 | |
| 62 | private readonly backend: Backend |
| 63 | |
| 64 | public constructor(backend: Backend) { |
| 65 | this.backend = backend |
| 66 | } |
| 67 | |
| 68 | public receiveHandlerId(newHandlerId: Identifier | null): void { |
| 69 | if (this.handlerId === newHandlerId) { |
| 70 | return |
| 71 | } |
| 72 | |
| 73 | this.handlerId = newHandlerId |
nothing calls this directly
no test coverage detected
searching dependent graphs…