Skip to content

Commit 1a47241

Browse files
dolezelwuweiweiwu
authored andcommitted
Patching react-dnd (#426)
1 parent 9343a55 commit 1a47241

File tree

3 files changed

+433
-288
lines changed

3 files changed

+433
-288
lines changed

package.json

+11-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.3.0",
44
"description": "Drag-and-drop sortable component for nested data and hierarchies",
55
"scripts": {
6-
"postinstall": "cd node_modules/react-dnd-scrollzone && npm i --ignore-scripts && npm run build",
6+
"postinstall": "patch-package",
77
"prebuild": "npm run lint",
88
"build": "npm run clean && NODE_ENV=rollup rollup -c",
99
"build:storybook": "npm run clean:storybook && build-storybook -o build",
@@ -60,15 +60,16 @@
6060
"dependencies": {
6161
"lodash.isequal": "^4.5.0",
6262
"prop-types": "^15.6.1",
63-
"react-dnd": "^6.0.0",
64-
"react-dnd-html5-backend": "^6.0.0",
65-
"react-dnd-scrollzone": "github:dolezel/react-dnd-scrollzone.git#41203ef00c991f744aa87e897d7d518d32f6a994",
63+
"react-dnd": "^7.0.1",
64+
"react-dnd-html5-backend": "^7.0.1",
65+
"react-dnd-scrollzone": "4.0.0",
6666
"react-lifecycles-compat": "^3.0.4",
6767
"react-virtualized": "^9.19.1"
6868
},
6969
"peerDependencies": {
70-
"react": "^15.3.0 || ^16.0.0",
71-
"react-dom": "^15.3.0 || ^16.0.0"
70+
"react": "^16.3.0",
71+
"react-dnd": "^6.0.0 || ^7.0.0",
72+
"react-dom": "^16.3.0"
7273
},
7374
"devDependencies": {
7475
"@babel/cli": "^7.1.5",
@@ -103,12 +104,14 @@
103104
"jest": "^23.1.0",
104105
"jest-enzyme": "^7.0.1",
105106
"json-loader": "^0.5.7",
107+
"patch-package": "^5.1.1",
106108
"postcss-loader": "^3.0.0",
109+
"postinstall-postinstall": "^2.0.0",
107110
"prettier": "^1.13.3",
108111
"react": "^16.4.0",
109112
"react-addons-shallow-compare": "^15.6.2",
110-
"react-dnd-test-backend": "6.0.0",
111-
"react-dnd-touch-backend": "0.6.0",
113+
"react-dnd-test-backend": "^7.0.1",
114+
"react-dnd-touch-backend": "^0.6.0",
112115
"react-dom": "^16.4.0",
113116
"react-hot-loader": "^4.3.0",
114117
"react-sortable-tree-theme-file-explorer": "^1.1.2",
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
patch-package
2+
--- a/node_modules/react-dnd-scrollzone/lib/index.js
3+
+++ b/node_modules/react-dnd-scrollzone/lib/index.js
4+
@@ -11,7 +11,8 @@ var _createClass = function () { function defineProperties(target, props) { for
5+
6+
exports.createHorizontalStrength = createHorizontalStrength;
7+
exports.createVerticalStrength = createVerticalStrength;
8+
-exports.default = createScrollingComponent;
9+
+exports.createScrollingComponent = createScrollingComponent;
10+
+exports.default = createScrollingComponentWithConsumer;
11+
12+
var _react = require('react');
13+
14+
@@ -35,6 +36,8 @@ var _reactDisplayName = require('react-display-name');
15+
16+
var _reactDisplayName2 = _interopRequireDefault(_reactDisplayName);
17+
18+
+var _DragDropContext = require('react-dnd/lib/DragDropContext');
19+
+
20+
var _hoistNonReactStatics = require('hoist-non-react-statics');
21+
22+
var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
23+
@@ -161,7 +164,7 @@ function createScrollingComponent(WrappedComponent) {
24+
// have to attach the listeners to the body
25+
window.document.body.addEventListener('touchmove', this.handleEvent);
26+
27+
- this.clearMonitorSubscription = this.context.dragDropManager.getMonitor().subscribeToStateChange(function () {
28+
+ this.clearMonitorSubscription = this.props.dragDropManager.getMonitor().subscribeToStateChange(function () {
29+
return _this2.handleMonitorChange();
30+
});
31+
}
32+
@@ -176,7 +179,7 @@ function createScrollingComponent(WrappedComponent) {
33+
}, {
34+
key: 'handleMonitorChange',
35+
value: function handleMonitorChange() {
36+
- var isDragging = this.context.dragDropManager.getMonitor().isDragging();
37+
+ var isDragging = this.props.dragDropManager.getMonitor().isDragging();
38+
39+
if (!this.dragging && isDragging) {
40+
this.dragging = true;
41+
@@ -286,6 +289,7 @@ function createScrollingComponent(WrappedComponent) {
42+
43+
ScrollingComponent.displayName = 'Scrolling(' + (0, _reactDisplayName2.default)(WrappedComponent) + ')';
44+
ScrollingComponent.propTypes = {
45+
+ dragDropManager: _propTypes2.default.object.isRequired,
46+
onScrollChange: _propTypes2.default.func,
47+
verticalStrength: _propTypes2.default.func,
48+
horizontalStrength: _propTypes2.default.func,
49+
@@ -297,10 +301,19 @@ function createScrollingComponent(WrappedComponent) {
50+
horizontalStrength: defaultHorizontalStrength,
51+
strengthMultiplier: 30
52+
};
53+
- ScrollingComponent.contextTypes = {
54+
- dragDropManager: _propTypes2.default.object
55+
- };
56+
57+
58+
return (0, _hoistNonReactStatics2.default)(ScrollingComponent, WrappedComponent);
59+
+}function createScrollingComponentWithConsumer(WrappedComponent) {
60+
+ var ScrollingComponent = createScrollingComponent(WrappedComponent);
61+
+ return function (props) {
62+
+ return _react2.default.createElement(
63+
+ _DragDropContext.Consumer,
64+
+ null,
65+
+ function (_ref4) {
66+
+ var dragDropManager = _ref4.dragDropManager;
67+
+ return dragDropManager === undefined ? null : _react2.default.createElement(ScrollingComponent, _extends({}, props, { dragDropManager: dragDropManager }));
68+
+ }
69+
+ );
70+
+ };
71+
}

0 commit comments

Comments
 (0)