dnd-core
Advanced tools
Comparing version 8.0.3 to 9.0.0
import { Action, DragDropManager, BeginDragPayload, BeginDragOptions } from '../../interfaces'; | ||
export default function createBeginDrag<Context>(manager: DragDropManager<Context>): (sourceIds?: string[], options?: BeginDragOptions) => Action<BeginDragPayload> | undefined; | ||
export default function createBeginDrag(manager: DragDropManager): (sourceIds?: string[], options?: BeginDragOptions) => Action<BeginDragPayload> | undefined; |
import { DragDropManager } from '../../interfaces'; | ||
export default function createDrop<Context>(manager: DragDropManager<Context>): (options?: {}) => void; | ||
export default function createDrop(manager: DragDropManager): (options?: {}) => void; |
import { DragDropManager, SentinelAction } from '../../interfaces'; | ||
export default function createEndDrag<Context>(manager: DragDropManager<Context>): () => SentinelAction; | ||
export default function createEndDrag(manager: DragDropManager): () => SentinelAction; |
import { Action, DragDropManager, HoverPayload, HoverOptions } from '../../interfaces'; | ||
export default function createHover<Context>(manager: DragDropManager<Context>): (targetIdsArg: string[], { clientOffset }?: HoverOptions) => Action<HoverPayload>; | ||
export default function createHover(manager: DragDropManager): (targetIdsArg: string[], { clientOffset }?: HoverOptions) => Action<HoverPayload>; |
import { DragDropManager } from '../../interfaces'; | ||
export * from './types'; | ||
export default function createDragDropActions<Context>(manager: DragDropManager<Context>): { | ||
export default function createDragDropActions(manager: DragDropManager): { | ||
beginDrag: (sourceIds?: string[], options?: import("../../interfaces").BeginDragOptions) => import("../../interfaces").Action<import("../../interfaces").BeginDragPayload> | undefined; | ||
@@ -5,0 +5,0 @@ publishDragSource: () => import("../../interfaces").SentinelAction | undefined; |
import { DragDropManager, SentinelAction } from '../../interfaces'; | ||
export default function createPublishDragSource<Context>(manager: DragDropManager<Context>): () => SentinelAction | undefined; | ||
export default function createPublishDragSource(manager: DragDropManager): () => SentinelAction | undefined; |
@@ -1,4 +0,3 @@ | ||
import { Backend, BackendFactory, DragDropActions, DragDropMonitor, DragDropManager, HandlerRegistry } from './interfaces'; | ||
export default class DragDropManagerImpl<Context> implements DragDropManager<Context> { | ||
private context; | ||
import { Backend, DragDropActions, DragDropMonitor, DragDropManager, HandlerRegistry } from './interfaces'; | ||
export default class DragDropManagerImpl implements DragDropManager { | ||
private store; | ||
@@ -8,4 +7,4 @@ private monitor; | ||
private isSetUp; | ||
constructor(createBackend: BackendFactory, context?: Context, debugMode?: boolean); | ||
getContext(): Context; | ||
constructor(debugMode?: boolean); | ||
receiveBackend(backend: Backend): void; | ||
getMonitor(): DragDropMonitor; | ||
@@ -12,0 +11,0 @@ getBackend(): Backend; |
@@ -19,15 +19,16 @@ import { createStore } from 'redux'; | ||
export default class DragDropManagerImpl { | ||
constructor(createBackend, context = {}, debugMode = false) { | ||
this.context = context; | ||
constructor(debugMode = false) { | ||
this.isSetUp = false; | ||
this.handleRefCountChange = () => { | ||
const shouldSetUp = this.store.getState().refCount > 0; | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
this.isSetUp = true; | ||
if (this.backend) { | ||
if (shouldSetUp && !this.isSetUp) { | ||
this.backend.setup(); | ||
this.isSetUp = true; | ||
} | ||
else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
} | ||
else if (!shouldSetUp && this.isSetUp) { | ||
this.backend.teardown(); | ||
this.isSetUp = false; | ||
} | ||
}; | ||
@@ -37,7 +38,6 @@ const store = makeStoreInstance(debugMode); | ||
this.monitor = new DragDropMonitorImpl(store, new HandlerRegistryImpl(store)); | ||
this.backend = createBackend(this); | ||
store.subscribe(this.handleRefCountChange); | ||
} | ||
getContext() { | ||
return this.context; | ||
receiveBackend(backend) { | ||
this.backend = backend; | ||
} | ||
@@ -44,0 +44,0 @@ getMonitor() { |
import { DragDropManager, BackendFactory } from './interfaces'; | ||
export declare function createDragDropManager<C>(backend: BackendFactory, context: C, debugMode?: boolean): DragDropManager<C>; | ||
export declare function createDragDropManager(backendFactory: BackendFactory, globalContext: any, backendOptions: any, debugMode?: boolean): DragDropManager; |
import DragDropManagerImpl from './DragDropManagerImpl'; | ||
export function createDragDropManager(backend, context, debugMode) { | ||
return new DragDropManagerImpl(backend, context, debugMode); | ||
export function createDragDropManager(backendFactory, globalContext, backendOptions, debugMode) { | ||
const manager = new DragDropManagerImpl(debugMode); | ||
const backend = backendFactory(manager, globalContext, backendOptions); | ||
manager.receiveBackend(backend); | ||
return manager; | ||
} |
@@ -152,4 +152,3 @@ import { Unsubscribe } from 'redux'; | ||
} | ||
export interface DragDropManager<Context> { | ||
getContext(): Context; | ||
export interface DragDropManager { | ||
getMonitor(): DragDropMonitor; | ||
@@ -161,3 +160,3 @@ getBackend(): Backend; | ||
} | ||
export declare type BackendFactory = (dragDropManager: DragDropManager<any>) => Backend; | ||
export declare type BackendFactory = (manager: DragDropManager, globalContext?: any, configuration?: any) => Backend; | ||
export interface DragSource { | ||
@@ -164,0 +163,0 @@ beginDrag(monitor: DragDropMonitor, targetId: Identifier): void; |
{ | ||
"name": "dnd-core", | ||
"version": "8.0.3", | ||
"version": "9.0.0", | ||
"description": "Drag and drop sans the GUI", | ||
@@ -21,3 +21,3 @@ "license": "MIT", | ||
"@types/asap": "^2.0.0", | ||
"@types/invariant": "^2.2.29", | ||
"@types/invariant": "^2.2.30", | ||
"asap": "^2.0.6", | ||
@@ -31,3 +31,4 @@ "invariant": "^2.2.4", | ||
"typescript": "^3.5.2" | ||
} | ||
}, | ||
"gitHead": "f591828f0ccaf70aa712785a8601017da2df4b45" | ||
} |
Sorry, the diff of this file is not supported yet
237024
1446
Updated@types/invariant@^2.2.30