react-dnd
Advanced tools
Comparing version 7.4.1 to 7.4.2
@@ -30,3 +30,3 @@ "use strict"; | ||
var disposables_1 = require("./utils/disposables"); | ||
var isClassComponent = require('recompose/isClassComponent').default; | ||
var isRefable_1 = require("./utils/isRefable"); | ||
var isPlainObject = require('lodash/isPlainObject'); | ||
@@ -61,3 +61,3 @@ var invariant = require('invariant'); | ||
DragDropContainer.prototype.getDecoratedComponentInstance = function () { | ||
invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component it can not be a stateless component.'); | ||
invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); | ||
return this.decoratedRef.current; | ||
@@ -135,3 +135,3 @@ }; | ||
// NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component. | ||
ref: isClassComponent(Decorated) ? _this.decoratedRef : null }))); | ||
ref: isRefable_1.isRefable(Decorated) ? _this.decoratedRef : null }))); | ||
})); | ||
@@ -138,0 +138,0 @@ }; |
@@ -30,2 +30,3 @@ "use strict"; | ||
var checkDecoratorArguments_1 = require("./utils/checkDecoratorArguments"); | ||
var isRefable_1 = require("./utils/isRefable"); | ||
var invariant = require('invariant'); | ||
@@ -80,3 +81,3 @@ var hoistStatics = require('hoist-non-react-statics'); | ||
DragDropContextContainer.prototype.getDecoratedComponentInstance = function () { | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component it can not be a stateless component.'); | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); | ||
return this.ref.current; | ||
@@ -86,3 +87,3 @@ }; | ||
return (React.createElement(exports.Provider, { value: childContext }, | ||
React.createElement(Decorated, __assign({}, this.props, { ref: this.ref })))); | ||
React.createElement(Decorated, __assign({}, this.props, { ref: isRefable_1.isRefable(Decorated) ? this.ref : null })))); | ||
}; | ||
@@ -89,0 +90,0 @@ DragDropContextContainer.DecoratedComponent = DecoratedComponent; |
@@ -30,2 +30,3 @@ "use strict"; | ||
var DragDropContext_1 = require("./DragDropContext"); | ||
var isRefable_1 = require("./utils/isRefable"); | ||
var hoistStatics = require('hoist-non-react-statics'); | ||
@@ -63,3 +64,3 @@ var isPlainObject = require('lodash/isPlainObject'); | ||
DragLayerContainer.prototype.getDecoratedComponentInstance = function () { | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component it can not be a stateless component.'); | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); | ||
return this.ref.current; | ||
@@ -98,3 +99,3 @@ }; | ||
} | ||
return (React.createElement(Decorated, __assign({}, _this.props, _this.state, { ref: _this.ref }))); | ||
return (React.createElement(Decorated, __assign({}, _this.props, _this.state, { ref: isRefable_1.isRefable(Decorated) ? _this.ref : null }))); | ||
})); | ||
@@ -101,0 +102,0 @@ }; |
@@ -33,4 +33,11 @@ "use strict"; | ||
canDrag: function () { | ||
var canDrag = spec.current.canDrag; | ||
return canDrag ? canDrag(monitor) : true; | ||
if (typeof spec.current.canDrag === 'boolean') { | ||
return spec.current.canDrag; | ||
} | ||
else if (typeof spec.current.canDrag === 'function') { | ||
return spec.current.canDrag(monitor); | ||
} | ||
else { | ||
return true; | ||
} | ||
}, | ||
@@ -37,0 +44,0 @@ isDragging: function (globalMonitor, target) { |
@@ -44,3 +44,3 @@ import { TargetType, SourceType } from 'dnd-core'; | ||
*/ | ||
canDrag?: (monitor: DragSourceMonitor) => boolean; | ||
canDrag?: boolean | ((monitor: DragSourceMonitor) => boolean); | ||
/** | ||
@@ -47,0 +47,0 @@ * Optional. |
import * as React from 'react'; | ||
import { Consumer } from './DragDropContext'; | ||
import { Disposable, CompositeDisposable, SerialDisposable, } from './utils/disposables'; | ||
const isClassComponent = require('recompose/isClassComponent').default; | ||
import { isRefable } from './utils/isRefable'; | ||
const isPlainObject = require('lodash/isPlainObject'); | ||
@@ -31,3 +31,3 @@ const invariant = require('invariant'); | ||
getDecoratedComponentInstance() { | ||
invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component it can not be a stateless component.'); | ||
invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); | ||
return this.decoratedRef.current; | ||
@@ -103,3 +103,3 @@ } | ||
// NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component. | ||
ref: isClassComponent(Decorated) ? this.decoratedRef : null }))); | ||
ref: isRefable(Decorated) ? this.decoratedRef : null }))); | ||
})); | ||
@@ -106,0 +106,0 @@ } |
import * as React from 'react'; | ||
import { createDragDropManager, } from 'dnd-core'; | ||
import checkDecoratorArguments from './utils/checkDecoratorArguments'; | ||
import { isRefable } from './utils/isRefable'; | ||
const invariant = require('invariant'); | ||
@@ -49,3 +50,3 @@ const hoistStatics = require('hoist-non-react-statics'); | ||
getDecoratedComponentInstance() { | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component it can not be a stateless component.'); | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); | ||
return this.ref.current; | ||
@@ -55,3 +56,3 @@ } | ||
return (React.createElement(Provider, { value: childContext }, | ||
React.createElement(Decorated, Object.assign({}, this.props, { ref: this.ref })))); | ||
React.createElement(Decorated, Object.assign({}, this.props, { ref: isRefable(Decorated) ? this.ref : null })))); | ||
} | ||
@@ -58,0 +59,0 @@ } |
import * as React from 'react'; | ||
import checkDecoratorArguments from './utils/checkDecoratorArguments'; | ||
import { Consumer } from './DragDropContext'; | ||
import { isRefable } from './utils/isRefable'; | ||
const hoistStatics = require('hoist-non-react-statics'); | ||
@@ -33,3 +34,3 @@ const isPlainObject = require('lodash/isPlainObject'); | ||
getDecoratedComponentInstance() { | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component it can not be a stateless component.'); | ||
invariant(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); | ||
return this.ref.current; | ||
@@ -66,3 +67,3 @@ } | ||
} | ||
return (React.createElement(Decorated, Object.assign({}, this.props, this.state, { ref: this.ref }))); | ||
return (React.createElement(Decorated, Object.assign({}, this.props, this.state, { ref: isRefable(Decorated) ? this.ref : null }))); | ||
})); | ||
@@ -69,0 +70,0 @@ } |
@@ -30,4 +30,11 @@ import { useEffect, useMemo } from 'react'; | ||
canDrag() { | ||
const { canDrag } = spec.current; | ||
return canDrag ? canDrag(monitor) : true; | ||
if (typeof spec.current.canDrag === 'boolean') { | ||
return spec.current.canDrag; | ||
} | ||
else if (typeof spec.current.canDrag === 'function') { | ||
return spec.current.canDrag(monitor); | ||
} | ||
else { | ||
return true; | ||
} | ||
}, | ||
@@ -34,0 +41,0 @@ isDragging(globalMonitor, target) { |
@@ -44,3 +44,3 @@ import { TargetType, SourceType } from 'dnd-core'; | ||
*/ | ||
canDrag?: (monitor: DragSourceMonitor) => boolean; | ||
canDrag?: boolean | ((monitor: DragSourceMonitor) => boolean); | ||
/** | ||
@@ -47,0 +47,0 @@ * Optional. |
{ | ||
"name": "react-dnd", | ||
"version": "7.4.1", | ||
"version": "7.4.2", | ||
"description": "Drag and Drop for React", | ||
@@ -28,3 +28,2 @@ "main": "lib/cjs/index.js", | ||
"lodash": "^4.17.11", | ||
"recompose": "^0.30.0", | ||
"shallowequal": "^1.1.0" | ||
@@ -52,3 +51,3 @@ }, | ||
}, | ||
"gitHead": "383a7f63566db164afde549f33fd20676059a339" | ||
"gitHead": "30579d2e2680f12be8c2589509069100f289ab3c" | ||
} |
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
618677
7
163
7448
- Removedrecompose@^0.30.0
- Removedchange-emitter@0.1.6(transitive)
- Removedcore-js@1.2.7(transitive)
- Removedencoding@0.1.13(transitive)
- Removedfbjs@0.8.18(transitive)
- Removedhoist-non-react-statics@2.5.5(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisomorphic-fetch@2.2.1(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpromise@7.3.1(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-lifecycles-compat@3.0.4(transitive)
- Removedrecompose@0.30.0(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedsymbol-observable@1.2.0(transitive)
- Removedua-parser-js@0.7.40(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)