This commit is contained in:
154
node_modules/react-dnd/dist/esm/internals/DragSourceMonitorImpl.js
generated
vendored
Normal file
154
node_modules/react-dnd/dist/esm/internals/DragSourceMonitorImpl.js
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
var isCallingCanDrag = false;
|
||||
var isCallingIsDragging = false;
|
||||
export var DragSourceMonitorImpl = /*#__PURE__*/function () {
|
||||
function DragSourceMonitorImpl(manager) {
|
||||
_classCallCheck(this, DragSourceMonitorImpl);
|
||||
|
||||
_defineProperty(this, "internalMonitor", void 0);
|
||||
|
||||
_defineProperty(this, "sourceId", null);
|
||||
|
||||
this.internalMonitor = manager.getMonitor();
|
||||
}
|
||||
|
||||
_createClass(DragSourceMonitorImpl, [{
|
||||
key: "receiveHandlerId",
|
||||
value: function receiveHandlerId(sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
}, {
|
||||
key: "getHandlerId",
|
||||
value: function getHandlerId() {
|
||||
return this.sourceId;
|
||||
}
|
||||
}, {
|
||||
key: "canDrag",
|
||||
value: function canDrag() {
|
||||
invariant(!isCallingCanDrag, 'You may not call monitor.canDrag() inside your canDrag() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
|
||||
|
||||
try {
|
||||
isCallingCanDrag = true;
|
||||
return this.internalMonitor.canDragSource(this.sourceId);
|
||||
} finally {
|
||||
isCallingCanDrag = false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "isDragging",
|
||||
value: function isDragging() {
|
||||
if (!this.sourceId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
invariant(!isCallingIsDragging, 'You may not call monitor.isDragging() inside your isDragging() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
|
||||
|
||||
try {
|
||||
isCallingIsDragging = true;
|
||||
return this.internalMonitor.isDraggingSource(this.sourceId);
|
||||
} finally {
|
||||
isCallingIsDragging = false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "subscribeToStateChange",
|
||||
value: function subscribeToStateChange(listener, options) {
|
||||
return this.internalMonitor.subscribeToStateChange(listener, options);
|
||||
}
|
||||
}, {
|
||||
key: "isDraggingSource",
|
||||
value: function isDraggingSource(sourceId) {
|
||||
return this.internalMonitor.isDraggingSource(sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "isOverTarget",
|
||||
value: function isOverTarget(targetId, options) {
|
||||
return this.internalMonitor.isOverTarget(targetId, options);
|
||||
}
|
||||
}, {
|
||||
key: "getTargetIds",
|
||||
value: function getTargetIds() {
|
||||
return this.internalMonitor.getTargetIds();
|
||||
}
|
||||
}, {
|
||||
key: "isSourcePublic",
|
||||
value: function isSourcePublic() {
|
||||
return this.internalMonitor.isSourcePublic();
|
||||
}
|
||||
}, {
|
||||
key: "getSourceId",
|
||||
value: function getSourceId() {
|
||||
return this.internalMonitor.getSourceId();
|
||||
}
|
||||
}, {
|
||||
key: "subscribeToOffsetChange",
|
||||
value: function subscribeToOffsetChange(listener) {
|
||||
return this.internalMonitor.subscribeToOffsetChange(listener);
|
||||
}
|
||||
}, {
|
||||
key: "canDragSource",
|
||||
value: function canDragSource(sourceId) {
|
||||
return this.internalMonitor.canDragSource(sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "canDropOnTarget",
|
||||
value: function canDropOnTarget(targetId) {
|
||||
return this.internalMonitor.canDropOnTarget(targetId);
|
||||
}
|
||||
}, {
|
||||
key: "getItemType",
|
||||
value: function getItemType() {
|
||||
return this.internalMonitor.getItemType();
|
||||
}
|
||||
}, {
|
||||
key: "getItem",
|
||||
value: function getItem() {
|
||||
return this.internalMonitor.getItem();
|
||||
}
|
||||
}, {
|
||||
key: "getDropResult",
|
||||
value: function getDropResult() {
|
||||
return this.internalMonitor.getDropResult();
|
||||
}
|
||||
}, {
|
||||
key: "didDrop",
|
||||
value: function didDrop() {
|
||||
return this.internalMonitor.didDrop();
|
||||
}
|
||||
}, {
|
||||
key: "getInitialClientOffset",
|
||||
value: function getInitialClientOffset() {
|
||||
return this.internalMonitor.getInitialClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getInitialSourceClientOffset",
|
||||
value: function getInitialSourceClientOffset() {
|
||||
return this.internalMonitor.getInitialSourceClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getSourceClientOffset",
|
||||
value: function getSourceClientOffset() {
|
||||
return this.internalMonitor.getSourceClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getClientOffset",
|
||||
value: function getClientOffset() {
|
||||
return this.internalMonitor.getClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getDifferenceFromInitialOffset",
|
||||
value: function getDifferenceFromInitialOffset() {
|
||||
return this.internalMonitor.getDifferenceFromInitialOffset();
|
||||
}
|
||||
}]);
|
||||
|
||||
return DragSourceMonitorImpl;
|
||||
}();
|
||||
113
node_modules/react-dnd/dist/esm/internals/DropTargetMonitorImpl.js
generated
vendored
Normal file
113
node_modules/react-dnd/dist/esm/internals/DropTargetMonitorImpl.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
var isCallingCanDrop = false;
|
||||
export var DropTargetMonitorImpl = /*#__PURE__*/function () {
|
||||
function DropTargetMonitorImpl(manager) {
|
||||
_classCallCheck(this, DropTargetMonitorImpl);
|
||||
|
||||
_defineProperty(this, "internalMonitor", void 0);
|
||||
|
||||
_defineProperty(this, "targetId", null);
|
||||
|
||||
this.internalMonitor = manager.getMonitor();
|
||||
}
|
||||
|
||||
_createClass(DropTargetMonitorImpl, [{
|
||||
key: "receiveHandlerId",
|
||||
value: function receiveHandlerId(targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
}, {
|
||||
key: "getHandlerId",
|
||||
value: function getHandlerId() {
|
||||
return this.targetId;
|
||||
}
|
||||
}, {
|
||||
key: "subscribeToStateChange",
|
||||
value: function subscribeToStateChange(listener, options) {
|
||||
return this.internalMonitor.subscribeToStateChange(listener, options);
|
||||
}
|
||||
}, {
|
||||
key: "canDrop",
|
||||
value: function canDrop() {
|
||||
// Cut out early if the target id has not been set. This should prevent errors
|
||||
// where the user has an older version of dnd-core like in
|
||||
// https://github.com/react-dnd/react-dnd/issues/1310
|
||||
if (!this.targetId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
invariant(!isCallingCanDrop, 'You may not call monitor.canDrop() inside your canDrop() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor');
|
||||
|
||||
try {
|
||||
isCallingCanDrop = true;
|
||||
return this.internalMonitor.canDropOnTarget(this.targetId);
|
||||
} finally {
|
||||
isCallingCanDrop = false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "isOver",
|
||||
value: function isOver(options) {
|
||||
if (!this.targetId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.internalMonitor.isOverTarget(this.targetId, options);
|
||||
}
|
||||
}, {
|
||||
key: "getItemType",
|
||||
value: function getItemType() {
|
||||
return this.internalMonitor.getItemType();
|
||||
}
|
||||
}, {
|
||||
key: "getItem",
|
||||
value: function getItem() {
|
||||
return this.internalMonitor.getItem();
|
||||
}
|
||||
}, {
|
||||
key: "getDropResult",
|
||||
value: function getDropResult() {
|
||||
return this.internalMonitor.getDropResult();
|
||||
}
|
||||
}, {
|
||||
key: "didDrop",
|
||||
value: function didDrop() {
|
||||
return this.internalMonitor.didDrop();
|
||||
}
|
||||
}, {
|
||||
key: "getInitialClientOffset",
|
||||
value: function getInitialClientOffset() {
|
||||
return this.internalMonitor.getInitialClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getInitialSourceClientOffset",
|
||||
value: function getInitialSourceClientOffset() {
|
||||
return this.internalMonitor.getInitialSourceClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getSourceClientOffset",
|
||||
value: function getSourceClientOffset() {
|
||||
return this.internalMonitor.getSourceClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getClientOffset",
|
||||
value: function getClientOffset() {
|
||||
return this.internalMonitor.getClientOffset();
|
||||
}
|
||||
}, {
|
||||
key: "getDifferenceFromInitialOffset",
|
||||
value: function getDifferenceFromInitialOffset() {
|
||||
return this.internalMonitor.getDifferenceFromInitialOffset();
|
||||
}
|
||||
}]);
|
||||
|
||||
return DropTargetMonitorImpl;
|
||||
}();
|
||||
241
node_modules/react-dnd/dist/esm/internals/SourceConnector.js
generated
vendored
Normal file
241
node_modules/react-dnd/dist/esm/internals/SourceConnector.js
generated
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import { wrapConnectorHooks } from './wrapConnectorHooks';
|
||||
import { isRef } from './isRef';
|
||||
import { shallowEqual } from '@react-dnd/shallowequal';
|
||||
export var SourceConnector = /*#__PURE__*/function () {
|
||||
// The drop target may either be attached via ref or connect function
|
||||
// The drag preview may either be attached via ref or connect function
|
||||
function SourceConnector(backend) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, SourceConnector);
|
||||
|
||||
_defineProperty(this, "hooks", wrapConnectorHooks({
|
||||
dragSource: function dragSource(node, options) {
|
||||
_this.clearDragSource();
|
||||
|
||||
_this.dragSourceOptions = options || null;
|
||||
|
||||
if (isRef(node)) {
|
||||
_this.dragSourceRef = node;
|
||||
} else {
|
||||
_this.dragSourceNode = node;
|
||||
}
|
||||
|
||||
_this.reconnectDragSource();
|
||||
},
|
||||
dragPreview: function dragPreview(node, options) {
|
||||
_this.clearDragPreview();
|
||||
|
||||
_this.dragPreviewOptions = options || null;
|
||||
|
||||
if (isRef(node)) {
|
||||
_this.dragPreviewRef = node;
|
||||
} else {
|
||||
_this.dragPreviewNode = node;
|
||||
}
|
||||
|
||||
_this.reconnectDragPreview();
|
||||
}
|
||||
}));
|
||||
|
||||
_defineProperty(this, "handlerId", null);
|
||||
|
||||
_defineProperty(this, "dragSourceRef", null);
|
||||
|
||||
_defineProperty(this, "dragSourceNode", void 0);
|
||||
|
||||
_defineProperty(this, "dragSourceOptionsInternal", null);
|
||||
|
||||
_defineProperty(this, "dragSourceUnsubscribe", void 0);
|
||||
|
||||
_defineProperty(this, "dragPreviewRef", null);
|
||||
|
||||
_defineProperty(this, "dragPreviewNode", void 0);
|
||||
|
||||
_defineProperty(this, "dragPreviewOptionsInternal", null);
|
||||
|
||||
_defineProperty(this, "dragPreviewUnsubscribe", void 0);
|
||||
|
||||
_defineProperty(this, "lastConnectedHandlerId", null);
|
||||
|
||||
_defineProperty(this, "lastConnectedDragSource", null);
|
||||
|
||||
_defineProperty(this, "lastConnectedDragSourceOptions", null);
|
||||
|
||||
_defineProperty(this, "lastConnectedDragPreview", null);
|
||||
|
||||
_defineProperty(this, "lastConnectedDragPreviewOptions", null);
|
||||
|
||||
_defineProperty(this, "backend", void 0);
|
||||
|
||||
this.backend = backend;
|
||||
}
|
||||
|
||||
_createClass(SourceConnector, [{
|
||||
key: "receiveHandlerId",
|
||||
value: function receiveHandlerId(newHandlerId) {
|
||||
if (this.handlerId === newHandlerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.handlerId = newHandlerId;
|
||||
this.reconnect();
|
||||
}
|
||||
}, {
|
||||
key: "connectTarget",
|
||||
get: function get() {
|
||||
return this.dragSource;
|
||||
}
|
||||
}, {
|
||||
key: "dragSourceOptions",
|
||||
get: function get() {
|
||||
return this.dragSourceOptionsInternal;
|
||||
},
|
||||
set: function set(options) {
|
||||
this.dragSourceOptionsInternal = options;
|
||||
}
|
||||
}, {
|
||||
key: "dragPreviewOptions",
|
||||
get: function get() {
|
||||
return this.dragPreviewOptionsInternal;
|
||||
},
|
||||
set: function set(options) {
|
||||
this.dragPreviewOptionsInternal = options;
|
||||
}
|
||||
}, {
|
||||
key: "reconnect",
|
||||
value: function reconnect() {
|
||||
this.reconnectDragSource();
|
||||
this.reconnectDragPreview();
|
||||
}
|
||||
}, {
|
||||
key: "reconnectDragSource",
|
||||
value: function reconnectDragSource() {
|
||||
var dragSource = this.dragSource; // if nothing has changed then don't resubscribe
|
||||
|
||||
var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
|
||||
|
||||
if (didChange) {
|
||||
this.disconnectDragSource();
|
||||
}
|
||||
|
||||
if (!this.handlerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dragSource) {
|
||||
this.lastConnectedDragSource = dragSource;
|
||||
return;
|
||||
}
|
||||
|
||||
if (didChange) {
|
||||
this.lastConnectedHandlerId = this.handlerId;
|
||||
this.lastConnectedDragSource = dragSource;
|
||||
this.lastConnectedDragSourceOptions = this.dragSourceOptions;
|
||||
this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "reconnectDragPreview",
|
||||
value: function reconnectDragPreview() {
|
||||
var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe
|
||||
|
||||
var didChange = this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
|
||||
|
||||
if (didChange) {
|
||||
this.disconnectDragPreview();
|
||||
}
|
||||
|
||||
if (!this.handlerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dragPreview) {
|
||||
this.lastConnectedDragPreview = dragPreview;
|
||||
return;
|
||||
}
|
||||
|
||||
if (didChange) {
|
||||
this.lastConnectedHandlerId = this.handlerId;
|
||||
this.lastConnectedDragPreview = dragPreview;
|
||||
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
|
||||
this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "didHandlerIdChange",
|
||||
value: function didHandlerIdChange() {
|
||||
return this.lastConnectedHandlerId !== this.handlerId;
|
||||
}
|
||||
}, {
|
||||
key: "didConnectedDragSourceChange",
|
||||
value: function didConnectedDragSourceChange() {
|
||||
return this.lastConnectedDragSource !== this.dragSource;
|
||||
}
|
||||
}, {
|
||||
key: "didConnectedDragPreviewChange",
|
||||
value: function didConnectedDragPreviewChange() {
|
||||
return this.lastConnectedDragPreview !== this.dragPreview;
|
||||
}
|
||||
}, {
|
||||
key: "didDragSourceOptionsChange",
|
||||
value: function didDragSourceOptionsChange() {
|
||||
return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
|
||||
}
|
||||
}, {
|
||||
key: "didDragPreviewOptionsChange",
|
||||
value: function didDragPreviewOptionsChange() {
|
||||
return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
|
||||
}
|
||||
}, {
|
||||
key: "disconnectDragSource",
|
||||
value: function disconnectDragSource() {
|
||||
if (this.dragSourceUnsubscribe) {
|
||||
this.dragSourceUnsubscribe();
|
||||
this.dragSourceUnsubscribe = undefined;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "disconnectDragPreview",
|
||||
value: function disconnectDragPreview() {
|
||||
if (this.dragPreviewUnsubscribe) {
|
||||
this.dragPreviewUnsubscribe();
|
||||
this.dragPreviewUnsubscribe = undefined;
|
||||
this.dragPreviewNode = null;
|
||||
this.dragPreviewRef = null;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "dragSource",
|
||||
get: function get() {
|
||||
return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
|
||||
}
|
||||
}, {
|
||||
key: "dragPreview",
|
||||
get: function get() {
|
||||
return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
|
||||
}
|
||||
}, {
|
||||
key: "clearDragSource",
|
||||
value: function clearDragSource() {
|
||||
this.dragSourceNode = null;
|
||||
this.dragSourceRef = null;
|
||||
}
|
||||
}, {
|
||||
key: "clearDragPreview",
|
||||
value: function clearDragPreview() {
|
||||
this.dragPreviewNode = null;
|
||||
this.dragPreviewRef = null;
|
||||
}
|
||||
}]);
|
||||
|
||||
return SourceConnector;
|
||||
}();
|
||||
144
node_modules/react-dnd/dist/esm/internals/TargetConnector.js
generated
vendored
Normal file
144
node_modules/react-dnd/dist/esm/internals/TargetConnector.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import { shallowEqual } from '@react-dnd/shallowequal';
|
||||
import { wrapConnectorHooks } from './wrapConnectorHooks';
|
||||
import { isRef } from './isRef';
|
||||
export var TargetConnector = /*#__PURE__*/function () {
|
||||
// The drop target may either be attached via ref or connect function
|
||||
function TargetConnector(backend) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, TargetConnector);
|
||||
|
||||
_defineProperty(this, "hooks", wrapConnectorHooks({
|
||||
dropTarget: function dropTarget(node, options) {
|
||||
_this.clearDropTarget();
|
||||
|
||||
_this.dropTargetOptions = options;
|
||||
|
||||
if (isRef(node)) {
|
||||
_this.dropTargetRef = node;
|
||||
} else {
|
||||
_this.dropTargetNode = node;
|
||||
}
|
||||
|
||||
_this.reconnect();
|
||||
}
|
||||
}));
|
||||
|
||||
_defineProperty(this, "handlerId", null);
|
||||
|
||||
_defineProperty(this, "dropTargetRef", null);
|
||||
|
||||
_defineProperty(this, "dropTargetNode", void 0);
|
||||
|
||||
_defineProperty(this, "dropTargetOptionsInternal", null);
|
||||
|
||||
_defineProperty(this, "unsubscribeDropTarget", void 0);
|
||||
|
||||
_defineProperty(this, "lastConnectedHandlerId", null);
|
||||
|
||||
_defineProperty(this, "lastConnectedDropTarget", null);
|
||||
|
||||
_defineProperty(this, "lastConnectedDropTargetOptions", null);
|
||||
|
||||
_defineProperty(this, "backend", void 0);
|
||||
|
||||
this.backend = backend;
|
||||
}
|
||||
|
||||
_createClass(TargetConnector, [{
|
||||
key: "connectTarget",
|
||||
get: function get() {
|
||||
return this.dropTarget;
|
||||
}
|
||||
}, {
|
||||
key: "reconnect",
|
||||
value: function reconnect() {
|
||||
// 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) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dropTarget) {
|
||||
this.lastConnectedDropTarget = dropTarget;
|
||||
return;
|
||||
}
|
||||
|
||||
if (didChange) {
|
||||
this.lastConnectedHandlerId = this.handlerId;
|
||||
this.lastConnectedDropTarget = dropTarget;
|
||||
this.lastConnectedDropTargetOptions = this.dropTargetOptions;
|
||||
this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "receiveHandlerId",
|
||||
value: function receiveHandlerId(newHandlerId) {
|
||||
if (newHandlerId === this.handlerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.handlerId = newHandlerId;
|
||||
this.reconnect();
|
||||
}
|
||||
}, {
|
||||
key: "dropTargetOptions",
|
||||
get: function get() {
|
||||
return this.dropTargetOptionsInternal;
|
||||
},
|
||||
set: function set(options) {
|
||||
this.dropTargetOptionsInternal = options;
|
||||
}
|
||||
}, {
|
||||
key: "didHandlerIdChange",
|
||||
value: function didHandlerIdChange() {
|
||||
return this.lastConnectedHandlerId !== this.handlerId;
|
||||
}
|
||||
}, {
|
||||
key: "didDropTargetChange",
|
||||
value: function didDropTargetChange() {
|
||||
return this.lastConnectedDropTarget !== this.dropTarget;
|
||||
}
|
||||
}, {
|
||||
key: "didOptionsChange",
|
||||
value: function didOptionsChange() {
|
||||
return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
|
||||
}
|
||||
}, {
|
||||
key: "disconnectDropTarget",
|
||||
value: function disconnectDropTarget() {
|
||||
if (this.unsubscribeDropTarget) {
|
||||
this.unsubscribeDropTarget();
|
||||
this.unsubscribeDropTarget = undefined;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "dropTarget",
|
||||
get: function get() {
|
||||
return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
|
||||
}
|
||||
}, {
|
||||
key: "clearDropTarget",
|
||||
value: function clearDropTarget() {
|
||||
this.dropTargetRef = null;
|
||||
this.dropTargetNode = null;
|
||||
}
|
||||
}]);
|
||||
|
||||
return TargetConnector;
|
||||
}();
|
||||
5
node_modules/react-dnd/dist/esm/internals/index.js
generated
vendored
Normal file
5
node_modules/react-dnd/dist/esm/internals/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export * from './DragSourceMonitorImpl';
|
||||
export * from './DropTargetMonitorImpl';
|
||||
export * from './SourceConnector';
|
||||
export * from './TargetConnector';
|
||||
export * from './registration';
|
||||
7
node_modules/react-dnd/dist/esm/internals/isRef.js
generated
vendored
Normal file
7
node_modules/react-dnd/dist/esm/internals/isRef.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
export function isRef(obj) {
|
||||
return (// eslint-disable-next-line no-prototype-builtins
|
||||
obj !== null && _typeof(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current')
|
||||
);
|
||||
}
|
||||
14
node_modules/react-dnd/dist/esm/internals/registration.js
generated
vendored
Normal file
14
node_modules/react-dnd/dist/esm/internals/registration.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export function registerTarget(type, target, manager) {
|
||||
var registry = manager.getRegistry();
|
||||
var targetId = registry.addTarget(type, target);
|
||||
return [targetId, function () {
|
||||
return registry.removeTarget(targetId);
|
||||
}];
|
||||
}
|
||||
export function registerSource(type, source, manager) {
|
||||
var registry = manager.getRegistry();
|
||||
var sourceId = registry.addSource(type, source);
|
||||
return [sourceId, function () {
|
||||
return registry.removeSource(sourceId);
|
||||
}];
|
||||
}
|
||||
85
node_modules/react-dnd/dist/esm/internals/wrapConnectorHooks.js
generated
vendored
Normal file
85
node_modules/react-dnd/dist/esm/internals/wrapConnectorHooks.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
import { cloneElement, isValidElement } from 'react';
|
||||
|
||||
function throwIfCompositeComponentElement(element) {
|
||||
// Custom components can no longer be wrapped directly in React DnD 2.0
|
||||
// so that we don't need to depend on findDOMNode() from react-dom.
|
||||
if (typeof element.type === 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
var displayName = element.type.displayName || element.type.name || 'the component';
|
||||
throw new Error('Only native element nodes can now be passed to React DnD connectors.' + "You can either wrap ".concat(displayName, " into a <div>, or turn it into a ") + 'drag source or a drop target itself.');
|
||||
}
|
||||
|
||||
function wrapHookToRecognizeElement(hook) {
|
||||
return function () {
|
||||
var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
||||
|
||||
// When passed a node, call the hook straight away.
|
||||
if (!isValidElement(elementOrNode)) {
|
||||
var node = elementOrNode;
|
||||
hook(node, options); // return the node so it can be chained (e.g. when within callback refs
|
||||
// <div ref={node => connectDragSource(connectDropTarget(node))}/>
|
||||
|
||||
return node;
|
||||
} // If passed a ReactElement, clone it and attach this function as a ref.
|
||||
// This helps us achieve a neat API where user doesn't even know that refs
|
||||
// are being used under the hood.
|
||||
|
||||
|
||||
var element = elementOrNode;
|
||||
throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly
|
||||
|
||||
var ref = options ? function (node) {
|
||||
return hook(node, options);
|
||||
} : hook;
|
||||
return cloneWithRef(element, ref);
|
||||
};
|
||||
}
|
||||
|
||||
export function wrapConnectorHooks(hooks) {
|
||||
var wrappedHooks = {};
|
||||
Object.keys(hooks).forEach(function (key) {
|
||||
var hook = hooks[key]; // ref objects should be passed straight through without wrapping
|
||||
|
||||
if (key.endsWith('Ref')) {
|
||||
wrappedHooks[key] = hooks[key];
|
||||
} else {
|
||||
var wrappedHook = wrapHookToRecognizeElement(hook);
|
||||
|
||||
wrappedHooks[key] = function () {
|
||||
return wrappedHook;
|
||||
};
|
||||
}
|
||||
});
|
||||
return wrappedHooks;
|
||||
}
|
||||
|
||||
function setRef(ref, node) {
|
||||
if (typeof ref === 'function') {
|
||||
ref(node);
|
||||
} else {
|
||||
ref.current = node;
|
||||
}
|
||||
}
|
||||
|
||||
function cloneWithRef(element, newRef) {
|
||||
var previousRef = element.ref;
|
||||
invariant(typeof previousRef !== 'string', 'Cannot connect React DnD to an element with an existing string ref. ' + 'Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. ' + 'Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs');
|
||||
|
||||
if (!previousRef) {
|
||||
// When there is no ref on the element, use the new ref directly
|
||||
return cloneElement(element, {
|
||||
ref: newRef
|
||||
});
|
||||
} else {
|
||||
return cloneElement(element, {
|
||||
ref: function ref(node) {
|
||||
setRef(previousRef, node);
|
||||
setRef(newRef, node);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user