react-dnd
Advanced tools
Comparing version 7.4.5 to 7.5.0
@@ -23,7 +23,9 @@ import * as React from 'react'; | ||
}; | ||
export interface DragDropContextProviderProps<BackendContext> { | ||
export declare type DragDropContextProviderProps<BackendContext> = { | ||
manager: DragDropManager<BackendContext>; | ||
} | { | ||
backend: BackendFactory; | ||
context?: BackendContext; | ||
debugMode?: boolean; | ||
} | ||
}; | ||
/** | ||
@@ -30,0 +32,0 @@ * A React component that provides the React-DnD context |
@@ -26,2 +26,13 @@ "use strict"; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -56,4 +67,6 @@ var React = require("react"); | ||
exports.DragDropContextProvider = function (_a) { | ||
var backend = _a.backend, context = _a.context, debugMode = _a.debugMode, children = _a.children; | ||
var contextValue = createChildContext(backend, context, debugMode); | ||
var children = _a.children, props = __rest(_a, ["children"]); | ||
var contextValue = 'manager' in props | ||
? { dragDropManager: props.manager } | ||
: createChildContext(props.backend, props.context, props.debugMode); | ||
return React.createElement(exports.Provider, { value: contextValue }, children); | ||
@@ -60,0 +73,0 @@ }; |
@@ -13,2 +13,3 @@ "use strict"; | ||
var specRef = react_1.useRef(spec); | ||
specRef.current = spec; | ||
// TODO: wire options into createSourceConnector | ||
@@ -15,0 +16,0 @@ invariant(spec.item != null, 'item must be defined'); |
@@ -13,2 +13,3 @@ "use strict"; | ||
var specRef = react_1.useRef(spec); | ||
specRef.current = spec; | ||
invariant(spec.accept != null, 'accept must be defined'); | ||
@@ -15,0 +16,0 @@ var _a = drop_1.useDropTargetMonitor(), monitor = _a[0], connector = _a[1]; |
@@ -84,11 +84,18 @@ "use strict"; | ||
SourceConnector.prototype.reconnectDragSource = function () { | ||
// if nothing has changed then don't resubscribe | ||
var didChange = this.didHandlerIdChange() || | ||
this.didConnectedDragSourceChange() || | ||
this.didDragSourceOptionsChange(); | ||
if (didChange) { | ||
this.disconnectDragSource(); | ||
} | ||
var dragSource = this.dragSource; | ||
if (!this.handlerId || !dragSource) { | ||
if (!this.handlerId) { | ||
return; | ||
} | ||
// if nothing has changed then don't resubscribe | ||
if (this.didHandlerIdChange() || | ||
this.didConnectedDragSourceChange() || | ||
this.didDragSourceOptionsChange()) { | ||
this.disconnectDragSource(); | ||
if (!dragSource) { | ||
this.lastConnectedDragSource = dragSource; | ||
return; | ||
} | ||
if (didChange) { | ||
this.lastConnectedHandlerId = this.handlerId; | ||
@@ -101,2 +108,9 @@ this.lastConnectedDragSource = dragSource; | ||
SourceConnector.prototype.reconnectDragPreview = function () { | ||
// if nothing has changed then don't resubscribe | ||
var didChange = this.didHandlerIdChange() || | ||
this.didConnectedDragPreviewChange() || | ||
this.didDragPreviewOptionsChange(); | ||
if (didChange) { | ||
this.disconnectDragPreview(); | ||
} | ||
var dragPreview = this.dragPreview; | ||
@@ -106,7 +120,3 @@ if (!this.handlerId || !dragPreview) { | ||
} | ||
// if nothing has changed then don't resubscribe | ||
if (this.didHandlerIdChange() || | ||
this.didConnectedDragPreviewChange() || | ||
this.didDragPreviewOptionsChange()) { | ||
this.disconnectDragPreview(); | ||
if (didChange) { | ||
this.lastConnectedHandlerId = this.handlerId; | ||
@@ -113,0 +123,0 @@ this.lastConnectedDragPreview = dragPreview; |
@@ -38,11 +38,18 @@ "use strict"; | ||
TargetConnector.prototype.reconnect = function () { | ||
// if nothing has changed then don't resubscribe | ||
var didChange = this.didHandlerIdChange() || | ||
this.didDropTargetChange() || | ||
this.didOptionsChange(); | ||
if (didChange) { | ||
this.disconnectDropTarget(); | ||
} | ||
var dropTarget = this.dropTarget; | ||
if (!this.handlerId || !dropTarget) { | ||
if (!this.handlerId) { | ||
return; | ||
} | ||
// if nothing has changed then don't resubscribe | ||
if (this.didHandlerIdChange() || | ||
this.didDropTargetChange() || | ||
this.didOptionsChange()) { | ||
this.disconnectDropTarget(); | ||
if (!dropTarget) { | ||
this.lastConnectedDropTarget = dropTarget; | ||
return; | ||
} | ||
if (didChange) { | ||
this.lastConnectedHandlerId = this.handlerId; | ||
@@ -49,0 +56,0 @@ this.lastConnectedDropTarget = dropTarget; |
export interface Ref<T> { | ||
current: T; | ||
} | ||
export declare function isRef(obj: any): boolean; | ||
export declare function isRef(obj: any): any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function isRef(obj) { | ||
if (obj !== null && typeof obj === 'object') { | ||
var keys = Object.keys(obj); | ||
return keys.length === 1 && keys[0] === 'current'; | ||
} | ||
return false; | ||
return (obj !== null && typeof obj === 'object' && obj.hasOwnProperty('current')); | ||
} | ||
exports.isRef = isRef; |
@@ -23,7 +23,9 @@ import * as React from 'react'; | ||
}; | ||
export interface DragDropContextProviderProps<BackendContext> { | ||
export declare type DragDropContextProviderProps<BackendContext> = { | ||
manager: DragDropManager<BackendContext>; | ||
} | { | ||
backend: BackendFactory; | ||
context?: BackendContext; | ||
debugMode?: boolean; | ||
} | ||
}; | ||
/** | ||
@@ -30,0 +32,0 @@ * A React component that provides the React-DnD context |
@@ -0,1 +1,12 @@ | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import * as React from 'react'; | ||
@@ -27,4 +38,7 @@ import { createDragDropManager, } from 'dnd-core'; | ||
*/ | ||
export const DragDropContextProvider = ({ backend, context, debugMode, children }) => { | ||
const contextValue = createChildContext(backend, context, debugMode); | ||
export const DragDropContextProvider = (_a) => { | ||
var { children } = _a, props = __rest(_a, ["children"]); | ||
const contextValue = 'manager' in props | ||
? { dragDropManager: props.manager } | ||
: createChildContext(props.backend, props.context, props.debugMode); | ||
return React.createElement(Provider, { value: contextValue }, children); | ||
@@ -31,0 +45,0 @@ }; |
@@ -11,2 +11,3 @@ import { useMonitorOutput } from './internal/useMonitorOutput'; | ||
const specRef = useRef(spec); | ||
specRef.current = spec; | ||
// TODO: wire options into createSourceConnector | ||
@@ -13,0 +14,0 @@ invariant(spec.item != null, 'item must be defined'); |
@@ -11,2 +11,3 @@ import { useMonitorOutput } from './internal/useMonitorOutput'; | ||
const specRef = useRef(spec); | ||
specRef.current = spec; | ||
invariant(spec.accept != null, 'accept must be defined'); | ||
@@ -13,0 +14,0 @@ const [monitor, connector] = useDropTargetMonitor(); |
@@ -69,11 +69,18 @@ import wrapConnectorHooks from './wrapConnectorHooks'; | ||
reconnectDragSource() { | ||
// if nothing has changed then don't resubscribe | ||
const didChange = this.didHandlerIdChange() || | ||
this.didConnectedDragSourceChange() || | ||
this.didDragSourceOptionsChange(); | ||
if (didChange) { | ||
this.disconnectDragSource(); | ||
} | ||
const dragSource = this.dragSource; | ||
if (!this.handlerId || !dragSource) { | ||
if (!this.handlerId) { | ||
return; | ||
} | ||
// if nothing has changed then don't resubscribe | ||
if (this.didHandlerIdChange() || | ||
this.didConnectedDragSourceChange() || | ||
this.didDragSourceOptionsChange()) { | ||
this.disconnectDragSource(); | ||
if (!dragSource) { | ||
this.lastConnectedDragSource = dragSource; | ||
return; | ||
} | ||
if (didChange) { | ||
this.lastConnectedHandlerId = this.handlerId; | ||
@@ -86,2 +93,9 @@ this.lastConnectedDragSource = dragSource; | ||
reconnectDragPreview() { | ||
// if nothing has changed then don't resubscribe | ||
const didChange = this.didHandlerIdChange() || | ||
this.didConnectedDragPreviewChange() || | ||
this.didDragPreviewOptionsChange(); | ||
if (didChange) { | ||
this.disconnectDragPreview(); | ||
} | ||
const dragPreview = this.dragPreview; | ||
@@ -91,7 +105,3 @@ if (!this.handlerId || !dragPreview) { | ||
} | ||
// if nothing has changed then don't resubscribe | ||
if (this.didHandlerIdChange() || | ||
this.didConnectedDragPreviewChange() || | ||
this.didDragPreviewOptionsChange()) { | ||
this.disconnectDragPreview(); | ||
if (didChange) { | ||
this.lastConnectedHandlerId = this.handlerId; | ||
@@ -98,0 +108,0 @@ this.lastConnectedDragPreview = dragPreview; |
@@ -31,11 +31,18 @@ import wrapConnectorHooks from './wrapConnectorHooks'; | ||
reconnect() { | ||
// if nothing has changed then don't resubscribe | ||
const didChange = this.didHandlerIdChange() || | ||
this.didDropTargetChange() || | ||
this.didOptionsChange(); | ||
if (didChange) { | ||
this.disconnectDropTarget(); | ||
} | ||
const dropTarget = this.dropTarget; | ||
if (!this.handlerId || !dropTarget) { | ||
if (!this.handlerId) { | ||
return; | ||
} | ||
// if nothing has changed then don't resubscribe | ||
if (this.didHandlerIdChange() || | ||
this.didDropTargetChange() || | ||
this.didOptionsChange()) { | ||
this.disconnectDropTarget(); | ||
if (!dropTarget) { | ||
this.lastConnectedDropTarget = dropTarget; | ||
return; | ||
} | ||
if (didChange) { | ||
this.lastConnectedHandlerId = this.handlerId; | ||
@@ -42,0 +49,0 @@ this.lastConnectedDropTarget = dropTarget; |
export interface Ref<T> { | ||
current: T; | ||
} | ||
export declare function isRef(obj: any): boolean; | ||
export declare function isRef(obj: any): any; |
export function isRef(obj) { | ||
if (obj !== null && typeof obj === 'object') { | ||
const keys = Object.keys(obj); | ||
return keys.length === 1 && keys[0] === 'current'; | ||
} | ||
return false; | ||
return (obj !== null && typeof obj === 'object' && obj.hasOwnProperty('current')); | ||
} |
{ | ||
"name": "react-dnd", | ||
"version": "7.4.5", | ||
"version": "7.5.0", | ||
"description": "Drag and Drop for React", | ||
"main": "lib/cjs/index.js", | ||
"module": "lib/esm/index.js", | ||
"types": "lib/cjs/index.d.ts", | ||
@@ -24,3 +25,4 @@ "repository": { | ||
"dependencies": { | ||
"dnd-core": "^7.4.4", | ||
"@types/hoist-non-react-statics": "^3.3.1", | ||
"dnd-core": "^7.5.0", | ||
"hoist-non-react-statics": "^3.3.0", | ||
@@ -31,8 +33,7 @@ "invariant": "^2.1.0", | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.3.4", | ||
"@types/hoist-non-react-statics": "^3.3.0", | ||
"@types/react": "^16.8.10", | ||
"@types/react-dom": "^16.8.3", | ||
"babel-loader": "^8.0.5", | ||
"@babel/cli": "^7.4.4", | ||
"@babel/core": "^7.4.5", | ||
"@types/react": "^16.8.19", | ||
"@types/react-dom": "^16.8.4", | ||
"babel-loader": "^8.0.6", | ||
"npm-run-all": "^4.1.5", | ||
@@ -42,6 +43,6 @@ "react": "^16.8.6", | ||
"rimraf": "^2.6.3", | ||
"ts-loader": "^5.3.3", | ||
"typescript": "^3.4.1", | ||
"webpack": "^4.29.6", | ||
"webpack-cli": "^3.2.3" | ||
"ts-loader": "^6.0.2", | ||
"typescript": "^3.5.1", | ||
"webpack": "^4.32.2", | ||
"webpack-cli": "^3.3.2" | ||
}, | ||
@@ -51,4 +52,3 @@ "peerDependencies": { | ||
"react-dom": ">= 16.8" | ||
}, | ||
"gitHead": "5fefffc8c6c1ceced3aa0356fd869354ad74734a" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
908737
13
177
6645
7
56
+ Added@types/hoist-non-react-statics@3.3.6(transitive)
+ Added@types/react@19.0.7(transitive)
+ Addedcsstype@3.1.3(transitive)
Updateddnd-core@^7.5.0