react-dnd
Advanced tools
Comparing version 8.0.3 to 9.0.0
@@ -6,4 +6,4 @@ import * as React from 'react'; | ||
*/ | ||
export interface DndContext<BC> { | ||
dragDropManager: DragDropManager<BC> | undefined; | ||
export interface DndContext { | ||
dragDropManager: DragDropManager | undefined; | ||
} | ||
@@ -13,3 +13,3 @@ /** | ||
*/ | ||
export declare const DndContext: React.Context<DndContext<any>>; | ||
export declare const DndContext: React.Context<DndContext>; | ||
/** | ||
@@ -20,4 +20,4 @@ * Creates the context object we're providing | ||
*/ | ||
export declare function createDndContext<BackendContext>(backend: BackendFactory, context?: BackendContext, debugMode?: boolean): { | ||
dragDropManager: DragDropManager<BackendContext | undefined>; | ||
export declare function createDndContext<BackendContext, BackendOptions>(backend: BackendFactory, context?: BackendContext, options?: BackendOptions, debugMode?: boolean): { | ||
dragDropManager: DragDropManager; | ||
}; |
@@ -14,6 +14,6 @@ import * as React from 'react'; | ||
*/ | ||
export function createDndContext(backend, context, debugMode) { | ||
export function createDndContext(backend, context, options, debugMode) { | ||
return { | ||
dragDropManager: createDragDropManager(backend, context, debugMode), | ||
dragDropManager: createDragDropManager(backend, context, options, debugMode), | ||
}; | ||
} |
import * as React from 'react'; | ||
import { DragDropManager, BackendFactory } from 'dnd-core'; | ||
export declare type DndProviderProps<BackendContext> = { | ||
manager: DragDropManager<BackendContext>; | ||
import { BackendFactory, DragDropManager } from 'dnd-core'; | ||
export declare type DndProviderProps<BackendContext, BackendOptions> = { | ||
manager: DragDropManager; | ||
} | { | ||
backend: BackendFactory; | ||
context?: BackendContext; | ||
options?: BackendOptions; | ||
debugMode?: boolean; | ||
@@ -13,2 +14,2 @@ }; | ||
*/ | ||
export declare const DndProvider: React.FC<DndProviderProps<any>>; | ||
export declare const DndProvider: React.FC<DndProviderProps<any, any>>; |
@@ -10,10 +10,10 @@ import * as React from 'react'; | ||
? { dragDropManager: props.manager } | ||
: createSingletonDndContext(props.backend, props.context, props.debugMode); | ||
: createSingletonDndContext(props.backend, props.context, props.options, props.debugMode); | ||
return React.createElement(DndContext.Provider, { value: context }, children); | ||
}); | ||
const instanceSymbol = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__'); | ||
function createSingletonDndContext(backend, context = getGlobalContext(), debugMode) { | ||
function createSingletonDndContext(backend, context = getGlobalContext(), options, debugMode) { | ||
const ctx = context; | ||
if (!ctx[instanceSymbol]) { | ||
ctx[instanceSymbol] = createDndContext(backend, context, debugMode); | ||
ctx[instanceSymbol] = createDndContext(backend, context, options, debugMode); | ||
} | ||
@@ -20,0 +20,0 @@ return ctx[instanceSymbol]; |
@@ -6,3 +6,3 @@ import { DragDropManager, Unsubscribe, Listener, Identifier } from 'dnd-core'; | ||
private sourceId; | ||
constructor(manager: DragDropManager<any>); | ||
constructor(manager: DragDropManager); | ||
receiveHandlerId(sourceId: Identifier | null): void; | ||
@@ -9,0 +9,0 @@ getHandlerId(): Identifier | null; |
@@ -6,3 +6,3 @@ import { DragDropManager, Unsubscribe, Listener, Identifier } from 'dnd-core'; | ||
private targetId; | ||
constructor(manager: DragDropManager<any>); | ||
constructor(manager: DragDropManager); | ||
receiveHandlerId(targetId: Identifier | null): void; | ||
@@ -9,0 +9,0 @@ getHandlerId(): Identifier | null; |
import { DragDropManager, DropTarget, Unsubscribe, Identifier, TargetType, SourceType, DragSource } from 'dnd-core'; | ||
export declare function registerTarget<Context>(type: TargetType, target: DropTarget, manager: DragDropManager<Context>): [Identifier, Unsubscribe]; | ||
export declare function registerSource<Context>(type: SourceType, source: DragSource, manager: DragDropManager<Context>): [Identifier, Unsubscribe]; | ||
export declare function registerTarget(type: TargetType, target: DropTarget, manager: DragDropManager): [Identifier, Unsubscribe]; | ||
export declare function registerSource(type: SourceType, source: DragSource, manager: DragDropManager): [Identifier, Unsubscribe]; |
@@ -6,3 +6,3 @@ import * as React from 'react'; | ||
DecoratedComponent: any; | ||
createMonitor: (manager: DragDropManager<any>) => HandlerReceiver; | ||
createMonitor: (manager: DragDropManager) => HandlerReceiver; | ||
createHandler: (monitor: HandlerReceiver, ref: React.RefObject<any>) => Handler<Props>; | ||
@@ -9,0 +9,0 @@ createConnector: any; |
export * from './DragSource'; | ||
export * from './DropTarget'; | ||
export * from './DragLayer'; | ||
export * from './DragDropContext'; | ||
export * from './interfaces'; |
export * from './DragSource'; | ||
export * from './DropTarget'; | ||
export * from './DragLayer'; | ||
export * from './DragDropContext'; |
@@ -10,3 +10,3 @@ import * as React from 'react'; | ||
getDecoratedComponentInstance(): React.Component<Props>; | ||
getManager(): DragDropManager<any>; | ||
getManager(): DragDropManager; | ||
} | ||
@@ -13,0 +13,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { useEffect, useMemo } from 'react'; | ||
import { useMemo, useLayoutEffect } from 'react'; | ||
import invariant from 'invariant'; | ||
@@ -54,3 +54,3 @@ import { registerSource } from '../../common/registration'; | ||
}, []); | ||
useEffect(function registerHandler() { | ||
useLayoutEffect(function registerHandler() { | ||
const [handlerId, unregister] = registerSource(spec.current.item.type, handler, manager); | ||
@@ -57,0 +57,0 @@ monitor.receiveHandlerId(handlerId); |
@@ -1,2 +0,2 @@ | ||
import { useEffect, useMemo } from 'react'; | ||
import { useMemo, useLayoutEffect } from 'react'; | ||
import { registerTarget } from '../../common/registration'; | ||
@@ -36,3 +36,3 @@ import { useDragDropManager } from './useDragDropManager'; | ||
}, [monitor]); | ||
useEffect(function registerHandler() { | ||
useLayoutEffect(function registerHandler() { | ||
const [handlerId, unregister] = registerTarget(spec.current.accept, handler, manager); | ||
@@ -39,0 +39,0 @@ monitor.receiveHandlerId(handlerId); |
/** | ||
* | ||
* @param monitor The monitor to colelct state from | ||
* @param monitor The monitor to collect state from | ||
* @param collect The collecting function | ||
@@ -5,0 +5,0 @@ * @param onUpdate A method to invoke when updates occur |
import shallowEqual from 'shallowequal'; | ||
import { useState, useCallback } from 'react'; | ||
import { useState, useCallback, useLayoutEffect } from 'react'; | ||
/** | ||
* | ||
* @param monitor The monitor to colelct state from | ||
* @param monitor The monitor to collect state from | ||
* @param collect The collecting function | ||
@@ -20,3 +20,6 @@ * @param onUpdate A method to invoke when updates occur | ||
}, [collected, monitor, onUpdate]); | ||
// update the collected properties after the first render | ||
// and the components are attached to dnd-core | ||
useLayoutEffect(updateCollected, []); | ||
return [collected, updateCollected]; | ||
} |
@@ -5,2 +5,2 @@ import { DragDropManager } from 'dnd-core'; | ||
*/ | ||
export declare function useDragDropManager<Context>(): DragDropManager<Context>; | ||
export declare function useDragDropManager(): DragDropManager; |
@@ -1,6 +0,6 @@ | ||
import { useEffect } from 'react'; | ||
import { useLayoutEffect } from 'react'; | ||
import { useCollector } from './useCollector'; | ||
export function useMonitorOutput(monitor, collect, onCollect) { | ||
const [collected, updateCollected] = useCollector(monitor, collect, onCollect); | ||
useEffect(function subscribeToMonitorStateChange() { | ||
useLayoutEffect(function subscribeToMonitorStateChange() { | ||
const handlerId = monitor.getHandlerId(); | ||
@@ -7,0 +7,0 @@ if (handlerId == null) { |
@@ -1,2 +0,2 @@ | ||
import { useEffect, useRef, useMemo } from 'react'; | ||
import { useRef, useMemo, useLayoutEffect } from 'react'; | ||
import invariant from 'invariant'; | ||
@@ -24,7 +24,7 @@ import { useMonitorOutput } from './internal/useMonitorOutput'; | ||
]); | ||
useEffect(() => { | ||
useLayoutEffect(() => { | ||
connector.dragSourceOptions = specRef.current.options || null; | ||
connector.reconnect(); | ||
}, [connector]); | ||
useEffect(() => { | ||
useLayoutEffect(() => { | ||
connector.dragPreviewOptions = specRef.current.previewOptions || null; | ||
@@ -31,0 +31,0 @@ connector.reconnect(); |
@@ -1,2 +0,2 @@ | ||
import { useEffect, useRef, useMemo } from 'react'; | ||
import { useRef, useMemo, useLayoutEffect } from 'react'; | ||
import invariant from 'invariant'; | ||
@@ -19,3 +19,3 @@ import { useMonitorOutput } from './internal/useMonitorOutput'; | ||
]); | ||
useEffect(() => { | ||
useLayoutEffect(() => { | ||
connector.dropTargetOptions = spec.options || null; | ||
@@ -22,0 +22,0 @@ connector.reconnect(); |
export function isRef(obj) { | ||
return (obj !== null && typeof obj === 'object' && obj.hasOwnProperty('current')); | ||
return ( | ||
// eslint-disable-next-line no-prototype-builtins | ||
obj !== null && typeof obj === 'object' && obj.hasOwnProperty('current')); | ||
} |
{ | ||
"name": "react-dnd", | ||
"version": "8.0.3", | ||
"version": "9.0.0", | ||
"description": "Drag and Drop for React", | ||
@@ -22,3 +22,3 @@ "main": "lib/index.js", | ||
"@types/shallowequal": "^1.1.1", | ||
"dnd-core": "^8.0.3", | ||
"dnd-core": "^9.0.0", | ||
"hoist-non-react-statics": "^3.3.0", | ||
@@ -31,3 +31,3 @@ "shallowequal": "^1.1.0" | ||
"@babel/preset-env": "^7.4.5", | ||
"@types/react": "^16.8.19", | ||
"@types/react": "^16.8.23", | ||
"@types/react-dom": "^16.8.4", | ||
@@ -40,3 +40,2 @@ "babel-jest": "^24.8.0", | ||
"rimraf": "^2.6.3", | ||
"ts-loader": "^6.0.2", | ||
"typescript": "^3.5.2" | ||
@@ -47,3 +46,4 @@ }, | ||
"react-dom": ">= 16.8" | ||
} | ||
}, | ||
"gitHead": "f591828f0ccaf70aa712785a8601017da2df4b45" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
309153
82
2322
+ Addeddnd-core@9.5.1(transitive)
- Removeddnd-core@8.0.3(transitive)
Updateddnd-core@^9.0.0